rdflib 2.2.20 → 2.2.21-acff123a
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 +9 -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 -126
- package/esm/convert.js +1 -2
- 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 -76
- package/esm/jsonldparser.js +24 -49
- package/esm/jsonparser.js +1 -8
- package/esm/lists.js +105 -0
- package/esm/literal.js +120 -189
- package/esm/log.js +7 -7
- package/esm/n3parser.js +1015 -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 -27
- package/esm/serializer.js +820 -1049
- package/esm/sparql-to-query.js +44 -134
- package/esm/statement.js +54 -78
- package/esm/store.js +831 -1102
- package/esm/types.js +22 -21
- package/esm/update-manager.js +869 -1104
- 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 +28 -19
- 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 -129
- package/lib/convert.js +3 -9
- 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.js +640 -855
- package/lib/index.js +66 -152
- package/lib/jsonldparser.js +23 -53
- package/lib/jsonparser.js +1 -10
- package/lib/lists.d.ts +13 -0
- package/lib/lists.js +113 -0
- package/lib/literal.js +120 -195
- package/lib/log.d.ts +0 -6
- package/lib/log.js +7 -8
- package/lib/n3parser.js +1030 -1436
- 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.js +11 -37
- package/lib/serializer.js +823 -1064
- package/lib/sparql-to-query.js +42 -167
- package/lib/statement.js +55 -84
- package/lib/store.d.ts +1 -1
- 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 -1101
- 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.d.ts +6 -1
- package/lib/utils/terms.js +29 -35
- 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 +35 -36
- package/src/collection.ts +2 -0
- package/src/fetcher.ts +2 -2
- package/src/lists.ts +121 -0
- package/src/statement.ts +7 -0
- package/src/store.ts +7 -7
- package/src/update-manager.ts +15 -9
- package/src/utils/terms.ts +23 -1
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.21-acff123a",
|
|
5
5
|
"private": false,
|
|
6
6
|
"browserslist": [
|
|
7
7
|
"> 0.5%"
|
|
@@ -44,49 +44,48 @@
|
|
|
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
|
-
"@xmldom/xmldom": "^0.8.
|
|
49
|
-
"async": "^3.2.
|
|
47
|
+
"@babel/runtime": "^7.20.1",
|
|
48
|
+
"@xmldom/xmldom": "^0.8.6",
|
|
49
|
+
"async": "^3.2.4",
|
|
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
|
-
"chai": "^4.3.6",
|
|
72
|
-
"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",
|
|
73
71
|
"dirty-chai": "^2.0.1",
|
|
74
|
-
"eslint": "^8.
|
|
72
|
+
"eslint": "^8.28.0",
|
|
75
73
|
"fs-grep": "0.0.5",
|
|
76
|
-
"locate-path": "^7.1.
|
|
77
|
-
"mocha": "^
|
|
78
|
-
"nock": "^13.2.
|
|
79
|
-
"node-fetch": "^
|
|
80
|
-
"node-polyfill-webpack-plugin": "^
|
|
81
|
-
"
|
|
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",
|
|
82
81
|
"sinon-chai": "^3.7.0",
|
|
83
|
-
"source-map-loader": "^
|
|
84
|
-
"ts-node": "^10.
|
|
85
|
-
"typedoc": "^0.
|
|
86
|
-
"typescript": "^4.
|
|
87
|
-
"webpack": "^5.
|
|
88
|
-
"webpack-cli": "^
|
|
89
|
-
"webpack-dev-server": "
|
|
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"
|
|
90
89
|
},
|
|
91
90
|
"scripts": {
|
|
92
91
|
"build": "babel src --extensions \".ts,.js\" -d lib",
|
package/src/collection.ts
CHANGED
|
@@ -112,6 +112,8 @@ export default class Collection<
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
static toNT (collection) {
|
|
115
|
+
// return '(' + collection.elements.map(x => x.toNT()).join(' ') + ')'
|
|
116
|
+
// As lists are not in NT and toNT() must be a reversible function, we kludge it for a list
|
|
115
117
|
return RdflibBlankNode.NTAnonymousNodePrefix + collection.id
|
|
116
118
|
}
|
|
117
119
|
|
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/lists.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/* Lists form conversion
|
|
2
|
+
*/
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
// import DataFactory from './factories/extended-term-factory'
|
|
6
|
+
// import jsonldParser from './jsonldparser'
|
|
7
|
+
// @ts-ignore is this injected?
|
|
8
|
+
import { Parser as N3jsParser } from 'n3' // @@ Goal: remove this dependency
|
|
9
|
+
// import N3Parser from './n3parser'
|
|
10
|
+
// import { parseRDFaDOM } from './rdfaparser'
|
|
11
|
+
// import RDFParser from './rdfxmlparser'
|
|
12
|
+
// import sparqlUpdateParser from './patch-parser'
|
|
13
|
+
// import * as Util from './utils-js'
|
|
14
|
+
import Node from './node-internal'
|
|
15
|
+
// import BlankNode from './blank-node'
|
|
16
|
+
// import NamedNode from './named-node'
|
|
17
|
+
import Collection from './collection'
|
|
18
|
+
import Statement from './statement'
|
|
19
|
+
// import Formula from './formula'
|
|
20
|
+
import Store from './store'
|
|
21
|
+
// import { ContentType, TurtleContentType, N3ContentType, RDFXMLContentType, XHTMLContentType, HTMLContentType, SPARQLUpdateContentType, SPARQLUpdateSingleMatchContentType, JSONLDContentType, NQuadsContentType, NQuadsAltContentType } from './types'
|
|
22
|
+
|
|
23
|
+
// import { Quad } from './tf-types'
|
|
24
|
+
|
|
25
|
+
import {BlankNode, NamedNode, Quad, Term,} from './tf-types'
|
|
26
|
+
import Namespace from './namespace'
|
|
27
|
+
|
|
28
|
+
const RDF = Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#')
|
|
29
|
+
|
|
30
|
+
/* Replace a given node with another node throughout a given document
|
|
31
|
+
*
|
|
32
|
+
* we do the predicate as well for complenesss though we don't expect Collections to use it
|
|
33
|
+
*/
|
|
34
|
+
export function substituteInDoc (store:Store, x:Term, y:Term, doc?: NamedNode ) {
|
|
35
|
+
// console.log(`substituteInDoc put ${x} for ${y} in ${doc}}`)
|
|
36
|
+
for (const quad of store.statementsMatching(y as any, null, null, doc as any)) {
|
|
37
|
+
const newStatement = new Statement(x as any, quad.predicate, quad.object, doc as any)
|
|
38
|
+
store.remove(quad)
|
|
39
|
+
store.add(newStatement)
|
|
40
|
+
}
|
|
41
|
+
for (const quad of store.statementsMatching(null, y as any, null, doc) as any) {
|
|
42
|
+
store.remove(quad)
|
|
43
|
+
// console.log(` substituteInDoc predicate ${x} in ${quad}}`)
|
|
44
|
+
store.add(new Statement(quad.subject, x as any, quad.object, doc as any))
|
|
45
|
+
}
|
|
46
|
+
for (const quad of store.statementsMatching(null, null, y as any, doc) as any) {
|
|
47
|
+
store.remove(quad)
|
|
48
|
+
store.add(new Statement(quad.subject, quad.predicate, x as any, doc as any))
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* Change all lone rdf:nil nodes into empty Collections
|
|
53
|
+
*/
|
|
54
|
+
export function substituteNillsInDoc (store:Store, doc?: NamedNode) {
|
|
55
|
+
const x = RDF('nil')
|
|
56
|
+
for (const quad of store.statementsMatching(x as any, null, null, doc as any)) {
|
|
57
|
+
store.remove(quad)
|
|
58
|
+
const y = new Collection()
|
|
59
|
+
store.add(new Statement(y as any, quad.predicate, quad.object, doc as any))
|
|
60
|
+
}
|
|
61
|
+
for (const quad of store.statementsMatching(null, null, x as any, doc) as any) {
|
|
62
|
+
if (!quad.predicate.sameTerm(RDF('rest'))) { // If not a tail
|
|
63
|
+
store.remove(quad)
|
|
64
|
+
const y = new Collection()
|
|
65
|
+
store.add(new Statement(quad.subject, quad.predicate, y as any, doc as any))
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Convert lists reified as rdf:first, rest
|
|
71
|
+
* Normal method is sync.
|
|
72
|
+
* Unfortunately jsdonld is currently written to need to be called async.
|
|
73
|
+
* Hence the mess below with executeCallback.
|
|
74
|
+
* @param store - The quadstore
|
|
75
|
+
* @param doc - The document in which the conversion is done
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
export function convertFirstRestNil (
|
|
80
|
+
store: Store,
|
|
81
|
+
doc: NamedNode | undefined, // Do whole store?
|
|
82
|
+
) {
|
|
83
|
+
|
|
84
|
+
function preceding (ele:BlankNode, listSoFar: Node[], trash: Quad[]): undefined {
|
|
85
|
+
|
|
86
|
+
const rests = store.statementsMatching(ele, RDF('rest'), null, doc)
|
|
87
|
+
if (rests.length !== 1) throw new Error(`Bad list structure: no rest at ${ele}`)
|
|
88
|
+
|
|
89
|
+
const firsts = store.statementsMatching(ele, RDF('first'), null, doc)
|
|
90
|
+
if (firsts.length !== 1) throw new Error(`Bad list structure: rest but ${firsts.length} firsts at ${ele}`)
|
|
91
|
+
const value = firsts[0].object
|
|
92
|
+
const total = [value].concat(listSoFar as any)
|
|
93
|
+
// console.log(' List now is: ', total)
|
|
94
|
+
const totalTrash = trash.concat(rests).concat(firsts)
|
|
95
|
+
|
|
96
|
+
const pres = store.statementsMatching(null, RDF('rest'), ele, doc)
|
|
97
|
+
if (pres.length === 0) { // Head of the list
|
|
98
|
+
const newList = new Collection(total)
|
|
99
|
+
store.remove(totalTrash)
|
|
100
|
+
// Replace old list with new list:
|
|
101
|
+
substituteInDoc(store, newList, ele, doc)
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
if (pres.length !== 1) throw new Error(`Bad list structure: ${pres.length} pres at ${ele}`)
|
|
105
|
+
const pre = pres[0].subject
|
|
106
|
+
if (pre.termType !== 'BlankNode') throw new Error(`Bad list element node ${pre} type: ${pre.termType} `)
|
|
107
|
+
|
|
108
|
+
preceding(pre, total, totalTrash)
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
substituteNillsInDoc(store, doc) // lone ones only
|
|
113
|
+
|
|
114
|
+
const tails = store.statementsMatching(null, RDF('rest'), RDF('nil'), doc)
|
|
115
|
+
tails.forEach(tail => {
|
|
116
|
+
if (tail.subject.termType !== 'BlankNode')
|
|
117
|
+
throw new Error(`Bad list element node ${tail.subject} type: ${tail.subject.termType} `)
|
|
118
|
+
preceding(tail.subject, [], [])
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
}
|
package/src/statement.ts
CHANGED
|
@@ -137,6 +137,13 @@ export default class Statement<
|
|
|
137
137
|
|
|
138
138
|
/** Creates a string representation of this statement */
|
|
139
139
|
toString (): string {
|
|
140
|
+
/*
|
|
141
|
+
return [
|
|
142
|
+
this.subject.toString(),
|
|
143
|
+
this.predicate.toString(),
|
|
144
|
+
this.object.toString(),
|
|
145
|
+
].join(' ') + ' .'
|
|
146
|
+
*/
|
|
140
147
|
return this.toNT()
|
|
141
148
|
}
|
|
142
149
|
}
|
package/src/store.ts
CHANGED
|
@@ -23,12 +23,14 @@ import Formula, { FormulaOpts } from './formula'
|
|
|
23
23
|
import { ArrayIndexOf } from './utils'
|
|
24
24
|
import { RDFArrayRemove } from './utils-js'
|
|
25
25
|
import {
|
|
26
|
+
isRDFlibSubject,
|
|
27
|
+
isRDFlibPredicate,
|
|
26
28
|
isRDFlibObject,
|
|
27
29
|
isStore,
|
|
28
30
|
isGraph,
|
|
29
|
-
isPredicate,
|
|
31
|
+
// isPredicate,
|
|
30
32
|
isQuad,
|
|
31
|
-
isSubject
|
|
33
|
+
// isSubject
|
|
32
34
|
} from './utils/terms'
|
|
33
35
|
import Node from './node'
|
|
34
36
|
import Variable from './variable'
|
|
@@ -429,10 +431,10 @@ export default class IndexedFormula extends Formula { // IN future - allow pass
|
|
|
429
431
|
pred = Node.fromValue(pred)
|
|
430
432
|
const objNode = Node.fromValue(obj) as Term
|
|
431
433
|
why = Node.fromValue(why)
|
|
432
|
-
if (!
|
|
434
|
+
if (!isRDFlibSubject(subj)) {
|
|
433
435
|
throw new Error('Subject is not a subject type')
|
|
434
436
|
}
|
|
435
|
-
if (!
|
|
437
|
+
if (!isRDFlibPredicate(pred)) {
|
|
436
438
|
throw new Error(`Predicate ${pred} is not a predicate type`)
|
|
437
439
|
}
|
|
438
440
|
if (!isRDFlibObject(objNode)) {
|
|
@@ -920,9 +922,7 @@ export default class IndexedFormula extends Formula { // IN future - allow pass
|
|
|
920
922
|
object?: Quad_Object | null,
|
|
921
923
|
graph?: Quad_Graph | null
|
|
922
924
|
): IndexedFormula {
|
|
923
|
-
this.
|
|
924
|
-
this.statementsMatching(subject, predicate, object, graph)
|
|
925
|
-
)
|
|
925
|
+
this.removeMany(subject, predicate, object, graph)
|
|
926
926
|
return this
|
|
927
927
|
}
|
|
928
928
|
|
package/src/update-manager.ts
CHANGED
|
@@ -689,7 +689,7 @@ export default class UpdateManager {
|
|
|
689
689
|
thisUpdater.update(deletions.filter(st => st.why.equals(doc)),
|
|
690
690
|
insertions.filter(st => st.why.equals(doc))))
|
|
691
691
|
if (updates.length > 1) {
|
|
692
|
-
console.log(`@@ updateMany to ${updates.length}: ${uniqueDocs}`)
|
|
692
|
+
// console.log(`@@ updateMany to ${updates.length}: ${uniqueDocs}`)
|
|
693
693
|
}
|
|
694
694
|
return Promise.all(updates)
|
|
695
695
|
}
|
|
@@ -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 = ''
|
|
@@ -840,12 +845,13 @@ export default class UpdateManager {
|
|
|
840
845
|
|
|
841
846
|
this.fire(doc.value, query, (uri, success, body, response) => {
|
|
842
847
|
(response as any).elapsedTimeMs = Date.now() - startTime
|
|
843
|
-
console.log(' UpdateManager: Return ' +
|
|
848
|
+
/* console.log(' UpdateManager: Return ' +
|
|
844
849
|
(success ? 'success ' : 'FAILURE ') + (response as Response).status +
|
|
845
850
|
' elapsed ' + (response as any).elapsedTimeMs + 'ms')
|
|
851
|
+
*/
|
|
846
852
|
if (success) {
|
|
847
853
|
try {
|
|
848
|
-
kb.remove(ds)
|
|
854
|
+
kb.remove(ds as Mutable<typeof ds>)
|
|
849
855
|
} catch (e) {
|
|
850
856
|
success = false
|
|
851
857
|
body = 'Remote Ok BUT error deleting ' + ds.length + ' from store!!! ' + e
|
|
@@ -866,11 +872,11 @@ export default class UpdateManager {
|
|
|
866
872
|
}
|
|
867
873
|
}, options)
|
|
868
874
|
} else if ((protocol as string).indexOf('DAV') >= 0) {
|
|
869
|
-
this.updateDav(doc, ds, is, callback, options)
|
|
875
|
+
this.updateDav(doc as NamedNode, ds, is, callback, options)
|
|
870
876
|
} else {
|
|
871
877
|
if ((protocol as string).indexOf('LOCALFILE') >= 0) {
|
|
872
878
|
try {
|
|
873
|
-
this.updateLocalFile(doc, ds, is, callback, options)
|
|
879
|
+
this.updateLocalFile(doc as NamedNode, ds, is, callback, options)
|
|
874
880
|
} catch (e) {
|
|
875
881
|
callback(doc.value, false,
|
|
876
882
|
'Exception trying to write back file <' + doc.value + '>\n'
|
package/src/utils/terms.ts
CHANGED
|
@@ -33,7 +33,7 @@ export function isCollection(obj: any): obj is Collection<any> {
|
|
|
33
33
|
&& (obj as Term).termType === CollectionTermType
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
/** TypeGuard for valid RDFlib Object types, also allows Collections */
|
|
36
|
+
/** TypeGuard for valid RDFlib Object types, also allows Collections, Graphs */
|
|
37
37
|
export function isRDFlibObject(obj: any): obj is ObjectType {
|
|
38
38
|
return obj && Object.prototype.hasOwnProperty.call(obj, 'termType') && (
|
|
39
39
|
obj.termType === NamedNodeTermType ||
|
|
@@ -45,6 +45,28 @@ export function isRDFlibObject(obj: any): obj is ObjectType {
|
|
|
45
45
|
)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/** TypeGuard for valid RDFlib Subject types, same as Object as RDFLib symmetrical.
|
|
49
|
+
*/
|
|
50
|
+
export function isRDFlibSubject(obj: any): obj is ObjectType {
|
|
51
|
+
return obj && Object.prototype.hasOwnProperty.call(obj, 'termType') && (
|
|
52
|
+
obj.termType === NamedNodeTermType ||
|
|
53
|
+
obj.termType === VariableTermType ||
|
|
54
|
+
obj.termType === BlankNodeTermType ||
|
|
55
|
+
obj.termType === CollectionTermType ||
|
|
56
|
+
obj.termType === LiteralTermType ||
|
|
57
|
+
obj.termType === GraphTermType
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** TypeGuard for valid RDF/JS spec Predicate types */
|
|
62
|
+
export function isRDFlibPredicate(obj: any): obj is Quad_Predicate {
|
|
63
|
+
return isTerm(obj) && (
|
|
64
|
+
obj.termType === NamedNodeTermType ||
|
|
65
|
+
obj.termType === BlankNodeTermType ||
|
|
66
|
+
obj.termType === VariableTermType
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
48
70
|
/** TypeGuard for RDFLib Variables */
|
|
49
71
|
export function isVariable(obj: any): obj is Variable {
|
|
50
72
|
return isTerm(obj)
|