rdflib 2.2.21 → 2.2.22-b51259b5

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 (106) hide show
  1. package/dist/rdflib.min.js +1 -1
  2. package/dist/rdflib.min.js.LICENSE.txt +9 -1
  3. package/dist/rdflib.min.js.map +1 -1
  4. package/esm/blank-node.js +61 -114
  5. package/esm/class-order.js +1 -1
  6. package/esm/collection.js +70 -128
  7. package/esm/convert.js +1 -2
  8. package/esm/default-graph.js +14 -48
  9. package/esm/empty.js +8 -39
  10. package/esm/factories/canonical-data-factory.js +33 -65
  11. package/esm/factories/extended-term-factory.js +18 -25
  12. package/esm/factories/factory-types.js +3 -2
  13. package/esm/factories/rdflib-data-factory.js +9 -19
  14. package/esm/fetcher.js +1341 -1854
  15. package/esm/formula.js +639 -846
  16. package/esm/index.js +40 -76
  17. package/esm/jsonldparser.js +24 -49
  18. package/esm/jsonparser.js +1 -8
  19. package/esm/lists.js +47 -110
  20. package/esm/literal.js +120 -189
  21. package/esm/log.js +7 -7
  22. package/esm/n3parser.js +1015 -1412
  23. package/esm/named-node.js +70 -119
  24. package/esm/namespace.js +2 -5
  25. package/esm/node-internal.js +73 -110
  26. package/esm/node.js +2 -7
  27. package/esm/parse.js +12 -19
  28. package/esm/patch-parser.js +10 -30
  29. package/esm/query-to-sparql.js +0 -18
  30. package/esm/query.js +63 -147
  31. package/esm/rdfaparser.js +794 -997
  32. package/esm/rdfxmlparser.js +347 -461
  33. package/esm/serialize.js +9 -27
  34. package/esm/serializer.js +820 -1049
  35. package/esm/sparql-to-query.js +44 -134
  36. package/esm/statement.js +54 -85
  37. package/esm/store.js +830 -1103
  38. package/esm/types.js +22 -21
  39. package/esm/update-manager.js +869 -1106
  40. package/esm/updates-via.js +104 -161
  41. package/esm/uri.js +9 -53
  42. package/esm/utils/default-graph-uri.js +3 -2
  43. package/esm/utils/termValue.js +0 -1
  44. package/esm/utils/terms.js +19 -21
  45. package/esm/utils-js.js +20 -61
  46. package/esm/utils.js +10 -21
  47. package/esm/variable.js +32 -78
  48. package/esm/xsd.js +2 -2
  49. package/lib/blank-node.js +60 -113
  50. package/lib/class-order.js +1 -2
  51. package/lib/collection.js +69 -131
  52. package/lib/convert.js +3 -9
  53. package/lib/default-graph.js +13 -52
  54. package/lib/empty.js +8 -43
  55. package/lib/factories/canonical-data-factory.js +35 -79
  56. package/lib/factories/extended-term-factory.js +18 -32
  57. package/lib/factories/factory-types.d.ts +6 -6
  58. package/lib/factories/factory-types.js +1 -4
  59. package/lib/factories/rdflib-data-factory.js +9 -23
  60. package/lib/fetcher.d.ts +6 -6
  61. package/lib/fetcher.js +1370 -1843
  62. package/lib/formula.js +640 -855
  63. package/lib/index.js +66 -152
  64. package/lib/jsonldparser.js +23 -53
  65. package/lib/jsonparser.js +1 -10
  66. package/lib/lists.js +55 -112
  67. package/lib/literal.js +120 -195
  68. package/lib/log.d.ts +0 -6
  69. package/lib/log.js +7 -8
  70. package/lib/n3parser.js +1030 -1436
  71. package/lib/named-node.js +69 -126
  72. package/lib/namespace.js +2 -7
  73. package/lib/node-internal.js +74 -107
  74. package/lib/node.js +2 -12
  75. package/lib/parse.d.ts +1 -1
  76. package/lib/parse.js +12 -32
  77. package/lib/patch-parser.js +11 -34
  78. package/lib/query-to-sparql.js +0 -23
  79. package/lib/query.js +62 -167
  80. package/lib/rdfaparser.js +796 -1009
  81. package/lib/rdfxmlparser.js +349 -466
  82. package/lib/serialize.js +11 -37
  83. package/lib/serializer.js +823 -1064
  84. package/lib/sparql-to-query.js +42 -167
  85. package/lib/statement.js +55 -91
  86. package/lib/store.d.ts +1 -1
  87. package/lib/store.js +850 -1112
  88. package/lib/tf-types.d.ts +4 -4
  89. package/lib/types.d.ts +8 -8
  90. package/lib/types.js +23 -23
  91. package/lib/update-manager.d.ts +1 -1
  92. package/lib/update-manager.js +865 -1103
  93. package/lib/updates-via.js +105 -164
  94. package/lib/uri.js +8 -61
  95. package/lib/utils/default-graph-uri.js +3 -5
  96. package/lib/utils/termValue.js +0 -2
  97. package/lib/utils/terms.js +19 -40
  98. package/lib/utils-js.js +23 -88
  99. package/lib/utils.js +10 -27
  100. package/lib/variable.js +34 -85
  101. package/lib/xsd-internal.js +0 -3
  102. package/lib/xsd.js +2 -6
  103. package/package.json +35 -35
  104. package/src/fetcher.ts +2 -2
  105. package/src/update-manager.ts +12 -7
  106. package/changes.txt +0 -59
@@ -1,7 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
- var _supports;
4
-
5
1
  import BlankNode from '../blank-node';
6
2
  import Literal from '../literal';
7
3
  import NamedNode from '../named-node';
@@ -12,51 +8,49 @@ import DefaultGraph from '../default-graph';
12
8
  import { Feature } from './factory-types';
13
9
  import { isQuad, isTerm } from '../utils/terms';
14
10
  export { defaultGraphURI } from '../utils/default-graph-uri';
11
+
15
12
  /**
16
13
  * Gets the default graph
17
14
  */
15
+ const defaultGraph = new DefaultGraph();
18
16
 
19
- var _defaultGraph = new DefaultGraph();
20
17
  /** A basic internal RDFlib datafactory, which does not support Collections */
21
-
22
-
23
- var CanonicalDataFactory = {
24
- supports: (_supports = {}, _defineProperty(_supports, Feature.collections, false), _defineProperty(_supports, Feature.defaultGraphType, false), _defineProperty(_supports, Feature.equalsMethod, true), _defineProperty(_supports, Feature.identity, false), _defineProperty(_supports, Feature.id, true), _defineProperty(_supports, Feature.reversibleId, false), _defineProperty(_supports, Feature.variableType, true), _supports),
25
-
18
+ const CanonicalDataFactory = {
19
+ supports: {
20
+ [Feature.collections]: false,
21
+ [Feature.defaultGraphType]: false,
22
+ [Feature.equalsMethod]: true,
23
+ [Feature.identity]: false,
24
+ [Feature.id]: true,
25
+ [Feature.reversibleId]: false,
26
+ [Feature.variableType]: true
27
+ },
26
28
  /**
27
29
  * Creates a new blank node
28
30
  * @param value - The blank node's identifier
29
31
  */
30
- blankNode: function blankNode(value) {
32
+ blankNode(value) {
31
33
  return new BlankNode(value);
32
34
  },
33
- defaultGraph: function defaultGraph() {
34
- return _defaultGraph;
35
- },
36
-
35
+ defaultGraph: () => defaultGraph,
37
36
  /**
38
37
  * Compares to (rdf) objects for equality.
39
38
  */
40
- equals: function equals(a, b) {
39
+ equals(a, b) {
41
40
  if (a === b || !a || !b) {
42
41
  return true;
43
42
  }
44
-
45
43
  if (isQuad(a) || isQuad(b)) {
46
44
  if (isQuad(a) && isQuad(b)) {
47
45
  return this.equals(a.subject, b.subject) && this.equals(a.predicate, b.predicate) && this.equals(a.object, b.object) && this.equals(a.graph, b.graph);
48
46
  }
49
-
50
47
  return false;
51
48
  }
52
-
53
49
  if (isTerm(a) && isTerm(b)) {
54
50
  return this.id(a) === this.id(b);
55
51
  }
56
-
57
52
  return false;
58
53
  },
59
-
60
54
  /**
61
55
  * Generates a uniquely identifiably *idempotent* string for the given {term}.
62
56
  *
@@ -65,48 +59,39 @@ var CanonicalDataFactory = {
65
59
  * @example Use this to associate data with a term in an object
66
60
  * { obj[id(term)] = "myData" }
67
61
  */
68
- id: function id(term) {
62
+ id(term) {
69
63
  if (!term) {
70
64
  return 'undefined';
71
65
  }
72
-
73
66
  if (isQuad(term)) {
74
67
  return this.quadToNQ(term);
75
68
  }
76
-
77
69
  switch (term.termType) {
78
70
  case DefaultGraphTermType:
79
71
  return 'defaultGraph';
80
-
81
72
  case VariableTermType:
82
73
  return Variable.toString(term);
83
-
84
74
  default:
85
- var nq = this.termToNQ(term);
86
-
75
+ const nq = this.termToNQ(term);
87
76
  if (nq) {
88
77
  return nq;
89
78
  }
90
-
91
- throw new Error("Can't id term with type '".concat(term.termType, "'"));
79
+ throw new Error(`Can't id term with type '${term.termType}'`);
92
80
  }
93
81
  },
94
- isQuad: function isQuad(obj) {
82
+ isQuad(obj) {
95
83
  return obj instanceof Statement;
96
84
  },
97
-
98
85
  /**
99
86
  * Creates a new literal node. Does some JS literal parsing for ease of use.
100
87
  * @param value - The lexical value
101
88
  * @param languageOrDatatype - Either the language or the datatype
102
89
  */
103
- literal: function literal(value, languageOrDatatype) {
90
+ literal(value, languageOrDatatype) {
104
91
  if (typeof value !== "string" && !languageOrDatatype) {
105
92
  return Literal.fromValue(value);
106
93
  }
107
-
108
- var strValue = typeof value === 'string' ? value : '' + value;
109
-
94
+ const strValue = typeof value === 'string' ? value : '' + value;
110
95
  if (typeof languageOrDatatype === 'string') {
111
96
  if (languageOrDatatype.indexOf(':') === -1) {
112
97
  return new Literal(strValue, languageOrDatatype);
@@ -117,15 +102,13 @@ var CanonicalDataFactory = {
117
102
  return new Literal(strValue, null, languageOrDatatype);
118
103
  }
119
104
  },
120
-
121
105
  /**
122
106
  * Creates a new named node
123
107
  * @param value - The new named node
124
108
  */
125
- namedNode: function namedNode(value) {
109
+ namedNode(value) {
126
110
  return new NamedNode(value);
127
111
  },
128
-
129
112
  /**
130
113
  * Creates a new statement
131
114
  * @param subject - The subject
@@ -133,10 +116,9 @@ var CanonicalDataFactory = {
133
116
  * @param object - The object
134
117
  * @param graph - The containing graph
135
118
  */
136
- quad: function quad(subject, predicate, object, graph) {
137
- return new Statement(subject, predicate, object, graph || _defaultGraph);
119
+ quad(subject, predicate, object, graph) {
120
+ return new Statement(subject, predicate, object, graph || defaultGraph);
138
121
  },
139
-
140
122
  /**
141
123
  * Creates a new statement
142
124
  * @param subject - The subject
@@ -144,61 +126,47 @@ var CanonicalDataFactory = {
144
126
  * @param object - The object
145
127
  * @param graph - The containing graph
146
128
  */
147
- triple: function triple(subject, predicate, object, graph) {
129
+ triple(subject, predicate, object, graph) {
148
130
  return this.quad(subject, predicate, object, graph);
149
131
  },
150
- quadToNQ: function quadToNQ(q) {
151
- return "".concat(this.termToNQ(q.subject), " ").concat(this.termToNQ(q.predicate), " ").concat(this.termToNQ(q.object), " ").concat(this.termToNQ(q.graph), " .");
132
+ quadToNQ(q) {
133
+ return `${this.termToNQ(q.subject)} ${this.termToNQ(q.predicate)} ${this.termToNQ(q.object)} ${this.termToNQ(q.graph)} .`;
152
134
  },
153
-
154
135
  /** Stringify a {term} to n-quads serialization. */
155
- termToNQ: function termToNQ(term) {
156
- var _this = this;
157
-
136
+ termToNQ(term) {
158
137
  switch (term.termType) {
159
138
  case BlankNodeTermType:
160
139
  return '_:' + term.value;
161
-
162
140
  case DefaultGraphTermType:
163
141
  return '';
164
-
165
142
  case EmptyTermType:
166
143
  return '<http://www.w3.org/1999/02/22-rdf-syntax-ns#nil>';
167
-
168
144
  case LiteralTermType:
169
145
  return Literal.toNT(term);
170
-
171
146
  case GraphTermType:
172
147
  case NamedNodeTermType:
173
148
  return '<' + term.value + '>';
174
-
175
149
  case CollectionTermType:
176
- return '(' + term.elements.map(function (t) {
177
- return _this.termToNQ(t);
178
- }).join(' ') + ')';
179
-
150
+ return '(' + term.elements.map(t => this.termToNQ(t)).join(' ') + ')';
180
151
  default:
181
- throw new Error("Can't serialize nonstandard term type (was '".concat(term.termType, "')"));
152
+ throw new Error(`Can't serialize nonstandard term type (was '${term.termType}')`);
182
153
  }
183
154
  },
184
-
185
155
  /** Convert an rdf object (term or quad) to n-quads serialization. */
186
- toNQ: function toNQ(term) {
156
+ toNQ(term) {
187
157
  if (this.isQuad(term)) {
188
158
  return this.quadToNQ(term);
189
159
  }
190
-
191
160
  return this.termToNQ(term);
192
161
  },
193
-
194
162
  /**
195
163
  * Creates a new variable
196
164
  * @param name - The name for the variable
197
165
  */
198
- variable: function variable(name) {
166
+ variable(name) {
199
167
  return new Variable(name);
200
168
  }
201
169
  };
202
- /** Contains the factory methods as defined in the spec, plus id */
203
170
 
171
+ /** Contains the factory methods as defined in the spec, plus id */
204
172
  export default CanonicalDataFactory;
@@ -1,55 +1,48 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
- var _supports;
4
-
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
-
7
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
8
-
9
1
  import Collection from '../collection';
10
2
  import CanonicalDataFactory from './canonical-data-factory';
11
3
  import { CollectionTermType } from '../types';
12
4
  import { Feature } from './factory-types';
13
5
  import { isCollection, isVariable } from '../utils/terms';
14
6
  import Variable from '../variable';
15
-
16
7
  /**
17
8
  * Data factory which also supports Collections
18
9
  *
19
10
  * Necessary for preventing circular dependencies.
20
11
  */
21
- var ExtendedTermFactory = _objectSpread(_objectSpread({}, CanonicalDataFactory), {}, {
22
- supports: (_supports = {}, _defineProperty(_supports, Feature.collections, true), _defineProperty(_supports, Feature.defaultGraphType, false), _defineProperty(_supports, Feature.equalsMethod, true), _defineProperty(_supports, Feature.identity, false), _defineProperty(_supports, Feature.id, true), _defineProperty(_supports, Feature.reversibleId, false), _defineProperty(_supports, Feature.variableType, true), _supports),
23
-
12
+ const ExtendedTermFactory = {
13
+ ...CanonicalDataFactory,
14
+ supports: {
15
+ [Feature.collections]: true,
16
+ [Feature.defaultGraphType]: false,
17
+ [Feature.equalsMethod]: true,
18
+ [Feature.identity]: false,
19
+ [Feature.id]: true,
20
+ [Feature.reversibleId]: false,
21
+ [Feature.variableType]: true
22
+ },
24
23
  /**
25
24
  * Creates a new collection
26
25
  * @param elements - The initial element
27
26
  */
28
- collection: function collection(elements) {
27
+ collection(elements) {
29
28
  return new Collection(elements);
30
29
  },
31
- id: function id(term) {
32
- var _this = this;
33
-
30
+ id(term) {
34
31
  if (isCollection(term)) {
35
- return "( ".concat(term.elements.map(function (e) {
36
- return _this.id(e);
37
- }).join(', '), " )");
32
+ return `( ${term.elements.map(e => {
33
+ return this.id(e);
34
+ }).join(', ')} )`;
38
35
  }
39
-
40
36
  if (isVariable(term)) {
41
37
  return Variable.toString(term);
42
38
  }
43
-
44
39
  return CanonicalDataFactory.id(term);
45
40
  },
46
- termToNQ: function termToNQ(term) {
41
+ termToNQ(term) {
47
42
  if (term.termType === CollectionTermType) {
48
43
  return Collection.toNT(term);
49
44
  }
50
-
51
45
  return CanonicalDataFactory.termToNQ(term);
52
46
  }
53
- });
54
-
47
+ };
55
48
  export default ExtendedTermFactory;
@@ -1,12 +1,13 @@
1
1
  /** A set of features that may be supported by a Data Factory */
2
- export var Feature;
2
+
3
+ export let Feature;
4
+
3
5
  /**
4
6
  * Defines a DataFactory as used in rdflib, based on the RDF/JS: Data model specification,
5
7
  * but with additional extensions
6
8
  *
7
9
  * bnIndex is optional but useful.
8
10
  */
9
-
10
11
  (function (Feature) {
11
12
  Feature["collections"] = "COLLECTIONS";
12
13
  Feature["defaultGraphType"] = "DEFAULT_GRAPH_TYPE";
@@ -1,45 +1,36 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
1
  import IndexedFormula from '../store';
8
2
  import Fetcher from '../fetcher';
9
3
  import ExtendedTermFactory from './extended-term-factory';
10
-
11
4
  /** Full RDFLib.js Data Factory */
12
- var RDFlibDataFactory = _objectSpread(_objectSpread({}, ExtendedTermFactory), {}, {
5
+ const RDFlibDataFactory = {
6
+ ...ExtendedTermFactory,
13
7
  /**
14
8
  * Creates a new fetcher
15
9
  * @param store - The store to use
16
10
  * @param options - The options
17
11
  */
18
- fetcher: function fetcher(store, options) {
12
+ fetcher(store, options) {
19
13
  return new Fetcher(store, options);
20
14
  },
21
-
22
15
  /**
23
16
  * Creates a new graph (store)
24
17
  */
25
- graph: function graph() {
26
- var features = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
27
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
18
+ graph() {
19
+ let features = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
20
+ let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
28
21
  return new IndexedFormula(features, opts || {
29
22
  rdfFactory: ExtendedTermFactory
30
23
  });
31
24
  },
32
-
33
25
  /**
34
26
  * Creates a new literal node
35
27
  * @param val The lexical value
36
28
  * @param lang The language
37
29
  * @param dt The datatype
38
30
  */
39
- lit: function lit(val, lang, dt) {
31
+ lit(val, lang, dt) {
40
32
  return this.literal('' + val, lang || dt);
41
33
  },
42
-
43
34
  /**
44
35
  * Creates a new statement
45
36
  * @param subject The subject
@@ -47,9 +38,8 @@ var RDFlibDataFactory = _objectSpread(_objectSpread({}, ExtendedTermFactory), {}
47
38
  * @param object The object
48
39
  * @param graph The containing graph
49
40
  */
50
- st: function st(subject, predicate, object, graph) {
41
+ st(subject, predicate, object, graph) {
51
42
  return this.quad(subject, predicate, object, graph);
52
43
  }
53
- });
54
-
44
+ };
55
45
  export default RDFlibDataFactory;