@comunica/actor-query-process-annotate-source-binding 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2017–now Ruben Taelman, Joachim Van Herwegen
4
+ Comunica Association and Ghent University – imec, Belgium
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Comunica Annotate Source Binding Query Process Actor
2
+
3
+ [![npm version](https://badge.fury.io/js/%40comunica%2Factor-query-process-annotate-source-binding.svg)](https://www.npmjs.com/package/@comunica/actor-query-process-annotate-source-binding)
4
+
5
+ A comunica Annotate Source Binding Query Process Actor that wraps around [actor-query-process-sequential](https://www.npmjs.com/package/@comunica/actor-query-process-sequential).
6
+ The wrapper processes sources in the context of any produced bindings.
7
+ It creates a new binding variable ```_source``` with a value equal to the extracted sources, enabling any serialization actor to include the tracked source information.
8
+
9
+ This module is part of the [Comunica framework](https://github.com/comunica/comunica),
10
+ and should only be used by [developers that want to build their own query engine](https://comunica.dev/docs/modify/).
11
+
12
+ [Click here if you just want to query with Comunica](https://comunica.dev/docs/query/).
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ $ yarn add @comunica/actor-query-process-annotate-source-binding
18
+ ```
19
+
20
+ ## Configure
21
+
22
+ After installing, this package can be added to your engine's configuration as follows:
23
+ ```text
24
+ {
25
+ "@context": [
26
+ ...
27
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-process-annotate-source-binding/^1.0.0/components/context.jsonld"
28
+ ],
29
+ "actors": [
30
+ ...
31
+ {
32
+ "@id": "urn:comunica:default:query-process/actors#annotate-source-binding",
33
+ "@type": "ActorQueryProcessAnnotateSourceBinding"
34
+ }
35
+ ]
36
+ }
37
+ ```
38
+
39
+ ### Config Parameters
40
+
41
+ * `mediatorQueryProcess`: A mediator over the [query process bus](https://github.com/comunica/comunica/tree/master/packages/bus-context-preprocess).
@@ -0,0 +1,182 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-process-annotate-source-binding/^3.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-query-process/^3.0.0/components/context.jsonld"
6
+ ],
7
+ "@id": "npmd:@comunica/actor-query-process-annotate-source-binding",
8
+ "components": [
9
+ {
10
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding",
11
+ "@type": "Class",
12
+ "requireElement": "ActorQueryProcessAnnotateSourceBinding",
13
+ "extends": [
14
+ "cbqp:components/ActorQueryProcess.jsonld#ActorQueryProcess"
15
+ ],
16
+ "comment": "A comunica Annotate Source Binding Query Process Actor.",
17
+ "parameters": [
18
+ {
19
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_mediatorQueryProcess",
20
+ "range": "cc:components/Mediator.jsonld#Mediator",
21
+ "comment": "The query process mediator so we can call our wrapped actor"
22
+ },
23
+ {
24
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_name",
25
+ "range": "xsd:string",
26
+ "default": {
27
+ "@id": "rdf:subject"
28
+ },
29
+ "comment": "The name for this actor."
30
+ },
31
+ {
32
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_bus",
33
+ "range": {
34
+ "@type": "ParameterRangeGenericComponent",
35
+ "component": "cc:components/Bus.jsonld#Bus",
36
+ "genericTypeInstances": [
37
+ {
38
+ "@type": "ParameterRangeGenericComponent",
39
+ "component": "cc:components/Actor.jsonld#Actor",
40
+ "genericTypeInstances": [
41
+ {
42
+ "@type": "ParameterRangeGenericTypeReference",
43
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
44
+ },
45
+ {
46
+ "@type": "ParameterRangeGenericTypeReference",
47
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
48
+ },
49
+ {
50
+ "@type": "ParameterRangeGenericTypeReference",
51
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "@type": "ParameterRangeGenericTypeReference",
57
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
58
+ },
59
+ {
60
+ "@type": "ParameterRangeGenericTypeReference",
61
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
62
+ },
63
+ {
64
+ "@type": "ParameterRangeGenericTypeReference",
65
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
66
+ }
67
+ ]
68
+ },
69
+ "default": {
70
+ "@id": "cbqp:components/ActorQueryProcess.jsonld#ActorQueryProcess_default_bus",
71
+ "@type": "cc:components/Bus.jsonld#Bus"
72
+ },
73
+ "comment": "The bus this actor subscribes to."
74
+ },
75
+ {
76
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_beforeActors",
77
+ "range": {
78
+ "@type": "ParameterRangeUnion",
79
+ "parameterRangeElements": [
80
+ {
81
+ "@type": "ParameterRangeArray",
82
+ "parameterRangeValue": {
83
+ "@type": "ParameterRangeGenericComponent",
84
+ "component": "cc:components/Actor.jsonld#Actor",
85
+ "genericTypeInstances": [
86
+ {
87
+ "@type": "ParameterRangeGenericTypeReference",
88
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
89
+ },
90
+ {
91
+ "@type": "ParameterRangeGenericTypeReference",
92
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
93
+ },
94
+ {
95
+ "@type": "ParameterRangeGenericTypeReference",
96
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
97
+ }
98
+ ]
99
+ }
100
+ },
101
+ {
102
+ "@type": "ParameterRangeUndefined"
103
+ }
104
+ ]
105
+ },
106
+ "comment": "Actor that must be registered in the bus before this actor."
107
+ }
108
+ ],
109
+ "memberFields": [
110
+ {
111
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding__member_dataFactory",
112
+ "memberFieldName": "dataFactory"
113
+ },
114
+ {
115
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding__member_mediatorQueryProcess",
116
+ "memberFieldName": "mediatorQueryProcess",
117
+ "range": "cc:components/Mediator.jsonld#Mediator"
118
+ },
119
+ {
120
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding__member_constructor",
121
+ "memberFieldName": "constructor"
122
+ },
123
+ {
124
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding__member_test",
125
+ "memberFieldName": "test"
126
+ },
127
+ {
128
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding__member_run",
129
+ "memberFieldName": "run"
130
+ },
131
+ {
132
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding__member_addSourcesToBindings",
133
+ "memberFieldName": "addSourcesToBindings"
134
+ }
135
+ ],
136
+ "constructorArguments": [
137
+ {
138
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args__constructorArgument",
139
+ "fields": [
140
+ {
141
+ "keyRaw": "mediatorQueryProcess",
142
+ "value": {
143
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_mediatorQueryProcess"
144
+ }
145
+ },
146
+ {
147
+ "keyRaw": "name",
148
+ "value": {
149
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_name"
150
+ }
151
+ },
152
+ {
153
+ "keyRaw": "bus",
154
+ "value": {
155
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_bus"
156
+ }
157
+ },
158
+ {
159
+ "keyRaw": "beforeActors",
160
+ "value": {
161
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_beforeActors"
162
+ }
163
+ }
164
+ ]
165
+ }
166
+ ]
167
+ },
168
+ {
169
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#IActorQueryProcessAnnotateSourceBindingArgs",
170
+ "@type": "AbstractClass",
171
+ "requireElement": "IActorQueryProcessAnnotateSourceBindingArgs",
172
+ "parameters": [],
173
+ "memberFields": [
174
+ {
175
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#IActorQueryProcessAnnotateSourceBindingArgs__member_mediatorQueryProcess",
176
+ "memberFieldName": "mediatorQueryProcess"
177
+ }
178
+ ],
179
+ "constructorArguments": []
180
+ }
181
+ ]
182
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-process-annotate-source-binding/^3.0.0/components/context.jsonld"
4
+ ],
5
+ "@id": "npmd:@comunica/actor-query-process-annotate-source-binding",
6
+ "@type": "Module",
7
+ "requireName": "@comunica/actor-query-process-annotate-source-binding",
8
+ "import": [
9
+ "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld"
10
+ ]
11
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^6.0.0/components/context.jsonld",
4
+ {
5
+ "npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
6
+ "caqpasb": "npmd:@comunica/actor-query-process-annotate-source-binding/^3.0.0/",
7
+ "ActorQueryProcessAnnotateSourceBinding": {
8
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding",
9
+ "@prefix": true,
10
+ "@context": {
11
+ "args_mediatorQueryProcess": {
12
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_mediatorQueryProcess"
13
+ },
14
+ "args_name": {
15
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_name"
16
+ },
17
+ "args_bus": {
18
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_bus"
19
+ },
20
+ "args_beforeActors": {
21
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_beforeActors",
22
+ "@container": "@list"
23
+ },
24
+ "mediatorQueryProcess": {
25
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_mediatorQueryProcess"
26
+ },
27
+ "name": {
28
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_name"
29
+ },
30
+ "bus": {
31
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_bus"
32
+ },
33
+ "beforeActors": {
34
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#ActorQueryProcessAnnotateSourceBinding_args_beforeActors",
35
+ "@container": "@list"
36
+ }
37
+ }
38
+ },
39
+ "IActorQueryProcessAnnotateSourceBindingArgs": {
40
+ "@id": "caqpasb:components/ActorQueryProcessAnnotateSourceBinding.jsonld#IActorQueryProcessAnnotateSourceBindingArgs",
41
+ "@prefix": true,
42
+ "@context": {}
43
+ }
44
+ }
45
+ ]
46
+ }
@@ -0,0 +1,23 @@
1
+ import type { IActionQueryProcess, IActorQueryProcessOutput, IActorQueryProcessArgs, MediatorQueryProcess } from '@comunica/bus-query-process';
2
+ import { ActorQueryProcess } from '@comunica/bus-query-process';
3
+ import type { IActorTest } from '@comunica/core';
4
+ import { ActionContextKey } from '@comunica/core';
5
+ import type { BindingsStream } from '@comunica/types';
6
+ /**
7
+ * A comunica Annotate Source Binding Query Process Actor.
8
+ */
9
+ export declare class ActorQueryProcessAnnotateSourceBinding extends ActorQueryProcess {
10
+ private readonly dataFactory;
11
+ readonly mediatorQueryProcess: MediatorQueryProcess;
12
+ constructor(args: IActorQueryProcessAnnotateSourceBindingArgs);
13
+ test(action: IActionQueryProcess): Promise<IActorTest>;
14
+ run(action: IActionQueryProcess): Promise<IActorQueryProcessOutput>;
15
+ addSourcesToBindings(iterator: BindingsStream): BindingsStream;
16
+ }
17
+ export interface IActorQueryProcessAnnotateSourceBindingArgs extends IActorQueryProcessArgs {
18
+ /**
19
+ * The query process mediator so we can call our wrapped actor
20
+ */
21
+ mediatorQueryProcess: MediatorQueryProcess;
22
+ }
23
+ export declare const KEY_CONTEXT_WRAPPED: ActionContextKey<boolean>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.KEY_CONTEXT_WRAPPED = exports.ActorQueryProcessAnnotateSourceBinding = void 0;
4
+ const bindings_factory_1 = require("@comunica/bindings-factory");
5
+ const bus_query_process_1 = require("@comunica/bus-query-process");
6
+ const context_entries_1 = require("@comunica/context-entries");
7
+ const core_1 = require("@comunica/core");
8
+ const rdf_data_factory_1 = require("rdf-data-factory");
9
+ /**
10
+ * A comunica Annotate Source Binding Query Process Actor.
11
+ */
12
+ class ActorQueryProcessAnnotateSourceBinding extends bus_query_process_1.ActorQueryProcess {
13
+ constructor(args) {
14
+ super(args);
15
+ this.dataFactory = new rdf_data_factory_1.DataFactory();
16
+ }
17
+ async test(action) {
18
+ if (action.context.get(exports.KEY_CONTEXT_WRAPPED)) {
19
+ throw new Error('Unable to query process multiple times');
20
+ }
21
+ return true;
22
+ }
23
+ async run(action) {
24
+ const context = action.context.set(exports.KEY_CONTEXT_WRAPPED, true);
25
+ action.context = context;
26
+ // Run all query processing steps in sequence
27
+ const output = await this.mediatorQueryProcess.mediate(action);
28
+ // Currently this only supports adding source provenance to bindings
29
+ if (output.result.type === 'bindings') {
30
+ output.result.bindingsStream = this.addSourcesToBindings(output.result.bindingsStream);
31
+ }
32
+ return output;
33
+ }
34
+ addSourcesToBindings(iterator) {
35
+ const ret = iterator.map((bindings) => {
36
+ if (bindings instanceof bindings_factory_1.Bindings) {
37
+ // Get sources from bindings context. If no sources are found, this should produce binding with empty literal
38
+ const source = bindings.getContextEntry(context_entries_1.KeysMergeBindingsContext.sourcesBinding);
39
+ const sourceAsLiteral = this.dataFactory.literal(JSON.stringify(source ?? []));
40
+ bindings = bindings.set('_source', sourceAsLiteral);
41
+ }
42
+ return bindings;
43
+ });
44
+ return ret;
45
+ }
46
+ }
47
+ exports.ActorQueryProcessAnnotateSourceBinding = ActorQueryProcessAnnotateSourceBinding;
48
+ exports.KEY_CONTEXT_WRAPPED = new core_1.ActionContextKey('@comunica/actor-query-process-annotate-source-binding:wrapped');
49
+ //# sourceMappingURL=ActorQueryProcessAnnotateSourceBinding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorQueryProcessAnnotateSourceBinding.js","sourceRoot":"","sources":["ActorQueryProcessAnnotateSourceBinding.ts"],"names":[],"mappings":";;;AAAA,iEAAsD;AAOtD,mEAAgE;AAChE,+DAAqE;AAErE,yCAAkD;AAGlD,uDAA+C;AAE/C;;GAEG;AACH,MAAa,sCAAuC,SAAQ,qCAAiB;IAI3E,YAAmB,IAAiD;QAClE,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,WAAW,GAAG,IAAI,8BAAW,EAAE,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA2B;QAC3C,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,2BAAmB,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,MAA2B;QAC1C,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,2BAAmB,EAAE,IAAI,CAAC,CAAC;QAC9D,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;QAEzB,6CAA6C;QAC7C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC/D,oEAAoE;QACpE,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YACtC,MAAM,CAAC,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEM,oBAAoB,CAAC,QAAwB;QAClD,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE;YACpC,IAAI,QAAQ,YAAY,2BAAQ,EAAE,CAAC;gBACjC,6GAA6G;gBAC7G,MAAM,MAAM,GAAe,QAAQ,CAAC,eAAe,CAAC,0CAAwB,CAAC,cAAc,CAAC,CAAC;gBAC7F,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;gBAC/E,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;YACtD,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AA1CD,wFA0CC;AASY,QAAA,mBAAmB,GAAG,IAAI,uBAAgB,CACrD,+DAA+D,CAChE,CAAC","sourcesContent":["import { Bindings } from '@comunica/bindings-factory';\nimport type {\n IActionQueryProcess,\n IActorQueryProcessOutput,\n IActorQueryProcessArgs,\n MediatorQueryProcess,\n} from '@comunica/bus-query-process';\nimport { ActorQueryProcess } from '@comunica/bus-query-process';\nimport { KeysMergeBindingsContext } from '@comunica/context-entries';\nimport type { IActorTest } from '@comunica/core';\nimport { ActionContextKey } from '@comunica/core';\nimport type { BindingsStream } from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport { DataFactory } from 'rdf-data-factory';\n\n/**\n * A comunica Annotate Source Binding Query Process Actor.\n */\nexport class ActorQueryProcessAnnotateSourceBinding extends ActorQueryProcess {\n private readonly dataFactory: RDF.DataFactory;\n public readonly mediatorQueryProcess: MediatorQueryProcess;\n\n public constructor(args: IActorQueryProcessAnnotateSourceBindingArgs) {\n super(args);\n this.dataFactory = new DataFactory();\n }\n\n public async test(action: IActionQueryProcess): Promise<IActorTest> {\n if (action.context.get(KEY_CONTEXT_WRAPPED)) {\n throw new Error('Unable to query process multiple times');\n }\n return true;\n }\n\n public async run(action: IActionQueryProcess): Promise<IActorQueryProcessOutput> {\n const context = action.context.set(KEY_CONTEXT_WRAPPED, true);\n action.context = context;\n\n // Run all query processing steps in sequence\n const output = await this.mediatorQueryProcess.mediate(action);\n // Currently this only supports adding source provenance to bindings\n if (output.result.type === 'bindings') {\n output.result.bindingsStream = this.addSourcesToBindings(output.result.bindingsStream);\n }\n return output;\n }\n\n public addSourcesToBindings(iterator: BindingsStream): BindingsStream {\n const ret = iterator.map((bindings) => {\n if (bindings instanceof Bindings) {\n // Get sources from bindings context. If no sources are found, this should produce binding with empty literal\n const source = <string []> bindings.getContextEntry(KeysMergeBindingsContext.sourcesBinding);\n const sourceAsLiteral = this.dataFactory.literal(JSON.stringify(source ?? []));\n bindings = bindings.set('_source', sourceAsLiteral);\n }\n return bindings;\n });\n\n return ret;\n }\n}\n\nexport interface IActorQueryProcessAnnotateSourceBindingArgs extends IActorQueryProcessArgs {\n /**\n * The query process mediator so we can call our wrapped actor\n */\n mediatorQueryProcess: MediatorQueryProcess;\n}\n\nexport const KEY_CONTEXT_WRAPPED = new ActionContextKey<boolean>(\n '@comunica/actor-query-process-annotate-source-binding:wrapped',\n);\n"]}
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './ActorQueryProcessAnnotateSourceBinding';
package/lib/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ActorQueryProcessAnnotateSourceBinding"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2EAAyD","sourcesContent":["export * from './ActorQueryProcessAnnotateSourceBinding';\n"]}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@comunica/actor-query-process-annotate-source-binding",
3
+ "version": "3.2.0",
4
+ "description": "A annotate-source-binding query-process actor",
5
+ "lsd:module": true,
6
+ "license": "MIT",
7
+ "homepage": "https://comunica.dev/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/comunica/comunica.git",
11
+ "directory": "packages/actor-query-process-annotate-source-binding"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/comunica/comunica/issues"
15
+ },
16
+ "keywords": [
17
+ "comunica",
18
+ "actor",
19
+ "query-process",
20
+ "annotate-source-binding"
21
+ ],
22
+ "sideEffects": false,
23
+ "main": "lib/index.js",
24
+ "typings": "lib/index",
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "files": [
29
+ "components",
30
+ "lib/**/*.d.ts",
31
+ "lib/**/*.js",
32
+ "lib/**/*.js.map"
33
+ ],
34
+ "scripts": {
35
+ "build": "npm run build:ts && npm run build:components",
36
+ "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
37
+ "build:components": "componentsjs-generator"
38
+ },
39
+ "dependencies": {
40
+ "@comunica/bindings-factory": "^3.2.0",
41
+ "@comunica/bus-query-process": "^3.2.0",
42
+ "@comunica/context-entries": "^3.2.0",
43
+ "@comunica/core": "^3.2.0",
44
+ "@comunica/types": "^3.2.0",
45
+ "rdf-data-factory": "^1.1.2"
46
+ },
47
+ "gitHead": "87baf2afed021a254859e64b92f34d9b51c6a7db"
48
+ }