rdflib 2.2.28 → 2.2.30-19be4b6a
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 +29 -31
- package/esm/formula.js +2 -3
- package/esm/node-internal.js +0 -1
- package/esm/statement.js +1 -1
- package/esm/update-manager.js +98 -15
- package/lib/blank-node.js +0 -1
- package/lib/fetcher.d.ts +1 -1
- package/lib/fetcher.js +29 -31
- 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 +98 -15
- package/package.json +1 -1
- package/src/blank-node.ts +0 -1
- package/src/fetcher.ts +16 -20
- 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 graph 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);
|
|
@@ -1437,17 +1432,19 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1437
1432
|
var _this10 = this;
|
|
1438
1433
|
var kb = this.store;
|
|
1439
1434
|
var responseNode = kb.bnode();
|
|
1440
|
-
kb.add(options.req, this.ns.link('response'), responseNode,
|
|
1441
|
-
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status),
|
|
1442
|
-
kb.add(responseNode, this.ns.http('statusText'), kb.rdfFactory.literal(response.statusText),
|
|
1435
|
+
kb.add(options.req, this.ns.link('response'), responseNode, this.appNode);
|
|
1436
|
+
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status), this.appNode);
|
|
1437
|
+
kb.add(responseNode, this.ns.http('statusText'), kb.rdfFactory.literal(response.statusText), this.appNode);
|
|
1443
1438
|
|
|
1444
1439
|
// Save the response headers
|
|
1445
1440
|
response.headers.forEach(function (value, header) {
|
|
1446
|
-
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value),
|
|
1441
|
+
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value), _this10.appNode);
|
|
1447
1442
|
if (header === 'content-type') {
|
|
1448
|
-
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), responseNode
|
|
1443
|
+
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), _this10.appNode // responseNode
|
|
1444
|
+
);
|
|
1449
1445
|
}
|
|
1450
1446
|
});
|
|
1447
|
+
|
|
1451
1448
|
return responseNode;
|
|
1452
1449
|
}
|
|
1453
1450
|
}, {
|
|
@@ -1543,7 +1540,8 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1543
1540
|
}, {
|
|
1544
1541
|
key: "retryNoCredentials",
|
|
1545
1542
|
value: function retryNoCredentials(docuri, options) {
|
|
1546
|
-
console.log('Fetcher: CORS: RETRYING with NO CREDENTIALS for ' + options.resource)
|
|
1543
|
+
// console.log('Fetcher: CORS: RETRYING with NO CREDENTIALS for ' + options.resource)
|
|
1544
|
+
|
|
1547
1545
|
options.retriedWithNoCredentials = true; // protect against being called twice
|
|
1548
1546
|
|
|
1549
1547
|
delete this.requested[docuri]; // forget the original request happened
|
|
@@ -1588,7 +1586,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1588
1586
|
// Now attempt retry via proxy
|
|
1589
1587
|
var proxyUri = Fetcher.crossSiteProxy(docuri);
|
|
1590
1588
|
if (proxyUri && !options.proxyUsed) {
|
|
1591
|
-
console.log('web: Direct failed so trying proxy ' + proxyUri)
|
|
1589
|
+
// console.log('web: Direct failed so trying proxy ' + proxyUri)
|
|
1592
1590
|
return this.redirectToProxy(proxyUri, options);
|
|
1593
1591
|
}
|
|
1594
1592
|
}
|
|
@@ -1661,7 +1659,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1661
1659
|
|
|
1662
1660
|
// Check for masked errors (CORS, etc)
|
|
1663
1661
|
if (response.status === 0) {
|
|
1664
|
-
console.log('Masked error - status 0 for ' + docuri)
|
|
1662
|
+
// console.log('Masked error - status 0 for ' + docuri)
|
|
1665
1663
|
return this.handleError(response, docuri, options);
|
|
1666
1664
|
}
|
|
1667
1665
|
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,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/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 graph 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);
|
|
@@ -1420,17 +1415,19 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1420
1415
|
var _this10 = this;
|
|
1421
1416
|
var kb = this.store;
|
|
1422
1417
|
var responseNode = kb.bnode();
|
|
1423
|
-
kb.add(options.req, this.ns.link('response'), responseNode,
|
|
1424
|
-
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status),
|
|
1425
|
-
kb.add(responseNode, this.ns.http('statusText'), kb.rdfFactory.literal(response.statusText),
|
|
1418
|
+
kb.add(options.req, this.ns.link('response'), responseNode, this.appNode);
|
|
1419
|
+
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status), this.appNode);
|
|
1420
|
+
kb.add(responseNode, this.ns.http('statusText'), kb.rdfFactory.literal(response.statusText), this.appNode);
|
|
1426
1421
|
|
|
1427
1422
|
// Save the response headers
|
|
1428
1423
|
response.headers.forEach(function (value, header) {
|
|
1429
|
-
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value),
|
|
1424
|
+
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value), _this10.appNode);
|
|
1430
1425
|
if (header === 'content-type') {
|
|
1431
|
-
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), responseNode
|
|
1426
|
+
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), _this10.appNode // responseNode
|
|
1427
|
+
);
|
|
1432
1428
|
}
|
|
1433
1429
|
});
|
|
1430
|
+
|
|
1434
1431
|
return responseNode;
|
|
1435
1432
|
}
|
|
1436
1433
|
}, {
|
|
@@ -1526,7 +1523,8 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1526
1523
|
}, {
|
|
1527
1524
|
key: "retryNoCredentials",
|
|
1528
1525
|
value: function retryNoCredentials(docuri, options) {
|
|
1529
|
-
console.log('Fetcher: CORS: RETRYING with NO CREDENTIALS for ' + options.resource)
|
|
1526
|
+
// console.log('Fetcher: CORS: RETRYING with NO CREDENTIALS for ' + options.resource)
|
|
1527
|
+
|
|
1530
1528
|
options.retriedWithNoCredentials = true; // protect against being called twice
|
|
1531
1529
|
|
|
1532
1530
|
delete this.requested[docuri]; // forget the original request happened
|
|
@@ -1571,7 +1569,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1571
1569
|
// Now attempt retry via proxy
|
|
1572
1570
|
var proxyUri = Fetcher.crossSiteProxy(docuri);
|
|
1573
1571
|
if (proxyUri && !options.proxyUsed) {
|
|
1574
|
-
console.log('web: Direct failed so trying proxy ' + proxyUri)
|
|
1572
|
+
// console.log('web: Direct failed so trying proxy ' + proxyUri)
|
|
1575
1573
|
return this.redirectToProxy(proxyUri, options);
|
|
1576
1574
|
}
|
|
1577
1575
|
}
|
|
@@ -1644,7 +1642,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1644
1642
|
|
|
1645
1643
|
// Check for masked errors (CORS, etc)
|
|
1646
1644
|
if (response.status === 0) {
|
|
1647
|
-
console.log('Masked error - status 0 for ' + docuri)
|
|
1645
|
+
// console.log('Masked error - status 0 for ' + docuri)
|
|
1648
1646
|
return this.handleError(response, docuri, options);
|
|
1649
1647
|
}
|
|
1650
1648
|
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(): 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.
|