rdflib 2.2.22-4e175603 → 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 +51 -31
- package/esm/jsonldparser.js +26 -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 -20
- 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.js +87 -66
- package/lib/jsonldparser.js +26 -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 -21
- 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 +6 -6
- package/src/jsonldparser.js +1 -1
- package/src/serialize.ts +4 -14
- package/src/serializer.js +24 -0
- package/src/update-manager.ts +8 -2
package/lib/literal.js
CHANGED
|
@@ -5,6 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
12
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
8
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
16
|
var _classOrder = _interopRequireDefault(require("./class-order"));
|
|
10
17
|
var _namedNode = _interopRequireDefault(require("./named-node"));
|
|
@@ -12,11 +19,15 @@ var _nodeInternal = _interopRequireDefault(require("./node-internal"));
|
|
|
12
19
|
var _types = require("./types");
|
|
13
20
|
var _terms = require("./utils/terms");
|
|
14
21
|
var _xsdInternal = _interopRequireDefault(require("./xsd-internal"));
|
|
22
|
+
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); }; }
|
|
23
|
+
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; } }
|
|
15
24
|
/**
|
|
16
25
|
* An RDF literal, containing some value which isn't expressed as an IRI.
|
|
17
26
|
* @link https://rdf.js.org/data-model-spec/#literal-interface
|
|
18
27
|
*/
|
|
19
|
-
|
|
28
|
+
var Literal = /*#__PURE__*/function (_Node) {
|
|
29
|
+
(0, _inherits2.default)(Literal, _Node);
|
|
30
|
+
var _super = _createSuper(Literal);
|
|
20
31
|
/**
|
|
21
32
|
* The literal's datatype as a named node
|
|
22
33
|
*/
|
|
@@ -31,145 +42,170 @@ class Literal extends _nodeInternal.default {
|
|
|
31
42
|
* @param language - The language for the literal. Defaults to ''.
|
|
32
43
|
* @param datatype - The literal's datatype as a named node. Defaults to xsd:string.
|
|
33
44
|
*/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
(0,
|
|
37
|
-
|
|
38
|
-
(0, _defineProperty2.default)(
|
|
39
|
-
(0, _defineProperty2.default)(
|
|
40
|
-
(0, _defineProperty2.default)(
|
|
45
|
+
function Literal(value, language, datatype) {
|
|
46
|
+
var _this;
|
|
47
|
+
(0, _classCallCheck2.default)(this, Literal);
|
|
48
|
+
_this = _super.call(this, value);
|
|
49
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "termType", _types.LiteralTermType);
|
|
50
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "classOrder", _classOrder.default.Literal);
|
|
51
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "datatype", _xsdInternal.default.string);
|
|
52
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isVar", 0);
|
|
53
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "language", '');
|
|
41
54
|
if (language) {
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
_this.language = language;
|
|
56
|
+
_this.datatype = _xsdInternal.default.langString;
|
|
44
57
|
} else if (datatype) {
|
|
45
|
-
|
|
58
|
+
_this.datatype = _namedNode.default.fromValue(datatype);
|
|
46
59
|
} else {
|
|
47
|
-
|
|
60
|
+
_this.datatype = _xsdInternal.default.string;
|
|
48
61
|
}
|
|
62
|
+
return _this;
|
|
49
63
|
}
|
|
50
64
|
|
|
51
65
|
/**
|
|
52
66
|
* Gets a copy of this literal
|
|
53
67
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Gets whether two literals are the same
|
|
60
|
-
* @param other The other statement
|
|
61
|
-
*/
|
|
62
|
-
equals(other) {
|
|
63
|
-
if (!other) {
|
|
64
|
-
return false;
|
|
68
|
+
(0, _createClass2.default)(Literal, [{
|
|
69
|
+
key: "copy",
|
|
70
|
+
value: function copy() {
|
|
71
|
+
return new Literal(this.value, this.lang, this.datatype);
|
|
65
72
|
}
|
|
66
|
-
return this.termType === other.termType && this.value === other.value && this.language === other.language && (!this.datatype && !other.datatype || this.datatype && this.datatype.equals(other.datatype));
|
|
67
|
-
}
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
74
|
+
/**
|
|
75
|
+
* Gets whether two literals are the same
|
|
76
|
+
* @param other The other statement
|
|
77
|
+
*/
|
|
78
|
+
}, {
|
|
79
|
+
key: "equals",
|
|
80
|
+
value: function equals(other) {
|
|
81
|
+
if (!other) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
return this.termType === other.termType && this.value === other.value && this.language === other.language && (!this.datatype && !other.datatype || this.datatype && this.datatype.equals(other.datatype));
|
|
85
|
+
}
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
/**
|
|
88
|
+
* The language for the literal
|
|
89
|
+
* @deprecated use {language} instead
|
|
90
|
+
*/
|
|
91
|
+
}, {
|
|
92
|
+
key: "lang",
|
|
93
|
+
get: function get() {
|
|
94
|
+
return this.language;
|
|
95
|
+
},
|
|
96
|
+
set: function set(language) {
|
|
97
|
+
this.language = language || '';
|
|
89
98
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
str = str.replace(/\"/g, '\\"');
|
|
95
|
-
str = str.replace(/\n/g, '\\n');
|
|
96
|
-
str = str.replace(/\r/g, '\\r');
|
|
97
|
-
str = '"' + str + '"';
|
|
98
|
-
if (literal.language) {
|
|
99
|
-
str += '@' + literal.language;
|
|
100
|
-
} else if (!literal.datatype.equals(_xsdInternal.default.string)) {
|
|
101
|
-
// Only add datatype if it's not a string
|
|
102
|
-
str += '^^' + literal.datatype.toCanonical();
|
|
99
|
+
}, {
|
|
100
|
+
key: "toNT",
|
|
101
|
+
value: function toNT() {
|
|
102
|
+
return Literal.toNT(this);
|
|
103
103
|
}
|
|
104
|
-
return str;
|
|
105
|
-
}
|
|
106
|
-
toString() {
|
|
107
|
-
return '' + this.value;
|
|
108
|
-
}
|
|
109
104
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
let strValue = value ? '1' : '0';
|
|
116
|
-
return new Literal(strValue, null, _xsdInternal.default.boolean);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Builds a literal node from a date value
|
|
121
|
-
* @param value The value
|
|
122
|
-
*/
|
|
123
|
-
static fromDate(value) {
|
|
124
|
-
if (!(value instanceof Date)) {
|
|
125
|
-
throw new TypeError('Invalid argument to Literal.fromDate()');
|
|
105
|
+
/** Serializes a literal to an N-Triples string */
|
|
106
|
+
}, {
|
|
107
|
+
key: "toString",
|
|
108
|
+
value: function toString() {
|
|
109
|
+
return '' + this.value;
|
|
126
110
|
}
|
|
127
|
-
let d2 = function (x) {
|
|
128
|
-
return ('' + (100 + x)).slice(1, 3);
|
|
129
|
-
};
|
|
130
|
-
let date = '' + value.getUTCFullYear() + '-' + d2(value.getUTCMonth() + 1) + '-' + d2(value.getUTCDate()) + 'T' + d2(value.getUTCHours()) + ':' + d2(value.getUTCMinutes()) + ':' + d2(value.getUTCSeconds()) + 'Z';
|
|
131
|
-
return new Literal(date, null, _xsdInternal.default.dateTime);
|
|
132
|
-
}
|
|
133
111
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Builds a literal node from a boolean value
|
|
114
|
+
* @param value - The value
|
|
115
|
+
*/
|
|
116
|
+
}], [{
|
|
117
|
+
key: "toNT",
|
|
118
|
+
value: function toNT(literal) {
|
|
119
|
+
if (typeof literal.value === 'number') {
|
|
120
|
+
return '' + literal.value;
|
|
121
|
+
} else if (typeof literal.value !== 'string') {
|
|
122
|
+
throw new Error('Value of RDF literal is not string or number: ' + literal.value);
|
|
123
|
+
}
|
|
124
|
+
var str = literal.value;
|
|
125
|
+
// #x22 ("), #x5C (\), #x0A (\n) and #xD (\r) are disallowed and need to be replaced
|
|
126
|
+
// see https://www.w3.org/TR/n-triples/#grammar-production-STRING_LITERAL_QUOTE
|
|
127
|
+
str = str.replace(/\\/g, '\\\\');
|
|
128
|
+
str = str.replace(/\"/g, '\\"');
|
|
129
|
+
str = str.replace(/\n/g, '\\n');
|
|
130
|
+
str = str.replace(/\r/g, '\\r');
|
|
131
|
+
str = '"' + str + '"';
|
|
132
|
+
if (literal.language) {
|
|
133
|
+
str += '@' + literal.language;
|
|
134
|
+
} else if (!literal.datatype.equals(_xsdInternal.default.string)) {
|
|
135
|
+
// Only add datatype if it's not a string
|
|
136
|
+
str += '^^' + literal.datatype.toCanonical();
|
|
137
|
+
}
|
|
138
|
+
return str;
|
|
141
139
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
datatype = _xsdInternal.default.double;
|
|
140
|
+
}, {
|
|
141
|
+
key: "fromBoolean",
|
|
142
|
+
value: function fromBoolean(value) {
|
|
143
|
+
var strValue = value ? '1' : '0';
|
|
144
|
+
return new Literal(strValue, null, _xsdInternal.default.boolean);
|
|
148
145
|
}
|
|
149
|
-
return new Literal(strValue, null, datatype);
|
|
150
|
-
}
|
|
151
146
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
147
|
+
/**
|
|
148
|
+
* Builds a literal node from a date value
|
|
149
|
+
* @param value The value
|
|
150
|
+
*/
|
|
151
|
+
}, {
|
|
152
|
+
key: "fromDate",
|
|
153
|
+
value: function fromDate(value) {
|
|
154
|
+
if (!(value instanceof Date)) {
|
|
155
|
+
throw new TypeError('Invalid argument to Literal.fromDate()');
|
|
156
|
+
}
|
|
157
|
+
var d2 = function d2(x) {
|
|
158
|
+
return ('' + (100 + x)).slice(1, 3);
|
|
159
|
+
};
|
|
160
|
+
var date = '' + value.getUTCFullYear() + '-' + d2(value.getUTCMonth() + 1) + '-' + d2(value.getUTCDate()) + 'T' + d2(value.getUTCHours()) + ':' + d2(value.getUTCMinutes()) + ':' + d2(value.getUTCSeconds()) + 'Z';
|
|
161
|
+
return new Literal(date, null, _xsdInternal.default.dateTime);
|
|
159
162
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Builds a literal node from a number value
|
|
166
|
+
* @param value - The value
|
|
167
|
+
*/
|
|
168
|
+
}, {
|
|
169
|
+
key: "fromNumber",
|
|
170
|
+
value: function fromNumber(value) {
|
|
171
|
+
if (typeof value !== 'number') {
|
|
172
|
+
throw new TypeError('Invalid argument to Literal.fromNumber()');
|
|
173
|
+
}
|
|
174
|
+
var datatype;
|
|
175
|
+
var strValue = value.toString();
|
|
176
|
+
if (strValue.indexOf('e') < 0 && Math.abs(value) <= Number.MAX_SAFE_INTEGER) {
|
|
177
|
+
datatype = Number.isInteger(value) ? _xsdInternal.default.integer : _xsdInternal.default.decimal;
|
|
178
|
+
} else {
|
|
179
|
+
datatype = _xsdInternal.default.double;
|
|
180
|
+
}
|
|
181
|
+
return new Literal(strValue, null, datatype);
|
|
171
182
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Builds a literal node from an input value
|
|
186
|
+
* @param value - The input value
|
|
187
|
+
*/
|
|
188
|
+
}, {
|
|
189
|
+
key: "fromValue",
|
|
190
|
+
value: function fromValue(value) {
|
|
191
|
+
if ((0, _terms.isLiteral)(value)) {
|
|
192
|
+
return value;
|
|
193
|
+
}
|
|
194
|
+
switch ((0, _typeof2.default)(value)) {
|
|
195
|
+
case 'object':
|
|
196
|
+
if (value instanceof Date) {
|
|
197
|
+
return Literal.fromDate(value);
|
|
198
|
+
}
|
|
199
|
+
case 'boolean':
|
|
200
|
+
return Literal.fromBoolean(value);
|
|
201
|
+
case 'number':
|
|
202
|
+
return Literal.fromNumber(value);
|
|
203
|
+
case 'string':
|
|
204
|
+
return new Literal(value);
|
|
205
|
+
}
|
|
206
|
+
throw new Error("Can't make literal from " + value + ' of type ' + (0, _typeof2.default)(value));
|
|
207
|
+
}
|
|
208
|
+
}]);
|
|
209
|
+
return Literal;
|
|
210
|
+
}(_nodeInternal.default);
|
|
175
211
|
exports.default = Literal;
|
package/lib/log.js
CHANGED
|
@@ -8,13 +8,13 @@ exports.default = void 0;
|
|
|
8
8
|
* A Dummy log
|
|
9
9
|
* @module log
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
debug(x) {},
|
|
13
|
-
warn(x) {},
|
|
14
|
-
info(x) {},
|
|
15
|
-
error(x) {},
|
|
16
|
-
success(x) {},
|
|
17
|
-
msg(x) {}
|
|
11
|
+
var log = {
|
|
12
|
+
debug: function debug(x) {},
|
|
13
|
+
warn: function warn(x) {},
|
|
14
|
+
info: function info(x) {},
|
|
15
|
+
error: function error(x) {},
|
|
16
|
+
success: function success(x) {},
|
|
17
|
+
msg: function msg(x) {}
|
|
18
18
|
};
|
|
19
19
|
var _default = log;
|
|
20
20
|
exports.default = _default;
|