rdflib 2.2.21 → 2.2.22-0de51c50
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 +13 -1
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +3 -27
- package/esm/collection.js +7 -29
- package/esm/default-graph.js +1 -15
- package/esm/empty.js +0 -13
- package/esm/factories/canonical-data-factory.js +5 -40
- package/esm/factories/extended-term-factory.js +0 -11
- package/esm/factories/factory-types.js +2 -1
- package/esm/factories/rdflib-data-factory.js +0 -8
- package/esm/fetcher.js +257 -481
- package/esm/formula.js +43 -142
- package/esm/index.js +19 -36
- package/esm/jsonldparser.js +20 -29
- package/esm/jsonparser.js +0 -7
- package/esm/lists.js +18 -33
- package/esm/literal.js +10 -42
- package/esm/n3parser.js +38 -351
- package/esm/named-node.js +8 -27
- package/esm/namespace.js +0 -1
- package/esm/node-internal.js +11 -24
- package/esm/node.js +1 -6
- package/esm/parse.js +10 -17
- package/esm/patch-parser.js +9 -29
- package/esm/query-to-sparql.js +0 -18
- package/esm/query.js +50 -133
- package/esm/rdfaparser.js +72 -210
- package/esm/rdfxmlparser.js +31 -128
- package/esm/serialize.js +8 -33
- package/esm/serializer.js +122 -286
- package/esm/sparql-to-query.js +44 -134
- package/esm/statement.js +8 -19
- package/esm/store.js +109 -280
- package/esm/types.js +3 -2
- package/esm/update-manager.js +110 -246
- package/esm/updates-via.js +0 -27
- package/esm/uri.js +6 -50
- package/esm/utils/default-graph-uri.js +1 -0
- package/esm/utils/termValue.js +0 -1
- package/esm/utils/terms.js +15 -16
- package/esm/utils-js.js +16 -57
- package/esm/utils.js +4 -15
- package/esm/variable.js +0 -20
- package/lib/blank-node.js +3 -28
- package/lib/class-order.js +0 -1
- package/lib/collection.js +7 -34
- package/lib/default-graph.js +0 -20
- package/lib/empty.js +0 -18
- package/lib/factories/canonical-data-factory.js +4 -51
- package/lib/factories/extended-term-factory.js +0 -18
- package/lib/factories/factory-types.d.ts +6 -6
- package/lib/factories/factory-types.js +0 -3
- package/lib/factories/rdflib-data-factory.js +0 -12
- package/lib/fetcher.d.ts +6 -6
- package/lib/fetcher.js +258 -470
- package/lib/formula.d.ts +1 -1
- package/lib/formula.js +43 -151
- package/lib/index.d.ts +1 -2
- package/lib/index.js +14 -82
- package/lib/jsonldparser.js +19 -33
- package/lib/jsonparser.js +0 -9
- package/lib/lists.js +14 -39
- package/lib/literal.js +10 -49
- package/lib/log.d.ts +0 -6
- package/lib/log.js +0 -1
- package/lib/n3parser.d.ts +1 -0
- package/lib/n3parser.js +39 -359
- package/lib/named-node.js +7 -35
- package/lib/namespace.js +0 -3
- package/lib/node-internal.js +11 -21
- package/lib/node.js +1 -11
- package/lib/parse.d.ts +1 -1
- package/lib/parse.js +8 -27
- package/lib/patch-parser.js +10 -33
- package/lib/query-to-sparql.js +0 -23
- package/lib/query.js +46 -152
- package/lib/rdfaparser.js +72 -220
- package/lib/rdfxmlparser.js +31 -132
- package/lib/serialize.d.ts +1 -1
- package/lib/serialize.js +8 -43
- package/lib/serializer.d.ts +1 -0
- package/lib/serializer.js +121 -297
- package/lib/sparql-to-query.js +42 -167
- package/lib/statement.js +8 -24
- package/lib/store.d.ts +2 -2
- package/lib/store.js +102 -282
- package/lib/tf-types.d.ts +4 -4
- package/lib/types.d.ts +8 -8
- package/lib/types.js +3 -3
- package/lib/update-manager.d.ts +2 -2
- package/lib/update-manager.js +110 -254
- package/lib/updates-via.js +0 -30
- package/lib/uri.js +5 -58
- package/lib/utils/default-graph-uri.js +1 -3
- package/lib/utils/termValue.js +0 -2
- package/lib/utils/terms.js +15 -34
- package/lib/utils-js.js +16 -80
- package/lib/utils.js +4 -21
- package/lib/variable.js +0 -25
- package/lib/xsd-internal.js +0 -3
- package/lib/xsd.js +0 -4
- package/package.json +40 -39
- package/src/fetcher.ts +2 -2
- package/src/index.ts +0 -2
- package/src/jsonldparser.js +13 -4
- package/src/n3parser.js +12 -4
- package/src/serialize.ts +4 -11
- package/src/serializer.js +24 -0
- package/src/update-manager.ts +18 -7
- package/changes.txt +0 -59
- package/esm/convert.js +0 -61
- package/lib/convert.d.ts +0 -2
- package/lib/convert.js +0 -77
- package/src/convert.js +0 -70
package/esm/blank-node.js
CHANGED
|
@@ -5,50 +5,36 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
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); }; }
|
|
10
|
-
|
|
11
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; } }
|
|
12
|
-
|
|
13
10
|
import ClassOrder from './class-order';
|
|
14
11
|
import Node from './node-internal';
|
|
15
12
|
import { BlankNodeTermType } from './types';
|
|
16
|
-
|
|
17
13
|
/**
|
|
18
14
|
* An RDF blank node is a Node without a URI
|
|
19
15
|
* @link https://rdf.js.org/data-model-spec/#blanknode-interface
|
|
20
16
|
*/
|
|
21
17
|
var BlankNode = /*#__PURE__*/function (_Node) {
|
|
22
18
|
_inherits(BlankNode, _Node);
|
|
23
|
-
|
|
24
19
|
var _super = _createSuper(BlankNode);
|
|
25
|
-
|
|
26
20
|
/**
|
|
27
21
|
* Initializes this node
|
|
28
22
|
* @param [id] The identifier for the blank node
|
|
29
23
|
*/
|
|
30
24
|
function BlankNode(id) {
|
|
31
25
|
var _this;
|
|
32
|
-
|
|
33
26
|
_classCallCheck(this, BlankNode);
|
|
34
|
-
|
|
35
27
|
_this = _super.call(this, BlankNode.getId(id));
|
|
36
|
-
|
|
37
28
|
_defineProperty(_assertThisInitialized(_this), "termType", BlankNodeTermType);
|
|
38
|
-
|
|
39
29
|
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.BlankNode);
|
|
40
|
-
|
|
41
30
|
_defineProperty(_assertThisInitialized(_this), "isBlank", 1);
|
|
42
|
-
|
|
43
31
|
_defineProperty(_assertThisInitialized(_this), "isVar", 1);
|
|
44
|
-
|
|
45
32
|
return _this;
|
|
46
33
|
}
|
|
34
|
+
|
|
47
35
|
/**
|
|
48
36
|
* The identifier for the blank node
|
|
49
37
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
38
|
_createClass(BlankNode, [{
|
|
53
39
|
key: "id",
|
|
54
40
|
get: function get() {
|
|
@@ -63,26 +49,22 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
63
49
|
if (this.classOrder < other.classOrder) {
|
|
64
50
|
return -1;
|
|
65
51
|
}
|
|
66
|
-
|
|
67
52
|
if (this.classOrder > other.classOrder) {
|
|
68
53
|
return +1;
|
|
69
54
|
}
|
|
70
|
-
|
|
71
55
|
if (this.id < other.id) {
|
|
72
56
|
return -1;
|
|
73
57
|
}
|
|
74
|
-
|
|
75
58
|
if (this.id > other.id) {
|
|
76
59
|
return +1;
|
|
77
60
|
}
|
|
78
|
-
|
|
79
61
|
return 0;
|
|
80
62
|
}
|
|
63
|
+
|
|
81
64
|
/**
|
|
82
65
|
* Gets a copy of this blank node in the specified formula
|
|
83
66
|
* @param formula The formula
|
|
84
67
|
*/
|
|
85
|
-
|
|
86
68
|
}, {
|
|
87
69
|
key: "copy",
|
|
88
70
|
value: function copy(formula) {
|
|
@@ -107,31 +89,25 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
107
89
|
/**
|
|
108
90
|
* The next unique identifier for blank nodes
|
|
109
91
|
*/
|
|
92
|
+
|
|
110
93
|
function getId(id) {
|
|
111
94
|
if (id) {
|
|
112
95
|
if (typeof id !== 'string') {
|
|
113
96
|
console.log('Bad blank id:', id);
|
|
114
97
|
throw new Error('Bad id argument to new blank node: ' + id);
|
|
115
98
|
}
|
|
116
|
-
|
|
117
99
|
if (id.includes('#')) {
|
|
118
100
|
// Is a URI with hash fragment
|
|
119
101
|
var fragments = id.split('#');
|
|
120
102
|
return fragments[fragments.length - 1];
|
|
121
103
|
}
|
|
122
|
-
|
|
123
104
|
return id;
|
|
124
105
|
}
|
|
125
|
-
|
|
126
106
|
return 'n' + BlankNode.nextId++;
|
|
127
107
|
}
|
|
128
108
|
}]);
|
|
129
|
-
|
|
130
109
|
return BlankNode;
|
|
131
110
|
}(Node);
|
|
132
|
-
|
|
133
111
|
_defineProperty(BlankNode, "nextId", 0);
|
|
134
|
-
|
|
135
112
|
_defineProperty(BlankNode, "NTAnonymousNodePrefix", '_:');
|
|
136
|
-
|
|
137
113
|
export { BlankNode as default };
|
package/esm/collection.js
CHANGED
|
@@ -5,18 +5,14 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
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); }; }
|
|
10
|
-
|
|
11
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; } }
|
|
12
|
-
|
|
13
10
|
import RdflibBlankNode from './blank-node';
|
|
14
11
|
import ClassOrder from './class-order';
|
|
15
12
|
import Literal from './literal';
|
|
16
13
|
import Node from './node-internal';
|
|
17
14
|
import { CollectionTermType } from './types';
|
|
18
15
|
import { isTerm } from './utils/terms';
|
|
19
|
-
|
|
20
16
|
/**
|
|
21
17
|
* Creates an RDF Node from a native javascript value.
|
|
22
18
|
* RDF Nodes are returned unchanged, undefined returned as itself.
|
|
@@ -29,60 +25,45 @@ export function fromValue(value) {
|
|
|
29
25
|
if (typeof value === 'undefined' || value === null) {
|
|
30
26
|
return value;
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
if (isTerm(value)) {
|
|
34
29
|
// a Node subclass or a Collection
|
|
35
30
|
return value;
|
|
36
31
|
}
|
|
37
|
-
|
|
38
32
|
if (Array.isArray(value)) {
|
|
39
33
|
return new Collection(value);
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
return Literal.fromValue(value);
|
|
43
36
|
}
|
|
37
|
+
|
|
44
38
|
/**
|
|
45
39
|
* A collection of other RDF nodes
|
|
46
40
|
*
|
|
47
41
|
* Use generic T to control the contents of the array.
|
|
48
42
|
*/
|
|
49
|
-
|
|
50
43
|
var Collection = /*#__PURE__*/function (_Node) {
|
|
51
44
|
_inherits(Collection, _Node);
|
|
52
|
-
|
|
53
45
|
var _super = _createSuper(Collection);
|
|
54
|
-
|
|
55
46
|
/**
|
|
56
47
|
* The nodes in this collection
|
|
57
48
|
*/
|
|
49
|
+
|
|
58
50
|
function Collection(initial) {
|
|
59
51
|
var _this;
|
|
60
|
-
|
|
61
52
|
_classCallCheck(this, Collection);
|
|
62
|
-
|
|
63
53
|
_this = _super.call(this, (RdflibBlankNode.nextId++).toString());
|
|
64
|
-
|
|
65
54
|
_defineProperty(_assertThisInitialized(_this), "termType", CollectionTermType);
|
|
66
|
-
|
|
67
55
|
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.Collection);
|
|
68
|
-
|
|
69
56
|
_defineProperty(_assertThisInitialized(_this), "closed", false);
|
|
70
|
-
|
|
71
57
|
_defineProperty(_assertThisInitialized(_this), "compareTerm", RdflibBlankNode.prototype.compareTerm);
|
|
72
|
-
|
|
73
58
|
_defineProperty(_assertThisInitialized(_this), "elements", []);
|
|
74
|
-
|
|
75
59
|
_defineProperty(_assertThisInitialized(_this), "isVar", 0);
|
|
76
|
-
|
|
77
60
|
if (initial && initial.length > 0) {
|
|
78
61
|
initial.forEach(function (element) {
|
|
79
62
|
_this.elements.push(fromValue(element));
|
|
80
63
|
});
|
|
81
64
|
}
|
|
82
|
-
|
|
83
65
|
return _this;
|
|
84
66
|
}
|
|
85
|
-
|
|
86
67
|
_createClass(Collection, [{
|
|
87
68
|
key: "id",
|
|
88
69
|
get: function get() {
|
|
@@ -91,40 +72,40 @@ var Collection = /*#__PURE__*/function (_Node) {
|
|
|
91
72
|
set: function set(value) {
|
|
92
73
|
this.value = value;
|
|
93
74
|
}
|
|
75
|
+
|
|
94
76
|
/**
|
|
95
77
|
* Appends an element to this collection
|
|
96
78
|
* @param element - The new element
|
|
97
79
|
*/
|
|
98
|
-
|
|
99
80
|
}, {
|
|
100
81
|
key: "append",
|
|
101
82
|
value: function append(element) {
|
|
102
83
|
return this.elements.push(element);
|
|
103
84
|
}
|
|
85
|
+
|
|
104
86
|
/**
|
|
105
87
|
* Closes this collection
|
|
106
88
|
*/
|
|
107
|
-
|
|
108
89
|
}, {
|
|
109
90
|
key: "close",
|
|
110
91
|
value: function close() {
|
|
111
92
|
this.closed = true;
|
|
112
93
|
return this.closed;
|
|
113
94
|
}
|
|
95
|
+
|
|
114
96
|
/**
|
|
115
97
|
* Removes the first element from the collection (and return it)
|
|
116
98
|
*/
|
|
117
|
-
|
|
118
99
|
}, {
|
|
119
100
|
key: "shift",
|
|
120
101
|
value: function shift() {
|
|
121
102
|
return this.elements.shift();
|
|
122
103
|
}
|
|
104
|
+
|
|
123
105
|
/**
|
|
124
106
|
* Creates a new Collection with the substituting bindings applied
|
|
125
107
|
* @param bindings - The bindings to substitute
|
|
126
108
|
*/
|
|
127
|
-
|
|
128
109
|
}, {
|
|
129
110
|
key: "substitute",
|
|
130
111
|
value: function substitute(bindings) {
|
|
@@ -148,11 +129,11 @@ var Collection = /*#__PURE__*/function (_Node) {
|
|
|
148
129
|
function toString() {
|
|
149
130
|
return '(' + this.elements.join(' ') + ')';
|
|
150
131
|
}
|
|
132
|
+
|
|
151
133
|
/**
|
|
152
134
|
* Prepends the specified element to the collection's front
|
|
153
135
|
* @param element - The element to prepend
|
|
154
136
|
*/
|
|
155
|
-
|
|
156
137
|
}, {
|
|
157
138
|
key: "unshift",
|
|
158
139
|
value: function unshift(element) {
|
|
@@ -166,10 +147,7 @@ var Collection = /*#__PURE__*/function (_Node) {
|
|
|
166
147
|
return RdflibBlankNode.NTAnonymousNodePrefix + collection.id;
|
|
167
148
|
}
|
|
168
149
|
}]);
|
|
169
|
-
|
|
170
150
|
return Collection;
|
|
171
151
|
}(Node);
|
|
172
|
-
|
|
173
152
|
_defineProperty(Collection, "termType", CollectionTermType);
|
|
174
|
-
|
|
175
153
|
export { Collection as default };
|
package/esm/default-graph.js
CHANGED
|
@@ -5,37 +5,25 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
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); }; }
|
|
10
|
-
|
|
11
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; } }
|
|
12
|
-
|
|
13
10
|
import Node from './node-internal';
|
|
14
11
|
import { DefaultGraphTermType } from './types';
|
|
15
12
|
import { defaultGraphURI } from './utils/default-graph-uri';
|
|
16
|
-
/** The RDF default graph */
|
|
17
13
|
|
|
14
|
+
/** The RDF default graph */
|
|
18
15
|
var DefaultGraph = /*#__PURE__*/function (_Node) {
|
|
19
16
|
_inherits(DefaultGraph, _Node);
|
|
20
|
-
|
|
21
17
|
var _super = _createSuper(DefaultGraph);
|
|
22
|
-
|
|
23
18
|
function DefaultGraph() {
|
|
24
19
|
var _this;
|
|
25
|
-
|
|
26
20
|
_classCallCheck(this, DefaultGraph);
|
|
27
|
-
|
|
28
21
|
_this = _super.call(this, '');
|
|
29
|
-
|
|
30
22
|
_defineProperty(_assertThisInitialized(_this), "value", '');
|
|
31
|
-
|
|
32
23
|
_defineProperty(_assertThisInitialized(_this), "termType", DefaultGraphTermType);
|
|
33
|
-
|
|
34
24
|
_defineProperty(_assertThisInitialized(_this), "uri", defaultGraphURI);
|
|
35
|
-
|
|
36
25
|
return _this;
|
|
37
26
|
}
|
|
38
|
-
|
|
39
27
|
_createClass(DefaultGraph, [{
|
|
40
28
|
key: "toCanonical",
|
|
41
29
|
value: function toCanonical() {
|
|
@@ -47,10 +35,8 @@ var DefaultGraph = /*#__PURE__*/function (_Node) {
|
|
|
47
35
|
return 'DefaultGraph';
|
|
48
36
|
}
|
|
49
37
|
}]);
|
|
50
|
-
|
|
51
38
|
return DefaultGraph;
|
|
52
39
|
}(Node);
|
|
53
|
-
|
|
54
40
|
export { DefaultGraph as default };
|
|
55
41
|
export function isDefaultGraph(object) {
|
|
56
42
|
return !!object && object.termType === DefaultGraphTermType;
|
package/esm/empty.js
CHANGED
|
@@ -5,42 +5,29 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
|
|
9
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); }; }
|
|
10
|
-
|
|
11
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; } }
|
|
12
|
-
|
|
13
10
|
import Node from './node-internal';
|
|
14
11
|
import { EmptyTermType } from './types';
|
|
15
|
-
|
|
16
12
|
/**
|
|
17
13
|
* An empty node
|
|
18
14
|
*/
|
|
19
15
|
var Empty = /*#__PURE__*/function (_Node) {
|
|
20
16
|
_inherits(Empty, _Node);
|
|
21
|
-
|
|
22
17
|
var _super = _createSuper(Empty);
|
|
23
|
-
|
|
24
18
|
function Empty() {
|
|
25
19
|
var _this;
|
|
26
|
-
|
|
27
20
|
_classCallCheck(this, Empty);
|
|
28
|
-
|
|
29
21
|
_this = _super.call(this, '');
|
|
30
|
-
|
|
31
22
|
_defineProperty(_assertThisInitialized(_this), "termType", EmptyTermType);
|
|
32
|
-
|
|
33
23
|
return _this;
|
|
34
24
|
}
|
|
35
|
-
|
|
36
25
|
_createClass(Empty, [{
|
|
37
26
|
key: "toString",
|
|
38
27
|
value: function toString() {
|
|
39
28
|
return '()';
|
|
40
29
|
}
|
|
41
30
|
}]);
|
|
42
|
-
|
|
43
31
|
return Empty;
|
|
44
32
|
}(Node);
|
|
45
|
-
|
|
46
33
|
export { Empty as default };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
var _supports;
|
|
4
|
-
|
|
5
3
|
import BlankNode from '../blank-node';
|
|
6
4
|
import Literal from '../literal';
|
|
7
5
|
import NamedNode from '../named-node';
|
|
@@ -12,17 +10,15 @@ import DefaultGraph from '../default-graph';
|
|
|
12
10
|
import { Feature } from './factory-types';
|
|
13
11
|
import { isQuad, isTerm } from '../utils/terms';
|
|
14
12
|
export { defaultGraphURI } from '../utils/default-graph-uri';
|
|
13
|
+
|
|
15
14
|
/**
|
|
16
15
|
* Gets the default graph
|
|
17
16
|
*/
|
|
18
|
-
|
|
19
17
|
var _defaultGraph = new DefaultGraph();
|
|
20
|
-
/** A basic internal RDFlib datafactory, which does not support Collections */
|
|
21
|
-
|
|
22
18
|
|
|
19
|
+
/** A basic internal RDFlib datafactory, which does not support Collections */
|
|
23
20
|
var CanonicalDataFactory = {
|
|
24
21
|
supports: (_supports = {}, _defineProperty(_supports, Feature.collections, false), _defineProperty(_supports, Feature.defaultGraphType, false), _defineProperty(_supports, Feature.equalsMethod, true), _defineProperty(_supports, Feature.identity, false), _defineProperty(_supports, Feature.id, true), _defineProperty(_supports, Feature.reversibleId, false), _defineProperty(_supports, Feature.variableType, true), _supports),
|
|
25
|
-
|
|
26
22
|
/**
|
|
27
23
|
* Creates a new blank node
|
|
28
24
|
* @param value - The blank node's identifier
|
|
@@ -33,7 +29,6 @@ var CanonicalDataFactory = {
|
|
|
33
29
|
defaultGraph: function defaultGraph() {
|
|
34
30
|
return _defaultGraph;
|
|
35
31
|
},
|
|
36
|
-
|
|
37
32
|
/**
|
|
38
33
|
* Compares to (rdf) objects for equality.
|
|
39
34
|
*/
|
|
@@ -41,22 +36,17 @@ var CanonicalDataFactory = {
|
|
|
41
36
|
if (a === b || !a || !b) {
|
|
42
37
|
return true;
|
|
43
38
|
}
|
|
44
|
-
|
|
45
39
|
if (isQuad(a) || isQuad(b)) {
|
|
46
40
|
if (isQuad(a) && isQuad(b)) {
|
|
47
41
|
return this.equals(a.subject, b.subject) && this.equals(a.predicate, b.predicate) && this.equals(a.object, b.object) && this.equals(a.graph, b.graph);
|
|
48
42
|
}
|
|
49
|
-
|
|
50
43
|
return false;
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
if (isTerm(a) && isTerm(b)) {
|
|
54
46
|
return this.id(a) === this.id(b);
|
|
55
47
|
}
|
|
56
|
-
|
|
57
48
|
return false;
|
|
58
49
|
},
|
|
59
|
-
|
|
60
50
|
/**
|
|
61
51
|
* Generates a uniquely identifiably *idempotent* string for the given {term}.
|
|
62
52
|
*
|
|
@@ -69,32 +59,25 @@ var CanonicalDataFactory = {
|
|
|
69
59
|
if (!term) {
|
|
70
60
|
return 'undefined';
|
|
71
61
|
}
|
|
72
|
-
|
|
73
62
|
if (isQuad(term)) {
|
|
74
63
|
return this.quadToNQ(term);
|
|
75
64
|
}
|
|
76
|
-
|
|
77
65
|
switch (term.termType) {
|
|
78
66
|
case DefaultGraphTermType:
|
|
79
67
|
return 'defaultGraph';
|
|
80
|
-
|
|
81
68
|
case VariableTermType:
|
|
82
69
|
return Variable.toString(term);
|
|
83
|
-
|
|
84
70
|
default:
|
|
85
71
|
var nq = this.termToNQ(term);
|
|
86
|
-
|
|
87
72
|
if (nq) {
|
|
88
73
|
return nq;
|
|
89
74
|
}
|
|
90
|
-
|
|
91
75
|
throw new Error("Can't id term with type '".concat(term.termType, "'"));
|
|
92
76
|
}
|
|
93
77
|
},
|
|
94
78
|
isQuad: function isQuad(obj) {
|
|
95
79
|
return obj instanceof Statement;
|
|
96
80
|
},
|
|
97
|
-
|
|
98
81
|
/**
|
|
99
82
|
* Creates a new literal node. Does some JS literal parsing for ease of use.
|
|
100
83
|
* @param value - The lexical value
|
|
@@ -104,9 +87,7 @@ var CanonicalDataFactory = {
|
|
|
104
87
|
if (typeof value !== "string" && !languageOrDatatype) {
|
|
105
88
|
return Literal.fromValue(value);
|
|
106
89
|
}
|
|
107
|
-
|
|
108
90
|
var strValue = typeof value === 'string' ? value : '' + value;
|
|
109
|
-
|
|
110
91
|
if (typeof languageOrDatatype === 'string') {
|
|
111
92
|
if (languageOrDatatype.indexOf(':') === -1) {
|
|
112
93
|
return new Literal(strValue, languageOrDatatype);
|
|
@@ -117,7 +98,6 @@ var CanonicalDataFactory = {
|
|
|
117
98
|
return new Literal(strValue, null, languageOrDatatype);
|
|
118
99
|
}
|
|
119
100
|
},
|
|
120
|
-
|
|
121
101
|
/**
|
|
122
102
|
* Creates a new named node
|
|
123
103
|
* @param value - The new named node
|
|
@@ -125,7 +105,6 @@ var CanonicalDataFactory = {
|
|
|
125
105
|
namedNode: function namedNode(value) {
|
|
126
106
|
return new NamedNode(value);
|
|
127
107
|
},
|
|
128
|
-
|
|
129
108
|
/**
|
|
130
109
|
* Creates a new statement
|
|
131
110
|
* @param subject - The subject
|
|
@@ -136,7 +115,6 @@ var CanonicalDataFactory = {
|
|
|
136
115
|
quad: function quad(subject, predicate, object, graph) {
|
|
137
116
|
return new Statement(subject, predicate, object, graph || _defaultGraph);
|
|
138
117
|
},
|
|
139
|
-
|
|
140
118
|
/**
|
|
141
119
|
* Creates a new statement
|
|
142
120
|
* @param subject - The subject
|
|
@@ -150,47 +128,34 @@ var CanonicalDataFactory = {
|
|
|
150
128
|
quadToNQ: function quadToNQ(q) {
|
|
151
129
|
return "".concat(this.termToNQ(q.subject), " ").concat(this.termToNQ(q.predicate), " ").concat(this.termToNQ(q.object), " ").concat(this.termToNQ(q.graph), " .");
|
|
152
130
|
},
|
|
153
|
-
|
|
154
|
-
/** Stringify a {term} to n-quads serialization. */
|
|
155
|
-
termToNQ: function termToNQ(term) {
|
|
131
|
+
/** Stringify a {term} to n-quads serialization. */termToNQ: function termToNQ(term) {
|
|
156
132
|
var _this = this;
|
|
157
|
-
|
|
158
133
|
switch (term.termType) {
|
|
159
134
|
case BlankNodeTermType:
|
|
160
135
|
return '_:' + term.value;
|
|
161
|
-
|
|
162
136
|
case DefaultGraphTermType:
|
|
163
137
|
return '';
|
|
164
|
-
|
|
165
138
|
case EmptyTermType:
|
|
166
139
|
return '<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>';
|
|
167
|
-
|
|
168
140
|
case LiteralTermType:
|
|
169
141
|
return Literal.toNT(term);
|
|
170
|
-
|
|
171
142
|
case GraphTermType:
|
|
172
143
|
case NamedNodeTermType:
|
|
173
144
|
return '<' + term.value + '>';
|
|
174
|
-
|
|
175
145
|
case CollectionTermType:
|
|
176
146
|
return '(' + term.elements.map(function (t) {
|
|
177
147
|
return _this.termToNQ(t);
|
|
178
148
|
}).join(' ') + ')';
|
|
179
|
-
|
|
180
149
|
default:
|
|
181
150
|
throw new Error("Can't serialize nonstandard term type (was '".concat(term.termType, "')"));
|
|
182
151
|
}
|
|
183
152
|
},
|
|
184
|
-
|
|
185
|
-
/** Convert an rdf object (term or quad) to n-quads serialization. */
|
|
186
|
-
toNQ: function toNQ(term) {
|
|
153
|
+
/** Convert an rdf object (term or quad) to n-quads serialization. */toNQ: function toNQ(term) {
|
|
187
154
|
if (this.isQuad(term)) {
|
|
188
155
|
return this.quadToNQ(term);
|
|
189
156
|
}
|
|
190
|
-
|
|
191
157
|
return this.termToNQ(term);
|
|
192
158
|
},
|
|
193
|
-
|
|
194
159
|
/**
|
|
195
160
|
* Creates a new variable
|
|
196
161
|
* @param name - The name for the variable
|
|
@@ -199,6 +164,6 @@ var CanonicalDataFactory = {
|
|
|
199
164
|
return new Variable(name);
|
|
200
165
|
}
|
|
201
166
|
};
|
|
202
|
-
/** Contains the factory methods as defined in the spec, plus id */
|
|
203
167
|
|
|
168
|
+
/** Contains the factory methods as defined in the spec, plus id */
|
|
204
169
|
export default CanonicalDataFactory;
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
var _supports;
|
|
4
|
-
|
|
5
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
-
|
|
7
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
|
|
9
5
|
import Collection from '../collection';
|
|
10
6
|
import CanonicalDataFactory from './canonical-data-factory';
|
|
11
7
|
import { CollectionTermType } from '../types';
|
|
12
8
|
import { Feature } from './factory-types';
|
|
13
9
|
import { isCollection, isVariable } from '../utils/terms';
|
|
14
10
|
import Variable from '../variable';
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* Data factory which also supports Collections
|
|
18
13
|
*
|
|
@@ -20,7 +15,6 @@ import Variable from '../variable';
|
|
|
20
15
|
*/
|
|
21
16
|
var ExtendedTermFactory = _objectSpread(_objectSpread({}, CanonicalDataFactory), {}, {
|
|
22
17
|
supports: (_supports = {}, _defineProperty(_supports, Feature.collections, true), _defineProperty(_supports, Feature.defaultGraphType, false), _defineProperty(_supports, Feature.equalsMethod, true), _defineProperty(_supports, Feature.identity, false), _defineProperty(_supports, Feature.id, true), _defineProperty(_supports, Feature.reversibleId, false), _defineProperty(_supports, Feature.variableType, true), _supports),
|
|
23
|
-
|
|
24
18
|
/**
|
|
25
19
|
* Creates a new collection
|
|
26
20
|
* @param elements - The initial element
|
|
@@ -30,26 +24,21 @@ var ExtendedTermFactory = _objectSpread(_objectSpread({}, CanonicalDataFactory),
|
|
|
30
24
|
},
|
|
31
25
|
id: function id(term) {
|
|
32
26
|
var _this = this;
|
|
33
|
-
|
|
34
27
|
if (isCollection(term)) {
|
|
35
28
|
return "( ".concat(term.elements.map(function (e) {
|
|
36
29
|
return _this.id(e);
|
|
37
30
|
}).join(', '), " )");
|
|
38
31
|
}
|
|
39
|
-
|
|
40
32
|
if (isVariable(term)) {
|
|
41
33
|
return Variable.toString(term);
|
|
42
34
|
}
|
|
43
|
-
|
|
44
35
|
return CanonicalDataFactory.id(term);
|
|
45
36
|
},
|
|
46
37
|
termToNQ: function termToNQ(term) {
|
|
47
38
|
if (term.termType === CollectionTermType) {
|
|
48
39
|
return Collection.toNT(term);
|
|
49
40
|
}
|
|
50
|
-
|
|
51
41
|
return CanonicalDataFactory.termToNQ(term);
|
|
52
42
|
}
|
|
53
43
|
});
|
|
54
|
-
|
|
55
44
|
export default ExtendedTermFactory;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/** A set of features that may be supported by a Data Factory */
|
|
2
|
+
|
|
2
3
|
export var Feature;
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Defines a DataFactory as used in rdflib, based on the RDF/JS: Data model specification,
|
|
5
7
|
* but with additional extensions
|
|
6
8
|
*
|
|
7
9
|
* bnIndex is optional but useful.
|
|
8
10
|
*/
|
|
9
|
-
|
|
10
11
|
(function (Feature) {
|
|
11
12
|
Feature["collections"] = "COLLECTIONS";
|
|
12
13
|
Feature["defaultGraphType"] = "DEFAULT_GRAPH_TYPE";
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
import IndexedFormula from '../store';
|
|
8
5
|
import Fetcher from '../fetcher';
|
|
9
6
|
import ExtendedTermFactory from './extended-term-factory';
|
|
10
|
-
|
|
11
7
|
/** Full RDFLib.js Data Factory */
|
|
12
8
|
var RDFlibDataFactory = _objectSpread(_objectSpread({}, ExtendedTermFactory), {}, {
|
|
13
9
|
/**
|
|
@@ -18,7 +14,6 @@ var RDFlibDataFactory = _objectSpread(_objectSpread({}, ExtendedTermFactory), {}
|
|
|
18
14
|
fetcher: function fetcher(store, options) {
|
|
19
15
|
return new Fetcher(store, options);
|
|
20
16
|
},
|
|
21
|
-
|
|
22
17
|
/**
|
|
23
18
|
* Creates a new graph (store)
|
|
24
19
|
*/
|
|
@@ -29,7 +24,6 @@ var RDFlibDataFactory = _objectSpread(_objectSpread({}, ExtendedTermFactory), {}
|
|
|
29
24
|
rdfFactory: ExtendedTermFactory
|
|
30
25
|
});
|
|
31
26
|
},
|
|
32
|
-
|
|
33
27
|
/**
|
|
34
28
|
* Creates a new literal node
|
|
35
29
|
* @param val The lexical value
|
|
@@ -39,7 +33,6 @@ var RDFlibDataFactory = _objectSpread(_objectSpread({}, ExtendedTermFactory), {}
|
|
|
39
33
|
lit: function lit(val, lang, dt) {
|
|
40
34
|
return this.literal('' + val, lang || dt);
|
|
41
35
|
},
|
|
42
|
-
|
|
43
36
|
/**
|
|
44
37
|
* Creates a new statement
|
|
45
38
|
* @param subject The subject
|
|
@@ -51,5 +44,4 @@ var RDFlibDataFactory = _objectSpread(_objectSpread({}, ExtendedTermFactory), {}
|
|
|
51
44
|
return this.quad(subject, predicate, object, graph);
|
|
52
45
|
}
|
|
53
46
|
});
|
|
54
|
-
|
|
55
47
|
export default RDFlibDataFactory;
|