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
package/esm/serialize.js CHANGED
@@ -1,14 +1,11 @@
1
1
  import * as convert from './convert';
2
2
  import Serializer from './serializer';
3
3
  import { JSONLDContentType, N3ContentType, N3LegacyContentType, NQuadsAltContentType, NQuadsContentType, NTriplesContentType, RDFXMLContentType, TurtleContentType, TurtleLegacyContentType } from './types';
4
-
5
4
  /**
6
5
  * Serialize to the appropriate format
7
6
  */
8
- export default function serialize(
9
- /** The graph or nodes that should be serialized */
10
- target,
11
- /** The store */
7
+ export default function serialize( /** The graph or nodes that should be serialized */
8
+ target, /** The store */
12
9
  kb, base,
13
10
  /**
14
11
  * The mime type.
@@ -16,71 +13,57 @@ kb, base,
16
13
  */
17
14
  contentType, callback, options) {
18
15
  base = base || (target === null || target === void 0 ? void 0 : target.value);
19
- var opts = options || {};
16
+ const opts = options || {};
20
17
  contentType = contentType || TurtleContentType; // text/n3 if complex?
21
-
22
18
  var documentString = undefined;
23
-
24
19
  try {
25
20
  var sz = Serializer(kb);
26
21
  if (opts.flags) sz.setFlags(opts.flags);
27
22
  var newSts = kb.statementsMatching(undefined, undefined, undefined, target);
28
- var n3String; // If an IndexedFormula, use the namespaces from the given graph as suggestions
23
+ var n3String;
29
24
 
25
+ // If an IndexedFormula, use the namespaces from the given graph as suggestions
30
26
  if ('namespaces' in kb) {
31
27
  sz.suggestNamespaces(kb.namespaces);
32
- } // use the provided options.namespaces are mandatory prefixes
33
-
28
+ }
34
29
 
30
+ // use the provided options.namespaces are mandatory prefixes
35
31
  if (opts.namespaces) {
36
32
  sz.setNamespaces(opts.namespaces);
37
33
  }
38
-
39
34
  sz.setBase(base);
40
-
41
35
  switch (contentType) {
42
36
  case RDFXMLContentType:
43
37
  documentString = sz.statementsToXML(newSts);
44
38
  return executeCallback(null, documentString);
45
-
46
39
  case N3ContentType:
47
40
  case N3LegacyContentType:
48
41
  documentString = sz.statementsToN3(newSts);
49
42
  return executeCallback(null, documentString);
50
-
51
43
  case TurtleContentType:
52
44
  case TurtleLegacyContentType:
53
45
  sz.setFlags('si'); // Suppress = for sameAs and => for implies
54
-
55
46
  documentString = sz.statementsToN3(newSts);
56
47
  return executeCallback(null, documentString);
57
-
58
48
  case NTriplesContentType:
59
49
  sz.setFlags('deinprstux'); // Suppress nice parts of N3 to make ntriples
60
-
61
50
  documentString = sz.statementsToNTriples(newSts);
62
51
  return executeCallback(null, documentString);
63
-
64
52
  case JSONLDContentType:
65
53
  sz.setFlags('deinprstux'); // Use adapters to connect to incmpatible parser
66
-
67
- n3String = sz.statementsToNTriples(newSts); // n3String = sz.statementsToN3(newSts)
68
-
54
+ n3String = sz.statementsToNTriples(newSts);
55
+ // n3String = sz.statementsToN3(newSts)
69
56
  convert.convertToJson(n3String, callback);
70
57
  break;
71
-
72
58
  case NQuadsContentType:
73
59
  case NQuadsAltContentType:
74
60
  // @@@ just outpout the quads? Does not work for collections
75
61
  sz.setFlags('deinprstux q'); // Suppress nice parts of N3 to make ntriples
76
-
77
62
  documentString = sz.statementsToNTriples(newSts); // q in flag means actually quads
78
-
79
63
  return executeCallback(null, documentString);
80
64
  // n3String = sz.statementsToN3(newSts)
81
65
  // documentString = convert.convertToNQuads(n3String, callback)
82
66
  // break
83
-
84
67
  default:
85
68
  throw new Error('Serialize: Content-type ' + contentType + ' not supported for data write.');
86
69
  }
@@ -89,7 +72,6 @@ contentType, callback, options) {
89
72
  // @ts-ignore
90
73
  return callback(err, undefined);
91
74
  }
92
-
93
75
  throw err; // Don't hide problems from caller in sync mode
94
76
  }
95
77