@comunica/actor-optimize-query-operation-assign-sources-exhaustive 4.4.2-alpha.49.0 → 5.0.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 +4 -0
- package/components/ActorOptimizeQueryOperationAssignSourcesExhaustive.jsonld +15 -15
- package/components/components.jsonld +1 -1
- package/components/context.jsonld +1 -1
- package/lib/ActorOptimizeQueryOperationAssignSourcesExhaustive.d.ts +2 -1
- package/lib/ActorOptimizeQueryOperationAssignSourcesExhaustive.js +29 -24
- package/lib/ActorOptimizeQueryOperationAssignSourcesExhaustive.js.map +1 -1
- package/package.json +8 -9
package/README.md
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
An [Optimize Query Operation](https://github.com/comunica/comunica/tree/master/packages/bus-optimize-query-operation) actor
|
|
6
6
|
that converts every quad pattern in the query to a union of quad patterns per source.
|
|
7
7
|
It will similarly handle property paths.
|
|
8
|
+
It assumes that sources are defined in the `KeysQueryOperation.querySources` context entry.
|
|
9
|
+
|
|
10
|
+
If the `KeysQueryOperation.serviceSources` context entry exists,
|
|
11
|
+
SERVICE clauses will be rewritten based on those service sources.
|
|
8
12
|
|
|
9
13
|
If only a single source is being queried over, it will attempt to assign the whole query operation to the source
|
|
10
14
|
if the source supports such operations. Otherwise, it will fallback to the union-based approach.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-assign-sources-exhaustive/^
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-optimize-query-operation/^
|
|
5
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-assign-sources-exhaustive/^5.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-assign-sources-exhaustive",
|
|
8
8
|
"components": [
|
|
@@ -35,37 +35,37 @@
|
|
|
35
35
|
"genericTypeInstances": [
|
|
36
36
|
{
|
|
37
37
|
"@type": "ParameterRangeGenericTypeReference",
|
|
38
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
38
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
"@type": "ParameterRangeGenericTypeReference",
|
|
42
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
42
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"@type": "ParameterRangeGenericTypeReference",
|
|
46
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
46
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
"@type": "ParameterRangeGenericTypeReference",
|
|
50
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
50
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
51
51
|
}
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"@type": "ParameterRangeGenericTypeReference",
|
|
56
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
56
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
"@type": "ParameterRangeGenericTypeReference",
|
|
60
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
60
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
63
|
"@type": "ParameterRangeGenericTypeReference",
|
|
64
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
64
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
65
65
|
},
|
|
66
66
|
{
|
|
67
67
|
"@type": "ParameterRangeGenericTypeReference",
|
|
68
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
68
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
69
69
|
}
|
|
70
70
|
]
|
|
71
71
|
},
|
|
@@ -102,19 +102,19 @@
|
|
|
102
102
|
"genericTypeInstances": [
|
|
103
103
|
{
|
|
104
104
|
"@type": "ParameterRangeGenericTypeReference",
|
|
105
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
105
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
"@type": "ParameterRangeGenericTypeReference",
|
|
109
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
109
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
112
|
"@type": "ParameterRangeGenericTypeReference",
|
|
113
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
113
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
114
114
|
},
|
|
115
115
|
{
|
|
116
116
|
"@type": "ParameterRangeGenericTypeReference",
|
|
117
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
117
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
118
118
|
}
|
|
119
119
|
]
|
|
120
120
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-assign-sources-exhaustive/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-optimize-query-operation-assign-sources-exhaustive/^5.0.0/components/context.jsonld"
|
|
4
4
|
],
|
|
5
5
|
"@id": "npmd:@comunica/actor-optimize-query-operation-assign-sources-exhaustive",
|
|
6
6
|
"@type": "Module",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld",
|
|
4
4
|
{
|
|
5
5
|
"npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
|
|
6
|
-
"caoqoase": "npmd:@comunica/actor-optimize-query-operation-assign-sources-exhaustive/^
|
|
6
|
+
"caoqoase": "npmd:@comunica/actor-optimize-query-operation-assign-sources-exhaustive/^5.0.0/",
|
|
7
7
|
"ActorOptimizeQueryOperationAssignSourcesExhaustive": {
|
|
8
8
|
"@id": "caoqoase:components/ActorOptimizeQueryOperationAssignSourcesExhaustive.jsonld#ActorOptimizeQueryOperationAssignSourcesExhaustive",
|
|
9
9
|
"@prefix": true,
|
|
@@ -17,6 +17,7 @@ export declare class ActorOptimizeQueryOperationAssignSourcesExhaustive extends
|
|
|
17
17
|
* @param factory The algebra factory.
|
|
18
18
|
* @param operation The input operation.
|
|
19
19
|
* @param sources The sources to assign.
|
|
20
|
+
* @param serviceSources Mapping of SERVICE names to sources.
|
|
20
21
|
*/
|
|
21
|
-
assignExhaustive(factory: AlgebraFactory, operation: Algebra.Operation, sources: IQuerySourceWrapper[]): Algebra.Operation;
|
|
22
|
+
assignExhaustive(factory: AlgebraFactory, operation: Algebra.Operation, sources: IQuerySourceWrapper[], serviceSources: Record<string, IQuerySourceWrapper>): Algebra.Operation;
|
|
22
23
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActorOptimizeQueryOperationAssignSourcesExhaustive = void 0;
|
|
4
4
|
const bus_optimize_query_operation_1 = require("@comunica/bus-optimize-query-operation");
|
|
5
|
-
const bus_rdf_update_quads_1 = require("@comunica/bus-rdf-update-quads");
|
|
6
5
|
const context_entries_1 = require("@comunica/context-entries");
|
|
7
6
|
const core_1 = require("@comunica/core");
|
|
8
7
|
const utils_algebra_1 = require("@comunica/utils-algebra");
|
|
@@ -21,30 +20,18 @@ class ActorOptimizeQueryOperationAssignSourcesExhaustive extends bus_optimize_qu
|
|
|
21
20
|
const dataFactory = action.context.getSafe(context_entries_1.KeysInitQuery.dataFactory);
|
|
22
21
|
const algebraFactory = new utils_algebra_1.AlgebraFactory(dataFactory);
|
|
23
22
|
const sources = action.context.get(context_entries_1.KeysQueryOperation.querySources) ?? [];
|
|
24
|
-
|
|
23
|
+
const serviceSources = action.context.get(context_entries_1.KeysQueryOperation.serviceSources) ?? {};
|
|
24
|
+
if (sources.length === 0 && Object.keys(serviceSources).length === 0) {
|
|
25
25
|
return { operation: action.operation, context: action.context };
|
|
26
26
|
}
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const shape = await sourceWrapper.source.getSelectorShape(action.context);
|
|
33
|
-
if ((0, utils_query_operation_1.doesShapeAcceptOperation)(shape, action.operation)) {
|
|
34
|
-
return {
|
|
35
|
-
operation: (0, utils_query_operation_1.assignOperationSource)(action.operation, sourceWrapper),
|
|
36
|
-
context: action.context,
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch {
|
|
41
|
-
// Fallback to the default case when the selector shape does not exist,
|
|
42
|
-
// which can occur for a non-existent destination.
|
|
43
|
-
}
|
|
44
|
-
}
|
|
27
|
+
if (await (0, utils_query_operation_1.passFullOperationToSource)(action.operation, sources, action.context)) {
|
|
28
|
+
return {
|
|
29
|
+
operation: (0, utils_query_operation_1.assignOperationSource)(action.operation, sources[0]),
|
|
30
|
+
context: action.context,
|
|
31
|
+
};
|
|
45
32
|
}
|
|
46
33
|
return {
|
|
47
|
-
operation: this.assignExhaustive(algebraFactory, action.operation, sources),
|
|
34
|
+
operation: this.assignExhaustive(algebraFactory, action.operation, sources, serviceSources),
|
|
48
35
|
// We only keep queryString in the context if we only have a single source that accepts the full operation.
|
|
49
36
|
// In that case, the queryString can be sent to the source as-is.
|
|
50
37
|
context: action.context
|
|
@@ -58,8 +45,9 @@ class ActorOptimizeQueryOperationAssignSourcesExhaustive extends bus_optimize_qu
|
|
|
58
45
|
* @param factory The algebra factory.
|
|
59
46
|
* @param operation The input operation.
|
|
60
47
|
* @param sources The sources to assign.
|
|
48
|
+
* @param serviceSources Mapping of SERVICE names to sources.
|
|
61
49
|
*/
|
|
62
|
-
assignExhaustive(factory, operation, sources) {
|
|
50
|
+
assignExhaustive(factory, operation, sources, serviceSources) {
|
|
63
51
|
return utils_algebra_1.algebraUtils.mapOperation(operation, {
|
|
64
52
|
[utils_algebra_1.Algebra.Types.PATTERN]: {
|
|
65
53
|
preVisitor: () => ({ continue: false }),
|
|
@@ -73,10 +61,27 @@ class ActorOptimizeQueryOperationAssignSourcesExhaustive extends bus_optimize_qu
|
|
|
73
61
|
},
|
|
74
62
|
[utils_algebra_1.Algebra.Types.SERVICE]: {
|
|
75
63
|
preVisitor: () => ({ continue: false }),
|
|
64
|
+
transform: (serviceOp) => {
|
|
65
|
+
if (serviceOp.name.termType === 'NamedNode') {
|
|
66
|
+
let source = serviceSources[serviceOp.name.value];
|
|
67
|
+
if (source) {
|
|
68
|
+
if (serviceOp.silent) {
|
|
69
|
+
source = {
|
|
70
|
+
...source,
|
|
71
|
+
context: (source.context ?? new core_1.ActionContext()).set(context_entries_1.KeysInitQuery.lenient, true),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return this.assignExhaustive(factory, serviceOp.input, [source],
|
|
75
|
+
// Pass empty serviceSources to ensure nested SERVICE clauses are not transformed.
|
|
76
|
+
{});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return serviceOp;
|
|
80
|
+
},
|
|
76
81
|
},
|
|
77
82
|
[utils_algebra_1.Algebra.Types.CONSTRUCT]: {
|
|
78
83
|
preVisitor: () => ({ continue: false }),
|
|
79
|
-
transform: constructOp => factory.createConstruct(this.assignExhaustive(factory, constructOp.input, sources), constructOp.template),
|
|
84
|
+
transform: constructOp => factory.createConstruct(this.assignExhaustive(factory, constructOp.input, sources, serviceSources), constructOp.template),
|
|
80
85
|
},
|
|
81
86
|
[utils_algebra_1.Algebra.Types.LINK]: {
|
|
82
87
|
preVisitor: () => ({ continue: false }),
|
|
@@ -100,7 +105,7 @@ class ActorOptimizeQueryOperationAssignSourcesExhaustive extends bus_optimize_qu
|
|
|
100
105
|
},
|
|
101
106
|
[utils_algebra_1.Algebra.Types.DELETE_INSERT]: {
|
|
102
107
|
preVisitor: () => ({ continue: false }),
|
|
103
|
-
transform: delInsOp => factory.createDeleteInsert(delInsOp.delete, delInsOp.insert, delInsOp.where ? this.assignExhaustive(factory, delInsOp.where, sources) : undefined),
|
|
108
|
+
transform: delInsOp => factory.createDeleteInsert(delInsOp.delete, delInsOp.insert, delInsOp.where ? this.assignExhaustive(factory, delInsOp.where, sources, serviceSources) : undefined),
|
|
104
109
|
},
|
|
105
110
|
});
|
|
106
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorOptimizeQueryOperationAssignSourcesExhaustive.js","sourceRoot":"","sources":["ActorOptimizeQueryOperationAssignSourcesExhaustive.ts"],"names":[],"mappings":";;;AAKA,yFAAqF;AACrF
|
|
1
|
+
{"version":3,"file":"ActorOptimizeQueryOperationAssignSourcesExhaustive.js","sourceRoot":"","sources":["ActorOptimizeQueryOperationAssignSourcesExhaustive.ts"],"names":[],"mappings":";;;AAKA,yFAAqF;AACrF,+DAA8E;AAE9E,yCAA6D;AAE7D,2DAAgF;AAChF,2EAGyC;AAEzC;;GAEG;AACH,MAAa,kDAAmD,SAAQ,0DAA2B;IACjG,YAAmB,IAAsC;QACvD,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,OAAsC;QACtD,OAAO,IAAA,mBAAY,GAAE,CAAC;IACxB,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,MAAqC;QACpD,MAAM,WAAW,GAAwB,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,+BAAa,CAAC,WAAW,CAAC,CAAC;QAC3F,MAAM,cAAc,GAAG,IAAI,8BAAc,CAAC,WAAW,CAAC,CAAC;QAEvD,MAAM,OAAO,GAAG,M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CAAC,uBAAO,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE;gBAC7B,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;gBACvC,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAC/C,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,MAAM,EACf,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS,CACrG;aACF;SACF,CAAC,CAAC;IACL,CAAC;CACF;AAxHD,gHAwHC","sourcesContent":["import type {\n IActionOptimizeQueryOperation,\n IActorOptimizeQueryOperationOutput,\n IActorOptimizeQueryOperationArgs,\n} from '@comunica/bus-optimize-query-operation';\nimport { ActorOptimizeQueryOperation } from '@comunica/bus-optimize-query-operation';\nimport { KeysInitQuery, KeysQueryOperation } from '@comunica/context-entries';\nimport type { IActorTest, TestResult } from '@comunica/core';\nimport { ActionContext, passTestVoid } from '@comunica/core';\nimport type { ComunicaDataFactory, IQuerySourceWrapper } from '@comunica/types';\nimport { Algebra, AlgebraFactory, algebraUtils } from '@comunica/utils-algebra';\nimport {\n assignOperationSource,\n passFullOperationToSource,\n} from '@comunica/utils-query-operation';\n\n/**\n * A comunica Assign Sources Exhaustive Optimize Query Operation Actor.\n */\nexport class ActorOptimizeQueryOperationAssignSourcesExhaustive extends ActorOptimizeQueryOperation {\n public constructor(args: IActorOptimizeQueryOperationArgs) {\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 const dataFactory: ComunicaDataFactory = action.context.getSafe(KeysInitQuery.dataFactory);\n const algebraFactory = new AlgebraFactory(dataFactory);\n\n const sources = action.context.get(KeysQueryOperation.querySources) ?? [];\n const serviceSources = action.context.get(KeysQueryOperation.serviceSources) ?? {};\n if (sources.length === 0 && Object.keys(serviceSources).length === 0) {\n return { operation: action.operation, context: action.context };\n }\n if (await passFullOperationToSource(action.operation, sources, action.context)) {\n return {\n operation: assignOperationSource(action.operation, sources[0]),\n context: action.context,\n };\n }\n return {\n operation: this.assignExhaustive(algebraFactory, action.operation, sources, serviceSources),\n // We only keep queryString in the context if we only have a single source that accepts the full operation.\n // In that case, the queryString can be sent to the source as-is.\n context: action.context\n .delete(KeysInitQuery.queryString),\n };\n }\n\n /**\n * Assign the given sources to the leaves in the given query operation.\n * Leaves will be wrapped in a union operation and duplicated for every source.\n * The input operation will not be modified.\n * @param factory The algebra factory.\n * @param operation The input operation.\n * @param sources The sources to assign.\n * @param serviceSources Mapping of SERVICE names to sources.\n */\n public assignExhaustive(\n factory: AlgebraFactory,\n operation: Algebra.Operation,\n sources: IQuerySourceWrapper[],\n serviceSources: Record<string, IQuerySourceWrapper>,\n ): Algebra.Operation {\n return algebraUtils.mapOperation(operation, {\n [Algebra.Types.PATTERN]: {\n preVisitor: () => ({ continue: false }),\n transform: (patternOp) => {\n if (sources.length === 1) {\n return assignOperationSource(patternOp, sources[0]);\n }\n return factory.createUnion(sources\n .map(source => assignOperationSource(patternOp, source)));\n },\n },\n [Algebra.Types.SERVICE]: {\n preVisitor: () => ({ continue: false }),\n transform: (serviceOp) => {\n if (serviceOp.name.termType === 'NamedNode') {\n let source = serviceSources[serviceOp.name.value];\n if (source) {\n if (serviceOp.silent) {\n source = {\n ...source,\n context: (source.context ?? new ActionContext()).set(KeysInitQuery.lenient, true),\n };\n }\n return this.assignExhaustive(\n factory,\n serviceOp.input,\n [ source ],\n // Pass empty serviceSources to ensure nested SERVICE clauses are not transformed.\n {},\n );\n }\n }\n return serviceOp;\n },\n },\n [Algebra.Types.CONSTRUCT]: {\n preVisitor: () => ({ continue: false }),\n transform: constructOp => factory.createConstruct(\n this.assignExhaustive(factory, constructOp.input, sources, serviceSources),\n constructOp.template,\n ),\n },\n [Algebra.Types.LINK]: {\n preVisitor: () => ({ continue: false }),\n transform: (linkOp) => {\n if (sources.length === 1) {\n return assignOperationSource(linkOp, sources[0]);\n }\n return factory.createAlt(sources\n .map(source => assignOperationSource(linkOp, source)));\n },\n },\n [Algebra.Types.NPS]: {\n preVisitor: () => ({ continue: false }),\n transform: (npsOp) => {\n if (sources.length === 1) {\n return assignOperationSource(npsOp, sources[0]);\n }\n return factory.createAlt(sources\n .map(source => assignOperationSource(npsOp, source)));\n },\n },\n [Algebra.Types.DELETE_INSERT]: {\n preVisitor: () => ({ continue: false }),\n transform: delInsOp => factory.createDeleteInsert(\n delInsOp.delete,\n delInsOp.insert,\n delInsOp.where ? this.assignExhaustive(factory, delInsOp.where, sources, serviceSources) : undefined,\n ),\n },\n });\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-optimize-query-operation-assign-sources-exhaustive",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "A assign-sources-exhaustive optimize-query-operation actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,13 +41,12 @@
|
|
|
41
41
|
"build:components": "componentsjs-generator"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@comunica/bus-optimize-query-operation": "
|
|
45
|
-
"@comunica/
|
|
46
|
-
"@comunica/
|
|
47
|
-
"@comunica/
|
|
48
|
-
"@comunica/
|
|
49
|
-
"@comunica/utils-
|
|
50
|
-
"@comunica/utils-query-operation": "4.4.2-alpha.49.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/types": "^5.0.0",
|
|
48
|
+
"@comunica/utils-algebra": "^5.0.0",
|
|
49
|
+
"@comunica/utils-query-operation": "^5.0.0"
|
|
51
50
|
},
|
|
52
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "0b1756fdb9bef014133432489627c1bd71779bd0"
|
|
53
52
|
}
|