rdflib 2.2.19 → 2.2.20-506bc192

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/lib/lists.js ADDED
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.convertFirstRestNil = convertFirstRestNil;
9
+ exports.substituteInDoc = substituteInDoc;
10
+ exports.substituteNillsInDoc = substituteNillsInDoc;
11
+
12
+ var _collection = _interopRequireDefault(require("./collection"));
13
+
14
+ var _statement = _interopRequireDefault(require("./statement"));
15
+
16
+ var _namespace = _interopRequireDefault(require("./namespace"));
17
+
18
+ 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; } } }; }
19
+
20
+ 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); }
21
+
22
+ 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; }
23
+
24
+ var RDF = (0, _namespace.default)('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
25
+ /* Replace a given node with another node throughout a given document
26
+ *
27
+ * we do the predicate as well for complenesss though we don't expect Collections to use it
28
+ */
29
+
30
+ function substituteInDoc(store, x, y, doc) {
31
+ // console.log(`substituteInDoc put ${x} for ${y} in ${doc}}`)
32
+ var _iterator = _createForOfIteratorHelper(store.statementsMatching(y, null, null, doc)),
33
+ _step;
34
+
35
+ try {
36
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
37
+ var quad = _step.value;
38
+ var newStatement = new _statement.default(x, quad.predicate, quad.object, doc);
39
+ store.remove(quad);
40
+ store.add(newStatement);
41
+ }
42
+ } catch (err) {
43
+ _iterator.e(err);
44
+ } finally {
45
+ _iterator.f();
46
+ }
47
+
48
+ var _iterator2 = _createForOfIteratorHelper(store.statementsMatching(null, y, null, doc)),
49
+ _step2;
50
+
51
+ try {
52
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
53
+ var _quad = _step2.value;
54
+ store.remove(_quad); // console.log(` substituteInDoc predicate ${x} in ${quad}}`)
55
+
56
+ store.add(new _statement.default(_quad.subject, x, _quad.object, doc));
57
+ }
58
+ } catch (err) {
59
+ _iterator2.e(err);
60
+ } finally {
61
+ _iterator2.f();
62
+ }
63
+
64
+ var _iterator3 = _createForOfIteratorHelper(store.statementsMatching(null, null, y, doc)),
65
+ _step3;
66
+
67
+ try {
68
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
69
+ var _quad2 = _step3.value;
70
+ store.remove(_quad2);
71
+ store.add(new _statement.default(_quad2.subject, _quad2.predicate, x, doc));
72
+ }
73
+ } catch (err) {
74
+ _iterator3.e(err);
75
+ } finally {
76
+ _iterator3.f();
77
+ }
78
+ }
79
+ /* Change all lone rdf:nil nodes into empty Collections
80
+ */
81
+
82
+
83
+ function substituteNillsInDoc(store, doc) {
84
+ var x = RDF('nil');
85
+
86
+ var _iterator4 = _createForOfIteratorHelper(store.statementsMatching(x, null, null, doc)),
87
+ _step4;
88
+
89
+ try {
90
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
91
+ var quad = _step4.value;
92
+ store.remove(quad);
93
+ var y = new _collection.default();
94
+ store.add(new _statement.default(y, quad.predicate, quad.object, doc));
95
+ }
96
+ } catch (err) {
97
+ _iterator4.e(err);
98
+ } finally {
99
+ _iterator4.f();
100
+ }
101
+
102
+ var _iterator5 = _createForOfIteratorHelper(store.statementsMatching(null, null, x, doc)),
103
+ _step5;
104
+
105
+ try {
106
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
107
+ var _quad3 = _step5.value;
108
+
109
+ if (!_quad3.predicate.sameTerm(RDF('rest'))) {
110
+ // If not a tail
111
+ store.remove(_quad3);
112
+
113
+ var _y = new _collection.default();
114
+
115
+ store.add(new _statement.default(_quad3.subject, _quad3.predicate, _y, doc));
116
+ }
117
+ }
118
+ } catch (err) {
119
+ _iterator5.e(err);
120
+ } finally {
121
+ _iterator5.f();
122
+ }
123
+ }
124
+ /**
125
+ * Convert lists reified as rdf:first, rest
126
+ * Normal method is sync.
127
+ * Unfortunately jsdonld is currently written to need to be called async.
128
+ * Hence the mess below with executeCallback.
129
+ * @param store - The quadstore
130
+ * @param doc - The document in which the conversion is done
131
+ */
132
+
133
+
134
+ function convertFirstRestNil(store, doc // Do whole store?
135
+ ) {
136
+ function preceding(ele, listSoFar, trash) {
137
+ var rests = store.statementsMatching(ele, RDF('rest'), null, doc);
138
+ if (rests.length !== 1) throw new Error("Bad list structure: no rest at ".concat(ele));
139
+ var firsts = store.statementsMatching(ele, RDF('first'), null, doc);
140
+ if (firsts.length !== 1) throw new Error("Bad list structure: rest but ".concat(firsts.length, " firsts at ").concat(ele));
141
+ var value = firsts[0].object;
142
+ var total = [value].concat(listSoFar); // console.log(' List now is: ', total)
143
+
144
+ var totalTrash = trash.concat(rests).concat(firsts);
145
+ var pres = store.statementsMatching(null, RDF('rest'), ele, doc);
146
+
147
+ if (pres.length === 0) {
148
+ // Head of the list
149
+ var newList = new _collection.default(total);
150
+ store.remove(totalTrash); // Replace old list with new list:
151
+
152
+ substituteInDoc(store, newList, ele, doc);
153
+ return;
154
+ }
155
+
156
+ if (pres.length !== 1) throw new Error("Bad list structure: ".concat(pres.length, " pres at ").concat(ele));
157
+ var pre = pres[0].subject;
158
+ if (pre.termType !== 'BlankNode') throw new Error("Bad list element node ".concat(pre, " type: ").concat(pre.termType, " "));
159
+ preceding(pre, total, totalTrash);
160
+ return;
161
+ }
162
+
163
+ substituteNillsInDoc(store, doc); // lone ones only
164
+
165
+ var tails = store.statementsMatching(null, RDF('rest'), RDF('nil'), doc);
166
+ tails.forEach(function (tail) {
167
+ if (tail.subject.termType !== 'BlankNode') throw new Error("Bad list element node ".concat(tail.subject, " type: ").concat(tail.subject.termType, " "));
168
+ preceding(tail.subject, [], []);
169
+ });
170
+ }
@@ -26,7 +26,7 @@ export class Serializer {
26
26
  toStr(x: any): any;
27
27
  fromStr(s: any): any;
28
28
  /**
29
- * Defines a set of [prefix, namespace] pairs to be uised by this Serializer instance.
29
+ * Defines a set of [prefix, namespace] pairs to be used by this Serializer instance.
30
30
  * Overrides previous prefixes if any
31
31
  * @param namespaces
32
32
  * @return {Serializer}
package/lib/serializer.js CHANGED
@@ -81,7 +81,7 @@ var Serializer = /*#__PURE__*/function () {
81
81
  this.prefixchars = 'abcdefghijklmnopqustuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
82
82
  this.incoming = null; // Array not calculated yet
83
83
 
84
- this.formulas = []; // remebering original formulae from hashes
84
+ this.formulas = []; // remembering original formulae from hashes
85
85
 
86
86
  this.store = store;
87
87
  this.rdfFactory = store.rdfFactory || _canonicalDataFactory.default;
@@ -123,7 +123,7 @@ var Serializer = /*#__PURE__*/function () {
123
123
  return this.store.fromNT(s);
124
124
  }
125
125
  /**
126
- * Defines a set of [prefix, namespace] pairs to be uised by this Serializer instance.
126
+ * Defines a set of [prefix, namespace] pairs to be used by this Serializer instance.
127
127
  * Overrides previous prefixes if any
128
128
  * @param namespaces
129
129
  * @return {Serializer}
@@ -686,7 +686,7 @@ var Serializer = /*#__PURE__*/function () {
686
686
  return val;
687
687
 
688
688
  case 'http://www.w3.org/2001/XMLSchema#decimal':
689
- // In urtle must have dot
689
+ // In Turtle, must have dot
690
690
  if (val.indexOf('.') < 0) val += '.0';
691
691
  return val;
692
692
 
@@ -717,6 +717,9 @@ var Serializer = /*#__PURE__*/function () {
717
717
  case 'NamedNode':
718
718
  return this.symbolToN3(expr);
719
719
 
720
+ case 'DefaultGraph':
721
+ return '';
722
+
720
723
  default:
721
724
  throw new Error('Internal: atomicTermToN3 cannot handle ' + expr + ' of termType: ' + expr.termType);
722
725
  }
package/lib/statement.js CHANGED
@@ -134,6 +134,13 @@ var Statement = /*#__PURE__*/function () {
134
134
  }, {
135
135
  key: "toString",
136
136
  value: function toString() {
137
+ /*
138
+ return [
139
+ this.subject.toString(),
140
+ this.predicate.toString(),
141
+ this.object.toString(),
142
+ ].join(' ') + ' .'
143
+ */
137
144
  return this.toNT();
138
145
  }
139
146
  }]);
package/lib/store.js CHANGED
@@ -450,11 +450,11 @@ var IndexedFormula = /*#__PURE__*/function (_Formula) {
450
450
 
451
451
  why = _node.default.fromValue(why);
452
452
 
453
- if (!(0, _terms.isSubject)(subj)) {
453
+ if (!(0, _terms.isRDFlibSubject)(subj)) {
454
454
  throw new Error('Subject is not a subject type');
455
455
  }
456
456
 
457
- if (!(0, _terms.isPredicate)(pred)) {
457
+ if (!(0, _terms.isRDFlibPredicate)(pred)) {
458
458
  throw new Error("Predicate ".concat(pred, " is not a predicate type"));
459
459
  }
460
460
 
@@ -1012,7 +1012,7 @@ var IndexedFormula = /*#__PURE__*/function (_Formula) {
1012
1012
  }, {
1013
1013
  key: "removeMatches",
1014
1014
  value: function removeMatches(subject, predicate, object, graph) {
1015
- this.removeStatements(this.statementsMatching(subject, predicate, object, graph));
1015
+ this.removeMany(subject, predicate, object, graph);
1016
1016
  return this;
1017
1017
  }
1018
1018
  /**
@@ -1,8 +1,8 @@
1
1
  import IndexedFormula from './store';
2
- import Fetcher from './fetcher';
2
+ import Fetcher, { Options } from './fetcher';
3
3
  import Statement from './statement';
4
4
  import RDFlibNamedNode from './named-node';
5
- import { BlankNode, NamedNode, Quad_Subject, Quad, Term } from './tf-types';
5
+ import { BlankNode, NamedNode, Quad, Quad_Subject, Term } from './tf-types';
6
6
  interface UpdateManagerFormula extends IndexedFormula {
7
7
  fetcher: Fetcher;
8
8
  }
@@ -41,6 +41,7 @@ export default class UpdateManager {
41
41
  editable(uri: string | NamedNode, kb?: IndexedFormula): string | boolean | undefined;
42
42
  anonymize(obj: any): any;
43
43
  anonymizeNT(stmt: Quad): string;
44
+ nTriples(stmt: any): string;
44
45
  /**
45
46
  * Returns a list of all bnodes occurring in a statement
46
47
  * @private
@@ -86,7 +87,7 @@ export default class UpdateManager {
86
87
  /**
87
88
  * @private
88
89
  */
89
- fire(uri: string, query: string, callbackFunction: CallBackFunction): Promise<void>;
90
+ fire(uri: string, query: string, callbackFunction: CallBackFunction, options?: Options): Promise<void>;
90
91
  /** return a statemnet updating function
91
92
  *
92
93
  * This does NOT update the statement.
@@ -155,9 +156,10 @@ export default class UpdateManager {
155
156
  * @param insertions - Statement or statements to be inserted.
156
157
  * @param callback - called as callbackFunction(uri, success, errorbody)
157
158
  * OR returns a promise
159
+ * @param options - Options for the fetch call
158
160
  */
159
- update(deletions: ReadonlyArray<Statement>, insertions: ReadonlyArray<Statement>, callback?: (uri: string | undefined | null, success: boolean, errorBody?: string, response?: Response | Error) => void, secondTry?: boolean): void | Promise<void>;
160
- updateDav(doc: Quad_Subject, ds: any, is: any, callbackFunction: any): null | Promise<void>;
161
+ update(deletions: ReadonlyArray<Statement>, insertions: ReadonlyArray<Statement>, callback?: (uri: string | undefined | null, success: boolean, errorBody?: string, response?: Response | Error) => void, secondTry?: boolean, options?: Options): void | Promise<void>;
162
+ updateDav(doc: Quad_Subject, ds: any, is: any, callbackFunction: any, options?: Options): null | Promise<void>;
161
163
  /**
162
164
  * Likely deprecated, since this lib no longer deals with browser extension
163
165
  *
@@ -165,8 +167,9 @@ export default class UpdateManager {
165
167
  * @param ds
166
168
  * @param is
167
169
  * @param callbackFunction
170
+ * @param options
168
171
  */
169
- updateLocalFile(doc: NamedNode, ds: any, is: any, callbackFunction: any): void;
172
+ updateLocalFile(doc: NamedNode, ds: any, is: any, callbackFunction: any, options?: Options): void;
170
173
  /**
171
174
  * @throws {Error} On unsupported content type
172
175
  *
@@ -236,6 +236,11 @@ var UpdateManager = /*#__PURE__*/function () {
236
236
  value: function anonymizeNT(stmt) {
237
237
  return this.anonymize(stmt.subject) + ' ' + this.anonymize(stmt.predicate) + ' ' + this.anonymize(stmt.object) + ' .';
238
238
  }
239
+ }, {
240
+ key: "nTriples",
241
+ value: function nTriples(stmt) {
242
+ return "".concat(stmt.subject.toNT(), " ").concat(stmt.predicate.toNT(), " ").concat(stmt.object.toNT(), " .");
243
+ }
239
244
  /**
240
245
  * Returns a list of all bnodes occurring in a statement
241
246
  * @private
@@ -437,17 +442,16 @@ var UpdateManager = /*#__PURE__*/function () {
437
442
  value: function fire(uri, query, callbackFunction) {
438
443
  var _this = this;
439
444
 
445
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
440
446
  return Promise.resolve().then(function () {
441
447
  if (!uri) {
442
448
  throw new Error('No URI given for remote editing operation: ' + query);
443
449
  } // console.log('UpdateManager: sending update to <' + uri + '>')
444
450
 
445
451
 
446
- var options = {
447
- noMeta: true,
448
- contentType: 'application/sparql-update',
449
- body: query
450
- };
452
+ options.noMeta = true;
453
+ options.contentType = 'application/sparql-update';
454
+ options.body = query;
451
455
  return _this.store.fetcher.webOperation('PATCH', uri, options);
452
456
  }).then(function (response) {
453
457
  if (!response.ok) {
@@ -798,8 +802,7 @@ var UpdateManager = /*#__PURE__*/function () {
798
802
  }));
799
803
  });
800
804
 
801
- if (updates.length > 1) {
802
- console.log("@@ updateMany to ".concat(updates.length, ": ").concat(uniqueDocs));
805
+ if (updates.length > 1) {// console.log(`@@ updateMany to ${updates.length}: ${uniqueDocs}`)
803
806
  }
804
807
 
805
808
  return Promise.all(updates);
@@ -812,6 +815,7 @@ var UpdateManager = /*#__PURE__*/function () {
812
815
  * @param insertions - Statement or statements to be inserted.
813
816
  * @param callback - called as callbackFunction(uri, success, errorbody)
814
817
  * OR returns a promise
818
+ * @param options - Options for the fetch call
815
819
  */
816
820
 
817
821
  }, {
@@ -819,6 +823,8 @@ var UpdateManager = /*#__PURE__*/function () {
819
823
  value: function update(deletions, insertions, callback, secondTry) {
820
824
  var _this3 = this;
821
825
 
826
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
827
+
822
828
  if (!callback) {
823
829
  var thisUpdater = this;
824
830
  return new Promise(function (resolve, reject) {
@@ -829,7 +835,7 @@ var UpdateManager = /*#__PURE__*/function () {
829
835
  } else {
830
836
  resolve();
831
837
  }
832
- }); // callbackFunction
838
+ }, secondTry, options); // callbackFunction
833
839
  }); // promise
834
840
  } // if
835
841
 
@@ -895,11 +901,11 @@ var UpdateManager = /*#__PURE__*/function () {
895
901
 
896
902
 
897
903
  this.store.fetcher.load(doc).then(function (response) {
898
- _this3.update(deletions, insertions, callback, true);
904
+ _this3.update(deletions, insertions, callback, true, options);
899
905
  }, function (err) {
900
906
  if (err.response.status === 404) {
901
907
  // nonexistent files are fine
902
- _this3.update(deletions, insertions, callback, true);
908
+ _this3.update(deletions, insertions, callback, true, options);
903
909
  } else {
904
910
  throw new Error("Update: Can't get updatability status ".concat(doc, " before patching: ").concat(err));
905
911
  }
@@ -953,7 +959,7 @@ var UpdateManager = /*#__PURE__*/function () {
953
959
  query += 'INSERT DATA { ';
954
960
 
955
961
  for (var _i7 = 0; _i7 < is.length; _i7++) {
956
- query += this.anonymizeNT(is[_i7]) + '\n';
962
+ query += this.nTriples(is[_i7]) + '\n';
957
963
  }
958
964
 
959
965
  query += ' }\n';
@@ -970,7 +976,10 @@ var UpdateManager = /*#__PURE__*/function () {
970
976
 
971
977
  this.fire(doc.value, query, function (uri, success, body, response) {
972
978
  response.elapsedTimeMs = Date.now() - startTime;
973
- console.log(' UpdateManager: Return ' + (success ? 'success ' : 'FAILURE ') + response.status + ' elapsed ' + response.elapsedTimeMs + 'ms');
979
+ /* console.log(' UpdateManager: Return ' +
980
+ (success ? 'success ' : 'FAILURE ') + (response as Response).status +
981
+ ' elapsed ' + (response as any).elapsedTimeMs + 'ms')
982
+ */
974
983
 
975
984
  if (success) {
976
985
  try {
@@ -995,13 +1004,13 @@ var UpdateManager = /*#__PURE__*/function () {
995
1004
 
996
1005
  downstreamAction(doc);
997
1006
  }
998
- });
1007
+ }, options);
999
1008
  } else if (protocol.indexOf('DAV') >= 0) {
1000
- this.updateDav(doc, ds, is, callback);
1009
+ this.updateDav(doc, ds, is, callback, options);
1001
1010
  } else {
1002
1011
  if (protocol.indexOf('LOCALFILE') >= 0) {
1003
1012
  try {
1004
- this.updateLocalFile(doc, ds, is, callback);
1013
+ this.updateLocalFile(doc, ds, is, callback, options);
1005
1014
  } catch (e) {
1006
1015
  callback(doc.value, false, 'Exception trying to write back file <' + doc.value + '>\n' // + tabulator.Util.stackString(e))
1007
1016
  );
@@ -1017,6 +1026,7 @@ var UpdateManager = /*#__PURE__*/function () {
1017
1026
  }, {
1018
1027
  key: "updateDav",
1019
1028
  value: function updateDav(doc, ds, is, callbackFunction) {
1029
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1020
1030
  var kb = this.store; // The code below is derived from Kenny's UpdateCenter.js
1021
1031
 
1022
1032
  var request = kb.any(doc, this.ns.link('request'));
@@ -1053,11 +1063,9 @@ var UpdateManager = /*#__PURE__*/function () {
1053
1063
  targetURI = (0, _uri.join)(candidateTarget.value, targetURI);
1054
1064
  }
1055
1065
 
1056
- var options = {
1057
- contentType: contentType,
1058
- noMeta: true,
1059
- body: documentString
1060
- };
1066
+ options.contentType = contentType;
1067
+ options.noMeta = true;
1068
+ options.body = documentString;
1061
1069
  return kb.fetcher.webOperation('PUT', targetURI, options).then(function (response) {
1062
1070
  if (!response.ok) {
1063
1071
  throw new Error(response.error);
@@ -1083,11 +1091,13 @@ var UpdateManager = /*#__PURE__*/function () {
1083
1091
  * @param ds
1084
1092
  * @param is
1085
1093
  * @param callbackFunction
1094
+ * @param options
1086
1095
  */
1087
1096
 
1088
1097
  }, {
1089
1098
  key: "updateLocalFile",
1090
1099
  value: function updateLocalFile(doc, ds, is, callbackFunction) {
1100
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
1091
1101
  var kb = this.store; // console.log('Writing back to local file\n')
1092
1102
  // prepare contents of revised document
1093
1103
 
@@ -1115,11 +1125,9 @@ var UpdateManager = /*#__PURE__*/function () {
1115
1125
  throw new Error('File extension .' + ext + ' not supported for data write');
1116
1126
  }
1117
1127
 
1118
- var documentString = this.serialize(doc.value, newSts, contentType);
1119
- kb.fetcher.webOperation('PUT', doc.value, {
1120
- "body": documentString,
1121
- contentType: contentType
1122
- }).then(function (response) {
1128
+ options.body = this.serialize(doc.value, newSts, contentType);
1129
+ options.contentType = contentType;
1130
+ kb.fetcher.webOperation('PUT', doc.value, options).then(function (response) {
1123
1131
  if (!response.ok) return callbackFunction(doc.value, false, response.error);
1124
1132
 
1125
1133
  for (var _i13 = 0; _i13 < ds.length; _i13++) {
@@ -9,8 +9,13 @@ export declare function isStatement(obj: any): obj is Statement;
9
9
  export declare function isStore(obj: any): obj is IndexedFormula;
10
10
  /** TypeGuard for RDFLib Collections */
11
11
  export declare function isCollection(obj: any): obj is Collection<any>;
12
- /** TypeGuard for valid RDFlib Object types, also allows Collections */
12
+ /** TypeGuard for valid RDFlib Object types, also allows Collections, Graphs */
13
13
  export declare function isRDFlibObject(obj: any): obj is ObjectType;
14
+ /** TypeGuard for valid RDFlib Subject types, same as Object as RDFLib symmetrical.
15
+ */
16
+ export declare function isRDFlibSubject(obj: any): obj is ObjectType;
17
+ /** TypeGuard for valid RDF/JS spec Predicate types */
18
+ export declare function isRDFlibPredicate(obj: any): obj is Quad_Predicate;
14
19
  /** TypeGuard for RDFLib Variables */
15
20
  export declare function isVariable(obj: any): obj is Variable;
16
21
  /** TypeGuard for RDF/JS spec Terms */
@@ -14,6 +14,8 @@ exports.isPredicate = isPredicate;
14
14
  exports.isQuad = isQuad;
15
15
  exports.isRDFObject = isRDFObject;
16
16
  exports.isRDFlibObject = isRDFlibObject;
17
+ exports.isRDFlibPredicate = isRDFlibPredicate;
18
+ exports.isRDFlibSubject = isRDFlibSubject;
17
19
  exports.isStatement = isStatement;
18
20
  exports.isStore = isStore;
19
21
  exports.isSubject = isSubject;
@@ -40,12 +42,25 @@ function isStore(obj) {
40
42
  function isCollection(obj) {
41
43
  return isTerm(obj) && obj.termType === _types.CollectionTermType;
42
44
  }
43
- /** TypeGuard for valid RDFlib Object types, also allows Collections */
45
+ /** TypeGuard for valid RDFlib Object types, also allows Collections, Graphs */
44
46
 
45
47
 
46
48
  function isRDFlibObject(obj) {
47
49
  return obj && Object.prototype.hasOwnProperty.call(obj, 'termType') && (obj.termType === _types.NamedNodeTermType || obj.termType === _types.VariableTermType || obj.termType === _types.BlankNodeTermType || obj.termType === _types.CollectionTermType || obj.termType === _types.LiteralTermType || obj.termType === _types.GraphTermType);
48
50
  }
51
+ /** TypeGuard for valid RDFlib Subject types, same as Object as RDFLib symmetrical.
52
+ */
53
+
54
+
55
+ function isRDFlibSubject(obj) {
56
+ return obj && Object.prototype.hasOwnProperty.call(obj, 'termType') && (obj.termType === _types.NamedNodeTermType || obj.termType === _types.VariableTermType || obj.termType === _types.BlankNodeTermType || obj.termType === _types.CollectionTermType || obj.termType === _types.LiteralTermType || obj.termType === _types.GraphTermType);
57
+ }
58
+ /** TypeGuard for valid RDF/JS spec Predicate types */
59
+
60
+
61
+ function isRDFlibPredicate(obj) {
62
+ return isTerm(obj) && (obj.termType === _types.NamedNodeTermType || obj.termType === _types.BlankNodeTermType || obj.termType === _types.VariableTermType);
63
+ }
49
64
  /** TypeGuard for RDFLib Variables */
50
65
 
51
66
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rdflib",
3
3
  "description": "an RDF library for node.js. Suitable for client and server side.",
4
- "version": "2.2.19",
4
+ "version": "2.2.20-506bc192",
5
5
  "private": false,
6
6
  "browserslist": [
7
7
  "> 0.5%"
@@ -64,7 +64,6 @@
64
64
  "@types/dirty-chai": "^2.0.2",
65
65
  "@types/express": "^4.17.13",
66
66
  "@types/jsonld": "^1.5.6",
67
- "@types/mocha": "^9.1.0",
68
67
  "@types/rdf-js": "^4.0.2",
69
68
  "@types/sinon-chai": "^3.2.8",
70
69
  "babel-loader": "^8.2.4",
package/src/collection.ts CHANGED
@@ -112,6 +112,8 @@ export default class Collection<
112
112
  }
113
113
 
114
114
  static toNT (collection) {
115
+ // return '(' + collection.elements.map(x => x.toNT()).join(' ') + ')'
116
+ // As lists are not in NT and toNT() must be a reversible function, we kludge it for a list
115
117
  return RdflibBlankNode.NTAnonymousNodePrefix + collection.id
116
118
  }
117
119
 
package/src/fetcher.ts CHANGED
@@ -133,7 +133,7 @@ type UserCallback = (
133
133
  type HTTPMethods = 'GET' | 'PUT' | 'POST' | 'PATCH' | 'HEAD' | 'DELETE' | 'CONNECT' | 'TRACE' | 'OPTIONS'
134
134
 
135
135
  /** All valid inputs for initFetchOptions */
136
- type Options = Partial<AutoInitOptions>
136
+ export type Options = Partial<AutoInitOptions>
137
137
 
138
138
  /** Initiated by initFetchOptions, which runs on load */
139
139
  export interface AutoInitOptions extends RequestInit{
@@ -1571,8 +1571,8 @@ export default class Fetcher implements CallbackifyInterface {
1571
1571
  }
1572
1572
 
1573
1573
  /**
1574
- * A generic web opeation, at the fetch() level.
1575
- * does not invole the quadstore.
1574
+ * A generic web operation, at the fetch() level.
1575
+ * does not involve the quad store.
1576
1576
  *
1577
1577
  * Returns promise of Response
1578
1578
  * If data is returned, copies it to response.responseText before returning