@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.
- package/dist/document/bind-extensions.d.ts +1 -1
- package/dist/document/bind-extensions.d.ts.map +1 -1
- package/dist/document/document.d.ts +6 -7
- package/dist/document/document.d.ts.map +1 -1
- package/dist/document/index.d.ts +3 -1
- package/dist/document/index.d.ts.map +1 -1
- package/dist/document/query/any/any-query.d.ts +2 -1
- package/dist/document/query/any/any-query.d.ts.map +1 -1
- package/dist/document/query/find/ancestor/find-ancestor.d.ts +2 -2
- package/dist/document/query/find/ancestor/find-ancestor.d.ts.map +1 -1
- package/dist/document/query/find/descendant/find-descendant.d.ts +2 -2
- package/dist/document/query/find/descendant/find-descendant.d.ts.map +1 -1
- package/dist/document/query/get/attribute/get-attribute.d.ts +2 -2
- package/dist/document/query/get/attribute/get-attribute.d.ts.map +1 -1
- package/dist/document/query/get/attribute/get-attributes.d.ts +2 -2
- package/dist/document/query/get/attribute/get-attributes.d.ts.map +1 -1
- package/dist/document/query/get/record/get-child.d.ts +2 -2
- package/dist/document/query/get/record/get-child.d.ts.map +1 -1
- package/dist/document/query/get/record/get-children.d.ts +2 -2
- package/dist/document/query/get/record/get-children.d.ts.map +1 -1
- package/dist/document/query/get/record/get-record.d.ts +2 -2
- package/dist/document/query/get/record/get-record.d.ts.map +1 -1
- package/dist/document/query/get/record/get-records.d.ts +2 -2
- package/dist/document/query/get/record/get-records.d.ts.map +1 -1
- package/dist/document/query/get/tree/get-tree.d.ts +2 -2
- package/dist/document/query/get/tree/get-tree.d.ts.map +1 -1
- package/dist/document/query/main.d.ts +4 -2
- package/dist/document/query/main.d.ts.map +1 -1
- package/dist/document/transaction/any/any-transaction.d.ts +2 -3
- package/dist/document/transaction/any/any-transaction.d.ts.map +1 -1
- package/dist/document/transaction/clone/clone.d.ts +2 -2
- package/dist/document/transaction/clone/clone.d.ts.map +1 -1
- package/dist/document/transaction/clone/clone.types.d.ts +2 -1
- package/dist/document/transaction/clone/clone.types.d.ts.map +1 -1
- package/dist/document/transaction/commit/commit.d.ts +3 -2
- package/dist/document/transaction/commit/commit.d.ts.map +1 -1
- package/dist/document/transaction/create/create.d.ts +2 -2
- 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 -2
- package/dist/document/transaction/ensure/ensure.d.ts.map +1 -1
- package/dist/document/transaction/main.d.ts +5 -4
- package/dist/document/transaction/main.d.ts.map +1 -1
- package/dist/document/transaction/update/update.d.ts +2 -2
- package/dist/document/transaction/update/update.d.ts.map +1 -1
- package/dist/document/types.d.ts +2 -1
- package/dist/document/types.d.ts.map +1 -1
- package/dist/{types/extensions.d.ts → document/types.extensions.d.ts} +3 -3
- package/dist/document/types.extensions.d.ts.map +1 -0
- package/dist/{types/ref.d.ts → document/types.ref.d.ts} +2 -3
- package/dist/document/types.ref.d.ts.map +1 -0
- package/dist/errors/codes.d.ts +16 -0
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/helpers/converter.d.ts +2 -1
- package/dist/helpers/converter.d.ts.map +1 -1
- package/dist/helpers/merge-extensions.d.ts +1 -2
- package/dist/helpers/merge-extensions.d.ts.map +1 -1
- package/dist/helpers.js +1 -1
- package/dist/{index-B1qiHOqL.js → index-C2WRi-6U.js} +27 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -38
- package/dist/{merge-extensions-D-JNgVJ8.js → merge-extensions-DQKNUthU.js} +1 -1
- package/dist/project/index.d.ts +9 -0
- package/dist/project/index.d.ts.map +1 -0
- package/dist/project/io/export-document.d.ts +7 -0
- package/dist/project/io/export-document.d.ts.map +1 -0
- package/dist/project/io/import-document.d.ts +7 -0
- package/dist/project/io/import-document.d.ts.map +1 -0
- package/dist/project/io/index.d.ts +4 -0
- package/dist/project/io/index.d.ts.map +1 -0
- package/dist/project/io/init-empty-document.d.ts +7 -0
- package/dist/project/io/init-empty-document.d.ts.map +1 -0
- package/dist/project/project.d.ts +80 -0
- package/dist/project/project.d.ts.map +1 -0
- package/dist/project/state/document-state.d.ts +11 -0
- package/dist/project/state/document-state.d.ts.map +1 -0
- package/dist/project/state/index.d.ts +2 -0
- package/dist/project/state/index.d.ts.map +1 -0
- package/dist/project/types.d.ts +128 -0
- package/dist/project/types.d.ts.map +1 -0
- package/dist/project-ChrJXVyu.js +6762 -0
- package/dist/store/index.d.ts +3 -2
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/local/dexie-store.d.ts +74 -0
- package/dist/store/local/dexie-store.d.ts.map +1 -0
- package/dist/store/local/index.d.ts +3 -0
- package/dist/store/local/index.d.ts.map +1 -0
- package/dist/store/local/types.d.ts +6 -0
- package/dist/store/local/types.d.ts.map +1 -0
- package/dist/store/resolve-store.d.ts +9 -0
- package/dist/store/resolve-store.d.ts.map +1 -0
- package/dist/store/store.constants.d.ts +18 -0
- package/dist/store/store.constants.d.ts.map +1 -0
- package/dist/store/store.types.d.ts +70 -32
- package/dist/store/store.types.d.ts.map +1 -1
- package/dist/test/assert-xml/assert-xml.d.ts +1 -1
- package/dist/test/config.d.ts +14 -0
- package/dist/test/config.d.ts.map +1 -1
- package/dist/test/create-test-dialecte.d.ts +20 -20
- package/dist/test/create-test-dialecte.d.ts.map +1 -1
- package/dist/test/run-test-cases.d.ts +6 -0
- package/dist/test/run-test-cases.d.ts.map +1 -1
- package/dist/test/run-test-cases.type.d.ts +4 -8
- package/dist/test/run-test-cases.type.d.ts.map +1 -1
- package/dist/test/test-record.d.ts +48 -0
- package/dist/test/test-record.d.ts.map +1 -1
- package/dist/test.js +227 -227
- package/dist/types/dialecte-config.d.ts +8 -1
- package/dist/types/dialecte-config.d.ts.map +1 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/xml/build/build-xml-document.d.ts +10 -0
- package/dist/xml/build/build-xml-document.d.ts.map +1 -0
- package/dist/xml/build/build-xml-document.types.d.ts +7 -0
- package/dist/xml/build/build-xml-document.types.d.ts.map +1 -0
- package/dist/xml/build/constant.d.ts.map +1 -0
- package/dist/{io/export → xml/build}/download-file.d.ts.map +1 -1
- package/dist/xml/build/formatter.d.ts.map +1 -0
- package/dist/xml/build/index.d.ts +6 -0
- package/dist/xml/build/index.d.ts.map +1 -0
- package/dist/xml/index.d.ts +3 -0
- package/dist/xml/index.d.ts.map +1 -0
- package/dist/{io/import → xml/parse}/guards.d.ts.map +1 -1
- package/dist/xml/parse/index.d.ts +5 -0
- package/dist/xml/parse/index.d.ts.map +1 -0
- package/dist/xml/parse/parse-session.d.ts +22 -0
- package/dist/xml/parse/parse-session.d.ts.map +1 -0
- package/dist/xml/parse/parse-xml-document.d.ts +12 -0
- package/dist/xml/parse/parse-xml-document.d.ts.map +1 -0
- package/dist/xml/parse/parse-xml-document.types.d.ts +17 -0
- package/dist/xml/parse/parse-xml-document.types.d.ts.map +1 -0
- package/dist/{io/import → xml/parse}/parser.d.ts +2 -0
- package/dist/xml/parse/parser.d.ts.map +1 -0
- package/dist/{io/import → xml/parse}/types.d.ts.map +1 -1
- package/package.json +1 -10
- package/dist/dialecte/index.d.ts +0 -2
- package/dist/dialecte/index.d.ts.map +0 -1
- package/dist/dialecte/main.d.ts +0 -6
- package/dist/dialecte/main.d.ts.map +0 -1
- package/dist/dialecte/main.types.d.ts +0 -12
- package/dist/dialecte/main.types.d.ts.map +0 -1
- package/dist/index-BI0vaz_1.js +0 -6662
- package/dist/io/database/index.d.ts +0 -3
- package/dist/io/database/index.d.ts.map +0 -1
- package/dist/io/database/instance.d.ts +0 -7
- package/dist/io/database/instance.d.ts.map +0 -1
- package/dist/io/database/types.d.ts +0 -7
- package/dist/io/database/types.d.ts.map +0 -1
- package/dist/io/export/constant.d.ts.map +0 -1
- package/dist/io/export/formatter.d.ts.map +0 -1
- package/dist/io/export/index.d.ts +0 -4
- package/dist/io/export/index.d.ts.map +0 -1
- package/dist/io/export/main.d.ts +0 -18
- package/dist/io/export/main.d.ts.map +0 -1
- package/dist/io/import/database-helpers.d.ts +0 -53
- package/dist/io/import/database-helpers.d.ts.map +0 -1
- package/dist/io/import/index.d.ts +0 -4
- package/dist/io/import/index.d.ts.map +0 -1
- package/dist/io/import/main.d.ts +0 -15
- package/dist/io/import/main.d.ts.map +0 -1
- package/dist/io/import/parser.d.ts.map +0 -1
- package/dist/io/import/relationships.d.ts +0 -9
- package/dist/io/import/relationships.d.ts.map +0 -1
- package/dist/io/import/test.types.d.ts +0 -4
- package/dist/io/import/test.types.d.ts.map +0 -1
- package/dist/io/index.d.ts +0 -3
- package/dist/io/index.d.ts.map +0 -1
- package/dist/script/element-parent-mapping.d.ts +0 -2
- package/dist/script/element-parent-mapping.d.ts.map +0 -1
- package/dist/script/find-singleton.d.ts +0 -1
- package/dist/script/find-singleton.d.ts.map +0 -1
- package/dist/script/find-unreferenced-elements.d.ts +0 -3
- package/dist/script/find-unreferenced-elements.d.ts.map +0 -1
- package/dist/script/generate-definition.d.ts +0 -3
- package/dist/script/generate-definition.d.ts.map +0 -1
- package/dist/script/generate-definition.types.d.ts +0 -86
- package/dist/script/generate-definition.types.d.ts.map +0 -1
- package/dist/script/pyodide.d.ts +0 -12
- package/dist/script/pyodide.d.ts.map +0 -1
- package/dist/script/sorted-dexie-dump-json.d.ts +0 -2
- package/dist/script/sorted-dexie-dump-json.d.ts.map +0 -1
- package/dist/script/test-pyodide.d.ts +0 -9
- package/dist/script/test-pyodide.d.ts.map +0 -1
- package/dist/store/dexie-store.d.ts +0 -36
- package/dist/store/dexie-store.d.ts.map +0 -1
- package/dist/types/extensions.d.ts.map +0 -1
- package/dist/types/ref.d.ts.map +0 -1
- /package/dist/{io/export → xml/build}/constant.d.ts +0 -0
- /package/dist/{io/export → xml/build}/download-file.d.ts +0 -0
- /package/dist/{io/export → xml/build}/formatter.d.ts +0 -0
- /package/dist/{io/import → xml/parse}/guards.d.ts +0 -0
- /package/dist/{io/import → xml/parse}/types.d.ts +0 -0
package/dist/test.js
CHANGED
|
@@ -1,153 +1,153 @@
|
|
|
1
|
-
import { expect as
|
|
2
|
-
import { x as
|
|
3
|
-
import { D as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
7
|
-
return [
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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 (
|
|
23
|
-
|
|
22
|
+
if (A === '"' || A === "'") {
|
|
23
|
+
a = A;
|
|
24
24
|
continue;
|
|
25
25
|
}
|
|
26
|
-
if (
|
|
27
|
-
|
|
26
|
+
if (A === "[") {
|
|
27
|
+
t++;
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
31
|
-
|
|
30
|
+
if (A === "]") {
|
|
31
|
+
t--;
|
|
32
32
|
continue;
|
|
33
33
|
}
|
|
34
|
-
if (
|
|
35
|
-
|
|
34
|
+
if (A === "(") {
|
|
35
|
+
r++;
|
|
36
36
|
continue;
|
|
37
37
|
}
|
|
38
|
-
if (
|
|
39
|
-
|
|
38
|
+
if (A === ")") {
|
|
39
|
+
r--;
|
|
40
40
|
continue;
|
|
41
41
|
}
|
|
42
|
-
if (!(
|
|
43
|
-
if (
|
|
44
|
-
|
|
42
|
+
if (!(t > 0 || r > 0) && A === "/") {
|
|
43
|
+
if (C === 0) {
|
|
44
|
+
B[C + 1] === "/" && C++;
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
|
-
if (
|
|
47
|
+
if (e.length === 0 && C === 1 && B[0] === "/")
|
|
48
48
|
continue;
|
|
49
|
-
|
|
49
|
+
e.push(C), B[C + 1] === "/" && C++;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
return
|
|
52
|
+
return e;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
const { namespaces:
|
|
54
|
+
function R(B) {
|
|
55
|
+
const { namespaces: e } = B, t = F(e);
|
|
56
56
|
return {
|
|
57
|
-
assertExpectedElementQueries(
|
|
58
|
-
|
|
57
|
+
assertExpectedElementQueries(r) {
|
|
58
|
+
V({ ...r, nsResolver: t });
|
|
59
59
|
},
|
|
60
|
-
assertUnexpectedElementQueries(
|
|
61
|
-
|
|
60
|
+
assertUnexpectedElementQueries(r) {
|
|
61
|
+
y({ ...r, nsResolver: t });
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
const { xmlDocument:
|
|
67
|
-
for (const
|
|
68
|
-
|
|
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
|
|
71
|
-
return (
|
|
70
|
+
function F(B) {
|
|
71
|
+
return (e) => e ? B[e]?.uri ?? null : null;
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
const { xmlDocument:
|
|
75
|
-
for (const
|
|
76
|
-
|
|
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
|
|
79
|
-
const { xmlDocument:
|
|
80
|
-
let
|
|
81
|
-
for (let s = 0; s <
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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 (
|
|
90
|
-
|
|
89
|
+
if (c) {
|
|
90
|
+
C = c, A = s + 1;
|
|
91
91
|
continue;
|
|
92
92
|
}
|
|
93
|
-
const
|
|
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(
|
|
96
|
-
${
|
|
97
|
-
|
|
98
|
-
|
|
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}/${
|
|
101
|
-
Full XPath: ${
|
|
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(
|
|
108
|
-
const { xml:
|
|
107
|
+
function x(B) {
|
|
108
|
+
const { xml: e } = B;
|
|
109
109
|
try {
|
|
110
|
-
return
|
|
110
|
+
return D(e, { indentation: " ", collapseContent: !0 });
|
|
111
111
|
} catch {
|
|
112
|
-
return
|
|
112
|
+
return e;
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
const { xmlDocument:
|
|
117
|
-
if (
|
|
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
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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 =
|
|
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
|
-
|
|
129
|
-
|
|
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 ${
|
|
133
|
-
Full XPath: ${
|
|
134
|
-
${
|
|
135
|
-
).toBeTruthy(), s =
|
|
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
|
|
139
|
-
e,
|
|
138
|
+
const A = e.evaluate(
|
|
140
139
|
t,
|
|
141
|
-
|
|
140
|
+
e,
|
|
141
|
+
r ?? null,
|
|
142
142
|
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
|
143
143
|
null
|
|
144
144
|
).singleNodeValue;
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
m(
|
|
146
|
+
A,
|
|
147
147
|
`Element should NOT exist in XML but was found.
|
|
148
|
-
XPath: ${
|
|
148
|
+
XPath: ${t}
|
|
149
149
|
Found:
|
|
150
|
-
${
|
|
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:
|
|
158
|
+
dev: w,
|
|
159
159
|
ext: {
|
|
160
160
|
uri: "http://dialecte.dev/XML/DEV-EXT",
|
|
161
161
|
prefix: "ext"
|
|
162
162
|
}
|
|
163
|
-
},
|
|
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
|
-
],
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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
|
-
},
|
|
1552
|
+
}, l = {
|
|
1546
1553
|
rootElementName: z,
|
|
1547
1554
|
singletonElements: G,
|
|
1548
|
-
elements:
|
|
1555
|
+
elements: N,
|
|
1549
1556
|
namespaces: d,
|
|
1550
1557
|
attributes: H,
|
|
1551
|
-
children:
|
|
1552
|
-
parents:
|
|
1553
|
-
descendants:
|
|
1554
|
-
ancestors:
|
|
1558
|
+
children: $,
|
|
1559
|
+
parents: P,
|
|
1560
|
+
descendants: Q,
|
|
1561
|
+
ancestors: j,
|
|
1555
1562
|
database: W,
|
|
1556
|
-
io:
|
|
1557
|
-
definition:
|
|
1563
|
+
io: K,
|
|
1564
|
+
definition: Y
|
|
1558
1565
|
};
|
|
1559
|
-
async function
|
|
1566
|
+
async function v(B) {
|
|
1560
1567
|
const {
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
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
|
|
1591
|
-
const { databaseName:
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
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
|
|
1600
|
-
function
|
|
1601
|
-
let
|
|
1610
|
+
const E = crypto.randomUUID.bind(crypto);
|
|
1611
|
+
function b() {
|
|
1612
|
+
let B = 0;
|
|
1602
1613
|
return function() {
|
|
1603
|
-
return `${
|
|
1614
|
+
return `${B++}`;
|
|
1604
1615
|
};
|
|
1605
1616
|
}
|
|
1606
|
-
function Z(
|
|
1617
|
+
function Z(B) {
|
|
1607
1618
|
const {
|
|
1608
|
-
testCases:
|
|
1609
|
-
act:
|
|
1610
|
-
hooks:
|
|
1611
|
-
dialecteConfig:
|
|
1612
|
-
} =
|
|
1613
|
-
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,
|
|
1616
|
-
(
|
|
1617
|
-
crypto.randomUUID =
|
|
1618
|
-
const n = await
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
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 =
|
|
1625
|
-
const {
|
|
1626
|
-
|
|
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
|
|
1640
|
+
await c.destroy();
|
|
1638
1641
|
}
|
|
1639
1642
|
});
|
|
1640
1643
|
}
|
|
1641
|
-
function J(
|
|
1644
|
+
function J(B) {
|
|
1642
1645
|
const {
|
|
1643
|
-
testCases:
|
|
1644
|
-
act:
|
|
1645
|
-
hooks:
|
|
1646
|
-
dialecteConfig:
|
|
1647
|
-
} =
|
|
1648
|
-
for (const [
|
|
1649
|
-
(
|
|
1650
|
-
crypto.randomUUID =
|
|
1651
|
-
const
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
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 =
|
|
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
|
|
1663
|
+
await _.destroy();
|
|
1664
1664
|
}
|
|
1665
1665
|
});
|
|
1666
1666
|
}
|
|
1667
|
-
function
|
|
1668
|
-
for (const [
|
|
1669
|
-
(
|
|
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 =
|
|
1672
|
-
function
|
|
1671
|
+
const ie = te(l);
|
|
1672
|
+
function te(B, e) {
|
|
1673
1673
|
return {
|
|
1674
|
-
withExport: (
|
|
1675
|
-
withoutExport: (
|
|
1676
|
-
generic:
|
|
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
|
|
1680
|
-
function t
|
|
1681
|
-
const { record:
|
|
1682
|
-
switch (
|
|
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
|
|
1686
|
+
return M({ record: C });
|
|
1687
1687
|
case "tree":
|
|
1688
|
-
return
|
|
1688
|
+
return O({ record: C });
|
|
1689
1689
|
default:
|
|
1690
|
-
throw new Error(`Unsupported record type: ${
|
|
1690
|
+
throw new Error(`Unsupported record type: ${a}`);
|
|
1691
1691
|
}
|
|
1692
1692
|
}
|
|
1693
|
-
return
|
|
1693
|
+
return e;
|
|
1694
1694
|
}
|
|
1695
|
-
const
|
|
1695
|
+
const ne = Be(l);
|
|
1696
1696
|
export {
|
|
1697
1697
|
W as DATABASE_CONFIG,
|
|
1698
1698
|
d as DIALECTE_NAMESPACES,
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
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
|
-
|
|
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;
|