@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/helpers.js
CHANGED
|
@@ -1,164 +1,30 @@
|
|
|
1
|
-
import { i as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"namespace",
|
|
9
|
-
"attributes",
|
|
10
|
-
"children",
|
|
11
|
-
"parent",
|
|
12
|
-
"value"
|
|
13
|
-
], b = [...E, "status"], D = [...b, "tree"];
|
|
14
|
-
function d(e, t) {
|
|
15
|
-
if (typeof e != "object" || e === null)
|
|
16
|
-
return !1;
|
|
17
|
-
const r = Object.keys(e);
|
|
18
|
-
return t.every((a) => a in e) && r.every((a) => t.includes(a)) && r.length === t.length;
|
|
19
|
-
}
|
|
20
|
-
function S(e) {
|
|
21
|
-
return Array.isArray(e);
|
|
22
|
-
}
|
|
23
|
-
function $(e) {
|
|
24
|
-
return d(e, E);
|
|
25
|
-
}
|
|
26
|
-
function z(e) {
|
|
27
|
-
return d(e, b);
|
|
28
|
-
}
|
|
29
|
-
function F(e) {
|
|
30
|
-
return d(e, D);
|
|
31
|
-
}
|
|
32
|
-
function K(e, t) {
|
|
33
|
-
return e.tagName === t;
|
|
34
|
-
}
|
|
35
|
-
function L(e, t) {
|
|
36
|
-
return e.tagName === t;
|
|
37
|
-
}
|
|
38
|
-
function V(e, t) {
|
|
39
|
-
return e.tagName === t;
|
|
40
|
-
}
|
|
41
|
-
function I(e) {
|
|
42
|
-
return {
|
|
43
|
-
id: e.id,
|
|
44
|
-
tagName: e.tagName,
|
|
45
|
-
namespace: e.namespace,
|
|
46
|
-
attributes: e.attributes,
|
|
47
|
-
value: e.value,
|
|
48
|
-
parent: e.parent,
|
|
49
|
-
children: e.children
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
function M(e) {
|
|
53
|
-
const { record: t, status: r } = e, a = r ?? ("status" in t ? t.status : "unchanged");
|
|
54
|
-
return {
|
|
55
|
-
...I(t),
|
|
56
|
-
status: a
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function Y(e) {
|
|
60
|
-
const { record: t, status: r, tree: a } = e, n = a ?? ("tree" in t ? t.tree : []);
|
|
61
|
-
return {
|
|
62
|
-
...M({ record: t, status: r }),
|
|
63
|
-
tree: n
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
function k(e) {
|
|
67
|
-
const { dialecteConfig: t, tagName: r, attributes: a } = e;
|
|
68
|
-
return S(a) ? a : Object.entries(a).map(
|
|
69
|
-
([n, i]) => ({
|
|
70
|
-
name: n,
|
|
71
|
-
value: i,
|
|
72
|
-
namespace: t.definition[r]?.attributes.details[n]?.namespace || void 0
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
function w(e) {
|
|
77
|
-
return R(e, {
|
|
78
|
-
detail: "The record or ref is undefined"
|
|
79
|
-
}), {
|
|
80
|
-
id: e.id,
|
|
81
|
-
tagName: e.tagName
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
function B(e) {
|
|
85
|
-
const { dialecteConfig: t, record: r } = e, { id: a, tagName: n, attributes: i, namespace: A, value: N } = r, O = a ?? crypto.randomUUID(), o = i ? k({ tagName: n, attributes: i, dialecteConfig: t }) : [], l = {
|
|
86
|
-
id: O,
|
|
87
|
-
tagName: n,
|
|
88
|
-
attributes: o,
|
|
89
|
-
namespace: A ?? {
|
|
90
|
-
prefix: "prefixNeededForNotSupportedNamespace",
|
|
91
|
-
uri: "uriNeededForNotSupportedNamespace"
|
|
92
|
-
},
|
|
93
|
-
value: N ?? "",
|
|
94
|
-
parent: r.parent ?? null,
|
|
95
|
-
children: r.children ?? []
|
|
96
|
-
};
|
|
97
|
-
if (!t.elements.includes(n)) return l;
|
|
98
|
-
const f = t.definition[n].attributes.sequence, c = t.definition[n].attributes.details, T = f.flatMap((s) => {
|
|
99
|
-
const y = c[s].required, h = c[s]?.namespace || void 0, p = o.find((_) => _.name === s)?.value || (y ? c[s]?.default || "" : void 0);
|
|
100
|
-
return p === void 0 ? [] : [
|
|
101
|
-
{
|
|
102
|
-
name: s,
|
|
103
|
-
value: p,
|
|
104
|
-
namespace: h
|
|
105
|
-
}
|
|
106
|
-
];
|
|
107
|
-
}), g = o.filter(
|
|
108
|
-
(s) => "namespace" in s && s.namespace != null && !f.includes(s.name)
|
|
109
|
-
);
|
|
110
|
-
let u = {
|
|
111
|
-
...l,
|
|
112
|
-
namespace: t.definition[n].namespace,
|
|
113
|
-
attributes: [...T, ...g]
|
|
114
|
-
};
|
|
115
|
-
return t.hooks?.afterStandardizedRecord && (u = t.hooks.afterStandardizedRecord({
|
|
116
|
-
record: u
|
|
117
|
-
})), u;
|
|
118
|
-
}
|
|
119
|
-
function m(e, t, r, a) {
|
|
120
|
-
if (!e || !t) return;
|
|
121
|
-
const n = Object.keys(t).filter((i) => i in e);
|
|
122
|
-
R(n.length === 0, {
|
|
123
|
-
key: "EXTENSION_METHOD_COLLISION",
|
|
124
|
-
detail: `Module "${r}" has conflicting ${a} method(s): ${n.map((i) => `"${i}"`).join(", ")}`
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
function P(e) {
|
|
128
|
-
const t = {}, r = {}, a = [
|
|
129
|
-
...Object.entries(e.base ?? {}),
|
|
130
|
-
...Object.entries(e.custom ?? {})
|
|
131
|
-
];
|
|
132
|
-
for (const [n, i] of a)
|
|
133
|
-
i.query && (m(
|
|
134
|
-
t[n],
|
|
135
|
-
i.query,
|
|
136
|
-
n,
|
|
137
|
-
"query"
|
|
138
|
-
), t[n] = { ...t[n], ...i.query }), i.transaction && (m(
|
|
139
|
-
r[n],
|
|
140
|
-
i.transaction,
|
|
141
|
-
n,
|
|
142
|
-
"transaction"
|
|
143
|
-
), r[n] = { ...r[n], ...i.transaction });
|
|
144
|
-
return { query: t, transaction: r };
|
|
1
|
+
import { C as n, a as T, D as d, i as A, b as E, c, d as f, e as u, f as O, g as _, h as l, j as C, m as b, s as D, t as m, k as p, l as I, n as S, o as M } from "./merge-extensions-BWXwiKx1.js";
|
|
2
|
+
function i(t, s) {
|
|
3
|
+
const r = new Set(s), a = { ...t, attributes: t.attributes.filter((e) => !r.has(e.name)) };
|
|
4
|
+
return "tree" in t ? {
|
|
5
|
+
...a,
|
|
6
|
+
tree: t.tree.map((e) => i(e, s))
|
|
7
|
+
} : a;
|
|
145
8
|
}
|
|
146
9
|
export {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
10
|
+
n as CUSTOM_RECORD_ID_ATTRIBUTE,
|
|
11
|
+
T as CUSTOM_RECORD_ID_ATTRIBUTE_NAME,
|
|
12
|
+
d as DIALECTE_DEV_NAMESPACE,
|
|
13
|
+
A as isAttributeOf,
|
|
14
|
+
E as isChildOf,
|
|
15
|
+
c as isElementOf,
|
|
16
|
+
f as isFullAttributeArray,
|
|
17
|
+
u as isParentOf,
|
|
18
|
+
O as isRawRecord,
|
|
19
|
+
_ as isRecordOf,
|
|
20
|
+
l as isTrackedRecord,
|
|
21
|
+
C as isTreeRecord,
|
|
22
|
+
b as mergeExtensions,
|
|
23
|
+
D as standardizeRecord,
|
|
24
|
+
i as stripAttributes,
|
|
25
|
+
m as toFullAttributeArray,
|
|
26
|
+
p as toRawRecord,
|
|
27
|
+
I as toRef,
|
|
28
|
+
S as toTrackedRecord,
|
|
29
|
+
M as toTreeRecord
|
|
164
30
|
};
|
|
@@ -63,6 +63,10 @@ const c = {
|
|
|
63
63
|
code: "D3003",
|
|
64
64
|
message: "Root element cannot be deleted"
|
|
65
65
|
},
|
|
66
|
+
REQUIRED_ATTRIBUTE_MISSING: {
|
|
67
|
+
code: "D3004",
|
|
68
|
+
message: "Required attribute is missing"
|
|
69
|
+
},
|
|
66
70
|
// D4xxx — Transaction lifecycle
|
|
67
71
|
ALREADY_COMMITTED: {
|
|
68
72
|
code: "D4001",
|