rdflib 2.2.21 → 2.2.22-04669b23
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 +11 -1
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +61 -114
- package/esm/class-order.js +1 -1
- package/esm/collection.js +70 -128
- package/esm/default-graph.js +14 -48
- package/esm/empty.js +8 -39
- package/esm/factories/canonical-data-factory.js +33 -65
- package/esm/factories/extended-term-factory.js +18 -25
- package/esm/factories/factory-types.js +3 -2
- package/esm/factories/rdflib-data-factory.js +9 -19
- package/esm/fetcher.js +1341 -1854
- package/esm/formula.js +639 -846
- package/esm/index.js +40 -77
- package/esm/jsonldparser.js +34 -50
- package/esm/jsonparser.js +1 -8
- package/esm/lists.js +47 -110
- package/esm/literal.js +120 -189
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1022 -1412
- package/esm/named-node.js +70 -119
- package/esm/namespace.js +2 -5
- package/esm/node-internal.js +73 -110
- package/esm/node.js +2 -7
- package/esm/parse.js +12 -19
- package/esm/patch-parser.js +10 -30
- package/esm/query-to-sparql.js +0 -18
- package/esm/query.js +63 -147
- package/esm/rdfaparser.js +794 -997
- package/esm/rdfxmlparser.js +347 -461
- package/esm/serialize.js +9 -34
- package/esm/serializer.js +842 -1048
- package/esm/sparql-to-query.js +44 -134
- package/esm/statement.js +54 -85
- package/esm/store.js +830 -1103
- package/esm/types.js +22 -21
- package/esm/update-manager.js +869 -1106
- package/esm/updates-via.js +104 -161
- package/esm/uri.js +9 -53
- package/esm/utils/default-graph-uri.js +3 -2
- package/esm/utils/termValue.js +0 -1
- package/esm/utils/terms.js +19 -21
- package/esm/utils-js.js +20 -61
- package/esm/utils.js +10 -21
- package/esm/variable.js +32 -78
- package/esm/xsd.js +2 -2
- package/lib/blank-node.js +60 -113
- package/lib/class-order.js +1 -2
- package/lib/collection.js +69 -131
- package/lib/default-graph.js +13 -52
- package/lib/empty.js +8 -43
- package/lib/factories/canonical-data-factory.js +35 -79
- package/lib/factories/extended-term-factory.js +18 -32
- package/lib/factories/factory-types.d.ts +6 -6
- package/lib/factories/factory-types.js +1 -4
- package/lib/factories/rdflib-data-factory.js +9 -23
- package/lib/fetcher.d.ts +6 -6
- package/lib/fetcher.js +1370 -1843
- package/lib/formula.d.ts +1 -1
- package/lib/formula.js +640 -855
- package/lib/index.d.ts +1 -2
- package/lib/index.js +67 -156
- package/lib/jsonldparser.js +33 -54
- package/lib/jsonparser.js +1 -10
- package/lib/lists.js +55 -112
- package/lib/literal.js +120 -195
- package/lib/log.d.ts +0 -6
- package/lib/log.js +7 -8
- package/lib/n3parser.d.ts +1 -0
- package/lib/n3parser.js +1023 -1422
- package/lib/named-node.js +69 -126
- package/lib/namespace.js +2 -7
- package/lib/node-internal.js +74 -107
- package/lib/node.js +2 -12
- package/lib/parse.d.ts +1 -1
- package/lib/parse.js +12 -32
- package/lib/patch-parser.js +11 -34
- package/lib/query-to-sparql.js +0 -23
- package/lib/query.js +62 -167
- package/lib/rdfaparser.js +796 -1009
- package/lib/rdfxmlparser.js +349 -466
- package/lib/serialize.d.ts +1 -1
- package/lib/serialize.js +9 -44
- package/lib/serializer.d.ts +1 -0
- package/lib/serializer.js +846 -1063
- package/lib/sparql-to-query.js +42 -167
- package/lib/statement.js +55 -91
- package/lib/store.d.ts +2 -2
- package/lib/store.js +850 -1112
- package/lib/tf-types.d.ts +4 -4
- package/lib/types.d.ts +8 -8
- package/lib/types.js +23 -23
- package/lib/update-manager.d.ts +1 -1
- package/lib/update-manager.js +865 -1103
- package/lib/updates-via.js +105 -164
- package/lib/uri.js +8 -61
- package/lib/utils/default-graph-uri.js +3 -5
- package/lib/utils/termValue.js +0 -2
- package/lib/utils/terms.js +19 -40
- package/lib/utils-js.js +23 -88
- package/lib/utils.js +10 -27
- package/lib/variable.js +34 -85
- package/lib/xsd-internal.js +0 -3
- package/lib/xsd.js +2 -6
- 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 +12 -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/lib/variable.js
CHANGED
|
@@ -1,44 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
4
|
Object.defineProperty(exports, "__esModule", {
|
|
8
5
|
value: true
|
|
9
6
|
});
|
|
10
7
|
exports.default = void 0;
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
24
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
9
|
var _classOrder = _interopRequireDefault(require("./class-order"));
|
|
27
|
-
|
|
28
10
|
var _nodeInternal = _interopRequireDefault(require("./node-internal"));
|
|
29
|
-
|
|
30
11
|
var _types = require("./types");
|
|
31
|
-
|
|
32
12
|
var Uri = _interopRequireWildcard(require("./uri"));
|
|
33
|
-
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
-
|
|
38
|
-
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); }; }
|
|
39
|
-
|
|
40
|
-
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; } }
|
|
41
|
-
|
|
13
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
42
15
|
/**
|
|
43
16
|
* Variables are placeholders used in patterns to be matched.
|
|
44
17
|
* In cwm they are symbols which are the formula's list of quantified variables.
|
|
@@ -46,11 +19,7 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
46
19
|
* a common special base URI for variables. Their names are uris,
|
|
47
20
|
* but the ? notation has an implicit base uri of 'varid:'
|
|
48
21
|
*/
|
|
49
|
-
|
|
50
|
-
(0, _inherits2.default)(Variable, _Node);
|
|
51
|
-
|
|
52
|
-
var _super = _createSuper(Variable);
|
|
53
|
-
|
|
22
|
+
class Variable extends _nodeInternal.default {
|
|
54
23
|
/** The base string for a variable's name */
|
|
55
24
|
|
|
56
25
|
/** The unique identifier of this variable */
|
|
@@ -59,58 +28,38 @@ var Variable = /*#__PURE__*/function (_Node) {
|
|
|
59
28
|
* Initializes this variable
|
|
60
29
|
* @param name The variable's name
|
|
61
30
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
(0,
|
|
67
|
-
|
|
68
|
-
(0, _defineProperty2.default)(
|
|
69
|
-
(0, _defineProperty2.default)(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "uri", void 0);
|
|
73
|
-
_this.base = 'varid:';
|
|
74
|
-
_this.uri = Uri.join(name, _this.base);
|
|
75
|
-
return _this;
|
|
31
|
+
constructor() {
|
|
32
|
+
let name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
33
|
+
super(name);
|
|
34
|
+
(0, _defineProperty2.default)(this, "termType", _types.VariableTermType);
|
|
35
|
+
(0, _defineProperty2.default)(this, "base", 'varid:');
|
|
36
|
+
(0, _defineProperty2.default)(this, "classOrder", _classOrder.default.Variable);
|
|
37
|
+
(0, _defineProperty2.default)(this, "isVar", 1);
|
|
38
|
+
(0, _defineProperty2.default)(this, "uri", void 0);
|
|
39
|
+
this.base = 'varid:';
|
|
40
|
+
this.uri = Uri.join(name, this.base);
|
|
76
41
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
value: function equals(other) {
|
|
81
|
-
if (!other) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return this.termType === other.termType && this.value === other.value;
|
|
86
|
-
}
|
|
87
|
-
}, {
|
|
88
|
-
key: "hashString",
|
|
89
|
-
value: function hashString() {
|
|
90
|
-
return this.toString();
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
key: "substitute",
|
|
94
|
-
value: function substitute(bindings) {
|
|
95
|
-
var ref;
|
|
96
|
-
return (ref = bindings[this.toNT()]) != null ? ref : this;
|
|
42
|
+
equals(other) {
|
|
43
|
+
if (!other) {
|
|
44
|
+
return false;
|
|
97
45
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
46
|
+
return this.termType === other.termType && this.value === other.value;
|
|
47
|
+
}
|
|
48
|
+
hashString() {
|
|
49
|
+
return this.toString();
|
|
50
|
+
}
|
|
51
|
+
substitute(bindings) {
|
|
52
|
+
var ref;
|
|
53
|
+
return (ref = bindings[this.toNT()]) != null ? ref : this;
|
|
54
|
+
}
|
|
55
|
+
toString() {
|
|
56
|
+
return Variable.toString(this);
|
|
57
|
+
}
|
|
58
|
+
static toString(variable) {
|
|
59
|
+
if (variable.uri.slice(0, variable.base.length) === variable.base) {
|
|
60
|
+
return `?${variable.uri.slice(variable.base.length)}`;
|
|
111
61
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
62
|
+
return `?${variable.uri}`;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
116
65
|
exports.default = Variable;
|
package/lib/xsd-internal.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _namedNode = _interopRequireDefault(require("./named-node"));
|
|
11
|
-
|
|
12
9
|
var _default = {
|
|
13
10
|
boolean: new _namedNode.default('http://www.w3.org/2001/XMLSchema#boolean'),
|
|
14
11
|
dateTime: new _namedNode.default('http://www.w3.org/2001/XMLSchema#dateTime'),
|
package/lib/xsd.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createXSD = createXSD;
|
|
9
8
|
exports.default = void 0;
|
|
10
|
-
|
|
11
9
|
var _canonicalDataFactory = _interopRequireDefault(require("./factories/canonical-data-factory"));
|
|
12
|
-
|
|
13
10
|
function createXSD() {
|
|
14
|
-
|
|
11
|
+
let localFactory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _canonicalDataFactory.default;
|
|
15
12
|
return {
|
|
16
13
|
boolean: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#boolean"),
|
|
17
14
|
dateTime: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#dateTime"),
|
|
@@ -22,7 +19,6 @@ function createXSD() {
|
|
|
22
19
|
string: localFactory.namedNode("http://www.w3.org/2001/XMLSchema#string")
|
|
23
20
|
};
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
var defaultXSD = createXSD(_canonicalDataFactory.default);
|
|
22
|
+
const defaultXSD = createXSD(_canonicalDataFactory.default);
|
|
27
23
|
var _default = defaultXSD;
|
|
28
24
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rdflib",
|
|
3
3
|
"description": "an RDF library for node.js. Suitable for client and server side.",
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.22-04669b23",
|
|
5
5
|
"private": false,
|
|
6
6
|
"browserslist": [
|
|
7
7
|
"> 0.5%"
|
|
@@ -44,62 +44,63 @@
|
|
|
44
44
|
"homepage": "http://github.com/linkeddata/rdflib.js",
|
|
45
45
|
"bugs": "http://github.com/linkeddata/rdflib.js/issues",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@babel/runtime": "^7.
|
|
48
|
-
"@
|
|
49
|
-
"
|
|
47
|
+
"@babel/runtime": "^7.20.1",
|
|
48
|
+
"@frogcat/ttl2jsonld": "^0.0.9",
|
|
49
|
+
"@xmldom/xmldom": "^0.8.6",
|
|
50
50
|
"cross-fetch": "^3.1.5",
|
|
51
|
-
"jsonld": "^
|
|
52
|
-
"n3": "^1.16.
|
|
51
|
+
"jsonld": "^8.1.0",
|
|
52
|
+
"n3": "^1.16.3",
|
|
53
53
|
"solid-namespace": "^0.5.2"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@babel/cli": "^7.
|
|
57
|
-
"@babel/core": "^7.
|
|
58
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
59
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
60
|
-
"@babel/preset-env": "^7.
|
|
61
|
-
"@babel/preset-typescript": "^7.
|
|
62
|
-
"@babel/register": "^7.
|
|
63
|
-
"@types/chai": "^4.3.
|
|
56
|
+
"@babel/cli": "^7.19.3",
|
|
57
|
+
"@babel/core": "^7.20.2",
|
|
58
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
59
|
+
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
60
|
+
"@babel/preset-env": "^7.20.2",
|
|
61
|
+
"@babel/preset-typescript": "^7.18.6",
|
|
62
|
+
"@babel/register": "^7.18.9",
|
|
63
|
+
"@types/chai": "^4.3.4",
|
|
64
64
|
"@types/dirty-chai": "^2.0.2",
|
|
65
|
-
"@types/express": "^4.17.
|
|
66
|
-
"@types/jsonld": "^1.5.
|
|
67
|
-
"@types/
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"diff": "^5.0.0",
|
|
65
|
+
"@types/express": "^4.17.14",
|
|
66
|
+
"@types/jsonld": "^1.5.8",
|
|
67
|
+
"@types/sinon-chai": "^3.2.9",
|
|
68
|
+
"babel-loader": "^9.1.0",
|
|
69
|
+
"chai": "^4.3.7",
|
|
70
|
+
"diff": "^5.1.0",
|
|
72
71
|
"dirty-chai": "^2.0.1",
|
|
73
|
-
"eslint": "^8.
|
|
72
|
+
"eslint": "^8.28.0",
|
|
74
73
|
"fs-grep": "0.0.5",
|
|
75
|
-
"locate-path": "^7.1.
|
|
76
|
-
"mocha": "^
|
|
77
|
-
"nock": "^13.2.
|
|
78
|
-
"node-fetch": "^
|
|
79
|
-
"node-polyfill-webpack-plugin": "^
|
|
80
|
-
"
|
|
74
|
+
"locate-path": "^7.1.1",
|
|
75
|
+
"mocha": "^10.1.0",
|
|
76
|
+
"nock": "^13.2.9",
|
|
77
|
+
"node-fetch": "^3.3.0",
|
|
78
|
+
"node-polyfill-webpack-plugin": "^2.0.1",
|
|
79
|
+
"rdf-js": "^4.0.2",
|
|
80
|
+
"sinon": "^14.0.2",
|
|
81
81
|
"sinon-chai": "^3.7.0",
|
|
82
|
-
"source-map-loader": "^
|
|
83
|
-
"ts-node": "^10.
|
|
84
|
-
"typedoc": "^0.
|
|
85
|
-
"typescript": "^4.
|
|
86
|
-
"webpack": "^5.
|
|
87
|
-
"webpack-cli": "^
|
|
88
|
-
"webpack-dev-server": "^4.
|
|
82
|
+
"source-map-loader": "^4.0.1",
|
|
83
|
+
"ts-node": "^10.9.1",
|
|
84
|
+
"typedoc": "^0.23.21",
|
|
85
|
+
"typescript": "^4.9.3",
|
|
86
|
+
"webpack": "^5.75.0",
|
|
87
|
+
"webpack-cli": "^5.0.0",
|
|
88
|
+
"webpack-dev-server": "^4.11.1"
|
|
89
89
|
},
|
|
90
90
|
"scripts": {
|
|
91
91
|
"build": "babel src --extensions \".ts,.js\" -d lib",
|
|
92
92
|
"build:esm": "babel src --extensions \".ts,.js\" --env-name esm -d esm",
|
|
93
93
|
"build:browser": "webpack --progress",
|
|
94
94
|
"build:types": "tsc --emitDeclarationOnly -d --moduleResolution node --declarationDir lib",
|
|
95
|
+
"build:all": "npm run build && npm run build:types && npm run build:browser && npm run build:esm ",
|
|
95
96
|
"doc": "typedoc --out ./doc ./src/index.ts --excludePrivate --excludeInternal --tsconfig ./tsconfig.json",
|
|
96
|
-
"ignore:prepublishOnly": "npm ci && npm run build
|
|
97
|
+
"ignore:prepublishOnly": "npm ci && npm run build:all && npm run doc && npm run test",
|
|
97
98
|
"postversion": "git push --follow-tags",
|
|
98
99
|
"start": "webpack serve --port 4800",
|
|
99
100
|
"test": "npm run test:unit && npm run test:serialize && npm run test:types",
|
|
100
101
|
"test:clean": "rimraf tests/serialize/,*",
|
|
101
102
|
"test:serialize": "npm run build && npm run test:serialize:all && npm run test:clean",
|
|
102
|
-
"test:serialize:all": "npm run test:serialize:1 && npm run test:serialize:2 && npm run test:serialize:3 && npm run test:serialize:4 && npm run test:serialize:5 && npm run test:serialize:6 && npm run test:serialize:7 && npm run test:serialize:10 && npm run test:serialize:11 && npm run test:serialize:12 && npm run test:serialize:13 && npm run test:serialize:14
|
|
103
|
+
"test:serialize:all": "npm run test:serialize:1 && npm run test:serialize:2 && npm run test:serialize:3 && npm run test:serialize:4 && npm run test:serialize:5 && npm run test:serialize:6 && npm run test:serialize:7 && npm run test:serialize:8 && npm run test:serialize:10 && npm run test:serialize:11 && npm run test:serialize:12 && npm run test:serialize:13 && npm run test:serialize:14 && npm run test:serialize:15",
|
|
103
104
|
"test:serialize:1": "cd ./tests/serialize && node ./data.js -in=t1.ttl -format=application/rdf+xml -out=,t1.xml && fs-grep http://www.w3.org/2001/XMLSchema#integer ,t1.xml",
|
|
104
105
|
"test:serialize:2": "cd ./tests/serialize && node ./data.js -in=t2.ttl -format=application/rdf+xml -out=,t2.xml && node diff ,t2.xml t2-ref.xml",
|
|
105
106
|
"test:serialize:3": "cd ./tests/serialize && node ./data.js -in=t3.ttl -format=application/rdf+xml -out=,t3.xml && node diff ,t3.xml t3-ref.xml",
|
|
@@ -107,14 +108,14 @@
|
|
|
107
108
|
"test:serialize:5": "cd ./tests/serialize && node ./data.js -in=t5.n3 -format=text/turtle -out=,t5.ttl && node diff ,t5.ttl t5-ref.ttl",
|
|
108
109
|
"test:serialize:6": "cd ./tests/serialize && node ./data.js -in=t5.n3 -format=text/n3 -out=,t6.n3 && node diff ,t6.n3 t6-ref.n3",
|
|
109
110
|
"test:serialize:7": "cd ./tests/serialize && node ./data.js -in=t7.n3 -format=application/n-triples -out=,t7.nt && node diff ,t7.nt t7-ref.nt",
|
|
110
|
-
"test:serialize:8": "cd ./tests/serialize && node ./data.js -in=t5.n3 -format=application/n-quads -
|
|
111
|
-
"test:serialize:9": "cd ./tests/serialize && node ./data.js -in=t7.n3 -format=application/ld+json -out=,t9.json && node diff ,t9.json t9-ref.json",
|
|
111
|
+
"test:serialize:8": "cd ./tests/serialize && node ./data.js -in=t5.n3 -format=application/n-quads -out=,t8.nq && node diff ,t8.nq t8-ref.nq",
|
|
112
112
|
"test:serialize:10": "cd ./tests/serialize && node ./data.js -in=details.ttl -format=text/turtle -out=,t10.ttl && node diff ,t10.ttl t10-ref.ttl",
|
|
113
113
|
"test:serialize:11": "cd ./tests/serialize && node ./data.js -in=structures.n3 -format=application/rdf+xml -out=,structures.xml && node diff ,structures.xml t11-ref.xml",
|
|
114
114
|
"test:serialize:12": "cd ./tests/serialize && node ./data.js -in=structures.n3 -format=text/turtle -out=,structures.ttl && node diff ,structures.ttl t12-ref.ttl",
|
|
115
115
|
"test:serialize:13": "cd ./tests/serialize && node ./data.js -in=structures.n3 -format=application/n-triples -out=,structures.nt && node ./data.js -format=application/n-triples -in=,structures.nt -format=text/turtle -out=,structures.nt.ttl && node diff ,structures.nt.ttl t13-ref.ttl",
|
|
116
116
|
"test:serialize:14": "cd ./tests/serialize && node ./data.js -in=t14.html -format=text/turtle -out=,t14.ttl && node diff ,t14.ttl t14-ref.ttl",
|
|
117
117
|
"test:serialize:15": "cd ./tests/serialize && node ./data.js -in=t15.html -format=text/turtle -out=,t15.ttl && node diff ,t15.ttl t15-ref.ttl",
|
|
118
|
+
"test:serialize:16": "cd ./tests/serialize && node ./data.js -in=t1.ttl -format=application/ld+json -out=,t1.jsonld && node diff ,t1.jsonld t16-ref.jsonld",
|
|
118
119
|
"test:types": "tsc --noEmit --target es2019 --moduleResolution node tests/types/*.ts",
|
|
119
120
|
"test:unit": "mocha --growl --require ./tests/babel-register.js tests/unit/**-test.*",
|
|
120
121
|
"test:unit:egp": "mocha --require ./tests/babel-register.js tests/unit/fetcher-egp-test.js",
|
package/src/fetcher.ts
CHANGED
|
@@ -979,7 +979,7 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
979
979
|
return this.pendingFetchPromise(docuri, initialisedOptions.baseURI, initialisedOptions) as any
|
|
980
980
|
}
|
|
981
981
|
|
|
982
|
-
pendingFetchPromise (
|
|
982
|
+
async pendingFetchPromise (
|
|
983
983
|
uri: string,
|
|
984
984
|
originalUri: string,
|
|
985
985
|
options: AutoInitOptions
|
|
@@ -987,7 +987,7 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
987
987
|
let pendingPromise
|
|
988
988
|
|
|
989
989
|
// Check to see if some request is already dealing with this uri
|
|
990
|
-
if (!options.force && this.fetchQueue[originalUri]) {
|
|
990
|
+
if (!options.force && await this.fetchQueue[originalUri]) {
|
|
991
991
|
pendingPromise = this.fetchQueue[originalUri]
|
|
992
992
|
} else {
|
|
993
993
|
pendingPromise = Promise
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { IRDFlibDataFactory } from './types'
|
|
|
2
2
|
|
|
3
3
|
import BlankNode from './blank-node'
|
|
4
4
|
import Collection from './collection'
|
|
5
|
-
import * as convert from './convert'
|
|
6
5
|
import Empty from './empty'
|
|
7
6
|
import Fetcher from './fetcher'
|
|
8
7
|
import Formula from './formula'
|
|
@@ -66,7 +65,6 @@ export type { AutoInitOptions, ExtendedResponse, FetchError } from './fetcher'
|
|
|
66
65
|
export {
|
|
67
66
|
BlankNode,
|
|
68
67
|
Collection,
|
|
69
|
-
convert,
|
|
70
68
|
DataFactory,
|
|
71
69
|
Empty,
|
|
72
70
|
Fetcher,
|
package/src/jsonldparser.js
CHANGED
|
@@ -22,7 +22,7 @@ export function jsonldObjectToTerm (kb, obj) {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
if (Object.prototype.hasOwnProperty.call(obj, '@id')) {
|
|
25
|
-
return kb
|
|
25
|
+
return nodeType(kb, obj)
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
if (Object.prototype.hasOwnProperty.call(obj, '@language')) {
|
|
@@ -44,7 +44,7 @@ export function jsonldObjectToTerm (kb, obj) {
|
|
|
44
44
|
* Adds the statements in a json-ld list object to {kb}.
|
|
45
45
|
*/
|
|
46
46
|
function listToStatements (kb, obj) {
|
|
47
|
-
const listId = obj['@id'] ? kb
|
|
47
|
+
const listId = obj['@id'] ? nodeType(kb, obj) : kb.rdfFactory.blankNode()
|
|
48
48
|
|
|
49
49
|
const items = obj['@list'].map((listItem => jsonldObjectToTerm(kb, listItem)))
|
|
50
50
|
const statements = arrayToStatements(kb.rdfFactory, listId, items)
|
|
@@ -82,10 +82,19 @@ export default function jsonldParser (str, kb, base, callback) {
|
|
|
82
82
|
.catch(callback)
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
function nodeType (kb, obj) {
|
|
86
|
+
if (obj['@id'].startsWith('_:')) {
|
|
87
|
+
// This object is a Blank Node. Pass the id without the `_:` prefix
|
|
88
|
+
return kb.rdfFactory.blankNode(obj['@id'].substring(2));
|
|
89
|
+
} else {
|
|
90
|
+
// This object is a Named Node
|
|
91
|
+
return kb.rdfFactory.namedNode(obj['@id']);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
85
94
|
|
|
86
95
|
function processResource(kb, base, flatResource) {
|
|
87
96
|
const id = flatResource['@id']
|
|
88
|
-
? kb
|
|
97
|
+
? nodeType(kb, flatResource)
|
|
89
98
|
: kb.rdfFactory.blankNode()
|
|
90
99
|
|
|
91
100
|
for (const property of Object.keys(flatResource)) {
|
|
@@ -136,4 +145,4 @@ function createStatement(kb, id, property, value, base) {
|
|
|
136
145
|
object = jsonldObjectToTerm(kb, value)
|
|
137
146
|
}
|
|
138
147
|
return kb.rdfFactory.quad(id, predicate, object, kb.rdfFactory.namedNode(base))
|
|
139
|
-
}
|
|
148
|
+
}
|
package/src/n3parser.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
**/
|
|
7
7
|
import * as Uri from './uri'
|
|
8
8
|
import { ArrayIndexOf } from './utils'
|
|
9
|
+
import { convertFirstRestNil } from './lists'
|
|
9
10
|
|
|
10
11
|
function hexify (str) { // also used in parser
|
|
11
12
|
return encodeURI(str);
|
|
@@ -148,6 +149,7 @@ var diag_progress = function(str) { /*$rdf.log.debug(str);*/ }
|
|
|
148
149
|
|
|
149
150
|
|
|
150
151
|
var RDF_type_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
|
|
152
|
+
var RDF_nil_URI = "http://www.w3.org/1999/02/22-rdf-syntax-ns#nil";
|
|
151
153
|
var DAML_sameAs_URI = "http://www.w3.org/2002/07/owl#sameAs";
|
|
152
154
|
|
|
153
155
|
/*
|
|
@@ -247,6 +249,7 @@ export class SinkParser {
|
|
|
247
249
|
this.source = store.sym(thisDoc);
|
|
248
250
|
this.lines = 0;
|
|
249
251
|
this.statementCount = 0;
|
|
252
|
+
this.hasNil = false;
|
|
250
253
|
this.startOfLine = 0;
|
|
251
254
|
this.previousLine = 0;
|
|
252
255
|
this._genPrefix = genPrefix;
|
|
@@ -509,14 +512,20 @@ export class SinkParser {
|
|
|
509
512
|
};
|
|
510
513
|
startDoc() {
|
|
511
514
|
};
|
|
512
|
-
endDoc() {
|
|
513
|
-
/*
|
|
514
|
-
Signal end of document and stop parsing. returns formula*/
|
|
515
515
|
|
|
516
|
+
/* Signal end of document and stop parsing. returns formula */
|
|
517
|
+
endDoc() {
|
|
518
|
+
if (this.hasNil && this._store.rdfFactory.supports["COLLECTIONS"]) {
|
|
519
|
+
convertFirstRestNil(this._store, this.source)
|
|
520
|
+
}
|
|
516
521
|
return this._formula;
|
|
517
522
|
};
|
|
518
523
|
makeStatement(quad) {
|
|
519
524
|
quad[0].add(quad[2], quad[1], quad[3], this.source);
|
|
525
|
+
if ((quad[2].uri && quad[2].uri === RDF_nil_URI)
|
|
526
|
+
|| (quad[3].uri && quad[3].uri === RDF_nil_URI)) {
|
|
527
|
+
this.hasNil = true
|
|
528
|
+
}
|
|
520
529
|
this.statementCount += 1;
|
|
521
530
|
};
|
|
522
531
|
statement(str, i) {
|
|
@@ -1571,4 +1580,3 @@ function stripCR(str) {
|
|
|
1571
1580
|
|
|
1572
1581
|
function dummyWrite(x) {
|
|
1573
1582
|
}
|
|
1574
|
-
|
package/src/serialize.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as convert from './convert'
|
|
2
1
|
import Formula from './formula'
|
|
3
2
|
import Serializer from './serializer'
|
|
4
3
|
import {
|
|
@@ -42,7 +41,7 @@ export default function serialize (
|
|
|
42
41
|
*/
|
|
43
42
|
namespaces?: Record<string, string>
|
|
44
43
|
}
|
|
45
|
-
): string | undefined {
|
|
44
|
+
): string | undefined | Promise<string> {
|
|
46
45
|
base = base || target?.value
|
|
47
46
|
const opts = options || {}
|
|
48
47
|
contentType = contentType || TurtleContentType // text/n3 if complex?
|
|
@@ -51,7 +50,6 @@ export default function serialize (
|
|
|
51
50
|
var sz = Serializer(kb)
|
|
52
51
|
if ((opts as any).flags) sz.setFlags((opts as any).flags)
|
|
53
52
|
var newSts = kb!.statementsMatching(undefined, undefined, undefined, target as NamedNode)
|
|
54
|
-
var n3String: string
|
|
55
53
|
|
|
56
54
|
// If an IndexedFormula, use the namespaces from the given graph as suggestions
|
|
57
55
|
if ('namespaces' in kb) {
|
|
@@ -82,19 +80,14 @@ export default function serialize (
|
|
|
82
80
|
documentString = sz.statementsToNTriples(newSts)
|
|
83
81
|
return executeCallback(null, documentString)
|
|
84
82
|
case JSONLDContentType:
|
|
85
|
-
sz.setFlags('
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
convert.convertToJson(n3String, callback)
|
|
89
|
-
break
|
|
83
|
+
sz.setFlags('si') // use turtle parameters
|
|
84
|
+
documentString = sz.statementsToJsonld(newSts) // convert via turtle
|
|
85
|
+
return executeCallback(null, documentString)
|
|
90
86
|
case NQuadsContentType:
|
|
91
87
|
case NQuadsAltContentType: // @@@ just outpout the quads? Does not work for collections
|
|
92
88
|
sz.setFlags('deinprstux q') // Suppress nice parts of N3 to make ntriples
|
|
93
89
|
documentString = sz.statementsToNTriples(newSts) // q in flag means actually quads
|
|
94
90
|
return executeCallback(null, documentString)
|
|
95
|
-
// n3String = sz.statementsToN3(newSts)
|
|
96
|
-
// documentString = convert.convertToNQuads(n3String, callback)
|
|
97
|
-
// break
|
|
98
91
|
default:
|
|
99
92
|
throw new Error('Serialize: Content-type ' + contentType + ' not supported for data write.')
|
|
100
93
|
}
|
package/src/serializer.js
CHANGED
|
@@ -12,6 +12,8 @@ import * as Util from './utils-js'
|
|
|
12
12
|
import CanonicalDataFactory from './factories/canonical-data-factory'
|
|
13
13
|
import { createXSD } from './xsd'
|
|
14
14
|
import solidNs from 'solid-namespace'
|
|
15
|
+
// import * as jsonld from 'jsonld'
|
|
16
|
+
import * as ttl2jsonld from '@frogcat/ttl2jsonld'
|
|
15
17
|
|
|
16
18
|
|
|
17
19
|
export default function createSerializer(store) {
|
|
@@ -1011,6 +1013,28 @@ export class Serializer {
|
|
|
1011
1013
|
var tree2 = [str, tree, '</rdf:RDF>'] // @@ namespace declrations
|
|
1012
1014
|
return XMLtreeToString(tree2, -1)
|
|
1013
1015
|
} // End @@ body
|
|
1016
|
+
|
|
1017
|
+
statementsToJsonld (sts) {
|
|
1018
|
+
// ttl2jsonld creates context keys for all ttl prefix
|
|
1019
|
+
// context keys must be full IRI
|
|
1020
|
+
function findId (itemObj) {
|
|
1021
|
+
if (itemObj['@id']) {
|
|
1022
|
+
const item = itemObj['@id'].split(':')
|
|
1023
|
+
if (keys[item[0]]) itemObj['@id'] = jsonldObj['@context'][item[0]] + item[1]
|
|
1024
|
+
}
|
|
1025
|
+
const itemValues = Object.values(itemObj)
|
|
1026
|
+
for (const i in itemValues) {
|
|
1027
|
+
if (typeof itemValues[i] !== 'string') { // @list contains array
|
|
1028
|
+
findId(itemValues[i])
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
const turtleDoc = this.statementsToN3(sts)
|
|
1033
|
+
const jsonldObj = ttl2jsonld.parse(turtleDoc)
|
|
1034
|
+
|
|
1035
|
+
return JSON.stringify(jsonldObj, null, 2)
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1014
1038
|
}
|
|
1015
1039
|
|
|
1016
1040
|
// String escaping utilities
|
package/src/update-manager.ts
CHANGED
|
@@ -752,7 +752,7 @@ export default class UpdateManager {
|
|
|
752
752
|
// console.log(message)
|
|
753
753
|
throw new Error(message)
|
|
754
754
|
}
|
|
755
|
-
var control = this.patchControlFor(doc)
|
|
755
|
+
var control = this.patchControlFor(doc as NamedNode)
|
|
756
756
|
var startTime = Date.now()
|
|
757
757
|
|
|
758
758
|
var props = ['subject', 'predicate', 'object', 'why']
|
|
@@ -781,7 +781,7 @@ export default class UpdateManager {
|
|
|
781
781
|
throw new Error('Update: Loaded ' + doc + "but stil can't figure out what editing protcol it supports.")
|
|
782
782
|
}
|
|
783
783
|
// console.log(`Update: have not loaded ${doc} before: loading now...`);
|
|
784
|
-
(this.store.fetcher.load(doc) as Promise<Response>).then(response => {
|
|
784
|
+
(this.store.fetcher.load(doc as NamedNode) as Promise<Response>).then(response => {
|
|
785
785
|
this.update(deletions, insertions, callback, true, options)
|
|
786
786
|
}, err => {
|
|
787
787
|
if (err.response.status === 404) { // nonexistent files are fine
|
|
@@ -793,8 +793,13 @@ export default class UpdateManager {
|
|
|
793
793
|
return
|
|
794
794
|
} else if ((protocol as string).indexOf('SPARQL') >= 0) {
|
|
795
795
|
var bnodes: BlankNode[] = []
|
|
796
|
-
|
|
797
|
-
|
|
796
|
+
// change ReadOnly type to Mutable type
|
|
797
|
+
type Mutable<Type> = {
|
|
798
|
+
-readonly [Key in keyof Type]: Type[Key];
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
if (ds.length) bnodes = this.statementArrayBnodes(ds as Mutable<typeof ds>)
|
|
802
|
+
if (is.length) bnodes = bnodes.concat(this.statementArrayBnodes(is as Mutable<typeof is>))
|
|
798
803
|
var context = this.bnodeContext(bnodes, doc)
|
|
799
804
|
var whereClause = this.contextWhere(context)
|
|
800
805
|
var query = ''
|
|
@@ -846,7 +851,7 @@ export default class UpdateManager {
|
|
|
846
851
|
*/
|
|
847
852
|
if (success) {
|
|
848
853
|
try {
|
|
849
|
-
kb.remove(ds)
|
|
854
|
+
kb.remove(ds as Mutable<typeof ds>)
|
|
850
855
|
} catch (e) {
|
|
851
856
|
success = false
|
|
852
857
|
body = 'Remote Ok BUT error deleting ' + ds.length + ' from store!!! ' + e
|
|
@@ -867,11 +872,11 @@ export default class UpdateManager {
|
|
|
867
872
|
}
|
|
868
873
|
}, options)
|
|
869
874
|
} else if ((protocol as string).indexOf('DAV') >= 0) {
|
|
870
|
-
this.updateDav(doc, ds, is, callback, options)
|
|
875
|
+
this.updateDav(doc as NamedNode, ds, is, callback, options)
|
|
871
876
|
} else {
|
|
872
877
|
if ((protocol as string).indexOf('LOCALFILE') >= 0) {
|
|
873
878
|
try {
|
|
874
|
-
this.updateLocalFile(doc, ds, is, callback, options)
|
|
879
|
+
this.updateLocalFile(doc as NamedNode, ds, is, callback, options)
|
|
875
880
|
} catch (e) {
|
|
876
881
|
callback(doc.value, false,
|
|
877
882
|
'Exception trying to write back file <' + doc.value + '>\n'
|