rdflib 2.2.34 → 2.2.35-2bb9ed0b
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/515.rdflib.min.js +3 -0
- package/dist/515.rdflib.min.js.map +1 -0
- package/dist/789.rdflib.min.js +1 -0
- 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 -85
- package/esm/class-order.js +1 -1
- package/esm/collection.js +70 -106
- package/esm/default-graph.js +13 -33
- package/esm/empty.js +8 -26
- package/esm/factories/canonical-data-factory.js +33 -30
- package/esm/factories/extended-term-factory.js +18 -14
- package/esm/factories/factory-types.js +1 -1
- package/esm/factories/rdflib-data-factory.js +9 -11
- package/esm/fetcher.js +1364 -1668
- package/esm/formula.js +631 -739
- package/esm/index.js +31 -51
- package/esm/jsonldparser.js +19 -26
- package/esm/jsonparser.js +1 -1
- package/esm/lists.js +41 -86
- package/esm/literal.js +120 -157
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1008 -1090
- package/esm/named-node.js +69 -99
- package/esm/namespace.js +2 -4
- package/esm/node-internal.js +73 -97
- package/esm/node.js +1 -2
- package/esm/parse.js +3 -3
- package/esm/patch-parser.js +1 -2
- package/esm/query.js +15 -30
- package/esm/rdfaparser.js +775 -846
- package/esm/rdfxmlparser.js +348 -365
- package/esm/serialize.js +2 -3
- package/esm/serializer.js +834 -889
- package/esm/sparql-to-query.js +0 -2
- package/esm/statement.js +52 -72
- package/esm/store.js +852 -963
- package/esm/types.js +26 -21
- package/esm/update-manager.js +963 -1104
- package/esm/updates-via.js +104 -134
- 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 -6
- package/esm/utils.js +7 -6
- package/esm/variable.js +32 -58
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +56 -83
- package/lib/class-order.js +2 -3
- package/lib/collection.js +69 -104
- package/lib/default-graph.js +13 -32
- package/lib/empty.js +8 -25
- package/lib/factories/canonical-data-factory.js +36 -34
- package/lib/factories/extended-term-factory.js +19 -16
- package/lib/factories/factory-types.js +2 -3
- package/lib/factories/rdflib-data-factory.js +10 -13
- package/lib/fetcher.js +1394 -1693
- package/lib/formula.js +631 -738
- package/lib/index.js +66 -89
- package/lib/jsonldparser.js +21 -32
- package/lib/jsonparser.js +3 -4
- package/lib/lists.js +47 -87
- package/lib/literal.js +120 -156
- package/lib/log.js +8 -9
- package/lib/n3parser.js +1011 -1096
- package/lib/named-node.js +69 -98
- package/lib/namespace.js +2 -4
- package/lib/node-internal.js +72 -95
- package/lib/node.js +2 -4
- package/lib/parse.js +5 -6
- package/lib/patch-parser.js +1 -2
- package/lib/query.js +19 -32
- package/lib/rdfaparser.js +777 -849
- package/lib/rdfxmlparser.js +350 -366
- package/lib/serialize.js +2 -3
- package/lib/serializer.js +838 -892
- package/lib/sparql-to-query.js +0 -2
- package/lib/statement.js +54 -74
- package/lib/store.js +873 -978
- package/lib/types.js +22 -43
- package/lib/update-manager.js +972 -1111
- package/lib/updates-via.js +105 -134
- package/lib/uri.js +3 -3
- package/lib/utils/default-graph-uri.js +2 -4
- package/lib/utils/terms.js +4 -6
- package/lib/utils-js.js +11 -13
- package/lib/utils.js +6 -7
- package/lib/variable.js +34 -60
- package/lib/xsd-internal.js +2 -3
- package/lib/xsd.js +3 -4
- package/package.json +31 -31
- package/src/n3parser.js +1 -1
- package/src/rdfxmlparser.js +2 -1
- package/src/serializer.js +1 -1
- package/.babelrc +0 -20
- package/dist/670.rdflib.min.js +0 -1
- package/dist/730.rdflib.min.js +0 -3
- package/dist/730.rdflib.min.js.map +0 -1
- /package/dist/{730.rdflib.min.js.LICENSE.txt → 515.rdflib.min.js.LICENSE.txt} +0 -0
package/esm/named-node.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
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";
|
|
7
1
|
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; } }
|
|
10
2
|
import ClassOrder from './class-order';
|
|
11
3
|
import Node from './node-internal';
|
|
12
4
|
import { NamedNodeTermType } from './types';
|
|
@@ -16,120 +8,98 @@ import { isTerm } from './utils/terms';
|
|
|
16
8
|
/**
|
|
17
9
|
* A named (IRI) RDF node
|
|
18
10
|
*/
|
|
19
|
-
|
|
20
|
-
_inherits(NamedNode, _Node);
|
|
21
|
-
var _super = _createSuper(NamedNode);
|
|
11
|
+
export default class NamedNode extends Node {
|
|
22
12
|
/**
|
|
23
13
|
* Create a named (IRI) RDF Node
|
|
24
14
|
* @constructor
|
|
25
15
|
* @param iri - The IRI for this node
|
|
26
16
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.NamedNode);
|
|
33
|
-
if (!_this.value) {
|
|
17
|
+
constructor(iri) {
|
|
18
|
+
super(termValue(iri));
|
|
19
|
+
_defineProperty(this, "termType", NamedNodeTermType);
|
|
20
|
+
_defineProperty(this, "classOrder", ClassOrder.NamedNode);
|
|
21
|
+
if (!this.value) {
|
|
34
22
|
throw new Error('Missing IRI for NamedNode');
|
|
35
23
|
}
|
|
36
|
-
if (!
|
|
24
|
+
if (!this.value.includes(':')) {
|
|
37
25
|
throw new Error('NamedNode IRI "' + iri + '" must be absolute.');
|
|
38
26
|
}
|
|
39
|
-
if (
|
|
27
|
+
if (this.value.includes(' ')) {
|
|
40
28
|
var message = 'Error: NamedNode IRI "' + iri + '" must not contain unencoded spaces.';
|
|
41
29
|
throw new Error(message);
|
|
42
30
|
}
|
|
43
|
-
return _this;
|
|
44
31
|
}
|
|
45
32
|
|
|
46
33
|
/**
|
|
47
34
|
* Returns an $rdf node for the containing directory, ending in slash.
|
|
48
35
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return new NamedNode(str.slice(0, p + 1));
|
|
57
|
-
}
|
|
36
|
+
dir() {
|
|
37
|
+
var str = this.value.split('#')[0];
|
|
38
|
+
var p = str.slice(0, -1).lastIndexOf('/');
|
|
39
|
+
var q = str.indexOf('//');
|
|
40
|
+
if (q >= 0 && p < q + 2 || p < 0) return null;
|
|
41
|
+
return new NamedNode(str.slice(0, p + 1));
|
|
42
|
+
}
|
|
58
43
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
} else {
|
|
73
|
-
return new NamedNode(str.slice(0, q + 1));
|
|
74
|
-
}
|
|
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));
|
|
75
57
|
}
|
|
58
|
+
}
|
|
76
59
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
} else {
|
|
87
|
-
return new NamedNode(this.value.split('#')[0]);
|
|
88
|
-
}
|
|
60
|
+
/**
|
|
61
|
+
* Creates the fetchable named node for the document.
|
|
62
|
+
* Removes everything from the # anchor tag.
|
|
63
|
+
*/
|
|
64
|
+
doc() {
|
|
65
|
+
if (this.value.indexOf('#') < 0) {
|
|
66
|
+
return this;
|
|
67
|
+
} else {
|
|
68
|
+
return new NamedNode(this.value.split('#')[0]);
|
|
89
69
|
}
|
|
70
|
+
}
|
|
90
71
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return '<' + this.value + '>';
|
|
98
|
-
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns the URI including <brackets>
|
|
74
|
+
*/
|
|
75
|
+
toString() {
|
|
76
|
+
return '<' + this.value + '>';
|
|
77
|
+
}
|
|
99
78
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
return this.value.split('#')[1];
|
|
105
|
-
}
|
|
79
|
+
/** The local identifier with the document */
|
|
80
|
+
id() {
|
|
81
|
+
return this.value.split('#')[1];
|
|
82
|
+
}
|
|
106
83
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
this.value = uri;
|
|
115
|
-
}
|
|
84
|
+
/** Alias for value, favored by Tim */
|
|
85
|
+
get uri() {
|
|
86
|
+
return this.value;
|
|
87
|
+
}
|
|
88
|
+
set uri(uri) {
|
|
89
|
+
this.value = uri;
|
|
90
|
+
}
|
|
116
91
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (typeof value === 'undefined' || value === null) {
|
|
125
|
-
return value;
|
|
126
|
-
}
|
|
127
|
-
if (isTerm(value)) {
|
|
128
|
-
return value;
|
|
129
|
-
}
|
|
130
|
-
return new NamedNode(value);
|
|
92
|
+
/**
|
|
93
|
+
* Creates a named node from the specified input value
|
|
94
|
+
* @param value - An input value
|
|
95
|
+
*/
|
|
96
|
+
static fromValue(value) {
|
|
97
|
+
if (typeof value === 'undefined' || value === null) {
|
|
98
|
+
return value;
|
|
131
99
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
100
|
+
if (isTerm(value)) {
|
|
101
|
+
return value;
|
|
102
|
+
}
|
|
103
|
+
return new NamedNode(value);
|
|
104
|
+
}
|
|
105
|
+
}
|
package/esm/namespace.js
CHANGED
|
@@ -5,10 +5,8 @@ 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:
|
|
10
|
-
return new RDFlibNamedNode(value);
|
|
11
|
-
}
|
|
8
|
+
const dataFactory = factory || {
|
|
9
|
+
namedNode: value => new RDFlibNamedNode(value)
|
|
12
10
|
};
|
|
13
11
|
return function (ln) {
|
|
14
12
|
return dataFactory.namedNode(nsuri + (ln || ''));
|
package/esm/node-internal.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
2
|
/**
|
|
5
3
|
* The superclass of all RDF Statement objects, that is
|
|
@@ -9,9 +7,8 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
9
7
|
* @link https://rdf.js.org/data-model-spec/#term-interface
|
|
10
8
|
* @class Node
|
|
11
9
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
_classCallCheck(this, Node);
|
|
10
|
+
export default class Node {
|
|
11
|
+
constructor(value) {
|
|
15
12
|
/** The type of node */
|
|
16
13
|
_defineProperty(this, "termType", void 0);
|
|
17
14
|
/** The class order for this node */
|
|
@@ -25,108 +22,87 @@ var Node = /*#__PURE__*/function () {
|
|
|
25
22
|
* Creates the substituted node for this one, according to the specified bindings
|
|
26
23
|
* @param bindings - Bindings of identifiers to nodes
|
|
27
24
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return this;
|
|
32
|
-
}
|
|
25
|
+
substitute(bindings) {
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
33
28
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (this.classOrder < other.classOrder) {
|
|
43
|
-
return -1;
|
|
44
|
-
}
|
|
45
|
-
if (this.classOrder > other.classOrder) {
|
|
46
|
-
return +1;
|
|
47
|
-
}
|
|
48
|
-
if (this.value < other.value) {
|
|
49
|
-
return -1;
|
|
50
|
-
}
|
|
51
|
-
if (this.value > other.value) {
|
|
52
|
-
return +1;
|
|
53
|
-
}
|
|
54
|
-
return 0;
|
|
29
|
+
/**
|
|
30
|
+
* Compares this node with another
|
|
31
|
+
* @see {equals} to check if two nodes are equal
|
|
32
|
+
* @param other - The other node
|
|
33
|
+
*/
|
|
34
|
+
compareTerm(other) {
|
|
35
|
+
if (this.classOrder < other.classOrder) {
|
|
36
|
+
return -1;
|
|
55
37
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
* Compares whether the two nodes are equal
|
|
59
|
-
* @param other The other node
|
|
60
|
-
*/
|
|
61
|
-
}, {
|
|
62
|
-
key: "equals",
|
|
63
|
-
value: function equals(other) {
|
|
64
|
-
if (!other) {
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
return this.termType === other.termType && this.value === other.value;
|
|
38
|
+
if (this.classOrder > other.classOrder) {
|
|
39
|
+
return +1;
|
|
68
40
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
* Creates a hash for this node
|
|
72
|
-
* @deprecated use {rdfFactory.id} instead if possible
|
|
73
|
-
*/
|
|
74
|
-
}, {
|
|
75
|
-
key: "hashString",
|
|
76
|
-
value: function hashString() {
|
|
77
|
-
return this.toCanonical();
|
|
41
|
+
if (this.value < other.value) {
|
|
42
|
+
return -1;
|
|
78
43
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
* Compares whether this node is the same as the other one
|
|
82
|
-
* @param other - Another node
|
|
83
|
-
*/
|
|
84
|
-
}, {
|
|
85
|
-
key: "sameTerm",
|
|
86
|
-
value: function sameTerm(other) {
|
|
87
|
-
return this.equals(other);
|
|
44
|
+
if (this.value > other.value) {
|
|
45
|
+
return +1;
|
|
88
46
|
}
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
89
49
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return
|
|
50
|
+
/**
|
|
51
|
+
* Compares whether the two nodes are equal
|
|
52
|
+
* @param other The other node
|
|
53
|
+
*/
|
|
54
|
+
equals(other) {
|
|
55
|
+
if (!other) {
|
|
56
|
+
return false;
|
|
97
57
|
}
|
|
58
|
+
return this.termType === other.termType && this.value === other.value;
|
|
59
|
+
}
|
|
98
60
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
61
|
+
/**
|
|
62
|
+
* Creates a hash for this node
|
|
63
|
+
* @deprecated use {rdfFactory.id} instead if possible
|
|
64
|
+
*/
|
|
65
|
+
hashString() {
|
|
66
|
+
return this.toCanonical();
|
|
67
|
+
}
|
|
107
68
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
69
|
+
/**
|
|
70
|
+
* Compares whether this node is the same as the other one
|
|
71
|
+
* @param other - Another node
|
|
72
|
+
*/
|
|
73
|
+
sameTerm(other) {
|
|
74
|
+
return this.equals(other);
|
|
75
|
+
}
|
|
116
76
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Creates a canonical string representation of this node
|
|
79
|
+
*/
|
|
80
|
+
toCanonical() {
|
|
81
|
+
return this.toNT();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Creates a n-triples string representation of this node
|
|
86
|
+
*/
|
|
87
|
+
toNT() {
|
|
88
|
+
return this.toString();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Creates a n-quads string representation of this node
|
|
93
|
+
*/
|
|
94
|
+
toNQ() {
|
|
95
|
+
return this.toNT();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Creates a string representation of this node
|
|
100
|
+
*/
|
|
101
|
+
toString() {
|
|
102
|
+
throw new Error('Node.toString() is abstract - see the subclasses instead');
|
|
103
|
+
}
|
|
104
|
+
}
|
|
128
105
|
// Specified in './node.ts' to prevent circular dependency
|
|
129
106
|
_defineProperty(Node, "fromValue", void 0);
|
|
130
107
|
// Specified in './node.ts' to prevent circular dependency
|
|
131
|
-
_defineProperty(Node, "toJS", void 0);
|
|
132
|
-
export { Node as default };
|
|
108
|
+
_defineProperty(Node, "toJS", void 0);
|
package/esm/node.js
CHANGED
|
@@ -14,7 +14,7 @@ import { isCollection, isLiteral } from './utils/terms';
|
|
|
14
14
|
*/
|
|
15
15
|
Node.fromValue = fromValue;
|
|
16
16
|
export default Node;
|
|
17
|
-
|
|
17
|
+
const ns = {
|
|
18
18
|
xsd: Namespace('http://www.w3.org/2001/XMLSchema#')
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -26,7 +26,6 @@ Node.toJS = function (term) {
|
|
|
26
26
|
if (isCollection(term)) {
|
|
27
27
|
return term.elements.map(Node.toJS); // Array node (not standard RDFJS)
|
|
28
28
|
}
|
|
29
|
-
|
|
30
29
|
if (!isLiteral(term)) return term;
|
|
31
30
|
if (term.datatype.equals(ns.xsd('boolean'))) {
|
|
32
31
|
return term.value === '1' || term.value === 'true';
|
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
|
+
let contentType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'text/turtle';
|
|
24
|
+
let 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
|
+
let 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
|
|
16
|
+
var badSyntax = function (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
|
|
|
@@ -39,7 +39,6 @@ export default function sparqlUpdateParser(str, kb, base) {
|
|
|
39
39
|
if (i < 0) {
|
|
40
40
|
return clauses; // Allow end in a
|
|
41
41
|
}
|
|
42
|
-
|
|
43
42
|
j = i;
|
|
44
43
|
}
|
|
45
44
|
var found = false;
|
package/esm/query.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
1
|
// Matching a formula against another formula
|
|
4
2
|
// Assync as well as Synchronously
|
|
5
3
|
//
|
|
@@ -27,14 +25,15 @@ import { docpart } from './uri';
|
|
|
27
25
|
/**
|
|
28
26
|
* Query class, for tracking queries the user has in the UI.
|
|
29
27
|
*/
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
28
|
+
export class Query {
|
|
29
|
+
constructor(name, id) {
|
|
30
|
+
this.pat = new IndexedFormula(); // The pattern to search for
|
|
31
|
+
this.vars = []; // Used by UI code but not in query.js
|
|
32
|
+
// this.orderBy = [] // Not used yet
|
|
33
|
+
this.name = name;
|
|
34
|
+
this.id = id;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
38
37
|
|
|
39
38
|
/**
|
|
40
39
|
* This function will match a pattern to the current Store
|
|
@@ -90,7 +89,6 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
90
89
|
b[self] = other;
|
|
91
90
|
return [[b, null]]; // Match
|
|
92
91
|
}
|
|
93
|
-
|
|
94
92
|
actual = self;
|
|
95
93
|
}
|
|
96
94
|
if (!actual.complexType) {
|
|
@@ -122,11 +120,9 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
122
120
|
if (self.length !== other.length) {
|
|
123
121
|
return []; // no way
|
|
124
122
|
}
|
|
125
|
-
|
|
126
123
|
if (!self.length) {
|
|
127
124
|
return [[[], null]]; // Success
|
|
128
125
|
}
|
|
129
|
-
|
|
130
126
|
var nbs = unifyTerm(self[0], other[0], bindings, formula);
|
|
131
127
|
if (nbs.length === 0) {
|
|
132
128
|
return nbs;
|
|
@@ -149,13 +145,11 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
149
145
|
bindings2[v] = nb[v]; // copy
|
|
150
146
|
}
|
|
151
147
|
}
|
|
152
|
-
|
|
153
148
|
for (v in bindings) {
|
|
154
149
|
if (bindings.hasOwnProperty(v)) {
|
|
155
150
|
bindings2[v] = bindings[v]; // copy
|
|
156
151
|
}
|
|
157
152
|
}
|
|
158
|
-
|
|
159
153
|
nbs2 = unifyContents(self.slice(1), other.slice(1), bindings2, formula);
|
|
160
154
|
m = nbs2.length;
|
|
161
155
|
for (j = 0; j < m; j++) {
|
|
@@ -263,7 +257,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
263
257
|
};
|
|
264
258
|
|
|
265
259
|
// An optional branch hoards its results.
|
|
266
|
-
var OptionalBranch = function
|
|
260
|
+
var OptionalBranch = function (junction) {
|
|
267
261
|
this.count = 0;
|
|
268
262
|
this.done = false;
|
|
269
263
|
this.results = [];
|
|
@@ -302,7 +296,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
302
296
|
terms = [item.subject, item.predicate, item.object, item.why];
|
|
303
297
|
ind = [f.subjectIndex, f.predicateIndex, f.objectIndex, f.whyIndex];
|
|
304
298
|
for (i = 0; i < 4; i++) {
|
|
305
|
-
|
|
299
|
+
let t = terms[i];
|
|
306
300
|
// console.log(" Prepare (" + t + ") "+(t in bindings))
|
|
307
301
|
if (t.uri && t.uri === defaultDocumentURI) {// chrome:session
|
|
308
302
|
// console.log(' query: Ignoring slot ' + i)
|
|
@@ -314,13 +308,11 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
314
308
|
if (f.redirections[f.id(t)]) {
|
|
315
309
|
t = f.redirections[f.id(t)]; // redirect
|
|
316
310
|
}
|
|
317
|
-
|
|
318
311
|
termIndex = ind[i][f.id(t)];
|
|
319
312
|
if (!termIndex) {
|
|
320
313
|
item.index = [];
|
|
321
314
|
return false; // Query line cannot match
|
|
322
315
|
}
|
|
323
|
-
|
|
324
316
|
if (item.index === null || item.index.length > termIndex.length) {
|
|
325
317
|
// Find smallest index
|
|
326
318
|
item.index = termIndex;
|
|
@@ -356,7 +348,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
356
348
|
*
|
|
357
349
|
* Will fetch linked data from the web iff the knowledge base an associated source fetcher (f.fetcher)
|
|
358
350
|
***/
|
|
359
|
-
var match = function
|
|
351
|
+
var match = function (f, g, bindingsSoFar, level, fetcher, localCallback, branch) {
|
|
360
352
|
log.debug('Match begins, Branch count now: ' + branch.count + ' for ' + branch.pattern_debug);
|
|
361
353
|
|
|
362
354
|
// log.debug("match: f has "+f.statements.length+", g has "+g.statements.length)
|
|
@@ -375,7 +367,6 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
375
367
|
br[b] = new OptionalBranch(junction); // Allocate branches to prevent premature ending
|
|
376
368
|
br[b].pattern_debug = g.optional[b]; // for diagnotics only
|
|
377
369
|
}
|
|
378
|
-
|
|
379
370
|
for (b = 0; b < g.optional.length; b++) {
|
|
380
371
|
br[b].count = br[b].count + 1; // Count how many matches we have yet to complete
|
|
381
372
|
match(f, g.optional[b], bindingsSoFar, '', fetcher, callback, br[b]);
|
|
@@ -385,7 +376,6 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
385
376
|
log.debug('Match ends -- success , Branch count now: ' + branch.count + ' for ' + branch.pattern_debug);
|
|
386
377
|
return; // Success
|
|
387
378
|
}
|
|
388
|
-
|
|
389
379
|
var item;
|
|
390
380
|
var i;
|
|
391
381
|
var n = pattern.length;
|
|
@@ -395,7 +385,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
395
385
|
if (fetcher) {
|
|
396
386
|
// Fetcher is used to fetch URIs, function first term is a URI term, second is the requester
|
|
397
387
|
var id = 'match' + matchIndex++;
|
|
398
|
-
var fetchResource = function
|
|
388
|
+
var fetchResource = function (requestedTerm, id) {
|
|
399
389
|
var docuri = requestedTerm.uri.split('#')[0];
|
|
400
390
|
fetcher.nowOrWhenFetched(docuri, undefined, function (ok, body, xhr) {
|
|
401
391
|
if (!ok) {
|
|
@@ -413,7 +403,6 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
413
403
|
fetchResource(bindingsSoFar[item.subject], id);
|
|
414
404
|
return; // only look up one per line this time, but we will come back again though match
|
|
415
405
|
}
|
|
416
|
-
|
|
417
406
|
if (bindingsSoFar[item.object] !== undefined && bindingsSoFar[item.object].uri && fetcher && fetcher.getState(docpart(bindingsSoFar[item.object].uri)) === 'unrequested') {
|
|
418
407
|
fetchResource(bindingsSoFar[item.object], id);
|
|
419
408
|
return;
|
|
@@ -423,7 +412,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
423
412
|
match2(f, g, bindingsSoFar, level, fetcher, localCallback, branch);
|
|
424
413
|
}; // match
|
|
425
414
|
|
|
426
|
-
var constraintsSatisfied = function
|
|
415
|
+
var constraintsSatisfied = function (bindings, constraints) {
|
|
427
416
|
var res = true;
|
|
428
417
|
var x;
|
|
429
418
|
var test;
|
|
@@ -441,7 +430,7 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
441
430
|
};
|
|
442
431
|
|
|
443
432
|
/** match2 -- stuff after the fetch **/
|
|
444
|
-
var match2 = function
|
|
433
|
+
var match2 = function (f, g, bindingsSoFar, level, fetcher, callback, branch) {
|
|
445
434
|
// post fetch
|
|
446
435
|
var pattern = g.statements;
|
|
447
436
|
var n = pattern.length;
|
|
@@ -459,7 +448,6 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
459
448
|
prepare(f, item, bindingsSoFar);
|
|
460
449
|
// if (item.index) console.log(' item.index.length ' + item.index.length)
|
|
461
450
|
}
|
|
462
|
-
|
|
463
451
|
pattern.sort(easiestQuery);
|
|
464
452
|
item = pattern[0];
|
|
465
453
|
// log.debug("Sorted pattern:\n"+pattern)
|
|
@@ -496,20 +484,17 @@ export function indexedFormulaQuery(myQuery, callback, fetcher, onDone) {
|
|
|
496
484
|
bindings2[v] = newBindings1[v]; // copy
|
|
497
485
|
}
|
|
498
486
|
}
|
|
499
|
-
|
|
500
487
|
for (v in bindingsSoFar) {
|
|
501
488
|
if (bindingsSoFar.hasOwnProperty(v)) {
|
|
502
489
|
bindings2[v] = bindingsSoFar[v]; // copy
|
|
503
490
|
}
|
|
504
491
|
}
|
|
505
|
-
|
|
506
492
|
branch.count++; // Count how many matches we have yet to complete
|
|
507
493
|
onward++;
|
|
508
494
|
match(f, rest, bindings2, level + ' ', fetcher, callback, branch); // call match
|
|
509
495
|
}
|
|
510
496
|
}
|
|
511
497
|
}
|
|
512
|
-
|
|
513
498
|
branch.count--;
|
|
514
499
|
if (onward === 0) {
|
|
515
500
|
log.debug('Match2 fails completely on ' + item);
|