rdflib 2.2.22 → 2.2.23-1c672b7b
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 +4 -0
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +90 -61
- package/esm/class-order.js +1 -1
- package/esm/collection.js +106 -70
- package/esm/default-graph.js +33 -13
- package/esm/empty.js +26 -8
- package/esm/factories/canonical-data-factory.js +30 -33
- package/esm/factories/extended-term-factory.js +14 -18
- package/esm/factories/factory-types.js +1 -1
- package/esm/factories/rdflib-data-factory.js +11 -9
- package/esm/fetcher.js +1644 -1355
- package/esm/formula.js +740 -632
- package/esm/index.js +52 -33
- package/esm/jsonldparser.js +35 -19
- package/esm/jsonparser.js +1 -1
- package/esm/lists.js +86 -38
- package/esm/literal.js +157 -120
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1088 -1004
- package/esm/named-node.js +99 -69
- package/esm/namespace.js +4 -2
- package/esm/node-internal.js +98 -74
- package/esm/node.js +1 -1
- package/esm/parse.js +3 -3
- package/esm/patch-parser.js +1 -1
- package/esm/query.js +16 -15
- package/esm/rdfaparser.js +846 -781
- package/esm/rdfxmlparser.js +365 -348
- package/esm/serialize.js +4 -11
- package/esm/serializer.js +886 -821
- package/esm/statement.js +72 -52
- package/esm/store.js +924 -822
- package/esm/types.js +21 -21
- package/esm/update-manager.js +983 -882
- package/esm/updates-via.js +134 -104
- package/esm/uri.js +3 -3
- package/esm/utils/default-graph-uri.js +2 -2
- package/esm/utils/terms.js +5 -4
- package/esm/utils-js.js +5 -5
- package/esm/utils.js +6 -6
- package/esm/variable.js +58 -32
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +88 -60
- package/lib/class-order.js +1 -1
- package/lib/collection.js +104 -69
- package/lib/default-graph.js +32 -13
- package/lib/empty.js +25 -8
- package/lib/factories/canonical-data-factory.js +32 -35
- package/lib/factories/extended-term-factory.js +14 -18
- package/lib/factories/factory-types.js +1 -1
- package/lib/factories/rdflib-data-factory.js +11 -9
- package/lib/fetcher.js +1646 -1385
- package/lib/formula.js +739 -632
- package/lib/index.d.ts +1 -2
- package/lib/index.js +88 -70
- package/lib/jsonldparser.js +35 -19
- package/lib/jsonparser.js +1 -1
- package/lib/lists.js +86 -54
- package/lib/literal.js +156 -120
- package/lib/log.js +7 -7
- package/lib/n3parser.d.ts +1 -0
- package/lib/n3parser.js +1092 -1006
- package/lib/named-node.js +98 -69
- package/lib/namespace.js +4 -2
- package/lib/node-internal.js +96 -73
- package/lib/node.js +1 -1
- package/lib/parse.js +6 -5
- package/lib/patch-parser.js +1 -1
- package/lib/query.js +18 -19
- package/lib/rdfaparser.js +848 -783
- package/lib/rdfxmlparser.js +366 -350
- package/lib/serialize.js +4 -13
- package/lib/serializer.d.ts +1 -0
- package/lib/serializer.js +890 -825
- package/lib/statement.js +74 -54
- package/lib/store.js +926 -844
- package/lib/types.js +21 -21
- package/lib/update-manager.d.ts +1 -1
- package/lib/update-manager.js +959 -865
- package/lib/updates-via.js +134 -105
- package/lib/uri.js +3 -3
- package/lib/utils/default-graph-uri.js +2 -2
- package/lib/utils/terms.js +6 -4
- package/lib/utils-js.js +9 -8
- package/lib/utils.js +6 -6
- package/lib/variable.js +60 -34
- package/lib/xsd.js +2 -2
- package/package.json +20 -19
- package/src/index.ts +0 -2
- package/src/jsonldparser.js +13 -4
- package/src/n3parser.js +12 -4
- package/src/serialize.ts +3 -10
- package/src/serializer.js +24 -0
- package/src/update-manager.ts +8 -2
- package/esm/convert.js +0 -60
- package/lib/convert.d.ts +0 -2
- package/lib/convert.js +0 -71
- package/src/convert.js +0 -70
package/lib/named-node.js
CHANGED
|
@@ -5,108 +5,137 @@ 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 _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
8
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
15
|
var _classOrder = _interopRequireDefault(require("./class-order"));
|
|
10
16
|
var _nodeInternal = _interopRequireDefault(require("./node-internal"));
|
|
11
17
|
var _types = require("./types");
|
|
12
18
|
var _termValue = require("./utils/termValue");
|
|
13
19
|
var _terms = require("./utils/terms");
|
|
20
|
+
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); }; }
|
|
21
|
+
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; } }
|
|
14
22
|
/**
|
|
15
23
|
* A named (IRI) RDF node
|
|
16
24
|
*/
|
|
17
|
-
|
|
25
|
+
var NamedNode = /*#__PURE__*/function (_Node) {
|
|
26
|
+
(0, _inherits2.default)(NamedNode, _Node);
|
|
27
|
+
var _super = _createSuper(NamedNode);
|
|
18
28
|
/**
|
|
19
29
|
* Create a named (IRI) RDF Node
|
|
20
30
|
* @constructor
|
|
21
31
|
* @param iri - The IRI for this node
|
|
22
32
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
(0,
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
function NamedNode(iri) {
|
|
34
|
+
var _this;
|
|
35
|
+
(0, _classCallCheck2.default)(this, NamedNode);
|
|
36
|
+
_this = _super.call(this, (0, _termValue.termValue)(iri));
|
|
37
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "termType", _types.NamedNodeTermType);
|
|
38
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "classOrder", _classOrder.default.NamedNode);
|
|
39
|
+
if (!_this.value) {
|
|
28
40
|
throw new Error('Missing IRI for NamedNode');
|
|
29
41
|
}
|
|
30
|
-
if (!
|
|
42
|
+
if (!_this.value.includes(':')) {
|
|
31
43
|
throw new Error('NamedNode IRI "' + iri + '" must be absolute.');
|
|
32
44
|
}
|
|
33
|
-
if (
|
|
45
|
+
if (_this.value.includes(' ')) {
|
|
34
46
|
var message = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.';
|
|
35
47
|
throw new Error(message);
|
|
36
48
|
}
|
|
49
|
+
return _this;
|
|
37
50
|
}
|
|
38
51
|
|
|
39
52
|
/**
|
|
40
53
|
* Returns an $rdf node for the containing directory, ending in slash.
|
|
41
54
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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));
|
|
55
|
+
(0, _createClass2.default)(NamedNode, [{
|
|
56
|
+
key: "dir",
|
|
57
|
+
value: function dir() {
|
|
58
|
+
var str = this.value.split('#')[0];
|
|
59
|
+
var p = str.slice(0, -1).lastIndexOf('/');
|
|
60
|
+
var q = str.indexOf('//');
|
|
61
|
+
if (q >= 0 && p < q + 2 || p < 0) return null;
|
|
62
|
+
return new NamedNode(str.slice(0, p + 1));
|
|
63
63
|
}
|
|
64
|
-
}
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Returns an NN for the whole web site, ending in slash.
|
|
67
|
+
* Contrast with the "origin" which does NOT have a trailing slash
|
|
68
|
+
*/
|
|
69
|
+
}, {
|
|
70
|
+
key: "site",
|
|
71
|
+
value: function site() {
|
|
72
|
+
var str = this.value.split('#')[0];
|
|
73
|
+
var p = str.indexOf('//');
|
|
74
|
+
if (p < 0) throw new Error('This URI does not have a web site part (origin)');
|
|
75
|
+
var q = str.indexOf('/', p + 2);
|
|
76
|
+
if (q < 0) {
|
|
77
|
+
return new NamedNode(str.slice(0) + '/'); // Add slash to a bare origin
|
|
78
|
+
} else {
|
|
79
|
+
return new NamedNode(str.slice(0, q + 1));
|
|
80
|
+
}
|
|
75
81
|
}
|
|
76
|
-
}
|
|
77
82
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Creates the fetchable named node for the document.
|
|
85
|
+
* Removes everything from the # anchor tag.
|
|
86
|
+
*/
|
|
87
|
+
}, {
|
|
88
|
+
key: "doc",
|
|
89
|
+
value: function doc() {
|
|
90
|
+
if (this.value.indexOf('#') < 0) {
|
|
91
|
+
return this;
|
|
92
|
+
} else {
|
|
93
|
+
return new NamedNode(this.value.split('#')[0]);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
84
96
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
97
|
+
/**
|
|
98
|
+
* Returns the URI including <brackets>
|
|
99
|
+
*/
|
|
100
|
+
}, {
|
|
101
|
+
key: "toString",
|
|
102
|
+
value: function toString() {
|
|
103
|
+
return '<' + this.value + '>';
|
|
104
|
+
}
|
|
89
105
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
106
|
+
/** The local identifier with the document */
|
|
107
|
+
}, {
|
|
108
|
+
key: "id",
|
|
109
|
+
value: function id() {
|
|
110
|
+
return this.value.split('#')[1];
|
|
111
|
+
}
|
|
97
112
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
/** Alias for value, favored by Tim */
|
|
114
|
+
}, {
|
|
115
|
+
key: "uri",
|
|
116
|
+
get: function get() {
|
|
117
|
+
return this.value;
|
|
118
|
+
},
|
|
119
|
+
set: function set(uri) {
|
|
120
|
+
this.value = uri;
|
|
105
121
|
}
|
|
106
|
-
|
|
107
|
-
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Creates a named node from the specified input value
|
|
125
|
+
* @param value - An input value
|
|
126
|
+
*/
|
|
127
|
+
}], [{
|
|
128
|
+
key: "fromValue",
|
|
129
|
+
value: function fromValue(value) {
|
|
130
|
+
if (typeof value === 'undefined' || value === null) {
|
|
131
|
+
return value;
|
|
132
|
+
}
|
|
133
|
+
if ((0, _terms.isTerm)(value)) {
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
return new NamedNode(value);
|
|
108
137
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
138
|
+
}]);
|
|
139
|
+
return NamedNode;
|
|
140
|
+
}(_nodeInternal.default);
|
|
112
141
|
exports.default = NamedNode;
|
package/lib/namespace.js
CHANGED
|
@@ -12,8 +12,10 @@ 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:
|
|
15
|
+
var dataFactory = factory || {
|
|
16
|
+
namedNode: function namedNode(value) {
|
|
17
|
+
return new _namedNode.default(value);
|
|
18
|
+
}
|
|
17
19
|
};
|
|
18
20
|
return function (ln) {
|
|
19
21
|
return dataFactory.namedNode(nsuri + (ln || ''));
|
package/lib/node-internal.js
CHANGED
|
@@ -5,6 +5,8 @@ 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"));
|
|
8
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
11
|
/**
|
|
10
12
|
* The superclass of all RDF Statement objects, that is
|
|
@@ -14,7 +16,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
14
16
|
* @link https://rdf.js.org/data-model-spec/#term-interface
|
|
15
17
|
* @class Node
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
var Node = /*#__PURE__*/function () {
|
|
18
20
|
// Specified in './node.ts' to prevent circular dependency
|
|
19
21
|
|
|
20
22
|
// Specified in './node.ts' to prevent circular dependency
|
|
@@ -25,7 +27,8 @@ class Node {
|
|
|
25
27
|
|
|
26
28
|
/** The node's value */
|
|
27
29
|
|
|
28
|
-
|
|
30
|
+
function Node(value) {
|
|
31
|
+
(0, _classCallCheck2.default)(this, Node);
|
|
29
32
|
(0, _defineProperty2.default)(this, "termType", void 0);
|
|
30
33
|
(0, _defineProperty2.default)(this, "classOrder", void 0);
|
|
31
34
|
(0, _defineProperty2.default)(this, "value", void 0);
|
|
@@ -36,87 +39,107 @@ class Node {
|
|
|
36
39
|
* Creates the substituted node for this one, according to the specified bindings
|
|
37
40
|
* @param bindings - Bindings of identifiers to nodes
|
|
38
41
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Compares this node with another
|
|
46
|
-
* @see {equals} to check if two nodes are equal
|
|
47
|
-
* @param other - The other node
|
|
48
|
-
*/
|
|
49
|
-
compareTerm(other) {
|
|
50
|
-
if (this.classOrder < other.classOrder) {
|
|
51
|
-
return -1;
|
|
52
|
-
}
|
|
53
|
-
if (this.classOrder > other.classOrder) {
|
|
54
|
-
return +1;
|
|
42
|
+
(0, _createClass2.default)(Node, [{
|
|
43
|
+
key: "substitute",
|
|
44
|
+
value: function substitute(bindings) {
|
|
45
|
+
console.log('@@@ node substitute' + this);
|
|
46
|
+
return this;
|
|
55
47
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Compares this node with another
|
|
51
|
+
* @see {equals} to check if two nodes are equal
|
|
52
|
+
* @param other - The other node
|
|
53
|
+
*/
|
|
54
|
+
}, {
|
|
55
|
+
key: "compareTerm",
|
|
56
|
+
value: function compareTerm(other) {
|
|
57
|
+
if (this.classOrder < other.classOrder) {
|
|
58
|
+
return -1;
|
|
59
|
+
}
|
|
60
|
+
if (this.classOrder > other.classOrder) {
|
|
61
|
+
return +1;
|
|
62
|
+
}
|
|
63
|
+
if (this.value < other.value) {
|
|
64
|
+
return -1;
|
|
65
|
+
}
|
|
66
|
+
if (this.value > other.value) {
|
|
67
|
+
return +1;
|
|
68
|
+
}
|
|
69
|
+
return 0;
|
|
61
70
|
}
|
|
62
|
-
return 0;
|
|
63
|
-
}
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Compares whether the two nodes are equal
|
|
74
|
+
* @param other The other node
|
|
75
|
+
*/
|
|
76
|
+
}, {
|
|
77
|
+
key: "equals",
|
|
78
|
+
value: function equals(other) {
|
|
79
|
+
if (!other) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
return this.termType === other.termType && this.value === other.value;
|
|
72
83
|
}
|
|
73
|
-
return this.termType === other.termType && this.value === other.value;
|
|
74
|
-
}
|
|
75
84
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Creates a hash for this node
|
|
87
|
+
* @deprecated use {rdfFactory.id} instead if possible
|
|
88
|
+
*/
|
|
89
|
+
}, {
|
|
90
|
+
key: "hashString",
|
|
91
|
+
value: function hashString() {
|
|
92
|
+
return this.toCanonical();
|
|
93
|
+
}
|
|
83
94
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Compares whether this node is the same as the other one
|
|
97
|
+
* @param other - Another node
|
|
98
|
+
*/
|
|
99
|
+
}, {
|
|
100
|
+
key: "sameTerm",
|
|
101
|
+
value: function sameTerm(other) {
|
|
102
|
+
return this.equals(other);
|
|
103
|
+
}
|
|
91
104
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Creates a canonical string representation of this node
|
|
107
|
+
*/
|
|
108
|
+
}, {
|
|
109
|
+
key: "toCanonical",
|
|
110
|
+
value: function toCanonical() {
|
|
111
|
+
return this.toNT();
|
|
112
|
+
}
|
|
98
113
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Creates a n-triples string representation of this node
|
|
116
|
+
*/
|
|
117
|
+
}, {
|
|
118
|
+
key: "toNT",
|
|
119
|
+
value: function toNT() {
|
|
120
|
+
return this.toString();
|
|
121
|
+
}
|
|
105
122
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
123
|
+
/**
|
|
124
|
+
* Creates a n-quads string representation of this node
|
|
125
|
+
*/
|
|
126
|
+
}, {
|
|
127
|
+
key: "toNQ",
|
|
128
|
+
value: function toNQ() {
|
|
129
|
+
return this.toNT();
|
|
130
|
+
}
|
|
112
131
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Creates a string representation of this node
|
|
134
|
+
*/
|
|
135
|
+
}, {
|
|
136
|
+
key: "toString",
|
|
137
|
+
value: function toString() {
|
|
138
|
+
throw new Error('Node.toString() is abstract - see the subclasses instead');
|
|
139
|
+
}
|
|
140
|
+
}]);
|
|
141
|
+
return Node;
|
|
142
|
+
}();
|
|
120
143
|
exports.default = Node;
|
|
121
144
|
(0, _defineProperty2.default)(Node, "fromValue", void 0);
|
|
122
145
|
(0, _defineProperty2.default)(Node, "toJS", void 0);
|
package/lib/node.js
CHANGED
|
@@ -23,7 +23,7 @@ var _terms = require("./utils/terms");
|
|
|
23
23
|
_nodeInternal.default.fromValue = _collection.fromValue;
|
|
24
24
|
var _default = _nodeInternal.default;
|
|
25
25
|
exports.default = _default;
|
|
26
|
-
|
|
26
|
+
var ns = {
|
|
27
27
|
xsd: (0, _namespace.default)('http://www.w3.org/2001/XMLSchema#')
|
|
28
28
|
};
|
|
29
29
|
|
package/lib/parse.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
@@ -14,8 +15,8 @@ var _rdfxmlparser = _interopRequireDefault(require("./rdfxmlparser"));
|
|
|
14
15
|
var _patchParser = _interopRequireDefault(require("./patch-parser"));
|
|
15
16
|
var Util = _interopRequireWildcard(require("./utils-js"));
|
|
16
17
|
var _types = require("./types");
|
|
17
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
18
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null ||
|
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
19
20
|
// @ts-ignore is this injected?
|
|
20
21
|
// @@ Goal: remove this dependency
|
|
21
22
|
|
|
@@ -31,8 +32,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
31
32
|
* @param [callback] - The callback to call when the data has been loaded
|
|
32
33
|
*/
|
|
33
34
|
function parse(str, kb, base) {
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
var contentType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'text/turtle';
|
|
36
|
+
var callback = arguments.length > 4 ? arguments[4] : undefined;
|
|
36
37
|
contentType = contentType || _types.TurtleContentType;
|
|
37
38
|
contentType = contentType.split(';')[0];
|
|
38
39
|
try {
|
|
@@ -104,7 +105,7 @@ function parse(str, kb, base) {
|
|
|
104
105
|
if (callback) {
|
|
105
106
|
callback(e, kb);
|
|
106
107
|
} else {
|
|
107
|
-
|
|
108
|
+
var e2 = new Error('' + e + ' while trying to parse <' + base + '> as ' + contentType);
|
|
108
109
|
//@ts-ignore .cause is not a default error property
|
|
109
110
|
e2.cause = e;
|
|
110
111
|
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 (uri, lines, str, i, why) {
|
|
24
|
+
var badSyntax = function badSyntax(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,6 +6,8 @@ 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"));
|
|
9
11
|
var _store = _interopRequireDefault(require("./store"));
|
|
10
12
|
var _defaultGraphUri = require("./utils/default-graph-uri");
|
|
11
13
|
var _log = _interopRequireDefault(require("./log"));
|
|
@@ -21,27 +23,24 @@ var _uri = require("./uri");
|
|
|
21
23
|
// Here we introduce for the first time a subclass of term: variable.
|
|
22
24
|
//
|
|
23
25
|
// SVN ID: $Id: query.js 25116 2008-11-15 16:13:48Z timbl $
|
|
24
|
-
|
|
25
26
|
// Variable
|
|
26
27
|
//
|
|
27
28
|
// Compare with BlankNode. They are similar, but a variable
|
|
28
29
|
// stands for something whose value is to be returned.
|
|
29
30
|
// Also, users name variables and want the same name back when stuff is printed
|
|
30
|
-
/* jsl:option explicit */
|
|
31
|
-
|
|
31
|
+
/* jsl:option explicit */
|
|
32
|
+
// Turn on JavaScriptLint variable declaration checking
|
|
32
33
|
/**
|
|
33
34
|
* Query class, for tracking queries the user has in the UI.
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
36
|
+
var Query = /*#__PURE__*/(0, _createClass2.default)(function Query(name, id) {
|
|
37
|
+
(0, _classCallCheck2.default)(this, Query);
|
|
38
|
+
this.pat = new _store.default(); // The pattern to search for
|
|
39
|
+
this.vars = []; // Used by UI code but not in query.js
|
|
40
|
+
// this.orderBy = [] // Not used yet
|
|
41
|
+
this.name = name;
|
|
42
|
+
this.id = id;
|
|
43
|
+
});
|
|
45
44
|
/**
|
|
46
45
|
* This function will match a pattern to the current Store
|
|
47
46
|
*
|
|
@@ -270,7 +269,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
270
269
|
};
|
|
271
270
|
|
|
272
271
|
// An optional branch hoards its results.
|
|
273
|
-
var OptionalBranch = function (junction) {
|
|
272
|
+
var OptionalBranch = function OptionalBranch(junction) {
|
|
274
273
|
this.count = 0;
|
|
275
274
|
this.done = false;
|
|
276
275
|
this.results = [];
|
|
@@ -309,7 +308,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
309
308
|
terms = [item.subject, item.predicate, item.object, item.why];
|
|
310
309
|
ind = [f.subjectIndex, f.predicateIndex, f.objectIndex, f.whyIndex];
|
|
311
310
|
for (i = 0; i < 4; i++) {
|
|
312
|
-
|
|
311
|
+
var t = terms[i];
|
|
313
312
|
// console.log(" Prepare (" + t + ") "+(t in bindings))
|
|
314
313
|
if (t.uri && t.uri === _defaultGraphUri.defaultGraphURI) {// chrome:session
|
|
315
314
|
// console.log(' query: Ignoring slot ' + i)
|
|
@@ -363,7 +362,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
363
362
|
*
|
|
364
363
|
* Will fetch linked data from the web iff the knowledge base an associated source fetcher (f.fetcher)
|
|
365
364
|
***/
|
|
366
|
-
var match = function (f, g, bindingsSoFar, level, fetcher, localCallback, branch) {
|
|
365
|
+
var match = function match(f, g, bindingsSoFar, level, fetcher, localCallback, branch) {
|
|
367
366
|
_log.default.debug('Match begins, Branch count now: ' + branch.count + ' for ' + branch.pattern_debug);
|
|
368
367
|
|
|
369
368
|
// log.debug("match: f has "+f.statements.length+", g has "+g.statements.length)
|
|
@@ -402,7 +401,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
402
401
|
if (fetcher) {
|
|
403
402
|
// Fetcher is used to fetch URIs, function first term is a URI term, second is the requester
|
|
404
403
|
var id = 'match' + matchIndex++;
|
|
405
|
-
var fetchResource = function (requestedTerm, id) {
|
|
404
|
+
var fetchResource = function fetchResource(requestedTerm, id) {
|
|
406
405
|
var docuri = requestedTerm.uri.split('#')[0];
|
|
407
406
|
fetcher.nowOrWhenFetched(docuri, undefined, function (ok, body, xhr) {
|
|
408
407
|
if (!ok) {
|
|
@@ -430,7 +429,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
430
429
|
match2(f, g, bindingsSoFar, level, fetcher, localCallback, branch);
|
|
431
430
|
}; // match
|
|
432
431
|
|
|
433
|
-
var constraintsSatisfied = function (bindings, constraints) {
|
|
432
|
+
var constraintsSatisfied = function constraintsSatisfied(bindings, constraints) {
|
|
434
433
|
var res = true;
|
|
435
434
|
var x;
|
|
436
435
|
var test;
|
|
@@ -448,7 +447,7 @@ function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
448
447
|
};
|
|
449
448
|
|
|
450
449
|
/** match2 -- stuff after the fetch **/
|
|
451
|
-
var match2 = function (f, g, bindingsSoFar, level, fetcher, callback, branch) {
|
|
450
|
+
var match2 = function match2(f, g, bindingsSoFar, level, fetcher, callback, branch) {
|
|
452
451
|
// post fetch
|
|
453
452
|
var pattern = g.statements;
|
|
454
453
|
var n = pattern.length;
|