@comunica/actor-query-source-identify-serialized 3.0.1-alpha.43.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,47 @@
1
+ # Comunica Serialized Query Source Identify Actor
2
+
3
+ [![npm version](https://badge.fury.io/js/%40comunica%2Factor-query-source-identify-serialized.svg)](https://www.npmjs.com/package/@comunica/actor-query-source-identify-serialized)
4
+
5
+ A [Query Source Identify](https://github.com/comunica/comunica/tree/master/packages/bus-query-source-identify) actor that handles serialized sources.
6
+
7
+ This actor enables to the possibility to provide data sources using the context in the form of a string, such as:
8
+ ```js
9
+ { sources: [{ type: 'serialized', value: `<ex:s> <ex:p> <ex:o>. <ex:s> <ex:p> <ex:z>.`, mediaType: 'text/turtle', baseIRI: 'http://example.org/' }]}
10
+ ```
11
+
12
+ This module is part of the [Comunica framework](https://github.com/comunica/comunica),
13
+ and should only be used by [developers that want to build their own query engine](https://comunica.dev/docs/modify/).
14
+
15
+ [Click here if you just want to query with Comunica](https://comunica.dev/docs/query/).
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ $ yarn add @comunica/actor-query-source-identify-serialized
21
+ ```
22
+
23
+ ## Configure
24
+
25
+ After installing, this package can be added to your engine's configuration as follows:
26
+ ```text
27
+ {
28
+ "@context": [
29
+ ...
30
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-source-identify-serialized/^1.0.0/components/context.jsonld"
31
+ ],
32
+ "actors": [
33
+ ...
34
+ {
35
+ "@id": "urn:comunica:default:query-source-identify/actors#serialized",
36
+ "@type": "ActorQuerySourceIdentifySerialized",
37
+ "mediatorRdfParse": { "@id": "urn:comunica:default:rdf-parse/mediators#parse" },
38
+ "mediatorQuerySourceIdentify": { "@id": "urn:comunica:default:query-source-identify/mediators#main" }
39
+ }
40
+ ]
41
+ }
42
+ ```
43
+
44
+ ### Config Parameters
45
+
46
+ * `mediatorRdfParse`: A mediator over the [RDF Parse bus](https://github.com/comunica/comunica/tree/master/packages/bus-rdf-parse).
47
+ * `mediatorQuerySourceIdentify`: A mediator over the [Query Source Identify bus](https://github.com/comunica/comunica/tree/master/packages/bus-query-source-identify).
@@ -0,0 +1,207 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-source-identify-serialized/^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-source-identify/^3.0.0/components/context.jsonld"
6
+ ],
7
+ "@id": "npmd:@comunica/actor-query-source-identify-serialized",
8
+ "components": [
9
+ {
10
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized",
11
+ "@type": "Class",
12
+ "requireElement": "ActorQuerySourceIdentifySerialized",
13
+ "extends": [
14
+ "cbqsi:components/ActorQuerySourceIdentify.jsonld#ActorQuerySourceIdentify"
15
+ ],
16
+ "comment": "A comunica Serialized Query Source Identify Actor.",
17
+ "parameters": [
18
+ {
19
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_mediatorRdfParse",
20
+ "range": "cc:components/Mediator.jsonld#Mediator",
21
+ "comment": "The quad pattern parser mediator."
22
+ },
23
+ {
24
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_mediatorQuerySourceIdentify",
25
+ "range": "cc:components/Mediator.jsonld#Mediator",
26
+ "comment": "The query source identify mediator."
27
+ },
28
+ {
29
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_name",
30
+ "range": "xsd:string",
31
+ "default": {
32
+ "@id": "rdf:subject"
33
+ },
34
+ "comment": "The name for this actor."
35
+ },
36
+ {
37
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_bus",
38
+ "range": {
39
+ "@type": "ParameterRangeGenericComponent",
40
+ "component": "cc:components/Bus.jsonld#Bus",
41
+ "genericTypeInstances": [
42
+ {
43
+ "@type": "ParameterRangeGenericComponent",
44
+ "component": "cc:components/Actor.jsonld#Actor",
45
+ "genericTypeInstances": [
46
+ {
47
+ "@type": "ParameterRangeGenericTypeReference",
48
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
49
+ },
50
+ {
51
+ "@type": "ParameterRangeGenericTypeReference",
52
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
53
+ },
54
+ {
55
+ "@type": "ParameterRangeGenericTypeReference",
56
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
57
+ }
58
+ ]
59
+ },
60
+ {
61
+ "@type": "ParameterRangeGenericTypeReference",
62
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
63
+ },
64
+ {
65
+ "@type": "ParameterRangeGenericTypeReference",
66
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
67
+ },
68
+ {
69
+ "@type": "ParameterRangeGenericTypeReference",
70
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
71
+ }
72
+ ]
73
+ },
74
+ "default": {
75
+ "@id": "cbqsi:components/ActorQuerySourceIdentify.jsonld#ActorQuerySourceIdentify_default_bus",
76
+ "@type": "cc:components/Bus.jsonld#Bus"
77
+ },
78
+ "comment": "The bus this actor subscribes to."
79
+ },
80
+ {
81
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_beforeActors",
82
+ "range": {
83
+ "@type": "ParameterRangeUnion",
84
+ "parameterRangeElements": [
85
+ {
86
+ "@type": "ParameterRangeArray",
87
+ "parameterRangeValue": {
88
+ "@type": "ParameterRangeGenericComponent",
89
+ "component": "cc:components/Actor.jsonld#Actor",
90
+ "genericTypeInstances": [
91
+ {
92
+ "@type": "ParameterRangeGenericTypeReference",
93
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
94
+ },
95
+ {
96
+ "@type": "ParameterRangeGenericTypeReference",
97
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
98
+ },
99
+ {
100
+ "@type": "ParameterRangeGenericTypeReference",
101
+ "parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
102
+ }
103
+ ]
104
+ }
105
+ },
106
+ {
107
+ "@type": "ParameterRangeUndefined"
108
+ }
109
+ ]
110
+ },
111
+ "comment": "Actor that must be registered in the bus before this actor."
112
+ }
113
+ ],
114
+ "memberFields": [
115
+ {
116
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized__member_cacheSize",
117
+ "memberFieldName": "cacheSize",
118
+ "range": "xsd:number"
119
+ },
120
+ {
121
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized__member_mediatorRdfParse",
122
+ "memberFieldName": "mediatorRdfParse",
123
+ "range": "cc:components/Mediator.jsonld#Mediator"
124
+ },
125
+ {
126
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized__member_mediatorQuerySourceIdentify",
127
+ "memberFieldName": "mediatorQuerySourceIdentify",
128
+ "range": "cc:components/Mediator.jsonld#Mediator"
129
+ },
130
+ {
131
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized__member_constructor",
132
+ "memberFieldName": "constructor"
133
+ },
134
+ {
135
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized__member_test",
136
+ "memberFieldName": "test"
137
+ },
138
+ {
139
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized__member_run",
140
+ "memberFieldName": "run"
141
+ },
142
+ {
143
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized__member_getRdfSource",
144
+ "memberFieldName": "getRdfSource"
145
+ },
146
+ {
147
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized__member_isStringSource",
148
+ "memberFieldName": "isStringSource"
149
+ }
150
+ ],
151
+ "constructorArguments": [
152
+ {
153
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args__constructorArgument",
154
+ "fields": [
155
+ {
156
+ "keyRaw": "mediatorRdfParse",
157
+ "value": {
158
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_mediatorRdfParse"
159
+ }
160
+ },
161
+ {
162
+ "keyRaw": "mediatorQuerySourceIdentify",
163
+ "value": {
164
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_mediatorQuerySourceIdentify"
165
+ }
166
+ },
167
+ {
168
+ "keyRaw": "name",
169
+ "value": {
170
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_name"
171
+ }
172
+ },
173
+ {
174
+ "keyRaw": "bus",
175
+ "value": {
176
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_bus"
177
+ }
178
+ },
179
+ {
180
+ "keyRaw": "beforeActors",
181
+ "value": {
182
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_beforeActors"
183
+ }
184
+ }
185
+ ]
186
+ }
187
+ ]
188
+ },
189
+ {
190
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#IActorQuerySourceIdentifySerializedArgs",
191
+ "@type": "AbstractClass",
192
+ "requireElement": "IActorQuerySourceIdentifySerializedArgs",
193
+ "parameters": [],
194
+ "memberFields": [
195
+ {
196
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#IActorQuerySourceIdentifySerializedArgs__member_mediatorRdfParse",
197
+ "memberFieldName": "mediatorRdfParse"
198
+ },
199
+ {
200
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#IActorQuerySourceIdentifySerializedArgs__member_mediatorQuerySourceIdentify",
201
+ "memberFieldName": "mediatorQuerySourceIdentify"
202
+ }
203
+ ],
204
+ "constructorArguments": []
205
+ }
206
+ ]
207
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-source-identify-serialized/^3.0.0/components/context.jsonld"
4
+ ],
5
+ "@id": "npmd:@comunica/actor-query-source-identify-serialized",
6
+ "@type": "Module",
7
+ "requireName": "@comunica/actor-query-source-identify-serialized",
8
+ "import": [
9
+ "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld"
10
+ ]
11
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "@context": [
3
+ "https://linkedsoftwaredependencies.org/bundles/npm/componentsjs/^5.0.0/components/context.jsonld",
4
+ {
5
+ "npmd": "https://linkedsoftwaredependencies.org/bundles/npm/",
6
+ "caqsis": "npmd:@comunica/actor-query-source-identify-serialized/^3.0.0/",
7
+ "ActorQuerySourceIdentifySerialized": {
8
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized",
9
+ "@prefix": true,
10
+ "@context": {
11
+ "args_mediatorRdfParse": {
12
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_mediatorRdfParse"
13
+ },
14
+ "args_mediatorQuerySourceIdentify": {
15
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_mediatorQuerySourceIdentify"
16
+ },
17
+ "args_name": {
18
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_name"
19
+ },
20
+ "args_bus": {
21
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_bus"
22
+ },
23
+ "args_beforeActors": {
24
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_beforeActors",
25
+ "@container": "@list"
26
+ },
27
+ "mediatorRdfParse": {
28
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_mediatorRdfParse"
29
+ },
30
+ "mediatorQuerySourceIdentify": {
31
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_mediatorQuerySourceIdentify"
32
+ },
33
+ "name": {
34
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_name"
35
+ },
36
+ "bus": {
37
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_bus"
38
+ },
39
+ "beforeActors": {
40
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#ActorQuerySourceIdentifySerialized_args_beforeActors",
41
+ "@container": "@list"
42
+ }
43
+ }
44
+ },
45
+ "IActorQuerySourceIdentifySerializedArgs": {
46
+ "@id": "caqsis:components/ActorQuerySourceIdentifySerialized.jsonld#IActorQuerySourceIdentifySerializedArgs",
47
+ "@prefix": true,
48
+ "@context": {}
49
+ }
50
+ }
51
+ ]
52
+ }
@@ -0,0 +1,35 @@
1
+ import type { IActionQuerySourceIdentify, IActorQuerySourceIdentifyOutput, IActorQuerySourceIdentifyArgs, MediatorQuerySourceIdentify } from '@comunica/bus-query-source-identify';
2
+ import { ActorQuerySourceIdentify } from '@comunica/bus-query-source-identify';
3
+ import type { MediatorRdfParseHandle } from '@comunica/bus-rdf-parse';
4
+ import type { IActorTest } from '@comunica/core';
5
+ import type { IQuerySourceSerialized, IActionContext } from '@comunica/types';
6
+ import type * as RDF from '@rdfjs/types';
7
+ /**
8
+ * A comunica Serialized Query Source Identify Actor.
9
+ */
10
+ export declare class ActorQuerySourceIdentifySerialized extends ActorQuerySourceIdentify {
11
+ readonly cacheSize: number;
12
+ readonly mediatorRdfParse: MediatorRdfParseHandle;
13
+ readonly mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;
14
+ constructor(args: IActorQuerySourceIdentifySerializedArgs);
15
+ test(action: IActionQuerySourceIdentify): Promise<IActorTest>;
16
+ run(action: IActionQuerySourceIdentify): Promise<IActorQuerySourceIdentifyOutput>;
17
+ /**
18
+ * Parses the string data source through the RDF parse bus, returning the RDF source.
19
+ * @param context The run action context
20
+ * @param source The source from the run action context
21
+ * @returns Parsed RDF source that can be passed to quad pattern resolve mediator as an RDF/JS source
22
+ */
23
+ protected getRdfSource(context: IActionContext, source: IQuerySourceSerialized): Promise<RDF.Source>;
24
+ private isStringSource;
25
+ }
26
+ export interface IActorQuerySourceIdentifySerializedArgs extends IActorQuerySourceIdentifyArgs {
27
+ /**
28
+ * The quad pattern parser mediator.
29
+ */
30
+ mediatorRdfParse: MediatorRdfParseHandle;
31
+ /**
32
+ * The query source identify mediator.
33
+ */
34
+ mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;
35
+ }
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActorQuerySourceIdentifySerialized = void 0;
4
+ const bus_query_source_identify_1 = require("@comunica/bus-query-source-identify");
5
+ const rdf_store_stream_1 = require("rdf-store-stream");
6
+ const readable_stream_1 = require("readable-stream");
7
+ /**
8
+ * A comunica Serialized Query Source Identify Actor.
9
+ */
10
+ class ActorQuerySourceIdentifySerialized extends bus_query_source_identify_1.ActorQuerySourceIdentify {
11
+ constructor(args) {
12
+ super(args);
13
+ }
14
+ async test(action) {
15
+ const source = action.querySourceUnidentified;
16
+ if (!this.isStringSource(action.querySourceUnidentified)) {
17
+ throw new Error(`${this.name} requires a single query source with serialized type to be present in the context.`);
18
+ }
19
+ return true;
20
+ }
21
+ async run(action) {
22
+ // Delegate source identification to the same bus again, by converting the string into an RDF/JS source
23
+ return await this.mediatorQuerySourceIdentify.mediate({
24
+ querySourceUnidentified: {
25
+ type: 'rdfjs',
26
+ value: await this.getRdfSource(action.context, action.querySourceUnidentified),
27
+ context: action.querySourceUnidentified.context,
28
+ },
29
+ context: action.context,
30
+ });
31
+ }
32
+ /**
33
+ * Parses the string data source through the RDF parse bus, returning the RDF source.
34
+ * @param context The run action context
35
+ * @param source The source from the run action context
36
+ * @returns Parsed RDF source that can be passed to quad pattern resolve mediator as an RDF/JS source
37
+ */
38
+ async getRdfSource(context, source) {
39
+ const textStream = new readable_stream_1.Readable({ objectMode: true });
40
+ /* istanbul ignore next */
41
+ textStream._read = () => {
42
+ // Do nothing
43
+ };
44
+ textStream.push(source.value);
45
+ textStream.push(null);
46
+ const parseAction = {
47
+ context,
48
+ handle: {
49
+ metadata: { baseIRI: source.baseIRI },
50
+ data: textStream,
51
+ context,
52
+ },
53
+ handleMediaType: source.mediaType,
54
+ };
55
+ const parseResult = await this.mediatorRdfParse.mediate(parseAction);
56
+ return await (0, rdf_store_stream_1.storeStream)(parseResult.handle.data);
57
+ }
58
+ isStringSource(source) {
59
+ if (!('type' in source)) {
60
+ if (!(typeof source.value === 'string')) {
61
+ return false;
62
+ }
63
+ return 'mediaType' in source;
64
+ }
65
+ return source.type === 'serialized';
66
+ }
67
+ }
68
+ exports.ActorQuerySourceIdentifySerialized = ActorQuerySourceIdentifySerialized;
69
+ //# sourceMappingURL=ActorQuerySourceIdentifySerialized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActorQuerySourceIdentifySerialized.js","sourceRoot":"","sources":["ActorQuerySourceIdentifySerialized.ts"],"names":[],"mappings":";;;AAMA,mFAA+E;AAS/E,uDAA+C;AAC/C,qDAA2C;AAE3C;;GAEG;AACH,MAAa,kCAAmC,SAAQ,oDAAwB;IAI9E,YAAmB,IAA6C;QAC9D,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAAkC;QAClD,MAAM,MAAM,GAAG,MAAM,CAAC,uBAAuB,CAAC;QAC9C,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,uBAAuB,CAAC,EAAE;YACxD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,oFAAoF,CAAC,CAAC;SACnH;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,MAAkC;QACjD,uGAAuG;QACvG,OAAO,MAAM,IAAI,CAAC,2BAA2B,CAAC,OAAO,CAAC;YACpD,uBAAuB,EAAE;gBACvB,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,MAAM,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAA2B,MAAM,CAAC,uBAAuB,CAAC;gBACvG,OAAO,EAAE,MAAM,CAAC,uBAAuB,CAAC,OAAO;aAChD;YACD,OAAO,EAAE,MAAM,CAAC,OAAO;SACxB,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACO,KAAK,CAAC,YAAY,CAAC,OAAuB,EAAE,MAA8B;QAClF,MAAM,UAAU,GAAG,IAAI,0BAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,0BAA0B;QAC1B,UAAU,CAAC,KAAK,GAAG,GAAG,EAAE;YACtB,aAAa;QACf,CAAC,CAAC;QACF,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEtB,MAAM,WAAW,GAA0B;YACzC,OAAO;YACP,MAAM,EAAE;gBACN,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE;gBACrC,IAAI,EAAE,UAAU;gBAChB,OAAO;aACR;YACD,eAAe,EAAE,MAAM,CAAC,SAAS;SAClC,CAAC;QAEF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QACrE,OAAO,MAAM,IAAA,8BAAW,EAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAEO,cAAc,CAAC,MAAuC;QAC5D,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,EAAE;YACvB,IAAI,CAAC,CAAC,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,EAAE;gBACvC,OAAO,KAAK,CAAC;aACd;YACD,OAAO,WAAW,IAAI,MAAM,CAAC;SAC9B;QACD,OAAO,MAAM,CAAC,IAAI,KAAK,YAAY,CAAC;IACtC,CAAC;CACF;AAlED,gFAkEC","sourcesContent":["import type {\n IActionQuerySourceIdentify,\n IActorQuerySourceIdentifyOutput,\n IActorQuerySourceIdentifyArgs,\n MediatorQuerySourceIdentify,\n} from '@comunica/bus-query-source-identify';\nimport { ActorQuerySourceIdentify } from '@comunica/bus-query-source-identify';\nimport type { IActionRdfParseHandle, MediatorRdfParseHandle } from '@comunica/bus-rdf-parse';\nimport type { IActorTest } from '@comunica/core';\nimport type {\n IQuerySourceSerialized,\n QuerySourceUnidentifiedExpanded,\n IActionContext,\n} from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport { storeStream } from 'rdf-store-stream';\nimport { Readable } from 'readable-stream';\n\n/**\n * A comunica Serialized Query Source Identify Actor.\n */\nexport class ActorQuerySourceIdentifySerialized extends ActorQuerySourceIdentify {\n public readonly cacheSize: number;\n public readonly mediatorRdfParse: MediatorRdfParseHandle;\n public readonly mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;\n public constructor(args: IActorQuerySourceIdentifySerializedArgs) {\n super(args);\n }\n\n public async test(action: IActionQuerySourceIdentify): Promise<IActorTest> {\n const source = action.querySourceUnidentified;\n if (!this.isStringSource(action.querySourceUnidentified)) {\n throw new Error(`${this.name} requires a single query source with serialized type to be present in the context.`);\n }\n return true;\n }\n\n public async run(action: IActionQuerySourceIdentify): Promise<IActorQuerySourceIdentifyOutput> {\n // Delegate source identification to the same bus again, by converting the string into an RDF/JS source\n return await this.mediatorQuerySourceIdentify.mediate({\n querySourceUnidentified: {\n type: 'rdfjs',\n value: await this.getRdfSource(action.context, <IQuerySourceSerialized> action.querySourceUnidentified),\n context: action.querySourceUnidentified.context,\n },\n context: action.context,\n });\n }\n\n /**\n * Parses the string data source through the RDF parse bus, returning the RDF source.\n * @param context The run action context\n * @param source The source from the run action context\n * @returns Parsed RDF source that can be passed to quad pattern resolve mediator as an RDF/JS source\n */\n protected async getRdfSource(context: IActionContext, source: IQuerySourceSerialized): Promise<RDF.Source> {\n const textStream = new Readable({ objectMode: true });\n /* istanbul ignore next */\n textStream._read = () => {\n // Do nothing\n };\n textStream.push(source.value);\n textStream.push(null);\n\n const parseAction: IActionRdfParseHandle = {\n context,\n handle: {\n metadata: { baseIRI: source.baseIRI },\n data: textStream,\n context,\n },\n handleMediaType: source.mediaType,\n };\n\n const parseResult = await this.mediatorRdfParse.mediate(parseAction);\n return await storeStream(parseResult.handle.data);\n }\n\n private isStringSource(source: QuerySourceUnidentifiedExpanded): source is IQuerySourceSerialized {\n if (!('type' in source)) {\n if (!(typeof source.value === 'string')) {\n return false;\n }\n return 'mediaType' in source;\n }\n return source.type === 'serialized';\n }\n}\n\nexport interface IActorQuerySourceIdentifySerializedArgs extends IActorQuerySourceIdentifyArgs {\n /**\n * The quad pattern parser mediator.\n */\n mediatorRdfParse: MediatorRdfParseHandle;\n /**\n * The query source identify mediator.\n */\n mediatorQuerySourceIdentify: MediatorQuerySourceIdentify;\n}\n"]}
package/lib/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './ActorQuerySourceIdentifySerialized';
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("./ActorQuerySourceIdentifySerialized"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uEAAqD","sourcesContent":["export * from './ActorQuerySourceIdentifySerialized';\n"]}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@comunica/actor-query-source-identify-serialized",
3
+ "version": "3.0.1-alpha.43.0",
4
+ "description": "A serialized query-source-identify actor",
5
+ "lsd:module": true,
6
+ "main": "lib/index.js",
7
+ "typings": "lib/index",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/comunica/comunica.git",
11
+ "directory": "packages/actor-query-source-identify-serialized"
12
+ },
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "sideEffects": false,
17
+ "keywords": [
18
+ "comunica",
19
+ "actor",
20
+ "query-source-identify",
21
+ "serialized"
22
+ ],
23
+ "license": "MIT",
24
+ "bugs": {
25
+ "url": "https://github.com/comunica/comunica/issues"
26
+ },
27
+ "homepage": "https://comunica.dev/",
28
+ "files": [
29
+ "components",
30
+ "lib/**/*.d.ts",
31
+ "lib/**/*.js",
32
+ "lib/**/*.js.map"
33
+ ],
34
+ "dependencies": {
35
+ "@comunica/bus-query-source-identify": "3.0.1-alpha.43.0",
36
+ "@comunica/bus-rdf-parse": "3.0.1-alpha.43.0",
37
+ "@comunica/core": "3.0.1-alpha.43.0",
38
+ "@comunica/types": "3.0.1-alpha.43.0",
39
+ "@rdfjs/types": "*",
40
+ "rdf-store-stream": "^2.0.0",
41
+ "readable-stream": "^4.2.0"
42
+ },
43
+ "scripts": {
44
+ "build": "npm run build:ts && npm run build:components",
45
+ "build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
46
+ "build:components": "componentsjs-generator"
47
+ },
48
+ "gitHead": "d11e44cf07d4699f9d2c51d5851b5ed443de1997"
49
+ }