rdflib 2.2.21 → 2.2.22-0de51c50
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/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +13 -1
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +3 -27
- package/esm/collection.js +7 -29
- package/esm/default-graph.js +1 -15
- package/esm/empty.js +0 -13
- package/esm/factories/canonical-data-factory.js +5 -40
- package/esm/factories/extended-term-factory.js +0 -11
- package/esm/factories/factory-types.js +2 -1
- package/esm/factories/rdflib-data-factory.js +0 -8
- package/esm/fetcher.js +257 -481
- package/esm/formula.js +43 -142
- package/esm/index.js +19 -36
- package/esm/jsonldparser.js +20 -29
- package/esm/jsonparser.js +0 -7
- package/esm/lists.js +18 -33
- package/esm/literal.js +10 -42
- package/esm/n3parser.js +38 -351
- package/esm/named-node.js +8 -27
- package/esm/namespace.js +0 -1
- package/esm/node-internal.js +11 -24
- package/esm/node.js +1 -6
- package/esm/parse.js +10 -17
- package/esm/patch-parser.js +9 -29
- package/esm/query-to-sparql.js +0 -18
- package/esm/query.js +50 -133
- package/esm/rdfaparser.js +72 -210
- package/esm/rdfxmlparser.js +31 -128
- package/esm/serialize.js +8 -33
- package/esm/serializer.js +122 -286
- package/esm/sparql-to-query.js +44 -134
- package/esm/statement.js +8 -19
- package/esm/store.js +109 -280
- package/esm/types.js +3 -2
- package/esm/update-manager.js +110 -246
- package/esm/updates-via.js +0 -27
- package/esm/uri.js +6 -50
- package/esm/utils/default-graph-uri.js +1 -0
- package/esm/utils/termValue.js +0 -1
- package/esm/utils/terms.js +15 -16
- package/esm/utils-js.js +16 -57
- package/esm/utils.js +4 -15
- package/esm/variable.js +0 -20
- package/lib/blank-node.js +3 -28
- package/lib/class-order.js +0 -1
- package/lib/collection.js +7 -34
- package/lib/default-graph.js +0 -20
- package/lib/empty.js +0 -18
- package/lib/factories/canonical-data-factory.js +4 -51
- package/lib/factories/extended-term-factory.js +0 -18
- package/lib/factories/factory-types.d.ts +6 -6
- package/lib/factories/factory-types.js +0 -3
- package/lib/factories/rdflib-data-factory.js +0 -12
- package/lib/fetcher.d.ts +6 -6
- package/lib/fetcher.js +258 -470
- package/lib/formula.d.ts +1 -1
- package/lib/formula.js +43 -151
- package/lib/index.d.ts +1 -2
- package/lib/index.js +14 -82
- package/lib/jsonldparser.js +19 -33
- package/lib/jsonparser.js +0 -9
- package/lib/lists.js +14 -39
- package/lib/literal.js +10 -49
- package/lib/log.d.ts +0 -6
- package/lib/log.js +0 -1
- package/lib/n3parser.d.ts +1 -0
- package/lib/n3parser.js +39 -359
- package/lib/named-node.js +7 -35
- package/lib/namespace.js +0 -3
- package/lib/node-internal.js +11 -21
- package/lib/node.js +1 -11
- package/lib/parse.d.ts +1 -1
- package/lib/parse.js +8 -27
- package/lib/patch-parser.js +10 -33
- package/lib/query-to-sparql.js +0 -23
- package/lib/query.js +46 -152
- package/lib/rdfaparser.js +72 -220
- package/lib/rdfxmlparser.js +31 -132
- package/lib/serialize.d.ts +1 -1
- package/lib/serialize.js +8 -43
- package/lib/serializer.d.ts +1 -0
- package/lib/serializer.js +121 -297
- package/lib/sparql-to-query.js +42 -167
- package/lib/statement.js +8 -24
- package/lib/store.d.ts +2 -2
- package/lib/store.js +102 -282
- package/lib/tf-types.d.ts +4 -4
- package/lib/types.d.ts +8 -8
- package/lib/types.js +3 -3
- package/lib/update-manager.d.ts +2 -2
- package/lib/update-manager.js +110 -254
- package/lib/updates-via.js +0 -30
- package/lib/uri.js +5 -58
- package/lib/utils/default-graph-uri.js +1 -3
- package/lib/utils/termValue.js +0 -2
- package/lib/utils/terms.js +15 -34
- package/lib/utils-js.js +16 -80
- package/lib/utils.js +4 -21
- package/lib/variable.js +0 -25
- package/lib/xsd-internal.js +0 -3
- package/lib/xsd.js +0 -4
- package/package.json +40 -39
- package/src/fetcher.ts +2 -2
- package/src/index.ts +0 -2
- package/src/jsonldparser.js +13 -4
- package/src/n3parser.js +12 -4
- package/src/serialize.ts +4 -11
- package/src/serializer.js +24 -0
- package/src/update-manager.ts +18 -7
- package/changes.txt +0 -59
- package/esm/convert.js +0 -61
- package/lib/convert.d.ts +0 -2
- package/lib/convert.js +0 -77
- package/src/convert.js +0 -70
package/esm/utils-js.js
CHANGED
|
@@ -12,12 +12,12 @@ var string = {
|
|
|
12
12
|
export { log, uri, string };
|
|
13
13
|
export function mediaTypeClass(mediaType) {
|
|
14
14
|
mediaType = mediaType.split(';')[0].trim(); // remove media type parameters
|
|
15
|
-
|
|
16
15
|
return new NamedNode('http://www.w3.org/ns/iana/media-types/' + mediaType + '#Resource');
|
|
17
16
|
}
|
|
18
17
|
export function linkRelationProperty(relation) {
|
|
19
18
|
return new NamedNode('http://www.w3.org/ns/iana/link-relations/relation#' + relation.trim());
|
|
20
19
|
}
|
|
20
|
+
|
|
21
21
|
/**
|
|
22
22
|
* Adds callback functionality to an object.
|
|
23
23
|
* Callback functions are indexed by a 'hook' string.
|
|
@@ -26,24 +26,19 @@ export function linkRelationProperty(relation) {
|
|
|
26
26
|
* @param obj {Object}
|
|
27
27
|
* @param callbacks {Array<string>}
|
|
28
28
|
*/
|
|
29
|
-
|
|
30
29
|
export function callbackify(obj, callbacks) {
|
|
31
30
|
obj.callbacks = {};
|
|
32
|
-
|
|
33
31
|
for (var x = callbacks.length - 1; x >= 0; x--) {
|
|
34
32
|
obj.callbacks[callbacks[x]] = [];
|
|
35
33
|
}
|
|
36
|
-
|
|
37
34
|
obj.addHook = function (hook) {
|
|
38
35
|
if (!obj.callbacks[hook]) {
|
|
39
36
|
obj.callbacks[hook] = [];
|
|
40
37
|
}
|
|
41
38
|
};
|
|
42
|
-
|
|
43
39
|
obj.addCallback = function (hook, func) {
|
|
44
40
|
obj.callbacks[hook].push(func);
|
|
45
41
|
};
|
|
46
|
-
|
|
47
42
|
obj.removeCallback = function (hook, funcName) {
|
|
48
43
|
for (var i = 0; i < obj.callbacks[hook].length; i++) {
|
|
49
44
|
if (obj.callbacks[hook][i].name === funcName) {
|
|
@@ -51,45 +46,39 @@ export function callbackify(obj, callbacks) {
|
|
|
51
46
|
return true;
|
|
52
47
|
}
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
return false;
|
|
56
50
|
};
|
|
57
|
-
|
|
58
51
|
obj.insertCallback = function (hook, func) {
|
|
59
52
|
obj.callbacks[hook].unshift(func);
|
|
60
53
|
};
|
|
61
|
-
|
|
62
54
|
obj.fireCallbacks = function fireCallbacks(hook, args) {
|
|
63
55
|
var newCallbacks = [];
|
|
64
56
|
var replaceCallbacks = [];
|
|
65
57
|
var len = obj.callbacks[hook].length;
|
|
66
58
|
var x;
|
|
67
|
-
var callback;
|
|
59
|
+
var callback;
|
|
68
60
|
|
|
61
|
+
// log.info('!@$ Firing '+hook+' call back with length'+len)
|
|
69
62
|
for (x = len - 1; x >= 0; x--) {
|
|
70
63
|
// log.info('@@ Firing '+hook+' callback '+ obj.callbacks[hook][x])
|
|
71
64
|
callback = obj.callbacks[hook][x];
|
|
72
|
-
|
|
73
65
|
if (callback && callback.apply(obj, args)) {
|
|
74
66
|
newCallbacks.push(callback);
|
|
75
67
|
}
|
|
76
68
|
}
|
|
77
|
-
|
|
78
69
|
for (x = newCallbacks.length - 1; x >= 0; x--) {
|
|
79
70
|
replaceCallbacks.push(newCallbacks[x]);
|
|
80
71
|
}
|
|
81
|
-
|
|
82
72
|
for (x = len; x < obj.callbacks[hook].length; x++) {
|
|
83
73
|
replaceCallbacks.push(obj.callbacks[hook][x]);
|
|
84
74
|
}
|
|
85
|
-
|
|
86
75
|
obj.callbacks[hook] = replaceCallbacks;
|
|
87
76
|
};
|
|
88
77
|
}
|
|
78
|
+
|
|
89
79
|
/**
|
|
90
80
|
* Returns a DOM parser based on current runtime environment.
|
|
91
81
|
*/
|
|
92
|
-
|
|
93
82
|
export function DOMParserFactory() {
|
|
94
83
|
if (window.DOMParser) {
|
|
95
84
|
return new DOMParser();
|
|
@@ -98,26 +87,23 @@ export function DOMParserFactory() {
|
|
|
98
87
|
} else {
|
|
99
88
|
return false;
|
|
100
89
|
}
|
|
101
|
-
}
|
|
90
|
+
}
|
|
102
91
|
|
|
92
|
+
// From https://github.com/linkeddata/dokieli
|
|
103
93
|
export function domToString(node, options) {
|
|
104
94
|
options = options || {};
|
|
105
95
|
var selfClosing = [];
|
|
106
|
-
|
|
107
96
|
if (options && options.selfClosing) {
|
|
108
97
|
options.selfClosing.split(' ').forEach(function (n) {
|
|
109
98
|
selfClosing[n] = true;
|
|
110
99
|
});
|
|
111
100
|
}
|
|
112
|
-
|
|
113
101
|
var skipAttributes = [];
|
|
114
|
-
|
|
115
102
|
if (options && options.skipAttributes) {
|
|
116
103
|
options.skipAttributes.split(' ').forEach(function (n) {
|
|
117
104
|
skipAttributes[n] = true;
|
|
118
105
|
});
|
|
119
106
|
}
|
|
120
|
-
|
|
121
107
|
return dumpNode(node, options, selfClosing, skipAttributes);
|
|
122
108
|
}
|
|
123
109
|
export function dumpNode(node, options, selfClosing, skipAttributes) {
|
|
@@ -125,7 +111,6 @@ export function dumpNode(node, options, selfClosing, skipAttributes) {
|
|
|
125
111
|
var out = '';
|
|
126
112
|
var noEsc = [false];
|
|
127
113
|
if (typeof node.nodeType === 'undefined') return out;
|
|
128
|
-
|
|
129
114
|
if (node.nodeType === 1) {
|
|
130
115
|
if (node.hasAttribute('class') && options && options.classWithChildText && node.matches(options.classWithChildText.class)) {
|
|
131
116
|
out += node.querySelector(options.classWithChildText.element).textContent;
|
|
@@ -133,43 +118,33 @@ export function dumpNode(node, options, selfClosing, skipAttributes) {
|
|
|
133
118
|
var ename = node.nodeName.toLowerCase();
|
|
134
119
|
out += '<' + ename;
|
|
135
120
|
var attrList = [];
|
|
136
|
-
|
|
137
121
|
for (i = node.attributes.length - 1; i >= 0; i--) {
|
|
138
122
|
var atn = node.attributes[i];
|
|
139
123
|
if (skipAttributes && skipAttributes.length > 0 && skipAttributes[atn.name]) continue;
|
|
140
124
|
if (/^\d+$/.test(atn.name)) continue;
|
|
141
|
-
|
|
142
125
|
if (atn.name === 'class' && options && options.replaceClassItemWith && atn.value.split(' ').indexOf(options.replaceClassItemWith.source) > -1) {
|
|
143
126
|
var re = new RegExp(options.replaceClassItemWith.source, 'g');
|
|
144
127
|
atn.value = atn.value.replace(re, options.replaceClassItemWith.target).trim();
|
|
145
128
|
}
|
|
146
|
-
|
|
147
129
|
if (!(atn.name === 'class' && options && options.skipClassWithValue && options.skipClassWithValue === atn.value)) {
|
|
148
130
|
attrList.push(atn.name + '=\'' + atn.value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/'/g, '"') + '\'');
|
|
149
131
|
}
|
|
150
132
|
}
|
|
151
|
-
|
|
152
133
|
if (attrList.length > 0) {
|
|
153
134
|
if (options && options.sortAttributes) {
|
|
154
135
|
attrList.sort(function (a, b) {
|
|
155
136
|
return a.toLowerCase().localeCompare(b.toLowerCase());
|
|
156
137
|
});
|
|
157
138
|
}
|
|
158
|
-
|
|
159
139
|
out += ' ' + attrList.join(' ');
|
|
160
140
|
}
|
|
161
|
-
|
|
162
141
|
if (selfClosing && selfClosing.ename) {
|
|
163
142
|
out += ' />';
|
|
164
143
|
} else {
|
|
165
144
|
out += '>';
|
|
166
145
|
out += ename === 'html' ? '\n ' : '';
|
|
167
146
|
noEsc.push(ename === 'style' || ename === 'script');
|
|
168
|
-
|
|
169
|
-
for (i = 0; i < node.childNodes.length; i++) {
|
|
170
|
-
out += dumpNode(node.childNodes[i]);
|
|
171
|
-
}
|
|
172
|
-
|
|
147
|
+
for (i = 0; i < node.childNodes.length; i++) out += dumpNode(node.childNodes[i]);
|
|
173
148
|
noEsc.pop();
|
|
174
149
|
out += ename === 'body' ? '</' + ename + '>' + '\n' : '</' + ename + '>';
|
|
175
150
|
}
|
|
@@ -185,7 +160,6 @@ export function dumpNode(node, options, selfClosing, skipAttributes) {
|
|
|
185
160
|
console.log('Warning; Cannot handle serialising nodes of type: ' + node.nodeType);
|
|
186
161
|
console.log(node);
|
|
187
162
|
}
|
|
188
|
-
|
|
189
163
|
return out;
|
|
190
164
|
}
|
|
191
165
|
export function dtstamp() {
|
|
@@ -203,15 +177,14 @@ export function dtstamp() {
|
|
|
203
177
|
if (second < 10) second = '0' + second;
|
|
204
178
|
return year + '-' + month + '-' + day + 'T' + hour + ':' + minute + ':' + second + 'Z';
|
|
205
179
|
}
|
|
180
|
+
|
|
206
181
|
/**
|
|
207
182
|
* Compares statements (heavy comparison for repeatable canonical ordering)
|
|
208
183
|
*/
|
|
209
|
-
|
|
210
184
|
export function heavyCompare(x, y, g, uriMap) {
|
|
211
185
|
var nonBlank = function nonBlank(x) {
|
|
212
186
|
return x.termType === 'BlankNode' ? null : x;
|
|
213
187
|
};
|
|
214
|
-
|
|
215
188
|
var signature = function signature(x) {
|
|
216
189
|
var lis = g.statementsMatching(x).map(function (st) {
|
|
217
190
|
return '' + nonBlank(st.subject) + ' ' + nonBlank(st.predicate) + ' ' + nonBlank(st.object);
|
|
@@ -221,12 +194,9 @@ export function heavyCompare(x, y, g, uriMap) {
|
|
|
221
194
|
lis.sort();
|
|
222
195
|
return lis.join('\n');
|
|
223
196
|
};
|
|
224
|
-
|
|
225
197
|
var comparison = Object.prototype.hasOwnProperty.call(g, "compareTerms") ? g.compareTerms(x, y) : x.compareTerm(y);
|
|
226
|
-
|
|
227
198
|
if (x.termType === 'BlankNode' && y.termType === 'BlankNode') {
|
|
228
199
|
if (comparison === 0) return 0; // Same
|
|
229
|
-
|
|
230
200
|
if (signature(x) > signature(y)) return +1;
|
|
231
201
|
if (signature(x) < signature(y)) return -1;
|
|
232
202
|
return comparison; // Too bad -- this order not canonical.
|
|
@@ -235,33 +205,31 @@ export function heavyCompare(x, y, g, uriMap) {
|
|
|
235
205
|
if (uriMap && x.uri && y.uri) {
|
|
236
206
|
return (uriMap[x.uri] || x.uri).localeCompare(uriMap[y.uri] || y.uri);
|
|
237
207
|
}
|
|
238
|
-
|
|
239
208
|
return comparison;
|
|
240
209
|
}
|
|
241
210
|
}
|
|
242
211
|
export function heavyCompareSPO(x, y, g, uriMap) {
|
|
243
212
|
return heavyCompare(x.subject, y.subject, g, uriMap) || heavyCompare(x.predicate, y.predicate, g, uriMap) || heavyCompare(x.object, y.object, g, uriMap);
|
|
244
213
|
}
|
|
214
|
+
|
|
245
215
|
/**
|
|
246
216
|
* Defines a simple debugging function
|
|
247
217
|
* @method output
|
|
248
218
|
* @param o {String}
|
|
249
219
|
*/
|
|
250
|
-
|
|
251
220
|
export function output(o) {
|
|
252
221
|
var k = document.createElement('div');
|
|
253
222
|
k.textContent = o;
|
|
254
223
|
document.body.appendChild(k);
|
|
255
224
|
}
|
|
256
225
|
import { DOMParser } from '@xmldom/xmldom';
|
|
226
|
+
|
|
257
227
|
/**
|
|
258
228
|
* Returns a DOM from parsed XML.
|
|
259
229
|
*/
|
|
260
|
-
|
|
261
230
|
export function parseXML(str, options) {
|
|
262
231
|
var dparser;
|
|
263
232
|
options = options || {};
|
|
264
|
-
|
|
265
233
|
if (typeof module !== 'undefined' && module && module.exports) {
|
|
266
234
|
// Node.js
|
|
267
235
|
var dom = new DOMParser().parseFromString(str, options.contentType || 'application/xhtml+xml');
|
|
@@ -276,10 +244,10 @@ export function parseXML(str, options) {
|
|
|
276
244
|
|
|
277
245
|
return dparser.parseFromString(str, 'application/xml');
|
|
278
246
|
}
|
|
247
|
+
|
|
279
248
|
/**
|
|
280
249
|
* Removes all statements equal to x from a
|
|
281
250
|
*/
|
|
282
|
-
|
|
283
251
|
export function RDFArrayRemove(a, x) {
|
|
284
252
|
for (var i = 0; i < a.length; i++) {
|
|
285
253
|
// TODO: This used to be the following, which didnt always work..why
|
|
@@ -289,60 +257,51 @@ export function RDFArrayRemove(a, x) {
|
|
|
289
257
|
return;
|
|
290
258
|
}
|
|
291
259
|
}
|
|
292
|
-
|
|
293
260
|
throw new Error('RDFArrayRemove: Array did not contain ' + x + ' ' + x.why);
|
|
294
261
|
}
|
|
295
262
|
export function string_startswith(str, pref) {
|
|
296
263
|
// missing library routines
|
|
297
264
|
return str.slice(0, pref.length) === pref;
|
|
298
265
|
}
|
|
266
|
+
|
|
299
267
|
/**
|
|
300
268
|
* C++, python style %s -> subs
|
|
301
269
|
*/
|
|
302
|
-
|
|
303
270
|
function stringTemplate(base, subs) {
|
|
304
271
|
var baseA = base.split('%s');
|
|
305
272
|
var result = '';
|
|
306
|
-
|
|
307
273
|
for (var i = 0; i < subs.length; i++) {
|
|
308
274
|
subs[i] += '';
|
|
309
275
|
result += baseA[i] + subs[i];
|
|
310
276
|
}
|
|
311
|
-
|
|
312
277
|
return result + baseA.slice(subs.length).join();
|
|
313
|
-
}
|
|
278
|
+
}
|
|
314
279
|
|
|
280
|
+
// Stack dump on errors - to pass errors back
|
|
315
281
|
|
|
316
282
|
export function stackString(e) {
|
|
317
283
|
var str = '' + e + '\n';
|
|
318
|
-
|
|
319
284
|
if (!e.stack) {
|
|
320
285
|
return str + 'No stack available.\n';
|
|
321
286
|
}
|
|
322
|
-
|
|
323
287
|
var lines = e.stack.toString().split('\n');
|
|
324
288
|
var toprint = [];
|
|
325
|
-
|
|
326
289
|
for (var i = 0; i < lines.length; i++) {
|
|
327
290
|
var line = lines[i];
|
|
328
|
-
|
|
329
291
|
if (line.indexOf('ecmaunit.js') > -1) {
|
|
330
292
|
// remove useless bit of traceback
|
|
331
293
|
break;
|
|
332
294
|
}
|
|
333
|
-
|
|
334
295
|
if (line.charAt(0) == '(') {
|
|
335
296
|
line = 'function' + line;
|
|
336
297
|
}
|
|
337
|
-
|
|
338
298
|
var chunks = line.split('@');
|
|
339
299
|
toprint.push(chunks);
|
|
340
|
-
}
|
|
341
|
-
|
|
300
|
+
}
|
|
301
|
+
// toprint.reverse(); No - I prefer the latest at the top by the error message -tbl
|
|
342
302
|
|
|
343
303
|
for (var i = 0; i < toprint.length; i++) {
|
|
344
304
|
str += ' ' + toprint[i][1] + '\n ' + toprint[i][0];
|
|
345
305
|
}
|
|
346
|
-
|
|
347
306
|
return str;
|
|
348
307
|
}
|
package/esm/utils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import log from './log';
|
|
2
2
|
import { docpart } from './uri';
|
|
3
3
|
import { string_startswith } from './utils-js';
|
|
4
|
-
|
|
5
4
|
/** RDF/JS spec Typeguards */
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -10,30 +9,28 @@ import { string_startswith } from './utils-js';
|
|
|
10
9
|
*/
|
|
11
10
|
export function AJAR_handleNewTerm(kb, p, requestedBy) {
|
|
12
11
|
var sf = null;
|
|
13
|
-
|
|
14
12
|
if (typeof kb.fetcher !== 'undefined') {
|
|
15
13
|
sf = kb.fetcher;
|
|
16
14
|
} else {
|
|
17
15
|
return;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
if (p.termType !== 'NamedNode') return;
|
|
21
18
|
var docuri = docpart(p.uri);
|
|
22
19
|
var fixuri;
|
|
23
|
-
|
|
24
20
|
if (p.uri.indexOf('#') < 0) {
|
|
25
21
|
// No hash
|
|
26
22
|
// @@ major hack for dbpedia Categories, which spread indefinitely
|
|
27
23
|
if (string_startswith(p.uri, 'http://dbpedia.org/resource/Category:')) return;
|
|
24
|
+
|
|
28
25
|
/*
|
|
29
26
|
if (string_startswith(p.uri, 'http://xmlns.com/foaf/0.1/')) {
|
|
30
27
|
fixuri = "http://dig.csail.mit.edu/2005/ajar/ajaw/test/foaf"
|
|
31
28
|
// should give HTTP 303 to ontology -- now is :-)
|
|
32
29
|
} else
|
|
33
30
|
*/
|
|
34
|
-
|
|
35
31
|
if (string_startswith(p.uri, 'http://purl.org/dc/elements/1.1/') || string_startswith(p.uri, 'http://purl.org/dc/terms/')) {
|
|
36
|
-
fixuri = 'http://dublincore.org/2005/06/13/dcq';
|
|
32
|
+
fixuri = 'http://dublincore.org/2005/06/13/dcq';
|
|
33
|
+
// dc fetched multiple times
|
|
37
34
|
} else if (string_startswith(p.uri, 'http://xmlns.com/wot/0.1/')) {
|
|
38
35
|
fixuri = 'http://xmlns.com/wot/0.1/index.rdf';
|
|
39
36
|
} else if (string_startswith(p.uri, 'http://web.resource.org/cc/')) {
|
|
@@ -41,18 +38,14 @@ export function AJAR_handleNewTerm(kb, p, requestedBy) {
|
|
|
41
38
|
fixuri = 'http://web.resource.org/cc/schema.rdf';
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
|
-
|
|
45
41
|
if (fixuri) {
|
|
46
42
|
docuri = fixuri;
|
|
47
43
|
}
|
|
48
|
-
|
|
49
44
|
if (sf && sf.getState(docuri) !== 'unrequested') return;
|
|
50
|
-
|
|
51
45
|
if (fixuri) {
|
|
52
46
|
// only give warning once: else happens too often
|
|
53
47
|
log.warn('Assuming server still broken, faking redirect of <' + p.uri + '> to <' + docuri + '>');
|
|
54
48
|
}
|
|
55
|
-
|
|
56
49
|
return sf.fetch(docuri, {
|
|
57
50
|
referringTerm: requestedBy
|
|
58
51
|
});
|
|
@@ -63,6 +56,7 @@ var rdf = {
|
|
|
63
56
|
rest: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#rest',
|
|
64
57
|
nil: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'
|
|
65
58
|
};
|
|
59
|
+
|
|
66
60
|
/**
|
|
67
61
|
* Expands an array of Terms to a set of statements representing the rdf:list.
|
|
68
62
|
* @param rdfFactory - The factory to use
|
|
@@ -70,20 +64,17 @@ var rdf = {
|
|
|
70
64
|
* @param data - The terms to expand into the list.
|
|
71
65
|
* @return The {data} as a set of statements.
|
|
72
66
|
*/
|
|
73
|
-
|
|
74
67
|
export function arrayToStatements(rdfFactory, subject, data) {
|
|
75
68
|
var statements = [];
|
|
76
69
|
data.reduce(function (id, _listObj, i, listData) {
|
|
77
70
|
statements.push(rdfFactory.quad(id, rdfFactory.namedNode(rdf.first), listData[i]));
|
|
78
71
|
var nextNode;
|
|
79
|
-
|
|
80
72
|
if (i < listData.length - 1) {
|
|
81
73
|
nextNode = rdfFactory.blankNode();
|
|
82
74
|
statements.push(rdfFactory.quad(id, rdfFactory.namedNode(rdf.rest), nextNode));
|
|
83
75
|
} else {
|
|
84
76
|
statements.push(rdfFactory.quad(id, rdfFactory.namedNode(rdf.rest), rdfFactory.namedNode(rdf.nil)));
|
|
85
77
|
}
|
|
86
|
-
|
|
87
78
|
return nextNode;
|
|
88
79
|
}, subject);
|
|
89
80
|
return statements;
|
|
@@ -92,12 +83,10 @@ export function ArrayIndexOf(arr, item) {
|
|
|
92
83
|
var i = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
93
84
|
var length = arr.length;
|
|
94
85
|
if (i < 0) i = length + i;
|
|
95
|
-
|
|
96
86
|
for (; i < length; i++) {
|
|
97
87
|
if (arr[i] === item) {
|
|
98
88
|
return i;
|
|
99
89
|
}
|
|
100
90
|
}
|
|
101
|
-
|
|
102
91
|
return -1;
|
|
103
92
|
}
|
package/esm/variable.js
CHANGED
|
@@ -5,16 +5,12 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
8
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
|
|
11
9
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
|
|
13
10
|
import ClassOrder from './class-order';
|
|
14
11
|
import Node from './node-internal';
|
|
15
12
|
import { VariableTermType } from './types';
|
|
16
13
|
import * as Uri from './uri';
|
|
17
|
-
|
|
18
14
|
/**
|
|
19
15
|
* Variables are placeholders used in patterns to be matched.
|
|
20
16
|
* In cwm they are symbols which are the formula's list of quantified variables.
|
|
@@ -24,9 +20,7 @@ import * as Uri from './uri';
|
|
|
24
20
|
*/
|
|
25
21
|
var Variable = /*#__PURE__*/function (_Node) {
|
|
26
22
|
_inherits(Variable, _Node);
|
|
27
|
-
|
|
28
23
|
var _super = _createSuper(Variable);
|
|
29
|
-
|
|
30
24
|
/** The base string for a variable's name */
|
|
31
25
|
|
|
32
26
|
/** The unique identifier of this variable */
|
|
@@ -37,35 +31,24 @@ var Variable = /*#__PURE__*/function (_Node) {
|
|
|
37
31
|
*/
|
|
38
32
|
function Variable() {
|
|
39
33
|
var _this;
|
|
40
|
-
|
|
41
34
|
var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
42
|
-
|
|
43
35
|
_classCallCheck(this, Variable);
|
|
44
|
-
|
|
45
36
|
_this = _super.call(this, name);
|
|
46
|
-
|
|
47
37
|
_defineProperty(_assertThisInitialized(_this), "termType", VariableTermType);
|
|
48
|
-
|
|
49
38
|
_defineProperty(_assertThisInitialized(_this), "base", 'varid:');
|
|
50
|
-
|
|
51
39
|
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.Variable);
|
|
52
|
-
|
|
53
40
|
_defineProperty(_assertThisInitialized(_this), "isVar", 1);
|
|
54
|
-
|
|
55
41
|
_defineProperty(_assertThisInitialized(_this), "uri", void 0);
|
|
56
|
-
|
|
57
42
|
_this.base = 'varid:';
|
|
58
43
|
_this.uri = Uri.join(name, _this.base);
|
|
59
44
|
return _this;
|
|
60
45
|
}
|
|
61
|
-
|
|
62
46
|
_createClass(Variable, [{
|
|
63
47
|
key: "equals",
|
|
64
48
|
value: function equals(other) {
|
|
65
49
|
if (!other) {
|
|
66
50
|
return false;
|
|
67
51
|
}
|
|
68
|
-
|
|
69
52
|
return this.termType === other.termType && this.value === other.value;
|
|
70
53
|
}
|
|
71
54
|
}, {
|
|
@@ -90,12 +73,9 @@ var Variable = /*#__PURE__*/function (_Node) {
|
|
|
90
73
|
if (variable.uri.slice(0, variable.base.length) === variable.base) {
|
|
91
74
|
return "?".concat(variable.uri.slice(variable.base.length));
|
|
92
75
|
}
|
|
93
|
-
|
|
94
76
|
return "?".concat(variable.uri);
|
|
95
77
|
}
|
|
96
78
|
}]);
|
|
97
|
-
|
|
98
79
|
return Variable;
|
|
99
80
|
}(Node);
|
|
100
|
-
|
|
101
81
|
export { Variable as default };
|
package/lib/blank-node.js
CHANGED
|
@@ -1,52 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
12
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
13
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
15
|
var _classOrder = _interopRequireDefault(require("./class-order"));
|
|
25
|
-
|
|
26
16
|
var _nodeInternal = _interopRequireDefault(require("./node-internal"));
|
|
27
|
-
|
|
28
17
|
var _types = require("./types");
|
|
29
|
-
|
|
30
18
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
31
|
-
|
|
32
19
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
33
|
-
|
|
34
20
|
/**
|
|
35
21
|
* An RDF blank node is a Node without a URI
|
|
36
22
|
* @link https://rdf.js.org/data-model-spec/#blanknode-interface
|
|
37
23
|
*/
|
|
38
24
|
var BlankNode = /*#__PURE__*/function (_Node) {
|
|
39
25
|
(0, _inherits2.default)(BlankNode, _Node);
|
|
40
|
-
|
|
41
26
|
var _super = _createSuper(BlankNode);
|
|
42
|
-
|
|
43
27
|
/**
|
|
44
28
|
* Initializes this node
|
|
45
29
|
* @param [id] The identifier for the blank node
|
|
46
30
|
*/
|
|
47
31
|
function BlankNode(id) {
|
|
48
32
|
var _this;
|
|
49
|
-
|
|
50
33
|
(0, _classCallCheck2.default)(this, BlankNode);
|
|
51
34
|
_this = _super.call(this, BlankNode.getId(id));
|
|
52
35
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "termType", _types.BlankNodeTermType);
|
|
@@ -55,11 +38,10 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
55
38
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isVar", 1);
|
|
56
39
|
return _this;
|
|
57
40
|
}
|
|
41
|
+
|
|
58
42
|
/**
|
|
59
43
|
* The identifier for the blank node
|
|
60
44
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
45
|
(0, _createClass2.default)(BlankNode, [{
|
|
64
46
|
key: "id",
|
|
65
47
|
get: function get() {
|
|
@@ -74,26 +56,22 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
74
56
|
if (this.classOrder < other.classOrder) {
|
|
75
57
|
return -1;
|
|
76
58
|
}
|
|
77
|
-
|
|
78
59
|
if (this.classOrder > other.classOrder) {
|
|
79
60
|
return +1;
|
|
80
61
|
}
|
|
81
|
-
|
|
82
62
|
if (this.id < other.id) {
|
|
83
63
|
return -1;
|
|
84
64
|
}
|
|
85
|
-
|
|
86
65
|
if (this.id > other.id) {
|
|
87
66
|
return +1;
|
|
88
67
|
}
|
|
89
|
-
|
|
90
68
|
return 0;
|
|
91
69
|
}
|
|
70
|
+
|
|
92
71
|
/**
|
|
93
72
|
* Gets a copy of this blank node in the specified formula
|
|
94
73
|
* @param formula The formula
|
|
95
74
|
*/
|
|
96
|
-
|
|
97
75
|
}, {
|
|
98
76
|
key: "copy",
|
|
99
77
|
value: function copy(formula) {
|
|
@@ -118,28 +96,25 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
118
96
|
/**
|
|
119
97
|
* The next unique identifier for blank nodes
|
|
120
98
|
*/
|
|
99
|
+
|
|
121
100
|
function getId(id) {
|
|
122
101
|
if (id) {
|
|
123
102
|
if (typeof id !== 'string') {
|
|
124
103
|
console.log('Bad blank id:', id);
|
|
125
104
|
throw new Error('Bad id argument to new blank node: ' + id);
|
|
126
105
|
}
|
|
127
|
-
|
|
128
106
|
if (id.includes('#')) {
|
|
129
107
|
// Is a URI with hash fragment
|
|
130
108
|
var fragments = id.split('#');
|
|
131
109
|
return fragments[fragments.length - 1];
|
|
132
110
|
}
|
|
133
|
-
|
|
134
111
|
return id;
|
|
135
112
|
}
|
|
136
|
-
|
|
137
113
|
return 'n' + BlankNode.nextId++;
|
|
138
114
|
}
|
|
139
115
|
}]);
|
|
140
116
|
return BlankNode;
|
|
141
117
|
}(_nodeInternal.default);
|
|
142
|
-
|
|
143
118
|
exports.default = BlankNode;
|
|
144
119
|
(0, _defineProperty2.default)(BlankNode, "nextId", 0);
|
|
145
120
|
(0, _defineProperty2.default)(BlankNode, "NTAnonymousNodePrefix", '_:');
|