@dialecte/core 0.2.14 → 0.2.16
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/helpers.d.ts +1 -1
- package/dist/helpers.js +162 -30
- package/dist/index.js +3 -56
- package/dist/project-BOM3Ipbu.js +7744 -0
- package/dist/test/create-test-dialecte.d.ts +5 -5
- package/dist/test/create-test-dialecte.d.ts.map +1 -1
- package/dist/test/run-test-cases.type.d.ts +3 -3
- package/dist/test/run-test-cases.type.d.ts.map +1 -1
- package/dist/test.d.ts +1 -1
- package/dist/test.js +2849 -1705
- package/dist/utils-B_-lXlpE.js +177 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +2 -23
- package/package.json +13 -15
- package/dist/index-CTdGZJiM.js +0 -7220
- package/dist/invariant-CqEgHr3M.js +0 -162
- package/dist/merge-extensions-CcL-L2ca.js +0 -172
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
const c = {
|
|
2
|
-
// D0xxx — Generic
|
|
3
|
-
UNKNOWN: {
|
|
4
|
-
code: "D0001",
|
|
5
|
-
message: "An unknown error occurred"
|
|
6
|
-
},
|
|
7
|
-
ASSERTION_FAILED: {
|
|
8
|
-
code: "D0002",
|
|
9
|
-
message: "Assertion failed"
|
|
10
|
-
},
|
|
11
|
-
// D1xxx — Store/persistence
|
|
12
|
-
STORE_CONNECTION_FAILED: {
|
|
13
|
-
code: "D1001",
|
|
14
|
-
message: "Failed to open database"
|
|
15
|
-
},
|
|
16
|
-
STORE_COMMIT_FAILED: {
|
|
17
|
-
code: "D1002",
|
|
18
|
-
message: "Failed to commit changes"
|
|
19
|
-
},
|
|
20
|
-
STORE_RECORD_NOT_FOUND: {
|
|
21
|
-
code: "D1003",
|
|
22
|
-
message: "Record not found in database"
|
|
23
|
-
},
|
|
24
|
-
STORE_BULK_ADD_FAILED: {
|
|
25
|
-
code: "D1004",
|
|
26
|
-
message: "Failed to add records to database"
|
|
27
|
-
},
|
|
28
|
-
STORE_BULK_UPDATE_FAILED: {
|
|
29
|
-
code: "D1005",
|
|
30
|
-
message: "Failed to update records in database"
|
|
31
|
-
},
|
|
32
|
-
STORE_DELETE_FAILED: {
|
|
33
|
-
code: "D1006",
|
|
34
|
-
message: "Failed to delete records from database"
|
|
35
|
-
},
|
|
36
|
-
STORE_NOT_WRITABLE: {
|
|
37
|
-
code: "D1007",
|
|
38
|
-
message: "Store is not writable"
|
|
39
|
-
},
|
|
40
|
-
STORE_BLOB_NOT_FOUND: {
|
|
41
|
-
code: "D1008",
|
|
42
|
-
message: "Blob not found"
|
|
43
|
-
},
|
|
44
|
-
// D2xxx — Element lookup
|
|
45
|
-
ELEMENT_NOT_FOUND: {
|
|
46
|
-
code: "D2001",
|
|
47
|
-
message: "Element not found"
|
|
48
|
-
},
|
|
49
|
-
ROOT_NOT_FOUND: {
|
|
50
|
-
code: "D2002",
|
|
51
|
-
message: "Root element not found"
|
|
52
|
-
},
|
|
53
|
-
DUPLICATE_ID: {
|
|
54
|
-
code: "D2003",
|
|
55
|
-
message: "Duplicate element ID"
|
|
56
|
-
},
|
|
57
|
-
ELEMENT_TAGNAME_MISMATCH: {
|
|
58
|
-
code: "D2004",
|
|
59
|
-
message: "Element tagName does not match the expected type"
|
|
60
|
-
},
|
|
61
|
-
// D3xxx — Constraint violations
|
|
62
|
-
INVALID_PARENT_CHILD: {
|
|
63
|
-
code: "D3001",
|
|
64
|
-
message: "Invalid parent-child relationship"
|
|
65
|
-
},
|
|
66
|
-
INVALID_ATTRIBUTE: {
|
|
67
|
-
code: "D3002",
|
|
68
|
-
message: "Invalid attribute for element"
|
|
69
|
-
},
|
|
70
|
-
PROTECTED_ROOT: {
|
|
71
|
-
code: "D3003",
|
|
72
|
-
message: "Root element cannot be deleted"
|
|
73
|
-
},
|
|
74
|
-
REQUIRED_ATTRIBUTE_MISSING: {
|
|
75
|
-
code: "D3004",
|
|
76
|
-
message: "Required attribute is missing"
|
|
77
|
-
},
|
|
78
|
-
UNIQUE_CONSTRAINT_VIOLATION: {
|
|
79
|
-
code: "D3005",
|
|
80
|
-
message: "Value is already used within its scope"
|
|
81
|
-
},
|
|
82
|
-
// D4xxx — Transaction lifecycle
|
|
83
|
-
ALREADY_COMMITTED: {
|
|
84
|
-
code: "D4001",
|
|
85
|
-
message: "Transaction already committed"
|
|
86
|
-
},
|
|
87
|
-
ALREADY_FAILED: {
|
|
88
|
-
code: "D4002",
|
|
89
|
-
message: "Transaction already failed"
|
|
90
|
-
},
|
|
91
|
-
DATABASE_COMMIT_ERROR: {
|
|
92
|
-
code: "D4003",
|
|
93
|
-
message: "An error occurred while committing changes to the database"
|
|
94
|
-
},
|
|
95
|
-
CONCURRENT_TRANSACTION: {
|
|
96
|
-
code: "D4004",
|
|
97
|
-
message: "A transaction is already in progress. Concurrent transactions are not supported yet — serialize them or implement a transaction queue."
|
|
98
|
-
},
|
|
99
|
-
// D5xxx — Import/Export
|
|
100
|
-
EXPORT_ROOT_NOT_FOUND: {
|
|
101
|
-
code: "D5001",
|
|
102
|
-
message: "Root element not found in records during export"
|
|
103
|
-
},
|
|
104
|
-
EXPORT_ORPHAN_CHILD_REF: {
|
|
105
|
-
code: "D5002",
|
|
106
|
-
message: "Parent references non-existent child record"
|
|
107
|
-
},
|
|
108
|
-
// D6xxx — Config
|
|
109
|
-
EXTENSION_METHOD_COLLISION: {
|
|
110
|
-
code: "D6001",
|
|
111
|
-
message: "Extension method name collision detected"
|
|
112
|
-
},
|
|
113
|
-
// D7xxx — Project
|
|
114
|
-
UNKNOWN_CONFIG_KEY: {
|
|
115
|
-
code: "D7001",
|
|
116
|
-
message: "Unknown config key"
|
|
117
|
-
},
|
|
118
|
-
DOCUMENT_NOT_REGISTERED: {
|
|
119
|
-
code: "D7002",
|
|
120
|
-
message: "Document not registered in project"
|
|
121
|
-
},
|
|
122
|
-
PROJECT_NOT_OPENED: {
|
|
123
|
-
code: "D7003",
|
|
124
|
-
message: "Project not opened"
|
|
125
|
-
},
|
|
126
|
-
BLOB_NOT_FOUND: {
|
|
127
|
-
code: "D7004",
|
|
128
|
-
message: "Blob not found in store"
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
function d(t, e) {
|
|
132
|
-
const s = c[t], o = {
|
|
133
|
-
code: s.code,
|
|
134
|
-
key: t,
|
|
135
|
-
message: e.message ?? s.message,
|
|
136
|
-
detail: e.detail,
|
|
137
|
-
method: i(new Error().stack),
|
|
138
|
-
ref: e.ref,
|
|
139
|
-
cause: e.cause
|
|
140
|
-
}, a = new Error(e.detail);
|
|
141
|
-
throw a.cause = o, a;
|
|
142
|
-
}
|
|
143
|
-
function i(t) {
|
|
144
|
-
if (!t) return "unknown";
|
|
145
|
-
const e = t.split(`
|
|
146
|
-
`).slice(1).find((r) => !/\b(throwDialecteError|assert)\b/.test(r));
|
|
147
|
-
if (!e) return "unknown";
|
|
148
|
-
const s = e.match(/\bat\s+(\S+)\s+\(([^)]+)\)/), o = s?.[1], a = s?.[2];
|
|
149
|
-
if (!a || !o) return o ?? "unknown";
|
|
150
|
-
const n = a.match(/(\w[\w-]*\/src\/[^?:]+)/);
|
|
151
|
-
return n ? `${n[1].replace(/\.[^/.]+$/, "")}::${o}` : o;
|
|
152
|
-
}
|
|
153
|
-
function D(t, e) {
|
|
154
|
-
if (t) return;
|
|
155
|
-
const { detail: s, key: o = "ASSERTION_FAILED", ref: a } = e;
|
|
156
|
-
d(o, { detail: s, ref: a });
|
|
157
|
-
}
|
|
158
|
-
export {
|
|
159
|
-
c as E,
|
|
160
|
-
D as i,
|
|
161
|
-
d as t
|
|
162
|
-
};
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { i as E } from "./invariant-CqEgHr3M.js";
|
|
2
|
-
const D = "db-id", v = {
|
|
3
|
-
uri: "http://dialecte.dev/XML/DEV",
|
|
4
|
-
prefix: "dev"
|
|
5
|
-
}, $ = `${v.prefix}:${D}`, b = [
|
|
6
|
-
"id",
|
|
7
|
-
"tagName",
|
|
8
|
-
"namespace",
|
|
9
|
-
"attributes",
|
|
10
|
-
"children",
|
|
11
|
-
"parent",
|
|
12
|
-
"value"
|
|
13
|
-
], A = [...b, "status"], S = [...A, "tree"];
|
|
14
|
-
function d(e, t) {
|
|
15
|
-
if (typeof e != "object" || e === null)
|
|
16
|
-
return !1;
|
|
17
|
-
const n = Object.keys(e);
|
|
18
|
-
return t.every((a) => a in e) && n.every((a) => t.includes(a)) && n.length === t.length;
|
|
19
|
-
}
|
|
20
|
-
function I(e) {
|
|
21
|
-
return Array.isArray(e);
|
|
22
|
-
}
|
|
23
|
-
function z(e) {
|
|
24
|
-
return d(e, b);
|
|
25
|
-
}
|
|
26
|
-
function F(e) {
|
|
27
|
-
return d(e, A);
|
|
28
|
-
}
|
|
29
|
-
function K(e) {
|
|
30
|
-
return d(e, S);
|
|
31
|
-
}
|
|
32
|
-
function L(e, t) {
|
|
33
|
-
return e.tagName === t;
|
|
34
|
-
}
|
|
35
|
-
function V(e, t) {
|
|
36
|
-
return e.tagName === t;
|
|
37
|
-
}
|
|
38
|
-
function Y(e, t) {
|
|
39
|
-
return e.tagName === t;
|
|
40
|
-
}
|
|
41
|
-
function w(e, t) {
|
|
42
|
-
return t.elements.includes(e);
|
|
43
|
-
}
|
|
44
|
-
function B(e, t) {
|
|
45
|
-
return e.attributes.some((n) => n.name === t);
|
|
46
|
-
}
|
|
47
|
-
function M(e) {
|
|
48
|
-
return {
|
|
49
|
-
id: e.id,
|
|
50
|
-
tagName: e.tagName,
|
|
51
|
-
namespace: e.namespace,
|
|
52
|
-
attributes: e.attributes,
|
|
53
|
-
value: e.value,
|
|
54
|
-
parent: e.parent,
|
|
55
|
-
children: e.children
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function j(e) {
|
|
59
|
-
const { record: t, status: n } = e, a = n ?? ("status" in t ? t.status : "unchanged");
|
|
60
|
-
return {
|
|
61
|
-
...M(t),
|
|
62
|
-
status: a
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
function P(e) {
|
|
66
|
-
const { record: t, status: n, tree: a } = e, r = a ?? ("tree" in t ? t.tree : []);
|
|
67
|
-
return {
|
|
68
|
-
...j({ record: t, status: n }),
|
|
69
|
-
tree: r
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function k(e) {
|
|
73
|
-
const { dialecteConfig: t, tagName: n, attributes: a } = e;
|
|
74
|
-
return I(a) ? a : Object.entries(a).map(
|
|
75
|
-
([r, s]) => ({
|
|
76
|
-
name: r,
|
|
77
|
-
value: s,
|
|
78
|
-
namespace: t.definition[n]?.attributes.details[r]?.namespace || void 0
|
|
79
|
-
})
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
function X(e) {
|
|
83
|
-
return E(e, {
|
|
84
|
-
detail: "The record or ref is undefined"
|
|
85
|
-
}), {
|
|
86
|
-
id: e.id,
|
|
87
|
-
tagName: e.tagName
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function G(e) {
|
|
91
|
-
const { dialecteConfig: t, hooks: n, record: a } = e, { id: r, tagName: s, attributes: l, namespace: O, value: g } = a, N = r ?? crypto.randomUUID(), c = l ? k({ tagName: s, attributes: l, dialecteConfig: t }) : [], f = {
|
|
92
|
-
id: N,
|
|
93
|
-
tagName: s,
|
|
94
|
-
attributes: c,
|
|
95
|
-
namespace: O ?? {
|
|
96
|
-
prefix: "prefixNeededForNotSupportedNamespace",
|
|
97
|
-
uri: "uriNeededForNotSupportedNamespace"
|
|
98
|
-
},
|
|
99
|
-
value: g ?? "",
|
|
100
|
-
parent: a.parent ?? null,
|
|
101
|
-
children: a.children ?? []
|
|
102
|
-
};
|
|
103
|
-
if (!t.elements.includes(s)) return f;
|
|
104
|
-
const m = t.definition[s].attributes.sequence, o = t.definition[s].attributes.details, T = m.flatMap((i) => {
|
|
105
|
-
const h = o[i].required, _ = o[i]?.namespace || void 0, p = c.find((C) => C.name === i)?.value ?? (h ? o[i]?.default ?? "" : o[i]?.default);
|
|
106
|
-
return p === void 0 ? [] : [
|
|
107
|
-
{
|
|
108
|
-
name: i,
|
|
109
|
-
value: p,
|
|
110
|
-
namespace: _
|
|
111
|
-
}
|
|
112
|
-
];
|
|
113
|
-
}), y = c.filter(
|
|
114
|
-
(i) => "namespace" in i && i.namespace != null && !m.includes(i.name)
|
|
115
|
-
);
|
|
116
|
-
let u = {
|
|
117
|
-
...f,
|
|
118
|
-
namespace: t.definition[s].namespace,
|
|
119
|
-
attributes: [...T, ...y]
|
|
120
|
-
};
|
|
121
|
-
return n?.afterStandardizedRecord && (u = n.afterStandardizedRecord({
|
|
122
|
-
record: u
|
|
123
|
-
})), u;
|
|
124
|
-
}
|
|
125
|
-
function R(e, t, n, a) {
|
|
126
|
-
if (!e || !t) return;
|
|
127
|
-
const r = Object.keys(t).filter((s) => s in e);
|
|
128
|
-
E(r.length === 0, {
|
|
129
|
-
key: "EXTENSION_METHOD_COLLISION",
|
|
130
|
-
detail: `Module "${n}" has conflicting ${a} method(s): ${r.map((s) => `"${s}"`).join(", ")}`
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
function H(e) {
|
|
134
|
-
const t = {}, n = {}, a = [
|
|
135
|
-
...Object.entries(e.base ?? {}),
|
|
136
|
-
...Object.entries(e.custom ?? {})
|
|
137
|
-
];
|
|
138
|
-
for (const [r, s] of a)
|
|
139
|
-
s.query && (R(
|
|
140
|
-
t[r],
|
|
141
|
-
s.query,
|
|
142
|
-
r,
|
|
143
|
-
"query"
|
|
144
|
-
), t[r] = { ...t[r], ...s.query }), s.transaction && (R(
|
|
145
|
-
n[r],
|
|
146
|
-
s.transaction,
|
|
147
|
-
r,
|
|
148
|
-
"transaction"
|
|
149
|
-
), n[r] = { ...n[r], ...s.transaction });
|
|
150
|
-
return { query: t, transaction: n };
|
|
151
|
-
}
|
|
152
|
-
export {
|
|
153
|
-
$ as C,
|
|
154
|
-
v as D,
|
|
155
|
-
D as a,
|
|
156
|
-
V as b,
|
|
157
|
-
w as c,
|
|
158
|
-
I as d,
|
|
159
|
-
Y as e,
|
|
160
|
-
z as f,
|
|
161
|
-
L as g,
|
|
162
|
-
F as h,
|
|
163
|
-
B as i,
|
|
164
|
-
K as j,
|
|
165
|
-
M as k,
|
|
166
|
-
X as l,
|
|
167
|
-
H as m,
|
|
168
|
-
j as n,
|
|
169
|
-
P as o,
|
|
170
|
-
G as s,
|
|
171
|
-
k as t
|
|
172
|
-
};
|