@dialecte/core 0.6.3 → 0.6.4

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.
@@ -5,10 +5,10 @@ import { AttributeDefaults } from '../../../../utils';
5
5
  * Fetch a single attribute for the given ref or record.
6
6
  *
7
7
  * Resolves the record (a record given in full is read as it is, through the staged
8
- * operations; a ref via staged → cache → store, see `resolveRecord`), then extracts the named
9
- * attribute. Pass `namespace` to scope by a namespace key (a local `name` is resolved
10
- * to the stored `prefix:local` key). `defaults` (default `'optional'`) controls the
11
- * fallback for an absent attribute: `'none'` → `''`; `'optional'` → `fixed` /
8
+ * operations; a ref via staged → cache → store, see `resolveRecord`), then reads the named
9
+ * attribute with {@link readAttribute}. Pass `namespace` to scope by a namespace key (a local
10
+ * `name` is resolved to the stored `prefix:local` key). `defaults` (default `'optional'`)
11
+ * controls the fallback for an absent attribute: `'none'` → `''`; `'optional'` → `fixed` /
12
12
  * non-empty `default` (else `''`); `'required'` → required/fixed materialized value.
13
13
  *
14
14
  * @example
@@ -24,9 +24,9 @@ export declare function getAttribute<GenericConfig extends AnyDialecteConfig, Ge
24
24
  }): Promise<GenericAttribute['value'] | ''>;
25
25
  /**
26
26
  * Fetch a single attribute for the given ref or record as a full object (name + value +
27
- * namespace). `defaults` (default `'optional'`) fills an absent schema attribute by
28
- * synthesizing its object; `'none'` returns `undefined` when the attribute is not
29
- * stored.
27
+ * namespace), read with {@link readAttribute}. `defaults` (default `'optional'`) fills an
28
+ * absent schema attribute by synthesizing its object; `'none'` returns `undefined` when the
29
+ * attribute is not stored.
30
30
  *
31
31
  * @example
32
32
  * getAttribute({ context, ref, name: 'name', fullObject: true }) // → FullAttributeObject | undefined
@@ -1 +1 @@
1
- {"version":3,"file":"get-attribute.d.ts","sourceRoot":"","sources":["../../../../../src/document/query/get/attribute/get-attribute.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY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Ob
3
3
  import { AttributeDefaults } from '../../../../utils';
4
4
  /**
5
5
  * Fetch attributes for the given ref or record as a destructurable value object. A record given in full is read as it
6
- * is, through the staged operations, with no store round trip (see `resolveRecord`).
6
+ * is, through the staged operations, with no store round trip (see `resolveRecord`); the reading itself is
7
+ * {@link readAttributes}.
7
8
  *
8
9
  * Without `namespace`, every attribute under the name it is stored by (`aA`, `xsi:type`, `ext:cA`) - what a write takes
9
10
  * back. With a `namespace` key, only that namespace's attributes, with the prefix stripped from the keys
@@ -17,14 +18,15 @@ import { AttributeDefaults } from '../../../../utils';
17
18
  * getAttributes({ context, ref }) // → { aA: '', bA: '', ... }
18
19
  * getAttributes({ context, ref, namespace: 'ext' }) // → { cA: '...' }
19
20
  */
20
- export declare function getAttributes<GenericConfig extends AnyDialecteConfig, GenericElement extends ElementsOf<GenericConfig>, GenericAttribute extends FullAttributeObjectOf<GenericConfig, GenericElement>>(params: {
21
+ export declare function getAttributes<GenericConfig extends AnyDialecteConfig, GenericElement extends ElementsOf<GenericConfig>, _GenericAttribute extends FullAttributeObjectOf<GenericConfig, GenericElement>>(params: {
21
22
  context: Context<GenericConfig>;
22
23
  ref: RefOrRecord<GenericConfig, GenericElement> | undefined;
23
24
  namespace?: string;
24
25
  defaults?: AttributeDefaults;
25
26
  }): Promise<AttributesValueObjectOf<GenericConfig, GenericElement>>;
26
27
  /**
27
- * Fetch all attributes of the given ref or record as a full array (name + value + namespace).
28
+ * Fetch all attributes of the given ref or record as a full array (name + value + namespace), read with
29
+ * {@link readAttributes}.
28
30
  *
29
31
  * `defaults` (default `'optional'`) fills absent schema attributes just like
30
32
  * {@link getAttributes}: `'none'` returns the faithful stored-only set;
@@ -1 +1 @@
1
- {"version":3,"file":"get-attributes.d.ts","sourceRoot":"","sources":["../../../../../src/document/query/get/attribute/get-attributes.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EACX,iBAAiB,EACjB,uBAAuB,EACvB,UAAU,EACV,qBAAqB,EAErB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;;;;;;;;;;;GAeG;AAEH,wBAAsB,aAAa,CAClC,aAAa,SAAS,iBAAiB,EACvC,cAAc,SAAS,UAAU,CAAC,aAAa,CAAC,EAChD,gBAAgB,SAAS,qBAAqB,CAAC,aAAa,EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE;IACT,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC/B,GAAG,EAAE,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,SAAS,CAAA;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,GAAG,OAAO,CAAC,uBAAuB,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC,CAqClE;AAmBD;;;;;;;;;;GAUG;AAEH,wBAAsB,uBAAuB,CAC5C,aAAa,SAAS,iBAAiB,EACvC,cAAc,SAAS,UAAU,CAAC,aAAa,CAAC,EAChD,gBAAgB,SAAS,qBAAqB,CAAC,aAAa,EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE;IACT,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC/B,GAAG,EAAE,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,SAAS,CAAA;IAC3D,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA6B9B"}
1
+ {"version":3,"file":"get-attributes.d.ts","sourceRoot":"","sources":["../../../../../src/document/query/get/attribute/get-attributes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EACX,iBAAiB,EACjB,uBAAuB,EACvB,UAAU,EACV,qBAAqB,EACrB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAsB,aAAa,CAClC,aAAa,SAAS,iBAAiB,EACvC,cAAc,SAAS,UAAU,CAAC,aAAa,CAAC,EAChD,iBAAiB,SAAS,qBAAqB,CAAC,aAAa,EAAE,cAAc,CAAC,EAC7E,MAAM,EAAE;IACT,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC/B,GAAG,EAAE,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,SAAS,CAAA;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,GAAG,OAAO,CAAC,uBAAuB,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC,CASlE;AAED;;;;;;;;;;;GAWG;AAEH,wBAAsB,uBAAuB,CAC5C,aAAa,SAAS,iBAAiB,EACvC,cAAc,SAAS,UAAU,CAAC,aAAa,CAAC,EAChD,gBAAgB,SAAS,qBAAqB,CAAC,aAAa,EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE;IACT,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC/B,GAAG,EAAE,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,SAAS,CAAA;IAC3D,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAW9B"}
@@ -6,4 +6,6 @@ export * from './assert-fixed';
6
6
  export * from './assert-xsi-type';
7
7
  export * from './merge-extensions';
8
8
  export * from './strip-attributes';
9
+ export * from './read-attributes';
10
+ export type * from './read-attributes.types';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,mBAAmB,yBAAyB,CAAA"}
@@ -0,0 +1,56 @@
1
+ import { ReadAttributesBaseParams } from './read-attributes.types';
2
+ import { AnyAttribute } from '../types';
3
+ /**
4
+ * Read one attribute of a record you hold, the way `query.getAttribute` reads it - same `namespace` scope, same
5
+ * `defaults` fill, same `''` for an absent attribute - with no query: synchronous, for an import pass or a pure
6
+ * composer. `query.getAttribute` itself delegates to it once it has the record.
7
+ *
8
+ * `fullObject: true` returns the attribute object, or `undefined` when there is none in that view: with
9
+ * `defaults: 'none'`, how to tell an absent attribute from one written empty.
10
+ *
11
+ * Reads the record as you hold it. Inside a transaction use `tx.getAttribute`, which sees the transaction's staged
12
+ * writes: a record held from before a write still reads its old values here.
13
+ *
14
+ * @example
15
+ * readAttribute({ record, dialecteConfig, name: 'aA' }) // → 'v' | ''
16
+ * readAttribute({ record, dialecteConfig, name: 'aA', defaults: 'none', fullObject: true }) // → undefined when absent
17
+ *
18
+ * @see {@link readAttributes}
19
+ */
20
+ export declare function readAttribute(params: ReadAttributesBaseParams & {
21
+ name: string;
22
+ namespace?: string;
23
+ fullObject?: false;
24
+ }): string;
25
+ export declare function readAttribute(params: ReadAttributesBaseParams & {
26
+ name: string;
27
+ namespace?: string;
28
+ fullObject: true;
29
+ }): AnyAttribute | undefined;
30
+ /**
31
+ * Read the attributes of a record you hold, the way `query.getAttributes` reads them - each under the name it is
32
+ * stored by, or keyed by local name in a `namespace` scope, absent schema attributes filled per `defaults` - with no
33
+ * query: synchronous, for an import pass or a pure composer. `query.getAttributes`
34
+ * itself delegates to it once it has the record. Values are plain strings: for typed reads use the query.
35
+ *
36
+ * Namespace declarations are left out of the value object; `fullObject: true` returns the stored attributes as they
37
+ * are, a declaration a document carries included (stored by its prefix, in the xmlns namespace).
38
+ *
39
+ * Reads the record as you hold it. Inside a transaction use `tx.getAttributes`, which sees the transaction's staged
40
+ * writes: a record held from before a write still reads its old values here.
41
+ *
42
+ * @example
43
+ * readAttributes({ record, dialecteConfig }) // → { aA: 'v', 'ext:cA': 'w' }
44
+ * readAttributes({ record, dialecteConfig, defaults: 'none' }) // → stored only
45
+ * readAttributes({ record, dialecteConfig, fullObject: true }) // → AnyAttribute[]
46
+ *
47
+ * @see {@link readAttribute}
48
+ */
49
+ export declare function readAttributes(params: ReadAttributesBaseParams & {
50
+ namespace?: string;
51
+ fullObject?: false;
52
+ }): Record<string, string>;
53
+ export declare function readAttributes(params: ReadAttributesBaseParams & {
54
+ fullObject: true;
55
+ }): AnyAttribute[];
56
+ //# sourceMappingURL=read-attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-attributes.d.ts","sourceRoot":"","sources":["../../src/helpers/read-attributes.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AACvE,OAAO,KAAK,EAAE,YAAY,EAA8C,MAAM,SAAS,CAAA;AAGvF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,wBAAwB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACzF,MAAM,CAAA;AACT,wBAAgB,aAAa,CAC5B,MAAM,EAAE,wBAAwB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,IAAI,CAAA;CAAE,GACvF,YAAY,GAAG,SAAS,CAAA;AAyC3B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,wBAAwB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GAC3E,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AACzB,wBAAgB,cAAc,CAC7B,MAAM,EAAE,wBAAwB,GAAG;IAAE,UAAU,EAAE,IAAI,CAAA;CAAE,GACrD,YAAY,EAAE,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { AnyDialecteConfig, AnyRawRecord } from '../types';
2
+ import { AttributeDefaults } from '../utils';
3
+ /** What every attribute read takes: the record as held (raw, tracked or tree), the config its schema values come from. */
4
+ export type ReadAttributesBaseParams = {
5
+ record: AnyRawRecord;
6
+ dialecteConfig: AnyDialecteConfig;
7
+ /** How an absent schema attribute is filled - as in `query.getAttribute(s)`. Default `'optional'`. */
8
+ defaults?: AttributeDefaults;
9
+ };
10
+ //# sourceMappingURL=read-attributes.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-attributes.types.d.ts","sourceRoot":"","sources":["../../src/helpers/read-attributes.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,0HAA0H;AAC1H,MAAM,MAAM,wBAAwB,GAAG;IACtC,MAAM,EAAE,YAAY,CAAA;IACpB,cAAc,EAAE,iBAAiB,CAAA;IACjC,sGAAsG;IACtG,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,CAAA"}
package/dist/helpers.js CHANGED
@@ -1,6 +1,6 @@
1
- import { A as e, C as t, D as n, E as r, L as i, M as a, N as o, O as s, S as c, a as l, h as u, i as d, j as f, k as p, l as m, m as h, o as g, s as _, v, w as y, x as b, y as x } from "./utils-CTBHUFs9.js";
1
+ import { A as e, C as t, D as n, E as r, L as i, M as a, N as o, O as s, S as c, _ as l, a as u, c as d, h as f, i as p, j as m, k as h, l as g, m as _, o as v, s as y, v as b, w as x, x as S, y as C } from "./utils-CTBHUFs9.js";
2
2
  //#region src/helpers/guard.ts
3
- var S = [
3
+ var w = [
4
4
  "id",
5
5
  "tagName",
6
6
  "namespace",
@@ -8,34 +8,34 @@ var S = [
8
8
  "children",
9
9
  "parent",
10
10
  "value"
11
- ], C = [...S, "status"], w = [...C, "tree"];
12
- function T(e, t) {
11
+ ], T = [...w, "status"], E = [...T, "tree"];
12
+ function D(e, t) {
13
13
  if (typeof e != "object" || !e) return !1;
14
14
  let n = Object.keys(e);
15
15
  return t.every((t) => t in e) && n.every((e) => t.includes(e)) && n.length === t.length;
16
16
  }
17
- function E(e) {
17
+ function O(e) {
18
18
  return Array.isArray(e);
19
19
  }
20
- function D(e) {
21
- return T(e, S);
20
+ function k(e) {
21
+ return D(e, w);
22
22
  }
23
- function O(e) {
24
- return T(e, C);
23
+ function A(e) {
24
+ return D(e, T);
25
25
  }
26
- function k(e) {
27
- return T(e, w);
26
+ function j(e) {
27
+ return D(e, E);
28
28
  }
29
- function A(e, t) {
29
+ function M(e, t) {
30
30
  return e.tagName === t;
31
31
  }
32
- function j(e, t) {
32
+ function N(e, t) {
33
33
  return e.tagName === t;
34
34
  }
35
- function M(e, t) {
35
+ function ee(e, t) {
36
36
  return e.tagName === t;
37
37
  }
38
- function N(e, t) {
38
+ function te(e, t) {
39
39
  return t.elements.includes(e);
40
40
  }
41
41
  function P(e, t) {
@@ -105,14 +105,14 @@ function B(e) {
105
105
  }
106
106
  function V(e) {
107
107
  let { attribute: t, dialecteConfig: n, tagName: r } = e, a;
108
- typeof t.namespace == "string" ? (a = _(n, t.namespace), a || i("UNKNOWN_NAMESPACE_PREFIX", {
108
+ typeof t.namespace == "string" ? (a = y(n, t.namespace), a || i("UNKNOWN_NAMESPACE_PREFIX", {
109
109
  detail: `Unknown namespace '${t.namespace}' on attribute '${t.name}' — use a registered namespace key or pass a full { name, namespace: { prefix, uri } }.`,
110
110
  ref: { tagName: r }
111
111
  })) : a = t.namespace;
112
112
  let o = t.name.indexOf(":");
113
113
  if (!a && o !== -1) {
114
114
  let e = t.name.slice(0, o);
115
- e !== "xmlns" && (a = g(n, e), a || i("UNKNOWN_NAMESPACE_PREFIX", {
115
+ e !== "xmlns" && (a = v(n, e), a || i("UNKNOWN_NAMESPACE_PREFIX", {
116
116
  detail: `Unknown namespace prefix '${e}' on attribute '${t.name}' — pass it explicitly as { name, namespace: { prefix, uri } }.`,
117
117
  ref: { tagName: r }
118
118
  }));
@@ -122,7 +122,7 @@ function V(e) {
122
122
  uri: a.uri
123
123
  }) ?? a), a && a.prefix && a.prefix !== "xmlns" ? {
124
124
  ...t,
125
- name: `${a.prefix}:${h(t.name)}`,
125
+ name: `${a.prefix}:${_(t.name)}`,
126
126
  namespace: a
127
127
  } : (t.namespace, {
128
128
  ...t,
@@ -134,7 +134,7 @@ function H(e) {
134
134
  return Object.values(t.namespaces).find((e) => e.uri === n && e.prefix !== "");
135
135
  }
136
136
  function U(e) {
137
- return m(e, { detail: "The record or ref is undefined" }), {
137
+ return g(e, { detail: "The record or ref is undefined" }), {
138
138
  id: e.id,
139
139
  tagName: e.tagName
140
140
  };
@@ -142,17 +142,17 @@ function U(e) {
142
142
  //#endregion
143
143
  //#region src/helpers/standardizing.ts
144
144
  function W(e) {
145
- let { dialecteConfig: t, hooks: n, record: r } = e, { id: i, tagName: a, attributes: o, namespace: s, value: c } = r, u = i ?? crypto.randomUUID(), f = G({
145
+ let { dialecteConfig: t, hooks: n, record: r } = e, { id: i, tagName: a, attributes: o, namespace: s, value: c } = r, l = i ?? crypto.randomUUID(), d = G({
146
146
  dialecteConfig: t,
147
147
  attributes: o ? z({
148
148
  tagName: a,
149
149
  attributes: o,
150
150
  dialecteConfig: t
151
151
  }) : []
152
- }), p = {
153
- id: u,
152
+ }), f = {
153
+ id: l,
154
154
  tagName: a,
155
- attributes: f,
155
+ attributes: d,
156
156
  namespace: s ?? {
157
157
  prefix: "prefixNeededForNotSupportedNamespace",
158
158
  uri: "uriNeededForNotSupportedNamespace"
@@ -161,35 +161,35 @@ function W(e) {
161
161
  parent: r.parent ?? null,
162
162
  children: r.children ?? []
163
163
  }, m = Object.values(t.namespaces).map(({ uri: e }) => e), h = s?.uri != null && !m.includes(s.uri);
164
- if (!(t.elements.includes(a) && !h)) return p;
165
- let g = x({
164
+ if (!(t.elements.includes(a) && !h)) return f;
165
+ let g = C({
166
166
  dialecteConfig: t,
167
167
  record: {
168
- ...p,
168
+ ...f,
169
169
  namespace: s
170
170
  }
171
- }), _ = g?.attributes.sequence ?? [], v = d({
171
+ }), _ = g?.attributes.sequence ?? [], v = p({
172
172
  wildcard: g?.attributes.any,
173
173
  namespaceUri: ""
174
- }), y = f.filter((e) => {
174
+ }), y = d.filter((e) => {
175
175
  let t = _.includes(e.name), n = "namespace" in e && e.namespace != null;
176
176
  if (!t && !n && !v) return !1;
177
177
  let r = e.value === void 0 || e.value === null || e.value === "";
178
178
  return !(t && r);
179
- }), b = t.namespaces.default.uri, S = y.map((e) => {
179
+ }), b = t.namespaces.default.uri, x = y.map((e) => {
180
180
  if ("namespace" in e && e.namespace?.uri === b) {
181
181
  let { namespace: t, ...n } = e;
182
182
  return n;
183
183
  }
184
184
  return e;
185
- }), C = t.definition[a], w = [g?.namespace ?? C.namespace, ...Object.values(C.declarations ?? {}).map((e) => e.namespace)], T = w.find((e) => e.uri === s?.uri), E = {
186
- ...p,
185
+ }), S = t.definition[a], w = [g?.namespace ?? S.namespace, ...Object.values(S.declarations ?? {}).map((e) => e.namespace)], T = w.find((e) => e.uri === s?.uri), E = {
186
+ ...f,
187
187
  namespace: T ?? s ?? w[0],
188
- attributes: l(S, _)
188
+ attributes: u(x, _)
189
189
  };
190
190
  return n?.afterStandardizedRecord && (E = n.afterStandardizedRecord({ record: E }), E = {
191
191
  ...E,
192
- attributes: l(G({
192
+ attributes: u(G({
193
193
  dialecteConfig: t,
194
194
  attributes: E.attributes
195
195
  }), _)
@@ -197,7 +197,7 @@ function W(e) {
197
197
  }
198
198
  function G(e) {
199
199
  let { dialecteConfig: n, attributes: r } = e;
200
- return y({
200
+ return x({
201
201
  dialecteConfig: n,
202
202
  attributes: r,
203
203
  namespaceOf: t({
@@ -211,7 +211,7 @@ function G(e) {
211
211
  function K(e) {
212
212
  let { dialecteConfig: t, record: n, attributes: r } = e;
213
213
  for (let e of r) {
214
- let r = u({
214
+ let r = f({
215
215
  dialecteConfig: t,
216
216
  record: n,
217
217
  attributeName: e.name
@@ -225,13 +225,13 @@ function K(e) {
225
225
  //#endregion
226
226
  //#region src/helpers/assert-xsi-type.ts
227
227
  function q(e) {
228
- let { dialecteConfig: t, record: n } = e, r = n.attributes.find(b);
228
+ let { dialecteConfig: t, record: n } = e, r = n.attributes.find(S);
229
229
  if (r === void 0) {
230
- x({
230
+ C({
231
231
  dialecteConfig: t,
232
232
  record: n
233
233
  })?.abstractType && i("XSI_TYPE_REQUIRED", {
234
- detail: `'${n.tagName}' is declared with an abstract type: name one of its variants with xsi:type (${v({
234
+ detail: `'${n.tagName}' is declared with an abstract type: name one of its variants with xsi:type (${b({
235
235
  dialecteConfig: t,
236
236
  record: n
237
237
  }).join(", ")}).`,
@@ -239,7 +239,7 @@ function q(e) {
239
239
  });
240
240
  return;
241
241
  }
242
- if (x({
242
+ if (C({
243
243
  dialecteConfig: t,
244
244
  record: n
245
245
  }) === void 0) return;
@@ -248,7 +248,7 @@ function q(e) {
248
248
  record: n
249
249
  });
250
250
  if (a?.namespace === "http://www.w3.org/2001/XMLSchema") return;
251
- let o = v({
251
+ let o = b({
252
252
  dialecteConfig: t,
253
253
  record: n
254
254
  });
@@ -262,7 +262,7 @@ function q(e) {
262
262
  });
263
263
  }
264
264
  function J(e) {
265
- let { dialecteConfig: t, merged: n, record: r } = e, a = new Set(r.attributes.map((e) => e.name)), o = n.filter((e) => e.value !== "" && !a.has(e.name)).map((e) => e.name), s = x({
265
+ let { dialecteConfig: t, merged: n, record: r } = e, a = new Set(r.attributes.map((e) => e.name)), o = n.filter((e) => e.value !== "" && !a.has(e.name)).map((e) => e.name), s = C({
266
266
  dialecteConfig: t,
267
267
  record: r
268
268
  }), c = new Set(s?.children.sequence ?? []), l = s?.children.any ? [] : [...new Set(r.children.map((e) => e.tagName))].filter((e) => !c.has(e));
@@ -280,7 +280,7 @@ function J(e) {
280
280
  function Y(e, t, n, r) {
281
281
  if (!e || !t) return;
282
282
  let i = Object.keys(t).filter((t) => t in e);
283
- m(i.length === 0, {
283
+ g(i.length === 0, {
284
284
  key: "EXTENSION_METHOD_COLLISION",
285
285
  detail: `Module "${n}" has conflicting ${r} method(s): ${i.map((e) => `"${e}"`).join(", ")}`
286
286
  });
@@ -312,4 +312,128 @@ function Z(e, t) {
312
312
  } : r;
313
313
  }
314
314
  //#endregion
315
- export { r as CUSTOM_RECORD_ID_ATTRIBUTE, n as CUSTOM_RECORD_ID_ATTRIBUTE_NAME, s as DIALECTE_DEV_NAMESPACE, p as DIALECTE_NAMESPACES, e as XMLNS_NAMESPACE_URI, f as XMLNS_XSI_NAMESPACE, a as XSD_NAMESPACE_URI, o as XSI_NAMESPACE, K as assertNoFixedViolation, q as assertXsiTypeAdmitted, J as assertXsiTypeChangeLeavesNothing, P as isAttributeOf, j as isChildOf, N as isElementOf, E as isFullAttributeArray, M as isParentOf, D as isRawRecord, A as isRecordOf, O as isTrackedRecord, k as isTreeRecord, X as mergeExtensions, W as standardizeRecord, Z as stripAttributes, z as toFullAttributeArray, F as toRawRecord, U as toRef, L as toTrackedRecord, R as toTreeRecord, I as widen };
315
+ //#region src/helpers/read-attributes.ts
316
+ function ne(e) {
317
+ let { record: t, dialecteConfig: n, name: r, namespace: i, fullObject: a, defaults: o = "optional" } = e, s = re({
318
+ dialecteConfig: n,
319
+ name: r,
320
+ namespace: i
321
+ }), c = t.attributes.find((e) => e.name === s);
322
+ if (c) return a ? c : c.value;
323
+ let u = l({
324
+ dialecteConfig: n,
325
+ record: t,
326
+ attributeName: s,
327
+ defaults: o
328
+ });
329
+ if (!a) return u ?? "";
330
+ if (u === void 0) return;
331
+ let { namespace: d } = f({
332
+ dialecteConfig: n,
333
+ record: t,
334
+ attributeName: s
335
+ });
336
+ return {
337
+ name: s,
338
+ value: u,
339
+ namespace: d
340
+ };
341
+ }
342
+ function re(e) {
343
+ let { dialecteConfig: t, name: n, namespace: r } = e;
344
+ if (r === void 0) return n;
345
+ let i = d(t, r);
346
+ return i ? `${i}:${n}` : n;
347
+ }
348
+ function ie(e) {
349
+ return e.fullObject ? oe(e) : ae(e);
350
+ }
351
+ function ae(e) {
352
+ let { record: t, dialecteConfig: n, namespace: r, defaults: i = "optional" } = e, a = r === void 0 ? void 0 : d(n, r), o = {};
353
+ for (let e of t.attributes) {
354
+ let t = $({
355
+ name: e.name,
356
+ namespace: e.namespace,
357
+ targetPrefix: a
358
+ });
359
+ t !== void 0 && (o[t] = e.value ?? "");
360
+ }
361
+ if (i === "none") return o;
362
+ for (let e of Q({
363
+ dialecteConfig: n,
364
+ record: t
365
+ })) {
366
+ let r = $({
367
+ name: e,
368
+ targetPrefix: a
369
+ });
370
+ if (r === void 0 || r in o) continue;
371
+ let s = l({
372
+ dialecteConfig: n,
373
+ record: t,
374
+ attributeName: e,
375
+ defaults: i
376
+ });
377
+ s !== void 0 && (o[r] = s);
378
+ }
379
+ return o;
380
+ }
381
+ function oe(e) {
382
+ let { record: t, dialecteConfig: n, defaults: r = "optional" } = e, i = [...t.attributes];
383
+ if (r === "none") return i;
384
+ let a = new Set(i.map((e) => e.name));
385
+ for (let e of Q({
386
+ dialecteConfig: n,
387
+ record: t
388
+ })) {
389
+ if (a.has(e)) continue;
390
+ let o = l({
391
+ dialecteConfig: n,
392
+ record: t,
393
+ attributeName: e,
394
+ defaults: r
395
+ });
396
+ if (o === void 0) continue;
397
+ let { namespace: s } = f({
398
+ dialecteConfig: n,
399
+ record: t,
400
+ attributeName: e
401
+ });
402
+ i.push({
403
+ name: e,
404
+ value: o,
405
+ namespace: s
406
+ });
407
+ }
408
+ return i;
409
+ }
410
+ function Q(e) {
411
+ let { dialecteConfig: t, record: n } = e;
412
+ return C({
413
+ dialecteConfig: t,
414
+ record: n
415
+ })?.attributes.sequence ?? [];
416
+ }
417
+ function $(e) {
418
+ let { name: t, namespace: n, targetPrefix: r } = e, { prefix: i, local: a, isXmlns: o } = se(t);
419
+ if (!(o || n?.uri === "http://www.w3.org/2000/xmlns/")) return r === void 0 ? t : i === r ? a : void 0;
420
+ }
421
+ function se(e) {
422
+ if (e === "xmlns" || e.startsWith("xmlns:")) return {
423
+ prefix: "",
424
+ local: e,
425
+ isXmlns: !0
426
+ };
427
+ let t = e.indexOf(":");
428
+ return t === -1 ? {
429
+ prefix: "",
430
+ local: e,
431
+ isXmlns: !1
432
+ } : {
433
+ prefix: e.slice(0, t),
434
+ local: e.slice(t + 1),
435
+ isXmlns: !1
436
+ };
437
+ }
438
+ //#endregion
439
+ export { r as CUSTOM_RECORD_ID_ATTRIBUTE, n as CUSTOM_RECORD_ID_ATTRIBUTE_NAME, s as DIALECTE_DEV_NAMESPACE, h as DIALECTE_NAMESPACES, e as XMLNS_NAMESPACE_URI, m as XMLNS_XSI_NAMESPACE, a as XSD_NAMESPACE_URI, o as XSI_NAMESPACE, K as assertNoFixedViolation, q as assertXsiTypeAdmitted, J as assertXsiTypeChangeLeavesNothing, P as isAttributeOf, N as isChildOf, te as isElementOf, O as isFullAttributeArray, ee as isParentOf, k as isRawRecord, M as isRecordOf, A as isTrackedRecord, j as isTreeRecord, X as mergeExtensions, ne as readAttribute, ie as readAttributes, W as standardizeRecord, Z as stripAttributes, z as toFullAttributeArray, F as toRawRecord, U as toRef, L as toTrackedRecord, R as toTreeRecord, I as widen };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as u, K as d, L as f, M as p, N as m, O as h, P as g, Q as _, R as v, S as y, T as b, U as x, W as S, X as C, Y as w, Z as T, _ as E, _t as D, a as O, at as k, b as A, c as j, ct as M, d as N, dt as P, et as F, f as I, ft as L, g as R, h as z, ht as B, i as V, it as H, j as U, k as W, l as G, lt as K, m as q, mt as J, n as Y, nt as X, o as Z, ot as Q, p as $, pt as ee, q as te, r as ne, rt as re, s as ie, st as ae, t as oe, tt as se, u as ce, ut as le, v as ue, w as de, x as fe, y as pe, z as me } from "./project-DEiVpWVV.js";
1
+ import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as u, K as d, L as f, M as p, N as m, O as h, P as g, Q as _, R as v, S as y, T as b, U as x, W as S, X as C, Y as w, Z as T, _ as E, _t as D, a as O, at as k, b as A, c as j, ct as M, d as N, dt as P, et as F, f as I, ft as L, g as R, h as z, ht as B, i as V, it as H, j as U, k as W, l as G, lt as K, m as q, mt as J, n as Y, nt as X, o as Z, ot as Q, p as $, pt as ee, q as te, r as ne, rt as re, s as ie, st as ae, t as oe, tt as se, u as ce, ut as le, v as ue, w as de, x as fe, y as pe, z as me } from "./project-DGQAe9G9.js";
2
2
  import { F as he, I as ge, L as _e, P as ve, R as ye, z as be } from "./utils-CTBHUFs9.js";
3
3
  export { W as AnyQuery, i as AnyTransaction, N as BLOBS_SCHEMA, I as BLOB_DATA_SCHEMA, $ as CHANGELOG_SCHEMA, q as DOCUMENTS_SCHEMA, ce as DexieStore, de as Document, be as ERROR_CATALOG, G as InMemoryStore, z as META_SCHEMA, m as NOOP_PERF, g as ParseSession, oe as Project, h as Query, R as TABLE_BLOBS, E as TABLE_BLOB_PREFIX, ue as TABLE_CHANGELOG, pe as TABLE_DOCUMENTS, A as TABLE_META, fe as TABLE_RECORD_PREFIX, me as TEMP_IDB_ID_ATTRIBUTE_NAME, a as Transaction, d as applyOmit, s as applyOrder, C as applyUnwrap, D as bindExtensions, y as blobTableName, V as buildDocumentState, l as buildXmlDocument, x as collectSnapshotRecords, ve as createDialecteError, p as createPerf, B as createStagedOperations, he as defineErrors, f as downloadFile, Z as exportBlob, ie as exportDocument, k as findAncestors, re as findByAttributes, X as findDescendants, n as formatXml, F as getAttribute, se as getAttributeFullObject, _ as getAttributes, e as getAttributesFullObject, M as getChild, ae as getChildren, T as getDefinition, L as getRecord, le as getRecords, K as getRecordsByTagName, t as getSnapshot, S as getTree, ne as importDocument, ee as indexStagedDeletesByParent, Y as initEmptyDocument, o as inspectXml, ge as isKnownDialecteError, te as isOmitted, b as isTransactionContext, Q as loadLiveRecords, H as matchesAttributeFilter, J as overlayAllStaged, u as parseOmit, U as parseXmlFile, O as reconcileDocumentState, r as recordTableName, c as recordsToTree, P as resolveRecord, j as resolveStore, w as shouldStopTraversal, _e as throwDialecteError, ye as toDialecteError, v as xmlDocumentToString };