@wazootech/sparql-engine 0.0.0-stage → 0.5.8-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +729 -2
- package/THIRD_PARTY_NOTICES.md +20 -0
- package/dist/ast-CIKmrXH9.d.ts +282 -0
- package/dist/data-factory-76Dxrf0g.js +286 -0
- package/dist/index.d.ts +365 -0
- package/dist/index.js +5023 -0
- package/dist/memory-store-DhAGI-j6.d.ts +102 -0
- package/dist/memory-store-Mq4x2Ya1.js +316 -0
- package/dist/mod-C4GFefO7.d.ts +78 -0
- package/dist/parser-CTZiNJfu.js +69170 -0
- package/dist/parser.d.ts +65 -0
- package/dist/parser.js +1 -0
- package/dist/public-BNHiaGho.d.ts +234 -0
- package/dist/public-D0uwoGhU.js +416 -0
- package/dist/rdf-terms-DGpxNnyn.d.ts +83 -0
- package/dist/serialize-BSkHhuBp.js +335 -0
- package/dist/serialize.d.ts +2 -0
- package/dist/serialize.js +1 -0
- package/dist/sparql-engine-interface-Bies9KjE.d.ts +102 -0
- package/dist/store.d.ts +2 -0
- package/dist/store.js +1 -0
- package/dist/term-s9I2y-ck.js +767 -0
- package/dist/term.d.ts +2 -0
- package/dist/term.js +4 -0
- package/dist/turtle-parser-CzWF7KXf.d.ts +83 -0
- package/package.json +117 -4
|
@@ -0,0 +1,767 @@
|
|
|
1
|
+
import { f as termKey, t as DataFactory } from "./data-factory-76Dxrf0g.js";
|
|
2
|
+
// src/term/numeric.ts
|
|
3
|
+
/**
|
|
4
|
+
* XSD is the XML Schema datatype namespace IRI.
|
|
5
|
+
*/
|
|
6
|
+
const XSD = "http://www.w3.org/2001/XMLSchema#";
|
|
7
|
+
/** XSD_STRING is the xsd:string datatype IRI. */
|
|
8
|
+
const XSD_STRING = `${XSD}string`;
|
|
9
|
+
/** XSD_BOOLEAN is the xsd:boolean datatype IRI. */
|
|
10
|
+
const XSD_BOOLEAN = `${XSD}boolean`;
|
|
11
|
+
/** XSD_INTEGER is the xsd:integer datatype IRI. */
|
|
12
|
+
const XSD_INTEGER = `${XSD}integer`;
|
|
13
|
+
/** XSD_DECIMAL is the xsd:decimal datatype IRI. */
|
|
14
|
+
const XSD_DECIMAL = `${XSD}decimal`;
|
|
15
|
+
/** XSD_FLOAT is the xsd:float datatype IRI. */
|
|
16
|
+
const XSD_FLOAT = `${XSD}float`;
|
|
17
|
+
/** XSD_DOUBLE is the xsd:double datatype IRI. */
|
|
18
|
+
const XSD_DOUBLE = `${XSD}double`;
|
|
19
|
+
/** XSD_DATETIME is the xsd:dateTime datatype IRI. */
|
|
20
|
+
const XSD_DATETIME = `${XSD}dateTime`;
|
|
21
|
+
/** XSD_DAYTIME_DURATION is the xsd:dayTimeDuration datatype IRI. */
|
|
22
|
+
const XSD_DAYTIME_DURATION = `${XSD}dayTimeDuration`;
|
|
23
|
+
/** INTEGER_DATATYPES is xsd:integer and every type XML Schema derives from it. */
|
|
24
|
+
const INTEGER_DATATYPES = /* @__PURE__ */ new Set([
|
|
25
|
+
XSD_INTEGER,
|
|
26
|
+
`${XSD}nonPositiveInteger`,
|
|
27
|
+
`${XSD}negativeInteger`,
|
|
28
|
+
`${XSD}long`,
|
|
29
|
+
`${XSD}int`,
|
|
30
|
+
`${XSD}short`,
|
|
31
|
+
`${XSD}byte`,
|
|
32
|
+
`${XSD}nonNegativeInteger`,
|
|
33
|
+
`${XSD}unsignedLong`,
|
|
34
|
+
`${XSD}unsignedInt`,
|
|
35
|
+
`${XSD}unsignedShort`,
|
|
36
|
+
`${XSD}unsignedByte`,
|
|
37
|
+
`${XSD}positiveInteger`
|
|
38
|
+
]);
|
|
39
|
+
/**
|
|
40
|
+
* NUMERIC_DATATYPES is the set of XSD datatypes with numeric value semantics
|
|
41
|
+
* per SPARQL 1.1 §17.1, including the types derived from xsd:integer:
|
|
42
|
+
* comparisons and arithmetic operate on their values rather than their lexical
|
|
43
|
+
* forms.
|
|
44
|
+
*/
|
|
45
|
+
const NUMERIC_DATATYPES = /* @__PURE__ */ new Set([
|
|
46
|
+
...INTEGER_DATATYPES,
|
|
47
|
+
XSD_DECIMAL,
|
|
48
|
+
XSD_FLOAT,
|
|
49
|
+
XSD_DOUBLE
|
|
50
|
+
]);
|
|
51
|
+
const DECIMAL_NUMBER_FORM = /^[+-]?(?:[0-9]+\.?[0-9]*|\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
|
|
52
|
+
const INFINITY_FORM = /^[+-]?Infinity$/;
|
|
53
|
+
const RADIX_FORMS = [
|
|
54
|
+
[/^0[xX][0-9a-fA-F]+$/, 16],
|
|
55
|
+
[/^0[oO][0-7]+$/, 8],
|
|
56
|
+
[/^0[bB][01]+$/, 2]
|
|
57
|
+
];
|
|
58
|
+
/**
|
|
59
|
+
* numberFromText parses a numeric lexical form as a JS number with the
|
|
60
|
+
* ToNumber semantics of `Number(text)`: surrounding whitespace is ignored,
|
|
61
|
+
* blank text is 0, and anything that is not a decimal, infinity, or
|
|
62
|
+
* radix-prefixed form is NaN. Every branch is statically typed, so the native
|
|
63
|
+
* compiler keeps it out of the dynamic tier (scriptc issues #221 and #247).
|
|
64
|
+
*/
|
|
65
|
+
function numberFromText(text) {
|
|
66
|
+
const trimmed = text.trim();
|
|
67
|
+
if (trimmed === "") return 0;
|
|
68
|
+
if (DECIMAL_NUMBER_FORM.test(trimmed)) return parseFloat(trimmed);
|
|
69
|
+
if (INFINITY_FORM.test(trimmed)) return trimmed.startsWith("-") ? -1e400 : 1e400;
|
|
70
|
+
for (const [form, radix] of RADIX_FORMS) if (form.test(trimmed)) return parseInt(trimmed.slice(2), radix);
|
|
71
|
+
return NaN;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* doubleFromText parses an xsd:float or xsd:double lexical form: the XML Schema
|
|
75
|
+
* spellings INF, +INF, -INF and NaN, or anything numberFromText reads. It
|
|
76
|
+
* returns null for any other text, so NaN stays a value.
|
|
77
|
+
*/
|
|
78
|
+
function doubleFromText(text) {
|
|
79
|
+
const trimmed = text.trim();
|
|
80
|
+
if (trimmed === "NaN") return NaN;
|
|
81
|
+
if (trimmed === "INF" || trimmed === "+INF") return 1e400;
|
|
82
|
+
if (trimmed === "-INF") return -1e400;
|
|
83
|
+
const parsed = numberFromText(trimmed);
|
|
84
|
+
return Number.isNaN(parsed) ? null : parsed;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* numberFromNumeric converts a numeric value to a JS number. A bigint goes
|
|
88
|
+
* through its exact decimal form, so the result keeps `Number(bigint)`
|
|
89
|
+
* rounding without the dynamic `Number()` constructor.
|
|
90
|
+
*/
|
|
91
|
+
function numberFromNumeric(value) {
|
|
92
|
+
return typeof value === "bigint" ? parseFloat(value.toString()) : value;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* numericValue extracts the numeric value of a literal, or null when it is
|
|
96
|
+
* not numeric or its lexical form is malformed. xsd:integer and its derived
|
|
97
|
+
* types parse with BigInt for exact arbitrary-precision arithmetic (a derived
|
|
98
|
+
* type's range is not enforced, as in Comunica); other numeric datatypes use JS
|
|
99
|
+
* number parsing.
|
|
100
|
+
*/
|
|
101
|
+
function numericValue(term) {
|
|
102
|
+
const datatype = term.datatype?.value;
|
|
103
|
+
if (datatype === void 0 || !NUMERIC_DATATYPES.has(datatype)) return null;
|
|
104
|
+
if (INTEGER_DATATYPES.has(datatype)) try {
|
|
105
|
+
return BigInt(term.value);
|
|
106
|
+
} catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
if (datatype === "http://www.w3.org/2001/XMLSchema#float" || datatype === "http://www.w3.org/2001/XMLSchema#double") return doubleFromText(term.value);
|
|
110
|
+
const numeric = numberFromText(term.value);
|
|
111
|
+
return Number.isNaN(numeric) ? null : numeric;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* compareNumericValues orders two numeric values, comparing BigInt pairs
|
|
115
|
+
* exactly and everything else as Numbers. It returns NaN when either value is
|
|
116
|
+
* NaN, so every ordering operator answers false, as XPath requires.
|
|
117
|
+
*/
|
|
118
|
+
function compareNumericValues(a, b) {
|
|
119
|
+
if (typeof a === "bigint" && typeof b === "bigint") return a < b ? -1 : a > b ? 1 : 0;
|
|
120
|
+
const an = numberFromNumeric(a);
|
|
121
|
+
const bn = numberFromNumeric(b);
|
|
122
|
+
if (Number.isNaN(an) || Number.isNaN(bn)) return NaN;
|
|
123
|
+
return an < bn ? -1 : an > bn ? 1 : 0;
|
|
124
|
+
}
|
|
125
|
+
// src/term/convert.ts
|
|
126
|
+
const { namedNode, blankNode, literal } = DataFactory;
|
|
127
|
+
/**
|
|
128
|
+
* sparqlTermToRdfTerm converts a sparqljs AST term to an RDF/JS term.
|
|
129
|
+
*/
|
|
130
|
+
function sparqlTermToRdfTerm(term) {
|
|
131
|
+
switch (term.termType) {
|
|
132
|
+
case "NamedNode": return namedNode(term.value);
|
|
133
|
+
case "BlankNode": return blankNode(term.value);
|
|
134
|
+
case "Literal":
|
|
135
|
+
if (term.language) return literal(term.value, {
|
|
136
|
+
language: term.language,
|
|
137
|
+
direction: term.direction ?? void 0
|
|
138
|
+
});
|
|
139
|
+
if (term.datatype) return literal(term.value, namedNode(term.datatype.value));
|
|
140
|
+
return literal(term.value);
|
|
141
|
+
case "Quad": return term;
|
|
142
|
+
default: throw new Error(`Unsupported term type: ${term.termType}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* rdfTermToSparqlValue converts an RDF/JS term to a SparqlValue, the engine's
|
|
147
|
+
* result wire format. Plain string literals carry no datatype (xsd:string is
|
|
148
|
+
* implicit in SPARQL results); lang-tagged and typed literals carry their
|
|
149
|
+
* language or datatype.
|
|
150
|
+
*/
|
|
151
|
+
function rdfTermToSparqlValue(term) {
|
|
152
|
+
switch (term.termType) {
|
|
153
|
+
case "NamedNode": return {
|
|
154
|
+
type: "uri",
|
|
155
|
+
value: term.value
|
|
156
|
+
};
|
|
157
|
+
case "BlankNode": return {
|
|
158
|
+
type: "bnode",
|
|
159
|
+
value: term.value
|
|
160
|
+
};
|
|
161
|
+
case "Literal": {
|
|
162
|
+
const result = {
|
|
163
|
+
type: "literal",
|
|
164
|
+
value: term.value
|
|
165
|
+
};
|
|
166
|
+
if (term.language) {
|
|
167
|
+
result["xml:lang"] = term.language;
|
|
168
|
+
if (term.direction) result["its:dir"] = term.direction;
|
|
169
|
+
} else if (term.datatype && term.datatype.value !== "http://www.w3.org/2001/XMLSchema#string") result.datatype = term.datatype.value;
|
|
170
|
+
return result;
|
|
171
|
+
}
|
|
172
|
+
case "Quad": return {
|
|
173
|
+
type: "triple",
|
|
174
|
+
value: {
|
|
175
|
+
subject: rdfTermToSparqlValue(term.subject),
|
|
176
|
+
predicate: rdfTermToSparqlValue(term.predicate),
|
|
177
|
+
object: rdfTermToSparqlValue(term.object)
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
default: throw new Error(`Unsupported RDF term type: ${term.termType}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
// src/term/canonical.ts
|
|
184
|
+
/**
|
|
185
|
+
* canonicalizeRdfTerm normalizes an RDF/JS-shaped term into a CanonicalTerm.
|
|
186
|
+
* Plain xsd:string literals drop their datatype (it is implicit), and
|
|
187
|
+
* RDF-star triple terms flatten to subject/predicate/object.
|
|
188
|
+
*/
|
|
189
|
+
function canonicalizeRdfTerm(term) {
|
|
190
|
+
switch (term.termType) {
|
|
191
|
+
case "NamedNode": return {
|
|
192
|
+
termType: "NamedNode",
|
|
193
|
+
value: term.value
|
|
194
|
+
};
|
|
195
|
+
case "BlankNode": return {
|
|
196
|
+
termType: "BlankNode",
|
|
197
|
+
value: term.value
|
|
198
|
+
};
|
|
199
|
+
case "DefaultGraph": return {
|
|
200
|
+
termType: "DefaultGraph",
|
|
201
|
+
value: term.value
|
|
202
|
+
};
|
|
203
|
+
case "Literal": {
|
|
204
|
+
const canonical = {
|
|
205
|
+
termType: "Literal",
|
|
206
|
+
value: term.value
|
|
207
|
+
};
|
|
208
|
+
if (term.language) {
|
|
209
|
+
canonical.language = term.language;
|
|
210
|
+
if (term.direction) canonical.direction = term.direction;
|
|
211
|
+
} else if (term.datatype && term.datatype.value !== "http://www.w3.org/2001/XMLSchema#string") canonical.datatype = term.datatype.value;
|
|
212
|
+
return canonical;
|
|
213
|
+
}
|
|
214
|
+
case "Quad": return {
|
|
215
|
+
termType: "Quad",
|
|
216
|
+
value: "",
|
|
217
|
+
subject: canonicalizeRdfTerm(term.subject),
|
|
218
|
+
predicate: canonicalizeRdfTerm(term.predicate),
|
|
219
|
+
object: canonicalizeRdfTerm(term.object)
|
|
220
|
+
};
|
|
221
|
+
default: throw new Error(`Unsupported RDF term type: ${term.termType}`);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* canonicalizeSparqlValue normalizes a wazoo SparqlValue into a
|
|
226
|
+
* CanonicalTerm, so wazoo results compare structurally with RDF/JS-shaped
|
|
227
|
+
* results from other engines.
|
|
228
|
+
*/
|
|
229
|
+
function canonicalizeSparqlValue(value) {
|
|
230
|
+
switch (value.type) {
|
|
231
|
+
case "uri": return {
|
|
232
|
+
termType: "NamedNode",
|
|
233
|
+
value: value.value
|
|
234
|
+
};
|
|
235
|
+
case "bnode": return {
|
|
236
|
+
termType: "BlankNode",
|
|
237
|
+
value: value.value
|
|
238
|
+
};
|
|
239
|
+
case "literal": {
|
|
240
|
+
const canonical = {
|
|
241
|
+
termType: "Literal",
|
|
242
|
+
value: value.value
|
|
243
|
+
};
|
|
244
|
+
if (value["xml:lang"]) {
|
|
245
|
+
canonical.language = value["xml:lang"];
|
|
246
|
+
if (value["its:dir"]) canonical.direction = value["its:dir"];
|
|
247
|
+
} else if (value.datatype && value.datatype !== "http://www.w3.org/2001/XMLSchema#string") canonical.datatype = value.datatype;
|
|
248
|
+
return canonical;
|
|
249
|
+
}
|
|
250
|
+
case "triple": return {
|
|
251
|
+
termType: "Quad",
|
|
252
|
+
value: "",
|
|
253
|
+
subject: canonicalizeSparqlValue(value.value.subject),
|
|
254
|
+
predicate: canonicalizeSparqlValue(value.value.predicate),
|
|
255
|
+
object: canonicalizeSparqlValue(value.value.object)
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
// src/term/temporal.ts
|
|
260
|
+
/**
|
|
261
|
+
* temporal.ts reads the value of an xsd date, time or duration lexical form so
|
|
262
|
+
* the value comparisons of SPARQL's operator mapping (XPath 2.0) can order
|
|
263
|
+
* them. Instants are seconds on the UTC timeline.
|
|
264
|
+
* @see {@link https://www.w3.org/TR/2010/REC-xpath-functions-20101214/ Malhotra, Melton & Walsh (eds.), "XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition)," W3C Recommendation, 2010}
|
|
265
|
+
*/
|
|
266
|
+
const ZONE = "(Z|[+-][0-9]{2}:[0-9]{2})?";
|
|
267
|
+
const DATE = "(-?[0-9]{4,})-([0-9]{2})-([0-9]{2})";
|
|
268
|
+
const TIME = "([0-9]{2}):([0-9]{2}):([0-9]{2})(\\.[0-9]+)?";
|
|
269
|
+
const DATE_TIME_FORM = new RegExp(`^${DATE}T${TIME}${ZONE}$`);
|
|
270
|
+
const DATE_FORM = new RegExp(`^${DATE}${ZONE}$`);
|
|
271
|
+
const TIME_FORM = new RegExp(`^${TIME}${ZONE}$`);
|
|
272
|
+
/** MONTH_LENGTHS holds the days of each month in a common year. */
|
|
273
|
+
const MONTH_LENGTHS = [
|
|
274
|
+
31,
|
|
275
|
+
28,
|
|
276
|
+
31,
|
|
277
|
+
30,
|
|
278
|
+
31,
|
|
279
|
+
30,
|
|
280
|
+
31,
|
|
281
|
+
31,
|
|
282
|
+
30,
|
|
283
|
+
31,
|
|
284
|
+
30,
|
|
285
|
+
31
|
|
286
|
+
];
|
|
287
|
+
/** daysFromCivil counts the days from 1970-01-01 to a proleptic date. */
|
|
288
|
+
function daysFromCivil(year, month, day) {
|
|
289
|
+
const shifted = month <= 2 ? year - 1 : year;
|
|
290
|
+
const era = Math.floor(shifted / 400);
|
|
291
|
+
const yearOfEra = shifted - era * 400;
|
|
292
|
+
const marchMonth = month > 2 ? month - 3 : month + 9;
|
|
293
|
+
const dayOfYear = Math.floor((153 * marchMonth + 2) / 5) + day - 1;
|
|
294
|
+
const dayOfEra = yearOfEra * 365 + Math.floor(yearOfEra / 4) - Math.floor(yearOfEra / 100) + dayOfYear;
|
|
295
|
+
return era * 146097 + dayOfEra - 719468;
|
|
296
|
+
}
|
|
297
|
+
/** dateDays validates a calendar date and returns its day number, or null. */
|
|
298
|
+
function dateDays(year, month, day) {
|
|
299
|
+
const y = numberFromText(year);
|
|
300
|
+
const m = numberFromText(month);
|
|
301
|
+
const d = numberFromText(day);
|
|
302
|
+
if (m < 1 || m > 12 || d < 1) return null;
|
|
303
|
+
const leap = y % 4 === 0 && (y % 100 !== 0 || y % 400 === 0);
|
|
304
|
+
return d > (m === 2 && leap ? 29 : MONTH_LENGTHS[m - 1]) ? null : daysFromCivil(y, m, d);
|
|
305
|
+
}
|
|
306
|
+
/** zoneSeconds returns a timezone's offset, or null when out of range. */
|
|
307
|
+
function zoneSeconds(zone) {
|
|
308
|
+
if (zone === void 0 || zone === "Z") return 0;
|
|
309
|
+
const hours = numberFromText(zone.slice(1, 3));
|
|
310
|
+
const minutes = numberFromText(zone.slice(4, 6));
|
|
311
|
+
if (hours > 14 || minutes > 59) return null;
|
|
312
|
+
const offset = hours * 3600 + minutes * 60;
|
|
313
|
+
return zone.startsWith("-") ? -offset : offset;
|
|
314
|
+
}
|
|
315
|
+
/** instant combines a day number, a time of day and a timezone. */
|
|
316
|
+
function instant(days, clock, fraction, zone) {
|
|
317
|
+
const offset = zoneSeconds(zone);
|
|
318
|
+
if (offset === null) return null;
|
|
319
|
+
return {
|
|
320
|
+
months: 0,
|
|
321
|
+
seconds: days * 86400 + clock - offset,
|
|
322
|
+
fraction: fraction === void 0 ? 0 : numberFromText(`0${fraction}`),
|
|
323
|
+
hasTimezone: zone !== void 0
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/** clockSeconds validates a time of day; 24:00:00 is the end of the day. */
|
|
327
|
+
function clockSeconds(hours, minutes, seconds, fraction) {
|
|
328
|
+
const h = numberFromText(hours);
|
|
329
|
+
const m = numberFromText(minutes);
|
|
330
|
+
const s = numberFromText(seconds);
|
|
331
|
+
const endOfDay = h === 24 && m === 0 && s === 0 && numberFromText(`0${fraction ?? ""}`) === 0;
|
|
332
|
+
if (h > 23 && !endOfDay || m > 59 || s > 59) return null;
|
|
333
|
+
return h * 3600 + m * 60 + s;
|
|
334
|
+
}
|
|
335
|
+
/** dateTimeValue reads an xsd:dateTime lexical form. */
|
|
336
|
+
function dateTimeValue(text) {
|
|
337
|
+
const match = DATE_TIME_FORM.exec(text);
|
|
338
|
+
if (match === null) return null;
|
|
339
|
+
const days = dateDays(match[1], match[2], match[3]);
|
|
340
|
+
const clock = clockSeconds(match[4], match[5], match[6], match[7]);
|
|
341
|
+
if (days === null || clock === null) return null;
|
|
342
|
+
return instant(days, clock, match[7], match[8]);
|
|
343
|
+
}
|
|
344
|
+
/** dateValue reads an xsd:date lexical form as its starting instant. */
|
|
345
|
+
function dateValue(text) {
|
|
346
|
+
const match = DATE_FORM.exec(text);
|
|
347
|
+
if (match === null) return null;
|
|
348
|
+
const days = dateDays(match[1], match[2], match[3]);
|
|
349
|
+
return days === null ? null : instant(days, 0, void 0, match[4]);
|
|
350
|
+
}
|
|
351
|
+
/** timeValue reads an xsd:time lexical form. */
|
|
352
|
+
function timeValue(text) {
|
|
353
|
+
const match = TIME_FORM.exec(text);
|
|
354
|
+
if (match === null) return null;
|
|
355
|
+
const clock = clockSeconds(match[1], match[2], match[3], match[4]);
|
|
356
|
+
return clock === null ? null : instant(0, clock % 86400, match[4], match[5]);
|
|
357
|
+
}
|
|
358
|
+
// src/term/datetime.ts
|
|
359
|
+
/**
|
|
360
|
+
* datetime.ts implements the xsd:dateTime value surface the SPARQL date/time
|
|
361
|
+
* functions (YEAR, MONTH, DAY, HOURS, MINUTES, SECONDS, TIMEZONE) need:
|
|
362
|
+
* strict lexical parsing and the xsd:dayTimeDuration lexical form for
|
|
363
|
+
* timezone offsets.
|
|
364
|
+
*/
|
|
365
|
+
const DATE_TIME_PATTERN = /^(-?\d{4,})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d+)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
366
|
+
/**
|
|
367
|
+
* parseDateTime parses an xsd:dateTime lexical form into its components, or
|
|
368
|
+
* null when the form is malformed or out of range.
|
|
369
|
+
*/
|
|
370
|
+
function parseDateTime(lexical) {
|
|
371
|
+
const match = DATE_TIME_PATTERN.exec(lexical);
|
|
372
|
+
if (match === null) return null;
|
|
373
|
+
const year = numberFromText(match[1]);
|
|
374
|
+
const month = numberFromText(match[2]);
|
|
375
|
+
const day = numberFromText(match[3]);
|
|
376
|
+
const hours = numberFromText(match[4]);
|
|
377
|
+
const minutes = numberFromText(match[5]);
|
|
378
|
+
const seconds = numberFromText(match[6]);
|
|
379
|
+
if (month < 1 || month > 12 || day < 1 || day > 31 || hours > 23 || minutes > 59 || seconds > 60) return null;
|
|
380
|
+
let hasTimezone = false;
|
|
381
|
+
let timezoneMinutes = 0;
|
|
382
|
+
const timezone = match[8];
|
|
383
|
+
if (timezone !== void 0) {
|
|
384
|
+
hasTimezone = true;
|
|
385
|
+
if (timezone !== "Z") {
|
|
386
|
+
const sign = timezone[0] === "-" ? -1 : 1;
|
|
387
|
+
const tzHours = numberFromText(timezone.slice(1, 3));
|
|
388
|
+
const tzMinutes = numberFromText(timezone.slice(4, 6));
|
|
389
|
+
if (tzHours > 23 || tzMinutes > 59) return null;
|
|
390
|
+
timezoneMinutes = sign * (tzHours * 60 + tzMinutes);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return {
|
|
394
|
+
year,
|
|
395
|
+
month,
|
|
396
|
+
day,
|
|
397
|
+
hours,
|
|
398
|
+
minutes,
|
|
399
|
+
seconds: match[7] !== void 0 ? numberFromText(match[6] + match[7]) : seconds,
|
|
400
|
+
hasTimezone,
|
|
401
|
+
timezoneMinutes
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* timezoneDurationLexical renders a signed UTC offset in minutes as the
|
|
406
|
+
* canonical xsd:dayTimeDuration lexical form: "PT0S" for zero, "-PT5H" for
|
|
407
|
+
* -05:00, "PT5H30M" for +05:30.
|
|
408
|
+
*/
|
|
409
|
+
function timezoneDurationLexical(offsetMinutes) {
|
|
410
|
+
if (offsetMinutes === 0) return "PT0S";
|
|
411
|
+
const sign = offsetMinutes < 0 ? "-" : "";
|
|
412
|
+
const total = Math.abs(offsetMinutes);
|
|
413
|
+
const hours = Math.floor(total / 60);
|
|
414
|
+
const minutes = total % 60;
|
|
415
|
+
let result = `${sign}PT`;
|
|
416
|
+
if (hours > 0) result += `${hours}H`;
|
|
417
|
+
if (minutes > 0) result += `${minutes}M`;
|
|
418
|
+
if (hours === 0 && minutes === 0) result += "0S";
|
|
419
|
+
return result;
|
|
420
|
+
}
|
|
421
|
+
/** XSD_DATE is the xsd:date datatype IRI. */
|
|
422
|
+
const XSD_DATE = `${XSD}date`;
|
|
423
|
+
/**
|
|
424
|
+
* parseCalendar parses the components of an xsd:dateTime or xsd:date lexical
|
|
425
|
+
* form, a date reading as its first instant, or null for any other datatype or
|
|
426
|
+
* an impossible date.
|
|
427
|
+
*/
|
|
428
|
+
function parseCalendar(lexical, datatype) {
|
|
429
|
+
if (datatype === "http://www.w3.org/2001/XMLSchema#dateTime") return parseDateTime(lexical);
|
|
430
|
+
if (datatype !== XSD_DATE || dateValue(lexical) === null) return null;
|
|
431
|
+
const zone = timezoneOf(lexical);
|
|
432
|
+
return parseDateTime(`${lexical.slice(0, lexical.length - zone.length)}T00:00:00${zone}`);
|
|
433
|
+
}
|
|
434
|
+
/** timezoneOf returns the timezone a date or dateTime form ends with, or "". */
|
|
435
|
+
function timezoneOf(lexical) {
|
|
436
|
+
return /(Z|[+-][0-9]{2}:[0-9]{2})$/.exec(lexical)?.[1] ?? "";
|
|
437
|
+
}
|
|
438
|
+
// src/term/md5-constants.ts
|
|
439
|
+
/**
|
|
440
|
+
* hash.ts implements the SPARQL 1.1 hash functions (MD5, SHA-1, SHA-256,
|
|
441
|
+
* SHA-384, SHA-512) synchronously in pure TypeScript, so the expression
|
|
442
|
+
* evaluator can call them without awaiting. SHA-1/SHA-256 use 32-bit word
|
|
443
|
+
* arithmetic; SHA-384/SHA-512 use BigInt for the 64-bit words. All five
|
|
444
|
+
* return lowercase hexadecimal strings of the digest.
|
|
445
|
+
*
|
|
446
|
+
* Prior art: the algorithms are the standard published message digests —
|
|
447
|
+
* MD5 per IETF RFC 1321 and the SHA family per NIST FIPS 180-4 (which
|
|
448
|
+
* SPARQL 1.1 §17.4.1.7 delegates to).
|
|
449
|
+
* @see {@link https://www.rfc-editor.org/rfc/rfc1321 Rivest, "The MD5 Message-Digest Algorithm," IETF RFC 1321, 1992}
|
|
450
|
+
* @see {@link https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf NIST, "Secure Hash Standard (SHS)," FIPS PUB 180-4, 2015}
|
|
451
|
+
*/
|
|
452
|
+
const MD5_S = [
|
|
453
|
+
7,
|
|
454
|
+
12,
|
|
455
|
+
17,
|
|
456
|
+
22,
|
|
457
|
+
7,
|
|
458
|
+
12,
|
|
459
|
+
17,
|
|
460
|
+
22,
|
|
461
|
+
7,
|
|
462
|
+
12,
|
|
463
|
+
17,
|
|
464
|
+
22,
|
|
465
|
+
7,
|
|
466
|
+
12,
|
|
467
|
+
17,
|
|
468
|
+
22,
|
|
469
|
+
5,
|
|
470
|
+
9,
|
|
471
|
+
14,
|
|
472
|
+
20,
|
|
473
|
+
5,
|
|
474
|
+
9,
|
|
475
|
+
14,
|
|
476
|
+
20,
|
|
477
|
+
5,
|
|
478
|
+
9,
|
|
479
|
+
14,
|
|
480
|
+
20,
|
|
481
|
+
5,
|
|
482
|
+
9,
|
|
483
|
+
14,
|
|
484
|
+
20,
|
|
485
|
+
4,
|
|
486
|
+
11,
|
|
487
|
+
16,
|
|
488
|
+
23,
|
|
489
|
+
4,
|
|
490
|
+
11,
|
|
491
|
+
16,
|
|
492
|
+
23,
|
|
493
|
+
4,
|
|
494
|
+
11,
|
|
495
|
+
16,
|
|
496
|
+
23,
|
|
497
|
+
4,
|
|
498
|
+
11,
|
|
499
|
+
16,
|
|
500
|
+
23,
|
|
501
|
+
6,
|
|
502
|
+
10,
|
|
503
|
+
15,
|
|
504
|
+
21,
|
|
505
|
+
6,
|
|
506
|
+
10,
|
|
507
|
+
15,
|
|
508
|
+
21,
|
|
509
|
+
6,
|
|
510
|
+
10,
|
|
511
|
+
15,
|
|
512
|
+
21,
|
|
513
|
+
6,
|
|
514
|
+
10,
|
|
515
|
+
15,
|
|
516
|
+
21
|
|
517
|
+
];
|
|
518
|
+
/**
|
|
519
|
+
* MD5_K holds the 64 round constants, defined as floor(|sin(i+1)| * 2^32).
|
|
520
|
+
*/
|
|
521
|
+
const MD5_K = Array.from({ length: 64 }, (_, index) => Math.floor(Math.abs(Math.sin(index + 1)) * 4294967296));
|
|
522
|
+
// src/term/md5.ts
|
|
523
|
+
/**
|
|
524
|
+
* md5Hex returns the MD5 digest of the UTF-8 encoding of the input as
|
|
525
|
+
* lowercase hexadecimal.
|
|
526
|
+
*/
|
|
527
|
+
function md5Hex(input) {
|
|
528
|
+
const bytes = new TextEncoder().encode(input);
|
|
529
|
+
const bitLength = bytes.length * 8;
|
|
530
|
+
const paddedLength = (bytes.length + 8 >> 6) + 1 << 6;
|
|
531
|
+
const padded = new Uint8Array(paddedLength);
|
|
532
|
+
padded.set(bytes);
|
|
533
|
+
padded[bytes.length] = 128;
|
|
534
|
+
const view = new DataView(padded.buffer);
|
|
535
|
+
view.setUint32(paddedLength - 8, bitLength >>> 0, true);
|
|
536
|
+
view.setUint32(paddedLength - 4, Math.floor(bitLength / 4294967296), true);
|
|
537
|
+
let a0 = 0x67452301;
|
|
538
|
+
let b0 = 0xefcdab89;
|
|
539
|
+
let c0 = 0x98badcfe;
|
|
540
|
+
let d0 = 271733878;
|
|
541
|
+
for (let offset = 0; offset < paddedLength; offset += 64) {
|
|
542
|
+
const m = new Array(16);
|
|
543
|
+
for (let index = 0; index < 16; index++) m[index] = view.getUint32(offset + index * 4, true);
|
|
544
|
+
let a = a0;
|
|
545
|
+
let b = b0;
|
|
546
|
+
let c = c0;
|
|
547
|
+
let d = d0;
|
|
548
|
+
for (let index = 0; index < 64; index++) {
|
|
549
|
+
let f;
|
|
550
|
+
let g;
|
|
551
|
+
if (index < 16) {
|
|
552
|
+
f = b & c | ~b & d;
|
|
553
|
+
g = index;
|
|
554
|
+
} else if (index < 32) {
|
|
555
|
+
f = d & b | ~d & c;
|
|
556
|
+
g = (5 * index + 1) % 16;
|
|
557
|
+
} else if (index < 48) {
|
|
558
|
+
f = b ^ c ^ d;
|
|
559
|
+
g = (3 * index + 5) % 16;
|
|
560
|
+
} else {
|
|
561
|
+
f = c ^ (b | ~d);
|
|
562
|
+
g = 7 * index % 16;
|
|
563
|
+
}
|
|
564
|
+
f = f + a + MD5_K[index] + m[g] >>> 0;
|
|
565
|
+
a = d;
|
|
566
|
+
d = c;
|
|
567
|
+
c = b;
|
|
568
|
+
b = b + (f << MD5_S[index] | f >>> 32 - MD5_S[index]) >>> 0;
|
|
569
|
+
}
|
|
570
|
+
a0 = a0 + a >>> 0;
|
|
571
|
+
b0 = b0 + b >>> 0;
|
|
572
|
+
c0 = c0 + c >>> 0;
|
|
573
|
+
d0 = d0 + d >>> 0;
|
|
574
|
+
}
|
|
575
|
+
const wordHex = (word) => {
|
|
576
|
+
let result = "";
|
|
577
|
+
for (let byte = 0; byte < 4; byte++) result += (word >>> byte * 8 & 255).toString(16).padStart(2, "0");
|
|
578
|
+
return result;
|
|
579
|
+
};
|
|
580
|
+
return wordHex(a0) + wordHex(b0) + wordHex(c0) + wordHex(d0);
|
|
581
|
+
}
|
|
582
|
+
// src/term/duration.ts
|
|
583
|
+
/**
|
|
584
|
+
* duration.ts reads an xsd:duration lexical form as a comparable value.
|
|
585
|
+
*/
|
|
586
|
+
const DURATION_FORM = /^(-)?P(?:([0-9]+)Y)?(?:([0-9]+)M)?(?:([0-9]+)D)?(?:T(?:([0-9]+)H)?(?:([0-9]+)M)?(?:([0-9]+)(\.[0-9]+)?S)?)?$/;
|
|
587
|
+
/** durationValue reads an xsd:duration lexical form of any subtype. */
|
|
588
|
+
function durationValue(text) {
|
|
589
|
+
const match = DURATION_FORM.exec(text);
|
|
590
|
+
if (match === null || text.endsWith("P") || text.endsWith("T")) return null;
|
|
591
|
+
const part = (index) => numberFromText(match[index] ?? "0");
|
|
592
|
+
const sign = match[1] === void 0 ? 1 : -1;
|
|
593
|
+
const seconds = part(4) * 86400 + part(5) * 3600 + part(6) * 60 + part(7);
|
|
594
|
+
const fraction = match[8] === void 0 ? 0 : numberFromText(`0${match[8]}`);
|
|
595
|
+
return {
|
|
596
|
+
months: sign * (part(2) * 12 + part(3)),
|
|
597
|
+
seconds: sign * seconds,
|
|
598
|
+
fraction: sign * fraction,
|
|
599
|
+
hasTimezone: false
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
// src/term/typed-value.ts
|
|
603
|
+
/** MAX_ZONE_SECONDS is the widest offset an unwritten timezone may stand for. */
|
|
604
|
+
const MAX_ZONE_SECONDS = 50400;
|
|
605
|
+
function plain(seconds) {
|
|
606
|
+
return {
|
|
607
|
+
months: 0,
|
|
608
|
+
seconds,
|
|
609
|
+
fraction: 0,
|
|
610
|
+
hasTimezone: false
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
function tagged(family, subtype, value) {
|
|
614
|
+
return value === null ? null : {
|
|
615
|
+
family,
|
|
616
|
+
subtype,
|
|
617
|
+
value
|
|
618
|
+
};
|
|
619
|
+
}
|
|
620
|
+
/** typedValue reads a boolean or temporal literal, or null for any other. */
|
|
621
|
+
function typedValue(literal) {
|
|
622
|
+
const datatype = literal.datatype?.value ?? "";
|
|
623
|
+
const text = literal.value;
|
|
624
|
+
if (datatype === "http://www.w3.org/2001/XMLSchema#boolean") {
|
|
625
|
+
if (text === "true" || text === "1") return tagged("boolean", "boolean", plain(1));
|
|
626
|
+
if (text === "false" || text === "0") return tagged("boolean", "boolean", plain(0));
|
|
627
|
+
return null;
|
|
628
|
+
}
|
|
629
|
+
if (datatype === "http://www.w3.org/2001/XMLSchema#dateTime" || datatype === `http://www.w3.org/2001/XMLSchema#dateTimeStamp`) return tagged("dateTime", "dateTime", dateTimeValue(text));
|
|
630
|
+
if (datatype === `http://www.w3.org/2001/XMLSchema#date`) return tagged("date", "date", dateValue(text));
|
|
631
|
+
if (datatype === `http://www.w3.org/2001/XMLSchema#time`) return tagged("time", "time", timeValue(text));
|
|
632
|
+
if (datatype === `http://www.w3.org/2001/XMLSchema#duration`) return tagged("duration", "duration", durationValue(text));
|
|
633
|
+
if (datatype === `http://www.w3.org/2001/XMLSchema#yearMonthDuration`) {
|
|
634
|
+
const value = durationValue(text);
|
|
635
|
+
return value === null || value.seconds !== 0 || value.fraction !== 0 ? null : tagged("duration", "yearMonth", value);
|
|
636
|
+
}
|
|
637
|
+
if (datatype === `http://www.w3.org/2001/XMLSchema#dayTimeDuration`) {
|
|
638
|
+
const value = durationValue(text);
|
|
639
|
+
return value === null || value.months !== 0 ? null : tagged("duration", "dayTime", value);
|
|
640
|
+
}
|
|
641
|
+
return null;
|
|
642
|
+
}
|
|
643
|
+
/** sign orders two values by months, then seconds, then the fraction. */
|
|
644
|
+
function sign(a, b) {
|
|
645
|
+
const difference = a.months - b.months || a.seconds - b.seconds || a.fraction - b.fraction;
|
|
646
|
+
return difference < 0 ? -1 : difference > 0 ? 1 : 0;
|
|
647
|
+
}
|
|
648
|
+
/**
|
|
649
|
+
* typedValuesEqual answers `=` for two literals of one family, or null when
|
|
650
|
+
* they are not both readable values of the same family. An instant with a
|
|
651
|
+
* timezone never equals one without.
|
|
652
|
+
*/
|
|
653
|
+
function typedValuesEqual(a, b) {
|
|
654
|
+
const left = typedValue(a);
|
|
655
|
+
const right = typedValue(b);
|
|
656
|
+
if (left === null || right === null || left.family !== right.family) return null;
|
|
657
|
+
return left.value.hasTimezone === right.value.hasTimezone && sign(left.value, right.value) === 0;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* orderTypedValues answers `<` and its siblings: a negative, zero or positive
|
|
661
|
+
* number, or undefined when the pair has no order. Following XML Schema, two
|
|
662
|
+
* instants of which only one has a timezone are ordered only when they are
|
|
663
|
+
* more than 14 hours apart.
|
|
664
|
+
*/
|
|
665
|
+
function orderTypedValues(a, b) {
|
|
666
|
+
const left = typedValue(a);
|
|
667
|
+
const right = typedValue(b);
|
|
668
|
+
if (left === null || right === null || left.family !== right.family) return;
|
|
669
|
+
if (left.family === "duration" && (left.subtype !== right.subtype || left.subtype === "duration")) return;
|
|
670
|
+
if (left.value.hasTimezone !== right.value.hasTimezone) {
|
|
671
|
+
if (Math.abs(left.value.seconds - right.value.seconds) <= MAX_ZONE_SECONDS) return;
|
|
672
|
+
}
|
|
673
|
+
return sign(left.value, right.value);
|
|
674
|
+
}
|
|
675
|
+
/**
|
|
676
|
+
* sortTypedValues is the total order ORDER BY, MIN and MAX use within one
|
|
677
|
+
* family (an unwritten timezone reads as UTC), or null for any other pair.
|
|
678
|
+
*/
|
|
679
|
+
function sortTypedValues(a, b) {
|
|
680
|
+
const left = typedValue(a);
|
|
681
|
+
const right = typedValue(b);
|
|
682
|
+
if (left === null || right === null || left.family !== right.family) return null;
|
|
683
|
+
return sign(left.value, right.value);
|
|
684
|
+
}
|
|
685
|
+
// src/term/ordering.ts
|
|
686
|
+
/**
|
|
687
|
+
* compareStrings orders two strings by codepoint comparison.
|
|
688
|
+
*/
|
|
689
|
+
function compareStrings(a, b) {
|
|
690
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
691
|
+
}
|
|
692
|
+
/**
|
|
693
|
+
* literalDatatype returns the effective datatype of a literal for ordering:
|
|
694
|
+
* plain literals are treated as xsd:string, matching SPARQL 1.1 result
|
|
695
|
+
* semantics and the reference engines.
|
|
696
|
+
*/
|
|
697
|
+
function literalDatatype(literal) {
|
|
698
|
+
return literal.datatype?.value ?? "http://www.w3.org/2001/XMLSchema#string";
|
|
699
|
+
}
|
|
700
|
+
/**
|
|
701
|
+
* compareLiterals orders two literals: numerically for literals of any
|
|
702
|
+
* numeric datatype in the XSD hierarchy (integer/decimal/float/double —
|
|
703
|
+
* MIN(1, 2.2) is 1), then by datatype IRI (plain literals counting as
|
|
704
|
+
* xsd:string), then by codepoint comparison of the lexical forms. This
|
|
705
|
+
* matches the SPARQL 1.1 §12.4 ordering rules as implemented by the
|
|
706
|
+
* reference engines, including the lang-tagged (rdf:langString) case.
|
|
707
|
+
*/
|
|
708
|
+
function compareLiterals(a, b) {
|
|
709
|
+
const da = literalDatatype(a);
|
|
710
|
+
const db = literalDatatype(b);
|
|
711
|
+
const an = NUMERIC_DATATYPES.has(da) ? numericValue(a) : null;
|
|
712
|
+
const bn = NUMERIC_DATATYPES.has(db) ? numericValue(b) : null;
|
|
713
|
+
if (an !== null && bn !== null) {
|
|
714
|
+
const order = compareNumericValues(an, bn);
|
|
715
|
+
return Number.isNaN(order) ? Number(Number.isNaN(an)) - Number(Number.isNaN(bn)) : order;
|
|
716
|
+
}
|
|
717
|
+
const typed = sortTypedValues(a, b);
|
|
718
|
+
if (typed !== null) return typed;
|
|
719
|
+
if (da !== db) return compareStrings(da, db);
|
|
720
|
+
const byValue = compareStrings(a.value, b.value);
|
|
721
|
+
if (byValue !== 0) return byValue;
|
|
722
|
+
return compareStrings(a.direction ?? "", b.direction ?? "");
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* compareRdfTerms orders two RDF terms (or undefined for an unbound
|
|
726
|
+
* variable) per SPARQL 1.1 §12.4: unbound sorts lowest, then blank nodes,
|
|
727
|
+
* then IRIs, then literals, then triple terms (per RDF 1.2's total order).
|
|
728
|
+
* Literals order by datatype IRI first (plain literals counting as
|
|
729
|
+
* xsd:string), numerically within the same numeric datatype, then by lexical
|
|
730
|
+
* form. Triple terms order lexicographically by subject, predicate, then
|
|
731
|
+
* object, recursively. Blank-node labels and the relative order of terms the
|
|
732
|
+
* spec leaves undefined are compared deterministically. Returns a negative,
|
|
733
|
+
* zero, or positive number suitable for Array.prototype.sort.
|
|
734
|
+
*
|
|
735
|
+
* Prior art: the ordering rules are SPARQL 1.1 §12.4 (ORDER BY), with the
|
|
736
|
+
* cross-datatype numeric comparisons following the XPath 2.0 value
|
|
737
|
+
* ordering the spec delegates to.
|
|
738
|
+
* @see {@link https://www.w3.org/TR/sparql11-query/ Harris & Seaborne (eds.), "SPARQL 1.1 Query Language," W3C Recommendation, 2013}
|
|
739
|
+
* @see {@link https://www.w3.org/TR/2010/REC-xpath-functions-20101214/ Malhotra, Melton & Walsh (eds.), "XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition)," W3C Recommendation, 2010}
|
|
740
|
+
*/
|
|
741
|
+
function compareRdfTerms(a, b) {
|
|
742
|
+
if (a === void 0) return b === void 0 ? 0 : -1;
|
|
743
|
+
if (b === void 0) return 1;
|
|
744
|
+
const rank = (term) => {
|
|
745
|
+
switch (term.termType) {
|
|
746
|
+
case "BlankNode": return 0;
|
|
747
|
+
case "NamedNode": return 1;
|
|
748
|
+
case "Literal": return 2;
|
|
749
|
+
default: return 3;
|
|
750
|
+
}
|
|
751
|
+
};
|
|
752
|
+
const ra = rank(a);
|
|
753
|
+
const rb = rank(b);
|
|
754
|
+
if (ra !== rb) return ra - rb;
|
|
755
|
+
switch (a.termType) {
|
|
756
|
+
case "BlankNode": return compareStrings(a.value, b.value);
|
|
757
|
+
case "NamedNode": return compareStrings(a.value, b.value);
|
|
758
|
+
case "Literal": return compareLiterals(a, b);
|
|
759
|
+
case "Quad": {
|
|
760
|
+
const qa = a;
|
|
761
|
+
const qb = b;
|
|
762
|
+
return compareRdfTerms(qa.subject, qb.subject) || compareRdfTerms(qa.predicate, qb.predicate) || compareRdfTerms(qa.object, qb.object);
|
|
763
|
+
}
|
|
764
|
+
default: return compareStrings(termKey(a), termKey(b));
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
export { XSD_INTEGER as C, numberFromNumeric as D, doubleFromText as E, numberFromText as O, XSD_FLOAT as S, compareNumericValues as T, XSD_BOOLEAN as _, md5Hex as a, XSD_DECIMAL as b, parseDateTime as c, canonicalizeRdfTerm as d, canonicalizeSparqlValue as f, XSD as g, NUMERIC_DATATYPES as h, typedValuesEqual as i, numericValue as k, timezoneDurationLexical as l, sparqlTermToRdfTerm as m, orderTypedValues as n, XSD_DATE as o, rdfTermToSparqlValue as p, typedValue as r, parseCalendar as s, compareRdfTerms as t, timezoneOf as u, XSD_DATETIME as v, XSD_STRING as w, XSD_DOUBLE as x, XSD_DAYTIME_DURATION as y };
|