@comunica/actor-query-operation-project 3.3.0 → 4.0.1
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 +1 -1
- package/components/ActorQueryOperationProject.jsonld +44 -12
- package/components/components.jsonld +1 -1
- package/components/context.jsonld +7 -1
- package/lib/ActorQueryOperationProject.d.ts +2 -2
- package/lib/ActorQueryOperationProject.js +25 -18
- package/lib/ActorQueryOperationProject.js.map +1 -1
- package/package.json +13 -8
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ 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-query-operation-project/^
|
|
25
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-project/^4.0.0/components/context.jsonld"
|
|
26
26
|
],
|
|
27
27
|
"actors": [
|
|
28
28
|
...
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-project/^
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^
|
|
5
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-query-operation/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-project/^4.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-query-operation/^4.0.0/components/context.jsonld"
|
|
6
6
|
],
|
|
7
7
|
"@id": "npmd:@comunica/actor-query-operation-project",
|
|
8
8
|
"components": [
|
|
@@ -45,29 +45,37 @@
|
|
|
45
45
|
"genericTypeInstances": [
|
|
46
46
|
{
|
|
47
47
|
"@type": "ParameterRangeGenericTypeReference",
|
|
48
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
48
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
49
49
|
},
|
|
50
50
|
{
|
|
51
51
|
"@type": "ParameterRangeGenericTypeReference",
|
|
52
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
52
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"@type": "ParameterRangeGenericTypeReference",
|
|
56
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
56
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
60
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
57
61
|
}
|
|
58
62
|
]
|
|
59
63
|
},
|
|
60
64
|
{
|
|
61
65
|
"@type": "ParameterRangeGenericTypeReference",
|
|
62
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
66
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
70
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
63
71
|
},
|
|
64
72
|
{
|
|
65
73
|
"@type": "ParameterRangeGenericTypeReference",
|
|
66
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
74
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
67
75
|
},
|
|
68
76
|
{
|
|
69
77
|
"@type": "ParameterRangeGenericTypeReference",
|
|
70
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
78
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
71
79
|
}
|
|
72
80
|
]
|
|
73
81
|
},
|
|
@@ -77,6 +85,20 @@
|
|
|
77
85
|
},
|
|
78
86
|
"comment": "The bus this actor subscribes to."
|
|
79
87
|
},
|
|
88
|
+
{
|
|
89
|
+
"@id": "caqop:components/ActorQueryOperationProject.jsonld#ActorQueryOperationProject_args_busFailMessage",
|
|
90
|
+
"range": {
|
|
91
|
+
"@type": "ParameterRangeUnion",
|
|
92
|
+
"parameterRangeElements": [
|
|
93
|
+
"xsd:string",
|
|
94
|
+
{
|
|
95
|
+
"@type": "ParameterRangeUndefined"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"default": "Query operation processing failed: none of the configured actors were able to handle the operation type ${action.operation.type}",
|
|
100
|
+
"comment": "The message that will be configured in the bus for reporting failures. This message may be a template string that contains references to the executed `action`. For example, the following templated string is allowed: \"RDF dereferencing failed: no actors could handle ${action.handle.mediaType}\""
|
|
101
|
+
},
|
|
80
102
|
{
|
|
81
103
|
"@id": "caqop:components/ActorQueryOperationProject.jsonld#ActorQueryOperationProject_args_beforeActors",
|
|
82
104
|
"range": {
|
|
@@ -90,15 +112,19 @@
|
|
|
90
112
|
"genericTypeInstances": [
|
|
91
113
|
{
|
|
92
114
|
"@type": "ParameterRangeGenericTypeReference",
|
|
93
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
115
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
94
116
|
},
|
|
95
117
|
{
|
|
96
118
|
"@type": "ParameterRangeGenericTypeReference",
|
|
97
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
119
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
98
120
|
},
|
|
99
121
|
{
|
|
100
122
|
"@type": "ParameterRangeGenericTypeReference",
|
|
101
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
123
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"@type": "ParameterRangeGenericTypeReference",
|
|
127
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^4.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
102
128
|
}
|
|
103
129
|
]
|
|
104
130
|
}
|
|
@@ -147,6 +173,12 @@
|
|
|
147
173
|
"@id": "caqop:components/ActorQueryOperationProject.jsonld#ActorQueryOperationProject_args_bus"
|
|
148
174
|
}
|
|
149
175
|
},
|
|
176
|
+
{
|
|
177
|
+
"keyRaw": "busFailMessage",
|
|
178
|
+
"value": {
|
|
179
|
+
"@id": "caqop:components/ActorQueryOperationProject.jsonld#ActorQueryOperationProject_args_busFailMessage"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
150
182
|
{
|
|
151
183
|
"keyRaw": "beforeActors",
|
|
152
184
|
"value": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-project/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-operation-project/^4.0.0/components/context.jsonld"
|
|
4
4
|
],
|
|
5
5
|
"@id": "npmd:@comunica/actor-query-operation-project",
|
|
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
|
-
"caqop": "npmd:@comunica/actor-query-operation-project/^
|
|
6
|
+
"caqop": "npmd:@comunica/actor-query-operation-project/^4.0.0/",
|
|
7
7
|
"ActorQueryOperationProject": {
|
|
8
8
|
"@id": "caqop:components/ActorQueryOperationProject.jsonld#ActorQueryOperationProject",
|
|
9
9
|
"@prefix": true,
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"args_bus": {
|
|
18
18
|
"@id": "caqop:components/ActorQueryOperationProject.jsonld#ActorQueryOperationProject_args_bus"
|
|
19
19
|
},
|
|
20
|
+
"args_busFailMessage": {
|
|
21
|
+
"@id": "caqop:components/ActorQueryOperationProject.jsonld#ActorQueryOperationProject_args_busFailMessage"
|
|
22
|
+
},
|
|
20
23
|
"args_beforeActors": {
|
|
21
24
|
"@id": "caqop:components/ActorQueryOperationProject.jsonld#ActorQueryOperationProject_args_beforeActors",
|
|
22
25
|
"@container": "@list"
|
|
@@ -30,6 +33,9 @@
|
|
|
30
33
|
"bus": {
|
|
31
34
|
"@id": "caqop:components/ActorQueryOperationProject.jsonld#ActorQueryOperationProject_args_bus"
|
|
32
35
|
},
|
|
36
|
+
"busFailMessage": {
|
|
37
|
+
"@id": "caqop:components/ActorQueryOperationProject.jsonld#ActorQueryOperationProject_args_busFailMessage"
|
|
38
|
+
},
|
|
33
39
|
"beforeActors": {
|
|
34
40
|
"@id": "caqop:components/ActorQueryOperationProject.jsonld#ActorQueryOperationProject_args_beforeActors",
|
|
35
41
|
"@container": "@list"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IActorQueryOperationTypedMediatedArgs } from '@comunica/bus-query-operation';
|
|
2
2
|
import { ActorQueryOperationTypedMediated } from '@comunica/bus-query-operation';
|
|
3
|
-
import type { IActorTest } from '@comunica/core';
|
|
3
|
+
import type { IActorTest, TestResult } from '@comunica/core';
|
|
4
4
|
import type { IActionContext, IQueryOperationResult } from '@comunica/types';
|
|
5
5
|
import type { Algebra } from 'sparqlalgebrajs';
|
|
6
6
|
/**
|
|
@@ -8,6 +8,6 @@ import type { Algebra } from 'sparqlalgebrajs';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare class ActorQueryOperationProject extends ActorQueryOperationTypedMediated<Algebra.Project> {
|
|
10
10
|
constructor(args: IActorQueryOperationTypedMediatedArgs);
|
|
11
|
-
testOperation(_operation: Algebra.Project, _context: IActionContext): Promise<IActorTest
|
|
11
|
+
testOperation(_operation: Algebra.Project, _context: IActionContext): Promise<TestResult<IActorTest>>;
|
|
12
12
|
runOperation(operation: Algebra.Project, context: IActionContext): Promise<IQueryOperationResult>;
|
|
13
13
|
}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActorQueryOperationProject = void 0;
|
|
4
4
|
const bus_query_operation_1 = require("@comunica/bus-query-operation");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const context_entries_1 = require("@comunica/context-entries");
|
|
6
|
+
const core_1 = require("@comunica/core");
|
|
7
|
+
const utils_data_factory_1 = require("@comunica/utils-data-factory");
|
|
8
|
+
const utils_query_operation_1 = require("@comunica/utils-query-operation");
|
|
8
9
|
/**
|
|
9
10
|
* A comunica Project Query Operation Actor.
|
|
10
11
|
*/
|
|
@@ -13,28 +14,34 @@ class ActorQueryOperationProject extends bus_query_operation_1.ActorQueryOperati
|
|
|
13
14
|
super(args, 'project');
|
|
14
15
|
}
|
|
15
16
|
async testOperation(_operation, _context) {
|
|
16
|
-
return
|
|
17
|
+
return (0, core_1.passTestVoid)();
|
|
17
18
|
}
|
|
18
19
|
async runOperation(operation, context) {
|
|
20
|
+
const dataFactory = context.getSafe(context_entries_1.KeysInitQuery.dataFactory);
|
|
19
21
|
// Resolve the input
|
|
20
|
-
const output =
|
|
21
|
-
//
|
|
22
|
+
const output = (0, utils_query_operation_1.getSafeBindings)(await this.mediatorQueryOperation.mediate({ operation: operation.input, context }));
|
|
23
|
+
// Index variables
|
|
22
24
|
const outputMetadata = await output.metadata();
|
|
23
|
-
const
|
|
25
|
+
const variablesOutputIndexed = Object
|
|
26
|
+
.fromEntries(outputMetadata.variables.map(entry => [entry.variable.value, entry]));
|
|
27
|
+
const variablesOperation = operation.variables.map(v => ({ variable: v, canBeUndef: false }));
|
|
28
|
+
const variablesOperationIndexed = Object
|
|
29
|
+
.fromEntries(variablesOperation.map(entry => [entry.variable.value, entry]));
|
|
30
|
+
// Find all variables that should be deleted from the input stream.
|
|
24
31
|
const deleteVariables = outputMetadata.variables
|
|
25
|
-
.filter(variable => !
|
|
26
|
-
//
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
+
.filter(variable => !(variable.variable.value in variablesOperationIndexed));
|
|
33
|
+
// Determine if variables can be undef
|
|
34
|
+
const variablesOutput = variablesOperation.map(variable => ({
|
|
35
|
+
variable: variable.variable,
|
|
36
|
+
canBeUndef: !(variable.variable.value in variablesOutputIndexed) ||
|
|
37
|
+
variablesOutputIndexed[variable.variable.value].canBeUndef,
|
|
38
|
+
}));
|
|
32
39
|
// Make sure the project variables are the only variables that are present in the bindings.
|
|
33
40
|
let bindingsStream = deleteVariables.length === 0 ?
|
|
34
41
|
output.bindingsStream :
|
|
35
42
|
output.bindingsStream.map((bindings) => {
|
|
36
43
|
for (const deleteVariable of deleteVariables) {
|
|
37
|
-
bindings = bindings.delete(deleteVariable);
|
|
44
|
+
bindings = bindings.delete(deleteVariable.variable);
|
|
38
45
|
}
|
|
39
46
|
return bindings;
|
|
40
47
|
});
|
|
@@ -46,10 +53,10 @@ class ActorQueryOperationProject extends bus_query_operation_1.ActorQueryOperati
|
|
|
46
53
|
blankNodeCounter++;
|
|
47
54
|
const scopedBlankNodesCache = new Map();
|
|
48
55
|
return bindings.map((term) => {
|
|
49
|
-
if (term instanceof
|
|
56
|
+
if (term instanceof utils_data_factory_1.BlankNodeBindingsScoped) {
|
|
50
57
|
let scopedBlankNode = scopedBlankNodesCache.get(term.value);
|
|
51
58
|
if (!scopedBlankNode) {
|
|
52
|
-
scopedBlankNode =
|
|
59
|
+
scopedBlankNode = dataFactory.blankNode(`${term.value}${blankNodeCounter}`);
|
|
53
60
|
scopedBlankNodesCache.set(term.value, scopedBlankNode);
|
|
54
61
|
}
|
|
55
62
|
return scopedBlankNode;
|
|
@@ -60,7 +67,7 @@ class ActorQueryOperationProject extends bus_query_operation_1.ActorQueryOperati
|
|
|
60
67
|
return {
|
|
61
68
|
type: 'bindings',
|
|
62
69
|
bindingsStream,
|
|
63
|
-
metadata: async () => ({ ...outputMetadata, variables }),
|
|
70
|
+
metadata: async () => ({ ...outputMetadata, variables: variablesOutput }),
|
|
64
71
|
};
|
|
65
72
|
}
|
|
66
73
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorQueryOperationProject.js","sourceRoot":"","sources":["ActorQueryOperationProject.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"ActorQueryOperationProject.js","sourceRoot":"","sources":["ActorQueryOperationProject.ts"],"names":[],"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AAe,GAAG,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;oBAC5D,IAAI,CAAC,eAAe,EAAE,CAAC;wBACrB,eAAe,GAAG,WAAW,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,KAAK,GAAG,gBAAgB,EAAE,CAAC,CAAC;wBAC5E,qBAAqB,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;oBACzD,CAAC;oBACD,OAAO,eAAe,CAAC;gBACzB,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,cAAc;YACd,QAAQ,EAAE,KAAK,IAAG,EAAE,CAAC,CAAC,EAAE,GAAG,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC;SACzE,CAAC;IACJ,CAAC;CACF;AAzED,gEAyEC","sourcesContent":["import type { IActorQueryOperationTypedMediatedArgs } from '@comunica/bus-query-operation';\nimport { ActorQueryOperationTypedMediated } from '@comunica/bus-query-operation';\nimport { KeysInitQuery } from '@comunica/context-entries';\nimport type { IActorTest, TestResult } from '@comunica/core';\nimport { passTestVoid } from '@comunica/core';\nimport type {\n Bindings,\n BindingsStream,\n ComunicaDataFactory,\n IActionContext,\n IQueryOperationResult,\n IQueryOperationResultBindings,\n MetadataVariable,\n} from '@comunica/types';\nimport { BlankNodeBindingsScoped } from '@comunica/utils-data-factory';\nimport { getSafeBindings } from '@comunica/utils-query-operation';\nimport type * as RDF from '@rdfjs/types';\nimport type { Algebra } from 'sparqlalgebrajs';\n\n/**\n * A comunica Project Query Operation Actor.\n */\nexport class ActorQueryOperationProject extends ActorQueryOperationTypedMediated<Algebra.Project> {\n public constructor(args: IActorQueryOperationTypedMediatedArgs) {\n super(args, 'project');\n }\n\n public async testOperation(_operation: Algebra.Project, _context: IActionContext): Promise<TestResult<IActorTest>> {\n return passTestVoid();\n }\n\n public async runOperation(operation: Algebra.Project, context: IActionContext):\n Promise<IQueryOperationResult> {\n const dataFactory: ComunicaDataFactory = context.getSafe(KeysInitQuery.dataFactory);\n\n // Resolve the input\n const output: IQueryOperationResultBindings = getSafeBindings(\n await this.mediatorQueryOperation.mediate({ operation: operation.input, context }),\n );\n\n // Index variables\n const outputMetadata = await output.metadata();\n const variablesOutputIndexed: Record<string, MetadataVariable> = Object\n .fromEntries(outputMetadata.variables.map(entry => [ entry.variable.value, entry ]));\n const variablesOperation: MetadataVariable[] = operation.variables.map(v => ({ variable: v, canBeUndef: false }));\n const variablesOperationIndexed: Record<string, MetadataVariable> = Object\n .fromEntries(variablesOperation.map(entry => [ entry.variable.value, entry ]));\n\n // Find all variables that should be deleted from the input stream.\n const deleteVariables = outputMetadata.variables\n .filter(variable => !(variable.variable.value in variablesOperationIndexed));\n\n // Determine if variables can be undef\n const variablesOutput: MetadataVariable[] = variablesOperation.map(variable => ({\n variable: variable.variable,\n canBeUndef: !(variable.variable.value in variablesOutputIndexed) ||\n variablesOutputIndexed[variable.variable.value].canBeUndef,\n }));\n\n // Make sure the project variables are the only variables that are present in the bindings.\n let bindingsStream: BindingsStream = deleteVariables.length === 0 ?\n output.bindingsStream :\n output.bindingsStream.map((bindings: Bindings) => {\n for (const deleteVariable of deleteVariables) {\n bindings = bindings.delete(deleteVariable.variable);\n }\n return bindings;\n });\n\n // Make sure that blank nodes with same labels are not reused over different bindings, as required by SPARQL 1.1.\n // Required for the BNODE() function: https://www.w3.org/TR/sparql11-query/#func-bnode\n // When we have a scoped blank node, make sure the skolemized value is maintained.\n let blankNodeCounter = 0;\n bindingsStream = bindingsStream.map((bindings: Bindings) => {\n blankNodeCounter++;\n const scopedBlankNodesCache = new Map<string, RDF.BlankNode>();\n return bindings.map((term) => {\n if (term instanceof BlankNodeBindingsScoped) {\n let scopedBlankNode = scopedBlankNodesCache.get(term.value);\n if (!scopedBlankNode) {\n scopedBlankNode = dataFactory.blankNode(`${term.value}${blankNodeCounter}`);\n scopedBlankNodesCache.set(term.value, scopedBlankNode);\n }\n return scopedBlankNode;\n }\n return term;\n });\n });\n\n return {\n type: 'bindings',\n bindingsStream,\n metadata: async() => ({ ...outputMetadata, variables: variablesOutput }),\n };\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-query-operation-project",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "A project query-operation actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"funding": {
|
|
8
|
+
"type": "opencollective",
|
|
9
|
+
"url": "https://opencollective.com/comunica-association"
|
|
10
|
+
},
|
|
7
11
|
"homepage": "https://comunica.dev/",
|
|
8
12
|
"repository": {
|
|
9
13
|
"type": "git",
|
|
@@ -37,13 +41,14 @@
|
|
|
37
41
|
"build:components": "componentsjs-generator"
|
|
38
42
|
},
|
|
39
43
|
"dependencies": {
|
|
40
|
-
"@comunica/bus-query-operation": "^
|
|
41
|
-
"@comunica/
|
|
42
|
-
"@comunica/
|
|
43
|
-
"@comunica/types": "^
|
|
44
|
+
"@comunica/bus-query-operation": "^4.0.1",
|
|
45
|
+
"@comunica/context-entries": "^4.0.1",
|
|
46
|
+
"@comunica/core": "^4.0.1",
|
|
47
|
+
"@comunica/types": "^4.0.1",
|
|
48
|
+
"@comunica/utils-data-factory": "^4.0.1",
|
|
49
|
+
"@comunica/utils-query-operation": "^4.0.1",
|
|
44
50
|
"@rdfjs/types": "*",
|
|
45
|
-
"
|
|
46
|
-
"sparqlalgebrajs": "^4.3.7"
|
|
51
|
+
"sparqlalgebrajs": "^4.3.8"
|
|
47
52
|
},
|
|
48
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "67831ba79e45ea1ced41fe3f83c5d6e8802dbeaa"
|
|
49
54
|
}
|