rdflib 2.2.30 → 2.2.31-6eec4945
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.map +1 -1
- package/esm/fetcher.js +41 -9
- package/esm/store.js +21 -1
- package/esm/update-manager.js +98 -15
- package/lib/fetcher.d.ts +1 -1
- package/lib/fetcher.js +41 -9
- package/lib/store.d.ts +1 -1
- package/lib/store.js +21 -1
- package/lib/update-manager.d.ts +20 -1
- package/lib/update-manager.js +98 -15
- package/package.json +2 -2
- package/src/fetcher.ts +22 -8
- package/src/store.ts +18 -1
- package/src/update-manager.ts +50 -5
- package/dist/670.rdflib.min.js +0 -1
- package/dist/730.rdflib.min.js +0 -3
- package/dist/730.rdflib.min.js.LICENSE.txt +0 -58
- package/dist/730.rdflib.min.js.map +0 -1
- package/esm/convert.js +0 -60
- package/lib/convert.d.ts +0 -2
- package/lib/convert.js +0 -71
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,9 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
598
601
|
if (!this._fetch) {
|
|
599
602
|
throw new Error('No _fetch function available for Fetcher');
|
|
600
603
|
}
|
|
601
|
-
|
|
604
|
+
// This is the name of the graph we store all the HTTP metadata in
|
|
605
|
+
this.appNode = this.store.sym('chrome://TheCurrentSession');
|
|
606
|
+
// this.appNode = this.store.rdfFactory.blankNode() // Needs to have a URI in tests
|
|
602
607
|
this.store.fetcher = this; // Bi-linked
|
|
603
608
|
this.requested = {};
|
|
604
609
|
this.timeouts = {};
|
|
@@ -686,6 +691,31 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
686
691
|
var docuri = termValue(uriIn);
|
|
687
692
|
docuri = docuri.split('#')[0];
|
|
688
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
|
+
}
|
|
689
719
|
var initialisedOptions = this.initFetchOptions(docuri, options);
|
|
690
720
|
return this.pendingFetchPromise(docuri, initialisedOptions.baseURI, initialisedOptions);
|
|
691
721
|
}
|
|
@@ -1388,10 +1418,10 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1388
1418
|
for (var r = 0; r < requests.length; r++) {
|
|
1389
1419
|
var request = requests[r];
|
|
1390
1420
|
if (request !== undefined) {
|
|
1391
|
-
var
|
|
1392
|
-
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')) {
|
|
1393
1423
|
// Only look at success returns - not 401 error messagess etc
|
|
1394
|
-
var results = kb.each(
|
|
1424
|
+
var results = kb.each(_response2, this.ns.httph(header.toLowerCase()));
|
|
1395
1425
|
if (results.length) {
|
|
1396
1426
|
return results.map(function (v) {
|
|
1397
1427
|
return v.value;
|
|
@@ -1430,17 +1460,19 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1430
1460
|
var _this10 = this;
|
|
1431
1461
|
var kb = this.store;
|
|
1432
1462
|
var responseNode = kb.bnode();
|
|
1433
|
-
kb.add(options.req, this.ns.link('response'), responseNode,
|
|
1434
|
-
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status),
|
|
1435
|
-
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);
|
|
1436
1466
|
|
|
1437
1467
|
// Save the response headers
|
|
1438
1468
|
response.headers.forEach(function (value, header) {
|
|
1439
|
-
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);
|
|
1440
1470
|
if (header === 'content-type') {
|
|
1441
|
-
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
|
+
);
|
|
1442
1473
|
}
|
|
1443
1474
|
});
|
|
1475
|
+
|
|
1444
1476
|
return responseNode;
|
|
1445
1477
|
}
|
|
1446
1478
|
}, {
|
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, 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
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
7
|
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; } } }; }
|
|
6
8
|
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); }
|
|
7
9
|
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; }
|
|
@@ -76,13 +78,87 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
76
78
|
return uri.slice(0, 4) === 'http';
|
|
77
79
|
}
|
|
78
80
|
|
|
81
|
+
/** Remove from the store HTTP authorization metadata
|
|
82
|
+
* The editble function below relies on copies we have in the store
|
|
83
|
+
* of the results of previous HTTP transactions. Howver, when
|
|
84
|
+
* the user logs in, then that data misrepresents what would happen
|
|
85
|
+
* if the user tried again.
|
|
86
|
+
*/
|
|
87
|
+
}, {
|
|
88
|
+
key: "flagAuthorizationMetadata",
|
|
89
|
+
value: function flagAuthorizationMetadata() {
|
|
90
|
+
var kb = this.store;
|
|
91
|
+
var meta = kb.fetcher.appNode;
|
|
92
|
+
var requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), undefined, meta).map(function (st) {
|
|
93
|
+
return st.subject;
|
|
94
|
+
});
|
|
95
|
+
var _iterator = _createForOfIteratorHelper(requests),
|
|
96
|
+
_step;
|
|
97
|
+
try {
|
|
98
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
99
|
+
var request = _step.value;
|
|
100
|
+
var _response = kb.any(request, this.ns.link('response'), null, meta);
|
|
101
|
+
if (_response !== undefined) {
|
|
102
|
+
// ts
|
|
103
|
+
this.store.add(_response, this.ns.link('outOfDate'), true, meta); // @@ Boolean is fine - fix types
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} catch (err) {
|
|
107
|
+
_iterator.e(err);
|
|
108
|
+
} finally {
|
|
109
|
+
_iterator.f();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
79
113
|
/**
|
|
80
114
|
* Tests whether a file is editable.
|
|
81
115
|
* If the file has a specific annotation that it is machine written,
|
|
82
116
|
* for safety, it is editable (this doesn't actually check for write access)
|
|
83
117
|
* If the file has wac-allow and accept patch headers, those are respected.
|
|
84
118
|
* and local write access is determined by those headers.
|
|
85
|
-
* This version only looks at past HTTP requests,
|
|
119
|
+
* This async version not only looks at past HTTP requests, it also makes new ones if necessary.
|
|
120
|
+
*
|
|
121
|
+
* @returns The method string SPARQL or DAV or
|
|
122
|
+
* LOCALFILE or false if known, undefined if not known.
|
|
123
|
+
*/
|
|
124
|
+
}, {
|
|
125
|
+
key: "checkEditable",
|
|
126
|
+
value: function () {
|
|
127
|
+
var _checkEditable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(uri, kb) {
|
|
128
|
+
var initial, final;
|
|
129
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
130
|
+
while (1) switch (_context.prev = _context.next) {
|
|
131
|
+
case 0:
|
|
132
|
+
initial = this.editable(uri, kb);
|
|
133
|
+
if (!(initial !== undefined)) {
|
|
134
|
+
_context.next = 3;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
return _context.abrupt("return", initial);
|
|
138
|
+
case 3:
|
|
139
|
+
_context.next = 5;
|
|
140
|
+
return this.store.fetcher.load(uri);
|
|
141
|
+
case 5:
|
|
142
|
+
final = this.editable(uri, kb); // console.log(`Loaded ${uri} just to check editable, result: ${final}.`)
|
|
143
|
+
return _context.abrupt("return", final);
|
|
144
|
+
case 7:
|
|
145
|
+
case "end":
|
|
146
|
+
return _context.stop();
|
|
147
|
+
}
|
|
148
|
+
}, _callee, this);
|
|
149
|
+
}));
|
|
150
|
+
function checkEditable(_x, _x2) {
|
|
151
|
+
return _checkEditable.apply(this, arguments);
|
|
152
|
+
}
|
|
153
|
+
return checkEditable;
|
|
154
|
+
}()
|
|
155
|
+
/**
|
|
156
|
+
* Tests whether a file is editable.
|
|
157
|
+
* If the file has a specific annotation that it is machine written,
|
|
158
|
+
* for safety, it is editable (this doesn't actually check for write access)
|
|
159
|
+
* If the file has wac-allow and accept patch headers, those are respected.
|
|
160
|
+
* and local write access is determined by those headers.
|
|
161
|
+
* This synchronous version only looks at past HTTP requests, does not make new ones.
|
|
86
162
|
*
|
|
87
163
|
* @returns The method string SPARQL or DAV or
|
|
88
164
|
* LOCALFILE or false if known, undefined if not known.
|
|
@@ -99,27 +175,34 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
99
175
|
}
|
|
100
176
|
uri = termValue(uri);
|
|
101
177
|
if (!this.isHttpUri(uri)) {
|
|
102
|
-
if (
|
|
178
|
+
if (this.store.holds(this.store.rdfFactory.namedNode(uri), this.store.rdfFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), this.store.rdfFactory.namedNode('http://www.w3.org/2007/ont/link#MachineEditableDocument'))) {
|
|
103
179
|
return 'LOCALFILE';
|
|
104
180
|
}
|
|
105
181
|
}
|
|
106
182
|
var request;
|
|
107
183
|
var definitive = false;
|
|
184
|
+
var meta = this.store.fetcher.appNode;
|
|
185
|
+
// const kb = s
|
|
186
|
+
|
|
108
187
|
// @ts-ignore passes a string to kb.each, which expects a term. Should this work?
|
|
109
|
-
var requests = kb.each(undefined, this.ns.link('requestedURI'), docpart(uri));
|
|
188
|
+
var requests = kb.each(undefined, this.ns.link('requestedURI'), docpart(uri), meta);
|
|
110
189
|
var method;
|
|
111
190
|
for (var r = 0; r < requests.length; r++) {
|
|
112
191
|
request = requests[r];
|
|
113
192
|
if (request !== undefined) {
|
|
114
|
-
var
|
|
115
|
-
if (
|
|
116
|
-
|
|
193
|
+
var _response2 = kb.any(request, this.ns.link('response'), null, meta);
|
|
194
|
+
if (_response2 !== undefined) {
|
|
195
|
+
// ts
|
|
196
|
+
|
|
197
|
+
var outOfDate = kb.anyJS(_response2, this.ns.link('outOfDate'), null, meta);
|
|
198
|
+
if (outOfDate) continue;
|
|
199
|
+
var wacAllow = kb.anyValue(_response2, this.ns.httph('wac-allow'));
|
|
117
200
|
if (wacAllow) {
|
|
118
|
-
var
|
|
119
|
-
|
|
201
|
+
var _iterator2 = _createForOfIteratorHelper(wacAllow.split(',')),
|
|
202
|
+
_step2;
|
|
120
203
|
try {
|
|
121
|
-
for (
|
|
122
|
-
var bit =
|
|
204
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
205
|
+
var bit = _step2.value;
|
|
123
206
|
var lr = bit.split('=');
|
|
124
207
|
if (lr[0].includes('user') && !lr[1].includes('write') && !lr[1].includes('append')) {
|
|
125
208
|
// console.log(' editable? excluded by WAC-Allow: ', wacAllow)
|
|
@@ -127,12 +210,12 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
127
210
|
}
|
|
128
211
|
}
|
|
129
212
|
} catch (err) {
|
|
130
|
-
|
|
213
|
+
_iterator2.e(err);
|
|
131
214
|
} finally {
|
|
132
|
-
|
|
215
|
+
_iterator2.f();
|
|
133
216
|
}
|
|
134
217
|
}
|
|
135
|
-
var acceptPatch = kb.each(
|
|
218
|
+
var acceptPatch = kb.each(_response2, this.ns.httph('accept-patch'));
|
|
136
219
|
if (acceptPatch.length) {
|
|
137
220
|
for (var i = 0; i < acceptPatch.length; i++) {
|
|
138
221
|
method = acceptPatch[i].value.trim();
|
|
@@ -140,7 +223,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
140
223
|
if (method.indexOf('application/sparql-update-single-match') >= 0) return 'SPARQL';
|
|
141
224
|
}
|
|
142
225
|
}
|
|
143
|
-
var authorVia = kb.each(
|
|
226
|
+
var authorVia = kb.each(_response2, this.ns.httph('ms-author-via'));
|
|
144
227
|
if (authorVia.length) {
|
|
145
228
|
for (var _i = 0; _i < authorVia.length; _i++) {
|
|
146
229
|
method = authorVia[_i].value.trim();
|
|
@@ -155,7 +238,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
155
238
|
if (!this.isHttpUri(uri)) {
|
|
156
239
|
if (!wacAllow) return false;else return 'LOCALFILE';
|
|
157
240
|
}
|
|
158
|
-
var status = kb.each(
|
|
241
|
+
var status = kb.each(_response2, this.ns.http('status'));
|
|
159
242
|
if (status.length) {
|
|
160
243
|
for (var _i2 = 0; _i2 < status.length; _i2++) {
|
|
161
244
|
// @ts-ignore since statuses should be TFTerms, this should always be false
|
package/lib/fetcher.d.ts
CHANGED
|
@@ -181,7 +181,7 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
181
181
|
_fetch: Fetch;
|
|
182
182
|
mediatypes: MediatypesMap;
|
|
183
183
|
/** Denoting this session */
|
|
184
|
-
appNode:
|
|
184
|
+
appNode: NamedNode;
|
|
185
185
|
/**
|
|
186
186
|
* this.requested[uri] states:
|
|
187
187
|
* undefined no record of web access or records reset
|
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,9 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
581
584
|
if (!this._fetch) {
|
|
582
585
|
throw new Error('No _fetch function available for Fetcher');
|
|
583
586
|
}
|
|
584
|
-
|
|
587
|
+
// This is the name of the graph we store all the HTTP metadata in
|
|
588
|
+
this.appNode = this.store.sym('chrome://TheCurrentSession');
|
|
589
|
+
// this.appNode = this.store.rdfFactory.blankNode() // Needs to have a URI in tests
|
|
585
590
|
this.store.fetcher = this; // Bi-linked
|
|
586
591
|
this.requested = {};
|
|
587
592
|
this.timeouts = {};
|
|
@@ -669,6 +674,31 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
669
674
|
var docuri = (0, _termValue.termValue)(uriIn);
|
|
670
675
|
docuri = docuri.split('#')[0];
|
|
671
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
|
+
}
|
|
672
702
|
var initialisedOptions = this.initFetchOptions(docuri, options);
|
|
673
703
|
return this.pendingFetchPromise(docuri, initialisedOptions.baseURI, initialisedOptions);
|
|
674
704
|
}
|
|
@@ -1371,10 +1401,10 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1371
1401
|
for (var r = 0; r < requests.length; r++) {
|
|
1372
1402
|
var request = requests[r];
|
|
1373
1403
|
if (request !== undefined) {
|
|
1374
|
-
var
|
|
1375
|
-
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')) {
|
|
1376
1406
|
// Only look at success returns - not 401 error messagess etc
|
|
1377
|
-
var results = kb.each(
|
|
1407
|
+
var results = kb.each(_response2, this.ns.httph(header.toLowerCase()));
|
|
1378
1408
|
if (results.length) {
|
|
1379
1409
|
return results.map(function (v) {
|
|
1380
1410
|
return v.value;
|
|
@@ -1413,17 +1443,19 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1413
1443
|
var _this10 = this;
|
|
1414
1444
|
var kb = this.store;
|
|
1415
1445
|
var responseNode = kb.bnode();
|
|
1416
|
-
kb.add(options.req, this.ns.link('response'), responseNode,
|
|
1417
|
-
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status),
|
|
1418
|
-
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);
|
|
1419
1449
|
|
|
1420
1450
|
// Save the response headers
|
|
1421
1451
|
response.headers.forEach(function (value, header) {
|
|
1422
|
-
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);
|
|
1423
1453
|
if (header === 'content-type') {
|
|
1424
|
-
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
|
+
);
|
|
1425
1456
|
}
|
|
1426
1457
|
});
|
|
1458
|
+
|
|
1427
1459
|
return responseNode;
|
|
1428
1460
|
}
|
|
1429
1461
|
}, {
|
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, 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, 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
|
@@ -27,13 +27,32 @@ export default class UpdateManager {
|
|
|
27
27
|
constructor(store?: IndexedFormula);
|
|
28
28
|
patchControlFor(doc: NamedNode): any;
|
|
29
29
|
isHttpUri(uri: string): boolean;
|
|
30
|
+
/** Remove from the store HTTP authorization metadata
|
|
31
|
+
* The editble function below relies on copies we have in the store
|
|
32
|
+
* of the results of previous HTTP transactions. Howver, when
|
|
33
|
+
* the user logs in, then that data misrepresents what would happen
|
|
34
|
+
* if the user tried again.
|
|
35
|
+
*/
|
|
36
|
+
flagAuthorizationMetadata(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Tests whether a file is editable.
|
|
39
|
+
* If the file has a specific annotation that it is machine written,
|
|
40
|
+
* for safety, it is editable (this doesn't actually check for write access)
|
|
41
|
+
* If the file has wac-allow and accept patch headers, those are respected.
|
|
42
|
+
* and local write access is determined by those headers.
|
|
43
|
+
* This async version not only looks at past HTTP requests, it also makes new ones if necessary.
|
|
44
|
+
*
|
|
45
|
+
* @returns The method string SPARQL or DAV or
|
|
46
|
+
* LOCALFILE or false if known, undefined if not known.
|
|
47
|
+
*/
|
|
48
|
+
checkEditable(uri: string | NamedNode, kb?: IndexedFormula): Promise<string | boolean | undefined>;
|
|
30
49
|
/**
|
|
31
50
|
* Tests whether a file is editable.
|
|
32
51
|
* If the file has a specific annotation that it is machine written,
|
|
33
52
|
* for safety, it is editable (this doesn't actually check for write access)
|
|
34
53
|
* If the file has wac-allow and accept patch headers, those are respected.
|
|
35
54
|
* and local write access is determined by those headers.
|
|
36
|
-
* This version only looks at past HTTP requests, does not make new ones.
|
|
55
|
+
* This synchronous version only looks at past HTTP requests, does not make new ones.
|
|
37
56
|
*
|
|
38
57
|
* @returns The method string SPARQL or DAV or
|
|
39
58
|
* LOCALFILE or false if known, undefined if not known.
|