@comunica/actor-query-source-identify-rdfjs 3.2.4-alpha.47.0 → 3.3.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/components/ActorQuerySourceIdentifyRdfJs.jsonld +0 -32
- package/components/QuerySourceRdfJs.jsonld +3 -22
- package/components/context.jsonld +0 -12
- package/lib/ActorQuerySourceIdentifyRdfJs.d.ts +2 -2
- package/lib/ActorQuerySourceIdentifyRdfJs.js +5 -7
- package/lib/ActorQuerySourceIdentifyRdfJs.js.map +1 -1
- package/lib/QuerySourceRdfJs.d.ts +4 -5
- package/lib/QuerySourceRdfJs.js +21 -19
- package/lib/QuerySourceRdfJs.js.map +1 -1
- package/package.json +11 -14
|
@@ -49,10 +49,6 @@
|
|
|
49
49
|
{
|
|
50
50
|
"@type": "ParameterRangeGenericTypeReference",
|
|
51
51
|
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"@type": "ParameterRangeGenericTypeReference",
|
|
55
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
56
52
|
}
|
|
57
53
|
]
|
|
58
54
|
},
|
|
@@ -67,10 +63,6 @@
|
|
|
67
63
|
{
|
|
68
64
|
"@type": "ParameterRangeGenericTypeReference",
|
|
69
65
|
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
"@type": "ParameterRangeGenericTypeReference",
|
|
73
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
74
66
|
}
|
|
75
67
|
]
|
|
76
68
|
},
|
|
@@ -80,20 +72,6 @@
|
|
|
80
72
|
},
|
|
81
73
|
"comment": "The bus this actor subscribes to."
|
|
82
74
|
},
|
|
83
|
-
{
|
|
84
|
-
"@id": "caqsir:components/ActorQuerySourceIdentifyRdfJs.jsonld#ActorQuerySourceIdentifyRdfJs_args_busFailMessage",
|
|
85
|
-
"range": {
|
|
86
|
-
"@type": "ParameterRangeUnion",
|
|
87
|
-
"parameterRangeElements": [
|
|
88
|
-
"xsd:string",
|
|
89
|
-
{
|
|
90
|
-
"@type": "ParameterRangeUndefined"
|
|
91
|
-
}
|
|
92
|
-
]
|
|
93
|
-
},
|
|
94
|
-
"default": "Query source identification failed: none of the configured actors were able to identify ${action.querySourceUnidentified.value}",
|
|
95
|
-
"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}\""
|
|
96
|
-
},
|
|
97
75
|
{
|
|
98
76
|
"@id": "caqsir:components/ActorQuerySourceIdentifyRdfJs.jsonld#ActorQuerySourceIdentifyRdfJs_args_beforeActors",
|
|
99
77
|
"range": {
|
|
@@ -116,10 +94,6 @@
|
|
|
116
94
|
{
|
|
117
95
|
"@type": "ParameterRangeGenericTypeReference",
|
|
118
96
|
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
"@type": "ParameterRangeGenericTypeReference",
|
|
122
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^3.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
123
97
|
}
|
|
124
98
|
]
|
|
125
99
|
}
|
|
@@ -173,12 +147,6 @@
|
|
|
173
147
|
"@id": "caqsir:components/ActorQuerySourceIdentifyRdfJs.jsonld#ActorQuerySourceIdentifyRdfJs_args_bus"
|
|
174
148
|
}
|
|
175
149
|
},
|
|
176
|
-
{
|
|
177
|
-
"keyRaw": "busFailMessage",
|
|
178
|
-
"value": {
|
|
179
|
-
"@id": "caqsir:components/ActorQuerySourceIdentifyRdfJs.jsonld#ActorQuerySourceIdentifyRdfJs_args_busFailMessage"
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
150
|
{
|
|
183
151
|
"keyRaw": "beforeActors",
|
|
184
152
|
"value": {
|
|
@@ -15,25 +15,13 @@
|
|
|
15
15
|
},
|
|
16
16
|
{
|
|
17
17
|
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#QuerySourceRdfJs_bindingsFactory",
|
|
18
|
-
"range": "urn:npm:@comunica/
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#QuerySourceRdfJs_dataFactory",
|
|
22
|
-
"range": {
|
|
23
|
-
"@type": "ParameterRangeIntersection",
|
|
24
|
-
"parameterRangeElements": [
|
|
25
|
-
"urn:npm:@rdfjs/types:DataFactory",
|
|
26
|
-
{
|
|
27
|
-
"@type": "ParameterRangeWildcard"
|
|
28
|
-
}
|
|
29
|
-
]
|
|
30
|
-
}
|
|
18
|
+
"range": "urn:npm:@comunica/bindings-factory:BindingsFactory"
|
|
31
19
|
}
|
|
32
20
|
],
|
|
33
21
|
"memberFields": [
|
|
34
22
|
{
|
|
35
|
-
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#
|
|
36
|
-
"memberFieldName": "
|
|
23
|
+
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#QuerySourceRdfJs__member_SELECTOR_SHAPE",
|
|
24
|
+
"memberFieldName": "SELECTOR_SHAPE",
|
|
37
25
|
"range": {
|
|
38
26
|
"@type": "ParameterRangeWildcard"
|
|
39
27
|
}
|
|
@@ -54,10 +42,6 @@
|
|
|
54
42
|
"memberFieldName": "source",
|
|
55
43
|
"range": "caqsir:components/IRdfJsSourceExtended.jsonld#IRdfJsSourceExtended"
|
|
56
44
|
},
|
|
57
|
-
{
|
|
58
|
-
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#QuerySourceRdfJs__member_dataFactory",
|
|
59
|
-
"memberFieldName": "dataFactory"
|
|
60
|
-
},
|
|
61
45
|
{
|
|
62
46
|
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#QuerySourceRdfJs__member_bindingsFactory",
|
|
63
47
|
"memberFieldName": "bindingsFactory"
|
|
@@ -107,9 +91,6 @@
|
|
|
107
91
|
{
|
|
108
92
|
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#QuerySourceRdfJs_source"
|
|
109
93
|
},
|
|
110
|
-
{
|
|
111
|
-
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#QuerySourceRdfJs_dataFactory"
|
|
112
|
-
},
|
|
113
94
|
{
|
|
114
95
|
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#QuerySourceRdfJs_bindingsFactory"
|
|
115
96
|
}
|
|
@@ -17,9 +17,6 @@
|
|
|
17
17
|
"args_bus": {
|
|
18
18
|
"@id": "caqsir:components/ActorQuerySourceIdentifyRdfJs.jsonld#ActorQuerySourceIdentifyRdfJs_args_bus"
|
|
19
19
|
},
|
|
20
|
-
"args_busFailMessage": {
|
|
21
|
-
"@id": "caqsir:components/ActorQuerySourceIdentifyRdfJs.jsonld#ActorQuerySourceIdentifyRdfJs_args_busFailMessage"
|
|
22
|
-
},
|
|
23
20
|
"args_beforeActors": {
|
|
24
21
|
"@id": "caqsir:components/ActorQuerySourceIdentifyRdfJs.jsonld#ActorQuerySourceIdentifyRdfJs_args_beforeActors",
|
|
25
22
|
"@container": "@list"
|
|
@@ -33,9 +30,6 @@
|
|
|
33
30
|
"bus": {
|
|
34
31
|
"@id": "caqsir:components/ActorQuerySourceIdentifyRdfJs.jsonld#ActorQuerySourceIdentifyRdfJs_args_bus"
|
|
35
32
|
},
|
|
36
|
-
"busFailMessage": {
|
|
37
|
-
"@id": "caqsir:components/ActorQuerySourceIdentifyRdfJs.jsonld#ActorQuerySourceIdentifyRdfJs_args_busFailMessage"
|
|
38
|
-
},
|
|
39
33
|
"beforeActors": {
|
|
40
34
|
"@id": "caqsir:components/ActorQuerySourceIdentifyRdfJs.jsonld#ActorQuerySourceIdentifyRdfJs_args_beforeActors",
|
|
41
35
|
"@container": "@list"
|
|
@@ -61,12 +55,6 @@
|
|
|
61
55
|
},
|
|
62
56
|
"bindingsFactory": {
|
|
63
57
|
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#QuerySourceRdfJs_bindingsFactory"
|
|
64
|
-
},
|
|
65
|
-
"dataFactory": {
|
|
66
|
-
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#QuerySourceRdfJs_dataFactory"
|
|
67
|
-
},
|
|
68
|
-
"ory": {
|
|
69
|
-
"@id": "caqsir:components/QuerySourceRdfJs.jsonld#QuerySourceRdfJs_bindingsFactory"
|
|
70
58
|
}
|
|
71
59
|
}
|
|
72
60
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { MediatorMergeBindingsContext } from '@comunica/bus-merge-bindings-context';
|
|
2
2
|
import type { IActionQuerySourceIdentify, IActorQuerySourceIdentifyOutput, IActorQuerySourceIdentifyArgs } from '@comunica/bus-query-source-identify';
|
|
3
3
|
import { ActorQuerySourceIdentify } from '@comunica/bus-query-source-identify';
|
|
4
|
-
import type { IActorTest
|
|
4
|
+
import type { IActorTest } from '@comunica/core';
|
|
5
5
|
/**
|
|
6
6
|
* A comunica RDFJS Query Source Identify Actor.
|
|
7
7
|
*/
|
|
8
8
|
export declare class ActorQuerySourceIdentifyRdfJs extends ActorQuerySourceIdentify {
|
|
9
9
|
readonly mediatorMergeBindingsContext: MediatorMergeBindingsContext;
|
|
10
10
|
constructor(args: IActorQuerySourceIdentifyRdfJsArgs);
|
|
11
|
-
test(action: IActionQuerySourceIdentify): Promise<
|
|
11
|
+
test(action: IActionQuerySourceIdentify): Promise<IActorTest>;
|
|
12
12
|
run(action: IActionQuerySourceIdentify): Promise<IActorQuerySourceIdentifyOutput>;
|
|
13
13
|
}
|
|
14
14
|
export interface IActorQuerySourceIdentifyRdfJsArgs extends IActorQuerySourceIdentifyArgs {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActorQuerySourceIdentifyRdfJs = void 0;
|
|
4
|
+
const bindings_factory_1 = require("@comunica/bindings-factory");
|
|
4
5
|
const bus_query_source_identify_1 = require("@comunica/bus-query-source-identify");
|
|
5
|
-
const context_entries_1 = require("@comunica/context-entries");
|
|
6
6
|
const core_1 = require("@comunica/core");
|
|
7
|
-
const utils_bindings_factory_1 = require("@comunica/utils-bindings-factory");
|
|
8
7
|
const QuerySourceRdfJs_1 = require("./QuerySourceRdfJs");
|
|
9
8
|
/**
|
|
10
9
|
* A comunica RDFJS Query Source Identify Actor.
|
|
@@ -16,18 +15,17 @@ class ActorQuerySourceIdentifyRdfJs extends bus_query_source_identify_1.ActorQue
|
|
|
16
15
|
async test(action) {
|
|
17
16
|
const source = action.querySourceUnidentified;
|
|
18
17
|
if (source.type !== undefined && source.type !== 'rdfjs') {
|
|
19
|
-
|
|
18
|
+
throw new Error(`${this.name} requires a single query source with rdfjs type to be present in the context.`);
|
|
20
19
|
}
|
|
21
20
|
if (typeof source.value === 'string' || !('match' in source.value)) {
|
|
22
|
-
|
|
21
|
+
throw new Error(`${this.name} received an invalid rdfjs query source.`);
|
|
23
22
|
}
|
|
24
|
-
return
|
|
23
|
+
return true;
|
|
25
24
|
}
|
|
26
25
|
async run(action) {
|
|
27
|
-
const dataFactory = action.context.getSafe(context_entries_1.KeysInitQuery.dataFactory);
|
|
28
26
|
return {
|
|
29
27
|
querySource: {
|
|
30
|
-
source: new QuerySourceRdfJs_1.QuerySourceRdfJs(action.querySourceUnidentified.value,
|
|
28
|
+
source: new QuerySourceRdfJs_1.QuerySourceRdfJs(action.querySourceUnidentified.value, await bindings_factory_1.BindingsFactory.create(this.mediatorMergeBindingsContext, action.context)),
|
|
31
29
|
context: action.querySourceUnidentified.context ?? new core_1.ActionContext(),
|
|
32
30
|
},
|
|
33
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorQuerySourceIdentifyRdfJs.js","sourceRoot":"","sources":["ActorQuerySourceIdentifyRdfJs.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ActorQuerySourceIdentifyRdfJs.js","sourceRoot":"","sources":["ActorQuerySourceIdentifyRdfJs.ts"],"names":[],"mappings":";;;AAAA,iEAA6D;AAO7D,mFAA+E;AAE/E,yCAA+C;AAE/C,yDAAsD;AAEtD;;GAEG;AACH,MAAa,6BAA8B,SAAQ,oDAAwB;IAGzE,YAAmB,IAAwC;QACzD,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAAkC;QAClD,MAAM,MAAM,GAAG,MAAM,CAAC,uBAAuB,CAAC;QAC9C,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YACzD,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,+EAA+E,CAAC,CAAC;QAC/G,CAAC;QACD,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACnE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,0CAA0C,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,MAAkC;QACjD,OAAO;YACL,WAAW,EAAE;gBACX,MAAM,EAAE,IAAI,mCAAgB,CACb,MAAM,CAAC,uBAAuB,CAAC,KAAK,EACjD,MAAM,kCAAe,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,EAAE,MAAM,CAAC,OAAO,CAAC,CAChF;gBACD,OAAO,EAAE,MAAM,CAAC,uBAAuB,CAAC,OAAO,IAAI,IAAI,oBAAa,EAAE;aACvE;SACF,CAAC;IACJ,CAAC;CACF;AA7BD,sEA6BC","sourcesContent":["import { BindingsFactory } from '@comunica/bindings-factory';\nimport type { MediatorMergeBindingsContext } from '@comunica/bus-merge-bindings-context';\nimport type {\n IActionQuerySourceIdentify,\n IActorQuerySourceIdentifyOutput,\n IActorQuerySourceIdentifyArgs,\n} from '@comunica/bus-query-source-identify';\nimport { ActorQuerySourceIdentify } from '@comunica/bus-query-source-identify';\nimport type { IActorTest } from '@comunica/core';\nimport { ActionContext } from '@comunica/core';\nimport type * as RDF from '@rdfjs/types';\nimport { QuerySourceRdfJs } from './QuerySourceRdfJs';\n\n/**\n * A comunica RDFJS Query Source Identify Actor.\n */\nexport class ActorQuerySourceIdentifyRdfJs extends ActorQuerySourceIdentify {\n public readonly mediatorMergeBindingsContext: MediatorMergeBindingsContext;\n\n public constructor(args: IActorQuerySourceIdentifyRdfJsArgs) {\n super(args);\n }\n\n public async test(action: IActionQuerySourceIdentify): Promise<IActorTest> {\n const source = action.querySourceUnidentified;\n if (source.type !== undefined && source.type !== 'rdfjs') {\n throw new Error(`${this.name} requires a single query source with rdfjs type to be present in the context.`);\n }\n if (typeof source.value === 'string' || !('match' in source.value)) {\n throw new Error(`${this.name} received an invalid rdfjs query source.`);\n }\n return true;\n }\n\n public async run(action: IActionQuerySourceIdentify): Promise<IActorQuerySourceIdentifyOutput> {\n return {\n querySource: {\n source: new QuerySourceRdfJs(\n <RDF.Source> action.querySourceUnidentified.value,\n await BindingsFactory.create(this.mediatorMergeBindingsContext, action.context),\n ),\n context: action.querySourceUnidentified.context ?? new ActionContext(),\n },\n };\n }\n}\n\nexport interface IActorQuerySourceIdentifyRdfJsArgs extends IActorQuerySourceIdentifyArgs {\n /**\n * A mediator for creating binding context merge handlers\n */\n mediatorMergeBindingsContext: MediatorMergeBindingsContext;\n}\n"]}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { BindingsFactory } from '@comunica/bindings-factory';
|
|
2
|
+
import type { IQuerySource, BindingsStream, IActionContext, FragmentSelectorShape } from '@comunica/types';
|
|
3
3
|
import type * as RDF from '@rdfjs/types';
|
|
4
4
|
import { AsyncIterator } from 'asynciterator';
|
|
5
5
|
import type { Algebra } from 'sparqlalgebrajs';
|
|
6
6
|
import type { IRdfJsSourceExtended } from './IRdfJsSourceExtended';
|
|
7
7
|
export declare class QuerySourceRdfJs implements IQuerySource {
|
|
8
|
-
protected readonly
|
|
8
|
+
protected static readonly SELECTOR_SHAPE: FragmentSelectorShape;
|
|
9
9
|
referenceValue: string | RDF.Source;
|
|
10
10
|
protected readonly source: IRdfJsSourceExtended;
|
|
11
|
-
private readonly dataFactory;
|
|
12
11
|
private readonly bindingsFactory;
|
|
13
|
-
constructor(source: RDF.Source,
|
|
12
|
+
constructor(source: RDF.Source, bindingsFactory: BindingsFactory);
|
|
14
13
|
static nullifyVariables(term: RDF.Term | undefined, quotedTripleFiltering: boolean): RDF.Term | undefined;
|
|
15
14
|
static hasDuplicateVariables(pattern: RDF.BaseQuad): boolean;
|
|
16
15
|
getSelectorShape(): Promise<FragmentSelectorShape>;
|
package/lib/QuerySourceRdfJs.js
CHANGED
|
@@ -3,29 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.QuerySourceRdfJs = void 0;
|
|
4
4
|
const bus_query_source_identify_1 = require("@comunica/bus-query-source-identify");
|
|
5
5
|
const context_entries_1 = require("@comunica/context-entries");
|
|
6
|
-
const
|
|
6
|
+
const metadata_1 = require("@comunica/metadata");
|
|
7
7
|
const asynciterator_1 = require("asynciterator");
|
|
8
|
+
const rdf_data_factory_1 = require("rdf-data-factory");
|
|
8
9
|
const rdf_terms_1 = require("rdf-terms");
|
|
9
10
|
const sparqlalgebrajs_1 = require("sparqlalgebrajs");
|
|
11
|
+
const AF = new sparqlalgebrajs_1.Factory();
|
|
12
|
+
const DF = new rdf_data_factory_1.DataFactory();
|
|
10
13
|
class QuerySourceRdfJs {
|
|
11
|
-
constructor(source,
|
|
14
|
+
constructor(source, bindingsFactory) {
|
|
12
15
|
this.source = source;
|
|
13
16
|
this.referenceValue = source;
|
|
14
|
-
this.dataFactory = dataFactory;
|
|
15
17
|
this.bindingsFactory = bindingsFactory;
|
|
16
|
-
const AF = new sparqlalgebrajs_1.Factory(this.dataFactory);
|
|
17
|
-
this.selectorShape = {
|
|
18
|
-
type: 'operation',
|
|
19
|
-
operation: {
|
|
20
|
-
operationType: 'pattern',
|
|
21
|
-
pattern: AF.createPattern(this.dataFactory.variable('s'), this.dataFactory.variable('p'), this.dataFactory.variable('o')),
|
|
22
|
-
},
|
|
23
|
-
variablesOptional: [
|
|
24
|
-
this.dataFactory.variable('s'),
|
|
25
|
-
this.dataFactory.variable('p'),
|
|
26
|
-
this.dataFactory.variable('o'),
|
|
27
|
-
],
|
|
28
|
-
};
|
|
29
18
|
}
|
|
30
19
|
static nullifyVariables(term, quotedTripleFiltering) {
|
|
31
20
|
return !term || term.termType === 'Variable' || (!quotedTripleFiltering &&
|
|
@@ -38,7 +27,7 @@ class QuerySourceRdfJs {
|
|
|
38
27
|
return variables.length > 1 && (0, rdf_terms_1.uniqTerms)(variables).length < variables.length;
|
|
39
28
|
}
|
|
40
29
|
async getSelectorShape() {
|
|
41
|
-
return
|
|
30
|
+
return QuerySourceRdfJs.SELECTOR_SHAPE;
|
|
42
31
|
}
|
|
43
32
|
queryBindings(operation, context) {
|
|
44
33
|
if (operation.type !== 'pattern') {
|
|
@@ -60,7 +49,7 @@ class QuerySourceRdfJs {
|
|
|
60
49
|
this.setMetadata(it, operation)
|
|
61
50
|
.catch(error => it.destroy(error));
|
|
62
51
|
}
|
|
63
|
-
return (0, bus_query_source_identify_1.quadsToBindings)(it, operation, this.
|
|
52
|
+
return (0, bus_query_source_identify_1.quadsToBindings)(it, operation, this.bindingsFactory, Boolean(context.get(context_entries_1.KeysQueryOperation.unionDefaultGraph)));
|
|
64
53
|
}
|
|
65
54
|
async setMetadata(it, operation) {
|
|
66
55
|
// Check if the source supports quoted triple filtering
|
|
@@ -87,8 +76,9 @@ class QuerySourceRdfJs {
|
|
|
87
76
|
(0, rdf_terms_1.someTerms)(operation, term => term.termType === 'Quad')) ||
|
|
88
77
|
QuerySourceRdfJs.hasDuplicateVariables(operation);
|
|
89
78
|
it.setProperty('metadata', {
|
|
90
|
-
state: new
|
|
79
|
+
state: new metadata_1.MetadataValidationState(),
|
|
91
80
|
cardinality: { type: wouldRequirePostFiltering ? 'estimate' : 'exact', value: cardinality },
|
|
81
|
+
canContainUndefs: false,
|
|
92
82
|
});
|
|
93
83
|
}
|
|
94
84
|
queryQuads(_operation, _context) {
|
|
@@ -105,4 +95,16 @@ class QuerySourceRdfJs {
|
|
|
105
95
|
}
|
|
106
96
|
}
|
|
107
97
|
exports.QuerySourceRdfJs = QuerySourceRdfJs;
|
|
98
|
+
QuerySourceRdfJs.SELECTOR_SHAPE = {
|
|
99
|
+
type: 'operation',
|
|
100
|
+
operation: {
|
|
101
|
+
operationType: 'pattern',
|
|
102
|
+
pattern: AF.createPattern(DF.variable('s'), DF.variable('p'), DF.variable('o')),
|
|
103
|
+
},
|
|
104
|
+
variablesOptional: [
|
|
105
|
+
DF.variable('s'),
|
|
106
|
+
DF.variable('p'),
|
|
107
|
+
DF.variable('o'),
|
|
108
|
+
],
|
|
109
|
+
};
|
|
108
110
|
//# sourceMappingURL=QuerySourceRdfJs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuerySourceRdfJs.js","sourceRoot":"","sources":["QuerySourceRdfJs.ts"],"names":[],"mappings":";;;AAAA,mFAAiG;AACjG,+DAA+D;AAS/D,6DAAmE;AAEn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,CACf,UAA6B,EAC7B,QAAwB;QAExB,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAEM,YAAY,CACjB,UAAuB,EACvB,QAAwB;QAExB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAEM,SAAS,CACd,UAA0B,EAC1B,QAAwB;QAExB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IAEM,QAAQ;QACb,OAAO,oBAAoB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC;IAC7D,CAAC;CACF;AA3JD,4CA2JC","sourcesContent":["import { filterMatchingQuotedQuads, quadsToBindings } from '@comunica/bus-query-source-identify';\nimport { KeysQueryOperation } from '@comunica/context-entries';\nimport type {\n IQuerySource,\n BindingsStream,\n IActionContext,\n FragmentSelectorShape,\n ComunicaDataFactory,\n} from '@comunica/types';\nimport type { BindingsFactory } from '@comunica/utils-bindings-factory';\nimport { MetadataValidationState } from '@comunica/utils-metadata';\nimport type * as RDF from '@rdfjs/types';\nimport { AsyncIterator, wrap as wrapAsyncIterator } from 'asynciterator';\nimport { someTermsNested, filterTermsNested, someTerms, uniqTerms } from 'rdf-terms';\nimport type { Algebra } from 'sparqlalgebrajs';\nimport { Factory } from 'sparqlalgebrajs';\nimport type { IRdfJsSourceExtended } from './IRdfJsSourceExtended';\n\nexport class QuerySourceRdfJs implements IQuerySource {\n protected readonly selectorShape: FragmentSelectorShape;\n public referenceValue: string | RDF.Source;\n protected readonly source: IRdfJsSourceExtended;\n private readonly dataFactory: ComunicaDataFactory;\n private readonly bindingsFactory: BindingsFactory;\n\n public constructor(source: RDF.Source, dataFactory: ComunicaDataFactory, bindingsFactory: BindingsFactory) {\n this.source = source;\n this.referenceValue = source;\n this.dataFactory = dataFactory;\n this.bindingsFactory = bindingsFactory;\n const AF = new Factory(<RDF.DataFactory> this.dataFactory);\n this.selectorShape = {\n type: 'operation',\n operation: {\n operationType: 'pattern',\n pattern: AF.createPattern(\n this.dataFactory.variable('s'),\n this.dataFactory.variable('p'),\n this.dataFactory.variable('o'),\n ),\n },\n variablesOptional: [\n this.dataFactory.variable('s'),\n this.dataFactory.variable('p'),\n this.dataFactory.variable('o'),\n ],\n };\n }\n\n public static nullifyVariables(term: RDF.Term | undefined, quotedTripleFiltering: boolean): RDF.Term | undefined {\n return !term || term.termType === 'Variable' || (!quotedTripleFiltering &&\n term.termType === 'Quad' && someTermsNested(term, value => value.termType === 'Variable')) ?\n undefined :\n term;\n }\n\n public static hasDuplicateVariables(pattern: RDF.BaseQuad): boolean {\n const variables = filterTermsNested(pattern, term => term.termType === 'Variable');\n return variables.length > 1 && uniqTerms(variables).length < variables.length;\n }\n\n public async getSelectorShape(): Promise<FragmentSelectorShape> {\n return this.selectorShape;\n }\n\n public queryBindings(operation: Algebra.Operation, context: IActionContext): BindingsStream {\n if (operation.type !== 'pattern') {\n throw new Error(`Attempted to pass non-pattern operation '${operation.type}' to QuerySourceRdfJs`);\n }\n\n // Check if the source supports quoted triple filtering\n const quotedTripleFiltering = Boolean(this.source.features?.quotedTripleFiltering);\n\n // Create an async iterator from the matched quad stream\n const rawStream = this.source.match(\n QuerySourceRdfJs.nullifyVariables(operation.subject, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.predicate, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.object, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.graph, quotedTripleFiltering),\n );\n let it: AsyncIterator<RDF.Quad> = rawStream instanceof AsyncIterator ?\n rawStream :\n wrapAsyncIterator<RDF.Quad>(rawStream, { autoStart: false });\n\n // Perform post-match-filtering if the source does not support quoted triple filtering.\n if (!quotedTripleFiltering) {\n it = filterMatchingQuotedQuads(operation, it);\n }\n\n // Determine metadata\n if (!it.getProperty('metadata')) {\n this.setMetadata(it, operation)\n .catch(error => it.destroy(error));\n }\n\n return quadsToBindings(\n it,\n operation,\n this.dataFactory,\n this.bindingsFactory,\n Boolean(context.get(KeysQueryOperation.unionDefaultGraph)),\n );\n }\n\n protected async setMetadata(\n it: AsyncIterator<RDF.Quad>,\n operation: Algebra.Pattern,\n ): Promise<void> {\n // Check if the source supports quoted triple filtering\n const quotedTripleFiltering = Boolean(this.source.features?.quotedTripleFiltering);\n\n let cardinality: number;\n if (this.source.countQuads) {\n // If the source provides a dedicated method for determining cardinality, use that.\n cardinality = await this.source.countQuads(\n QuerySourceRdfJs.nullifyVariables(operation.subject, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.predicate, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.object, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.graph, quotedTripleFiltering),\n );\n } else {\n // Otherwise, fallback to a sub-optimal alternative where we just call match again to count the quads.\n // WARNING: we can NOT reuse the original data stream here,\n // because we may lose data elements due to things happening async.\n let i = 0;\n cardinality = await new Promise((resolve, reject) => {\n const matches = this.source.match(\n QuerySourceRdfJs.nullifyVariables(operation.subject, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.predicate, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.object, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.graph, quotedTripleFiltering),\n );\n matches.on('error', reject);\n matches.on('end', () => resolve(i));\n matches.on('data', () => i++);\n });\n }\n\n // If `match` would require filtering afterwards, our count will be an over-estimate.\n const wouldRequirePostFiltering = (!quotedTripleFiltering &&\n someTerms(operation, term => term.termType === 'Quad')) ||\n QuerySourceRdfJs.hasDuplicateVariables(operation);\n\n it.setProperty('metadata', {\n state: new MetadataValidationState(),\n cardinality: { type: wouldRequirePostFiltering ? 'estimate' : 'exact', value: cardinality },\n });\n }\n\n public queryQuads(\n _operation: Algebra.Operation,\n _context: IActionContext,\n ): AsyncIterator<RDF.Quad> {\n throw new Error('queryQuads is not implemented in QuerySourceRdfJs');\n }\n\n public queryBoolean(\n _operation: Algebra.Ask,\n _context: IActionContext,\n ): Promise<boolean> {\n throw new Error('queryBoolean is not implemented in QuerySourceRdfJs');\n }\n\n public queryVoid(\n _operation: Algebra.Update,\n _context: IActionContext,\n ): Promise<void> {\n throw new Error('queryVoid is not implemented in QuerySourceRdfJs');\n }\n\n public toString(): string {\n return `QuerySourceRdfJs(${this.source.constructor.name})`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"QuerySourceRdfJs.js","sourceRoot":"","sources":["QuerySourceRdfJs.ts"],"names":[],"mappings":";;;AACA,mFAAiG;AACjG,+DAA+D;AAC/D,iDAA6D;AAG7D,iDAAyE;AACzE,uDAA+C;AAC/C,yCAAqF;AAErF,qDAA0C;AAG1C,MAAM,EAAE,GAAG,IAAI,yBAAO,EAAE,CAAC;AACzB,MAAM,EAAE,GAAG,IAAI,8BAAW,EAAgB,CAAC;AAE3C,MAAa,gBAAgB;IAkB3B,YAAmB,MAAkB,EAAE,eAAgC;QACrE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;QAC7B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAEM,MAAM,CAAC,gBAAgB,CAAC,IAA0B,EAAE,qBAA8B;QACvF,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,KAAK,UAAU,IAAI,CAAC,CAAC,qBAAqB;YACrE,IAAI,CAAC,QAAQ,KAAK,MAAM,IAAI,IAAA,2BAAe,EAAC,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC;YAC5F,SAAS,CAAC,CAAC;YACX,IAAI,CAAC;IACT,CAAC;IAEM,MAAM,CAAC,qBAAqB,CAAC,OAAqB;QACvD,MAAM,SAAS,GAAG,IAAA,6BAAiB,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,C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B,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAEM,SAAS,CACd,UAA0B,EAC1B,QAAwB;QAExB,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACtE,CAAC;IAEM,QAAQ;QACb,OAAO,oBAAoB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC;IAC7D,CAAC;;AAnJH,4CAoJC;AAnJ2B,+BAAc,GAA0B;IAChE,IAAI,EAAE,WAAW;IACjB,SAAS,EAAE;QACT,aAAa,EAAE,SAAS;QACxB,OAAO,EAAE,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;KAChF;IACD,iBAAiB,EAAE;QACjB,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;QAChB,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;QAChB,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC;KACjB;CACF,CAAC","sourcesContent":["import type { BindingsFactory } from '@comunica/bindings-factory';\nimport { filterMatchingQuotedQuads, quadsToBindings } from '@comunica/bus-query-source-identify';\nimport { KeysQueryOperation } from '@comunica/context-entries';\nimport { MetadataValidationState } from '@comunica/metadata';\nimport type { IQuerySource, BindingsStream, IActionContext, FragmentSelectorShape } from '@comunica/types';\nimport type * as RDF from '@rdfjs/types';\nimport { AsyncIterator, wrap as wrapAsyncIterator } from 'asynciterator';\nimport { DataFactory } from 'rdf-data-factory';\nimport { someTermsNested, filterTermsNested, someTerms, uniqTerms } from 'rdf-terms';\nimport type { Algebra } from 'sparqlalgebrajs';\nimport { Factory } from 'sparqlalgebrajs';\nimport type { IRdfJsSourceExtended } from './IRdfJsSourceExtended';\n\nconst AF = new Factory();\nconst DF = new DataFactory<RDF.BaseQuad>();\n\nexport class QuerySourceRdfJs implements IQuerySource {\n protected static readonly SELECTOR_SHAPE: FragmentSelectorShape = {\n type: 'operation',\n operation: {\n operationType: 'pattern',\n pattern: AF.createPattern(DF.variable('s'), DF.variable('p'), DF.variable('o')),\n },\n variablesOptional: [\n DF.variable('s'),\n DF.variable('p'),\n DF.variable('o'),\n ],\n };\n\n public referenceValue: string | RDF.Source;\n protected readonly source: IRdfJsSourceExtended;\n private readonly bindingsFactory: BindingsFactory;\n\n public constructor(source: RDF.Source, bindingsFactory: BindingsFactory) {\n this.source = source;\n this.referenceValue = source;\n this.bindingsFactory = bindingsFactory;\n }\n\n public static nullifyVariables(term: RDF.Term | undefined, quotedTripleFiltering: boolean): RDF.Term | undefined {\n return !term || term.termType === 'Variable' || (!quotedTripleFiltering &&\n term.termType === 'Quad' && someTermsNested(term, value => value.termType === 'Variable')) ?\n undefined :\n term;\n }\n\n public static hasDuplicateVariables(pattern: RDF.BaseQuad): boolean {\n const variables = filterTermsNested(pattern, term => term.termType === 'Variable');\n return variables.length > 1 && uniqTerms(variables).length < variables.length;\n }\n\n public async getSelectorShape(): Promise<FragmentSelectorShape> {\n return QuerySourceRdfJs.SELECTOR_SHAPE;\n }\n\n public queryBindings(operation: Algebra.Operation, context: IActionContext): BindingsStream {\n if (operation.type !== 'pattern') {\n throw new Error(`Attempted to pass non-pattern operation '${operation.type}' to QuerySourceRdfJs`);\n }\n\n // Check if the source supports quoted triple filtering\n const quotedTripleFiltering = Boolean(this.source.features?.quotedTripleFiltering);\n\n // Create an async iterator from the matched quad stream\n const rawStream = this.source.match(\n QuerySourceRdfJs.nullifyVariables(operation.subject, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.predicate, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.object, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.graph, quotedTripleFiltering),\n );\n let it: AsyncIterator<RDF.Quad> = rawStream instanceof AsyncIterator ?\n rawStream :\n wrapAsyncIterator<RDF.Quad>(rawStream, { autoStart: false });\n\n // Perform post-match-filtering if the source does not support quoted triple filtering.\n if (!quotedTripleFiltering) {\n it = filterMatchingQuotedQuads(operation, it);\n }\n\n // Determine metadata\n if (!it.getProperty('metadata')) {\n this.setMetadata(it, operation)\n .catch(error => it.destroy(error));\n }\n\n return quadsToBindings(\n it,\n operation,\n this.bindingsFactory,\n Boolean(context.get(KeysQueryOperation.unionDefaultGraph)),\n );\n }\n\n protected async setMetadata(\n it: AsyncIterator<RDF.Quad>,\n operation: Algebra.Pattern,\n ): Promise<void> {\n // Check if the source supports quoted triple filtering\n const quotedTripleFiltering = Boolean(this.source.features?.quotedTripleFiltering);\n\n let cardinality: number;\n if (this.source.countQuads) {\n // If the source provides a dedicated method for determining cardinality, use that.\n cardinality = await this.source.countQuads(\n QuerySourceRdfJs.nullifyVariables(operation.subject, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.predicate, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.object, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.graph, quotedTripleFiltering),\n );\n } else {\n // Otherwise, fallback to a sub-optimal alternative where we just call match again to count the quads.\n // WARNING: we can NOT reuse the original data stream here,\n // because we may lose data elements due to things happening async.\n let i = 0;\n cardinality = await new Promise((resolve, reject) => {\n const matches = this.source.match(\n QuerySourceRdfJs.nullifyVariables(operation.subject, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.predicate, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.object, quotedTripleFiltering),\n QuerySourceRdfJs.nullifyVariables(operation.graph, quotedTripleFiltering),\n );\n matches.on('error', reject);\n matches.on('end', () => resolve(i));\n matches.on('data', () => i++);\n });\n }\n\n // If `match` would require filtering afterwards, our count will be an over-estimate.\n const wouldRequirePostFiltering = (!quotedTripleFiltering &&\n someTerms(operation, term => term.termType === 'Quad')) ||\n QuerySourceRdfJs.hasDuplicateVariables(operation);\n\n it.setProperty('metadata', {\n state: new MetadataValidationState(),\n cardinality: { type: wouldRequirePostFiltering ? 'estimate' : 'exact', value: cardinality },\n canContainUndefs: false,\n });\n }\n\n public queryQuads(\n _operation: Algebra.Operation,\n _context: IActionContext,\n ): AsyncIterator<RDF.Quad> {\n throw new Error('queryQuads is not implemented in QuerySourceRdfJs');\n }\n\n public queryBoolean(\n _operation: Algebra.Ask,\n _context: IActionContext,\n ): Promise<boolean> {\n throw new Error('queryBoolean is not implemented in QuerySourceRdfJs');\n }\n\n public queryVoid(\n _operation: Algebra.Update,\n _context: IActionContext,\n ): Promise<void> {\n throw new Error('queryVoid is not implemented in QuerySourceRdfJs');\n }\n\n public toString(): string {\n return `QuerySourceRdfJs(${this.source.constructor.name})`;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-query-source-identify-rdfjs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "A rdfjs query-source-identify actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"funding": {
|
|
8
|
-
"type": "opencollective",
|
|
9
|
-
"url": "https://opencollective.com/comunica-association"
|
|
10
|
-
},
|
|
11
7
|
"homepage": "https://comunica.dev/",
|
|
12
8
|
"repository": {
|
|
13
9
|
"type": "git",
|
|
@@ -41,17 +37,18 @@
|
|
|
41
37
|
"build:components": "componentsjs-generator"
|
|
42
38
|
},
|
|
43
39
|
"dependencies": {
|
|
44
|
-
"@comunica/
|
|
45
|
-
"@comunica/bus-
|
|
46
|
-
"@comunica/
|
|
47
|
-
"@comunica/
|
|
48
|
-
"@comunica/
|
|
49
|
-
"@comunica/
|
|
50
|
-
"@comunica/
|
|
40
|
+
"@comunica/bindings-factory": "^3.3.0",
|
|
41
|
+
"@comunica/bus-merge-bindings-context": "^3.3.0",
|
|
42
|
+
"@comunica/bus-query-source-identify": "^3.3.0",
|
|
43
|
+
"@comunica/context-entries": "^3.3.0",
|
|
44
|
+
"@comunica/core": "^3.3.0",
|
|
45
|
+
"@comunica/metadata": "^3.3.0",
|
|
46
|
+
"@comunica/types": "^3.3.0",
|
|
51
47
|
"@rdfjs/types": "*",
|
|
52
48
|
"asynciterator": "^3.9.0",
|
|
49
|
+
"rdf-data-factory": "^1.1.1",
|
|
53
50
|
"rdf-terms": "^1.11.0",
|
|
54
|
-
"sparqlalgebrajs": "^4.3.
|
|
51
|
+
"sparqlalgebrajs": "^4.3.7"
|
|
55
52
|
},
|
|
56
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "02bde397d206f1f5a523643a6a604c89e792e2f9"
|
|
57
54
|
}
|