rdflib 2.2.31 → 2.2.32-2f2a2f3c
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/670.rdflib.min.js +1 -0
- package/dist/730.rdflib.min.js +3 -0
- package/dist/730.rdflib.min.js.LICENSE.txt +58 -0
- package/dist/730.rdflib.min.js.map +1 -0
- package/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +0 -59
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +10 -6
- package/esm/collection.js +3 -4
- package/esm/factories/factory-types.js +10 -10
- package/esm/fetcher.js +64 -35
- package/esm/formula.js +10 -13
- package/esm/jsonldparser.js +4 -3
- package/esm/lists.js +2 -1
- package/esm/literal.js +6 -8
- package/esm/node-internal.js +5 -10
- package/esm/rdfxmlparser.js +3 -0
- package/esm/serializer.js +2 -3
- package/esm/statement.js +7 -11
- package/esm/store.js +39 -32
- package/esm/types.js +18 -1
- package/esm/update-manager.js +150 -83
- package/esm/utils.js +0 -1
- package/esm/variable.js +2 -4
- package/lib/blank-node.js +10 -6
- package/lib/collection.js +3 -4
- package/lib/factories/factory-types.js +10 -10
- package/lib/fetcher.js +88 -36
- package/lib/formula.js +10 -13
- package/lib/index.d.ts +1 -1
- package/lib/jsonldparser.js +9 -3
- package/lib/lists.js +15 -1
- package/lib/literal.js +6 -8
- package/lib/node-internal.js +5 -10
- package/lib/query.d.ts +1 -1
- package/lib/rdfxmlparser.js +3 -0
- package/lib/serializer.d.ts +1 -1
- package/lib/serializer.js +2 -3
- package/lib/sparql-to-query.d.ts +1 -1
- package/lib/statement.js +7 -11
- package/lib/store.d.ts +1 -1
- package/lib/store.js +55 -34
- package/lib/types.js +22 -0
- package/lib/update-manager.d.ts +25 -5
- package/lib/update-manager.js +154 -82
- package/lib/utils-js.d.ts +3 -3
- package/lib/variable.js +2 -4
- package/lib/xsd-internal.d.ts +1 -1
- package/package.json +20 -19
- package/src/fetcher.ts +13 -0
- package/src/jsonldparser.js +2 -4
- package/src/serializer.js +1 -1
- package/src/store.ts +18 -1
- package/src/update-manager.ts +243 -163
package/lib/types.js
CHANGED
|
@@ -50,4 +50,26 @@ var XHTMLContentType = "application/xhtml+xml";
|
|
|
50
50
|
/**
|
|
51
51
|
* A valid mime type header
|
|
52
52
|
*/
|
|
53
|
+
|
|
54
|
+
/** A type for values that serves as inputs */
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* In this project, there exist two types for the same kind of RDF concept.
|
|
58
|
+
* We have RDF/JS spec types (standardized, generic), and RDFlib types (internal, specific).
|
|
59
|
+
* When deciding which type to use in a function, it is preferable to accept generic inputs,
|
|
60
|
+
* whenever possible, and provide strict outputs.
|
|
61
|
+
* In some ways, the TF types in here are a bit more strict.
|
|
62
|
+
* Variables are missing, and the statement requires specific types of terms (e.g. NamedNode instead of Term).
|
|
63
|
+
*/
|
|
64
|
+
|
|
65
|
+
/** An RDF/JS Subject */
|
|
66
|
+
|
|
67
|
+
/** An RDF/JS Predicate */
|
|
68
|
+
|
|
69
|
+
/** An RDF/JS Object */
|
|
70
|
+
|
|
71
|
+
/** An RDF/JS Graph */
|
|
72
|
+
// | Formula
|
|
73
|
+
|
|
74
|
+
/** All the types that a .fromValue() method might return */
|
|
53
75
|
exports.XHTMLContentType = XHTMLContentType;
|
package/lib/update-manager.d.ts
CHANGED
|
@@ -28,12 +28,12 @@ export default class UpdateManager {
|
|
|
28
28
|
patchControlFor(doc: NamedNode): any;
|
|
29
29
|
isHttpUri(uri: string): boolean;
|
|
30
30
|
/** Remove from the store HTTP authorization metadata
|
|
31
|
-
* The
|
|
32
|
-
* of the results of previous HTTP transactions.
|
|
31
|
+
* The editable function below relies on copies we have in the store
|
|
32
|
+
* of the results of previous HTTP transactions. However, when
|
|
33
33
|
* the user logs in, then that data misrepresents what would happen
|
|
34
34
|
* if the user tried again.
|
|
35
35
|
*/
|
|
36
|
-
flagAuthorizationMetadata(): void;
|
|
36
|
+
flagAuthorizationMetadata(kb?: IndexedFormula): void;
|
|
37
37
|
/**
|
|
38
38
|
* Tests whether a file is editable.
|
|
39
39
|
* If the file has a specific annotation that it is machine written,
|
|
@@ -42,7 +42,7 @@ export default class UpdateManager {
|
|
|
42
42
|
* and local write access is determined by those headers.
|
|
43
43
|
* This async version not only looks at past HTTP requests, it also makes new ones if necessary.
|
|
44
44
|
*
|
|
45
|
-
* @returns The method string SPARQL or DAV or
|
|
45
|
+
* @returns The method string N3PATCH or SPARQL or DAV or
|
|
46
46
|
* LOCALFILE or false if known, undefined if not known.
|
|
47
47
|
*/
|
|
48
48
|
checkEditable(uri: string | NamedNode, kb?: IndexedFormula): Promise<string | boolean | undefined>;
|
|
@@ -168,7 +168,27 @@ export default class UpdateManager {
|
|
|
168
168
|
*/
|
|
169
169
|
updateMany(deletions: ReadonlyArray<Statement>, insertions?: ReadonlyArray<Statement>): Promise<void[]>;
|
|
170
170
|
/**
|
|
171
|
-
*
|
|
171
|
+
* @private
|
|
172
|
+
*
|
|
173
|
+
* This helper function constructs SPARQL Update query from resolved arguments.
|
|
174
|
+
*
|
|
175
|
+
* @param ds: deletions array.
|
|
176
|
+
* @param is: insertions array.
|
|
177
|
+
* @param bnodes_context: Additional context to uniquely identify any blank nodes.
|
|
178
|
+
*/
|
|
179
|
+
constructSparqlUpdateQuery(ds: ReadonlyArray<Statement>, is: ReadonlyArray<Statement>, bnodes_context: any): string;
|
|
180
|
+
/**
|
|
181
|
+
* @private
|
|
182
|
+
*
|
|
183
|
+
* This helper function constructs n3-patch query from resolved arguments.
|
|
184
|
+
*
|
|
185
|
+
* @param ds: deletions array.
|
|
186
|
+
* @param is: insertions array.
|
|
187
|
+
* @param bnodes_context: Additional context to uniquely identify any blanknodes.
|
|
188
|
+
*/
|
|
189
|
+
constructN3PatchQuery(ds: ReadonlyArray<Statement>, is: ReadonlyArray<Statement>, bnodes_context: any): string;
|
|
190
|
+
/**
|
|
191
|
+
* This high-level function updates the local store if the web is changed successfully.
|
|
172
192
|
* Deletions, insertions may be undefined or single statements or lists or formulae (may contain bnodes which can be indirectly identified by a where clause).
|
|
173
193
|
* The `why` property of each statement must be the same and give the web document to be updated.
|
|
174
194
|
* @param deletions - Statement or statements to be deleted.
|
package/lib/update-manager.js
CHANGED
|
@@ -24,7 +24,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
24
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
|
|
25
25
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
26
26
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
27
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
27
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /* @file Update Manager Class
|
|
28
|
+
**
|
|
29
|
+
** 2007-07-15 original SPARQL Update module by Joe Presbrey <presbrey@mit.edu>
|
|
30
|
+
** 2010-08-08 TimBL folded in Kenny's WEBDAV
|
|
31
|
+
** 2010-12-07 TimBL added local file write code
|
|
32
|
+
*/
|
|
28
33
|
/**
|
|
29
34
|
* The UpdateManager is a helper object for a store.
|
|
30
35
|
* Just as a Fetcher provides the store with the ability to read and write,
|
|
@@ -32,10 +37,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
32
37
|
* and also looking out for concurrent updates from other agents
|
|
33
38
|
*/
|
|
34
39
|
var UpdateManager = /*#__PURE__*/function () {
|
|
35
|
-
/** Index of objects for coordinating incoming and outgoing patches */
|
|
36
|
-
|
|
37
|
-
/** Object of namespaces */
|
|
38
|
-
|
|
39
40
|
/**
|
|
40
41
|
* @param store - The quadstore to store data and metadata. Created if not passed.
|
|
41
42
|
*/
|
|
@@ -44,7 +45,9 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
44
45
|
(0, _defineProperty2.default)(this, "store", void 0);
|
|
45
46
|
(0, _defineProperty2.default)(this, "ifps", void 0);
|
|
46
47
|
(0, _defineProperty2.default)(this, "fps", void 0);
|
|
48
|
+
/** Index of objects for coordinating incoming and outgoing patches */
|
|
47
49
|
(0, _defineProperty2.default)(this, "patchControl", void 0);
|
|
50
|
+
/** Object of namespaces */
|
|
48
51
|
(0, _defineProperty2.default)(this, "ns", void 0);
|
|
49
52
|
store = store || new _store.default();
|
|
50
53
|
if (store.updater) {
|
|
@@ -83,16 +86,19 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
83
86
|
}
|
|
84
87
|
|
|
85
88
|
/** Remove from the store HTTP authorization metadata
|
|
86
|
-
* The
|
|
87
|
-
* of the results of previous HTTP transactions.
|
|
89
|
+
* The editable function below relies on copies we have in the store
|
|
90
|
+
* of the results of previous HTTP transactions. However, when
|
|
88
91
|
* the user logs in, then that data misrepresents what would happen
|
|
89
92
|
* if the user tried again.
|
|
90
93
|
*/
|
|
91
94
|
}, {
|
|
92
95
|
key: "flagAuthorizationMetadata",
|
|
93
|
-
value: function flagAuthorizationMetadata() {
|
|
94
|
-
var
|
|
95
|
-
|
|
96
|
+
value: function flagAuthorizationMetadata(kb) {
|
|
97
|
+
var _kb$fetcher;
|
|
98
|
+
if (!kb) {
|
|
99
|
+
kb = this.store;
|
|
100
|
+
}
|
|
101
|
+
var meta = (_kb$fetcher = kb.fetcher) === null || _kb$fetcher === void 0 ? void 0 : _kb$fetcher.appNode;
|
|
96
102
|
var requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), undefined, meta).map(function (st) {
|
|
97
103
|
return st.subject;
|
|
98
104
|
});
|
|
@@ -104,7 +110,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
104
110
|
var _response = kb.any(request, this.ns.link('response'), null, meta);
|
|
105
111
|
if (_response !== undefined) {
|
|
106
112
|
// ts
|
|
107
|
-
|
|
113
|
+
kb.add(_response, this.ns.link('outOfDate'), true, meta); // @@ Boolean is fine - fix types
|
|
108
114
|
}
|
|
109
115
|
}
|
|
110
116
|
} catch (err) {
|
|
@@ -122,30 +128,40 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
122
128
|
* and local write access is determined by those headers.
|
|
123
129
|
* This async version not only looks at past HTTP requests, it also makes new ones if necessary.
|
|
124
130
|
*
|
|
125
|
-
* @returns The method string SPARQL or DAV or
|
|
131
|
+
* @returns The method string N3PATCH or SPARQL or DAV or
|
|
126
132
|
* LOCALFILE or false if known, undefined if not known.
|
|
127
133
|
*/
|
|
128
134
|
}, {
|
|
129
135
|
key: "checkEditable",
|
|
130
136
|
value: function () {
|
|
131
137
|
var _checkEditable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(uri, kb) {
|
|
138
|
+
var _kb$fetcher2;
|
|
132
139
|
var initial, final;
|
|
133
140
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
134
141
|
while (1) switch (_context.prev = _context.next) {
|
|
135
142
|
case 0:
|
|
143
|
+
if (uri) {
|
|
144
|
+
_context.next = 2;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
return _context.abrupt("return", false);
|
|
148
|
+
case 2:
|
|
149
|
+
if (!kb) {
|
|
150
|
+
kb = this.store;
|
|
151
|
+
}
|
|
136
152
|
initial = this.editable(uri, kb);
|
|
137
153
|
if (!(initial !== undefined)) {
|
|
138
|
-
_context.next =
|
|
154
|
+
_context.next = 6;
|
|
139
155
|
break;
|
|
140
156
|
}
|
|
141
157
|
return _context.abrupt("return", initial);
|
|
142
|
-
case
|
|
143
|
-
_context.next =
|
|
144
|
-
return
|
|
145
|
-
case
|
|
158
|
+
case 6:
|
|
159
|
+
_context.next = 8;
|
|
160
|
+
return (_kb$fetcher2 = kb.fetcher) === null || _kb$fetcher2 === void 0 ? void 0 : _kb$fetcher2.load(uri);
|
|
161
|
+
case 8:
|
|
146
162
|
final = this.editable(uri, kb); // console.log(`Loaded ${uri} just to check editable, result: ${final}.`)
|
|
147
163
|
return _context.abrupt("return", final);
|
|
148
|
-
case
|
|
164
|
+
case 10:
|
|
149
165
|
case "end":
|
|
150
166
|
return _context.stop();
|
|
151
167
|
}
|
|
@@ -170,6 +186,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
170
186
|
}, {
|
|
171
187
|
key: "editable",
|
|
172
188
|
value: function editable(uri, kb) {
|
|
189
|
+
var _kb$fetcher3;
|
|
173
190
|
if (!uri) {
|
|
174
191
|
return false; // Eg subject is bnode, no known doc to write to
|
|
175
192
|
}
|
|
@@ -179,13 +196,13 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
179
196
|
}
|
|
180
197
|
uri = (0, _termValue.termValue)(uri);
|
|
181
198
|
if (!this.isHttpUri(uri)) {
|
|
182
|
-
if (
|
|
199
|
+
if (kb.holds(kb.rdfFactory.namedNode(uri), kb.rdfFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), kb.rdfFactory.namedNode('http://www.w3.org/2007/ont/link#MachineEditableDocument'))) {
|
|
183
200
|
return 'LOCALFILE';
|
|
184
201
|
}
|
|
185
202
|
}
|
|
186
203
|
var request;
|
|
187
204
|
var definitive = false;
|
|
188
|
-
var meta =
|
|
205
|
+
var meta = (_kb$fetcher3 = kb.fetcher) === null || _kb$fetcher3 === void 0 ? void 0 : _kb$fetcher3.appNode;
|
|
189
206
|
// const kb = s
|
|
190
207
|
|
|
191
208
|
// @ts-ignore passes a string to kb.each, which expects a term. Should this work?
|
|
@@ -223,6 +240,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
223
240
|
if (acceptPatch.length) {
|
|
224
241
|
for (var i = 0; i < acceptPatch.length; i++) {
|
|
225
242
|
method = acceptPatch[i].value.trim();
|
|
243
|
+
if (method.indexOf('text/n3') >= 0) return 'N3PATCH';
|
|
226
244
|
if (method.indexOf('application/sparql-update') >= 0) return 'SPARQL';
|
|
227
245
|
if (method.indexOf('application/sparql-update-single-match') >= 0) return 'SPARQL';
|
|
228
246
|
}
|
|
@@ -270,7 +288,8 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
270
288
|
}, {
|
|
271
289
|
key: "anonymize",
|
|
272
290
|
value: function anonymize(obj) {
|
|
273
|
-
|
|
291
|
+
var anonymized = obj.toNT().substr(0, 2) === '_:' && this.mentioned(obj) ? '?' + obj.toNT().substr(2) : obj.toNT();
|
|
292
|
+
return anonymized;
|
|
274
293
|
}
|
|
275
294
|
}, {
|
|
276
295
|
key: "anonymizeNT",
|
|
@@ -468,7 +487,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
468
487
|
// console.log('UpdateManager: sending update to <' + uri + '>')
|
|
469
488
|
|
|
470
489
|
options.noMeta = true;
|
|
471
|
-
options.contentType = 'application/sparql-update';
|
|
490
|
+
options.contentType = options.contentType || 'application/sparql-update';
|
|
472
491
|
options.body = query;
|
|
473
492
|
return _this.store.fetcher.webOperation('PATCH', uri, options);
|
|
474
493
|
}).then(function (response) {
|
|
@@ -486,7 +505,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
486
505
|
});
|
|
487
506
|
}
|
|
488
507
|
|
|
489
|
-
// ARE THESE
|
|
508
|
+
// ARE THESE THREE FUNCTIONS USED? DEPRECATE?
|
|
490
509
|
|
|
491
510
|
/** return a statemnet updating function
|
|
492
511
|
*
|
|
@@ -796,7 +815,93 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
796
815
|
}
|
|
797
816
|
|
|
798
817
|
/**
|
|
799
|
-
*
|
|
818
|
+
* @private
|
|
819
|
+
*
|
|
820
|
+
* This helper function constructs SPARQL Update query from resolved arguments.
|
|
821
|
+
*
|
|
822
|
+
* @param ds: deletions array.
|
|
823
|
+
* @param is: insertions array.
|
|
824
|
+
* @param bnodes_context: Additional context to uniquely identify any blank nodes.
|
|
825
|
+
*/
|
|
826
|
+
}, {
|
|
827
|
+
key: "constructSparqlUpdateQuery",
|
|
828
|
+
value: function constructSparqlUpdateQuery(ds, is, bnodes_context) {
|
|
829
|
+
var whereClause = this.contextWhere(bnodes_context);
|
|
830
|
+
var query = '';
|
|
831
|
+
if (whereClause.length) {
|
|
832
|
+
// Is there a WHERE clause?
|
|
833
|
+
if (ds.length) {
|
|
834
|
+
query += 'DELETE { ';
|
|
835
|
+
for (var i = 0; i < ds.length; i++) {
|
|
836
|
+
query += this.anonymizeNT(ds[i]) + '\n';
|
|
837
|
+
}
|
|
838
|
+
query += ' }\n';
|
|
839
|
+
}
|
|
840
|
+
if (is.length) {
|
|
841
|
+
query += 'INSERT { ';
|
|
842
|
+
for (var _i5 = 0; _i5 < is.length; _i5++) {
|
|
843
|
+
query += this.anonymizeNT(is[_i5]) + '\n';
|
|
844
|
+
}
|
|
845
|
+
query += ' }\n';
|
|
846
|
+
}
|
|
847
|
+
query += whereClause;
|
|
848
|
+
} else {
|
|
849
|
+
// no where clause
|
|
850
|
+
if (ds.length) {
|
|
851
|
+
query += 'DELETE DATA { ';
|
|
852
|
+
for (var _i6 = 0; _i6 < ds.length; _i6++) {
|
|
853
|
+
query += this.anonymizeNT(ds[_i6]) + '\n';
|
|
854
|
+
}
|
|
855
|
+
query += ' } \n';
|
|
856
|
+
}
|
|
857
|
+
if (is.length) {
|
|
858
|
+
if (ds.length) query += ' ; ';
|
|
859
|
+
query += 'INSERT DATA { ';
|
|
860
|
+
for (var _i7 = 0; _i7 < is.length; _i7++) {
|
|
861
|
+
query += this.nTriples(is[_i7]) + '\n';
|
|
862
|
+
}
|
|
863
|
+
query += ' }\n';
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return query;
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* @private
|
|
871
|
+
*
|
|
872
|
+
* This helper function constructs n3-patch query from resolved arguments.
|
|
873
|
+
*
|
|
874
|
+
* @param ds: deletions array.
|
|
875
|
+
* @param is: insertions array.
|
|
876
|
+
* @param bnodes_context: Additional context to uniquely identify any blanknodes.
|
|
877
|
+
*/
|
|
878
|
+
}, {
|
|
879
|
+
key: "constructN3PatchQuery",
|
|
880
|
+
value: function constructN3PatchQuery(ds, is, bnodes_context) {
|
|
881
|
+
var _this3 = this;
|
|
882
|
+
var query = "\n@prefix solid: <http://www.w3.org/ns/solid/terms#>.\n@prefix ex: <http://www.example.org/terms#>.\n\n_:patch\n";
|
|
883
|
+
// If bnode context is non trivial, express it as ?conditions formula.
|
|
884
|
+
if (bnodes_context && bnodes_context.length > 0) {
|
|
885
|
+
query += "\n solid:where {\n ".concat(bnodes_context.map(function (x) {
|
|
886
|
+
return _this3.anonymizeNT(x);
|
|
887
|
+
}).join('\n '), "\n };");
|
|
888
|
+
}
|
|
889
|
+
if (ds.length > 0) {
|
|
890
|
+
query += "\n solid:deletes {\n ".concat(ds.map(function (x) {
|
|
891
|
+
return _this3.anonymizeNT(x);
|
|
892
|
+
}).join('\n '), "\n };");
|
|
893
|
+
}
|
|
894
|
+
if (is.length > 0) {
|
|
895
|
+
query += "\n solid:inserts {\n ".concat(is.map(function (x) {
|
|
896
|
+
return _this3.anonymizeNT(x);
|
|
897
|
+
}).join('\n '), "\n };");
|
|
898
|
+
}
|
|
899
|
+
query += " a solid:InsertDeletePatch .\n";
|
|
900
|
+
return query;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* This high-level function updates the local store if the web is changed successfully.
|
|
800
905
|
* Deletions, insertions may be undefined or single statements or lists or formulae (may contain bnodes which can be indirectly identified by a where clause).
|
|
801
906
|
* The `why` property of each statement must be the same and give the web document to be updated.
|
|
802
907
|
* @param deletions - Statement or statements to be deleted.
|
|
@@ -808,7 +913,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
808
913
|
}, {
|
|
809
914
|
key: "update",
|
|
810
915
|
value: function update(deletions, insertions, callback, secondTry) {
|
|
811
|
-
var
|
|
916
|
+
var _this4 = this;
|
|
812
917
|
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
|
813
918
|
if (!callback) {
|
|
814
919
|
var thisUpdater = this;
|
|
@@ -876,64 +981,31 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
876
981
|
if (protocol === undefined) {
|
|
877
982
|
// Not enough metadata
|
|
878
983
|
if (secondTry) {
|
|
879
|
-
throw new Error('Update: Loaded ' + doc + "but
|
|
984
|
+
throw new Error('Update: Loaded ' + doc + "but still can't figure out what editing protocol it supports.");
|
|
880
985
|
}
|
|
881
986
|
// console.log(`Update: have not loaded ${doc} before: loading now...`);
|
|
882
987
|
this.store.fetcher.load(doc).then(function (response) {
|
|
883
|
-
|
|
988
|
+
_this4.update(deletions, insertions, callback, true, options);
|
|
884
989
|
}, function (err) {
|
|
885
990
|
if (err.response.status === 404) {
|
|
886
991
|
// nonexistent files are fine
|
|
887
|
-
|
|
992
|
+
_this4.update(deletions, insertions, callback, true, options);
|
|
888
993
|
} else {
|
|
889
994
|
throw new Error("Update: Can't get updatability status ".concat(doc, " before patching: ").concat(err));
|
|
890
995
|
}
|
|
891
996
|
});
|
|
892
997
|
return;
|
|
893
|
-
} else if (protocol.indexOf('SPARQL') >= 0) {
|
|
998
|
+
} else if (protocol.indexOf('SPARQL') >= 0 || protocol.indexOf('N3PATCH') >= 0) {
|
|
999
|
+
var isSparql = protocol.indexOf('SPARQL') >= 0;
|
|
894
1000
|
var bnodes = [];
|
|
895
1001
|
// change ReadOnly type to Mutable type
|
|
896
1002
|
|
|
897
1003
|
if (ds.length) bnodes = this.statementArrayBnodes(ds);
|
|
898
1004
|
if (is.length) bnodes = bnodes.concat(this.statementArrayBnodes(is));
|
|
899
1005
|
var context = this.bnodeContext(bnodes, doc);
|
|
900
|
-
var
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
// Is there a WHERE clause?
|
|
904
|
-
if (ds.length) {
|
|
905
|
-
query += 'DELETE { ';
|
|
906
|
-
for (var i = 0; i < ds.length; i++) {
|
|
907
|
-
query += this.anonymizeNT(ds[i]) + '\n';
|
|
908
|
-
}
|
|
909
|
-
query += ' }\n';
|
|
910
|
-
}
|
|
911
|
-
if (is.length) {
|
|
912
|
-
query += 'INSERT { ';
|
|
913
|
-
for (var _i5 = 0; _i5 < is.length; _i5++) {
|
|
914
|
-
query += this.anonymizeNT(is[_i5]) + '\n';
|
|
915
|
-
}
|
|
916
|
-
query += ' }\n';
|
|
917
|
-
}
|
|
918
|
-
query += whereClause;
|
|
919
|
-
} else {
|
|
920
|
-
// no where clause
|
|
921
|
-
if (ds.length) {
|
|
922
|
-
query += 'DELETE DATA { ';
|
|
923
|
-
for (var _i6 = 0; _i6 < ds.length; _i6++) {
|
|
924
|
-
query += this.anonymizeNT(ds[_i6]) + '\n';
|
|
925
|
-
}
|
|
926
|
-
query += ' } \n';
|
|
927
|
-
}
|
|
928
|
-
if (is.length) {
|
|
929
|
-
if (ds.length) query += ' ; ';
|
|
930
|
-
query += 'INSERT DATA { ';
|
|
931
|
-
for (var _i7 = 0; _i7 < is.length; _i7++) {
|
|
932
|
-
query += this.nTriples(is[_i7]) + '\n';
|
|
933
|
-
}
|
|
934
|
-
query += ' }\n';
|
|
935
|
-
}
|
|
936
|
-
}
|
|
1006
|
+
var query = isSparql ? this.constructSparqlUpdateQuery(ds, is, context) : this.constructN3PatchQuery(ds, is, context);
|
|
1007
|
+
options.contentType = isSparql ? 'application/sparql-update' : 'text/n3';
|
|
1008
|
+
|
|
937
1009
|
// Track pending upstream patches until they have finished their callbackFunction
|
|
938
1010
|
control.pendingUpstream = control.pendingUpstream ? control.pendingUpstream + 1 : 1;
|
|
939
1011
|
if ('upstreamCount' in control) {
|
|
@@ -954,8 +1026,8 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
954
1026
|
success = false;
|
|
955
1027
|
body = 'Remote Ok BUT error deleting ' + ds.length + ' from store!!! ' + e;
|
|
956
1028
|
} // Add in any case -- help recover from weirdness??
|
|
957
|
-
for (var
|
|
958
|
-
kb.add(is[
|
|
1029
|
+
for (var i = 0; i < is.length; i++) {
|
|
1030
|
+
kb.add(is[i].subject, is[i].predicate, is[i].object, doc);
|
|
959
1031
|
}
|
|
960
1032
|
}
|
|
961
1033
|
callback(uri, success, body, response);
|
|
@@ -1009,8 +1081,8 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
1009
1081
|
for (var i = 0; i < ds.length; i++) {
|
|
1010
1082
|
Util.RDFArrayRemove(newSts, ds[i]);
|
|
1011
1083
|
}
|
|
1012
|
-
for (var
|
|
1013
|
-
newSts.push(is[
|
|
1084
|
+
for (var _i8 = 0; _i8 < is.length; _i8++) {
|
|
1085
|
+
newSts.push(is[_i8]);
|
|
1014
1086
|
}
|
|
1015
1087
|
var documentString = this.serialize(doc.value, newSts, contentType);
|
|
1016
1088
|
|
|
@@ -1027,11 +1099,11 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
1027
1099
|
if (!response.ok) {
|
|
1028
1100
|
throw new Error(response.error);
|
|
1029
1101
|
}
|
|
1030
|
-
for (var
|
|
1031
|
-
kb.remove(ds[
|
|
1102
|
+
for (var _i9 = 0; _i9 < ds.length; _i9++) {
|
|
1103
|
+
kb.remove(ds[_i9]);
|
|
1032
1104
|
}
|
|
1033
|
-
for (var
|
|
1034
|
-
kb.add(is[
|
|
1105
|
+
for (var _i10 = 0; _i10 < is.length; _i10++) {
|
|
1106
|
+
kb.add(is[_i10].subject, is[_i10].predicate, is[_i10].object, doc);
|
|
1035
1107
|
}
|
|
1036
1108
|
callbackFunction(doc.value, response.ok, response.responseText, response);
|
|
1037
1109
|
}).catch(function (err) {
|
|
@@ -1061,8 +1133,8 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
1061
1133
|
for (var i = 0; i < ds.length; i++) {
|
|
1062
1134
|
Util.RDFArrayRemove(newSts, ds[i]);
|
|
1063
1135
|
}
|
|
1064
|
-
for (var
|
|
1065
|
-
newSts.push(is[
|
|
1136
|
+
for (var _i11 = 0; _i11 < is.length; _i11++) {
|
|
1137
|
+
newSts.push(is[_i11]);
|
|
1066
1138
|
}
|
|
1067
1139
|
// serialize to the appropriate format
|
|
1068
1140
|
var dot = doc.value.lastIndexOf('.');
|
|
@@ -1078,11 +1150,11 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
1078
1150
|
options.contentType = contentType;
|
|
1079
1151
|
kb.fetcher.webOperation('PUT', doc.value, options).then(function (response) {
|
|
1080
1152
|
if (!response.ok) return callbackFunction(doc.value, false, response.error);
|
|
1081
|
-
for (var
|
|
1082
|
-
kb.remove(ds[
|
|
1153
|
+
for (var _i12 = 0; _i12 < ds.length; _i12++) {
|
|
1154
|
+
kb.remove(ds[_i12]);
|
|
1083
1155
|
}
|
|
1084
|
-
for (var
|
|
1085
|
-
kb.add(is[
|
|
1156
|
+
for (var _i13 = 0; _i13 < is.length; _i13++) {
|
|
1157
|
+
kb.add(is[_i13].subject, is[_i13].predicate, is[_i13].object, doc);
|
|
1086
1158
|
}
|
|
1087
1159
|
callbackFunction(doc.value, true, ''); // success!
|
|
1088
1160
|
});
|
|
@@ -1130,11 +1202,11 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
1130
1202
|
}, {
|
|
1131
1203
|
key: "put",
|
|
1132
1204
|
value: function put(doc, data, contentType, callback) {
|
|
1133
|
-
var
|
|
1205
|
+
var _this5 = this;
|
|
1134
1206
|
var kb = this.store;
|
|
1135
1207
|
var documentString;
|
|
1136
1208
|
return Promise.resolve().then(function () {
|
|
1137
|
-
documentString =
|
|
1209
|
+
documentString = _this5.serialize(doc.value, data, contentType);
|
|
1138
1210
|
return kb.fetcher.webOperation('PUT', doc.value, {
|
|
1139
1211
|
contentType: contentType,
|
|
1140
1212
|
body: documentString
|
package/lib/utils-js.d.ts
CHANGED
|
@@ -37,9 +37,9 @@ export function parseXML(str: any, options: any): Document;
|
|
|
37
37
|
export function RDFArrayRemove(a: any, x: any): void;
|
|
38
38
|
export function string_startswith(str: any, pref: any): boolean;
|
|
39
39
|
export function stackString(e: any): string;
|
|
40
|
-
import NamedNode from
|
|
41
|
-
import log from
|
|
42
|
-
import * as uri from
|
|
40
|
+
import NamedNode from './named-node';
|
|
41
|
+
import log from './log';
|
|
42
|
+
import * as uri from './uri';
|
|
43
43
|
export namespace string {
|
|
44
44
|
export { stringTemplate as template };
|
|
45
45
|
}
|
package/lib/variable.js
CHANGED
|
@@ -31,10 +31,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
31
31
|
var Variable = /*#__PURE__*/function (_Node) {
|
|
32
32
|
(0, _inherits2.default)(Variable, _Node);
|
|
33
33
|
var _super = _createSuper(Variable);
|
|
34
|
-
/** The base string for a variable's name */
|
|
35
|
-
|
|
36
|
-
/** The unique identifier of this variable */
|
|
37
|
-
|
|
38
34
|
/**
|
|
39
35
|
* Initializes this variable
|
|
40
36
|
* @param name The variable's name
|
|
@@ -45,9 +41,11 @@ var Variable = /*#__PURE__*/function (_Node) {
|
|
|
45
41
|
(0, _classCallCheck2.default)(this, Variable);
|
|
46
42
|
_this = _super.call(this, name);
|
|
47
43
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "termType", _types.VariableTermType);
|
|
44
|
+
/** The base string for a variable's name */
|
|
48
45
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "base", 'varid:');
|
|
49
46
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "classOrder", _classOrder.default.Variable);
|
|
50
47
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isVar", 1);
|
|
48
|
+
/** The unique identifier of this variable */
|
|
51
49
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "uri", void 0);
|
|
52
50
|
_this.base = 'varid:';
|
|
53
51
|
_this.uri = Uri.join(name, _this.base);
|
package/lib/xsd-internal.d.ts
CHANGED
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.32-2f2a2f3c",
|
|
5
5
|
"private": false,
|
|
6
6
|
"browserslist": [
|
|
7
7
|
"> 0.5%"
|
|
@@ -44,48 +44,49 @@
|
|
|
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.
|
|
47
|
+
"@babel/runtime": "^7.21.0",
|
|
48
48
|
"@frogcat/ttl2jsonld": "^0.0.9",
|
|
49
|
-
"@xmldom/xmldom": "^0.8.
|
|
49
|
+
"@xmldom/xmldom": "^0.8.7",
|
|
50
50
|
"cross-fetch": "^3.1.5",
|
|
51
|
-
"jsonld": "^
|
|
52
|
-
"n3": "^1.16.
|
|
53
|
-
"solid-namespace": "^0.5.
|
|
51
|
+
"jsonld": "^8.1.1",
|
|
52
|
+
"n3": "^1.16.4",
|
|
53
|
+
"solid-namespace": "^0.5.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@babel/cli": "^7.
|
|
57
|
-
"@babel/core": "^7.
|
|
56
|
+
"@babel/cli": "^7.21.0",
|
|
57
|
+
"@babel/core": "^7.21.4",
|
|
58
58
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
59
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
60
|
-
"@babel/preset-env": "^7.
|
|
61
|
-
"@babel/preset-typescript": "^7.
|
|
62
|
-
"@babel/register": "^7.
|
|
59
|
+
"@babel/plugin-transform-runtime": "^7.21.4",
|
|
60
|
+
"@babel/preset-env": "^7.21.4",
|
|
61
|
+
"@babel/preset-typescript": "^7.21.4",
|
|
62
|
+
"@babel/register": "^7.21.0",
|
|
63
63
|
"@types/chai": "^4.3.4",
|
|
64
64
|
"@types/dirty-chai": "^2.0.2",
|
|
65
65
|
"@types/express": "^4.17.17",
|
|
66
66
|
"@types/jsonld": "^1.5.8",
|
|
67
|
+
"@types/mocha": "^10.0.4",
|
|
67
68
|
"@types/sinon-chai": "^3.2.9",
|
|
68
69
|
"babel-loader": "^9.1.2",
|
|
69
70
|
"chai": "^4.3.7",
|
|
70
71
|
"diff": "^5.1.0",
|
|
71
72
|
"dirty-chai": "^2.0.1",
|
|
72
|
-
"eslint": "^8.
|
|
73
|
+
"eslint": "^8.38.0",
|
|
73
74
|
"fs-grep": "0.0.5",
|
|
74
75
|
"locate-path": "^7.2.0",
|
|
75
76
|
"mocha": "^10.2.0",
|
|
76
77
|
"nock": "^13.3.0",
|
|
77
|
-
"node-fetch": "^3.3.
|
|
78
|
+
"node-fetch": "^3.3.1",
|
|
78
79
|
"node-polyfill-webpack-plugin": "^2.0.1",
|
|
79
80
|
"rdf-js": "^4.0.2",
|
|
80
|
-
"sinon": "^15.0.
|
|
81
|
+
"sinon": "^15.0.3",
|
|
81
82
|
"sinon-chai": "^3.7.0",
|
|
82
83
|
"source-map-loader": "^4.0.1",
|
|
83
84
|
"ts-node": "^10.9.1",
|
|
84
|
-
"typedoc": "^0.
|
|
85
|
-
"typescript": "^
|
|
86
|
-
"webpack": "^5.
|
|
85
|
+
"typedoc": "^0.24.2",
|
|
86
|
+
"typescript": "^5.0.4",
|
|
87
|
+
"webpack": "^5.79.0",
|
|
87
88
|
"webpack-cli": "^5.0.1",
|
|
88
|
-
"webpack-dev-server": "^4.
|
|
89
|
+
"webpack-dev-server": "^4.13.3"
|
|
89
90
|
},
|
|
90
91
|
"scripts": {
|
|
91
92
|
"build": "babel src --extensions \".ts,.js\" -d lib",
|
package/src/fetcher.ts
CHANGED
|
@@ -974,6 +974,19 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
974
974
|
docuri = docuri.split('#')[0]
|
|
975
975
|
|
|
976
976
|
options = this.initFetchOptions(docuri, options)
|
|
977
|
+
// if metadata flaged clear cache and removeDocument
|
|
978
|
+
const meta = this.appNode
|
|
979
|
+
const kb = this.store
|
|
980
|
+
const requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), kb.sym(docuri), meta).map(st => st.subject)
|
|
981
|
+
for (const request of requests) {
|
|
982
|
+
const response = kb.any(request, this.ns.link('response'), null, meta) as Quad_Subject
|
|
983
|
+
if (response !== undefined) { // ts
|
|
984
|
+
const quad = kb.statementsMatching(response, this.ns.link('outOfDate'), true as any, meta)
|
|
985
|
+
kb.remove(quad)
|
|
986
|
+
options.force = true
|
|
987
|
+
options.clearPreviousData = true
|
|
988
|
+
}
|
|
989
|
+
}
|
|
977
990
|
|
|
978
991
|
const initialisedOptions = this.initFetchOptions(docuri, options)
|
|
979
992
|
|