rdflib 2.2.22-2f49e8ef → 2.2.22-53d65d90
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 +1085 -1008
- 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.d.ts +1 -1
- 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.js +1089 -1010
- 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.d.ts +1 -1
- 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.d.ts +1 -1
- 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 +9 -8
- package/src/index.ts +0 -2
- package/src/jsonldparser.js +13 -4
- package/src/serialize.ts +4 -11
- 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/esm/named-node.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
1
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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); }; }
|
|
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; } }
|
|
2
10
|
import ClassOrder from './class-order';
|
|
3
11
|
import Node from './node-internal';
|
|
4
12
|
import { NamedNodeTermType } from './types';
|
|
@@ -8,98 +16,120 @@ import { isTerm } from './utils/terms';
|
|
|
8
16
|
/**
|
|
9
17
|
* A named (IRI) RDF node
|
|
10
18
|
*/
|
|
11
|
-
|
|
19
|
+
var NamedNode = /*#__PURE__*/function (_Node) {
|
|
20
|
+
_inherits(NamedNode, _Node);
|
|
21
|
+
var _super = _createSuper(NamedNode);
|
|
12
22
|
/**
|
|
13
23
|
* Create a named (IRI) RDF Node
|
|
14
24
|
* @constructor
|
|
15
25
|
* @param iri - The IRI for this node
|
|
16
26
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
function NamedNode(iri) {
|
|
28
|
+
var _this;
|
|
29
|
+
_classCallCheck(this, NamedNode);
|
|
30
|
+
_this = _super.call(this, termValue(iri));
|
|
31
|
+
_defineProperty(_assertThisInitialized(_this), "termType", NamedNodeTermType);
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.NamedNode);
|
|
33
|
+
if (!_this.value) {
|
|
22
34
|
throw new Error('Missing IRI for NamedNode');
|
|
23
35
|
}
|
|
24
|
-
if (!
|
|
36
|
+
if (!_this.value.includes(':')) {
|
|
25
37
|
throw new Error('NamedNode IRI "' + iri + '" must be absolute.');
|
|
26
38
|
}
|
|
27
|
-
if (
|
|
39
|
+
if (_this.value.includes(' ')) {
|
|
28
40
|
var message = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.';
|
|
29
41
|
throw new Error(message);
|
|
30
42
|
}
|
|
43
|
+
return _this;
|
|
31
44
|
}
|
|
32
45
|
|
|
33
46
|
/**
|
|
34
47
|
* Returns an $rdf node for the containing directory, ending in slash.
|
|
35
48
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Returns an NN for the whole web site, ending in slash.
|
|
46
|
-
* Contrast with the "origin" which does NOT have a trailing slash
|
|
47
|
-
*/
|
|
48
|
-
site() {
|
|
49
|
-
var str = this.value.split('#')[0];
|
|
50
|
-
var p = str.indexOf('//');
|
|
51
|
-
if (p < 0) throw new Error('This URI does not have a web site part (origin)');
|
|
52
|
-
var q = str.indexOf('/', p + 2);
|
|
53
|
-
if (q < 0) {
|
|
54
|
-
return new NamedNode(str.slice(0) + '/'); // Add slash to a bare origin
|
|
55
|
-
} else {
|
|
56
|
-
return new NamedNode(str.slice(0, q + 1));
|
|
49
|
+
_createClass(NamedNode, [{
|
|
50
|
+
key: "dir",
|
|
51
|
+
value: function dir() {
|
|
52
|
+
var str = this.value.split('#')[0];
|
|
53
|
+
var p = str.slice(0, -1).lastIndexOf('/');
|
|
54
|
+
var q = str.indexOf('//');
|
|
55
|
+
if (q >= 0 && p < q + 2 || p < 0) return null;
|
|
56
|
+
return new NamedNode(str.slice(0, p + 1));
|
|
57
57
|
}
|
|
58
|
-
}
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Returns an NN for the whole web site, ending in slash.
|
|
61
|
+
* Contrast with the "origin" which does NOT have a trailing slash
|
|
62
|
+
*/
|
|
63
|
+
}, {
|
|
64
|
+
key: "site",
|
|
65
|
+
value: function site() {
|
|
66
|
+
var str = this.value.split('#')[0];
|
|
67
|
+
var p = str.indexOf('//');
|
|
68
|
+
if (p < 0) throw new Error('This URI does not have a web site part (origin)');
|
|
69
|
+
var q = str.indexOf('/', p + 2);
|
|
70
|
+
if (q < 0) {
|
|
71
|
+
return new NamedNode(str.slice(0) + '/'); // Add slash to a bare origin
|
|
72
|
+
} else {
|
|
73
|
+
return new NamedNode(str.slice(0, q + 1));
|
|
74
|
+
}
|
|
69
75
|
}
|
|
70
|
-
}
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Creates the fetchable named node for the document.
|
|
79
|
+
* Removes everything from the # anchor tag.
|
|
80
|
+
*/
|
|
81
|
+
}, {
|
|
82
|
+
key: "doc",
|
|
83
|
+
value: function doc() {
|
|
84
|
+
if (this.value.indexOf('#') < 0) {
|
|
85
|
+
return this;
|
|
86
|
+
} else {
|
|
87
|
+
return new NamedNode(this.value.split('#')[0]);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
78
90
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
91
|
+
/**
|
|
92
|
+
* Returns the URI including <brackets>
|
|
93
|
+
*/
|
|
94
|
+
}, {
|
|
95
|
+
key: "toString",
|
|
96
|
+
value: function toString() {
|
|
97
|
+
return '<' + this.value + '>';
|
|
98
|
+
}
|
|
83
99
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
100
|
+
/** The local identifier with the document */
|
|
101
|
+
}, {
|
|
102
|
+
key: "id",
|
|
103
|
+
value: function id() {
|
|
104
|
+
return this.value.split('#')[1];
|
|
105
|
+
}
|
|
91
106
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
107
|
+
/** Alias for value, favored by Tim */
|
|
108
|
+
}, {
|
|
109
|
+
key: "uri",
|
|
110
|
+
get: function get() {
|
|
111
|
+
return this.value;
|
|
112
|
+
},
|
|
113
|
+
set: function set(uri) {
|
|
114
|
+
this.value = uri;
|
|
99
115
|
}
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Creates a named node from the specified input value
|
|
119
|
+
* @param value - An input value
|
|
120
|
+
*/
|
|
121
|
+
}], [{
|
|
122
|
+
key: "fromValue",
|
|
123
|
+
value: function fromValue(value) {
|
|
124
|
+
if (typeof value === 'undefined' || value === null) {
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
if (isTerm(value)) {
|
|
128
|
+
return value;
|
|
129
|
+
}
|
|
130
|
+
return new NamedNode(value);
|
|
102
131
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
132
|
+
}]);
|
|
133
|
+
return NamedNode;
|
|
134
|
+
}(Node);
|
|
135
|
+
export { NamedNode as default };
|
package/esm/namespace.js
CHANGED
|
@@ -5,8 +5,10 @@ import RDFlibNamedNode from './named-node';
|
|
|
5
5
|
* @param [factory] - The factory for creating named nodes with
|
|
6
6
|
*/
|
|
7
7
|
export default function Namespace(nsuri, factory) {
|
|
8
|
-
|
|
9
|
-
namedNode:
|
|
8
|
+
var dataFactory = factory || {
|
|
9
|
+
namedNode: function namedNode(value) {
|
|
10
|
+
return new RDFlibNamedNode(value);
|
|
11
|
+
}
|
|
10
12
|
};
|
|
11
13
|
return function (ln) {
|
|
12
14
|
return dataFactory.namedNode(nsuri + (ln || ''));
|
package/esm/node-internal.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
1
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
4
|
/**
|
|
3
5
|
* The superclass of all RDF Statement objects, that is
|
|
@@ -7,7 +9,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
7
9
|
* @link https://rdf.js.org/data-model-spec/#term-interface
|
|
8
10
|
* @class Node
|
|
9
11
|
*/
|
|
10
|
-
|
|
12
|
+
var Node = /*#__PURE__*/function () {
|
|
11
13
|
// Specified in './node.ts' to prevent circular dependency
|
|
12
14
|
|
|
13
15
|
// Specified in './node.ts' to prevent circular dependency
|
|
@@ -18,7 +20,8 @@ export default class Node {
|
|
|
18
20
|
|
|
19
21
|
/** The node's value */
|
|
20
22
|
|
|
21
|
-
|
|
23
|
+
function Node(value) {
|
|
24
|
+
_classCallCheck(this, Node);
|
|
22
25
|
_defineProperty(this, "termType", void 0);
|
|
23
26
|
_defineProperty(this, "classOrder", void 0);
|
|
24
27
|
_defineProperty(this, "value", void 0);
|
|
@@ -29,86 +32,107 @@ export default class Node {
|
|
|
29
32
|
* Creates the substituted node for this one, according to the specified bindings
|
|
30
33
|
* @param bindings - Bindings of identifiers to nodes
|
|
31
34
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Compares this node with another
|
|
39
|
-
* @see {equals} to check if two nodes are equal
|
|
40
|
-
* @param other - The other node
|
|
41
|
-
*/
|
|
42
|
-
compareTerm(other) {
|
|
43
|
-
if (this.classOrder < other.classOrder) {
|
|
44
|
-
return -1;
|
|
45
|
-
}
|
|
46
|
-
if (this.classOrder > other.classOrder) {
|
|
47
|
-
return +1;
|
|
35
|
+
_createClass(Node, [{
|
|
36
|
+
key: "substitute",
|
|
37
|
+
value: function substitute(bindings) {
|
|
38
|
+
console.log('@@@ node substitute' + this);
|
|
39
|
+
return this;
|
|
48
40
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Compares this node with another
|
|
44
|
+
* @see {equals} to check if two nodes are equal
|
|
45
|
+
* @param other - The other node
|
|
46
|
+
*/
|
|
47
|
+
}, {
|
|
48
|
+
key: "compareTerm",
|
|
49
|
+
value: function compareTerm(other) {
|
|
50
|
+
if (this.classOrder < other.classOrder) {
|
|
51
|
+
return -1;
|
|
52
|
+
}
|
|
53
|
+
if (this.classOrder > other.classOrder) {
|
|
54
|
+
return +1;
|
|
55
|
+
}
|
|
56
|
+
if (this.value < other.value) {
|
|
57
|
+
return -1;
|
|
58
|
+
}
|
|
59
|
+
if (this.value > other.value) {
|
|
60
|
+
return +1;
|
|
61
|
+
}
|
|
62
|
+
return 0;
|
|
54
63
|
}
|
|
55
|
-
return 0;
|
|
56
|
-
}
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Compares whether the two nodes are equal
|
|
67
|
+
* @param other The other node
|
|
68
|
+
*/
|
|
69
|
+
}, {
|
|
70
|
+
key: "equals",
|
|
71
|
+
value: function equals(other) {
|
|
72
|
+
if (!other) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return this.termType === other.termType && this.value === other.value;
|
|
65
76
|
}
|
|
66
|
-
return this.termType === other.termType && this.value === other.value;
|
|
67
|
-
}
|
|
68
77
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Creates a hash for this node
|
|
80
|
+
* @deprecated use {rdfFactory.id} instead if possible
|
|
81
|
+
*/
|
|
82
|
+
}, {
|
|
83
|
+
key: "hashString",
|
|
84
|
+
value: function hashString() {
|
|
85
|
+
return this.toCanonical();
|
|
86
|
+
}
|
|
76
87
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
/**
|
|
89
|
+
* Compares whether this node is the same as the other one
|
|
90
|
+
* @param other - Another node
|
|
91
|
+
*/
|
|
92
|
+
}, {
|
|
93
|
+
key: "sameTerm",
|
|
94
|
+
value: function sameTerm(other) {
|
|
95
|
+
return this.equals(other);
|
|
96
|
+
}
|
|
84
97
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Creates a canonical string representation of this node
|
|
100
|
+
*/
|
|
101
|
+
}, {
|
|
102
|
+
key: "toCanonical",
|
|
103
|
+
value: function toCanonical() {
|
|
104
|
+
return this.toNT();
|
|
105
|
+
}
|
|
91
106
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Creates a n-triples string representation of this node
|
|
109
|
+
*/
|
|
110
|
+
}, {
|
|
111
|
+
key: "toNT",
|
|
112
|
+
value: function toNT() {
|
|
113
|
+
return this.toString();
|
|
114
|
+
}
|
|
98
115
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Creates a n-quads string representation of this node
|
|
118
|
+
*/
|
|
119
|
+
}, {
|
|
120
|
+
key: "toNQ",
|
|
121
|
+
value: function toNQ() {
|
|
122
|
+
return this.toNT();
|
|
123
|
+
}
|
|
105
124
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Creates a string representation of this node
|
|
127
|
+
*/
|
|
128
|
+
}, {
|
|
129
|
+
key: "toString",
|
|
130
|
+
value: function toString() {
|
|
131
|
+
throw new Error('Node.toString() is abstract - see the subclasses instead');
|
|
132
|
+
}
|
|
133
|
+
}]);
|
|
134
|
+
return Node;
|
|
135
|
+
}();
|
|
113
136
|
_defineProperty(Node, "fromValue", void 0);
|
|
114
|
-
_defineProperty(Node, "toJS", void 0);
|
|
137
|
+
_defineProperty(Node, "toJS", void 0);
|
|
138
|
+
export { Node as default };
|
package/esm/node.js
CHANGED
package/esm/parse.js
CHANGED
|
@@ -20,8 +20,8 @@ import { TurtleContentType, N3ContentType, RDFXMLContentType, XHTMLContentType,
|
|
|
20
20
|
* @param [callback] - The callback to call when the data has been loaded
|
|
21
21
|
*/
|
|
22
22
|
export default function parse(str, kb, base) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
var contentType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'text/turtle';
|
|
24
|
+
var callback = arguments.length > 4 ? arguments[4] : undefined;
|
|
25
25
|
contentType = contentType || TurtleContentType;
|
|
26
26
|
contentType = contentType.split(';')[0];
|
|
27
27
|
try {
|
|
@@ -93,7 +93,7 @@ export default function parse(str, kb, base) {
|
|
|
93
93
|
if (callback) {
|
|
94
94
|
callback(e, kb);
|
|
95
95
|
} else {
|
|
96
|
-
|
|
96
|
+
var e2 = new Error('' + e + ' while trying to parse <' + base + '> as ' + contentType);
|
|
97
97
|
//@ts-ignore .cause is not a default error property
|
|
98
98
|
e2.cause = e;
|
|
99
99
|
throw e2;
|
package/esm/patch-parser.js
CHANGED
|
@@ -13,7 +13,7 @@ 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
|
-
var badSyntax = function (uri, lines, str, i, why) {
|
|
16
|
+
var badSyntax = function badSyntax(uri, lines, str, i, why) {
|
|
17
17
|
return 'Line ' + (lines + 1) + ' of <' + uri + '>: Bad syntax:\n ' + why + '\n at: "' + str.slice(i, i + 30) + '"';
|
|
18
18
|
};
|
|
19
19
|
|
package/esm/query.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
1
3
|
// Matching a formula against another formula
|
|
2
4
|
// Assync as well as Synchronously
|
|
3
5
|
//
|
|
@@ -25,15 +27,14 @@ import { docpart } from './uri';
|
|
|
25
27
|
/**
|
|
26
28
|
* Query class, for tracking queries the user has in the UI.
|
|
27
29
|
*/
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
30
|
+
export var Query = /*#__PURE__*/_createClass(function Query(name, id) {
|
|
31
|
+
_classCallCheck(this, Query);
|
|
32
|
+
this.pat = new IndexedFormula(); // The pattern to search for
|
|
33
|
+
this.vars = []; // Used by UI code but not in query.js
|
|
34
|
+
// this.orderBy = [] // Not used yet
|
|
35
|
+
this.name = name;
|
|
36
|
+
this.id = id;
|
|
37
|
+
});
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* This function will match a pattern to the current Store
|
|
@@ -262,7 +263,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
262
263
|
};
|
|
263
264
|
|
|
264
265
|
// An optional branch hoards its results.
|
|
265
|
-
var OptionalBranch = function (junction) {
|
|
266
|
+
var OptionalBranch = function OptionalBranch(junction) {
|
|
266
267
|
this.count = 0;
|
|
267
268
|
this.done = false;
|
|
268
269
|
this.results = [];
|
|
@@ -301,7 +302,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
301
302
|
terms = [item.subject, item.predicate, item.object, item.why];
|
|
302
303
|
ind = [f.subjectIndex, f.predicateIndex, f.objectIndex, f.whyIndex];
|
|
303
304
|
for (i = 0; i < 4; i++) {
|
|
304
|
-
|
|
305
|
+
var t = terms[i];
|
|
305
306
|
// console.log(" Prepare (" + t + ") "+(t in bindings))
|
|
306
307
|
if (t.uri && t.uri === defaultDocumentURI) {// chrome:session
|
|
307
308
|
// console.log(' query: Ignoring slot ' + i)
|
|
@@ -355,7 +356,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
355
356
|
*
|
|
356
357
|
* Will fetch linked data from the web iff the knowledge base an associated source fetcher (f.fetcher)
|
|
357
358
|
***/
|
|
358
|
-
var match = function (f, g, bindingsSoFar, level, fetcher, localCallback, branch) {
|
|
359
|
+
var match = function match(f, g, bindingsSoFar, level, fetcher, localCallback, branch) {
|
|
359
360
|
log.debug('Match begins, Branch count now: ' + branch.count + ' for ' + branch.pattern_debug);
|
|
360
361
|
|
|
361
362
|
// log.debug("match: f has "+f.statements.length+", g has "+g.statements.length)
|
|
@@ -394,7 +395,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
394
395
|
if (fetcher) {
|
|
395
396
|
// Fetcher is used to fetch URIs, function first term is a URI term, second is the requester
|
|
396
397
|
var id = 'match' + matchIndex++;
|
|
397
|
-
var fetchResource = function (requestedTerm, id) {
|
|
398
|
+
var fetchResource = function fetchResource(requestedTerm, id) {
|
|
398
399
|
var docuri = requestedTerm.uri.split('#')[0];
|
|
399
400
|
fetcher.nowOrWhenFetched(docuri, undefined, function (ok, body, xhr) {
|
|
400
401
|
if (!ok) {
|
|
@@ -422,7 +423,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
422
423
|
match2(f, g, bindingsSoFar, level, fetcher, localCallback, branch);
|
|
423
424
|
}; // match
|
|
424
425
|
|
|
425
|
-
var constraintsSatisfied = function (bindings, constraints) {
|
|
426
|
+
var constraintsSatisfied = function constraintsSatisfied(bindings, constraints) {
|
|
426
427
|
var res = true;
|
|
427
428
|
var x;
|
|
428
429
|
var test;
|
|
@@ -440,7 +441,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
440
441
|
};
|
|
441
442
|
|
|
442
443
|
/** match2 -- stuff after the fetch **/
|
|
443
|
-
var match2 = function (f, g, bindingsSoFar, level, fetcher, callback, branch) {
|
|
444
|
+
var match2 = function match2(f, g, bindingsSoFar, level, fetcher, callback, branch) {
|
|
444
445
|
// post fetch
|
|
445
446
|
var pattern = g.statements;
|
|
446
447
|
var n = pattern.length;
|