@dialecte/core 0.6.3 → 0.7.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.
Files changed (56) hide show
  1. package/dist/diagnostics/diagnostics.d.ts +26 -0
  2. package/dist/diagnostics/diagnostics.d.ts.map +1 -0
  3. package/dist/diagnostics/index.d.ts +3 -0
  4. package/dist/diagnostics/index.d.ts.map +1 -0
  5. package/dist/diagnostics/types.d.ts +72 -0
  6. package/dist/diagnostics/types.d.ts.map +1 -0
  7. package/dist/document/query/get/attribute/get-attribute.d.ts +7 -7
  8. package/dist/document/query/get/attribute/get-attribute.d.ts.map +1 -1
  9. package/dist/document/query/get/attribute/get-attributes.d.ts +5 -3
  10. package/dist/document/query/get/attribute/get-attributes.d.ts.map +1 -1
  11. package/dist/errors/codes.d.ts +4 -0
  12. package/dist/errors/codes.d.ts.map +1 -1
  13. package/dist/helpers/index.d.ts +2 -0
  14. package/dist/helpers/index.d.ts.map +1 -1
  15. package/dist/helpers/read-attributes.d.ts +56 -0
  16. package/dist/helpers/read-attributes.d.ts.map +1 -0
  17. package/dist/helpers/read-attributes.types.d.ts +10 -0
  18. package/dist/helpers/read-attributes.types.d.ts.map +1 -0
  19. package/dist/helpers.js +167 -43
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +22 -3
  23. package/dist/project/index.d.ts +2 -1
  24. package/dist/project/index.d.ts.map +1 -1
  25. package/dist/project/io/import-document.d.ts.map +1 -1
  26. package/dist/project/io/init-empty-document.d.ts.map +1 -1
  27. package/dist/project/io/resolve-config.d.ts +4 -0
  28. package/dist/project/io/resolve-config.d.ts.map +1 -0
  29. package/dist/project/project.d.ts +39 -9
  30. package/dist/project/project.d.ts.map +1 -1
  31. package/dist/project/state/document-lifecycle.d.ts +18 -0
  32. package/dist/project/state/document-lifecycle.d.ts.map +1 -0
  33. package/dist/project/types.d.ts +44 -0
  34. package/dist/project/types.d.ts.map +1 -1
  35. package/dist/{project-DEiVpWVV.js → project-DIKdMMHx.js} +1844 -1775
  36. package/dist/store/in-memory/in-memory-store.d.ts +1 -1
  37. package/dist/store/in-memory/in-memory-store.d.ts.map +1 -1
  38. package/dist/store/local/dexie-store.d.ts +1 -1
  39. package/dist/store/local/dexie-store.d.ts.map +1 -1
  40. package/dist/store/local/types.d.ts +3 -0
  41. package/dist/store/local/types.d.ts.map +1 -1
  42. package/dist/store/store.types.d.ts +2 -2
  43. package/dist/store/store.types.d.ts.map +1 -1
  44. package/dist/test.js +11 -11
  45. package/dist/types/io.d.ts +30 -27
  46. package/dist/types/io.d.ts.map +1 -1
  47. package/dist/{utils-CTBHUFs9.js → utils-DJN0Md0v.js} +4 -0
  48. package/dist/utils.js +1 -1
  49. package/dist/xml/parse/parse-xml-document.d.ts.map +1 -1
  50. package/dist/xml/parse/parse-xml-document.types.d.ts +5 -0
  51. package/dist/xml/parse/parse-xml-document.types.d.ts.map +1 -1
  52. package/dist/xml/parse/parser.d.ts +4 -2
  53. package/dist/xml/parse/parser.d.ts.map +1 -1
  54. package/dist/xml/parse/types.d.ts +2 -0
  55. package/dist/xml/parse/types.d.ts.map +1 -1
  56. package/package.json +1 -1
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-DJN0Md0v.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.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './diagnostics';
1
2
  export * from './document';
2
3
  export * from './errors';
3
4
  export * from './perf';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AAErB,mBAAmB,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA;AAErB,mBAAmB,SAAS,CAAA"}
package/dist/index.js CHANGED
@@ -1,3 +1,22 @@
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";
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
- 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 };
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 ee, I as te, J as c, K as l, L as u, M as d, N as f, O as p, P as m, Q as h, R as g, S as _, T as v, V as y, W as b, X as x, Y as S, Z as C, _ as w, _t as T, a as E, at as D, b as O, c as k, ct as A, d as j, dt as M, et as N, f as P, ft as F, g as I, gt as L, h as R, ht as z, i as B, it as V, j as H, k as U, l as ne, lt as W, m as G, mt as K, n as q, nt as J, o as Y, ot as X, p as Z, pt as re, q as ie, r as ae, rt as oe, s as se, st as ce, t as le, tt as ue, u as de, ut as fe, v as pe, w as me, x as Q, y as he, yt as ge, z as _e } from "./project-DIKdMMHx.js";
2
+ import { F as ve, I as ye, L as $, P as be, R as xe, z as Se } from "./utils-DJN0Md0v.js";
3
+ //#region src/diagnostics/diagnostics.ts
4
+ function Ce(e, t, n) {
5
+ let r = e.codes[t];
6
+ r || $("ASSERTION_FAILED", { detail: `createDiagnostic: "${t}" is not a code of the "${e.source}" catalogue` });
7
+ let { ref: i, message: a = r.message, related: o, meta: s } = n;
8
+ return {
9
+ code: t,
10
+ severity: r.severity,
11
+ source: e.source,
12
+ message: a,
13
+ ref: i,
14
+ ...o && { related: o },
15
+ ...s && { meta: s }
16
+ };
17
+ }
18
+ function we(e, t) {
19
+ return t.catalogues.some((t) => t.source === e.source && Object.hasOwn(t.codes, e.code));
20
+ }
21
+ //#endregion
22
+ export { H as AnyQuery, U as AnyTransaction, Z as BLOBS_SCHEMA, G as BLOB_DATA_SCHEMA, R as CHANGELOG_SCHEMA, I as DOCUMENTS_SCHEMA, P as DexieStore, a as Document, Se as ERROR_CATALOG, Y as IMPORT_HEARTBEAT_MS, j as InMemoryStore, w as META_SCHEMA, o as NOOP_PERF, te as ParseSession, le as Project, t as Query, se as STALE_IMPORT_MS, pe as TABLE_BLOBS, he as TABLE_BLOB_PREFIX, O as TABLE_CHANGELOG, Q as TABLE_DOCUMENTS, _ as TABLE_META, r as TABLE_RECORD_PREFIX, y as TEMP_IDB_ID_ATTRIBUTE_NAME, p as Transaction, c as applyOmit, ie as applyOrder, h as applyUnwrap, ge as bindExtensions, me as blobTableName, B as buildDocumentState, g as buildXmlDocument, s as collectSnapshotRecords, Ce as createDiagnostic, be as createDialecteError, m as createPerf, T as createStagedOperations, ve as defineErrors, _e as downloadFile, k as exportBlob, ne as exportDocument, ce as findAncestors, D as findByAttributes, V as findDescendants, ee as formatXml, J as getAttribute, oe as getAttributeFullObject, N as getAttributes, ue as getAttributesFullObject, fe as getChild, W as getChildren, e as getDefinition, K as getRecord, F as getRecords, M as getRecordsByTagName, d as getSnapshot, l as getTree, ae as importDocument, z as indexStagedDeletesByParent, q as initEmptyDocument, u as inspectXml, we as isKnownDiagnostic, ye as isKnownDialecteError, S as isOmitted, i as isTransactionContext, A as loadLiveRecords, X as matchesAttributeFilter, L as overlayAllStaged, x as parseOmit, f as parseXmlFile, E as reconcileDocumentState, v as recordTableName, b as recordsToTree, re as resolveRecord, de as resolveStore, C as shouldStopTraversal, $ as throwDialecteError, xe as toDialecteError, n as xmlDocumentToString };
@@ -1,10 +1,11 @@
1
1
  export { Project } from './project';
2
2
  export { buildDocumentState, reconcileDocumentState } from './state/document-state';
3
+ export { IMPORT_HEARTBEAT_MS, STALE_IMPORT_MS } from './state/document-lifecycle';
3
4
  export { exportDocument } from './io/export-document';
4
5
  export { exportBlob } from './io/export-blob';
5
6
  export { initEmptyDocument } from './io/init-empty-document';
6
7
  export { importDocument } from './io/import-document';
7
8
  export { resolveStore } from '../store/resolve-store';
8
- export type { ProjectParams, InitEmptyDocumentOptions, ImportDocumentOptions, ExportDocumentOptions, ExportBlobOptions, StorageParam, DocumentRecord, DocumentEntry, ProjectState, ProjectChannelMessage, } from './types';
9
+ export type { ProjectParams, InitEmptyDocumentOptions, ImportDocumentOptions, ImportedDocument, ImportEntry, ExportDocumentOptions, ExportBlobOptions, StorageParam, DocumentRecord, DocumentStatus, DocumentEntry, ProjectState, ProjectChannelMessage, } from './types';
9
10
  export type { InitEmptyDocumentParams, InitEmptyDocumentResult, ImportDocumentParams, ImportDocumentResult, ExportDocumentParams, ExportDocumentResult, ExportBlobParams, ExportBlobResult, } from './types';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/project/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,YAAY,EACX,aAAa,EACb,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,EACZ,qBAAqB,GACrB,MAAM,SAAS,CAAA;AAChB,YAAY,EACX,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,SAAS,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/project/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AACnF,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,YAAY,EACX,aAAa,EACb,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,qBAAqB,EACrB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,aAAa,EACb,YAAY,EACZ,qBAAqB,GACrB,MAAM,SAAS,CAAA;AAChB,YAAY,EACX,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAChB,gBAAgB,GAChB,MAAM,SAAS,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"import-document.d.ts","sourceRoot":"","sources":["../../../src/project/io/import-document.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAG1E;;;GAGG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAsDhG"}
1
+ {"version":3,"file":"import-document.d.ts","sourceRoot":"","sources":["../../../src/project/io/import-document.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAI1E;;;GAGG;AACH,wBAAsB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA4EhG"}
@@ -1 +1 @@
1
- {"version":3,"file":"init-empty-document.d.ts","sourceRoot":"","sources":["../../../src/project/io/init-empty-document.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,uBAAuB,EAAkB,MAAM,UAAU,CAAA;AAGhG;;;GAGG;AACH,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,uBAAuB,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CA4ClC"}
1
+ {"version":3,"file":"init-empty-document.d.ts","sourceRoot":"","sources":["../../../src/project/io/init-empty-document.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,uBAAuB,EAAkB,MAAM,UAAU,CAAA;AAGhG;;;GAGG;AACH,wBAAsB,iBAAiB,CACtC,MAAM,EAAE,uBAAuB,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CA2ClC"}
@@ -0,0 +1,4 @@
1
+ import { ResolveConfigParams, ResolvedConfig } from '../types';
2
+ /** The config a document is imported or created with: the key given, or the project's default. */
3
+ export declare function resolveConfig(params: ResolveConfigParams): ResolvedConfig;
4
+ //# sourceMappingURL=resolve-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-config.d.ts","sourceRoot":"","sources":["../../../src/project/io/resolve-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAEnE,kGAAkG;AAClG,wBAAgB,aAAa,CAAC,MAAM,EAAE,mBAAmB,GAAG,cAAc,CAUzE"}
@@ -1,5 +1,5 @@
1
1
  import { Document, ExtensionModules, MergedExtensions, QueryExtensions, Query } from '../document';
2
- import { InitEmptyDocumentOptions, ImportDocumentOptions, ExportDocumentOptions, ExportBlobOptions, ExportBlobResult, ProjectParams, ProjectState, DocumentRecord } from './types';
2
+ import { InitEmptyDocumentOptions, ImportDocumentOptions, ImportedDocument, ImportEntry, ExportDocumentOptions, ExportBlobOptions, ExportBlobResult, ProjectParams, ProjectState, DocumentRecord } from './types';
3
3
  import { Perf } from '../perf';
4
4
  import { Store } from '../store';
5
5
  import { AnyDialecteConfig, BlobAttachment, BlobRecord, DialecteHooks } from '../types';
@@ -22,6 +22,8 @@ export declare class Project<GenericConfig extends AnyDialecteConfig, GenericMod
22
22
  private _channel?;
23
23
  /** Set once close()/destroy() begins, to stop new channel-triggered store work. */
24
24
  private closing;
25
+ /** While open: the imports whose heartbeat went stale are swept every `STALE_IMPORT_MS`. */
26
+ private staleSweep?;
25
27
  /** In-flight fire-and-forget work triggered by foreign messages, awaited on teardown. */
26
28
  private readonly pendingBroadcastWork;
27
29
  private readonly storage;
@@ -32,7 +34,17 @@ export declare class Project<GenericConfig extends AnyDialecteConfig, GenericMod
32
34
  /** Single project-lived dev perf helper; frozen no-op unless `dev.perf`. */
33
35
  readonly perf: Perf;
34
36
  get name(): string;
37
+ /** The store of an open project: one never opened, closed or destroyed has none to read or write. */
35
38
  private get store();
39
+ /**
40
+ * The imports of this project, one after the other: a call made while another import runs
41
+ * waits for it. The chain never blocks on a failed import; each caller gets its own outcome.
42
+ */
43
+ private importChain;
44
+ /** Run `work` once every import queued before it has settled: one file in flight per project. */
45
+ private enqueueImport;
46
+ /** Resolved once every import queued so far has settled, however it settled. */
47
+ private settledImports;
36
48
  private get channel();
37
49
  /**
38
50
  * Name of this project's BroadcastChannel — the public event contract.
@@ -96,11 +108,13 @@ export declare class Project<GenericConfig extends AnyDialecteConfig, GenericMod
96
108
  /** Recompute canUndo/canRedo for a document from the store's history. */
97
109
  private refreshHistoryStatus;
98
110
  /**
99
- * Close the store and release resources.
111
+ * Close the store and release resources, once the imports in flight have landed - they
112
+ * broadcast on the live channel. From the call on, the project is closed: a new call throws
113
+ * `PROJECT_NOT_OPENED`.
100
114
  */
101
- close(): void;
115
+ close(): Promise<void>;
102
116
  /**
103
- * Destroy the project - deletes the database entirely.
117
+ * Destroy the project - deletes the database entirely, once the imports in flight have landed.
104
118
  */
105
119
  destroy(): Promise<void>;
106
120
  /**
@@ -113,12 +127,27 @@ export declare class Project<GenericConfig extends AnyDialecteConfig, GenericMod
113
127
  */
114
128
  removeDocument(documentId: string): Promise<void>;
115
129
  /**
116
- * Import one or more Files into the project: register, parse XML, persist records.
130
+ * What is about an import call, checked at the call and before any file: an open project (its
131
+ * store, which the import then writes to even if the project closes meanwhile), a known
132
+ * `configKey`.
117
133
  */
118
- import(files: File[], options?: ImportDocumentOptions): Promise<Array<{
119
- documentId: string;
120
- recordCount: number;
121
- }>>;
134
+ private importStore;
135
+ /**
136
+ * Import Files into the project: one entry per file, in the order given. The files are imported
137
+ * one after the other - memory is bounded by one file's batches, the registry sees one import -
138
+ * and a file that fails is its own `failed` entry, the next file still attempted: nothing of a
139
+ * failed file lands. The call itself rejects only for what is about the call: an unknown
140
+ * `configKey`, a project not open.
141
+ */
142
+ import(files: File[], options?: ImportDocumentOptions): Promise<ImportEntry[]>;
143
+ /**
144
+ * Import one File into the project: register, parse XML, persist records. The document is in
145
+ * the project state and broadcast once its last record is stored; whatever fails before that
146
+ * removes it again and is thrown (`PARSE_ERROR` for a malformed file). One file is in flight
147
+ * per project: a call made while another import runs waits for it.
148
+ */
149
+ importFile(file: File, options?: ImportDocumentOptions): Promise<ImportedDocument>;
150
+ private importOne;
122
151
  /**
123
152
  * Export a document as an XMLDocument built from stored records.
124
153
  */
@@ -126,6 +155,7 @@ export declare class Project<GenericConfig extends AnyDialecteConfig, GenericMod
126
155
  xmlDocument: XMLDocument;
127
156
  filename: string;
128
157
  }>;
158
+ /** The documents of the project; one still importing - here or in another realm - is not among them. */
129
159
  getDocuments(): Promise<DocumentRecord[]>;
130
160
  getDocument(documentId: string): Promise<DocumentRecord | undefined>;
131
161
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/project/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAKrC,OAAO,KAAK,EACX,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAEhB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAC5F,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAClC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAI3F;;;;;GAKG;AACH,qBAAa,OAAO,CACnB,aAAa,SAAS,iBAAiB,EACvC,cAAc,SAAS,gBAAgB,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAC9D,YAAY,SAAS,KAAK,GAAG,KAAK;IAElC,OAAO,CAAC,KAAK,CAAC,CAAQ;IACtB,OAAO,CAAC,MAAM,CAAC,CAAc;IAC7B;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,CAAkB;IACnC,mFAAmF;IACnF,OAAO,CAAC,OAAO,CAAQ;IACvB,yFAAyF;IACzF,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA2B;IAChE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyC;IACjE,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,gBAAgB,CAAC,CAAkC;IAC3D,OAAO,CAAC,KAAK,CAAC,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AC;IAO/C;;;OAGG;IACG,UAAU,CAAC,MAAM,EACtB,aAAa,EAAE,CACd,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,eAAe,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,KAC3E,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAC9B,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAS9B;;;OAGG;IACG,QAAQ,CAAC,MAAM,EACpB,aAAa,EAAE,CACd,KAAK,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,eAAe,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,KAC3E,OAAO,CAAC,MAAM,EAAE,CAAC,GACpB,OAAO,CAAC,MAAM,EAAE,CAAC;IAYpB,iHAAiH;IACjH,mBAAmB,IAAI,UAAU,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;YAIxD,YAAY;IAK1B;;;;;OAKG;YACW,sBAAsB;CAKpC"}
@@ -0,0 +1,18 @@
1
+ import { DocumentRecord } from '../types';
2
+ /** How often an import says it is still alive, through `DocumentRecord.importingAt`. */
3
+ export declare const IMPORT_HEARTBEAT_MS = 2000;
4
+ /**
5
+ * An import whose last heartbeat is older than this was left by a realm that died (a tab closed
6
+ * mid-import): `open()` removes it. Generous on purpose - a false "dead" loses a running import, a
7
+ * false "alive" only keeps a hidden leftover a few minutes longer: a hidden tab's timers are
8
+ * throttled to once a minute by the browser, and a dialecte's `afterImport` on a very large file
9
+ * may hold the main thread for tens of seconds.
10
+ */
11
+ export declare const STALE_IMPORT_MS: number;
12
+ /** A document whose records are still being stored - by this realm or another one. */
13
+ export declare function isImporting(record: DocumentRecord): boolean;
14
+ /** An import nobody is running any more: still `importing`, its heartbeat long gone. */
15
+ export declare function isStaleImport(record: DocumentRecord, now?: number): boolean;
16
+ /** The documents a project opens, lists and serves: nothing half-imported is ever visible. */
17
+ export declare function openableDocuments(records: readonly DocumentRecord[]): DocumentRecord[];
18
+ //# sourceMappingURL=document-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"document-lifecycle.d.ts","sourceRoot":"","sources":["../../../src/project/state/document-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAErD,wFAAwF;AACxF,eAAO,MAAM,mBAAmB,OAAQ,CAAA;AAExC;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,QAAa,CAAA;AAEzC,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAE3D;AAED,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,EAAE,GAAG,SAAa,GAAG,OAAO,CAE/E;AAED,8FAA8F;AAC9F,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,GAAG,cAAc,EAAE,CAEtF"}
@@ -1,4 +1,6 @@
1
+ import { Diagnostic } from '../diagnostics';
1
2
  import { DocumentState, ExtensionModules } from '../document';
3
+ import { DialecteError } from '../errors';
2
4
  import { Perf } from '../perf';
3
5
  import { Store } from '../store/store.types';
4
6
  import { AnyDialecteConfig, BlobAttachment, BlobRecord, ChunkOptions, DialecteHooks } from '../types';
@@ -21,7 +23,17 @@ export type DocumentRecord = {
21
23
  createdAt: number;
22
24
  /** Extensible per-file metadata, populated by config.extractMetadata at import */
23
25
  metadata?: Record<string, unknown>;
26
+ /**
27
+ * `importing` from registration until the last record is stored, `ready` after. A failed import
28
+ * removes the document; one left `importing` with no heartbeat for `STALE_IMPORT_MS` was left
29
+ * by a realm that died, and `open()` removes it. A document is never opened, listed or served
30
+ * while `importing`.
31
+ */
32
+ status: DocumentStatus;
33
+ /** While `importing`: the last time the importing realm said it was alive (ms since epoch). */
34
+ importingAt?: number;
24
35
  };
36
+ export type DocumentStatus = 'importing' | 'ready';
25
37
  /**
26
38
  * DocumentState - observable state for a single document within a Project.
27
39
  * Extends DocumentState with project-level fields.
@@ -117,6 +129,16 @@ export type ProjectParams<GenericConfig extends AnyDialecteConfig, BaseExtension
117
129
  /** All lifecycle hooks (IO + record), applied to every Document opened from this Project */
118
130
  hooks?: DialecteHooks<GenericConfig>;
119
131
  };
132
+ export type ResolveConfigParams = {
133
+ configs: Record<string, AnyDialecteConfig>;
134
+ defaultConfigKey: string;
135
+ /** Key into configs registry. Defaults to defaultConfigKey. */
136
+ configKey?: string;
137
+ };
138
+ export type ResolvedConfig = {
139
+ configKey: string;
140
+ config: AnyDialecteConfig;
141
+ };
120
142
  export type InitEmptyDocumentOptions = {
121
143
  /** Filename without extension. Defaults to 'untitled'. */
122
144
  name?: string;
@@ -166,6 +188,28 @@ export type ImportDocumentResult = {
166
188
  record: DocumentRecord;
167
189
  documentState: DocumentEntry;
168
190
  recordCount: number;
191
+ /** What the import had to say about the file; `[]` when nothing */
192
+ diagnostics: Diagnostic[];
193
+ };
194
+ /** A file `Project.importFile` imported: the document it is now, and what the import had to say. */
195
+ export type ImportedDocument = {
196
+ /** `file.name` as given */
197
+ fileName: string;
198
+ documentId: string;
199
+ recordCount: number;
200
+ /** Always present, `[]` when the import had nothing to say; an open union, narrowed with `isKnownDiagnostic` */
201
+ diagnostics: Diagnostic[];
202
+ };
203
+ /**
204
+ * What `Project.import` says of one file: imported, or failed with the structured error - a file's
205
+ * failure is its entry, never the call's.
206
+ */
207
+ export type ImportEntry = ({
208
+ status: 'imported';
209
+ } & ImportedDocument) | {
210
+ status: 'failed';
211
+ fileName: string;
212
+ error: DialecteError;
169
213
  };
170
214
  export type ExportDocumentParams = {
171
215
  documentId: string;