rdflib 2.2.31-d71f8cd7 → 2.2.32-2b635b59

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.
Files changed (49) hide show
  1. package/dist/670.rdflib.min.js +1 -0
  2. package/dist/730.rdflib.min.js +3 -0
  3. package/dist/730.rdflib.min.js.LICENSE.txt +58 -0
  4. package/dist/730.rdflib.min.js.map +1 -0
  5. package/dist/rdflib.min.js +1 -1
  6. package/dist/rdflib.min.js.LICENSE.txt +0 -59
  7. package/dist/rdflib.min.js.map +1 -1
  8. package/esm/blank-node.js +10 -6
  9. package/esm/collection.js +3 -4
  10. package/esm/factories/factory-types.js +10 -10
  11. package/esm/fetcher.js +38 -33
  12. package/esm/formula.js +10 -13
  13. package/esm/jsonldparser.js +4 -3
  14. package/esm/lists.js +2 -1
  15. package/esm/literal.js +6 -8
  16. package/esm/node-internal.js +5 -10
  17. package/esm/rdfxmlparser.js +3 -0
  18. package/esm/serializer.js +1 -2
  19. package/esm/statement.js +7 -11
  20. package/esm/store.js +18 -31
  21. package/esm/types.js +18 -1
  22. package/esm/update-manager.js +2 -4
  23. package/esm/utils.js +0 -1
  24. package/esm/variable.js +2 -4
  25. package/lib/blank-node.js +10 -6
  26. package/lib/collection.js +3 -4
  27. package/lib/factories/factory-types.js +10 -10
  28. package/lib/fetcher.js +62 -34
  29. package/lib/formula.js +10 -13
  30. package/lib/index.d.ts +1 -1
  31. package/lib/jsonldparser.js +9 -3
  32. package/lib/lists.js +15 -1
  33. package/lib/literal.js +6 -8
  34. package/lib/node-internal.js +5 -10
  35. package/lib/query.d.ts +1 -1
  36. package/lib/rdfxmlparser.js +3 -0
  37. package/lib/serializer.d.ts +1 -1
  38. package/lib/serializer.js +1 -2
  39. package/lib/sparql-to-query.d.ts +1 -1
  40. package/lib/statement.js +7 -11
  41. package/lib/store.js +34 -33
  42. package/lib/types.js +22 -0
  43. package/lib/update-manager.js +8 -5
  44. package/lib/utils-js.d.ts +3 -3
  45. package/lib/variable.js +2 -4
  46. package/lib/xsd-internal.d.ts +1 -1
  47. package/package.json +19 -19
  48. package/src/fetcher.ts +5 -1
  49. package/src/jsonldparser.js +2 -4
package/lib/fetcher.js CHANGED
@@ -36,7 +36,30 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
36
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
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; }
38
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); }; }
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; } }
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
+ */
40
63
  var Parsable = {
41
64
  'text/n3': true,
42
65
  'text/turtle': true,
@@ -76,14 +99,19 @@ var getNS = function getNS(factory) {
76
99
  };
77
100
  };
78
101
  var ns = getNS();
79
- var Handler = /*#__PURE__*/(0, _createClass2.default)(
80
- // TODO: Document, type
81
102
 
82
- // TODO: Document, type
103
+ /** An extended interface of Response, since RDFlib.js adds some properties. */
83
104
 
84
- function Handler(response, dom) {
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) {
85
111
  (0, _classCallCheck2.default)(this, Handler);
112
+ // TODO: Document, type
86
113
  (0, _defineProperty2.default)(this, "response", void 0);
114
+ // TODO: Document, type
87
115
  (0, _defineProperty2.default)(this, "dom", void 0);
88
116
  this.response = response;
89
117
  // The type assertion operator here might need to be removed.
@@ -458,7 +486,11 @@ var N3Handler = /*#__PURE__*/function (_Handler7) {
458
486
  value: function parse(fetcher, responseText, options, response) {
459
487
  // Parse the text of this N3 file
460
488
  var kb = fetcher.store;
461
- var p = (0, _n3parser.default)(kb, kb, options.original.value, options.original.value, null, null, '', null);
489
+ var baseUrl = options.original.value;
490
+ var isContainer = kb.any(options.original, null, ns.ldp('Container'));
491
+ console.log('@@ isContainer ' + isContainer);
492
+ if (isContainer && !baseUrl.endsWith('/')) baseUrl = baseUrl + '/';
493
+ var p = (0, _n3parser.default)(kb, kb, baseUrl, baseUrl, null, null, '', null);
462
494
  // p.loadBuf(xhr.responseText)
463
495
  try {
464
496
  p.loadBuf(responseText);
@@ -519,6 +551,10 @@ function isXMLNS(responseText) {
519
551
  var match = responseText.match(/[^(<html)]*<html\s+[^<]*xmlns=['"]http:\/\/www.w3.org\/1999\/xhtml["'][^<]*>/);
520
552
  return !!match;
521
553
  }
554
+
555
+ // Not sure about the shapes of this. Response? FetchError?
556
+
557
+ /** Differs from normal Fetch, has an extended Response type */
522
558
  /** Fetcher
523
559
  *
524
560
  * The Fetcher object is a helper object for a quadstore
@@ -528,34 +564,6 @@ function isXMLNS(responseText) {
528
564
  * and put back the data to the web.
529
565
  */
530
566
  var Fetcher = /*#__PURE__*/function () {
531
- /** Denoting this session */
532
-
533
- /**
534
- * this.requested[uri] states:
535
- * undefined no record of web access or records reset
536
- * true has been requested, fetch in progress
537
- * 'done' received, Ok
538
- * 401 Not logged in
539
- * 403 HTTP status unauthorized
540
- * 404 Resource does not exist. Can be created etc.
541
- * 'redirected' In attempt to counter CORS problems retried.
542
- * 'parse_error' Parse error
543
- * 'unsupported_protocol' URI is not a protocol Fetcher can deal with
544
- * other strings mean various other errors.
545
- */
546
-
547
- /** List of timeouts associated with a requested URL */
548
-
549
- /** Redirected from *key uri* to *value uri* */
550
-
551
- /** fetchCallbacks[uri].push(callback) */
552
-
553
- /** Keep track of explicit 404s -> we can overwrite etc */
554
-
555
- // TODO: Document this
556
-
557
- /** Methods added by calling Util.callbackify in the constructor*/
558
-
559
567
  function Fetcher(store) {
560
568
  var _this = this;
561
569
  var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -564,16 +572,35 @@ var Fetcher = /*#__PURE__*/function () {
564
572
  (0, _defineProperty2.default)(this, "timeout", void 0);
565
573
  (0, _defineProperty2.default)(this, "_fetch", void 0);
566
574
  (0, _defineProperty2.default)(this, "mediatypes", void 0);
575
+ /** Denoting this session */
567
576
  (0, _defineProperty2.default)(this, "appNode", void 0);
577
+ /**
578
+ * this.requested[uri] states:
579
+ * undefined no record of web access or records reset
580
+ * true has been requested, fetch in progress
581
+ * 'done' received, Ok
582
+ * 401 Not logged in
583
+ * 403 HTTP status unauthorized
584
+ * 404 Resource does not exist. Can be created etc.
585
+ * 'redirected' In attempt to counter CORS problems retried.
586
+ * 'parse_error' Parse error
587
+ * 'unsupported_protocol' URI is not a protocol Fetcher can deal with
588
+ * other strings mean various other errors.
589
+ */
568
590
  (0, _defineProperty2.default)(this, "requested", void 0);
591
+ /** List of timeouts associated with a requested URL */
569
592
  (0, _defineProperty2.default)(this, "timeouts", void 0);
593
+ /** Redirected from *key uri* to *value uri* */
570
594
  (0, _defineProperty2.default)(this, "redirectedTo", void 0);
571
595
  (0, _defineProperty2.default)(this, "fetchQueue", void 0);
596
+ /** fetchCallbacks[uri].push(callback) */
572
597
  (0, _defineProperty2.default)(this, "fetchCallbacks", void 0);
598
+ /** Keep track of explicit 404s -> we can overwrite etc */
573
599
  (0, _defineProperty2.default)(this, "nonexistent", void 0);
574
600
  (0, _defineProperty2.default)(this, "lookedUp", void 0);
575
601
  (0, _defineProperty2.default)(this, "handlers", void 0);
576
602
  (0, _defineProperty2.default)(this, "ns", void 0);
603
+ /** Methods added by calling Util.callbackify in the constructor*/
577
604
  (0, _defineProperty2.default)(this, "fireCallbacks", void 0);
578
605
  this.store = store || new _store.default();
579
606
  this.ns = getNS(this.store.rdfFactory);
@@ -1967,6 +1994,7 @@ var Fetcher = /*#__PURE__*/function () {
1967
1994
  exports.default = Fetcher;
1968
1995
  (0, _defineProperty2.default)(Fetcher, "HANDLERS", void 0);
1969
1996
  (0, _defineProperty2.default)(Fetcher, "CONTENT_TYPE_BY_EXT", void 0);
1997
+ // TODO: Document this
1970
1998
  (0, _defineProperty2.default)(Fetcher, "crossSiteProxyTemplate", void 0);
1971
1999
  Fetcher.HANDLERS = defaultHandlers;
1972
2000
  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<any>>(value: import("./types").ValueType) => T;
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';
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = jsonldParser;
8
8
  exports.jsonldObjectToTerm = jsonldObjectToTerm;
9
- var _jsonld = _interopRequireDefault(require("jsonld"));
9
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
10
  var _utils = require("./utils");
11
+ 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); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || (0, _typeof2.default)(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; }
11
13
  /**
12
14
  * Parses json-ld formatted JS objects to a rdf Term.
13
15
  * @param kb - The DataFactory to use.
@@ -67,8 +69,12 @@ function listToCollection(kb, obj) {
67
69
  */
68
70
  function jsonldParser(str, kb, base, callback) {
69
71
  var baseString = base && Object.prototype.hasOwnProperty.call(base, 'termType') ? base.value : base;
70
- return _jsonld.default.flatten(JSON.parse(str), null, {
71
- base: baseString
72
+ return Promise.resolve().then(function () {
73
+ return _interopRequireWildcard(require('jsonld'));
74
+ }).then(function (jsonld) {
75
+ return jsonld.flatten(JSON.parse(str), null, {
76
+ base: baseString
77
+ });
72
78
  }).then(function (flattened) {
73
79
  return flattened.reduce(function (store, flatResource) {
74
80
  kb = processResource(kb, base, flatResource);
package/lib/lists.js CHANGED
@@ -12,7 +12,21 @@ var _statement = _interopRequireDefault(require("./statement"));
12
12
  var _namespace = _interopRequireDefault(require("./namespace"));
13
13
  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; } } }; }
14
14
  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); }
15
- 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; }
15
+ 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; } /* Lists form conversion
16
+ */ // import DataFactory from './factories/extended-term-factory'
17
+ // import jsonldParser from './jsonldparser'
18
+ // @ts-ignore is this injected?
19
+ // @@ Goal: remove this dependency
20
+ // import N3Parser from './n3parser'
21
+ // import { parseRDFaDOM } from './rdfaparser'
22
+ // import RDFParser from './rdfxmlparser'
23
+ // import sparqlUpdateParser from './patch-parser'
24
+ // import * as Util from './utils-js'
25
+ // import BlankNode from './blank-node'
26
+ // import NamedNode from './named-node'
27
+ // import Formula from './formula'
28
+ // import { ContentType, TurtleContentType, N3ContentType, RDFXMLContentType, XHTMLContentType, HTMLContentType, SPARQLUpdateContentType, SPARQLUpdateSingleMatchContentType, JSONLDContentType, NQuadsContentType, NQuadsAltContentType } from './types'
29
+ // import { Quad } from './tf-types'
16
30
  var RDF = (0, _namespace.default)('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
17
31
 
18
32
  /* Replace a given node with another node throughout a given document
package/lib/literal.js CHANGED
@@ -28,14 +28,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
28
28
  var Literal = /*#__PURE__*/function (_Node) {
29
29
  (0, _inherits2.default)(Literal, _Node);
30
30
  var _super = _createSuper(Literal);
31
- /**
32
- * The literal's datatype as a named node
33
- */
34
-
35
- /**
36
- * The language for the literal
37
- */
38
-
39
31
  /**
40
32
  * Initializes a literal
41
33
  * @param value - The literal's lexical value
@@ -48,8 +40,14 @@ var Literal = /*#__PURE__*/function (_Node) {
48
40
  _this = _super.call(this, value);
49
41
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "termType", _types.LiteralTermType);
50
42
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "classOrder", _classOrder.default.Literal);
43
+ /**
44
+ * The literal's datatype as a named node
45
+ */
51
46
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "datatype", _xsdInternal.default.string);
52
47
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isVar", 0);
48
+ /**
49
+ * The language for the literal
50
+ */
53
51
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "language", '');
54
52
  if (language) {
55
53
  _this.language = language;
@@ -17,20 +17,13 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
17
17
  * @class Node
18
18
  */
19
19
  var Node = /*#__PURE__*/function () {
20
- // Specified in './node.ts' to prevent circular dependency
21
-
22
- // Specified in './node.ts' to prevent circular dependency
23
-
24
- /** The type of node */
25
-
26
- /** The class order for this node */
27
-
28
- /** The node's value */
29
-
30
20
  function Node(value) {
31
21
  (0, _classCallCheck2.default)(this, Node);
22
+ /** The type of node */
32
23
  (0, _defineProperty2.default)(this, "termType", void 0);
24
+ /** The class order for this node */
33
25
  (0, _defineProperty2.default)(this, "classOrder", void 0);
26
+ /** The node's value */
34
27
  (0, _defineProperty2.default)(this, "value", void 0);
35
28
  this.value = value;
36
29
  }
@@ -140,5 +133,7 @@ var Node = /*#__PURE__*/function () {
140
133
  return Node;
141
134
  }();
142
135
  exports.default = Node;
136
+ // Specified in './node.ts' to prevent circular dependency
143
137
  (0, _defineProperty2.default)(Node, "fromValue", void 0);
138
+ // Specified in './node.ts' to prevent circular dependency
144
139
  (0, _defineProperty2.default)(Node, "toJS", void 0);
package/lib/query.d.ts CHANGED
@@ -24,4 +24,4 @@ export class Query {
24
24
  name: any;
25
25
  id: any;
26
26
  }
27
- import IndexedFormula from "./store";
27
+ import IndexedFormula from './store';
@@ -485,6 +485,9 @@ exports.default = RDFParser;
485
485
  'RDF': 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
486
486
  'RDFS': 'http://www.w3.org/2000/01/rdf-schema#'
487
487
  });
488
+ /** DOM Level 2 node type magic numbers @final
489
+ * @member RDFParser
490
+ */
488
491
  (0, _defineProperty2.default)(RDFParser, "nodeType", {
489
492
  'ELEMENT': 1,
490
493
  'ATTRIBUTE': 2,
@@ -65,4 +65,4 @@ export class Serializer {
65
65
  statementsToXML(sts: any): string;
66
66
  statementsToJsonld(sts: any): string;
67
67
  }
68
- import NamedNode from "./named-node";
68
+ import NamedNode from './named-node';
package/lib/serializer.js CHANGED
@@ -37,6 +37,7 @@ var Serializer = /*#__PURE__*/function () {
37
37
  (0, _classCallCheck2.default)(this, Serializer);
38
38
  (0, _defineProperty2.default)(this, "_notQNameChars", '\t\r\n !"#$%&\'()*.,+/;<=>?@[\\]^`{|}~');
39
39
  (0, _defineProperty2.default)(this, "_notNameChars", this._notQNameChars + ':');
40
+ // stringToN3: String escaping for N3
40
41
  (0, _defineProperty2.default)(this, "validPrefix", new RegExp(/^[a-zA-Z][a-zA-Z0-9]*$/));
41
42
  (0, _defineProperty2.default)(this, "forbidden1", new RegExp(/[\\"\b\f\r\v\t\n\u0080-\uffff]/gm));
42
43
  (0, _defineProperty2.default)(this, "forbidden3", new RegExp(/[\\"\b\f\r\v\u0080-\uffff]/gm));
@@ -600,8 +601,6 @@ var Serializer = /*#__PURE__*/function () {
600
601
  throw new Error('Internal: atomicTermToN3 cannot handle ' + expr + ' of termType: ' + expr.termType);
601
602
  }
602
603
  }
603
-
604
- // stringToN3: String escaping for N3
605
604
  }, {
606
605
  key: "stringToN3",
607
606
  value: function stringToN3(str, flags) {
@@ -3,4 +3,4 @@
3
3
  * @testMode: testing flag. Prevents loading of sources.
4
4
  */
5
5
  export default function SPARQLToQuery(SPARQL: any, testMode: any, kb: any): false | Query;
6
- import { Query } from "./query";
6
+ import { Query } from './query';
package/lib/statement.js CHANGED
@@ -18,17 +18,6 @@ var defaultGraph = new _defaultGraph.default();
18
18
 
19
19
  /** A Statement represents an RDF Triple or Quad. */
20
20
  var Statement = /*#__PURE__*/function () {
21
- /** The subject of the triple. What the Statement is about. */
22
-
23
- /** The relationship which is asserted between the subject and object */
24
-
25
- /** The thing or data value which is asserted to be related to the subject */
26
-
27
- /**
28
- * The graph param is a named node of the document in which the triple when
29
- * it is stored on the web.
30
- */
31
-
32
21
  /**
33
22
  * Construct a new statement
34
23
  *
@@ -48,9 +37,16 @@ var Statement = /*#__PURE__*/function () {
48
37
  */
49
38
  function Statement(subject, predicate, object, graph) {
50
39
  (0, _classCallCheck2.default)(this, Statement);
40
+ /** The subject of the triple. What the Statement is about. */
51
41
  (0, _defineProperty2.default)(this, "subject", void 0);
42
+ /** The relationship which is asserted between the subject and object */
52
43
  (0, _defineProperty2.default)(this, "predicate", void 0);
44
+ /** The thing or data value which is asserted to be related to the subject */
53
45
  (0, _defineProperty2.default)(this, "object", void 0);
46
+ /**
47
+ * The graph param is a named node of the document in which the triple when
48
+ * it is stored on the web.
49
+ */
54
50
  (0, _defineProperty2.default)(this, "graph", void 0);
55
51
  this.subject = _nodeInternal.default.fromValue(subject);
56
52
  this.predicate = _nodeInternal.default.fromValue(predicate);
package/lib/store.js CHANGED
@@ -40,10 +40,24 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
40
40
  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); }
41
41
  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; }
42
42
  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); }; }
43
- 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; } }
43
+ 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; } } /* Identity management and indexing for RDF
44
+ *
45
+ * This file provides IndexedFormula a formula (set of triples) which
46
+ * indexed by predicate, subject and object.
47
+ *
48
+ * It "smushes" (merges into a single node) things which are identical
49
+ * according to owl:sameAs or an owl:InverseFunctionalProperty
50
+ * or an owl:FunctionalProperty
51
+ *
52
+ *
53
+ * 2005-10 Written Tim Berners-Lee
54
+ * 2007 Changed so as not to munge statements from documents when smushing
55
+ * 2019 Converted to typescript
56
+ *
57
+ *
58
+ */ /** @module store */
44
59
  var owlNamespaceURI = 'http://www.w3.org/2002/07/owl#';
45
60
  // var link_ns = 'http://www.w3.org/2007/ont/link#'
46
-
47
61
  // Handle Functional Property
48
62
  function handleFP(formula, subj, pred, obj) {
49
63
  var o1 = formula.any(subj, pred, undefined);
@@ -87,37 +101,6 @@ function handleRDFType(formula, subj, pred, obj, why) {
87
101
  var IndexedFormula = /*#__PURE__*/function (_Formula) {
88
102
  (0, _inherits2.default)(IndexedFormula, _Formula);
89
103
  var _super = _createSuper(IndexedFormula);
90
- // IN future - allow pass array of statements to constructor
91
- /**
92
- * An UpdateManager initialised to this store
93
- */
94
-
95
- /**
96
- * Dictionary of namespace prefixes
97
- */
98
-
99
- /** Map of iri predicates to functions to call when adding { s type X } */
100
-
101
- /** Map of iri predicates to functions to call when getting statement with {s X o} */
102
-
103
- /** Redirect to lexically smaller equivalent symbol */
104
-
105
- /** Reverse mapping to redirection: aliases for this */
106
-
107
- /** Redirections we got from HTTP */
108
-
109
- /** Array of statements with this X as subject */
110
-
111
- /** Array of statements with this X as predicate */
112
-
113
- /** Array of statements with this X as object */
114
-
115
- /** Array of statements with X as provenance */
116
-
117
- /** Function to remove quads from the store arrays with */
118
-
119
- /** Callbacks which are triggered after a statement has been added to the store */
120
-
121
104
  /**
122
105
  * Creates a new formula
123
106
  * @param features - What sort of automatic processing to do? Array of string
@@ -132,22 +115,40 @@ var IndexedFormula = /*#__PURE__*/function (_Formula) {
132
115
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
133
116
  (0, _classCallCheck2.default)(this, IndexedFormula);
134
117
  _this = _super.call(this, undefined, undefined, undefined, undefined, opts);
118
+ // IN future - allow pass array of statements to constructor
119
+ /**
120
+ * An UpdateManager initialised to this store
121
+ */
135
122
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updater", void 0);
123
+ /**
124
+ * Dictionary of namespace prefixes
125
+ */
136
126
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "namespaces", void 0);
127
+ /** Map of iri predicates to functions to call when adding { s type X } */
137
128
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "classActions", void 0);
129
+ /** Map of iri predicates to functions to call when getting statement with {s X o} */
138
130
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "propertyActions", void 0);
131
+ /** Redirect to lexically smaller equivalent symbol */
139
132
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "redirections", void 0);
133
+ /** Reverse mapping to redirection: aliases for this */
140
134
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "aliases", void 0);
135
+ /** Redirections we got from HTTP */
141
136
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "HTTPRedirects", void 0);
137
+ /** Array of statements with this X as subject */
142
138
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "subjectIndex", void 0);
139
+ /** Array of statements with this X as predicate */
143
140
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "predicateIndex", void 0);
141
+ /** Array of statements with this X as object */
144
142
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "objectIndex", void 0);
143
+ /** Array of statements with X as provenance */
145
144
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "whyIndex", void 0);
146
145
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "index", void 0);
147
146
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "features", void 0);
148
147
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_universalVariables", void 0);
149
148
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "_existentialVariables", void 0);
149
+ /** Function to remove quads from the store arrays with */
150
150
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "rdfArrayRemove", void 0);
151
+ /** Callbacks which are triggered after a statement has been added to the store */
151
152
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "dataCallbacks", void 0);
152
153
  _this.propertyActions = {};
153
154
  _this.classActions = {};
package/lib/types.js CHANGED
@@ -50,4 +50,26 @@ var XHTMLContentType = "application/xhtml+xml";
50
50
  /**
51
51
  * A valid mime type header
52
52
  */
53
+
54
+ /** A type for values that serves as inputs */
55
+
56
+ /**
57
+ * In this project, there exist two types for the same kind of RDF concept.
58
+ * We have RDF/JS spec types (standardized, generic), and RDFlib types (internal, specific).
59
+ * When deciding which type to use in a function, it is preferable to accept generic inputs,
60
+ * whenever possible, and provide strict outputs.
61
+ * In some ways, the TF types in here are a bit more strict.
62
+ * Variables are missing, and the statement requires specific types of terms (e.g. NamedNode instead of Term).
63
+ */
64
+
65
+ /** An RDF/JS Subject */
66
+
67
+ /** An RDF/JS Predicate */
68
+
69
+ /** An RDF/JS Object */
70
+
71
+ /** An RDF/JS Graph */
72
+ // | Formula
73
+
74
+ /** All the types that a .fromValue() method might return */
53
75
  exports.XHTMLContentType = XHTMLContentType;
@@ -24,7 +24,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
24
24
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof3(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; }
25
25
  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; } } }; }
26
26
  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); }
27
- 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; }
27
+ 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; } /* @file Update Manager Class
28
+ **
29
+ ** 2007-07-15 originall sparl update module by Joe Presbrey <presbrey@mit.edu>
30
+ ** 2010-08-08 TimBL folded in Kenny's WEBDAV
31
+ ** 2010-12-07 TimBL addred local file write code
32
+ */
28
33
  /**
29
34
  * The UpdateManager is a helper object for a store.
30
35
  * Just as a Fetcher provides the store with the ability to read and write,
@@ -32,10 +37,6 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
32
37
  * and also looking out for concurrent updates from other agents
33
38
  */
34
39
  var UpdateManager = /*#__PURE__*/function () {
35
- /** Index of objects for coordinating incoming and outgoing patches */
36
-
37
- /** Object of namespaces */
38
-
39
40
  /**
40
41
  * @param store - The quadstore to store data and metadata. Created if not passed.
41
42
  */
@@ -44,7 +45,9 @@ var UpdateManager = /*#__PURE__*/function () {
44
45
  (0, _defineProperty2.default)(this, "store", void 0);
45
46
  (0, _defineProperty2.default)(this, "ifps", void 0);
46
47
  (0, _defineProperty2.default)(this, "fps", void 0);
48
+ /** Index of objects for coordinating incoming and outgoing patches */
47
49
  (0, _defineProperty2.default)(this, "patchControl", void 0);
50
+ /** Object of namespaces */
48
51
  (0, _defineProperty2.default)(this, "ns", void 0);
49
52
  store = store || new _store.default();
50
53
  if (store.updater) {
package/lib/utils-js.d.ts CHANGED
@@ -37,9 +37,9 @@ export function parseXML(str: any, options: any): Document;
37
37
  export function RDFArrayRemove(a: any, x: any): void;
38
38
  export function string_startswith(str: any, pref: any): boolean;
39
39
  export function stackString(e: any): string;
40
- import NamedNode from "./named-node";
41
- import log from "./log";
42
- import * as uri from "./uri";
40
+ import NamedNode from './named-node';
41
+ import log from './log';
42
+ import * as uri from './uri';
43
43
  export namespace string {
44
44
  export { stringTemplate as template };
45
45
  }