@dialecte/core 0.6.4 → 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.
- package/dist/diagnostics/diagnostics.d.ts +26 -0
- package/dist/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics/index.d.ts +3 -0
- package/dist/diagnostics/index.d.ts.map +1 -0
- package/dist/diagnostics/types.d.ts +72 -0
- package/dist/diagnostics/types.d.ts.map +1 -0
- package/dist/errors/codes.d.ts +4 -0
- package/dist/errors/codes.d.ts.map +1 -1
- package/dist/helpers.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -3
- package/dist/project/index.d.ts +2 -1
- package/dist/project/index.d.ts.map +1 -1
- package/dist/project/io/import-document.d.ts.map +1 -1
- package/dist/project/io/init-empty-document.d.ts.map +1 -1
- package/dist/project/io/resolve-config.d.ts +4 -0
- package/dist/project/io/resolve-config.d.ts.map +1 -0
- package/dist/project/project.d.ts +39 -9
- package/dist/project/project.d.ts.map +1 -1
- package/dist/project/state/document-lifecycle.d.ts +18 -0
- package/dist/project/state/document-lifecycle.d.ts.map +1 -0
- package/dist/project/types.d.ts +44 -0
- package/dist/project/types.d.ts.map +1 -1
- package/dist/{project-DGQAe9G9.js → project-DIKdMMHx.js} +573 -433
- package/dist/store/in-memory/in-memory-store.d.ts +1 -1
- package/dist/store/in-memory/in-memory-store.d.ts.map +1 -1
- package/dist/store/local/dexie-store.d.ts +1 -1
- package/dist/store/local/dexie-store.d.ts.map +1 -1
- package/dist/store/local/types.d.ts +3 -0
- package/dist/store/local/types.d.ts.map +1 -1
- package/dist/store/store.types.d.ts +2 -2
- package/dist/store/store.types.d.ts.map +1 -1
- package/dist/test.js +11 -11
- package/dist/types/io.d.ts +30 -27
- package/dist/types/io.d.ts.map +1 -1
- package/dist/{utils-CTBHUFs9.js → utils-DJN0Md0v.js} +4 -0
- package/dist/utils.js +1 -1
- package/dist/xml/parse/parse-xml-document.d.ts.map +1 -1
- package/dist/xml/parse/parse-xml-document.types.d.ts +5 -0
- package/dist/xml/parse/parse-xml-document.types.d.ts.map +1 -1
- package/dist/xml/parse/parser.d.ts +4 -2
- package/dist/xml/parse/parser.d.ts.map +1 -1
- package/dist/xml/parse/types.d.ts +2 -0
- package/dist/xml/parse/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CreateDiagnosticParams, CreatedDiagnostic, Diagnostic, DiagnosticCatalogue, KnownDiagnosticCode } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Build a diagnostic of a catalogue: `severity`, `source` and the default `message` come from the
|
|
4
|
+
* entry, so a producer only says what the diagnostic is about. The `meta` and `related` given keep
|
|
5
|
+
* their type on the way out, so a dialecte's typed diagnostic (`Diagnostic<'x'> & { meta: {…} }`) is
|
|
6
|
+
* what this returns when it is given that `meta`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* createDiagnostic(SCL_IMPORT_DIAGNOSTICS, 'unresolved-reference', {
|
|
10
|
+
* ref: { tagName: 'FunctionRef', id, attribute: 'function' },
|
|
11
|
+
* meta: { pathValue, triedKeys },
|
|
12
|
+
* })
|
|
13
|
+
*/
|
|
14
|
+
export declare function createDiagnostic<const GenericCatalogue extends DiagnosticCatalogue, GenericCode extends keyof GenericCatalogue['codes'] & string, GenericParams extends CreateDiagnosticParams>(catalogue: GenericCatalogue, code: GenericCode, params: GenericParams): CreatedDiagnostic<GenericCode, GenericParams>;
|
|
15
|
+
/**
|
|
16
|
+
* Whether a diagnostic is one the caller knows: an entry of one of the catalogues named, matched on
|
|
17
|
+
* the pair (`source`, `code`) - two dialectes may both have an `unresolved-reference`. Its `code` is
|
|
18
|
+
* then narrowed to those catalogues' codes, so a `switch` on it or a table read with it is checked.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* if (isKnownDiagnostic(diagnostic, { catalogues: [SCL_IMPORT_DIAGNOSTICS] })) sentences[diagnostic.code]
|
|
22
|
+
*/
|
|
23
|
+
export declare function isKnownDiagnostic<const GenericCatalogues extends readonly DiagnosticCatalogue[]>(diagnostic: Diagnostic, params: {
|
|
24
|
+
catalogues: GenericCatalogues;
|
|
25
|
+
}): diagnostic is Diagnostic<KnownDiagnosticCode<GenericCatalogues>>;
|
|
26
|
+
//# sourceMappingURL=diagnostics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sourceRoot":"","sources":["../../src/diagnostics/diagnostics.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,MAAM,SAAS,CAAA;AAEhB;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC/B,KAAK,CAAC,gBAAgB,SAAS,mBAAmB,EAClD,WAAW,SAAS,MAAM,gBAAgB,CAAC,OAAO,CAAC,GAAG,MAAM,EAC5D,aAAa,SAAS,sBAAsB,EAE5C,SAAS,EAAE,gBAAgB,EAC3B,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,aAAa,GACnB,iBAAiB,CAAC,WAAW,EAAE,aAAa,CAAC,CAiB/C;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,iBAAiB,SAAS,SAAS,mBAAmB,EAAE,EAC/F,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE;IAAE,UAAU,EAAE,iBAAiB,CAAA;CAAE,GACvC,UAAU,IAAI,UAAU,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC,CAKlE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diagnostics/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,mBAAmB,SAAS,CAAA"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The levels of the language-server protocol: `error` and `warning` say something is wrong,
|
|
3
|
+
* `information` reports what was done (a value rewritten on import), `hint` what could be better.
|
|
4
|
+
*/
|
|
5
|
+
export type DiagnosticSeverity = 'error' | 'warning' | 'information' | 'hint';
|
|
6
|
+
/** What a diagnostic is about - the axis a reader filters by; a property of the catalogue entry, not of the diagnostic. */
|
|
7
|
+
export type DiagnosticFamily = 'value' | 'attribute' | 'structure' | 'identity' | 'reference' | 'import';
|
|
8
|
+
/** The record a diagnostic points at, and the attribute when it is about one. */
|
|
9
|
+
export type DiagnosticRef = {
|
|
10
|
+
tagName: string;
|
|
11
|
+
id: string;
|
|
12
|
+
attribute?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Something a producer - an import hook, a validation rule - says about one record of a document.
|
|
16
|
+
* The shape of the language-server protocol's `Diagnostic`, with `ref` where it has a text range
|
|
17
|
+
* and `meta` where it has `data`. Plain data: it crosses a worker boundary as is.
|
|
18
|
+
*
|
|
19
|
+
* Its identity is the pair (`source`, `code`): two dialectes may both have an `unresolved-reference`.
|
|
20
|
+
*/
|
|
21
|
+
export type Diagnostic<GenericCode extends string = string> = {
|
|
22
|
+
/** A code of the producer's catalogue. */
|
|
23
|
+
code: GenericCode;
|
|
24
|
+
severity: DiagnosticSeverity;
|
|
25
|
+
/** Who said it: `'core'` for definition rules, the dialecte's name for its hooks and domain rules. */
|
|
26
|
+
source: string;
|
|
27
|
+
/** Default wording; a consumer words it from `code` and `meta` and falls back to this. */
|
|
28
|
+
message: string;
|
|
29
|
+
ref: DiagnosticRef;
|
|
30
|
+
/** The other records it involves - an incoherent reference names two elements. */
|
|
31
|
+
related?: {
|
|
32
|
+
ref: DiagnosticRef;
|
|
33
|
+
message: string;
|
|
34
|
+
}[];
|
|
35
|
+
/** What it is about, as serializable data - the contract, with `code`; `message` is the convenience. */
|
|
36
|
+
meta?: Record<string, unknown>;
|
|
37
|
+
};
|
|
38
|
+
/** What a catalogue says of one code: the severity its diagnostics carry, their family, their default wording. */
|
|
39
|
+
export type DiagnosticCatalogueEntry = {
|
|
40
|
+
severity: DiagnosticSeverity;
|
|
41
|
+
family: DiagnosticFamily;
|
|
42
|
+
message: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The diagnostics a producer may emit, by code, under one `source`. A dialecte writes one per
|
|
46
|
+
* concern (`SCL_IMPORT_DIAGNOSTICS`); a consumer narrows a diagnostic to its codes with
|
|
47
|
+
* `isKnownDiagnostic`.
|
|
48
|
+
*/
|
|
49
|
+
export type DiagnosticCatalogue = {
|
|
50
|
+
readonly source: string;
|
|
51
|
+
readonly codes: {
|
|
52
|
+
readonly [GenericCode: string]: DiagnosticCatalogueEntry;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
/** What `createDiagnostic` is given beside the code: the record, and what the diagnostic is about. */
|
|
56
|
+
export type CreateDiagnosticParams = {
|
|
57
|
+
ref: DiagnosticRef;
|
|
58
|
+
/** A wording for this occurrence; the entry's default otherwise. */
|
|
59
|
+
message?: string;
|
|
60
|
+
related?: Diagnostic['related'];
|
|
61
|
+
meta?: Record<string, unknown>;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* What `createDiagnostic` returns: the diagnostic of that code, its `meta` and `related` typed as they
|
|
65
|
+
* were given - so a dialecte's `Diagnostic<'x'> & { meta: {…} }` is what comes out, with no cast.
|
|
66
|
+
*/
|
|
67
|
+
export type CreatedDiagnostic<GenericCode extends string, GenericParams extends CreateDiagnosticParams> = Omit<Diagnostic<GenericCode>, 'meta' | 'related'> & Omit<GenericParams, 'ref' | 'message'>;
|
|
68
|
+
/** The codes of the catalogues named, as `isKnownDiagnostic` narrows them. */
|
|
69
|
+
export type KnownDiagnosticCode<GenericCatalogues extends readonly DiagnosticCatalogue[]> = CodesOfCatalogue<GenericCatalogues[number]>;
|
|
70
|
+
type CodesOfCatalogue<GenericCatalogue> = GenericCatalogue extends DiagnosticCatalogue ? keyof GenericCatalogue['codes'] & string : never;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/diagnostics/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,GAAG,aAAa,GAAG,MAAM,CAAA;AAE7E,2HAA2H;AAC3H,MAAM,MAAM,gBAAgB,GACzB,OAAO,GACP,WAAW,GACX,WAAW,GACX,UAAU,GACV,WAAW,GACX,QAAQ,CAAA;AAEX,iFAAiF;AACjF,MAAM,MAAM,aAAa,GAAG;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,CAAC,WAAW,SAAS,MAAM,GAAG,MAAM,IAAI;IAC7D,0CAA0C;IAC1C,IAAI,EAAE,WAAW,CAAA;IACjB,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,sGAAsG;IACtG,MAAM,EAAE,MAAM,CAAA;IACd,0FAA0F;IAC1F,OAAO,EAAE,MAAM,CAAA;IACf,GAAG,EAAE,aAAa,CAAA;IAClB,kFAAkF;IAClF,OAAO,CAAC,EAAE;QAAE,GAAG,EAAE,aAAa,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACnD,wGAAwG;IACxG,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B,CAAA;AAED,kHAAkH;AAClH,MAAM,MAAM,wBAAwB,GAAG;IACtC,QAAQ,EAAE,kBAAkB,CAAA;IAC5B,MAAM,EAAE,gBAAgB,CAAA;IACxB,OAAO,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,GAAG,wBAAwB,CAAA;KAAE,CAAA;CAC5E,CAAA;AAED,sGAAsG;AACtG,MAAM,MAAM,sBAAsB,GAAG;IACpC,GAAG,EAAE,aAAa,CAAA;IAClB,oEAAoE;IACpE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,iBAAiB,CAC5B,WAAW,SAAS,MAAM,EAC1B,aAAa,SAAS,sBAAsB,IACzC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,aAAa,EAAE,KAAK,GAAG,SAAS,CAAC,CAAA;AAE9F,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,CAAC,iBAAiB,SAAS,SAAS,mBAAmB,EAAE,IACvF,gBAAgB,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAA;AAE5C,KAAK,gBAAgB,CAAC,gBAAgB,IAAI,gBAAgB,SAAS,mBAAmB,GACnF,MAAM,gBAAgB,CAAC,OAAO,CAAC,GAAG,MAAM,GACxC,KAAK,CAAA"}
|
package/dist/errors/codes.d.ts
CHANGED
|
@@ -127,6 +127,10 @@ export declare const ERROR_CATALOG: {
|
|
|
127
127
|
readonly code: "D5003";
|
|
128
128
|
readonly message: "Failed to parse XML";
|
|
129
129
|
};
|
|
130
|
+
readonly IMPORT_FAILED: {
|
|
131
|
+
readonly code: "D5004";
|
|
132
|
+
readonly message: "Failed to import the file";
|
|
133
|
+
};
|
|
130
134
|
readonly EXTENSION_METHOD_COLLISION: {
|
|
131
135
|
readonly code: "D6001";
|
|
132
136
|
readonly message: "Extension method name collision detected";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/errors/codes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/errors/codes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2KhB,CAAA"}
|
package/dist/helpers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-
|
|
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
3
|
var w = [
|
|
4
4
|
"id",
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -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
|
|
2
|
-
import { F as
|
|
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 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 };
|
package/dist/project/index.d.ts
CHANGED
|
@@ -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":"
|
|
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,
|
|
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
|
-
*
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/project/project.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAMrC,OAAO,KAAK,EACX,wBAAwB,EACxB,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,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,K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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"}
|
package/dist/project/types.d.ts
CHANGED
|
@@ -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;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/project/types.ts"],"names":[],"mappings":"AA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