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/lib/update-manager.js
CHANGED
|
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
10
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -80,13 +82,101 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
80
82
|
return uri.slice(0, 4) === 'http';
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
/** Remove from the store HTTP authorization metadata
|
|
86
|
+
* The editble function below relies on copies we have in the store
|
|
87
|
+
* of the results of previous HTTP transactions. Howver, when
|
|
88
|
+
* the user logs in, then that data misrepresents what would happen
|
|
89
|
+
* if the user tried again.
|
|
90
|
+
*/
|
|
91
|
+
}, {
|
|
92
|
+
key: "flagAuthorizationMetadata",
|
|
93
|
+
value: function () {
|
|
94
|
+
var _flagAuthorizationMetadata = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
95
|
+
var kb, meta, requests, _iterator, _step, request, _response;
|
|
96
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
97
|
+
while (1) switch (_context.prev = _context.next) {
|
|
98
|
+
case 0:
|
|
99
|
+
kb = this.store;
|
|
100
|
+
meta = kb.fetcher.appNode;
|
|
101
|
+
requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), undefined, meta).map(function (st) {
|
|
102
|
+
return st.subject;
|
|
103
|
+
});
|
|
104
|
+
_iterator = _createForOfIteratorHelper(requests);
|
|
105
|
+
try {
|
|
106
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
107
|
+
request = _step.value;
|
|
108
|
+
_response = kb.any(request, this.ns.link('response'), null, meta);
|
|
109
|
+
if (_response !== undefined) {
|
|
110
|
+
// ts
|
|
111
|
+
this.store.add(_response, this.ns.link('outOfDate'), true, meta); // @@ Boolean is fine - fix types
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
} catch (err) {
|
|
115
|
+
_iterator.e(err);
|
|
116
|
+
} finally {
|
|
117
|
+
_iterator.f();
|
|
118
|
+
}
|
|
119
|
+
case 5:
|
|
120
|
+
case "end":
|
|
121
|
+
return _context.stop();
|
|
122
|
+
}
|
|
123
|
+
}, _callee, this);
|
|
124
|
+
}));
|
|
125
|
+
function flagAuthorizationMetadata() {
|
|
126
|
+
return _flagAuthorizationMetadata.apply(this, arguments);
|
|
127
|
+
}
|
|
128
|
+
return flagAuthorizationMetadata;
|
|
129
|
+
}()
|
|
83
130
|
/**
|
|
84
131
|
* Tests whether a file is editable.
|
|
85
132
|
* If the file has a specific annotation that it is machine written,
|
|
86
133
|
* for safety, it is editable (this doesn't actually check for write access)
|
|
87
134
|
* If the file has wac-allow and accept patch headers, those are respected.
|
|
88
135
|
* and local write access is determined by those headers.
|
|
89
|
-
* This version only looks at past HTTP requests,
|
|
136
|
+
* This async version not only looks at past HTTP requests, it also makes new ones if necessary.
|
|
137
|
+
*
|
|
138
|
+
* @returns The method string SPARQL or DAV or
|
|
139
|
+
* LOCALFILE or false if known, undefined if not known.
|
|
140
|
+
*/
|
|
141
|
+
}, {
|
|
142
|
+
key: "checkEditable",
|
|
143
|
+
value: function () {
|
|
144
|
+
var _checkEditable = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(uri, kb) {
|
|
145
|
+
var initial, final;
|
|
146
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
147
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
148
|
+
case 0:
|
|
149
|
+
initial = this.editable(uri, kb);
|
|
150
|
+
if (!(initial !== undefined)) {
|
|
151
|
+
_context2.next = 3;
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
return _context2.abrupt("return", initial);
|
|
155
|
+
case 3:
|
|
156
|
+
_context2.next = 5;
|
|
157
|
+
return this.store.fetcher.load(uri);
|
|
158
|
+
case 5:
|
|
159
|
+
final = this.editable(uri, kb);
|
|
160
|
+
console.log("Loaded ".concat(uri, " just to check editable, result: ").concat(final, "."));
|
|
161
|
+
return _context2.abrupt("return", final);
|
|
162
|
+
case 8:
|
|
163
|
+
case "end":
|
|
164
|
+
return _context2.stop();
|
|
165
|
+
}
|
|
166
|
+
}, _callee2, this);
|
|
167
|
+
}));
|
|
168
|
+
function checkEditable(_x, _x2) {
|
|
169
|
+
return _checkEditable.apply(this, arguments);
|
|
170
|
+
}
|
|
171
|
+
return checkEditable;
|
|
172
|
+
}()
|
|
173
|
+
/**
|
|
174
|
+
* Tests whether a file is editable.
|
|
175
|
+
* If the file has a specific annotation that it is machine written,
|
|
176
|
+
* for safety, it is editable (this doesn't actually check for write access)
|
|
177
|
+
* If the file has wac-allow and accept patch headers, those are respected.
|
|
178
|
+
* and local write access is determined by those headers.
|
|
179
|
+
* This synchronous version only looks at past HTTP requests, does not make new ones.
|
|
90
180
|
*
|
|
91
181
|
* @returns The method string SPARQL or DAV or
|
|
92
182
|
* LOCALFILE or false if known, undefined if not known.
|
|
@@ -103,27 +193,34 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
103
193
|
}
|
|
104
194
|
uri = (0, _termValue.termValue)(uri);
|
|
105
195
|
if (!this.isHttpUri(uri)) {
|
|
106
|
-
if (
|
|
196
|
+
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'))) {
|
|
107
197
|
return 'LOCALFILE';
|
|
108
198
|
}
|
|
109
199
|
}
|
|
110
200
|
var request;
|
|
111
201
|
var definitive = false;
|
|
202
|
+
var meta = this.store.fetcher.appNode;
|
|
203
|
+
// const kb = s
|
|
204
|
+
|
|
112
205
|
// @ts-ignore passes a string to kb.each, which expects a term. Should this work?
|
|
113
|
-
var requests = kb.each(undefined, this.ns.link('requestedURI'), (0, _uri.docpart)(uri));
|
|
206
|
+
var requests = kb.each(undefined, this.ns.link('requestedURI'), (0, _uri.docpart)(uri), meta);
|
|
114
207
|
var method;
|
|
115
208
|
for (var r = 0; r < requests.length; r++) {
|
|
116
209
|
request = requests[r];
|
|
117
210
|
if (request !== undefined) {
|
|
118
|
-
var
|
|
119
|
-
if (
|
|
120
|
-
|
|
211
|
+
var _response2 = kb.any(request, this.ns.link('response'));
|
|
212
|
+
if (_response2 !== undefined) {
|
|
213
|
+
// ts
|
|
214
|
+
|
|
215
|
+
var outOfDate = kb.anyJS(_response2, this.ns.link('outOfDate'));
|
|
216
|
+
if (outOfDate) continue;
|
|
217
|
+
var wacAllow = kb.anyValue(_response2, this.ns.httph('wac-allow'));
|
|
121
218
|
if (wacAllow) {
|
|
122
|
-
var
|
|
123
|
-
|
|
219
|
+
var _iterator2 = _createForOfIteratorHelper(wacAllow.split(',')),
|
|
220
|
+
_step2;
|
|
124
221
|
try {
|
|
125
|
-
for (
|
|
126
|
-
var bit =
|
|
222
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
223
|
+
var bit = _step2.value;
|
|
127
224
|
var lr = bit.split('=');
|
|
128
225
|
if (lr[0].includes('user') && !lr[1].includes('write') && !lr[1].includes('append')) {
|
|
129
226
|
// console.log(' editable? excluded by WAC-Allow: ', wacAllow)
|
|
@@ -131,12 +228,12 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
131
228
|
}
|
|
132
229
|
}
|
|
133
230
|
} catch (err) {
|
|
134
|
-
|
|
231
|
+
_iterator2.e(err);
|
|
135
232
|
} finally {
|
|
136
|
-
|
|
233
|
+
_iterator2.f();
|
|
137
234
|
}
|
|
138
235
|
}
|
|
139
|
-
var acceptPatch = kb.each(
|
|
236
|
+
var acceptPatch = kb.each(_response2, this.ns.httph('accept-patch'));
|
|
140
237
|
if (acceptPatch.length) {
|
|
141
238
|
for (var i = 0; i < acceptPatch.length; i++) {
|
|
142
239
|
method = acceptPatch[i].value.trim();
|
|
@@ -144,7 +241,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
144
241
|
if (method.indexOf('application/sparql-update-single-match') >= 0) return 'SPARQL';
|
|
145
242
|
}
|
|
146
243
|
}
|
|
147
|
-
var authorVia = kb.each(
|
|
244
|
+
var authorVia = kb.each(_response2, this.ns.httph('ms-author-via'));
|
|
148
245
|
if (authorVia.length) {
|
|
149
246
|
for (var _i = 0; _i < authorVia.length; _i++) {
|
|
150
247
|
method = authorVia[_i].value.trim();
|
|
@@ -159,7 +256,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
159
256
|
if (!this.isHttpUri(uri)) {
|
|
160
257
|
if (!wacAllow) return false;else return 'LOCALFILE';
|
|
161
258
|
}
|
|
162
|
-
var status = kb.each(
|
|
259
|
+
var status = kb.each(_response2, this.ns.http('status'));
|
|
163
260
|
if (status.length) {
|
|
164
261
|
for (var _i2 = 0; _i2 < status.length; _i2++) {
|
|
165
262
|
// @ts-ignore since statuses should be TFTerms, this should always be false
|
package/package.json
CHANGED
package/src/blank-node.ts
CHANGED
|
@@ -19,7 +19,6 @@ export default class BlankNode extends Node implements TFBlankNode {
|
|
|
19
19
|
private static getId (id: string | unknown): string {
|
|
20
20
|
if (id) {
|
|
21
21
|
if (typeof id !== 'string') {
|
|
22
|
-
console.log('Bad blank id:', id)
|
|
23
22
|
throw new Error('Bad id argument to new blank node: ' + id)
|
|
24
23
|
}
|
|
25
24
|
|
package/src/fetcher.ts
CHANGED
|
@@ -721,7 +721,7 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
721
721
|
_fetch: Fetch
|
|
722
722
|
mediatypes: MediatypesMap
|
|
723
723
|
/** Denoting this session */
|
|
724
|
-
appNode:
|
|
724
|
+
appNode: NamedNode
|
|
725
725
|
/**
|
|
726
726
|
* this.requested[uri] states:
|
|
727
727
|
* undefined no record of web access or records reset
|
|
@@ -771,8 +771,9 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
771
771
|
if (!this._fetch) {
|
|
772
772
|
throw new Error('No _fetch function available for Fetcher')
|
|
773
773
|
}
|
|
774
|
-
|
|
775
|
-
this.appNode = this.store.
|
|
774
|
+
// This is the name of the graphh we store all the HTTP metadata in
|
|
775
|
+
this.appNode = this.store.sym('chrome://TheCurrentSession')
|
|
776
|
+
// this.appNode = this.store.rdfFactory.blankNode() // Needs to have a URI in tests
|
|
776
777
|
this.store.fetcher = this // Bi-linked
|
|
777
778
|
this.requested = {}
|
|
778
779
|
this.timeouts = {}
|
|
@@ -1160,7 +1161,7 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
1160
1161
|
size: 0,
|
|
1161
1162
|
timeout: 0
|
|
1162
1163
|
}
|
|
1163
|
-
console.log('Fetcher: <' + actualProxyURI + '> Non-HTTP fetch exception: ' + error)
|
|
1164
|
+
// console.log('Fetcher: <' + actualProxyURI + '> Non-HTTP fetch exception: ' + error)
|
|
1164
1165
|
return this.handleError(dummyResponse, docuri, options) // possible credentials retry
|
|
1165
1166
|
// return this.failFetch(options, 'fetch failed: ' + error, 999, dummyResponse) // Fake status code: fetch exception
|
|
1166
1167
|
|
|
@@ -1227,24 +1228,20 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
1227
1228
|
if ((fetchResponse as Response).ok) {
|
|
1228
1229
|
userCallback(true, 'OK', fetchResponse)
|
|
1229
1230
|
} else {
|
|
1230
|
-
// console.log('@@@ fetcher.js Should not take this path !!!!!!!!!!!!')
|
|
1231
1231
|
let oops = 'HTTP error: Status ' + fetchResponse.status + ' (' + fetchResponse.statusText + ')'
|
|
1232
1232
|
if (fetchResponse.responseText) {
|
|
1233
1233
|
oops += ' ' + fetchResponse.responseText // not in 404, dns error, nock failure
|
|
1234
1234
|
}
|
|
1235
|
-
console.log(oops + ' fetching ' + uri)
|
|
1236
1235
|
userCallback(false, oops, fetchResponse)
|
|
1237
1236
|
}
|
|
1238
1237
|
} else {
|
|
1239
1238
|
let oops = ('@@ nowOrWhenFetched: no response object!')
|
|
1240
|
-
console.log(oops)
|
|
1241
1239
|
userCallback(false, oops)
|
|
1242
1240
|
}
|
|
1243
1241
|
}
|
|
1244
1242
|
}, function (err: FetchError) {
|
|
1245
1243
|
var message = err.message || err.statusText
|
|
1246
1244
|
message = 'Failed to load <' + uri + '> ' + message
|
|
1247
|
-
console.log(message)
|
|
1248
1245
|
if (err.response && err.response.status) {
|
|
1249
1246
|
message += ' status: ' + err.response.status
|
|
1250
1247
|
}
|
|
@@ -1497,18 +1494,18 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
1497
1494
|
} catch (err) {
|
|
1498
1495
|
// @ts-ignore
|
|
1499
1496
|
if (err.response.status === 404) {
|
|
1500
|
-
console.log('createIfNotExists: doc does NOT exist, will create... ' + doc)
|
|
1497
|
+
// console.log('createIfNotExists: doc does NOT exist, will create... ' + doc)
|
|
1501
1498
|
try {
|
|
1502
1499
|
response = await fetcher.webOperation('PUT', doc.value, {data, contentType})
|
|
1503
1500
|
} catch (err) {
|
|
1504
|
-
console.log('createIfNotExists doc FAILED: ' + doc + ': ' + err)
|
|
1501
|
+
// console.log('createIfNotExists doc FAILED: ' + doc + ': ' + err)
|
|
1505
1502
|
throw err
|
|
1506
1503
|
}
|
|
1507
1504
|
delete fetcher.requested[doc.value] // delete cached 404 error
|
|
1508
1505
|
// console.log('createIfNotExists doc created ok ' + doc)
|
|
1509
1506
|
return response
|
|
1510
1507
|
} else {
|
|
1511
|
-
console.log('createIfNotExists doc load error NOT 404: ' + doc + ': ' + err)
|
|
1508
|
+
// console.log('createIfNotExists doc load error NOT 404: ' + doc + ': ' + err)
|
|
1512
1509
|
throw err
|
|
1513
1510
|
}
|
|
1514
1511
|
}
|
|
@@ -1837,7 +1834,7 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
1837
1834
|
docuri: string,
|
|
1838
1835
|
options
|
|
1839
1836
|
): Promise<Result> {
|
|
1840
|
-
console.log('Fetcher: CORS: RETRYING with NO CREDENTIALS for ' + options.resource)
|
|
1837
|
+
// console.log('Fetcher: CORS: RETRYING with NO CREDENTIALS for ' + options.resource)
|
|
1841
1838
|
|
|
1842
1839
|
options.retriedWithNoCredentials = true // protect against being called twice
|
|
1843
1840
|
|
|
@@ -1886,8 +1883,7 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
1886
1883
|
let proxyUri = Fetcher.crossSiteProxy(docuri)
|
|
1887
1884
|
|
|
1888
1885
|
if (proxyUri && !options.proxyUsed) {
|
|
1889
|
-
console.log('web: Direct failed so trying proxy ' + proxyUri)
|
|
1890
|
-
|
|
1886
|
+
// console.log('web: Direct failed so trying proxy ' + proxyUri)
|
|
1891
1887
|
return this.redirectToProxy(proxyUri, options)
|
|
1892
1888
|
}
|
|
1893
1889
|
}
|
|
@@ -1960,7 +1956,7 @@ export default class Fetcher implements CallbackifyInterface {
|
|
|
1960
1956
|
|
|
1961
1957
|
// Check for masked errors (CORS, etc)
|
|
1962
1958
|
if (response.status === 0) {
|
|
1963
|
-
console.log('Masked error - status 0 for ' + docuri)
|
|
1959
|
+
// console.log('Masked error - status 0 for ' + docuri)
|
|
1964
1960
|
return this.handleError(response, docuri, options)
|
|
1965
1961
|
}
|
|
1966
1962
|
|
package/src/formula.ts
CHANGED
|
@@ -589,7 +589,6 @@ export default class Formula extends Node {
|
|
|
589
589
|
while (todo.length) {
|
|
590
590
|
follow(todo.shift())
|
|
591
591
|
}
|
|
592
|
-
// console.log('' + result.length + ' statements about ' + subject)
|
|
593
592
|
return result
|
|
594
593
|
}
|
|
595
594
|
|
|
@@ -736,10 +735,10 @@ export default class Formula extends Node {
|
|
|
736
735
|
let statementsCopy = this.statements.map(function (ea) {
|
|
737
736
|
return (ea as Statement).substitute(bindings)
|
|
738
737
|
})
|
|
739
|
-
console.log('Formula subs statmnts:' + statementsCopy)
|
|
738
|
+
// console.log('Formula subs statmnts:' + statementsCopy)
|
|
740
739
|
const y = new Formula()
|
|
741
740
|
y.addAll(statementsCopy as Quad[])
|
|
742
|
-
console.log('indexed-form subs formula:' + y)
|
|
741
|
+
// console.log('indexed-form subs formula:' + y)
|
|
743
742
|
return y as unknown as T
|
|
744
743
|
}
|
|
745
744
|
|
package/src/node-internal.ts
CHANGED
package/src/statement.ts
CHANGED
|
@@ -99,7 +99,7 @@ export default class Statement<
|
|
|
99
99
|
isDefaultGraph(this.graph) ? this.graph :
|
|
100
100
|
(this.graph as G).substitute(bindings)
|
|
101
101
|
) // 2016
|
|
102
|
-
console.log('@@@ statement substitute:' + y)
|
|
102
|
+
// console.log('@@@ statement substitute:' + y)
|
|
103
103
|
return y
|
|
104
104
|
}
|
|
105
105
|
|
package/src/update-manager.ts
CHANGED
|
@@ -81,14 +81,52 @@ export default class UpdateManager {
|
|
|
81
81
|
return( uri.slice(0,4) === 'http' )
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/** Remove from the store HTTP authorization metadata
|
|
85
|
+
* The editble function below relies on copies we have in the store
|
|
86
|
+
* of the results of previous HTTP transactions. Howver, when
|
|
87
|
+
* the user logs in, then that data misrepresents what would happen
|
|
88
|
+
* if the user tried again.
|
|
89
|
+
*/
|
|
90
|
+
async flagAuthorizationMetadata () {
|
|
91
|
+
const kb = this.store
|
|
92
|
+
const meta = kb.fetcher.appNode
|
|
93
|
+
const requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), undefined, meta).map(st => st.subject)
|
|
94
|
+
for (const request of requests) {
|
|
95
|
+
const response = kb.any(request, this.ns.link('response'), null, meta) as Quad_Subject
|
|
96
|
+
if (response !== undefined) { // ts
|
|
97
|
+
this.store.add(response, this.ns.link('outOfDate'), true as any, meta) // @@ Boolean is fine - fix types
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
84
101
|
|
|
102
|
+
/**
|
|
103
|
+
* Tests whether a file is editable.
|
|
104
|
+
* If the file has a specific annotation that it is machine written,
|
|
105
|
+
* for safety, it is editable (this doesn't actually check for write access)
|
|
106
|
+
* If the file has wac-allow and accept patch headers, those are respected.
|
|
107
|
+
* and local write access is determined by those headers.
|
|
108
|
+
* This async version not only looks at past HTTP requests, it also makes new ones if necessary.
|
|
109
|
+
*
|
|
110
|
+
* @returns The method string SPARQL or DAV or
|
|
111
|
+
* LOCALFILE or false if known, undefined if not known.
|
|
112
|
+
*/
|
|
113
|
+
async checkEditable (uri: string | NamedNode, kb?: IndexedFormula): Promise<string | boolean | undefined> {
|
|
114
|
+
const initial = this.editable(uri, kb)
|
|
115
|
+
if (initial !== undefined) {
|
|
116
|
+
return initial
|
|
117
|
+
}
|
|
118
|
+
await this.store.fetcher.load(uri)
|
|
119
|
+
const final = this.editable(uri, kb)
|
|
120
|
+
console.log(`Loaded ${uri} just to check editable, result: ${final}.`)
|
|
121
|
+
return final
|
|
122
|
+
}
|
|
85
123
|
/**
|
|
86
124
|
* Tests whether a file is editable.
|
|
87
125
|
* If the file has a specific annotation that it is machine written,
|
|
88
126
|
* for safety, it is editable (this doesn't actually check for write access)
|
|
89
127
|
* If the file has wac-allow and accept patch headers, those are respected.
|
|
90
128
|
* and local write access is determined by those headers.
|
|
91
|
-
* This version only looks at past HTTP requests, does not make new ones.
|
|
129
|
+
* This synchronous version only looks at past HTTP requests, does not make new ones.
|
|
92
130
|
*
|
|
93
131
|
* @returns The method string SPARQL or DAV or
|
|
94
132
|
* LOCALFILE or false if known, undefined if not known.
|
|
@@ -103,7 +141,7 @@ export default class UpdateManager {
|
|
|
103
141
|
uri = termValue(uri)
|
|
104
142
|
|
|
105
143
|
if ( !this.isHttpUri(uri as string) ) {
|
|
106
|
-
if (
|
|
144
|
+
if (this.store.holds(
|
|
107
145
|
this.store.rdfFactory.namedNode(uri),
|
|
108
146
|
this.store.rdfFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
|
|
109
147
|
this.store.rdfFactory.namedNode('http://www.w3.org/2007/ont/link#MachineEditableDocument'))) {
|
|
@@ -113,14 +151,21 @@ export default class UpdateManager {
|
|
|
113
151
|
|
|
114
152
|
var request
|
|
115
153
|
var definitive = false
|
|
154
|
+
const meta = this.store.fetcher.appNode
|
|
155
|
+
// const kb = s
|
|
156
|
+
|
|
116
157
|
// @ts-ignore passes a string to kb.each, which expects a term. Should this work?
|
|
117
|
-
var requests = kb.each(undefined, this.ns.link('requestedURI'), docpart(uri))
|
|
158
|
+
var requests = kb.each(undefined, this.ns.link('requestedURI'), docpart(uri), meta)
|
|
118
159
|
var method: string
|
|
119
160
|
for (var r = 0; r < requests.length; r++) {
|
|
120
161
|
request = requests[r]
|
|
121
162
|
if (request !== undefined) {
|
|
122
|
-
|
|
123
|
-
if (
|
|
163
|
+
const response = kb.any(request, this.ns.link('response')) as Quad_Subject
|
|
164
|
+
if (response !== undefined) { // ts
|
|
165
|
+
|
|
166
|
+
const outOfDate = kb.anyJS(response, this.ns.link('outOfDate')) as Quad_Subject
|
|
167
|
+
if (outOfDate) continue
|
|
168
|
+
|
|
124
169
|
var wacAllow = kb.anyValue(response, this.ns.httph('wac-allow'))
|
|
125
170
|
if (wacAllow) {
|
|
126
171
|
for (var bit of wacAllow.split(',')) {
|