rdflib 2.2.35 → 2.2.36
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 +0 -2
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +57 -82
- package/esm/class-order.js +1 -1
- package/esm/collection.js +70 -103
- package/esm/default-graph.js +13 -30
- package/esm/empty.js +8 -23
- package/esm/factories/canonical-data-factory.js +33 -29
- package/esm/factories/extended-term-factory.js +18 -13
- package/esm/factories/factory-types.js +1 -1
- package/esm/factories/rdflib-data-factory.js +9 -11
- package/esm/fetcher.js +1366 -1651
- package/esm/formula.js +631 -736
- package/esm/index.js +31 -48
- package/esm/jsonldparser.js +19 -26
- package/esm/jsonparser.js +1 -1
- package/esm/lists.js +38 -86
- package/esm/literal.js +120 -154
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1009 -1086
- package/esm/named-node.js +69 -96
- package/esm/namespace.js +2 -4
- package/esm/node-internal.js +73 -96
- package/esm/node.js +1 -1
- package/esm/parse.js +3 -3
- package/esm/patch-parser.js +1 -1
- package/esm/query.js +15 -16
- package/esm/rdfaparser.js +775 -841
- package/esm/rdfxmlparser.js +348 -364
- package/esm/serialize.js +2 -2
- package/esm/serializer.js +835 -877
- package/esm/statement.js +52 -71
- package/esm/store.js +853 -957
- package/esm/types.js +21 -21
- package/esm/update-manager.js +965 -1100
- package/esm/updates-via.js +104 -132
- package/esm/uri.js +3 -3
- package/esm/utils/default-graph-uri.js +2 -2
- package/esm/utils/terms.js +4 -5
- package/esm/utils-js.js +5 -5
- package/esm/utils.js +6 -6
- package/esm/variable.js +32 -55
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +57 -80
- package/lib/class-order.js +1 -1
- package/lib/collection.js +70 -101
- package/lib/default-graph.js +14 -29
- package/lib/empty.js +9 -22
- package/lib/factories/canonical-data-factory.js +35 -31
- package/lib/factories/extended-term-factory.js +18 -13
- package/lib/factories/factory-types.js +1 -1
- package/lib/factories/rdflib-data-factory.js +9 -11
- package/lib/fetcher.js +1375 -1654
- package/lib/formula.js +632 -735
- package/lib/index.js +80 -84
- package/lib/jsonldparser.js +21 -32
- package/lib/jsonparser.js +1 -1
- package/lib/lists.js +47 -87
- package/lib/literal.js +121 -153
- package/lib/log.js +7 -7
- package/lib/n3parser.js +1012 -1090
- package/lib/named-node.js +70 -95
- package/lib/namespace.js +2 -4
- package/lib/node-internal.js +73 -94
- package/lib/node.js +1 -1
- package/lib/parse.js +5 -6
- package/lib/patch-parser.js +1 -1
- package/lib/query.js +20 -18
- package/lib/rdfaparser.js +778 -843
- package/lib/rdfxmlparser.js +351 -365
- package/lib/serialize.js +2 -2
- package/lib/serializer.js +840 -880
- package/lib/statement.js +55 -73
- package/lib/store.js +860 -958
- package/lib/types.js +21 -21
- package/lib/update-manager.js +970 -1102
- package/lib/updates-via.js +107 -132
- package/lib/uri.js +3 -3
- package/lib/utils/default-graph-uri.js +2 -2
- package/lib/utils/terms.js +4 -6
- package/lib/utils-js.js +8 -9
- package/lib/utils.js +6 -6
- package/lib/variable.js +35 -57
- package/lib/xsd.js +2 -2
- package/package.json +2 -2
- package/src/n3parser.js +1 -1
- package/src/serializer.js +1 -1
- package/src/update-manager.ts +2 -1
- package/.babelrc +0 -20
package/lib/named-node.js
CHANGED
|
@@ -5,133 +5,108 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
11
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
12
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
9
|
var _classOrder = _interopRequireDefault(require("./class-order"));
|
|
15
10
|
var _nodeInternal = _interopRequireDefault(require("./node-internal"));
|
|
16
11
|
var _types = require("./types");
|
|
17
12
|
var _termValue = require("./utils/termValue");
|
|
18
13
|
var _terms = require("./utils/terms");
|
|
19
|
-
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
20
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
21
14
|
/**
|
|
22
15
|
* A named (IRI) RDF node
|
|
23
16
|
*/
|
|
24
|
-
|
|
17
|
+
class NamedNode extends _nodeInternal.default {
|
|
25
18
|
/**
|
|
26
19
|
* Create a named (IRI) RDF Node
|
|
27
20
|
* @constructor
|
|
28
21
|
* @param iri - The IRI for this node
|
|
29
22
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
(0,
|
|
33
|
-
|
|
34
|
-
(
|
|
35
|
-
(0, _defineProperty2.default)(_this, "classOrder", _classOrder.default.NamedNode);
|
|
36
|
-
if (!_this.value) {
|
|
23
|
+
constructor(iri) {
|
|
24
|
+
super((0, _termValue.termValue)(iri));
|
|
25
|
+
(0, _defineProperty2.default)(this, "termType", _types.NamedNodeTermType);
|
|
26
|
+
(0, _defineProperty2.default)(this, "classOrder", _classOrder.default.NamedNode);
|
|
27
|
+
if (!this.value) {
|
|
37
28
|
throw new Error('Missing IRI for NamedNode');
|
|
38
29
|
}
|
|
39
|
-
if (!
|
|
30
|
+
if (!this.value.includes(':')) {
|
|
40
31
|
throw new Error('NamedNode IRI "' + iri + '" must be absolute.');
|
|
41
32
|
}
|
|
42
|
-
if (
|
|
33
|
+
if (this.value.includes(' ')) {
|
|
43
34
|
var message = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.';
|
|
44
35
|
throw new Error(message);
|
|
45
36
|
}
|
|
46
|
-
return _this;
|
|
47
37
|
}
|
|
48
38
|
|
|
49
39
|
/**
|
|
50
40
|
* Returns an $rdf node for the containing directory, ending in slash.
|
|
51
41
|
*/
|
|
52
|
-
(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (q >= 0 && p < q + 2 || p < 0) return null;
|
|
60
|
-
return new NamedNode(str.slice(0, p + 1));
|
|
61
|
-
}
|
|
42
|
+
dir() {
|
|
43
|
+
var str = this.value.split('#')[0];
|
|
44
|
+
var p = str.slice(0, -1).lastIndexOf('/');
|
|
45
|
+
var q = str.indexOf('//');
|
|
46
|
+
if (q >= 0 && p < q + 2 || p < 0) return null;
|
|
47
|
+
return new NamedNode(str.slice(0, p + 1));
|
|
48
|
+
}
|
|
62
49
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} else {
|
|
77
|
-
return new NamedNode(str.slice(0, q + 1));
|
|
78
|
-
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns an NN for the whole web site, ending in slash.
|
|
52
|
+
* Contrast with the "origin" which does NOT have a trailing slash
|
|
53
|
+
*/
|
|
54
|
+
site() {
|
|
55
|
+
var str = this.value.split('#')[0];
|
|
56
|
+
var p = str.indexOf('//');
|
|
57
|
+
if (p < 0) throw new Error('This URI does not have a web site part (origin)');
|
|
58
|
+
var q = str.indexOf('/', p + 2);
|
|
59
|
+
if (q < 0) {
|
|
60
|
+
return new NamedNode(str.slice(0) + '/'); // Add slash to a bare origin
|
|
61
|
+
} else {
|
|
62
|
+
return new NamedNode(str.slice(0, q + 1));
|
|
79
63
|
}
|
|
64
|
+
}
|
|
80
65
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
} else {
|
|
91
|
-
return new NamedNode(this.value.split('#')[0]);
|
|
92
|
-
}
|
|
66
|
+
/**
|
|
67
|
+
* Creates the fetchable named node for the document.
|
|
68
|
+
* Removes everything from the # anchor tag.
|
|
69
|
+
*/
|
|
70
|
+
doc() {
|
|
71
|
+
if (this.value.indexOf('#') < 0) {
|
|
72
|
+
return this;
|
|
73
|
+
} else {
|
|
74
|
+
return new NamedNode(this.value.split('#')[0]);
|
|
93
75
|
}
|
|
76
|
+
}
|
|
94
77
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return '<' + this.value + '>';
|
|
102
|
-
}
|
|
78
|
+
/**
|
|
79
|
+
* Returns the URI including <brackets>
|
|
80
|
+
*/
|
|
81
|
+
toString() {
|
|
82
|
+
return '<' + this.value + '>';
|
|
83
|
+
}
|
|
103
84
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
return this.value.split('#')[1];
|
|
109
|
-
}
|
|
85
|
+
/** The local identifier with the document */
|
|
86
|
+
id() {
|
|
87
|
+
return this.value.split('#')[1];
|
|
88
|
+
}
|
|
110
89
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
this.value = uri;
|
|
119
|
-
}
|
|
90
|
+
/** Alias for value, favored by Tim */
|
|
91
|
+
get uri() {
|
|
92
|
+
return this.value;
|
|
93
|
+
}
|
|
94
|
+
set uri(uri) {
|
|
95
|
+
this.value = uri;
|
|
96
|
+
}
|
|
120
97
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (typeof value === 'undefined' || value === null) {
|
|
129
|
-
return value;
|
|
130
|
-
}
|
|
131
|
-
if ((0, _terms.isTerm)(value)) {
|
|
132
|
-
return value;
|
|
133
|
-
}
|
|
134
|
-
return new NamedNode(value);
|
|
98
|
+
/**
|
|
99
|
+
* Creates a named node from the specified input value
|
|
100
|
+
* @param value - An input value
|
|
101
|
+
*/
|
|
102
|
+
static fromValue(value) {
|
|
103
|
+
if (typeof value === 'undefined' || value === null) {
|
|
104
|
+
return value;
|
|
135
105
|
}
|
|
136
|
-
|
|
137
|
-
|
|
106
|
+
if ((0, _terms.isTerm)(value)) {
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
return new NamedNode(value);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.default = NamedNode;
|
package/lib/namespace.js
CHANGED
|
@@ -12,10 +12,8 @@ var _namedNode = _interopRequireDefault(require("./named-node"));
|
|
|
12
12
|
* @param [factory] - The factory for creating named nodes with
|
|
13
13
|
*/
|
|
14
14
|
function Namespace(nsuri, factory) {
|
|
15
|
-
|
|
16
|
-
namedNode:
|
|
17
|
-
return new _namedNode.default(value);
|
|
18
|
-
}
|
|
15
|
+
const dataFactory = factory || {
|
|
16
|
+
namedNode: value => new _namedNode.default(value)
|
|
19
17
|
};
|
|
20
18
|
return function (ln) {
|
|
21
19
|
return dataFactory.namedNode(nsuri + (ln || ''));
|
package/lib/node-internal.js
CHANGED
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
9
|
/**
|
|
12
10
|
* The superclass of all RDF Statement objects, that is
|
|
@@ -16,9 +14,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
16
14
|
* @link https://rdf.js.org/data-model-spec/#term-interface
|
|
17
15
|
* @class Node
|
|
18
16
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
(0, _classCallCheck2.default)(this, Node);
|
|
17
|
+
class Node {
|
|
18
|
+
constructor(value) {
|
|
22
19
|
/** The type of node */
|
|
23
20
|
(0, _defineProperty2.default)(this, "termType", void 0);
|
|
24
21
|
/** The class order for this node */
|
|
@@ -32,105 +29,87 @@ var Node = exports.default = /*#__PURE__*/function () {
|
|
|
32
29
|
* Creates the substituted node for this one, according to the specified bindings
|
|
33
30
|
* @param bindings - Bindings of identifiers to nodes
|
|
34
31
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
32
|
+
substitute(bindings) {
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
40
35
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (this.classOrder < other.classOrder) {
|
|
50
|
-
return -1;
|
|
51
|
-
}
|
|
52
|
-
if (this.classOrder > other.classOrder) {
|
|
53
|
-
return +1;
|
|
54
|
-
}
|
|
55
|
-
if (this.value < other.value) {
|
|
56
|
-
return -1;
|
|
57
|
-
}
|
|
58
|
-
if (this.value > other.value) {
|
|
59
|
-
return +1;
|
|
60
|
-
}
|
|
61
|
-
return 0;
|
|
36
|
+
/**
|
|
37
|
+
* Compares this node with another
|
|
38
|
+
* @see {equals} to check if two nodes are equal
|
|
39
|
+
* @param other - The other node
|
|
40
|
+
*/
|
|
41
|
+
compareTerm(other) {
|
|
42
|
+
if (this.classOrder < other.classOrder) {
|
|
43
|
+
return -1;
|
|
62
44
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* Compares whether the two nodes are equal
|
|
66
|
-
* @param other The other node
|
|
67
|
-
*/
|
|
68
|
-
}, {
|
|
69
|
-
key: "equals",
|
|
70
|
-
value: function equals(other) {
|
|
71
|
-
if (!other) {
|
|
72
|
-
return false;
|
|
73
|
-
}
|
|
74
|
-
return this.termType === other.termType && this.value === other.value;
|
|
45
|
+
if (this.classOrder > other.classOrder) {
|
|
46
|
+
return +1;
|
|
75
47
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
* Creates a hash for this node
|
|
79
|
-
* @deprecated use {rdfFactory.id} instead if possible
|
|
80
|
-
*/
|
|
81
|
-
}, {
|
|
82
|
-
key: "hashString",
|
|
83
|
-
value: function hashString() {
|
|
84
|
-
return this.toCanonical();
|
|
48
|
+
if (this.value < other.value) {
|
|
49
|
+
return -1;
|
|
85
50
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* Compares whether this node is the same as the other one
|
|
89
|
-
* @param other - Another node
|
|
90
|
-
*/
|
|
91
|
-
}, {
|
|
92
|
-
key: "sameTerm",
|
|
93
|
-
value: function sameTerm(other) {
|
|
94
|
-
return this.equals(other);
|
|
51
|
+
if (this.value > other.value) {
|
|
52
|
+
return +1;
|
|
95
53
|
}
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
96
56
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return
|
|
57
|
+
/**
|
|
58
|
+
* Compares whether the two nodes are equal
|
|
59
|
+
* @param other The other node
|
|
60
|
+
*/
|
|
61
|
+
equals(other) {
|
|
62
|
+
if (!other) {
|
|
63
|
+
return false;
|
|
104
64
|
}
|
|
65
|
+
return this.termType === other.termType && this.value === other.value;
|
|
66
|
+
}
|
|
105
67
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a hash for this node
|
|
70
|
+
* @deprecated use {rdfFactory.id} instead if possible
|
|
71
|
+
*/
|
|
72
|
+
hashString() {
|
|
73
|
+
return this.toCanonical();
|
|
74
|
+
}
|
|
114
75
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
76
|
+
/**
|
|
77
|
+
* Compares whether this node is the same as the other one
|
|
78
|
+
* @param other - Another node
|
|
79
|
+
*/
|
|
80
|
+
sameTerm(other) {
|
|
81
|
+
return this.equals(other);
|
|
82
|
+
}
|
|
123
83
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Creates a canonical string representation of this node
|
|
86
|
+
*/
|
|
87
|
+
toCanonical() {
|
|
88
|
+
return this.toNT();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Creates a n-triples string representation of this node
|
|
93
|
+
*/
|
|
94
|
+
toNT() {
|
|
95
|
+
return this.toString();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Creates a n-quads string representation of this node
|
|
100
|
+
*/
|
|
101
|
+
toNQ() {
|
|
102
|
+
return this.toNT();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Creates a string representation of this node
|
|
107
|
+
*/
|
|
108
|
+
toString() {
|
|
109
|
+
throw new Error('Node.toString() is abstract - see the subclasses instead');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
exports.default = Node;
|
|
134
113
|
// Specified in './node.ts' to prevent circular dependency
|
|
135
114
|
(0, _defineProperty2.default)(Node, "fromValue", void 0);
|
|
136
115
|
// Specified in './node.ts' to prevent circular dependency
|
package/lib/node.js
CHANGED
|
@@ -22,7 +22,7 @@ var _terms = require("./utils/terms");
|
|
|
22
22
|
*/
|
|
23
23
|
_nodeInternal.default.fromValue = _collection.fromValue;
|
|
24
24
|
var _default = exports.default = _nodeInternal.default;
|
|
25
|
-
|
|
25
|
+
const ns = {
|
|
26
26
|
xsd: (0, _namespace.default)('http://www.w3.org/2001/XMLSchema#')
|
|
27
27
|
};
|
|
28
28
|
|
package/lib/parse.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -15,8 +14,8 @@ var _rdfxmlparser = _interopRequireDefault(require("./rdfxmlparser"));
|
|
|
15
14
|
var _patchParser = _interopRequireDefault(require("./patch-parser"));
|
|
16
15
|
var Util = _interopRequireWildcard(require("./utils-js"));
|
|
17
16
|
var _types = require("./types");
|
|
18
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function
|
|
19
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" !=
|
|
17
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
18
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
19
|
// @ts-ignore is this injected?
|
|
21
20
|
// @@ Goal: remove this dependency
|
|
22
21
|
|
|
@@ -32,8 +31,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
32
31
|
* @param [callback] - The callback to call when the data has been loaded
|
|
33
32
|
*/
|
|
34
33
|
function parse(str, kb, base) {
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
let contentType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'text/turtle';
|
|
35
|
+
let callback = arguments.length > 4 ? arguments[4] : undefined;
|
|
37
36
|
contentType = contentType || _types.TurtleContentType;
|
|
38
37
|
contentType = contentType.split(';')[0];
|
|
39
38
|
try {
|
|
@@ -105,7 +104,7 @@ function parse(str, kb, base) {
|
|
|
105
104
|
if (callback) {
|
|
106
105
|
callback(e, kb);
|
|
107
106
|
} else {
|
|
108
|
-
|
|
107
|
+
let e2 = new Error('' + e + ' while trying to parse <' + base + '> as ' + contentType);
|
|
109
108
|
//@ts-ignore .cause is not a default error property
|
|
110
109
|
e2.cause = e;
|
|
111
110
|
throw e2;
|
package/lib/patch-parser.js
CHANGED
|
@@ -21,7 +21,7 @@ function sparqlUpdateParser(str, kb, base) {
|
|
|
21
21
|
var SQNS = (0, _namespace.default)('http://www.w3.org/ns/pim/patch#');
|
|
22
22
|
var p = (0, _n3parser.default)(kb, kb, base, base, null, null, '', null);
|
|
23
23
|
var clauses = {};
|
|
24
|
-
var badSyntax = function
|
|
24
|
+
var badSyntax = function (uri, lines, str, i, why) {
|
|
25
25
|
return 'Line ' + (lines + 1) + ' of <' + uri + '>: Bad syntax:\n ' + why + '\n at: "' + str.slice(i, i + 30) + '"';
|
|
26
26
|
};
|
|
27
27
|
|
package/lib/query.js
CHANGED
|
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.Query = void 0;
|
|
8
8
|
exports.indexedFormulaQuery = indexedFormulaQuery;
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
9
|
var _store = _interopRequireDefault(require("./store"));
|
|
12
10
|
var _defaultGraphUri = require("./utils/default-graph-uri");
|
|
13
11
|
var _log = _interopRequireDefault(require("./log"));
|
|
@@ -23,24 +21,27 @@ var _uri = require("./uri");
|
|
|
23
21
|
// Here we introduce for the first time a subclass of term: variable.
|
|
24
22
|
//
|
|
25
23
|
// SVN ID: $Id: query.js 25116 2008-11-15 16:13:48Z timbl $
|
|
24
|
+
|
|
26
25
|
// Variable
|
|
27
26
|
//
|
|
28
27
|
// Compare with BlankNode. They are similar, but a variable
|
|
29
28
|
// stands for something whose value is to be returned.
|
|
30
29
|
// Also, users name variables and want the same name back when stuff is printed
|
|
31
|
-
/* jsl:option explicit */
|
|
32
|
-
|
|
30
|
+
/* jsl:option explicit */ // Turn on JavaScriptLint variable declaration checking
|
|
31
|
+
|
|
33
32
|
/**
|
|
34
33
|
* Query class, for tracking queries the user has in the UI.
|
|
35
34
|
*/
|
|
36
|
-
|
|
37
|
-
(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
35
|
+
class Query {
|
|
36
|
+
constructor(name, id) {
|
|
37
|
+
this.pat = new _store.default(); // The pattern to search for
|
|
38
|
+
this.vars = []; // Used by UI code but not in query.js
|
|
39
|
+
// this.orderBy = [] // Not used yet
|
|
40
|
+
this.name = name;
|
|
41
|
+
this.id = id;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
44
45
|
/**
|
|
45
46
|
* This function will match a pattern to the current Store
|
|
46
47
|
*
|
|
@@ -56,6 +57,7 @@ var Query = exports.Query = /*#__PURE__*/(0, _createClass2.default)(function Que
|
|
|
56
57
|
* which has been created for the quadstore being queried.
|
|
57
58
|
* @param onDone - callback when query finished
|
|
58
59
|
*/
|
|
60
|
+
exports.Query = Query;
|
|
59
61
|
function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
60
62
|
/** Debug strings
|
|
61
63
|
*/
|
|
@@ -263,7 +265,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
263
265
|
};
|
|
264
266
|
|
|
265
267
|
// An optional branch hoards its results.
|
|
266
|
-
var OptionalBranch = function
|
|
268
|
+
var OptionalBranch = function (junction) {
|
|
267
269
|
this.count = 0;
|
|
268
270
|
this.done = false;
|
|
269
271
|
this.results = [];
|
|
@@ -302,7 +304,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
302
304
|
terms = [item.subject, item.predicate, item.object, item.why];
|
|
303
305
|
ind = [f.subjectIndex, f.predicateIndex, f.objectIndex, f.whyIndex];
|
|
304
306
|
for (i = 0; i < 4; i++) {
|
|
305
|
-
|
|
307
|
+
let t = terms[i];
|
|
306
308
|
// console.log(" Prepare (" + t + ") "+(t in bindings))
|
|
307
309
|
if (t.uri && t.uri === _defaultGraphUri.defaultGraphURI) {// chrome:session
|
|
308
310
|
// console.log(' query: Ignoring slot ' + i)
|
|
@@ -354,7 +356,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
354
356
|
*
|
|
355
357
|
* Will fetch linked data from the web iff the knowledge base an associated source fetcher (f.fetcher)
|
|
356
358
|
***/
|
|
357
|
-
var match = function
|
|
359
|
+
var match = function (f, g, bindingsSoFar, level, fetcher, localCallback, branch) {
|
|
358
360
|
_log.default.debug('Match begins, Branch count now: ' + branch.count + ' for ' + branch.pattern_debug);
|
|
359
361
|
|
|
360
362
|
// log.debug("match: f has "+f.statements.length+", g has "+g.statements.length)
|
|
@@ -391,7 +393,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
391
393
|
if (fetcher) {
|
|
392
394
|
// Fetcher is used to fetch URIs, function first term is a URI term, second is the requester
|
|
393
395
|
var id = 'match' + matchIndex++;
|
|
394
|
-
var fetchResource = function
|
|
396
|
+
var fetchResource = function (requestedTerm, id) {
|
|
395
397
|
var docuri = requestedTerm.uri.split('#')[0];
|
|
396
398
|
fetcher.nowOrWhenFetched(docuri, undefined, function (ok, body, xhr) {
|
|
397
399
|
if (!ok) {
|
|
@@ -418,7 +420,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
418
420
|
match2(f, g, bindingsSoFar, level, fetcher, localCallback, branch);
|
|
419
421
|
}; // match
|
|
420
422
|
|
|
421
|
-
var constraintsSatisfied = function
|
|
423
|
+
var constraintsSatisfied = function (bindings, constraints) {
|
|
422
424
|
var res = true;
|
|
423
425
|
var x;
|
|
424
426
|
var test;
|
|
@@ -436,7 +438,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
436
438
|
};
|
|
437
439
|
|
|
438
440
|
/** match2 -- stuff after the fetch **/
|
|
439
|
-
var match2 = function
|
|
441
|
+
var match2 = function (f, g, bindingsSoFar, level, fetcher, callback, branch) {
|
|
440
442
|
// post fetch
|
|
441
443
|
var pattern = g.statements;
|
|
442
444
|
var n = pattern.length;
|