rdflib 2.2.30 → 2.2.31-4e4dc84d
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/730.rdflib.min.js +1 -1
- package/dist/730.rdflib.min.js.map +1 -1
- package/dist/rdflib.min.js +1 -1
- package/dist/rdflib.min.js.LICENSE.txt +0 -59
- package/dist/rdflib.min.js.map +1 -1
- package/esm/blank-node.js +10 -6
- package/esm/collection.js +3 -4
- package/esm/factories/factory-types.js +10 -10
- package/esm/fetcher.js +74 -41
- package/esm/formula.js +10 -13
- package/esm/jsonldparser.js +4 -3
- package/esm/lists.js +2 -1
- package/esm/literal.js +6 -8
- package/esm/node-internal.js +5 -10
- package/esm/rdfxmlparser.js +3 -0
- package/esm/serializer.js +1 -2
- package/esm/statement.js +7 -11
- package/esm/store.js +39 -32
- package/esm/types.js +18 -1
- package/esm/update-manager.js +114 -19
- package/esm/utils.js +0 -1
- package/esm/variable.js +2 -4
- package/lib/blank-node.js +10 -6
- package/lib/collection.js +3 -4
- package/lib/factories/factory-types.js +10 -10
- package/lib/fetcher.d.ts +1 -1
- package/lib/fetcher.js +98 -42
- package/lib/formula.js +10 -13
- package/lib/index.d.ts +1 -1
- package/lib/jsonldparser.js +9 -3
- package/lib/lists.js +15 -1
- package/lib/literal.js +6 -8
- package/lib/node-internal.js +5 -10
- package/lib/query.d.ts +1 -1
- package/lib/rdfxmlparser.js +3 -0
- package/lib/serializer.d.ts +1 -1
- package/lib/serializer.js +1 -2
- package/lib/sparql-to-query.d.ts +1 -1
- package/lib/statement.js +7 -11
- package/lib/store.d.ts +1 -1
- package/lib/store.js +55 -34
- package/lib/types.js +22 -0
- package/lib/update-manager.d.ts +20 -1
- package/lib/update-manager.js +120 -20
- package/lib/utils-js.d.ts +3 -3
- package/lib/variable.js +2 -4
- package/lib/xsd-internal.d.ts +1 -1
- package/package.json +20 -20
- package/src/fetcher.ts +22 -8
- package/src/jsonldparser.js +2 -4
- package/src/store.ts +18 -1
- package/src/update-manager.ts +61 -7
- package/esm/convert.js +0 -60
- package/lib/convert.d.ts +0 -2
- package/lib/convert.js +0 -71
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; }
|
|
@@ -26,10 +28,6 @@ import { termValue } from './utils/termValue';
|
|
|
26
28
|
* and also looking out for concurrent updates from other agents
|
|
27
29
|
*/
|
|
28
30
|
var UpdateManager = /*#__PURE__*/function () {
|
|
29
|
-
/** Index of objects for coordinating incoming and outgoing patches */
|
|
30
|
-
|
|
31
|
-
/** Object of namespaces */
|
|
32
|
-
|
|
33
31
|
/**
|
|
34
32
|
* @param store - The quadstore to store data and metadata. Created if not passed.
|
|
35
33
|
*/
|
|
@@ -38,7 +36,9 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
38
36
|
_defineProperty(this, "store", void 0);
|
|
39
37
|
_defineProperty(this, "ifps", void 0);
|
|
40
38
|
_defineProperty(this, "fps", void 0);
|
|
39
|
+
/** Index of objects for coordinating incoming and outgoing patches */
|
|
41
40
|
_defineProperty(this, "patchControl", void 0);
|
|
41
|
+
/** Object of namespaces */
|
|
42
42
|
_defineProperty(this, "ns", void 0);
|
|
43
43
|
store = store || new IndexedFormula();
|
|
44
44
|
if (store.updater) {
|
|
@@ -76,13 +76,100 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
76
76
|
return uri.slice(0, 4) === 'http';
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/** Remove from the store HTTP authorization metadata
|
|
80
|
+
* The editble function below relies on copies we have in the store
|
|
81
|
+
* of the results of previous HTTP transactions. Howver, when
|
|
82
|
+
* the user logs in, then that data misrepresents what would happen
|
|
83
|
+
* if the user tried again.
|
|
84
|
+
*/
|
|
85
|
+
}, {
|
|
86
|
+
key: "flagAuthorizationMetadata",
|
|
87
|
+
value: function flagAuthorizationMetadata(kb) {
|
|
88
|
+
var _kb$fetcher;
|
|
89
|
+
if (!kb) {
|
|
90
|
+
kb = this.store;
|
|
91
|
+
}
|
|
92
|
+
var meta = (_kb$fetcher = kb.fetcher) === null || _kb$fetcher === void 0 ? void 0 : _kb$fetcher.appNode;
|
|
93
|
+
var requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), undefined, meta).map(function (st) {
|
|
94
|
+
return st.subject;
|
|
95
|
+
});
|
|
96
|
+
var _iterator = _createForOfIteratorHelper(requests),
|
|
97
|
+
_step;
|
|
98
|
+
try {
|
|
99
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
100
|
+
var request = _step.value;
|
|
101
|
+
var _response = kb.any(request, this.ns.link('response'), null, meta);
|
|
102
|
+
if (_response !== undefined) {
|
|
103
|
+
// ts
|
|
104
|
+
kb.add(_response, this.ns.link('outOfDate'), true, meta); // @@ Boolean is fine - fix types
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
} catch (err) {
|
|
108
|
+
_iterator.e(err);
|
|
109
|
+
} finally {
|
|
110
|
+
_iterator.f();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
79
114
|
/**
|
|
80
115
|
* Tests whether a file is editable.
|
|
81
116
|
* If the file has a specific annotation that it is machine written,
|
|
82
117
|
* for safety, it is editable (this doesn't actually check for write access)
|
|
83
118
|
* If the file has wac-allow and accept patch headers, those are respected.
|
|
84
119
|
* and local write access is determined by those headers.
|
|
85
|
-
* This version only looks at past HTTP requests,
|
|
120
|
+
* This async version not only looks at past HTTP requests, it also makes new ones if necessary.
|
|
121
|
+
*
|
|
122
|
+
* @returns The method string SPARQL or DAV or
|
|
123
|
+
* LOCALFILE or false if known, undefined if not known.
|
|
124
|
+
*/
|
|
125
|
+
}, {
|
|
126
|
+
key: "checkEditable",
|
|
127
|
+
value: function () {
|
|
128
|
+
var _checkEditable = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(uri, kb) {
|
|
129
|
+
var _kb$fetcher2;
|
|
130
|
+
var initial, final;
|
|
131
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
132
|
+
while (1) switch (_context.prev = _context.next) {
|
|
133
|
+
case 0:
|
|
134
|
+
if (uri) {
|
|
135
|
+
_context.next = 2;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
return _context.abrupt("return", false);
|
|
139
|
+
case 2:
|
|
140
|
+
if (!kb) {
|
|
141
|
+
kb = this.store;
|
|
142
|
+
}
|
|
143
|
+
initial = this.editable(uri, kb);
|
|
144
|
+
if (!(initial !== undefined)) {
|
|
145
|
+
_context.next = 6;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
return _context.abrupt("return", initial);
|
|
149
|
+
case 6:
|
|
150
|
+
_context.next = 8;
|
|
151
|
+
return (_kb$fetcher2 = kb.fetcher) === null || _kb$fetcher2 === void 0 ? void 0 : _kb$fetcher2.load(uri);
|
|
152
|
+
case 8:
|
|
153
|
+
final = this.editable(uri, kb); // console.log(`Loaded ${uri} just to check editable, result: ${final}.`)
|
|
154
|
+
return _context.abrupt("return", final);
|
|
155
|
+
case 10:
|
|
156
|
+
case "end":
|
|
157
|
+
return _context.stop();
|
|
158
|
+
}
|
|
159
|
+
}, _callee, this);
|
|
160
|
+
}));
|
|
161
|
+
function checkEditable(_x, _x2) {
|
|
162
|
+
return _checkEditable.apply(this, arguments);
|
|
163
|
+
}
|
|
164
|
+
return checkEditable;
|
|
165
|
+
}()
|
|
166
|
+
/**
|
|
167
|
+
* Tests whether a file is editable.
|
|
168
|
+
* If the file has a specific annotation that it is machine written,
|
|
169
|
+
* for safety, it is editable (this doesn't actually check for write access)
|
|
170
|
+
* If the file has wac-allow and accept patch headers, those are respected.
|
|
171
|
+
* and local write access is determined by those headers.
|
|
172
|
+
* This synchronous version only looks at past HTTP requests, does not make new ones.
|
|
86
173
|
*
|
|
87
174
|
* @returns The method string SPARQL or DAV or
|
|
88
175
|
* LOCALFILE or false if known, undefined if not known.
|
|
@@ -90,6 +177,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
90
177
|
}, {
|
|
91
178
|
key: "editable",
|
|
92
179
|
value: function editable(uri, kb) {
|
|
180
|
+
var _kb$fetcher3;
|
|
93
181
|
if (!uri) {
|
|
94
182
|
return false; // Eg subject is bnode, no known doc to write to
|
|
95
183
|
}
|
|
@@ -99,27 +187,34 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
99
187
|
}
|
|
100
188
|
uri = termValue(uri);
|
|
101
189
|
if (!this.isHttpUri(uri)) {
|
|
102
|
-
if (kb.holds(
|
|
190
|
+
if (kb.holds(kb.rdfFactory.namedNode(uri), kb.rdfFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), kb.rdfFactory.namedNode('http://www.w3.org/2007/ont/link#MachineEditableDocument'))) {
|
|
103
191
|
return 'LOCALFILE';
|
|
104
192
|
}
|
|
105
193
|
}
|
|
106
194
|
var request;
|
|
107
195
|
var definitive = false;
|
|
196
|
+
var meta = (_kb$fetcher3 = kb.fetcher) === null || _kb$fetcher3 === void 0 ? void 0 : _kb$fetcher3.appNode;
|
|
197
|
+
// const kb = s
|
|
198
|
+
|
|
108
199
|
// @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));
|
|
200
|
+
var requests = kb.each(undefined, this.ns.link('requestedURI'), docpart(uri), meta);
|
|
110
201
|
var method;
|
|
111
202
|
for (var r = 0; r < requests.length; r++) {
|
|
112
203
|
request = requests[r];
|
|
113
204
|
if (request !== undefined) {
|
|
114
|
-
var
|
|
115
|
-
if (
|
|
116
|
-
|
|
205
|
+
var _response2 = kb.any(request, this.ns.link('response'), null, meta);
|
|
206
|
+
if (_response2 !== undefined) {
|
|
207
|
+
// ts
|
|
208
|
+
|
|
209
|
+
var outOfDate = kb.anyJS(_response2, this.ns.link('outOfDate'), null, meta);
|
|
210
|
+
if (outOfDate) continue;
|
|
211
|
+
var wacAllow = kb.anyValue(_response2, this.ns.httph('wac-allow'));
|
|
117
212
|
if (wacAllow) {
|
|
118
|
-
var
|
|
119
|
-
|
|
213
|
+
var _iterator2 = _createForOfIteratorHelper(wacAllow.split(',')),
|
|
214
|
+
_step2;
|
|
120
215
|
try {
|
|
121
|
-
for (
|
|
122
|
-
var bit =
|
|
216
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
217
|
+
var bit = _step2.value;
|
|
123
218
|
var lr = bit.split('=');
|
|
124
219
|
if (lr[0].includes('user') && !lr[1].includes('write') && !lr[1].includes('append')) {
|
|
125
220
|
// console.log(' editable? excluded by WAC-Allow: ', wacAllow)
|
|
@@ -127,12 +222,12 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
127
222
|
}
|
|
128
223
|
}
|
|
129
224
|
} catch (err) {
|
|
130
|
-
|
|
225
|
+
_iterator2.e(err);
|
|
131
226
|
} finally {
|
|
132
|
-
|
|
227
|
+
_iterator2.f();
|
|
133
228
|
}
|
|
134
229
|
}
|
|
135
|
-
var acceptPatch = kb.each(
|
|
230
|
+
var acceptPatch = kb.each(_response2, this.ns.httph('accept-patch'));
|
|
136
231
|
if (acceptPatch.length) {
|
|
137
232
|
for (var i = 0; i < acceptPatch.length; i++) {
|
|
138
233
|
method = acceptPatch[i].value.trim();
|
|
@@ -140,7 +235,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
140
235
|
if (method.indexOf('application/sparql-update-single-match') >= 0) return 'SPARQL';
|
|
141
236
|
}
|
|
142
237
|
}
|
|
143
|
-
var authorVia = kb.each(
|
|
238
|
+
var authorVia = kb.each(_response2, this.ns.httph('ms-author-via'));
|
|
144
239
|
if (authorVia.length) {
|
|
145
240
|
for (var _i = 0; _i < authorVia.length; _i++) {
|
|
146
241
|
method = authorVia[_i].value.trim();
|
|
@@ -155,7 +250,7 @@ var UpdateManager = /*#__PURE__*/function () {
|
|
|
155
250
|
if (!this.isHttpUri(uri)) {
|
|
156
251
|
if (!wacAllow) return false;else return 'LOCALFILE';
|
|
157
252
|
}
|
|
158
|
-
var status = kb.each(
|
|
253
|
+
var status = kb.each(_response2, this.ns.http('status'));
|
|
159
254
|
if (status.length) {
|
|
160
255
|
for (var _i2 = 0; _i2 < status.length; _i2++) {
|
|
161
256
|
// @ts-ignore since statuses should be TFTerms, this should always be false
|
package/esm/utils.js
CHANGED
package/esm/variable.js
CHANGED
|
@@ -21,10 +21,6 @@ import * as Uri from './uri';
|
|
|
21
21
|
var Variable = /*#__PURE__*/function (_Node) {
|
|
22
22
|
_inherits(Variable, _Node);
|
|
23
23
|
var _super = _createSuper(Variable);
|
|
24
|
-
/** The base string for a variable's name */
|
|
25
|
-
|
|
26
|
-
/** The unique identifier of this variable */
|
|
27
|
-
|
|
28
24
|
/**
|
|
29
25
|
* Initializes this variable
|
|
30
26
|
* @param name The variable's name
|
|
@@ -35,9 +31,11 @@ var Variable = /*#__PURE__*/function (_Node) {
|
|
|
35
31
|
_classCallCheck(this, Variable);
|
|
36
32
|
_this = _super.call(this, name);
|
|
37
33
|
_defineProperty(_assertThisInitialized(_this), "termType", VariableTermType);
|
|
34
|
+
/** The base string for a variable's name */
|
|
38
35
|
_defineProperty(_assertThisInitialized(_this), "base", 'varid:');
|
|
39
36
|
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.Variable);
|
|
40
37
|
_defineProperty(_assertThisInitialized(_this), "isVar", 1);
|
|
38
|
+
/** The unique identifier of this variable */
|
|
41
39
|
_defineProperty(_assertThisInitialized(_this), "uri", void 0);
|
|
42
40
|
_this.base = 'varid:';
|
|
43
41
|
_this.uri = Uri.join(name, _this.base);
|
package/lib/blank-node.js
CHANGED
|
@@ -34,7 +34,13 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
34
34
|
_this = _super.call(this, BlankNode.getId(id));
|
|
35
35
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "termType", _types.BlankNodeTermType);
|
|
36
36
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "classOrder", _classOrder.default.BlankNode);
|
|
37
|
+
/** Whether this is a blank node */
|
|
37
38
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isBlank", 1);
|
|
39
|
+
/**
|
|
40
|
+
* This type of node is a variable.
|
|
41
|
+
*
|
|
42
|
+
* Note that the existence of this property already indicates that it is a variable.
|
|
43
|
+
*/
|
|
38
44
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isVar", 1);
|
|
39
45
|
return _this;
|
|
40
46
|
}
|
|
@@ -92,12 +98,7 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
92
98
|
}
|
|
93
99
|
}], [{
|
|
94
100
|
key: "getId",
|
|
95
|
-
value:
|
|
96
|
-
/**
|
|
97
|
-
* The next unique identifier for blank nodes
|
|
98
|
-
*/
|
|
99
|
-
|
|
100
|
-
function getId(id) {
|
|
101
|
+
value: function getId(id) {
|
|
101
102
|
if (id) {
|
|
102
103
|
if (typeof id !== 'string') {
|
|
103
104
|
throw new Error('Bad id argument to new blank node: ' + id);
|
|
@@ -115,5 +116,8 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
115
116
|
return BlankNode;
|
|
116
117
|
}(_nodeInternal.default);
|
|
117
118
|
exports.default = BlankNode;
|
|
119
|
+
/**
|
|
120
|
+
* The next unique identifier for blank nodes
|
|
121
|
+
*/
|
|
118
122
|
(0, _defineProperty2.default)(BlankNode, "nextId", 0);
|
|
119
123
|
(0, _defineProperty2.default)(BlankNode, "NTAnonymousNodePrefix", '_:');
|
package/lib/collection.js
CHANGED
|
@@ -51,10 +51,6 @@ function fromValue(value) {
|
|
|
51
51
|
var Collection = /*#__PURE__*/function (_Node) {
|
|
52
52
|
(0, _inherits2.default)(Collection, _Node);
|
|
53
53
|
var _super = _createSuper(Collection);
|
|
54
|
-
/**
|
|
55
|
-
* The nodes in this collection
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
54
|
function Collection(initial) {
|
|
59
55
|
var _this;
|
|
60
56
|
(0, _classCallCheck2.default)(this, Collection);
|
|
@@ -63,6 +59,9 @@ var Collection = /*#__PURE__*/function (_Node) {
|
|
|
63
59
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "classOrder", _classOrder.default.Collection);
|
|
64
60
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "closed", false);
|
|
65
61
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "compareTerm", _blankNode.default.prototype.compareTerm);
|
|
62
|
+
/**
|
|
63
|
+
* The nodes in this collection
|
|
64
|
+
*/
|
|
66
65
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "elements", []);
|
|
67
66
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isVar", 0);
|
|
68
67
|
if (initial && initial.length > 0) {
|
|
@@ -5,15 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Feature = void 0;
|
|
7
7
|
/** A set of features that may be supported by a Data Factory */
|
|
8
|
-
var Feature
|
|
9
|
-
/**
|
|
10
|
-
* Defines a DataFactory as used in rdflib, based on the RDF/JS: Data model specification,
|
|
11
|
-
* but with additional extensions
|
|
12
|
-
*
|
|
13
|
-
* bnIndex is optional but useful.
|
|
14
|
-
*/
|
|
15
|
-
exports.Feature = Feature;
|
|
16
|
-
(function (Feature) {
|
|
8
|
+
var Feature = /*#__PURE__*/function (Feature) {
|
|
17
9
|
Feature["collections"] = "COLLECTIONS";
|
|
18
10
|
Feature["defaultGraphType"] = "DEFAULT_GRAPH_TYPE";
|
|
19
11
|
Feature["equalsMethod"] = "EQUALS_METHOD";
|
|
@@ -21,4 +13,12 @@ exports.Feature = Feature;
|
|
|
21
13
|
Feature["identity"] = "IDENTITY";
|
|
22
14
|
Feature["reversibleId"] = "REVERSIBLE_ID";
|
|
23
15
|
Feature["variableType"] = "VARIABLE_TYPE";
|
|
24
|
-
|
|
16
|
+
return Feature;
|
|
17
|
+
}({});
|
|
18
|
+
/**
|
|
19
|
+
* Defines a DataFactory as used in rdflib, based on the RDF/JS: Data model specification,
|
|
20
|
+
* but with additional extensions
|
|
21
|
+
*
|
|
22
|
+
* bnIndex is optional but useful.
|
|
23
|
+
*/
|
|
24
|
+
exports.Feature = Feature;
|
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,8 +32,34 @@ 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
|
-
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; } }
|
|
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; } } /* global $SolidTestEnvironment */ /**
|
|
40
|
+
*
|
|
41
|
+
* Project: rdflib.js
|
|
42
|
+
*
|
|
43
|
+
* @file: fetcher.js
|
|
44
|
+
*
|
|
45
|
+
* Description: contains functions for requesting/fetching/retracting
|
|
46
|
+
* This implements quite a lot of the web architecture.
|
|
47
|
+
* A fetcher is bound to a specific quad store, into which
|
|
48
|
+
* it loads stuff and into which it writes its metadata
|
|
49
|
+
* @@ The metadata could be optionally a separate graph
|
|
50
|
+
*
|
|
51
|
+
* - implements semantics of HTTP headers, Internet Content Types
|
|
52
|
+
* - selects parsers for rdf/xml, n3, rdfa, grddl
|
|
53
|
+
*
|
|
54
|
+
* TO do:
|
|
55
|
+
* - Implement a runtime registry for parsers and serializers
|
|
56
|
+
* -
|
|
57
|
+
*/ /**
|
|
58
|
+
* Things to test: callbacks on request, refresh, retract
|
|
59
|
+
* loading from HTTP, HTTPS, FTP, FILE, others?
|
|
60
|
+
* To do:
|
|
61
|
+
* Firing up a mail client for mid: (message:) URLs
|
|
62
|
+
*/
|
|
37
63
|
var Parsable = {
|
|
38
64
|
'text/n3': true,
|
|
39
65
|
'text/turtle': true,
|
|
@@ -73,14 +99,19 @@ var getNS = function getNS(factory) {
|
|
|
73
99
|
};
|
|
74
100
|
};
|
|
75
101
|
var ns = getNS();
|
|
76
|
-
var Handler = /*#__PURE__*/(0, _createClass2.default)(
|
|
77
|
-
// TODO: Document, type
|
|
78
102
|
|
|
79
|
-
|
|
103
|
+
/** An extended interface of Response, since RDFlib.js adds some properties. */
|
|
80
104
|
|
|
81
|
-
|
|
105
|
+
/** tell typescript that a 'panes' child may exist on Window */
|
|
106
|
+
|
|
107
|
+
/** All valid inputs for initFetchOptions */
|
|
108
|
+
|
|
109
|
+
/** Initiated by initFetchOptions, which runs on load */
|
|
110
|
+
var Handler = /*#__PURE__*/(0, _createClass2.default)(function Handler(response, dom) {
|
|
82
111
|
(0, _classCallCheck2.default)(this, Handler);
|
|
112
|
+
// TODO: Document, type
|
|
83
113
|
(0, _defineProperty2.default)(this, "response", void 0);
|
|
114
|
+
// TODO: Document, type
|
|
84
115
|
(0, _defineProperty2.default)(this, "dom", void 0);
|
|
85
116
|
this.response = response;
|
|
86
117
|
// The type assertion operator here might need to be removed.
|
|
@@ -516,6 +547,10 @@ function isXMLNS(responseText) {
|
|
|
516
547
|
var match = responseText.match(/[^(<html)]*<html\s+[^<]*xmlns=['"]http:\/\/www.w3.org\/1999\/xhtml["'][^<]*>/);
|
|
517
548
|
return !!match;
|
|
518
549
|
}
|
|
550
|
+
|
|
551
|
+
// Not sure about the shapes of this. Response? FetchError?
|
|
552
|
+
|
|
553
|
+
/** Differs from normal Fetch, has an extended Response type */
|
|
519
554
|
/** Fetcher
|
|
520
555
|
*
|
|
521
556
|
* The Fetcher object is a helper object for a quadstore
|
|
@@ -525,34 +560,6 @@ function isXMLNS(responseText) {
|
|
|
525
560
|
* and put back the data to the web.
|
|
526
561
|
*/
|
|
527
562
|
var Fetcher = /*#__PURE__*/function () {
|
|
528
|
-
/** Denoting this session */
|
|
529
|
-
|
|
530
|
-
/**
|
|
531
|
-
* this.requested[uri] states:
|
|
532
|
-
* undefined no record of web access or records reset
|
|
533
|
-
* true has been requested, fetch in progress
|
|
534
|
-
* 'done' received, Ok
|
|
535
|
-
* 401 Not logged in
|
|
536
|
-
* 403 HTTP status unauthorized
|
|
537
|
-
* 404 Resource does not exist. Can be created etc.
|
|
538
|
-
* 'redirected' In attempt to counter CORS problems retried.
|
|
539
|
-
* 'parse_error' Parse error
|
|
540
|
-
* 'unsupported_protocol' URI is not a protocol Fetcher can deal with
|
|
541
|
-
* other strings mean various other errors.
|
|
542
|
-
*/
|
|
543
|
-
|
|
544
|
-
/** List of timeouts associated with a requested URL */
|
|
545
|
-
|
|
546
|
-
/** Redirected from *key uri* to *value uri* */
|
|
547
|
-
|
|
548
|
-
/** fetchCallbacks[uri].push(callback) */
|
|
549
|
-
|
|
550
|
-
/** Keep track of explicit 404s -> we can overwrite etc */
|
|
551
|
-
|
|
552
|
-
// TODO: Document this
|
|
553
|
-
|
|
554
|
-
/** Methods added by calling Util.callbackify in the constructor*/
|
|
555
|
-
|
|
556
563
|
function Fetcher(store) {
|
|
557
564
|
var _this = this;
|
|
558
565
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -561,16 +568,35 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
561
568
|
(0, _defineProperty2.default)(this, "timeout", void 0);
|
|
562
569
|
(0, _defineProperty2.default)(this, "_fetch", void 0);
|
|
563
570
|
(0, _defineProperty2.default)(this, "mediatypes", void 0);
|
|
571
|
+
/** Denoting this session */
|
|
564
572
|
(0, _defineProperty2.default)(this, "appNode", void 0);
|
|
573
|
+
/**
|
|
574
|
+
* this.requested[uri] states:
|
|
575
|
+
* undefined no record of web access or records reset
|
|
576
|
+
* true has been requested, fetch in progress
|
|
577
|
+
* 'done' received, Ok
|
|
578
|
+
* 401 Not logged in
|
|
579
|
+
* 403 HTTP status unauthorized
|
|
580
|
+
* 404 Resource does not exist. Can be created etc.
|
|
581
|
+
* 'redirected' In attempt to counter CORS problems retried.
|
|
582
|
+
* 'parse_error' Parse error
|
|
583
|
+
* 'unsupported_protocol' URI is not a protocol Fetcher can deal with
|
|
584
|
+
* other strings mean various other errors.
|
|
585
|
+
*/
|
|
565
586
|
(0, _defineProperty2.default)(this, "requested", void 0);
|
|
587
|
+
/** List of timeouts associated with a requested URL */
|
|
566
588
|
(0, _defineProperty2.default)(this, "timeouts", void 0);
|
|
589
|
+
/** Redirected from *key uri* to *value uri* */
|
|
567
590
|
(0, _defineProperty2.default)(this, "redirectedTo", void 0);
|
|
568
591
|
(0, _defineProperty2.default)(this, "fetchQueue", void 0);
|
|
592
|
+
/** fetchCallbacks[uri].push(callback) */
|
|
569
593
|
(0, _defineProperty2.default)(this, "fetchCallbacks", void 0);
|
|
594
|
+
/** Keep track of explicit 404s -> we can overwrite etc */
|
|
570
595
|
(0, _defineProperty2.default)(this, "nonexistent", void 0);
|
|
571
596
|
(0, _defineProperty2.default)(this, "lookedUp", void 0);
|
|
572
597
|
(0, _defineProperty2.default)(this, "handlers", void 0);
|
|
573
598
|
(0, _defineProperty2.default)(this, "ns", void 0);
|
|
599
|
+
/** Methods added by calling Util.callbackify in the constructor*/
|
|
574
600
|
(0, _defineProperty2.default)(this, "fireCallbacks", void 0);
|
|
575
601
|
this.store = store || new _store.default();
|
|
576
602
|
this.ns = getNS(this.store.rdfFactory);
|
|
@@ -581,7 +607,9 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
581
607
|
if (!this._fetch) {
|
|
582
608
|
throw new Error('No _fetch function available for Fetcher');
|
|
583
609
|
}
|
|
584
|
-
|
|
610
|
+
// This is the name of the graph we store all the HTTP metadata in
|
|
611
|
+
this.appNode = this.store.sym('chrome://TheCurrentSession');
|
|
612
|
+
// this.appNode = this.store.rdfFactory.blankNode() // Needs to have a URI in tests
|
|
585
613
|
this.store.fetcher = this; // Bi-linked
|
|
586
614
|
this.requested = {};
|
|
587
615
|
this.timeouts = {};
|
|
@@ -669,6 +697,31 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
669
697
|
var docuri = (0, _termValue.termValue)(uriIn);
|
|
670
698
|
docuri = docuri.split('#')[0];
|
|
671
699
|
options = this.initFetchOptions(docuri, options);
|
|
700
|
+
// if metadata flaged clear cache and removeDocument
|
|
701
|
+
var meta = this.appNode;
|
|
702
|
+
var kb = this.store;
|
|
703
|
+
var requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), kb.sym(docuri), meta).map(function (st) {
|
|
704
|
+
return st.subject;
|
|
705
|
+
});
|
|
706
|
+
var _iterator = _createForOfIteratorHelper(requests),
|
|
707
|
+
_step;
|
|
708
|
+
try {
|
|
709
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
710
|
+
var request = _step.value;
|
|
711
|
+
var _response = kb.any(request, this.ns.link('response'), null, meta);
|
|
712
|
+
if (_response !== undefined) {
|
|
713
|
+
// ts
|
|
714
|
+
var quad = kb.statementsMatching(_response, this.ns.link('outOfDate'), true, meta);
|
|
715
|
+
kb.remove(quad);
|
|
716
|
+
options.force = true;
|
|
717
|
+
options.clearPreviousData = true;
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
} catch (err) {
|
|
721
|
+
_iterator.e(err);
|
|
722
|
+
} finally {
|
|
723
|
+
_iterator.f();
|
|
724
|
+
}
|
|
672
725
|
var initialisedOptions = this.initFetchOptions(docuri, options);
|
|
673
726
|
return this.pendingFetchPromise(docuri, initialisedOptions.baseURI, initialisedOptions);
|
|
674
727
|
}
|
|
@@ -1371,10 +1424,10 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1371
1424
|
for (var r = 0; r < requests.length; r++) {
|
|
1372
1425
|
var request = requests[r];
|
|
1373
1426
|
if (request !== undefined) {
|
|
1374
|
-
var
|
|
1375
|
-
if (
|
|
1427
|
+
var _response2 = kb.any(request, this.ns.link('response'));
|
|
1428
|
+
if (_response2 !== undefined && kb.anyValue(_response2, this.ns.http('status')) && kb.anyValue(_response2, this.ns.http('status')).startsWith('2')) {
|
|
1376
1429
|
// Only look at success returns - not 401 error messagess etc
|
|
1377
|
-
var results = kb.each(
|
|
1430
|
+
var results = kb.each(_response2, this.ns.httph(header.toLowerCase()));
|
|
1378
1431
|
if (results.length) {
|
|
1379
1432
|
return results.map(function (v) {
|
|
1380
1433
|
return v.value;
|
|
@@ -1413,17 +1466,19 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1413
1466
|
var _this10 = this;
|
|
1414
1467
|
var kb = this.store;
|
|
1415
1468
|
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),
|
|
1469
|
+
kb.add(options.req, this.ns.link('response'), responseNode, this.appNode);
|
|
1470
|
+
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status), this.appNode);
|
|
1471
|
+
kb.add(responseNode, this.ns.http('statusText'), kb.rdfFactory.literal(response.statusText), this.appNode);
|
|
1419
1472
|
|
|
1420
1473
|
// Save the response headers
|
|
1421
1474
|
response.headers.forEach(function (value, header) {
|
|
1422
|
-
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value),
|
|
1475
|
+
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value), _this10.appNode);
|
|
1423
1476
|
if (header === 'content-type') {
|
|
1424
|
-
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), responseNode
|
|
1477
|
+
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), _this10.appNode // responseNode
|
|
1478
|
+
);
|
|
1425
1479
|
}
|
|
1426
1480
|
});
|
|
1481
|
+
|
|
1427
1482
|
return responseNode;
|
|
1428
1483
|
}
|
|
1429
1484
|
}, {
|
|
@@ -1935,6 +1990,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1935
1990
|
exports.default = Fetcher;
|
|
1936
1991
|
(0, _defineProperty2.default)(Fetcher, "HANDLERS", void 0);
|
|
1937
1992
|
(0, _defineProperty2.default)(Fetcher, "CONTENT_TYPE_BY_EXT", void 0);
|
|
1993
|
+
// TODO: Document this
|
|
1938
1994
|
(0, _defineProperty2.default)(Fetcher, "crossSiteProxyTemplate", void 0);
|
|
1939
1995
|
Fetcher.HANDLERS = defaultHandlers;
|
|
1940
1996
|
Fetcher.CONTENT_TYPE_BY_EXT = CONTENT_TYPE_BY_EXT;
|
package/lib/formula.js
CHANGED
|
@@ -35,19 +35,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
35
35
|
var Formula = /*#__PURE__*/function (_Node) {
|
|
36
36
|
(0, _inherits2.default)(Formula, _Node);
|
|
37
37
|
var _super = _createSuper(Formula);
|
|
38
|
-
/**
|
|
39
|
-
* The accompanying fetcher instance.
|
|
40
|
-
*
|
|
41
|
-
* Is set by the fetcher when initialized.
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* A namespace for the specified namespace's URI
|
|
46
|
-
* @param nsuri The URI for the namespace
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
/** The factory used to generate statements and terms */
|
|
50
|
-
|
|
51
38
|
/**
|
|
52
39
|
* Initializes this formula
|
|
53
40
|
* @constructor
|
|
@@ -73,9 +60,19 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
73
60
|
_this.optional = optional;
|
|
74
61
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "termType", _types.GraphTermType);
|
|
75
62
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "classOrder", _classOrder.default.Graph);
|
|
63
|
+
/**
|
|
64
|
+
* The accompanying fetcher instance.
|
|
65
|
+
*
|
|
66
|
+
* Is set by the fetcher when initialized.
|
|
67
|
+
*/
|
|
76
68
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fetcher", void 0);
|
|
77
69
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isVar", 0);
|
|
70
|
+
/**
|
|
71
|
+
* A namespace for the specified namespace's URI
|
|
72
|
+
* @param nsuri The URI for the namespace
|
|
73
|
+
*/
|
|
78
74
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "ns", _namespace.default);
|
|
75
|
+
/** The factory used to generate statements and terms */
|
|
79
76
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "rdfFactory", void 0);
|
|
80
77
|
_this.rdfFactory = opts && opts.rdfFactory || _canonicalDataFactory.default;
|
|
81
78
|
// Enable default factory methods on this while preserving factory context.
|
package/lib/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ import Variable from './variable';
|
|
|
30
30
|
import DataFactory from './factories/rdflib-data-factory';
|
|
31
31
|
declare const fetcher: (store: Store, options: any) => Fetcher, graph: (features?: any, opts?: any) => Store, lit: (val: string, lang?: string | undefined, dt?: import("./tf-types").NamedNode | undefined) => Literal, st: (subject: import("./tf-types").Quad_Subject, predicate: import("./tf-types").Quad_Predicate, object: import("./tf-types").Quad_Object, graph?: import("./tf-types").Quad_Graph | undefined) => Statement<import("./types").SubjectType, import("./types").PredicateType, import("./types").ObjectType, import("./types").GraphType>, namedNode: (value: string) => NamedNode, variable: (value: string) => Variable, blankNode: (value?: string | undefined) => BlankNode, defaultGraph: () => import("./default-graph").default, literal: (value: string, languageOrDatatype?: string | import("./tf-types").NamedNode | undefined) => Literal, quad: (subject: import("./tf-types").Term, predicate: import("./tf-types").Term, object: import("./tf-types").Term, graph?: import("./tf-types").Term | undefined) => Statement<import("./types").SubjectType, import("./types").PredicateType, import("./types").ObjectType, import("./types").GraphType>, triple: (subject: import("./tf-types").Term, predicate: import("./tf-types").Term, object: import("./tf-types").Term, graph?: import("./tf-types").Term | undefined) => import("./tf-types").Quad<any, any, any, any>;
|
|
32
32
|
declare const fromNT: (str: any) => any;
|
|
33
|
-
declare const term: <T extends import("./types").FromValueReturns
|
|
33
|
+
declare const term: <T extends import("./types").FromValueReturns>(value: import("./types").ValueType) => T;
|
|
34
34
|
declare const NextId: number;
|
|
35
35
|
export * from './utils/terms';
|
|
36
36
|
export type { AutoInitOptions, ExtendedResponse, FetchError } from './fetcher';
|