@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.
- package/dist/dialecte/main.d.ts +3 -9
- package/dist/dialecte/main.d.ts.map +1 -1
- package/dist/dialecte/main.types.d.ts +12 -0
- package/dist/dialecte/main.types.d.ts.map +1 -0
- package/dist/document/document.d.ts +3 -2
- package/dist/document/document.d.ts.map +1 -1
- package/dist/document/query/main.d.ts +32 -13
- package/dist/document/query/main.d.ts.map +1 -1
- package/dist/document/transaction/clone/clone.d.ts +4 -2
- package/dist/document/transaction/clone/clone.d.ts.map +1 -1
- package/dist/document/transaction/clone/clone.types.d.ts +6 -2
- package/dist/document/transaction/clone/clone.types.d.ts.map +1 -1
- package/dist/document/transaction/create/create.d.ts +2 -1
- package/dist/document/transaction/create/create.d.ts.map +1 -1
- package/dist/document/transaction/delete/delete.d.ts +2 -2
- package/dist/document/transaction/delete/delete.d.ts.map +1 -1
- package/dist/document/transaction/ensure/ensure.d.ts +2 -1
- package/dist/document/transaction/ensure/ensure.d.ts.map +1 -1
- package/dist/document/transaction/main.d.ts +7 -3
- package/dist/document/transaction/main.d.ts.map +1 -1
- package/dist/document/transaction/update/update.d.ts +2 -1
- package/dist/document/transaction/update/update.d.ts.map +1 -1
- package/dist/errors/codes.d.ts +4 -0
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/helpers/guard.d.ts +20 -1
- package/dist/helpers/guard.d.ts.map +1 -1
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.d.ts.map +1 -1
- package/dist/helpers/standardizing.d.ts +2 -1
- package/dist/helpers/standardizing.d.ts.map +1 -1
- package/dist/helpers/strip-attributes.d.ts +9 -0
- package/dist/helpers/strip-attributes.d.ts.map +1 -0
- package/dist/helpers.js +27 -161
- package/dist/{index-aALGfPYv.js → index-B1qiHOqL.js} +4 -0
- package/dist/index-MWde6dqY.js +6382 -0
- package/dist/index.js +27 -26
- package/dist/merge-extensions-BWXwiKx1.js +172 -0
- package/dist/test/config.d.ts +0 -1
- package/dist/test/config.d.ts.map +1 -1
- package/dist/test/create-test-dialecte.d.ts +2 -1
- package/dist/test/create-test-dialecte.d.ts.map +1 -1
- package/dist/test/run-test-cases.d.ts +2 -3
- package/dist/test/run-test-cases.d.ts.map +1 -1
- package/dist/test/run-test-cases.type.d.ts +3 -1
- package/dist/test/run-test-cases.type.d.ts.map +1 -1
- package/dist/test/test-record.d.ts +0 -8
- package/dist/test/test-record.d.ts.map +1 -1
- package/dist/test.js +215 -201
- package/dist/types/dialecte-config.d.ts +9 -10
- package/dist/types/dialecte-config.d.ts.map +1 -1
- package/dist/types/ref.d.ts +2 -1
- package/dist/types/ref.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/{assert.d.ts → invariant.d.ts} +1 -1
- package/dist/utils/invariant.d.ts.map +1 -0
- package/dist/utils.js +1 -1
- package/package.json +3 -3
- package/dist/index-DRYqQRsA.js +0 -6229
- 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
|
|
3
|
-
import {
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
7
|
-
return [
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
22
|
+
if (C === '"' || C === "'") {
|
|
23
|
+
B = C;
|
|
24
24
|
continue;
|
|
25
25
|
}
|
|
26
|
-
if (
|
|
27
|
-
|
|
26
|
+
if (C === "[") {
|
|
27
|
+
e++;
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
31
|
-
|
|
30
|
+
if (C === "]") {
|
|
31
|
+
e--;
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
34
|
-
if (
|
|
35
|
-
|
|
34
|
+
if (C === "(") {
|
|
35
|
+
A++;
|
|
36
36
|
continue;
|
|
37
37
|
}
|
|
38
|
-
if (
|
|
39
|
-
|
|
38
|
+
if (C === ")") {
|
|
39
|
+
A--;
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
|
-
if (!(
|
|
43
|
-
if (
|
|
44
|
-
|
|
42
|
+
if (!(e > 0 || A > 0) && C === "/") {
|
|
43
|
+
if (_ === 0) {
|
|
44
|
+
a[_ + 1] === "/" && _++;
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
|
-
if (
|
|
47
|
+
if (t.length === 0 && _ === 1 && a[0] === "/")
|
|
48
48
|
continue;
|
|
49
|
-
|
|
49
|
+
t.push(_), a[_ + 1] === "/" && _++;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
return
|
|
52
|
+
return t;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
const { namespaces:
|
|
54
|
+
function k(a) {
|
|
55
|
+
const { namespaces: t } = a, e = V(t);
|
|
56
56
|
return {
|
|
57
|
-
assertExpectedElementQueries(
|
|
58
|
-
|
|
57
|
+
assertExpectedElementQueries(A) {
|
|
58
|
+
R({ ...A, nsResolver: e });
|
|
59
59
|
},
|
|
60
|
-
assertUnexpectedElementQueries(
|
|
61
|
-
|
|
60
|
+
assertUnexpectedElementQueries(A) {
|
|
61
|
+
F({ ...A, nsResolver: e });
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
const { xmlDocument:
|
|
67
|
-
for (const
|
|
68
|
-
|
|
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
|
|
71
|
-
return (
|
|
70
|
+
function V(a) {
|
|
71
|
+
return (t) => t ? a[t]?.uri ?? null : null;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
const { xmlDocument:
|
|
75
|
-
for (const
|
|
76
|
-
|
|
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
|
|
79
|
-
const { xmlDocument:
|
|
80
|
-
let
|
|
81
|
-
for (let
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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 (
|
|
90
|
-
|
|
89
|
+
if (n) {
|
|
90
|
+
_ = n, C = s + 1;
|
|
91
91
|
continue;
|
|
92
92
|
}
|
|
93
|
-
const
|
|
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(
|
|
96
|
-
${
|
|
95
|
+
${x({ xml: new XMLSerializer().serializeToString(t) })}` : `[Last match at step ${C}/${B.length}]:
|
|
96
|
+
${_ ? x({ xml: _.outerHTML }) : "(none)"}`;
|
|
97
97
|
f(
|
|
98
|
-
|
|
98
|
+
n,
|
|
99
99
|
`Element not found in XML.
|
|
100
|
-
Failed at step ${
|
|
101
|
-
Full XPath: ${
|
|
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(
|
|
108
|
-
const { xml:
|
|
107
|
+
function x(a) {
|
|
108
|
+
const { xml: t } = a;
|
|
109
109
|
try {
|
|
110
|
-
return
|
|
110
|
+
return q(t, { indentation: " ", collapseContent: !0 });
|
|
111
111
|
} catch {
|
|
112
|
-
return
|
|
112
|
+
return t;
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
const { xmlDocument:
|
|
117
|
-
if (
|
|
118
|
-
let
|
|
119
|
-
for (let
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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 =
|
|
127
|
-
${
|
|
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
|
-
|
|
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 ${
|
|
133
|
-
Full XPath: ${
|
|
134
|
-
${
|
|
135
|
-
).toBeTruthy(),
|
|
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
|
|
139
|
-
a,
|
|
138
|
+
const C = t.evaluate(
|
|
140
139
|
e,
|
|
141
|
-
|
|
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: ${
|
|
148
|
+
XPath: ${e}
|
|
149
149
|
Found:
|
|
150
|
-
${
|
|
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:
|
|
158
|
+
dev: L,
|
|
159
159
|
ext: {
|
|
160
160
|
uri: "http://dialecte.dev/XML/DEV-EXT",
|
|
161
161
|
prefix: "ext"
|
|
162
162
|
}
|
|
163
|
-
},
|
|
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
|
-
],
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
1521
|
-
rootElementName:
|
|
1522
|
-
singletonElements:
|
|
1523
|
-
elements:
|
|
1520
|
+
}, o = {
|
|
1521
|
+
rootElementName: z,
|
|
1522
|
+
singletonElements: G,
|
|
1523
|
+
elements: y,
|
|
1524
1524
|
namespaces: d,
|
|
1525
|
-
attributes:
|
|
1526
|
-
children:
|
|
1527
|
-
parents:
|
|
1528
|
-
descendants:
|
|
1529
|
-
ancestors:
|
|
1530
|
-
database:
|
|
1531
|
-
io:
|
|
1532
|
-
definition:
|
|
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(
|
|
1536
|
-
const {
|
|
1537
|
-
|
|
1538
|
-
dialecteConfig:
|
|
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],
|
|
1541
|
-
config:
|
|
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:
|
|
1546
|
-
databaseName:
|
|
1549
|
+
document: r,
|
|
1550
|
+
databaseName: s,
|
|
1547
1551
|
exportCurrentTest: async (c) => {
|
|
1548
|
-
const { extension:
|
|
1549
|
-
return
|
|
1550
|
-
dialecteConfig:
|
|
1551
|
-
databaseName:
|
|
1552
|
-
extension:
|
|
1553
|
-
withDatabaseIds:
|
|
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
|
-
|
|
1561
|
+
r.destroy();
|
|
1558
1562
|
}
|
|
1559
1563
|
};
|
|
1560
1564
|
}
|
|
1561
|
-
function
|
|
1562
|
-
const { databaseName:
|
|
1565
|
+
function se(a) {
|
|
1566
|
+
const { databaseName: t, dialecteConfig: e } = a;
|
|
1563
1567
|
return {
|
|
1564
|
-
store: new
|
|
1568
|
+
store: new S(t, e),
|
|
1565
1569
|
recordCache: /* @__PURE__ */ new Map(),
|
|
1566
1570
|
stagedOperations: []
|
|
1567
1571
|
};
|
|
1568
1572
|
}
|
|
1569
|
-
const
|
|
1570
|
-
function
|
|
1571
|
-
let
|
|
1573
|
+
const b = crypto.randomUUID.bind(crypto);
|
|
1574
|
+
function X() {
|
|
1575
|
+
let a = 0;
|
|
1572
1576
|
return function() {
|
|
1573
|
-
return `${
|
|
1577
|
+
return `${a++}`;
|
|
1574
1578
|
};
|
|
1575
1579
|
}
|
|
1576
|
-
function
|
|
1580
|
+
function Z(a) {
|
|
1577
1581
|
const {
|
|
1578
|
-
testCases:
|
|
1579
|
-
act:
|
|
1580
|
-
|
|
1581
|
-
|
|
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 [
|
|
1585
|
-
(
|
|
1586
|
-
crypto.randomUUID =
|
|
1587
|
-
const n = await m({
|
|
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 =
|
|
1590
|
-
const { assertDatabaseName:
|
|
1591
|
-
testCase:
|
|
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:
|
|
1603
|
+
}), { xmlDocument: h } = await v({
|
|
1595
1604
|
dialecteConfig: B,
|
|
1596
|
-
databaseName:
|
|
1605
|
+
databaseName: u,
|
|
1597
1606
|
extension: B.io.supportedFileExtensions[0],
|
|
1598
|
-
withDatabaseIds:
|
|
1607
|
+
withDatabaseIds: l ?? !0
|
|
1599
1608
|
});
|
|
1600
|
-
|
|
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
|
|
1615
|
+
function J(a) {
|
|
1607
1616
|
const {
|
|
1608
|
-
testCases:
|
|
1609
|
-
act:
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
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 =
|
|
1618
|
-
testCase:
|
|
1619
|
-
source: { document:
|
|
1620
|
-
target:
|
|
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
|
|
1637
|
+
await r.cleanup(), await i?.cleanup();
|
|
1624
1638
|
}
|
|
1625
1639
|
});
|
|
1626
1640
|
}
|
|
1627
|
-
function
|
|
1628
|
-
for (const [
|
|
1629
|
-
(
|
|
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
|
|
1632
|
-
function
|
|
1645
|
+
const ce = ee(o);
|
|
1646
|
+
function ee(a, t) {
|
|
1633
1647
|
return {
|
|
1634
|
-
withExport: (e) =>
|
|
1635
|
-
withoutExport: (e) =>
|
|
1636
|
-
generic:
|
|
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
|
|
1640
|
-
function e
|
|
1641
|
-
const { record:
|
|
1642
|
-
switch (
|
|
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
|
|
1658
|
+
return _;
|
|
1645
1659
|
case "tracked":
|
|
1646
|
-
return
|
|
1660
|
+
return O({ record: _ });
|
|
1647
1661
|
case "tree":
|
|
1648
|
-
return
|
|
1662
|
+
return g({ record: _ });
|
|
1649
1663
|
default:
|
|
1650
|
-
throw new Error(`Unsupported record type: ${
|
|
1664
|
+
throw new Error(`Unsupported record type: ${B}`);
|
|
1651
1665
|
}
|
|
1652
1666
|
}
|
|
1653
|
-
return
|
|
1667
|
+
return t;
|
|
1654
1668
|
}
|
|
1655
|
-
const
|
|
1669
|
+
const ie = te(o);
|
|
1656
1670
|
export {
|
|
1657
|
-
|
|
1671
|
+
W as DATABASE_CONFIG,
|
|
1658
1672
|
d as DIALECTE_NAMESPACES,
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
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
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
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?: <
|
|
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?: <
|
|
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?: <
|
|
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 source
|
|
55
|
+
* Receives the full source->target mapping. Return additional operations to stage
|
|
57
56
|
*/
|
|
58
|
-
afterDeepClone?:
|
|
59
|
-
|
|
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?: <
|
|
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?: <
|
|
77
|
+
beforeDelete?: <GenericElement extends ElementsOf<GenericConfig>>(params: {
|
|
79
78
|
record: RawRecord<GenericConfig, GenericElement>;
|
|
80
79
|
query: Query<GenericConfig>;
|
|
81
80
|
}) => Promise<Operation<GenericConfig>[]>;
|