@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris 0.6.0 → 0.8.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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "@context": [
3
3
  "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris/^0.0.0/components/context.jsonld",
4
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^4.0.0/components/context.jsonld",
5
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-optimize-query-operation/^4.0.0/components/context.jsonld"
4
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-optimize-query-operation/^5.0.0/components/context.jsonld",
5
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^5.0.0/components/context.jsonld"
6
6
  ],
7
7
  "@id": "npmd:@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris",
8
8
  "components": [
@@ -15,11 +15,6 @@
15
15
  ],
16
16
  "comment": "A comunica Set Seed Sources Quadpattern IRIs Optimize Query Operation Actor.",
17
17
  "parameters": [
18
- {
19
- "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_mediatorQuerySourceIdentify",
20
- "range": "cc:components/Mediator.jsonld#Mediator",
21
- "comment": "Mediator for identifying query sources."
22
- },
23
18
  {
24
19
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_extractSubjects",
25
20
  "range": "xsd:boolean",
@@ -163,11 +158,6 @@
163
158
  }
164
159
  ],
165
160
  "memberFields": [
166
- {
167
- "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris__member_mediatorQuerySourceIdentify",
168
- "memberFieldName": "mediatorQuerySourceIdentify",
169
- "range": "cc:components/Mediator.jsonld#Mediator"
170
- },
171
161
  {
172
162
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris__member_extractSubjects",
173
163
  "memberFieldName": "extractSubjects"
@@ -209,12 +199,6 @@
209
199
  {
210
200
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args__constructorArgument",
211
201
  "fields": [
212
- {
213
- "keyRaw": "mediatorQuerySourceIdentify",
214
- "value": {
215
- "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_mediatorQuerySourceIdentify"
216
- }
217
- },
218
202
  {
219
203
  "keyRaw": "extractSubjects",
220
204
  "value": {
@@ -290,10 +274,6 @@
290
274
  ],
291
275
  "parameters": [],
292
276
  "memberFields": [
293
- {
294
- "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs__member_mediatorQuerySourceIdentify",
295
- "memberFieldName": "mediatorQuerySourceIdentify"
296
- },
297
277
  {
298
278
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs__member_extractSubjects",
299
279
  "memberFieldName": "extractSubjects"
@@ -8,9 +8,6 @@
8
8
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris",
9
9
  "@prefix": true,
10
10
  "@context": {
11
- "args_mediatorQuerySourceIdentify": {
12
- "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_mediatorQuerySourceIdentify"
13
- },
14
11
  "args_extractSubjects": {
15
12
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_extractSubjects"
16
13
  },
@@ -39,9 +36,6 @@
39
36
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_beforeActors",
40
37
  "@container": "@list"
41
38
  },
42
- "mediatorQuerySourceIdentify": {
43
- "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_mediatorQuerySourceIdentify"
44
- },
45
39
  "extractSubjects": {
46
40
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_extractSubjects"
47
41
  },
@@ -1,13 +1,11 @@
1
1
  import type { IActionOptimizeQueryOperation, IActorOptimizeQueryOperationOutput } from '@comunica/bus-optimize-query-operation';
2
2
  import { ActorOptimizeQueryOperation } from '@comunica/bus-optimize-query-operation';
3
- import type { MediatorQuerySourceIdentify } from '@comunica/bus-query-source-identify';
4
3
  import type { IActorArgs, IActorTest, TestResult } from '@comunica/core';
5
- import { Algebra } from 'sparqlalgebrajs';
4
+ import { Algebra } from '@comunica/utils-algebra';
6
5
  /**
7
6
  * A comunica Set Seed Sources Quadpattern IRIs Optimize Query Operation Actor.
8
7
  */
9
8
  export declare class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris extends ActorOptimizeQueryOperation {
10
- readonly mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;
11
9
  private readonly extractSubjects;
12
10
  private readonly extractPredicates;
13
11
  private readonly extractObjects;
@@ -19,10 +17,6 @@ export declare class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris ex
19
17
  extractIrisFromOperation(operation: Algebra.Operation): string[];
20
18
  }
21
19
  export interface IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs extends IActorArgs<IActionOptimizeQueryOperation, IActorTest, IActorOptimizeQueryOperationOutput> {
22
- /**
23
- * Mediator for identifying query sources.
24
- */
25
- mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;
26
20
  /**
27
21
  * If IRIs should be extracted from subject positions.
28
22
  * @default {true}
@@ -4,70 +4,81 @@ exports.ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris = void 0;
4
4
  const bus_optimize_query_operation_1 = require("@comunica/bus-optimize-query-operation");
5
5
  const context_entries_1 = require("@comunica/context-entries");
6
6
  const core_1 = require("@comunica/core");
7
- const sparqlalgebrajs_1 = require("sparqlalgebrajs");
7
+ const utils_algebra_1 = require("@comunica/utils-algebra");
8
8
  /**
9
9
  * A comunica Set Seed Sources Quadpattern IRIs Optimize Query Operation Actor.
10
10
  */
11
11
  class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris extends bus_optimize_query_operation_1.ActorOptimizeQueryOperation {
12
+ extractSubjects;
13
+ extractPredicates;
14
+ extractObjects;
15
+ extractGraphs;
16
+ extractVocabIris;
12
17
  constructor(args) {
13
18
  super(args);
19
+ this.extractSubjects = args.extractSubjects;
20
+ this.extractPredicates = args.extractPredicates;
21
+ this.extractObjects = args.extractObjects;
22
+ this.extractGraphs = args.extractGraphs;
23
+ this.extractVocabIris = args.extractVocabIris;
14
24
  }
15
25
  async test(_action) {
16
26
  return (0, core_1.passTestVoid)();
17
27
  }
18
28
  async run(action) {
19
- let sources = action.context.get(context_entries_1.KeysQueryOperation.querySources);
29
+ const sources = action.context.get(context_entries_1.KeysInitQuery.querySourcesUnidentified);
20
30
  if (!sources || sources.length === 0) {
21
- sources = await Promise.all([...new Set(this.extractIrisFromOperation(action.operation))]
22
- .map(async (source) => {
31
+ const links = [...new Set(this.extractIrisFromOperation(action.operation))]
32
+ .map((source) => {
23
33
  // Remove fragment from URL
24
34
  const hashPosition = source.indexOf('#');
25
35
  if (hashPosition >= 0) {
26
36
  source = source.slice(0, hashPosition);
27
37
  }
28
- return (await this.mediatorQuerySourceIdentify.mediate({
29
- querySourceUnidentified: {
30
- value: source,
31
- context: new core_1.ActionContext().set(context_entries_1.KeysQuerySourceIdentify.traverse, true),
32
- },
33
- context: action.context,
34
- })).querySource;
35
- }));
36
- action.context = action.context.set(context_entries_1.KeysQueryOperation.querySources, sources);
38
+ // Track as discovered link
39
+ action.context.get(context_entries_1.KeysStatistics.discoveredLinks)
40
+ ?.updateStatistic({ url: source, metadata: { seed: true } }, { url: 'root' });
41
+ return source;
42
+ });
43
+ action.context = action.context.set(context_entries_1.KeysInitQuery.querySourcesUnidentified, links);
37
44
  }
38
45
  return { ...action, context: action.context };
39
46
  }
40
47
  extractIrisFromOperation(operation) {
41
48
  const iris = [];
42
- sparqlalgebrajs_1.Util.recurseOperation(operation, {
43
- [sparqlalgebrajs_1.Algebra.types.PATH]: (path) => {
44
- if (this.extractSubjects && path.subject.termType === 'NamedNode') {
45
- iris.push(path.subject.value);
46
- }
47
- // Predicates are ignored
48
- if (this.extractObjects && path.object.termType === 'NamedNode') {
49
- iris.push(path.object.value);
50
- }
51
- if (this.extractGraphs && path.graph.termType === 'NamedNode') {
52
- iris.push(path.graph.value);
53
- }
54
- return false;
49
+ utils_algebra_1.algebraUtils.visitOperation(operation, {
50
+ [utils_algebra_1.Algebra.Types.PATH]: {
51
+ preVisitor: () => ({ continue: false }),
52
+ visitor: (path) => {
53
+ if (this.extractSubjects && path.subject.termType === 'NamedNode') {
54
+ iris.push(path.subject.value);
55
+ }
56
+ // Predicates are ignored
57
+ if (this.extractObjects && path.object.termType === 'NamedNode') {
58
+ iris.push(path.object.value);
59
+ }
60
+ if (this.extractGraphs && path.graph.termType === 'NamedNode') {
61
+ iris.push(path.graph.value);
62
+ }
63
+ },
55
64
  },
56
- [sparqlalgebrajs_1.Algebra.types.PATTERN]: (pattern) => {
57
- if (this.extractSubjects && pattern.subject.termType === 'NamedNode') {
58
- iris.push(pattern.subject.value);
59
- }
60
- if (this.extractPredicates && pattern.predicate.termType === 'NamedNode') {
61
- iris.push(pattern.predicate.value);
62
- }
63
- if (this.extractObjects && pattern.object.termType === 'NamedNode' &&
64
- (this.extractVocabIris || pattern.predicate.value !== 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')) {
65
- iris.push(pattern.object.value);
66
- }
67
- if (this.extractGraphs && pattern.graph.termType === 'NamedNode') {
68
- iris.push(pattern.graph.value);
69
- }
70
- return false;
65
+ [utils_algebra_1.Algebra.Types.PATTERN]: {
66
+ preVisitor: () => ({ continue: false }),
67
+ visitor: (pattern) => {
68
+ if (this.extractSubjects && pattern.subject.termType === 'NamedNode') {
69
+ iris.push(pattern.subject.value);
70
+ }
71
+ if (this.extractPredicates && pattern.predicate.termType === 'NamedNode') {
72
+ iris.push(pattern.predicate.value);
73
+ }
74
+ if (this.extractObjects && pattern.object.termType === 'NamedNode' &&
75
+ (this.extractVocabIris || pattern.predicate.value !== 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')) {
76
+ iris.push(pattern.object.value);
77
+ }
78
+ if (this.extractGraphs && pattern.graph.termType === 'NamedNode') {
79
+ iris.push(pattern.graph.value);
80
+ }
81
+ },
71
82
  },
72
83
  });
73
84
  return iris;
@@ -1 +1 @@
1
- {"version":3,"file":"ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.js","sourceRoot":"","sources":["ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.ts"],"names":[],"mappings":";;;AAIA,yFAAqF;AAErF,+DAAwF;AAExF,yCAA6D;AAE7D,qDAAgD;AAEhD;;GAEG;AACH,MAAa,wDAAyD,SAAQ,0DAA2B;IAQvG,YAAmB,IA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AK,CAAC,CAAC;gBACrC,CAAC;gBACD,IAAI,IAAI,CAAC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,WAAW;oBAChE,CAAC,IAAI,CAAC,gBAAgB,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,KAAK,iDAAiD,CAAC,EAAE,CAAC;oBAC3G,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAClC,CAAC;gBACD,IAAI,IAAI,CAAC,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;oBACjE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACjC,CAAC;gBACD,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA7ED,4HA6EC","sourcesContent":["import type {\n IActionOptimizeQueryOperation,\n IActorOptimizeQueryOperationOutput,\n} from '@comunica/bus-optimize-query-operation';\nimport { ActorOptimizeQueryOperation } from '@comunica/bus-optimize-query-operation';\nimport type { MediatorQuerySourceIdentify } from '@comunica/bus-query-source-identify';\nimport { KeysQueryOperation, KeysQuerySourceIdentify } from '@comunica/context-entries';\nimport type { IActorArgs, IActorTest, TestResult } from '@comunica/core';\nimport { ActionContext, passTestVoid } from '@comunica/core';\nimport type { IQuerySourceWrapper } from '@comunica/types';\nimport { Algebra, Util } from 'sparqlalgebrajs';\n\n/**\n * A comunica Set Seed Sources Quadpattern IRIs Optimize Query Operation Actor.\n */\nexport class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris extends ActorOptimizeQueryOperation {\n public readonly mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;\n private readonly extractSubjects: boolean;\n private readonly extractPredicates: boolean;\n private readonly extractObjects: boolean;\n private readonly extractGraphs: boolean;\n private readonly extractVocabIris: boolean;\n\n public constructor(args: IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs) {\n super(args);\n }\n\n public async test(_action: IActionOptimizeQueryOperation): Promise<TestResult<IActorTest>> {\n return passTestVoid();\n }\n\n public async run(action: IActionOptimizeQueryOperation): Promise<IActorOptimizeQueryOperationOutput> {\n let sources: IQuerySourceWrapper[] | undefined = action.context.get(KeysQueryOperation.querySources);\n if (!sources || sources.length === 0) {\n sources = await Promise.all(\n [ ...new Set(this.extractIrisFromOperation(action.operation)) ]\n .map(async(source) => {\n // Remove fragment from URL\n const hashPosition = source.indexOf('#');\n if (hashPosition >= 0) {\n source = source.slice(0, hashPosition);\n }\n\n return (await this.mediatorQuerySourceIdentify.mediate({\n querySourceUnidentified: {\n value: source,\n context: new ActionContext().set(KeysQuerySourceIdentify.traverse, true),\n },\n context: action.context,\n })).querySource;\n }),\n );\n action.context = action.context.set(KeysQueryOperation.querySources, sources);\n }\n return { ...action, context: action.context };\n }\n\n public extractIrisFromOperation(operation: Algebra.Operation): string[] {\n const iris: string[] = [];\n Util.recurseOperation(operation, {\n [Algebra.types.PATH]: (path) => {\n if (this.extractSubjects && path.subject.termType === 'NamedNode') {\n iris.push(path.subject.value);\n }\n // Predicates are ignored\n if (this.extractObjects && path.object.termType === 'NamedNode') {\n iris.push(path.object.value);\n }\n if (this.extractGraphs && path.graph.termType === 'NamedNode') {\n iris.push(path.graph.value);\n }\n return false;\n },\n [Algebra.types.PATTERN]: (pattern) => {\n if (this.extractSubjects && pattern.subject.termType === 'NamedNode') {\n iris.push(pattern.subject.value);\n }\n if (this.extractPredicates && pattern.predicate.termType === 'NamedNode') {\n iris.push(pattern.predicate.value);\n }\n if (this.extractObjects && pattern.object.termType === 'NamedNode' &&\n (this.extractVocabIris || pattern.predicate.value !== 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')) {\n iris.push(pattern.object.value);\n }\n if (this.extractGraphs && pattern.graph.termType === 'NamedNode') {\n iris.push(pattern.graph.value);\n }\n return false;\n },\n });\n return iris;\n }\n}\n\nexport interface IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs\n extends IActorArgs<IActionOptimizeQueryOperation, IActorTest, IActorOptimizeQueryOperationOutput> {\n /**\n * Mediator for identifying query sources.\n */\n mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;\n /**\n * If IRIs should be extracted from subject positions.\n * @default {true}\n */\n extractSubjects: boolean;\n /**\n * If IRIs should be extracted from predicate positions.\n * @default {false}\n */\n extractPredicates: boolean;\n /**\n * If IRIs should be extracted from object positions.\n * @default {true}\n */\n extractObjects: boolean;\n /**\n * If IRIs should be extracted from graph positions.\n * @default {true}\n */\n extractGraphs: boolean;\n /**\n * If object IRIs should be extracted if the predicate is rdf:type.\n * @default {false}\n */\n extractVocabIris: boolean;\n}\n"]}
1
+ {"version":3,"file":"ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.js","sourceRoot":"","sources":["ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.ts"],"names":[],"mappings":";;;AAIA,yFAAqF;AACrF,+DAA0E;AAE1E,yCAA8C;AAC9C,2DAAgE;AAEhE;;GAEG;AACH,MAAa,wDAAyD,SAAQ,0DAA2B;IACtF,eAAe,CAAU;IACzB,iBAAiB,CAAU;IAC3B,cAAc,CAAU;IACxB,aAAa,CAAU;IACvB,gBAAgB,CAAU;IAE3C,YAAmB,IAAmE;QACpF,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC;QAC5C,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAChD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC;IAChD,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,OAAsC;QACtD,OAAO,IAAA,mBAAY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AAC,KAAK,CAAC,CAAC;oBACrC,CAAC;oBACD,IAAI,IAAI,CAAC,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,WAAW;wBAC9D,CAAC,IAAI,CAAC,gBAAgB,IAAI,OAAO,CAAC,SAAS,CAAC,KAAK,KAAK,iDAAiD,CAAC,EAAE,CAAC;wBAC7G,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;oBAClC,CAAC;oBACD,IAAI,IAAI,CAAC,aAAa,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;wBACjE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBACjC,CAAC;gBACH,CAAC;aACF;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAjFD,4HAiFC","sourcesContent":["import type {\n IActionOptimizeQueryOperation,\n IActorOptimizeQueryOperationOutput,\n} from '@comunica/bus-optimize-query-operation';\nimport { ActorOptimizeQueryOperation } from '@comunica/bus-optimize-query-operation';\nimport { KeysInitQuery, KeysStatistics } from '@comunica/context-entries';\nimport type { IActorArgs, IActorTest, TestResult } from '@comunica/core';\nimport { passTestVoid } from '@comunica/core';\nimport { Algebra, algebraUtils } from '@comunica/utils-algebra';\n\n/**\n * A comunica Set Seed Sources Quadpattern IRIs Optimize Query Operation Actor.\n */\nexport class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris extends ActorOptimizeQueryOperation {\n private readonly extractSubjects: boolean;\n private readonly extractPredicates: boolean;\n private readonly extractObjects: boolean;\n private readonly extractGraphs: boolean;\n private readonly extractVocabIris: boolean;\n\n public constructor(args: IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs) {\n super(args);\n this.extractSubjects = args.extractSubjects;\n this.extractPredicates = args.extractPredicates;\n this.extractObjects = args.extractObjects;\n this.extractGraphs = args.extractGraphs;\n this.extractVocabIris = args.extractVocabIris;\n }\n\n public async test(_action: IActionOptimizeQueryOperation): Promise<TestResult<IActorTest>> {\n return passTestVoid();\n }\n\n public async run(action: IActionOptimizeQueryOperation): Promise<IActorOptimizeQueryOperationOutput> {\n const sources = action.context.get(KeysInitQuery.querySourcesUnidentified);\n if (!sources || sources.length === 0) {\n const links: string[] = [ ...new Set(this.extractIrisFromOperation(action.operation)) ]\n .map((source) => {\n // Remove fragment from URL\n const hashPosition = source.indexOf('#');\n if (hashPosition >= 0) {\n source = source.slice(0, hashPosition);\n }\n\n // Track as discovered link\n action.context.get(KeysStatistics.discoveredLinks)\n ?.updateStatistic({ url: source, metadata: { seed: true }}, { url: 'root' });\n\n return source;\n });\n action.context = action.context.set(KeysInitQuery.querySourcesUnidentified, links);\n }\n return { ...action, context: action.context };\n }\n\n public extractIrisFromOperation(operation: Algebra.Operation): string[] {\n const iris: string[] = [];\n algebraUtils.visitOperation(operation, {\n [Algebra.Types.PATH]: {\n preVisitor: () => ({ continue: false }),\n visitor: (path) => {\n if (this.extractSubjects && path.subject.termType === 'NamedNode') {\n iris.push(path.subject.value);\n }\n // Predicates are ignored\n if (this.extractObjects && path.object.termType === 'NamedNode') {\n iris.push(path.object.value);\n }\n if (this.extractGraphs && path.graph.termType === 'NamedNode') {\n iris.push(path.graph.value);\n }\n },\n },\n [Algebra.Types.PATTERN]: {\n preVisitor: () => ({ continue: false }),\n visitor: (pattern) => {\n if (this.extractSubjects && pattern.subject.termType === 'NamedNode') {\n iris.push(pattern.subject.value);\n }\n if (this.extractPredicates && pattern.predicate.termType === 'NamedNode') {\n iris.push(pattern.predicate.value);\n }\n if (this.extractObjects && pattern.object.termType === 'NamedNode' &&\n (this.extractVocabIris || pattern.predicate.value !== 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type')) {\n iris.push(pattern.object.value);\n }\n if (this.extractGraphs && pattern.graph.termType === 'NamedNode') {\n iris.push(pattern.graph.value);\n }\n },\n },\n });\n return iris;\n }\n}\n\nexport interface IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs\n extends IActorArgs<IActionOptimizeQueryOperation, IActorTest, IActorOptimizeQueryOperationOutput> {\n /**\n * If IRIs should be extracted from subject positions.\n * @default {true}\n */\n extractSubjects: boolean;\n /**\n * If IRIs should be extracted from predicate positions.\n * @default {false}\n */\n extractPredicates: boolean;\n /**\n * If IRIs should be extracted from object positions.\n * @default {true}\n */\n extractObjects: boolean;\n /**\n * If IRIs should be extracted from graph positions.\n * @default {true}\n */\n extractGraphs: boolean;\n /**\n * If object IRIs should be extracted if the predicate is rdf:type.\n * @default {false}\n */\n extractVocabIris: boolean;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "A set-seed-sources-quadpattern-iris optimize-query-operation actor",
5
5
  "lsd:module": true,
6
6
  "license": "MIT",
@@ -41,12 +41,10 @@
41
41
  "build:components": "componentsjs-generator"
42
42
  },
43
43
  "dependencies": {
44
- "@comunica/bus-optimize-query-operation": "^4.0.1",
45
- "@comunica/bus-query-source-identify": "^4.0.1",
46
- "@comunica/context-entries": "^4.0.1",
47
- "@comunica/core": "^4.0.1",
48
- "@comunica/types": "^4.0.1",
49
- "sparqlalgebrajs": "^4.2.0"
44
+ "@comunica/bus-optimize-query-operation": "^5.0.0",
45
+ "@comunica/context-entries": "^5.0.0",
46
+ "@comunica/core": "^5.0.0",
47
+ "@comunica/utils-algebra": "^4.0.2"
50
48
  },
51
- "gitHead": "658ec9ab431031a56874c4262532c5dc23a8d327"
49
+ "gitHead": "8ffee3e33348f45ce70b033426f3abae4ed4ce71"
52
50
  }