@dialecte/core 0.1.22 → 0.2.1

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 (195) hide show
  1. package/dist/document/bind-extensions.d.ts +1 -1
  2. package/dist/document/bind-extensions.d.ts.map +1 -1
  3. package/dist/document/document.d.ts +6 -7
  4. package/dist/document/document.d.ts.map +1 -1
  5. package/dist/document/index.d.ts +3 -1
  6. package/dist/document/index.d.ts.map +1 -1
  7. package/dist/document/query/any/any-query.d.ts +2 -1
  8. package/dist/document/query/any/any-query.d.ts.map +1 -1
  9. package/dist/document/query/find/ancestor/find-ancestor.d.ts +2 -2
  10. package/dist/document/query/find/ancestor/find-ancestor.d.ts.map +1 -1
  11. package/dist/document/query/find/descendant/find-descendant.d.ts +2 -2
  12. package/dist/document/query/find/descendant/find-descendant.d.ts.map +1 -1
  13. package/dist/document/query/get/attribute/get-attribute.d.ts +2 -2
  14. package/dist/document/query/get/attribute/get-attribute.d.ts.map +1 -1
  15. package/dist/document/query/get/attribute/get-attributes.d.ts +2 -2
  16. package/dist/document/query/get/attribute/get-attributes.d.ts.map +1 -1
  17. package/dist/document/query/get/record/get-child.d.ts +2 -2
  18. package/dist/document/query/get/record/get-child.d.ts.map +1 -1
  19. package/dist/document/query/get/record/get-children.d.ts +2 -2
  20. package/dist/document/query/get/record/get-children.d.ts.map +1 -1
  21. package/dist/document/query/get/record/get-record.d.ts +2 -2
  22. package/dist/document/query/get/record/get-record.d.ts.map +1 -1
  23. package/dist/document/query/get/record/get-records.d.ts +2 -2
  24. package/dist/document/query/get/record/get-records.d.ts.map +1 -1
  25. package/dist/document/query/get/tree/get-tree.d.ts +2 -2
  26. package/dist/document/query/get/tree/get-tree.d.ts.map +1 -1
  27. package/dist/document/query/main.d.ts +4 -2
  28. package/dist/document/query/main.d.ts.map +1 -1
  29. package/dist/document/transaction/any/any-transaction.d.ts +2 -3
  30. package/dist/document/transaction/any/any-transaction.d.ts.map +1 -1
  31. package/dist/document/transaction/clone/clone.d.ts +2 -2
  32. package/dist/document/transaction/clone/clone.d.ts.map +1 -1
  33. package/dist/document/transaction/clone/clone.types.d.ts +2 -1
  34. package/dist/document/transaction/clone/clone.types.d.ts.map +1 -1
  35. package/dist/document/transaction/commit/commit.d.ts +3 -2
  36. package/dist/document/transaction/commit/commit.d.ts.map +1 -1
  37. package/dist/document/transaction/create/create.d.ts +2 -2
  38. package/dist/document/transaction/create/create.d.ts.map +1 -1
  39. package/dist/document/transaction/delete/delete.d.ts +2 -2
  40. package/dist/document/transaction/delete/delete.d.ts.map +1 -1
  41. package/dist/document/transaction/ensure/ensure.d.ts +2 -2
  42. package/dist/document/transaction/ensure/ensure.d.ts.map +1 -1
  43. package/dist/document/transaction/main.d.ts +5 -4
  44. package/dist/document/transaction/main.d.ts.map +1 -1
  45. package/dist/document/transaction/update/update.d.ts +2 -2
  46. package/dist/document/transaction/update/update.d.ts.map +1 -1
  47. package/dist/document/types.d.ts +2 -1
  48. package/dist/document/types.d.ts.map +1 -1
  49. package/dist/{types/extensions.d.ts → document/types.extensions.d.ts} +3 -3
  50. package/dist/document/types.extensions.d.ts.map +1 -0
  51. package/dist/{types/ref.d.ts → document/types.ref.d.ts} +2 -3
  52. package/dist/document/types.ref.d.ts.map +1 -0
  53. package/dist/errors/codes.d.ts +16 -0
  54. package/dist/errors/codes.d.ts.map +1 -1
  55. package/dist/helpers/converter.d.ts +2 -1
  56. package/dist/helpers/converter.d.ts.map +1 -1
  57. package/dist/helpers/merge-extensions.d.ts +1 -2
  58. package/dist/helpers/merge-extensions.d.ts.map +1 -1
  59. package/dist/helpers.js +1 -1
  60. package/dist/{index-B1qiHOqL.js → index-C2WRi-6U.js} +27 -10
  61. package/dist/index.d.ts +2 -2
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +73 -38
  64. package/dist/{merge-extensions-D-JNgVJ8.js → merge-extensions-DQKNUthU.js} +1 -1
  65. package/dist/project/index.d.ts +9 -0
  66. package/dist/project/index.d.ts.map +1 -0
  67. package/dist/project/io/export-document.d.ts +7 -0
  68. package/dist/project/io/export-document.d.ts.map +1 -0
  69. package/dist/project/io/import-document.d.ts +7 -0
  70. package/dist/project/io/import-document.d.ts.map +1 -0
  71. package/dist/project/io/index.d.ts +4 -0
  72. package/dist/project/io/index.d.ts.map +1 -0
  73. package/dist/project/io/init-empty-document.d.ts +7 -0
  74. package/dist/project/io/init-empty-document.d.ts.map +1 -0
  75. package/dist/project/project.d.ts +80 -0
  76. package/dist/project/project.d.ts.map +1 -0
  77. package/dist/project/state/document-state.d.ts +11 -0
  78. package/dist/project/state/document-state.d.ts.map +1 -0
  79. package/dist/project/state/index.d.ts +2 -0
  80. package/dist/project/state/index.d.ts.map +1 -0
  81. package/dist/project/types.d.ts +128 -0
  82. package/dist/project/types.d.ts.map +1 -0
  83. package/dist/project-ChrJXVyu.js +6762 -0
  84. package/dist/store/index.d.ts +3 -2
  85. package/dist/store/index.d.ts.map +1 -1
  86. package/dist/store/local/dexie-store.d.ts +74 -0
  87. package/dist/store/local/dexie-store.d.ts.map +1 -0
  88. package/dist/store/local/index.d.ts +3 -0
  89. package/dist/store/local/index.d.ts.map +1 -0
  90. package/dist/store/local/types.d.ts +6 -0
  91. package/dist/store/local/types.d.ts.map +1 -0
  92. package/dist/store/resolve-store.d.ts +9 -0
  93. package/dist/store/resolve-store.d.ts.map +1 -0
  94. package/dist/store/store.constants.d.ts +18 -0
  95. package/dist/store/store.constants.d.ts.map +1 -0
  96. package/dist/store/store.types.d.ts +70 -32
  97. package/dist/store/store.types.d.ts.map +1 -1
  98. package/dist/test/assert-xml/assert-xml.d.ts +1 -1
  99. package/dist/test/config.d.ts +14 -0
  100. package/dist/test/config.d.ts.map +1 -1
  101. package/dist/test/create-test-dialecte.d.ts +20 -20
  102. package/dist/test/create-test-dialecte.d.ts.map +1 -1
  103. package/dist/test/run-test-cases.d.ts +6 -0
  104. package/dist/test/run-test-cases.d.ts.map +1 -1
  105. package/dist/test/run-test-cases.type.d.ts +4 -8
  106. package/dist/test/run-test-cases.type.d.ts.map +1 -1
  107. package/dist/test/test-record.d.ts +48 -0
  108. package/dist/test/test-record.d.ts.map +1 -1
  109. package/dist/test.js +227 -227
  110. package/dist/types/dialecte-config.d.ts +8 -1
  111. package/dist/types/dialecte-config.d.ts.map +1 -1
  112. package/dist/types/index.d.ts +0 -2
  113. package/dist/types/index.d.ts.map +1 -1
  114. package/dist/utils.js +1 -1
  115. package/dist/xml/build/build-xml-document.d.ts +10 -0
  116. package/dist/xml/build/build-xml-document.d.ts.map +1 -0
  117. package/dist/xml/build/build-xml-document.types.d.ts +7 -0
  118. package/dist/xml/build/build-xml-document.types.d.ts.map +1 -0
  119. package/dist/xml/build/constant.d.ts.map +1 -0
  120. package/dist/{io/export → xml/build}/download-file.d.ts.map +1 -1
  121. package/dist/xml/build/formatter.d.ts.map +1 -0
  122. package/dist/xml/build/index.d.ts +6 -0
  123. package/dist/xml/build/index.d.ts.map +1 -0
  124. package/dist/xml/index.d.ts +3 -0
  125. package/dist/xml/index.d.ts.map +1 -0
  126. package/dist/{io/import → xml/parse}/guards.d.ts.map +1 -1
  127. package/dist/xml/parse/index.d.ts +5 -0
  128. package/dist/xml/parse/index.d.ts.map +1 -0
  129. package/dist/xml/parse/parse-session.d.ts +22 -0
  130. package/dist/xml/parse/parse-session.d.ts.map +1 -0
  131. package/dist/xml/parse/parse-xml-document.d.ts +12 -0
  132. package/dist/xml/parse/parse-xml-document.d.ts.map +1 -0
  133. package/dist/xml/parse/parse-xml-document.types.d.ts +17 -0
  134. package/dist/xml/parse/parse-xml-document.types.d.ts.map +1 -0
  135. package/dist/{io/import → xml/parse}/parser.d.ts +2 -0
  136. package/dist/xml/parse/parser.d.ts.map +1 -0
  137. package/dist/{io/import → xml/parse}/types.d.ts.map +1 -1
  138. package/package.json +1 -10
  139. package/dist/dialecte/index.d.ts +0 -2
  140. package/dist/dialecte/index.d.ts.map +0 -1
  141. package/dist/dialecte/main.d.ts +0 -6
  142. package/dist/dialecte/main.d.ts.map +0 -1
  143. package/dist/dialecte/main.types.d.ts +0 -12
  144. package/dist/dialecte/main.types.d.ts.map +0 -1
  145. package/dist/index-BI0vaz_1.js +0 -6662
  146. package/dist/io/database/index.d.ts +0 -3
  147. package/dist/io/database/index.d.ts.map +0 -1
  148. package/dist/io/database/instance.d.ts +0 -7
  149. package/dist/io/database/instance.d.ts.map +0 -1
  150. package/dist/io/database/types.d.ts +0 -7
  151. package/dist/io/database/types.d.ts.map +0 -1
  152. package/dist/io/export/constant.d.ts.map +0 -1
  153. package/dist/io/export/formatter.d.ts.map +0 -1
  154. package/dist/io/export/index.d.ts +0 -4
  155. package/dist/io/export/index.d.ts.map +0 -1
  156. package/dist/io/export/main.d.ts +0 -18
  157. package/dist/io/export/main.d.ts.map +0 -1
  158. package/dist/io/import/database-helpers.d.ts +0 -53
  159. package/dist/io/import/database-helpers.d.ts.map +0 -1
  160. package/dist/io/import/index.d.ts +0 -4
  161. package/dist/io/import/index.d.ts.map +0 -1
  162. package/dist/io/import/main.d.ts +0 -15
  163. package/dist/io/import/main.d.ts.map +0 -1
  164. package/dist/io/import/parser.d.ts.map +0 -1
  165. package/dist/io/import/relationships.d.ts +0 -9
  166. package/dist/io/import/relationships.d.ts.map +0 -1
  167. package/dist/io/import/test.types.d.ts +0 -4
  168. package/dist/io/import/test.types.d.ts.map +0 -1
  169. package/dist/io/index.d.ts +0 -3
  170. package/dist/io/index.d.ts.map +0 -1
  171. package/dist/script/element-parent-mapping.d.ts +0 -2
  172. package/dist/script/element-parent-mapping.d.ts.map +0 -1
  173. package/dist/script/find-singleton.d.ts +0 -1
  174. package/dist/script/find-singleton.d.ts.map +0 -1
  175. package/dist/script/find-unreferenced-elements.d.ts +0 -3
  176. package/dist/script/find-unreferenced-elements.d.ts.map +0 -1
  177. package/dist/script/generate-definition.d.ts +0 -3
  178. package/dist/script/generate-definition.d.ts.map +0 -1
  179. package/dist/script/generate-definition.types.d.ts +0 -86
  180. package/dist/script/generate-definition.types.d.ts.map +0 -1
  181. package/dist/script/pyodide.d.ts +0 -12
  182. package/dist/script/pyodide.d.ts.map +0 -1
  183. package/dist/script/sorted-dexie-dump-json.d.ts +0 -2
  184. package/dist/script/sorted-dexie-dump-json.d.ts.map +0 -1
  185. package/dist/script/test-pyodide.d.ts +0 -9
  186. package/dist/script/test-pyodide.d.ts.map +0 -1
  187. package/dist/store/dexie-store.d.ts +0 -36
  188. package/dist/store/dexie-store.d.ts.map +0 -1
  189. package/dist/types/extensions.d.ts.map +0 -1
  190. package/dist/types/ref.d.ts.map +0 -1
  191. /package/dist/{io/export → xml/build}/constant.d.ts +0 -0
  192. /package/dist/{io/export → xml/build}/download-file.d.ts +0 -0
  193. /package/dist/{io/export → xml/build}/formatter.d.ts +0 -0
  194. /package/dist/{io/import → xml/parse}/guards.d.ts +0 -0
  195. /package/dist/{io/import → xml/parse}/types.d.ts +0 -0
package/dist/test.js CHANGED
@@ -1,153 +1,153 @@
1
- import { expect as f, it as p } from "vitest";
2
- import { x as q, D as S, i as D, o as T, e as v } from "./index-BI0vaz_1.js";
3
- import { D as L, s as w, o as g, n as O } from "./merge-extensions-D-JNgVJ8.js";
4
- function E(a) {
5
- const t = M(a);
6
- if (t.length === 0)
7
- return [a];
8
- const e = [];
9
- for (const A of t)
10
- e.push(a.slice(0, A));
11
- return e.push(a), e;
12
- }
13
- function M(a) {
1
+ import { expect as m, it as p } from "vitest";
2
+ import { x as D, b as L, d as T } from "./project-ChrJXVyu.js";
3
+ import { D as w, s as g, o as O, n as M } from "./merge-extensions-DQKNUthU.js";
4
+ function h(B) {
5
+ const e = k(B);
6
+ if (e.length === 0)
7
+ return [B];
14
8
  const t = [];
15
- let e = 0, A = 0, B = null;
16
- for (let _ = 0; _ < a.length; _++) {
17
- const C = a[_];
18
- if (B) {
19
- C === B && (B = null);
9
+ for (const r of e)
10
+ t.push(B.slice(0, r));
11
+ return t.push(B), t;
12
+ }
13
+ function k(B) {
14
+ const e = [];
15
+ let t = 0, r = 0, a = null;
16
+ for (let C = 0; C < B.length; C++) {
17
+ const A = B[C];
18
+ if (a) {
19
+ A === a && (a = null);
20
20
  continue;
21
21
  }
22
- if (C === '"' || C === "'") {
23
- B = C;
22
+ if (A === '"' || A === "'") {
23
+ a = A;
24
24
  continue;
25
25
  }
26
- if (C === "[") {
27
- e++;
26
+ if (A === "[") {
27
+ t++;
28
28
  continue;
29
29
  }
30
- if (C === "]") {
31
- e--;
30
+ if (A === "]") {
31
+ t--;
32
32
  continue;
33
33
  }
34
- if (C === "(") {
35
- A++;
34
+ if (A === "(") {
35
+ r++;
36
36
  continue;
37
37
  }
38
- if (C === ")") {
39
- A--;
38
+ if (A === ")") {
39
+ r--;
40
40
  continue;
41
41
  }
42
- if (!(e > 0 || A > 0) && C === "/") {
43
- if (_ === 0) {
44
- a[_ + 1] === "/" && _++;
42
+ if (!(t > 0 || r > 0) && A === "/") {
43
+ if (C === 0) {
44
+ B[C + 1] === "/" && C++;
45
45
  continue;
46
46
  }
47
- if (t.length === 0 && _ === 1 && a[0] === "/")
47
+ if (e.length === 0 && C === 1 && B[0] === "/")
48
48
  continue;
49
- t.push(_), a[_ + 1] === "/" && _++;
49
+ e.push(C), B[C + 1] === "/" && C++;
50
50
  }
51
51
  }
52
- return t;
52
+ return e;
53
53
  }
54
- function k(a) {
55
- const { namespaces: t } = a, e = V(t);
54
+ function R(B) {
55
+ const { namespaces: e } = B, t = F(e);
56
56
  return {
57
- assertExpectedElementQueries(A) {
58
- R({ ...A, nsResolver: e });
57
+ assertExpectedElementQueries(r) {
58
+ V({ ...r, nsResolver: t });
59
59
  },
60
- assertUnexpectedElementQueries(A) {
61
- F({ ...A, nsResolver: e });
60
+ assertUnexpectedElementQueries(r) {
61
+ y({ ...r, nsResolver: t });
62
62
  }
63
63
  };
64
64
  }
65
- function R(a) {
66
- const { xmlDocument: t, queries: e, nsResolver: A } = a;
67
- for (const B of e)
68
- y({ xmlDocument: t, xpath: B, nsResolver: A });
65
+ function V(B) {
66
+ const { xmlDocument: e, queries: t, nsResolver: r } = B;
67
+ for (const a of t)
68
+ I({ xmlDocument: e, xpath: a, nsResolver: r });
69
69
  }
70
- function V(a) {
71
- return (t) => t ? a[t]?.uri ?? null : null;
70
+ function F(B) {
71
+ return (e) => e ? B[e]?.uri ?? null : null;
72
72
  }
73
- function F(a) {
74
- const { xmlDocument: t, queries: e, nsResolver: A } = a;
75
- for (const B of e)
76
- N({ xmlDocument: t, xpath: B, nsResolver: A });
73
+ function y(B) {
74
+ const { xmlDocument: e, queries: t, nsResolver: r } = B;
75
+ for (const a of t)
76
+ U({ xmlDocument: e, xpath: a, nsResolver: r });
77
77
  }
78
- function y(a) {
79
- const { xmlDocument: t, xpath: e, nsResolver: A } = a, B = E(e);
80
- let _ = null, C = 0;
81
- for (let s = 0; s < B.length; s++) {
82
- const r = B[s], n = t.evaluate(
83
- r,
84
- t,
85
- A ?? null,
78
+ function I(B) {
79
+ const { xmlDocument: e, xpath: t, nsResolver: r } = B, a = h(t);
80
+ let C = null, A = 0;
81
+ for (let s = 0; s < a.length; s++) {
82
+ const _ = a[s], c = e.evaluate(
83
+ _,
84
+ e,
85
+ r ?? null,
86
86
  XPathResult.FIRST_ORDERED_NODE_TYPE,
87
87
  null
88
88
  ).singleNodeValue;
89
- if (n) {
90
- _ = n, C = s + 1;
89
+ if (c) {
90
+ C = c, A = s + 1;
91
91
  continue;
92
92
  }
93
- const i = s === 0 ? B[0] : e.slice(B[s - 1].length), u = C === 0 ? `[No parent matched — failed from document root]
93
+ const n = s === 0 ? a[0] : t.slice(a[s - 1].length), u = A === 0 ? `[No parent matched — failed from document root]
94
94
  Document:
95
- ${x({ xml: new XMLSerializer().serializeToString(t) })}` : `[Last match at step ${C}/${B.length}]:
96
- ${_ ? x({ xml: _.outerHTML }) : "(none)"}`;
97
- f(
98
- n,
95
+ ${x({ xml: new XMLSerializer().serializeToString(e) })}` : `[Last match at step ${A}/${a.length}]:
96
+ ${C ? x({ xml: C.outerHTML }) : "(none)"}`;
97
+ m(
98
+ c,
99
99
  `Element not found in XML.
100
- Failed at step ${s + 1}/${B.length}: ${i.trim()}
101
- Full XPath: ${e}
100
+ Failed at step ${s + 1}/${a.length}: ${n.trim()}
101
+ Full XPath: ${t}
102
102
  ${u}`
103
103
  ).toBeTruthy();
104
104
  return;
105
105
  }
106
106
  }
107
- function x(a) {
108
- const { xml: t } = a;
107
+ function x(B) {
108
+ const { xml: e } = B;
109
109
  try {
110
- return q(t, { indentation: " ", collapseContent: !0 });
110
+ return D(e, { indentation: " ", collapseContent: !0 });
111
111
  } catch {
112
- return t;
112
+ return e;
113
113
  }
114
114
  }
115
- function N(a) {
116
- const { xmlDocument: t, xpath: e, nsResolver: A } = a, B = E(e);
117
- if (B.length > 1) {
115
+ function U(B) {
116
+ const { xmlDocument: e, xpath: t, nsResolver: r } = B, a = h(t);
117
+ if (a.length > 1) {
118
118
  let s = null;
119
- for (let r = 0; r < B.length - 1; r++) {
120
- const c = B[r], i = t.evaluate(
121
- c,
122
- t,
123
- A ?? null,
119
+ for (let _ = 0; _ < a.length - 1; _++) {
120
+ const i = a[_], n = e.evaluate(
121
+ i,
122
+ e,
123
+ r ?? null,
124
124
  XPathResult.FIRST_ORDERED_NODE_TYPE,
125
125
  null
126
- ).singleNodeValue, u = r === 0 ? B[0] : e.slice(B[r - 1].length), l = r === 0 ? "[Document root — no parent context]" : `[Parent element found at step ${r}]:
126
+ ).singleNodeValue, u = _ === 0 ? a[0] : t.slice(a[_ - 1].length), o = _ === 0 ? "[Document root — no parent context]" : `[Parent element found at step ${_}]:
127
127
  ${s ? x({ xml: s.outerHTML }) : "(none)"}`;
128
- f(
129
- i,
128
+ m(
129
+ n,
130
130
  `Absent assertion is unreliable: ancestor step does not exist.
131
131
  The query passes but for the wrong reason — an ancestor is missing, not the target element.
132
- Missing at step ${r + 1}/${B.length}: ${u.trim()}
133
- Full XPath: ${e}
134
- ${l}`
135
- ).toBeTruthy(), s = i;
132
+ Missing at step ${_ + 1}/${a.length}: ${u.trim()}
133
+ Full XPath: ${t}
134
+ ${o}`
135
+ ).toBeTruthy(), s = n;
136
136
  }
137
137
  }
138
- const C = t.evaluate(
139
- e,
138
+ const A = e.evaluate(
140
139
  t,
141
- A ?? null,
140
+ e,
141
+ r ?? null,
142
142
  XPathResult.FIRST_ORDERED_NODE_TYPE,
143
143
  null
144
144
  ).singleNodeValue;
145
- f(
146
- C,
145
+ m(
146
+ A,
147
147
  `Element should NOT exist in XML but was found.
148
- XPath: ${e}
148
+ XPath: ${t}
149
149
  Found:
150
- ${C ? x({ xml: C.outerHTML }) : "(none)"}`
150
+ ${A ? x({ xml: A.outerHTML }) : "(none)"}`
151
151
  ).toBeFalsy();
152
152
  }
153
153
  const d = {
@@ -155,12 +155,12 @@ const d = {
155
155
  uri: "http://dialecte.dev/XML/DEFAULT",
156
156
  prefix: ""
157
157
  },
158
- dev: L,
158
+ dev: w,
159
159
  ext: {
160
160
  uri: "http://dialecte.dev/XML/DEV-EXT",
161
161
  prefix: "ext"
162
162
  }
163
- }, re = `xmlns="${d.default.uri}"`, Ce = `xmlns:${d.dev.prefix}="${d.dev.uri}"`, _e = `xmlns:${d.ext.prefix}="${d.ext.uri}"`, U = [
163
+ }, Ce = `xmlns="${d.default.uri}"`, _e = `xmlns:${d.dev.prefix}="${d.dev.uri}"`, se = `xmlns:${d.ext.prefix}="${d.ext.uri}"`, N = [
164
164
  "A",
165
165
  "AAAA_1",
166
166
  "AAAA_2",
@@ -192,7 +192,7 @@ const d = {
192
192
  "CC_2",
193
193
  "CC_3",
194
194
  "Root"
195
- ], I = {
195
+ ], $ = {
196
196
  A: ["AA_1", "AA_2", "AA_3"],
197
197
  AAAA_1: [],
198
198
  AAAA_2: [],
@@ -224,7 +224,7 @@ const d = {
224
224
  CC_2: ["CCC_1", "CCC_2", "CCC_3"],
225
225
  CC_3: ["CCC_1", "CCC_2", "CCC_3"],
226
226
  Root: ["A", "B", "C"]
227
- }, $ = {
227
+ }, P = {
228
228
  A: ["Root"],
229
229
  AAAA_1: ["AAA_1", "AAA_2", "AAA_3"],
230
230
  AAAA_2: ["AAA_1", "AAA_2", "AAA_3"],
@@ -256,7 +256,7 @@ const d = {
256
256
  CC_2: ["C"],
257
257
  CC_3: ["C"],
258
258
  Root: []
259
- }, P = {
259
+ }, Q = {
260
260
  A: ["AAAA_1", "AAAA_2", "AAAA_3", "AAA_1", "AAA_2", "AAA_3", "AA_1", "AA_2", "AA_3"],
261
261
  AAAA_1: [],
262
262
  AAAA_2: [],
@@ -319,7 +319,7 @@ const d = {
319
319
  "CC_2",
320
320
  "CC_3"
321
321
  ]
322
- }, Q = {
322
+ }, j = {
323
323
  A: ["Root"],
324
324
  AAAA_1: ["A", "AAA_1", "AAA_2", "AAA_3", "AA_1", "AA_2", "AA_3", "Root"],
325
325
  AAAA_2: ["A", "AAA_1", "AAA_2", "AAA_3", "AA_1", "AA_2", "AA_3", "Root"],
@@ -508,7 +508,7 @@ const d = {
508
508
  "ext:root": "",
509
509
  root: ""
510
510
  }
511
- }, j = {
511
+ }, Y = {
512
512
  A: {
513
513
  tag: "A",
514
514
  namespace: { prefix: "", uri: "http://dialecte.dev/XML/DEFAULT" },
@@ -1533,183 +1533,183 @@ const d = {
1533
1533
  }
1534
1534
  ]
1535
1535
  }
1536
- }, Y = {
1536
+ }, K = {
1537
1537
  supportedFileExtensions: [".xml"]
1538
1538
  }, W = {
1539
+ recordSchema: {
1540
+ primaryKey: "id",
1541
+ indexes: ["tagName", "parent.id", "parent.tagName"],
1542
+ compoundIndexes: [["id", "tagName"]],
1543
+ arrayIndexes: ["children.id", "children.tagName"]
1544
+ },
1545
+ /** @deprecated - kept for old io/ pipeline until Phase 5 removes it */
1539
1546
  tables: {
1540
1547
  xmlElements: {
1541
1548
  name: "xmlElements",
1542
1549
  schema: "id, tagName, [id+tagName], parent.id, parent.tagName, *children.id, *children.tagName"
1543
1550
  }
1544
1551
  }
1545
- }, o = {
1552
+ }, l = {
1546
1553
  rootElementName: z,
1547
1554
  singletonElements: G,
1548
- elements: U,
1555
+ elements: N,
1549
1556
  namespaces: d,
1550
1557
  attributes: H,
1551
- children: I,
1552
- parents: $,
1553
- descendants: P,
1554
- ancestors: Q,
1558
+ children: $,
1559
+ parents: P,
1560
+ descendants: Q,
1561
+ ancestors: j,
1555
1562
  database: W,
1556
- io: Y,
1557
- definition: j
1563
+ io: K,
1564
+ definition: Y
1558
1565
  };
1559
- async function m(a) {
1566
+ async function v(B) {
1560
1567
  const {
1561
- xmlString: t,
1562
- dialecteConfig: e = o,
1563
- hooks: A
1564
- } = a, B = `test-${crypto.randomUUID()}.xml`, _ = new File([t], B, { type: "text/xml" }), s = (await D({
1565
- files: [_],
1566
- dialecteConfig: e,
1567
- useCustomRecordsIds: !0
1568
- }))[0], r = T({
1569
- config: e,
1570
- storage: { type: "local", databaseName: s },
1571
- hooks: A
1572
- });
1573
- return {
1574
- document: r,
1575
- databaseName: s,
1576
- exportCurrentTest: async (i) => {
1577
- const { extension: u = e.io.supportedFileExtensions[0], withDatabaseIds: l = !1 } = i || {};
1578
- return v({
1579
- dialecteConfig: e,
1580
- databaseName: s,
1581
- extension: u,
1582
- withDatabaseIds: l
1583
- });
1584
- },
1585
- cleanup: async () => {
1586
- r.destroy();
1587
- }
1568
+ sourceXml: e,
1569
+ targetXml: t,
1570
+ dialecteConfig: r = l,
1571
+ hooks: a
1572
+ } = B, C = `test-${crypto.randomUUID()}`, A = await T.open({
1573
+ name: C,
1574
+ configs: { default: r },
1575
+ defaultConfigKey: "default",
1576
+ storage: { type: "local" },
1577
+ hooks: a
1578
+ }), s = await A.import(
1579
+ new File([e], "source.xml", { type: "text/xml" }),
1580
+ { useCustomRecordsIds: !0 }
1581
+ ), _ = {
1582
+ documentId: s.documentId,
1583
+ document: A.openDocument(s.documentId)
1588
1584
  };
1585
+ let i;
1586
+ if (t) {
1587
+ const c = await A.import(
1588
+ new File([t], "target.xml", { type: "text/xml" }),
1589
+ { useCustomRecordsIds: !0 }
1590
+ );
1591
+ i = {
1592
+ documentId: c.documentId,
1593
+ document: A.openDocument(c.documentId)
1594
+ };
1595
+ }
1596
+ return { project: A, source: _, target: i };
1589
1597
  }
1590
- function se(a) {
1591
- const { databaseName: t, dialecteConfig: e } = a;
1592
- return {
1593
- store: new S(t, e),
1594
- dialecteConfig: e,
1598
+ async function ce(B) {
1599
+ const { databaseName: e, dialecteConfig: t, documentId: r } = B, a = new L(e, {
1600
+ recordSchema: t.database.recordSchema
1601
+ });
1602
+ return await a.open(), {
1603
+ dialecteConfig: t,
1604
+ store: a,
1605
+ documentId: r,
1595
1606
  recordCache: /* @__PURE__ */ new Map(),
1596
1607
  stagedOperations: []
1597
1608
  };
1598
1609
  }
1599
- const b = crypto.randomUUID.bind(crypto);
1600
- function X() {
1601
- let a = 0;
1610
+ const E = crypto.randomUUID.bind(crypto);
1611
+ function b() {
1612
+ let B = 0;
1602
1613
  return function() {
1603
- return `${a++}`;
1614
+ return `${B++}`;
1604
1615
  };
1605
1616
  }
1606
- function Z(a) {
1617
+ function Z(B) {
1607
1618
  const {
1608
- testCases: t,
1609
- act: e,
1610
- hooks: A,
1611
- dialecteConfig: B = o
1612
- } = a, { assertExpectedElementQueries: _, assertUnexpectedElementQueries: C } = k({
1613
- namespaces: B.namespaces
1619
+ testCases: e,
1620
+ act: t,
1621
+ hooks: r,
1622
+ dialecteConfig: a = l
1623
+ } = B, { assertExpectedElementQueries: C, assertUnexpectedElementQueries: A } = R({
1624
+ namespaces: a.namespaces
1614
1625
  });
1615
- for (const [s, r] of Object.entries(t))
1616
- (r.only ? p.only : p)(s, async () => {
1617
- crypto.randomUUID = b;
1618
- const n = await m({
1619
- xmlString: r.sourceXml,
1620
- dialecteConfig: B,
1621
- hooks: A
1622
- }), i = r.targetXml ? await m({ xmlString: r.targetXml, dialecteConfig: B, hooks: A }) : void 0;
1626
+ for (const [s, _] of Object.entries(e))
1627
+ (_.only ? p.only : p)(s, async () => {
1628
+ crypto.randomUUID = E;
1629
+ const { project: c, source: n, target: u } = await v({
1630
+ sourceXml: _.sourceXml,
1631
+ targetXml: _.targetXml,
1632
+ dialecteConfig: a,
1633
+ hooks: r
1634
+ });
1623
1635
  try {
1624
- crypto.randomUUID = X();
1625
- const { assertDatabaseName: u, withDatabaseIds: l } = await e({
1626
- testCase: r,
1627
- source: { document: n.document, databaseName: n.databaseName },
1628
- target: i ? { document: i.document, databaseName: i.databaseName } : void 0
1629
- }), { xmlDocument: h } = await v({
1630
- dialecteConfig: B,
1631
- databaseName: u,
1632
- extension: B.io.supportedFileExtensions[0],
1633
- withDatabaseIds: l ?? !0
1634
- });
1635
- r.expectedQueries?.length && _({ xmlDocument: h, queries: r.expectedQueries }), r.unexpectedQueries?.length && C({ xmlDocument: h, queries: r.unexpectedQueries });
1636
+ crypto.randomUUID = b();
1637
+ const o = await t({ testCase: _, source: n.document, target: u?.document }), X = o?.assertOn ?? "source", q = o?.withDatabaseIds ?? !0, S = X === "target" ? u.documentId : n.documentId, { xmlDocument: f } = await c.export(S, { withDatabaseIds: q });
1638
+ _.expectedQueries?.length && C({ xmlDocument: f, queries: _.expectedQueries }), _.unexpectedQueries?.length && A({ xmlDocument: f, queries: _.unexpectedQueries });
1636
1639
  } finally {
1637
- await n.cleanup(), await i?.cleanup();
1640
+ await c.destroy();
1638
1641
  }
1639
1642
  });
1640
1643
  }
1641
- function J(a) {
1644
+ function J(B) {
1642
1645
  const {
1643
- testCases: t,
1644
- act: e,
1645
- hooks: A,
1646
- dialecteConfig: B = o
1647
- } = a;
1648
- for (const [_, C] of Object.entries(t))
1649
- (C.only ? p.only : p)(_, async () => {
1650
- crypto.randomUUID = b;
1651
- const r = await m({
1652
- xmlString: C.sourceXml,
1653
- dialecteConfig: B,
1654
- hooks: A
1655
- }), c = C.targetXml ? await m({ xmlString: C.targetXml, dialecteConfig: B, hooks: A }) : void 0;
1646
+ testCases: e,
1647
+ act: t,
1648
+ hooks: r,
1649
+ dialecteConfig: a = l
1650
+ } = B;
1651
+ for (const [C, A] of Object.entries(e))
1652
+ (A.only ? p.only : p)(C, async () => {
1653
+ crypto.randomUUID = E;
1654
+ const { project: _, source: i, target: c } = await v({
1655
+ sourceXml: A.sourceXml,
1656
+ targetXml: A.targetXml,
1657
+ dialecteConfig: a,
1658
+ hooks: r
1659
+ });
1656
1660
  try {
1657
- crypto.randomUUID = X(), await e({
1658
- testCase: C,
1659
- source: { document: r.document, databaseName: r.databaseName },
1660
- target: c ? { document: c.document, databaseName: c.databaseName } : void 0
1661
- });
1661
+ crypto.randomUUID = b(), await t({ testCase: A, source: i.document, target: c?.document });
1662
1662
  } finally {
1663
- await r.cleanup(), await c?.cleanup();
1663
+ await _.destroy();
1664
1664
  }
1665
1665
  });
1666
1666
  }
1667
- function K(a, t) {
1668
- for (const [e, A] of Object.entries(a))
1669
- (A.only ? p.only : p)(e, () => t(A));
1667
+ function ee(B, e) {
1668
+ for (const [t, r] of Object.entries(B))
1669
+ (r.only ? p.only : p)(t, () => e(r));
1670
1670
  }
1671
- const ie = ee(o);
1672
- function ee(a, t) {
1671
+ const ie = te(l);
1672
+ function te(B, e) {
1673
1673
  return {
1674
- withExport: (e) => Z({ dialecteConfig: a, hooks: t, ...e }),
1675
- withoutExport: (e) => J({ dialecteConfig: a, hooks: t, ...e }),
1676
- generic: K
1674
+ withExport: (t) => Z({ dialecteConfig: B, hooks: e, ...t }),
1675
+ withoutExport: (t) => J({ dialecteConfig: B, hooks: e, ...t }),
1676
+ generic: ee
1677
1677
  };
1678
1678
  }
1679
- function te(a) {
1680
- function t(e) {
1681
- const { record: A, type: B = "raw" } = e, _ = w({ record: A, dialecteConfig: a });
1682
- switch (B) {
1679
+ function Be(B) {
1680
+ function e(t) {
1681
+ const { record: r, type: a = "raw" } = t, C = g({ record: r, dialecteConfig: B });
1682
+ switch (a) {
1683
1683
  case "raw":
1684
- return _;
1684
+ return C;
1685
1685
  case "tracked":
1686
- return O({ record: _ });
1686
+ return M({ record: C });
1687
1687
  case "tree":
1688
- return g({ record: _ });
1688
+ return O({ record: C });
1689
1689
  default:
1690
- throw new Error(`Unsupported record type: ${B}`);
1690
+ throw new Error(`Unsupported record type: ${a}`);
1691
1691
  }
1692
1692
  }
1693
- return t;
1693
+ return e;
1694
1694
  }
1695
- const ce = te(o);
1695
+ const ne = Be(l);
1696
1696
  export {
1697
1697
  W as DATABASE_CONFIG,
1698
1698
  d as DIALECTE_NAMESPACES,
1699
- Y as IO_CONFIG,
1700
- o as TEST_DIALECTE_CONFIG,
1701
- re as XMLNS_DEFAULT_NAMESPACE,
1702
- Ce as XMLNS_DEV_NAMESPACE,
1703
- _e as XMLNS_EXT_NAMESPACE,
1704
- R as assertExpectedElementQueries,
1705
- F as assertUnexpectedElementQueries,
1706
- X as createMockRandomUUID,
1707
- se as createTestContext,
1708
- m as createTestDialecte,
1709
- ce as createTestRecord,
1710
- te as createTestRecordFactory,
1711
- ee as createTestRunner,
1712
- k as createXmlAssertions,
1699
+ K as IO_CONFIG,
1700
+ l as TEST_DIALECTE_CONFIG,
1701
+ Ce as XMLNS_DEFAULT_NAMESPACE,
1702
+ _e as XMLNS_DEV_NAMESPACE,
1703
+ se as XMLNS_EXT_NAMESPACE,
1704
+ V as assertExpectedElementQueries,
1705
+ y as assertUnexpectedElementQueries,
1706
+ b as createMockRandomUUID,
1707
+ ce as createTestContext,
1708
+ v as createTestProject,
1709
+ ne as createTestRecord,
1710
+ Be as createTestRecordFactory,
1711
+ te as createTestRunner,
1712
+ R as createXmlAssertions,
1713
1713
  ie as runTestCases,
1714
- E as splitXpathIntoSteps
1714
+ h as splitXpathIntoSteps
1715
1715
  };
@@ -3,6 +3,7 @@ import { ImportOptions, ExportOptions, IOHooks } from './io';
3
3
  import { Operation } from './operations';
4
4
  import { Namespace, RawRecord, TreeRecord } from './records';
5
5
  import { CloneMapping, Query } from '../document';
6
+ import { RecordSchema } from '../store';
6
7
  export type RawDialecteConfig<GenericElementNames extends readonly string[], GenericRootElement extends GenericElementNames[number], GenericAttributes extends Record<string, any>, GenericChildren extends Record<string, readonly string[]>, GenericParents extends Record<string, readonly string[]>, GenericDescendants extends Record<string, readonly string[]>, GenericAncestors extends Record<string, readonly string[]>> = {
7
8
  rootElementName: GenericRootElement;
8
9
  singletonElements?: readonly GenericElementNames[number][];
@@ -81,7 +82,13 @@ export type TransactionHooks<GenericConfig extends AnyDialecteConfig> = {
81
82
  }) => Promise<Operation<GenericConfig>[]>;
82
83
  };
83
84
  export type DatabaseConfig = Readonly<{
84
- tables: {
85
+ /** Backend-agnostic index schema for per-file record tables */
86
+ recordSchema: RecordSchema;
87
+ /**
88
+ * @deprecated Legacy table config. Removed in Project-driven rewrite (Phase 5).
89
+ * Only kept for backward compat with old io/ pipeline until it's replaced.
90
+ */
91
+ tables?: {
85
92
  xmlElements: {
86
93
  name: string;
87
94
  schema: string;