@comunica/actor-abstract-path 1.21.1 → 2.0.1-alpha.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
4
+ Comunica Association and Ghent University – imec, Belgium
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -0,0 +1,177 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-abstract-path/^2.0.0/components/context.jsonld",
4
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^2.0.0/components/context.jsonld",
5
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-query-operation/^2.0.0/components/context.jsonld"
6
+ ],
7
+ "@id": "npmd:@comunica/actor-abstract-path",
8
+ "components": [
9
+ {
10
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath",
11
+ "@type": "AbstractClass",
12
+ "requireElement": "ActorAbstractPath",
13
+ "extends": [
14
+ {
15
+ "@type": "GenericComponentExtension",
16
+ "component": "cbqo:components/ActorQueryOperationTypedMediated.jsonld#ActorQueryOperationTypedMediated",
17
+ "genericTypeInstances": [
18
+ "urn:npm:sparqlalgebrajs:Path"
19
+ ]
20
+ }
21
+ ],
22
+ "comment": "An abstract actor that handles Path operations. Provides multiple helper functions used by the Path operation actors.",
23
+ "parameters": [
24
+ {
25
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_predicateType",
26
+ "range": "xsd:string"
27
+ },
28
+ {
29
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_mediatorQueryOperation",
30
+ "range": "cc:components/Mediator.jsonld#Mediator"
31
+ },
32
+ {
33
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_name",
34
+ "range": "xsd:string",
35
+ "default": {
36
+ "@id": "rdf:subject"
37
+ },
38
+ "comment": "The name for this actor."
39
+ },
40
+ {
41
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_bus",
42
+ "range": {
43
+ "@type": "ParameterRangeGenericComponent",
44
+ "component": "cc:components/Bus.jsonld#Bus",
45
+ "genericTypeInstances": [
46
+ {
47
+ "@type": "ParameterRangeGenericComponent",
48
+ "component": "cc:components/Actor.jsonld#Actor",
49
+ "genericTypeInstances": [
50
+ {
51
+ "@type": "ParameterRangeGenericTypeReference",
52
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
53
+ },
54
+ {
55
+ "@type": "ParameterRangeGenericTypeReference",
56
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
57
+ },
58
+ {
59
+ "@type": "ParameterRangeGenericTypeReference",
60
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
61
+ }
62
+ ]
63
+ },
64
+ {
65
+ "@type": "ParameterRangeGenericTypeReference",
66
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
67
+ },
68
+ {
69
+ "@type": "ParameterRangeGenericTypeReference",
70
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
71
+ },
72
+ {
73
+ "@type": "ParameterRangeGenericTypeReference",
74
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
75
+ }
76
+ ]
77
+ },
78
+ "default": {
79
+ "@id": "cbqo:components/ActorQueryOperation.jsonld#ActorQueryOperation_default_bus",
80
+ "@type": "cc:components/Bus.jsonld#Bus"
81
+ },
82
+ "comment": "The bus this actor subscribes to."
83
+ },
84
+ {
85
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_beforeActors",
86
+ "range": {
87
+ "@type": "ParameterRangeUnion",
88
+ "parameterRangeElements": [
89
+ {
90
+ "@type": "ParameterRangeArray",
91
+ "parameterRangeValue": {
92
+ "@type": "ParameterRangeGenericComponent",
93
+ "component": "cc:components/Actor.jsonld#Actor",
94
+ "genericTypeInstances": [
95
+ {
96
+ "@type": "ParameterRangeGenericTypeReference",
97
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
98
+ },
99
+ {
100
+ "@type": "ParameterRangeGenericTypeReference",
101
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
102
+ },
103
+ {
104
+ "@type": "ParameterRangeGenericTypeReference",
105
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^2.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
106
+ }
107
+ ]
108
+ }
109
+ },
110
+ {
111
+ "@type": "ParameterRangeUndefined"
112
+ }
113
+ ]
114
+ },
115
+ "comment": "Actor that must be registered in the bus before this actor."
116
+ }
117
+ ],
118
+ "memberKeys": [
119
+ "FACTORY",
120
+ "predicateType",
121
+ "constructor",
122
+ "testOperation",
123
+ "generateVariable",
124
+ "isPathArbitraryLengthDistinct",
125
+ "predicateStarGraphVariable",
126
+ "getObjectsPredicateStarEval",
127
+ "getObjectsPredicateStar",
128
+ "getSubjectAndObjectBindingsPredicateStar"
129
+ ],
130
+ "constructorArguments": [
131
+ {
132
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args__constructorArgument",
133
+ "fields": [
134
+ {
135
+ "keyRaw": "mediatorQueryOperation",
136
+ "value": {
137
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_mediatorQueryOperation"
138
+ }
139
+ },
140
+ {
141
+ "keyRaw": "name",
142
+ "value": {
143
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_name"
144
+ }
145
+ },
146
+ {
147
+ "keyRaw": "bus",
148
+ "value": {
149
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_bus"
150
+ }
151
+ },
152
+ {
153
+ "keyRaw": "beforeActors",
154
+ "value": {
155
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_beforeActors"
156
+ }
157
+ }
158
+ ]
159
+ },
160
+ {
161
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_predicateType"
162
+ }
163
+ ]
164
+ },
165
+ {
166
+ "@id": "caap:components/ActorAbstractPath.jsonld#IPathResultStream",
167
+ "@type": "AbstractClass",
168
+ "requireElement": "IPathResultStream",
169
+ "parameters": [],
170
+ "memberKeys": [
171
+ "bindingsStream",
172
+ "metadata"
173
+ ],
174
+ "constructorArguments": []
175
+ }
176
+ ]
177
+ }
@@ -1,9 +1,11 @@
1
1
  {
2
- "@context": "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-abstract-path/^1.0.0/components/context.jsonld",
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-abstract-path/^2.0.0/components/context.jsonld"
4
+ ],
3
5
  "@id": "npmd:@comunica/actor-abstract-path",
4
6
  "@type": "Module",
5
7
  "requireName": "@comunica/actor-abstract-path",
6
8
  "import": [
7
- "files-caap:components/Actor/AbstractPath.jsonld"
9
+ "caap:components/ActorAbstractPath.jsonld"
8
10
  ]
9
- }
11
+ }
@@ -1,12 +1,52 @@
1
1
  {
2
2
  "@context": [
3
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^1.0.0/components/context.jsonld",
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^4.0.0/components/context.jsonld",
4
4
  {
5
5
  "npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
6
- "caap": "npmd:@comunica/actor-abstract-path/",
7
- "files-caap": "caap:^1.0.0/",
8
-
9
- "AbstractPath": "caap:Actor/AbstractPath"
6
+ "caap": "npmd:@comunica/actor-abstract-path/^2.0.0/",
7
+ "ActorAbstractPath": {
8
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath",
9
+ "@prefix": true,
10
+ "@context": {
11
+ "predicateType": {
12
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_predicateType"
13
+ },
14
+ "args_mediatorQueryOperation": {
15
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_mediatorQueryOperation"
16
+ },
17
+ "args_name": {
18
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_name"
19
+ },
20
+ "args_bus": {
21
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_bus"
22
+ },
23
+ "args_beforeActors": {
24
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_beforeActors",
25
+ "@container": "@list"
26
+ },
27
+ "cateType": {
28
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_predicateType"
29
+ },
30
+ "mediatorQueryOperation": {
31
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_mediatorQueryOperation"
32
+ },
33
+ "name": {
34
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_name"
35
+ },
36
+ "bus": {
37
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_bus"
38
+ },
39
+ "beforeActors": {
40
+ "@id": "caap:components/ActorAbstractPath.jsonld#ActorAbstractPath_args_beforeActors",
41
+ "@container": "@list"
42
+ }
43
+ }
44
+ },
45
+ "IPathResultStream": {
46
+ "@id": "caap:components/ActorAbstractPath.jsonld#IPathResultStream",
47
+ "@prefix": true,
48
+ "@context": {}
49
+ }
10
50
  }
11
51
  ]
12
- }
52
+ }
@@ -1,11 +1,10 @@
1
1
  import type { IActorQueryOperationTypedMediatedArgs } from '@comunica/bus-query-operation';
2
- import { ActorQueryOperationTypedMediated, Bindings } from '@comunica/bus-query-operation';
2
+ import { ActorQueryOperationTypedMediated } from '@comunica/bus-query-operation';
3
3
  import type { IActorTest } from '@comunica/core';
4
- import { ActionContext } from '@comunica/core';
5
- import type { IActorQueryOperationOutputBindings } from '@comunica/types';
4
+ import type { IQueryOperationResultBindings, Bindings, IActionContext, MetadataBindings } from '@comunica/types';
5
+ import type * as RDF from '@rdfjs/types';
6
6
  import type { AsyncIterator } from 'asynciterator';
7
7
  import { BufferedIterator } from 'asynciterator';
8
- import type { Term, Variable } from 'rdf-js';
9
8
  import type { Algebra } from 'sparqlalgebrajs';
10
9
  import { Factory } from 'sparqlalgebrajs';
11
10
  /**
@@ -16,13 +15,12 @@ import { Factory } from 'sparqlalgebrajs';
16
15
  export declare abstract class ActorAbstractPath extends ActorQueryOperationTypedMediated<Algebra.Path> {
17
16
  protected static readonly FACTORY: Factory;
18
17
  protected readonly predicateType: string;
19
- static isPathArbitraryLengthDistinctKey: string;
20
18
  protected constructor(args: IActorQueryOperationTypedMediatedArgs, predicateType: string);
21
- testOperation(pattern: Algebra.Path, context: ActionContext): Promise<IActorTest>;
22
- generateVariable(path?: Algebra.Path, name?: string): Variable;
23
- isPathArbitraryLengthDistinct(context: ActionContext, path: Algebra.Path): Promise<{
24
- context: ActionContext;
25
- operation: IActorQueryOperationOutputBindings | undefined;
19
+ testOperation(operation: Algebra.Path, context: IActionContext): Promise<IActorTest>;
20
+ generateVariable(path?: Algebra.Path, name?: string): RDF.Variable;
21
+ isPathArbitraryLengthDistinct(context: IActionContext, path: Algebra.Path): Promise<{
22
+ context: IActionContext;
23
+ operation: IQueryOperationResultBindings | undefined;
26
24
  }>;
27
25
  private predicateStarGraphVariable;
28
26
  /**
@@ -36,23 +34,23 @@ export declare abstract class ActorAbstractPath extends ActorQueryOperationTyped
36
34
  * @param {ActionContext} context
37
35
  * @return {Promise<AsyncIterator<Bindings>} Iterator to where all bindings of query should have been pushed.
38
36
  */
39
- getObjectsPredicateStarEval(subject: Term, object: Variable, predicate: Algebra.PropertyPathSymbol, graph: Term, context: ActionContext): Promise<AsyncIterator<Bindings>>;
37
+ getObjectsPredicateStarEval(subject: RDF.Term, object: RDF.Variable, predicate: Algebra.PropertyPathSymbol, graph: RDF.Term, context: IActionContext): Promise<IPathResultStream>;
40
38
  /**
41
39
  * Pushes all terms to iterator `it` that are a solution of object predicate* ?o.
42
40
  * @param {Term} object Term of where we start the predicate* search.
43
41
  * @param {Algebra.PropertyPathSymbol} predicate Predicate of the *-path.
44
42
  * @param {Term} graph The graph in which we search for the pattern.
45
43
  * @param {ActionContext} context
46
- * @param {{[id: string]: Term}} termHashes Remembers the objects we've already searched for.
44
+ * @param {Record<string, Term>} termHashes Remembers the objects we've already searched for.
47
45
  * @param {BufferedIterator<Term>} it Iterator to push terms to.
48
46
  * @param {any} counter Counts how many searches are in progress to close it when needed (when counter == 0).
49
- * @return {Promise<void>} All solutions of query should have been pushed to it by then.
47
+ * @return {Promise<IPathResultStream['metadata']>} The results metadata.
50
48
  */
51
- getObjectsPredicateStar(object: Term, predicate: Algebra.PropertyPathSymbol, graph: Term, context: ActionContext, termHashes: Record<string, Term>, it: BufferedIterator<Term>, counter: any): Promise<void>;
49
+ getObjectsPredicateStar(object: RDF.Term, predicate: Algebra.PropertyPathSymbol, graph: RDF.Term, context: IActionContext, termHashes: Record<string, RDF.Term>, it: BufferedIterator<RDF.Term>, counter: any): Promise<IPathResultStream['metadata'] | undefined>;
52
50
  /**
53
51
  * Pushes all terms to iterator `it` that are a solution of ?s predicate* ?o.
54
- * @param {string} subjectString String representation of subjectVariable
55
- * @param {string} objectString String representation of objectVariable
52
+ * @param {string} subjectVar String representation of subjectVariable
53
+ * @param {string} objectVar String representation of objectVariable
56
54
  * @param {Term} subjectVal Term of where we start the predicate* search.
57
55
  * @param {Term} objectVal Found solution for an object, start for the new step.
58
56
  * @param {Algebra.PropertyPathSymbol} predicate Predicate of the *-path.
@@ -66,5 +64,9 @@ export declare abstract class ActorAbstractPath extends ActorQueryOperationTyped
66
64
  * @param {any} counter Counts how many searches are in progress to close it when needed (when counter == 0).
67
65
  * @return {Promise<void>} All solutions of query should have been pushed to it by then.
68
66
  */
69
- getSubjectAndObjectBindingsPredicateStar(subjectString: string, objectString: string, subjectVal: Term, objectVal: Term, predicate: Algebra.PropertyPathSymbol, graph: Term, context: ActionContext, termHashesGlobal: Record<string, Promise<Term[]>>, termHashesCurrentSubject: Record<string, boolean>, it: BufferedIterator<Bindings>, counter: any): Promise<void>;
67
+ getSubjectAndObjectBindingsPredicateStar(subjectVar: RDF.Variable, objectVar: RDF.Variable, subjectVal: RDF.Term, objectVal: RDF.Term, predicate: Algebra.PropertyPathSymbol, graph: RDF.Term, context: IActionContext, termHashesGlobal: Record<string, Promise<RDF.Term[]>>, termHashesCurrentSubject: Record<string, boolean>, it: BufferedIterator<Bindings>, counter: any): Promise<void>;
68
+ }
69
+ export interface IPathResultStream {
70
+ bindingsStream: AsyncIterator<Bindings>;
71
+ metadata: () => Promise<MetadataBindings>;
70
72
  }
@@ -1,13 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ActorAbstractPath = void 0;
4
+ const bindings_factory_1 = require("@comunica/bindings-factory");
4
5
  const bus_query_operation_1 = require("@comunica/bus-query-operation");
5
- const core_1 = require("@comunica/core");
6
+ const context_entries_1 = require("@comunica/context-entries");
6
7
  const asynciterator_1 = require("asynciterator");
7
8
  const rdf_data_factory_1 = require("rdf-data-factory");
8
9
  const rdf_string_1 = require("rdf-string");
9
10
  const sparqlalgebrajs_1 = require("sparqlalgebrajs");
10
11
  const DF = new rdf_data_factory_1.DataFactory();
12
+ const BF = new bindings_factory_1.BindingsFactory();
11
13
  /**
12
14
  * An abstract actor that handles Path operations.
13
15
  *
@@ -18,8 +20,8 @@ class ActorAbstractPath extends bus_query_operation_1.ActorQueryOperationTypedMe
18
20
  super(args, 'path');
19
21
  this.predicateType = predicateType;
20
22
  }
21
- async testOperation(pattern, context) {
22
- if (pattern.predicate.type !== this.predicateType) {
23
+ async testOperation(operation, context) {
24
+ if (operation.predicate.type !== this.predicateType) {
23
25
  throw new Error(`This Actor only supports ${this.predicateType} Path operations.`);
24
26
  }
25
27
  return true;
@@ -39,40 +41,43 @@ class ActorAbstractPath extends bus_query_operation_1.ActorQueryOperationTypedMe
39
41
  // of ways the connection can be made) even if the repeated path itself would otherwise result in duplicates.
40
42
  // https://www.w3.org/TR/sparql11-query/#propertypaths
41
43
  async isPathArbitraryLengthDistinct(context, path) {
42
- if (!context || !context.get(ActorAbstractPath.isPathArbitraryLengthDistinctKey)) {
43
- context = context ?
44
- context.set(ActorAbstractPath.isPathArbitraryLengthDistinctKey, true) :
45
- core_1.ActionContext({ [ActorAbstractPath.isPathArbitraryLengthDistinctKey]: true });
44
+ if (!context.get(context_entries_1.KeysQueryOperation.isPathArbitraryLengthDistinctKey)) {
45
+ context = context.set(context_entries_1.KeysQueryOperation.isPathArbitraryLengthDistinctKey, true);
46
46
  return { context,
47
47
  operation: bus_query_operation_1.ActorQueryOperation.getSafeBindings(await this.mediatorQueryOperation.mediate({
48
48
  operation: ActorAbstractPath.FACTORY.createDistinct(path),
49
49
  context,
50
50
  })) };
51
51
  }
52
- context = context.set(ActorAbstractPath.isPathArbitraryLengthDistinctKey, false);
52
+ context = context.set(context_entries_1.KeysQueryOperation.isPathArbitraryLengthDistinctKey, false);
53
53
  return { context, operation: undefined };
54
54
  }
55
55
  async predicateStarGraphVariable(subject, object, predicate, graph, context) {
56
56
  // Construct path to obtain all graphs where subject exists
57
57
  const predVar = this.generateVariable(ActorAbstractPath.FACTORY.createPath(subject, predicate, object, graph));
58
- const findGraphs = ActorAbstractPath.FACTORY.createUnion(ActorAbstractPath.FACTORY.createPattern(subject, predVar, object, graph), ActorAbstractPath.FACTORY.createPattern(object, predVar, subject, graph));
58
+ const findGraphs = ActorAbstractPath.FACTORY.createUnion([
59
+ ActorAbstractPath.FACTORY.createPattern(subject, predVar, object, graph),
60
+ ActorAbstractPath.FACTORY.createPattern(object, predVar, subject, graph),
61
+ ]);
59
62
  const results = bus_query_operation_1.ActorQueryOperation.getSafeBindings(await this.mediatorQueryOperation.mediate({ context, operation: findGraphs }));
60
- const objectString = rdf_string_1.termToString(object);
61
63
  const passedGraphs = new Set();
62
- return new asynciterator_1.MultiTransformIterator(results.bindingsStream, {
64
+ const bindingsStream = new asynciterator_1.MultiTransformIterator(results.bindingsStream, {
63
65
  multiTransform: (bindings) => {
64
66
  // Extract the graph and start a predicate* search starting from subject in each graph
65
- const graphValue = bindings.get(rdf_string_1.termToString(graph));
66
- if (passedGraphs.has(rdf_string_1.termToString(graphValue))) {
67
+ const graphValue = bindings.get(graph);
68
+ if (passedGraphs.has(graphValue.value)) {
67
69
  return new asynciterator_1.EmptyIterator();
68
70
  }
69
- passedGraphs.add(rdf_string_1.termToString(graphValue));
71
+ passedGraphs.add(graphValue.value);
70
72
  return new asynciterator_1.TransformIterator(async () => {
71
73
  const it = new asynciterator_1.BufferedIterator();
72
74
  await this.getObjectsPredicateStar(subject, predicate, graphValue, context, {}, it, { count: 0 });
73
75
  return it.transform({
74
76
  transform(item, next, push) {
75
- push(bus_query_operation_1.Bindings({ [objectString]: item, [rdf_string_1.termToString(graph)]: graphValue }));
77
+ push(BF.bindings([
78
+ [object, item],
79
+ [graph, graphValue],
80
+ ]));
76
81
  next();
77
82
  },
78
83
  });
@@ -80,6 +85,10 @@ class ActorAbstractPath extends bus_query_operation_1.ActorQueryOperationTypedMe
80
85
  },
81
86
  autoStart: false,
82
87
  });
88
+ return {
89
+ bindingsStream,
90
+ metadata: results.metadata,
91
+ };
83
92
  }
84
93
  /**
85
94
  * Returns an iterator with Bindings of the query subject predicate* ?o
@@ -97,13 +106,20 @@ class ActorAbstractPath extends bus_query_operation_1.ActorQueryOperationTypedMe
97
106
  return this.predicateStarGraphVariable(subject, object, predicate, graph, context);
98
107
  }
99
108
  const it = new asynciterator_1.BufferedIterator();
100
- await this.getObjectsPredicateStar(subject, predicate, graph, context, {}, it, { count: 0 });
101
- return it.transform({
109
+ // We can safely ignore undefs because termHashes is empty
110
+ // eslint-disable-next-line @typescript-eslint/non-nullable-type-assertion-style
111
+ const metadata = await this
112
+ .getObjectsPredicateStar(subject, predicate, graph, context, {}, it, { count: 0 });
113
+ const bindingsStream = it.transform({
102
114
  transform(item, next, push) {
103
- push(bus_query_operation_1.Bindings({ [rdf_string_1.termToString(object)]: item }));
115
+ push(BF.bindings([[object, item]]));
104
116
  next();
105
117
  },
106
118
  });
119
+ return {
120
+ bindingsStream,
121
+ metadata,
122
+ };
107
123
  }
108
124
  /**
109
125
  * Pushes all terms to iterator `it` that are a solution of object predicate* ?o.
@@ -111,13 +127,13 @@ class ActorAbstractPath extends bus_query_operation_1.ActorQueryOperationTypedMe
111
127
  * @param {Algebra.PropertyPathSymbol} predicate Predicate of the *-path.
112
128
  * @param {Term} graph The graph in which we search for the pattern.
113
129
  * @param {ActionContext} context
114
- * @param {{[id: string]: Term}} termHashes Remembers the objects we've already searched for.
130
+ * @param {Record<string, Term>} termHashes Remembers the objects we've already searched for.
115
131
  * @param {BufferedIterator<Term>} it Iterator to push terms to.
116
132
  * @param {any} counter Counts how many searches are in progress to close it when needed (when counter == 0).
117
- * @return {Promise<void>} All solutions of query should have been pushed to it by then.
133
+ * @return {Promise<IPathResultStream['metadata']>} The results metadata.
118
134
  */
119
135
  async getObjectsPredicateStar(object, predicate, graph, context, termHashes, it, counter) {
120
- const termString = rdf_string_1.termToString(object);
136
+ const termString = (0, rdf_string_1.termToString)(object);
121
137
  if (termHashes[termString]) {
122
138
  return;
123
139
  }
@@ -125,11 +141,10 @@ class ActorAbstractPath extends bus_query_operation_1.ActorQueryOperationTypedMe
125
141
  termHashes[termString] = object;
126
142
  counter.count++;
127
143
  const thisVariable = this.generateVariable();
128
- const vString = rdf_string_1.termToString(thisVariable);
129
144
  const path = ActorAbstractPath.FACTORY.createPath(object, predicate, thisVariable, graph);
130
145
  const results = bus_query_operation_1.ActorQueryOperation.getSafeBindings(await this.mediatorQueryOperation.mediate({ operation: path, context }));
131
146
  results.bindingsStream.on('data', async (bindings) => {
132
- const result = bindings.get(vString);
147
+ const result = bindings.get(thisVariable);
133
148
  await this.getObjectsPredicateStar(result, predicate, graph, context, termHashes, it, counter);
134
149
  });
135
150
  results.bindingsStream.on('end', () => {
@@ -137,11 +152,12 @@ class ActorAbstractPath extends bus_query_operation_1.ActorQueryOperationTypedMe
137
152
  it.close();
138
153
  }
139
154
  });
155
+ return results.metadata;
140
156
  }
141
157
  /**
142
158
  * Pushes all terms to iterator `it` that are a solution of ?s predicate* ?o.
143
- * @param {string} subjectString String representation of subjectVariable
144
- * @param {string} objectString String representation of objectVariable
159
+ * @param {string} subjectVar String representation of subjectVariable
160
+ * @param {string} objectVar String representation of objectVariable
145
161
  * @param {Term} subjectVal Term of where we start the predicate* search.
146
162
  * @param {Term} objectVal Found solution for an object, start for the new step.
147
163
  * @param {Algebra.PropertyPathSymbol} predicate Predicate of the *-path.
@@ -157,20 +173,23 @@ class ActorAbstractPath extends bus_query_operation_1.ActorQueryOperationTypedMe
157
173
  */
158
174
  // Let the iterator `it` emit all bindings of size 2, with subjectStringVariable as value subjectVal
159
175
  // and objectStringVariable as value all nodes reachable through predicate* beginning at objectVal
160
- async getSubjectAndObjectBindingsPredicateStar(subjectString, objectString, subjectVal, objectVal, predicate, graph, context, termHashesGlobal, termHashesCurrentSubject, it, counter) {
161
- const termString = rdf_string_1.termToString(objectVal) + rdf_string_1.termToString(graph);
176
+ async getSubjectAndObjectBindingsPredicateStar(subjectVar, objectVar, subjectVal, objectVal, predicate, graph, context, termHashesGlobal, termHashesCurrentSubject, it, counter) {
177
+ const termString = (0, rdf_string_1.termToString)(objectVal) + (0, rdf_string_1.termToString)(graph);
162
178
  // If this combination of subject and object already done, return nothing
163
179
  if (termHashesCurrentSubject[termString]) {
164
180
  return;
165
181
  }
166
182
  counter.count++;
167
183
  termHashesCurrentSubject[termString] = true;
168
- it._push(bus_query_operation_1.Bindings({ [subjectString]: subjectVal, [objectString]: objectVal }));
184
+ it._push(BF.bindings([
185
+ [subjectVar, subjectVal],
186
+ [objectVar, objectVal],
187
+ ]));
169
188
  // If every reachable node from object has already been calculated, use these for current subject too
170
189
  if (termString in termHashesGlobal) {
171
190
  const objects = await termHashesGlobal[termString];
172
191
  for (const object of objects) {
173
- await this.getSubjectAndObjectBindingsPredicateStar(subjectString, objectString, subjectVal, object, predicate, graph, context, termHashesGlobal, termHashesCurrentSubject, it, counter);
192
+ await this.getSubjectAndObjectBindingsPredicateStar(subjectVar, objectVar, subjectVal, object, predicate, graph, context, termHashesGlobal, termHashesCurrentSubject, it, counter);
174
193
  }
175
194
  if (--counter.count === 0) {
176
195
  it.close();
@@ -182,14 +201,13 @@ class ActorAbstractPath extends bus_query_operation_1.ActorQueryOperationTypedMe
182
201
  const objectsArray = [];
183
202
  // Construct path that leads us one step through predicate
184
203
  const thisVariable = this.generateVariable();
185
- const vString = rdf_string_1.termToString(thisVariable);
186
204
  const path = ActorAbstractPath.FACTORY.createPath(objectVal, predicate, thisVariable, graph);
187
205
  const results = bus_query_operation_1.ActorQueryOperation.getSafeBindings(await this.mediatorQueryOperation.mediate({ operation: path, context }));
188
206
  // Recursive call on all neighbours
189
207
  results.bindingsStream.on('data', async (bindings) => {
190
- const result = bindings.get(vString);
208
+ const result = bindings.get(thisVariable);
191
209
  objectsArray.push(result);
192
- await this.getSubjectAndObjectBindingsPredicateStar(subjectString, objectString, subjectVal, result, predicate, graph, context, termHashesGlobal, termHashesCurrentSubject, it, counter);
210
+ await this.getSubjectAndObjectBindingsPredicateStar(subjectVar, objectVar, subjectVal, result, predicate, graph, context, termHashesGlobal, termHashesCurrentSubject, it, counter);
193
211
  });
194
212
  results.bindingsStream.on('error', reject);
195
213
  results.bindingsStream.on('end', () => {
@@ -205,5 +223,4 @@ class ActorAbstractPath extends bus_query_operation_1.ActorQueryOperationTypedMe
205
223
  }
206
224
  exports.ActorAbstractPath = ActorAbstractPath;
207
225
  ActorAbstractPath.FACTORY = new sparqlalgebrajs_1.Factory();
208
- ActorAbstractPath.isPathArbitraryLengthDistinctKey = 'isPathArbitraryLengthDistinct';
209
226
  //# sourceMappingURL=ActorAbstractPath.js.map
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './ActorAbstractPath';
@@ -10,5 +10,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./lib/ActorAbstractPath"), exports);
13
+ __exportStar(require("./ActorAbstractPath"), exports);
14
14
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@comunica/actor-abstract-path",
3
- "version": "1.21.1",
3
+ "version": "2.0.1-alpha.6.0",
4
4
  "description": "An abstract actor for handling mediatypes",
5
5
  "lsd:module": true,
6
- "main": "index.js",
7
- "typings": "index",
6
+ "main": "lib/index.js",
7
+ "typings": "lib/index",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/comunica/comunica.git",
@@ -13,6 +13,7 @@
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
+ "sideEffects": false,
16
17
  "keywords": [
17
18
  "comunica",
18
19
  "actor",
@@ -27,47 +28,26 @@
27
28
  "files": [
28
29
  "components",
29
30
  "lib/**/*.d.ts",
30
- "lib/**/*.js",
31
- "index.d.ts",
32
- "index.js"
31
+ "lib/**/*.js"
33
32
  ],
34
- "peerDependencies": {
35
- "@comunica/core": "^1.0.0"
36
- },
37
33
  "dependencies": {
38
- "@comunica/types": "^1.21.1",
39
- "@types/rdf-js": "*",
40
- "asynciterator": "^3.1.0",
34
+ "@comunica/bindings-factory": "2.0.1-alpha.6.0",
35
+ "@comunica/bus-query-operation": "2.0.1-alpha.6.0",
36
+ "@comunica/bus-rdf-join": "2.0.1-alpha.6.0",
37
+ "@comunica/context-entries": "2.0.1-alpha.6.0",
38
+ "@comunica/core": "2.0.1-alpha.6.0",
39
+ "@comunica/mediatortype-join-coefficients": "2.0.1-alpha.6.0",
40
+ "@comunica/types": "2.0.1-alpha.6.0",
41
+ "@rdfjs/types": "*",
42
+ "asynciterator": "^3.2.1",
41
43
  "rdf-data-factory": "^1.0.3",
42
44
  "rdf-string": "^1.5.0",
43
- "sparqlalgebrajs": "^2.5.5"
44
- },
45
- "devDependencies": {
46
- "@comunica/bus-query-operation": "^1.21.1",
47
- "@comunica/bus-rdf-join": "^1.21.1",
48
- "@comunica/core": "^1.21.1",
49
- "@comunica/mediatortype-iterations": "^1.21.1"
50
- },
51
- "jest": {
52
- "globals": {
53
- "ts-jest": {
54
- "tsConfig": "../../tsconfig.json"
55
- }
56
- },
57
- "transform": {
58
- "^.+\\.ts$": "ts-jest"
59
- },
60
- "testRegex": "(/test/.*|(\\.|/)(test|spec))\\.ts$",
61
- "moduleFileExtensions": [
62
- "ts",
63
- "js"
64
- ],
65
- "collectCoverage": true
45
+ "sparqlalgebrajs": "^4.0.0"
66
46
  },
67
47
  "scripts": {
68
- "test": "node \"../../node_modules/jest/bin/jest.js\" ${1}",
69
- "test-watch": "node \"../../node_modules/jest/bin/jest.js\" ${1} --watch",
70
- "build": "node \"../../node_modules/typescript/bin/tsc\"",
71
- "validate": "npm ls"
72
- }
48
+ "build": "npm run build:ts && npm run build:components",
49
+ "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
50
+ "build:components": "componentsjs-generator"
51
+ },
52
+ "gitHead": "bbf46a068e635256495a40e784a4691b22e88bd3"
73
53
  }
@@ -1,21 +0,0 @@
1
- {
2
- "@context": [
3
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-abstract-path/^1.0.0/components/context.jsonld",
4
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-query-operation/^1.0.0/components/context.jsonld"
5
- ],
6
- "@id": "npmd:@comunica/actor-abstract-path",
7
- "components": [
8
- {
9
- "@id": "caap:Actor/AbstractPath",
10
- "@type": "AbstractClass",
11
- "extends": "cbqo:Actor/QueryOperationTypedMediated",
12
- "requireElement": "ActorAbstractPath",
13
- "comment": "An abstract comunica actor for handling Path operations.",
14
- "constructorArguments": [
15
- {
16
- "extends": "cbqo:Actor/QueryOperationTypedMediated/constructorArgumentsObject"
17
- }
18
- ]
19
- }
20
- ]
21
- }
package/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './lib/ActorAbstractPath';