@azx-pbc/axiom-builder 0.0.0-stage → 0.0.6
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,175 @@
|
|
|
1
|
+
import type { DatasetDiagnostic, SchemaDiagnostic } from '@azx-pbc/axiom-compiler';
|
|
2
|
+
/**
|
|
3
|
+
* The closed set of reasons an authoring store refuses a change.
|
|
4
|
+
*
|
|
5
|
+
* A refusal is not a diagnostic: a diagnostic says what is wrong with a document a caller may
|
|
6
|
+
* still hold, and a refusal says the store declined to produce one at all. The distinction is
|
|
7
|
+
* the ticket's hard/soft line — a hard refusal commits nothing, so the document and the undo
|
|
8
|
+
* chain are untouched.
|
|
9
|
+
*
|
|
10
|
+
* Every code is switched exhaustively by `repairFor`, so a new refusal cannot ship without a
|
|
11
|
+
* stated repair and a README line beside the others.
|
|
12
|
+
*/
|
|
13
|
+
export type AuthoringRefusalCode =
|
|
14
|
+
/** The command is not one the store states: a missing member, a wrong type, an unknown member. */
|
|
15
|
+
'MALFORMED_COMMAND'
|
|
16
|
+
/** The command names a field the document does not declare. */
|
|
17
|
+
| 'UNKNOWN_FIELD'
|
|
18
|
+
/** The command names an option code the field's domain does not declare. */
|
|
19
|
+
| 'UNKNOWN_OPTION'
|
|
20
|
+
/**
|
|
21
|
+
* A control that offers a declared domain — a chooser, a rating, a Likert scale — states
|
|
22
|
+
* neither `options` nor `optionSource`, so there is nothing for the control to offer.
|
|
23
|
+
*/
|
|
24
|
+
| 'MISSING_OPTION_DOMAIN'
|
|
25
|
+
/** The command names a message key no declaration, rule or layout node of the draft states. */
|
|
26
|
+
| 'UNKNOWN_MESSAGE'
|
|
27
|
+
/**
|
|
28
|
+
* The text is filed under a locale the document's catalogue does not own: not one of `locales`,
|
|
29
|
+
* and not a locale of any entry it already states.
|
|
30
|
+
*/
|
|
31
|
+
| 'UNDECLARED_LOCALE'
|
|
32
|
+
/** The command names a rule the document does not declare. */
|
|
33
|
+
| 'UNKNOWN_RULE'
|
|
34
|
+
/** The command names a `gate` rule the document does not declare as that kind. */
|
|
35
|
+
| 'UNKNOWN_GATE'
|
|
36
|
+
/** The command names a `screen` rule the document does not declare as that kind. */
|
|
37
|
+
| 'UNKNOWN_SCREEN'
|
|
38
|
+
/** The command names a table id the document does not pin. */
|
|
39
|
+
| 'UNKNOWN_DATASET'
|
|
40
|
+
/** The command names a context root the document does not declare. */
|
|
41
|
+
| 'UNKNOWN_CONTEXT_ROOT'
|
|
42
|
+
/**
|
|
43
|
+
* The expression cannot be stored as stated: a visual form this draft does not read back at the
|
|
44
|
+
* rule's scope, or a tree the printer has no canonical source for.
|
|
45
|
+
*/
|
|
46
|
+
| 'UNREPRESENTABLE_EXPRESSION'
|
|
47
|
+
/** A field id, rule id, step id, layout placement or minted message key is already taken. */
|
|
48
|
+
| 'DUPLICATE_ID'
|
|
49
|
+
/** The change would rewrite a declaration that is already published. */
|
|
50
|
+
| 'PUBLISHED_FIELD'
|
|
51
|
+
/** The field or option is already deprecated, so there is nothing left to retire. */
|
|
52
|
+
| 'ALREADY_DEPRECATED'
|
|
53
|
+
/** The layout path names no node in the document's layout tree. */
|
|
54
|
+
| 'UNKNOWN_LAYOUT'
|
|
55
|
+
/** The candidate is not a document the compiler's structural stage admits. */
|
|
56
|
+
| 'INVALID_STRUCTURE'
|
|
57
|
+
/** The structural stage refused a member the node does not declare, `unevaluatedProperties`. */
|
|
58
|
+
| 'UNKNOWN_PROPERTY'
|
|
59
|
+
/** C11: `visibleWhen` may reach only a section, chrome or an instruction-only step. */
|
|
60
|
+
| 'C11_VIOLATION'
|
|
61
|
+
/** The layout grammar refuses this containment, member or reference. */
|
|
62
|
+
| 'INVALID_LAYOUT'
|
|
63
|
+
/** A field's `colSpan` is wider than the columns its layout parent lays out. */
|
|
64
|
+
| 'COLUMN_OVERFLOW'
|
|
65
|
+
/**
|
|
66
|
+
* A dataset command names another table than the store holds. A Studio with several tables open
|
|
67
|
+
* can dispatch a command against the wrong one, and the store states that rather than rewriting
|
|
68
|
+
* the table it was handed.
|
|
69
|
+
*/
|
|
70
|
+
| 'UNKNOWN_TABLE'
|
|
71
|
+
/** A dataset command names a `rowId` the table does not hold. */
|
|
72
|
+
| 'UNKNOWN_ROW'
|
|
73
|
+
/** A dataset command names a `columnId` the table does not declare. */
|
|
74
|
+
| 'UNKNOWN_COLUMN'
|
|
75
|
+
/** A cell is not the canonical spelling its declared column's primitive requires. */
|
|
76
|
+
| 'INVALID_CELL'
|
|
77
|
+
/** The key a row would carry equals another row's, under a `UNIQUE` table. */
|
|
78
|
+
| 'DUPLICATE_KEY'
|
|
79
|
+
/** A row's members do not fit the table's kind: a lookup row's `outcome`, a PASS row's output. */
|
|
80
|
+
| 'INVALID_ROW'
|
|
81
|
+
/** The declared columns are not a column set the table's rows can be addressed by. */
|
|
82
|
+
| 'INVALID_COLUMNS'
|
|
83
|
+
/** An edit a table's `kind` or `binding` does not admit, or an effective range that is empty. */
|
|
84
|
+
| 'INVALID_TABLE'
|
|
85
|
+
/**
|
|
86
|
+
* The document the store holds no longer answers the pin the schema states: another version,
|
|
87
|
+
* another digest, or another table. Publishing it would claim the pinned bytes for rows that
|
|
88
|
+
* are not them (`DATA-1.1.2`, `DATA-4.1.6`).
|
|
89
|
+
*/
|
|
90
|
+
| 'DATASET_PIN_MISMATCH'
|
|
91
|
+
/**
|
|
92
|
+
* The pasted document states an older edition than the host published. An edition only moves
|
|
93
|
+
* forward, so the paste is refused instead of opening the draft behind its published revision.
|
|
94
|
+
*/
|
|
95
|
+
| 'STALE_EDITION';
|
|
96
|
+
/**
|
|
97
|
+
* Every reason an authoring store refuses a change, as the tuple a caller names each by.
|
|
98
|
+
*
|
|
99
|
+
* The annotation refuses a name the union does not state, and the repair table below is typed
|
|
100
|
+
* `Record<AuthoringRefusalCode, string>`, so a union member with no row fails typecheck. The two
|
|
101
|
+
* therefore cannot drift, and a gate reads the codes without reaching the table.
|
|
102
|
+
*/
|
|
103
|
+
export declare const AUTHORING_REFUSAL_CODES: readonly AuthoringRefusalCode[];
|
|
104
|
+
/** One refused change, at the document location that caused it, with the repair stated. */
|
|
105
|
+
export interface AuthoringRefusal {
|
|
106
|
+
readonly code: AuthoringRefusalCode;
|
|
107
|
+
/** The document path the refusal is about, or `#` when the command itself is malformed. */
|
|
108
|
+
readonly path: string;
|
|
109
|
+
/** The concrete cause, kept verbatim so a host reports or logs it unchanged. */
|
|
110
|
+
readonly detail: string;
|
|
111
|
+
/** What to do instead, in one sentence. */
|
|
112
|
+
readonly repair: string;
|
|
113
|
+
/**
|
|
114
|
+
* The row a dataset refusal is about, when the command named one. A host can focus the grid on
|
|
115
|
+
* it instead of parsing the detail; a schema refusal states none.
|
|
116
|
+
*/
|
|
117
|
+
readonly rowId?: string;
|
|
118
|
+
/**
|
|
119
|
+
* The composite key of the row a dataset refusal is about, as its canonical JSON text. A row is
|
|
120
|
+
* identified for an author by what it is keyed by, so the refusal states it beside the id.
|
|
121
|
+
*/
|
|
122
|
+
readonly rowKey?: string;
|
|
123
|
+
/**
|
|
124
|
+
* The column a dataset refusal is about, when a cell is at fault. The detail names it too; the
|
|
125
|
+
* structured member is what a grid scrolls to.
|
|
126
|
+
*/
|
|
127
|
+
readonly column?: string;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The repair each refusal states, keyed by the closed code union.
|
|
131
|
+
*
|
|
132
|
+
* A caller never spells a repair itself: `authoringRefusal` reads this table, and the gate in
|
|
133
|
+
* `__tests__/authoring.test.ts` fails when a code is added without an imperative row or when
|
|
134
|
+
* two codes would read the same.
|
|
135
|
+
*/
|
|
136
|
+
export declare const AUTHORING_REFUSAL_REPAIRS: Readonly<Record<AuthoringRefusalCode, string>>;
|
|
137
|
+
/** A refusal with its repair filled in from the code, so a host never spells a repair itself. */
|
|
138
|
+
export declare function authoringRefusal(code: AuthoringRefusalCode, path: string, detail: string): AuthoringRefusal;
|
|
139
|
+
/** The row and column a dataset refusal is about, when the command named one. */
|
|
140
|
+
export interface DatasetRefusalSubject {
|
|
141
|
+
readonly rowId?: string;
|
|
142
|
+
/** The row’s composite key, as its canonical JSON text. */
|
|
143
|
+
readonly rowKey?: string;
|
|
144
|
+
readonly column?: string;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* A dataset refusal: the same shape a schema refusal states, with the row and column an author
|
|
148
|
+
* repairs named structurally as well as in the detail.
|
|
149
|
+
*
|
|
150
|
+
* A grid focuses the cell `column` names and the row `rowId` names; a host that only logs reads the
|
|
151
|
+
* detail, which states both. `exactOptionalPropertyTypes` means the subject members are spread only
|
|
152
|
+
* when the subject stated them, so an absent one is absent rather than `undefined`.
|
|
153
|
+
*/
|
|
154
|
+
export declare function datasetRefusal(code: AuthoringRefusalCode, path: string, detail: string, subject?: DatasetRefusalSubject): AuthoringRefusal;
|
|
155
|
+
/**
|
|
156
|
+
* The dataset compiler's verdict as the store's refusal.
|
|
157
|
+
*
|
|
158
|
+
* The compiler is the only authority on a dataset's structure, so this maps its answer and nothing
|
|
159
|
+
* else. A row diagnostic is a 1-based table row rather than an id, and its detail already names the
|
|
160
|
+
* row it found; the declared column travels structurally because the diagnostic states it. The code
|
|
161
|
+
* is the compiler's own reason: a duplicate identifier or key stays that reason, an uncanonical
|
|
162
|
+
* cell stays `INVALID_CELL`, and a table-level semantic complaint is the candidate's structure.
|
|
163
|
+
*/
|
|
164
|
+
export declare function datasetDiagnosticRefusal(diagnostic: DatasetDiagnostic): AuthoringRefusal;
|
|
165
|
+
/**
|
|
166
|
+
* The refusal one closed-shape diagnostic earns, decided by the keyword that produced it.
|
|
167
|
+
*
|
|
168
|
+
* The closed metaschema is the only authority on what a document may contain, so this maps its
|
|
169
|
+
* answer and nothing else: a member the node does not declare is `UNKNOWN_PROPERTY` (an author
|
|
170
|
+
* can remove it), and every other failing keyword is `INVALID_STRUCTURE` (an author repairs the
|
|
171
|
+
* value the detail names). Both the candidate gate and the document reader report through it, so a
|
|
172
|
+
* member an edit would write and a member a stored draft carries are refused in one vocabulary.
|
|
173
|
+
*/
|
|
174
|
+
export declare function closedShapeRefusal(diagnostic: SchemaDiagnostic): AuthoringRefusal;
|
|
175
|
+
//# sourceMappingURL=refusals.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusals.d.ts","sourceRoot":"","sources":["../../src/store/refusals.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,iBAAiB,EAEjB,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,oBAAoB;AAC9B,kGAAkG;AAChG,mBAAmB;AACrB,+DAA+D;GAC7D,eAAe;AACjB,4EAA4E;GAC1E,gBAAgB;AAClB;;;GAGG;GACD,uBAAuB;AACzB,+FAA+F;GAC7F,iBAAiB;AACnB;;;GAGG;GACD,mBAAmB;AACrB,8DAA8D;GAC5D,cAAc;AAChB,kFAAkF;GAChF,cAAc;AAChB,oFAAoF;GAClF,gBAAgB;AAClB,8DAA8D;GAC5D,iBAAiB;AACnB,sEAAsE;GACpE,sBAAsB;AACxB;;;GAGG;GACD,4BAA4B;AAC9B,6FAA6F;GAC3F,cAAc;AAChB,wEAAwE;GACtE,iBAAiB;AACnB,qFAAqF;GACnF,oBAAoB;AACtB,mEAAmE;GACjE,gBAAgB;AAClB,8EAA8E;GAC5E,mBAAmB;AACrB,gGAAgG;GAC9F,kBAAkB;AACpB,uFAAuF;GACrF,eAAe;AACjB,wEAAwE;GACtE,gBAAgB;AAClB,gFAAgF;GAC9E,iBAAiB;AACnB;;;;GAIG;GACD,eAAe;AACjB,iEAAiE;GAC/D,aAAa;AACf,uEAAuE;GACrE,gBAAgB;AAClB,qFAAqF;GACnF,cAAc;AAChB,8EAA8E;GAC5E,eAAe;AACjB,kGAAkG;GAChG,aAAa;AACf,sFAAsF;GACpF,iBAAiB;AACnB,iGAAiG;GAC/F,eAAe;AACjB;;;;GAIG;GACD,sBAAsB;AACxB;;;GAGG;GACD,eAAe,CAAC;AAEpB;;;;;;GAMG;AACH,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;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,gBAAgB,GAAG,gBAAgB,CAKjF"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { assertNever } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
/**
|
|
3
|
+
* Every reason an authoring store refuses a change, as the tuple a caller names each by.
|
|
4
|
+
*
|
|
5
|
+
* The annotation refuses a name the union does not state, and the repair table below is typed
|
|
6
|
+
* `Record<AuthoringRefusalCode, string>`, so a union member with no row fails typecheck. The two
|
|
7
|
+
* therefore cannot drift, and a gate reads the codes without reaching the table.
|
|
8
|
+
*/
|
|
9
|
+
export const AUTHORING_REFUSAL_CODES = Object.freeze([
|
|
10
|
+
'MALFORMED_COMMAND',
|
|
11
|
+
'UNKNOWN_FIELD',
|
|
12
|
+
'UNKNOWN_OPTION',
|
|
13
|
+
'MISSING_OPTION_DOMAIN',
|
|
14
|
+
'UNKNOWN_MESSAGE',
|
|
15
|
+
'UNDECLARED_LOCALE',
|
|
16
|
+
'UNKNOWN_RULE',
|
|
17
|
+
'UNKNOWN_GATE',
|
|
18
|
+
'UNKNOWN_SCREEN',
|
|
19
|
+
'UNKNOWN_DATASET',
|
|
20
|
+
'UNKNOWN_CONTEXT_ROOT',
|
|
21
|
+
'UNREPRESENTABLE_EXPRESSION',
|
|
22
|
+
'DUPLICATE_ID',
|
|
23
|
+
'PUBLISHED_FIELD',
|
|
24
|
+
'ALREADY_DEPRECATED',
|
|
25
|
+
'UNKNOWN_LAYOUT',
|
|
26
|
+
'INVALID_STRUCTURE',
|
|
27
|
+
'UNKNOWN_PROPERTY',
|
|
28
|
+
'C11_VIOLATION',
|
|
29
|
+
'INVALID_LAYOUT',
|
|
30
|
+
'COLUMN_OVERFLOW',
|
|
31
|
+
'UNKNOWN_TABLE',
|
|
32
|
+
'UNKNOWN_ROW',
|
|
33
|
+
'UNKNOWN_COLUMN',
|
|
34
|
+
'INVALID_CELL',
|
|
35
|
+
'DUPLICATE_KEY',
|
|
36
|
+
'INVALID_ROW',
|
|
37
|
+
'INVALID_COLUMNS',
|
|
38
|
+
'INVALID_TABLE',
|
|
39
|
+
'DATASET_PIN_MISMATCH',
|
|
40
|
+
'STALE_EDITION',
|
|
41
|
+
]);
|
|
42
|
+
/**
|
|
43
|
+
* The repair each refusal states, keyed by the closed code union.
|
|
44
|
+
*
|
|
45
|
+
* A caller never spells a repair itself: `authoringRefusal` reads this table, and the gate in
|
|
46
|
+
* `__tests__/authoring.test.ts` fails when a code is added without an imperative row or when
|
|
47
|
+
* two codes would read the same.
|
|
48
|
+
*/
|
|
49
|
+
export const AUTHORING_REFUSAL_REPAIRS = Object.freeze({
|
|
50
|
+
MALFORMED_COMMAND: 'Try the action again. If it keeps failing, reload the page.',
|
|
51
|
+
UNKNOWN_FIELD: 'Add the question first, then choose it here.',
|
|
52
|
+
UNKNOWN_OPTION: 'name an option `code` the field’s own `options` declares, or add the option first',
|
|
53
|
+
MISSING_OPTION_DOMAIN: 'state `options` with at least one code and label, or an `optionSource`, in the same command that adds the field; a chooser or a rating with no domain offers the user nothing to choose',
|
|
54
|
+
UNKNOWN_RULE: 'name a `ruleId` the document declares, or add the rule first',
|
|
55
|
+
UNKNOWN_GATE: 'name a `ruleId` whose `kind` is `gate`, or add the gate first',
|
|
56
|
+
UNKNOWN_SCREEN: 'name a `ruleId` whose `kind` is `screen`, or add the screen first',
|
|
57
|
+
UNKNOWN_DATASET: 'name a `tableId` the document pins with `pinDataset`, or pin it first',
|
|
58
|
+
UNKNOWN_CONTEXT_ROOT: 'name a `path` the document declares in `context.roots`, or declare it with `setContextRoot` first',
|
|
59
|
+
UNREPRESENTABLE_EXPRESSION: 'state the rule as source, or build the visual form from declarations this draft holds: a declared field or context root, and `$it` only on an item-scoped rule',
|
|
60
|
+
UNKNOWN_MESSAGE: 'write the text of a message key the document names (`addField`, `addOption` and `addRule` mint one) or of a key `messages` already holds; a text nothing renders is unreachable and reserves the slot',
|
|
61
|
+
UNDECLARED_LOCALE: 'Add this language under Languages before you translate it.',
|
|
62
|
+
DUPLICATE_ID: 'choose an unused `fieldId` (`suggestFieldId` mints one), rule id, option code, step id, message key or placement; retire an existing field with `deprecateField` instead of replacing it',
|
|
63
|
+
PUBLISHED_FIELD: 'retire the field with `deprecateField`, advance the edition with `setSchemaVersion`, and add a new `fieldId`; published declarations keep what a device reads',
|
|
64
|
+
ALREADY_DEPRECATED: 'take no action; the field or option is already retired',
|
|
65
|
+
UNKNOWN_LAYOUT: 'name an index path into the document’s `layout` tree, as `[0, 1]` for the second child of the first node',
|
|
66
|
+
INVALID_STRUCTURE: 'Fix the value the checker named.',
|
|
67
|
+
UNKNOWN_PROPERTY: 'remove the member the node does not declare, or spell the one the contract names',
|
|
68
|
+
C11_VIOLATION: 'move `visibleWhen` to a section, callout, sop_block, summary_card or instruction-only step; a group, wizard or data-bearing step cannot be hidden conditionally',
|
|
69
|
+
INVALID_LAYOUT: 'place the node where the layout grammar admits it: a step only inside a wizard, a wizard only at the top level, and a field under a container',
|
|
70
|
+
COLUMN_OVERFLOW: 'Give the group more columns, or make this question narrower.',
|
|
71
|
+
UNKNOWN_TABLE: 'dispatch the command to the store that holds this `tableId`, or start the table with `createDatasetTable`',
|
|
72
|
+
UNKNOWN_ROW: 'name a `rowId` the table holds, or add the row with `addDatasetRow` first',
|
|
73
|
+
UNKNOWN_COLUMN: 'name a `columnId` the table declares, or declare it with `setDatasetColumns` first',
|
|
74
|
+
INVALID_CELL: 'write the cell as its column’s primitive spells it: text, a boolean, a canonical integer, canonical decimal text, a money object, a `{ value, unit }` quantity, an existing ISO civil date or a fixed-millisecond instant',
|
|
75
|
+
DUPLICATE_KEY: 'choose a key no other row states; under `FIRST` and `COLLECT` a repeated key is legal, so change the policy with `setDatasetHitPolicy` if two rows are meant to share one',
|
|
76
|
+
INVALID_ROW: 'state the row the table kind expects: a lookup row has an `output` and no `outcome`, a decision row has an `outcome`, and a `PASS` row also has an `output`',
|
|
77
|
+
INVALID_COLUMNS: 'declare at least one `key` column, name each `columnId` once, and remove the rows with `removeDatasetRow` before changing the key or output columns they are addressed by',
|
|
78
|
+
INVALID_TABLE: 'send the command that fits this table: `setDatasetValues` writes a `set`, the row commands write a `lookup` or `decision_table`, and only a `data` table states an effective range',
|
|
79
|
+
DATASET_PIN_MISMATCH: 'publish the schema against the version and digest the rows now state (`pinDataset` names the version and the artifact pins the digest), or advance `tableVersion` so the edit is a new edition',
|
|
80
|
+
STALE_EDITION: 'state the published edition or a later one: an edition only moves forward, and the host owns the number it published',
|
|
81
|
+
});
|
|
82
|
+
function repairFor(code) {
|
|
83
|
+
return AUTHORING_REFUSAL_REPAIRS[code];
|
|
84
|
+
}
|
|
85
|
+
/** A refusal with its repair filled in from the code, so a host never spells a repair itself. */
|
|
86
|
+
export function authoringRefusal(code, path, detail) {
|
|
87
|
+
return { code, path, detail, repair: repairFor(code) };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A dataset refusal: the same shape a schema refusal states, with the row and column an author
|
|
91
|
+
* repairs named structurally as well as in the detail.
|
|
92
|
+
*
|
|
93
|
+
* A grid focuses the cell `column` names and the row `rowId` names; a host that only logs reads the
|
|
94
|
+
* detail, which states both. `exactOptionalPropertyTypes` means the subject members are spread only
|
|
95
|
+
* when the subject stated them, so an absent one is absent rather than `undefined`.
|
|
96
|
+
*/
|
|
97
|
+
export function datasetRefusal(code, path, detail, subject = {}) {
|
|
98
|
+
const { rowId, rowKey, column } = subject;
|
|
99
|
+
return {
|
|
100
|
+
code,
|
|
101
|
+
path,
|
|
102
|
+
detail,
|
|
103
|
+
repair: repairFor(code),
|
|
104
|
+
...(rowId === undefined ? {} : { rowId }),
|
|
105
|
+
...(rowKey === undefined ? {} : { rowKey }),
|
|
106
|
+
...(column === undefined ? {} : { column }),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function isDatasetDocumentDiagnosticCode(code) {
|
|
110
|
+
return code !== 'INVALID_HEADER' && code !== 'CSV_BOUNDS' && code !== 'OVERLAPPING_WINDOW';
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The dataset compiler's verdict as the store's refusal.
|
|
114
|
+
*
|
|
115
|
+
* The compiler is the only authority on a dataset's structure, so this maps its answer and nothing
|
|
116
|
+
* else. A row diagnostic is a 1-based table row rather than an id, and its detail already names the
|
|
117
|
+
* row it found; the declared column travels structurally because the diagnostic states it. The code
|
|
118
|
+
* is the compiler's own reason: a duplicate identifier or key stays that reason, an uncanonical
|
|
119
|
+
* cell stays `INVALID_CELL`, and a table-level semantic complaint is the candidate's structure.
|
|
120
|
+
*/
|
|
121
|
+
export function datasetDiagnosticRefusal(diagnostic) {
|
|
122
|
+
const subject = diagnostic.column === undefined ? {} : { column: diagnostic.column };
|
|
123
|
+
const code = diagnostic.code;
|
|
124
|
+
if (!isDatasetDocumentDiagnosticCode(code)) {
|
|
125
|
+
// A single-table JSON compile is the only producer this mapping serves, so a CSV or
|
|
126
|
+
// installation code is a caller defect rather than a refusal to state.
|
|
127
|
+
throw new Error(`a single-table dataset compile cannot state the \`${code}\` diagnostic`);
|
|
128
|
+
}
|
|
129
|
+
switch (code) {
|
|
130
|
+
case 'DUPLICATE_IDENTIFIER':
|
|
131
|
+
return datasetRefusal('DUPLICATE_ID', diagnostic.path, diagnostic.detail, subject);
|
|
132
|
+
case 'DUPLICATE_KEY':
|
|
133
|
+
return datasetRefusal('DUPLICATE_KEY', diagnostic.path, diagnostic.detail, subject);
|
|
134
|
+
case 'INVALID_CELL':
|
|
135
|
+
return datasetRefusal('INVALID_CELL', diagnostic.path, diagnostic.detail, subject);
|
|
136
|
+
case 'INVALID_ROW':
|
|
137
|
+
return datasetRefusal('INVALID_ROW', diagnostic.path, diagnostic.detail, subject);
|
|
138
|
+
case 'DATASET_INVALID':
|
|
139
|
+
case 'JSON_INGEST_ERROR':
|
|
140
|
+
return datasetRefusal('INVALID_STRUCTURE', diagnostic.path, diagnostic.detail, subject);
|
|
141
|
+
default:
|
|
142
|
+
return assertNever(code);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The refusal one closed-shape diagnostic earns, decided by the keyword that produced it.
|
|
147
|
+
*
|
|
148
|
+
* The closed metaschema is the only authority on what a document may contain, so this maps its
|
|
149
|
+
* answer and nothing else: a member the node does not declare is `UNKNOWN_PROPERTY` (an author
|
|
150
|
+
* can remove it), and every other failing keyword is `INVALID_STRUCTURE` (an author repairs the
|
|
151
|
+
* value the detail names). Both the candidate gate and the document reader report through it, so a
|
|
152
|
+
* member an edit would write and a member a stored draft carries are refused in one vocabulary.
|
|
153
|
+
*/
|
|
154
|
+
export function closedShapeRefusal(diagnostic) {
|
|
155
|
+
return diagnostic.keyword === 'unevaluatedProperties' ||
|
|
156
|
+
diagnostic.keyword === 'additionalProperties'
|
|
157
|
+
? authoringRefusal('UNKNOWN_PROPERTY', diagnostic.path, diagnostic.detail)
|
|
158
|
+
: authoringRefusal('INVALID_STRUCTURE', diagnostic.path, diagnostic.detail);
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=refusals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusals.js","sourceRoot":"","sources":["../../src/store/refusals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAsGrD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAoC,MAAM,CAAC,MAAM,CAAC;IACpF,mBAAmB;IACnB,eAAe;IACf,gBAAgB;IAChB,uBAAuB;IACvB,iBAAiB;IACjB,mBAAmB;IACnB,cAAc;IACd,cAAc;IACd,gBAAgB;IAChB,iBAAiB;IACjB,sBAAsB;IACtB,4BAA4B;IAC5B,cAAc;IACd,iBAAiB;IACjB,oBAAoB;IACpB,gBAAgB;IAChB,mBAAmB;IACnB,kBAAkB;IAClB,eAAe;IACf,gBAAgB;IAChB,iBAAiB;IACjB,eAAe;IACf,aAAa;IACb,gBAAgB;I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C;IAC5F,CAAC;IACD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,sBAAsB;YACzB,OAAO,cAAc,CAAC,cAAc,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrF,KAAK,eAAe;YAClB,OAAO,cAAc,CAAC,eAAe,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACtF,KAAK,cAAc;YACjB,OAAO,cAAc,CAAC,cAAc,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrF,KAAK,aAAa;YAChB,OAAO,cAAc,CAAC,aAAa,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpF,KAAK,iBAAiB,CAAC;QACvB,KAAK,mBAAmB;YACtB,OAAO,cAAc,CAAC,mBAAmB,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC1F;YACE,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAA4B;IAC7D,OAAO,UAAU,CAAC,OAAO,KAAK,uBAAuB;QACnD,UAAU,CAAC,OAAO,KAAK,sBAAsB;QAC7C,CAAC,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC;QAC1E,CAAC,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import { assertNever } from '@azx-pbc/axiom-runtime';\nimport type {\n DatasetDiagnostic,\n DatasetDiagnosticCode,\n SchemaDiagnostic,\n} from '@azx-pbc/axiom-compiler';\n\n/**\n * The closed set of reasons an authoring store refuses a change.\n *\n * A refusal is not a diagnostic: a diagnostic says what is wrong with a document a caller may\n * still hold, and a refusal says the store declined to produce one at all. The distinction is\n * the ticket's hard/soft line — a hard refusal commits nothing, so the document and the undo\n * chain are untouched.\n *\n * Every code is switched exhaustively by `repairFor`, so a new refusal cannot ship without a\n * stated repair and a README line beside the others.\n */\nexport type AuthoringRefusalCode =\n /** The command is not one the store states: a missing member, a wrong type, an unknown member. */\n | 'MALFORMED_COMMAND'\n /** The command names a field the document does not declare. */\n | 'UNKNOWN_FIELD'\n /** The command names an option code the field's domain does not declare. */\n | 'UNKNOWN_OPTION'\n /**\n * A control that offers a declared domain — a chooser, a rating, a Likert scale — states\n * neither `options` nor `optionSource`, so there is nothing for the control to offer.\n */\n | 'MISSING_OPTION_DOMAIN'\n /** The command names a message key no declaration, rule or layout node of the draft states. */\n | 'UNKNOWN_MESSAGE'\n /**\n * The text is filed under a locale the document's catalogue does not own: not one of `locales`,\n * and not a locale of any entry it already states.\n */\n | 'UNDECLARED_LOCALE'\n /** The command names a rule the document does not declare. */\n | 'UNKNOWN_RULE'\n /** The command names a `gate` rule the document does not declare as that kind. */\n | 'UNKNOWN_GATE'\n /** The command names a `screen` rule the document does not declare as that kind. */\n | 'UNKNOWN_SCREEN'\n /** The command names a table id the document does not pin. */\n | 'UNKNOWN_DATASET'\n /** The command names a context root the document does not declare. */\n | 'UNKNOWN_CONTEXT_ROOT'\n /**\n * The expression cannot be stored as stated: a visual form this draft does not read back at the\n * rule's scope, or a tree the printer has no canonical source for.\n */\n | 'UNREPRESENTABLE_EXPRESSION'\n /** A field id, rule id, step id, layout placement or minted message key is already taken. */\n | 'DUPLICATE_ID'\n /** The change would rewrite a declaration that is already published. */\n | 'PUBLISHED_FIELD'\n /** The field or option is already deprecated, so there is nothing left to retire. */\n | 'ALREADY_DEPRECATED'\n /** The layout path names no node in the document's layout tree. */\n | 'UNKNOWN_LAYOUT'\n /** The candidate is not a document the compiler's structural stage admits. */\n | 'INVALID_STRUCTURE'\n /** The structural stage refused a member the node does not declare, `unevaluatedProperties`. */\n | 'UNKNOWN_PROPERTY'\n /** C11: `visibleWhen` may reach only a section, chrome or an instruction-only step. */\n | 'C11_VIOLATION'\n /** The layout grammar refuses this containment, member or reference. */\n | 'INVALID_LAYOUT'\n /** A field's `colSpan` is wider than the columns its layout parent lays out. */\n | 'COLUMN_OVERFLOW'\n /**\n * A dataset command names another table than the store holds. A Studio with several tables open\n * can dispatch a command against the wrong one, and the store states that rather than rewriting\n * the table it was handed.\n */\n | 'UNKNOWN_TABLE'\n /** A dataset command names a `rowId` the table does not hold. */\n | 'UNKNOWN_ROW'\n /** A dataset command names a `columnId` the table does not declare. */\n | 'UNKNOWN_COLUMN'\n /** A cell is not the canonical spelling its declared column's primitive requires. */\n | 'INVALID_CELL'\n /** The key a row would carry equals another row's, under a `UNIQUE` table. */\n | 'DUPLICATE_KEY'\n /** A row's members do not fit the table's kind: a lookup row's `outcome`, a PASS row's output. */\n | 'INVALID_ROW'\n /** The declared columns are not a column set the table's rows can be addressed by. */\n | 'INVALID_COLUMNS'\n /** An edit a table's `kind` or `binding` does not admit, or an effective range that is empty. */\n | 'INVALID_TABLE'\n /**\n * The document the store holds no longer answers the pin the schema states: another version,\n * another digest, or another table. Publishing it would claim the pinned bytes for rows that\n * are not them (`DATA-1.1.2`, `DATA-4.1.6`).\n */\n | 'DATASET_PIN_MISMATCH'\n /**\n * The pasted document states an older edition than the host published. An edition only moves\n * forward, so the paste is refused instead of opening the draft behind its published revision.\n */\n | 'STALE_EDITION';\n\n/**\n * Every reason an authoring store refuses a change, as the tuple a caller names each by.\n *\n * The annotation refuses a name the union does not state, and the repair table below is typed\n * `Record<AuthoringRefusalCode, string>`, so a union member with no row fails typecheck. The two\n * therefore cannot drift, and a gate reads the codes without reaching the table.\n */\nexport const AUTHORING_REFUSAL_CODES: readonly AuthoringRefusalCode[] = Object.freeze([\n 'MALFORMED_COMMAND',\n 'UNKNOWN_FIELD',\n 'UNKNOWN_OPTION',\n 'MISSING_OPTION_DOMAIN',\n 'UNKNOWN_MESSAGE',\n 'UNDECLARED_LOCALE',\n 'UNKNOWN_RULE',\n 'UNKNOWN_GATE',\n 'UNKNOWN_SCREEN',\n 'UNKNOWN_DATASET',\n 'UNKNOWN_CONTEXT_ROOT',\n 'UNREPRESENTABLE_EXPRESSION',\n 'DUPLICATE_ID',\n 'PUBLISHED_FIELD',\n 'ALREADY_DEPRECATED',\n 'UNKNOWN_LAYOUT',\n 'INVALID_STRUCTURE',\n 'UNKNOWN_PROPERTY',\n 'C11_VIOLATION',\n 'INVALID_LAYOUT',\n 'COLUMN_OVERFLOW',\n 'UNKNOWN_TABLE',\n 'UNKNOWN_ROW',\n 'UNKNOWN_COLUMN',\n 'INVALID_CELL',\n 'DUPLICATE_KEY',\n 'INVALID_ROW',\n 'INVALID_COLUMNS',\n 'INVALID_TABLE',\n 'DATASET_PIN_MISMATCH',\n 'STALE_EDITION',\n]);\n\n/** One refused change, at the document location that caused it, with the repair stated. */\nexport interface AuthoringRefusal {\n readonly code: AuthoringRefusalCode;\n /** The document path the refusal is about, or `#` when the command itself is malformed. */\n readonly path: string;\n /** The concrete cause, kept verbatim so a host reports or logs it unchanged. */\n readonly detail: string;\n /** What to do instead, in one sentence. */\n readonly repair: string;\n /**\n * The row a dataset refusal is about, when the command named one. A host can focus the grid on\n * it instead of parsing the detail; a schema refusal states none.\n */\n readonly rowId?: string;\n /**\n * The composite key of the row a dataset refusal is about, as its canonical JSON text. A row is\n * identified for an author by what it is keyed by, so the refusal states it beside the id.\n */\n readonly rowKey?: string;\n /**\n * The column a dataset refusal is about, when a cell is at fault. The detail names it too; the\n * structured member is what a grid scrolls to.\n */\n readonly column?: string;\n}\n\n/**\n * The repair each refusal states, keyed by the closed code union.\n *\n * A caller never spells a repair itself: `authoringRefusal` reads this table, and the gate in\n * `__tests__/authoring.test.ts` fails when a code is added without an imperative row or when\n * two codes would read the same.\n */\nexport const AUTHORING_REFUSAL_REPAIRS: Readonly<Record<AuthoringRefusalCode, string>> =\n Object.freeze({\n MALFORMED_COMMAND: 'Try the action again. If it keeps failing, reload the page.',\n UNKNOWN_FIELD: 'Add the question first, then choose it here.',\n UNKNOWN_OPTION:\n 'name an option `code` the field’s own `options` declares, or add the option first',\n MISSING_OPTION_DOMAIN:\n 'state `options` with at least one code and label, or an `optionSource`, in the same command that adds the field; a chooser or a rating with no domain offers the user nothing to choose',\n UNKNOWN_RULE: 'name a `ruleId` the document declares, or add the rule first',\n UNKNOWN_GATE: 'name a `ruleId` whose `kind` is `gate`, or add the gate first',\n UNKNOWN_SCREEN: 'name a `ruleId` whose `kind` is `screen`, or add the screen first',\n UNKNOWN_DATASET: 'name a `tableId` the document pins with `pinDataset`, or pin it first',\n UNKNOWN_CONTEXT_ROOT:\n 'name a `path` the document declares in `context.roots`, or declare it with `setContextRoot` first',\n UNREPRESENTABLE_EXPRESSION:\n 'state the rule as source, or build the visual form from declarations this draft holds: a declared field or context root, and `$it` only on an item-scoped rule',\n UNKNOWN_MESSAGE:\n 'write the text of a message key the document names (`addField`, `addOption` and `addRule` mint one) or of a key `messages` already holds; a text nothing renders is unreachable and reserves the slot',\n UNDECLARED_LOCALE: 'Add this language under Languages before you translate it.',\n DUPLICATE_ID:\n 'choose an unused `fieldId` (`suggestFieldId` mints one), rule id, option code, step id, message key or placement; retire an existing field with `deprecateField` instead of replacing it',\n PUBLISHED_FIELD:\n 'retire the field with `deprecateField`, advance the edition with `setSchemaVersion`, and add a new `fieldId`; published declarations keep what a device reads',\n ALREADY_DEPRECATED: 'take no action; the field or option is already retired',\n UNKNOWN_LAYOUT:\n 'name an index path into the document’s `layout` tree, as `[0, 1]` for the second child of the first node',\n INVALID_STRUCTURE: 'Fix the value the checker named.',\n UNKNOWN_PROPERTY:\n 'remove the member the node does not declare, or spell the one the contract names',\n C11_VIOLATION:\n 'move `visibleWhen` to a section, callout, sop_block, summary_card or instruction-only step; a group, wizard or data-bearing step cannot be hidden conditionally',\n INVALID_LAYOUT:\n 'place the node where the layout grammar admits it: a step only inside a wizard, a wizard only at the top level, and a field under a container',\n COLUMN_OVERFLOW: 'Give the group more columns, or make this question narrower.',\n UNKNOWN_TABLE:\n 'dispatch the command to the store that holds this `tableId`, or start the table with `createDatasetTable`',\n UNKNOWN_ROW: 'name a `rowId` the table holds, or add the row with `addDatasetRow` first',\n UNKNOWN_COLUMN:\n 'name a `columnId` the table declares, or declare it with `setDatasetColumns` first',\n INVALID_CELL:\n 'write the cell as its column’s primitive spells it: text, a boolean, a canonical integer, canonical decimal text, a money object, a `{ value, unit }` quantity, an existing ISO civil date or a fixed-millisecond instant',\n DUPLICATE_KEY:\n 'choose a key no other row states; under `FIRST` and `COLLECT` a repeated key is legal, so change the policy with `setDatasetHitPolicy` if two rows are meant to share one',\n INVALID_ROW:\n 'state the row the table kind expects: a lookup row has an `output` and no `outcome`, a decision row has an `outcome`, and a `PASS` row also has an `output`',\n INVALID_COLUMNS:\n 'declare at least one `key` column, name each `columnId` once, and remove the rows with `removeDatasetRow` before changing the key or output columns they are addressed by',\n INVALID_TABLE:\n 'send the command that fits this table: `setDatasetValues` writes a `set`, the row commands write a `lookup` or `decision_table`, and only a `data` table states an effective range',\n DATASET_PIN_MISMATCH:\n 'publish the schema against the version and digest the rows now state (`pinDataset` names the version and the artifact pins the digest), or advance `tableVersion` so the edit is a new edition',\n STALE_EDITION:\n 'state the published edition or a later one: an edition only moves forward, and the host owns the number it published',\n });\n\nfunction repairFor(code: AuthoringRefusalCode): string {\n return AUTHORING_REFUSAL_REPAIRS[code];\n}\n\n/** A refusal with its repair filled in from the code, so a host never spells a repair itself. */\nexport function authoringRefusal(\n code: AuthoringRefusalCode,\n path: string,\n detail: string,\n): AuthoringRefusal {\n return { code, path, detail, repair: repairFor(code) };\n}\n\n/** The row and column a dataset refusal is about, when the command named one. */\nexport interface DatasetRefusalSubject {\n readonly rowId?: string;\n /** The row’s composite key, as its canonical JSON text. */\n readonly rowKey?: string;\n readonly column?: string;\n}\n\n/**\n * A dataset refusal: the same shape a schema refusal states, with the row and column an author\n * repairs named structurally as well as in the detail.\n *\n * A grid focuses the cell `column` names and the row `rowId` names; a host that only logs reads the\n * detail, which states both. `exactOptionalPropertyTypes` means the subject members are spread only\n * when the subject stated them, so an absent one is absent rather than `undefined`.\n */\nexport function datasetRefusal(\n code: AuthoringRefusalCode,\n path: string,\n detail: string,\n subject: DatasetRefusalSubject = {},\n): AuthoringRefusal {\n const { rowId, rowKey, column } = subject;\n return {\n code,\n path,\n detail,\n repair: repairFor(code),\n ...(rowId === undefined ? {} : { rowId }),\n ...(rowKey === undefined ? {} : { rowKey }),\n ...(column === undefined ? {} : { column }),\n };\n}\n\n/**\n * The diagnostic codes one JSON table document can compile to.\n *\n * `compileDataset` also reads CSV, which states `INVALID_HEADER` and `CSV_BOUNDS`, and\n * `compileDatasetInstallation` states `OVERLAPPING_WINDOW` for a set of individually valid tables.\n * Neither door is this store's: `checkDatasetCandidate` and `readDatasetDocument` compile one JSON\n * table, so the refusal mapping is total over these six and never sees the other three.\n */\ntype DatasetDocumentDiagnosticCode = Exclude<\n DatasetDiagnosticCode,\n 'INVALID_HEADER' | 'CSV_BOUNDS' | 'OVERLAPPING_WINDOW'\n>;\n\nfunction isDatasetDocumentDiagnosticCode(\n code: DatasetDiagnosticCode,\n): code is DatasetDocumentDiagnosticCode {\n return code !== 'INVALID_HEADER' && code !== 'CSV_BOUNDS' && code !== 'OVERLAPPING_WINDOW';\n}\n\n/**\n * The dataset compiler's verdict as the store's refusal.\n *\n * The compiler is the only authority on a dataset's structure, so this maps its answer and nothing\n * else. A row diagnostic is a 1-based table row rather than an id, and its detail already names the\n * row it found; the declared column travels structurally because the diagnostic states it. The code\n * is the compiler's own reason: a duplicate identifier or key stays that reason, an uncanonical\n * cell stays `INVALID_CELL`, and a table-level semantic complaint is the candidate's structure.\n */\nexport function datasetDiagnosticRefusal(diagnostic: DatasetDiagnostic): AuthoringRefusal {\n const subject: DatasetRefusalSubject =\n diagnostic.column === undefined ? {} : { column: diagnostic.column };\n const code = diagnostic.code;\n if (!isDatasetDocumentDiagnosticCode(code)) {\n // A single-table JSON compile is the only producer this mapping serves, so a CSV or\n // installation code is a caller defect rather than a refusal to state.\n throw new Error(`a single-table dataset compile cannot state the \\`${code}\\` diagnostic`);\n }\n switch (code) {\n case 'DUPLICATE_IDENTIFIER':\n return datasetRefusal('DUPLICATE_ID', diagnostic.path, diagnostic.detail, subject);\n case 'DUPLICATE_KEY':\n return datasetRefusal('DUPLICATE_KEY', diagnostic.path, diagnostic.detail, subject);\n case 'INVALID_CELL':\n return datasetRefusal('INVALID_CELL', diagnostic.path, diagnostic.detail, subject);\n case 'INVALID_ROW':\n return datasetRefusal('INVALID_ROW', diagnostic.path, diagnostic.detail, subject);\n case 'DATASET_INVALID':\n case 'JSON_INGEST_ERROR':\n return datasetRefusal('INVALID_STRUCTURE', diagnostic.path, diagnostic.detail, subject);\n default:\n return assertNever(code);\n }\n}\n\n/**\n * The refusal one closed-shape diagnostic earns, decided by the keyword that produced it.\n *\n * The closed metaschema is the only authority on what a document may contain, so this maps its\n * answer and nothing else: a member the node does not declare is `UNKNOWN_PROPERTY` (an author\n * can remove it), and every other failing keyword is `INVALID_STRUCTURE` (an author repairs the\n * value the detail names). Both the candidate gate and the document reader report through it, so a\n * member an edit would write and a member a stored draft carries are refused in one vocabulary.\n */\nexport function closedShapeRefusal(diagnostic: SchemaDiagnostic): AuthoringRefusal {\n return diagnostic.keyword === 'unevaluatedProperties' ||\n diagnostic.keyword === 'additionalProperties'\n ? authoringRefusal('UNKNOWN_PROPERTY', diagnostic.path, diagnostic.detail)\n : authoringRefusal('INVALID_STRUCTURE', diagnostic.path, diagnostic.detail);\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AuthoringCommand, DatasetCommand } from './commands.js';
|
|
2
|
+
/**
|
|
3
|
+
* One short sentence describing what a command changed, for the retained audit trail.
|
|
4
|
+
*
|
|
5
|
+
* The trail is the host's evidence of "who changed what", not an operation log a renderer reads
|
|
6
|
+
* to redraw: the strings are deterministic and carry the declaration the command addressed, so a
|
|
7
|
+
* reviewer can tell an edit of `r_gate` from an edit of `r_photo` without holding the command
|
|
8
|
+
* payload. They are not localisable UI copy and no test should treat their exact wording as a
|
|
9
|
+
* contract beyond naming the declaration.
|
|
10
|
+
*/
|
|
11
|
+
export declare function describeCommand(command: AuthoringCommand): string;
|
|
12
|
+
/** One short sentence describing what a table command changed. */
|
|
13
|
+
export declare function describeDatasetCommand(command: DatasetCommand): string;
|
|
14
|
+
//# sourceMappingURL=steps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"steps.d.ts","sourceRoot":"","sources":["../../src/store/steps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEtE;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAyFjE;AAED,kEAAkE;AAClE,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAqBtE"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { assertNever } from '@azx-pbc/axiom-runtime';
|
|
2
|
+
/**
|
|
3
|
+
* One short sentence describing what a command changed, for the retained audit trail.
|
|
4
|
+
*
|
|
5
|
+
* The trail is the host's evidence of "who changed what", not an operation log a renderer reads
|
|
6
|
+
* to redraw: the strings are deterministic and carry the declaration the command addressed, so a
|
|
7
|
+
* reviewer can tell an edit of `r_gate` from an edit of `r_photo` without holding the command
|
|
8
|
+
* payload. They are not localisable UI copy and no test should treat their exact wording as a
|
|
9
|
+
* contract beyond naming the declaration.
|
|
10
|
+
*/
|
|
11
|
+
export function describeCommand(command) {
|
|
12
|
+
switch (command.kind) {
|
|
13
|
+
case 'addField':
|
|
14
|
+
return `add field \`${command.field.fieldId}\``;
|
|
15
|
+
case 'addOption':
|
|
16
|
+
return `add option \`${String(command.code)}\` to \`${command.fieldId}\``;
|
|
17
|
+
case 'editField':
|
|
18
|
+
return `edit field \`${command.fieldId}\``;
|
|
19
|
+
case 'setFieldDeclaration':
|
|
20
|
+
return `edit declaration of \`${command.fieldId}\``;
|
|
21
|
+
case 'setFieldPrimitive':
|
|
22
|
+
return `change the value domain of \`${command.fieldId}\` to \`${command.field.primitive}\``;
|
|
23
|
+
case 'deprecateOption':
|
|
24
|
+
return `retire option \`${String(command.code)}\` of \`${command.fieldId}\``;
|
|
25
|
+
case 'setOptionAvailability':
|
|
26
|
+
return command.availability === null
|
|
27
|
+
? `make option \`${String(command.code)}\` of \`${command.fieldId}\` always available`
|
|
28
|
+
: `state when option \`${String(command.code)}\` of \`${command.fieldId}\` is available`;
|
|
29
|
+
case 'moveOption':
|
|
30
|
+
return `move option \`${String(command.code)}\` of \`${command.fieldId}\``;
|
|
31
|
+
case 'addRule':
|
|
32
|
+
return `add \`${command.rule.kind}\` rule \`${command.rule.ruleId}\``;
|
|
33
|
+
case 'addRuleTestCase':
|
|
34
|
+
return `add case \`${command.testCase.caseId}\` to rule \`${command.ruleId}\``;
|
|
35
|
+
case 'setRuleExpr':
|
|
36
|
+
return `edit the expression of rule \`${command.ruleId}\``;
|
|
37
|
+
case 'setRuleNote':
|
|
38
|
+
return `edit the note of rule \`${command.ruleId}\``;
|
|
39
|
+
case 'setRuleSuggests':
|
|
40
|
+
return command.suggests === null
|
|
41
|
+
? `remove the alternatives of rule \`${command.ruleId}\``
|
|
42
|
+
: `state ${String(command.suggests.length)} alternative${command.suggests.length === 1 ? '' : 's'} for rule \`${command.ruleId}\``;
|
|
43
|
+
case 'editRule':
|
|
44
|
+
return `edit rule \`${command.ruleId}\``;
|
|
45
|
+
case 'removeRule':
|
|
46
|
+
return `remove rule \`${command.ruleId}\``;
|
|
47
|
+
case 'setMessageText':
|
|
48
|
+
return `set message \`${command.messageKey}\` in \`${command.locale}\``;
|
|
49
|
+
case 'deprecateField':
|
|
50
|
+
return `retire field \`${command.fieldId}\``;
|
|
51
|
+
case 'removeField':
|
|
52
|
+
return `remove field \`${command.fieldId}\``;
|
|
53
|
+
case 'addLayoutNode':
|
|
54
|
+
return `add a \`${String(command.node['kind'])}\` layout node`;
|
|
55
|
+
case 'editLayoutNode':
|
|
56
|
+
return `edit layout node at ${JSON.stringify(command.target)}`;
|
|
57
|
+
case 'removeLayoutNode':
|
|
58
|
+
return `remove layout node at ${JSON.stringify(command.target)}`;
|
|
59
|
+
case 'setGroupColumns':
|
|
60
|
+
return `set ${JSON.stringify(command.group)} to ${String(command.columns)} columns`;
|
|
61
|
+
case 'placeField':
|
|
62
|
+
return `place field \`${command.fieldId}\``;
|
|
63
|
+
case 'moveLayoutNode':
|
|
64
|
+
return `move layout node from ${JSON.stringify(command.target)}`;
|
|
65
|
+
case 'addRecordArray':
|
|
66
|
+
return `add repeating record \`${command.array.fieldId}\``;
|
|
67
|
+
case 'addRowMember':
|
|
68
|
+
return `add a member to \`${command.arrayFieldId}\``;
|
|
69
|
+
case 'addRecordMember':
|
|
70
|
+
return `add a member to record \`${command.parentFieldId}\``;
|
|
71
|
+
case 'setRowKey':
|
|
72
|
+
return `set the row identity of \`${command.fieldId}\``;
|
|
73
|
+
case 'setLocales':
|
|
74
|
+
return `set the locales to ${command.locales.join(', ')}`;
|
|
75
|
+
case 'setSchemaVersion':
|
|
76
|
+
return `advance the edition to ${String(command.schemaVersion)}`;
|
|
77
|
+
case 'importTranslations':
|
|
78
|
+
return `import ${String(command.translations.length)} translation${command.translations.length === 1 ? '' : 's'}`;
|
|
79
|
+
case 'setPrimary':
|
|
80
|
+
return `designate \`${command.ruleId}\` as the primary ${command.ruleKind}`;
|
|
81
|
+
case 'pinDataset':
|
|
82
|
+
return `pin table \`${command.tableId}\` at version ${String(command.tableVersion)}`;
|
|
83
|
+
case 'unpinDataset':
|
|
84
|
+
return `unpin table \`${command.tableId}\``;
|
|
85
|
+
case 'setContextRoot':
|
|
86
|
+
return `declare context root \`${command.root.path}\``;
|
|
87
|
+
case 'removeContextRoot':
|
|
88
|
+
return `remove context root \`${command.path}\``;
|
|
89
|
+
case 'setOnHide':
|
|
90
|
+
return command.onHide === null
|
|
91
|
+
? 'clear the hiding policy'
|
|
92
|
+
: `set the hiding policy to \`${command.onHide}\``;
|
|
93
|
+
case 'setDocumentTitle':
|
|
94
|
+
return 'set the document title';
|
|
95
|
+
case 'setSignatureCovers':
|
|
96
|
+
return `set the coverage of signature \`${command.fieldId}\``;
|
|
97
|
+
default:
|
|
98
|
+
return assertNever(command);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/** One short sentence describing what a table command changed. */
|
|
102
|
+
export function describeDatasetCommand(command) {
|
|
103
|
+
switch (command.kind) {
|
|
104
|
+
case 'addDatasetRow':
|
|
105
|
+
return `add row \`${command.row.rowId}\` to \`${command.tableId}\``;
|
|
106
|
+
case 'replaceDatasetRow':
|
|
107
|
+
return `replace row \`${command.rowId}\` of \`${command.tableId}\``;
|
|
108
|
+
case 'removeDatasetRow':
|
|
109
|
+
return `remove row \`${command.rowId}\` of \`${command.tableId}\``;
|
|
110
|
+
case 'setDatasetCell':
|
|
111
|
+
return `set \`${command.columnId}\` of row \`${command.rowId}\` in \`${command.tableId}\``;
|
|
112
|
+
case 'setDatasetColumns':
|
|
113
|
+
return `declare ${String(command.columns.length)} column${command.columns.length === 1 ? '' : 's'} of \`${command.tableId}\``;
|
|
114
|
+
case 'setDatasetValues':
|
|
115
|
+
return `set the membership of \`${command.tableId}\``;
|
|
116
|
+
case 'setDatasetHitPolicy':
|
|
117
|
+
return `set the hit policy of \`${command.tableId}\` to \`${command.policy.hitPolicy}\``;
|
|
118
|
+
case 'setDatasetEffectiveRange':
|
|
119
|
+
return `set the effective range of \`${command.tableId}\``;
|
|
120
|
+
default:
|
|
121
|
+
return assertNever(command);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=steps.js.map
|
|
@@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,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,OAAO,CAAC,OAAO,IAAI,CAAC;QAChI,KAAK,kBAAkB;YACrB,OAAO,2BAA2B,OAAO,CAAC,OAAO,IAAI,CAAC;QACxD,KAAK,qBAAqB;YACxB,OAAO,2BAA2B,OAAO,CAAC,OAAO,WAAW,OAAO,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC;QAC3F,KAAK,0BAA0B;YAC7B,OAAO,gCAAgC,OAAO,CAAC,OAAO,IAAI,CAAC;QAC7D;YACE,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;AACH,CAAC","sourcesContent":["import { assertNever } from '@azx-pbc/axiom-runtime';\nimport type { AuthoringCommand, DatasetCommand } from './commands.js';\n\n/**\n * One short sentence describing what a command changed, for the retained audit trail.\n *\n * The trail is the host's evidence of \"who changed what\", not an operation log a renderer reads\n * to redraw: the strings are deterministic and carry the declaration the command addressed, so a\n * reviewer can tell an edit of `r_gate` from an edit of `r_photo` without holding the command\n * payload. They are not localisable UI copy and no test should treat their exact wording as a\n * contract beyond naming the declaration.\n */\nexport function describeCommand(command: AuthoringCommand): string {\n switch (command.kind) {\n case 'addField':\n return `add field \\`${command.field.fieldId}\\``;\n case 'addOption':\n return `add option \\`${String(command.code)}\\` to \\`${command.fieldId}\\``;\n case 'editField':\n return `edit field \\`${command.fieldId}\\``;\n case 'setFieldDeclaration':\n return `edit declaration of \\`${command.fieldId}\\``;\n case 'setFieldPrimitive':\n return `change the value domain of \\`${command.fieldId}\\` to \\`${command.field.primitive}\\``;\n case 'deprecateOption':\n return `retire option \\`${String(command.code)}\\` of \\`${command.fieldId}\\``;\n case 'setOptionAvailability':\n return command.availability === null\n ? `make option \\`${String(command.code)}\\` of \\`${command.fieldId}\\` always available`\n : `state when option \\`${String(command.code)}\\` of \\`${command.fieldId}\\` is available`;\n case 'moveOption':\n return `move option \\`${String(command.code)}\\` of \\`${command.fieldId}\\``;\n case 'addRule':\n return `add \\`${command.rule.kind}\\` rule \\`${command.rule.ruleId}\\``;\n case 'addRuleTestCase':\n return `add case \\`${command.testCase.caseId}\\` to rule \\`${command.ruleId}\\``;\n case 'setRuleExpr':\n return `edit the expression of rule \\`${command.ruleId}\\``;\n case 'setRuleNote':\n return `edit the note of rule \\`${command.ruleId}\\``;\n case 'setRuleSuggests':\n return command.suggests === null\n ? `remove the alternatives of rule \\`${command.ruleId}\\``\n : `state ${String(command.suggests.length)} alternative${command.suggests.length === 1 ? '' : 's'} for rule \\`${command.ruleId}\\``;\n case 'editRule':\n return `edit rule \\`${command.ruleId}\\``;\n case 'removeRule':\n return `remove rule \\`${command.ruleId}\\``;\n case 'setMessageText':\n return `set message \\`${command.messageKey}\\` in \\`${command.locale}\\``;\n case 'deprecateField':\n return `retire field \\`${command.fieldId}\\``;\n case 'removeField':\n return `remove field \\`${command.fieldId}\\``;\n case 'addLayoutNode':\n return `add a \\`${String(command.node['kind'])}\\` layout node`;\n case 'editLayoutNode':\n return `edit layout node at ${JSON.stringify(command.target)}`;\n case 'removeLayoutNode':\n return `remove layout node at ${JSON.stringify(command.target)}`;\n case 'setGroupColumns':\n return `set ${JSON.stringify(command.group)} to ${String(command.columns)} columns`;\n case 'placeField':\n return `place field \\`${command.fieldId}\\``;\n case 'moveLayoutNode':\n return `move layout node from ${JSON.stringify(command.target)}`;\n case 'addRecordArray':\n return `add repeating record \\`${command.array.fieldId}\\``;\n case 'addRowMember':\n return `add a member to \\`${command.arrayFieldId}\\``;\n case 'addRecordMember':\n return `add a member to record \\`${command.parentFieldId}\\``;\n case 'setRowKey':\n return `set the row identity of \\`${command.fieldId}\\``;\n case 'setLocales':\n return `set the locales to ${command.locales.join(', ')}`;\n case 'setSchemaVersion':\n return `advance the edition to ${String(command.schemaVersion)}`;\n case 'importTranslations':\n return `import ${String(command.translations.length)} translation${command.translations.length === 1 ? '' : 's'}`;\n case 'setPrimary':\n return `designate \\`${command.ruleId}\\` as the primary ${command.ruleKind}`;\n case 'pinDataset':\n return `pin table \\`${command.tableId}\\` at version ${String(command.tableVersion)}`;\n case 'unpinDataset':\n return `unpin table \\`${command.tableId}\\``;\n case 'setContextRoot':\n return `declare context root \\`${command.root.path}\\``;\n case 'removeContextRoot':\n return `remove context root \\`${command.path}\\``;\n case 'setOnHide':\n return command.onHide === null\n ? 'clear the hiding policy'\n : `set the hiding policy to \\`${command.onHide}\\``;\n case 'setDocumentTitle':\n return 'set the document title';\n case 'setSignatureCovers':\n return `set the coverage of signature \\`${command.fieldId}\\``;\n default:\n return assertNever(command);\n }\n}\n\n/** One short sentence describing what a table command changed. */\nexport function describeDatasetCommand(command: DatasetCommand): string {\n switch (command.kind) {\n case 'addDatasetRow':\n return `add row \\`${command.row.rowId}\\` to \\`${command.tableId}\\``;\n case 'replaceDatasetRow':\n return `replace row \\`${command.rowId}\\` of \\`${command.tableId}\\``;\n case 'removeDatasetRow':\n return `remove row \\`${command.rowId}\\` of \\`${command.tableId}\\``;\n case 'setDatasetCell':\n return `set \\`${command.columnId}\\` of row \\`${command.rowId}\\` in \\`${command.tableId}\\``;\n case 'setDatasetColumns':\n return `declare ${String(command.columns.length)} column${command.columns.length === 1 ? '' : 's'} of \\`${command.tableId}\\``;\n case 'setDatasetValues':\n return `set the membership of \\`${command.tableId}\\``;\n case 'setDatasetHitPolicy':\n return `set the hit policy of \\`${command.tableId}\\` to \\`${command.policy.hitPolicy}\\``;\n case 'setDatasetEffectiveRange':\n return `set the effective range of \\`${command.tableId}\\``;\n default:\n return assertNever(command);\n }\n}\n"]}
|