@comunica/utils-algebra
Advanced tools
+58
-0
@@ -53,4 +53,13 @@ /** | ||
| }>; | ||
| /** | ||
| * Algebra operation taking a single operation as input. | ||
| */ | ||
| export type Single = Opened<Algebra.Single>; | ||
| /** | ||
| * Algebra operation taking multiple operations as input. | ||
| */ | ||
| export type Multi = Opened<Algebra.Multi>; | ||
| /** | ||
| * Algebra operation taking exactly two input operations. | ||
| */ | ||
| export type Double = Opened<Algebra.Double>; | ||
@@ -64,2 +73,6 @@ export type AggregateExpression = Opened<Algebra.AggregateExpression>; | ||
| export type WildcardExpression = Opened<Algebra.WildcardExpression>; | ||
| /** | ||
| * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) alternative (`|`). | ||
| * Property paths have a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths) | ||
| */ | ||
| export type Alt = Opened<Algebra.Alt>; | ||
@@ -79,15 +92,45 @@ export type Ask = Opened<Algebra.Ask>; | ||
| }>; | ||
| /** | ||
| * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) inverse (`^`). | ||
| * Having a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths) | ||
| * This operation, besides basic mode is the reason SPARQL can contain literals in the subject position. | ||
| */ | ||
| export type Inv = Opened<Algebra.Inv>; | ||
| export type Join = Opened<Algebra.Join>; | ||
| export type LeftJoin = Opened<Algebra.LeftJoin>; | ||
| /** | ||
| * Algebra operation representing the property of a [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths). | ||
| * Property paths have a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths) | ||
| * This operation, is just a way of saying to a Propery Path operation that nothing fancy is going on, | ||
| * and it should just match this property. | ||
| */ | ||
| export type Link = Opened<Algebra.Link>; | ||
| export type Minus = Opened<Algebra.Minus>; | ||
| /** | ||
| * An empty operation. | ||
| * For example used for the algebra representation of a query string that does not contain any operation. | ||
| */ | ||
| export type Nop = Opened<Algebra.Nop>; | ||
| /** | ||
| * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) negated property set (`!`). | ||
| * Property paths have a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths) | ||
| */ | ||
| export type Nps = Opened<Algebra.Nps>; | ||
| /** | ||
| * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) one or more (`+`). | ||
| * Property paths have a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths) | ||
| */ | ||
| export type OneOrMorePath = Opened<Algebra.OneOrMorePath>; | ||
| export type OrderBy = Opened<Algebra.OrderBy>; | ||
| export type Path = Opened<Algebra.Path>; | ||
| /** | ||
| * Simple BGP entry (triple) | ||
| */ | ||
| export type Pattern = Algebra.Pattern & withMeta; | ||
| export type Project = Opened<Algebra.Project>; | ||
| export type Reduced = Opened<Algebra.Reduced>; | ||
| /** | ||
| * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) sequence (`/`). | ||
| * Property paths have a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths) | ||
| */ | ||
| export type Seq = Opened<Algebra.Seq>; | ||
@@ -97,4 +140,19 @@ export type Service = Opened<Algebra.Service>; | ||
| export type Union = Opened<Algebra.Union>; | ||
| /** | ||
| * Algebra operation representing the [VALUES pattern](https://www.w3.org/TR/sparql11-query/#inline-data) | ||
| * Has a list of variables that will be assigned. | ||
| * The assignments are represented as a list of object containing bindings. | ||
| * Each binging links the variable value to the appropriate Term for this binding. | ||
| * Does not take any input. | ||
| */ | ||
| export type Values = Opened<Algebra.Values>; | ||
| /** | ||
| * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) zero or more (`*`). | ||
| * The having specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths) | ||
| */ | ||
| export type ZeroOrMorePath = Opened<Algebra.ZeroOrMorePath>; | ||
| /** | ||
| * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) zero or one (`?`). | ||
| * The having specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths) | ||
| */ | ||
| export type ZeroOrOnePath = Opened<Algebra.ZeroOrOnePath>; | ||
@@ -101,0 +159,0 @@ export type CompositeUpdate = Opened<Algebra.CompositeUpdate>; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"Algebra.js","sourceRoot":"","sources":["Algebra.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,oFAA8E;AAArE,oHAAA,KAAK,OAAA;AAAE,8HAAA,eAAe,OAAA","sourcesContent":["/**\n * We redefine our algebra components to use interfaces instead of type unions.\n * Thereby opening up the algebra for unknown extensions\n */\n\nimport type { Algebra } from '@traqula/algebra-transformations-1-2';\nimport type { Patch } from '@traqula/core';\n\nexport { Types, ExpressionTypes } from '@traqula/algebra-transformations-1-2';\n\ntype withMeta = { metadata?: Record<string, unknown> };\n\n// Base types\nexport type BaseOperation = Algebra.BaseOperation & withMeta;\nexport type BaseExpression = Algebra.BaseExpression & withMeta;\nexport type Operation = BaseOperation;\nexport type Expression = BaseExpression;\n\n// https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n/**\n * Maps algebra operation (as union types) Algebra.baseOperations (as interface) as values,\n * staying as precises as possible, and also working on arrays.\n */\nexport type OpenSingle<T> = [T] extends [any[]] ? OpenSingle<T[number]>[] :\n [T] extends [Algebra.Pattern] ? Algebra.Pattern & withMeta :\n [T] extends [Algebra.Expression] ? Expression :\n [T] extends [Algebra.Operation] ? Operation : T;\n\n/**\n * Reverse operation of OpenSingle\n */\nexport type CloseSingle<T> = T extends any[] ? CloseSingle<T[number]>[] :\n T extends BoundAggregate ? Algebra.BoundAggregate :\n T extends Algebra.BaseExpression ? Algebra.Expression :\n T extends Algebra.BaseOperation ? Algebra.Operation : T;\n\n/**\n * Maps a single object or array containing values of type algebra operation (as union types)\n * the same type but having Algebra.baseOperations (as interface) as values.\n */\nexport type Opened<T extends object> = {[K in keyof T]: OpenSingle<T[K]> } & withMeta;\n/**\n * Reversed of Opened\n */\nexport type Closed<T extends object > = {[K in keyof T]: CloseSingle<T[K]> };\n\n// Redefinitions of types\nexport type KnownOperation = Ask | KnownExpression | Bgp | Construct | Describe | Distinct | Extend | From | Filter\n | Graph | Group | Join | LeftJoin | Minus | Nop | OrderBy | Path | Pattern | Project | KnownPropertyPathSymbol\n | Reduced | Service | Slice | Union | Values | KnownUpdate | CompositeUpdate;\nexport type KnownExpression = AggregateExpression | GroupConcatExpression | ExistenceExpression | NamedExpression |\n OperatorExpression | TermExpression | WildcardExpression | BoundAggregate;\nexport type KnownPropertyPathSymbol = Alt | Inv | Link | Nps | OneOrMorePath | Seq | ZeroOrMorePath | ZeroOrOnePath;\nexport type KnownUpdate = DeleteInsert | Load | Clear | Create | Drop | Add | Move | Copy;\n\nexport type TypedOperation<T extends Algebra.Types> = Extract<KnownOperation, { type: T }>;\nexport type TypedExpression<T extends Algebra.ExpressionTypes> = Extract<KnownOperation, { subType: T }>;\n\nexport type Single = Opened<Algebra.Single>;\nexport type Multi = Opened<Algebra.Multi>;\nexport type Double = Opened<Algebra.Double>;\nexport type AggregateExpression = Opened<Algebra.AggregateExpression>;\nexport type GroupConcatExpression = Opened<Algebra.GroupConcatExpression>;\nexport type ExistenceExpression = Opened<Algebra.ExistenceExpression>;\nexport type NamedExpression = Opened<Algebra.NamedExpression>;\nexport type OperatorExpression = Opened<Algebra.OperatorExpression>;\nexport type TermExpression = Opened<Algebra.TermExpression>;\nexport type WildcardExpression = Opened<Algebra.WildcardExpression>;\nexport type Alt = Opened<Algebra.Alt>;\nexport type Ask = Opened<Algebra.Ask>;\nexport type Bgp = Opened<Algebra.Bgp>;\nexport type Construct = Opened<Algebra.Construct>;\nexport type Describe = Opened<Algebra.Describe>;\nexport type Distinct = Opened<Algebra.Distinct>;\nexport type Extend = Opened<Algebra.Extend>;\nexport type From = Opened<Algebra.From>;\nexport type Filter = Opened<Algebra.Filter>;\nexport type Graph = Opened<Algebra.Graph>;\nexport type BoundAggregate = Opened<Algebra.BoundAggregate>;\nexport type Group = Patch<Opened<Algebra.Group>, { aggregates: BoundAggregate[] }>;\nexport type Inv = Opened<Algebra.Inv>;\nexport type Join = Opened<Algebra.Join>;\nexport type LeftJoin = Opened<Algebra.LeftJoin>;\nexport type Link = Opened<Algebra.Link>;\nexport type Minus = Opened<Algebra.Minus>;\nexport type Nop = Opened<Algebra.Nop>;\nexport type Nps = Opened<Algebra.Nps>;\nexport type OneOrMorePath = Opened<Algebra.OneOrMorePath>;\nexport type OrderBy = Opened<Algebra.OrderBy>;\nexport type Path = Opened<Algebra.Path>;\nexport type Pattern = Algebra.Pattern & withMeta;\nexport type Project = Opened<Algebra.Project>;\nexport type Reduced = Opened<Algebra.Reduced>;\nexport type Seq = Opened<Algebra.Seq>;\nexport type Service = Opened<Algebra.Service>;\nexport type Slice = Opened<Algebra.Slice>;\nexport type Union = Opened<Algebra.Union>;\nexport type Values = Opened<Algebra.Values>;\nexport type ZeroOrMorePath = Opened<Algebra.ZeroOrMorePath>;\nexport type ZeroOrOnePath = Opened<Algebra.ZeroOrOnePath>;\nexport type CompositeUpdate = Opened<Algebra.CompositeUpdate>;\nexport type DeleteInsert = Opened<Algebra.DeleteInsert>;\nexport type UpdateGraph = Opened<Algebra.UpdateGraph>;\nexport type Load = Opened<Algebra.Load>;\nexport type Clear = Opened<Algebra.Clear>;\nexport type Create = Opened<Algebra.Create>;\nexport type Drop = Opened<Algebra.Drop>;\nexport type UpdateGraphShortcut = Opened<Algebra.UpdateGraphShortcut>;\nexport type Add = Opened<Algebra.Add>;\nexport type Move = Opened<Algebra.Move>;\nexport type Copy = Opened<Algebra.Copy>;\n"]} | ||
| {"version":3,"file":"Algebra.js","sourceRoot":"","sources":["Algebra.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,oFAA8E;AAArE,oHAAA,KAAK,OAAA;AAAE,8HAAA,eAAe,OAAA","sourcesContent":["/**\n * We redefine our algebra components to use interfaces instead of type unions.\n * Thereby opening up the algebra for unknown extensions\n */\n\nimport type { Algebra } from '@traqula/algebra-transformations-1-2';\nimport type { Patch } from '@traqula/core';\n\nexport { Types, ExpressionTypes } from '@traqula/algebra-transformations-1-2';\n\ntype withMeta = { metadata?: Record<string, unknown> };\n\n// Base types\nexport type BaseOperation = Algebra.BaseOperation & withMeta;\nexport type BaseExpression = Algebra.BaseExpression & withMeta;\nexport type Operation = BaseOperation;\nexport type Expression = BaseExpression;\n\n// https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types\n/**\n * Maps algebra operation (as union types) Algebra.baseOperations (as interface) as values,\n * staying as precises as possible, and also working on arrays.\n */\nexport type OpenSingle<T> = [T] extends [any[]] ? OpenSingle<T[number]>[] :\n [T] extends [Algebra.Pattern] ? Algebra.Pattern & withMeta :\n [T] extends [Algebra.Expression] ? Expression :\n [T] extends [Algebra.Operation] ? Operation : T;\n\n/**\n * Reverse operation of OpenSingle\n */\nexport type CloseSingle<T> = T extends any[] ? CloseSingle<T[number]>[] :\n T extends BoundAggregate ? Algebra.BoundAggregate :\n T extends Algebra.BaseExpression ? Algebra.Expression :\n T extends Algebra.BaseOperation ? Algebra.Operation : T;\n\n/**\n * Maps a single object or array containing values of type algebra operation (as union types)\n * the same type but having Algebra.baseOperations (as interface) as values.\n */\nexport type Opened<T extends object> = {[K in keyof T]: OpenSingle<T[K]> } & withMeta;\n/**\n * Reversed of Opened\n */\nexport type Closed<T extends object > = {[K in keyof T]: CloseSingle<T[K]> };\n\n// Redefinitions of types\nexport type KnownOperation = Ask | KnownExpression | Bgp | Construct | Describe | Distinct | Extend | From | Filter\n | Graph | Group | Join | LeftJoin | Minus | Nop | OrderBy | Path | Pattern | Project | KnownPropertyPathSymbol\n | Reduced | Service | Slice | Union | Values | KnownUpdate | CompositeUpdate;\nexport type KnownExpression = AggregateExpression | GroupConcatExpression | ExistenceExpression | NamedExpression |\n OperatorExpression | TermExpression | WildcardExpression | BoundAggregate;\nexport type KnownPropertyPathSymbol = Alt | Inv | Link | Nps | OneOrMorePath | Seq | ZeroOrMorePath | ZeroOrOnePath;\nexport type KnownUpdate = DeleteInsert | Load | Clear | Create | Drop | Add | Move | Copy;\n\nexport type TypedOperation<T extends Algebra.Types> = Extract<KnownOperation, { type: T }>;\nexport type TypedExpression<T extends Algebra.ExpressionTypes> = Extract<KnownOperation, { subType: T }>;\n/**\n * Algebra operation taking a single operation as input.\n */\nexport type Single = Opened<Algebra.Single>;\n/**\n * Algebra operation taking multiple operations as input.\n */\nexport type Multi = Opened<Algebra.Multi>;\n/**\n * Algebra operation taking exactly two input operations.\n */\nexport type Double = Opened<Algebra.Double>;\nexport type AggregateExpression = Opened<Algebra.AggregateExpression>;\nexport type GroupConcatExpression = Opened<Algebra.GroupConcatExpression>;\nexport type ExistenceExpression = Opened<Algebra.ExistenceExpression>;\nexport type NamedExpression = Opened<Algebra.NamedExpression>;\nexport type OperatorExpression = Opened<Algebra.OperatorExpression>;\nexport type TermExpression = Opened<Algebra.TermExpression>;\nexport type WildcardExpression = Opened<Algebra.WildcardExpression>;\n/**\n * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) alternative (`|`).\n * Property paths have a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths)\n */\nexport type Alt = Opened<Algebra.Alt>;\nexport type Ask = Opened<Algebra.Ask>;\nexport type Bgp = Opened<Algebra.Bgp>;\nexport type Construct = Opened<Algebra.Construct>;\nexport type Describe = Opened<Algebra.Describe>;\nexport type Distinct = Opened<Algebra.Distinct>;\nexport type Extend = Opened<Algebra.Extend>;\nexport type From = Opened<Algebra.From>;\nexport type Filter = Opened<Algebra.Filter>;\nexport type Graph = Opened<Algebra.Graph>;\nexport type BoundAggregate = Opened<Algebra.BoundAggregate>;\nexport type Group = Patch<Opened<Algebra.Group>, { aggregates: BoundAggregate[] }>;\n/**\n * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) inverse (`^`).\n * Having a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths)\n * This operation, besides basic mode is the reason SPARQL can contain literals in the subject position.\n */\nexport type Inv = Opened<Algebra.Inv>;\nexport type Join = Opened<Algebra.Join>;\nexport type LeftJoin = Opened<Algebra.LeftJoin>;\n/**\n * Algebra operation representing the property of a [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths).\n * Property paths have a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths)\n * This operation, is just a way of saying to a Propery Path operation that nothing fancy is going on,\n * and it should just match this property.\n */\nexport type Link = Opened<Algebra.Link>;\nexport type Minus = Opened<Algebra.Minus>;\n/**\n * An empty operation.\n * For example used for the algebra representation of a query string that does not contain any operation.\n */\nexport type Nop = Opened<Algebra.Nop>;\n/**\n * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) negated property set (`!`).\n * Property paths have a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths)\n */\nexport type Nps = Opened<Algebra.Nps>;\n/**\n * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) one or more (`+`).\n * Property paths have a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths)\n */\nexport type OneOrMorePath = Opened<Algebra.OneOrMorePath>;\nexport type OrderBy = Opened<Algebra.OrderBy>;\nexport type Path = Opened<Algebra.Path>;\n/**\n * Simple BGP entry (triple)\n */\nexport type Pattern = Algebra.Pattern & withMeta;\nexport type Project = Opened<Algebra.Project>;\nexport type Reduced = Opened<Algebra.Reduced>;\n/**\n * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) sequence (`/`).\n * Property paths have a specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths)\n */\nexport type Seq = Opened<Algebra.Seq>;\nexport type Service = Opened<Algebra.Service>;\nexport type Slice = Opened<Algebra.Slice>;\nexport type Union = Opened<Algebra.Union>;\n/**\n * Algebra operation representing the [VALUES pattern](https://www.w3.org/TR/sparql11-query/#inline-data)\n * Has a list of variables that will be assigned.\n * The assignments are represented as a list of object containing bindings.\n * Each binging links the variable value to the appropriate Term for this binding.\n * Does not take any input.\n */\nexport type Values = Opened<Algebra.Values>;\n/**\n * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) zero or more (`*`).\n * The having specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths)\n */\nexport type ZeroOrMorePath = Opened<Algebra.ZeroOrMorePath>;\n/**\n * Algebra operation representing the [Property path](https://www.w3.org/TR/sparql11-query/#propertypaths) zero or one (`?`).\n * The having specific [SPARQL definition](https://www.w3.org/TR/sparql11-query/#sparqlPropertyPaths)\n */\nexport type ZeroOrOnePath = Opened<Algebra.ZeroOrOnePath>;\nexport type CompositeUpdate = Opened<Algebra.CompositeUpdate>;\nexport type DeleteInsert = Opened<Algebra.DeleteInsert>;\nexport type UpdateGraph = Opened<Algebra.UpdateGraph>;\nexport type Load = Opened<Algebra.Load>;\nexport type Clear = Opened<Algebra.Clear>;\nexport type Create = Opened<Algebra.Create>;\nexport type Drop = Opened<Algebra.Drop>;\nexport type UpdateGraphShortcut = Opened<Algebra.UpdateGraphShortcut>;\nexport type Add = Opened<Algebra.Add>;\nexport type Move = Opened<Algebra.Move>;\nexport type Copy = Opened<Algebra.Copy>;\n"]} |
+1
-1
| export * as Algebra from './Algebra'; | ||
| export { isKnownOperation, isKnownSubType } from './utils'; | ||
| export { isKnownOperation, isKnownSubType, transformer } from './utils'; | ||
| export * as algebraUtils from './utils'; | ||
| export { AlgebraFactory } from '@traqula/algebra-transformations-1-2'; |
+2
-1
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.AlgebraFactory = exports.algebraUtils = exports.isKnownSubType = exports.isKnownOperation = exports.Algebra = void 0; | ||
| exports.AlgebraFactory = exports.algebraUtils = exports.transformer = exports.isKnownSubType = exports.isKnownOperation = exports.Algebra = void 0; | ||
| exports.Algebra = require("./Algebra"); | ||
@@ -8,2 +8,3 @@ var utils_1 = require("./utils"); | ||
| Object.defineProperty(exports, "isKnownSubType", { enumerable: true, get: function () { return utils_1.isKnownSubType; } }); | ||
| Object.defineProperty(exports, "transformer", { enumerable: true, get: function () { return utils_1.transformer; } }); | ||
| exports.algebraUtils = require("./utils"); | ||
@@ -10,0 +11,0 @@ var algebra_transformations_1_2_1 = require("@traqula/algebra-transformations-1-2"); |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,iCAA2D;AAAlD,yGAAA,gBAAgB,OAAA;AAAE,uGAAA,cAAc,OAAA;AACzC,0CAAwC;AACxC,oFAAsE;AAA7D,6HAAA,cAAc,OAAA","sourcesContent":["export * as Algebra from './Algebra';\nexport { isKnownOperation, isKnownSubType } from './utils';\nexport * as algebraUtils from './utils';\nexport { AlgebraFactory } from '@traqula/algebra-transformations-1-2';\n"]} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AACrC,iCAAwE;AAA/D,yGAAA,gBAAgB,OAAA;AAAE,uGAAA,cAAc,OAAA;AAAE,oGAAA,WAAW,OAAA;AACtD,0CAAwC;AACxC,oFAAsE;AAA7D,6HAAA,cAAc,OAAA","sourcesContent":["export * as Algebra from './Algebra';\nexport { isKnownOperation, isKnownSubType, transformer } from './utils';\nexport * as algebraUtils from './utils';\nexport { AlgebraFactory } from '@traqula/algebra-transformations-1-2';\n"]} |
+465
-185
| import type { Algebra as TraqulaAlgebra } from '@traqula/algebra-transformations-1-2'; | ||
| import { algebraUtils } from '@traqula/algebra-transformations-1-2'; | ||
| import type { TransformContext, VisitContext } from '@traqula/core'; | ||
| import { TransformerSubTyped } from '@traqula/core'; | ||
@@ -11,5 +12,8 @@ import type { KnownOperation, Operation } from './Algebra'; | ||
| * the type guard will conclude the operation contains all member Comunica expects from this operation-type and subtype. | ||
| * @param val | ||
| * @param type | ||
| * @param subType | ||
| * @param val the operation that should be type checked | ||
| * @param type the type we want to test against | ||
| * @param subType the potential subtype we want to test against | ||
| * - when provided and not matching, we do not fall back to just checking the type. | ||
| * @return a boolean indicating whether the type and subtype are equal to the expected type and subtype. | ||
| * Only checking the subtype when a string is provided. | ||
| */ | ||
@@ -38,4 +42,5 @@ export declare function isKnownOperation<Type extends KnownOperation['type'], SubType extends Extract<KnownOperation, { | ||
| * the type guard will conclude the operation contains all member Comunica expects from this operation-subtype | ||
| * @param val | ||
| * @param subType | ||
| * @param val the operation that should be type checked | ||
| * @param subType the subType we want to test against | ||
| * @return a boolean indicating whether the subType equals the expected subType | ||
| */ | ||
@@ -51,44 +56,87 @@ export declare function isKnownSubType<SubType extends KnownOperation['subType'], Obj extends Operation>(val: Obj, subType: SubType): val is Extract<KnownOperation, { | ||
| }; | ||
| declare const transformer: TransformerSubTyped<KnownOperation>; | ||
| export declare const mapOperation: (typeof transformer.transformNode<'unsafe', Operation>); | ||
| export declare const transformer: TransformerSubTyped<KnownOperation>; | ||
| /** | ||
| * Transform a single operation, similar to {@link mapOperation}, but using stricter typings. | ||
| * e.g. wrapping a distinct around the outermost project: | ||
| * ```ts | ||
| * mapOperationStrict<'unsafe', Operation>({ | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, { | ||
| * [Algebra.Types.PROJECT]: { | ||
| * preVisitor: () => ({ continue: false }), | ||
| * transform: projection => algebraFactory.createDistinct(projection), | ||
| * }, | ||
| * }); | ||
| * const returns = { | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, | ||
| * }; | ||
| * ``` | ||
| * @param startObject the object from which we will start the transformation, | ||
| * potentially visiting and transforming its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and transformer. | ||
| * The preVisitor allows you to provide {@link TransformContext} for the current object, | ||
| * altering how it will be transformed. | ||
| * The transformer allows you to manipulate the copy of the current object, | ||
| * and expects you to return the value that should take the current objects place. | ||
| * @return the result of transforming the requested descendant operations (based on the preVisitor) | ||
| * using a transformer that works its way back up from the descendant to the startObject. | ||
| */ | ||
| export declare const mapOperationStrict: <Safe extends import("@traqula/core").Safeness = "safe", OutType = unknown>(startObject: object, nodeCallBacks: { | ||
| ask?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Ask>, orig: import("./Algebra").Ask) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Ask) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Ask) => TransformContext) | undefined; | ||
| } | undefined; | ||
| bgp?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Bgp>, orig: import("./Algebra").Bgp) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Bgp) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Bgp) => TransformContext) | undefined; | ||
| } | undefined; | ||
| construct?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Construct>, orig: import("./Algebra").Construct) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Construct) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Construct) => TransformContext) | undefined; | ||
| } | undefined; | ||
| describe?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Describe>, orig: import("./Algebra").Describe) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Describe) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Describe) => TransformContext) | undefined; | ||
| } | undefined; | ||
| distinct?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Distinct>, orig: import("./Algebra").Distinct) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Distinct) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Distinct) => TransformContext) | undefined; | ||
| } | undefined; | ||
| expression?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").KnownExpression>, orig: import("./Algebra").KnownExpression) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").KnownExpression) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").KnownExpression) => TransformContext) | undefined; | ||
| } | undefined; | ||
| extend?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Extend>, orig: import("./Algebra").Extend) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Extend) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Extend) => TransformContext) | undefined; | ||
| } | undefined; | ||
| filter?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Filter>, orig: import("./Algebra").Filter) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Filter) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Filter) => TransformContext) | undefined; | ||
| } | undefined; | ||
| from?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").From>, orig: import("./Algebra").From) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").From) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").From) => TransformContext) | undefined; | ||
| } | undefined; | ||
| graph?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Graph>, orig: import("./Algebra").Graph) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Graph) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Graph) => TransformContext) | undefined; | ||
| } | undefined; | ||
@@ -103,166 +151,264 @@ group?: { | ||
| aggregates: import("./Algebra").BoundAggregate[]; | ||
| }>) => import("@traqula/core").TransformContext) | undefined; | ||
| }>) => TransformContext) | undefined; | ||
| } | undefined; | ||
| join?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Join>, orig: import("./Algebra").Join) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Join) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Join) => TransformContext) | undefined; | ||
| } | undefined; | ||
| leftjoin?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").LeftJoin>, orig: import("./Algebra").LeftJoin) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").LeftJoin) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").LeftJoin) => TransformContext) | undefined; | ||
| } | undefined; | ||
| minus?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Minus>, orig: import("./Algebra").Minus) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Minus) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Minus) => TransformContext) | undefined; | ||
| } | undefined; | ||
| nop?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Nop>, orig: import("./Algebra").Nop) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Nop) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Nop) => TransformContext) | undefined; | ||
| } | undefined; | ||
| orderby?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").OrderBy>, orig: import("./Algebra").OrderBy) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").OrderBy) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").OrderBy) => TransformContext) | undefined; | ||
| } | undefined; | ||
| pattern?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Pattern>, orig: import("./Algebra").Pattern) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Pattern) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Pattern) => TransformContext) | undefined; | ||
| } | undefined; | ||
| project?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Project>, orig: import("./Algebra").Project) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Project) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Project) => TransformContext) | undefined; | ||
| } | undefined; | ||
| reduced?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Reduced>, orig: import("./Algebra").Reduced) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Reduced) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Reduced) => TransformContext) | undefined; | ||
| } | undefined; | ||
| service?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Service>, orig: import("./Algebra").Service) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Service) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Service) => TransformContext) | undefined; | ||
| } | undefined; | ||
| slice?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Slice>, orig: import("./Algebra").Slice) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Slice) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Slice) => TransformContext) | undefined; | ||
| } | undefined; | ||
| union?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Union>, orig: import("./Algebra").Union) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Union) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Union) => TransformContext) | undefined; | ||
| } | undefined; | ||
| values?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Values>, orig: import("./Algebra").Values) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Values) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Values) => TransformContext) | undefined; | ||
| } | undefined; | ||
| compositeupdate?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").CompositeUpdate>, orig: import("./Algebra").CompositeUpdate) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").CompositeUpdate) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").CompositeUpdate) => TransformContext) | undefined; | ||
| } | undefined; | ||
| deleteinsert?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").DeleteInsert>, orig: import("./Algebra").DeleteInsert) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").DeleteInsert) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").DeleteInsert) => TransformContext) | undefined; | ||
| } | undefined; | ||
| load?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Load>, orig: import("./Algebra").Load) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Load) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Load) => TransformContext) | undefined; | ||
| } | undefined; | ||
| clear?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Clear>, orig: import("./Algebra").Clear) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Clear) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Clear) => TransformContext) | undefined; | ||
| } | undefined; | ||
| create?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Create>, orig: import("./Algebra").Create) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Create) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Create) => TransformContext) | undefined; | ||
| } | undefined; | ||
| drop?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Drop>, orig: import("./Algebra").Drop) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Drop) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Drop) => TransformContext) | undefined; | ||
| } | undefined; | ||
| add?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Add>, orig: import("./Algebra").Add) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Add) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Add) => TransformContext) | undefined; | ||
| } | undefined; | ||
| move?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Move>, orig: import("./Algebra").Move) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Move) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Move) => TransformContext) | undefined; | ||
| } | undefined; | ||
| copy?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Copy>, orig: import("./Algebra").Copy) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Copy) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Copy) => TransformContext) | undefined; | ||
| } | undefined; | ||
| path?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Path>, orig: import("./Algebra").Path) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Path) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Path) => TransformContext) | undefined; | ||
| } | undefined; | ||
| alt?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Alt>, orig: import("./Algebra").Alt) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Alt) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Alt) => TransformContext) | undefined; | ||
| } | undefined; | ||
| inv?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Inv>, orig: import("./Algebra").Inv) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Inv) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Inv) => TransformContext) | undefined; | ||
| } | undefined; | ||
| link?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Link>, orig: import("./Algebra").Link) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Link) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Link) => TransformContext) | undefined; | ||
| } | undefined; | ||
| OneOrMorePath?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").OneOrMorePath>, orig: import("./Algebra").OneOrMorePath) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").OneOrMorePath) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").OneOrMorePath) => TransformContext) | undefined; | ||
| } | undefined; | ||
| seq?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Seq>, orig: import("./Algebra").Seq) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Seq) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Seq) => TransformContext) | undefined; | ||
| } | undefined; | ||
| nps?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Nps>, orig: import("./Algebra").Nps) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Nps) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Nps) => TransformContext) | undefined; | ||
| } | undefined; | ||
| ZeroOrMorePath?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").ZeroOrMorePath>, orig: import("./Algebra").ZeroOrMorePath) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").ZeroOrMorePath) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").ZeroOrMorePath) => TransformContext) | undefined; | ||
| } | undefined; | ||
| ZeroOrOnePath?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").ZeroOrOnePath>, orig: import("./Algebra").ZeroOrOnePath) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").ZeroOrOnePath) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").ZeroOrOnePath) => TransformContext) | undefined; | ||
| } | undefined; | ||
| }) => Safe extends "unsafe" ? OutType : unknown; | ||
| export declare const mapOperationSub: (typeof transformer.transformNodeSpecific<'unsafe', Operation>); | ||
| /** | ||
| * Transform a single operation. | ||
| * e.g. wrapping a distinct around the outermost project: | ||
| * ```ts | ||
| * mapOperation({ | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, { | ||
| * [Algebra.Types.PROJECT]: { | ||
| * preVisitor: () => ({ continue: false }), | ||
| * transform: projection => algebraFactory.createDistinct(projection), | ||
| * }, | ||
| * }); | ||
| * const returns = { | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, | ||
| * }; | ||
| * ``` | ||
| * @param startObject the object from which we will start the transformation, | ||
| * potentially visiting and transforming its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and transformer. | ||
| * The preVisitor allows you to provide {@link TransformContext} for the current object, | ||
| * altering how it will be transformed. | ||
| * The transformer allows you to manipulate the copy of the current object, | ||
| * and expects you to return the value that should take the current objects place. | ||
| * @return the result of transforming the requested descendant operations (based on the preVisitor) | ||
| * using a transformer that works its way back up from the descendant to the startObject. | ||
| */ | ||
| export declare const mapOperation: (typeof mapOperationStrict<'unsafe', Operation>); | ||
| /** | ||
| * Transform a single operation, similar to {@link mapOperationSub}, but using stricter typings. | ||
| * e.g. wrapping a distinct around the all project operations not contained in an aggregate expression | ||
| * (invalid algebra anyway): | ||
| * ```ts | ||
| * mapOperationSubStrict<'unsafe', Operation>({ | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ | ||
| * type: Algebra.Types.EXPRESSION, | ||
| * subType: Algebra.ExpressionTypes.AGGREGATE, | ||
| * input: { type: Algebra.Types.PROJECT }, | ||
| * }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, { [Algebra.Types.PROJECT]: { | ||
| * transform: projection => algebraFactory.createDistinct(projection), | ||
| * }}, { [Algebra.Types.EXPRESSION]: { [Algebra.ExpressionTypes.AGGREGATE]: { | ||
| * preVisitor: () => ({ continue: false }), | ||
| * }}}); | ||
| * const returns = { | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ | ||
| * type: Algebra.Types.EXPRESSION, | ||
| * subType: Algebra.ExpressionTypes.AGGREGATE, | ||
| * input: { type: Algebra.Types.PROJECT }, | ||
| * }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, | ||
| * }; | ||
| * ``` | ||
| * @param startObject the object from which we will start the transformation, | ||
| * potentially visiting and transforming its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and transformer. | ||
| * The preVisitor allows you to provide {@link TransformContext} for the current object, | ||
| * altering how it will be transformed. | ||
| * The transformer allows you to manipulate the copy of the current object, | ||
| * and expects you to return the value that should take the current objects place. | ||
| * @param nodeSpecificCallBacks Same as nodeCallBacks but using an additional level of indirection to | ||
| * indicate the subType. | ||
| * @return the result of transforming the requested descendant operations (based on the preVisitor) | ||
| * using a transformer that works its way back up from the descendant to the startObject. | ||
| */ | ||
| export declare const mapOperationSubStrict: <Safe extends import("@traqula/core").Safeness = "safe", OutType = unknown>(startObject: object, nodeCallBacks: { | ||
| ask?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Ask>, orig: import("./Algebra").Ask) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Ask) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Ask) => TransformContext) | undefined; | ||
| } | undefined; | ||
| bgp?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Bgp>, orig: import("./Algebra").Bgp) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Bgp) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Bgp) => TransformContext) | undefined; | ||
| } | undefined; | ||
| construct?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Construct>, orig: import("./Algebra").Construct) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Construct) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Construct) => TransformContext) | undefined; | ||
| } | undefined; | ||
| describe?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Describe>, orig: import("./Algebra").Describe) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Describe) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Describe) => TransformContext) | undefined; | ||
| } | undefined; | ||
| distinct?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Distinct>, orig: import("./Algebra").Distinct) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Distinct) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Distinct) => TransformContext) | undefined; | ||
| } | undefined; | ||
| expression?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").KnownExpression>, orig: import("./Algebra").KnownExpression) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").KnownExpression) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").KnownExpression) => TransformContext) | undefined; | ||
| } | undefined; | ||
| extend?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Extend>, orig: import("./Algebra").Extend) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Extend) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Extend) => TransformContext) | undefined; | ||
| } | undefined; | ||
| filter?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Filter>, orig: import("./Algebra").Filter) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Filter) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Filter) => TransformContext) | undefined; | ||
| } | undefined; | ||
| from?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").From>, orig: import("./Algebra").From) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").From) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").From) => TransformContext) | undefined; | ||
| } | undefined; | ||
| graph?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Graph>, orig: import("./Algebra").Graph) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Graph) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Graph) => TransformContext) | undefined; | ||
| } | undefined; | ||
@@ -277,123 +423,123 @@ group?: { | ||
| aggregates: import("./Algebra").BoundAggregate[]; | ||
| }>) => import("@traqula/core").TransformContext) | undefined; | ||
| }>) => TransformContext) | undefined; | ||
| } | undefined; | ||
| join?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Join>, orig: import("./Algebra").Join) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Join) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Join) => TransformContext) | undefined; | ||
| } | undefined; | ||
| leftjoin?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").LeftJoin>, orig: import("./Algebra").LeftJoin) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").LeftJoin) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").LeftJoin) => TransformContext) | undefined; | ||
| } | undefined; | ||
| minus?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Minus>, orig: import("./Algebra").Minus) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Minus) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Minus) => TransformContext) | undefined; | ||
| } | undefined; | ||
| nop?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Nop>, orig: import("./Algebra").Nop) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Nop) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Nop) => TransformContext) | undefined; | ||
| } | undefined; | ||
| orderby?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").OrderBy>, orig: import("./Algebra").OrderBy) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").OrderBy) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").OrderBy) => TransformContext) | undefined; | ||
| } | undefined; | ||
| pattern?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Pattern>, orig: import("./Algebra").Pattern) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Pattern) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Pattern) => TransformContext) | undefined; | ||
| } | undefined; | ||
| project?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Project>, orig: import("./Algebra").Project) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Project) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Project) => TransformContext) | undefined; | ||
| } | undefined; | ||
| reduced?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Reduced>, orig: import("./Algebra").Reduced) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Reduced) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Reduced) => TransformContext) | undefined; | ||
| } | undefined; | ||
| service?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Service>, orig: import("./Algebra").Service) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Service) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Service) => TransformContext) | undefined; | ||
| } | undefined; | ||
| slice?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Slice>, orig: import("./Algebra").Slice) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Slice) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Slice) => TransformContext) | undefined; | ||
| } | undefined; | ||
| union?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Union>, orig: import("./Algebra").Union) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Union) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Union) => TransformContext) | undefined; | ||
| } | undefined; | ||
| values?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Values>, orig: import("./Algebra").Values) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Values) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Values) => TransformContext) | undefined; | ||
| } | undefined; | ||
| compositeupdate?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").CompositeUpdate>, orig: import("./Algebra").CompositeUpdate) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").CompositeUpdate) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").CompositeUpdate) => TransformContext) | undefined; | ||
| } | undefined; | ||
| deleteinsert?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").DeleteInsert>, orig: import("./Algebra").DeleteInsert) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").DeleteInsert) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").DeleteInsert) => TransformContext) | undefined; | ||
| } | undefined; | ||
| load?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Load>, orig: import("./Algebra").Load) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Load) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Load) => TransformContext) | undefined; | ||
| } | undefined; | ||
| clear?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Clear>, orig: import("./Algebra").Clear) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Clear) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Clear) => TransformContext) | undefined; | ||
| } | undefined; | ||
| create?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Create>, orig: import("./Algebra").Create) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Create) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Create) => TransformContext) | undefined; | ||
| } | undefined; | ||
| drop?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Drop>, orig: import("./Algebra").Drop) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Drop) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Drop) => TransformContext) | undefined; | ||
| } | undefined; | ||
| add?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Add>, orig: import("./Algebra").Add) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Add) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Add) => TransformContext) | undefined; | ||
| } | undefined; | ||
| move?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Move>, orig: import("./Algebra").Move) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Move) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Move) => TransformContext) | undefined; | ||
| } | undefined; | ||
| copy?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Copy>, orig: import("./Algebra").Copy) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Copy) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Copy) => TransformContext) | undefined; | ||
| } | undefined; | ||
| path?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Path>, orig: import("./Algebra").Path) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Path) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Path) => TransformContext) | undefined; | ||
| } | undefined; | ||
| alt?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Alt>, orig: import("./Algebra").Alt) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Alt) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Alt) => TransformContext) | undefined; | ||
| } | undefined; | ||
| inv?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Inv>, orig: import("./Algebra").Inv) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Inv) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Inv) => TransformContext) | undefined; | ||
| } | undefined; | ||
| link?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Link>, orig: import("./Algebra").Link) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Link) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Link) => TransformContext) | undefined; | ||
| } | undefined; | ||
| OneOrMorePath?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").OneOrMorePath>, orig: import("./Algebra").OneOrMorePath) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").OneOrMorePath) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").OneOrMorePath) => TransformContext) | undefined; | ||
| } | undefined; | ||
| seq?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Seq>, orig: import("./Algebra").Seq) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Seq) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Seq) => TransformContext) | undefined; | ||
| } | undefined; | ||
| nps?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Nps>, orig: import("./Algebra").Nps) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Nps) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").Nps) => TransformContext) | undefined; | ||
| } | undefined; | ||
| ZeroOrMorePath?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").ZeroOrMorePath>, orig: import("./Algebra").ZeroOrMorePath) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").ZeroOrMorePath) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").ZeroOrMorePath) => TransformContext) | undefined; | ||
| } | undefined; | ||
| ZeroOrOnePath?: { | ||
| transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").ZeroOrOnePath>, orig: import("./Algebra").ZeroOrOnePath) => unknown) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").ZeroOrOnePath) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((orig: import("./Algebra").ZeroOrOnePath) => TransformContext) | undefined; | ||
| } | undefined; | ||
@@ -409,23 +555,23 @@ }, nodeSpecificCallBacks: { | ||
| transform?: ((op: import("@traqula/core").SafeWrap<Safe, import("./Algebra").BoundAggregate | import("./Algebra").AggregateExpression | import("./Algebra").GroupConcatExpression>) => unknown) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").BoundAggregate | import("./Algebra").AggregateExpression | import("./Algebra").GroupConcatExpression) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").BoundAggregate | import("./Algebra").AggregateExpression | import("./Algebra").GroupConcatExpression) => TransformContext) | undefined; | ||
| } | undefined; | ||
| existence?: { | ||
| transform?: ((op: import("@traqula/core").SafeWrap<Safe, import("./Algebra").ExistenceExpression>) => unknown) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ExistenceExpression) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ExistenceExpression) => TransformContext) | undefined; | ||
| } | undefined; | ||
| named?: { | ||
| transform?: ((op: import("@traqula/core").SafeWrap<Safe, import("./Algebra").NamedExpression>) => unknown) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").NamedExpression) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").NamedExpression) => TransformContext) | undefined; | ||
| } | undefined; | ||
| operator?: { | ||
| transform?: ((op: import("@traqula/core").SafeWrap<Safe, import("./Algebra").OperatorExpression>) => unknown) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OperatorExpression) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OperatorExpression) => TransformContext) | undefined; | ||
| } | undefined; | ||
| term?: { | ||
| transform?: ((op: import("@traqula/core").SafeWrap<Safe, import("./Algebra").TermExpression>) => unknown) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").TermExpression) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").TermExpression) => TransformContext) | undefined; | ||
| } | undefined; | ||
| wildcard?: { | ||
| transform?: ((op: import("@traqula/core").SafeWrap<Safe, import("./Algebra").WildcardExpression>) => unknown) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").WildcardExpression) => import("@traqula/core").TransformContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").WildcardExpression) => TransformContext) | undefined; | ||
| } | undefined; | ||
@@ -469,42 +615,128 @@ } | undefined; | ||
| }) => Safe extends "unsafe" ? OutType : unknown; | ||
| /** | ||
| * Transform a single operation, similar to {@link mapOperation}, but also allowing you to target subTypes. | ||
| * e.g. wrapping a distinct around the all project operations not contained in an aggregate expression | ||
| * (invalid algebra anyway): | ||
| * ```ts | ||
| * mapOperationSub({ | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ | ||
| * type: Algebra.Types.EXPRESSION, | ||
| * subType: Algebra.ExpressionTypes.AGGREGATE, | ||
| * input: { type: Algebra.Types.PROJECT }, | ||
| * }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, { [Algebra.Types.PROJECT]: { | ||
| * transform: projection => algebraFactory.createDistinct(projection), | ||
| * }}, { [Algebra.Types.EXPRESSION]: { [Algebra.ExpressionTypes.AGGREGATE]: { | ||
| * preVisitor: () => ({ continue: false }), | ||
| * }}}); | ||
| * const returns = { | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ | ||
| * type: Algebra.Types.EXPRESSION, | ||
| * subType: Algebra.ExpressionTypes.AGGREGATE, | ||
| * input: { type: Algebra.Types.PROJECT }, | ||
| * }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, | ||
| * }; | ||
| * ``` | ||
| * @param startObject the object from which we will start the transformation, | ||
| * potentially visiting and transforming its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and transformer. | ||
| * The preVisitor allows you to provide {@link TransformContext} for the current object, | ||
| * altering how it will be transformed. | ||
| * The transformer allows you to manipulate the copy of the current object, | ||
| * and expects you to return the value that should take the current objects place. | ||
| * @param nodeSpecificCallBacks Same as nodeCallBacks but using an additional level of indirection to | ||
| * indicate the subType. | ||
| * @return the result of transforming the requested descendant operations (based on the preVisitor) | ||
| * using a transformer that works its way back up from the descendant to the startObject. | ||
| */ | ||
| export declare const mapOperationSub: (typeof mapOperationSubStrict<'unsafe', Operation>); | ||
| /** | ||
| * Similar to {@link mapOperation}, but only visiting instead of copying and transforming explicitly. | ||
| * e.g.: | ||
| * ```ts | ||
| * visitOperation({ | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { type: Algebra.Types.DISTINCT }, | ||
| * }, | ||
| * }, { | ||
| * [Algebra.Types.DISTINCT]: { visitor: () => console.log('1') }, | ||
| * [Algebra.Types.PROJECT]: { | ||
| * preVisitor: () => ({ continue: false }), | ||
| * visitor: () => console.log('2'), | ||
| * }, | ||
| * }); | ||
| * ``` | ||
| * Will first call the preVisitor on the project and notice it should not iterate on its descendants. | ||
| * It then visits the project, and the outermost distinct, printing '21'. | ||
| * The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse. | ||
| * @param startObject the object from which we will start visiting, | ||
| * potentially visiting its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and visitor. | ||
| * The preVisitor allows you to provide {@link VisitContext} for the current object, | ||
| * altering how it will be visited. | ||
| * The visitor allows you to visit the object from deepest to the outermost object. | ||
| * This is useful if you for example want to manipulate the objects you visit during your visits, | ||
| * similar to {@link mapOperation}. | ||
| */ | ||
| export declare const visitOperation: (startObject: object, nodeCallBacks: { | ||
| ask?: { | ||
| visitor?: ((op: import("./Algebra").Ask) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Ask) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Ask) => VisitContext) | undefined; | ||
| } | undefined; | ||
| bgp?: { | ||
| visitor?: ((op: import("./Algebra").Bgp) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Bgp) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Bgp) => VisitContext) | undefined; | ||
| } | undefined; | ||
| construct?: { | ||
| visitor?: ((op: import("./Algebra").Construct) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Construct) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Construct) => VisitContext) | undefined; | ||
| } | undefined; | ||
| describe?: { | ||
| visitor?: ((op: import("./Algebra").Describe) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Describe) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Describe) => VisitContext) | undefined; | ||
| } | undefined; | ||
| distinct?: { | ||
| visitor?: ((op: import("./Algebra").Distinct) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Distinct) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Distinct) => VisitContext) | undefined; | ||
| } | undefined; | ||
| expression?: { | ||
| visitor?: ((op: import("./Algebra").KnownExpression) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").KnownExpression) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").KnownExpression) => VisitContext) | undefined; | ||
| } | undefined; | ||
| extend?: { | ||
| visitor?: ((op: import("./Algebra").Extend) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Extend) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Extend) => VisitContext) | undefined; | ||
| } | undefined; | ||
| filter?: { | ||
| visitor?: ((op: import("./Algebra").Filter) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Filter) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Filter) => VisitContext) | undefined; | ||
| } | undefined; | ||
| from?: { | ||
| visitor?: ((op: import("./Algebra").From) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").From) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").From) => VisitContext) | undefined; | ||
| } | undefined; | ||
| graph?: { | ||
| visitor?: ((op: import("./Algebra").Graph) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Graph) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Graph) => VisitContext) | undefined; | ||
| } | undefined; | ||
@@ -517,165 +749,205 @@ group?: { | ||
| aggregates: import("./Algebra").BoundAggregate[]; | ||
| }>) => import("@traqula/core").VisitContext) | undefined; | ||
| }>) => VisitContext) | undefined; | ||
| } | undefined; | ||
| join?: { | ||
| visitor?: ((op: import("./Algebra").Join) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Join) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Join) => VisitContext) | undefined; | ||
| } | undefined; | ||
| leftjoin?: { | ||
| visitor?: ((op: import("./Algebra").LeftJoin) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").LeftJoin) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").LeftJoin) => VisitContext) | undefined; | ||
| } | undefined; | ||
| minus?: { | ||
| visitor?: ((op: import("./Algebra").Minus) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Minus) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Minus) => VisitContext) | undefined; | ||
| } | undefined; | ||
| nop?: { | ||
| visitor?: ((op: import("./Algebra").Nop) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Nop) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Nop) => VisitContext) | undefined; | ||
| } | undefined; | ||
| orderby?: { | ||
| visitor?: ((op: import("./Algebra").OrderBy) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OrderBy) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OrderBy) => VisitContext) | undefined; | ||
| } | undefined; | ||
| pattern?: { | ||
| visitor?: ((op: import("./Algebra").Pattern) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Pattern) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Pattern) => VisitContext) | undefined; | ||
| } | undefined; | ||
| project?: { | ||
| visitor?: ((op: import("./Algebra").Project) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Project) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Project) => VisitContext) | undefined; | ||
| } | undefined; | ||
| reduced?: { | ||
| visitor?: ((op: import("./Algebra").Reduced) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Reduced) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Reduced) => VisitContext) | undefined; | ||
| } | undefined; | ||
| service?: { | ||
| visitor?: ((op: import("./Algebra").Service) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Service) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Service) => VisitContext) | undefined; | ||
| } | undefined; | ||
| slice?: { | ||
| visitor?: ((op: import("./Algebra").Slice) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Slice) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Slice) => VisitContext) | undefined; | ||
| } | undefined; | ||
| union?: { | ||
| visitor?: ((op: import("./Algebra").Union) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Union) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Union) => VisitContext) | undefined; | ||
| } | undefined; | ||
| values?: { | ||
| visitor?: ((op: import("./Algebra").Values) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Values) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Values) => VisitContext) | undefined; | ||
| } | undefined; | ||
| compositeupdate?: { | ||
| visitor?: ((op: import("./Algebra").CompositeUpdate) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").CompositeUpdate) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").CompositeUpdate) => VisitContext) | undefined; | ||
| } | undefined; | ||
| deleteinsert?: { | ||
| visitor?: ((op: import("./Algebra").DeleteInsert) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").DeleteInsert) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").DeleteInsert) => VisitContext) | undefined; | ||
| } | undefined; | ||
| load?: { | ||
| visitor?: ((op: import("./Algebra").Load) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Load) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Load) => VisitContext) | undefined; | ||
| } | undefined; | ||
| clear?: { | ||
| visitor?: ((op: import("./Algebra").Clear) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Clear) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Clear) => VisitContext) | undefined; | ||
| } | undefined; | ||
| create?: { | ||
| visitor?: ((op: import("./Algebra").Create) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Create) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Create) => VisitContext) | undefined; | ||
| } | undefined; | ||
| drop?: { | ||
| visitor?: ((op: import("./Algebra").Drop) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Drop) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Drop) => VisitContext) | undefined; | ||
| } | undefined; | ||
| add?: { | ||
| visitor?: ((op: import("./Algebra").Add) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Add) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Add) => VisitContext) | undefined; | ||
| } | undefined; | ||
| move?: { | ||
| visitor?: ((op: import("./Algebra").Move) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Move) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Move) => VisitContext) | undefined; | ||
| } | undefined; | ||
| copy?: { | ||
| visitor?: ((op: import("./Algebra").Copy) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Copy) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Copy) => VisitContext) | undefined; | ||
| } | undefined; | ||
| path?: { | ||
| visitor?: ((op: import("./Algebra").Path) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Path) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Path) => VisitContext) | undefined; | ||
| } | undefined; | ||
| alt?: { | ||
| visitor?: ((op: import("./Algebra").Alt) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Alt) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Alt) => VisitContext) | undefined; | ||
| } | undefined; | ||
| inv?: { | ||
| visitor?: ((op: import("./Algebra").Inv) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Inv) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Inv) => VisitContext) | undefined; | ||
| } | undefined; | ||
| link?: { | ||
| visitor?: ((op: import("./Algebra").Link) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Link) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Link) => VisitContext) | undefined; | ||
| } | undefined; | ||
| OneOrMorePath?: { | ||
| visitor?: ((op: import("./Algebra").OneOrMorePath) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OneOrMorePath) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OneOrMorePath) => VisitContext) | undefined; | ||
| } | undefined; | ||
| seq?: { | ||
| visitor?: ((op: import("./Algebra").Seq) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Seq) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Seq) => VisitContext) | undefined; | ||
| } | undefined; | ||
| nps?: { | ||
| visitor?: ((op: import("./Algebra").Nps) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Nps) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Nps) => VisitContext) | undefined; | ||
| } | undefined; | ||
| ZeroOrMorePath?: { | ||
| visitor?: ((op: import("./Algebra").ZeroOrMorePath) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ZeroOrMorePath) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ZeroOrMorePath) => VisitContext) | undefined; | ||
| } | undefined; | ||
| ZeroOrOnePath?: { | ||
| visitor?: ((op: import("./Algebra").ZeroOrOnePath) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ZeroOrOnePath) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ZeroOrOnePath) => VisitContext) | undefined; | ||
| } | undefined; | ||
| }) => void; | ||
| /** | ||
| * Visits an object and it's descendants, similar to {@link visitOperation}, | ||
| * but also allowing you to target subTypes. e.g.: | ||
| * e.g.: | ||
| * ```ts | ||
| * visitOperationSub({ | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.DISTINCT, | ||
| * subType: 'special', | ||
| * }, | ||
| * }, { | ||
| * [Algebra.Types.DISTINCT]: { | ||
| * visitor: () => console.log('1'), | ||
| * preVisitor: () => { | ||
| * console.log('2'); | ||
| * return {}; | ||
| * }, | ||
| * }, | ||
| * }, { | ||
| * [Algebra.Types.DISTINCT]: { special: { | ||
| * visitor: () => console.log('3'), | ||
| * }}, | ||
| * }); | ||
| * ``` | ||
| * Will call the preVisitor on the outer distinct, then the visitor of the special distinct, | ||
| * followed by the visiting the outer distinct, printing '231'. | ||
| * The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse. | ||
| * @param startObject the object from which we will start visiting, | ||
| * potentially visiting its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and visitor. | ||
| * The preVisitor allows you to provide {@link VisitContext} for the current object, | ||
| * altering how it will be visited. | ||
| * The visitor allows you to visit the object from deepest to the outermost object. | ||
| * This is useful if you for example want to manipulate the objects you visit during your visits, | ||
| * similar to {@link mapOperation}. | ||
| * @param nodeSpecificCallBacks Same as nodeCallBacks but using an additional level of indirection to | ||
| * indicate the subType. | ||
| */ | ||
| export declare const visitOperationSub: (startObject: object, nodeCallBacks: { | ||
| ask?: { | ||
| visitor?: ((op: import("./Algebra").Ask) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Ask) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Ask) => VisitContext) | undefined; | ||
| } | undefined; | ||
| bgp?: { | ||
| visitor?: ((op: import("./Algebra").Bgp) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Bgp) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Bgp) => VisitContext) | undefined; | ||
| } | undefined; | ||
| construct?: { | ||
| visitor?: ((op: import("./Algebra").Construct) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Construct) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Construct) => VisitContext) | undefined; | ||
| } | undefined; | ||
| describe?: { | ||
| visitor?: ((op: import("./Algebra").Describe) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Describe) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Describe) => VisitContext) | undefined; | ||
| } | undefined; | ||
| distinct?: { | ||
| visitor?: ((op: import("./Algebra").Distinct) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Distinct) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Distinct) => VisitContext) | undefined; | ||
| } | undefined; | ||
| expression?: { | ||
| visitor?: ((op: import("./Algebra").KnownExpression) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").KnownExpression) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").KnownExpression) => VisitContext) | undefined; | ||
| } | undefined; | ||
| extend?: { | ||
| visitor?: ((op: import("./Algebra").Extend) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Extend) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Extend) => VisitContext) | undefined; | ||
| } | undefined; | ||
| filter?: { | ||
| visitor?: ((op: import("./Algebra").Filter) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Filter) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Filter) => VisitContext) | undefined; | ||
| } | undefined; | ||
| from?: { | ||
| visitor?: ((op: import("./Algebra").From) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").From) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").From) => VisitContext) | undefined; | ||
| } | undefined; | ||
| graph?: { | ||
| visitor?: ((op: import("./Algebra").Graph) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Graph) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Graph) => VisitContext) | undefined; | ||
| } | undefined; | ||
@@ -688,123 +960,123 @@ group?: { | ||
| aggregates: import("./Algebra").BoundAggregate[]; | ||
| }>) => import("@traqula/core").VisitContext) | undefined; | ||
| }>) => VisitContext) | undefined; | ||
| } | undefined; | ||
| join?: { | ||
| visitor?: ((op: import("./Algebra").Join) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Join) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Join) => VisitContext) | undefined; | ||
| } | undefined; | ||
| leftjoin?: { | ||
| visitor?: ((op: import("./Algebra").LeftJoin) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").LeftJoin) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").LeftJoin) => VisitContext) | undefined; | ||
| } | undefined; | ||
| minus?: { | ||
| visitor?: ((op: import("./Algebra").Minus) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Minus) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Minus) => VisitContext) | undefined; | ||
| } | undefined; | ||
| nop?: { | ||
| visitor?: ((op: import("./Algebra").Nop) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Nop) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Nop) => VisitContext) | undefined; | ||
| } | undefined; | ||
| orderby?: { | ||
| visitor?: ((op: import("./Algebra").OrderBy) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OrderBy) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OrderBy) => VisitContext) | undefined; | ||
| } | undefined; | ||
| pattern?: { | ||
| visitor?: ((op: import("./Algebra").Pattern) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Pattern) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Pattern) => VisitContext) | undefined; | ||
| } | undefined; | ||
| project?: { | ||
| visitor?: ((op: import("./Algebra").Project) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Project) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Project) => VisitContext) | undefined; | ||
| } | undefined; | ||
| reduced?: { | ||
| visitor?: ((op: import("./Algebra").Reduced) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Reduced) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Reduced) => VisitContext) | undefined; | ||
| } | undefined; | ||
| service?: { | ||
| visitor?: ((op: import("./Algebra").Service) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Service) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Service) => VisitContext) | undefined; | ||
| } | undefined; | ||
| slice?: { | ||
| visitor?: ((op: import("./Algebra").Slice) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Slice) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Slice) => VisitContext) | undefined; | ||
| } | undefined; | ||
| union?: { | ||
| visitor?: ((op: import("./Algebra").Union) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Union) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Union) => VisitContext) | undefined; | ||
| } | undefined; | ||
| values?: { | ||
| visitor?: ((op: import("./Algebra").Values) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Values) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Values) => VisitContext) | undefined; | ||
| } | undefined; | ||
| compositeupdate?: { | ||
| visitor?: ((op: import("./Algebra").CompositeUpdate) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").CompositeUpdate) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").CompositeUpdate) => VisitContext) | undefined; | ||
| } | undefined; | ||
| deleteinsert?: { | ||
| visitor?: ((op: import("./Algebra").DeleteInsert) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").DeleteInsert) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").DeleteInsert) => VisitContext) | undefined; | ||
| } | undefined; | ||
| load?: { | ||
| visitor?: ((op: import("./Algebra").Load) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Load) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Load) => VisitContext) | undefined; | ||
| } | undefined; | ||
| clear?: { | ||
| visitor?: ((op: import("./Algebra").Clear) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Clear) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Clear) => VisitContext) | undefined; | ||
| } | undefined; | ||
| create?: { | ||
| visitor?: ((op: import("./Algebra").Create) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Create) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Create) => VisitContext) | undefined; | ||
| } | undefined; | ||
| drop?: { | ||
| visitor?: ((op: import("./Algebra").Drop) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Drop) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Drop) => VisitContext) | undefined; | ||
| } | undefined; | ||
| add?: { | ||
| visitor?: ((op: import("./Algebra").Add) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Add) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Add) => VisitContext) | undefined; | ||
| } | undefined; | ||
| move?: { | ||
| visitor?: ((op: import("./Algebra").Move) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Move) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Move) => VisitContext) | undefined; | ||
| } | undefined; | ||
| copy?: { | ||
| visitor?: ((op: import("./Algebra").Copy) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Copy) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Copy) => VisitContext) | undefined; | ||
| } | undefined; | ||
| path?: { | ||
| visitor?: ((op: import("./Algebra").Path) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Path) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Path) => VisitContext) | undefined; | ||
| } | undefined; | ||
| alt?: { | ||
| visitor?: ((op: import("./Algebra").Alt) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Alt) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Alt) => VisitContext) | undefined; | ||
| } | undefined; | ||
| inv?: { | ||
| visitor?: ((op: import("./Algebra").Inv) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Inv) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Inv) => VisitContext) | undefined; | ||
| } | undefined; | ||
| link?: { | ||
| visitor?: ((op: import("./Algebra").Link) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Link) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Link) => VisitContext) | undefined; | ||
| } | undefined; | ||
| OneOrMorePath?: { | ||
| visitor?: ((op: import("./Algebra").OneOrMorePath) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OneOrMorePath) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OneOrMorePath) => VisitContext) | undefined; | ||
| } | undefined; | ||
| seq?: { | ||
| visitor?: ((op: import("./Algebra").Seq) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Seq) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Seq) => VisitContext) | undefined; | ||
| } | undefined; | ||
| nps?: { | ||
| visitor?: ((op: import("./Algebra").Nps) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Nps) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").Nps) => VisitContext) | undefined; | ||
| } | undefined; | ||
| ZeroOrMorePath?: { | ||
| visitor?: ((op: import("./Algebra").ZeroOrMorePath) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ZeroOrMorePath) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ZeroOrMorePath) => VisitContext) | undefined; | ||
| } | undefined; | ||
| ZeroOrOnePath?: { | ||
| visitor?: ((op: import("./Algebra").ZeroOrOnePath) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ZeroOrOnePath) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ZeroOrOnePath) => VisitContext) | undefined; | ||
| } | undefined; | ||
@@ -820,23 +1092,23 @@ }, nodeSpecificCallBacks: { | ||
| visitor?: ((op: import("./Algebra").BoundAggregate | import("./Algebra").AggregateExpression | import("./Algebra").GroupConcatExpression) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").BoundAggregate | import("./Algebra").AggregateExpression | import("./Algebra").GroupConcatExpression) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").BoundAggregate | import("./Algebra").AggregateExpression | import("./Algebra").GroupConcatExpression) => VisitContext) | undefined; | ||
| } | undefined; | ||
| existence?: { | ||
| visitor?: ((op: import("./Algebra").ExistenceExpression) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ExistenceExpression) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").ExistenceExpression) => VisitContext) | undefined; | ||
| } | undefined; | ||
| named?: { | ||
| visitor?: ((op: import("./Algebra").NamedExpression) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").NamedExpression) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").NamedExpression) => VisitContext) | undefined; | ||
| } | undefined; | ||
| operator?: { | ||
| visitor?: ((op: import("./Algebra").OperatorExpression) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OperatorExpression) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").OperatorExpression) => VisitContext) | undefined; | ||
| } | undefined; | ||
| term?: { | ||
| visitor?: ((op: import("./Algebra").TermExpression) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").TermExpression) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").TermExpression) => VisitContext) | undefined; | ||
| } | undefined; | ||
| wildcard?: { | ||
| visitor?: ((op: import("./Algebra").WildcardExpression) => void) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").WildcardExpression) => import("@traqula/core").VisitContext) | undefined; | ||
| preVisitor?: ((op: import("./Algebra").WildcardExpression) => VisitContext) | undefined; | ||
| } | undefined; | ||
@@ -880,3 +1152,11 @@ } | undefined; | ||
| }) => void; | ||
| /** | ||
| * Detects all in-scope variables. | ||
| * In practice this means iterating through the entire algebra tree, finding all variables, | ||
| * and stopping when a project function is found. | ||
| * @param {Operation} op Input algebra tree. | ||
| * @param visitor the visitor to be used to traverse the various nodes. | ||
| * Allows you to provide a visitor with different default preVisitor cotexts. | ||
| * @returns {RDF.Variable[]} List of unique in-scope variables. | ||
| */ | ||
| export declare const inScopeVariables: typeof algebraUtils.inScopeVariables; | ||
| export {}; |
+296
-16
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.inScopeVariables = exports.visitOperationSub = exports.visitOperation = exports.mapOperationSubStrict = exports.mapOperationSub = exports.mapOperationStrict = exports.mapOperation = exports.isKnownSubType = exports.isKnownOperation = exports.objectify = exports.resolveIRI = void 0; | ||
| exports.inScopeVariables = exports.visitOperationSub = exports.visitOperation = exports.mapOperationSub = exports.mapOperationSubStrict = exports.mapOperation = exports.mapOperationStrict = exports.transformer = exports.objectify = exports.resolveIRI = void 0; | ||
| exports.isKnownOperation = isKnownOperation; | ||
| exports.isKnownSubType = isKnownSubType; | ||
| const algebra_transformations_1_2_1 = require("@traqula/algebra-transformations-1-2"); | ||
@@ -12,10 +14,12 @@ const core_1 = require("@traqula/core"); | ||
| * the type guard will conclude the operation contains all member Comunica expects from this operation-type and subtype. | ||
| * @param val | ||
| * @param type | ||
| * @param subType | ||
| * @param val the operation that should be type checked | ||
| * @param type the type we want to test against | ||
| * @param subType the potential subtype we want to test against | ||
| * - when provided and not matching, we do not fall back to just checking the type. | ||
| * @return a boolean indicating whether the type and subtype are equal to the expected type and subtype. | ||
| * Only checking the subtype when a string is provided. | ||
| */ | ||
| function isKnownOperation(val, type, subType) { | ||
| return val.type === type && val.subType === subType; | ||
| return val.type === type && (subType === undefined || val.subType === subType); | ||
| } | ||
| exports.isKnownOperation = isKnownOperation; | ||
| /** | ||
@@ -25,4 +29,5 @@ * Type guard that checks if an operation is of a certain subType known by Comunica. | ||
| * the type guard will conclude the operation contains all member Comunica expects from this operation-subtype | ||
| * @param val | ||
| * @param subType | ||
| * @param val the operation that should be type checked | ||
| * @param subType the subType we want to test against | ||
| * @return a boolean indicating whether the subType equals the expected subType | ||
| */ | ||
@@ -32,4 +37,3 @@ function isKnownSubType(val, subType) { | ||
| } | ||
| exports.isKnownSubType = isKnownSubType; | ||
| const transformer = new core_1.TransformerSubTyped({ | ||
| exports.transformer = new core_1.TransformerSubTyped({ | ||
| /** | ||
@@ -66,10 +70,286 @@ * Metadata often contains references to actors, | ||
| }); | ||
| exports.mapOperation = transformer.transformNode.bind(transformer); | ||
| exports.mapOperationStrict = transformer.transformNode.bind(transformer); | ||
| exports.mapOperationSub = transformer.transformNodeSpecific.bind(transformer); | ||
| exports.mapOperationSubStrict = transformer.transformNodeSpecific.bind(transformer); | ||
| exports.visitOperation = transformer.visitNode.bind(transformer); | ||
| exports.visitOperationSub = transformer.visitNodeSpecific.bind(transformer); | ||
| /** | ||
| * Transform a single operation, similar to {@link mapOperation}, but using stricter typings. | ||
| * e.g. wrapping a distinct around the outermost project: | ||
| * ```ts | ||
| * mapOperationStrict<'unsafe', Operation>({ | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, { | ||
| * [Algebra.Types.PROJECT]: { | ||
| * preVisitor: () => ({ continue: false }), | ||
| * transform: projection => algebraFactory.createDistinct(projection), | ||
| * }, | ||
| * }); | ||
| * const returns = { | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, | ||
| * }; | ||
| * ``` | ||
| * @param startObject the object from which we will start the transformation, | ||
| * potentially visiting and transforming its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and transformer. | ||
| * The preVisitor allows you to provide {@link TransformContext} for the current object, | ||
| * altering how it will be transformed. | ||
| * The transformer allows you to manipulate the copy of the current object, | ||
| * and expects you to return the value that should take the current objects place. | ||
| * @return the result of transforming the requested descendant operations (based on the preVisitor) | ||
| * using a transformer that works its way back up from the descendant to the startObject. | ||
| */ | ||
| exports.mapOperationStrict = exports.transformer.transformNode.bind(exports.transformer); | ||
| /** | ||
| * Transform a single operation. | ||
| * e.g. wrapping a distinct around the outermost project: | ||
| * ```ts | ||
| * mapOperation({ | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, { | ||
| * [Algebra.Types.PROJECT]: { | ||
| * preVisitor: () => ({ continue: false }), | ||
| * transform: projection => algebraFactory.createDistinct(projection), | ||
| * }, | ||
| * }); | ||
| * const returns = { | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, | ||
| * }; | ||
| * ``` | ||
| * @param startObject the object from which we will start the transformation, | ||
| * potentially visiting and transforming its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and transformer. | ||
| * The preVisitor allows you to provide {@link TransformContext} for the current object, | ||
| * altering how it will be transformed. | ||
| * The transformer allows you to manipulate the copy of the current object, | ||
| * and expects you to return the value that should take the current objects place. | ||
| * @return the result of transforming the requested descendant operations (based on the preVisitor) | ||
| * using a transformer that works its way back up from the descendant to the startObject. | ||
| */ | ||
| exports.mapOperation = exports.mapOperationStrict; | ||
| /** | ||
| * Transform a single operation, similar to {@link mapOperationSub}, but using stricter typings. | ||
| * e.g. wrapping a distinct around the all project operations not contained in an aggregate expression | ||
| * (invalid algebra anyway): | ||
| * ```ts | ||
| * mapOperationSubStrict<'unsafe', Operation>({ | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ | ||
| * type: Algebra.Types.EXPRESSION, | ||
| * subType: Algebra.ExpressionTypes.AGGREGATE, | ||
| * input: { type: Algebra.Types.PROJECT }, | ||
| * }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, { [Algebra.Types.PROJECT]: { | ||
| * transform: projection => algebraFactory.createDistinct(projection), | ||
| * }}, { [Algebra.Types.EXPRESSION]: { [Algebra.ExpressionTypes.AGGREGATE]: { | ||
| * preVisitor: () => ({ continue: false }), | ||
| * }}}); | ||
| * const returns = { | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ | ||
| * type: Algebra.Types.EXPRESSION, | ||
| * subType: Algebra.ExpressionTypes.AGGREGATE, | ||
| * input: { type: Algebra.Types.PROJECT }, | ||
| * }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, | ||
| * }; | ||
| * ``` | ||
| * @param startObject the object from which we will start the transformation, | ||
| * potentially visiting and transforming its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and transformer. | ||
| * The preVisitor allows you to provide {@link TransformContext} for the current object, | ||
| * altering how it will be transformed. | ||
| * The transformer allows you to manipulate the copy of the current object, | ||
| * and expects you to return the value that should take the current objects place. | ||
| * @param nodeSpecificCallBacks Same as nodeCallBacks but using an additional level of indirection to | ||
| * indicate the subType. | ||
| * @return the result of transforming the requested descendant operations (based on the preVisitor) | ||
| * using a transformer that works its way back up from the descendant to the startObject. | ||
| */ | ||
| exports.mapOperationSubStrict = exports.transformer.transformNodeSpecific.bind(exports.transformer); | ||
| /** | ||
| * Transform a single operation, similar to {@link mapOperation}, but also allowing you to target subTypes. | ||
| * e.g. wrapping a distinct around the all project operations not contained in an aggregate expression | ||
| * (invalid algebra anyway): | ||
| * ```ts | ||
| * mapOperationSub({ | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ | ||
| * type: Algebra.Types.EXPRESSION, | ||
| * subType: Algebra.ExpressionTypes.AGGREGATE, | ||
| * input: { type: Algebra.Types.PROJECT }, | ||
| * }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, { [Algebra.Types.PROJECT]: { | ||
| * transform: projection => algebraFactory.createDistinct(projection), | ||
| * }}, { [Algebra.Types.EXPRESSION]: { [Algebra.ExpressionTypes.AGGREGATE]: { | ||
| * preVisitor: () => ({ continue: false }), | ||
| * }}}); | ||
| * const returns = { | ||
| * type: Algebra.Types.SLICE, | ||
| * input: { | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { | ||
| * type: Algebra.Types.JOIN, | ||
| * input: [{ | ||
| * type: Algebra.Types.EXPRESSION, | ||
| * subType: Algebra.ExpressionTypes.AGGREGATE, | ||
| * input: { type: Algebra.Types.PROJECT }, | ||
| * }, { type: Algebra.Types.BGP }], | ||
| * }, | ||
| * }, | ||
| * }, | ||
| * }; | ||
| * ``` | ||
| * @param startObject the object from which we will start the transformation, | ||
| * potentially visiting and transforming its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and transformer. | ||
| * The preVisitor allows you to provide {@link TransformContext} for the current object, | ||
| * altering how it will be transformed. | ||
| * The transformer allows you to manipulate the copy of the current object, | ||
| * and expects you to return the value that should take the current objects place. | ||
| * @param nodeSpecificCallBacks Same as nodeCallBacks but using an additional level of indirection to | ||
| * indicate the subType. | ||
| * @return the result of transforming the requested descendant operations (based on the preVisitor) | ||
| * using a transformer that works its way back up from the descendant to the startObject. | ||
| */ | ||
| exports.mapOperationSub = exports.mapOperationSubStrict; | ||
| /** | ||
| * Similar to {@link mapOperation}, but only visiting instead of copying and transforming explicitly. | ||
| * e.g.: | ||
| * ```ts | ||
| * visitOperation({ | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.PROJECT, | ||
| * input: { type: Algebra.Types.DISTINCT }, | ||
| * }, | ||
| * }, { | ||
| * [Algebra.Types.DISTINCT]: { visitor: () => console.log('1') }, | ||
| * [Algebra.Types.PROJECT]: { | ||
| * preVisitor: () => ({ continue: false }), | ||
| * visitor: () => console.log('2'), | ||
| * }, | ||
| * }); | ||
| * ``` | ||
| * Will first call the preVisitor on the project and notice it should not iterate on its descendants. | ||
| * It then visits the project, and the outermost distinct, printing '21'. | ||
| * The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse. | ||
| * @param startObject the object from which we will start visiting, | ||
| * potentially visiting its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and visitor. | ||
| * The preVisitor allows you to provide {@link VisitContext} for the current object, | ||
| * altering how it will be visited. | ||
| * The visitor allows you to visit the object from deepest to the outermost object. | ||
| * This is useful if you for example want to manipulate the objects you visit during your visits, | ||
| * similar to {@link mapOperation}. | ||
| */ | ||
| exports.visitOperation = exports.transformer.visitNode.bind(exports.transformer); | ||
| /** | ||
| * Visits an object and it's descendants, similar to {@link visitOperation}, | ||
| * but also allowing you to target subTypes. e.g.: | ||
| * e.g.: | ||
| * ```ts | ||
| * visitOperationSub({ | ||
| * type: Algebra.Types.DISTINCT, | ||
| * input: { | ||
| * type: Algebra.Types.DISTINCT, | ||
| * subType: 'special', | ||
| * }, | ||
| * }, { | ||
| * [Algebra.Types.DISTINCT]: { | ||
| * visitor: () => console.log('1'), | ||
| * preVisitor: () => { | ||
| * console.log('2'); | ||
| * return {}; | ||
| * }, | ||
| * }, | ||
| * }, { | ||
| * [Algebra.Types.DISTINCT]: { special: { | ||
| * visitor: () => console.log('3'), | ||
| * }}, | ||
| * }); | ||
| * ``` | ||
| * Will call the preVisitor on the outer distinct, then the visitor of the special distinct, | ||
| * followed by the visiting the outer distinct, printing '231'. | ||
| * The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse. | ||
| * @param startObject the object from which we will start visiting, | ||
| * potentially visiting its descendants along the way. | ||
| * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally | ||
| * containing preVisitor and visitor. | ||
| * The preVisitor allows you to provide {@link VisitContext} for the current object, | ||
| * altering how it will be visited. | ||
| * The visitor allows you to visit the object from deepest to the outermost object. | ||
| * This is useful if you for example want to manipulate the objects you visit during your visits, | ||
| * similar to {@link mapOperation}. | ||
| * @param nodeSpecificCallBacks Same as nodeCallBacks but using an additional level of indirection to | ||
| * indicate the subType. | ||
| */ | ||
| exports.visitOperationSub = exports.transformer.visitNodeSpecific.bind(exports.transformer); | ||
| /** | ||
| * Detects all in-scope variables. | ||
| * In practice this means iterating through the entire algebra tree, finding all variables, | ||
| * and stopping when a project function is found. | ||
| * @param {Operation} op Input algebra tree. | ||
| * @param visitor the visitor to be used to traverse the various nodes. | ||
| * Allows you to provide a visitor with different default preVisitor cotexts. | ||
| * @returns {RDF.Variable[]} List of unique in-scope variables. | ||
| */ | ||
| const inScopeVariables = (op, visitor = exports.visitOperation) => algebra_transformations_1_2_1.algebraUtils.inScopeVariables(op, visitor); | ||
| exports.inScopeVariables = inScopeVariables; | ||
| //# sourceMappingURL=utils.js.map |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":"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","sourcesContent":["import type { Algebra as TraqulaAlgebra } from '@traqula/algebra-transformations-1-2';\nimport { algebraUtils, Types } from '@traqula/algebra-transformations-1-2';\nimport { TransformerSubTyped } from '@traqula/core';\nimport type { KnownOperation, Operation } from './Algebra';\n\nexport const resolveIRI = algebraUtils.resolveIRI;\nexport const objectify = algebraUtils.objectify;\n\n/**\n * Type guard that checks if an operation is of a certain type and subType known by Comunica.\n * In case the type and subtype matches one known by Comunica,\n * the type guard will conclude the operation contains all member Comunica expects from this operation-type and subtype.\n * @param val\n * @param type\n * @param subType\n */\nexport function isKnownOperation<\n Type extends KnownOperation['type'],\n SubType extends Extract<KnownOperation, { type: Type }>['subType'] | undefined = undefined,\n>(val: Operation, type: Type, subType?: SubType): val is\n SubType extends undefined ? (\n Extract<KnownOperation, { type: Type }> extends object ?\n Extract<KnownOperation, { type: Type }> : { type: Type }\n ) : Extract<KnownOperation, { type: Type; subType: SubType }> extends object ?\n Extract<KnownOperation, { type: Type; subType: SubType }> : { type: Type; subType: SubType } {\n return val.type === type && val.subType === subType;\n}\n\n/**\n * Type guard that checks if an operation is of a certain subType known by Comunica.\n * In case the subtype matches one known by Comunica,\n * the type guard will conclude the operation contains all member Comunica expects from this operation-subtype\n * @param val\n * @param subType\n */\nexport function isKnownSubType<\n SubType extends KnownOperation['subType'],\n Obj extends Operation,\n>(val: Obj, subType: SubType):\n val is Extract<KnownOperation, { type: Obj['type']; subType: SubType }> extends object ?\n Obj & Extract<KnownOperation, { type: Obj['type']; subType: SubType }> : Obj & { subType: SubType } {\n return val.subType === subType;\n}\n\n// ----------------------- manipulators --------------------\n\ntype _NeedRefForReusabilityWithoutExplicitTypeDefinition = TraqulaAlgebra.Operation;\nconst transformer = new TransformerSubTyped<KnownOperation>({\n /**\n * Metadata often contains references to actors,\n * the transformer should not copy these actors, nor should it traverse the actors when visitingOperations.\n * (since there can be cycles involved).\n * It should however still make a shallowCopy from the metadata object, but not map over it.\n */\n shallowKeys: new Set([ 'metadata' ]),\n ignoreKeys: new Set([ 'metadata' ]),\n}, {\n // Optimization that causes search tree pruning\n [Types.PATTERN]: { ignoreKeys: new Set([ 'subject', 'predicate', 'object', 'graph', 'metadata' ]) },\n [Types.EXPRESSION]: { ignoreKeys: new Set([ 'name', 'term', 'wildcard', 'variable', 'metadata' ]) },\n [Types.DESCRIBE]: { ignoreKeys: new Set([ 'terms', 'metadata' ]) },\n [Types.EXTEND]: { ignoreKeys: new Set([ 'variable', 'metadata' ]) },\n [Types.FROM]: { ignoreKeys: new Set([ 'default', 'named', 'metadata' ]) },\n [Types.GRAPH]: { ignoreKeys: new Set([ 'name', 'metadata' ]) },\n [Types.GROUP]: { ignoreKeys: new Set([ 'variables', 'metadata' ]) },\n [Types.LINK]: { ignoreKeys: new Set([ 'iri', 'metadata' ]) },\n [Types.NPS]: { ignoreKeys: new Set([ 'iris', 'metadata' ]) },\n [Types.PATH]: { ignoreKeys: new Set([ 'subject', 'object', 'graph', 'metadata' ]) },\n [Types.PROJECT]: { ignoreKeys: new Set([ 'variables', 'metadata' ]) },\n [Types.SERVICE]: { ignoreKeys: new Set([ 'name', 'metadata' ]) },\n [Types.VALUES]: { ignoreKeys: new Set([ 'variables', 'bindings', 'metadata' ]) },\n [Types.LOAD]: { ignoreKeys: new Set([ 'source', 'destination', 'metadata' ]) },\n [Types.CLEAR]: { ignoreKeys: new Set([ 'source', 'metadata' ]) },\n [Types.CREATE]: { ignoreKeys: new Set([ 'source', 'metadata' ]) },\n [Types.DROP]: { ignoreKeys: new Set([ 'source', 'metadata' ]) },\n [Types.ADD]: { ignoreKeys: new Set([ 'source', 'destination', 'metadata' ]) },\n [Types.MOVE]: { ignoreKeys: new Set([ 'source', 'destination', 'metadata' ]) },\n [Types.COPY]: { ignoreKeys: new Set([ 'source', 'destination', 'metadata' ]) },\n});\n\nexport const mapOperation: (typeof transformer.transformNode<'unsafe', Operation>) = <any>\n transformer.transformNode.bind(transformer);\n\nexport const mapOperationStrict = transformer.transformNode.bind(transformer);\n\nexport const mapOperationSub: (typeof transformer.transformNodeSpecific<'unsafe', Operation>) = <any>\n transformer.transformNodeSpecific.bind(transformer);\nexport const mapOperationSubStrict = transformer.transformNodeSpecific.bind(transformer);\n\nexport const visitOperation = transformer.visitNode.bind(transformer);\nexport const visitOperationSub = transformer.visitNodeSpecific.bind(transformer);\n\nexport const inScopeVariables: typeof algebraUtils.inScopeVariables =\n (op, visitor = <typeof algebraUtils.visitOperation> visitOperation) =>\n algebraUtils.inScopeVariables(op, visitor);\n"]} | ||
| {"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":"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","sourcesContent":["import type * as RDF from '@rdfjs/types';\nimport type { Algebra as TraqulaAlgebra } from '@traqula/algebra-transformations-1-2';\nimport { algebraUtils, Types } from '@traqula/algebra-transformations-1-2';\n\n// eslint-disable-next-line unused-imports/no-unused-imports,unused-imports/no-unused-imports-ts\nimport type { TransformContext, VisitContext } from '@traqula/core';\nimport { TransformerSubTyped } from '@traqula/core';\nimport type { KnownOperation, Operation } from './Algebra';\n\nexport const resolveIRI = algebraUtils.resolveIRI;\nexport const objectify = algebraUtils.objectify;\n\n/**\n * Type guard that checks if an operation is of a certain type and subType known by Comunica.\n * In case the type and subtype matches one known by Comunica,\n * the type guard will conclude the operation contains all member Comunica expects from this operation-type and subtype.\n * @param val the operation that should be type checked\n * @param type the type we want to test against\n * @param subType the potential subtype we want to test against\n * - when provided and not matching, we do not fall back to just checking the type.\n * @return a boolean indicating whether the type and subtype are equal to the expected type and subtype.\n * Only checking the subtype when a string is provided.\n */\nexport function isKnownOperation<\n Type extends KnownOperation['type'],\n SubType extends Extract<KnownOperation, { type: Type }>['subType'] | undefined = undefined,\n>(val: Operation, type: Type, subType?: SubType): val is\n SubType extends undefined ? (\n Extract<KnownOperation, { type: Type }> extends object ?\n Extract<KnownOperation, { type: Type }> : { type: Type }\n ) : Extract<KnownOperation, { type: Type; subType: SubType }> extends object ?\n Extract<KnownOperation, { type: Type; subType: SubType }> : { type: Type; subType: SubType } {\n return val.type === type && (subType === undefined || val.subType === subType);\n}\n\n/**\n * Type guard that checks if an operation is of a certain subType known by Comunica.\n * In case the subtype matches one known by Comunica,\n * the type guard will conclude the operation contains all member Comunica expects from this operation-subtype\n * @param val the operation that should be type checked\n * @param subType the subType we want to test against\n * @return a boolean indicating whether the subType equals the expected subType\n */\nexport function isKnownSubType<\n SubType extends KnownOperation['subType'],\n Obj extends Operation,\n>(val: Obj, subType: SubType):\n val is Extract<KnownOperation, { type: Obj['type']; subType: SubType }> extends object ?\n Obj & Extract<KnownOperation, { type: Obj['type']; subType: SubType }> : Obj & { subType: SubType } {\n return val.subType === subType;\n}\n\n// ----------------------- manipulators --------------------\n\ntype _NeedRefForReusabilityWithoutExplicitTypeDefinition = TraqulaAlgebra.Operation;\nexport const transformer = new TransformerSubTyped<KnownOperation>({\n /**\n * Metadata often contains references to actors,\n * the transformer should not copy these actors, nor should it traverse the actors when visitingOperations.\n * (since there can be cycles involved).\n * It should however still make a shallowCopy from the metadata object, but not map over it.\n */\n shallowKeys: new Set([ 'metadata' ]),\n ignoreKeys: new Set([ 'metadata' ]),\n}, {\n // Optimization that causes search tree pruning\n [Types.PATTERN]: { ignoreKeys: new Set([ 'subject', 'predicate', 'object', 'graph', 'metadata' ]) },\n [Types.EXPRESSION]: { ignoreKeys: new Set([ 'name', 'term', 'wildcard', 'variable', 'metadata' ]) },\n [Types.DESCRIBE]: { ignoreKeys: new Set([ 'terms', 'metadata' ]) },\n [Types.EXTEND]: { ignoreKeys: new Set([ 'variable', 'metadata' ]) },\n [Types.FROM]: { ignoreKeys: new Set([ 'default', 'named', 'metadata' ]) },\n [Types.GRAPH]: { ignoreKeys: new Set([ 'name', 'metadata' ]) },\n [Types.GROUP]: { ignoreKeys: new Set([ 'variables', 'metadata' ]) },\n [Types.LINK]: { ignoreKeys: new Set([ 'iri', 'metadata' ]) },\n [Types.NPS]: { ignoreKeys: new Set([ 'iris', 'metadata' ]) },\n [Types.PATH]: { ignoreKeys: new Set([ 'subject', 'object', 'graph', 'metadata' ]) },\n [Types.PROJECT]: { ignoreKeys: new Set([ 'variables', 'metadata' ]) },\n [Types.SERVICE]: { ignoreKeys: new Set([ 'name', 'metadata' ]) },\n [Types.VALUES]: { ignoreKeys: new Set([ 'variables', 'bindings', 'metadata' ]) },\n [Types.LOAD]: { ignoreKeys: new Set([ 'source', 'destination', 'metadata' ]) },\n [Types.CLEAR]: { ignoreKeys: new Set([ 'source', 'metadata' ]) },\n [Types.CREATE]: { ignoreKeys: new Set([ 'source', 'metadata' ]) },\n [Types.DROP]: { ignoreKeys: new Set([ 'source', 'metadata' ]) },\n [Types.ADD]: { ignoreKeys: new Set([ 'source', 'destination', 'metadata' ]) },\n [Types.MOVE]: { ignoreKeys: new Set([ 'source', 'destination', 'metadata' ]) },\n [Types.COPY]: { ignoreKeys: new Set([ 'source', 'destination', 'metadata' ]) },\n});\n\n/**\n * Transform a single operation, similar to {@link mapOperation}, but using stricter typings.\n * e.g. wrapping a distinct around the outermost project:\n * ```ts\n * mapOperationStrict<'unsafe', Operation>({\n * type: Algebra.Types.SLICE,\n * input: {\n * type: Algebra.Types.PROJECT,\n * input: {\n * type: Algebra.Types.JOIN,\n * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }],\n * },\n * },\n * }, {\n * [Algebra.Types.PROJECT]: {\n * preVisitor: () => ({ continue: false }),\n * transform: projection => algebraFactory.createDistinct(projection),\n * },\n * });\n * const returns = {\n * type: Algebra.Types.SLICE,\n * input: {\n * type: Algebra.Types.DISTINCT,\n * input: {\n * type: Algebra.Types.PROJECT,\n * input: {\n * type: Algebra.Types.JOIN,\n * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }],\n * },\n * },\n * },\n * };\n * ```\n * @param startObject the object from which we will start the transformation,\n * potentially visiting and transforming its descendants along the way.\n * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally\n * containing preVisitor and transformer.\n * The preVisitor allows you to provide {@link TransformContext} for the current object,\n * altering how it will be transformed.\n * The transformer allows you to manipulate the copy of the current object,\n * and expects you to return the value that should take the current objects place.\n * @return the result of transforming the requested descendant operations (based on the preVisitor)\n * using a transformer that works its way back up from the descendant to the startObject.\n */\nexport const mapOperationStrict = transformer.transformNode.bind(transformer);\n\n/**\n * Transform a single operation.\n * e.g. wrapping a distinct around the outermost project:\n * ```ts\n * mapOperation({\n * type: Algebra.Types.SLICE,\n * input: {\n * type: Algebra.Types.PROJECT,\n * input: {\n * type: Algebra.Types.JOIN,\n * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }],\n * },\n * },\n * }, {\n * [Algebra.Types.PROJECT]: {\n * preVisitor: () => ({ continue: false }),\n * transform: projection => algebraFactory.createDistinct(projection),\n * },\n * });\n * const returns = {\n * type: Algebra.Types.SLICE,\n * input: {\n * type: Algebra.Types.DISTINCT,\n * input: {\n * type: Algebra.Types.PROJECT,\n * input: {\n * type: Algebra.Types.JOIN,\n * input: [{ type: Algebra.Types.PROJECT }, { type: Algebra.Types.BGP }],\n * },\n * },\n * },\n * };\n * ```\n * @param startObject the object from which we will start the transformation,\n * potentially visiting and transforming its descendants along the way.\n * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally\n * containing preVisitor and transformer.\n * The preVisitor allows you to provide {@link TransformContext} for the current object,\n * altering how it will be transformed.\n * The transformer allows you to manipulate the copy of the current object,\n * and expects you to return the value that should take the current objects place.\n * @return the result of transforming the requested descendant operations (based on the preVisitor)\n * using a transformer that works its way back up from the descendant to the startObject.\n */\nexport const mapOperation: (typeof mapOperationStrict<'unsafe', Operation>) = <any> mapOperationStrict;\n\n/**\n * Transform a single operation, similar to {@link mapOperationSub}, but using stricter typings.\n * e.g. wrapping a distinct around the all project operations not contained in an aggregate expression\n * (invalid algebra anyway):\n * ```ts\n * mapOperationSubStrict<'unsafe', Operation>({\n * type: Algebra.Types.SLICE,\n * input: {\n * type: Algebra.Types.PROJECT,\n * input: {\n * type: Algebra.Types.JOIN,\n * input: [{\n * type: Algebra.Types.EXPRESSION,\n * subType: Algebra.ExpressionTypes.AGGREGATE,\n * input: { type: Algebra.Types.PROJECT },\n * }, { type: Algebra.Types.BGP }],\n * },\n * },\n * }, { [Algebra.Types.PROJECT]: {\n * transform: projection => algebraFactory.createDistinct(projection),\n * }}, { [Algebra.Types.EXPRESSION]: { [Algebra.ExpressionTypes.AGGREGATE]: {\n * preVisitor: () => ({ continue: false }),\n * }}});\n * const returns = {\n * type: Algebra.Types.SLICE,\n * input: {\n * type: Algebra.Types.DISTINCT,\n * input: {\n * type: Algebra.Types.PROJECT,\n * input: {\n * type: Algebra.Types.JOIN,\n * input: [{\n * type: Algebra.Types.EXPRESSION,\n * subType: Algebra.ExpressionTypes.AGGREGATE,\n * input: { type: Algebra.Types.PROJECT },\n * }, { type: Algebra.Types.BGP }],\n * },\n * },\n * },\n * };\n * ```\n * @param startObject the object from which we will start the transformation,\n * potentially visiting and transforming its descendants along the way.\n * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally\n * containing preVisitor and transformer.\n * The preVisitor allows you to provide {@link TransformContext} for the current object,\n * altering how it will be transformed.\n * The transformer allows you to manipulate the copy of the current object,\n * and expects you to return the value that should take the current objects place.\n * @param nodeSpecificCallBacks Same as nodeCallBacks but using an additional level of indirection to\n * indicate the subType.\n * @return the result of transforming the requested descendant operations (based on the preVisitor)\n * using a transformer that works its way back up from the descendant to the startObject.\n */\nexport const mapOperationSubStrict = transformer.transformNodeSpecific.bind(transformer);\n\n/**\n * Transform a single operation, similar to {@link mapOperation}, but also allowing you to target subTypes.\n * e.g. wrapping a distinct around the all project operations not contained in an aggregate expression\n * (invalid algebra anyway):\n * ```ts\n * mapOperationSub({\n * type: Algebra.Types.SLICE,\n * input: {\n * type: Algebra.Types.PROJECT,\n * input: {\n * type: Algebra.Types.JOIN,\n * input: [{\n * type: Algebra.Types.EXPRESSION,\n * subType: Algebra.ExpressionTypes.AGGREGATE,\n * input: { type: Algebra.Types.PROJECT },\n * }, { type: Algebra.Types.BGP }],\n * },\n * },\n * }, { [Algebra.Types.PROJECT]: {\n * transform: projection => algebraFactory.createDistinct(projection),\n * }}, { [Algebra.Types.EXPRESSION]: { [Algebra.ExpressionTypes.AGGREGATE]: {\n * preVisitor: () => ({ continue: false }),\n * }}});\n * const returns = {\n * type: Algebra.Types.SLICE,\n * input: {\n * type: Algebra.Types.DISTINCT,\n * input: {\n * type: Algebra.Types.PROJECT,\n * input: {\n * type: Algebra.Types.JOIN,\n * input: [{\n * type: Algebra.Types.EXPRESSION,\n * subType: Algebra.ExpressionTypes.AGGREGATE,\n * input: { type: Algebra.Types.PROJECT },\n * }, { type: Algebra.Types.BGP }],\n * },\n * },\n * },\n * };\n * ```\n * @param startObject the object from which we will start the transformation,\n * potentially visiting and transforming its descendants along the way.\n * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally\n * containing preVisitor and transformer.\n * The preVisitor allows you to provide {@link TransformContext} for the current object,\n * altering how it will be transformed.\n * The transformer allows you to manipulate the copy of the current object,\n * and expects you to return the value that should take the current objects place.\n * @param nodeSpecificCallBacks Same as nodeCallBacks but using an additional level of indirection to\n * indicate the subType.\n * @return the result of transforming the requested descendant operations (based on the preVisitor)\n * using a transformer that works its way back up from the descendant to the startObject.\n */\nexport const mapOperationSub: (typeof mapOperationSubStrict<'unsafe', Operation>) = <any> mapOperationSubStrict;\n\n/**\n * Similar to {@link mapOperation}, but only visiting instead of copying and transforming explicitly.\n * e.g.:\n * ```ts\n * visitOperation({\n * type: Algebra.Types.DISTINCT,\n * input: {\n * type: Algebra.Types.PROJECT,\n * input: { type: Algebra.Types.DISTINCT },\n * },\n * }, {\n * [Algebra.Types.DISTINCT]: { visitor: () => console.log('1') },\n * [Algebra.Types.PROJECT]: {\n * preVisitor: () => ({ continue: false }),\n * visitor: () => console.log('2'),\n * },\n * });\n * ```\n * Will first call the preVisitor on the project and notice it should not iterate on its descendants.\n * It then visits the project, and the outermost distinct, printing '21'.\n * The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.\n * @param startObject the object from which we will start visiting,\n * potentially visiting its descendants along the way.\n * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally\n * containing preVisitor and visitor.\n * The preVisitor allows you to provide {@link VisitContext} for the current object,\n * altering how it will be visited.\n * The visitor allows you to visit the object from deepest to the outermost object.\n * This is useful if you for example want to manipulate the objects you visit during your visits,\n * similar to {@link mapOperation}.\n */\nexport const visitOperation = transformer.visitNode.bind(transformer);\n\n/**\n * Visits an object and it's descendants, similar to {@link visitOperation},\n * but also allowing you to target subTypes. e.g.:\n * e.g.:\n * ```ts\n * visitOperationSub({\n * type: Algebra.Types.DISTINCT,\n * input: {\n * type: Algebra.Types.DISTINCT,\n * subType: 'special',\n * },\n * }, {\n * [Algebra.Types.DISTINCT]: {\n * visitor: () => console.log('1'),\n * preVisitor: () => {\n * console.log('2');\n * return {};\n * },\n * },\n * }, {\n * [Algebra.Types.DISTINCT]: { special: {\n * visitor: () => console.log('3'),\n * }},\n * });\n * ```\n * Will call the preVisitor on the outer distinct, then the visitor of the special distinct,\n * followed by the visiting the outer distinct, printing '231'.\n * The pre-visitor visits starting from the root, going deeper, while the actual visitor goes in reverse.\n * @param startObject the object from which we will start visiting,\n * potentially visiting its descendants along the way.\n * @param nodeCallBacks a dictionary mapping the various operation types to objects optionally\n * containing preVisitor and visitor.\n * The preVisitor allows you to provide {@link VisitContext} for the current object,\n * altering how it will be visited.\n * The visitor allows you to visit the object from deepest to the outermost object.\n * This is useful if you for example want to manipulate the objects you visit during your visits,\n * similar to {@link mapOperation}.\n * @param nodeSpecificCallBacks Same as nodeCallBacks but using an additional level of indirection to\n * indicate the subType.\n */\nexport const visitOperationSub = transformer.visitNodeSpecific.bind(transformer);\n\n/**\n * Detects all in-scope variables.\n * In practice this means iterating through the entire algebra tree, finding all variables,\n * and stopping when a project function is found.\n * @param {Operation} op Input algebra tree.\n * @param visitor the visitor to be used to traverse the various nodes.\n * Allows you to provide a visitor with different default preVisitor cotexts.\n * @returns {RDF.Variable[]} List of unique in-scope variables.\n */\nexport const inScopeVariables: typeof algebraUtils.inScopeVariables =\n (op: Operation, visitor = <typeof algebraUtils.visitOperation>visitOperation): RDF.Variable[] =>\n algebraUtils.inScopeVariables(op, visitor);\n"]} |
+4
-4
| { | ||
| "name": "@comunica/utils-algebra", | ||
| "version": "4.4.2-alpha.49.0", | ||
| "version": "5.0.0", | ||
| "description": "Query algebra definitions and utilities", | ||
@@ -39,6 +39,6 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "@traqula/algebra-transformations-1-2": "^0.0.24", | ||
| "@traqula/core": "^0.0.24" | ||
| "@traqula/algebra-transformations-1-2": "^1.0.0", | ||
| "@traqula/core": "^1.0.0" | ||
| }, | ||
| "gitHead": "ef6f96cfd8faf7c37955bb7e0fe9f6fc6a994bdf" | ||
| "gitHead": "0b1756fdb9bef014133432489627c1bd71779bd0" | ||
| } |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
122310
45.91%1691
57.6%0
-100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated