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
@@ -13,98 +13,78 @@ export default function sparqlUpdateParser(str, kb, base) {
13
13
  var SQNS = Namespace('http://www.w3.org/ns/pim/patch#');
14
14
  var p = N3Parser(kb, kb, base, base, null, null, '', null);
15
15
  var clauses = {};
16
-
17
- var badSyntax = function badSyntax(uri, lines, str, i, why) {
16
+ var badSyntax = function (uri, lines, str, i, why) {
18
17
  return 'Line ' + (lines + 1) + ' of <' + uri + '>: Bad syntax:\n ' + why + '\n at: "' + str.slice(i, i + 30) + '"';
19
- }; // var check = function (next, last, message) {
18
+ };
19
+
20
+ // var check = function (next, last, message) {
20
21
  // if (next < 0) {
21
22
  // throw badSyntax(p._thisDoc, p.lines, str, j, last, message)
22
23
  // }
23
24
  // return next
24
25
  // }
25
-
26
-
27
26
  i = 0;
28
27
  var query = kb.sym(base + '#query'); // Invent a URI for the query
29
-
30
28
  clauses['query'] = query; // A way of accessing it in its N3 model.
31
29
 
32
30
  while (true) {
33
31
  // console.log("A Now at i = " + i)
34
32
  j = p.skipSpace(str, i);
35
-
36
33
  if (j < 0) {
37
34
  return clauses;
38
- } // console.log("B After space at j= " + j)
39
-
40
-
35
+ }
36
+ // console.log("B After space at j= " + j)
41
37
  if (str[j] === ';') {
42
38
  i = p.skipSpace(str, j + 1);
43
-
44
39
  if (i < 0) {
45
40
  return clauses; // Allow end in a
46
41
  }
47
42
 
48
43
  j = i;
49
44
  }
50
-
51
45
  var found = false;
52
-
53
46
  for (k = 0; k < keywords.length; k++) {
54
47
  var key = keywords[k];
55
-
56
48
  if (str.slice(j, j + key.length) === key) {
57
49
  i = p.skipSpace(str, j + key.length);
58
-
59
50
  if (i < 0) {
60
51
  throw badSyntax(p._thisDoc, p.lines, str, j + key.length, 'found EOF, needed {...} after ' + key);
61
52
  }
62
-
63
53
  if ((key === 'INSERT' || key === 'DELETE') && str.slice(i, i + 4) === 'DATA') {
64
54
  // Some wanted 'DATA'. Whatever
65
55
  j = p.skipSpace(str, i + 4);
66
-
67
56
  if (j < 0) {
68
57
  throw badSyntax(p._thisDoc, p.lines, str, i + 4, 'needed {...} after INSERT DATA ' + key);
69
58
  }
70
-
71
59
  i = j;
72
60
  }
73
-
74
61
  var res2 = [];
75
62
  j = p.node(str, i, res2); // Parse all the complexity of the clause
76
63
 
77
64
  if (j < 0) {
78
65
  throw badSyntax(p._thisDoc, p.lines, str, i, 'bad syntax or EOF in {...} after ' + key);
79
66
  }
80
-
81
67
  clauses[key.toLowerCase()] = res2[0];
82
68
  kb.add(query, SQNS(key.toLowerCase()), res2[0]); // , kb.sym(base)
83
69
  // key is the keyword and res2 has the contents
84
-
85
70
  found = true;
86
71
  i = j;
87
72
  }
88
73
  }
89
-
90
74
  if (!found && str.slice(j, j + 7) === '@prefix') {
91
75
  i = p.directive(str, j);
92
-
93
76
  if (i < 0) {
94
77
  throw badSyntax(p._thisDoc, p.lines, str, i, 'bad syntax or EOF after @prefix ');
95
- } // console.log("P before dot i= " + i)
96
-
97
-
98
- i = p.checkDot(str, i); // console.log("Q after dot i= " + i)
99
-
78
+ }
79
+ // console.log("P before dot i= " + i)
80
+ i = p.checkDot(str, i);
81
+ // console.log("Q after dot i= " + i)
100
82
  found = true;
101
83
  }
102
-
103
84
  if (!found) {
104
85
  // console.log("Bad syntax " + j)
105
86
  throw badSyntax(p._thisDoc, p.lines, str, j, "Unknown syntax at start of statememt: '" + str.slice(j).slice(0, 20) + "'");
106
87
  }
107
88
  } // while
108
89
  // return clauses
109
-
110
90
  }
@@ -1,44 +1,33 @@
1
1
  import log from './log';
2
2
  export default function queryToSPARQL(query) {
3
3
  var indent = 0;
4
-
5
4
  function getSelect(query) {
6
5
  var str = addIndent() + 'SELECT ';
7
-
8
6
  for (var i = 0; i < query.vars.length; i++) {
9
7
  str += query.vars[i] + ' ';
10
8
  }
11
-
12
9
  str += '\n';
13
10
  return str;
14
11
  }
15
-
16
12
  function getPattern(pat) {
17
13
  var str = '';
18
14
  var st = pat.statements;
19
-
20
15
  for (var x in st) {
21
16
  log.debug('Found statement: ' + st);
22
17
  str += addIndent() + st[x] + '\n';
23
18
  }
24
-
25
19
  return str;
26
20
  }
27
-
28
21
  function getConstraints(pat) {
29
22
  var str = '';
30
-
31
23
  for (var v in pat.constraints) {
32
24
  var foo = pat.constraints[v];
33
25
  str += addIndent() + 'FILTER ( ' + foo.describe(v) + ' ) ' + '\n';
34
26
  }
35
-
36
27
  return str;
37
28
  }
38
-
39
29
  function getOptionals(pat) {
40
30
  var str = '';
41
-
42
31
  for (var x = 0; x < pat.optional.length; x++) {
43
32
  // alert(pat.optional.termType)
44
33
  log.debug('Found optional query');
@@ -50,10 +39,8 @@ export default function queryToSPARQL(query) {
50
39
  indent--;
51
40
  str += addIndent() + '}' + '\n';
52
41
  }
53
-
54
42
  return str;
55
43
  }
56
-
57
44
  function getWhere(pat) {
58
45
  var str = addIndent() + 'WHERE \n' + '{ \n';
59
46
  indent++;
@@ -64,20 +51,15 @@ export default function queryToSPARQL(query) {
64
51
  str += '}';
65
52
  return str;
66
53
  }
67
-
68
54
  function addIndent() {
69
55
  var str = '';
70
-
71
56
  for (var i = 0; i < indent; i++) {
72
57
  str += ' ';
73
58
  }
74
-
75
59
  return str;
76
60
  }
77
-
78
61
  function getSPARQL(query) {
79
62
  return getSelect(query) + getWhere(query.pat);
80
63
  }
81
-
82
64
  return getSPARQL(query);
83
65
  }