rdflib 2.2.30-c488dd5d → 2.2.31-10c4e145
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/fetcher.js +39 -9
- package/esm/jsonldparser.js +4 -3
- package/esm/store.js +21 -1
- package/esm/update-manager.js +29 -16
- package/lib/fetcher.js +39 -9
- package/lib/jsonldparser.js +9 -3
- package/lib/store.d.ts +1 -1
- package/lib/store.js +21 -1
- package/lib/update-manager.d.ts +1 -1
- package/lib/update-manager.js +29 -16
- package/package.json +2 -2
- package/src/fetcher.ts +19 -6
- package/src/jsonldparser.js +2 -4
- package/src/store.ts +18 -1
- package/src/update-manager.ts +23 -14
package/esm/fetcher.js
CHANGED
|
@@ -6,6 +6,9 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
6
6
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
8
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
+
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; } } }; }
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
9
12
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
13
|
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; } }
|
|
11
14
|
/* global $SolidTestEnvironment */
|
|
@@ -598,7 +601,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
598
601
|
if (!this._fetch) {
|
|
599
602
|
throw new Error('No _fetch function available for Fetcher');
|
|
600
603
|
}
|
|
601
|
-
// This is the name of the
|
|
604
|
+
// This is the name of the graph we store all the HTTP metadata in
|
|
602
605
|
this.appNode = this.store.sym('chrome://TheCurrentSession');
|
|
603
606
|
// this.appNode = this.store.rdfFactory.blankNode() // Needs to have a URI in tests
|
|
604
607
|
this.store.fetcher = this; // Bi-linked
|
|
@@ -688,6 +691,31 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
688
691
|
var docuri = termValue(uriIn);
|
|
689
692
|
docuri = docuri.split('#')[0];
|
|
690
693
|
options = this.initFetchOptions(docuri, options);
|
|
694
|
+
// if metadata flaged clear cache and removeDocument
|
|
695
|
+
var meta = this.appNode;
|
|
696
|
+
var kb = this.store;
|
|
697
|
+
var requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), kb.sym(docuri), meta).map(function (st) {
|
|
698
|
+
return st.subject;
|
|
699
|
+
});
|
|
700
|
+
var _iterator = _createForOfIteratorHelper(requests),
|
|
701
|
+
_step;
|
|
702
|
+
try {
|
|
703
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
704
|
+
var request = _step.value;
|
|
705
|
+
var _response = kb.any(request, this.ns.link('response'), null, meta);
|
|
706
|
+
if (_response !== undefined) {
|
|
707
|
+
// ts
|
|
708
|
+
var quad = kb.statementsMatching(_response, this.ns.link('outOfDate'), true, meta);
|
|
709
|
+
kb.remove(quad);
|
|
710
|
+
options.force = true;
|
|
711
|
+
options.clearPreviousData = true;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
} catch (err) {
|
|
715
|
+
_iterator.e(err);
|
|
716
|
+
} finally {
|
|
717
|
+
_iterator.f();
|
|
718
|
+
}
|
|
691
719
|
var initialisedOptions = this.initFetchOptions(docuri, options);
|
|
692
720
|
return this.pendingFetchPromise(docuri, initialisedOptions.baseURI, initialisedOptions);
|
|
693
721
|
}
|
|
@@ -1390,10 +1418,10 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1390
1418
|
for (var r = 0; r < requests.length; r++) {
|
|
1391
1419
|
var request = requests[r];
|
|
1392
1420
|
if (request !== undefined) {
|
|
1393
|
-
var
|
|
1394
|
-
if (
|
|
1421
|
+
var _response2 = kb.any(request, this.ns.link('response'));
|
|
1422
|
+
if (_response2 !== undefined && kb.anyValue(_response2, this.ns.http('status')) && kb.anyValue(_response2, this.ns.http('status')).startsWith('2')) {
|
|
1395
1423
|
// Only look at success returns - not 401 error messagess etc
|
|
1396
|
-
var results = kb.each(
|
|
1424
|
+
var results = kb.each(_response2, this.ns.httph(header.toLowerCase()));
|
|
1397
1425
|
if (results.length) {
|
|
1398
1426
|
return results.map(function (v) {
|
|
1399
1427
|
return v.value;
|
|
@@ -1432,17 +1460,19 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1432
1460
|
var _this10 = this;
|
|
1433
1461
|
var kb = this.store;
|
|
1434
1462
|
var responseNode = kb.bnode();
|
|
1435
|
-
kb.add(options.req, this.ns.link('response'), responseNode,
|
|
1436
|
-
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status),
|
|
1437
|
-
kb.add(responseNode, this.ns.http('statusText'), kb.rdfFactory.literal(response.statusText),
|
|
1463
|
+
kb.add(options.req, this.ns.link('response'), responseNode, this.appNode);
|
|
1464
|
+
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status), this.appNode);
|
|
1465
|
+
kb.add(responseNode, this.ns.http('statusText'), kb.rdfFactory.literal(response.statusText), this.appNode);
|
|
1438
1466
|
|
|
1439
1467
|
// Save the response headers
|
|
1440
1468
|
response.headers.forEach(function (value, header) {
|
|
1441
|
-
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value),
|
|
1469
|
+
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value), _this10.appNode);
|
|
1442
1470
|
if (header === 'content-type') {
|
|
1443
|
-
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), responseNode
|
|
1471
|
+
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), _this10.appNode // responseNode
|
|
1472
|
+
);
|
|
1444
1473
|
}
|
|
1445
1474
|
});
|
|
1475
|
+
|
|
1446
1476
|
return responseNode;
|
|
1447
1477
|
}
|
|
1448
1478
|
}, {
|
package/esm/jsonldparser.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import jsonld from 'jsonld';
|
|
2
1
|
import { arrayToStatements } from './utils';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -60,8 +59,10 @@ function listToCollection(kb, obj) {
|
|
|
60
59
|
*/
|
|
61
60
|
export default function jsonldParser(str, kb, base, callback) {
|
|
62
61
|
var baseString = base && Object.prototype.hasOwnProperty.call(base, 'termType') ? base.value : base;
|
|
63
|
-
return jsonld.
|
|
64
|
-
|
|
62
|
+
return import('jsonld').then(function (jsonld) {
|
|
63
|
+
return jsonld.flatten(JSON.parse(str), null, {
|
|
64
|
+
base: baseString
|
|
65
|
+
});
|
|
65
66
|
}).then(function (flattened) {
|
|
66
67
|
return flattened.reduce(function (store, flatResource) {
|
|
67
68
|
kb = processResource(kb, base, flatResource);
|
package/esm/store.js
CHANGED
|
@@ -838,12 +838,32 @@ var IndexedFormula = /*#__PURE__*/function (_Formula) {
|
|
|
838
838
|
}
|
|
839
839
|
|
|
840
840
|
/**
|
|
841
|
-
* Removes all statements in a doc
|
|
841
|
+
* Removes all statements in a doc, along with the related metadata including request/response
|
|
842
842
|
* @param doc - The document / graph
|
|
843
843
|
*/
|
|
844
844
|
}, {
|
|
845
845
|
key: "removeDocument",
|
|
846
846
|
value: function removeDocument(doc) {
|
|
847
|
+
var meta = this.sym('chrome://TheCurrentSession'); // or this.rdfFactory.namedNode('chrome://TheCurrentSession')
|
|
848
|
+
var linkNamespaceURI = 'http://www.w3.org/2007/ont/link#'; // alain
|
|
849
|
+
// remove request/response and metadata
|
|
850
|
+
var requests = this.statementsMatching(undefined, this.sym("".concat(linkNamespaceURI, "requestedURI")), this.rdfFactory.literal(doc.value), meta).map(function (st) {
|
|
851
|
+
return st.subject;
|
|
852
|
+
});
|
|
853
|
+
for (var r = 0; r < requests.length; r++) {
|
|
854
|
+
var request = requests[r];
|
|
855
|
+
if (request !== undefined) {
|
|
856
|
+
this.removeMatches(request, null, null, meta);
|
|
857
|
+
var response = this.any(request, this.sym("".concat(linkNamespaceURI, "response")), null, meta);
|
|
858
|
+
if (response !== undefined) {
|
|
859
|
+
// ts
|
|
860
|
+
this.removeMatches(response, null, null, meta);
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
this.removeMatches(this.sym(doc.value), null, null, meta); // content-type
|
|
865
|
+
|
|
866
|
+
// remove document
|
|
847
867
|
var sts = this.statementsMatching(undefined, undefined, undefined, doc).slice(); // Take a copy as this is the actual index
|
|
848
868
|
for (var i = 0; i < sts.length; i++) {
|
|
849
869
|
this.removeStatement(sts[i]);
|
package/esm/update-manager.js
CHANGED
|
@@ -86,9 +86,12 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
86
86
|
*/
|
|
87
87
|
}, {
|
|
88
88
|
key: "flagAuthorizationMetadata",
|
|
89
|
-
value: function flagAuthorizationMetadata() {
|
|
90
|
-
var
|
|
91
|
-
|
|
89
|
+
value: function flagAuthorizationMetadata(kb) {
|
|
90
|
+
var _kb$fetcher;
|
|
91
|
+
if (!kb) {
|
|
92
|
+
kb = this.store;
|
|
93
|
+
}
|
|
94
|
+
var meta = (_kb$fetcher = kb.fetcher) === null || _kb$fetcher === void 0 ? void 0 : _kb$fetcher.appNode;
|
|
92
95
|
var requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), undefined, meta).map(function (st) {
|
|
93
96
|
return st.subject;
|
|
94
97
|
});
|
|
@@ -100,7 +103,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
100
103
|
var _response = kb.any(request, this.ns.link('response'), null, meta);
|
|
101
104
|
if (_response !== undefined) {
|
|
102
105
|
// ts
|
|
103
|
-
|
|
106
|
+
kb.add(_response, this.ns.link('outOfDate'), true, meta); // @@ Boolean is fine - fix types
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
} catch (err) {
|
|
@@ -125,24 +128,33 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
125
128
|
key: "checkEditable",
|
|
126
129
|
value: function () {
|
|
127
130
|
var _checkEditable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(uri, kb) {
|
|
131
|
+
var _kb$fetcher2;
|
|
128
132
|
var initial, final;
|
|
129
133
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
130
134
|
while (1) switch (_context.prev = _context.next) {
|
|
131
135
|
case 0:
|
|
136
|
+
if (uri) {
|
|
137
|
+
_context.next = 2;
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
return _context.abrupt("return", false);
|
|
141
|
+
case 2:
|
|
142
|
+
if (!kb) {
|
|
143
|
+
kb = this.store;
|
|
144
|
+
}
|
|
132
145
|
initial = this.editable(uri, kb);
|
|
133
146
|
if (!(initial !== undefined)) {
|
|
134
|
-
_context.next =
|
|
147
|
+
_context.next = 6;
|
|
135
148
|
break;
|
|
136
149
|
}
|
|
137
150
|
return _context.abrupt("return", initial);
|
|
138
|
-
case
|
|
139
|
-
_context.next =
|
|
140
|
-
return
|
|
141
|
-
case 5:
|
|
142
|
-
final = this.editable(uri, kb);
|
|
143
|
-
console.log("Loaded ".concat(uri, " just to check editable, result: ").concat(final, "."));
|
|
144
|
-
return _context.abrupt("return", final);
|
|
151
|
+
case 6:
|
|
152
|
+
_context.next = 8;
|
|
153
|
+
return (_kb$fetcher2 = kb.fetcher) === null || _kb$fetcher2 === void 0 ? void 0 : _kb$fetcher2.load(uri);
|
|
145
154
|
case 8:
|
|
155
|
+
final = this.editable(uri, kb); // console.log(`Loaded ${uri} just to check editable, result: ${final}.`)
|
|
156
|
+
return _context.abrupt("return", final);
|
|
157
|
+
case 10:
|
|
146
158
|
case "end":
|
|
147
159
|
return _context.stop();
|
|
148
160
|
}
|
|
@@ -167,6 +179,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
167
179
|
}, {
|
|
168
180
|
key: "editable",
|
|
169
181
|
value: function editable(uri, kb) {
|
|
182
|
+
var _kb$fetcher3;
|
|
170
183
|
if (!uri) {
|
|
171
184
|
return false; // Eg subject is bnode, no known doc to write to
|
|
172
185
|
}
|
|
@@ -176,13 +189,13 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
176
189
|
}
|
|
177
190
|
uri = termValue(uri);
|
|
178
191
|
if (!this.isHttpUri(uri)) {
|
|
179
|
-
if (
|
|
192
|
+
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'))) {
|
|
180
193
|
return 'LOCALFILE';
|
|
181
194
|
}
|
|
182
195
|
}
|
|
183
196
|
var request;
|
|
184
197
|
var definitive = false;
|
|
185
|
-
var meta =
|
|
198
|
+
var meta = (_kb$fetcher3 = kb.fetcher) === null || _kb$fetcher3 === void 0 ? void 0 : _kb$fetcher3.appNode;
|
|
186
199
|
// const kb = s
|
|
187
200
|
|
|
188
201
|
// @ts-ignore passes a string to kb.each, which expects a term. Should this work?
|
|
@@ -191,11 +204,11 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
191
204
|
for (var r = 0; r < requests.length; r++) {
|
|
192
205
|
request = requests[r];
|
|
193
206
|
if (request !== undefined) {
|
|
194
|
-
var _response2 = kb.any(request, this.ns.link('response'));
|
|
207
|
+
var _response2 = kb.any(request, this.ns.link('response'), null, meta);
|
|
195
208
|
if (_response2 !== undefined) {
|
|
196
209
|
// ts
|
|
197
210
|
|
|
198
|
-
var outOfDate = kb.anyJS(_response2, this.ns.link('outOfDate'));
|
|
211
|
+
var outOfDate = kb.anyJS(_response2, this.ns.link('outOfDate'), null, meta);
|
|
199
212
|
if (outOfDate) continue;
|
|
200
213
|
var wacAllow = kb.anyValue(_response2, this.ns.httph('wac-allow'));
|
|
201
214
|
if (wacAllow) {
|
package/lib/fetcher.js
CHANGED
|
@@ -32,6 +32,9 @@ var _termValue = require("./utils/termValue");
|
|
|
32
32
|
var _jsonldparser = _interopRequireDefault(require("./jsonldparser"));
|
|
33
33
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
34
34
|
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; }
|
|
35
|
+
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; } } }; }
|
|
36
|
+
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); }
|
|
37
|
+
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; }
|
|
35
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); }; }
|
|
36
39
|
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; } }
|
|
37
40
|
var Parsable = {
|
|
@@ -581,7 +584,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
581
584
|
if (!this._fetch) {
|
|
582
585
|
throw new Error('No _fetch function available for Fetcher');
|
|
583
586
|
}
|
|
584
|
-
// This is the name of the
|
|
587
|
+
// This is the name of the graph we store all the HTTP metadata in
|
|
585
588
|
this.appNode = this.store.sym('chrome://TheCurrentSession');
|
|
586
589
|
// this.appNode = this.store.rdfFactory.blankNode() // Needs to have a URI in tests
|
|
587
590
|
this.store.fetcher = this; // Bi-linked
|
|
@@ -671,6 +674,31 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
671
674
|
var docuri = (0, _termValue.termValue)(uriIn);
|
|
672
675
|
docuri = docuri.split('#')[0];
|
|
673
676
|
options = this.initFetchOptions(docuri, options);
|
|
677
|
+
// if metadata flaged clear cache and removeDocument
|
|
678
|
+
var meta = this.appNode;
|
|
679
|
+
var kb = this.store;
|
|
680
|
+
var requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), kb.sym(docuri), meta).map(function (st) {
|
|
681
|
+
return st.subject;
|
|
682
|
+
});
|
|
683
|
+
var _iterator = _createForOfIteratorHelper(requests),
|
|
684
|
+
_step;
|
|
685
|
+
try {
|
|
686
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
687
|
+
var request = _step.value;
|
|
688
|
+
var _response = kb.any(request, this.ns.link('response'), null, meta);
|
|
689
|
+
if (_response !== undefined) {
|
|
690
|
+
// ts
|
|
691
|
+
var quad = kb.statementsMatching(_response, this.ns.link('outOfDate'), true, meta);
|
|
692
|
+
kb.remove(quad);
|
|
693
|
+
options.force = true;
|
|
694
|
+
options.clearPreviousData = true;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
} catch (err) {
|
|
698
|
+
_iterator.e(err);
|
|
699
|
+
} finally {
|
|
700
|
+
_iterator.f();
|
|
701
|
+
}
|
|
674
702
|
var initialisedOptions = this.initFetchOptions(docuri, options);
|
|
675
703
|
return this.pendingFetchPromise(docuri, initialisedOptions.baseURI, initialisedOptions);
|
|
676
704
|
}
|
|
@@ -1373,10 +1401,10 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1373
1401
|
for (var r = 0; r < requests.length; r++) {
|
|
1374
1402
|
var request = requests[r];
|
|
1375
1403
|
if (request !== undefined) {
|
|
1376
|
-
var
|
|
1377
|
-
if (
|
|
1404
|
+
var _response2 = kb.any(request, this.ns.link('response'));
|
|
1405
|
+
if (_response2 !== undefined && kb.anyValue(_response2, this.ns.http('status')) && kb.anyValue(_response2, this.ns.http('status')).startsWith('2')) {
|
|
1378
1406
|
// Only look at success returns - not 401 error messagess etc
|
|
1379
|
-
var results = kb.each(
|
|
1407
|
+
var results = kb.each(_response2, this.ns.httph(header.toLowerCase()));
|
|
1380
1408
|
if (results.length) {
|
|
1381
1409
|
return results.map(function (v) {
|
|
1382
1410
|
return v.value;
|
|
@@ -1415,17 +1443,19 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1415
1443
|
var _this10 = this;
|
|
1416
1444
|
var kb = this.store;
|
|
1417
1445
|
var responseNode = kb.bnode();
|
|
1418
|
-
kb.add(options.req, this.ns.link('response'), responseNode,
|
|
1419
|
-
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status),
|
|
1420
|
-
kb.add(responseNode, this.ns.http('statusText'), kb.rdfFactory.literal(response.statusText),
|
|
1446
|
+
kb.add(options.req, this.ns.link('response'), responseNode, this.appNode);
|
|
1447
|
+
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status), this.appNode);
|
|
1448
|
+
kb.add(responseNode, this.ns.http('statusText'), kb.rdfFactory.literal(response.statusText), this.appNode);
|
|
1421
1449
|
|
|
1422
1450
|
// Save the response headers
|
|
1423
1451
|
response.headers.forEach(function (value, header) {
|
|
1424
|
-
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value),
|
|
1452
|
+
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value), _this10.appNode);
|
|
1425
1453
|
if (header === 'content-type') {
|
|
1426
|
-
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), responseNode
|
|
1454
|
+
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), _this10.appNode // responseNode
|
|
1455
|
+
);
|
|
1427
1456
|
}
|
|
1428
1457
|
});
|
|
1458
|
+
|
|
1429
1459
|
return responseNode;
|
|
1430
1460
|
}
|
|
1431
1461
|
}, {
|
package/lib/jsonldparser.js
CHANGED
|
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = jsonldParser;
|
|
8
8
|
exports.jsonldObjectToTerm = jsonldObjectToTerm;
|
|
9
|
-
var
|
|
9
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
10
10
|
var _utils = require("./utils");
|
|
11
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || (0, _typeof2.default)(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; }
|
|
11
13
|
/**
|
|
12
14
|
* Parses json-ld formatted JS objects to a rdf Term.
|
|
13
15
|
* @param kb - The DataFactory to use.
|
|
@@ -67,8 +69,12 @@ function listToCollection(kb, obj) {
|
|
|
67
69
|
*/
|
|
68
70
|
function jsonldParser(str, kb, base, callback) {
|
|
69
71
|
var baseString = base && Object.prototype.hasOwnProperty.call(base, 'termType') ? base.value : base;
|
|
70
|
-
return
|
|
71
|
-
|
|
72
|
+
return Promise.resolve().then(function () {
|
|
73
|
+
return _interopRequireWildcard(require('jsonld'));
|
|
74
|
+
}).then(function (jsonld) {
|
|
75
|
+
return jsonld.flatten(JSON.parse(str), null, {
|
|
76
|
+
base: baseString
|
|
77
|
+
});
|
|
72
78
|
}).then(function (flattened) {
|
|
73
79
|
return flattened.reduce(function (store, flatResource) {
|
|
74
80
|
kb = processResource(kb, base, flatResource);
|
package/lib/store.d.ts
CHANGED
|
@@ -233,7 +233,7 @@ export default class IndexedFormula extends Formula {
|
|
|
233
233
|
*/
|
|
234
234
|
remove(st: Quad | Quad[]): IndexedFormula;
|
|
235
235
|
/**
|
|
236
|
-
* Removes all statements in a doc
|
|
236
|
+
* Removes all statements in a doc, along with the related metadata including request/response
|
|
237
237
|
* @param doc - The document / graph
|
|
238
238
|
*/
|
|
239
239
|
removeDocument(doc: Quad_Graph): IndexedFormula;
|
package/lib/store.js
CHANGED
|
@@ -827,12 +827,32 @@ var IndexedFormula = /*#__PURE__*/function (_Formula) {
|
|
|
827
827
|
}
|
|
828
828
|
|
|
829
829
|
/**
|
|
830
|
-
* Removes all statements in a doc
|
|
830
|
+
* Removes all statements in a doc, along with the related metadata including request/response
|
|
831
831
|
* @param doc - The document / graph
|
|
832
832
|
*/
|
|
833
833
|
}, {
|
|
834
834
|
key: "removeDocument",
|
|
835
835
|
value: function removeDocument(doc) {
|
|
836
|
+
var meta = this.sym('chrome://TheCurrentSession'); // or this.rdfFactory.namedNode('chrome://TheCurrentSession')
|
|
837
|
+
var linkNamespaceURI = 'http://www.w3.org/2007/ont/link#'; // alain
|
|
838
|
+
// remove request/response and metadata
|
|
839
|
+
var requests = this.statementsMatching(undefined, this.sym("".concat(linkNamespaceURI, "requestedURI")), this.rdfFactory.literal(doc.value), meta).map(function (st) {
|
|
840
|
+
return st.subject;
|
|
841
|
+
});
|
|
842
|
+
for (var r = 0; r < requests.length; r++) {
|
|
843
|
+
var request = requests[r];
|
|
844
|
+
if (request !== undefined) {
|
|
845
|
+
this.removeMatches(request, null, null, meta);
|
|
846
|
+
var response = this.any(request, this.sym("".concat(linkNamespaceURI, "response")), null, meta);
|
|
847
|
+
if (response !== undefined) {
|
|
848
|
+
// ts
|
|
849
|
+
this.removeMatches(response, null, null, meta);
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
this.removeMatches(this.sym(doc.value), null, null, meta); // content-type
|
|
854
|
+
|
|
855
|
+
// remove document
|
|
836
856
|
var sts = this.statementsMatching(undefined, undefined, undefined, doc).slice(); // Take a copy as this is the actual index
|
|
837
857
|
for (var i = 0; i < sts.length; i++) {
|
|
838
858
|
this.removeStatement(sts[i]);
|
package/lib/update-manager.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export default class UpdateManager {
|
|
|
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,
|
package/lib/update-manager.js
CHANGED
|
@@ -90,9 +90,12 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
90
90
|
*/
|
|
91
91
|
}, {
|
|
92
92
|
key: "flagAuthorizationMetadata",
|
|
93
|
-
value: function flagAuthorizationMetadata() {
|
|
94
|
-
var
|
|
95
|
-
|
|
93
|
+
value: function flagAuthorizationMetadata(kb) {
|
|
94
|
+
var _kb$fetcher;
|
|
95
|
+
if (!kb) {
|
|
96
|
+
kb = this.store;
|
|
97
|
+
}
|
|
98
|
+
var meta = (_kb$fetcher = kb.fetcher) === null || _kb$fetcher === void 0 ? void 0 : _kb$fetcher.appNode;
|
|
96
99
|
var requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), undefined, meta).map(function (st) {
|
|
97
100
|
return st.subject;
|
|
98
101
|
});
|
|
@@ -104,7 +107,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
104
107
|
var _response = kb.any(request, this.ns.link('response'), null, meta);
|
|
105
108
|
if (_response !== undefined) {
|
|
106
109
|
// ts
|
|
107
|
-
|
|
110
|
+
kb.add(_response, this.ns.link('outOfDate'), true, meta); // @@ Boolean is fine - fix types
|
|
108
111
|
}
|
|
109
112
|
}
|
|
110
113
|
} catch (err) {
|
|
@@ -129,24 +132,33 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
129
132
|
key: "checkEditable",
|
|
130
133
|
value: function () {
|
|
131
134
|
var _checkEditable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(uri, kb) {
|
|
135
|
+
var _kb$fetcher2;
|
|
132
136
|
var initial, final;
|
|
133
137
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
134
138
|
while (1) switch (_context.prev = _context.next) {
|
|
135
139
|
case 0:
|
|
140
|
+
if (uri) {
|
|
141
|
+
_context.next = 2;
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
return _context.abrupt("return", false);
|
|
145
|
+
case 2:
|
|
146
|
+
if (!kb) {
|
|
147
|
+
kb = this.store;
|
|
148
|
+
}
|
|
136
149
|
initial = this.editable(uri, kb);
|
|
137
150
|
if (!(initial !== undefined)) {
|
|
138
|
-
_context.next =
|
|
151
|
+
_context.next = 6;
|
|
139
152
|
break;
|
|
140
153
|
}
|
|
141
154
|
return _context.abrupt("return", initial);
|
|
142
|
-
case
|
|
143
|
-
_context.next =
|
|
144
|
-
return
|
|
145
|
-
case 5:
|
|
146
|
-
final = this.editable(uri, kb);
|
|
147
|
-
console.log("Loaded ".concat(uri, " just to check editable, result: ").concat(final, "."));
|
|
148
|
-
return _context.abrupt("return", final);
|
|
155
|
+
case 6:
|
|
156
|
+
_context.next = 8;
|
|
157
|
+
return (_kb$fetcher2 = kb.fetcher) === null || _kb$fetcher2 === void 0 ? void 0 : _kb$fetcher2.load(uri);
|
|
149
158
|
case 8:
|
|
159
|
+
final = this.editable(uri, kb); // console.log(`Loaded ${uri} just to check editable, result: ${final}.`)
|
|
160
|
+
return _context.abrupt("return", final);
|
|
161
|
+
case 10:
|
|
150
162
|
case "end":
|
|
151
163
|
return _context.stop();
|
|
152
164
|
}
|
|
@@ -171,6 +183,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
171
183
|
}, {
|
|
172
184
|
key: "editable",
|
|
173
185
|
value: function editable(uri, kb) {
|
|
186
|
+
var _kb$fetcher3;
|
|
174
187
|
if (!uri) {
|
|
175
188
|
return false; // Eg subject is bnode, no known doc to write to
|
|
176
189
|
}
|
|
@@ -180,13 +193,13 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
180
193
|
}
|
|
181
194
|
uri = (0, _termValue.termValue)(uri);
|
|
182
195
|
if (!this.isHttpUri(uri)) {
|
|
183
|
-
if (
|
|
196
|
+
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'))) {
|
|
184
197
|
return 'LOCALFILE';
|
|
185
198
|
}
|
|
186
199
|
}
|
|
187
200
|
var request;
|
|
188
201
|
var definitive = false;
|
|
189
|
-
var meta =
|
|
202
|
+
var meta = (_kb$fetcher3 = kb.fetcher) === null || _kb$fetcher3 === void 0 ? void 0 : _kb$fetcher3.appNode;
|
|
190
203
|
// const kb = s
|
|
191
204
|
|
|
192
205
|
// @ts-ignore passes a string to kb.each, which expects a term. Should this work?
|
|
@@ -195,11 +208,11 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
195
208
|
for (var r = 0; r < requests.length; r++) {
|
|
196
209
|
request = requests[r];
|
|
197
210
|
if (request !== undefined) {
|
|
198
|
-
var _response2 = kb.any(request, this.ns.link('response'));
|
|
211
|
+
var _response2 = kb.any(request, this.ns.link('response'), null, meta);
|
|
199
212
|
if (_response2 !== undefined) {
|
|
200
213
|
// ts
|
|
201
214
|
|
|
202
|
-
var outOfDate = kb.anyJS(_response2, this.ns.link('outOfDate'));
|
|
215
|
+
var outOfDate = kb.anyJS(_response2, this.ns.link('outOfDate'), null, meta);
|
|
203
216
|
if (outOfDate) continue;
|
|
204
217
|
var wacAllow = kb.anyValue(_response2, this.ns.httph('wac-allow'));
|
|
205
218
|
if (wacAllow) {
|
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.31-10c4e145",
|
|
5
5
|
"private": false,
|
|
6
6
|
"browserslist": [
|
|
7
7
|
"> 0.5%"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@frogcat/ttl2jsonld": "^0.0.9",
|
|
49
49
|
"@xmldom/xmldom": "^0.8.6",
|
|
50
50
|
"cross-fetch": "^3.1.5",
|
|
51
|
-
"jsonld": "^
|
|
51
|
+
"jsonld": "^8.1.1",
|
|
52
52
|
"n3": "^1.16.3",
|
|
53
53
|
"solid-namespace": "^0.5.2"
|
|
54
54
|
},
|
package/src/fetcher.ts
CHANGED
|
@@ -771,7 +771,7 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
771
771
|
if (!this._fetch) {
|
|
772
772
|
throw new Error('No _fetch function available for Fetcher')
|
|
773
773
|
}
|
|
774
|
-
// This is the name of the
|
|
774
|
+
// This is the name of the graph we store all the HTTP metadata in
|
|
775
775
|
this.appNode = this.store.sym('chrome://TheCurrentSession')
|
|
776
776
|
// this.appNode = this.store.rdfFactory.blankNode() // Needs to have a URI in tests
|
|
777
777
|
this.store.fetcher = this // Bi-linked
|
|
@@ -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
|
|
|
@@ -1726,22 +1739,22 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
1726
1739
|
|
|
1727
1740
|
let responseNode = kb.bnode()
|
|
1728
1741
|
|
|
1729
|
-
kb.add(options.req, this.ns.link('response'), responseNode,
|
|
1742
|
+
kb.add(options.req, this.ns.link('response'), responseNode, this.appNode)
|
|
1730
1743
|
kb.add(responseNode, this.ns.http('status'),
|
|
1731
|
-
kb.rdfFactory.literal(response.status as any),
|
|
1744
|
+
kb.rdfFactory.literal(response.status as any), this.appNode)
|
|
1732
1745
|
kb.add(responseNode, this.ns.http('statusText'),
|
|
1733
|
-
kb.rdfFactory.literal(response.statusText),
|
|
1746
|
+
kb.rdfFactory.literal(response.statusText), this.appNode)
|
|
1734
1747
|
|
|
1735
1748
|
// Save the response headers
|
|
1736
1749
|
response.headers.forEach((value, header) => {
|
|
1737
|
-
kb.add(responseNode, this.ns.httph(header), this.store.rdfFactory.literal(value),
|
|
1750
|
+
kb.add(responseNode, this.ns.httph(header), this.store.rdfFactory.literal(value), this.appNode)
|
|
1738
1751
|
|
|
1739
1752
|
if (header === 'content-type') {
|
|
1740
1753
|
kb.add(
|
|
1741
1754
|
options.resource,
|
|
1742
1755
|
this.ns.rdf('type'),
|
|
1743
1756
|
kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value),
|
|
1744
|
-
responseNode
|
|
1757
|
+
this.appNode // responseNode
|
|
1745
1758
|
)
|
|
1746
1759
|
}
|
|
1747
1760
|
})
|
package/src/jsonldparser.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import jsonld from 'jsonld'
|
|
3
1
|
import { arrayToStatements } from './utils'
|
|
4
2
|
|
|
5
3
|
/**
|
|
@@ -70,8 +68,8 @@ export default function jsonldParser (str, kb, base, callback) {
|
|
|
70
68
|
? base.value
|
|
71
69
|
: base
|
|
72
70
|
|
|
73
|
-
return jsonld
|
|
74
|
-
.flatten(JSON.parse(str), null, { base: baseString })
|
|
71
|
+
return import('jsonld')
|
|
72
|
+
.then(jsonld => { return jsonld.flatten(JSON.parse(str), null, { base: baseString }) })
|
|
75
73
|
.then((flattened) => flattened.reduce((store, flatResource) => {
|
|
76
74
|
|
|
77
75
|
kb = processResource(kb, base, flatResource)
|