@dialecte/core 0.5.2 → 0.5.3

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.
@@ -106,6 +106,12 @@ export declare class Document<GenericConfig extends AnyDialecteConfig, GenericEx
106
106
  prepare(fn: (tx: Transaction<GenericConfig> & AllExtensions<GenericExtension>) => Promise<void>, options?: {
107
107
  label?: string;
108
108
  }): Promise<PreparedTransaction<GenericConfig, GenericExtension>>;
109
+ /**
110
+ * What a failed operation throws, kept as the document's last error: a structured error stays
111
+ * what it is — its key, its data — and anything else is reported as unknown, the original kept
112
+ * as its cause.
113
+ */
114
+ private reportFailure;
109
115
  /** Close the store connection */
110
116
  close(): void;
111
117
  /** Close connection and delete the database entirely */
@@ -1 +1 @@
1
- {"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/document/document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAI3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAC5F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE/D;;;;;;;;;;;GAWG;AACH,qBAAa,QAAQ,CACpB,aAAa,SAAS,iBAAiB,EACvC,gBAAgB,SAAS,kBAAkB,GAAG,EAAE;IAEhD,SAAS,CAAC,KAAK,EAAE,KAAK,CAAA;IACtB,SAAS,CAAC,MAAM,EAAE,aAAa,CA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AmB,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;IAmFhE;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAiBrB,iCAAiC;IACjC,KAAK,IAAI,IAAI;IAIb,wDAAwD;IAClD,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG9B"}
@@ -1,4 +1,4 @@
1
- import { DialecteErrorKey } from './types';
1
+ import { CoreCatalogueCollisions, DialecteError, DialecteErrorCatalogInput, DialecteErrorDefinition, DialecteErrorDefinitions, DialecteErrorKey, KnownDialecteErrorKey, ThrowDialecteErrorParams } from './types';
2
2
  /**
3
3
  * Create a structured error and throw it.
4
4
  * When `method` is omitted, the caller's name is extracted from the stack trace.
@@ -6,16 +6,41 @@ import { DialecteErrorKey } from './types';
6
6
  * Wraps the DialecteError in a real Error (for stack trace) and sets it as `.cause`
7
7
  * so `toDialecteError` can extract it in catch blocks.
8
8
  *
9
+ * `key` is a key of the core catalogue, or an error a dialecte declared with `defineErrors`.
10
+ *
9
11
  * @example
10
12
  * throwDialecteError('ELEMENT_NOT_FOUND', { detail: 'parent not found' })
11
13
  */
12
- export declare function throwDialecteError(key: DialecteErrorKey, params: {
13
- detail: string;
14
- message?: string;
15
- ref?: {
16
- tagName: string;
17
- id?: string;
18
- };
19
- cause?: Error;
20
- }): never;
14
+ export declare function throwDialecteError(key: DialecteErrorKey | DialecteErrorDefinition, params: ThrowDialecteErrorParams): never;
15
+ /**
16
+ * Build the Error `throwDialecteError` throws, without throwing it — for a caller that reports an
17
+ * error it caught instead of raising one.
18
+ */
19
+ export declare function createDialecteError(key: DialecteErrorKey | DialecteErrorDefinition, params: ThrowDialecteErrorParams): Error;
20
+ /**
21
+ * Declare the errors of a dialecte: each entry gets its property name as `key`, so it can be
22
+ * passed wherever a core key is — `throwDialecteError`, `invariant`.
23
+ *
24
+ * @example
25
+ * const ERRORS = defineErrors({ NAME_TAKEN: { code: 'X1001', message: 'The name is already taken' } })
26
+ * invariant(isFree, { key: ERRORS.NAME_TAKEN, detail: '…', meta: { name } })
27
+ */
28
+ export declare function defineErrors<const GenericCatalog extends DialecteErrorCatalogInput>(catalog: GenericCatalog & CoreCatalogueCollisions<GenericCatalog>): DialecteErrorDefinitions<GenericCatalog>;
29
+ /**
30
+ * The structured error a caught value carries — thrown by `throwDialecteError` or `invariant` —
31
+ * or nothing when it is any other error or value.
32
+ */
33
+ export declare function toDialecteError(thrown: unknown): DialecteError | undefined;
34
+ /**
35
+ * Whether a structured error is one the caller knows: a key of the core catalogue, or an entry of
36
+ * one of the catalogues named — same key, same code. Its `key` is then narrowed to those keys, so a
37
+ * `switch` on it or a table read with it is checked again.
38
+ *
39
+ * @example
40
+ * const error = toDialecteError(thrown)
41
+ * if (error && isKnownDialecteError(error, { catalogues: [MY_ERRORS] })) sentences[error.key]
42
+ */
43
+ export declare function isKnownDialecteError<const GenericCatalogues extends readonly DialecteErrorDefinitions<DialecteErrorCatalogInput>[]>(error: DialecteError, params: {
44
+ catalogues: GenericCatalogues;
45
+ }): error is DialecteError<KnownDialecteErrorKey<GenericCatalogues>>;
21
46
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE;IACP,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACtC,KAAK,CAAC,EAAE,KAAK,CAAA;CACb,GACC,KAAK,CAcP"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors/errors.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,uBAAuB,EACvB,aAAa,EACb,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,gBAAgB,EAChB,qBAAqB,EACrB,wBAAwB,EACxB,MAAM,SAAS,CAAA;AAEhB;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,gBAAgB,GAAG,uBAAuB,EAC/C,MAAM,EAAE,wBAAwB,GAC9B,KAAK,CAEP;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,GAAG,EAAE,gBAAgB,GAAG,uBAAuB,EAC/C,MAAM,EAAE,wBAAwB,GAC9B,KAAK,CAeP;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,CAAC,cAAc,SAAS,yBAAyB,EAClF,OAAO,EAAE,cAAc,GAAG,uBAAuB,CAAC,cAAc,CAAC,GAC/D,wBAAwB,CAAC,cAAc,CAAC,CA0B1C;AAID;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAO1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CACnC,KAAK,CAAC,iBAAiB,SAAS,SAAS,wBAAwB,CAAC,yBAAyB,CAAC,EAAE,EAE9F,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE;IAAE,UAAU,EAAE,iBAAiB,CAAA;CAAE,GACvC,KAAK,IAAI,aAAa,CAAC,qBAAqB,CAAC,iBAAiB,CAAC,CAAC,CAKlE"}
@@ -1,13 +1,44 @@
1
1
  import { ERROR_CATALOG } from './codes';
2
2
  export type DialecteErrorKey = keyof typeof ERROR_CATALOG;
3
3
  export type DialecteErrorCode = (typeof ERROR_CATALOG)[DialecteErrorKey]['code'];
4
+ /**
5
+ * An error a dialecte declares beside the core catalogue: its own key, its own code and the
6
+ * default message shown when the consumer has no wording of its own for that key.
7
+ * Build a catalogue of them with `defineErrors`.
8
+ */
9
+ export type DialecteErrorDefinition<GenericKey extends string = string> = {
10
+ key: GenericKey;
11
+ code: string;
12
+ message: string;
13
+ };
14
+ /** What a dialecte gives `defineErrors`: one entry per error, named by its key. */
15
+ export type DialecteErrorCatalogInput = Record<string, {
16
+ code: string;
17
+ message: string;
18
+ }>;
19
+ /** What `defineErrors` returns: each entry of the catalogue with its property name as `key`. */
20
+ export type DialecteErrorDefinitions<GenericCatalog extends DialecteErrorCatalogInput> = {
21
+ readonly [GenericKey in keyof GenericCatalog & string]: DialecteErrorDefinition<GenericKey> & GenericCatalog[GenericKey];
22
+ };
23
+ /**
24
+ * The entries of a catalogue that take a key or a code of the core catalogue, each typed `never`:
25
+ * `defineErrors` refuses them at the type-check, on the entry itself.
26
+ */
27
+ export type CoreCatalogueCollisions<GenericCatalog extends DialecteErrorCatalogInput> = {
28
+ [GenericKey in keyof GenericCatalog as GenericKey extends DialecteErrorKey ? GenericKey : GenericCatalog[GenericKey]['code'] extends DialecteErrorCode ? GenericKey : never]: never;
29
+ };
4
30
  /**
5
31
  * Structured error — serializable, worker-safe, UI-consumable.
6
32
  * Original Error goes in `cause` to preserve stack trace.
7
33
  */
8
- export type DialecteError = {
9
- code: DialecteErrorCode;
10
- key: DialecteErrorKey;
34
+ export type DialecteError<GenericKey extends string = DialecteErrorKey | (string & {})> = {
35
+ /** A code of the core catalogue, or the code of an error a dialecte declared. */
36
+ code: DialecteErrorCode | (string & {});
37
+ /**
38
+ * A key of the core catalogue, or the key of an error a dialecte declared. Narrowed to the keys
39
+ * of the core and of the catalogues named, by `isKnownDialecteError`.
40
+ */
41
+ key: GenericKey;
11
42
  message: string;
12
43
  detail: string;
13
44
  method: string;
@@ -15,6 +46,27 @@ export type DialecteError = {
15
46
  tagName: string;
16
47
  id: string;
17
48
  };
49
+ /**
50
+ * What the error is about, as data: the consumer builds its own wording from it instead of
51
+ * reading it out of `detail`. Serializable values only.
52
+ */
53
+ meta?: Record<string, unknown>;
54
+ cause?: Error;
55
+ };
56
+ /** What is given with the key when a structured error is raised. */
57
+ export type ThrowDialecteErrorParams = {
58
+ detail: string;
59
+ message?: string;
60
+ ref?: {
61
+ tagName: string;
62
+ id?: string;
63
+ };
64
+ /** What the error is about, as serializable data. */
65
+ meta?: Record<string, unknown>;
18
66
  cause?: Error;
19
67
  };
68
+ /** The keys of the catalogues `isKnownDialecteError` is given, with the keys of the core. */
69
+ export type KnownDialecteErrorKey<GenericCatalogues extends readonly DialecteErrorDefinitions<DialecteErrorCatalogInput>[]> = DialecteErrorKey | KeysOfCatalogue<GenericCatalogues[number]>;
70
+ type KeysOfCatalogue<GenericCatalogue> = GenericCatalogue extends unknown ? keyof GenericCatalogue & string : never;
71
+ export {};
20
72
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/errors/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,aAAa,CAAA;AACzD,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAA;AAEhF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC3B,IAAI,EAAE,iBAAiB,CAAA;IACvB,GAAG,EAAE,gBAAgB,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;IACrC,KAAK,CAAC,EAAE,KAAK,CAAA;CACb,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/errors/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,MAAM,MAAM,gBAAgB,GAAG,MAAM,O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AA;IACd,GAAG,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;IACrC;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAA;CACb,CAAA;AAED,oEAAoE;AACpE,MAAM,MAAM,wBAAwB,GAAG;IACtC,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,GAAG,CAAC,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;IACtC,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAA;CACb,CAAA;AAED,6FAA6F;AAC7F,MAAM,MAAM,qBAAqB,CAChC,iBAAiB,SAAS,SAAS,wBAAwB,CAAC,yBAAyB,CAAC,EAAE,IACrF,gBAAgB,GAAG,eAAe,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAA;AAEjE,KAAK,eAAe,CAAC,gBAAgB,IAAI,gBAAgB,SAAS,OAAO,GACtE,MAAM,gBAAgB,GAAG,MAAM,GAC/B,KAAK,CAAA"}
package/dist/helpers.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as e, d as t, f as n, g as r, h as i, r as a, s as o, u as s } from "./utils-ERge2irW.js";
1
+ import { c as e, d as t, f as n, h as r, r as i, s as a, u as o, y as s } from "./utils-Cgqv3qwv.js";
2
2
  //#region src/helpers/constant.ts
3
3
  var c = "db-id", l = {
4
4
  uri: "http://dialecte.dev/XML/DEV",
@@ -96,30 +96,30 @@ function j(e) {
96
96
  }));
97
97
  }
98
98
  function M(e) {
99
- let { attribute: i, dialecteConfig: a, tagName: s } = e, c;
100
- typeof i.namespace == "string" ? (c = n(a, i.namespace), c || r("UNKNOWN_NAMESPACE_PREFIX", {
101
- detail: `Unknown namespace '${i.namespace}' on attribute '${i.name}' — use a registered namespace key or pass a full { name, namespace: { prefix, uri } }.`,
102
- ref: { tagName: s }
103
- })) : c = i.namespace;
104
- let l = i.name.indexOf(":");
99
+ let { attribute: r, dialecteConfig: i, tagName: o } = e, c;
100
+ typeof r.namespace == "string" ? (c = n(i, r.namespace), c || s("UNKNOWN_NAMESPACE_PREFIX", {
101
+ detail: `Unknown namespace '${r.namespace}' on attribute '${r.name}' — use a registered namespace key or pass a full { name, namespace: { prefix, uri } }.`,
102
+ ref: { tagName: o }
103
+ })) : c = r.namespace;
104
+ let l = r.name.indexOf(":");
105
105
  if (!c && l !== -1) {
106
- let e = i.name.slice(0, l);
107
- e !== "xmlns" && (c = t(a, e), c || r("UNKNOWN_NAMESPACE_PREFIX", {
108
- detail: `Unknown namespace prefix '${e}' on attribute '${i.name}' — pass it explicitly as { name, namespace: { prefix, uri } }.`,
109
- ref: { tagName: s }
106
+ let e = r.name.slice(0, l);
107
+ e !== "xmlns" && (c = t(i, e), c || s("UNKNOWN_NAMESPACE_PREFIX", {
108
+ detail: `Unknown namespace prefix '${e}' on attribute '${r.name}' — pass it explicitly as { name, namespace: { prefix, uri } }.`,
109
+ ref: { tagName: o }
110
110
  }));
111
111
  }
112
112
  return c && c.prefix && c.prefix !== "xmlns" ? {
113
- ...i,
114
- name: `${c.prefix}:${o(i.name)}`,
113
+ ...r,
114
+ name: `${c.prefix}:${a(r.name)}`,
115
115
  namespace: c
116
- } : (i.namespace, {
117
- ...i,
116
+ } : (r.namespace, {
117
+ ...r,
118
118
  namespace: c
119
119
  });
120
120
  }
121
121
  function N(e) {
122
- return a(e, { detail: "The record or ref is undefined" }), {
122
+ return i(e, { detail: "The record or ref is undefined" }), {
123
123
  id: e.id,
124
124
  tagName: e.tagName
125
125
  };
@@ -127,24 +127,24 @@ function N(e) {
127
127
  //#endregion
128
128
  //#region src/helpers/standardizing.ts
129
129
  function P(e) {
130
- let { dialecteConfig: t, hooks: n, record: r } = e, { id: a, tagName: o, attributes: c, namespace: l, value: u } = r, d = r.parent?.tagName, f = a ?? crypto.randomUUID(), p = c ? j({
131
- tagName: o,
130
+ let { dialecteConfig: t, hooks: n, record: i } = e, { id: a, tagName: s, attributes: c, namespace: l, value: u } = i, d = i.parent?.tagName, f = a ?? crypto.randomUUID(), p = c ? j({
131
+ tagName: s,
132
132
  attributes: c,
133
133
  dialecteConfig: t
134
134
  }) : [], m = {
135
135
  id: f,
136
- tagName: o,
136
+ tagName: s,
137
137
  attributes: p,
138
138
  namespace: l ?? {
139
139
  prefix: "prefixNeededForNotSupportedNamespace",
140
140
  uri: "uriNeededForNotSupportedNamespace"
141
141
  },
142
142
  value: u ?? "",
143
- parent: r.parent ?? null,
144
- children: r.children ?? []
143
+ parent: i.parent ?? null,
144
+ children: i.children ?? []
145
145
  }, h = Object.values(t.namespaces).map(({ uri: e }) => e), g = l?.uri != null && !h.includes(l.uri);
146
- if (!(t.elements.includes(o) && !g)) return m;
147
- let _ = i({
146
+ if (!(t.elements.includes(s) && !g)) return m;
147
+ let _ = r({
148
148
  dialecteConfig: t,
149
149
  record: m
150
150
  })?.attributes.sequence ?? [], v = p.filter((e) => {
@@ -158,29 +158,29 @@ function P(e) {
158
158
  return n;
159
159
  }
160
160
  return e;
161
- }), x = d ? t.definition[d]?.children?.details?.[o]?.namespace : void 0, S = {
161
+ }), x = d ? t.definition[d]?.children?.details?.[s]?.namespace : void 0, S = {
162
162
  ...m,
163
- namespace: x ?? t.definition[o].namespace,
164
- attributes: s(b, _)
163
+ namespace: x ?? t.definition[s].namespace,
164
+ attributes: o(b, _)
165
165
  };
166
166
  return n?.afterStandardizedRecord && (S = n.afterStandardizedRecord({ record: S }), S = {
167
167
  ...S,
168
- attributes: s(S.attributes, _)
168
+ attributes: o(S.attributes, _)
169
169
  }), S;
170
170
  }
171
171
  //#endregion
172
172
  //#region src/helpers/assert-fixed.ts
173
173
  function F(t) {
174
- let { dialecteConfig: n, record: i, attributes: a } = t;
175
- for (let t of a) {
176
- let a = e({
174
+ let { dialecteConfig: n, record: r, attributes: i } = t;
175
+ for (let t of i) {
176
+ let i = e({
177
177
  dialecteConfig: n,
178
- record: i,
178
+ record: r,
179
179
  attributeName: t.name
180
180
  });
181
- a.fixed !== void 0 && t.value !== a.fixed && r("FIXED_VALUE_VIOLATION", {
182
- detail: `Attribute '${t.name}' on '${i.tagName}' is fixed to '${a.fixed}' but was set to '${String(t.value)}'.`,
183
- ref: { tagName: i.tagName }
181
+ i.fixed !== void 0 && t.value !== i.fixed && s("FIXED_VALUE_VIOLATION", {
182
+ detail: `Attribute '${t.name}' on '${r.tagName}' is fixed to '${i.fixed}' but was set to '${String(t.value)}'.`,
183
+ ref: { tagName: r.tagName }
184
184
  });
185
185
  }
186
186
  }
@@ -188,10 +188,10 @@ function F(t) {
188
188
  //#region src/helpers/merge-extensions.ts
189
189
  function I(e, t, n, r) {
190
190
  if (!e || !t) return;
191
- let i = Object.keys(t).filter((t) => t in e);
192
- a(i.length === 0, {
191
+ let a = Object.keys(t).filter((t) => t in e);
192
+ i(a.length === 0, {
193
193
  key: "EXTENSION_METHOD_COLLISION",
194
- detail: `Module "${n}" has conflicting ${r} method(s): ${i.map((e) => `"${e}"`).join(", ")}`
194
+ detail: `Module "${n}" has conflicting ${r} method(s): ${a.map((e) => `"${e}"`).join(", ")}`
195
195
  });
196
196
  }
197
197
  function L(e) {
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, a as D, at as O, b as k, c as A, ct as j, d as M, dt as N, et as P, f as F, ft as I, g as L, h as R, ht as z, i as B, it as V, j as H, k as U, l as W, lt as G, m as K, n as q, nt as J, o as Y, ot as X, p as Z, pt as Q, q as $, r as ee, rt as te, s as ne, st as re, t as ie, tt as ae, u as oe, ut as se, v as ce, w as le, x as ue, y as de, z as fe } from "./project-Bd3fSPam.js";
2
- import { _ as pe, g as me } from "./utils-ERge2irW.js";
3
- export { U as AnyQuery, i as AnyTransaction, M as BLOBS_SCHEMA, F as BLOB_DATA_SCHEMA, Z as CHANGELOG_SCHEMA, K as DOCUMENTS_SCHEMA, oe as DexieStore, le as Document, pe as ERROR_CATALOG, W as InMemoryStore, R as META_SCHEMA, m as NOOP_PERF, g as ParseSession, ie as Project, h as Query, L as TABLE_BLOBS, E as TABLE_BLOB_PREFIX, ce as TABLE_CHANGELOG, de as TABLE_DOCUMENTS, k as TABLE_META, ue as TABLE_RECORD_PREFIX, fe as TEMP_IDB_ID_ATTRIBUTE_NAME, a as Transaction, d as applyOmit, s as applyOrder, C as applyUnwrap, z as bindExtensions, y as blobTableName, B as buildDocumentState, l as buildXmlDocument, x as collectSnapshotRecords, p as createPerf, Q as createStagedOperations, f as downloadFile, Y as exportBlob, ne as exportDocument, O as findAncestors, te as findByAttributes, J as findDescendants, n as formatXml, P as getAttribute, ae as getAttributeFullObject, _ as getAttributes, e as getAttributesFullObject, re as getChild, X as getChildren, T as getDefinition, se as getRecord, G as getRecords, j as getRecordsByTagName, t as getSnapshot, S as getTree, ee as importDocument, N as indexStagedDeletesByParent, q as initEmptyDocument, o as inspectXml, $ as isOmitted, b as isTransactionContext, V as matchesAttributeFilter, I as overlayAllStaged, u as parseOmit, H as parseXmlFile, D as reconcileDocumentState, r as recordTableName, c as recordsToTree, A as resolveStore, w as shouldStopTraversal, me as throwDialecteError, v as xmlDocumentToString };
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, a as D, at as O, b as k, c as A, ct as j, d as M, dt as N, et as P, f as F, ft as I, g as L, h as R, ht as z, i as B, it as V, j as H, k as U, l as W, lt as G, m as K, n as q, nt as J, o as Y, ot as X, p as Z, pt as Q, q as $, r as ee, rt as te, s as ne, st as re, t as ie, tt as ae, u as oe, ut as se, v as ce, w as le, x as ue, y as de, z as fe } from "./project-U2L6RvRW.js";
2
+ import { _ as pe, b as me, g as he, v as ge, x as _e, y as ve } from "./utils-Cgqv3qwv.js";
3
+ export { U as AnyQuery, i as AnyTransaction, M as BLOBS_SCHEMA, F as BLOB_DATA_SCHEMA, Z as CHANGELOG_SCHEMA, K as DOCUMENTS_SCHEMA, oe as DexieStore, le as Document, _e as ERROR_CATALOG, W as InMemoryStore, R as META_SCHEMA, m as NOOP_PERF, g as ParseSession, ie as Project, h as Query, L as TABLE_BLOBS, E as TABLE_BLOB_PREFIX, ce as TABLE_CHANGELOG, de as TABLE_DOCUMENTS, k as TABLE_META, ue as TABLE_RECORD_PREFIX, fe as TEMP_IDB_ID_ATTRIBUTE_NAME, a as Transaction, d as applyOmit, s as applyOrder, C as applyUnwrap, z as bindExtensions, y as blobTableName, B as buildDocumentState, l as buildXmlDocument, x as collectSnapshotRecords, he as createDialecteError, p as createPerf, Q as createStagedOperations, pe as defineErrors, f as downloadFile, Y as exportBlob, ne as exportDocument, O as findAncestors, te as findByAttributes, J as findDescendants, n as formatXml, P as getAttribute, ae as getAttributeFullObject, _ as getAttributes, e as getAttributesFullObject, re as getChild, X as getChildren, T as getDefinition, se as getRecord, G as getRecords, j as getRecordsByTagName, t as getSnapshot, S as getTree, ee as importDocument, N as indexStagedDeletesByParent, q as initEmptyDocument, o as inspectXml, ge as isKnownDialecteError, $ as isOmitted, b as isTransactionContext, V as matchesAttributeFilter, I as overlayAllStaged, u as parseOmit, H as parseXmlFile, D as reconcileDocumentState, r as recordTableName, c as recordsToTree, A as resolveStore, w as shouldStopTraversal, ve as throwDialecteError, me as toDialecteError, v as xmlDocumentToString };