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/lib/patch-parser.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
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 = sparqlUpdateParser;
|
|
9
|
-
|
|
10
8
|
var _n3parser = _interopRequireDefault(require("./n3parser"));
|
|
11
|
-
|
|
12
9
|
var _namespace = _interopRequireDefault(require("./namespace"));
|
|
13
|
-
|
|
14
10
|
// Parse a simple SPARL-Update subset syntax for patches.
|
|
15
11
|
//
|
|
16
12
|
// This parses
|
|
@@ -18,104 +14,85 @@ var _namespace = _interopRequireDefault(require("./namespace"));
|
|
|
18
14
|
// (not necessarily in that order)
|
|
19
15
|
// as though it were the n3
|
|
20
16
|
// <#query> patch:where {xxx}; patch:delete {yyy}; patch:insert {zzz}.
|
|
17
|
+
|
|
21
18
|
function sparqlUpdateParser(str, kb, base) {
|
|
22
19
|
var i, j, k;
|
|
23
20
|
var keywords = ['INSERT', 'DELETE', 'WHERE'];
|
|
24
21
|
var SQNS = (0, _namespace.default)('http://www.w3.org/ns/pim/patch#');
|
|
25
22
|
var p = (0, _n3parser.default)(kb, kb, base, base, null, null, '', null);
|
|
26
23
|
var clauses = {};
|
|
27
|
-
|
|
28
|
-
var badSyntax = function badSyntax(uri, lines, str, i, why) {
|
|
24
|
+
var badSyntax = function (uri, lines, str, i, why) {
|
|
29
25
|
return 'Line ' + (lines + 1) + ' of <' + uri + '>: Bad syntax:\n ' + why + '\n at: "' + str.slice(i, i + 30) + '"';
|
|
30
|
-
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// var check = function (next, last, message) {
|
|
31
29
|
// if (next < 0) {
|
|
32
30
|
// throw badSyntax(p._thisDoc, p.lines, str, j, last, message)
|
|
33
31
|
// }
|
|
34
32
|
// return next
|
|
35
33
|
// }
|
|
36
|
-
|
|
37
|
-
|
|
38
34
|
i = 0;
|
|
39
35
|
var query = kb.sym(base + '#query'); // Invent a URI for the query
|
|
40
|
-
|
|
41
36
|
clauses['query'] = query; // A way of accessing it in its N3 model.
|
|
42
37
|
|
|
43
38
|
while (true) {
|
|
44
39
|
// console.log("A Now at i = " + i)
|
|
45
40
|
j = p.skipSpace(str, i);
|
|
46
|
-
|
|
47
41
|
if (j < 0) {
|
|
48
42
|
return clauses;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
}
|
|
44
|
+
// console.log("B After space at j= " + j)
|
|
52
45
|
if (str[j] === ';') {
|
|
53
46
|
i = p.skipSpace(str, j + 1);
|
|
54
|
-
|
|
55
47
|
if (i < 0) {
|
|
56
48
|
return clauses; // Allow end in a
|
|
57
49
|
}
|
|
58
50
|
|
|
59
51
|
j = i;
|
|
60
52
|
}
|
|
61
|
-
|
|
62
53
|
var found = false;
|
|
63
|
-
|
|
64
54
|
for (k = 0; k < keywords.length; k++) {
|
|
65
55
|
var key = keywords[k];
|
|
66
|
-
|
|
67
56
|
if (str.slice(j, j + key.length) === key) {
|
|
68
57
|
i = p.skipSpace(str, j + key.length);
|
|
69
|
-
|
|
70
58
|
if (i < 0) {
|
|
71
59
|
throw badSyntax(p._thisDoc, p.lines, str, j + key.length, 'found EOF, needed {...} after ' + key);
|
|
72
60
|
}
|
|
73
|
-
|
|
74
61
|
if ((key === 'INSERT' || key === 'DELETE') && str.slice(i, i + 4) === 'DATA') {
|
|
75
62
|
// Some wanted 'DATA'. Whatever
|
|
76
63
|
j = p.skipSpace(str, i + 4);
|
|
77
|
-
|
|
78
64
|
if (j < 0) {
|
|
79
65
|
throw badSyntax(p._thisDoc, p.lines, str, i + 4, 'needed {...} after INSERT DATA ' + key);
|
|
80
66
|
}
|
|
81
|
-
|
|
82
67
|
i = j;
|
|
83
68
|
}
|
|
84
|
-
|
|
85
69
|
var res2 = [];
|
|
86
70
|
j = p.node(str, i, res2); // Parse all the complexity of the clause
|
|
87
71
|
|
|
88
72
|
if (j < 0) {
|
|
89
73
|
throw badSyntax(p._thisDoc, p.lines, str, i, 'bad syntax or EOF in {...} after ' + key);
|
|
90
74
|
}
|
|
91
|
-
|
|
92
75
|
clauses[key.toLowerCase()] = res2[0];
|
|
93
76
|
kb.add(query, SQNS(key.toLowerCase()), res2[0]); // , kb.sym(base)
|
|
94
77
|
// key is the keyword and res2 has the contents
|
|
95
|
-
|
|
96
78
|
found = true;
|
|
97
79
|
i = j;
|
|
98
80
|
}
|
|
99
81
|
}
|
|
100
|
-
|
|
101
82
|
if (!found && str.slice(j, j + 7) === '@prefix') {
|
|
102
83
|
i = p.directive(str, j);
|
|
103
|
-
|
|
104
84
|
if (i < 0) {
|
|
105
85
|
throw badSyntax(p._thisDoc, p.lines, str, i, 'bad syntax or EOF after @prefix ');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
86
|
+
}
|
|
87
|
+
// console.log("P before dot i= " + i)
|
|
88
|
+
i = p.checkDot(str, i);
|
|
89
|
+
// console.log("Q after dot i= " + i)
|
|
111
90
|
found = true;
|
|
112
91
|
}
|
|
113
|
-
|
|
114
92
|
if (!found) {
|
|
115
93
|
// console.log("Bad syntax " + j)
|
|
116
94
|
throw badSyntax(p._thisDoc, p.lines, str, j, "Unknown syntax at start of statememt: '" + str.slice(j).slice(0, 20) + "'");
|
|
117
95
|
}
|
|
118
96
|
} // while
|
|
119
97
|
// return clauses
|
|
120
|
-
|
|
121
98
|
}
|
package/lib/query-to-sparql.js
CHANGED
|
@@ -1,59 +1,43 @@
|
|
|
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 = queryToSPARQL;
|
|
9
|
-
|
|
10
8
|
var _log = _interopRequireDefault(require("./log"));
|
|
11
|
-
|
|
12
9
|
function queryToSPARQL(query) {
|
|
13
10
|
var indent = 0;
|
|
14
|
-
|
|
15
11
|
function getSelect(query) {
|
|
16
12
|
var str = addIndent() + 'SELECT ';
|
|
17
|
-
|
|
18
13
|
for (var i = 0; i < query.vars.length; i++) {
|
|
19
14
|
str += query.vars[i] + ' ';
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
str += '\n';
|
|
23
17
|
return str;
|
|
24
18
|
}
|
|
25
|
-
|
|
26
19
|
function getPattern(pat) {
|
|
27
20
|
var str = '';
|
|
28
21
|
var st = pat.statements;
|
|
29
|
-
|
|
30
22
|
for (var x in st) {
|
|
31
23
|
_log.default.debug('Found statement: ' + st);
|
|
32
|
-
|
|
33
24
|
str += addIndent() + st[x] + '\n';
|
|
34
25
|
}
|
|
35
|
-
|
|
36
26
|
return str;
|
|
37
27
|
}
|
|
38
|
-
|
|
39
28
|
function getConstraints(pat) {
|
|
40
29
|
var str = '';
|
|
41
|
-
|
|
42
30
|
for (var v in pat.constraints) {
|
|
43
31
|
var foo = pat.constraints[v];
|
|
44
32
|
str += addIndent() + 'FILTER ( ' + foo.describe(v) + ' ) ' + '\n';
|
|
45
33
|
}
|
|
46
|
-
|
|
47
34
|
return str;
|
|
48
35
|
}
|
|
49
|
-
|
|
50
36
|
function getOptionals(pat) {
|
|
51
37
|
var str = '';
|
|
52
|
-
|
|
53
38
|
for (var x = 0; x < pat.optional.length; x++) {
|
|
54
39
|
// alert(pat.optional.termType)
|
|
55
40
|
_log.default.debug('Found optional query');
|
|
56
|
-
|
|
57
41
|
str += addIndent() + 'OPTIONAL { ' + '\n';
|
|
58
42
|
indent++;
|
|
59
43
|
str += getPattern(pat.optional[x]);
|
|
@@ -62,10 +46,8 @@ function queryToSPARQL(query) {
|
|
|
62
46
|
indent--;
|
|
63
47
|
str += addIndent() + '}' + '\n';
|
|
64
48
|
}
|
|
65
|
-
|
|
66
49
|
return str;
|
|
67
50
|
}
|
|
68
|
-
|
|
69
51
|
function getWhere(pat) {
|
|
70
52
|
var str = addIndent() + 'WHERE \n' + '{ \n';
|
|
71
53
|
indent++;
|
|
@@ -76,20 +58,15 @@ function queryToSPARQL(query) {
|
|
|
76
58
|
str += '}';
|
|
77
59
|
return str;
|
|
78
60
|
}
|
|
79
|
-
|
|
80
61
|
function addIndent() {
|
|
81
62
|
var str = '';
|
|
82
|
-
|
|
83
63
|
for (var i = 0; i < indent; i++) {
|
|
84
64
|
str += ' ';
|
|
85
65
|
}
|
|
86
|
-
|
|
87
66
|
return str;
|
|
88
67
|
}
|
|
89
|
-
|
|
90
68
|
function getSPARQL(query) {
|
|
91
69
|
return getSelect(query) + getWhere(query.pat);
|
|
92
70
|
}
|
|
93
|
-
|
|
94
71
|
return getSPARQL(query);
|
|
95
72
|
}
|