@dialecte/core 0.5.3 → 0.6.0
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/document.d.ts.map +1 -1
- package/dist/document/query/any/any-query.d.ts +2 -2
- package/dist/document/query/any/any-query.d.ts.map +1 -1
- package/dist/document/query/find/by-attribute/find-by-attributes.d.ts +3 -0
- package/dist/document/query/find/by-attribute/find-by-attributes.d.ts.map +1 -1
- package/dist/document/query/find/by-attribute/find-by-attributes.types.d.ts +21 -1
- package/dist/document/query/find/by-attribute/find-by-attributes.types.d.ts.map +1 -1
- package/dist/document/query/get/attribute/get-attributes.d.ts +4 -6
- package/dist/document/query/get/attribute/get-attributes.d.ts.map +1 -1
- package/dist/document/query/get/definition/get-definition.d.ts +2 -2
- package/dist/document/query/get/definition/get-definition.d.ts.map +1 -1
- package/dist/document/query/main.d.ts +11 -10
- package/dist/document/query/main.d.ts.map +1 -1
- package/dist/document/query/tree-filter/omit.d.ts +7 -1
- package/dist/document/query/tree-filter/omit.d.ts.map +1 -1
- package/dist/document/transaction/before-commit/before-commit.d.ts +9 -0
- package/dist/document/transaction/before-commit/before-commit.d.ts.map +1 -0
- package/dist/document/transaction/before-commit/index.d.ts +2 -0
- package/dist/document/transaction/before-commit/index.d.ts.map +1 -0
- package/dist/document/transaction/create/create.d.ts.map +1 -1
- package/dist/document/transaction/create/create.types.d.ts +5 -5
- package/dist/document/transaction/create/create.types.d.ts.map +1 -1
- package/dist/document/transaction/main.d.ts +6 -0
- package/dist/document/transaction/main.d.ts.map +1 -1
- package/dist/document/transaction/update/update.d.ts.map +1 -1
- package/dist/errors/codes.d.ts +12 -0
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/helpers/assert-fixed.d.ts +3 -2
- package/dist/helpers/assert-fixed.d.ts.map +1 -1
- package/dist/helpers/assert-xsi-type.d.ts +28 -0
- package/dist/helpers/assert-xsi-type.d.ts.map +1 -0
- package/dist/helpers/constant.d.ts +4 -0
- package/dist/helpers/constant.d.ts.map +1 -1
- package/dist/helpers/converter.d.ts +9 -1
- package/dist/helpers/converter.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.map +1 -1
- package/dist/helpers.js +195 -107
- package/dist/index.js +3 -3
- package/dist/{project-U2L6RvRW.js → project-DwtNI4J5.js} +1648 -1499
- package/dist/test/assert-valid-xml/assert-valid-xml.d.ts.map +1 -1
- package/dist/test/assert-valid-xml/assert-valid-xml.types.d.ts +10 -4
- package/dist/test/assert-valid-xml/assert-valid-xml.types.d.ts.map +1 -1
- package/dist/test/config.d.ts +972 -740
- package/dist/test/config.d.ts.map +1 -1
- package/dist/test/generated/constants.generated.d.ts +59 -4
- package/dist/test/generated/constants.generated.d.ts.map +1 -1
- package/dist/test/generated/definition.generated.d.ts +920 -736
- package/dist/test/generated/definition.generated.d.ts.map +1 -1
- package/dist/test/generated/types.generated.d.ts +401 -1
- package/dist/test/generated/types.generated.d.ts.map +1 -1
- package/dist/test/run-test-cases.d.ts +972 -740
- package/dist/test/run-test-cases.d.ts.map +1 -1
- package/dist/test/test-record.d.ts +9979 -8123
- package/dist/test/test-record.d.ts.map +1 -1
- package/dist/test.js +1234 -735
- package/dist/types/definition.d.ts +80 -68
- package/dist/types/definition.d.ts.map +1 -1
- package/dist/types/dialecte-config.d.ts +20 -7
- package/dist/types/dialecte-config.d.ts.map +1 -1
- package/dist/utils/attribute-rules.d.ts +5 -49
- package/dist/utils/attribute-rules.d.ts.map +1 -1
- package/dist/utils/datatype.d.ts +12 -0
- package/dist/utils/datatype.d.ts.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/namespaces.d.ts +47 -0
- package/dist/utils/namespaces.d.ts.map +1 -0
- package/dist/utils/resolve-definition.d.ts +29 -11
- package/dist/utils/resolve-definition.d.ts.map +1 -1
- package/dist/utils/resolve-definition.types.d.ts +6 -0
- package/dist/utils/resolve-definition.types.d.ts.map +1 -0
- package/dist/utils/xsi-type.d.ts +55 -0
- package/dist/utils/xsi-type.d.ts.map +1 -0
- package/dist/utils/xsi-type.types.d.ts +10 -0
- package/dist/utils/xsi-type.types.d.ts.map +1 -0
- package/dist/{utils-Cgqv3qwv.js → utils-CZ12wsuC.js} +216 -61
- package/dist/utils.js +2 -2
- package/dist/xml/build/build-xml-document.d.ts.map +1 -1
- package/dist/xml/parse/parser.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { NamespaceLookup, XsiTypeName } from './xsi-type.types';
|
|
2
|
+
import { AnyDialecteConfig, Namespace } from '../types';
|
|
3
|
+
export type { NamespaceLookup, XsiTypeName } from './xsi-type.types';
|
|
4
|
+
type NamespacesConfig = Pick<AnyDialecteConfig, 'namespaces'>;
|
|
5
|
+
type AttributeLike = {
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly value: unknown;
|
|
8
|
+
readonly namespace?: Namespace;
|
|
9
|
+
};
|
|
10
|
+
/** Whether an attribute is xsi:type: `type` in the XSI namespace, whatever prefix the document gave it. */
|
|
11
|
+
export declare function isXsiTypeAttribute(attribute: AttributeLike): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The type a QName value names, read with `namespaceOf`: `prefix:local`, `local` (the default namespace, none when
|
|
14
|
+
* no default is bound) or a Clark name `{uri}local`. `undefined` when its prefix is bound nowhere.
|
|
15
|
+
*/
|
|
16
|
+
export declare function xsiTypeNameOf(params: {
|
|
17
|
+
value: string;
|
|
18
|
+
namespaceOf: NamespaceLookup;
|
|
19
|
+
}): XsiTypeName | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The type a record names with xsi:type, read as core stores it (`storedNamespaceLookup`); `undefined` without
|
|
22
|
+
* xsi:type or when its prefix is bound nowhere.
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveXsiType(params: {
|
|
25
|
+
dialecteConfig: NamespacesConfig;
|
|
26
|
+
record: {
|
|
27
|
+
readonly attributes: readonly AttributeLike[];
|
|
28
|
+
};
|
|
29
|
+
}): XsiTypeName | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* How core reads a stored xsi:type value: unprefixed is the dialecte's default namespace, a dialecte prefix its
|
|
32
|
+
* namespace (the canonical form); another prefix is read where the record itself binds it (a value kept as written).
|
|
33
|
+
*/
|
|
34
|
+
export declare function storedNamespaceLookup(params: {
|
|
35
|
+
dialecteConfig: NamespacesConfig;
|
|
36
|
+
attributes: readonly AttributeLike[];
|
|
37
|
+
}): NamespaceLookup;
|
|
38
|
+
/**
|
|
39
|
+
* The form core stores an xsi:type value in: the local name for a type in the dialecte's default namespace, the
|
|
40
|
+
* dialecte's prefix and the local name for a type in another namespace it declares. A value whose prefix is bound
|
|
41
|
+
* nowhere, or naming a namespace the dialecte does not declare, is kept as written. The value keeps what XML says it
|
|
42
|
+
* means: only the prefix it is written with changes.
|
|
43
|
+
*/
|
|
44
|
+
export declare function canonicalXsiType(params: {
|
|
45
|
+
dialecteConfig: NamespacesConfig;
|
|
46
|
+
value: string;
|
|
47
|
+
namespaceOf: NamespaceLookup;
|
|
48
|
+
}): string;
|
|
49
|
+
/** The attributes with the xsi:type value, if any, in the form core stores (`canonicalXsiType`). */
|
|
50
|
+
export declare function withCanonicalXsiType<GenericAttribute extends AttributeLike>(params: {
|
|
51
|
+
dialecteConfig: NamespacesConfig;
|
|
52
|
+
attributes: readonly GenericAttribute[];
|
|
53
|
+
namespaceOf: NamespaceLookup;
|
|
54
|
+
}): GenericAttribute[];
|
|
55
|
+
//# sourceMappingURL=xsi-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xsi-type.d.ts","sourceRoot":"","sources":["../../src/utils/xsi-type.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACpE,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAE3D,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEpE,KAAK,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAA;AAC7D,KAAK,aAAa,GAAG;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,CAAA;CAC9B,CAAA;AAED,2GAA2G;AAC3G,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,aAAa,GAAG,OAAO,CAIpE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,eAAe,CAAA;CAC5B,GAAG,WAAW,GAAG,SAAS,CAe1B;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE;IACtC,cAAc,EAAE,gBAAgB,CAAA;IAChC,MAAM,EAAE;QAAE,QAAQ,CAAC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAA;KAAE,CAAA;CACzD,GAAG,WAAW,GAAG,SAAS,CAM1B;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC7C,cAAc,EAAE,gBAAgB,CAAA;IAChC,UAAU,EAAE,SAAS,aAAa,EAAE,CAAA;CACpC,GAAG,eAAe,CAelB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACxC,cAAc,EAAE,gBAAgB,CAAA;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,eAAe,CAAA;CAC5B,GAAG,MAAM,CAST;AAED,oGAAoG;AACpG,wBAAgB,oBAAoB,CAAC,gBAAgB,SAAS,aAAa,EAAE,MAAM,EAAE;IACpF,cAAc,EAAE,gBAAgB,CAAA;IAChC,UAAU,EAAE,SAAS,gBAAgB,EAAE,CAAA;IACvC,WAAW,EAAE,eAAe,CAAA;CAC5B,GAAG,gBAAgB,EAAE,CAUrB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The namespace uri a prefix names (`''` for the default namespace); `undefined` when it is bound nowhere. */
|
|
2
|
+
export type NamespaceLookup = (prefix: string) => string | undefined;
|
|
3
|
+
/** A type an element names with xsi:type: its Clark name (`{uri}local`, bare `local` in no namespace), parts. */
|
|
4
|
+
export type XsiTypeName = {
|
|
5
|
+
readonly clark: string;
|
|
6
|
+
/** `''` for no namespace. */
|
|
7
|
+
readonly namespace: string;
|
|
8
|
+
readonly local: string;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=xsi-type.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"xsi-type.types.d.ts","sourceRoot":"","sources":["../../src/utils/xsi-type.types.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAC/G,MAAM,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAA;AAEpE,iHAAiH;AACjH,MAAM,MAAM,WAAW,GAAG;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,6BAA6B;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACtB,CAAA"}
|
|
@@ -88,6 +88,18 @@ var e = {
|
|
|
88
88
|
code: "D3008",
|
|
89
89
|
message: "Attribute value differs from the schema-fixed value"
|
|
90
90
|
},
|
|
91
|
+
XSI_TYPE_REQUIRED: {
|
|
92
|
+
code: "D3009",
|
|
93
|
+
message: "The element is declared with an abstract type: name a type with xsi:type"
|
|
94
|
+
},
|
|
95
|
+
XSI_TYPE_NOT_ADMITTED: {
|
|
96
|
+
code: "D3010",
|
|
97
|
+
message: "The element may not take the type named with xsi:type"
|
|
98
|
+
},
|
|
99
|
+
XSI_TYPE_CHANGE_LEAVES_CONTENT: {
|
|
100
|
+
code: "D3011",
|
|
101
|
+
message: "The new xsi:type does not admit content the element still holds"
|
|
102
|
+
},
|
|
91
103
|
ALREADY_COMMITTED: {
|
|
92
104
|
code: "D4001",
|
|
93
105
|
message: "Transaction already committed"
|
|
@@ -196,30 +208,162 @@ function l(e) {
|
|
|
196
208
|
return e ? s.has(e.slice(e.lastIndexOf(".") + 1)) : !1;
|
|
197
209
|
}
|
|
198
210
|
//#endregion
|
|
211
|
+
//#region src/helpers/constant.ts
|
|
212
|
+
var u = "db-id", d = {
|
|
213
|
+
uri: "http://dialecte.dev/XML/DEV",
|
|
214
|
+
prefix: "dev"
|
|
215
|
+
}, f = `${d.prefix}:${u}`, p = {
|
|
216
|
+
uri: "http://www.w3.org/2001/XMLSchema-instance",
|
|
217
|
+
prefix: "xsi"
|
|
218
|
+
}, m = "http://www.w3.org/2001/XMLSchema", h = "http://www.w3.org/2000/xmlns/", g = `xmlns:${p.prefix}="${p.uri}"`, _ = {
|
|
219
|
+
dev: d,
|
|
220
|
+
xsi: p
|
|
221
|
+
};
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/utils/xsi-type.ts
|
|
224
|
+
function v(e) {
|
|
225
|
+
return e.namespace?.uri === p.uri && e.name.split(":").at(-1) === "type";
|
|
226
|
+
}
|
|
227
|
+
function y(e) {
|
|
228
|
+
let { namespaceOf: t } = e, n = e.value.trim();
|
|
229
|
+
if (n.startsWith("{")) {
|
|
230
|
+
let e = n.indexOf("}");
|
|
231
|
+
return e === -1 ? void 0 : w({
|
|
232
|
+
uri: n.slice(1, e),
|
|
233
|
+
local: n.slice(e + 1)
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
let r = n.indexOf(":"), i = r === -1 ? "" : n.slice(0, r), a = r === -1 ? n : n.slice(r + 1), o = i ? t(i) : t("") ?? "";
|
|
237
|
+
if (o !== void 0) return w({
|
|
238
|
+
uri: o,
|
|
239
|
+
local: a
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
function b(e) {
|
|
243
|
+
let { dialecteConfig: t, record: n } = e, r = n.attributes.find(v);
|
|
244
|
+
if (r === void 0 || typeof r.value != "string") return;
|
|
245
|
+
let i = x({
|
|
246
|
+
dialecteConfig: t,
|
|
247
|
+
attributes: n.attributes
|
|
248
|
+
});
|
|
249
|
+
return y({
|
|
250
|
+
value: r.value,
|
|
251
|
+
namespaceOf: i
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
function x(e) {
|
|
255
|
+
let { dialecteConfig: t, attributes: n } = e, r = Object.values(t.namespaces);
|
|
256
|
+
return function(e) {
|
|
257
|
+
if (!e) return t.namespaces.default.uri;
|
|
258
|
+
let i = r.find((t) => t.prefix === e);
|
|
259
|
+
if (i) return i.uri;
|
|
260
|
+
let a = n.find((t) => t.name === `xmlns:${e}` || t.namespace?.uri === "http://www.w3.org/2000/xmlns/" && t.name === e);
|
|
261
|
+
return typeof a?.value == "string" ? a.value : void 0;
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function S(e) {
|
|
265
|
+
let { dialecteConfig: t, value: n, namespaceOf: r } = e, i = y({
|
|
266
|
+
value: n,
|
|
267
|
+
namespaceOf: r
|
|
268
|
+
});
|
|
269
|
+
if (i === void 0) return n;
|
|
270
|
+
if (i.namespace === t.namespaces.default.uri) return i.local;
|
|
271
|
+
let a = Object.values(t.namespaces).find((e) => e.uri === i.namespace && e.prefix !== "");
|
|
272
|
+
return a ? `${a.prefix}:${i.local}` : n;
|
|
273
|
+
}
|
|
274
|
+
function C(e) {
|
|
275
|
+
let { dialecteConfig: t, attributes: n, namespaceOf: r } = e;
|
|
276
|
+
return n.map((e) => v(e) && typeof e.value == "string" ? {
|
|
277
|
+
...e,
|
|
278
|
+
value: S({
|
|
279
|
+
dialecteConfig: t,
|
|
280
|
+
value: e.value,
|
|
281
|
+
namespaceOf: r
|
|
282
|
+
})
|
|
283
|
+
} : e);
|
|
284
|
+
}
|
|
285
|
+
function w(e) {
|
|
286
|
+
let { uri: t, local: n } = e;
|
|
287
|
+
return {
|
|
288
|
+
clark: t ? `{${t}}${n}` : n,
|
|
289
|
+
namespace: t,
|
|
290
|
+
local: n
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
//#endregion
|
|
199
294
|
//#region src/utils/resolve-definition.ts
|
|
200
|
-
function
|
|
201
|
-
let { dialecteConfig: t, record: n } = e,
|
|
202
|
-
if (
|
|
203
|
-
let
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
295
|
+
function T(e) {
|
|
296
|
+
let { dialecteConfig: t, record: n, parentDefinition: r } = e, i = t.definition[n.tagName];
|
|
297
|
+
if (i === void 0) return;
|
|
298
|
+
let a = D({
|
|
299
|
+
dialecteConfig: t,
|
|
300
|
+
record: n,
|
|
301
|
+
tagLevel: i,
|
|
302
|
+
parentDefinition: r
|
|
303
|
+
}), o = O({
|
|
304
|
+
dialecteConfig: t,
|
|
305
|
+
record: n
|
|
306
|
+
}), s = a === i ? Object.values(i.declarations ?? {}).concat(i) : [a], c = o !== void 0 && s.some((e) => e.variants?.includes(o)) ? t.types[o] : void 0;
|
|
307
|
+
return a === i && c === void 0 && i.declarations === void 0 ? i : k({
|
|
308
|
+
tagLevel: i,
|
|
309
|
+
declaration: a,
|
|
310
|
+
type: c
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function E(e) {
|
|
314
|
+
let { dialecteConfig: t, record: n, parentDefinition: r } = e, i = t.definition[n.tagName];
|
|
315
|
+
if (i === void 0) return [];
|
|
316
|
+
let a = D({
|
|
317
|
+
dialecteConfig: t,
|
|
318
|
+
record: n,
|
|
319
|
+
tagLevel: i,
|
|
320
|
+
parentDefinition: r
|
|
321
|
+
}), o = (a === i ? [i, ...Object.values(i.declarations ?? {})] : [a]).flatMap((e) => [...e.type === void 0 || e.abstractType ? [] : [e.type], ...e.variants ?? []]);
|
|
322
|
+
return [...new Set(o)];
|
|
323
|
+
}
|
|
324
|
+
function D(e) {
|
|
325
|
+
let { dialecteConfig: t, record: n, tagLevel: r, parentDefinition: i } = e, a = r.declarations;
|
|
326
|
+
if (a === void 0) return r;
|
|
327
|
+
let o = i ?? (n.parent ? t.definition[n.parent.tagName] : void 0), s = o?.children.details[n.tagName]?.declarations;
|
|
328
|
+
if (s !== void 0) {
|
|
329
|
+
let e = Object.keys(s), t = n.namespace?.uri ?? (e.length === 1 ? e[0] : void 0), i = t === void 0 ? void 0 : s[t];
|
|
330
|
+
if (i !== void 0) return i.length === 1 ? a[i[0]] ?? r : r;
|
|
331
|
+
}
|
|
332
|
+
let c = o === void 0 || o.children.any === !0, l = n.namespace?.uri;
|
|
333
|
+
return !c || l === void 0 ? r : Object.values(a).find((e) => e.global && e.namespace.uri === l) ?? r;
|
|
334
|
+
}
|
|
335
|
+
function O(e) {
|
|
336
|
+
return b(e)?.clark;
|
|
337
|
+
}
|
|
338
|
+
function k(e) {
|
|
339
|
+
let { tagLevel: t, declaration: n, type: r } = e, i = A.get(n) ?? /* @__PURE__ */ new Map();
|
|
340
|
+
A.set(n, i);
|
|
341
|
+
let a = i.get(r);
|
|
342
|
+
if (a?.tag === t.tag && a.parents === t.parents) return a;
|
|
343
|
+
let { declarations: o, abstractType: s, ...c } = n, l = {
|
|
344
|
+
...c,
|
|
345
|
+
tag: t.tag,
|
|
346
|
+
parents: t.parents
|
|
347
|
+
}, u = r === void 0 ? {
|
|
348
|
+
...l,
|
|
349
|
+
...n.abstractType ? { abstractType: !0 } : {}
|
|
350
|
+
} : {
|
|
351
|
+
...l,
|
|
352
|
+
attributes: n.attributes.identityFields === void 0 ? r.attributes : {
|
|
353
|
+
...r.attributes,
|
|
354
|
+
identityFields: n.attributes.identityFields
|
|
355
|
+
},
|
|
356
|
+
children: r.children,
|
|
357
|
+
contentModel: r.contentModel,
|
|
358
|
+
textContent: r.textContent
|
|
217
359
|
};
|
|
360
|
+
return u.contentModel === void 0 && delete u.contentModel, u.textContent === void 0 && delete u.textContent, i.set(r, u), u;
|
|
218
361
|
}
|
|
362
|
+
var A = /* @__PURE__ */ new WeakMap();
|
|
219
363
|
//#endregion
|
|
220
364
|
//#region src/utils/attribute-rules.ts
|
|
221
|
-
function
|
|
222
|
-
let { dialecteConfig: t, record: n, attributeName: r } = e, i = t.elements.includes(n.tagName), a = i ?
|
|
365
|
+
function j(e) {
|
|
366
|
+
let { dialecteConfig: t, record: n, attributeName: r } = e, i = t.elements.includes(n.tagName), a = i ? T({
|
|
223
367
|
dialecteConfig: t,
|
|
224
368
|
record: n
|
|
225
369
|
}) : void 0, o = a?.attributes.details[r];
|
|
@@ -233,10 +377,10 @@ function d(e) {
|
|
|
233
377
|
namespace: o?.namespace || void 0
|
|
234
378
|
};
|
|
235
379
|
}
|
|
236
|
-
function
|
|
380
|
+
function M(e) {
|
|
237
381
|
let { dialecteConfig: t, record: n, attributeName: r, defaults: i } = e;
|
|
238
382
|
if (i === "none") return;
|
|
239
|
-
let a =
|
|
383
|
+
let a = j({
|
|
240
384
|
dialecteConfig: t,
|
|
241
385
|
record: n,
|
|
242
386
|
attributeName: r
|
|
@@ -245,48 +389,39 @@ function f(e) {
|
|
|
245
389
|
if (a.fixed !== void 0) return a.fixed;
|
|
246
390
|
if (a.default) return a.default;
|
|
247
391
|
}
|
|
248
|
-
function
|
|
249
|
-
let { dialecteConfig: t, record: n, attributeName: r, value: i } = e, a =
|
|
392
|
+
function N(e) {
|
|
393
|
+
let { dialecteConfig: t, record: n, attributeName: r, value: i } = e, a = j({
|
|
250
394
|
dialecteConfig: t,
|
|
251
395
|
record: n,
|
|
252
396
|
attributeName: r
|
|
253
397
|
}), o = a.fixed ?? a.default;
|
|
254
398
|
return o !== void 0 && i === o;
|
|
255
399
|
}
|
|
256
|
-
function
|
|
400
|
+
function P(e) {
|
|
257
401
|
let t = e.lastIndexOf(":");
|
|
258
402
|
return t === -1 ? e : e.slice(t + 1);
|
|
259
403
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return e.namespaces[t] ?? h(e, t);
|
|
265
|
-
}
|
|
266
|
-
function _(e, t) {
|
|
267
|
-
return e.namespaces[t]?.prefix ?? t;
|
|
268
|
-
}
|
|
269
|
-
function v(e, t) {
|
|
270
|
-
let n = e.namespace?.uri ?? "", r = t.namespace?.uri ?? "";
|
|
271
|
-
return n === r ? e.name === t.name ? 0 : e.name < t.name ? -1 : 1 : n < r ? -1 : 1;
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/utils/datatype.ts
|
|
406
|
+
function F(e) {
|
|
407
|
+
return e === void 0 ? [] : e.facets?.enumeration === void 0 ? "union" in e ? [...new Set(e.union.flatMap(F))] : [] : e.facets.enumeration;
|
|
272
408
|
}
|
|
273
|
-
function
|
|
274
|
-
|
|
275
|
-
return [...n, ...r];
|
|
409
|
+
function I(e) {
|
|
410
|
+
return (e?.facets?.pattern ?? []).map((e) => RegExp(`^(?:${e.map((e) => `(?:${e})`).join("|")})$`, "u"));
|
|
276
411
|
}
|
|
277
412
|
//#endregion
|
|
278
413
|
//#region src/utils/format-xml.ts
|
|
279
|
-
function
|
|
280
|
-
let n = t.indent ?? " ", r = t.baseIndent ?? "", i =
|
|
281
|
-
for (let e of i)
|
|
414
|
+
function L(e, t = {}) {
|
|
415
|
+
let n = t.indent ?? " ", r = t.baseIndent ?? "", i = B(z(e.trim())), a = [];
|
|
416
|
+
for (let e of i) H(e, r, n, a);
|
|
282
417
|
return a.join("\n");
|
|
283
418
|
}
|
|
284
|
-
function
|
|
419
|
+
function R(e, t) {
|
|
285
420
|
let n = t;
|
|
286
421
|
for (; n < e.length && !/[\s/>]/.test(e[n]);) n++;
|
|
287
422
|
return e.slice(t, n);
|
|
288
423
|
}
|
|
289
|
-
function
|
|
424
|
+
function z(e) {
|
|
290
425
|
let t = [], n = 0;
|
|
291
426
|
for (; n < e.length;) {
|
|
292
427
|
if (e[n] === "<") {
|
|
@@ -317,15 +452,15 @@ function S(e) {
|
|
|
317
452
|
let a = r < e.length ? r + 1 : e.length, o = e.slice(n, a);
|
|
318
453
|
n = a, o[1] === "/" ? t.push({
|
|
319
454
|
type: "close",
|
|
320
|
-
name:
|
|
455
|
+
name: R(o, 2),
|
|
321
456
|
raw: o
|
|
322
457
|
}) : o.endsWith("/>") ? t.push({
|
|
323
458
|
type: "selfclose",
|
|
324
|
-
name:
|
|
459
|
+
name: R(o, 1),
|
|
325
460
|
raw: o
|
|
326
461
|
}) : t.push({
|
|
327
462
|
type: "open",
|
|
328
|
-
name:
|
|
463
|
+
name: R(o, 1),
|
|
329
464
|
raw: o
|
|
330
465
|
});
|
|
331
466
|
continue;
|
|
@@ -338,8 +473,9 @@ function S(e) {
|
|
|
338
473
|
}
|
|
339
474
|
return t;
|
|
340
475
|
}
|
|
341
|
-
function
|
|
342
|
-
let t = 0
|
|
476
|
+
function B(e) {
|
|
477
|
+
let t = 0;
|
|
478
|
+
function n() {
|
|
343
479
|
let r = [];
|
|
344
480
|
for (; t < e.length;) {
|
|
345
481
|
let i = e[t];
|
|
@@ -365,13 +501,13 @@ function C(e) {
|
|
|
365
501
|
});
|
|
366
502
|
}
|
|
367
503
|
return r;
|
|
368
|
-
}
|
|
504
|
+
}
|
|
369
505
|
return n();
|
|
370
506
|
}
|
|
371
|
-
function
|
|
372
|
-
return e.kind === "element" ? e.selfClosing ? e.openRaw : `${e.openRaw}${e.children.map(
|
|
507
|
+
function V(e) {
|
|
508
|
+
return e.kind === "element" ? e.selfClosing ? e.openRaw : `${e.openRaw}${e.children.map(V).join("")}</${e.name}>` : e.raw;
|
|
373
509
|
}
|
|
374
|
-
function
|
|
510
|
+
function H(e, t, n, r) {
|
|
375
511
|
if (e.kind === "text") {
|
|
376
512
|
e.raw.trim() !== "" && r.push(t + e.raw.trim());
|
|
377
513
|
return;
|
|
@@ -391,17 +527,17 @@ function T(e, t, n, r) {
|
|
|
391
527
|
return;
|
|
392
528
|
}
|
|
393
529
|
if (o) {
|
|
394
|
-
r.push(t + e.openRaw + e.children.map(
|
|
530
|
+
r.push(t + e.openRaw + e.children.map(V).join("") + i);
|
|
395
531
|
return;
|
|
396
532
|
}
|
|
397
533
|
r.push(t + e.openRaw);
|
|
398
|
-
for (let i of e.children) i.kind !== "text" &&
|
|
534
|
+
for (let i of e.children) i.kind !== "text" && H(i, t + n, n, r);
|
|
399
535
|
r.push(t + i);
|
|
400
536
|
}
|
|
401
|
-
function
|
|
537
|
+
function U(e, t = {}) {
|
|
402
538
|
let n = t.indent ?? " ";
|
|
403
539
|
return e.replace(/^([ \t]*)(.*?\/\*\s*xml\s*\*\/[ \t]*)`([\s\S]*?)`/gm, (e, t, r, i) => {
|
|
404
|
-
let a =
|
|
540
|
+
let a = L(i, {
|
|
405
541
|
indent: n,
|
|
406
542
|
baseIndent: t + n
|
|
407
543
|
});
|
|
@@ -410,7 +546,7 @@ function E(e, t = {}) {
|
|
|
410
546
|
}
|
|
411
547
|
//#endregion
|
|
412
548
|
//#region src/utils/invariant.ts
|
|
413
|
-
function
|
|
549
|
+
function W(e, n) {
|
|
414
550
|
if (e) return;
|
|
415
551
|
let { detail: r, key: i = "ASSERTION_FAILED", ref: a, meta: o } = n;
|
|
416
552
|
t(i, {
|
|
@@ -420,8 +556,27 @@ function D(e, n) {
|
|
|
420
556
|
});
|
|
421
557
|
}
|
|
422
558
|
//#endregion
|
|
559
|
+
//#region src/utils/namespaces.ts
|
|
560
|
+
function G(e, t) {
|
|
561
|
+
if (t) return Object.values(e.namespaces).find((e) => e.prefix === t);
|
|
562
|
+
}
|
|
563
|
+
function K(e, t) {
|
|
564
|
+
return e.namespaces[t] ?? G(e, t);
|
|
565
|
+
}
|
|
566
|
+
function q(e, t) {
|
|
567
|
+
return e.namespaces[t]?.prefix ?? t;
|
|
568
|
+
}
|
|
569
|
+
function J(e, t) {
|
|
570
|
+
let n = e.namespace?.uri ?? "", r = t.namespace?.uri ?? "";
|
|
571
|
+
return n === r ? e.name === t.name ? 0 : e.name < t.name ? -1 : 1 : n < r ? -1 : 1;
|
|
572
|
+
}
|
|
573
|
+
function Y(e, t) {
|
|
574
|
+
let n = t.flatMap((t) => e.filter((e) => e.name === t)), r = e.filter((e) => !t.includes(e.name)).sort(J);
|
|
575
|
+
return [...n, ...r];
|
|
576
|
+
}
|
|
577
|
+
//#endregion
|
|
423
578
|
//#region src/utils/order-children.ts
|
|
424
|
-
function
|
|
579
|
+
function X(e) {
|
|
425
580
|
let { parentTagName: t, children: n, childrenConfig: r } = e, i = r[t];
|
|
426
581
|
if (!i || i.length === 0) return n;
|
|
427
582
|
let a = new Set(i), o = /* @__PURE__ */ new Map();
|
|
@@ -440,7 +595,7 @@ function O(e) {
|
|
|
440
595
|
}
|
|
441
596
|
//#endregion
|
|
442
597
|
//#region src/utils/save-to-disk.ts
|
|
443
|
-
async function
|
|
598
|
+
async function Z(e) {
|
|
444
599
|
let { data: t, filename: n, pickerType: r } = e;
|
|
445
600
|
if ("showSaveFilePicker" in window) try {
|
|
446
601
|
let e = await (await window.showSaveFilePicker({
|
|
@@ -458,4 +613,4 @@ async function k(e) {
|
|
|
458
613
|
a.href = i, a.download = n, document.body.appendChild(a), a.click(), a.remove(), URL.revokeObjectURL(i);
|
|
459
614
|
}
|
|
460
615
|
//#endregion
|
|
461
|
-
export { r as _,
|
|
616
|
+
export { g as A, C, d as D, u as E, o as F, t as I, a as L, p as M, n as N, _ as O, r as P, e as R, x as S, f as T, E as _, G as a, v as b, W as c, F as d, I as f, M as g, N as h, Y as i, m as j, h as k, U as l, j as m, X as n, K as o, P as p, J as r, q as s, Z as t, L as u, T as v, y as w, b as x, S as y };
|
package/dist/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g, v as _, x as v, y } from "./utils-CZ12wsuC.js";
|
|
2
|
+
export { e as admittedXsiTypes, y as canonicalXsiType, p as compareQualifiedAttributes, r as enumeratedValues, f as extractLocalName, c as formatEmbeddedXml, g as formatXml, l as getAttributeRules, n as invariant, o as isSchemaDefaultValue, s as orderAttributesBySequence, u as orderByConfigSequence, _ as resolveDefinition, t as resolveNamespaceByPrefix, d as resolveNamespaceByScope, m as resolvePrefixByNamespaceScope, a as resolveSchemaAttributeValue, v as resolveXsiType, h as saveToDisk, i as valuePatterns };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-xml-document.d.ts","sourceRoot":"","sources":["../../../src/xml/build/build-xml-document.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build-xml-document.d.ts","sourceRoot":"","sources":["../../../src/xml/build/build-xml-document.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAA;AAYxE;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,sBAAsB,GAAG,WAAW,CAgF5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/xml/parse/parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/xml/parse/parser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAS9C,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,SAAS,CAAA;AAC1D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,KAAK,EAEX,iBAAiB,EAKjB,aAAa,EACb,MAAM,SAAS,CAAA;AAIhB;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE;IACpC,cAAc,EAAE,iBAAiB,CAAA;IACjC,mBAAmB,EAAE,OAAO,CAAA;IAC5B,OAAO,EAAE,YAAY,CAAA;IACrB,KAAK,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAA;IACxC,IAAI,CAAC,EAAE,IAAI,CAAA;CACX,GAAG,cAAc,CA+DjB"}
|