@dialecte/core 0.2.14 → 0.2.15
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.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
package/dist/helpers.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './helpers/index'
|
|
1
|
+
export * from './helpers/index.js'
|
|
2
2
|
export {}
|
package/dist/helpers.js
CHANGED
|
@@ -1,30 +1,162 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { n as e } from "./utils-B_-lXlpE.js";
|
|
2
|
+
//#region src/helpers/constant.ts
|
|
3
|
+
var t = "db-id", n = {
|
|
4
|
+
uri: "http://dialecte.dev/XML/DEV",
|
|
5
|
+
prefix: "dev"
|
|
6
|
+
}, r = `${n.prefix}:${t}`, i = [
|
|
7
|
+
"id",
|
|
8
|
+
"tagName",
|
|
9
|
+
"namespace",
|
|
10
|
+
"attributes",
|
|
11
|
+
"children",
|
|
12
|
+
"parent",
|
|
13
|
+
"value"
|
|
14
|
+
], a = [...i, "status"], o = [...a, "tree"];
|
|
15
|
+
function s(e, t) {
|
|
16
|
+
if (typeof e != "object" || !e) return !1;
|
|
17
|
+
let n = Object.keys(e);
|
|
18
|
+
return t.every((t) => t in e) && n.every((e) => t.includes(e)) && n.length === t.length;
|
|
19
|
+
}
|
|
20
|
+
function c(e) {
|
|
21
|
+
return Array.isArray(e);
|
|
22
|
+
}
|
|
23
|
+
function l(e) {
|
|
24
|
+
return s(e, i);
|
|
25
|
+
}
|
|
26
|
+
function u(e) {
|
|
27
|
+
return s(e, a);
|
|
28
|
+
}
|
|
29
|
+
function d(e) {
|
|
30
|
+
return s(e, o);
|
|
31
|
+
}
|
|
32
|
+
function f(e, t) {
|
|
33
|
+
return e.tagName === t;
|
|
34
|
+
}
|
|
35
|
+
function p(e, t) {
|
|
36
|
+
return e.tagName === t;
|
|
37
|
+
}
|
|
38
|
+
function m(e, t) {
|
|
39
|
+
return e.tagName === t;
|
|
40
|
+
}
|
|
41
|
+
function h(e, t) {
|
|
42
|
+
return t.elements.includes(e);
|
|
43
|
+
}
|
|
44
|
+
function g(e, t) {
|
|
45
|
+
return e.attributes.some((e) => e.name === t);
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region src/helpers/converter.ts
|
|
49
|
+
function _(e) {
|
|
50
|
+
return {
|
|
51
|
+
id: e.id,
|
|
52
|
+
tagName: e.tagName,
|
|
53
|
+
namespace: e.namespace,
|
|
54
|
+
attributes: e.attributes,
|
|
55
|
+
value: e.value,
|
|
56
|
+
parent: e.parent,
|
|
57
|
+
children: e.children
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
function v(e) {
|
|
61
|
+
let { record: t, status: n } = e, r = n ?? ("status" in t ? t.status : "unchanged");
|
|
62
|
+
return {
|
|
63
|
+
..._(t),
|
|
64
|
+
status: r
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function y(e) {
|
|
68
|
+
let { record: t, status: n, tree: r } = e, i = r ?? ("tree" in t ? t.tree : []);
|
|
69
|
+
return {
|
|
70
|
+
...v({
|
|
71
|
+
record: t,
|
|
72
|
+
status: n
|
|
73
|
+
}),
|
|
74
|
+
tree: i
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function b(e) {
|
|
78
|
+
let { dialecteConfig: t, tagName: n, attributes: r } = e;
|
|
79
|
+
return c(r) ? r : Object.entries(r).map(([e, r]) => ({
|
|
80
|
+
name: e,
|
|
81
|
+
value: r,
|
|
82
|
+
namespace: t.definition[n]?.attributes.details[e]?.namespace || void 0
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
function x(t) {
|
|
86
|
+
return e(t, { detail: "The record or ref is undefined" }), {
|
|
87
|
+
id: t.id,
|
|
88
|
+
tagName: t.tagName
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/helpers/standardizing.ts
|
|
93
|
+
function S(e) {
|
|
94
|
+
let { dialecteConfig: t, hooks: n, record: r } = e, { id: i, tagName: a, attributes: o, namespace: s, value: c } = r, l = i ?? crypto.randomUUID(), u = o ? b({
|
|
95
|
+
tagName: a,
|
|
96
|
+
attributes: o,
|
|
97
|
+
dialecteConfig: t
|
|
98
|
+
}) : [], d = {
|
|
99
|
+
id: l,
|
|
100
|
+
tagName: a,
|
|
101
|
+
attributes: u,
|
|
102
|
+
namespace: s ?? {
|
|
103
|
+
prefix: "prefixNeededForNotSupportedNamespace",
|
|
104
|
+
uri: "uriNeededForNotSupportedNamespace"
|
|
105
|
+
},
|
|
106
|
+
value: c ?? "",
|
|
107
|
+
parent: r.parent ?? null,
|
|
108
|
+
children: r.children ?? []
|
|
109
|
+
};
|
|
110
|
+
if (!t.elements.includes(a)) return d;
|
|
111
|
+
let f = t.definition[a].attributes.sequence, p = t.definition[a].attributes.details, m = f.flatMap((e) => {
|
|
112
|
+
let t = p[e].required, n = p[e]?.namespace || void 0, r = u.find((t) => t.name === e)?.value ?? (t ? p[e]?.default ?? "" : p[e]?.default);
|
|
113
|
+
return r === void 0 ? [] : [{
|
|
114
|
+
name: e,
|
|
115
|
+
value: r,
|
|
116
|
+
namespace: n
|
|
117
|
+
}];
|
|
118
|
+
}), h = u.filter((e) => "namespace" in e && e.namespace != null && !f.includes(e.name)), g = {
|
|
119
|
+
...d,
|
|
120
|
+
namespace: t.definition[a].namespace,
|
|
121
|
+
attributes: [...m, ...h]
|
|
122
|
+
};
|
|
123
|
+
return n?.afterStandardizedRecord && (g = n.afterStandardizedRecord({ record: g })), g;
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/helpers/merge-extensions.ts
|
|
127
|
+
function C(t, n, r, i) {
|
|
128
|
+
if (!t || !n) return;
|
|
129
|
+
let a = Object.keys(n).filter((e) => e in t);
|
|
130
|
+
e(a.length === 0, {
|
|
131
|
+
key: "EXTENSION_METHOD_COLLISION",
|
|
132
|
+
detail: `Module "${r}" has conflicting ${i} method(s): ${a.map((e) => `"${e}"`).join(", ")}`
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function w(e) {
|
|
136
|
+
let t = {}, n = {}, r = [...Object.entries(e.base ?? {}), ...Object.entries(e.custom ?? {})];
|
|
137
|
+
for (let [e, i] of r) i.query && (C(t[e], i.query, e, "query"), t[e] = {
|
|
138
|
+
...t[e],
|
|
139
|
+
...i.query
|
|
140
|
+
}), i.transaction && (C(n[e], i.transaction, e, "transaction"), n[e] = {
|
|
141
|
+
...n[e],
|
|
142
|
+
...i.transaction
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
query: t,
|
|
146
|
+
transaction: n
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/helpers/strip-attributes.ts
|
|
151
|
+
function T(e, t) {
|
|
152
|
+
let n = new Set(t), r = {
|
|
153
|
+
...e,
|
|
154
|
+
attributes: e.attributes.filter((e) => !n.has(e.name))
|
|
155
|
+
};
|
|
156
|
+
return "tree" in e ? {
|
|
157
|
+
...r,
|
|
158
|
+
tree: e.tree.map((e) => T(e, t))
|
|
159
|
+
} : r;
|
|
160
|
+
}
|
|
161
|
+
//#endregion
|
|
162
|
+
export { r as CUSTOM_RECORD_ID_ATTRIBUTE, t as CUSTOM_RECORD_ID_ATTRIBUTE_NAME, n as DIALECTE_DEV_NAMESPACE, g as isAttributeOf, p as isChildOf, h as isElementOf, c as isFullAttributeArray, m as isParentOf, l as isRawRecord, f as isRecordOf, u as isTrackedRecord, d as isTreeRecord, w as mergeExtensions, S as standardizeRecord, T as stripAttributes, b as toFullAttributeArray, _ as toRawRecord, x as toRef, v as toTrackedRecord, y as toTreeRecord };
|
package/dist/index.js
CHANGED
|
@@ -1,56 +1,3 @@
|
|
|
1
|
-
import { A as e,
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
e as AnyQuery,
|
|
5
|
-
t as AnyTransaction,
|
|
6
|
-
r as BLOBS_SCHEMA,
|
|
7
|
-
o as BLOB_DATA_SCHEMA,
|
|
8
|
-
n as CHANGELOG_SCHEMA,
|
|
9
|
-
A as DOCUMENTS_SCHEMA,
|
|
10
|
-
i as DexieStore,
|
|
11
|
-
E as Document,
|
|
12
|
-
$ as ERROR_CATALOG,
|
|
13
|
-
c as InMemoryStore,
|
|
14
|
-
T as META_SCHEMA,
|
|
15
|
-
l as ParseSession,
|
|
16
|
-
m as Project,
|
|
17
|
-
u as Query,
|
|
18
|
-
B as TABLE_BLOBS,
|
|
19
|
-
_ as TABLE_BLOB_PREFIX,
|
|
20
|
-
b as TABLE_CHANGELOG,
|
|
21
|
-
D as TABLE_DOCUMENTS,
|
|
22
|
-
d as TABLE_META,
|
|
23
|
-
S as TABLE_RECORD_PREFIX,
|
|
24
|
-
C as TEMP_IDB_ID_ATTRIBUTE_NAME,
|
|
25
|
-
L as Transaction,
|
|
26
|
-
O as bindExtensions,
|
|
27
|
-
M as blobTableName,
|
|
28
|
-
g as buildDocumentState,
|
|
29
|
-
R as buildXmlDocument,
|
|
30
|
-
y as downloadFile,
|
|
31
|
-
N as exportBlob,
|
|
32
|
-
p as exportDocument,
|
|
33
|
-
F as findAncestors,
|
|
34
|
-
H as findByAttributes,
|
|
35
|
-
f as findDescendants,
|
|
36
|
-
x as formatXml,
|
|
37
|
-
I as getAttribute,
|
|
38
|
-
G as getAttributeFullObject,
|
|
39
|
-
P as getAttributes,
|
|
40
|
-
X as getAttributesFullObject,
|
|
41
|
-
h as getChild,
|
|
42
|
-
j as getChildren,
|
|
43
|
-
U as getRecord,
|
|
44
|
-
w as getRecords,
|
|
45
|
-
Q as getRecordsByTagName,
|
|
46
|
-
v as getTree,
|
|
47
|
-
k as importDocument,
|
|
48
|
-
q as initEmptyDocument,
|
|
49
|
-
z as isTransactionContext,
|
|
50
|
-
J as matchesAttributeFilter,
|
|
51
|
-
K as parseXmlFile,
|
|
52
|
-
V as reconcileDocumentState,
|
|
53
|
-
W as recordTableName,
|
|
54
|
-
Y as resolveStore,
|
|
55
|
-
aa as throwDialecteError
|
|
56
|
-
};
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, F as a, G as o, H as s, I as c, J as l, K as u, L as d, M as f, N as p, O as m, P as h, R as g, S as _, T as v, U as y, V as b, W as x, X as S, Y as C, Z as w, _ as T, a as E, b as D, c as O, d as k, f as A, g as j, h as M, i as N, j as P, k as F, l as I, n as L, o as R, p as z, q as B, r as V, s as H, t as U, u as W, v as G, w as K, x as q, y as J, z as Y } from "./project-BOM3Ipbu.js";
|
|
2
|
+
import { i as X, r as Z } from "./utils-B_-lXlpE.js";
|
|
3
|
+
export { c as AnyQuery, h as AnyTransaction, G as BLOBS_SCHEMA, J as BLOB_DATA_SCHEMA, D as CHANGELOG_SCHEMA, q as DOCUMENTS_SCHEMA, T as DexieStore, P as Document, X as ERROR_CATALOG, j as InMemoryStore, _ as META_SCHEMA, I as ParseSession, U as Project, a as Query, n as TABLE_BLOBS, K as TABLE_BLOB_PREFIX, v as TABLE_CHANGELOG, i as TABLE_DOCUMENTS, r as TABLE_META, m as TABLE_RECORD_PREFIX, A as TEMP_IDB_ID_ATTRIBUTE_NAME, p as Transaction, w as bindExtensions, F as blobTableName, N as buildDocumentState, W as buildXmlDocument, k as downloadFile, R as exportBlob, H as exportDocument, o as findAncestors, y as findByAttributes, s as findDescendants, z as formatXml, t as getAttribute, b as getAttributeFullObject, g as getAttributes, Y as getAttributesFullObject, B as getChild, u as getChildren, S as getRecord, C as getRecords, l as getRecordsByTagName, d as getTree, V as importDocument, L as initEmptyDocument, f as isTransactionContext, x as matchesAttributeFilter, O as parseXmlFile, E as reconcileDocumentState, e as recordTableName, M as resolveStore, Z as throwDialecteError };
|