@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
@@ -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,3 @@
1
+ export * from './diagnostics';
2
+ export type * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -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":"A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AM,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"}
@@ -5,10 +5,10 @@ import { AttributeDefaults } from '../../../../utils';
5
5
  * Fetch a single attribute for the given ref or record.
6
6
  *
7
7
  * Resolves the record (a record given in full is read as it is, through the staged
8
- * operations; a ref via staged → cache → store, see `resolveRecord`), then extracts the named
9
- * attribute. Pass `namespace` to scope by a namespace key (a local `name` is resolved
10
- * to the stored `prefix:local` key). `defaults` (default `'optional'`) controls the
11
- * fallback for an absent attribute: `'none'` → `''`; `'optional'` → `fixed` /
8
+ * operations; a ref via staged → cache → store, see `resolveRecord`), then reads the named
9
+ * attribute with {@link readAttribute}. Pass `namespace` to scope by a namespace key (a local
10
+ * `name` is resolved to the stored `prefix:local` key). `defaults` (default `'optional'`)
11
+ * controls the fallback for an absent attribute: `'none'` → `''`; `'optional'` → `fixed` /
12
12
  * non-empty `default` (else `''`); `'required'` → required/fixed materialized value.
13
13
  *
14
14
  * @example
@@ -24,9 +24,9 @@ export declare function getAttribute<GenericConfig extends AnyDialecteConfig, Ge
24
24
  }): Promise<GenericAttribute['value'] | ''>;
25
25
  /**
26
26
  * Fetch a single attribute for the given ref or record as a full object (name + value +
27
- * namespace). `defaults` (default `'optional'`) fills an absent schema attribute by
28
- * synthesizing its object; `'none'` returns `undefined` when the attribute is not
29
- * stored.
27
+ * namespace), read with {@link readAttribute}. `defaults` (default `'optional'`) fills an
28
+ * absent schema attribute by synthesizing its object; `'none'` returns `undefined` when the
29
+ * attribute is not stored.
30
30
  *
31
31
  * @example
32
32
  * getAttribute({ context, ref, name: 'name', fullObject: true }) // → FullAttributeObject | undefined
@@ -1 +1 @@
1
- {"version":3,"file":"get-attribute.d.ts","sourceRoot":"","sources":["../../../../../src/document/query/get/attribute/get-attribute.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,YAAY,CACjC,aAAa,SAAS,iBAAiB,EACvC,cAAc,SAAS,UAAU,CAAC,aAAa,CAAC,EAChD,gBAAgB,SAAS,qBAAqB,CAAC,aAAa,EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE;IACT,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC/B,GAAG,EAAE,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,SAAS,CAAA;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,GAAG,OAAO,CAAC,gBAAg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AAiB,CAAA;CAC5B,GAAG,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAQ1C;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC3C,aAAa,SAAS,iBAAiB,EACvC,cAAc,SAAS,UAAU,CAAC,aAAa,CAAC,EAChD,gBAAgB,SAAS,qBAAqB,CAAC,aAAa,EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE;IACT,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC/B,GAAG,EAAE,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,SAAS,CAAA;IAC3D,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAQxC"}
@@ -3,7 +3,8 @@ import { AnyDialecteConfig, AttributesValueObjectOf, ElementsOf, FullAttributeOb
3
3
  import { AttributeDefaults } from '../../../../utils';
4
4
  /**
5
5
  * Fetch attributes for the given ref or record as a destructurable value object. A record given in full is read as it
6
- * is, through the staged operations, with no store round trip (see `resolveRecord`).
6
+ * is, through the staged operations, with no store round trip (see `resolveRecord`); the reading itself is
7
+ * {@link readAttributes}.
7
8
  *
8
9
  * Without `namespace`, every attribute under the name it is stored by (`aA`, `xsi:type`, `ext:cA`) - what a write takes
9
10
  * back. With a `namespace` key, only that namespace's attributes, with the prefix stripped from the keys
@@ -17,14 +18,15 @@ import { AttributeDefaults } from '../../../../utils';
17
18
  * getAttributes({ context, ref }) // → { aA: '', bA: '', ... }
18
19
  * getAttributes({ context, ref, namespace: 'ext' }) // → { cA: '...' }
19
20
  */
20
- export declare function getAttributes<GenericConfig extends AnyDialecteConfig, GenericElement extends ElementsOf<GenericConfig>, GenericAttribute extends FullAttributeObjectOf<GenericConfig, GenericElement>>(params: {
21
+ export declare function getAttributes<GenericConfig extends AnyDialecteConfig, GenericElement extends ElementsOf<GenericConfig>, _GenericAttribute extends FullAttributeObjectOf<GenericConfig, GenericElement>>(params: {
21
22
  context: Context<GenericConfig>;
22
23
  ref: RefOrRecord<GenericConfig, GenericElement> | undefined;
23
24
  namespace?: string;
24
25
  defaults?: AttributeDefaults;
25
26
  }): Promise<AttributesValueObjectOf<GenericConfig, GenericElement>>;
26
27
  /**
27
- * Fetch all attributes of the given ref or record as a full array (name + value + namespace).
28
+ * Fetch all attributes of the given ref or record as a full array (name + value + namespace), read with
29
+ * {@link readAttributes}.
28
30
  *
29
31
  * `defaults` (default `'optional'`) fills absent schema attributes just like
30
32
  * {@link getAttributes}: `'none'` returns the faithful stored-only set;
@@ -1 +1 @@
1
- {"version":3,"file":"get-attributes.d.ts","sourceRoot":"","sources":["../../../../../src/document/query/get/attribute/get-attributes.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EACX,iBAAiB,EACjB,uBAAuB,EACvB,UAAU,EACV,qBAAqB,EAErB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;;;;;;;;;;;GAeG;AAEH,wBAAsB,aAAa,CAClC,aAAa,SAAS,iBAAiB,EACvC,cAAc,SAAS,UAAU,CAAC,aAAa,CAAC,EAChD,gBAAgB,SAAS,qBAAqB,CAAC,aAAa,EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE;IACT,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC/B,GAAG,EAAE,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,SAAS,CAAA;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,GAAG,OAAO,CAAC,uBAAuB,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC,CAqClE;AAmBD;;;;;;;;;;GAUG;AAEH,wBAAsB,uBAAuB,CAC5C,aAAa,SAAS,iBAAiB,EACvC,cAAc,SAAS,UAAU,CAAC,aAAa,CAAC,EAChD,gBAAgB,SAAS,qBAAqB,CAAC,aAAa,EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE;IACT,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC/B,GAAG,EAAE,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,SAAS,CAAA;IAC3D,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA6B9B"}
1
+ {"version":3,"file":"get-attributes.d.ts","sourceRoot":"","sources":["../../../../../src/document/query/get/attribute/get-attributes.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,KAAK,EACX,iBAAiB,EACjB,uBAAuB,EACvB,UAAU,EACV,qBAAqB,EACrB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAsB,aAAa,CAClC,aAAa,SAAS,iBAAiB,EACvC,cAAc,SAAS,UAAU,CAAC,aAAa,CAAC,EAChD,iBAAiB,SAAS,qBAAqB,CAAC,aAAa,EAAE,cAAc,CAAC,EAC7E,MAAM,EAAE;IACT,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC/B,GAAG,EAAE,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,SAAS,CAAA;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,GAAG,OAAO,CAAC,uBAAuB,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC,CASlE;AAED;;;;;;;;;;;GAWG;AAEH,wBAAsB,uBAAuB,CAC5C,aAAa,SAAS,iBAAiB,EACvC,cAAc,SAAS,UAAU,CAAC,aAAa,CAAC,EAChD,gBAAgB,SAAS,qBAAqB,CAAC,aAAa,EAAE,cAAc,CAAC,EAC5E,MAAM,EAAE;IACT,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC/B,GAAG,EAAE,WAAW,CAAC,aAAa,EAAE,cAAc,CAAC,GAAG,SAAS,CAAA;IAC3D,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAW9B"}
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuKhB,CAAA"}
1
+ {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/errors/codes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2KhB,CAAA"}
@@ -6,4 +6,6 @@ export * from './assert-fixed';
6
6
  export * from './assert-xsi-type';
7
7
  export * from './merge-extensions';
8
8
  export * from './strip-attributes';
9
+ export * from './read-attributes';
10
+ export type * from './read-attributes.types';
9
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,mBAAmB,yBAAyB,CAAA"}
@@ -0,0 +1,56 @@
1
+ import { ReadAttributesBaseParams } from './read-attributes.types';
2
+ import { AnyAttribute } from '../types';
3
+ /**
4
+ * Read one attribute of a record you hold, the way `query.getAttribute` reads it - same `namespace` scope, same
5
+ * `defaults` fill, same `''` for an absent attribute - with no query: synchronous, for an import pass or a pure
6
+ * composer. `query.getAttribute` itself delegates to it once it has the record.
7
+ *
8
+ * `fullObject: true` returns the attribute object, or `undefined` when there is none in that view: with
9
+ * `defaults: 'none'`, how to tell an absent attribute from one written empty.
10
+ *
11
+ * Reads the record as you hold it. Inside a transaction use `tx.getAttribute`, which sees the transaction's staged
12
+ * writes: a record held from before a write still reads its old values here.
13
+ *
14
+ * @example
15
+ * readAttribute({ record, dialecteConfig, name: 'aA' }) // → 'v' | ''
16
+ * readAttribute({ record, dialecteConfig, name: 'aA', defaults: 'none', fullObject: true }) // → undefined when absent
17
+ *
18
+ * @see {@link readAttributes}
19
+ */
20
+ export declare function readAttribute(params: ReadAttributesBaseParams & {
21
+ name: string;
22
+ namespace?: string;
23
+ fullObject?: false;
24
+ }): string;
25
+ export declare function readAttribute(params: ReadAttributesBaseParams & {
26
+ name: string;
27
+ namespace?: string;
28
+ fullObject: true;
29
+ }): AnyAttribute | undefined;
30
+ /**
31
+ * Read the attributes of a record you hold, the way `query.getAttributes` reads them - each under the name it is
32
+ * stored by, or keyed by local name in a `namespace` scope, absent schema attributes filled per `defaults` - with no
33
+ * query: synchronous, for an import pass or a pure composer. `query.getAttributes`
34
+ * itself delegates to it once it has the record. Values are plain strings: for typed reads use the query.
35
+ *
36
+ * Namespace declarations are left out of the value object; `fullObject: true` returns the stored attributes as they
37
+ * are, a declaration a document carries included (stored by its prefix, in the xmlns namespace).
38
+ *
39
+ * Reads the record as you hold it. Inside a transaction use `tx.getAttributes`, which sees the transaction's staged
40
+ * writes: a record held from before a write still reads its old values here.
41
+ *
42
+ * @example
43
+ * readAttributes({ record, dialecteConfig }) // → { aA: 'v', 'ext:cA': 'w' }
44
+ * readAttributes({ record, dialecteConfig, defaults: 'none' }) // → stored only
45
+ * readAttributes({ record, dialecteConfig, fullObject: true }) // → AnyAttribute[]
46
+ *
47
+ * @see {@link readAttribute}
48
+ */
49
+ export declare function readAttributes(params: ReadAttributesBaseParams & {
50
+ namespace?: string;
51
+ fullObject?: false;
52
+ }): Record<string, string>;
53
+ export declare function readAttributes(params: ReadAttributesBaseParams & {
54
+ fullObject: true;
55
+ }): AnyAttribute[];
56
+ //# sourceMappingURL=read-attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-attributes.d.ts","sourceRoot":"","sources":["../../src/helpers/read-attributes.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAA;AACvE,OAAO,KAAK,EAAE,YAAY,EAA8C,MAAM,SAAS,CAAA;AAGvF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,wBAAwB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GACzF,MAAM,CAAA;AACT,wBAAgB,aAAa,CAC5B,MAAM,EAAE,wBAAwB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,IAAI,CAAA;CAAE,GACvF,YAAY,GAAG,SAAS,CAAA;AAyC3B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC7B,MAAM,EAAE,wBAAwB,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,KAAK,CAAA;CAAE,GAC3E,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AACzB,wBAAgB,cAAc,CAC7B,MAAM,EAAE,wBAAwB,GAAG;IAAE,UAAU,EAAE,IAAI,CAAA;CAAE,GACrD,YAAY,EAAE,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { AnyDialecteConfig, AnyRawRecord } from '../types';
2
+ import { AttributeDefaults } from '../utils';
3
+ /** What every attribute read takes: the record as held (raw, tracked or tree), the config its schema values come from. */
4
+ export type ReadAttributesBaseParams = {
5
+ record: AnyRawRecord;
6
+ dialecteConfig: AnyDialecteConfig;
7
+ /** How an absent schema attribute is filled - as in `query.getAttribute(s)`. Default `'optional'`. */
8
+ defaults?: AttributeDefaults;
9
+ };
10
+ //# sourceMappingURL=read-attributes.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-attributes.types.d.ts","sourceRoot":"","sources":["../../src/helpers/read-attributes.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,0HAA0H;AAC1H,MAAM,MAAM,wBAAwB,GAAG;IACtC,MAAM,EAAE,YAAY,CAAA;IACpB,cAAc,EAAE,iBAAiB,CAAA;IACjC,sGAAsG;IACtG,QAAQ,CAAC,EAAE,iBAAiB,CAAA;CAC5B,CAAA"}