@comunica/actor-query-source-identify-hypermedia-sparql 4.5.0 → 5.0.2
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 +3 -1
- package/components/ActorQuerySourceIdentifyHypermediaSparql.jsonld +37 -33
- package/components/QuerySourceSparql.jsonld +38 -7
- package/components/components.jsonld +1 -1
- package/components/context.jsonld +18 -3
- package/lib/ActorQuerySourceIdentifyHypermediaSparql.d.ts +8 -2
- package/lib/ActorQuerySourceIdentifyHypermediaSparql.js +30 -4
- package/lib/ActorQuerySourceIdentifyHypermediaSparql.js.map +1 -1
- package/lib/QuerySourceSparql.d.ts +14 -10
- package/lib/QuerySourceSparql.js +140 -88
- package/lib/QuerySourceSparql.js.map +1 -1
- package/lib/index.d.ts +0 -0
- package/lib/index.js +0 -0
- package/lib/index.js.map +0 -0
- package/package.json +17 -16
package/README.md
CHANGED
|
@@ -30,7 +30,8 @@ After installing, this package can be added to your engine's configuration as fo
|
|
|
30
30
|
"@id": "urn:comunica:default:query-source-identify-hypermedia/actors#sparql",
|
|
31
31
|
"@type": "ActorQuerySourceIdentifyHypermediaSparql",
|
|
32
32
|
"mediatorHttp": { "@id": "urn:comunica:default:http/mediators#main" },
|
|
33
|
-
"mediatorMergeBindingsContext": { "@id": "urn:comunica:default:merge-bindings-context/mediators#main" }
|
|
33
|
+
"mediatorMergeBindingsContext": { "@id": "urn:comunica:default:merge-bindings-context/mediators#main" },
|
|
34
|
+
"mediatorQuerySerialize": { "@id": "urn:comunica:default:query-serialize/mediators#main" }
|
|
34
35
|
}
|
|
35
36
|
]
|
|
36
37
|
}
|
|
@@ -40,6 +41,7 @@ After installing, this package can be added to your engine's configuration as fo
|
|
|
40
41
|
|
|
41
42
|
* `mediatorHttp`: A mediator over the [HTTP bus](https://github.com/comunica/comunica/tree/master/packages/bus-http).
|
|
42
43
|
* `mediatorMergeBindingsContext`: A mediator over the [Merge Bindings Context bus](https://github.com/comunica/comunica/tree/master/packages/bus-merge-bindings-context).
|
|
44
|
+
* `mediatorQuerySerialize`: A mediator over the [Query Serialize bus](https://github.com/comunica/comunica/tree/master/packages/bus-query-serialize).
|
|
43
45
|
* `checkUrlSuffix`: If URLs ending with '/sparql' should also be considered SPARQL endpoints, defaults to `true`.
|
|
44
46
|
* `forceHttpGet`: If queries should be sent via HTTP GET instead of POST, defaults to `false`.
|
|
45
47
|
* `forceSourceType`: Forces all sources provided to be interpreted as SPARQL endpoints, defaults to `false`.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-source-identify-hypermedia-sparql/^
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^
|
|
5
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-query-source-identify-hypermedia/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-source-identify-hypermedia-sparql/^5.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^5.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/bus-query-source-identify-hypermedia/^5.0.0/components/context.jsonld"
|
|
6
6
|
],
|
|
7
7
|
"@id": "npmd:@comunica/actor-query-source-identify-hypermedia-sparql",
|
|
8
8
|
"components": [
|
|
@@ -25,6 +25,11 @@
|
|
|
25
25
|
"range": "cc:components/Mediator.jsonld#Mediator",
|
|
26
26
|
"comment": "A mediator for creating binding context merge handlers"
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_mediatorQuerySerialize",
|
|
30
|
+
"range": "cc:components/Mediator.jsonld#Mediator",
|
|
31
|
+
"comment": "Mediator for serializing queries."
|
|
32
|
+
},
|
|
28
33
|
{
|
|
29
34
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_checkUrlSuffix",
|
|
30
35
|
"range": "xsd:boolean",
|
|
@@ -39,15 +44,7 @@
|
|
|
39
44
|
},
|
|
40
45
|
{
|
|
41
46
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_cacheSize",
|
|
42
|
-
"range":
|
|
43
|
-
"@type": "ParameterRangeUnion",
|
|
44
|
-
"parameterRangeElements": [
|
|
45
|
-
"xsd:integer",
|
|
46
|
-
{
|
|
47
|
-
"@type": "ParameterRangeUndefined"
|
|
48
|
-
}
|
|
49
|
-
]
|
|
50
|
-
},
|
|
47
|
+
"range": "xsd:integer",
|
|
51
48
|
"default": "1024",
|
|
52
49
|
"comment": "The cache size for COUNT queries."
|
|
53
50
|
},
|
|
@@ -107,15 +104,7 @@
|
|
|
107
104
|
},
|
|
108
105
|
{
|
|
109
106
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_forceGetIfUrlLengthBelow",
|
|
110
|
-
"range":
|
|
111
|
-
"@type": "ParameterRangeUnion",
|
|
112
|
-
"parameterRangeElements": [
|
|
113
|
-
"xsd:number",
|
|
114
|
-
{
|
|
115
|
-
"@type": "ParameterRangeUndefined"
|
|
116
|
-
}
|
|
117
|
-
]
|
|
118
|
-
},
|
|
107
|
+
"range": "xsd:number",
|
|
119
108
|
"default": "600",
|
|
120
109
|
"comment": "Force an HTTP GET instead of default POST (when forceHttpGet is false) when the url length (including encoded query) is below this number."
|
|
121
110
|
},
|
|
@@ -139,37 +128,37 @@
|
|
|
139
128
|
"genericTypeInstances": [
|
|
140
129
|
{
|
|
141
130
|
"@type": "ParameterRangeGenericTypeReference",
|
|
142
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
131
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
143
132
|
},
|
|
144
133
|
{
|
|
145
134
|
"@type": "ParameterRangeGenericTypeReference",
|
|
146
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
135
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
147
136
|
},
|
|
148
137
|
{
|
|
149
138
|
"@type": "ParameterRangeGenericTypeReference",
|
|
150
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
139
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
151
140
|
},
|
|
152
141
|
{
|
|
153
142
|
"@type": "ParameterRangeGenericTypeReference",
|
|
154
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
143
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
155
144
|
}
|
|
156
145
|
]
|
|
157
146
|
},
|
|
158
147
|
{
|
|
159
148
|
"@type": "ParameterRangeGenericTypeReference",
|
|
160
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
149
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
161
150
|
},
|
|
162
151
|
{
|
|
163
152
|
"@type": "ParameterRangeGenericTypeReference",
|
|
164
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
153
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
165
154
|
},
|
|
166
155
|
{
|
|
167
156
|
"@type": "ParameterRangeGenericTypeReference",
|
|
168
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
157
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
169
158
|
},
|
|
170
159
|
{
|
|
171
160
|
"@type": "ParameterRangeGenericTypeReference",
|
|
172
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
161
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
173
162
|
}
|
|
174
163
|
]
|
|
175
164
|
},
|
|
@@ -206,19 +195,19 @@
|
|
|
206
195
|
"genericTypeInstances": [
|
|
207
196
|
{
|
|
208
197
|
"@type": "ParameterRangeGenericTypeReference",
|
|
209
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
198
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_I"
|
|
210
199
|
},
|
|
211
200
|
{
|
|
212
201
|
"@type": "ParameterRangeGenericTypeReference",
|
|
213
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
202
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_T"
|
|
214
203
|
},
|
|
215
204
|
{
|
|
216
205
|
"@type": "ParameterRangeGenericTypeReference",
|
|
217
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
206
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_O"
|
|
218
207
|
},
|
|
219
208
|
{
|
|
220
209
|
"@type": "ParameterRangeGenericTypeReference",
|
|
221
|
-
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^
|
|
210
|
+
"parameterRangeGenericType": "npmd:@comunica/actor-abstract-mediatyped/^5.0.0/components/ActorAbstractMediaTyped.jsonld#ActorAbstractMediaTyped__generic_TS"
|
|
222
211
|
}
|
|
223
212
|
]
|
|
224
213
|
}
|
|
@@ -242,6 +231,11 @@
|
|
|
242
231
|
"memberFieldName": "mediatorMergeBindingsContext",
|
|
243
232
|
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
244
233
|
},
|
|
234
|
+
{
|
|
235
|
+
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql__member_mediatorQuerySerialize",
|
|
236
|
+
"memberFieldName": "mediatorQuerySerialize",
|
|
237
|
+
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
238
|
+
},
|
|
245
239
|
{
|
|
246
240
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql__member_checkUrlSuffix",
|
|
247
241
|
"memberFieldName": "checkUrlSuffix",
|
|
@@ -332,6 +326,12 @@
|
|
|
332
326
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_mediatorMergeBindingsContext"
|
|
333
327
|
}
|
|
334
328
|
},
|
|
329
|
+
{
|
|
330
|
+
"keyRaw": "mediatorQuerySerialize",
|
|
331
|
+
"value": {
|
|
332
|
+
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_mediatorQuerySerialize"
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
335
|
{
|
|
336
336
|
"keyRaw": "checkUrlSuffix",
|
|
337
337
|
"value": {
|
|
@@ -428,6 +428,10 @@
|
|
|
428
428
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#IActorQuerySourceIdentifyHypermediaSparqlArgs__member_mediatorMergeBindingsContext",
|
|
429
429
|
"memberFieldName": "mediatorMergeBindingsContext"
|
|
430
430
|
},
|
|
431
|
+
{
|
|
432
|
+
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#IActorQuerySourceIdentifyHypermediaSparqlArgs__member_mediatorQuerySerialize",
|
|
433
|
+
"memberFieldName": "mediatorQuerySerialize"
|
|
434
|
+
},
|
|
431
435
|
{
|
|
432
436
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#IActorQuerySourceIdentifyHypermediaSparqlArgs__member_checkUrlSuffix",
|
|
433
437
|
"memberFieldName": "checkUrlSuffix"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-source-identify-hypermedia-sparql/^
|
|
4
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/types/^
|
|
5
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-source-identify-hypermedia-sparql/^5.0.0/components/context.jsonld",
|
|
4
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/types/^5.0.0/components/context.jsonld",
|
|
5
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/core/^5.0.0/components/context.jsonld"
|
|
6
6
|
],
|
|
7
7
|
"@id": "npmd:@comunica/actor-query-source-identify-hypermedia-sparql",
|
|
8
8
|
"components": [
|
|
@@ -16,10 +16,8 @@
|
|
|
16
16
|
"range": "xsd:string"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
"@id": "caqsihs:components/QuerySourceSparql.jsonld#
|
|
20
|
-
"range":
|
|
21
|
-
"@type": "ParameterRangeWildcard"
|
|
22
|
-
}
|
|
19
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_urlBackup",
|
|
20
|
+
"range": "xsd:string"
|
|
23
21
|
},
|
|
24
22
|
{
|
|
25
23
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_forceHttpGet",
|
|
@@ -45,6 +43,14 @@
|
|
|
45
43
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_forceGetIfUrlLengthBelow",
|
|
46
44
|
"range": "xsd:number"
|
|
47
45
|
},
|
|
46
|
+
{
|
|
47
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_parseUnsupportedVersions",
|
|
48
|
+
"range": "xsd:boolean"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_algebraFactory",
|
|
52
|
+
"range": "urn:npm:@traqula/algebra-transformations-1-1:AlgebraFactory"
|
|
53
|
+
},
|
|
48
54
|
{
|
|
49
55
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_bindingsFactory",
|
|
50
56
|
"range": "urn:npm:@comunica/utils-bindings-factory:BindingsFactory"
|
|
@@ -74,6 +80,10 @@
|
|
|
74
80
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_mediatorHttp",
|
|
75
81
|
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
76
82
|
},
|
|
83
|
+
{
|
|
84
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_mediatorQuerySerialize",
|
|
85
|
+
"range": "cc:components/Mediator.jsonld#Mediator"
|
|
86
|
+
},
|
|
77
87
|
{
|
|
78
88
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_bindMethod",
|
|
79
89
|
"range": {
|
|
@@ -117,6 +127,10 @@
|
|
|
117
127
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql__member_url",
|
|
118
128
|
"memberFieldName": "url"
|
|
119
129
|
},
|
|
130
|
+
{
|
|
131
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql__member_urlBackup",
|
|
132
|
+
"memberFieldName": "urlBackup"
|
|
133
|
+
},
|
|
120
134
|
{
|
|
121
135
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql__member_context",
|
|
122
136
|
"memberFieldName": "context"
|
|
@@ -125,6 +139,10 @@
|
|
|
125
139
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql__member_mediatorHttp",
|
|
126
140
|
"memberFieldName": "mediatorHttp"
|
|
127
141
|
},
|
|
142
|
+
{
|
|
143
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql__member_mediatorQuerySerialize",
|
|
144
|
+
"memberFieldName": "mediatorQuerySerialize"
|
|
145
|
+
},
|
|
128
146
|
{
|
|
129
147
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql__member_bindMethod",
|
|
130
148
|
"memberFieldName": "bindMethod"
|
|
@@ -193,6 +211,10 @@
|
|
|
193
211
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql__member_constructor",
|
|
194
212
|
"memberFieldName": "constructor"
|
|
195
213
|
},
|
|
214
|
+
{
|
|
215
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql__member_getFilterFactor",
|
|
216
|
+
"memberFieldName": "getFilterFactor"
|
|
217
|
+
},
|
|
196
218
|
{
|
|
197
219
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql__member_getSelectorShape",
|
|
198
220
|
"memberFieldName": "getSelectorShape"
|
|
@@ -262,12 +284,18 @@
|
|
|
262
284
|
{
|
|
263
285
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_url"
|
|
264
286
|
},
|
|
287
|
+
{
|
|
288
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_urlBackup"
|
|
289
|
+
},
|
|
265
290
|
{
|
|
266
291
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_context"
|
|
267
292
|
},
|
|
268
293
|
{
|
|
269
294
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_mediatorHttp"
|
|
270
295
|
},
|
|
296
|
+
{
|
|
297
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_mediatorQuerySerialize"
|
|
298
|
+
},
|
|
271
299
|
{
|
|
272
300
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_bindMethod"
|
|
273
301
|
},
|
|
@@ -298,6 +326,9 @@
|
|
|
298
326
|
{
|
|
299
327
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_forceGetIfUrlLengthBelow"
|
|
300
328
|
},
|
|
329
|
+
{
|
|
330
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_parseUnsupportedVersions"
|
|
331
|
+
},
|
|
301
332
|
{
|
|
302
333
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_metadata__constructorArgument",
|
|
303
334
|
"fields": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-source-identify-hypermedia-sparql/^
|
|
3
|
+
"https://linkedsoftwaredependencies.org/bundles/npm/@comunica/actor-query-source-identify-hypermedia-sparql/^5.0.0/components/context.jsonld"
|
|
4
4
|
],
|
|
5
5
|
"@id": "npmd:@comunica/actor-query-source-identify-hypermedia-sparql",
|
|
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
|
-
"caqsihs": "npmd:@comunica/actor-query-source-identify-hypermedia-sparql/^
|
|
6
|
+
"caqsihs": "npmd:@comunica/actor-query-source-identify-hypermedia-sparql/^5.0.0/",
|
|
7
7
|
"ActorQuerySourceIdentifyHypermediaSparql": {
|
|
8
8
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql",
|
|
9
9
|
"@prefix": true,
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
"args_mediatorMergeBindingsContext": {
|
|
15
15
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_mediatorMergeBindingsContext"
|
|
16
16
|
},
|
|
17
|
+
"args_mediatorQuerySerialize": {
|
|
18
|
+
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_mediatorQuerySerialize"
|
|
19
|
+
},
|
|
17
20
|
"args_checkUrlSuffix": {
|
|
18
21
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_checkUrlSuffix"
|
|
19
22
|
},
|
|
@@ -60,6 +63,9 @@
|
|
|
60
63
|
"mediatorMergeBindingsContext": {
|
|
61
64
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_mediatorMergeBindingsContext"
|
|
62
65
|
},
|
|
66
|
+
"mediatorQuerySerialize": {
|
|
67
|
+
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_mediatorQuerySerialize"
|
|
68
|
+
},
|
|
63
69
|
"checkUrlSuffix": {
|
|
64
70
|
"@id": "caqsihs:components/ActorQuerySourceIdentifyHypermediaSparql.jsonld#ActorQuerySourceIdentifyHypermediaSparql_args_checkUrlSuffix"
|
|
65
71
|
},
|
|
@@ -114,8 +120,8 @@
|
|
|
114
120
|
"url": {
|
|
115
121
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_url"
|
|
116
122
|
},
|
|
117
|
-
"
|
|
118
|
-
"@id": "caqsihs:components/QuerySourceSparql.jsonld#
|
|
123
|
+
"urlBackup": {
|
|
124
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_urlBackup"
|
|
119
125
|
},
|
|
120
126
|
"forceHttpGet": {
|
|
121
127
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_forceHttpGet"
|
|
@@ -135,6 +141,12 @@
|
|
|
135
141
|
"forceGetIfUrlLengthBelow": {
|
|
136
142
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_forceGetIfUrlLengthBelow"
|
|
137
143
|
},
|
|
144
|
+
"parseUnsupportedVersions": {
|
|
145
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_parseUnsupportedVersions"
|
|
146
|
+
},
|
|
147
|
+
"algebraFactory": {
|
|
148
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_algebraFactory"
|
|
149
|
+
},
|
|
138
150
|
"bindingsFactory": {
|
|
139
151
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_bindingsFactory"
|
|
140
152
|
},
|
|
@@ -148,6 +160,9 @@
|
|
|
148
160
|
"mediatorHttp": {
|
|
149
161
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_mediatorHttp"
|
|
150
162
|
},
|
|
163
|
+
"mediatorQuerySerialize": {
|
|
164
|
+
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_mediatorQuerySerialize"
|
|
165
|
+
},
|
|
151
166
|
"bindMethod": {
|
|
152
167
|
"@id": "caqsihs:components/QuerySourceSparql.jsonld#QuerySourceSparql_bindMethod"
|
|
153
168
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { MediatorHttp } from '@comunica/bus-http';
|
|
2
2
|
import type { MediatorMergeBindingsContext } from '@comunica/bus-merge-bindings-context';
|
|
3
|
+
import type { MediatorQuerySerialize } from '@comunica/bus-query-serialize';
|
|
3
4
|
import type { IActionQuerySourceIdentifyHypermedia, IActorQuerySourceIdentifyHypermediaOutput, IActorQuerySourceIdentifyHypermediaArgs, IActorQuerySourceIdentifyHypermediaTest } from '@comunica/bus-query-source-identify-hypermedia';
|
|
4
5
|
import { ActorQuerySourceIdentifyHypermedia } from '@comunica/bus-query-source-identify-hypermedia';
|
|
5
6
|
import type { TestResult } from '@comunica/core';
|
|
@@ -9,6 +10,7 @@ import type { TestResult } from '@comunica/core';
|
|
|
9
10
|
export declare class ActorQuerySourceIdentifyHypermediaSparql extends ActorQuerySourceIdentifyHypermedia {
|
|
10
11
|
readonly mediatorHttp: MediatorHttp;
|
|
11
12
|
readonly mediatorMergeBindingsContext: MediatorMergeBindingsContext;
|
|
13
|
+
readonly mediatorQuerySerialize: MediatorQuerySerialize;
|
|
12
14
|
readonly checkUrlSuffix: boolean;
|
|
13
15
|
readonly forceHttpGet: boolean;
|
|
14
16
|
readonly cacheSize: number;
|
|
@@ -31,6 +33,10 @@ export interface IActorQuerySourceIdentifyHypermediaSparqlArgs extends IActorQue
|
|
|
31
33
|
* A mediator for creating binding context merge handlers
|
|
32
34
|
*/
|
|
33
35
|
mediatorMergeBindingsContext: MediatorMergeBindingsContext;
|
|
36
|
+
/**
|
|
37
|
+
* Mediator for serializing queries.
|
|
38
|
+
*/
|
|
39
|
+
mediatorQuerySerialize: MediatorQuerySerialize;
|
|
34
40
|
/**
|
|
35
41
|
* If URLs ending with '/sparql' should also be considered SPARQL endpoints.
|
|
36
42
|
* @default {true}
|
|
@@ -46,7 +52,7 @@ export interface IActorQuerySourceIdentifyHypermediaSparqlArgs extends IActorQue
|
|
|
46
52
|
* @range {integer}
|
|
47
53
|
* @default {1024}
|
|
48
54
|
*/
|
|
49
|
-
cacheSize
|
|
55
|
+
cacheSize: number;
|
|
50
56
|
/**
|
|
51
57
|
* If provided, forces the source type of a source.
|
|
52
58
|
* @default {false}
|
|
@@ -80,6 +86,6 @@ export interface IActorQuerySourceIdentifyHypermediaSparqlArgs extends IActorQue
|
|
|
80
86
|
* when the url length (including encoded query) is below this number.
|
|
81
87
|
* @default {600}
|
|
82
88
|
*/
|
|
83
|
-
forceGetIfUrlLengthBelow
|
|
89
|
+
forceGetIfUrlLengthBelow: number;
|
|
84
90
|
}
|
|
85
91
|
export type BindMethod = 'values' | 'union' | 'filter';
|
|
@@ -4,15 +4,39 @@ exports.ActorQuerySourceIdentifyHypermediaSparql = void 0;
|
|
|
4
4
|
const bus_query_source_identify_hypermedia_1 = require("@comunica/bus-query-source-identify-hypermedia");
|
|
5
5
|
const context_entries_1 = require("@comunica/context-entries");
|
|
6
6
|
const core_1 = require("@comunica/core");
|
|
7
|
+
const utils_algebra_1 = require("@comunica/utils-algebra");
|
|
7
8
|
const utils_bindings_factory_1 = require("@comunica/utils-bindings-factory");
|
|
8
|
-
const sparqlalgebrajs_1 = require("sparqlalgebrajs");
|
|
9
9
|
const QuerySourceSparql_1 = require("./QuerySourceSparql");
|
|
10
10
|
/**
|
|
11
11
|
* A comunica SPARQL Query Source Identify Hypermedia Actor.
|
|
12
12
|
*/
|
|
13
13
|
class ActorQuerySourceIdentifyHypermediaSparql extends bus_query_source_identify_hypermedia_1.ActorQuerySourceIdentifyHypermedia {
|
|
14
|
+
mediatorHttp;
|
|
15
|
+
mediatorMergeBindingsContext;
|
|
16
|
+
mediatorQuerySerialize;
|
|
17
|
+
checkUrlSuffix;
|
|
18
|
+
forceHttpGet;
|
|
19
|
+
cacheSize;
|
|
20
|
+
forceSourceType;
|
|
21
|
+
bindMethod;
|
|
22
|
+
countTimeout;
|
|
23
|
+
cardinalityCountQueries;
|
|
24
|
+
cardinalityEstimateConstruction;
|
|
25
|
+
forceGetIfUrlLengthBelow;
|
|
14
26
|
constructor(args) {
|
|
15
27
|
super(args, 'sparql');
|
|
28
|
+
this.mediatorHttp = args.mediatorHttp;
|
|
29
|
+
this.mediatorMergeBindingsContext = args.mediatorMergeBindingsContext;
|
|
30
|
+
this.mediatorQuerySerialize = args.mediatorQuerySerialize;
|
|
31
|
+
this.checkUrlSuffix = args.checkUrlSuffix;
|
|
32
|
+
this.forceHttpGet = args.forceHttpGet;
|
|
33
|
+
this.cacheSize = args.cacheSize;
|
|
34
|
+
this.forceSourceType = Boolean(args.forceSourceType);
|
|
35
|
+
this.bindMethod = args.bindMethod;
|
|
36
|
+
this.countTimeout = args.countTimeout;
|
|
37
|
+
this.cardinalityCountQueries = args.cardinalityCountQueries;
|
|
38
|
+
this.cardinalityEstimateConstruction = args.cardinalityEstimateConstruction;
|
|
39
|
+
this.forceGetIfUrlLengthBelow = args.forceGetIfUrlLengthBelow;
|
|
16
40
|
}
|
|
17
41
|
async testMetadata(action) {
|
|
18
42
|
if (!action.forceSourceType && !this.forceSourceType && !action.metadata.sparqlService &&
|
|
@@ -24,11 +48,13 @@ class ActorQuerySourceIdentifyHypermediaSparql extends bus_query_source_identify
|
|
|
24
48
|
async run(action) {
|
|
25
49
|
this.logInfo(action.context, `Identified ${action.url} as sparql source with service URL: ${action.metadata.sparqlService || action.url}`);
|
|
26
50
|
const dataFactory = action.context.getSafe(context_entries_1.KeysInitQuery.dataFactory);
|
|
27
|
-
const algebraFactory = new
|
|
51
|
+
const algebraFactory = new utils_algebra_1.AlgebraFactory(dataFactory);
|
|
28
52
|
const isSingularSource = action.context.get(context_entries_1.KeysQueryOperation.querySources)?.length === 1;
|
|
29
|
-
const source = new QuerySourceSparql_1.QuerySourceSparql((action.forceSourceType ?? this.forceSourceType) ? action.url : action.metadata.sparqlService || action.url,
|
|
53
|
+
const source = new QuerySourceSparql_1.QuerySourceSparql((action.forceSourceType ?? this.forceSourceType) ? action.url : action.metadata.sparqlService || action.url,
|
|
54
|
+
// Pass the original URL as backup, as some endpoints misconfigure their endpoint URL in the service description.
|
|
55
|
+
action.url, action.context, this.mediatorHttp, this.mediatorQuerySerialize, this.bindMethod, dataFactory, algebraFactory, await utils_bindings_factory_1.BindingsFactory.create(this.mediatorMergeBindingsContext, action.context, dataFactory), this.forceHttpGet, this.cacheSize, this.countTimeout,
|
|
30
56
|
// Cardinalities can be infinity when we're querying just a single source.
|
|
31
|
-
this.cardinalityCountQueries && !isSingularSource, this.cardinalityEstimateConstruction, this.forceGetIfUrlLengthBelow, action.metadata);
|
|
57
|
+
this.cardinalityCountQueries && !isSingularSource, this.cardinalityEstimateConstruction, this.forceGetIfUrlLengthBelow, Boolean(action.context.get(context_entries_1.KeysInitQuery.parseUnsupportedVersions)), action.metadata);
|
|
32
58
|
return { source };
|
|
33
59
|
}
|
|
34
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActorQuerySourceIdentifyHypermediaSparql.js","sourceRoot":"","sources":["ActorQuerySourceIdentifyHypermediaSparql.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ActorQuerySourceIdentifyHypermediaSparql.js","sourceRoot":"","sources":["ActorQuerySourceIdentifyHypermediaSparql.ts"],"names":[],"mappings":";;;AASA,yGAEwD;AACxD,+DAA8E;AAE9E,yCAAoD;AAEpD,2DAAyD;AACzD,6EAAmE;AACnE,2DAAwD;AAExD;;GAEG;AACH,MAAa,wCAAyC,SAAQ,yEAAkC;IAC9E,YAAY,CAAe;IAC3B,4BAA4B,CAA+B;IAC3D,sBAAsB,CAAyB;IAC/C,cAAc,CAAU;IACxB,YAAY,CAAU;IACtB,SAAS,CAAS;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gB,EACjD,IAAI,CAAC,+BAA+B,EACpC,IAAI,CAAC,wBAAwB,EAC7B,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,+BAAa,CAAC,wBAAwB,CAAC,CAAC,EACnE,MAAM,CAAC,QAAQ,CAChB,CAAC;QACF,OAAO,EAAE,MAAM,EAAE,CAAC;IACpB,CAAC;CACF;AArED,4FAqEC","sourcesContent":["import type { MediatorHttp } from '@comunica/bus-http';\nimport type { MediatorMergeBindingsContext } from '@comunica/bus-merge-bindings-context';\nimport type { MediatorQuerySerialize } from '@comunica/bus-query-serialize';\nimport type {\n IActionQuerySourceIdentifyHypermedia,\n IActorQuerySourceIdentifyHypermediaOutput,\n IActorQuerySourceIdentifyHypermediaArgs,\n IActorQuerySourceIdentifyHypermediaTest,\n} from '@comunica/bus-query-source-identify-hypermedia';\nimport {\n ActorQuerySourceIdentifyHypermedia,\n} from '@comunica/bus-query-source-identify-hypermedia';\nimport { KeysInitQuery, KeysQueryOperation } from '@comunica/context-entries';\nimport type { TestResult } from '@comunica/core';\nimport { failTest, passTest } from '@comunica/core';\nimport type { ComunicaDataFactory } from '@comunica/types';\nimport { AlgebraFactory } from '@comunica/utils-algebra';\nimport { BindingsFactory } from '@comunica/utils-bindings-factory';\nimport { QuerySourceSparql } from './QuerySourceSparql';\n\n/**\n * A comunica SPARQL Query Source Identify Hypermedia Actor.\n */\nexport class ActorQuerySourceIdentifyHypermediaSparql extends ActorQuerySourceIdentifyHypermedia {\n public readonly mediatorHttp: MediatorHttp;\n public readonly mediatorMergeBindingsContext: MediatorMergeBindingsContext;\n public readonly mediatorQuerySerialize: MediatorQuerySerialize;\n public readonly checkUrlSuffix: boolean;\n public readonly forceHttpGet: boolean;\n public readonly cacheSize: number;\n public readonly forceSourceType: boolean;\n public readonly bindMethod: BindMethod;\n public readonly countTimeout: number;\n public readonly cardinalityCountQueries: boolean;\n public readonly cardinalityEstimateConstruction: boolean;\n public readonly forceGetIfUrlLengthBelow: number;\n\n public constructor(args: IActorQuerySourceIdentifyHypermediaSparqlArgs) {\n super(args, 'sparql');\n this.mediatorHttp = args.mediatorHttp;\n this.mediatorMergeBindingsContext = args.mediatorMergeBindingsContext;\n this.mediatorQuerySerialize = args.mediatorQuerySerialize;\n this.checkUrlSuffix = args.checkUrlSuffix;\n this.forceHttpGet = args.forceHttpGet;\n this.cacheSize = args.cacheSize;\n this.forceSourceType = Boolean(args.forceSourceType);\n this.bindMethod = args.bindMethod;\n this.countTimeout = args.countTimeout;\n this.cardinalityCountQueries = args.cardinalityCountQueries;\n this.cardinalityEstimateConstruction = args.cardinalityEstimateConstruction;\n this.forceGetIfUrlLengthBelow = args.forceGetIfUrlLengthBelow;\n }\n\n public async testMetadata(\n action: IActionQuerySourceIdentifyHypermedia,\n ): Promise<TestResult<IActorQuerySourceIdentifyHypermediaTest>> {\n if (!action.forceSourceType && !this.forceSourceType && !action.metadata.sparqlService &&\n !(this.checkUrlSuffix && (action.url.endsWith('/sparql') || action.url.endsWith('/sparql/')))) {\n return failTest(`Actor ${this.name} could not detect a SPARQL service description or URL ending on /sparql.`);\n }\n return passTest({ filterFactor: 1 });\n }\n\n public async run(action: IActionQuerySourceIdentifyHypermedia): Promise<IActorQuerySourceIdentifyHypermediaOutput> {\n this.logInfo(action.context, `Identified ${action.url} as sparql source with service URL: ${action.metadata.sparqlService || action.url}`);\n\n const dataFactory: ComunicaDataFactory = action.context.getSafe(KeysInitQuery.dataFactory);\n const algebraFactory = new AlgebraFactory(dataFactory);\n const isSingularSource = action.context.get(KeysQueryOperation.querySources)?.length === 1;\n const source = new QuerySourceSparql(\n (action.forceSourceType ?? this.forceSourceType) ? action.url : action.metadata.sparqlService || action.url,\n // Pass the original URL as backup, as some endpoints misconfigure their endpoint URL in the service description.\n action.url,\n action.context,\n this.mediatorHttp,\n this.mediatorQuerySerialize,\n this.bindMethod,\n dataFactory,\n algebraFactory,\n await BindingsFactory.create(this.mediatorMergeBindingsContext, action.context, dataFactory),\n this.forceHttpGet,\n this.cacheSize,\n this.countTimeout,\n // Cardinalities can be infinity when we're querying just a single source.\n this.cardinalityCountQueries && !isSingularSource,\n this.cardinalityEstimateConstruction,\n this.forceGetIfUrlLengthBelow,\n Boolean(action.context.get(KeysInitQuery.parseUnsupportedVersions)),\n action.metadata,\n );\n return { source };\n }\n}\n\nexport interface IActorQuerySourceIdentifyHypermediaSparqlArgs extends IActorQuerySourceIdentifyHypermediaArgs {\n /**\n * The HTTP mediator\n */\n mediatorHttp: MediatorHttp;\n /**\n * A mediator for creating binding context merge handlers\n */\n mediatorMergeBindingsContext: MediatorMergeBindingsContext;\n /**\n * Mediator for serializing queries.\n */\n mediatorQuerySerialize: MediatorQuerySerialize;\n /**\n * If URLs ending with '/sparql' should also be considered SPARQL endpoints.\n * @default {true}\n */\n checkUrlSuffix: boolean;\n /**\n * If non-update queries should be sent via HTTP GET instead of POST\n * @default {false}\n */\n forceHttpGet: boolean;\n /**\n * The cache size for COUNT queries.\n * @range {integer}\n * @default {1024}\n */\n cacheSize: number;\n /**\n * If provided, forces the source type of a source.\n * @default {false}\n */\n forceSourceType?: boolean;\n /**\n * The query operation for communicating bindings.\n * @default {values}\n */\n bindMethod: BindMethod;\n /**\n * Timeout in ms of how long count queries are allowed to take.\n * If the timeout is reached, an infinity cardinality is returned.\n * @default {3000}\n */\n countTimeout: number;\n /**\n * If count queries should be sent to obtain the cardinality of (sub)queries.\n * If set to false, resulting cardinalities will always be considered infinity.\n * @default {true}\n */\n cardinalityCountQueries: boolean;\n /**\n * If estimates for queries should be constructed locally from sub-query cardinalities.\n * If set to false, count queries will used for cardinality estimation at all levels.\n * @default {false}\n */\n cardinalityEstimateConstruction: boolean;\n /**\n * Force an HTTP GET instead of default POST (when forceHttpGet is false)\n * when the url length (including encoded query) is below this number.\n * @default {600}\n */\n forceGetIfUrlLengthBelow: number;\n}\n\nexport type BindMethod = 'values' | 'union' | 'filter';\n"]}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type { MediatorHttp } from '@comunica/bus-http';
|
|
2
|
+
import type { MediatorQuerySerialize } from '@comunica/bus-query-serialize';
|
|
2
3
|
import type { BindingsStream, ComunicaDataFactory, FragmentSelectorShape, IActionContext, IQueryBindingsOptions, IQuerySource, MetadataBindings, QueryResultCardinality } from '@comunica/types';
|
|
4
|
+
import type { AlgebraFactory } from '@comunica/utils-algebra';
|
|
5
|
+
import { Algebra } from '@comunica/utils-algebra';
|
|
3
6
|
import type { BindingsFactory } from '@comunica/utils-bindings-factory';
|
|
4
7
|
import type * as RDF from '@rdfjs/types';
|
|
5
8
|
import type { AsyncIterator } from 'asynciterator';
|
|
6
|
-
import type { Factory } from 'sparqlalgebrajs';
|
|
7
|
-
import { Algebra } from 'sparqlalgebrajs';
|
|
8
9
|
import type { BindMethod } from './ActorQuerySourceIdentifyHypermediaSparql';
|
|
9
10
|
export declare class QuerySourceSparql implements IQuerySource {
|
|
10
11
|
readonly referenceValue: string;
|
|
11
|
-
private
|
|
12
|
+
private url;
|
|
13
|
+
private readonly urlBackup;
|
|
12
14
|
private readonly context;
|
|
13
15
|
private readonly mediatorHttp;
|
|
16
|
+
private readonly mediatorQuerySerialize;
|
|
14
17
|
private readonly bindMethod;
|
|
15
18
|
private readonly countTimeout;
|
|
16
19
|
private readonly cardinalityCountQueries;
|
|
@@ -26,12 +29,13 @@ export declare class QuerySourceSparql implements IQuerySource {
|
|
|
26
29
|
private readonly endpointFetcher;
|
|
27
30
|
private readonly cache;
|
|
28
31
|
private lastSourceContext;
|
|
29
|
-
constructor(url: string, context: IActionContext, mediatorHttp: MediatorHttp, bindMethod: BindMethod, dataFactory: ComunicaDataFactory, algebraFactory:
|
|
32
|
+
constructor(url: string, urlBackup: string, context: IActionContext, mediatorHttp: MediatorHttp, mediatorQuerySerialize: MediatorQuerySerialize, bindMethod: BindMethod, dataFactory: ComunicaDataFactory, algebraFactory: AlgebraFactory, bindingsFactory: BindingsFactory, forceHttpGet: boolean, cacheSize: number, countTimeout: number, cardinalityCountQueries: boolean, cardinalityEstimateConstruction: boolean, forceGetIfUrlLengthBelow: number, parseUnsupportedVersions: boolean, metadata: Record<string, any>);
|
|
33
|
+
getFilterFactor(): Promise<number>;
|
|
30
34
|
getSelectorShape(): Promise<FragmentSelectorShape>;
|
|
31
35
|
queryBindings(operationIn: Algebra.Operation, context: IActionContext, options?: IQueryBindingsOptions): BindingsStream;
|
|
32
36
|
queryQuads(operation: Algebra.Operation, context: IActionContext): AsyncIterator<RDF.Quad>;
|
|
33
37
|
queryBoolean(operation: Algebra.Ask, context: IActionContext): Promise<boolean>;
|
|
34
|
-
queryVoid(operation: Algebra.
|
|
38
|
+
queryVoid(operation: Algebra.Operation, context: IActionContext): Promise<void>;
|
|
35
39
|
protected attachMetadata(target: AsyncIterator<any>, context: IActionContext, operationPromise: Promise<Algebra.Operation>): void;
|
|
36
40
|
/**
|
|
37
41
|
* Convert an algebra operation into a query string, and if the operation is a simple triple pattern,
|
|
@@ -39,7 +43,7 @@ export declare class QuerySourceSparql implements IQuerySource {
|
|
|
39
43
|
* @param {Algebra.Operation} operation The operation to convert into a query string.
|
|
40
44
|
* @returns {string} Query string for a COUNT query over the operation.
|
|
41
45
|
*/
|
|
42
|
-
operationToNormalizedCountQuery(operation: Algebra.Operation): string
|
|
46
|
+
operationToNormalizedCountQuery(operation: Algebra.Operation): Promise<string>;
|
|
43
47
|
/**
|
|
44
48
|
* Performs local cardinality estimation for the specified SPARQL algebra operation, which should
|
|
45
49
|
* result in better estimation performance at the expense of accuracy.
|
|
@@ -62,7 +66,7 @@ export declare class QuerySourceSparql implements IQuerySource {
|
|
|
62
66
|
* @param addBindings.bindings The bindings stream.
|
|
63
67
|
* @param addBindings.metadata The bindings metadata.
|
|
64
68
|
*/
|
|
65
|
-
static addBindingsToOperation(algebraFactory:
|
|
69
|
+
static addBindingsToOperation(algebraFactory: AlgebraFactory, bindMethod: BindMethod, operation: Algebra.Operation, addBindings: {
|
|
66
70
|
bindings: BindingsStream;
|
|
67
71
|
metadata: MetadataBindings;
|
|
68
72
|
}): Promise<Algebra.Operation>;
|
|
@@ -73,7 +77,7 @@ export declare class QuerySourceSparql implements IQuerySource {
|
|
|
73
77
|
* @param {RDF.Variable[]} variables The variables in scope for the operation.
|
|
74
78
|
* @return {string} A select query string.
|
|
75
79
|
*/
|
|
76
|
-
|
|
80
|
+
operationToSelectQuery(algebraFactory: AlgebraFactory, operation: Algebra.Operation, variables: RDF.Variable[]): Promise<string>;
|
|
77
81
|
/**
|
|
78
82
|
* Convert an operation to a count query for the number of matching triples for this pattern.
|
|
79
83
|
* @param dataFactory The data factory.
|
|
@@ -81,13 +85,13 @@ export declare class QuerySourceSparql implements IQuerySource {
|
|
|
81
85
|
* @param {Algebra.Operation} operation A query operation.
|
|
82
86
|
* @return {string} A count query string.
|
|
83
87
|
*/
|
|
84
|
-
|
|
88
|
+
operationToCountQuery(dataFactory: ComunicaDataFactory, algebraFactory: AlgebraFactory, operation: Algebra.Operation): Promise<string>;
|
|
85
89
|
/**
|
|
86
90
|
* Convert an operation to a query for this pattern.
|
|
87
91
|
* @param {Algebra.Operation} operation A query operation.
|
|
88
92
|
* @return {string} A query string.
|
|
89
93
|
*/
|
|
90
|
-
|
|
94
|
+
operationToQuery(operation: Algebra.Operation): Promise<string>;
|
|
91
95
|
/**
|
|
92
96
|
* Check if the given operation may produce undefined values.
|
|
93
97
|
* @param operation
|
package/lib/QuerySourceSparql.js
CHANGED
|
@@ -3,30 +3,65 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.QuerySourceSparql = void 0;
|
|
4
4
|
const context_entries_1 = require("@comunica/context-entries");
|
|
5
5
|
const core_1 = require("@comunica/core");
|
|
6
|
+
const utils_algebra_1 = require("@comunica/utils-algebra");
|
|
6
7
|
const utils_metadata_1 = require("@comunica/utils-metadata");
|
|
7
8
|
const utils_query_operation_1 = require("@comunica/utils-query-operation");
|
|
8
9
|
const asynciterator_1 = require("asynciterator");
|
|
9
10
|
const fetch_sparql_endpoint_1 = require("fetch-sparql-endpoint");
|
|
10
11
|
const lru_cache_1 = require("lru-cache");
|
|
11
12
|
const rdf_terms_1 = require("rdf-terms");
|
|
12
|
-
const sparqlalgebrajs_1 = require("sparqlalgebrajs");
|
|
13
13
|
class QuerySourceSparql {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
referenceValue;
|
|
15
|
+
url;
|
|
16
|
+
urlBackup;
|
|
17
|
+
context;
|
|
18
|
+
mediatorHttp;
|
|
19
|
+
mediatorQuerySerialize;
|
|
20
|
+
bindMethod;
|
|
21
|
+
countTimeout;
|
|
22
|
+
cardinalityCountQueries;
|
|
23
|
+
cardinalityEstimateConstruction;
|
|
24
|
+
defaultGraph;
|
|
25
|
+
unionDefaultGraph;
|
|
26
|
+
propertyFeatures;
|
|
27
|
+
datasets;
|
|
28
|
+
extensionFunctions;
|
|
29
|
+
dataFactory;
|
|
30
|
+
algebraFactory;
|
|
31
|
+
bindingsFactory;
|
|
32
|
+
endpointFetcher;
|
|
33
|
+
cache;
|
|
34
|
+
lastSourceContext;
|
|
35
|
+
constructor(url, urlBackup, context, mediatorHttp, mediatorQuerySerialize, bindMethod, dataFactory, algebraFactory, bindingsFactory, forceHttpGet, cacheSize, countTimeout, cardinalityCountQueries, cardinalityEstimateConstruction, forceGetIfUrlLengthBelow, parseUnsupportedVersions, metadata) {
|
|
36
|
+
this.referenceValue = urlBackup;
|
|
16
37
|
this.url = url;
|
|
38
|
+
this.urlBackup = urlBackup;
|
|
17
39
|
this.context = context;
|
|
18
40
|
this.mediatorHttp = mediatorHttp;
|
|
41
|
+
this.mediatorQuerySerialize = mediatorQuerySerialize;
|
|
19
42
|
this.bindMethod = bindMethod;
|
|
20
43
|
this.dataFactory = dataFactory;
|
|
21
44
|
this.algebraFactory = algebraFactory;
|
|
22
45
|
this.bindingsFactory = bindingsFactory;
|
|
23
46
|
this.endpointFetcher = new fetch_sparql_endpoint_1.SparqlEndpointFetcher({
|
|
24
47
|
method: forceHttpGet ? 'GET' : 'POST',
|
|
25
|
-
fetch: (input, init) =>
|
|
48
|
+
fetch: async (input, init) => {
|
|
49
|
+
const response = await this.mediatorHttp.mediate({ input, init, context: this.lastSourceContext });
|
|
50
|
+
// If we encounter a 404, try our backup URL.
|
|
51
|
+
// After retrying the request with the new URL, we replace the URL for future requests.
|
|
52
|
+
if (response.status === 404 && this.url !== this.urlBackup) {
|
|
53
|
+
core_1.Actor.getContextLogger(this.context)?.warn(`Encountered a 404 when requesting ${this.url} according to the service description of ${this.urlBackup}. This is a server configuration issue. Retrying the current and modifying future requests to ${this.urlBackup} instead.`);
|
|
54
|
+
input = input.replace(this.url, this.urlBackup);
|
|
55
|
+
this.url = this.urlBackup;
|
|
56
|
+
return await this.mediatorHttp.mediate({ input, init, context: this.lastSourceContext });
|
|
57
|
+
}
|
|
58
|
+
return response;
|
|
59
|
+
},
|
|
26
60
|
prefixVariableQuestionMark: true,
|
|
27
61
|
dataFactory,
|
|
28
62
|
forceGetIfUrlLengthBelow,
|
|
29
63
|
directPost: metadata.postAccepted && !metadata.postAccepted.includes('application/x-www-form-urlencoded'),
|
|
64
|
+
parseUnsupportedVersions,
|
|
30
65
|
});
|
|
31
66
|
this.cache = cacheSize > 0 ?
|
|
32
67
|
new lru_cache_1.LRUCache({ max: cacheSize }) :
|
|
@@ -40,6 +75,9 @@ class QuerySourceSparql {
|
|
|
40
75
|
this.extensionFunctions = metadata.extensionFunctions;
|
|
41
76
|
this.propertyFeatures = metadata.propertyFeatures ? new Set(metadata.propertyFeatures) : undefined;
|
|
42
77
|
}
|
|
78
|
+
async getFilterFactor() {
|
|
79
|
+
return 1;
|
|
80
|
+
}
|
|
43
81
|
async getSelectorShape() {
|
|
44
82
|
const innerDisjunction = {
|
|
45
83
|
type: 'disjunction',
|
|
@@ -56,7 +94,7 @@ class QuerySourceSparql {
|
|
|
56
94
|
type: 'operation',
|
|
57
95
|
operation: {
|
|
58
96
|
operationType: 'type',
|
|
59
|
-
type:
|
|
97
|
+
type: utils_algebra_1.Algebra.Types.EXPRESSION,
|
|
60
98
|
extensionFunctions: this.extensionFunctions,
|
|
61
99
|
},
|
|
62
100
|
joinBindings: true,
|
|
@@ -71,11 +109,11 @@ class QuerySourceSparql {
|
|
|
71
109
|
type: 'negation',
|
|
72
110
|
child: {
|
|
73
111
|
type: 'operation',
|
|
74
|
-
operation: { operationType: 'type', type:
|
|
112
|
+
operation: { operationType: 'type', type: utils_algebra_1.Algebra.Types.DISTINCT },
|
|
75
113
|
children: [
|
|
76
114
|
{
|
|
77
115
|
type: 'operation',
|
|
78
|
-
operation: { operationType: 'type', type:
|
|
116
|
+
operation: { operationType: 'type', type: utils_algebra_1.Algebra.Types.CONSTRUCT },
|
|
79
117
|
children: [
|
|
80
118
|
{
|
|
81
119
|
type: 'operation',
|
|
@@ -102,12 +140,12 @@ class QuerySourceSparql {
|
|
|
102
140
|
const bindings = new asynciterator_1.TransformIterator(async () => {
|
|
103
141
|
// Prepare queries
|
|
104
142
|
const operation = await operationPromise;
|
|
105
|
-
const variables =
|
|
143
|
+
const variables = utils_algebra_1.algebraUtils.inScopeVariables(operation);
|
|
106
144
|
const queryString = context.get(context_entries_1.KeysInitQuery.queryString);
|
|
107
145
|
const queryFormat = context.getSafe(context_entries_1.KeysInitQuery.queryFormat);
|
|
108
146
|
const selectQuery = !options?.joinBindings && queryString && queryFormat.language === 'sparql' ?
|
|
109
147
|
queryString :
|
|
110
|
-
|
|
148
|
+
await this.operationToSelectQuery(this.algebraFactory, operation, variables);
|
|
111
149
|
const undefVariables = QuerySourceSparql.getOperationUndefs(operation);
|
|
112
150
|
return this.queryBindingsRemote(this.url, selectQuery, variables, context, undefVariables);
|
|
113
151
|
}, { autoStart: false });
|
|
@@ -115,29 +153,31 @@ class QuerySourceSparql {
|
|
|
115
153
|
return bindings;
|
|
116
154
|
}
|
|
117
155
|
queryQuads(operation, context) {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
156
|
+
const quads = (0, asynciterator_1.wrap)((async () => {
|
|
157
|
+
this.lastSourceContext = this.context.merge(context);
|
|
158
|
+
const query = context.get(context_entries_1.KeysInitQuery.queryString) ?? await this.operationToQuery(operation);
|
|
159
|
+
const rawStream = await this.endpointFetcher.fetchTriples(this.url, query);
|
|
160
|
+
this.lastSourceContext = undefined;
|
|
161
|
+
return rawStream;
|
|
162
|
+
})(), { autoStart: false, maxBufferSize: Number.POSITIVE_INFINITY });
|
|
123
163
|
this.attachMetadata(quads, context, Promise.resolve(operation.input));
|
|
124
164
|
return quads;
|
|
125
165
|
}
|
|
126
|
-
queryBoolean(operation, context) {
|
|
166
|
+
async queryBoolean(operation, context) {
|
|
127
167
|
// Shortcut the ASK query to return true when supported propertyFeature predicates are used in it.
|
|
128
168
|
if (this.operationUsesPropertyFeatures(operation)) {
|
|
129
|
-
return
|
|
169
|
+
return true;
|
|
130
170
|
}
|
|
131
171
|
// Without propertyFeature overlap, perform the actual ASK query.
|
|
132
172
|
this.lastSourceContext = this.context.merge(context);
|
|
133
|
-
const query = context.get(context_entries_1.KeysInitQuery.queryString) ??
|
|
173
|
+
const query = context.get(context_entries_1.KeysInitQuery.queryString) ?? await this.operationToQuery(operation);
|
|
134
174
|
const promise = this.endpointFetcher.fetchAsk(this.url, query);
|
|
135
175
|
this.lastSourceContext = undefined;
|
|
136
176
|
return promise;
|
|
137
177
|
}
|
|
138
|
-
queryVoid(operation, context) {
|
|
178
|
+
async queryVoid(operation, context) {
|
|
139
179
|
this.lastSourceContext = this.context.merge(context);
|
|
140
|
-
const query = context.get(context_entries_1.KeysInitQuery.queryString) ??
|
|
180
|
+
const query = context.get(context_entries_1.KeysInitQuery.queryString) ?? await this.operationToQuery(operation);
|
|
141
181
|
const promise = this.endpointFetcher.fetchUpdate(this.url, query);
|
|
142
182
|
this.lastSourceContext = undefined;
|
|
143
183
|
return promise;
|
|
@@ -149,8 +189,8 @@ class QuerySourceSparql {
|
|
|
149
189
|
new Promise(async (resolve, reject) => {
|
|
150
190
|
try {
|
|
151
191
|
const operation = await operationPromise;
|
|
152
|
-
const variablesScoped =
|
|
153
|
-
const countQuery = this.operationToNormalizedCountQuery(operation);
|
|
192
|
+
const variablesScoped = utils_algebra_1.algebraUtils.inScopeVariables(operation);
|
|
193
|
+
const countQuery = await this.operationToNormalizedCountQuery(operation);
|
|
154
194
|
const undefVariables = QuerySourceSparql.getOperationUndefs(operation);
|
|
155
195
|
variablesCount = variablesScoped.map(variable => ({
|
|
156
196
|
variable,
|
|
@@ -230,12 +270,11 @@ class QuerySourceSparql {
|
|
|
230
270
|
* @param {Algebra.Operation} operation The operation to convert into a query string.
|
|
231
271
|
* @returns {string} Query string for a COUNT query over the operation.
|
|
232
272
|
*/
|
|
233
|
-
operationToNormalizedCountQuery(operation) {
|
|
234
|
-
const normalizedOperation = operation
|
|
273
|
+
async operationToNormalizedCountQuery(operation) {
|
|
274
|
+
const normalizedOperation = (0, utils_algebra_1.isKnownOperation)(operation, utils_algebra_1.Algebra.Types.PATTERN) ?
|
|
235
275
|
this.algebraFactory.createPattern(operation.subject.termType === 'Variable' ? this.dataFactory.variable('s') : operation.subject, operation.predicate.termType === 'Variable' ? this.dataFactory.variable('p') : operation.predicate, operation.object.termType === 'Variable' ? this.dataFactory.variable('o') : operation.object) :
|
|
236
276
|
operation;
|
|
237
|
-
|
|
238
|
-
return operationString;
|
|
277
|
+
return await this.operationToCountQuery(this.dataFactory, this.algebraFactory, normalizedOperation);
|
|
239
278
|
}
|
|
240
279
|
/**
|
|
241
280
|
* Performs local cardinality estimation for the specified SPARQL algebra operation, which should
|
|
@@ -247,16 +286,16 @@ class QuerySourceSparql {
|
|
|
247
286
|
return { type: 'estimate', value: 1, dataset: this.url };
|
|
248
287
|
}
|
|
249
288
|
const dataset = {
|
|
250
|
-
getCardinality: (operation) => {
|
|
251
|
-
const queryString = this.operationToNormalizedCountQuery(operation);
|
|
289
|
+
getCardinality: async (operation) => {
|
|
290
|
+
const queryString = await this.operationToNormalizedCountQuery(operation);
|
|
252
291
|
const cachedCardinality = this.cache?.get(queryString);
|
|
253
292
|
if (cachedCardinality) {
|
|
254
293
|
return cachedCardinality;
|
|
255
294
|
}
|
|
256
295
|
if (this.datasets) {
|
|
257
|
-
const cardinalities = this.datasets
|
|
296
|
+
const cardinalities = await Promise.all(this.datasets
|
|
258
297
|
.filter(ds => this.unionDefaultGraph || (this.defaultGraph && ds.uri.endsWith(this.defaultGraph)))
|
|
259
|
-
.map(ds => (0, utils_query_operation_1.estimateCardinality)(operation, ds));
|
|
298
|
+
.map(ds => (0, utils_query_operation_1.estimateCardinality)(operation, ds)));
|
|
260
299
|
const cardinality = {
|
|
261
300
|
type: cardinalities.some(card => card.type === 'estimate') ? 'estimate' : 'exact',
|
|
262
301
|
value: cardinalities.length > 0 ? cardinalities.reduce((acc, card) => acc + card.value, 0) : 0,
|
|
@@ -279,24 +318,30 @@ class QuerySourceSparql {
|
|
|
279
318
|
operationUsesPropertyFeatures(operation) {
|
|
280
319
|
let propertyFeaturesUsed = false;
|
|
281
320
|
if (this.propertyFeatures) {
|
|
282
|
-
|
|
283
|
-
[
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
321
|
+
utils_algebra_1.algebraUtils.visitOperation(operation, {
|
|
322
|
+
[utils_algebra_1.Algebra.Types.PATTERN]: {
|
|
323
|
+
visitor: (subOp) => {
|
|
324
|
+
if (subOp.predicate.termType === 'NamedNode' && this.propertyFeatures.has(subOp.predicate.value)) {
|
|
325
|
+
propertyFeaturesUsed = true;
|
|
326
|
+
}
|
|
327
|
+
return false;
|
|
328
|
+
},
|
|
288
329
|
},
|
|
289
|
-
[
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
330
|
+
[utils_algebra_1.Algebra.Types.LINK]: {
|
|
331
|
+
visitor: (subOp) => {
|
|
332
|
+
if (this.propertyFeatures.has(subOp.iri.value)) {
|
|
333
|
+
propertyFeaturesUsed = true;
|
|
334
|
+
}
|
|
335
|
+
return false;
|
|
336
|
+
},
|
|
294
337
|
},
|
|
295
|
-
[
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
338
|
+
[utils_algebra_1.Algebra.Types.NPS]: {
|
|
339
|
+
visitor: (subOp) => {
|
|
340
|
+
if (subOp.iris.some(iri => this.propertyFeatures.has(iri.value))) {
|
|
341
|
+
propertyFeaturesUsed = true;
|
|
342
|
+
}
|
|
343
|
+
return false;
|
|
344
|
+
},
|
|
300
345
|
},
|
|
301
346
|
});
|
|
302
347
|
}
|
|
@@ -317,7 +362,7 @@ class QuerySourceSparql {
|
|
|
317
362
|
case 'values':
|
|
318
363
|
return algebraFactory.createJoin([
|
|
319
364
|
algebraFactory.createValues(addBindings.metadata.variables.map(v => v.variable), bindings.map(binding => Object.fromEntries([...binding]
|
|
320
|
-
.map(([key, value]) => [
|
|
365
|
+
.map(([key, value]) => [key.value, value])))),
|
|
321
366
|
operation,
|
|
322
367
|
], false);
|
|
323
368
|
case 'union': {
|
|
@@ -335,8 +380,8 @@ class QuerySourceSparql {
|
|
|
335
380
|
* @param {RDF.Variable[]} variables The variables in scope for the operation.
|
|
336
381
|
* @return {string} A select query string.
|
|
337
382
|
*/
|
|
338
|
-
|
|
339
|
-
return
|
|
383
|
+
operationToSelectQuery(algebraFactory, operation, variables) {
|
|
384
|
+
return this.operationToQuery(algebraFactory.createProject(operation, variables));
|
|
340
385
|
}
|
|
341
386
|
/**
|
|
342
387
|
* Convert an operation to a count query for the number of matching triples for this pattern.
|
|
@@ -345,16 +390,22 @@ class QuerySourceSparql {
|
|
|
345
390
|
* @param {Algebra.Operation} operation A query operation.
|
|
346
391
|
* @return {string} A count query string.
|
|
347
392
|
*/
|
|
348
|
-
|
|
349
|
-
return
|
|
393
|
+
operationToCountQuery(dataFactory, algebraFactory, operation) {
|
|
394
|
+
return this.operationToQuery(algebraFactory.createProject(algebraFactory.createExtend(algebraFactory.createGroup(operation, [], [algebraFactory.createBoundAggregate(dataFactory.variable('var0'), 'count', algebraFactory.createWildcardExpression(), false)]), dataFactory.variable('count'), algebraFactory.createTermExpression(dataFactory.variable('var0'))), [dataFactory.variable('count')]));
|
|
350
395
|
}
|
|
351
396
|
/**
|
|
352
397
|
* Convert an operation to a query for this pattern.
|
|
353
398
|
* @param {Algebra.Operation} operation A query operation.
|
|
354
399
|
* @return {string} A query string.
|
|
355
400
|
*/
|
|
356
|
-
|
|
357
|
-
return (
|
|
401
|
+
async operationToQuery(operation) {
|
|
402
|
+
return (await this.mediatorQuerySerialize.mediate({
|
|
403
|
+
queryFormat: { language: 'sparql', version: '1.2' },
|
|
404
|
+
operation,
|
|
405
|
+
newlines: false,
|
|
406
|
+
indentWidth: 0,
|
|
407
|
+
context: this.context,
|
|
408
|
+
})).query;
|
|
358
409
|
}
|
|
359
410
|
/**
|
|
360
411
|
* Check if the given operation may produce undefined values.
|
|
@@ -362,35 +413,35 @@ class QuerySourceSparql {
|
|
|
362
413
|
*/
|
|
363
414
|
static getOperationUndefs(operation) {
|
|
364
415
|
const variables = [];
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
416
|
+
utils_algebra_1.algebraUtils.visitOperation(operation, {
|
|
417
|
+
[utils_algebra_1.Algebra.Types.LEFT_JOIN]: { preVisitor: (subOperation) => {
|
|
418
|
+
const left = utils_algebra_1.algebraUtils.inScopeVariables(subOperation.input[0]);
|
|
419
|
+
const right = utils_algebra_1.algebraUtils.inScopeVariables(subOperation.input[1]);
|
|
420
|
+
for (const varRight of right) {
|
|
421
|
+
if (!left.some(varLeft => varLeft.equals(varRight))) {
|
|
422
|
+
variables.push(varRight);
|
|
423
|
+
}
|
|
372
424
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
425
|
+
return { continue: false };
|
|
426
|
+
} },
|
|
427
|
+
[utils_algebra_1.Algebra.Types.VALUES]: { preVisitor: (values) => {
|
|
428
|
+
for (const variable of values.variables) {
|
|
429
|
+
if (values.bindings.some(bindings => !(variable.value in bindings))) {
|
|
430
|
+
variables.push(variable);
|
|
431
|
+
}
|
|
380
432
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
433
|
+
return { continue: false };
|
|
434
|
+
} },
|
|
435
|
+
[utils_algebra_1.Algebra.Types.UNION]: { preVisitor: (union) => {
|
|
436
|
+
// Determine variables in scope of the union branches that are not occurring in every branch
|
|
437
|
+
const scopedVariables = union.input.map(op => utils_algebra_1.algebraUtils.inScopeVariables(op));
|
|
438
|
+
for (const variable of (0, rdf_terms_1.uniqTerms)(scopedVariables.flat())) {
|
|
439
|
+
if (!scopedVariables.every(input => input.some(inputVar => inputVar.equals(variable)))) {
|
|
440
|
+
variables.push(variable);
|
|
441
|
+
}
|
|
390
442
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
},
|
|
443
|
+
return {};
|
|
444
|
+
} },
|
|
394
445
|
});
|
|
395
446
|
return (0, rdf_terms_1.uniqTerms)(variables);
|
|
396
447
|
}
|
|
@@ -409,16 +460,17 @@ class QuerySourceSparql {
|
|
|
409
460
|
this.lastSourceContext = this.context.merge(context);
|
|
410
461
|
const rawStream = await this.endpointFetcher.fetchBindings(endpoint, query);
|
|
411
462
|
this.lastSourceContext = undefined;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
.map((variable) => {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
.
|
|
463
|
+
const wrapped = (0, asynciterator_1.wrap)(rawStream, { autoStart: false, maxBufferSize: Number.POSITIVE_INFINITY });
|
|
464
|
+
return wrapped.map((rawData) => {
|
|
465
|
+
const bindings = variables.map((variable) => {
|
|
466
|
+
const value = rawData[`?${variable.value}`];
|
|
467
|
+
if (!undefVariablesSet.has(variable.value) && !value) {
|
|
468
|
+
core_1.Actor.getContextLogger(this.context)?.warn(`The endpoint ${endpoint} failed to provide a binding for ${variable.value}.`);
|
|
469
|
+
}
|
|
470
|
+
return [variable, value];
|
|
471
|
+
}).filter(([_, v]) => Boolean(v));
|
|
472
|
+
return this.bindingsFactory.bindings(bindings);
|
|
473
|
+
});
|
|
422
474
|
}
|
|
423
475
|
toString() {
|
|
424
476
|
return `QuerySourceSparql(${this.url})`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuerySourceSparql.js","sourceRoot":"","sources":["QuerySourceSparql.ts"],"names":[],"mappings":";;;AACA,+DAA0D;AAC1D,yCAAuC;AAevC,6DAAmE;AACnE,2EAAsE;AAGtE,iDAAwD;AACxD,iEAA8D;AAC9D,yCAAqC;AACrC,yCAAsC;AAEtC,qDAA0D;AAG1D,MAAa,iBAAiB;IAuB5B,YACE,GAAW,EACX,OAAuB,EACvB,YAA0B,EAC1B,UAAsB,EACtB,WAAgC,EAChC,cAAuB,EACvB,eAAgC,EAChC,YAAqB,EACrB,SAAiB,EACjB,YAAoB,EACpB,uBAAgC,EAChC,+BAAwC,EACxC,wBAAgC,EAChC,QAA6B;QAE7B,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC;QAC1B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,eAAe,GAAG,IAAI,6CAAqB,CAAC;YAC/C,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,KAAK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CAAC,GAAG,GAAG,CAAC;IAC1C,CAAC;CACF;AA3hBD,8CA2hBC","sourcesContent":["import type { MediatorHttp } from '@comunica/bus-http';\nimport { KeysInitQuery } from '@comunica/context-entries';\nimport { Actor } from '@comunica/core';\nimport type {\n Bindings,\n BindingsStream,\n ComunicaDataFactory,\n FragmentSelectorShape,\n IActionContext,\n IDataset,\n IQueryBindingsOptions,\n IQuerySource,\n MetadataBindings,\n MetadataVariable,\n QueryResultCardinality,\n} from '@comunica/types';\nimport type { BindingsFactory } from '@comunica/utils-bindings-factory';\nimport { MetadataValidationState } from '@comunica/utils-metadata';\nimport { estimateCardinality } from '@comunica/utils-query-operation';\nimport type * as RDF from '@rdfjs/types';\nimport type { AsyncIterator } from 'asynciterator';\nimport { TransformIterator, wrap } from 'asynciterator';\nimport { SparqlEndpointFetcher } from 'fetch-sparql-endpoint';\nimport { LRUCache } from 'lru-cache';\nimport { uniqTerms } from 'rdf-terms';\nimport type { Factory } from 'sparqlalgebrajs';\nimport { toSparql, Algebra, Util } from 'sparqlalgebrajs';\nimport type { BindMethod } from './ActorQuerySourceIdentifyHypermediaSparql';\n\nexport class QuerySourceSparql implements IQuerySource {\n public readonly referenceValue: string;\n private readonly url: string;\n private readonly context: IActionContext;\n private readonly mediatorHttp: MediatorHttp;\n private readonly bindMethod: BindMethod;\n private readonly countTimeout: number;\n private readonly cardinalityCountQueries: boolean;\n private readonly cardinalityEstimateConstruction: boolean;\n private readonly defaultGraph?: string;\n private readonly unionDefaultGraph: boolean;\n private readonly propertyFeatures?: Set<string>;\n private readonly datasets?: IDataset[];\n public readonly extensionFunctions?: string[];\n private readonly dataFactory: ComunicaDataFactory;\n private readonly algebraFactory: Factory;\n private readonly bindingsFactory: BindingsFactory;\n\n private readonly endpointFetcher: SparqlEndpointFetcher;\n private readonly cache: LRUCache<string, QueryResultCardinality> | undefined;\n\n private lastSourceContext: IActionContext | undefined;\n\n public constructor(\n url: string,\n context: IActionContext,\n mediatorHttp: MediatorHttp,\n bindMethod: BindMethod,\n dataFactory: ComunicaDataFactory,\n algebraFactory: Factory,\n bindingsFactory: BindingsFactory,\n forceHttpGet: boolean,\n cacheSize: number,\n countTimeout: number,\n cardinalityCountQueries: boolean,\n cardinalityEstimateConstruction: boolean,\n forceGetIfUrlLengthBelow: number,\n metadata: Record<string, any>,\n ) {\n this.referenceValue = url;\n this.url = url;\n this.context = context;\n this.mediatorHttp = mediatorHttp;\n this.bindMethod = bindMethod;\n this.dataFactory = dataFactory;\n this.algebraFactory = algebraFactory;\n this.bindingsFactory = bindingsFactory;\n this.endpointFetcher = new SparqlEndpointFetcher({\n method: forceHttpGet ? 'GET' : 'POST',\n fetch: (input: Request | string, init?: RequestInit) => this.mediatorHttp.mediate(\n { input, init, context: this.lastSourceContext! },\n ),\n prefixVariableQuestionMark: true,\n dataFactory,\n forceGetIfUrlLengthBelow,\n directPost: metadata.postAccepted && !metadata.postAccepted.includes('application/x-www-form-urlencoded'),\n });\n this.cache = cacheSize > 0 ?\n new LRUCache<string, QueryResultCardinality>({ max: cacheSize }) :\n undefined;\n this.countTimeout = countTimeout;\n this.cardinalityCountQueries = cardinalityCountQueries;\n this.cardinalityEstimateConstruction = cardinalityEstimateConstruction;\n this.defaultGraph = metadata.defaultGraph;\n this.unionDefaultGraph = metadata.unionDefaultGraph ?? false;\n this.datasets = metadata.datasets;\n this.extensionFunctions = metadata.extensionFunctions;\n this.propertyFeatures = metadata.propertyFeatures ? new Set(metadata.propertyFeatures) : undefined;\n }\n\n public async getSelectorShape(): Promise<FragmentSelectorShape> {\n const innerDisjunction: FragmentSelectorShape = {\n type: 'disjunction',\n children: [\n {\n type: 'operation',\n operation: { operationType: 'wildcard' },\n joinBindings: true,\n },\n ],\n };\n if (this.extensionFunctions) {\n innerDisjunction.children.push({\n type: 'operation',\n operation: {\n operationType: 'type',\n type: Algebra.types.EXPRESSION,\n extensionFunctions: this.extensionFunctions,\n },\n joinBindings: true,\n });\n }\n return {\n type: 'conjunction',\n children: [\n innerDisjunction,\n {\n // DISTINCT CONSTRUCT is not allowed in SPARQL 1.1, so we explicitly disallowed it.\n type: 'negation',\n child: {\n type: 'operation',\n operation: { operationType: 'type', type: Algebra.types.DISTINCT },\n children: [\n {\n type: 'operation',\n operation: { operationType: 'type', type: Algebra.types.CONSTRUCT },\n children: [\n {\n type: 'operation',\n operation: { operationType: 'wildcard' },\n joinBindings: true,\n },\n ],\n },\n ],\n },\n },\n ],\n };\n }\n\n public queryBindings(\n operationIn: Algebra.Operation,\n context: IActionContext,\n options?: IQueryBindingsOptions,\n ): BindingsStream {\n // If bindings are passed, modify the operations\n let operationPromise: Promise<Algebra.Operation>;\n if (options?.joinBindings) {\n operationPromise = QuerySourceSparql.addBindingsToOperation(\n this.algebraFactory,\n this.bindMethod,\n operationIn,\n options.joinBindings,\n );\n } else {\n operationPromise = Promise.resolve(operationIn);\n }\n\n const bindings: BindingsStream = new TransformIterator(async() => {\n // Prepare queries\n const operation = await operationPromise;\n const variables: RDF.Variable[] = Util.inScopeVariables(operation);\n const queryString = context.get<string>(KeysInitQuery.queryString);\n const queryFormat: RDF.QueryFormat = context.getSafe(KeysInitQuery.queryFormat);\n const selectQuery: string = !options?.joinBindings && queryString && queryFormat.language === 'sparql' ?\n queryString :\n QuerySourceSparql.operationToSelectQuery(this.algebraFactory, operation, variables);\n const undefVariables = QuerySourceSparql.getOperationUndefs(operation);\n\n return this.queryBindingsRemote(this.url, selectQuery, variables, context, undefVariables);\n }, { autoStart: false });\n this.attachMetadata(bindings, context, operationPromise);\n\n return bindings;\n }\n\n public queryQuads(operation: Algebra.Operation, context: IActionContext): AsyncIterator<RDF.Quad> {\n this.lastSourceContext = this.context.merge(context);\n const query: string = context.get(KeysInitQuery.queryString) ?? QuerySourceSparql.operationToQuery(operation);\n const rawStream = this.endpointFetcher.fetchTriples(this.url, query);\n this.lastSourceContext = undefined;\n const quads = wrap<any>(rawStream, { autoStart: false, maxBufferSize: Number.POSITIVE_INFINITY });\n this.attachMetadata(quads, context, Promise.resolve(operation.input));\n return quads;\n }\n\n public queryBoolean(operation: Algebra.Ask, context: IActionContext): Promise<boolean> {\n // Shortcut the ASK query to return true when supported propertyFeature predicates are used in it.\n if (this.operationUsesPropertyFeatures(operation)) {\n return Promise.resolve(true);\n }\n // Without propertyFeature overlap, perform the actual ASK query.\n this.lastSourceContext = this.context.merge(context);\n const query: string = context.get(KeysInitQuery.queryString) ?? QuerySourceSparql.operationToQuery(operation);\n const promise = this.endpointFetcher.fetchAsk(this.url, query);\n this.lastSourceContext = undefined;\n return promise;\n }\n\n public queryVoid(operation: Algebra.Update, context: IActionContext): Promise<void> {\n this.lastSourceContext = this.context.merge(context);\n const query: string = context.get(KeysInitQuery.queryString) ?? QuerySourceSparql.operationToQuery(operation);\n const promise = this.endpointFetcher.fetchUpdate(this.url, query);\n this.lastSourceContext = undefined;\n return promise;\n }\n\n protected attachMetadata(\n target: AsyncIterator<any>,\n context: IActionContext,\n operationPromise: Promise<Algebra.Operation>,\n ): void {\n // Emit metadata containing the estimated count\n let variablesCount: MetadataVariable[] = [];\n // eslint-disable-next-line no-async-promise-executor,ts/no-misused-promises\n new Promise<QueryResultCardinality>(async(resolve, reject) => {\n try {\n const operation = await operationPromise;\n const variablesScoped = Util.inScopeVariables(operation);\n const countQuery = this.operationToNormalizedCountQuery(operation);\n\n const undefVariables = QuerySourceSparql.getOperationUndefs(operation);\n variablesCount = variablesScoped.map(variable => ({\n variable,\n canBeUndef: undefVariables.some(undefVariable => undefVariable.equals(variable)),\n }));\n\n const cachedCardinality = this.cache?.get(countQuery);\n if (cachedCardinality) {\n return resolve(cachedCardinality);\n }\n\n // Attempt to estimate locally prior to sending a COUNT request, as this should be much faster.\n // The estimates may be off by varying amounts, so this is set behind a configuration flag.\n if (this.cardinalityEstimateConstruction) {\n const localEstimate = await this.estimateOperationCardinality(operation);\n if (Number.isFinite(localEstimate.value)) {\n this.cache?.set(countQuery, localEstimate);\n return resolve(localEstimate);\n }\n }\n\n // Don't send count queries if disabled.\n if (!this.cardinalityCountQueries) {\n return resolve({ type: 'estimate', value: Number.POSITIVE_INFINITY, dataset: this.url });\n }\n\n const timeoutHandler = setTimeout(() => resolve({\n type: 'estimate',\n value: Number.POSITIVE_INFINITY,\n dataset: this.url,\n }), this.countTimeout);\n const varCount = this.dataFactory.variable('count');\n const bindingsStream: BindingsStream = await this\n .queryBindingsRemote(this.url, countQuery, [ varCount ], context, []);\n bindingsStream\n .on('data', (bindings: Bindings) => {\n clearTimeout(timeoutHandler);\n const count = bindings.get(varCount);\n const cardinality: QueryResultCardinality = {\n type: 'estimate',\n value: Number.POSITIVE_INFINITY,\n dataset: this.url,\n };\n if (count) {\n const cardinalityValue: number = Number.parseInt(count.value, 10);\n if (!Number.isNaN(cardinalityValue)) {\n cardinality.type = 'exact';\n cardinality.value = cardinalityValue;\n this.cache?.set(countQuery, cardinality);\n }\n }\n return resolve(cardinality);\n })\n .on('error', () => {\n clearTimeout(timeoutHandler);\n resolve({ type: 'estimate', value: Number.POSITIVE_INFINITY, dataset: this.url });\n })\n .on('end', () => {\n clearTimeout(timeoutHandler);\n resolve({ type: 'estimate', value: Number.POSITIVE_INFINITY, dataset: this.url });\n });\n } catch (error: unknown) {\n reject(error);\n }\n })\n .then(cardinality => target.setProperty('metadata', {\n state: new MetadataValidationState(),\n cardinality,\n variables: variablesCount,\n }))\n .catch(() => target.setProperty('metadata', {\n state: new MetadataValidationState(),\n cardinality: { type: 'estimate', value: Number.POSITIVE_INFINITY, dataset: this.url },\n variables: variablesCount,\n }));\n }\n\n /**\n * Convert an algebra operation into a query string, and if the operation is a simple triple pattern,\n * then also replace any variables with s, p, and o to increase the chance of cache hits.\n * @param {Algebra.Operation} operation The operation to convert into a query string.\n * @returns {string} Query string for a COUNT query over the operation.\n */\n public operationToNormalizedCountQuery(operation: Algebra.Operation): string {\n const normalizedOperation = operation.type === Algebra.types.PATTERN ?\n this.algebraFactory.createPattern(\n operation.subject.termType === 'Variable' ? this.dataFactory.variable('s') : operation.subject,\n operation.predicate.termType === 'Variable' ? this.dataFactory.variable('p') : operation.predicate,\n operation.object.termType === 'Variable' ? this.dataFactory.variable('o') : operation.object,\n ) :\n operation;\n const operationString = QuerySourceSparql.operationToCountQuery(\n this.dataFactory,\n this.algebraFactory,\n normalizedOperation,\n );\n return operationString;\n }\n\n /**\n * Performs local cardinality estimation for the specified SPARQL algebra operation, which should\n * result in better estimation performance at the expense of accuracy.\n * @param {Algebra.Operation} operation A query operation.\n */\n public async estimateOperationCardinality(operation: Algebra.Operation): Promise<QueryResultCardinality> {\n if (this.operationUsesPropertyFeatures(operation)) {\n return { type: 'estimate', value: 1, dataset: this.url };\n }\n\n const dataset: IDataset = {\n getCardinality: (operation: Algebra.Operation): QueryResultCardinality | undefined => {\n const queryString = this.operationToNormalizedCountQuery(operation);\n\n const cachedCardinality = this.cache?.get(queryString);\n if (cachedCardinality) {\n return cachedCardinality;\n }\n\n if (this.datasets) {\n const cardinalities = this.datasets\n .filter(ds => this.unionDefaultGraph || (this.defaultGraph && ds.uri.endsWith(this.defaultGraph)))\n .map(ds => estimateCardinality(operation, ds));\n\n const cardinality: QueryResultCardinality = {\n type: cardinalities.some(card => card.type === 'estimate') ? 'estimate' : 'exact',\n value: cardinalities.length > 0 ? cardinalities.reduce((acc, card) => acc + card.value, 0) : 0,\n dataset: this.url,\n };\n\n return cardinality;\n }\n },\n source: this.url,\n uri: this.url,\n };\n\n return estimateCardinality(operation, dataset);\n }\n\n /**\n * Checks whether the provided operation makes use of this endpoint's property features,\n * if the endpoint has property features detected.\n * @param {Algebra.Operation} operation The operation to check.\n * @returns {boolean} Whether the operation makes use of property features.\n */\n public operationUsesPropertyFeatures(operation: Algebra.Operation): boolean {\n let propertyFeaturesUsed = false;\n if (this.propertyFeatures) {\n Util.recurseOperation(operation, {\n [Algebra.types.PATTERN]: (op) => {\n if (op.predicate.termType === 'NamedNode' && this.propertyFeatures!.has(op.predicate.value)) {\n propertyFeaturesUsed = true;\n }\n return false;\n },\n [Algebra.types.LINK]: (op) => {\n if (this.propertyFeatures!.has(op.iri.value)) {\n propertyFeaturesUsed = true;\n }\n return false;\n },\n [Algebra.types.NPS]: (op) => {\n if (op.iris.some(iri => this.propertyFeatures!.has(iri.value))) {\n propertyFeaturesUsed = true;\n }\n return false;\n },\n });\n }\n return propertyFeaturesUsed;\n }\n\n /**\n * Create an operation that includes the bindings from the given bindings stream.\n * @param algebraFactory The algebra factory.\n * @param bindMethod A method for adding bindings to an operation.\n * @param operation The operation to bind to.\n * @param addBindings The bindings to add.\n * @param addBindings.bindings The bindings stream.\n * @param addBindings.metadata The bindings metadata.\n */\n public static async addBindingsToOperation(\n algebraFactory: Factory,\n bindMethod: BindMethod,\n operation: Algebra.Operation,\n addBindings: { bindings: BindingsStream; metadata: MetadataBindings },\n ): Promise<Algebra.Operation> {\n const bindings = await addBindings.bindings.toArray();\n\n switch (bindMethod) {\n case 'values':\n return algebraFactory.createJoin([\n algebraFactory.createValues(\n addBindings.metadata.variables.map(v => v.variable),\n bindings.map(binding => Object.fromEntries([ ...binding ]\n .map(([ key, value ]) => [ `?${key.value}`, <RDF.Literal | RDF.NamedNode> value ]))),\n ),\n operation,\n ], false);\n case 'union': { throw new Error('Not implemented yet: \"union\" case'); }\n case 'filter': { throw new Error('Not implemented yet: \"filter\" case'); }\n }\n }\n\n /**\n * Convert an operation to a select query for this pattern.\n * @param algebraFactory The algebra factory.\n * @param {Algebra.Operation} operation A query operation.\n * @param {RDF.Variable[]} variables The variables in scope for the operation.\n * @return {string} A select query string.\n */\n public static operationToSelectQuery(\n algebraFactory: Factory,\n operation: Algebra.Operation,\n variables: RDF.Variable[],\n ): string {\n return QuerySourceSparql.operationToQuery(algebraFactory.createProject(operation, variables));\n }\n\n /**\n * Convert an operation to a count query for the number of matching triples for this pattern.\n * @param dataFactory The data factory.\n * @param algebraFactory The algebra factory.\n * @param {Algebra.Operation} operation A query operation.\n * @return {string} A count query string.\n */\n public static operationToCountQuery(\n dataFactory: ComunicaDataFactory,\n algebraFactory: Factory,\n operation: Algebra.Operation,\n ): string {\n return QuerySourceSparql.operationToQuery(algebraFactory.createProject(\n algebraFactory.createExtend(\n algebraFactory.createGroup(\n operation,\n [],\n [ algebraFactory.createBoundAggregate(\n dataFactory.variable('var0'),\n 'count',\n algebraFactory.createWildcardExpression(),\n false,\n ) ],\n ),\n dataFactory.variable('count'),\n algebraFactory.createTermExpression(dataFactory.variable('var0')),\n ),\n [ dataFactory.variable('count') ],\n ));\n }\n\n /**\n * Convert an operation to a query for this pattern.\n * @param {Algebra.Operation} operation A query operation.\n * @return {string} A query string.\n */\n public static operationToQuery(operation: Algebra.Operation): string {\n return toSparql(operation, { sparqlStar: true });\n }\n\n /**\n * Check if the given operation may produce undefined values.\n * @param operation\n */\n public static getOperationUndefs(operation: Algebra.Operation): RDF.Variable[] {\n const variables: RDF.Variable[] = [];\n Util.recurseOperation(operation, {\n leftjoin(subOperation): boolean {\n const left = Util.inScopeVariables(subOperation.input[0]);\n const right = Util.inScopeVariables(subOperation.input[1]);\n for (const varRight of right) {\n if (!left.some(varLeft => varLeft.equals(varRight))) {\n variables.push(varRight);\n }\n }\n return false;\n },\n values(values: Algebra.Values): boolean {\n for (const variable of values.variables) {\n if (values.bindings.some(bindings => !(`?${variable.value}` in bindings))) {\n variables.push(variable);\n }\n }\n return false;\n },\n union(union: Algebra.Union): boolean {\n // Determine variables in scope of the union branches that are not occurring in every branch\n const scopedVariables = union.input.map(Util.inScopeVariables);\n for (const variable of uniqTerms(scopedVariables.flat())) {\n if (!scopedVariables.every(input => input.some(inputVar => inputVar.equals(variable)))) {\n variables.push(variable);\n }\n }\n\n return true;\n },\n });\n return uniqTerms(variables);\n }\n\n /**\n * Send a SPARQL query to a SPARQL endpoint and retrieve its bindings as a stream.\n * @param {string} endpoint A SPARQL endpoint URL.\n * @param {string} query A SPARQL query string.\n * @param {RDF.Variable[]} variables The expected variables.\n * @param {IActionContext} context The source context.\n * @param undefVariables Variables that may have undefs.\n * @return {BindingsStream} A stream of bindings.\n */\n public async queryBindingsRemote(\n endpoint: string,\n query: string,\n variables: RDF.Variable[],\n context: IActionContext,\n undefVariables: RDF.Variable[],\n ): Promise<BindingsStream> {\n // Index undef variables\n const undefVariablesSet = new Set(undefVariables.map(v => v.value));\n\n this.lastSourceContext = this.context.merge(context);\n const rawStream = await this.endpointFetcher.fetchBindings(endpoint, query);\n this.lastSourceContext = undefined;\n\n return wrap<any>(rawStream, { autoStart: false, maxBufferSize: Number.POSITIVE_INFINITY })\n .map<RDF.Bindings>((rawData: Record<string, RDF.Term>) => this.bindingsFactory.bindings(variables\n .map((variable) => {\n const value = rawData[`?${variable.value}`];\n if (!undefVariablesSet.has(variable.value) && !value) {\n Actor.getContextLogger(this.context)?.warn(`The endpoint ${endpoint} failed to provide a binding for ${variable.value}.`);\n }\n return <[RDF.Variable, RDF.Term]>[ variable, value ];\n })\n .filter(([ _, v ]) => Boolean(v))));\n }\n\n public toString(): string {\n return `QuerySourceSparql(${this.url})`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"QuerySourceSparql.js","sourceRoot":"","sources":["QuerySourceSparql.ts"],"names":[],"mappings":";;;AAEA,+DAA0D;AAC1D,yCAAuC;AAevC,2DAAkF;AAElF,6DAAmE;AACnE,2EAAsE;AAGtE,iDAAwD;AACxD,iEAA8D;AAC9D,yCAAqC;AACrC,yCAAsC;AAGtC,MAAa,iBAAiB;IACZ,cAAc,CAAS;IAC/B,GAAG,CAAS;IACH,SAAS,CAAS;IAClB,OAAO,CAAiB;IACxB,YAAY,CAAe;IAC3B,sBAAsB,CAAyB;IAC/C,UAAU,CAAa;IACvB,YAAY,CAAS;IACrB,uBAAuB,CAAU;IACjC,+BAA+B,CAAU;IACzC,YAAY,CAAU;IACtB,iBAAiB,CAAU;IAC3B,gBAAgB,CAAe;IAC/B,QAAQ,CAAc;IACvB,kBAAkB,CAAY;IAC7B,WAAW,CAAsB;IACjC,cAAc,CAAiB;IAC/B,eAAe,CAAkB;IAEjC,eA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} from '@comunica/bus-query-serialize';\nimport { KeysInitQuery } from '@comunica/context-entries';\nimport { Actor } from '@comunica/core';\nimport type {\n Bindings,\n BindingsStream,\n ComunicaDataFactory,\n FragmentSelectorShape,\n IActionContext,\n IDataset,\n IQueryBindingsOptions,\n IQuerySource,\n MetadataBindings,\n MetadataVariable,\n QueryResultCardinality,\n} from '@comunica/types';\nimport type { AlgebraFactory } from '@comunica/utils-algebra';\nimport { Algebra, algebraUtils, isKnownOperation } from '@comunica/utils-algebra';\nimport type { BindingsFactory } from '@comunica/utils-bindings-factory';\nimport { MetadataValidationState } from '@comunica/utils-metadata';\nimport { estimateCardinality } from '@comunica/utils-query-operation';\nimport type * as RDF from '@rdfjs/types';\nimport type { AsyncIterator } from 'asynciterator';\nimport { TransformIterator, wrap } from 'asynciterator';\nimport { SparqlEndpointFetcher } from 'fetch-sparql-endpoint';\nimport { LRUCache } from 'lru-cache';\nimport { uniqTerms } from 'rdf-terms';\nimport type { BindMethod } from './ActorQuerySourceIdentifyHypermediaSparql';\n\nexport class QuerySourceSparql implements IQuerySource {\n public readonly referenceValue: string;\n private url: string;\n private readonly urlBackup: string;\n private readonly context: IActionContext;\n private readonly mediatorHttp: MediatorHttp;\n private readonly mediatorQuerySerialize: MediatorQuerySerialize;\n private readonly bindMethod: BindMethod;\n private readonly countTimeout: number;\n private readonly cardinalityCountQueries: boolean;\n private readonly cardinalityEstimateConstruction: boolean;\n private readonly defaultGraph?: string;\n private readonly unionDefaultGraph: boolean;\n private readonly propertyFeatures?: Set<string>;\n private readonly datasets?: IDataset[];\n public readonly extensionFunctions?: string[];\n private readonly dataFactory: ComunicaDataFactory;\n private readonly algebraFactory: AlgebraFactory;\n private readonly bindingsFactory: BindingsFactory;\n\n private readonly endpointFetcher: SparqlEndpointFetcher;\n private readonly cache: LRUCache<string, QueryResultCardinality> | undefined;\n\n private lastSourceContext: IActionContext | undefined;\n\n public constructor(\n url: string,\n urlBackup: string,\n context: IActionContext,\n mediatorHttp: MediatorHttp,\n mediatorQuerySerialize: MediatorQuerySerialize,\n bindMethod: BindMethod,\n dataFactory: ComunicaDataFactory,\n algebraFactory: AlgebraFactory,\n bindingsFactory: BindingsFactory,\n forceHttpGet: boolean,\n cacheSize: number,\n countTimeout: number,\n cardinalityCountQueries: boolean,\n cardinalityEstimateConstruction: boolean,\n forceGetIfUrlLengthBelow: number,\n parseUnsupportedVersions: boolean,\n metadata: Record<string, any>,\n ) {\n this.referenceValue = urlBackup;\n this.url = url;\n this.urlBackup = urlBackup;\n this.context = context;\n this.mediatorHttp = mediatorHttp;\n this.mediatorQuerySerialize = mediatorQuerySerialize;\n this.bindMethod = bindMethod;\n this.dataFactory = dataFactory;\n this.algebraFactory = algebraFactory;\n this.bindingsFactory = bindingsFactory;\n this.endpointFetcher = new SparqlEndpointFetcher({\n method: forceHttpGet ? 'GET' : 'POST',\n fetch: async(input: Request | string, init?: RequestInit) => {\n const response = await this.mediatorHttp.mediate(\n { input, init, context: this.lastSourceContext! },\n );\n // If we encounter a 404, try our backup URL.\n // After retrying the request with the new URL, we replace the URL for future requests.\n if (response.status === 404 && this.url !== this.urlBackup) {\n Actor.getContextLogger(this.context)?.warn(`Encountered a 404 when requesting ${this.url} according to the service description of ${this.urlBackup}. This is a server configuration issue. Retrying the current and modifying future requests to ${this.urlBackup} instead.`);\n input = (<string> input).replace(this.url, this.urlBackup);\n this.url = this.urlBackup;\n return await this.mediatorHttp.mediate(\n { input, init, context: this.lastSourceContext! },\n );\n }\n return response;\n },\n prefixVariableQuestionMark: true,\n dataFactory,\n forceGetIfUrlLengthBelow,\n directPost: metadata.postAccepted && !metadata.postAccepted.includes('application/x-www-form-urlencoded'),\n parseUnsupportedVersions,\n });\n this.cache = cacheSize > 0 ?\n new LRUCache<string, QueryResultCardinality>({ max: cacheSize }) :\n undefined;\n this.countTimeout = countTimeout;\n this.cardinalityCountQueries = cardinalityCountQueries;\n this.cardinalityEstimateConstruction = cardinalityEstimateConstruction;\n this.defaultGraph = metadata.defaultGraph;\n this.unionDefaultGraph = metadata.unionDefaultGraph ?? false;\n this.datasets = metadata.datasets;\n this.extensionFunctions = metadata.extensionFunctions;\n this.propertyFeatures = metadata.propertyFeatures ? new Set(metadata.propertyFeatures) : undefined;\n }\n\n public async getFilterFactor(): Promise<number> {\n return 1;\n }\n\n public async getSelectorShape(): Promise<FragmentSelectorShape> {\n const innerDisjunction: FragmentSelectorShape = {\n type: 'disjunction',\n children: [\n {\n type: 'operation',\n operation: { operationType: 'wildcard' },\n joinBindings: true,\n },\n ],\n };\n if (this.extensionFunctions) {\n innerDisjunction.children.push({\n type: 'operation',\n operation: {\n operationType: 'type',\n type: Algebra.Types.EXPRESSION,\n extensionFunctions: this.extensionFunctions,\n },\n joinBindings: true,\n });\n }\n return {\n type: 'conjunction',\n children: [\n innerDisjunction,\n {\n // DISTINCT CONSTRUCT is not allowed in SPARQL 1.1, so we explicitly disallowed it.\n type: 'negation',\n child: {\n type: 'operation',\n operation: { operationType: 'type', type: Algebra.Types.DISTINCT },\n children: [\n {\n type: 'operation',\n operation: { operationType: 'type', type: Algebra.Types.CONSTRUCT },\n children: [\n {\n type: 'operation',\n operation: { operationType: 'wildcard' },\n joinBindings: true,\n },\n ],\n },\n ],\n },\n },\n ],\n };\n }\n\n public queryBindings(\n operationIn: Algebra.Operation,\n context: IActionContext,\n options?: IQueryBindingsOptions,\n ): BindingsStream {\n // If bindings are passed, modify the operations\n let operationPromise: Promise<Algebra.Operation>;\n if (options?.joinBindings) {\n operationPromise = QuerySourceSparql.addBindingsToOperation(\n this.algebraFactory,\n this.bindMethod,\n operationIn,\n options.joinBindings,\n );\n } else {\n operationPromise = Promise.resolve(operationIn);\n }\n\n const bindings: BindingsStream = new TransformIterator(async() => {\n // Prepare queries\n const operation = await operationPromise;\n const variables: RDF.Variable[] = algebraUtils.inScopeVariables(operation);\n const queryString = context.get<string>(KeysInitQuery.queryString);\n const queryFormat: RDF.QueryFormat = context.getSafe(KeysInitQuery.queryFormat);\n const selectQuery: string = !options?.joinBindings && queryString && queryFormat.language === 'sparql' ?\n queryString :\n await this.operationToSelectQuery(this.algebraFactory, operation, variables);\n const undefVariables = QuerySourceSparql.getOperationUndefs(operation);\n\n return this.queryBindingsRemote(this.url, selectQuery, variables, context, undefVariables);\n }, { autoStart: false });\n this.attachMetadata(bindings, context, operationPromise);\n\n return bindings;\n }\n\n public queryQuads(operation: Algebra.Operation, context: IActionContext): AsyncIterator<RDF.Quad> {\n const quads = wrap<any>((async() => {\n this.lastSourceContext = this.context.merge(context);\n const query: string = context.get(KeysInitQuery.queryString) ?? await this.operationToQuery(operation);\n const rawStream = await this.endpointFetcher.fetchTriples(this.url, query);\n this.lastSourceContext = undefined;\n return rawStream;\n })(), { autoStart: false, maxBufferSize: Number.POSITIVE_INFINITY });\n this.attachMetadata(quads, context, Promise.resolve((<Algebra.Operation & { input: any }>operation).input));\n return quads;\n }\n\n public async queryBoolean(operation: Algebra.Ask, context: IActionContext): Promise<boolean> {\n // Shortcut the ASK query to return true when supported propertyFeature predicates are used in it.\n if (this.operationUsesPropertyFeatures(operation)) {\n return true;\n }\n // Without propertyFeature overlap, perform the actual ASK query.\n this.lastSourceContext = this.context.merge(context);\n const query: string = context.get(KeysInitQuery.queryString) ?? await this.operationToQuery(operation);\n const promise = this.endpointFetcher.fetchAsk(this.url, query);\n this.lastSourceContext = undefined;\n return promise;\n }\n\n public async queryVoid(operation: Algebra.Operation, context: IActionContext): Promise<void> {\n this.lastSourceContext = this.context.merge(context);\n const query: string = context.get(KeysInitQuery.queryString) ?? await this.operationToQuery(operation);\n const promise = this.endpointFetcher.fetchUpdate(this.url, query);\n this.lastSourceContext = undefined;\n return promise;\n }\n\n protected attachMetadata(\n target: AsyncIterator<any>,\n context: IActionContext,\n operationPromise: Promise<Algebra.Operation>,\n ): void {\n // Emit metadata containing the estimated count\n let variablesCount: MetadataVariable[] = [];\n // eslint-disable-next-line no-async-promise-executor,ts/no-misused-promises\n new Promise<QueryResultCardinality>(async(resolve, reject) => {\n try {\n const operation = await operationPromise;\n const variablesScoped = algebraUtils.inScopeVariables(operation);\n const countQuery = await this.operationToNormalizedCountQuery(operation);\n\n const undefVariables = QuerySourceSparql.getOperationUndefs(operation);\n variablesCount = variablesScoped.map(variable => ({\n variable,\n canBeUndef: undefVariables.some(undefVariable => undefVariable.equals(variable)),\n }));\n\n const cachedCardinality = this.cache?.get(countQuery);\n if (cachedCardinality) {\n return resolve(cachedCardinality);\n }\n\n // Attempt to estimate locally prior to sending a COUNT request, as this should be much faster.\n // The estimates may be off by varying amounts, so this is set behind a configuration flag.\n if (this.cardinalityEstimateConstruction) {\n const localEstimate = await this.estimateOperationCardinality(operation);\n if (Number.isFinite(localEstimate.value)) {\n this.cache?.set(countQuery, localEstimate);\n return resolve(localEstimate);\n }\n }\n\n // Don't send count queries if disabled.\n if (!this.cardinalityCountQueries) {\n return resolve({ type: 'estimate', value: Number.POSITIVE_INFINITY, dataset: this.url });\n }\n\n const timeoutHandler = setTimeout(() => resolve({\n type: 'estimate',\n value: Number.POSITIVE_INFINITY,\n dataset: this.url,\n }), this.countTimeout);\n const varCount = this.dataFactory.variable('count');\n const bindingsStream: BindingsStream = await this\n .queryBindingsRemote(this.url, countQuery, [ varCount ], context, []);\n bindingsStream\n .on('data', (bindings: Bindings) => {\n clearTimeout(timeoutHandler);\n const count = bindings.get(varCount);\n const cardinality: QueryResultCardinality = {\n type: 'estimate',\n value: Number.POSITIVE_INFINITY,\n dataset: this.url,\n };\n if (count) {\n const cardinalityValue: number = Number.parseInt(count.value, 10);\n if (!Number.isNaN(cardinalityValue)) {\n cardinality.type = 'exact';\n cardinality.value = cardinalityValue;\n this.cache?.set(countQuery, cardinality);\n }\n }\n return resolve(cardinality);\n })\n .on('error', () => {\n clearTimeout(timeoutHandler);\n resolve({ type: 'estimate', value: Number.POSITIVE_INFINITY, dataset: this.url });\n })\n .on('end', () => {\n clearTimeout(timeoutHandler);\n resolve({ type: 'estimate', value: Number.POSITIVE_INFINITY, dataset: this.url });\n });\n } catch (error: unknown) {\n reject(error);\n }\n })\n .then(cardinality => target.setProperty('metadata', {\n state: new MetadataValidationState(),\n cardinality,\n variables: variablesCount,\n }))\n .catch(() => target.setProperty('metadata', {\n state: new MetadataValidationState(),\n cardinality: { type: 'estimate', value: Number.POSITIVE_INFINITY, dataset: this.url },\n variables: variablesCount,\n }));\n }\n\n /**\n * Convert an algebra operation into a query string, and if the operation is a simple triple pattern,\n * then also replace any variables with s, p, and o to increase the chance of cache hits.\n * @param {Algebra.Operation} operation The operation to convert into a query string.\n * @returns {string} Query string for a COUNT query over the operation.\n */\n public async operationToNormalizedCountQuery(operation: Algebra.Operation): Promise<string> {\n const normalizedOperation = isKnownOperation(operation, Algebra.Types.PATTERN) ?\n this.algebraFactory.createPattern(\n operation.subject.termType === 'Variable' ? this.dataFactory.variable('s') : operation.subject,\n operation.predicate.termType === 'Variable' ? this.dataFactory.variable('p') : operation.predicate,\n operation.object.termType === 'Variable' ? this.dataFactory.variable('o') : operation.object,\n ) :\n operation;\n return await this.operationToCountQuery(\n this.dataFactory,\n this.algebraFactory,\n normalizedOperation,\n );\n }\n\n /**\n * Performs local cardinality estimation for the specified SPARQL algebra operation, which should\n * result in better estimation performance at the expense of accuracy.\n * @param {Algebra.Operation} operation A query operation.\n */\n public async estimateOperationCardinality(operation: Algebra.Operation): Promise<QueryResultCardinality> {\n if (this.operationUsesPropertyFeatures(operation)) {\n return { type: 'estimate', value: 1, dataset: this.url };\n }\n\n const dataset: IDataset = {\n getCardinality: async(operation: Algebra.Operation): Promise<QueryResultCardinality | undefined> => {\n const queryString = await this.operationToNormalizedCountQuery(operation);\n\n const cachedCardinality = this.cache?.get(queryString);\n if (cachedCardinality) {\n return cachedCardinality;\n }\n\n if (this.datasets) {\n const cardinalities = await Promise.all(this.datasets\n .filter(ds => this.unionDefaultGraph || (this.defaultGraph && ds.uri.endsWith(this.defaultGraph)))\n .map(ds => estimateCardinality(operation, ds)));\n\n const cardinality: QueryResultCardinality = {\n type: cardinalities.some(card => card.type === 'estimate') ? 'estimate' : 'exact',\n value: cardinalities.length > 0 ? cardinalities.reduce((acc, card) => acc + card.value, 0) : 0,\n dataset: this.url,\n };\n\n return cardinality;\n }\n },\n source: this.url,\n uri: this.url,\n };\n\n return estimateCardinality(operation, dataset);\n }\n\n /**\n * Checks whether the provided operation makes use of this endpoint's property features,\n * if the endpoint has property features detected.\n * @param {Algebra.Operation} operation The operation to check.\n * @returns {boolean} Whether the operation makes use of property features.\n */\n public operationUsesPropertyFeatures(operation: Algebra.Operation): boolean {\n let propertyFeaturesUsed = false;\n if (this.propertyFeatures) {\n algebraUtils.visitOperation(operation, {\n [Algebra.Types.PATTERN]: {\n visitor: (subOp) => {\n if (subOp.predicate.termType === 'NamedNode' && this.propertyFeatures!.has(subOp.predicate.value)) {\n propertyFeaturesUsed = true;\n }\n return false;\n },\n },\n [Algebra.Types.LINK]: {\n visitor: (subOp) => {\n if (this.propertyFeatures!.has(subOp.iri.value)) {\n propertyFeaturesUsed = true;\n }\n return false;\n },\n },\n [Algebra.Types.NPS]: {\n visitor: (subOp) => {\n if (subOp.iris.some(iri => this.propertyFeatures!.has(iri.value))) {\n propertyFeaturesUsed = true;\n }\n return false;\n },\n },\n });\n }\n return propertyFeaturesUsed;\n }\n\n /**\n * Create an operation that includes the bindings from the given bindings stream.\n * @param algebraFactory The algebra factory.\n * @param bindMethod A method for adding bindings to an operation.\n * @param operation The operation to bind to.\n * @param addBindings The bindings to add.\n * @param addBindings.bindings The bindings stream.\n * @param addBindings.metadata The bindings metadata.\n */\n public static async addBindingsToOperation(\n algebraFactory: AlgebraFactory,\n bindMethod: BindMethod,\n operation: Algebra.Operation,\n addBindings: { bindings: BindingsStream; metadata: MetadataBindings },\n ): Promise<Algebra.Operation> {\n const bindings = await addBindings.bindings.toArray();\n\n switch (bindMethod) {\n case 'values':\n return algebraFactory.createJoin([\n algebraFactory.createValues(\n addBindings.metadata.variables.map(v => v.variable),\n bindings.map(binding => Object.fromEntries([ ...binding ]\n .map(([ key, value ]) => [ key.value, <RDF.Literal | RDF.NamedNode> value ]))),\n ),\n operation,\n ], false);\n case 'union': { throw new Error('Not implemented yet: \"union\" case'); }\n case 'filter': { throw new Error('Not implemented yet: \"filter\" case'); }\n }\n }\n\n /**\n * Convert an operation to a select query for this pattern.\n * @param algebraFactory The algebra factory.\n * @param {Algebra.Operation} operation A query operation.\n * @param {RDF.Variable[]} variables The variables in scope for the operation.\n * @return {string} A select query string.\n */\n public operationToSelectQuery(\n algebraFactory: AlgebraFactory,\n operation: Algebra.Operation,\n variables: RDF.Variable[],\n ): Promise<string> {\n return this.operationToQuery(algebraFactory.createProject(operation, variables));\n }\n\n /**\n * Convert an operation to a count query for the number of matching triples for this pattern.\n * @param dataFactory The data factory.\n * @param algebraFactory The algebra factory.\n * @param {Algebra.Operation} operation A query operation.\n * @return {string} A count query string.\n */\n public operationToCountQuery(\n dataFactory: ComunicaDataFactory,\n algebraFactory: AlgebraFactory,\n operation: Algebra.Operation,\n ): Promise<string> {\n return this.operationToQuery(algebraFactory.createProject(\n algebraFactory.createExtend(\n algebraFactory.createGroup(\n operation,\n [],\n [ algebraFactory.createBoundAggregate(\n dataFactory.variable('var0'),\n 'count',\n algebraFactory.createWildcardExpression(),\n false,\n ) ],\n ),\n dataFactory.variable('count'),\n algebraFactory.createTermExpression(dataFactory.variable('var0')),\n ),\n [ dataFactory.variable('count') ],\n ));\n }\n\n /**\n * Convert an operation to a query for this pattern.\n * @param {Algebra.Operation} operation A query operation.\n * @return {string} A query string.\n */\n public async operationToQuery(operation: Algebra.Operation): Promise<string> {\n return (await this.mediatorQuerySerialize.mediate({\n queryFormat: { language: 'sparql', version: '1.2' },\n operation,\n newlines: false,\n indentWidth: 0,\n context: this.context,\n })).query;\n }\n\n /**\n * Check if the given operation may produce undefined values.\n * @param operation\n */\n public static getOperationUndefs(operation: Algebra.Operation): RDF.Variable[] {\n const variables: RDF.Variable[] = [];\n algebraUtils.visitOperation(operation, {\n [Algebra.Types.LEFT_JOIN]: { preVisitor: (subOperation) => {\n const left = algebraUtils.inScopeVariables(subOperation.input[0]);\n const right = algebraUtils.inScopeVariables(subOperation.input[1]);\n for (const varRight of right) {\n if (!left.some(varLeft => varLeft.equals(varRight))) {\n variables.push(varRight);\n }\n }\n return { continue: false };\n } },\n [Algebra.Types.VALUES]: { preVisitor: (values) => {\n for (const variable of values.variables) {\n if (values.bindings.some(bindings => !(variable.value in bindings))) {\n variables.push(variable);\n }\n }\n return { continue: false };\n } },\n [Algebra.Types.UNION]: { preVisitor: (union) => {\n // Determine variables in scope of the union branches that are not occurring in every branch\n const scopedVariables = union.input.map(op => algebraUtils.inScopeVariables(op));\n for (const variable of uniqTerms(scopedVariables.flat())) {\n if (!scopedVariables.every(input => input.some(inputVar => inputVar.equals(variable)))) {\n variables.push(variable);\n }\n }\n return {};\n } },\n });\n return uniqTerms(variables);\n }\n\n /**\n * Send a SPARQL query to a SPARQL endpoint and retrieve its bindings as a stream.\n * @param {string} endpoint A SPARQL endpoint URL.\n * @param {string} query A SPARQL query string.\n * @param {RDF.Variable[]} variables The expected variables.\n * @param {IActionContext} context The source context.\n * @param undefVariables Variables that may have undefs.\n * @return {BindingsStream} A stream of bindings.\n */\n public async queryBindingsRemote(\n endpoint: string,\n query: string,\n variables: RDF.Variable[],\n context: IActionContext,\n undefVariables: RDF.Variable[],\n ): Promise<BindingsStream> {\n // Index undef variables\n const undefVariablesSet = new Set(undefVariables.map(v => v.value));\n\n this.lastSourceContext = this.context.merge(context);\n const rawStream = await this.endpointFetcher.fetchBindings(endpoint, query);\n this.lastSourceContext = undefined;\n\n const wrapped = wrap<any>(rawStream, { autoStart: false, maxBufferSize: Number.POSITIVE_INFINITY });\n return wrapped.map<RDF.Bindings>((rawData: Record<string, RDF.Term>) => {\n const bindings = variables.map((variable) => {\n const value = rawData[`?${variable.value}`];\n if (!undefVariablesSet.has(variable.value) && !value) {\n Actor.getContextLogger(this.context)?.warn(`The endpoint ${endpoint} failed to provide a binding for ${variable.value}.`);\n }\n return <[RDF.Variable, RDF.Term]>[ variable, value ];\n }).filter(([ _, v ]) => Boolean(v));\n return this.bindingsFactory.bindings(bindings);\n });\n }\n\n public toString(): string {\n return `QuerySourceSparql(${this.url})`;\n }\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
File without changes
|
package/lib/index.js
CHANGED
|
File without changes
|
package/lib/index.js.map
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comunica/actor-query-source-identify-hypermedia-sparql",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "A sparql query-source-identify-hypermedia actor",
|
|
5
5
|
"lsd:module": true,
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,21 +41,22 @@
|
|
|
41
41
|
"build:components": "componentsjs-generator"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@comunica/bus-http": "^
|
|
45
|
-
"@comunica/bus-merge-bindings-context": "^
|
|
46
|
-
"@comunica/bus-query-
|
|
47
|
-
"@comunica/
|
|
48
|
-
"@comunica/
|
|
49
|
-
"@comunica/
|
|
50
|
-
"@comunica/
|
|
51
|
-
"@comunica/utils-
|
|
52
|
-
"@comunica/utils-
|
|
44
|
+
"@comunica/bus-http": "^5.0.2",
|
|
45
|
+
"@comunica/bus-merge-bindings-context": "^5.0.2",
|
|
46
|
+
"@comunica/bus-query-serialize": "^5.0.2",
|
|
47
|
+
"@comunica/bus-query-source-identify-hypermedia": "^5.0.2",
|
|
48
|
+
"@comunica/context-entries": "^5.0.2",
|
|
49
|
+
"@comunica/core": "^5.0.2",
|
|
50
|
+
"@comunica/types": "^5.0.0",
|
|
51
|
+
"@comunica/utils-algebra": "^5.0.0",
|
|
52
|
+
"@comunica/utils-bindings-factory": "^5.0.2",
|
|
53
|
+
"@comunica/utils-metadata": "^5.0.0",
|
|
54
|
+
"@comunica/utils-query-operation": "^5.0.2",
|
|
53
55
|
"@rdfjs/types": "*",
|
|
54
|
-
"asynciterator": "^3.
|
|
55
|
-
"fetch-sparql-endpoint": "^
|
|
56
|
-
"lru-cache": "^
|
|
57
|
-
"rdf-terms": "^
|
|
58
|
-
"sparqlalgebrajs": "^5.0.2"
|
|
56
|
+
"asynciterator": "^3.10.0",
|
|
57
|
+
"fetch-sparql-endpoint": "^7.1.0",
|
|
58
|
+
"lru-cache": "^11.2.2",
|
|
59
|
+
"rdf-terms": "^2.0.0"
|
|
59
60
|
},
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "3b29f914010fd2fc56682a0ceff962ef6ff24f32"
|
|
61
62
|
}
|