@dialecte/core 0.1.11 → 0.1.13

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 (60) hide show
  1. package/dist/dialecte/main.d.ts +3 -9
  2. package/dist/dialecte/main.d.ts.map +1 -1
  3. package/dist/dialecte/main.types.d.ts +12 -0
  4. package/dist/dialecte/main.types.d.ts.map +1 -0
  5. package/dist/document/document.d.ts +3 -2
  6. package/dist/document/document.d.ts.map +1 -1
  7. package/dist/document/query/main.d.ts +32 -13
  8. package/dist/document/query/main.d.ts.map +1 -1
  9. package/dist/document/transaction/clone/clone.d.ts +4 -2
  10. package/dist/document/transaction/clone/clone.d.ts.map +1 -1
  11. package/dist/document/transaction/clone/clone.types.d.ts +6 -2
  12. package/dist/document/transaction/clone/clone.types.d.ts.map +1 -1
  13. package/dist/document/transaction/create/create.d.ts +2 -1
  14. package/dist/document/transaction/create/create.d.ts.map +1 -1
  15. package/dist/document/transaction/delete/delete.d.ts +2 -2
  16. package/dist/document/transaction/delete/delete.d.ts.map +1 -1
  17. package/dist/document/transaction/ensure/ensure.d.ts +2 -1
  18. package/dist/document/transaction/ensure/ensure.d.ts.map +1 -1
  19. package/dist/document/transaction/main.d.ts +7 -3
  20. package/dist/document/transaction/main.d.ts.map +1 -1
  21. package/dist/document/transaction/update/update.d.ts +2 -1
  22. package/dist/document/transaction/update/update.d.ts.map +1 -1
  23. package/dist/errors/codes.d.ts +4 -0
  24. package/dist/errors/codes.d.ts.map +1 -1
  25. package/dist/helpers/guard.d.ts +20 -1
  26. package/dist/helpers/guard.d.ts.map +1 -1
  27. package/dist/helpers/index.d.ts +1 -0
  28. package/dist/helpers/index.d.ts.map +1 -1
  29. package/dist/helpers/standardizing.d.ts +2 -1
  30. package/dist/helpers/standardizing.d.ts.map +1 -1
  31. package/dist/helpers/strip-attributes.d.ts +9 -0
  32. package/dist/helpers/strip-attributes.d.ts.map +1 -0
  33. package/dist/helpers.js +27 -161
  34. package/dist/{index-aALGfPYv.js → index-B1qiHOqL.js} +4 -0
  35. package/dist/index-MWde6dqY.js +6382 -0
  36. package/dist/index.js +27 -26
  37. package/dist/merge-extensions-BWXwiKx1.js +172 -0
  38. package/dist/test/config.d.ts +0 -1
  39. package/dist/test/config.d.ts.map +1 -1
  40. package/dist/test/create-test-dialecte.d.ts +2 -1
  41. package/dist/test/create-test-dialecte.d.ts.map +1 -1
  42. package/dist/test/run-test-cases.d.ts +2 -3
  43. package/dist/test/run-test-cases.d.ts.map +1 -1
  44. package/dist/test/run-test-cases.type.d.ts +3 -1
  45. package/dist/test/run-test-cases.type.d.ts.map +1 -1
  46. package/dist/test/test-record.d.ts +0 -8
  47. package/dist/test/test-record.d.ts.map +1 -1
  48. package/dist/test.js +215 -201
  49. package/dist/types/dialecte-config.d.ts +9 -10
  50. package/dist/types/dialecte-config.d.ts.map +1 -1
  51. package/dist/types/ref.d.ts +2 -1
  52. package/dist/types/ref.d.ts.map +1 -1
  53. package/dist/utils/index.d.ts +1 -1
  54. package/dist/utils/index.d.ts.map +1 -1
  55. package/dist/utils/{assert.d.ts → invariant.d.ts} +1 -1
  56. package/dist/utils/invariant.d.ts.map +1 -0
  57. package/dist/utils.js +1 -1
  58. package/package.json +3 -3
  59. package/dist/index-DRYqQRsA.js +0 -6229
  60. package/dist/utils/assert.d.ts.map +0 -1
package/dist/test.js CHANGED
@@ -1,153 +1,153 @@
1
1
  import { expect as f, it as p } from "vitest";
2
- import { x as X, D as q, i as S, o as D, e as h } from "./index-DRYqQRsA.js";
3
- import { DIALECTE_DEV_NAMESPACE as T, standardizeRecord as L, toTreeRecord as w, toTrackedRecord as g } from "./helpers.js";
4
- function v(t) {
5
- const e = O(t);
6
- if (e.length === 0)
7
- return [t];
8
- const a = [];
9
- for (const B of e)
10
- a.push(t.slice(0, B));
11
- return a.push(t), a;
12
- }
13
- function O(t) {
2
+ import { x as q, D as S, i as D, o as T, e as v } from "./index-MWde6dqY.js";
3
+ import { D as L, s as w, o as g, n as O } from "./merge-extensions-BWXwiKx1.js";
4
+ function E(a) {
5
+ const t = M(a);
6
+ if (t.length === 0)
7
+ return [a];
14
8
  const e = [];
15
- let a = 0, B = 0, A = null;
16
- for (let r = 0; r < t.length; r++) {
17
- const _ = t[r];
18
- if (A) {
19
- _ === A && (A = null);
9
+ for (const A of t)
10
+ e.push(a.slice(0, A));
11
+ return e.push(a), e;
12
+ }
13
+ function M(a) {
14
+ 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);
20
20
  continue;
21
21
  }
22
- if (_ === '"' || _ === "'") {
23
- A = _;
22
+ if (C === '"' || C === "'") {
23
+ B = C;
24
24
  continue;
25
25
  }
26
- if (_ === "[") {
27
- a++;
26
+ if (C === "[") {
27
+ e++;
28
28
  continue;
29
29
  }
30
- if (_ === "]") {
31
- a--;
30
+ if (C === "]") {
31
+ e--;
32
32
  continue;
33
33
  }
34
- if (_ === "(") {
35
- B++;
34
+ if (C === "(") {
35
+ A++;
36
36
  continue;
37
37
  }
38
- if (_ === ")") {
39
- B--;
38
+ if (C === ")") {
39
+ A--;
40
40
  continue;
41
41
  }
42
- if (!(a > 0 || B > 0) && _ === "/") {
43
- if (r === 0) {
44
- t[r + 1] === "/" && r++;
42
+ if (!(e > 0 || A > 0) && C === "/") {
43
+ if (_ === 0) {
44
+ a[_ + 1] === "/" && _++;
45
45
  continue;
46
46
  }
47
- if (e.length === 0 && r === 1 && t[0] === "/")
47
+ if (t.length === 0 && _ === 1 && a[0] === "/")
48
48
  continue;
49
- e.push(r), t[r + 1] === "/" && r++;
49
+ t.push(_), a[_ + 1] === "/" && _++;
50
50
  }
51
51
  }
52
- return e;
52
+ return t;
53
53
  }
54
- function M(t) {
55
- const { namespaces: e } = t, a = R(e);
54
+ function k(a) {
55
+ const { namespaces: t } = a, e = V(t);
56
56
  return {
57
- assertExpectedElementQueries(B) {
58
- k({ ...B, nsResolver: a });
57
+ assertExpectedElementQueries(A) {
58
+ R({ ...A, nsResolver: e });
59
59
  },
60
- assertUnexpectedElementQueries(B) {
61
- V({ ...B, nsResolver: a });
60
+ assertUnexpectedElementQueries(A) {
61
+ F({ ...A, nsResolver: e });
62
62
  }
63
63
  };
64
64
  }
65
- function k(t) {
66
- const { xmlDocument: e, queries: a, nsResolver: B } = t;
67
- for (const A of a)
68
- F({ xmlDocument: e, xpath: A, nsResolver: B });
65
+ function R(a) {
66
+ const { xmlDocument: t, queries: e, nsResolver: A } = a;
67
+ for (const B of e)
68
+ N({ xmlDocument: t, xpath: B, nsResolver: A });
69
69
  }
70
- function R(t) {
71
- return (e) => e ? t[e]?.uri ?? null : null;
70
+ function V(a) {
71
+ return (t) => t ? a[t]?.uri ?? null : null;
72
72
  }
73
- function V(t) {
74
- const { xmlDocument: e, queries: a, nsResolver: B } = t;
75
- for (const A of a)
76
- N({ xmlDocument: e, xpath: A, nsResolver: B });
73
+ function F(a) {
74
+ const { xmlDocument: t, queries: e, nsResolver: A } = a;
75
+ for (const B of e)
76
+ U({ xmlDocument: t, xpath: B, nsResolver: A });
77
77
  }
78
- function F(t) {
79
- const { xmlDocument: e, xpath: a, nsResolver: B } = t, A = v(a);
80
- let r = null, _ = 0;
81
- for (let C = 0; C < A.length; C++) {
82
- const s = A[C], c = e.evaluate(
83
- s,
84
- e,
85
- B ?? null,
78
+ function N(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,
86
86
  XPathResult.FIRST_ORDERED_NODE_TYPE,
87
87
  null
88
88
  ).singleNodeValue;
89
- if (c) {
90
- r = c, _ = C + 1;
89
+ if (n) {
90
+ _ = n, C = s + 1;
91
91
  continue;
92
92
  }
93
- const i = C === 0 ? A[0] : a.slice(A[C - 1].length), u = _ === 0 ? `[No parent matched — failed from document root]
93
+ const c = s === 0 ? B[0] : e.slice(B[s - 1].length), u = C === 0 ? `[No parent matched — failed from document root]
94
94
  Document:
95
- ${x({ xml: new XMLSerializer().serializeToString(e) })}` : `[Last match at step ${_}/${A.length}]:
96
- ${r ? x({ xml: r.outerHTML }) : "(none)"}`;
95
+ ${x({ xml: new XMLSerializer().serializeToString(t) })}` : `[Last match at step ${C}/${B.length}]:
96
+ ${_ ? x({ xml: _.outerHTML }) : "(none)"}`;
97
97
  f(
98
- c,
98
+ n,
99
99
  `Element not found in XML.
100
- Failed at step ${C + 1}/${A.length}: ${i.trim()}
101
- Full XPath: ${a}
100
+ Failed at step ${s + 1}/${B.length}: ${c.trim()}
101
+ Full XPath: ${e}
102
102
  ${u}`
103
103
  ).toBeTruthy();
104
104
  return;
105
105
  }
106
106
  }
107
- function x(t) {
108
- const { xml: e } = t;
107
+ function x(a) {
108
+ const { xml: t } = a;
109
109
  try {
110
- return X(e, { indentation: " ", collapseContent: !0 });
110
+ return q(t, { indentation: " ", collapseContent: !0 });
111
111
  } catch {
112
- return e;
112
+ return t;
113
113
  }
114
114
  }
115
- function N(t) {
116
- const { xmlDocument: e, xpath: a, nsResolver: B } = t, A = v(a);
117
- if (A.length > 1) {
118
- let C = null;
119
- for (let s = 0; s < A.length - 1; s++) {
120
- const n = A[s], i = e.evaluate(
121
- n,
122
- e,
123
- B ?? null,
115
+ function U(a) {
116
+ const { xmlDocument: t, xpath: e, nsResolver: A } = a, B = E(e);
117
+ if (B.length > 1) {
118
+ let s = null;
119
+ for (let r = 0; r < B.length - 1; r++) {
120
+ const i = B[r], c = t.evaluate(
121
+ i,
122
+ t,
123
+ A ?? null,
124
124
  XPathResult.FIRST_ORDERED_NODE_TYPE,
125
125
  null
126
- ).singleNodeValue, u = s === 0 ? A[0] : a.slice(A[s - 1].length), o = s === 0 ? "[Document root — no parent context]" : `[Parent element found at step ${s}]:
127
- ${C ? x({ xml: C.outerHTML }) : "(none)"}`;
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}]:
127
+ ${s ? x({ xml: s.outerHTML }) : "(none)"}`;
128
128
  f(
129
- i,
129
+ c,
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 ${s + 1}/${A.length}: ${u.trim()}
133
- Full XPath: ${a}
134
- ${o}`
135
- ).toBeTruthy(), C = i;
132
+ Missing at step ${r + 1}/${B.length}: ${u.trim()}
133
+ Full XPath: ${e}
134
+ ${l}`
135
+ ).toBeTruthy(), s = c;
136
136
  }
137
137
  }
138
- const _ = e.evaluate(
139
- a,
138
+ const C = t.evaluate(
140
139
  e,
141
- B ?? null,
140
+ t,
141
+ A ?? null,
142
142
  XPathResult.FIRST_ORDERED_NODE_TYPE,
143
143
  null
144
144
  ).singleNodeValue;
145
145
  f(
146
- _,
146
+ C,
147
147
  `Element should NOT exist in XML but was found.
148
- XPath: ${a}
148
+ XPath: ${e}
149
149
  Found:
150
- ${_ ? x({ xml: _.outerHTML }) : "(none)"}`
150
+ ${C ? x({ xml: C.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: T,
158
+ dev: L,
159
159
  ext: {
160
160
  uri: "http://dialecte.dev/XML/DEV-EXT",
161
161
  prefix: "ext"
162
162
  }
163
- }, Ae = `xmlns="${d.default.uri}"`, re = `xmlns:${d.dev.prefix}="${d.dev.uri}"`, Ce = `xmlns:${d.ext.prefix}="${d.ext.uri}"`, U = [
163
+ }, re = `xmlns="${d.default.uri}"`, Ce = `xmlns:${d.dev.prefix}="${d.dev.uri}"`, _e = `xmlns:${d.ext.prefix}="${d.ext.uri}"`, y = [
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
- ], y = {
195
+ ], I = {
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
- }, I = {
227
+ }, $ = {
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
- }, $ = {
259
+ }, P = {
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
- }, P = {
322
+ }, Q = {
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"],
@@ -351,7 +351,7 @@ const d = {
351
351
  CC_2: ["C", "Root"],
352
352
  CC_3: ["C", "Root"],
353
353
  Root: []
354
- }, Q = "Root", z = ["A", "AA_1", "B", "BB_1", "C", "CC_1", "CC_2", "Root"], G = {
354
+ }, z = "Root", G = ["A", "AA_1", "B", "BB_1", "C", "CC_1", "CC_2", "Root"], H = {
355
355
  A: {
356
356
  aA: "",
357
357
  bA: "",
@@ -506,7 +506,7 @@ const d = {
506
506
  "ext:root": "",
507
507
  root: ""
508
508
  }
509
- }, H = {
509
+ }, j = {
510
510
  A: {
511
511
  tag: "A",
512
512
  namespace: { prefix: "", uri: "http://dialecte.dev/XML/DEFAULT" },
@@ -1508,168 +1508,182 @@ const d = {
1508
1508
  }
1509
1509
  ]
1510
1510
  }
1511
- }, j = {
1512
- supportedFileExtensions: [".xml"]
1513
1511
  }, Y = {
1512
+ supportedFileExtensions: [".xml"]
1513
+ }, W = {
1514
1514
  tables: {
1515
1515
  xmlElements: {
1516
1516
  name: "xmlElements",
1517
1517
  schema: "id, tagName, [id+tagName], parent.id, parent.tagName, *children.id, *children.tagName"
1518
1518
  }
1519
1519
  }
1520
- }, l = {
1521
- rootElementName: Q,
1522
- singletonElements: z,
1523
- elements: U,
1520
+ }, o = {
1521
+ rootElementName: z,
1522
+ singletonElements: G,
1523
+ elements: y,
1524
1524
  namespaces: d,
1525
- attributes: G,
1526
- children: y,
1527
- parents: I,
1528
- descendants: $,
1529
- ancestors: P,
1530
- database: Y,
1531
- io: j,
1532
- definition: H,
1533
- hooks: {}
1525
+ attributes: H,
1526
+ children: I,
1527
+ parents: $,
1528
+ descendants: P,
1529
+ ancestors: Q,
1530
+ database: W,
1531
+ io: Y,
1532
+ definition: j
1534
1533
  };
1535
- async function m(t) {
1536
- const { xmlString: e, dialecteConfig: a = l } = t, B = `test-${crypto.randomUUID()}.xml`, A = new File([e], B, { type: "text/xml" }), _ = (await S({
1537
- files: [A],
1538
- dialecteConfig: a,
1534
+ async function m(a) {
1535
+ const {
1536
+ xmlString: t,
1537
+ dialecteConfig: e = o,
1538
+ hooks: A
1539
+ } = a, B = `test-${crypto.randomUUID()}.xml`, _ = new File([t], B, { type: "text/xml" }), s = (await D({
1540
+ files: [_],
1541
+ dialecteConfig: e,
1539
1542
  useCustomRecordsIds: !0
1540
- }))[0], C = D({
1541
- config: a,
1542
- storage: { type: "local", databaseName: _ }
1543
+ }))[0], r = T({
1544
+ config: e,
1545
+ storage: { type: "local", databaseName: s },
1546
+ hooks: A
1543
1547
  });
1544
1548
  return {
1545
- document: C,
1546
- databaseName: _,
1549
+ document: r,
1550
+ databaseName: s,
1547
1551
  exportCurrentTest: async (c) => {
1548
- const { extension: i = a.io.supportedFileExtensions[0], withDatabaseIds: u = !1 } = c || {};
1549
- return h({
1550
- dialecteConfig: a,
1551
- databaseName: _,
1552
- extension: i,
1553
- withDatabaseIds: u
1552
+ const { extension: u = e.io.supportedFileExtensions[0], withDatabaseIds: l = !1 } = c || {};
1553
+ return v({
1554
+ dialecteConfig: e,
1555
+ databaseName: s,
1556
+ extension: u,
1557
+ withDatabaseIds: l
1554
1558
  });
1555
1559
  },
1556
1560
  cleanup: async () => {
1557
- C.destroy();
1561
+ r.destroy();
1558
1562
  }
1559
1563
  };
1560
1564
  }
1561
- function _e(t) {
1562
- const { databaseName: e, dialecteConfig: a } = t;
1565
+ function se(a) {
1566
+ const { databaseName: t, dialecteConfig: e } = a;
1563
1567
  return {
1564
- store: new q(e, a),
1568
+ store: new S(t, e),
1565
1569
  recordCache: /* @__PURE__ */ new Map(),
1566
1570
  stagedOperations: []
1567
1571
  };
1568
1572
  }
1569
- const E = crypto.randomUUID.bind(crypto);
1570
- function b() {
1571
- let t = 0;
1573
+ const b = crypto.randomUUID.bind(crypto);
1574
+ function X() {
1575
+ let a = 0;
1572
1576
  return function() {
1573
- return `${t++}`;
1577
+ return `${a++}`;
1574
1578
  };
1575
1579
  }
1576
- function W(t) {
1580
+ function Z(a) {
1577
1581
  const {
1578
- testCases: e,
1579
- act: a,
1580
- dialecteConfig: B = l
1581
- } = t, { assertExpectedElementQueries: A, assertUnexpectedElementQueries: r } = M({
1582
+ testCases: t,
1583
+ act: e,
1584
+ hooks: A,
1585
+ dialecteConfig: B = o
1586
+ } = a, { assertExpectedElementQueries: _, assertUnexpectedElementQueries: C } = k({
1582
1587
  namespaces: B.namespaces
1583
1588
  });
1584
- for (const [_, C] of Object.entries(e))
1585
- (C.only ? p.only : p)(_, async () => {
1586
- crypto.randomUUID = E;
1587
- const n = await m({ xmlString: C.sourceXml, dialecteConfig: B }), c = C.targetXml ? await m({ xmlString: C.targetXml, dialecteConfig: B }) : void 0;
1589
+ for (const [s, r] of Object.entries(t))
1590
+ (r.only ? p.only : p)(s, async () => {
1591
+ crypto.randomUUID = b;
1592
+ const n = await m({
1593
+ xmlString: r.sourceXml,
1594
+ dialecteConfig: B,
1595
+ hooks: A
1596
+ }), c = r.targetXml ? await m({ xmlString: r.targetXml, dialecteConfig: B, hooks: A }) : void 0;
1588
1597
  try {
1589
- crypto.randomUUID = b();
1590
- const { assertDatabaseName: i, withDatabaseIds: u } = await a({
1591
- testCase: C,
1598
+ crypto.randomUUID = X();
1599
+ const { assertDatabaseName: u, withDatabaseIds: l } = await e({
1600
+ testCase: r,
1592
1601
  source: { document: n.document, databaseName: n.databaseName },
1593
1602
  target: c ? { document: c.document, databaseName: c.databaseName } : void 0
1594
- }), { xmlDocument: o } = await h({
1603
+ }), { xmlDocument: h } = await v({
1595
1604
  dialecteConfig: B,
1596
- databaseName: i,
1605
+ databaseName: u,
1597
1606
  extension: B.io.supportedFileExtensions[0],
1598
- withDatabaseIds: u ?? !0
1607
+ withDatabaseIds: l ?? !0
1599
1608
  });
1600
- C.expectedQueries?.length && A({ xmlDocument: o, queries: C.expectedQueries }), C.unexpectedQueries?.length && r({ xmlDocument: o, queries: C.unexpectedQueries });
1609
+ r.expectedQueries?.length && _({ xmlDocument: h, queries: r.expectedQueries }), r.unexpectedQueries?.length && C({ xmlDocument: h, queries: r.unexpectedQueries });
1601
1610
  } finally {
1602
1611
  await n.cleanup(), await c?.cleanup();
1603
1612
  }
1604
1613
  });
1605
1614
  }
1606
- function Z(t) {
1615
+ function J(a) {
1607
1616
  const {
1608
- testCases: e,
1609
- act: a,
1610
- dialecteConfig: B = l
1611
- } = t;
1612
- for (const [A, r] of Object.entries(e))
1613
- (r.only ? p.only : p)(A, async () => {
1614
- crypto.randomUUID = E;
1615
- const C = await m({ xmlString: r.sourceXml, dialecteConfig: B }), s = r.targetXml ? await m({ xmlString: r.targetXml, dialecteConfig: B }) : void 0;
1617
+ testCases: t,
1618
+ act: e,
1619
+ hooks: A,
1620
+ dialecteConfig: B = o
1621
+ } = a;
1622
+ for (const [_, C] of Object.entries(t))
1623
+ (C.only ? p.only : p)(_, async () => {
1624
+ crypto.randomUUID = b;
1625
+ const r = await m({
1626
+ xmlString: C.sourceXml,
1627
+ dialecteConfig: B,
1628
+ hooks: A
1629
+ }), i = C.targetXml ? await m({ xmlString: C.targetXml, dialecteConfig: B, hooks: A }) : void 0;
1616
1630
  try {
1617
- crypto.randomUUID = b(), await a({
1618
- testCase: r,
1619
- source: { document: C.document, databaseName: C.databaseName },
1620
- target: s ? { document: s.document, databaseName: s.databaseName } : void 0
1631
+ crypto.randomUUID = X(), await e({
1632
+ testCase: C,
1633
+ source: { document: r.document, databaseName: r.databaseName },
1634
+ target: i ? { document: i.document, databaseName: i.databaseName } : void 0
1621
1635
  });
1622
1636
  } finally {
1623
- await C.cleanup(), await s?.cleanup();
1637
+ await r.cleanup(), await i?.cleanup();
1624
1638
  }
1625
1639
  });
1626
1640
  }
1627
- function J(t, e) {
1628
- for (const [a, B] of Object.entries(t))
1629
- (B.only ? p.only : p)(a, () => e(B));
1641
+ function K(a, t) {
1642
+ for (const [e, A] of Object.entries(a))
1643
+ (A.only ? p.only : p)(e, () => t(A));
1630
1644
  }
1631
- const se = K(l);
1632
- function K(t) {
1645
+ const ce = ee(o);
1646
+ function ee(a, t) {
1633
1647
  return {
1634
- withExport: (e) => W({ dialecteConfig: t, ...e }),
1635
- withoutExport: (e) => Z({ dialecteConfig: t, ...e }),
1636
- generic: J
1648
+ withExport: (e) => Z({ dialecteConfig: a, hooks: t, ...e }),
1649
+ withoutExport: (e) => J({ dialecteConfig: a, hooks: t, ...e }),
1650
+ generic: K
1637
1651
  };
1638
1652
  }
1639
- function ee(t) {
1640
- function e(a) {
1641
- const { record: B, type: A = "raw" } = a, r = L({ record: B, dialecteConfig: t });
1642
- switch (A) {
1653
+ function te(a) {
1654
+ function t(e) {
1655
+ const { record: A, type: B = "raw" } = e, _ = w({ record: A, dialecteConfig: a });
1656
+ switch (B) {
1643
1657
  case "raw":
1644
- return r;
1658
+ return _;
1645
1659
  case "tracked":
1646
- return g({ record: r });
1660
+ return O({ record: _ });
1647
1661
  case "tree":
1648
- return w({ record: r });
1662
+ return g({ record: _ });
1649
1663
  default:
1650
- throw new Error(`Unsupported record type: ${A}`);
1664
+ throw new Error(`Unsupported record type: ${B}`);
1651
1665
  }
1652
1666
  }
1653
- return e;
1667
+ return t;
1654
1668
  }
1655
- const ce = ee(l);
1669
+ const ie = te(o);
1656
1670
  export {
1657
- Y as DATABASE_CONFIG,
1671
+ W as DATABASE_CONFIG,
1658
1672
  d as DIALECTE_NAMESPACES,
1659
- j as IO_CONFIG,
1660
- l as TEST_DIALECTE_CONFIG,
1661
- Ae as XMLNS_DEFAULT_NAMESPACE,
1662
- re as XMLNS_DEV_NAMESPACE,
1663
- Ce as XMLNS_EXT_NAMESPACE,
1664
- k as assertExpectedElementQueries,
1665
- V as assertUnexpectedElementQueries,
1666
- b as createMockRandomUUID,
1667
- _e as createTestContext,
1673
+ Y as IO_CONFIG,
1674
+ o as TEST_DIALECTE_CONFIG,
1675
+ re as XMLNS_DEFAULT_NAMESPACE,
1676
+ Ce as XMLNS_DEV_NAMESPACE,
1677
+ _e as XMLNS_EXT_NAMESPACE,
1678
+ R as assertExpectedElementQueries,
1679
+ F as assertUnexpectedElementQueries,
1680
+ X as createMockRandomUUID,
1681
+ se as createTestContext,
1668
1682
  m as createTestDialecte,
1669
- ce as createTestRecord,
1670
- ee as createTestRecordFactory,
1671
- K as createTestRunner,
1672
- M as createXmlAssertions,
1673
- se as runTestCases,
1674
- v as splitXpathIntoSteps
1683
+ ie as createTestRecord,
1684
+ te as createTestRecordFactory,
1685
+ ee as createTestRunner,
1686
+ k as createXmlAssertions,
1687
+ ce as runTestCases,
1688
+ E as splitXpathIntoSteps
1675
1689
  };
@@ -16,7 +16,6 @@ export type RawDialecteConfig<GenericElementNames extends readonly string[], Gen
16
16
  database: DatabaseConfig;
17
17
  io: IOConfig;
18
18
  definition: AnyDefinition;
19
- hooks: TransactionHooks;
20
19
  };
21
20
  export type IOConfig = {
22
21
  supportedFileExtensions: readonly string[];
@@ -24,12 +23,12 @@ export type IOConfig = {
24
23
  exportOptions?: Partial<ExportOptions>;
25
24
  hooks?: IOHooks;
26
25
  };
27
- export type TransactionHooks = {
26
+ export type TransactionHooks<GenericConfig extends AnyDialecteConfig> = {
28
27
  /**
29
28
  * Called before cloning a record.
30
29
  * Return modified attributes for the clone.
31
30
  */
32
- beforeClone?: <GenericConfig extends AnyDialecteConfig, GenericElement extends ElementsOf<GenericConfig>>(params: {
31
+ beforeClone?: <GenericElement extends ElementsOf<GenericConfig>>(params: {
33
32
  record: TreeRecord<GenericConfig, GenericElement>;
34
33
  }) => {
35
34
  shouldBeCloned: boolean;
@@ -39,31 +38,31 @@ export type TransactionHooks = {
39
38
  * Called after core standardizes element from definition.
40
39
  * Use to enrich record (e.g., auto-generate UUIDs).
41
40
  */
42
- afterStandardizedRecord?: <GenericConfig extends AnyDialecteConfig, GenericElement extends ElementsOf<GenericConfig>>(params: {
41
+ afterStandardizedRecord?: <GenericElement extends ElementsOf<GenericConfig>>(params: {
43
42
  record: RawRecord<GenericConfig, GenericElement>;
44
43
  }) => RawRecord<GenericConfig, GenericElement>;
45
44
  /**
46
45
  * Called after record created but before staging.
47
46
  * Return additional operations (e.g., wrapper elements).
48
47
  */
49
- afterCreated?: <GenericConfig extends AnyDialecteConfig, GenericElement extends ElementsOf<GenericConfig>, GenericParentElement extends ParentsOf<GenericConfig, GenericElement>>(params: {
48
+ afterCreated?: <GenericElement extends ElementsOf<GenericConfig>, GenericParentElement extends ParentsOf<GenericConfig, GenericElement>>(params: {
50
49
  childRecord: RawRecord<GenericConfig, GenericElement>;
51
50
  parentRecord: RawRecord<GenericConfig, GenericParentElement>;
52
51
  query: Query<GenericConfig>;
53
52
  }) => Promise<Operation<GenericConfig>[]>;
54
53
  /**
55
54
  * Called after deepClone completes all recursive cloning.
56
- * Receives the full sourcetarget mapping. Return additional operations to stage
55
+ * Receives the full source->target mapping. Return additional operations to stage
57
56
  */
58
- afterDeepClone?: <GenericConfig extends AnyDialecteConfig>(params: {
59
- mappings: CloneMapping<GenericConfig>[];
57
+ afterDeepClone?: (params: {
58
+ cumulativeCloneMappings: CloneMapping<GenericConfig>[];
60
59
  query: Query<GenericConfig>;
61
60
  }) => Promise<Operation<GenericConfig>[]>;
62
61
  /**
63
62
  * Called after a record is updated (attributes or value changed).
64
63
  * Return additional operations to stage (e.g., update path attrs on dependent refs).
65
64
  */
66
- afterUpdated?: <GenericConfig extends AnyDialecteConfig, GenericElement extends ElementsOf<GenericConfig>>(params: {
65
+ afterUpdated?: <GenericElement extends ElementsOf<GenericConfig>>(params: {
67
66
  oldRecord: RawRecord<GenericConfig, GenericElement>;
68
67
  newRecord: RawRecord<GenericConfig, GenericElement>;
69
68
  query: Query<GenericConfig>;
@@ -75,7 +74,7 @@ export type TransactionHooks = {
75
74
  * Return additional operations to stage (e.g., clear or delete ref elements
76
75
  * pointing to this record or any of its descendants).
77
76
  */
78
- beforeDelete?: <GenericConfig extends AnyDialecteConfig, GenericElement extends ElementsOf<GenericConfig>>(params: {
77
+ beforeDelete?: <GenericElement extends ElementsOf<GenericConfig>>(params: {
79
78
  record: RawRecord<GenericConfig, GenericElement>;
80
79
  query: Query<GenericConfig>;
81
80
  }) => Promise<Operation<GenericConfig>[]>;