rdflib 2.2.21 → 2.2.22-04669b23

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 (118) hide show
  1. package/dist/rdflib.min.js +1 -1
  2. package/dist/rdflib.min.js.LICENSE.txt +11 -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/default-graph.js +14 -48
  8. package/esm/empty.js +8 -39
  9. package/esm/factories/canonical-data-factory.js +33 -65
  10. package/esm/factories/extended-term-factory.js +18 -25
  11. package/esm/factories/factory-types.js +3 -2
  12. package/esm/factories/rdflib-data-factory.js +9 -19
  13. package/esm/fetcher.js +1341 -1854
  14. package/esm/formula.js +639 -846
  15. package/esm/index.js +40 -77
  16. package/esm/jsonldparser.js +34 -50
  17. package/esm/jsonparser.js +1 -8
  18. package/esm/lists.js +47 -110
  19. package/esm/literal.js +120 -189
  20. package/esm/log.js +7 -7
  21. package/esm/n3parser.js +1022 -1412
  22. package/esm/named-node.js +70 -119
  23. package/esm/namespace.js +2 -5
  24. package/esm/node-internal.js +73 -110
  25. package/esm/node.js +2 -7
  26. package/esm/parse.js +12 -19
  27. package/esm/patch-parser.js +10 -30
  28. package/esm/query-to-sparql.js +0 -18
  29. package/esm/query.js +63 -147
  30. package/esm/rdfaparser.js +794 -997
  31. package/esm/rdfxmlparser.js +347 -461
  32. package/esm/serialize.js +9 -34
  33. package/esm/serializer.js +842 -1048
  34. package/esm/sparql-to-query.js +44 -134
  35. package/esm/statement.js +54 -85
  36. package/esm/store.js +830 -1103
  37. package/esm/types.js +22 -21
  38. package/esm/update-manager.js +869 -1106
  39. package/esm/updates-via.js +104 -161
  40. package/esm/uri.js +9 -53
  41. package/esm/utils/default-graph-uri.js +3 -2
  42. package/esm/utils/termValue.js +0 -1
  43. package/esm/utils/terms.js +19 -21
  44. package/esm/utils-js.js +20 -61
  45. package/esm/utils.js +10 -21
  46. package/esm/variable.js +32 -78
  47. package/esm/xsd.js +2 -2
  48. package/lib/blank-node.js +60 -113
  49. package/lib/class-order.js +1 -2
  50. package/lib/collection.js +69 -131
  51. package/lib/default-graph.js +13 -52
  52. package/lib/empty.js +8 -43
  53. package/lib/factories/canonical-data-factory.js +35 -79
  54. package/lib/factories/extended-term-factory.js +18 -32
  55. package/lib/factories/factory-types.d.ts +6 -6
  56. package/lib/factories/factory-types.js +1 -4
  57. package/lib/factories/rdflib-data-factory.js +9 -23
  58. package/lib/fetcher.d.ts +6 -6
  59. package/lib/fetcher.js +1370 -1843
  60. package/lib/formula.d.ts +1 -1
  61. package/lib/formula.js +640 -855
  62. package/lib/index.d.ts +1 -2
  63. package/lib/index.js +67 -156
  64. package/lib/jsonldparser.js +33 -54
  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.d.ts +1 -0
  71. package/lib/n3parser.js +1023 -1422
  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.d.ts +1 -1
  84. package/lib/serialize.js +9 -44
  85. package/lib/serializer.d.ts +1 -0
  86. package/lib/serializer.js +846 -1063
  87. package/lib/sparql-to-query.js +42 -167
  88. package/lib/statement.js +55 -91
  89. package/lib/store.d.ts +2 -2
  90. package/lib/store.js +850 -1112
  91. package/lib/tf-types.d.ts +4 -4
  92. package/lib/types.d.ts +8 -8
  93. package/lib/types.js +23 -23
  94. package/lib/update-manager.d.ts +1 -1
  95. package/lib/update-manager.js +865 -1103
  96. package/lib/updates-via.js +105 -164
  97. package/lib/uri.js +8 -61
  98. package/lib/utils/default-graph-uri.js +3 -5
  99. package/lib/utils/termValue.js +0 -2
  100. package/lib/utils/terms.js +19 -40
  101. package/lib/utils-js.js +23 -88
  102. package/lib/utils.js +10 -27
  103. package/lib/variable.js +34 -85
  104. package/lib/xsd-internal.js +0 -3
  105. package/lib/xsd.js +2 -6
  106. package/package.json +40 -39
  107. package/src/fetcher.ts +2 -2
  108. package/src/index.ts +0 -2
  109. package/src/jsonldparser.js +13 -4
  110. package/src/n3parser.js +12 -4
  111. package/src/serialize.ts +4 -11
  112. package/src/serializer.js +24 -0
  113. package/src/update-manager.ts +12 -7
  114. package/changes.txt +0 -59
  115. package/esm/convert.js +0 -61
  116. package/lib/convert.d.ts +0 -2
  117. package/lib/convert.js +0 -77
  118. package/src/convert.js +0 -70
@@ -23,4 +23,4 @@ contentType?: string | ContentType, callback?: (err: Error | undefined | null, r
23
23
  * A set of [prefix, uri] pairs that define namespace prefixes
24
24
  */
25
25
  namespaces?: Record<string, string>;
26
- }): string | undefined;
26
+ }): string | undefined | Promise<string>;
package/lib/serialize.js CHANGED
@@ -1,31 +1,17 @@
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
- var convert = _interopRequireWildcard(require("./convert"));
13
-
14
8
  var _serializer = _interopRequireDefault(require("./serializer"));
15
-
16
9
  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
-
22
10
  /**
23
11
  * Serialize to the appropriate format
24
12
  */
25
- function serialize(
26
- /** The graph or nodes that should be serialized */
27
- target,
28
- /** The store */
13
+ function serialize( /** The graph or nodes that should be serialized */
14
+ target, /** The store */
29
15
  kb, base,
30
16
  /**
31
17
  * The mime type.
@@ -33,71 +19,51 @@ kb, base,
33
19
  */
34
20
  contentType, callback, options) {
35
21
  base = base || (target === null || target === void 0 ? void 0 : target.value);
36
- var opts = options || {};
22
+ const opts = options || {};
37
23
  contentType = contentType || _types.TurtleContentType; // text/n3 if complex?
38
-
39
24
  var documentString = undefined;
40
-
41
25
  try {
42
26
  var sz = (0, _serializer.default)(kb);
43
27
  if (opts.flags) sz.setFlags(opts.flags);
44
28
  var newSts = kb.statementsMatching(undefined, undefined, undefined, target);
45
- var n3String; // If an IndexedFormula, use the namespaces from the given graph as suggestions
46
29
 
30
+ // If an IndexedFormula, use the namespaces from the given graph as suggestions
47
31
  if ('namespaces' in kb) {
48
32
  sz.suggestNamespaces(kb.namespaces);
49
- } // use the provided options.namespaces are mandatory prefixes
50
-
33
+ }
51
34
 
35
+ // use the provided options.namespaces are mandatory prefixes
52
36
  if (opts.namespaces) {
53
37
  sz.setNamespaces(opts.namespaces);
54
38
  }
55
-
56
39
  sz.setBase(base);
57
-
58
40
  switch (contentType) {
59
41
  case _types.RDFXMLContentType:
60
42
  documentString = sz.statementsToXML(newSts);
61
43
  return executeCallback(null, documentString);
62
-
63
44
  case _types.N3ContentType:
64
45
  case _types.N3LegacyContentType:
65
46
  documentString = sz.statementsToN3(newSts);
66
47
  return executeCallback(null, documentString);
67
-
68
48
  case _types.TurtleContentType:
69
49
  case _types.TurtleLegacyContentType:
70
50
  sz.setFlags('si'); // Suppress = for sameAs and => for implies
71
-
72
51
  documentString = sz.statementsToN3(newSts);
73
52
  return executeCallback(null, documentString);
74
-
75
53
  case _types.NTriplesContentType:
76
54
  sz.setFlags('deinprstux'); // Suppress nice parts of N3 to make ntriples
77
-
78
55
  documentString = sz.statementsToNTriples(newSts);
79
56
  return executeCallback(null, documentString);
80
-
81
57
  case _types.JSONLDContentType:
82
- sz.setFlags('deinprstux'); // Use adapters to connect to incmpatible parser
83
-
84
- n3String = sz.statementsToNTriples(newSts); // n3String = sz.statementsToN3(newSts)
85
-
86
- convert.convertToJson(n3String, callback);
87
- break;
88
-
58
+ sz.setFlags('si'); // use turtle parameters
59
+ documentString = sz.statementsToJsonld(newSts); // convert via turtle
60
+ return executeCallback(null, documentString);
89
61
  case _types.NQuadsContentType:
90
62
  case _types.NQuadsAltContentType:
91
63
  // @@@ just outpout the quads? Does not work for collections
92
64
  sz.setFlags('deinprstux q'); // Suppress nice parts of N3 to make ntriples
93
-
94
65
  documentString = sz.statementsToNTriples(newSts); // q in flag means actually quads
95
-
96
66
  return executeCallback(null, documentString);
97
- // n3String = sz.statementsToN3(newSts)
98
- // documentString = convert.convertToNQuads(n3String, callback)
99
- // break
100
-
101
67
  default:
102
68
  throw new Error('Serialize: Content-type ' + contentType + ' not supported for data write.');
103
69
  }
@@ -106,7 +72,6 @@ contentType, callback, options) {
106
72
  // @ts-ignore
107
73
  return callback(err, undefined);
108
74
  }
109
-
110
75
  throw err; // Don't hide problems from caller in sync mode
111
76
  }
112
77
 
@@ -63,5 +63,6 @@ export class Serializer {
63
63
  symbolToN3(x: any): any;
64
64
  writeStore(write: any): void;
65
65
  statementsToXML(sts: any): string;
66
+ statementsToJsonld(sts: any): string;
66
67
  }
67
68
  import NamedNode from "./named-node";