@azx-pbc/axiom-builder 0.0.0-stage → 0.0.1
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/LICENSE +21 -0
- package/README.md +648 -2
- package/dist/cards/selectors.d.ts +70 -0
- package/dist/cards/selectors.d.ts.map +1 -0
- package/dist/cards/selectors.js +194 -0
- package/dist/cards/selectors.js.map +1 -0
- package/dist/definition.d.ts +36 -0
- package/dist/definition.d.ts.map +1 -0
- package/dist/definition.js +48 -0
- package/dist/definition.js.map +1 -0
- package/dist/evidence/cases.d.ts +44 -0
- package/dist/evidence/cases.d.ts.map +1 -0
- package/dist/evidence/cases.js +578 -0
- package/dist/evidence/cases.js.map +1 -0
- package/dist/evidence/repairs.d.ts +99 -0
- package/dist/evidence/repairs.d.ts.map +1 -0
- package/dist/evidence/repairs.js +181 -0
- package/dist/evidence/repairs.js.map +1 -0
- package/dist/evidence/summary.d.ts +35 -0
- package/dist/evidence/summary.d.ts.map +1 -0
- package/dist/evidence/summary.js +38 -0
- package/dist/evidence/summary.js.map +1 -0
- package/dist/i18n/gaps.d.ts +3 -0
- package/dist/i18n/gaps.d.ts.map +1 -0
- package/dist/i18n/gaps.js +2 -0
- package/dist/i18n/gaps.js.map +1 -0
- package/dist/i18n/message-slots.d.ts +19 -0
- package/dist/i18n/message-slots.d.ts.map +1 -0
- package/dist/i18n/message-slots.js +101 -0
- package/dist/i18n/message-slots.js.map +1 -0
- package/dist/i18n/text-locale.d.ts +13 -0
- package/dist/i18n/text-locale.d.ts.map +1 -0
- package/dist/i18n/text-locale.js +14 -0
- package/dist/i18n/text-locale.js.map +1 -0
- package/dist/i18n/translations.d.ts +56 -0
- package/dist/i18n/translations.d.ts.map +1 -0
- package/dist/i18n/translations.js +103 -0
- package/dist/i18n/translations.js.map +1 -0
- package/dist/impact/references.d.ts +143 -0
- package/dist/impact/references.d.ts.map +1 -0
- package/dist/impact/references.js +429 -0
- package/dist/impact/references.js.map +1 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/dist/preview/compile-preview.d.ts +67 -0
- package/dist/preview/compile-preview.d.ts.map +1 -0
- package/dist/preview/compile-preview.js +286 -0
- package/dist/preview/compile-preview.js.map +1 -0
- package/dist/preview/handle.d.ts +119 -0
- package/dist/preview/handle.d.ts.map +1 -0
- package/dist/preview/handle.js +2 -0
- package/dist/preview/handle.js.map +1 -0
- package/dist/preview/held.d.ts +39 -0
- package/dist/preview/held.d.ts.map +1 -0
- package/dist/preview/held.js +15 -0
- package/dist/preview/held.js.map +1 -0
- package/dist/preview/measurement.d.ts +5 -0
- package/dist/preview/measurement.d.ts.map +1 -0
- package/dist/preview/measurement.js +18 -0
- package/dist/preview/measurement.js.map +1 -0
- package/dist/publish/build.d.ts +33 -0
- package/dist/publish/build.d.ts.map +1 -0
- package/dist/publish/build.js +15 -0
- package/dist/publish/build.js.map +1 -0
- package/dist/publish/diff.d.ts +208 -0
- package/dist/publish/diff.d.ts.map +1 -0
- package/dist/publish/diff.js +227 -0
- package/dist/publish/diff.js.map +1 -0
- package/dist/publish/review.d.ts +41 -0
- package/dist/publish/review.d.ts.map +1 -0
- package/dist/publish/review.js +22 -0
- package/dist/publish/review.js.map +1 -0
- package/dist/schema/dataset-input.d.ts +30 -0
- package/dist/schema/dataset-input.d.ts.map +1 -0
- package/dist/schema/dataset-input.js +58 -0
- package/dist/schema/dataset-input.js.map +1 -0
- package/dist/schema/dataset.d.ts +166 -0
- package/dist/schema/dataset.d.ts.map +1 -0
- package/dist/schema/dataset.js +281 -0
- package/dist/schema/dataset.js.map +1 -0
- package/dist/schema/declarations.d.ts +15 -0
- package/dist/schema/declarations.d.ts.map +1 -0
- package/dist/schema/declarations.js +47 -0
- package/dist/schema/declarations.js.map +1 -0
- package/dist/schema/document.d.ts +504 -0
- package/dist/schema/document.d.ts.map +1 -0
- package/dist/schema/document.js +337 -0
- package/dist/schema/document.js.map +1 -0
- package/dist/schema/error.d.ts +15 -0
- package/dist/schema/error.d.ts.map +1 -0
- package/dist/schema/error.js +18 -0
- package/dist/schema/error.js.map +1 -0
- package/dist/schema/field-id.d.ts +8 -0
- package/dist/schema/field-id.d.ts.map +1 -0
- package/dist/schema/field-id.js +47 -0
- package/dist/schema/field-id.js.map +1 -0
- package/dist/schema/layout.d.ts +118 -0
- package/dist/schema/layout.d.ts.map +1 -0
- package/dist/schema/layout.js +101 -0
- package/dist/schema/layout.js.map +1 -0
- package/dist/schema/palette.d.ts +103 -0
- package/dist/schema/palette.d.ts.map +1 -0
- package/dist/schema/palette.js +140 -0
- package/dist/schema/palette.js.map +1 -0
- package/dist/schema/read.d.ts +49 -0
- package/dist/schema/read.d.ts.map +1 -0
- package/dist/schema/read.js +942 -0
- package/dist/schema/read.js.map +1 -0
- package/dist/store/apply-dataset.d.ts +14 -0
- package/dist/store/apply-dataset.d.ts.map +1 -0
- package/dist/store/apply-dataset.js +513 -0
- package/dist/store/apply-dataset.js.map +1 -0
- package/dist/store/apply.d.ts +37 -0
- package/dist/store/apply.d.ts.map +1 -0
- package/dist/store/apply.js +2269 -0
- package/dist/store/apply.js.map +1 -0
- package/dist/store/candidate.d.ts +37 -0
- package/dist/store/candidate.d.ts.map +1 -0
- package/dist/store/candidate.js +178 -0
- package/dist/store/candidate.js.map +1 -0
- package/dist/store/commands/coverage.d.ts +58 -0
- package/dist/store/commands/coverage.d.ts.map +1 -0
- package/dist/store/commands/coverage.js +354 -0
- package/dist/store/commands/coverage.js.map +1 -0
- package/dist/store/commands/dataset.d.ts +26 -0
- package/dist/store/commands/dataset.d.ts.map +1 -0
- package/dist/store/commands/dataset.js +368 -0
- package/dist/store/commands/dataset.js.map +1 -0
- package/dist/store/commands/document.d.ts +21 -0
- package/dist/store/commands/document.d.ts.map +1 -0
- package/dist/store/commands/document.js +160 -0
- package/dist/store/commands/document.js.map +1 -0
- package/dist/store/commands/field.d.ts +32 -0
- package/dist/store/commands/field.d.ts.map +1 -0
- package/dist/store/commands/field.js +572 -0
- package/dist/store/commands/field.js.map +1 -0
- package/dist/store/commands/layout.d.ts +16 -0
- package/dist/store/commands/layout.d.ts.map +1 -0
- package/dist/store/commands/layout.js +70 -0
- package/dist/store/commands/layout.js.map +1 -0
- package/dist/store/commands/parse.d.ts +19 -0
- package/dist/store/commands/parse.d.ts.map +1 -0
- package/dist/store/commands/parse.js +328 -0
- package/dist/store/commands/parse.js.map +1 -0
- package/dist/store/commands/readers.d.ts +198 -0
- package/dist/store/commands/readers.d.ts.map +1 -0
- package/dist/store/commands/readers.js +711 -0
- package/dist/store/commands/readers.js.map +1 -0
- package/dist/store/commands/rule.d.ts +24 -0
- package/dist/store/commands/rule.d.ts.map +1 -0
- package/dist/store/commands/rule.js +379 -0
- package/dist/store/commands/rule.js.map +1 -0
- package/dist/store/commands/shapes.d.ts +900 -0
- package/dist/store/commands/shapes.d.ts.map +1 -0
- package/dist/store/commands/shapes.js +166 -0
- package/dist/store/commands/shapes.js.map +1 -0
- package/dist/store/commands/suggestions.d.ts +37 -0
- package/dist/store/commands/suggestions.d.ts.map +1 -0
- package/dist/store/commands/suggestions.js +177 -0
- package/dist/store/commands/suggestions.js.map +1 -0
- package/dist/store/commands.d.ts +16 -0
- package/dist/store/commands.d.ts.map +1 -0
- package/dist/store/commands.js +13 -0
- package/dist/store/commands.js.map +1 -0
- package/dist/store/dataset-candidate.d.ts +33 -0
- package/dist/store/dataset-candidate.d.ts.map +1 -0
- package/dist/store/dataset-candidate.js +31 -0
- package/dist/store/dataset-candidate.js.map +1 -0
- package/dist/store/dataset-pin.d.ts +93 -0
- package/dist/store/dataset-pin.d.ts.map +1 -0
- package/dist/store/dataset-pin.js +86 -0
- package/dist/store/dataset-pin.js.map +1 -0
- package/dist/store/dataset-store.d.ts +96 -0
- package/dist/store/dataset-store.d.ts.map +1 -0
- package/dist/store/dataset-store.js +112 -0
- package/dist/store/dataset-store.js.map +1 -0
- package/dist/store/history.d.ts +149 -0
- package/dist/store/history.d.ts.map +1 -0
- package/dist/store/history.js +173 -0
- package/dist/store/history.js.map +1 -0
- package/dist/store/measurement.d.ts +5 -0
- package/dist/store/measurement.d.ts.map +1 -0
- package/dist/store/measurement.js +20 -0
- package/dist/store/measurement.js.map +1 -0
- package/dist/store/notify.d.ts +11 -0
- package/dist/store/notify.d.ts.map +1 -0
- package/dist/store/notify.js +26 -0
- package/dist/store/notify.js.map +1 -0
- package/dist/store/published.d.ts +50 -0
- package/dist/store/published.d.ts.map +1 -0
- package/dist/store/published.js +27 -0
- package/dist/store/published.js.map +1 -0
- package/dist/store/refusals.d.ts +175 -0
- package/dist/store/refusals.d.ts.map +1 -0
- package/dist/store/refusals.js +160 -0
- package/dist/store/refusals.js.map +1 -0
- package/dist/store/steps.d.ts +14 -0
- package/dist/store/steps.d.ts.map +1 -0
- package/dist/store/steps.js +124 -0
- package/dist/store/steps.js.map +1 -0
- package/dist/store/store.d.ts +142 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +136 -0
- package/dist/store/store.js.map +1 -0
- package/dist/store/unchanged.d.ts +12 -0
- package/dist/store/unchanged.d.ts.map +1 -0
- package/dist/store/unchanged.js +35 -0
- package/dist/store/unchanged.js.map +1 -0
- package/dist/visual/emit.d.ts +21 -0
- package/dist/visual/emit.d.ts.map +1 -0
- package/dist/visual/emit.js +133 -0
- package/dist/visual/emit.js.map +1 -0
- package/dist/visual/parse.d.ts +32 -0
- package/dist/visual/parse.d.ts.map +1 -0
- package/dist/visual/parse.js +330 -0
- package/dist/visual/parse.js.map +1 -0
- package/dist/visual/project.d.ts +40 -0
- package/dist/visual/project.d.ts.map +1 -0
- package/dist/visual/project.js +349 -0
- package/dist/visual/project.js.map +1 -0
- package/dist/visual/represent.d.ts +50 -0
- package/dist/visual/represent.d.ts.map +1 -0
- package/dist/visual/represent.js +66 -0
- package/dist/visual/represent.js.map +1 -0
- package/dist/visual/vocabulary.d.ts +121 -0
- package/dist/visual/vocabulary.d.ts.map +1 -0
- package/dist/visual/vocabulary.js +32 -0
- package/dist/visual/vocabulary.js.map +1 -0
- package/package.json +52 -3
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { SchemaDiagnostic, TranslationGap } from '@azx-pbc/axiom-compiler';
|
|
2
|
+
import type { Control, Primitive } from '@azx-pbc/axiom-runtime';
|
|
3
|
+
import type { AuthoringDocument } from '../schema/document.js';
|
|
4
|
+
import type { PublishedBaseline } from '../store/published.js';
|
|
5
|
+
/**
|
|
6
|
+
* The card projection an authoring UI renders.
|
|
7
|
+
*
|
|
8
|
+
* A card is one declaration as a list row: its identity, its label key, the control it offers,
|
|
9
|
+
* whether it is published and retired, the diagnostics that belong to it and the translations it
|
|
10
|
+
* is missing. The projection is pure — it reads the document, the baseline and a diagnostic list
|
|
11
|
+
* and returns plain data — so a host renders it in React, in a template language, or in a test
|
|
12
|
+
* without the store running.
|
|
13
|
+
*
|
|
14
|
+
* A diagnostic reaches its card by location. The compiler states a metaschema refusal's location
|
|
15
|
+
* as `instancePath`, and the semantic walkers state the same location as a rendered `path`; both
|
|
16
|
+
* spellings are read here, through the compiler's own path reader rather than a second reading of
|
|
17
|
+
* its notation, so a rule's expression error lands on the card of the field the rule targets and a
|
|
18
|
+
* message's locale gap lands on the card of the field whose label it is. A path the reader refuses
|
|
19
|
+
* names no card: an unmapped diagnostic is reported as unattached, which a caller sees, instead of
|
|
20
|
+
* a card selector failing a whole list or attaching the reason to a declaration it never named.
|
|
21
|
+
*
|
|
22
|
+
* `fieldCards` is one walk of the declarations to build the index below, then one pass over the
|
|
23
|
+
* diagnostics and one over the gaps: `O(F + D + G)`. Resolving each diagnostic on its own would
|
|
24
|
+
* re-walk the declaration tree per (card, diagnostic) pair — `O(F·D·F)` — which a form with a few
|
|
25
|
+
* hundred fields pays per keystroke, so the index is built once and shared by both projections.
|
|
26
|
+
*/
|
|
27
|
+
/** What a caller may supply that the document does not derive. */
|
|
28
|
+
export interface CardContext {
|
|
29
|
+
/** The published baseline, so a card states whether its declaration is immutable. */
|
|
30
|
+
readonly published?: PublishedBaseline;
|
|
31
|
+
/** The diagnostics to distribute; the store's `getState().diagnostics` is the source. */
|
|
32
|
+
readonly diagnostics?: readonly SchemaDiagnostic[];
|
|
33
|
+
}
|
|
34
|
+
/** One declaration as a card. */
|
|
35
|
+
export interface FieldCard {
|
|
36
|
+
readonly fieldId: string;
|
|
37
|
+
/** The message key the field's label renders from. */
|
|
38
|
+
readonly labelKey: string | undefined;
|
|
39
|
+
readonly primitive: Primitive;
|
|
40
|
+
readonly control: Control | undefined;
|
|
41
|
+
/** Whether the published baseline already carries this field. */
|
|
42
|
+
readonly published: boolean;
|
|
43
|
+
/** Whether the field is retired, `annotations.deprecated`. */
|
|
44
|
+
readonly deprecated: boolean;
|
|
45
|
+
/** Every diagnostic that belongs to this declaration, in the order it was reported. */
|
|
46
|
+
readonly diagnostics: readonly SchemaDiagnostic[];
|
|
47
|
+
/** Every declared locale one of this declaration's messages is missing. */
|
|
48
|
+
readonly translationGaps: readonly TranslationGap[];
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The card a diagnostic belongs to, or `undefined` when it belongs to none.
|
|
52
|
+
*
|
|
53
|
+
* A caller distributing one diagnostic asks this; a caller distributing a list asks `fieldCards`
|
|
54
|
+
* or `unattachedDiagnostics`, which build the declaration index once instead of per diagnostic.
|
|
55
|
+
*/
|
|
56
|
+
export declare function diagnosticCardField(document: AuthoringDocument, diagnostic: SchemaDiagnostic): string | undefined;
|
|
57
|
+
/** The diagnostics that belong to no declared field's card. */
|
|
58
|
+
export declare function unattachedDiagnostics(document: AuthoringDocument, diagnostics: readonly SchemaDiagnostic[]): readonly SchemaDiagnostic[];
|
|
59
|
+
/**
|
|
60
|
+
* One card per top-level declaration, in declaration order.
|
|
61
|
+
*
|
|
62
|
+
* A member lives inside its container's card rather than beside it: the container is what the
|
|
63
|
+
* layout places and what a UI renders as one repeating structure, and the diagnostics the
|
|
64
|
+
* compiler reports for a member are located under the container in the document, so a second
|
|
65
|
+
* card for the member would move a defect away from the declaration that owns it. A rule's
|
|
66
|
+
* message is the card's too, whichever member the rule names, because that is the card the rule's
|
|
67
|
+
* diagnostic is placed on.
|
|
68
|
+
*/
|
|
69
|
+
export declare function fieldCards(document: AuthoringDocument, context?: CardContext): readonly FieldCard[];
|
|
70
|
+
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/cards/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEhF,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEjE,OAAO,KAAK,EAAE,iBAAiB,EAAuC,MAAM,uBAAuB,CAAC;AAOpG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAI/D;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,kEAAkE;AAClE,MAAM,WAAW,WAAW;IAC1B,qFAAqF;IACrF,QAAQ,CAAC,SAAS,CAAC,EAAE,iBAAiB,CAAC;IACvC,yFAAyF;IACzF,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACpD;AAED,iCAAiC;AACjC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,iEAAiE;IACjE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,8DAA8D;IAC9D,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,uFAAuF;IACvF,QAAQ,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAClD,2EAA2E;IAC3E,QAAQ,CAAC,eAAe,EAAE,SAAS,cAAc,EAAE,CAAC;CACrD;AAmJD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,iBAAiB,EAC3B,UAAU,EAAE,gBAAgB,GAC3B,MAAM,GAAG,SAAS,CAEpB;AAED,+DAA+D;AAC/D,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,SAAS,gBAAgB,EAAE,GACvC,SAAS,gBAAgB,EAAE,CAK7B;AAkBD;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CACxB,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE,WAAgB,GACxB,SAAS,SAAS,EAAE,CAiBtB"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { parseDocumentPath } from '@azx-pbc/axiom-compiler';
|
|
2
|
+
import { isRecord } from '@azx-pbc/axiom-runtime';
|
|
3
|
+
import { authoredFields, fieldDeclarationMessageKeys, fieldMessageKey, optionMessageKey, } from '../schema/document.js';
|
|
4
|
+
import { publishedFields } from '../store/published.js';
|
|
5
|
+
import { translationGaps } from '../i18n/gaps.js';
|
|
6
|
+
/**
|
|
7
|
+
* Every message key one declaration states by its own members.
|
|
8
|
+
*
|
|
9
|
+
* This is the declaration half of the message-key index: label, description, placeholder, option
|
|
10
|
+
* labels, availability reasons and alternative labels. A member's keys are that member's own
|
|
11
|
+
* entry, not its container's, so the index
|
|
12
|
+
* that walks `authoredFields` reads each declaration once instead of re-walking every container's
|
|
13
|
+
* subtree. A rule's message is the other half, and `cardIndexOf` adds it for the card the rule
|
|
14
|
+
* names.
|
|
15
|
+
*/
|
|
16
|
+
function messageKeysOf(field, trail) {
|
|
17
|
+
const keys = [
|
|
18
|
+
fieldMessageKey(trail),
|
|
19
|
+
field.labelKey ?? '',
|
|
20
|
+
field.descriptionKey ?? '',
|
|
21
|
+
field.placeholderKey ?? '',
|
|
22
|
+
...fieldDeclarationMessageKeys(field),
|
|
23
|
+
];
|
|
24
|
+
for (const option of field.options ?? []) {
|
|
25
|
+
// An option is named by the key it states and by the key its code derives; both spellings
|
|
26
|
+
// resolve to the same card. Its availability reason and alternatives belong there too.
|
|
27
|
+
keys.push(option.labelKey, optionMessageKey(trail, option.code));
|
|
28
|
+
if (option.unavailableMessageKey !== undefined)
|
|
29
|
+
keys.push(option.unavailableMessageKey);
|
|
30
|
+
for (const suggestion of option.suggests ?? [])
|
|
31
|
+
keys.push(suggestion.labelKey);
|
|
32
|
+
}
|
|
33
|
+
return keys.filter((key) => key !== '');
|
|
34
|
+
}
|
|
35
|
+
function cardIndexOf(document) {
|
|
36
|
+
const topLevel = new Set(document.fields.map((field) => field.fieldId));
|
|
37
|
+
const cardOfFieldId = new Map();
|
|
38
|
+
const cardOfMessage = new Map();
|
|
39
|
+
for (const { field, trail } of authoredFields(document)) {
|
|
40
|
+
const outer = trail[0];
|
|
41
|
+
if (outer === undefined || !topLevel.has(outer))
|
|
42
|
+
continue;
|
|
43
|
+
if (!cardOfFieldId.has(field.fieldId))
|
|
44
|
+
cardOfFieldId.set(field.fieldId, outer);
|
|
45
|
+
for (const key of messageKeysOf(field, trail)) {
|
|
46
|
+
if (!cardOfMessage.has(key))
|
|
47
|
+
cardOfMessage.set(key, outer);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// A rule's own and alternatives' messages are its card's too: the card their diagnostics and
|
|
51
|
+
// translation gaps are placed on.
|
|
52
|
+
for (const rule of document.rules ?? []) {
|
|
53
|
+
const owner = cardOfFieldId.get(rule.fieldId ?? rule.targetFieldId ?? '');
|
|
54
|
+
if (owner === undefined)
|
|
55
|
+
continue;
|
|
56
|
+
const keys = [
|
|
57
|
+
rule.messageKey,
|
|
58
|
+
...(rule.suggests ?? []).map((suggestion) => suggestion.labelKey),
|
|
59
|
+
];
|
|
60
|
+
for (const key of keys) {
|
|
61
|
+
if (key !== undefined && !cardOfMessage.has(key))
|
|
62
|
+
cardOfMessage.set(key, owner);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return { cardOfFieldId, cardOfMessage };
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The layout node an index path reaches, narrowed to the record its members are read from.
|
|
69
|
+
*
|
|
70
|
+
* The compiler renders a node's child as `${node}.children[${index}]`, so `children` is the
|
|
71
|
+
* descent marker between a node and its child index rather than a step of its own: a path
|
|
72
|
+
* `$.layout[0].children[1]` names the second child of the first node. A diagnostic about a
|
|
73
|
+
* node's *member* (`$.layout[1].colSpan`) names the node first and the member after it, so the
|
|
74
|
+
* walk stops at the first non-index step once a node is reached: the card a layout refusal
|
|
75
|
+
* belongs to is the card of the field that node places.
|
|
76
|
+
*/
|
|
77
|
+
function layoutNodeAt(layout, path) {
|
|
78
|
+
let nodes = layout;
|
|
79
|
+
let found;
|
|
80
|
+
for (const step of path) {
|
|
81
|
+
if (step === 'children')
|
|
82
|
+
continue;
|
|
83
|
+
if (typeof step !== 'number')
|
|
84
|
+
return found;
|
|
85
|
+
const node = nodes[step];
|
|
86
|
+
if (node === undefined)
|
|
87
|
+
return undefined;
|
|
88
|
+
found = node;
|
|
89
|
+
const children = node['children'];
|
|
90
|
+
nodes = Array.isArray(children) ? children.filter(isRecord) : [];
|
|
91
|
+
}
|
|
92
|
+
return found;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The steps a diagnostic's location names, or `undefined` when it names none.
|
|
96
|
+
*
|
|
97
|
+
* `instancePath` is already the structured steps a metaschema walk resolved against the document,
|
|
98
|
+
* so it is read as it stands; a rendered `path` has to be read back through the notation's own
|
|
99
|
+
* parser, and a path that parser refuses is a location no card can be attached to.
|
|
100
|
+
*/
|
|
101
|
+
function locationOf(diagnostic) {
|
|
102
|
+
if (diagnostic.instancePath !== undefined)
|
|
103
|
+
return diagnostic.instancePath;
|
|
104
|
+
const read = parseDocumentPath(diagnostic.path);
|
|
105
|
+
return read.ok ? read.segments : undefined;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The card a diagnostic belongs to, or `undefined` when it belongs to none.
|
|
109
|
+
*
|
|
110
|
+
* A diagnostic about the document itself (`$.locales`, `$.schemaId`) belongs to no card: there is
|
|
111
|
+
* no declaration that owns it, and pretending one does would put a document-level repair on an
|
|
112
|
+
* author's field.
|
|
113
|
+
*/
|
|
114
|
+
function cardForDiagnostic(document, index, diagnostic) {
|
|
115
|
+
const segments = locationOf(diagnostic);
|
|
116
|
+
if (segments === undefined)
|
|
117
|
+
return undefined;
|
|
118
|
+
const [root, second] = segments;
|
|
119
|
+
if (root === 'fields' && typeof second === 'number') {
|
|
120
|
+
return document.fields[second]?.fieldId;
|
|
121
|
+
}
|
|
122
|
+
if (root === 'rules' && typeof second === 'number') {
|
|
123
|
+
const rule = document.rules?.[second];
|
|
124
|
+
if (rule === undefined)
|
|
125
|
+
return undefined;
|
|
126
|
+
return index.cardOfFieldId.get(rule.fieldId ?? rule.targetFieldId ?? '');
|
|
127
|
+
}
|
|
128
|
+
if (root === 'layout') {
|
|
129
|
+
const node = layoutNodeAt(document.layout, segments.slice(1));
|
|
130
|
+
const fieldId = node?.['fieldId'];
|
|
131
|
+
return typeof fieldId === 'string' ? index.cardOfFieldId.get(fieldId) : undefined;
|
|
132
|
+
}
|
|
133
|
+
if (root === 'messages') {
|
|
134
|
+
const key = typeof second === 'string' ? second : diagnostic.messageKey;
|
|
135
|
+
return key === undefined ? undefined : index.cardOfMessage.get(key);
|
|
136
|
+
}
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The card a diagnostic belongs to, or `undefined` when it belongs to none.
|
|
141
|
+
*
|
|
142
|
+
* A caller distributing one diagnostic asks this; a caller distributing a list asks `fieldCards`
|
|
143
|
+
* or `unattachedDiagnostics`, which build the declaration index once instead of per diagnostic.
|
|
144
|
+
*/
|
|
145
|
+
export function diagnosticCardField(document, diagnostic) {
|
|
146
|
+
return cardForDiagnostic(document, cardIndexOf(document), diagnostic);
|
|
147
|
+
}
|
|
148
|
+
/** The diagnostics that belong to no declared field's card. */
|
|
149
|
+
export function unattachedDiagnostics(document, diagnostics) {
|
|
150
|
+
const index = cardIndexOf(document);
|
|
151
|
+
return diagnostics.filter((diagnostic) => cardForDiagnostic(document, index, diagnostic) === undefined);
|
|
152
|
+
}
|
|
153
|
+
/** The diagnostics and gaps of one card, grouped by the card that owns them. */
|
|
154
|
+
function grouped(items, cardOf) {
|
|
155
|
+
const grouped = new Map();
|
|
156
|
+
for (const item of items) {
|
|
157
|
+
const card = cardOf(item);
|
|
158
|
+
if (card === undefined)
|
|
159
|
+
continue;
|
|
160
|
+
const held = grouped.get(card);
|
|
161
|
+
if (held === undefined)
|
|
162
|
+
grouped.set(card, [item]);
|
|
163
|
+
else
|
|
164
|
+
held.push(item);
|
|
165
|
+
}
|
|
166
|
+
return grouped;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* One card per top-level declaration, in declaration order.
|
|
170
|
+
*
|
|
171
|
+
* A member lives inside its container's card rather than beside it: the container is what the
|
|
172
|
+
* layout places and what a UI renders as one repeating structure, and the diagnostics the
|
|
173
|
+
* compiler reports for a member are located under the container in the document, so a second
|
|
174
|
+
* card for the member would move a defect away from the declaration that owns it. A rule's
|
|
175
|
+
* message is the card's too, whichever member the rule names, because that is the card the rule's
|
|
176
|
+
* diagnostic is placed on.
|
|
177
|
+
*/
|
|
178
|
+
export function fieldCards(document, context = {}) {
|
|
179
|
+
const index = cardIndexOf(document);
|
|
180
|
+
const published = publishedFields(document, context.published);
|
|
181
|
+
const diagnostics = grouped(context.diagnostics ?? [], (diagnostic) => cardForDiagnostic(document, index, diagnostic));
|
|
182
|
+
const gaps = grouped(translationGaps(document), (gap) => index.cardOfMessage.get(gap.messageKey));
|
|
183
|
+
return document.fields.map((field) => ({
|
|
184
|
+
fieldId: field.fieldId,
|
|
185
|
+
labelKey: field.labelKey,
|
|
186
|
+
primitive: field.primitive,
|
|
187
|
+
control: field.control,
|
|
188
|
+
published: published.has(field.fieldId),
|
|
189
|
+
deprecated: field.annotations?.['deprecated'] === true,
|
|
190
|
+
diagnostics: diagnostics.get(field.fieldId) ?? [],
|
|
191
|
+
translationGaps: gaps.get(field.fieldId) ?? [],
|
|
192
|
+
}));
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=selectors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectors.js","sourceRoot":"","sources":["../../src/cards/selectors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EACL,cAAc,EACd,2BAA2B,EAC3B,eAAe,EACf,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAkDlD;;;;;;;;;GASG;AACH,SAAS,aAAa,CAAC,KAAqB,EAAE,KAAwB;IACpE,MAAM,IAAI,GAAG;QACX,eAAe,CAAC,KAAK,CAAC;QACtB,KAAK,CAAC,QAAQ,IAAI,EAAE;QACpB,KAAK,CAAC,cAAc,IAAI,EAAE;QAC1B,KAAK,CAAC,cAAc,IAAI,EAAE;QAC1B,GAAG,2BAA2B,CAAC,KAAK,CAAC;KACtC,CAAC;IACF,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;QACzC,0FAA0F;QAC1F,uFAAuF;QACvF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACjE,IAAI,MAAM,CAAC,qBAAqB,KAAK,SAAS;Y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CAAC,KAAK,IAAI;QACtD,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;QACjD,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;KAC/C,CAAC,CAAC,CAAC;AACN,CAAC","sourcesContent":["import type { SchemaDiagnostic, TranslationGap } from '@azx-pbc/axiom-compiler';\nimport { parseDocumentPath } from '@azx-pbc/axiom-compiler';\nimport type { Control, Primitive } from '@azx-pbc/axiom-runtime';\nimport { isRecord } from '@azx-pbc/axiom-runtime';\nimport type { AuthoringDocument, AuthoringField, AuthoringLayoutNode } from '../schema/document.js';\nimport {\n authoredFields,\n fieldDeclarationMessageKeys,\n fieldMessageKey,\n optionMessageKey,\n} from '../schema/document.js';\nimport type { PublishedBaseline } from '../store/published.js';\nimport { publishedFields } from '../store/published.js';\nimport { translationGaps } from '../i18n/gaps.js';\n\n/**\n * The card projection an authoring UI renders.\n *\n * A card is one declaration as a list row: its identity, its label key, the control it offers,\n * whether it is published and retired, the diagnostics that belong to it and the translations it\n * is missing. The projection is pure — it reads the document, the baseline and a diagnostic list\n * and returns plain data — so a host renders it in React, in a template language, or in a test\n * without the store running.\n *\n * A diagnostic reaches its card by location. The compiler states a metaschema refusal's location\n * as `instancePath`, and the semantic walkers state the same location as a rendered `path`; both\n * spellings are read here, through the compiler's own path reader rather than a second reading of\n * its notation, so a rule's expression error lands on the card of the field the rule targets and a\n * message's locale gap lands on the card of the field whose label it is. A path the reader refuses\n * names no card: an unmapped diagnostic is reported as unattached, which a caller sees, instead of\n * a card selector failing a whole list or attaching the reason to a declaration it never named.\n *\n * `fieldCards` is one walk of the declarations to build the index below, then one pass over the\n * diagnostics and one over the gaps: `O(F + D + G)`. Resolving each diagnostic on its own would\n * re-walk the declaration tree per (card, diagnostic) pair — `O(F·D·F)` — which a form with a few\n * hundred fields pays per keystroke, so the index is built once and shared by both projections.\n */\n\n/** What a caller may supply that the document does not derive. */\nexport interface CardContext {\n /** The published baseline, so a card states whether its declaration is immutable. */\n readonly published?: PublishedBaseline;\n /** The diagnostics to distribute; the store's `getState().diagnostics` is the source. */\n readonly diagnostics?: readonly SchemaDiagnostic[];\n}\n\n/** One declaration as a card. */\nexport interface FieldCard {\n readonly fieldId: string;\n /** The message key the field's label renders from. */\n readonly labelKey: string | undefined;\n readonly primitive: Primitive;\n readonly control: Control | undefined;\n /** Whether the published baseline already carries this field. */\n readonly published: boolean;\n /** Whether the field is retired, `annotations.deprecated`. */\n readonly deprecated: boolean;\n /** Every diagnostic that belongs to this declaration, in the order it was reported. */\n readonly diagnostics: readonly SchemaDiagnostic[];\n /** Every declared locale one of this declaration's messages is missing. */\n readonly translationGaps: readonly TranslationGap[];\n}\n\n/**\n * Every message key one declaration states by its own members.\n *\n * This is the declaration half of the message-key index: label, description, placeholder, option\n * labels, availability reasons and alternative labels. A member's keys are that member's own\n * entry, not its container's, so the index\n * that walks `authoredFields` reads each declaration once instead of re-walking every container's\n * subtree. A rule's message is the other half, and `cardIndexOf` adds it for the card the rule\n * names.\n */\nfunction messageKeysOf(field: AuthoringField, trail: readonly string[]): readonly string[] {\n const keys = [\n fieldMessageKey(trail),\n field.labelKey ?? '',\n field.descriptionKey ?? '',\n field.placeholderKey ?? '',\n ...fieldDeclarationMessageKeys(field),\n ];\n for (const option of field.options ?? []) {\n // An option is named by the key it states and by the key its code derives; both spellings\n // resolve to the same card. Its availability reason and alternatives belong there too.\n keys.push(option.labelKey, optionMessageKey(trail, option.code));\n if (option.unavailableMessageKey !== undefined) keys.push(option.unavailableMessageKey);\n for (const suggestion of option.suggests ?? []) keys.push(suggestion.labelKey);\n }\n return keys.filter((key) => key !== '');\n}\n\n/**\n * The two lookups a diagnostic or a gap resolves through, built once per projection.\n *\n * `cardOfFieldId` answers \"which card owns this declaration\" for every id at any nesting level,\n * and `cardOfMessage` answers \"which card owns this message key\" for every key a declaration or a\n * rule names. The first owner in declaration order wins, which is the order the projection\n * reports, so a key stated twice lands on the card a reader sees first.\n */\ninterface CardIndex {\n readonly cardOfFieldId: ReadonlyMap<string, string>;\n readonly cardOfMessage: ReadonlyMap<string, string>;\n}\n\nfunction cardIndexOf(document: AuthoringDocument): CardIndex {\n const topLevel = new Set(document.fields.map((field) => field.fieldId));\n const cardOfFieldId = new Map<string, string>();\n const cardOfMessage = new Map<string, string>();\n for (const { field, trail } of authoredFields(document)) {\n const outer = trail[0];\n if (outer === undefined || !topLevel.has(outer)) continue;\n if (!cardOfFieldId.has(field.fieldId)) cardOfFieldId.set(field.fieldId, outer);\n for (const key of messageKeysOf(field, trail)) {\n if (!cardOfMessage.has(key)) cardOfMessage.set(key, outer);\n }\n }\n // A rule's own and alternatives' messages are its card's too: the card their diagnostics and\n // translation gaps are placed on.\n for (const rule of document.rules ?? []) {\n const owner = cardOfFieldId.get(rule.fieldId ?? rule.targetFieldId ?? '');\n if (owner === undefined) continue;\n const keys = [\n rule.messageKey,\n ...(rule.suggests ?? []).map((suggestion) => suggestion.labelKey),\n ];\n for (const key of keys) {\n if (key !== undefined && !cardOfMessage.has(key)) cardOfMessage.set(key, owner);\n }\n }\n return { cardOfFieldId, cardOfMessage };\n}\n\n/**\n * The layout node an index path reaches, narrowed to the record its members are read from.\n *\n * The compiler renders a node's child as `${node}.children[${index}]`, so `children` is the\n * descent marker between a node and its child index rather than a step of its own: a path\n * `$.layout[0].children[1]` names the second child of the first node. A diagnostic about a\n * node's *member* (`$.layout[1].colSpan`) names the node first and the member after it, so the\n * walk stops at the first non-index step once a node is reached: the card a layout refusal\n * belongs to is the card of the field that node places.\n */\nfunction layoutNodeAt(\n layout: readonly AuthoringLayoutNode[],\n path: readonly (string | number)[],\n): AuthoringLayoutNode | undefined {\n let nodes = layout;\n let found: AuthoringLayoutNode | undefined;\n for (const step of path) {\n if (step === 'children') continue;\n if (typeof step !== 'number') return found;\n const node = nodes[step];\n if (node === undefined) return undefined;\n found = node;\n const children = node['children'];\n nodes = Array.isArray(children) ? children.filter(isRecord) : [];\n }\n return found;\n}\n\n/**\n * The steps a diagnostic's location names, or `undefined` when it names none.\n *\n * `instancePath` is already the structured steps a metaschema walk resolved against the document,\n * so it is read as it stands; a rendered `path` has to be read back through the notation's own\n * parser, and a path that parser refuses is a location no card can be attached to.\n */\nfunction locationOf(diagnostic: SchemaDiagnostic): readonly (string | number)[] | undefined {\n if (diagnostic.instancePath !== undefined) return diagnostic.instancePath;\n const read = parseDocumentPath(diagnostic.path);\n return read.ok ? read.segments : undefined;\n}\n\n/**\n * The card a diagnostic belongs to, or `undefined` when it belongs to none.\n *\n * A diagnostic about the document itself (`$.locales`, `$.schemaId`) belongs to no card: there is\n * no declaration that owns it, and pretending one does would put a document-level repair on an\n * author's field.\n */\nfunction cardForDiagnostic(\n document: AuthoringDocument,\n index: CardIndex,\n diagnostic: SchemaDiagnostic,\n): string | undefined {\n const segments = locationOf(diagnostic);\n if (segments === undefined) return undefined;\n const [root, second] = segments;\n if (root === 'fields' && typeof second === 'number') {\n return document.fields[second]?.fieldId;\n }\n if (root === 'rules' && typeof second === 'number') {\n const rule = document.rules?.[second];\n if (rule === undefined) return undefined;\n return index.cardOfFieldId.get(rule.fieldId ?? rule.targetFieldId ?? '');\n }\n if (root === 'layout') {\n const node = layoutNodeAt(document.layout, segments.slice(1));\n const fieldId = node?.['fieldId'];\n return typeof fieldId === 'string' ? index.cardOfFieldId.get(fieldId) : undefined;\n }\n if (root === 'messages') {\n const key = typeof second === 'string' ? second : diagnostic.messageKey;\n return key === undefined ? undefined : index.cardOfMessage.get(key);\n }\n return undefined;\n}\n\n/**\n * The card a diagnostic belongs to, or `undefined` when it belongs to none.\n *\n * A caller distributing one diagnostic asks this; a caller distributing a list asks `fieldCards`\n * or `unattachedDiagnostics`, which build the declaration index once instead of per diagnostic.\n */\nexport function diagnosticCardField(\n document: AuthoringDocument,\n diagnostic: SchemaDiagnostic,\n): string | undefined {\n return cardForDiagnostic(document, cardIndexOf(document), diagnostic);\n}\n\n/** The diagnostics that belong to no declared field's card. */\nexport function unattachedDiagnostics(\n document: AuthoringDocument,\n diagnostics: readonly SchemaDiagnostic[],\n): readonly SchemaDiagnostic[] {\n const index = cardIndexOf(document);\n return diagnostics.filter(\n (diagnostic) => cardForDiagnostic(document, index, diagnostic) === undefined,\n );\n}\n\n/** The diagnostics and gaps of one card, grouped by the card that owns them. */\nfunction grouped<T>(\n items: readonly T[],\n cardOf: (item: T) => string | undefined,\n): ReadonlyMap<string, T[]> {\n const grouped = new Map<string, T[]>();\n for (const item of items) {\n const card = cardOf(item);\n if (card === undefined) continue;\n const held = grouped.get(card);\n if (held === undefined) grouped.set(card, [item]);\n else held.push(item);\n }\n return grouped;\n}\n\n/**\n * One card per top-level declaration, in declaration order.\n *\n * A member lives inside its container's card rather than beside it: the container is what the\n * layout places and what a UI renders as one repeating structure, and the diagnostics the\n * compiler reports for a member are located under the container in the document, so a second\n * card for the member would move a defect away from the declaration that owns it. A rule's\n * message is the card's too, whichever member the rule names, because that is the card the rule's\n * diagnostic is placed on.\n */\nexport function fieldCards(\n document: AuthoringDocument,\n context: CardContext = {},\n): readonly FieldCard[] {\n const index = cardIndexOf(document);\n const published = publishedFields(document, context.published);\n const diagnostics = grouped(context.diagnostics ?? [], (diagnostic) =>\n cardForDiagnostic(document, index, diagnostic),\n );\n const gaps = grouped(translationGaps(document), (gap) => index.cardOfMessage.get(gap.messageKey));\n return document.fields.map((field) => ({\n fieldId: field.fieldId,\n labelKey: field.labelKey,\n primitive: field.primitive,\n control: field.control,\n published: published.has(field.fieldId),\n deprecated: field.annotations?.['deprecated'] === true,\n diagnostics: diagnostics.get(field.fieldId) ?? [],\n translationGaps: gaps.get(field.fieldId) ?? [],\n }));\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { CompileOptions, SchemaDiagnostic } from '@azx-pbc/axiom-compiler';
|
|
2
|
+
import type { ShapeOfDocument, TypedArtifact } from '@azx-pbc/axiom-runtime';
|
|
3
|
+
import type { AuthoringDocument } from './schema/document.js';
|
|
4
|
+
/**
|
|
5
|
+
* One document authored in source, compiled at the definition and remembered in the type.
|
|
6
|
+
*
|
|
7
|
+
* `defineDocument` is the typed front door to an authored literal. The artifact it returns is the
|
|
8
|
+
* compiler's own `CompiledSchema` — the value a `FormProvider` already takes — and the literal's
|
|
9
|
+
* shape rides beside it in the type: the declared field ids, each field's row-key requirement,
|
|
10
|
+
* the record's member types where the primitive makes them knowable, and the declared rule ids.
|
|
11
|
+
* `@azx-pbc/axiom-react`'s typed hooks read that shape, so `useField(def, 'f_total')` names a
|
|
12
|
+
* declared id and a row key is stated only where the declaration holds rows.
|
|
13
|
+
*
|
|
14
|
+
* The document literal is read through the same canonical restricted-JSON text the CLI and the
|
|
15
|
+
* compiler's other doors read, so a definition is held to the closed contract exactly as a stored
|
|
16
|
+
* document is. A refusal is thrown rather than returned: the value is authored in source, the
|
|
17
|
+
* module cannot stand without it, and a build that silently carried on would defer the failure to
|
|
18
|
+
* the first render. Every diagnostic stays attached, so a bundler or test reports the document
|
|
19
|
+
* path and the repair as the compiler stated them.
|
|
20
|
+
*/
|
|
21
|
+
export declare class DefinitionError extends Error {
|
|
22
|
+
/** The document's `schemaId`, so a refusal names the definition that failed. */
|
|
23
|
+
readonly schemaId: string;
|
|
24
|
+
/** Every reason the document did not compile, in the compiler's own order. */
|
|
25
|
+
readonly diagnostics: readonly SchemaDiagnostic[];
|
|
26
|
+
constructor(schemaId: string, diagnostics: readonly SchemaDiagnostic[]);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Compiles one authored document literal and returns the artifact its typed bindings read.
|
|
30
|
+
*
|
|
31
|
+
* The `const` type parameter is what keeps the literal: without it the field ids would widen to
|
|
32
|
+
* `string` and the artifact would carry no shape worth having. State the document inline, or
|
|
33
|
+
* declare it `as const`, and the returned value narrows every binding to the declarations below.
|
|
34
|
+
*/
|
|
35
|
+
export declare function defineDocument<const Document extends AuthoringDocument>(document: Document, options?: CompileOptions): TypedArtifact<ShapeOfDocument<Document>>;
|
|
36
|
+
//# sourceMappingURL=definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.d.ts","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,gFAAgF;IAChF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,8EAA8E;IAC9E,QAAQ,CAAC,WAAW,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAElD,YAAY,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,gBAAgB,EAAE,EAUrE;CACF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,QAAQ,SAAS,iBAAiB,EACrE,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,cAAmB,GAC3B,aAAa,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAI1C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { compile } from '@azx-pbc/axiom-compiler';
|
|
2
|
+
import { serializeDocument } from './schema/document.js';
|
|
3
|
+
/**
|
|
4
|
+
* One document authored in source, compiled at the definition and remembered in the type.
|
|
5
|
+
*
|
|
6
|
+
* `defineDocument` is the typed front door to an authored literal. The artifact it returns is the
|
|
7
|
+
* compiler's own `CompiledSchema` — the value a `FormProvider` already takes — and the literal's
|
|
8
|
+
* shape rides beside it in the type: the declared field ids, each field's row-key requirement,
|
|
9
|
+
* the record's member types where the primitive makes them knowable, and the declared rule ids.
|
|
10
|
+
* `@azx-pbc/axiom-react`'s typed hooks read that shape, so `useField(def, 'f_total')` names a
|
|
11
|
+
* declared id and a row key is stated only where the declaration holds rows.
|
|
12
|
+
*
|
|
13
|
+
* The document literal is read through the same canonical restricted-JSON text the CLI and the
|
|
14
|
+
* compiler's other doors read, so a definition is held to the closed contract exactly as a stored
|
|
15
|
+
* document is. A refusal is thrown rather than returned: the value is authored in source, the
|
|
16
|
+
* module cannot stand without it, and a build that silently carried on would defer the failure to
|
|
17
|
+
* the first render. Every diagnostic stays attached, so a bundler or test reports the document
|
|
18
|
+
* path and the repair as the compiler stated them.
|
|
19
|
+
*/
|
|
20
|
+
export class DefinitionError extends Error {
|
|
21
|
+
/** The document's `schemaId`, so a refusal names the definition that failed. */
|
|
22
|
+
schemaId;
|
|
23
|
+
/** Every reason the document did not compile, in the compiler's own order. */
|
|
24
|
+
diagnostics;
|
|
25
|
+
constructor(schemaId, diagnostics) {
|
|
26
|
+
const first = diagnostics[0];
|
|
27
|
+
super(first === undefined
|
|
28
|
+
? `schema \`${schemaId}\` did not compile`
|
|
29
|
+
: `schema \`${schemaId}\` did not compile: ${first.code} at ${first.path}: ${first.detail}`);
|
|
30
|
+
this.name = 'DefinitionError';
|
|
31
|
+
this.schemaId = schemaId;
|
|
32
|
+
this.diagnostics = diagnostics;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Compiles one authored document literal and returns the artifact its typed bindings read.
|
|
37
|
+
*
|
|
38
|
+
* The `const` type parameter is what keeps the literal: without it the field ids would widen to
|
|
39
|
+
* `string` and the artifact would carry no shape worth having. State the document inline, or
|
|
40
|
+
* declare it `as const`, and the returned value narrows every binding to the declarations below.
|
|
41
|
+
*/
|
|
42
|
+
export function defineDocument(document, options = {}) {
|
|
43
|
+
const result = compile(serializeDocument(document), options);
|
|
44
|
+
if (!result.ok)
|
|
45
|
+
throw new DefinitionError(document.schemaId, result.diagnostics);
|
|
46
|
+
return result.schema;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"definition.js","sourceRoot":"","sources":["../src/definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGlD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,gFAAgF;IACvE,QAAQ,CAAS;IAC1B,8EAA8E;IACrE,WAAW,CAA8B;IAElD,YAAY,QAAgB,EAAE,WAAwC;QACpE,MAAM,KAAK,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAC7B,KAAK,CACH,KAAK,KAAK,SAAS;YACjB,CAAC,CAAC,YAAY,QAAQ,oBAAoB;YAC1C,CAAC,CAAC,YAAY,QAAQ,uBAAuB,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,MAAM,EAAE,CAC9F,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAC5B,QAAkB,EAClB,OAAO,GAAmB,EAAE;IAE5B,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7D,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,MAAM,IAAI,eAAe,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACjF,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC","sourcesContent":["import { compile } from '@azx-pbc/axiom-compiler';\nimport type { CompileOptions, SchemaDiagnostic } from '@azx-pbc/axiom-compiler';\nimport type { ShapeOfDocument, TypedArtifact } from '@azx-pbc/axiom-runtime';\nimport { serializeDocument } from './schema/document.js';\nimport type { AuthoringDocument } from './schema/document.js';\n\n/**\n * One document authored in source, compiled at the definition and remembered in the type.\n *\n * `defineDocument` is the typed front door to an authored literal. The artifact it returns is the\n * compiler's own `CompiledSchema` — the value a `FormProvider` already takes — and the literal's\n * shape rides beside it in the type: the declared field ids, each field's row-key requirement,\n * the record's member types where the primitive makes them knowable, and the declared rule ids.\n * `@azx-pbc/axiom-react`'s typed hooks read that shape, so `useField(def, 'f_total')` names a\n * declared id and a row key is stated only where the declaration holds rows.\n *\n * The document literal is read through the same canonical restricted-JSON text the CLI and the\n * compiler's other doors read, so a definition is held to the closed contract exactly as a stored\n * document is. A refusal is thrown rather than returned: the value is authored in source, the\n * module cannot stand without it, and a build that silently carried on would defer the failure to\n * the first render. Every diagnostic stays attached, so a bundler or test reports the document\n * path and the repair as the compiler stated them.\n */\nexport class DefinitionError extends Error {\n /** The document's `schemaId`, so a refusal names the definition that failed. */\n readonly schemaId: string;\n /** Every reason the document did not compile, in the compiler's own order. */\n readonly diagnostics: readonly SchemaDiagnostic[];\n\n constructor(schemaId: string, diagnostics: readonly SchemaDiagnostic[]) {\n const first = diagnostics[0];\n super(\n first === undefined\n ? `schema \\`${schemaId}\\` did not compile`\n : `schema \\`${schemaId}\\` did not compile: ${first.code} at ${first.path}: ${first.detail}`,\n );\n this.name = 'DefinitionError';\n this.schemaId = schemaId;\n this.diagnostics = diagnostics;\n }\n}\n\n/**\n * Compiles one authored document literal and returns the artifact its typed bindings read.\n *\n * The `const` type parameter is what keeps the literal: without it the field ids would widen to\n * `string` and the artifact would carry no shape worth having. State the document inline, or\n * declare it `as const`, and the returned value narrows every binding to the declarations below.\n */\nexport function defineDocument<const Document extends AuthoringDocument>(\n document: Document,\n options: CompileOptions = {},\n): TypedArtifact<ShapeOfDocument<Document>> {\n const result = compile(serializeDocument(document), options);\n if (!result.ok) throw new DefinitionError(document.schemaId, result.diagnostics);\n return result.schema;\n}\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CompiledRule, CompiledSchema, WireValue } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
/**
|
|
3
|
+
* Deriving the case a declared gap is asking for.
|
|
4
|
+
*
|
|
5
|
+
* A repair is only evidence if the case it writes holds. An embedded case is a record of values
|
|
6
|
+
* plus the outcome the artifact decides for them, so both members have to come from the artifact:
|
|
7
|
+
* the values from a search over the fields the rule reads, and the expectation from evaluating
|
|
8
|
+
* those values and reading the rule's own result back. This module is that derivation, kept
|
|
9
|
+
* apart from the sentence a repair states so a host can prove the search directly.
|
|
10
|
+
*
|
|
11
|
+
* The search is bounded on purpose. A rule can name context, a table or a capability that a
|
|
12
|
+
* record cannot carry in `values`; a large rule can read more fields than a synchronously
|
|
13
|
+
* requested repair can vary. Both are reported as the reason no case was written rather than
|
|
14
|
+
* papered over with an expectation the rule never reaches — the author is told the check cannot
|
|
15
|
+
* be proved by a test instead of being handed a button that cannot succeed.
|
|
16
|
+
*/
|
|
17
|
+
/** The two branches publishing asks a rule's own evidence to prove. */
|
|
18
|
+
export type EvidenceBranch = 'firing' | 'non_firing';
|
|
19
|
+
/** The values one embedded case submits, keyed by top-level field id. */
|
|
20
|
+
type CaseValues = Readonly<Record<string, WireValue>>;
|
|
21
|
+
/** One case the repair can write: complete, runnable and expected to hold. */
|
|
22
|
+
interface SynthesizedCase {
|
|
23
|
+
readonly caseId: string;
|
|
24
|
+
/** What the rule decides for `values`, read back from an evaluation of the artifact. */
|
|
25
|
+
readonly expected: WireValue;
|
|
26
|
+
readonly values: CaseValues;
|
|
27
|
+
}
|
|
28
|
+
/** The case for one branch, or the reason no case writes that branch. */
|
|
29
|
+
export type CaseSearch = {
|
|
30
|
+
readonly ok: true;
|
|
31
|
+
readonly testCase: SynthesizedCase;
|
|
32
|
+
} | {
|
|
33
|
+
readonly ok: false;
|
|
34
|
+
readonly reason: string;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* The case that proves one branch of one rule, or the reason no case does.
|
|
38
|
+
*
|
|
39
|
+
* `caseId` is the caller's: an authoring document identifies one vector by it, and the repair
|
|
40
|
+
* walk owns the naming so a second click cannot mint a second id for the same branch.
|
|
41
|
+
*/
|
|
42
|
+
export declare function synthesizeRuleCase(schema: CompiledSchema, rule: CompiledRule, branch: EvidenceBranch, caseId: string): CaseSearch;
|
|
43
|
+
export {};
|
|
44
|
+
//# sourceMappingURL=cases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cases.d.ts","sourceRoot":"","sources":["../../src/evidence/cases.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAEV,YAAY,EACZ,cAAc,EAGd,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;;;;GAcG;AAEH,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,YAAY,CAAC;AAErD,yEAAyE;AACzE,KAAK,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AAEtD,8EAA8E;AAC9E,UAAU,eAAe;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wFAAwF;IACxF,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B;AAED,yEAAyE;AACzE,MAAM,MAAM,UAAU,GAClB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAA;CAAE,GACzD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AA+kBpD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,cAAc,EACtB,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,MAAM,GACb,UAAU,CA0BZ"}
|