rdflib 2.2.21 → 2.2.22
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 +9 -1
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +61 -114
- package/esm/class-order.js +1 -1
- package/esm/collection.js +70 -128
- package/esm/convert.js +1 -2
- package/esm/default-graph.js +14 -48
- package/esm/empty.js +8 -39
- package/esm/factories/canonical-data-factory.js +33 -65
- package/esm/factories/extended-term-factory.js +18 -25
- package/esm/factories/factory-types.js +3 -2
- package/esm/factories/rdflib-data-factory.js +9 -19
- package/esm/fetcher.js +1341 -1854
- package/esm/formula.js +639 -846
- package/esm/index.js +40 -76
- package/esm/jsonldparser.js +24 -49
- package/esm/jsonparser.js +1 -8
- package/esm/lists.js +47 -110
- package/esm/literal.js +120 -189
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1015 -1412
- package/esm/named-node.js +70 -119
- package/esm/namespace.js +2 -5
- package/esm/node-internal.js +73 -110
- package/esm/node.js +2 -7
- package/esm/parse.js +12 -19
- package/esm/patch-parser.js +10 -30
- package/esm/query-to-sparql.js +0 -18
- package/esm/query.js +63 -147
- package/esm/rdfaparser.js +794 -997
- package/esm/rdfxmlparser.js +347 -461
- package/esm/serialize.js +9 -27
- package/esm/serializer.js +820 -1049
- package/esm/sparql-to-query.js +44 -134
- package/esm/statement.js +54 -85
- package/esm/store.js +830 -1103
- package/esm/types.js +22 -21
- package/esm/update-manager.js +869 -1106
- package/esm/updates-via.js +104 -161
- package/esm/uri.js +9 -53
- package/esm/utils/default-graph-uri.js +3 -2
- package/esm/utils/termValue.js +0 -1
- package/esm/utils/terms.js +19 -21
- package/esm/utils-js.js +20 -61
- package/esm/utils.js +10 -21
- package/esm/variable.js +32 -78
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +60 -113
- package/lib/class-order.js +1 -2
- package/lib/collection.js +69 -131
- package/lib/convert.js +3 -9
- package/lib/default-graph.js +13 -52
- package/lib/empty.js +8 -43
- package/lib/factories/canonical-data-factory.js +35 -79
- package/lib/factories/extended-term-factory.js +18 -32
- package/lib/factories/factory-types.d.ts +6 -6
- package/lib/factories/factory-types.js +1 -4
- package/lib/factories/rdflib-data-factory.js +9 -23
- package/lib/fetcher.d.ts +6 -6
- package/lib/fetcher.js +1370 -1843
- package/lib/formula.js +640 -855
- package/lib/index.js +66 -152
- package/lib/jsonldparser.js +23 -53
- package/lib/jsonparser.js +1 -10
- package/lib/lists.js +55 -112
- package/lib/literal.js +120 -195
- package/lib/log.d.ts +0 -6
- package/lib/log.js +7 -8
- package/lib/n3parser.js +1030 -1436
- package/lib/named-node.js +69 -126
- package/lib/namespace.js +2 -7
- package/lib/node-internal.js +74 -107
- package/lib/node.js +2 -12
- package/lib/parse.d.ts +1 -1
- package/lib/parse.js +12 -32
- package/lib/patch-parser.js +11 -34
- package/lib/query-to-sparql.js +0 -23
- package/lib/query.js +62 -167
- package/lib/rdfaparser.js +796 -1009
- package/lib/rdfxmlparser.js +349 -466
- package/lib/serialize.js +11 -37
- package/lib/serializer.js +823 -1064
- package/lib/sparql-to-query.js +42 -167
- package/lib/statement.js +55 -91
- package/lib/store.d.ts +1 -1
- package/lib/store.js +850 -1112
- package/lib/tf-types.d.ts +4 -4
- package/lib/types.d.ts +8 -8
- package/lib/types.js +23 -23
- package/lib/update-manager.d.ts +1 -1
- package/lib/update-manager.js +865 -1103
- package/lib/updates-via.js +105 -164
- package/lib/uri.js +8 -61
- package/lib/utils/default-graph-uri.js +3 -5
- package/lib/utils/termValue.js +0 -2
- package/lib/utils/terms.js +19 -40
- package/lib/utils-js.js +23 -88
- package/lib/utils.js +10 -27
- package/lib/variable.js +34 -85
- package/lib/xsd-internal.js +0 -3
- package/lib/xsd.js +2 -6
- package/package.json +36 -36
- package/src/fetcher.ts +2 -2
- package/src/update-manager.ts +12 -7
- package/changes.txt +0 -59
package/esm/patch-parser.js
CHANGED
|
@@ -13,98 +13,78 @@ export default function sparqlUpdateParser(str, kb, base) {
|
|
|
13
13
|
var SQNS = Namespace('http://www.w3.org/ns/pim/patch#');
|
|
14
14
|
var p = N3Parser(kb, kb, base, base, null, null, '', null);
|
|
15
15
|
var clauses = {};
|
|
16
|
-
|
|
17
|
-
var badSyntax = function badSyntax(uri, lines, str, i, why) {
|
|
16
|
+
var badSyntax = function (uri, lines, str, i, why) {
|
|
18
17
|
return 'Line ' + (lines + 1) + ' of <' + uri + '>: Bad syntax:\n ' + why + '\n at: "' + str.slice(i, i + 30) + '"';
|
|
19
|
-
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// var check = function (next, last, message) {
|
|
20
21
|
// if (next < 0) {
|
|
21
22
|
// throw badSyntax(p._thisDoc, p.lines, str, j, last, message)
|
|
22
23
|
// }
|
|
23
24
|
// return next
|
|
24
25
|
// }
|
|
25
|
-
|
|
26
|
-
|
|
27
26
|
i = 0;
|
|
28
27
|
var query = kb.sym(base + '#query'); // Invent a URI for the query
|
|
29
|
-
|
|
30
28
|
clauses['query'] = query; // A way of accessing it in its N3 model.
|
|
31
29
|
|
|
32
30
|
while (true) {
|
|
33
31
|
// console.log("A Now at i = " + i)
|
|
34
32
|
j = p.skipSpace(str, i);
|
|
35
|
-
|
|
36
33
|
if (j < 0) {
|
|
37
34
|
return clauses;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
}
|
|
36
|
+
// console.log("B After space at j= " + j)
|
|
41
37
|
if (str[j] === ';') {
|
|
42
38
|
i = p.skipSpace(str, j + 1);
|
|
43
|
-
|
|
44
39
|
if (i < 0) {
|
|
45
40
|
return clauses; // Allow end in a
|
|
46
41
|
}
|
|
47
42
|
|
|
48
43
|
j = i;
|
|
49
44
|
}
|
|
50
|
-
|
|
51
45
|
var found = false;
|
|
52
|
-
|
|
53
46
|
for (k = 0; k < keywords.length; k++) {
|
|
54
47
|
var key = keywords[k];
|
|
55
|
-
|
|
56
48
|
if (str.slice(j, j + key.length) === key) {
|
|
57
49
|
i = p.skipSpace(str, j + key.length);
|
|
58
|
-
|
|
59
50
|
if (i < 0) {
|
|
60
51
|
throw badSyntax(p._thisDoc, p.lines, str, j + key.length, 'found EOF, needed {...} after ' + key);
|
|
61
52
|
}
|
|
62
|
-
|
|
63
53
|
if ((key === 'INSERT' || key === 'DELETE') && str.slice(i, i + 4) === 'DATA') {
|
|
64
54
|
// Some wanted 'DATA'. Whatever
|
|
65
55
|
j = p.skipSpace(str, i + 4);
|
|
66
|
-
|
|
67
56
|
if (j < 0) {
|
|
68
57
|
throw badSyntax(p._thisDoc, p.lines, str, i + 4, 'needed {...} after INSERT DATA ' + key);
|
|
69
58
|
}
|
|
70
|
-
|
|
71
59
|
i = j;
|
|
72
60
|
}
|
|
73
|
-
|
|
74
61
|
var res2 = [];
|
|
75
62
|
j = p.node(str, i, res2); // Parse all the complexity of the clause
|
|
76
63
|
|
|
77
64
|
if (j < 0) {
|
|
78
65
|
throw badSyntax(p._thisDoc, p.lines, str, i, 'bad syntax or EOF in {...} after ' + key);
|
|
79
66
|
}
|
|
80
|
-
|
|
81
67
|
clauses[key.toLowerCase()] = res2[0];
|
|
82
68
|
kb.add(query, SQNS(key.toLowerCase()), res2[0]); // , kb.sym(base)
|
|
83
69
|
// key is the keyword and res2 has the contents
|
|
84
|
-
|
|
85
70
|
found = true;
|
|
86
71
|
i = j;
|
|
87
72
|
}
|
|
88
73
|
}
|
|
89
|
-
|
|
90
74
|
if (!found && str.slice(j, j + 7) === '@prefix') {
|
|
91
75
|
i = p.directive(str, j);
|
|
92
|
-
|
|
93
76
|
if (i < 0) {
|
|
94
77
|
throw badSyntax(p._thisDoc, p.lines, str, i, 'bad syntax or EOF after @prefix ');
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
78
|
+
}
|
|
79
|
+
// console.log("P before dot i= " + i)
|
|
80
|
+
i = p.checkDot(str, i);
|
|
81
|
+
// console.log("Q after dot i= " + i)
|
|
100
82
|
found = true;
|
|
101
83
|
}
|
|
102
|
-
|
|
103
84
|
if (!found) {
|
|
104
85
|
// console.log("Bad syntax " + j)
|
|
105
86
|
throw badSyntax(p._thisDoc, p.lines, str, j, "Unknown syntax at start of statememt: '" + str.slice(j).slice(0, 20) + "'");
|
|
106
87
|
}
|
|
107
88
|
} // while
|
|
108
89
|
// return clauses
|
|
109
|
-
|
|
110
90
|
}
|
package/esm/query-to-sparql.js
CHANGED
|
@@ -1,44 +1,33 @@
|
|
|
1
1
|
import log from './log';
|
|
2
2
|
export default function queryToSPARQL(query) {
|
|
3
3
|
var indent = 0;
|
|
4
|
-
|
|
5
4
|
function getSelect(query) {
|
|
6
5
|
var str = addIndent() + 'SELECT ';
|
|
7
|
-
|
|
8
6
|
for (var i = 0; i < query.vars.length; i++) {
|
|
9
7
|
str += query.vars[i] + ' ';
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
str += '\n';
|
|
13
10
|
return str;
|
|
14
11
|
}
|
|
15
|
-
|
|
16
12
|
function getPattern(pat) {
|
|
17
13
|
var str = '';
|
|
18
14
|
var st = pat.statements;
|
|
19
|
-
|
|
20
15
|
for (var x in st) {
|
|
21
16
|
log.debug('Found statement: ' + st);
|
|
22
17
|
str += addIndent() + st[x] + '\n';
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
return str;
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
function getConstraints(pat) {
|
|
29
22
|
var str = '';
|
|
30
|
-
|
|
31
23
|
for (var v in pat.constraints) {
|
|
32
24
|
var foo = pat.constraints[v];
|
|
33
25
|
str += addIndent() + 'FILTER ( ' + foo.describe(v) + ' ) ' + '\n';
|
|
34
26
|
}
|
|
35
|
-
|
|
36
27
|
return str;
|
|
37
28
|
}
|
|
38
|
-
|
|
39
29
|
function getOptionals(pat) {
|
|
40
30
|
var str = '';
|
|
41
|
-
|
|
42
31
|
for (var x = 0; x < pat.optional.length; x++) {
|
|
43
32
|
// alert(pat.optional.termType)
|
|
44
33
|
log.debug('Found optional query');
|
|
@@ -50,10 +39,8 @@ export default function queryToSPARQL(query) {
|
|
|
50
39
|
indent--;
|
|
51
40
|
str += addIndent() + '}' + '\n';
|
|
52
41
|
}
|
|
53
|
-
|
|
54
42
|
return str;
|
|
55
43
|
}
|
|
56
|
-
|
|
57
44
|
function getWhere(pat) {
|
|
58
45
|
var str = addIndent() + 'WHERE \n' + '{ \n';
|
|
59
46
|
indent++;
|
|
@@ -64,20 +51,15 @@ export default function queryToSPARQL(query) {
|
|
|
64
51
|
str += '}';
|
|
65
52
|
return str;
|
|
66
53
|
}
|
|
67
|
-
|
|
68
54
|
function addIndent() {
|
|
69
55
|
var str = '';
|
|
70
|
-
|
|
71
56
|
for (var i = 0; i < indent; i++) {
|
|
72
57
|
str += ' ';
|
|
73
58
|
}
|
|
74
|
-
|
|
75
59
|
return str;
|
|
76
60
|
}
|
|
77
|
-
|
|
78
61
|
function getSPARQL(query) {
|
|
79
62
|
return getSelect(query) + getWhere(query.pat);
|
|
80
63
|
}
|
|
81
|
-
|
|
82
64
|
return getSPARQL(query);
|
|
83
65
|
}
|