rdflib 2.2.28 → 2.2.30-6e0dc97e
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/blank-node.js +0 -1
- package/esm/fetcher.js +22 -26
- package/esm/formula.js +2 -3
- package/esm/node-internal.js +0 -1
- package/esm/statement.js +1 -1
- package/esm/update-manager.js +112 -15
- package/lib/blank-node.js +0 -1
- package/lib/fetcher.d.ts +1 -1
- package/lib/fetcher.js +22 -26
- package/lib/formula.js +2 -3
- package/lib/node-internal.js +0 -1
- package/lib/statement.js +1 -1
- package/lib/update-manager.d.ts +20 -1
- package/lib/update-manager.js +112 -15
- package/package.json +1 -1
- package/src/blank-node.ts +0 -1
- package/src/fetcher.ts +11 -15
- package/src/formula.ts +2 -3
- package/src/node-internal.ts +0 -1
- package/src/statement.ts +1 -1
- package/src/update-manager.ts +50 -5
package/esm/blank-node.js
CHANGED
package/esm/fetcher.js
CHANGED
|
@@ -598,7 +598,9 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
598
598
|
if (!this._fetch) {
|
|
599
599
|
throw new Error('No _fetch function available for Fetcher');
|
|
600
600
|
}
|
|
601
|
-
|
|
601
|
+
// This is the name of the graphh we store all the HTTP metadata in
|
|
602
|
+
this.appNode = this.store.sym('chrome://TheCurrentSession');
|
|
603
|
+
// this.appNode = this.store.rdfFactory.blankNode() // Needs to have a URI in tests
|
|
602
604
|
this.store.fetcher = this; // Bi-linked
|
|
603
605
|
this.requested = {};
|
|
604
606
|
this.timeouts = {};
|
|
@@ -878,7 +880,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
878
880
|
size: 0,
|
|
879
881
|
timeout: 0
|
|
880
882
|
};
|
|
881
|
-
console.log('Fetcher: <' + actualProxyURI + '> Non-HTTP fetch exception: ' + error)
|
|
883
|
+
// console.log('Fetcher: <' + actualProxyURI + '> Non-HTTP fetch exception: ' + error)
|
|
882
884
|
return _this5.handleError(dummyResponse, docuri, options); // possible credentials retry
|
|
883
885
|
// return this.failFetch(options, 'fetch failed: ' + error, 999, dummyResponse) // Fake status code: fetch exception
|
|
884
886
|
|
|
@@ -939,25 +941,21 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
939
941
|
if (fetchResponse.ok) {
|
|
940
942
|
userCallback(true, 'OK', fetchResponse);
|
|
941
943
|
} else {
|
|
942
|
-
// console.log('@@@ fetcher.js Should not take this path !!!!!!!!!!!!')
|
|
943
944
|
var oops = 'HTTP error: Status ' + fetchResponse.status + ' (' + fetchResponse.statusText + ')';
|
|
944
945
|
if (fetchResponse.responseText) {
|
|
945
946
|
oops += ' ' + fetchResponse.responseText; // not in 404, dns error, nock failure
|
|
946
947
|
}
|
|
947
948
|
|
|
948
|
-
console.log(oops + ' fetching ' + uri);
|
|
949
949
|
userCallback(false, oops, fetchResponse);
|
|
950
950
|
}
|
|
951
951
|
} else {
|
|
952
952
|
var _oops = '@@ nowOrWhenFetched: no response object!';
|
|
953
|
-
console.log(_oops);
|
|
954
953
|
userCallback(false, _oops);
|
|
955
954
|
}
|
|
956
955
|
}
|
|
957
956
|
}, function (err) {
|
|
958
957
|
var message = err.message || err.statusText;
|
|
959
958
|
message = 'Failed to load <' + uri + '> ' + message;
|
|
960
|
-
console.log(message);
|
|
961
959
|
if (err.response && err.response.status) {
|
|
962
960
|
message += ' status: ' + err.response.status;
|
|
963
961
|
}
|
|
@@ -1196,45 +1194,42 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1196
1194
|
return fetcher.load(doc);
|
|
1197
1195
|
case 6:
|
|
1198
1196
|
response = _context2.sent;
|
|
1199
|
-
_context2.next =
|
|
1197
|
+
_context2.next = 26;
|
|
1200
1198
|
break;
|
|
1201
1199
|
case 9:
|
|
1202
1200
|
_context2.prev = 9;
|
|
1203
1201
|
_context2.t0 = _context2["catch"](3);
|
|
1204
1202
|
if (!(_context2.t0.response.status === 404)) {
|
|
1205
|
-
_context2.next =
|
|
1203
|
+
_context2.next = 25;
|
|
1206
1204
|
break;
|
|
1207
1205
|
}
|
|
1208
|
-
|
|
1209
|
-
_context2.
|
|
1210
|
-
_context2.next = 16;
|
|
1206
|
+
_context2.prev = 12;
|
|
1207
|
+
_context2.next = 15;
|
|
1211
1208
|
return fetcher.webOperation('PUT', doc.value, {
|
|
1212
1209
|
data: data,
|
|
1213
1210
|
contentType: contentType
|
|
1214
1211
|
});
|
|
1215
|
-
case
|
|
1212
|
+
case 15:
|
|
1216
1213
|
response = _context2.sent;
|
|
1217
|
-
_context2.next =
|
|
1214
|
+
_context2.next = 21;
|
|
1218
1215
|
break;
|
|
1219
|
-
case
|
|
1220
|
-
_context2.prev =
|
|
1221
|
-
_context2.t1 = _context2["catch"](
|
|
1222
|
-
console.log('createIfNotExists doc FAILED: ' + doc + ': ' + _context2.t1);
|
|
1216
|
+
case 18:
|
|
1217
|
+
_context2.prev = 18;
|
|
1218
|
+
_context2.t1 = _context2["catch"](12);
|
|
1223
1219
|
throw _context2.t1;
|
|
1224
|
-
case
|
|
1220
|
+
case 21:
|
|
1225
1221
|
delete fetcher.requested[doc.value]; // delete cached 404 error
|
|
1226
1222
|
// console.log('createIfNotExists doc created ok ' + doc)
|
|
1227
1223
|
return _context2.abrupt("return", response);
|
|
1228
|
-
case
|
|
1229
|
-
console.log('createIfNotExists doc load error NOT 404: ' + doc + ': ' + _context2.t0);
|
|
1224
|
+
case 25:
|
|
1230
1225
|
throw _context2.t0;
|
|
1231
|
-
case
|
|
1226
|
+
case 26:
|
|
1232
1227
|
return _context2.abrupt("return", response);
|
|
1233
|
-
case
|
|
1228
|
+
case 27:
|
|
1234
1229
|
case "end":
|
|
1235
1230
|
return _context2.stop();
|
|
1236
1231
|
}
|
|
1237
|
-
}, _callee2, this, [[3, 9], [
|
|
1232
|
+
}, _callee2, this, [[3, 9], [12, 18]]);
|
|
1238
1233
|
}));
|
|
1239
1234
|
function createIfNotExists(_x4) {
|
|
1240
1235
|
return _createIfNotExists.apply(this, arguments);
|
|
@@ -1543,7 +1538,8 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1543
1538
|
}, {
|
|
1544
1539
|
key: "retryNoCredentials",
|
|
1545
1540
|
value: function retryNoCredentials(docuri, options) {
|
|
1546
|
-
console.log('Fetcher: CORS: RETRYING with NO CREDENTIALS for ' + options.resource)
|
|
1541
|
+
// console.log('Fetcher: CORS: RETRYING with NO CREDENTIALS for ' + options.resource)
|
|
1542
|
+
|
|
1547
1543
|
options.retriedWithNoCredentials = true; // protect against being called twice
|
|
1548
1544
|
|
|
1549
1545
|
delete this.requested[docuri]; // forget the original request happened
|
|
@@ -1588,7 +1584,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1588
1584
|
// Now attempt retry via proxy
|
|
1589
1585
|
var proxyUri = Fetcher.crossSiteProxy(docuri);
|
|
1590
1586
|
if (proxyUri && !options.proxyUsed) {
|
|
1591
|
-
console.log('web: Direct failed so trying proxy ' + proxyUri)
|
|
1587
|
+
// console.log('web: Direct failed so trying proxy ' + proxyUri)
|
|
1592
1588
|
return this.redirectToProxy(proxyUri, options);
|
|
1593
1589
|
}
|
|
1594
1590
|
}
|
|
@@ -1661,7 +1657,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1661
1657
|
|
|
1662
1658
|
// Check for masked errors (CORS, etc)
|
|
1663
1659
|
if (response.status === 0) {
|
|
1664
|
-
console.log('Masked error - status 0 for ' + docuri)
|
|
1660
|
+
// console.log('Masked error - status 0 for ' + docuri)
|
|
1665
1661
|
return this.handleError(response, docuri, options);
|
|
1666
1662
|
}
|
|
1667
1663
|
if (response.status >= 400) {
|
package/esm/formula.js
CHANGED
|
@@ -552,7 +552,6 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
552
552
|
while (todo.length) {
|
|
553
553
|
follow(todo.shift());
|
|
554
554
|
}
|
|
555
|
-
// console.log('' + result.length + ' statements about ' + subject)
|
|
556
555
|
return result;
|
|
557
556
|
}
|
|
558
557
|
|
|
@@ -709,10 +708,10 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
709
708
|
var statementsCopy = this.statements.map(function (ea) {
|
|
710
709
|
return ea.substitute(bindings);
|
|
711
710
|
});
|
|
712
|
-
console.log('Formula subs statmnts:' + statementsCopy)
|
|
711
|
+
// console.log('Formula subs statmnts:' + statementsCopy)
|
|
713
712
|
var y = new Formula();
|
|
714
713
|
y.addAll(statementsCopy);
|
|
715
|
-
console.log('indexed-form subs formula:' + y)
|
|
714
|
+
// console.log('indexed-form subs formula:' + y)
|
|
716
715
|
return y;
|
|
717
716
|
}
|
|
718
717
|
}, {
|
package/esm/node-internal.js
CHANGED
package/esm/statement.js
CHANGED
|
@@ -76,7 +76,7 @@ var Statement = /*#__PURE__*/function () {
|
|
|
76
76
|
key: "substitute",
|
|
77
77
|
value: function substitute(bindings) {
|
|
78
78
|
var y = new Statement(this.subject.substitute(bindings), this.predicate.substitute(bindings), this.object.substitute(bindings), isDefaultGraph(this.graph) ? this.graph : this.graph.substitute(bindings)); // 2016
|
|
79
|
-
console.log('@@@ statement substitute:' + y)
|
|
79
|
+
// console.log('@@@ statement substitute:' + y)
|
|
80
80
|
return y;
|
|
81
81
|
}
|
|
82
82
|
|
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,101 @@ 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 () {
|
|
90
|
+
var _flagAuthorizationMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
91
|
+
var kb, meta, requests, _iterator, _step, request, _response;
|
|
92
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
93
|
+
while (1) switch (_context.prev = _context.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
kb = this.store;
|
|
96
|
+
meta = kb.fetcher.appNode;
|
|
97
|
+
requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), undefined, meta).map(function (st) {
|
|
98
|
+
return st.subject;
|
|
99
|
+
});
|
|
100
|
+
_iterator = _createForOfIteratorHelper(requests);
|
|
101
|
+
try {
|
|
102
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
103
|
+
request = _step.value;
|
|
104
|
+
_response = kb.any(request, this.ns.link('response'), null, meta);
|
|
105
|
+
if (_response !== undefined) {
|
|
106
|
+
// ts
|
|
107
|
+
this.store.add(_response, this.ns.link('outOfDate'), true, meta); // @@ Boolean is fine - fix types
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
} catch (err) {
|
|
111
|
+
_iterator.e(err);
|
|
112
|
+
} finally {
|
|
113
|
+
_iterator.f();
|
|
114
|
+
}
|
|
115
|
+
case 5:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context.stop();
|
|
118
|
+
}
|
|
119
|
+
}, _callee, this);
|
|
120
|
+
}));
|
|
121
|
+
function flagAuthorizationMetadata() {
|
|
122
|
+
return _flagAuthorizationMetadata.apply(this, arguments);
|
|
123
|
+
}
|
|
124
|
+
return flagAuthorizationMetadata;
|
|
125
|
+
}()
|
|
79
126
|
/**
|
|
80
127
|
* Tests whether a file is editable.
|
|
81
128
|
* If the file has a specific annotation that it is machine written,
|
|
82
129
|
* for safety, it is editable (this doesn't actually check for write access)
|
|
83
130
|
* If the file has wac-allow and accept patch headers, those are respected.
|
|
84
131
|
* and local write access is determined by those headers.
|
|
85
|
-
* This version only looks at past HTTP requests,
|
|
132
|
+
* This async version not only looks at past HTTP requests, it also makes new ones if necessary.
|
|
133
|
+
*
|
|
134
|
+
* @returns The method string SPARQL or DAV or
|
|
135
|
+
* LOCALFILE or false if known, undefined if not known.
|
|
136
|
+
*/
|
|
137
|
+
}, {
|
|
138
|
+
key: "checkEditable",
|
|
139
|
+
value: function () {
|
|
140
|
+
var _checkEditable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(uri, kb) {
|
|
141
|
+
var initial, final;
|
|
142
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
143
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
144
|
+
case 0:
|
|
145
|
+
initial = this.editable(uri, kb);
|
|
146
|
+
if (!(initial !== undefined)) {
|
|
147
|
+
_context2.next = 3;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
return _context2.abrupt("return", initial);
|
|
151
|
+
case 3:
|
|
152
|
+
_context2.next = 5;
|
|
153
|
+
return this.store.fetcher.load(uri);
|
|
154
|
+
case 5:
|
|
155
|
+
final = this.editable(uri, kb);
|
|
156
|
+
console.log("Loaded ".concat(uri, " just to check editable, result: ").concat(final, "."));
|
|
157
|
+
return _context2.abrupt("return", final);
|
|
158
|
+
case 8:
|
|
159
|
+
case "end":
|
|
160
|
+
return _context2.stop();
|
|
161
|
+
}
|
|
162
|
+
}, _callee2, this);
|
|
163
|
+
}));
|
|
164
|
+
function checkEditable(_x, _x2) {
|
|
165
|
+
return _checkEditable.apply(this, arguments);
|
|
166
|
+
}
|
|
167
|
+
return checkEditable;
|
|
168
|
+
}()
|
|
169
|
+
/**
|
|
170
|
+
* Tests whether a file is editable.
|
|
171
|
+
* If the file has a specific annotation that it is machine written,
|
|
172
|
+
* for safety, it is editable (this doesn't actually check for write access)
|
|
173
|
+
* If the file has wac-allow and accept patch headers, those are respected.
|
|
174
|
+
* and local write access is determined by those headers.
|
|
175
|
+
* This synchronous version only looks at past HTTP requests, does not make new ones.
|
|
86
176
|
*
|
|
87
177
|
* @returns The method string SPARQL or DAV or
|
|
88
178
|
* LOCALFILE or false if known, undefined if not known.
|
|
@@ -99,27 +189,34 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
99
189
|
}
|
|
100
190
|
uri = termValue(uri);
|
|
101
191
|
if (!this.isHttpUri(uri)) {
|
|
102
|
-
if (
|
|
192
|
+
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
193
|
return 'LOCALFILE';
|
|
104
194
|
}
|
|
105
195
|
}
|
|
106
196
|
var request;
|
|
107
197
|
var definitive = false;
|
|
198
|
+
var meta = this.store.fetcher.appNode;
|
|
199
|
+
// const kb = s
|
|
200
|
+
|
|
108
201
|
// @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));
|
|
202
|
+
var requests = kb.each(undefined, this.ns.link('requestedURI'), docpart(uri), meta);
|
|
110
203
|
var method;
|
|
111
204
|
for (var r = 0; r < requests.length; r++) {
|
|
112
205
|
request = requests[r];
|
|
113
206
|
if (request !== undefined) {
|
|
114
|
-
var
|
|
115
|
-
if (
|
|
116
|
-
|
|
207
|
+
var _response2 = kb.any(request, this.ns.link('response'));
|
|
208
|
+
if (_response2 !== undefined) {
|
|
209
|
+
// ts
|
|
210
|
+
|
|
211
|
+
var outOfDate = kb.anyJS(_response2, this.ns.link('outOfDate'));
|
|
212
|
+
if (outOfDate) continue;
|
|
213
|
+
var wacAllow = kb.anyValue(_response2, this.ns.httph('wac-allow'));
|
|
117
214
|
if (wacAllow) {
|
|
118
|
-
var
|
|
119
|
-
|
|
215
|
+
var _iterator2 = _createForOfIteratorHelper(wacAllow.split(',')),
|
|
216
|
+
_step2;
|
|
120
217
|
try {
|
|
121
|
-
for (
|
|
122
|
-
var bit =
|
|
218
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
219
|
+
var bit = _step2.value;
|
|
123
220
|
var lr = bit.split('=');
|
|
124
221
|
if (lr[0].includes('user') && !lr[1].includes('write') && !lr[1].includes('append')) {
|
|
125
222
|
// console.log(' editable? excluded by WAC-Allow: ', wacAllow)
|
|
@@ -127,12 +224,12 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
127
224
|
}
|
|
128
225
|
}
|
|
129
226
|
} catch (err) {
|
|
130
|
-
|
|
227
|
+
_iterator2.e(err);
|
|
131
228
|
} finally {
|
|
132
|
-
|
|
229
|
+
_iterator2.f();
|
|
133
230
|
}
|
|
134
231
|
}
|
|
135
|
-
var acceptPatch = kb.each(
|
|
232
|
+
var acceptPatch = kb.each(_response2, this.ns.httph('accept-patch'));
|
|
136
233
|
if (acceptPatch.length) {
|
|
137
234
|
for (var i = 0; i < acceptPatch.length; i++) {
|
|
138
235
|
method = acceptPatch[i].value.trim();
|
|
@@ -140,7 +237,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
140
237
|
if (method.indexOf('application/sparql-update-single-match') >= 0) return 'SPARQL';
|
|
141
238
|
}
|
|
142
239
|
}
|
|
143
|
-
var authorVia = kb.each(
|
|
240
|
+
var authorVia = kb.each(_response2, this.ns.httph('ms-author-via'));
|
|
144
241
|
if (authorVia.length) {
|
|
145
242
|
for (var _i = 0; _i < authorVia.length; _i++) {
|
|
146
243
|
method = authorVia[_i].value.trim();
|
|
@@ -155,7 +252,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
155
252
|
if (!this.isHttpUri(uri)) {
|
|
156
253
|
if (!wacAllow) return false;else return 'LOCALFILE';
|
|
157
254
|
}
|
|
158
|
-
var status = kb.each(
|
|
255
|
+
var status = kb.each(_response2, this.ns.http('status'));
|
|
159
256
|
if (status.length) {
|
|
160
257
|
for (var _i2 = 0; _i2 < status.length; _i2++) {
|
|
161
258
|
// @ts-ignore since statuses should be TFTerms, this should always be false
|
package/lib/blank-node.js
CHANGED
|
@@ -100,7 +100,6 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
100
100
|
function getId(id) {
|
|
101
101
|
if (id) {
|
|
102
102
|
if (typeof id !== 'string') {
|
|
103
|
-
console.log('Bad blank id:', id);
|
|
104
103
|
throw new Error('Bad id argument to new blank node: ' + id);
|
|
105
104
|
}
|
|
106
105
|
if (id.includes('#')) {
|
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
|
@@ -581,7 +581,9 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
581
581
|
if (!this._fetch) {
|
|
582
582
|
throw new Error('No _fetch function available for Fetcher');
|
|
583
583
|
}
|
|
584
|
-
|
|
584
|
+
// This is the name of the graphh we store all the HTTP metadata in
|
|
585
|
+
this.appNode = this.store.sym('chrome://TheCurrentSession');
|
|
586
|
+
// this.appNode = this.store.rdfFactory.blankNode() // Needs to have a URI in tests
|
|
585
587
|
this.store.fetcher = this; // Bi-linked
|
|
586
588
|
this.requested = {};
|
|
587
589
|
this.timeouts = {};
|
|
@@ -861,7 +863,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
861
863
|
size: 0,
|
|
862
864
|
timeout: 0
|
|
863
865
|
};
|
|
864
|
-
console.log('Fetcher: <' + actualProxyURI + '> Non-HTTP fetch exception: ' + error)
|
|
866
|
+
// console.log('Fetcher: <' + actualProxyURI + '> Non-HTTP fetch exception: ' + error)
|
|
865
867
|
return _this5.handleError(dummyResponse, docuri, options); // possible credentials retry
|
|
866
868
|
// return this.failFetch(options, 'fetch failed: ' + error, 999, dummyResponse) // Fake status code: fetch exception
|
|
867
869
|
|
|
@@ -922,25 +924,21 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
922
924
|
if (fetchResponse.ok) {
|
|
923
925
|
userCallback(true, 'OK', fetchResponse);
|
|
924
926
|
} else {
|
|
925
|
-
// console.log('@@@ fetcher.js Should not take this path !!!!!!!!!!!!')
|
|
926
927
|
var oops = 'HTTP error: Status ' + fetchResponse.status + ' (' + fetchResponse.statusText + ')';
|
|
927
928
|
if (fetchResponse.responseText) {
|
|
928
929
|
oops += ' ' + fetchResponse.responseText; // not in 404, dns error, nock failure
|
|
929
930
|
}
|
|
930
931
|
|
|
931
|
-
console.log(oops + ' fetching ' + uri);
|
|
932
932
|
userCallback(false, oops, fetchResponse);
|
|
933
933
|
}
|
|
934
934
|
} else {
|
|
935
935
|
var _oops = '@@ nowOrWhenFetched: no response object!';
|
|
936
|
-
console.log(_oops);
|
|
937
936
|
userCallback(false, _oops);
|
|
938
937
|
}
|
|
939
938
|
}
|
|
940
939
|
}, function (err) {
|
|
941
940
|
var message = err.message || err.statusText;
|
|
942
941
|
message = 'Failed to load <' + uri + '> ' + message;
|
|
943
|
-
console.log(message);
|
|
944
942
|
if (err.response && err.response.status) {
|
|
945
943
|
message += ' status: ' + err.response.status;
|
|
946
944
|
}
|
|
@@ -1179,45 +1177,42 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1179
1177
|
return fetcher.load(doc);
|
|
1180
1178
|
case 6:
|
|
1181
1179
|
response = _context2.sent;
|
|
1182
|
-
_context2.next =
|
|
1180
|
+
_context2.next = 26;
|
|
1183
1181
|
break;
|
|
1184
1182
|
case 9:
|
|
1185
1183
|
_context2.prev = 9;
|
|
1186
1184
|
_context2.t0 = _context2["catch"](3);
|
|
1187
1185
|
if (!(_context2.t0.response.status === 404)) {
|
|
1188
|
-
_context2.next =
|
|
1186
|
+
_context2.next = 25;
|
|
1189
1187
|
break;
|
|
1190
1188
|
}
|
|
1191
|
-
|
|
1192
|
-
_context2.
|
|
1193
|
-
_context2.next = 16;
|
|
1189
|
+
_context2.prev = 12;
|
|
1190
|
+
_context2.next = 15;
|
|
1194
1191
|
return fetcher.webOperation('PUT', doc.value, {
|
|
1195
1192
|
data: data,
|
|
1196
1193
|
contentType: contentType
|
|
1197
1194
|
});
|
|
1198
|
-
case
|
|
1195
|
+
case 15:
|
|
1199
1196
|
response = _context2.sent;
|
|
1200
|
-
_context2.next =
|
|
1197
|
+
_context2.next = 21;
|
|
1201
1198
|
break;
|
|
1202
|
-
case
|
|
1203
|
-
_context2.prev =
|
|
1204
|
-
_context2.t1 = _context2["catch"](
|
|
1205
|
-
console.log('createIfNotExists doc FAILED: ' + doc + ': ' + _context2.t1);
|
|
1199
|
+
case 18:
|
|
1200
|
+
_context2.prev = 18;
|
|
1201
|
+
_context2.t1 = _context2["catch"](12);
|
|
1206
1202
|
throw _context2.t1;
|
|
1207
|
-
case
|
|
1203
|
+
case 21:
|
|
1208
1204
|
delete fetcher.requested[doc.value]; // delete cached 404 error
|
|
1209
1205
|
// console.log('createIfNotExists doc created ok ' + doc)
|
|
1210
1206
|
return _context2.abrupt("return", response);
|
|
1211
|
-
case
|
|
1212
|
-
console.log('createIfNotExists doc load error NOT 404: ' + doc + ': ' + _context2.t0);
|
|
1207
|
+
case 25:
|
|
1213
1208
|
throw _context2.t0;
|
|
1214
|
-
case
|
|
1209
|
+
case 26:
|
|
1215
1210
|
return _context2.abrupt("return", response);
|
|
1216
|
-
case
|
|
1211
|
+
case 27:
|
|
1217
1212
|
case "end":
|
|
1218
1213
|
return _context2.stop();
|
|
1219
1214
|
}
|
|
1220
|
-
}, _callee2, this, [[3, 9], [
|
|
1215
|
+
}, _callee2, this, [[3, 9], [12, 18]]);
|
|
1221
1216
|
}));
|
|
1222
1217
|
function createIfNotExists(_x4) {
|
|
1223
1218
|
return _createIfNotExists.apply(this, arguments);
|
|
@@ -1526,7 +1521,8 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1526
1521
|
}, {
|
|
1527
1522
|
key: "retryNoCredentials",
|
|
1528
1523
|
value: function retryNoCredentials(docuri, options) {
|
|
1529
|
-
console.log('Fetcher: CORS: RETRYING with NO CREDENTIALS for ' + options.resource)
|
|
1524
|
+
// console.log('Fetcher: CORS: RETRYING with NO CREDENTIALS for ' + options.resource)
|
|
1525
|
+
|
|
1530
1526
|
options.retriedWithNoCredentials = true; // protect against being called twice
|
|
1531
1527
|
|
|
1532
1528
|
delete this.requested[docuri]; // forget the original request happened
|
|
@@ -1571,7 +1567,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1571
1567
|
// Now attempt retry via proxy
|
|
1572
1568
|
var proxyUri = Fetcher.crossSiteProxy(docuri);
|
|
1573
1569
|
if (proxyUri && !options.proxyUsed) {
|
|
1574
|
-
console.log('web: Direct failed so trying proxy ' + proxyUri)
|
|
1570
|
+
// console.log('web: Direct failed so trying proxy ' + proxyUri)
|
|
1575
1571
|
return this.redirectToProxy(proxyUri, options);
|
|
1576
1572
|
}
|
|
1577
1573
|
}
|
|
@@ -1644,7 +1640,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1644
1640
|
|
|
1645
1641
|
// Check for masked errors (CORS, etc)
|
|
1646
1642
|
if (response.status === 0) {
|
|
1647
|
-
console.log('Masked error - status 0 for ' + docuri)
|
|
1643
|
+
// console.log('Masked error - status 0 for ' + docuri)
|
|
1648
1644
|
return this.handleError(response, docuri, options);
|
|
1649
1645
|
}
|
|
1650
1646
|
if (response.status >= 400) {
|
package/lib/formula.js
CHANGED
|
@@ -559,7 +559,6 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
559
559
|
while (todo.length) {
|
|
560
560
|
follow(todo.shift());
|
|
561
561
|
}
|
|
562
|
-
// console.log('' + result.length + ' statements about ' + subject)
|
|
563
562
|
return result;
|
|
564
563
|
}
|
|
565
564
|
|
|
@@ -716,10 +715,10 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
716
715
|
var statementsCopy = this.statements.map(function (ea) {
|
|
717
716
|
return ea.substitute(bindings);
|
|
718
717
|
});
|
|
719
|
-
console.log('Formula subs statmnts:' + statementsCopy)
|
|
718
|
+
// console.log('Formula subs statmnts:' + statementsCopy)
|
|
720
719
|
var y = new Formula();
|
|
721
720
|
y.addAll(statementsCopy);
|
|
722
|
-
console.log('indexed-form subs formula:' + y)
|
|
721
|
+
// console.log('indexed-form subs formula:' + y)
|
|
723
722
|
return y;
|
|
724
723
|
}
|
|
725
724
|
}, {
|
package/lib/node-internal.js
CHANGED
package/lib/statement.js
CHANGED
|
@@ -86,7 +86,7 @@ var Statement = /*#__PURE__*/function () {
|
|
|
86
86
|
key: "substitute",
|
|
87
87
|
value: function substitute(bindings) {
|
|
88
88
|
var y = new Statement(this.subject.substitute(bindings), this.predicate.substitute(bindings), this.object.substitute(bindings), (0, _defaultGraph.isDefaultGraph)(this.graph) ? this.graph : this.graph.substitute(bindings)); // 2016
|
|
89
|
-
console.log('@@@ statement substitute:' + y)
|
|
89
|
+
// console.log('@@@ statement substitute:' + y)
|
|
90
90
|
return y;
|
|
91
91
|
}
|
|
92
92
|
|
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(): Promise<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.
|