@netwerk-digitaal-erfgoed/network-of-terms-query 6.2.13 → 6.2.15
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/CHANGELOG.md +8 -0
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +3 -54
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/query.ts +3 -60
- package/vite.config.ts +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 6.2.15 (2026-01-30)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for @netwerk-digitaal-erfgoed/network-of-terms-query to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 6.2.14 (2026-01-30)
|
|
6
|
+
|
|
7
|
+
This was a version bump only for @netwerk-digitaal-erfgoed/network-of-terms-query to align it with other projects, there were no code changes.
|
|
8
|
+
|
|
1
9
|
## 6.2.13 (2026-01-30)
|
|
2
10
|
|
|
3
11
|
### 🚀 Features
|
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAGA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,IAAI,EAAoB,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,SAAS,EAAiB,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAGA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAA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utils-bindings-factory';
|
|
|
10
10
|
import { DataFactory } from 'rdf-data-factory';
|
|
11
11
|
import { sourceQueriesHistogram } from './instrumentation.js';
|
|
12
12
|
import { config } from './config.js';
|
|
13
|
-
/**
|
|
14
|
-
* Check if a query requires string substitution instead of initialBindings.
|
|
15
|
-
* Workaround for Comunica v5 traqula bug that crashes with:
|
|
16
|
-
* - SERVICE clauses
|
|
17
|
-
* - VALUES combination
|
|
18
|
-
*/
|
|
19
|
-
function requiresStringSubstitution(query) {
|
|
20
|
-
const hasService = /\bSERVICE\b/i.test(query);
|
|
21
|
-
const hasValues = /\bVALUES\b/i.test(query);
|
|
22
|
-
return hasService || hasValues;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Substitute bindings directly into a SPARQL query string.
|
|
26
|
-
* This is a workaround for Comunica v5's initialBindings bug with SERVICE clauses.
|
|
27
|
-
*/
|
|
28
|
-
function substituteBindings(query, bindings) {
|
|
29
|
-
let result = query;
|
|
30
|
-
for (const [name, term] of Object.entries(bindings)) {
|
|
31
|
-
const pattern = new RegExp(`\\?${name}\\b`, 'g');
|
|
32
|
-
if (term.termType === 'NamedNode') {
|
|
33
|
-
result = result.replace(pattern, `<${term.value}>`);
|
|
34
|
-
}
|
|
35
|
-
else if (term.termType === 'Literal') {
|
|
36
|
-
const literal = term;
|
|
37
|
-
const datatype = literal.datatype?.value;
|
|
38
|
-
if (datatype &&
|
|
39
|
-
datatype !== 'http://www.w3.org/2001/XMLSchema#string' &&
|
|
40
|
-
datatype !== 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString') {
|
|
41
|
-
result = result.replace(pattern, `"${term.value}"^^<${datatype}>`);
|
|
42
|
-
}
|
|
43
|
-
else if (literal.language) {
|
|
44
|
-
result = result.replace(pattern, `"${term.value}"@${literal.language}`);
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
result = result.replace(pattern, `"${term.value}"`);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
13
|
export class TermsResponse {
|
|
54
14
|
result;
|
|
55
15
|
responseTimeMs;
|
|
@@ -150,16 +110,8 @@ export class QueryTermsService {
|
|
|
150
110
|
const logger = new LoggerPino({ logger: this.logger });
|
|
151
111
|
// Extract HTTP credentials if the distribution URL contains any.
|
|
152
112
|
const url = new URL(distribution.endpoint.toString());
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
// - SERVICE clauses crash with initialBindings
|
|
156
|
-
// - VALUES crashes in some combinations
|
|
157
|
-
const useStringSubstitution = requiresStringSubstitution(query);
|
|
158
|
-
const finalQuery = useStringSubstitution
|
|
159
|
-
? substituteBindings(query, bindings)
|
|
160
|
-
: query;
|
|
161
|
-
this.logger.info(`Querying "${url}" with "${finalQuery}"...`);
|
|
162
|
-
const quadStream = await this.engine.queryQuads(finalQuery, {
|
|
113
|
+
this.logger.info(`Querying "${url}" with "${query}"...`);
|
|
114
|
+
const quadStream = await this.engine.queryQuads(query, {
|
|
163
115
|
log: logger,
|
|
164
116
|
httpAuth: url.username === '' ? undefined : url.username + ':' + url.password,
|
|
165
117
|
httpTimeout: timeoutMs,
|
|
@@ -170,10 +122,7 @@ export class QueryTermsService {
|
|
|
170
122
|
value: url.origin + url.pathname,
|
|
171
123
|
},
|
|
172
124
|
],
|
|
173
|
-
|
|
174
|
-
...(useStringSubstitution
|
|
175
|
-
? {}
|
|
176
|
-
: { initialBindings: bindingsFactory.fromRecord(bindings) }),
|
|
125
|
+
initialBindings: bindingsFactory.fromRecord(bindings),
|
|
177
126
|
});
|
|
178
127
|
return new Promise((resolve) => {
|
|
179
128
|
const termsTransformer = new TermsTransformer();
|