@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris 0.2.0 → 0.4.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/README.md CHANGED
@@ -22,13 +22,14 @@ After installing, this package can be added to your engine's configuration as fo
22
22
  {
23
23
  "@context": [
24
24
  ...
25
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris/^1.0.0/components/context.jsonld"
25
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris/^1.0.0/components/context.jsonld"
26
26
  ],
27
27
  "actors": [
28
28
  ...
29
29
  {
30
30
  "@id": "config-setsslt:set-seeds.json#mySeedSetter",
31
- "@type": "ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris"
31
+ "@type": "ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris",
32
+ "mediatorQuerySourceIdentify": { "@id": "urn:comunica:default:query-source-identify/mediators#main" }
32
33
  }
33
34
  ]
34
35
  }
@@ -36,8 +37,9 @@ After installing, this package can be added to your engine's configuration as fo
36
37
 
37
38
  ### Config Parameters
38
39
 
39
- * `caoqosssqi:Actor/OptimizeQueryOperation/SetSeedSourcesQuadpatternIris#extractSubjects`: If IRIs should be extracted from subject positions. (default `true`)
40
- * `caoqosssqi:Actor/OptimizeQueryOperation/SetSeedSourcesQuadpatternIris#extractPredicates`: If IRIs should be extracted from predicate positions. (default `false`)
41
- * `caoqosssqi:Actor/OptimizeQueryOperation/SetSeedSourcesQuadpatternIris#extractObjects`: If IRIs should be extracted from object positions. (default `true`)
42
- * `caoqosssqi:Actor/OptimizeQueryOperation/SetSeedSourcesQuadpatternIris#extractGraphs`: If IRIs should be extracted from graph positions. (default `true`)
43
- * `caoqosssqi:Actor/OptimizeQueryOperation/SetSeedSourcesQuadpatternIris#extractVocabIris`: If object IRIs should be extracted if the predicate is rdf:type. (default `false`)
40
+ * `mediatorQuerySourceIdentify`: A mediator over the [Query Source Identify bus](https://github.com/comunica/comunica/tree/master/packages/bus-query-source-identify).
41
+ * `extractSubjects`: If IRIs should be extracted from subject positions. (default `true`)
42
+ * `extractPredicates`: If IRIs should be extracted from predicate positions. (default `false`)
43
+ * `extractObjects`: If IRIs should be extracted from object positions. (default `true`)
44
+ * `extractGraphs`: If IRIs should be extracted from graph positions. (default `true`)
45
+ * `extractVocabIris`: If object IRIs should be extracted if the predicate is rdf:type. (default `false`)
@@ -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/bus-optimize-query-operation/^2.0.0/components/context.jsonld",
5
- "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^2.0.0/components/context.jsonld"
4
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^3.0.0/components/context.jsonld",
5
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-optimize-query-operation/^3.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,6 +15,11 @@
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
+ },
18
23
  {
19
24
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_extractSubjects",
20
25
  "range": "xsd:boolean",
@@ -64,24 +69,30 @@
64
69
  "component": "cc:components/Actor.jsonld#Actor",
65
70
  "genericTypeInstances": [
66
71
  {
67
- "@type": "ParameterRangeWildcard"
72
+ "@type": "ParameterRangeGenericTypeReference",
73
+ "parameterRangeGenericType": "npmd:@comunica/actor-context-preprocess-set-defaults-link-traversal/^0.0.0/components/ActorContextPreprocessSetDefaultsLinkTraversal.jsonld#ActorContextPreprocessSetDefaultsLinkTraversal__generic_I"
68
74
  },
69
75
  {
70
- "@type": "ParameterRangeWildcard"
76
+ "@type": "ParameterRangeGenericTypeReference",
77
+ "parameterRangeGenericType": "npmd:@comunica/actor-context-preprocess-set-defaults-link-traversal/^0.0.0/components/ActorContextPreprocessSetDefaultsLinkTraversal.jsonld#ActorContextPreprocessSetDefaultsLinkTraversal__generic_T"
71
78
  },
72
79
  {
73
- "@type": "ParameterRangeWildcard"
80
+ "@type": "ParameterRangeGenericTypeReference",
81
+ "parameterRangeGenericType": "npmd:@comunica/actor-context-preprocess-set-defaults-link-traversal/^0.0.0/components/ActorContextPreprocessSetDefaultsLinkTraversal.jsonld#ActorContextPreprocessSetDefaultsLinkTraversal__generic_O"
74
82
  }
75
83
  ]
76
84
  },
77
85
  {
78
- "@type": "ParameterRangeWildcard"
86
+ "@type": "ParameterRangeGenericTypeReference",
87
+ "parameterRangeGenericType": "npmd:@comunica/actor-context-preprocess-set-defaults-link-traversal/^0.0.0/components/ActorContextPreprocessSetDefaultsLinkTraversal.jsonld#ActorContextPreprocessSetDefaultsLinkTraversal__generic_I"
79
88
  },
80
89
  {
81
- "@type": "ParameterRangeWildcard"
90
+ "@type": "ParameterRangeGenericTypeReference",
91
+ "parameterRangeGenericType": "npmd:@comunica/actor-context-preprocess-set-defaults-link-traversal/^0.0.0/components/ActorContextPreprocessSetDefaultsLinkTraversal.jsonld#ActorContextPreprocessSetDefaultsLinkTraversal__generic_T"
82
92
  },
83
93
  {
84
- "@type": "ParameterRangeWildcard"
94
+ "@type": "ParameterRangeGenericTypeReference",
95
+ "parameterRangeGenericType": "npmd:@comunica/actor-context-preprocess-set-defaults-link-traversal/^0.0.0/components/ActorContextPreprocessSetDefaultsLinkTraversal.jsonld#ActorContextPreprocessSetDefaultsLinkTraversal__generic_O"
85
96
  }
86
97
  ]
87
98
  },
@@ -103,13 +114,16 @@
103
114
  "component": "cc:components/Actor.jsonld#Actor",
104
115
  "genericTypeInstances": [
105
116
  {
106
- "@type": "ParameterRangeWildcard"
117
+ "@type": "ParameterRangeGenericTypeReference",
118
+ "parameterRangeGenericType": "npmd:@comunica/actor-context-preprocess-set-defaults-link-traversal/^0.0.0/components/ActorContextPreprocessSetDefaultsLinkTraversal.jsonld#ActorContextPreprocessSetDefaultsLinkTraversal__generic_I"
107
119
  },
108
120
  {
109
- "@type": "ParameterRangeWildcard"
121
+ "@type": "ParameterRangeGenericTypeReference",
122
+ "parameterRangeGenericType": "npmd:@comunica/actor-context-preprocess-set-defaults-link-traversal/^0.0.0/components/ActorContextPreprocessSetDefaultsLinkTraversal.jsonld#ActorContextPreprocessSetDefaultsLinkTraversal__generic_T"
110
123
  },
111
124
  {
112
- "@type": "ParameterRangeWildcard"
125
+ "@type": "ParameterRangeGenericTypeReference",
126
+ "parameterRangeGenericType": "npmd:@comunica/actor-context-preprocess-set-defaults-link-traversal/^0.0.0/components/ActorContextPreprocessSetDefaultsLinkTraversal.jsonld#ActorContextPreprocessSetDefaultsLinkTraversal__generic_O"
113
127
  }
114
128
  ]
115
129
  }
@@ -123,6 +137,11 @@
123
137
  }
124
138
  ],
125
139
  "memberFields": [
140
+ {
141
+ "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris__member_mediatorQuerySourceIdentify",
142
+ "memberFieldName": "mediatorQuerySourceIdentify",
143
+ "range": "cc:components/Mediator.jsonld#Mediator"
144
+ },
126
145
  {
127
146
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris__member_extractSubjects",
128
147
  "memberFieldName": "extractSubjects"
@@ -164,6 +183,12 @@
164
183
  {
165
184
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args__constructorArgument",
166
185
  "fields": [
186
+ {
187
+ "keyRaw": "mediatorQuerySourceIdentify",
188
+ "value": {
189
+ "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_mediatorQuerySourceIdentify"
190
+ }
191
+ },
167
192
  {
168
193
  "keyRaw": "extractSubjects",
169
194
  "value": {
@@ -233,6 +258,10 @@
233
258
  ],
234
259
  "parameters": [],
235
260
  "memberFields": [
261
+ {
262
+ "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs__member_mediatorQuerySourceIdentify",
263
+ "memberFieldName": "mediatorQuerySourceIdentify"
264
+ },
236
265
  {
237
266
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs__member_extractSubjects",
238
267
  "memberFieldName": "extractSubjects"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "@context": [
3
- "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld",
4
4
  {
5
5
  "npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
6
6
  "caoqosssqi": "npmd:@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris/^0.0.0/",
@@ -8,6 +8,9 @@
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
+ },
11
14
  "args_extractSubjects": {
12
15
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_extractSubjects"
13
16
  },
@@ -33,6 +36,9 @@
33
36
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_beforeActors",
34
37
  "@container": "@list"
35
38
  },
39
+ "mediatorQuerySourceIdentify": {
40
+ "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_mediatorQuerySourceIdentify"
41
+ },
36
42
  "extractSubjects": {
37
43
  "@id": "caoqosssqi:components/ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.jsonld#ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris_args_extractSubjects"
38
44
  },
@@ -1,22 +1,28 @@
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';
3
4
  import type { IActorArgs, IActorTest } from '@comunica/core';
4
5
  import { Algebra } from 'sparqlalgebrajs';
5
6
  /**
6
7
  * A comunica Set Seed Sources Quadpattern IRIs Optimize Query Operation Actor.
7
8
  */
8
9
  export declare class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris extends ActorOptimizeQueryOperation {
10
+ readonly mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;
9
11
  private readonly extractSubjects;
10
12
  private readonly extractPredicates;
11
13
  private readonly extractObjects;
12
14
  private readonly extractGraphs;
13
15
  private readonly extractVocabIris;
14
16
  constructor(args: IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs);
15
- test(action: IActionOptimizeQueryOperation): Promise<IActorTest>;
17
+ test(_action: IActionOptimizeQueryOperation): Promise<IActorTest>;
16
18
  run(action: IActionOptimizeQueryOperation): Promise<IActorOptimizeQueryOperationOutput>;
17
19
  extractIrisFromOperation(operation: Algebra.Operation): string[];
18
20
  }
19
21
  export interface IActorOptimizeQueryOperationSetSeedSourcesQuadpatternIrisArgs extends IActorArgs<IActionOptimizeQueryOperation, IActorTest, IActorOptimizeQueryOperationOutput> {
22
+ /**
23
+ * Mediator for identifying query sources.
24
+ */
25
+ mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;
20
26
  /**
21
27
  * If IRIs should be extracted from subject positions.
22
28
  * @default {true}
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  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
+ const core_1 = require("@comunica/core");
6
7
  const sparqlalgebrajs_1 = require("sparqlalgebrajs");
7
8
  /**
8
9
  * A comunica Set Seed Sources Quadpattern IRIs Optimize Query Operation Actor.
@@ -11,21 +12,35 @@ class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris extends bus_optim
11
12
  constructor(args) {
12
13
  super(args);
13
14
  }
14
- async test(action) {
15
+ async test(_action) {
15
16
  return true;
16
17
  }
17
18
  async run(action) {
18
- const contextSources = action.context.get(context_entries_1.KeysRdfResolveQuadPattern.sources);
19
- if (!contextSources || contextSources.length === 0) {
20
- const sources = [...new Set(this.extractIrisFromOperation(action.operation))];
21
- action.context = action.context.set(context_entries_1.KeysRdfResolveQuadPattern.sources, sources);
19
+ let sources = action.context.get(context_entries_1.KeysQueryOperation.querySources);
20
+ if (!sources || sources.length === 0) {
21
+ sources = await Promise.all([...new Set(this.extractIrisFromOperation(action.operation))]
22
+ .map(async (source) => {
23
+ // Remove fragment from URL
24
+ const hashPosition = source.indexOf('#');
25
+ if (hashPosition >= 0) {
26
+ source = source.slice(0, hashPosition);
27
+ }
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);
22
37
  }
23
38
  return { ...action, context: action.context };
24
39
  }
25
40
  extractIrisFromOperation(operation) {
26
41
  const iris = [];
27
42
  sparqlalgebrajs_1.Util.recurseOperation(operation, {
28
- [sparqlalgebrajs_1.Algebra.types.PATH]: path => {
43
+ [sparqlalgebrajs_1.Algebra.types.PATH]: (path) => {
29
44
  if (this.extractSubjects && path.subject.termType === 'NamedNode') {
30
45
  iris.push(path.subject.value);
31
46
  }
@@ -38,7 +53,7 @@ class ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris extends bus_optim
38
53
  }
39
54
  return false;
40
55
  },
41
- [sparqlalgebrajs_1.Algebra.types.PATTERN]: pattern => {
56
+ [sparqlalgebrajs_1.Algebra.types.PATTERN]: (pattern) => {
42
57
  if (this.extractSubjects && pattern.subject.termType === 'NamedNode') {
43
58
  iris.push(pattern.subject.value);
44
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ActorOptimizeQueryOperationSetSeedSourcesQuadpatternIris.js","sourceRoot":"","sources":["ActorOptimizeQueryOperationSet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F;AA3DD,4HA2DC","sourcesContent":["import type {\n IActionOptimizeQueryOperation,\n IActorOptimizeQueryOperationOutput,\n} from '@comunica/bus-optimize-query-operation';\nimport { ActorOptimizeQueryOperation } from '@comunica/bus-optimize-query-operation';\nimport { KeysRdfResolveQuadPattern } from '@comunica/context-entries';\nimport type { IActorArgs, IActorTest } from '@comunica/core';\nimport type { DataSources } 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 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<IActorTest> {\n return true;\n }\n\n public async run(action: IActionOptimizeQueryOperation): Promise<IActorOptimizeQueryOperationOutput> {\n const contextSources: DataSources | undefined = action.context.get(KeysRdfResolveQuadPattern.sources);\n if (!contextSources || contextSources.length === 0) {\n const sources: string[] = [ ...new Set(this.extractIrisFromOperation(action.operation)) ];\n action.context = action.context.set(KeysRdfResolveQuadPattern.sources, 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 * 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;AAErF,+DAAwF;AAExF,yCAA+C;AAE/C,qDAAgD;AAEhD;;GAEG;AACH,MAAa,wDAAyD,SAAQ,0DAA2B;IAQvG,YAAmB,IAAmE;QACpF,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,OAAsC;QACtD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,MAAqC;QACpD,IAAI,OAAO,GAAsC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,oCAAkB,CAAC,YAAY,CAAC,CAAC;QACrG,IAAI,CAAC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BAClC,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 } from '@comunica/core';\nimport { ActionContext } 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<IActorTest> {\n return true;\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"]}
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@comunica/actor-optimize-query-operation-set-seed-sources-quadpattern-iris",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "A set-seed-sources-quadpattern-iris optimize-query-operation actor",
5
5
  "lsd:module": true,
6
- "main": "lib/index.js",
7
- "typings": "lib/index",
6
+ "license": "MIT",
7
+ "homepage": "https://comunica.dev/",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/comunica/comunica.git",
11
11
  "directory": "packages/actor-optimize-query-operation-set-seed-sources-quadpattern-iris"
12
12
  },
13
- "sideEffects": false,
14
- "publishConfig": {
15
- "access": "public"
13
+ "bugs": {
14
+ "url": "https://github.com/comunica/comunica/issues"
16
15
  },
17
16
  "keywords": [
18
17
  "comunica",
@@ -20,28 +19,29 @@
20
19
  "optimize-query-operation",
21
20
  "set-seed-sources-quadpattern-iris"
22
21
  ],
23
- "license": "MIT",
24
- "bugs": {
25
- "url": "https://github.com/comunica/comunica/issues"
22
+ "sideEffects": false,
23
+ "main": "lib/index.js",
24
+ "typings": "lib/index",
25
+ "publishConfig": {
26
+ "access": "public"
26
27
  },
27
- "homepage": "https://comunica.dev/",
28
28
  "files": [
29
29
  "components",
30
30
  "lib/**/*.d.ts",
31
31
  "lib/**/*.js",
32
32
  "lib/**/*.js.map"
33
33
  ],
34
- "dependencies": {
35
- "@comunica/bus-optimize-query-operation": "^2.7.0",
36
- "@comunica/context-entries": "^2.7.0",
37
- "@comunica/core": "^2.7.0",
38
- "@comunica/types": "^2.7.0",
39
- "sparqlalgebrajs": "^4.0.2"
40
- },
41
34
  "scripts": {
42
35
  "build": "npm run build:ts && npm run build:components",
43
36
  "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
44
37
  "build:components": "componentsjs-generator"
45
38
  },
46
- "gitHead": "dfd714dab02334e45c1943da38bf1c362ca65597"
39
+ "dependencies": {
40
+ "@comunica/bus-optimize-query-operation": "^3.0.1",
41
+ "@comunica/context-entries": "^3.0.1",
42
+ "@comunica/core": "^3.0.1",
43
+ "@comunica/types": "^3.0.1",
44
+ "sparqlalgebrajs": "^4.2.0"
45
+ },
46
+ "gitHead": "328f362bb193b8ea5e0e4886a7ea3c21e28f0a67"
47
47
  }