🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@comunica/utils-algebra

Package Overview
Dependencies
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@comunica/utils-algebra - npm Package Compare versions

Comparing version
5.1.3
to
5.2.0
+8
lib/AlgebraFactory.d.ts
import type * as RDF from '@rdfjs/types';
import { AlgebraFactory as AlgebraFactoryBase } from '@traqula/algebra-transformations-1-2';
import type { QuadTermName } from 'rdf-terms';
import type { DistinctTerms, Nodes } from './Algebra';
export declare class AlgebraFactory extends AlgebraFactoryBase {
createNodes(graph: RDF.Term, variable: RDF.Variable): Nodes;
createDistinctTerms(variables: RDF.Variable[], terms: Record<string, QuadTermName>): DistinctTerms;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AlgebraFactory = void 0;
const algebra_transformations_1_2_1 = require("@traqula/algebra-transformations-1-2");
const TypesComunica_1 = require("./TypesComunica");
class AlgebraFactory extends algebra_transformations_1_2_1.AlgebraFactory {
createNodes(graph, variable) {
return {
type: TypesComunica_1.TypesComunica.NODES,
graph,
variable,
};
}
createDistinctTerms(variables, terms) {
return {
type: TypesComunica_1.TypesComunica.DISTINCT_TERMS,
variables,
terms,
};
}
}
exports.AlgebraFactory = AlgebraFactory;
//# sourceMappingURL=AlgebraFactory.js.map
{"version":3,"file":"AlgebraFactory.js","sourceRoot":"","sources":["AlgebraFactory.ts"],"names":[],"mappings":";;;AACA,sFAA4F;AAG5F,mDAAgD;AAEhD,MAAa,cAAe,SAAQ,4CAAkB;IAC7C,WAAW,CAAC,KAAe,EAAE,QAAsB;QACxD,OAAO;YACL,IAAI,EAAE,6BAAa,CAAC,KAAK;YACzB,KAAK;YACL,QAAQ;SACT,CAAC;IACJ,CAAC;IAEM,mBAAmB,CACxB,SAAyB,EACzB,KAAmC;QAEnC,OAAO;YACL,IAAI,EAAE,6BAAa,CAAC,cAAc;YAClC,SAAS;YACT,KAAK;SACN,CAAC;IACJ,CAAC;CACF;AAnBD,wCAmBC","sourcesContent":["import type * as RDF from '@rdfjs/types';\nimport { AlgebraFactory as AlgebraFactoryBase } from '@traqula/algebra-transformations-1-2';\nimport type { QuadTermName } from 'rdf-terms';\nimport type { DistinctTerms, Nodes } from './Algebra';\nimport { TypesComunica } from './TypesComunica';\n\nexport class AlgebraFactory extends AlgebraFactoryBase {\n public createNodes(graph: RDF.Term, variable: RDF.Variable): Nodes {\n return {\n type: TypesComunica.NODES,\n graph,\n variable,\n };\n }\n\n public createDistinctTerms(\n variables: RDF.Variable[],\n terms: Record<string, QuadTermName>,\n ): DistinctTerms {\n return {\n type: TypesComunica.DISTINCT_TERMS,\n variables,\n terms,\n };\n }\n}\n"]}
/**
* Algebra operations that are defined by Comunica for internal use, but are not part of the SPARQL spec.
*/
export declare enum TypesComunica {
NODES = "nodes",
DISTINCT_TERMS = "distinctterms"
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypesComunica = void 0;
/**
* Algebra operations that are defined by Comunica for internal use, but are not part of the SPARQL spec.
*/
var TypesComunica;
(function (TypesComunica) {
TypesComunica["NODES"] = "nodes";
TypesComunica["DISTINCT_TERMS"] = "distinctterms";
})(TypesComunica || (exports.TypesComunica = TypesComunica = {}));
//# sourceMappingURL=TypesComunica.js.map
{"version":3,"file":"TypesComunica.js","sourceRoot":"","sources":["TypesComunica.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,gCAAe,CAAA;IACf,iDAAgC,CAAA;AAClC,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB","sourcesContent":["/**\n * Algebra operations that are defined by Comunica for internal use, but are not part of the SPARQL spec.\n */\nexport enum TypesComunica {\n NODES = 'nodes',\n DISTINCT_TERMS = 'distinctterms',\n}\n"]}
+25
-1

@@ -5,4 +5,7 @@ /**

*/
import type * as RDF from '@rdfjs/types';
import type { Algebra } from '@traqula/algebra-transformations-1-2';
import type { Patch } from '@traqula/core';
import type { QuadTermName } from 'rdf-terms';
import type { TypesComunica } from './TypesComunica';
export { Types, ExpressionTypes } from '@traqula/algebra-transformations-1-2';

@@ -44,3 +47,3 @@ type withMeta = {

};
export type KnownOperation = Ask | KnownExpression | Bgp | Construct | Describe | Distinct | Extend | From | Filter | Graph | Group | Join | LeftJoin | Minus | Nop | OrderBy | Path | Pattern | Project | KnownPropertyPathSymbol | Reduced | Service | Slice | Union | Values | KnownUpdate | CompositeUpdate;
export type KnownOperation = Ask | KnownExpression | Bgp | Construct | Describe | Distinct | Extend | From | Filter | Graph | Group | Join | LeftJoin | Minus | Nop | OrderBy | Path | Pattern | Project | KnownPropertyPathSymbol | Reduced | Service | Slice | Union | Values | KnownUpdate | CompositeUpdate | Nodes | DistinctTerms;
export type KnownExpression = AggregateExpression | GroupConcatExpression | ExistenceExpression | NamedExpression | OperatorExpression | TermExpression | WildcardExpression | BoundAggregate;

@@ -168,1 +171,22 @@ export type KnownPropertyPathSymbol = Alt | Inv | Link | Nps | OneOrMorePath | Seq | ZeroOrMorePath | ZeroOrOnePath;

export type Copy = Opened<Algebra.Copy>;
/**
* A non-standard operator to represent the nodes of a graph.
* It returns all nodes (subjects or objects) in the graph.
* https://www.w3.org/TR/sparql12-query/#defn_nodeSet
*/
export interface NodesUnopened extends BaseOperation {
type: TypesComunica.NODES;
graph: RDF.Term;
variable: RDF.Variable;
}
export type Nodes = Opened<NodesUnopened>;
/**
* A non-standard operator to represent distinct values of specific terms.
* It returns distinct combinations of the specified quad term positions.
*/
export interface DistinctTermsUnopened extends BaseOperation {
type: TypesComunica.DISTINCT_TERMS;
variables: RDF.Variable[];
terms: Record<string, QuadTermName>;
}
export type DistinctTerms = Opened<DistinctTermsUnopened>;
+1
-1

@@ -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/**\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"]}
{"version":3,"file":"Algebra.js","sourceRoot":"","sources":["Algebra.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,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 * as RDF from '@rdfjs/types';\nimport type { Algebra } from '@traqula/algebra-transformations-1-2';\nimport type { Patch } from '@traqula/core';\nimport type { QuadTermName } from 'rdf-terms';\nimport type { TypesComunica } from './TypesComunica';\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 | Nodes | DistinctTerms;\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\n/**\n * A non-standard operator to represent the nodes of a graph.\n * It returns all nodes (subjects or objects) in the graph.\n * https://www.w3.org/TR/sparql12-query/#defn_nodeSet\n */\nexport interface NodesUnopened extends BaseOperation {\n type: TypesComunica.NODES;\n graph: RDF.Term;\n variable: RDF.Variable;\n}\nexport type Nodes = Opened<NodesUnopened>;\n\n/**\n * A non-standard operator to represent distinct values of specific terms.\n * It returns distinct combinations of the specified quad term positions.\n */\nexport interface DistinctTermsUnopened extends BaseOperation {\n type: TypesComunica.DISTINCT_TERMS;\n variables: RDF.Variable[];\n terms: Record<string, QuadTermName>;\n}\nexport type DistinctTerms = Opened<DistinctTermsUnopened>;\n"]}
export * as Algebra from './Algebra';
export { isKnownOperation, isKnownSubType, transformer } from './utils';
export * from './TypesComunica';
export * as algebraUtils from './utils';
export { AlgebraFactory } from '@traqula/algebra-transformations-1-2';
export { AlgebraFactory } from './AlgebraFactory';
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AlgebraFactory = exports.algebraUtils = exports.transformer = exports.isKnownSubType = exports.isKnownOperation = exports.Algebra = void 0;
exports.Algebra = require("./Algebra");
exports.Algebra = __importStar(require("./Algebra"));
var utils_1 = require("./utils");

@@ -9,5 +45,6 @@ Object.defineProperty(exports, "isKnownOperation", { enumerable: true, get: function () { return utils_1.isKnownOperation; } });

Object.defineProperty(exports, "transformer", { enumerable: true, get: function () { return utils_1.transformer; } });
exports.algebraUtils = require("./utils");
var algebra_transformations_1_2_1 = require("@traqula/algebra-transformations-1-2");
Object.defineProperty(exports, "AlgebraFactory", { enumerable: true, get: function () { return algebra_transformations_1_2_1.AlgebraFactory; } });
__exportStar(require("./TypesComunica"), exports);
exports.algebraUtils = __importStar(require("./utils"));
var AlgebraFactory_1 = require("./AlgebraFactory");
Object.defineProperty(exports, "AlgebraFactory", { enumerable: true, get: function () { return AlgebraFactory_1.AlgebraFactory; } });
//# sourceMappingURL=index.js.map

@@ -1,1 +0,1 @@

{"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"]}
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAqC;AACrC,iCAAwE;AAA/D,yGAAA,gBAAgB,OAAA;AAAE,uGAAA,cAAc,OAAA;AAAE,oGAAA,WAAW,OAAA;AACtD,kDAAgC;AAChC,wDAAwC;AACxC,mDAAkD;AAAzC,gHAAA,cAAc,OAAA","sourcesContent":["export * as Algebra from './Algebra';\nexport { isKnownOperation, isKnownSubType, transformer } from './utils';\nexport * from './TypesComunica';\nexport * as algebraUtils from './utils';\nexport { AlgebraFactory } from './AlgebraFactory';\n"]}

@@ -270,2 +270,10 @@ import type { Algebra as TraqulaAlgebra } from '@traqula/algebra-transformations-1-2';

} | undefined;
nodes?: {
transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Nodes>, orig: import("./Algebra").Nodes) => unknown) | undefined;
preVisitor?: ((orig: import("./Algebra").Nodes) => TransformContext) | undefined;
} | undefined;
distinctterms?: {
transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").DistinctTerms>, orig: import("./Algebra").DistinctTerms) => unknown) | undefined;
preVisitor?: ((orig: import("./Algebra").DistinctTerms) => TransformContext) | undefined;
} | undefined;
}) => Safe extends "unsafe" ? OutType : unknown;

@@ -542,2 +550,10 @@ /**

} | undefined;
nodes?: {
transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").Nodes>, orig: import("./Algebra").Nodes) => unknown) | undefined;
preVisitor?: ((orig: import("./Algebra").Nodes) => TransformContext) | undefined;
} | undefined;
distinctterms?: {
transform?: ((copy: import("@traqula/core").SafeWrap<Safe, import("./Algebra").DistinctTerms>, orig: import("./Algebra").DistinctTerms) => unknown) | undefined;
preVisitor?: ((orig: import("./Algebra").DistinctTerms) => TransformContext) | undefined;
} | undefined;
}, nodeSpecificCallBacks: {

@@ -610,2 +626,4 @@ ask?: {} | undefined;

ZeroOrOnePath?: {} | undefined;
nodes?: {} | undefined;
distinctterms?: {} | undefined;
}) => Safe extends "unsafe" ? OutType : unknown;

@@ -867,2 +885,10 @@ /**

} | undefined;
nodes?: {
visitor?: ((op: import("./Algebra").Nodes) => void) | undefined;
preVisitor?: ((op: import("./Algebra").Nodes) => VisitContext) | undefined;
} | undefined;
distinctterms?: {
visitor?: ((op: import("./Algebra").DistinctTerms) => void) | undefined;
preVisitor?: ((op: import("./Algebra").DistinctTerms) => VisitContext) | undefined;
} | undefined;
}) => void;

@@ -1078,2 +1104,10 @@ /**

} | undefined;
nodes?: {
visitor?: ((op: import("./Algebra").Nodes) => void) | undefined;
preVisitor?: ((op: import("./Algebra").Nodes) => VisitContext) | undefined;
} | undefined;
distinctterms?: {
visitor?: ((op: import("./Algebra").DistinctTerms) => void) | undefined;
preVisitor?: ((op: import("./Algebra").DistinctTerms) => VisitContext) | undefined;
} | undefined;
}, nodeSpecificCallBacks: {

@@ -1146,2 +1180,4 @@ ask?: {} | undefined;

ZeroOrOnePath?: {} | undefined;
nodes?: {} | undefined;
distinctterms?: {} | undefined;
}) => void;

@@ -1148,0 +1184,0 @@ /**

@@ -8,2 +8,3 @@ "use strict";

const core_1 = require("@traqula/core");
const TypesComunica_1 = require("./TypesComunica");
exports.resolveIRI = algebra_transformations_1_2_1.algebraUtils.resolveIRI;

@@ -67,2 +68,3 @@ exports.objectify = algebra_transformations_1_2_1.algebraUtils.objectify;

[algebra_transformations_1_2_1.Types.COPY]: { ignoreKeys: new Set(['source', 'destination', 'metadata']) },
[TypesComunica_1.TypesComunica.NODES]: { ignoreKeys: new Set(['variable', 'metadata']) },
});

@@ -69,0 +71,0 @@ /**

@@ -1,1 +0,1 @@

{"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":";;;AAuBA,4CAUC;AAUD,wCAOC;AAhDD,sFAA2E;AAI3E,wCAAoD;AAGvC,QAAA,UAAU,GAAG,0CAAY,CAAC,UAAU,CAAC;AACrC,QAAA,SAAS,GAAG,0CAAY,CAAC,SAAS,CAAC;AAEhD;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAG9B,GAAc,EAAE,IAAU,EAAE,OAAiB;IAM7C,OAAO,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,SAAS,IAAI,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;AACjF,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc,CAG5B,GAAQ,EAAE,OAAgB;IAG1B,OAAO,GAAG,CAAC,OAAO,KAAK,OAAO,CAAC;AACjC,CAAC;AAKY,QAAA,WAAW,GAAG,IAAI,0BAAmB,CAAiB;IACjE;;;;;OAKG;IACH,WAAW,EAAE,IAAI,GAAG,CAAC,CA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C,CAAC;AAFlC,QAAA,gBAAgB,oBAEkB","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"]}
{"version":3,"file":"utils.js","sourceRoot":"","sources":["utils.ts"],"names":[],"mappings":";;;AAwBA,4CAUC;AAUD,wCAOC;AAjDD,sFAA2E;AAI3E,wCAAoD;AAEpD,mDAAgD;AAEnC,QAAA,UAAU,GAAG,0CAAY,CAA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qDG;AACU,QAAA,qBAAqB,GAAG,mBAAW,CAAC,qBAAqB,CAAC,IAAI,CAAC,mBAAW,CAAC,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACU,QAAA,eAAe,GAA8D,6BAAqB,CAAC;AAEhH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACU,QAAA,cAAc,GAAG,mBAAW,CAAC,SAAS,CAAC,IAAI,CAAC,mBAAW,CAAC,CAAC;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACU,QAAA,iBAAiB,GAAG,mBAAW,CAAC,iBAAiB,CAAC,IAAI,CAAC,mBAAW,CAAC,CAAC;AAEjF;;;;;;;;GAQG;AACI,MAAM,gBAAgB,GAC3B,CAAC,EAAa,EAAE,UAA8C,sBAAc,EAAkB,EAAE,CAC9F,0CAAY,CAAC,gBAAgB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AAFlC,QAAA,gBAAgB,oBAEkB","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';\nimport { TypesComunica } from './TypesComunica';\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 [TypesComunica.NODES]: { ignoreKeys: new Set([ 'variable', '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"]}
{
"name": "@comunica/utils-algebra",
"version": "5.1.3",
"version": "5.2.0",
"description": "Query algebra definitions and utilities",

@@ -39,6 +39,8 @@ "license": "MIT",

"dependencies": {
"@rdfjs/types": "*",
"@traqula/algebra-transformations-1-2": "^1.0.1",
"@traqula/core": "^1.0.0"
"@traqula/core": "^1.0.0",
"rdf-terms": "^2.0.0"
},
"gitHead": "8740a36019a375fd2ba27e799c52d63eb5cacc24"
"gitHead": "ebb0e79bddcd850fcb8d0fb5b422af88e67fa283"
}

@@ -15,3 +15,3 @@ # Comunica Algebra

```bash
$ yarn add @comunica/utils-data-factory
$ yarn add @comunica/utils-algebra
```

@@ -18,0 +18,0 @@