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/blank-node.js
CHANGED
|
@@ -27,7 +27,13 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
27
27
|
_this = _super.call(this, BlankNode.getId(id));
|
|
28
28
|
_defineProperty(_assertThisInitialized(_this), "termType", BlankNodeTermType);
|
|
29
29
|
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.BlankNode);
|
|
30
|
+
/** Whether this is a blank node */
|
|
30
31
|
_defineProperty(_assertThisInitialized(_this), "isBlank", 1);
|
|
32
|
+
/**
|
|
33
|
+
* This type of node is a variable.
|
|
34
|
+
*
|
|
35
|
+
* Note that the existence of this property already indicates that it is a variable.
|
|
36
|
+
*/
|
|
31
37
|
_defineProperty(_assertThisInitialized(_this), "isVar", 1);
|
|
32
38
|
return _this;
|
|
33
39
|
}
|
|
@@ -85,12 +91,7 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
85
91
|
}
|
|
86
92
|
}], [{
|
|
87
93
|
key: "getId",
|
|
88
|
-
value:
|
|
89
|
-
/**
|
|
90
|
-
* The next unique identifier for blank nodes
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
|
-
function getId(id) {
|
|
94
|
+
value: function getId(id) {
|
|
94
95
|
if (id) {
|
|
95
96
|
if (typeof id !== 'string') {
|
|
96
97
|
throw new Error('Bad id argument to new blank node: ' + id);
|
|
@@ -107,6 +108,9 @@ var BlankNode = /*#__PURE__*/function (_Node) {
|
|
|
107
108
|
}]);
|
|
108
109
|
return BlankNode;
|
|
109
110
|
}(Node);
|
|
111
|
+
/**
|
|
112
|
+
* The next unique identifier for blank nodes
|
|
113
|
+
*/
|
|
110
114
|
_defineProperty(BlankNode, "nextId", 0);
|
|
111
115
|
_defineProperty(BlankNode, "NTAnonymousNodePrefix", '_:');
|
|
112
116
|
export { BlankNode as default };
|
package/esm/collection.js
CHANGED
|
@@ -43,10 +43,6 @@ export function fromValue(value) {
|
|
|
43
43
|
var Collection = /*#__PURE__*/function (_Node) {
|
|
44
44
|
_inherits(Collection, _Node);
|
|
45
45
|
var _super = _createSuper(Collection);
|
|
46
|
-
/**
|
|
47
|
-
* The nodes in this collection
|
|
48
|
-
*/
|
|
49
|
-
|
|
50
46
|
function Collection(initial) {
|
|
51
47
|
var _this;
|
|
52
48
|
_classCallCheck(this, Collection);
|
|
@@ -55,6 +51,9 @@ var Collection = /*#__PURE__*/function (_Node) {
|
|
|
55
51
|
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.Collection);
|
|
56
52
|
_defineProperty(_assertThisInitialized(_this), "closed", false);
|
|
57
53
|
_defineProperty(_assertThisInitialized(_this), "compareTerm", RdflibBlankNode.prototype.compareTerm);
|
|
54
|
+
/**
|
|
55
|
+
* The nodes in this collection
|
|
56
|
+
*/
|
|
58
57
|
_defineProperty(_assertThisInitialized(_this), "elements", []);
|
|
59
58
|
_defineProperty(_assertThisInitialized(_this), "isVar", 0);
|
|
60
59
|
if (initial && initial.length > 0) {
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
/** A set of features that may be supported by a Data Factory */
|
|
2
2
|
|
|
3
|
-
export var Feature
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Defines a DataFactory as used in rdflib, based on the RDF/JS: Data model specification,
|
|
7
|
-
* but with additional extensions
|
|
8
|
-
*
|
|
9
|
-
* bnIndex is optional but useful.
|
|
10
|
-
*/
|
|
11
|
-
(function (Feature) {
|
|
3
|
+
export var Feature = /*#__PURE__*/function (Feature) {
|
|
12
4
|
Feature["collections"] = "COLLECTIONS";
|
|
13
5
|
Feature["defaultGraphType"] = "DEFAULT_GRAPH_TYPE";
|
|
14
6
|
Feature["equalsMethod"] = "EQUALS_METHOD";
|
|
@@ -16,4 +8,12 @@ export var Feature;
|
|
|
16
8
|
Feature["identity"] = "IDENTITY";
|
|
17
9
|
Feature["reversibleId"] = "REVERSIBLE_ID";
|
|
18
10
|
Feature["variableType"] = "VARIABLE_TYPE";
|
|
19
|
-
|
|
11
|
+
return Feature;
|
|
12
|
+
}({});
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Defines a DataFactory as used in rdflib, based on the RDF/JS: Data model specification,
|
|
16
|
+
* but with additional extensions
|
|
17
|
+
*
|
|
18
|
+
* bnIndex is optional but useful.
|
|
19
|
+
*/
|
package/esm/fetcher.js
CHANGED
|
@@ -6,6 +6,9 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
6
6
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
8
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
10
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
12
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
13
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
11
14
|
/* global $SolidTestEnvironment */
|
|
@@ -90,14 +93,19 @@ var getNS = function getNS(factory) {
|
|
|
90
93
|
};
|
|
91
94
|
};
|
|
92
95
|
var ns = getNS();
|
|
93
|
-
var Handler = /*#__PURE__*/_createClass(
|
|
94
|
-
// TODO: Document, type
|
|
95
96
|
|
|
96
|
-
|
|
97
|
+
/** An extended interface of Response, since RDFlib.js adds some properties. */
|
|
97
98
|
|
|
98
|
-
|
|
99
|
+
/** tell typescript that a 'panes' child may exist on Window */
|
|
100
|
+
|
|
101
|
+
/** All valid inputs for initFetchOptions */
|
|
102
|
+
|
|
103
|
+
/** Initiated by initFetchOptions, which runs on load */
|
|
104
|
+
var Handler = /*#__PURE__*/_createClass(function Handler(response, dom) {
|
|
99
105
|
_classCallCheck(this, Handler);
|
|
106
|
+
// TODO: Document, type
|
|
100
107
|
_defineProperty(this, "response", void 0);
|
|
108
|
+
// TODO: Document, type
|
|
101
109
|
_defineProperty(this, "dom", void 0);
|
|
102
110
|
this.response = response;
|
|
103
111
|
// The type assertion operator here might need to be removed.
|
|
@@ -533,6 +541,10 @@ function isXMLNS(responseText) {
|
|
|
533
541
|
var match = responseText.match(/[^(<html)]*<html\s+[^<]*xmlns=['"]http:\/\/www.w3.org\/1999\/xhtml["'][^<]*>/);
|
|
534
542
|
return !!match;
|
|
535
543
|
}
|
|
544
|
+
|
|
545
|
+
// Not sure about the shapes of this. Response? FetchError?
|
|
546
|
+
|
|
547
|
+
/** Differs from normal Fetch, has an extended Response type */
|
|
536
548
|
/** Fetcher
|
|
537
549
|
*
|
|
538
550
|
* The Fetcher object is a helper object for a quadstore
|
|
@@ -542,34 +554,6 @@ function isXMLNS(responseText) {
|
|
|
542
554
|
* and put back the data to the web.
|
|
543
555
|
*/
|
|
544
556
|
var Fetcher = /*#__PURE__*/function () {
|
|
545
|
-
/** Denoting this session */
|
|
546
|
-
|
|
547
|
-
/**
|
|
548
|
-
* this.requested[uri] states:
|
|
549
|
-
* undefined no record of web access or records reset
|
|
550
|
-
* true has been requested, fetch in progress
|
|
551
|
-
* 'done' received, Ok
|
|
552
|
-
* 401 Not logged in
|
|
553
|
-
* 403 HTTP status unauthorized
|
|
554
|
-
* 404 Resource does not exist. Can be created etc.
|
|
555
|
-
* 'redirected' In attempt to counter CORS problems retried.
|
|
556
|
-
* 'parse_error' Parse error
|
|
557
|
-
* 'unsupported_protocol' URI is not a protocol Fetcher can deal with
|
|
558
|
-
* other strings mean various other errors.
|
|
559
|
-
*/
|
|
560
|
-
|
|
561
|
-
/** List of timeouts associated with a requested URL */
|
|
562
|
-
|
|
563
|
-
/** Redirected from *key uri* to *value uri* */
|
|
564
|
-
|
|
565
|
-
/** fetchCallbacks[uri].push(callback) */
|
|
566
|
-
|
|
567
|
-
/** Keep track of explicit 404s -> we can overwrite etc */
|
|
568
|
-
|
|
569
|
-
// TODO: Document this
|
|
570
|
-
|
|
571
|
-
/** Methods added by calling Util.callbackify in the constructor*/
|
|
572
|
-
|
|
573
557
|
function Fetcher(store) {
|
|
574
558
|
var _this = this;
|
|
575
559
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -578,16 +562,35 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
578
562
|
_defineProperty(this, "timeout", void 0);
|
|
579
563
|
_defineProperty(this, "_fetch", void 0);
|
|
580
564
|
_defineProperty(this, "mediatypes", void 0);
|
|
565
|
+
/** Denoting this session */
|
|
581
566
|
_defineProperty(this, "appNode", void 0);
|
|
567
|
+
/**
|
|
568
|
+
* this.requested[uri] states:
|
|
569
|
+
* undefined no record of web access or records reset
|
|
570
|
+
* true has been requested, fetch in progress
|
|
571
|
+
* 'done' received, Ok
|
|
572
|
+
* 401 Not logged in
|
|
573
|
+
* 403 HTTP status unauthorized
|
|
574
|
+
* 404 Resource does not exist. Can be created etc.
|
|
575
|
+
* 'redirected' In attempt to counter CORS problems retried.
|
|
576
|
+
* 'parse_error' Parse error
|
|
577
|
+
* 'unsupported_protocol' URI is not a protocol Fetcher can deal with
|
|
578
|
+
* other strings mean various other errors.
|
|
579
|
+
*/
|
|
582
580
|
_defineProperty(this, "requested", void 0);
|
|
581
|
+
/** List of timeouts associated with a requested URL */
|
|
583
582
|
_defineProperty(this, "timeouts", void 0);
|
|
583
|
+
/** Redirected from *key uri* to *value uri* */
|
|
584
584
|
_defineProperty(this, "redirectedTo", void 0);
|
|
585
585
|
_defineProperty(this, "fetchQueue", void 0);
|
|
586
|
+
/** fetchCallbacks[uri].push(callback) */
|
|
586
587
|
_defineProperty(this, "fetchCallbacks", void 0);
|
|
588
|
+
/** Keep track of explicit 404s -> we can overwrite etc */
|
|
587
589
|
_defineProperty(this, "nonexistent", void 0);
|
|
588
590
|
_defineProperty(this, "lookedUp", void 0);
|
|
589
591
|
_defineProperty(this, "handlers", void 0);
|
|
590
592
|
_defineProperty(this, "ns", void 0);
|
|
593
|
+
/** Methods added by calling Util.callbackify in the constructor*/
|
|
591
594
|
_defineProperty(this, "fireCallbacks", void 0);
|
|
592
595
|
this.store = store || new IndexedFormula();
|
|
593
596
|
this.ns = getNS(this.store.rdfFactory);
|
|
@@ -598,7 +601,9 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
598
601
|
if (!this._fetch) {
|
|
599
602
|
throw new Error('No _fetch function available for Fetcher');
|
|
600
603
|
}
|
|
601
|
-
|
|
604
|
+
// This is the name of the graph we store all the HTTP metadata in
|
|
605
|
+
this.appNode = this.store.sym('chrome://TheCurrentSession');
|
|
606
|
+
// this.appNode = this.store.rdfFactory.blankNode() // Needs to have a URI in tests
|
|
602
607
|
this.store.fetcher = this; // Bi-linked
|
|
603
608
|
this.requested = {};
|
|
604
609
|
this.timeouts = {};
|
|
@@ -686,6 +691,31 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
686
691
|
var docuri = termValue(uriIn);
|
|
687
692
|
docuri = docuri.split('#')[0];
|
|
688
693
|
options = this.initFetchOptions(docuri, options);
|
|
694
|
+
// if metadata flaged clear cache and removeDocument
|
|
695
|
+
var meta = this.appNode;
|
|
696
|
+
var kb = this.store;
|
|
697
|
+
var requests = kb.statementsMatching(undefined, this.ns.link('requestedURI'), kb.sym(docuri), meta).map(function (st) {
|
|
698
|
+
return st.subject;
|
|
699
|
+
});
|
|
700
|
+
var _iterator = _createForOfIteratorHelper(requests),
|
|
701
|
+
_step;
|
|
702
|
+
try {
|
|
703
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
704
|
+
var request = _step.value;
|
|
705
|
+
var _response = kb.any(request, this.ns.link('response'), null, meta);
|
|
706
|
+
if (_response !== undefined) {
|
|
707
|
+
// ts
|
|
708
|
+
var quad = kb.statementsMatching(_response, this.ns.link('outOfDate'), true, meta);
|
|
709
|
+
kb.remove(quad);
|
|
710
|
+
options.force = true;
|
|
711
|
+
options.clearPreviousData = true;
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
} catch (err) {
|
|
715
|
+
_iterator.e(err);
|
|
716
|
+
} finally {
|
|
717
|
+
_iterator.f();
|
|
718
|
+
}
|
|
689
719
|
var initialisedOptions = this.initFetchOptions(docuri, options);
|
|
690
720
|
return this.pendingFetchPromise(docuri, initialisedOptions.baseURI, initialisedOptions);
|
|
691
721
|
}
|
|
@@ -1388,10 +1418,10 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1388
1418
|
for (var r = 0; r < requests.length; r++) {
|
|
1389
1419
|
var request = requests[r];
|
|
1390
1420
|
if (request !== undefined) {
|
|
1391
|
-
var
|
|
1392
|
-
if (
|
|
1421
|
+
var _response2 = kb.any(request, this.ns.link('response'));
|
|
1422
|
+
if (_response2 !== undefined && kb.anyValue(_response2, this.ns.http('status')) && kb.anyValue(_response2, this.ns.http('status')).startsWith('2')) {
|
|
1393
1423
|
// Only look at success returns - not 401 error messagess etc
|
|
1394
|
-
var results = kb.each(
|
|
1424
|
+
var results = kb.each(_response2, this.ns.httph(header.toLowerCase()));
|
|
1395
1425
|
if (results.length) {
|
|
1396
1426
|
return results.map(function (v) {
|
|
1397
1427
|
return v.value;
|
|
@@ -1430,17 +1460,19 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1430
1460
|
var _this10 = this;
|
|
1431
1461
|
var kb = this.store;
|
|
1432
1462
|
var responseNode = kb.bnode();
|
|
1433
|
-
kb.add(options.req, this.ns.link('response'), responseNode,
|
|
1434
|
-
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status),
|
|
1435
|
-
kb.add(responseNode, this.ns.http('statusText'), kb.rdfFactory.literal(response.statusText),
|
|
1463
|
+
kb.add(options.req, this.ns.link('response'), responseNode, this.appNode);
|
|
1464
|
+
kb.add(responseNode, this.ns.http('status'), kb.rdfFactory.literal(response.status), this.appNode);
|
|
1465
|
+
kb.add(responseNode, this.ns.http('statusText'), kb.rdfFactory.literal(response.statusText), this.appNode);
|
|
1436
1466
|
|
|
1437
1467
|
// Save the response headers
|
|
1438
1468
|
response.headers.forEach(function (value, header) {
|
|
1439
|
-
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value),
|
|
1469
|
+
kb.add(responseNode, _this10.ns.httph(header), _this10.store.rdfFactory.literal(value), _this10.appNode);
|
|
1440
1470
|
if (header === 'content-type') {
|
|
1441
|
-
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), responseNode
|
|
1471
|
+
kb.add(options.resource, _this10.ns.rdf('type'), kb.rdfFactory.namedNode(Util.mediaTypeClass(value).value), _this10.appNode // responseNode
|
|
1472
|
+
);
|
|
1442
1473
|
}
|
|
1443
1474
|
});
|
|
1475
|
+
|
|
1444
1476
|
return responseNode;
|
|
1445
1477
|
}
|
|
1446
1478
|
}, {
|
|
@@ -1951,6 +1983,7 @@ var Fetcher = /*#__PURE__*/function () {
|
|
|
1951
1983
|
}();
|
|
1952
1984
|
_defineProperty(Fetcher, "HANDLERS", void 0);
|
|
1953
1985
|
_defineProperty(Fetcher, "CONTENT_TYPE_BY_EXT", void 0);
|
|
1986
|
+
// TODO: Document this
|
|
1954
1987
|
_defineProperty(Fetcher, "crossSiteProxyTemplate", void 0);
|
|
1955
1988
|
export { Fetcher as default };
|
|
1956
1989
|
Fetcher.HANDLERS = defaultHandlers;
|
package/esm/formula.js
CHANGED
|
@@ -28,19 +28,6 @@ import NamedNode from './named-node';
|
|
|
28
28
|
var Formula = /*#__PURE__*/function (_Node) {
|
|
29
29
|
_inherits(Formula, _Node);
|
|
30
30
|
var _super = _createSuper(Formula);
|
|
31
|
-
/**
|
|
32
|
-
* The accompanying fetcher instance.
|
|
33
|
-
*
|
|
34
|
-
* Is set by the fetcher when initialized.
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A namespace for the specified namespace's URI
|
|
39
|
-
* @param nsuri The URI for the namespace
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
/** The factory used to generate statements and terms */
|
|
43
|
-
|
|
44
31
|
/**
|
|
45
32
|
* Initializes this formula
|
|
46
33
|
* @constructor
|
|
@@ -66,9 +53,19 @@ var Formula = /*#__PURE__*/function (_Node) {
|
|
|
66
53
|
_this.optional = optional;
|
|
67
54
|
_defineProperty(_assertThisInitialized(_this), "termType", GraphTermType);
|
|
68
55
|
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.Graph);
|
|
56
|
+
/**
|
|
57
|
+
* The accompanying fetcher instance.
|
|
58
|
+
*
|
|
59
|
+
* Is set by the fetcher when initialized.
|
|
60
|
+
*/
|
|
69
61
|
_defineProperty(_assertThisInitialized(_this), "fetcher", void 0);
|
|
70
62
|
_defineProperty(_assertThisInitialized(_this), "isVar", 0);
|
|
63
|
+
/**
|
|
64
|
+
* A namespace for the specified namespace's URI
|
|
65
|
+
* @param nsuri The URI for the namespace
|
|
66
|
+
*/
|
|
71
67
|
_defineProperty(_assertThisInitialized(_this), "ns", Namespace);
|
|
68
|
+
/** The factory used to generate statements and terms */
|
|
72
69
|
_defineProperty(_assertThisInitialized(_this), "rdfFactory", void 0);
|
|
73
70
|
_this.rdfFactory = opts && opts.rdfFactory || CanonicalDataFactory;
|
|
74
71
|
// Enable default factory methods on this while preserving factory context.
|
package/esm/jsonldparser.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import jsonld from 'jsonld';
|
|
2
1
|
import { arrayToStatements } from './utils';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -60,8 +59,10 @@ function listToCollection(kb, obj) {
|
|
|
60
59
|
*/
|
|
61
60
|
export default function jsonldParser(str, kb, base, callback) {
|
|
62
61
|
var baseString = base && Object.prototype.hasOwnProperty.call(base, 'termType') ? base.value : base;
|
|
63
|
-
return jsonld.
|
|
64
|
-
|
|
62
|
+
return import('jsonld').then(function (jsonld) {
|
|
63
|
+
return jsonld.flatten(JSON.parse(str), null, {
|
|
64
|
+
base: baseString
|
|
65
|
+
});
|
|
65
66
|
}).then(function (flattened) {
|
|
66
67
|
return flattened.reduce(function (store, flatResource) {
|
|
67
68
|
kb = processResource(kb, base, flatResource);
|
package/esm/lists.js
CHANGED
|
@@ -13,13 +13,14 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
13
13
|
// import RDFParser from './rdfxmlparser'
|
|
14
14
|
// import sparqlUpdateParser from './patch-parser'
|
|
15
15
|
// import * as Util from './utils-js'
|
|
16
|
-
|
|
17
16
|
// import BlankNode from './blank-node'
|
|
18
17
|
// import NamedNode from './named-node'
|
|
19
18
|
import Collection from './collection';
|
|
20
19
|
import Statement from './statement';
|
|
21
20
|
// import Formula from './formula'
|
|
22
21
|
|
|
22
|
+
// import { ContentType, TurtleContentType, N3ContentType, RDFXMLContentType, XHTMLContentType, HTMLContentType, SPARQLUpdateContentType, SPARQLUpdateSingleMatchContentType, JSONLDContentType, NQuadsContentType, NQuadsAltContentType } from './types'
|
|
23
|
+
// import { Quad } from './tf-types'
|
|
23
24
|
import Namespace from './namespace';
|
|
24
25
|
var RDF = Namespace('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
|
|
25
26
|
|
package/esm/literal.js
CHANGED
|
@@ -21,14 +21,6 @@ import XSD from './xsd-internal';
|
|
|
21
21
|
var Literal = /*#__PURE__*/function (_Node) {
|
|
22
22
|
_inherits(Literal, _Node);
|
|
23
23
|
var _super = _createSuper(Literal);
|
|
24
|
-
/**
|
|
25
|
-
* The literal's datatype as a named node
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The language for the literal
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
24
|
/**
|
|
33
25
|
* Initializes a literal
|
|
34
26
|
* @param value - The literal's lexical value
|
|
@@ -41,8 +33,14 @@ var Literal = /*#__PURE__*/function (_Node) {
|
|
|
41
33
|
_this = _super.call(this, value);
|
|
42
34
|
_defineProperty(_assertThisInitialized(_this), "termType", LiteralTermType);
|
|
43
35
|
_defineProperty(_assertThisInitialized(_this), "classOrder", ClassOrder.Literal);
|
|
36
|
+
/**
|
|
37
|
+
* The literal's datatype as a named node
|
|
38
|
+
*/
|
|
44
39
|
_defineProperty(_assertThisInitialized(_this), "datatype", XSD.string);
|
|
45
40
|
_defineProperty(_assertThisInitialized(_this), "isVar", 0);
|
|
41
|
+
/**
|
|
42
|
+
* The language for the literal
|
|
43
|
+
*/
|
|
46
44
|
_defineProperty(_assertThisInitialized(_this), "language", '');
|
|
47
45
|
if (language) {
|
|
48
46
|
_this.language = language;
|
package/esm/node-internal.js
CHANGED
|
@@ -10,20 +10,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
10
10
|
* @class Node
|
|
11
11
|
*/
|
|
12
12
|
var Node = /*#__PURE__*/function () {
|
|
13
|
-
// Specified in './node.ts' to prevent circular dependency
|
|
14
|
-
|
|
15
|
-
// Specified in './node.ts' to prevent circular dependency
|
|
16
|
-
|
|
17
|
-
/** The type of node */
|
|
18
|
-
|
|
19
|
-
/** The class order for this node */
|
|
20
|
-
|
|
21
|
-
/** The node's value */
|
|
22
|
-
|
|
23
13
|
function Node(value) {
|
|
24
14
|
_classCallCheck(this, Node);
|
|
15
|
+
/** The type of node */
|
|
25
16
|
_defineProperty(this, "termType", void 0);
|
|
17
|
+
/** The class order for this node */
|
|
26
18
|
_defineProperty(this, "classOrder", void 0);
|
|
19
|
+
/** The node's value */
|
|
27
20
|
_defineProperty(this, "value", void 0);
|
|
28
21
|
this.value = value;
|
|
29
22
|
}
|
|
@@ -132,6 +125,8 @@ var Node = /*#__PURE__*/function () {
|
|
|
132
125
|
}]);
|
|
133
126
|
return Node;
|
|
134
127
|
}();
|
|
128
|
+
// Specified in './node.ts' to prevent circular dependency
|
|
135
129
|
_defineProperty(Node, "fromValue", void 0);
|
|
130
|
+
// Specified in './node.ts' to prevent circular dependency
|
|
136
131
|
_defineProperty(Node, "toJS", void 0);
|
|
137
132
|
export { Node as default };
|
package/esm/rdfxmlparser.js
CHANGED
|
@@ -474,6 +474,9 @@ _defineProperty(RDFParser, "ns", {
|
|
|
474
474
|
'RDF': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
|
475
475
|
'RDFS': 'http://www.w3.org/2000/01/rdf-schema#'
|
|
476
476
|
});
|
|
477
|
+
/** DOM Level 2 node type magic numbers @final
|
|
478
|
+
* @member RDFParser
|
|
479
|
+
*/
|
|
477
480
|
_defineProperty(RDFParser, "nodeType", {
|
|
478
481
|
'ELEMENT': 1,
|
|
479
482
|
'ATTRIBUTE': 2,
|
package/esm/serializer.js
CHANGED
|
@@ -25,6 +25,7 @@ export var Serializer = /*#__PURE__*/function () {
|
|
|
25
25
|
_classCallCheck(this, Serializer);
|
|
26
26
|
_defineProperty(this, "_notQNameChars", '\t\r\n !"#$%&\'()*.,+/;<=>?@[\\]^`{|}~');
|
|
27
27
|
_defineProperty(this, "_notNameChars", this._notQNameChars + ':');
|
|
28
|
+
// stringToN3: String escaping for N3
|
|
28
29
|
_defineProperty(this, "validPrefix", new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/));
|
|
29
30
|
_defineProperty(this, "forbidden1", new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm));
|
|
30
31
|
_defineProperty(this, "forbidden3", new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm));
|
|
@@ -588,8 +589,6 @@ export var Serializer = /*#__PURE__*/function () {
|
|
|
588
589
|
throw new Error('Internal: atomicTermToN3 cannot handle ' + expr + ' of termType: ' + expr.termType);
|
|
589
590
|
}
|
|
590
591
|
}
|
|
591
|
-
|
|
592
|
-
// stringToN3: String escaping for N3
|
|
593
592
|
}, {
|
|
594
593
|
key: "stringToN3",
|
|
595
594
|
value: function stringToN3(str, flags) {
|
package/esm/statement.js
CHANGED
|
@@ -8,17 +8,6 @@ var defaultGraph = new DefaultGraphNode();
|
|
|
8
8
|
|
|
9
9
|
/** A Statement represents an RDF Triple or Quad. */
|
|
10
10
|
var Statement = /*#__PURE__*/function () {
|
|
11
|
-
/** The subject of the triple. What the Statement is about. */
|
|
12
|
-
|
|
13
|
-
/** The relationship which is asserted between the subject and object */
|
|
14
|
-
|
|
15
|
-
/** The thing or data value which is asserted to be related to the subject */
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* The graph param is a named node of the document in which the triple when
|
|
19
|
-
* it is stored on the web.
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
11
|
/**
|
|
23
12
|
* Construct a new statement
|
|
24
13
|
*
|
|
@@ -38,9 +27,16 @@ var Statement = /*#__PURE__*/function () {
|
|
|
38
27
|
*/
|
|
39
28
|
function Statement(subject, predicate, object, graph) {
|
|
40
29
|
_classCallCheck(this, Statement);
|
|
30
|
+
/** The subject of the triple. What the Statement is about. */
|
|
41
31
|
_defineProperty(this, "subject", void 0);
|
|
32
|
+
/** The relationship which is asserted between the subject and object */
|
|
42
33
|
_defineProperty(this, "predicate", void 0);
|
|
34
|
+
/** The thing or data value which is asserted to be related to the subject */
|
|
43
35
|
_defineProperty(this, "object", void 0);
|
|
36
|
+
/**
|
|
37
|
+
* The graph param is a named node of the document in which the triple when
|
|
38
|
+
* it is stored on the web.
|
|
39
|
+
*/
|
|
44
40
|
_defineProperty(this, "graph", void 0);
|
|
45
41
|
this.subject = Node.fromValue(subject);
|
|
46
42
|
this.predicate = Node.fromValue(predicate);
|
package/esm/store.js
CHANGED
|
@@ -98,37 +98,6 @@ function handleRDFType(formula, subj, pred, obj, why) {
|
|
|
98
98
|
var IndexedFormula = /*#__PURE__*/function (_Formula) {
|
|
99
99
|
_inherits(IndexedFormula, _Formula);
|
|
100
100
|
var _super = _createSuper(IndexedFormula);
|
|
101
|
-
// IN future - allow pass array of statements to constructor
|
|
102
|
-
/**
|
|
103
|
-
* An UpdateManager initialised to this store
|
|
104
|
-
*/
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Dictionary of namespace prefixes
|
|
108
|
-
*/
|
|
109
|
-
|
|
110
|
-
/** Map of iri predicates to functions to call when adding { s type X } */
|
|
111
|
-
|
|
112
|
-
/** Map of iri predicates to functions to call when getting statement with {s X o} */
|
|
113
|
-
|
|
114
|
-
/** Redirect to lexically smaller equivalent symbol */
|
|
115
|
-
|
|
116
|
-
/** Reverse mapping to redirection: aliases for this */
|
|
117
|
-
|
|
118
|
-
/** Redirections we got from HTTP */
|
|
119
|
-
|
|
120
|
-
/** Array of statements with this X as subject */
|
|
121
|
-
|
|
122
|
-
/** Array of statements with this X as predicate */
|
|
123
|
-
|
|
124
|
-
/** Array of statements with this X as object */
|
|
125
|
-
|
|
126
|
-
/** Array of statements with X as provenance */
|
|
127
|
-
|
|
128
|
-
/** Function to remove quads from the store arrays with */
|
|
129
|
-
|
|
130
|
-
/** Callbacks which are triggered after a statement has been added to the store */
|
|
131
|
-
|
|
132
101
|
/**
|
|
133
102
|
* Creates a new formula
|
|
134
103
|
* @param features - What sort of automatic processing to do? Array of string
|
|
@@ -143,22 +112,40 @@ var IndexedFormula = /*#__PURE__*/function (_Formula) {
|
|
|
143
112
|
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
144
113
|
_classCallCheck(this, IndexedFormula);
|
|
145
114
|
_this = _super.call(this, undefined, undefined, undefined, undefined, opts);
|
|
115
|
+
// IN future - allow pass array of statements to constructor
|
|
116
|
+
/**
|
|
117
|
+
* An UpdateManager initialised to this store
|
|
118
|
+
*/
|
|
146
119
|
_defineProperty(_assertThisInitialized(_this), "updater", void 0);
|
|
120
|
+
/**
|
|
121
|
+
* Dictionary of namespace prefixes
|
|
122
|
+
*/
|
|
147
123
|
_defineProperty(_assertThisInitialized(_this), "namespaces", void 0);
|
|
124
|
+
/** Map of iri predicates to functions to call when adding { s type X } */
|
|
148
125
|
_defineProperty(_assertThisInitialized(_this), "classActions", void 0);
|
|
126
|
+
/** Map of iri predicates to functions to call when getting statement with {s X o} */
|
|
149
127
|
_defineProperty(_assertThisInitialized(_this), "propertyActions", void 0);
|
|
128
|
+
/** Redirect to lexically smaller equivalent symbol */
|
|
150
129
|
_defineProperty(_assertThisInitialized(_this), "redirections", void 0);
|
|
130
|
+
/** Reverse mapping to redirection: aliases for this */
|
|
151
131
|
_defineProperty(_assertThisInitialized(_this), "aliases", void 0);
|
|
132
|
+
/** Redirections we got from HTTP */
|
|
152
133
|
_defineProperty(_assertThisInitialized(_this), "HTTPRedirects", void 0);
|
|
134
|
+
/** Array of statements with this X as subject */
|
|
153
135
|
_defineProperty(_assertThisInitialized(_this), "subjectIndex", void 0);
|
|
136
|
+
/** Array of statements with this X as predicate */
|
|
154
137
|
_defineProperty(_assertThisInitialized(_this), "predicateIndex", void 0);
|
|
138
|
+
/** Array of statements with this X as object */
|
|
155
139
|
_defineProperty(_assertThisInitialized(_this), "objectIndex", void 0);
|
|
140
|
+
/** Array of statements with X as provenance */
|
|
156
141
|
_defineProperty(_assertThisInitialized(_this), "whyIndex", void 0);
|
|
157
142
|
_defineProperty(_assertThisInitialized(_this), "index", void 0);
|
|
158
143
|
_defineProperty(_assertThisInitialized(_this), "features", void 0);
|
|
159
144
|
_defineProperty(_assertThisInitialized(_this), "_universalVariables", void 0);
|
|
160
145
|
_defineProperty(_assertThisInitialized(_this), "_existentialVariables", void 0);
|
|
146
|
+
/** Function to remove quads from the store arrays with */
|
|
161
147
|
_defineProperty(_assertThisInitialized(_this), "rdfArrayRemove", void 0);
|
|
148
|
+
/** Callbacks which are triggered after a statement has been added to the store */
|
|
162
149
|
_defineProperty(_assertThisInitialized(_this), "dataCallbacks", void 0);
|
|
163
150
|
_this.propertyActions = {};
|
|
164
151
|
_this.classActions = {};
|
|
@@ -838,12 +825,32 @@ var IndexedFormula = /*#__PURE__*/function (_Formula) {
|
|
|
838
825
|
}
|
|
839
826
|
|
|
840
827
|
/**
|
|
841
|
-
* Removes all statements in a doc
|
|
828
|
+
* Removes all statements in a doc, along with the related metadata including request/response
|
|
842
829
|
* @param doc - The document / graph
|
|
843
830
|
*/
|
|
844
831
|
}, {
|
|
845
832
|
key: "removeDocument",
|
|
846
833
|
value: function removeDocument(doc) {
|
|
834
|
+
var meta = this.sym('chrome://TheCurrentSession'); // or this.rdfFactory.namedNode('chrome://TheCurrentSession')
|
|
835
|
+
var linkNamespaceURI = 'http://www.w3.org/2007/ont/link#'; // alain
|
|
836
|
+
// remove request/response and metadata
|
|
837
|
+
var requests = this.statementsMatching(undefined, this.sym("".concat(linkNamespaceURI, "requestedURI")), this.rdfFactory.literal(doc.value), meta).map(function (st) {
|
|
838
|
+
return st.subject;
|
|
839
|
+
});
|
|
840
|
+
for (var r = 0; r < requests.length; r++) {
|
|
841
|
+
var request = requests[r];
|
|
842
|
+
if (request !== undefined) {
|
|
843
|
+
this.removeMatches(request, null, null, meta);
|
|
844
|
+
var response = this.any(request, this.sym("".concat(linkNamespaceURI, "response")), null, meta);
|
|
845
|
+
if (response !== undefined) {
|
|
846
|
+
// ts
|
|
847
|
+
this.removeMatches(response, null, null, meta);
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
this.removeMatches(this.sym(doc.value), null, null, meta); // content-type
|
|
852
|
+
|
|
853
|
+
// remove document
|
|
847
854
|
var sts = this.statementsMatching(undefined, undefined, undefined, doc).slice(); // Take a copy as this is the actual index
|
|
848
855
|
for (var i = 0; i < sts.length; i++) {
|
|
849
856
|
this.removeStatement(sts[i]);
|
package/esm/types.js
CHANGED
|
@@ -23,4 +23,21 @@ export var XHTMLContentType = "application/xhtml+xml";
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* A valid mime type header
|
|
26
|
-
*/
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/** A type for values that serves as inputs */
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* In this project, there exist two types for the same kind of RDF concept.
|
|
32
|
+
* We have RDF/JS spec types (standardized, generic), and RDFlib types (internal, specific).
|
|
33
|
+
* When deciding which type to use in a function, it is preferable to accept generic inputs,
|
|
34
|
+
* whenever possible, and provide strict outputs.
|
|
35
|
+
* In some ways, the TF types in here are a bit more strict.
|
|
36
|
+
* Variables are missing, and the statement requires specific types of terms (e.g. NamedNode instead of Term).
|
|
37
|
+
*/
|
|
38
|
+
/** An RDF/JS Subject */
|
|
39
|
+
/** An RDF/JS Predicate */
|
|
40
|
+
/** An RDF/JS Object */
|
|
41
|
+
/** An RDF/JS Graph */
|
|
42
|
+
// | Formula
|
|
43
|
+
/** All the types that a .fromValue() method might return */
|