rdflib 2.2.20 → 2.2.21-acff123a

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 (112) 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 -126
  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 +105 -0
  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 -78
  37. package/esm/store.js +831 -1102
  38. package/esm/types.js +22 -21
  39. package/esm/update-manager.js +869 -1104
  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 +28 -19
  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 -129
  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.d.ts +13 -0
  67. package/lib/lists.js +113 -0
  68. package/lib/literal.js +120 -195
  69. package/lib/log.d.ts +0 -6
  70. package/lib/log.js +7 -8
  71. package/lib/n3parser.js +1030 -1436
  72. package/lib/named-node.js +69 -126
  73. package/lib/namespace.js +2 -7
  74. package/lib/node-internal.js +74 -107
  75. package/lib/node.js +2 -12
  76. package/lib/parse.d.ts +1 -1
  77. package/lib/parse.js +12 -32
  78. package/lib/patch-parser.js +11 -34
  79. package/lib/query-to-sparql.js +0 -23
  80. package/lib/query.js +62 -167
  81. package/lib/rdfaparser.js +796 -1009
  82. package/lib/rdfxmlparser.js +349 -466
  83. package/lib/serialize.js +11 -37
  84. package/lib/serializer.js +823 -1064
  85. package/lib/sparql-to-query.js +42 -167
  86. package/lib/statement.js +55 -84
  87. package/lib/store.d.ts +1 -1
  88. package/lib/store.js +850 -1112
  89. package/lib/tf-types.d.ts +4 -4
  90. package/lib/types.d.ts +8 -8
  91. package/lib/types.js +23 -23
  92. package/lib/update-manager.d.ts +1 -1
  93. package/lib/update-manager.js +865 -1101
  94. package/lib/updates-via.js +105 -164
  95. package/lib/uri.js +8 -61
  96. package/lib/utils/default-graph-uri.js +3 -5
  97. package/lib/utils/termValue.js +0 -2
  98. package/lib/utils/terms.d.ts +6 -1
  99. package/lib/utils/terms.js +29 -35
  100. package/lib/utils-js.js +23 -88
  101. package/lib/utils.js +10 -27
  102. package/lib/variable.js +34 -85
  103. package/lib/xsd-internal.js +0 -3
  104. package/lib/xsd.js +2 -6
  105. package/package.json +35 -36
  106. package/src/collection.ts +2 -0
  107. package/src/fetcher.ts +2 -2
  108. package/src/lists.ts +121 -0
  109. package/src/statement.ts +7 -0
  110. package/src/store.ts +7 -7
  111. package/src/update-manager.ts +15 -9
  112. package/src/utils/terms.ts +23 -1
package/lib/serialize.js CHANGED
@@ -1,31 +1,20 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
4
  Object.defineProperty(exports, "__esModule", {
8
5
  value: true
9
6
  });
10
7
  exports.default = serialize;
11
-
12
8
  var convert = _interopRequireWildcard(require("./convert"));
13
-
14
9
  var _serializer = _interopRequireDefault(require("./serializer"));
15
-
16
10
  var _types = require("./types");
17
-
18
- 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); }
19
-
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
11
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
22
13
  /**
23
14
  * Serialize to the appropriate format
24
15
  */
25
- function serialize(
26
- /** The graph or nodes that should be serialized */
27
- target,
28
- /** The store */
16
+ function serialize( /** The graph or nodes that should be serialized */
17
+ target, /** The store */
29
18
  kb, base,
30
19
  /**
31
20
  * The mime type.
@@ -33,71 +22,57 @@ kb, base,
33
22
  */
34
23
  contentType, callback, options) {
35
24
  base = base || (target === null || target === void 0 ? void 0 : target.value);
36
- var opts = options || {};
25
+ const opts = options || {};
37
26
  contentType = contentType || _types.TurtleContentType; // text/n3 if complex?
38
-
39
27
  var documentString = undefined;
40
-
41
28
  try {
42
29
  var sz = (0, _serializer.default)(kb);
43
30
  if (opts.flags) sz.setFlags(opts.flags);
44
31
  var newSts = kb.statementsMatching(undefined, undefined, undefined, target);
45
- var n3String; // If an IndexedFormula, use the namespaces from the given graph as suggestions
32
+ var n3String;
46
33
 
34
+ // If an IndexedFormula, use the namespaces from the given graph as suggestions
47
35
  if ('namespaces' in kb) {
48
36
  sz.suggestNamespaces(kb.namespaces);
49
- } // use the provided options.namespaces are mandatory prefixes
50
-
37
+ }
51
38
 
39
+ // use the provided options.namespaces are mandatory prefixes
52
40
  if (opts.namespaces) {
53
41
  sz.setNamespaces(opts.namespaces);
54
42
  }
55
-
56
43
  sz.setBase(base);
57
-
58
44
  switch (contentType) {
59
45
  case _types.RDFXMLContentType:
60
46
  documentString = sz.statementsToXML(newSts);
61
47
  return executeCallback(null, documentString);
62
-
63
48
  case _types.N3ContentType:
64
49
  case _types.N3LegacyContentType:
65
50
  documentString = sz.statementsToN3(newSts);
66
51
  return executeCallback(null, documentString);
67
-
68
52
  case _types.TurtleContentType:
69
53
  case _types.TurtleLegacyContentType:
70
54
  sz.setFlags('si'); // Suppress = for sameAs and => for implies
71
-
72
55
  documentString = sz.statementsToN3(newSts);
73
56
  return executeCallback(null, documentString);
74
-
75
57
  case _types.NTriplesContentType:
76
58
  sz.setFlags('deinprstux'); // Suppress nice parts of N3 to make ntriples
77
-
78
59
  documentString = sz.statementsToNTriples(newSts);
79
60
  return executeCallback(null, documentString);
80
-
81
61
  case _types.JSONLDContentType:
82
62
  sz.setFlags('deinprstux'); // Use adapters to connect to incmpatible parser
83
-
84
- n3String = sz.statementsToNTriples(newSts); // n3String = sz.statementsToN3(newSts)
85
-
63
+ n3String = sz.statementsToNTriples(newSts);
64
+ // n3String = sz.statementsToN3(newSts)
86
65
  convert.convertToJson(n3String, callback);
87
66
  break;
88
-
89
67
  case _types.NQuadsContentType:
90
68
  case _types.NQuadsAltContentType:
91
69
  // @@@ just outpout the quads? Does not work for collections
92
70
  sz.setFlags('deinprstux q'); // Suppress nice parts of N3 to make ntriples
93
-
94
71
  documentString = sz.statementsToNTriples(newSts); // q in flag means actually quads
95
-
96
72
  return executeCallback(null, documentString);
97
73
  // n3String = sz.statementsToN3(newSts)
98
74
  // documentString = convert.convertToNQuads(n3String, callback)
99
75
  // break
100
-
101
76
  default:
102
77
  throw new Error('Serialize: Content-type ' + contentType + ' not supported for data write.');
103
78
  }
@@ -106,7 +81,6 @@ contentType, callback, options) {
106
81
  // @ts-ignore
107
82
  return callback(err, undefined);
108
83
  }
109
-
110
84
  throw err; // Don't hide problems from caller in sync mode
111
85
  }
112
86