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