@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.
Files changed (231) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +648 -2
  3. package/dist/cards/selectors.d.ts +70 -0
  4. package/dist/cards/selectors.d.ts.map +1 -0
  5. package/dist/cards/selectors.js +194 -0
  6. package/dist/cards/selectors.js.map +1 -0
  7. package/dist/definition.d.ts +36 -0
  8. package/dist/definition.d.ts.map +1 -0
  9. package/dist/definition.js +48 -0
  10. package/dist/definition.js.map +1 -0
  11. package/dist/evidence/cases.d.ts +44 -0
  12. package/dist/evidence/cases.d.ts.map +1 -0
  13. package/dist/evidence/cases.js +578 -0
  14. package/dist/evidence/cases.js.map +1 -0
  15. package/dist/evidence/repairs.d.ts +99 -0
  16. package/dist/evidence/repairs.d.ts.map +1 -0
  17. package/dist/evidence/repairs.js +181 -0
  18. package/dist/evidence/repairs.js.map +1 -0
  19. package/dist/evidence/summary.d.ts +35 -0
  20. package/dist/evidence/summary.d.ts.map +1 -0
  21. package/dist/evidence/summary.js +38 -0
  22. package/dist/evidence/summary.js.map +1 -0
  23. package/dist/i18n/gaps.d.ts +3 -0
  24. package/dist/i18n/gaps.d.ts.map +1 -0
  25. package/dist/i18n/gaps.js +2 -0
  26. package/dist/i18n/gaps.js.map +1 -0
  27. package/dist/i18n/message-slots.d.ts +19 -0
  28. package/dist/i18n/message-slots.d.ts.map +1 -0
  29. package/dist/i18n/message-slots.js +101 -0
  30. package/dist/i18n/message-slots.js.map +1 -0
  31. package/dist/i18n/text-locale.d.ts +13 -0
  32. package/dist/i18n/text-locale.d.ts.map +1 -0
  33. package/dist/i18n/text-locale.js +14 -0
  34. package/dist/i18n/text-locale.js.map +1 -0
  35. package/dist/i18n/translations.d.ts +56 -0
  36. package/dist/i18n/translations.d.ts.map +1 -0
  37. package/dist/i18n/translations.js +103 -0
  38. package/dist/i18n/translations.js.map +1 -0
  39. package/dist/impact/references.d.ts +143 -0
  40. package/dist/impact/references.d.ts.map +1 -0
  41. package/dist/impact/references.js +429 -0
  42. package/dist/impact/references.js.map +1 -0
  43. package/dist/index.d.ts +86 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +58 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/preview/compile-preview.d.ts +67 -0
  48. package/dist/preview/compile-preview.d.ts.map +1 -0
  49. package/dist/preview/compile-preview.js +286 -0
  50. package/dist/preview/compile-preview.js.map +1 -0
  51. package/dist/preview/handle.d.ts +119 -0
  52. package/dist/preview/handle.d.ts.map +1 -0
  53. package/dist/preview/handle.js +2 -0
  54. package/dist/preview/handle.js.map +1 -0
  55. package/dist/preview/held.d.ts +39 -0
  56. package/dist/preview/held.d.ts.map +1 -0
  57. package/dist/preview/held.js +15 -0
  58. package/dist/preview/held.js.map +1 -0
  59. package/dist/preview/measurement.d.ts +5 -0
  60. package/dist/preview/measurement.d.ts.map +1 -0
  61. package/dist/preview/measurement.js +18 -0
  62. package/dist/preview/measurement.js.map +1 -0
  63. package/dist/publish/build.d.ts +33 -0
  64. package/dist/publish/build.d.ts.map +1 -0
  65. package/dist/publish/build.js +15 -0
  66. package/dist/publish/build.js.map +1 -0
  67. package/dist/publish/diff.d.ts +208 -0
  68. package/dist/publish/diff.d.ts.map +1 -0
  69. package/dist/publish/diff.js +227 -0
  70. package/dist/publish/diff.js.map +1 -0
  71. package/dist/publish/review.d.ts +41 -0
  72. package/dist/publish/review.d.ts.map +1 -0
  73. package/dist/publish/review.js +22 -0
  74. package/dist/publish/review.js.map +1 -0
  75. package/dist/schema/dataset-input.d.ts +30 -0
  76. package/dist/schema/dataset-input.d.ts.map +1 -0
  77. package/dist/schema/dataset-input.js +58 -0
  78. package/dist/schema/dataset-input.js.map +1 -0
  79. package/dist/schema/dataset.d.ts +166 -0
  80. package/dist/schema/dataset.d.ts.map +1 -0
  81. package/dist/schema/dataset.js +281 -0
  82. package/dist/schema/dataset.js.map +1 -0
  83. package/dist/schema/declarations.d.ts +15 -0
  84. package/dist/schema/declarations.d.ts.map +1 -0
  85. package/dist/schema/declarations.js +47 -0
  86. package/dist/schema/declarations.js.map +1 -0
  87. package/dist/schema/document.d.ts +504 -0
  88. package/dist/schema/document.d.ts.map +1 -0
  89. package/dist/schema/document.js +337 -0
  90. package/dist/schema/document.js.map +1 -0
  91. package/dist/schema/error.d.ts +15 -0
  92. package/dist/schema/error.d.ts.map +1 -0
  93. package/dist/schema/error.js +18 -0
  94. package/dist/schema/error.js.map +1 -0
  95. package/dist/schema/field-id.d.ts +8 -0
  96. package/dist/schema/field-id.d.ts.map +1 -0
  97. package/dist/schema/field-id.js +47 -0
  98. package/dist/schema/field-id.js.map +1 -0
  99. package/dist/schema/layout.d.ts +118 -0
  100. package/dist/schema/layout.d.ts.map +1 -0
  101. package/dist/schema/layout.js +101 -0
  102. package/dist/schema/layout.js.map +1 -0
  103. package/dist/schema/palette.d.ts +103 -0
  104. package/dist/schema/palette.d.ts.map +1 -0
  105. package/dist/schema/palette.js +140 -0
  106. package/dist/schema/palette.js.map +1 -0
  107. package/dist/schema/read.d.ts +49 -0
  108. package/dist/schema/read.d.ts.map +1 -0
  109. package/dist/schema/read.js +942 -0
  110. package/dist/schema/read.js.map +1 -0
  111. package/dist/store/apply-dataset.d.ts +14 -0
  112. package/dist/store/apply-dataset.d.ts.map +1 -0
  113. package/dist/store/apply-dataset.js +513 -0
  114. package/dist/store/apply-dataset.js.map +1 -0
  115. package/dist/store/apply.d.ts +37 -0
  116. package/dist/store/apply.d.ts.map +1 -0
  117. package/dist/store/apply.js +2269 -0
  118. package/dist/store/apply.js.map +1 -0
  119. package/dist/store/candidate.d.ts +37 -0
  120. package/dist/store/candidate.d.ts.map +1 -0
  121. package/dist/store/candidate.js +178 -0
  122. package/dist/store/candidate.js.map +1 -0
  123. package/dist/store/commands/coverage.d.ts +58 -0
  124. package/dist/store/commands/coverage.d.ts.map +1 -0
  125. package/dist/store/commands/coverage.js +354 -0
  126. package/dist/store/commands/coverage.js.map +1 -0
  127. package/dist/store/commands/dataset.d.ts +26 -0
  128. package/dist/store/commands/dataset.d.ts.map +1 -0
  129. package/dist/store/commands/dataset.js +368 -0
  130. package/dist/store/commands/dataset.js.map +1 -0
  131. package/dist/store/commands/document.d.ts +21 -0
  132. package/dist/store/commands/document.d.ts.map +1 -0
  133. package/dist/store/commands/document.js +160 -0
  134. package/dist/store/commands/document.js.map +1 -0
  135. package/dist/store/commands/field.d.ts +32 -0
  136. package/dist/store/commands/field.d.ts.map +1 -0
  137. package/dist/store/commands/field.js +572 -0
  138. package/dist/store/commands/field.js.map +1 -0
  139. package/dist/store/commands/layout.d.ts +16 -0
  140. package/dist/store/commands/layout.d.ts.map +1 -0
  141. package/dist/store/commands/layout.js +70 -0
  142. package/dist/store/commands/layout.js.map +1 -0
  143. package/dist/store/commands/parse.d.ts +19 -0
  144. package/dist/store/commands/parse.d.ts.map +1 -0
  145. package/dist/store/commands/parse.js +328 -0
  146. package/dist/store/commands/parse.js.map +1 -0
  147. package/dist/store/commands/readers.d.ts +198 -0
  148. package/dist/store/commands/readers.d.ts.map +1 -0
  149. package/dist/store/commands/readers.js +711 -0
  150. package/dist/store/commands/readers.js.map +1 -0
  151. package/dist/store/commands/rule.d.ts +24 -0
  152. package/dist/store/commands/rule.d.ts.map +1 -0
  153. package/dist/store/commands/rule.js +379 -0
  154. package/dist/store/commands/rule.js.map +1 -0
  155. package/dist/store/commands/shapes.d.ts +900 -0
  156. package/dist/store/commands/shapes.d.ts.map +1 -0
  157. package/dist/store/commands/shapes.js +166 -0
  158. package/dist/store/commands/shapes.js.map +1 -0
  159. package/dist/store/commands/suggestions.d.ts +37 -0
  160. package/dist/store/commands/suggestions.d.ts.map +1 -0
  161. package/dist/store/commands/suggestions.js +177 -0
  162. package/dist/store/commands/suggestions.js.map +1 -0
  163. package/dist/store/commands.d.ts +16 -0
  164. package/dist/store/commands.d.ts.map +1 -0
  165. package/dist/store/commands.js +13 -0
  166. package/dist/store/commands.js.map +1 -0
  167. package/dist/store/dataset-candidate.d.ts +33 -0
  168. package/dist/store/dataset-candidate.d.ts.map +1 -0
  169. package/dist/store/dataset-candidate.js +31 -0
  170. package/dist/store/dataset-candidate.js.map +1 -0
  171. package/dist/store/dataset-pin.d.ts +93 -0
  172. package/dist/store/dataset-pin.d.ts.map +1 -0
  173. package/dist/store/dataset-pin.js +86 -0
  174. package/dist/store/dataset-pin.js.map +1 -0
  175. package/dist/store/dataset-store.d.ts +96 -0
  176. package/dist/store/dataset-store.d.ts.map +1 -0
  177. package/dist/store/dataset-store.js +112 -0
  178. package/dist/store/dataset-store.js.map +1 -0
  179. package/dist/store/history.d.ts +149 -0
  180. package/dist/store/history.d.ts.map +1 -0
  181. package/dist/store/history.js +173 -0
  182. package/dist/store/history.js.map +1 -0
  183. package/dist/store/measurement.d.ts +5 -0
  184. package/dist/store/measurement.d.ts.map +1 -0
  185. package/dist/store/measurement.js +20 -0
  186. package/dist/store/measurement.js.map +1 -0
  187. package/dist/store/notify.d.ts +11 -0
  188. package/dist/store/notify.d.ts.map +1 -0
  189. package/dist/store/notify.js +26 -0
  190. package/dist/store/notify.js.map +1 -0
  191. package/dist/store/published.d.ts +50 -0
  192. package/dist/store/published.d.ts.map +1 -0
  193. package/dist/store/published.js +27 -0
  194. package/dist/store/published.js.map +1 -0
  195. package/dist/store/refusals.d.ts +175 -0
  196. package/dist/store/refusals.d.ts.map +1 -0
  197. package/dist/store/refusals.js +160 -0
  198. package/dist/store/refusals.js.map +1 -0
  199. package/dist/store/steps.d.ts +14 -0
  200. package/dist/store/steps.d.ts.map +1 -0
  201. package/dist/store/steps.js +124 -0
  202. package/dist/store/steps.js.map +1 -0
  203. package/dist/store/store.d.ts +142 -0
  204. package/dist/store/store.d.ts.map +1 -0
  205. package/dist/store/store.js +136 -0
  206. package/dist/store/store.js.map +1 -0
  207. package/dist/store/unchanged.d.ts +12 -0
  208. package/dist/store/unchanged.d.ts.map +1 -0
  209. package/dist/store/unchanged.js +35 -0
  210. package/dist/store/unchanged.js.map +1 -0
  211. package/dist/visual/emit.d.ts +21 -0
  212. package/dist/visual/emit.d.ts.map +1 -0
  213. package/dist/visual/emit.js +133 -0
  214. package/dist/visual/emit.js.map +1 -0
  215. package/dist/visual/parse.d.ts +32 -0
  216. package/dist/visual/parse.d.ts.map +1 -0
  217. package/dist/visual/parse.js +330 -0
  218. package/dist/visual/parse.js.map +1 -0
  219. package/dist/visual/project.d.ts +40 -0
  220. package/dist/visual/project.d.ts.map +1 -0
  221. package/dist/visual/project.js +349 -0
  222. package/dist/visual/project.js.map +1 -0
  223. package/dist/visual/represent.d.ts +50 -0
  224. package/dist/visual/represent.d.ts.map +1 -0
  225. package/dist/visual/represent.js +66 -0
  226. package/dist/visual/represent.js.map +1 -0
  227. package/dist/visual/vocabulary.d.ts +121 -0
  228. package/dist/visual/vocabulary.d.ts.map +1 -0
  229. package/dist/visual/vocabulary.js +32 -0
  230. package/dist/visual/vocabulary.js.map +1 -0
  231. package/package.json +52 -3
@@ -0,0 +1,900 @@
1
+ import type { Control, DatasetColumn, DurationUnit, ItemPrimitive, MoneyValue, OnHidePolicy, QuantityValue, OptionSource, Outcome, Primitive, ScalarWireValue } from '@azx-pbc/axiom-runtime';
2
+ import type { AuthoringAnnotations, AuthoringItem, AuthoringLayoutNode, AuthoringRowKey, AuthoringSuggestionOperation, AuthoringTestCase, ScalarPrimitive } from '../../schema/document.js';
3
+ import type { AuthoredHitPolicy } from '../../schema/dataset.js';
4
+ import type { TranslationEntry } from '../../i18n/translations.js';
5
+ import type { RuleExpression } from '../../visual/vocabulary.js';
6
+ /**
7
+ * The shape of every authoring intent, and the union a store dispatches.
8
+ *
9
+ * A command states one author's intent. It is deliberately narrower than the wire contract in
10
+ * the values it accepts, and deliberately as wide as the document the compiler admits: a member
11
+ * `spec/metaschema/schema.v1.json` requires has a command that writes it, and `coverage.ts`
12
+ * fails the gate when the metaschema grows one this file does not.
13
+ *
14
+ * Every command carries validated values. `parseCommand` is the only constructor of one, and it
15
+ * narrows untrusted input — a form state, a stored draft, a JSON round trip — into this union or
16
+ * a `MALFORMED_COMMAND` refusal. The union is what keeps a host's switch over intents
17
+ * exhaustive.
18
+ */
19
+ /** A path into the document's `layout` tree: the index of each child from the root. */
20
+ export type LayoutPath = readonly number[];
21
+ /** The rule kinds a command authors: every kind the metaschema's `rule.kind` enumerates. */
22
+ export type AuthoringRuleKind = 'validate' | 'visible' | 'required' | 'enabled' | 'compute' | 'defaultCompute' | 'gate' | 'screen';
23
+ /** One option a field declares at the moment it is added, with its literal label. */
24
+ export interface AddOptionSpec {
25
+ readonly code: string | number;
26
+ readonly label: string;
27
+ }
28
+ /**
29
+ * One write an alternative performs, as the author states it.
30
+ *
31
+ * The authored document and the command state one shape, so this names it rather than restating the
32
+ * members: an operation names a binding (`ref`), a row template or a row key, and every expression
33
+ * is the Expr v1 source an author writes. The compiler's parser is the one authority on meaning.
34
+ */
35
+ export type SuggestionOperationSpec = AuthoringSuggestionOperation;
36
+ /**
37
+ * One alternative a rule or an option offers, as the author states it.
38
+ *
39
+ * The label is the literal text a reader sees; the store mints the message key it is filed under
40
+ * from that text, exactly as it mints a field's label or an option's.
41
+ */
42
+ export interface SuggestionSpec {
43
+ readonly label: string;
44
+ readonly operations: readonly SuggestionOperationSpec[];
45
+ }
46
+ /**
47
+ * The availability one declared option states, `schema.v1.json` `option`.
48
+ *
49
+ * The condition, its reason and the alternatives it offers are edited as one fact, so replacing
50
+ * or clearing availability cannot leave a reason or an alternative attached to an old condition.
51
+ * A reason is optional where the host supplies the fallback sentence.
52
+ */
53
+ export interface OptionAvailabilitySpec {
54
+ /** The condition under which the option may be chosen, as Expr v1 source. */
55
+ readonly availableWhen: string;
56
+ /** The literal sentence a reader sees when the option is unavailable. */
57
+ readonly reason?: string;
58
+ /** The reason's message arguments, each an expression. */
59
+ readonly params?: Readonly<Record<string, string>>;
60
+ /** The alternatives the option offers while its held code is unavailable. */
61
+ readonly suggests?: readonly SuggestionSpec[];
62
+ }
63
+ /**
64
+ * States, replaces or clears one declared option's availability.
65
+ *
66
+ * A `null` availability clears every member the specification states, so an option can go back to
67
+ * being always available without being removed and re-added, which would lose its identity and
68
+ * every record that names its code. The option's own label and code are not editable here: they
69
+ * are the option's identity.
70
+ */
71
+ export interface SetOptionAvailabilityCommand {
72
+ readonly kind: 'setOptionAvailability';
73
+ readonly fieldId: string;
74
+ readonly code: string | number;
75
+ readonly availability: OptionAvailabilitySpec | null;
76
+ }
77
+ /**
78
+ * Replaces one validate rule's alternatives, or clears them.
79
+ *
80
+ * This is the suggestion-list edit on its own, for a host that offers the alternative editor
81
+ * without the rest of the rule payload. `editRule` states the same member; both reach the one
82
+ * document member, and the store refuses either on a rule whose kind states no verdict.
83
+ */
84
+ export interface SetRuleSuggestsCommand {
85
+ readonly kind: 'setRuleSuggests';
86
+ readonly ruleId: string;
87
+ readonly suggests: readonly SuggestionSpec[] | null;
88
+ }
89
+ /** The field a new declaration adds and the placement it gets. */
90
+ export interface AddFieldSpec {
91
+ readonly fieldId: string;
92
+ /** The literal label, written into `defaultLocale` under the minted `labelKey`. */
93
+ readonly label: string;
94
+ readonly primitive: ScalarPrimitive | 'array' | 'record';
95
+ readonly control?: Control;
96
+ /** Required on a scalar or attachment array; refused on a scalar field. */
97
+ readonly items?: ItemPrimitive;
98
+ readonly currency?: string;
99
+ readonly scale?: number;
100
+ /**
101
+ * A `quantity` field's unit domain, `MODEL-2.1.21`, or a `quantity` item's.
102
+ *
103
+ * It travels to the item declaration where the quantity is the array's element, the way
104
+ * `currency` and `scale` travel to a money item: the domain belongs to the declaration that
105
+ * holds the measured value.
106
+ */
107
+ readonly units?: readonly string[];
108
+ /** A `duration` field's unit, `MODEL-2.1.24`, or a `duration` item's. Defaults to `minutes`. */
109
+ readonly unit?: DurationUnit;
110
+ /**
111
+ * A number control's increment, `MODEL-2.1.16`: a positive safe integer on an `integer` field
112
+ * and positive canonical decimal text on a `decimal` one. Presentation only.
113
+ */
114
+ readonly step?: number | string;
115
+ /**
116
+ * A value bound and the literal sentence it raises, `MODEL-2.1.16`.
117
+ *
118
+ * The store mints `field.<trail>.minimum`/`.maximum`, exactly as it mints a label from `label`,
119
+ * so a caller states the author's words rather than a key derived from an id it may not know.
120
+ * The two members are a pair: a bound without its sentence is a declaration the compiler
121
+ * refuses, and `readFieldSpec` refuses it here with the repair.
122
+ */
123
+ readonly minimum?: number | string;
124
+ readonly maximum?: number | string;
125
+ readonly minimumMessage?: string;
126
+ readonly maximumMessage?: string;
127
+ /**
128
+ * A record's members: at least one, `minItems: 1`.
129
+ *
130
+ * A `record` is the one container `addField` authors, because a top-level record is a document
131
+ * declaration like any other and `FIELD_PALETTE` offers it. Refused on every other primitive,
132
+ * and a member's own placement is its container's, so a member spec states neither `parent`
133
+ * nor `colSpan`.
134
+ */
135
+ readonly members?: readonly MemberSpec[];
136
+ /**
137
+ * A scalar array's closed option domain, with a literal label per option.
138
+ *
139
+ * An array states either this or `rowKey`, never both and never neither: the metaschema makes
140
+ * an option-bearing array identified by its values and a freeform one identified by a row key.
141
+ * Options written here are minted exactly as `addOption` mints them.
142
+ */
143
+ readonly options?: readonly AddOptionSpec[];
144
+ /**
145
+ * Where the option domain comes from when the field declares no `options`, `schema.v1.json`
146
+ * `optionSource`. The two are two authorities for one domain, so a field states at most one.
147
+ */
148
+ readonly optionSource?: OptionSource;
149
+ /**
150
+ * A `signature_ref`'s bound targets: the `fieldId` of every value its signature signs, in
151
+ * binding order (`field.covers`, `CANON-4.1.1`).
152
+ *
153
+ * Mandatory on a `signature_capture` declaration, because a signature only binds what its
154
+ * coverage declares. Every target has to be declared before it is named, so a host adds the
155
+ * signed fields first; `setSignatureCovers` edits the list until the field is published.
156
+ */
157
+ readonly covers?: readonly string[];
158
+ /** How an array's rows are identified; required on a freeform array, refused elsewhere. */
159
+ readonly rowKey?: AuthoringRowKey;
160
+ /**
161
+ * Whether the declaration gets a layout leaf now.
162
+ *
163
+ * `append` (the default) places it at the top level or under `parent`. `none` declares the
164
+ * field without a placement, which is the draft state a later `placeField` completes: a
165
+ * declared field is not yet a presented one, and forcing a placement on every add would make
166
+ * the store invent a layout the author had not designed.
167
+ */
168
+ readonly placement?: 'append' | 'none';
169
+ readonly colSpan?: number;
170
+ readonly parent?: LayoutPath;
171
+ /**
172
+ * The position among `parent`'s children, with append when absent.
173
+ *
174
+ * A duplicate is placed immediately after its source and an "insert after this row" is the
175
+ * same fact; appending would make the author move the thing they just asked to place.
176
+ */
177
+ readonly index?: number;
178
+ readonly annotations?: AuthoringAnnotations;
179
+ }
180
+ /** A member field has no top-level placement; its container owns the layout leaf. */
181
+ export type MemberFieldSpec = Omit<AddFieldSpec, 'colSpan' | 'parent' | 'placement'>;
182
+ /** One member a container command adds: a field, or a nested record with its own members. */
183
+ export type MemberSpec = {
184
+ readonly kind: 'field';
185
+ readonly field: MemberFieldSpec;
186
+ } | {
187
+ readonly kind: 'record';
188
+ readonly recordId: string;
189
+ readonly members: readonly [MemberSpec, ...MemberSpec[]];
190
+ };
191
+ /** A repeating structure's declaration: its row key and the members one row holds. */
192
+ export interface AddRecordArraySpec {
193
+ readonly fieldId: string;
194
+ /**
195
+ * The literal label of the table itself, written into `defaultLocale` under the minted
196
+ * `labelKey`.
197
+ *
198
+ * A table is a declaration a reader sees as a region with a title, so it names itself the way
199
+ * every other authored field does. A host that authors a table for a person supplies one; the
200
+ * builder palette always does. Omitted, the declaration states no label key and a renderer has
201
+ * no text but the field id.
202
+ */
203
+ readonly label?: string;
204
+ readonly rowKey: AuthoringRowKey;
205
+ /** At least one row member: the metaschema's `fields` states `minItems: 1`. */
206
+ readonly members: readonly [MemberSpec, ...MemberSpec[]];
207
+ /** `append` (the default) places the array now; `none` leaves it for `placeField`. */
208
+ readonly placement?: 'append' | 'none';
209
+ readonly colSpan?: number;
210
+ readonly parent?: LayoutPath;
211
+ }
212
+ /**
213
+ * One declared field's editable metadata.
214
+ *
215
+ * An absent member is left as it is and a `null` removes it, so one command expresses "change the
216
+ * control", "give the field help text" and "drop its placeholder" without three shapes. Nothing an
217
+ * edit can state is part of a field's value domain: its `primitive`, `items`, `rowKey` and `options`
218
+ * are what a device reads a value against, so they are declaration decisions rather than edits
219
+ * (`setFieldPrimitive` is the one that changes a domain, and it keeps the field's identity).
220
+ */
221
+ export interface EditFieldSpec {
222
+ /** The semantic hint the field offers; the control matrix is the authority on the pairing. */
223
+ readonly control?: Control | null;
224
+ /** The message key a renderer shows as the field's help text. */
225
+ readonly descriptionKey?: string | null;
226
+ /** The message key a renderer shows as the field's empty-input placeholder. */
227
+ readonly placeholderKey?: string | null;
228
+ /** This declaration's own hiding policy, overriding the document's. */
229
+ readonly onHide?: OnHidePolicy | null;
230
+ /** The governed per-field annotations, replaced as one value. */
231
+ readonly annotations?: AuthoringAnnotations | null;
232
+ }
233
+ /**
234
+ * The field members that compile into a rule, as one edit states them.
235
+ *
236
+ * An absent member is left alone and a `null` removes it, so this is the same three-state edit
237
+ * `EditFieldSpec` states. A bound and the key of the sentence it raises are separate members
238
+ * because the metaschema states them separately; a caller changing one changes both, and the
239
+ * closed shape refuses a bound whose message key is missing. The expressions are Expr v1 source
240
+ * text, the spelling an authored document stores, so the compiler's parser is the authority on
241
+ * what they mean.
242
+ */
243
+ export interface FieldDeclarationSpec {
244
+ /** Whether the field must hold a value; compiles to a `required` rule. */
245
+ readonly required?: boolean | null;
246
+ /** The message key the required rule raises. */
247
+ readonly requiredMessageKey?: string | null;
248
+ /** The condition that requires the field; compiles to a `required` rule with that condition. */
249
+ readonly requiredWhen?: string | null;
250
+ /** The condition that reveals the field; compiles to a `visible` rule. */
251
+ readonly visibleWhen?: string | null;
252
+ /** The smallest and largest number of code points a string may hold. */
253
+ readonly minLength?: number | null;
254
+ readonly maxLength?: number | null;
255
+ readonly minLengthMessageKey?: string | null;
256
+ readonly maxLengthMessageKey?: string | null;
257
+ /** The smallest and largest number of entries an array may hold. */
258
+ readonly minItems?: number | null;
259
+ readonly maxItems?: number | null;
260
+ /**
261
+ * The largest number of fractional digits a `decimal` value may carry, `MODEL-2.1.27`, with
262
+ * the sentence an over-scale value states. A declared fact, not a rule, so it carries no
263
+ * evidence member.
264
+ */
265
+ readonly maxScale?: number | null;
266
+ readonly maxScaleMessageKey?: string | null;
267
+ /** An inclusive value bound: a number, or a `date`/`instant` written as canonical text. */
268
+ readonly minimum?: number | string | null;
269
+ readonly maximum?: number | string | null;
270
+ readonly minimumMessageKey?: string | null;
271
+ readonly maximumMessageKey?: string | null;
272
+ /**
273
+ * The increment a number control steps by, `MODEL-2.1.16`: a positive safe integer on an
274
+ * `integer` field, positive canonical decimal text on a `decimal` one.
275
+ */
276
+ readonly step?: number | string | null;
277
+ /**
278
+ * The media types a capture declaration admits, `MODEL-2.1.20`. The compiler canonicalises
279
+ * the lower-case spelling on the artifact and refuses an empty, malformed or duplicate entry.
280
+ */
281
+ readonly accept?: readonly string[] | null;
282
+ /** The smallest and largest `byteSize` a captured `media_ref` may carry, `MODEL-2.1.20`. */
283
+ readonly minBytes?: number | null;
284
+ readonly maxBytes?: number | null;
285
+ /**
286
+ * The Expr v1 integer source whose value is an array's expected row count, `MODEL-2.1.22`.
287
+ * The compiler compiles it and carries the text beside the AST; a non-integer, a negative
288
+ * literal and a count derived from the rows it sizes are refused by that pass.
289
+ */
290
+ readonly rowsFrom?: string | null;
291
+ /**
292
+ * The evidence for the rule each declaration compiles to, `RULES-3.1.1`.
293
+ *
294
+ * A case list sits beside the member it evidences; `null` clears the list, an absent member
295
+ * keeps it, and a stated list replaces it. The compiler copies the cases onto the synthesized
296
+ * rule, so the author never addresses `r_<fieldId>_…`.
297
+ */
298
+ readonly requiredTestCases?: readonly TestCaseSpec[] | null;
299
+ readonly visibleWhenTestCases?: readonly TestCaseSpec[] | null;
300
+ readonly minimumTestCases?: readonly TestCaseSpec[] | null;
301
+ readonly maximumTestCases?: readonly TestCaseSpec[] | null;
302
+ readonly minLengthTestCases?: readonly TestCaseSpec[] | null;
303
+ readonly maxLengthTestCases?: readonly TestCaseSpec[] | null;
304
+ }
305
+ /** Edits one declared field's members that compile into a rule. */
306
+ export interface SetFieldDeclarationCommand {
307
+ readonly kind: 'setFieldDeclaration';
308
+ readonly fieldId: string;
309
+ readonly declaration: FieldDeclarationSpec;
310
+ }
311
+ /** One item a gate states: its identity, its condition and the text it raises (`gateItem`). */
312
+ export interface GateItemSpec {
313
+ readonly itemId: string;
314
+ readonly expression: RuleExpression;
315
+ /** The literal message text, written into `defaultLocale` under the minted `messageKey`. */
316
+ readonly message: string;
317
+ /** The item's own message arguments, each an expression source. */
318
+ readonly params?: Readonly<Record<string, string>>;
319
+ }
320
+ /** A gate rule's own payload, `schema.v1.json` `rule.gate`. */
321
+ export interface GateSpec {
322
+ /** At least one item: the metaschema states `minItems: 1` on `gate.items`. */
323
+ readonly items: readonly [GateItemSpec, ...GateItemSpec[]];
324
+ readonly hard: boolean;
325
+ /** The condition that takes the gate out of force (`RULES-2.1.14`). */
326
+ readonly activeWhen?: RuleExpression;
327
+ /** A non-hard gate's policy for a read-only diagnostic; absent means `block`. */
328
+ readonly onReadOnlyError?: 'defer' | 'warn' | 'block';
329
+ }
330
+ /** One reason a screen states, `schema.v1.json` `screenReasonDeclaration`. */
331
+ export interface ScreenReasonSpec {
332
+ /** The stable problem the reason states; `diagnosticCode`'s upper-case grammar. */
333
+ readonly code: string;
334
+ readonly when: RuleExpression;
335
+ /** The literal message text, written into `defaultLocale` under the minted `messageKey`. */
336
+ readonly message: string;
337
+ /** The reason's own message arguments, each an expression source. */
338
+ readonly params?: Readonly<Record<string, string>>;
339
+ }
340
+ /**
341
+ * One embedded vector, as the metaschema's `testCase` states it.
342
+ *
343
+ * The authored shape is exactly `AuthoringTestCase`: a draft stores the case, and the compiler
344
+ * reads the same members. Reusing it rather than restating it is what keeps a command's evidence
345
+ * and the artifact's evidence one shape.
346
+ */
347
+ export type TestCaseSpec = AuthoringTestCase;
348
+ /** One rule a command adds. */
349
+ export interface AddRuleSpec {
350
+ readonly ruleId: string;
351
+ readonly kind: AuthoringRuleKind;
352
+ readonly scope: 'field' | 'record' | 'array' | 'item';
353
+ /**
354
+ * The rule's expression, as the editor holds it.
355
+ *
356
+ * A visual expression is stored as the printer's canonical source and a source expression is
357
+ * stored unchanged, so a rule created in the visual editor and one typed as source reach the
358
+ * document through this one member.
359
+ */
360
+ readonly expression: RuleExpression;
361
+ /**
362
+ * Why the rule exists, as author-facing documentation.
363
+ *
364
+ * Plain text of 1 to 500 characters after trimming; a blank note is refused at the member.
365
+ * It is never rendered and never translated, so it has no message key and no locale; it
366
+ * travels into the compiled artifact and is excluded from `behaviorHash`.
367
+ */
368
+ readonly note?: string;
369
+ readonly evaluateOn?: 'client' | 'server';
370
+ /**
371
+ * The verdict a failing `validate` rule states.
372
+ *
373
+ * A `validate` rule defaults to `block`, the value the closed metaschema requires it to state
374
+ * and the one a validation is for; every other kind states the severity it means, because a
375
+ * `visible` or `compute` rule has no verdict of its own.
376
+ */
377
+ readonly severity?: 'block' | 'warn' | 'info';
378
+ readonly fieldId?: string;
379
+ /**
380
+ * The fields a `visible` or `enabled` rule decides, for a rule that names more than one.
381
+ * `schema.v1.json` admits it only there, only at `record` scope, and never with `fieldId`.
382
+ */
383
+ readonly fieldIds?: readonly string[];
384
+ readonly targetFieldId?: string;
385
+ /**
386
+ * The literal message text, written into `defaultLocale` under `rule.<ruleId>`.
387
+ *
388
+ * Required wherever the metaschema requires a `messageKey`: a `validate`, `gate` or `screen`
389
+ * rule. The store mints the key from this text, so a rule that needs a message and states none
390
+ * is refused at the member rather than by a compile that cannot name the repair.
391
+ */
392
+ readonly message?: string;
393
+ readonly params?: Readonly<Record<string, string>>;
394
+ /** A screen rule's referral condition, `schema.v1.json` `rule.referWhen`. */
395
+ readonly referWhen?: RuleExpression;
396
+ /** A screen's declared reasons, in the order the report lists them. */
397
+ readonly reasons?: readonly ScreenReasonSpec[];
398
+ /** A `defaultCompute` rule's companion override field, `schema.v1.json` `overrideFieldId`. */
399
+ readonly overrideFieldId?: string;
400
+ /** A gate rule's own items and policy. */
401
+ readonly gate?: GateSpec;
402
+ /**
403
+ * The alternatives this rule offers when it decides `FAIL`, `RULES-6.1.1`.
404
+ *
405
+ * Admitted on `kind: validate` only, because every other kind states a branch rather than a
406
+ * verdict and an alternative to one names nothing. The store refuses the pair at the member, so
407
+ * an author reads the repair rather than a compile that has to name the same fact.
408
+ */
409
+ readonly suggests?: readonly SuggestionSpec[];
410
+ /** The vectors embedded on the rule, executed by `verifyPublishReadiness`. */
411
+ readonly testCases?: readonly TestCaseSpec[];
412
+ }
413
+ /**
414
+ * One declaration's new value domain.
415
+ *
416
+ * Changing a primitive is not a metadata edit: a device reads a value through `primitive`,
417
+ * `items`, `currency`, `scale` and the option or row identity, so all of them move together and
418
+ * the new declaration has to state the whole domain. The field's identity, its copy (label, help
419
+ * text, placeholder), its annotations and its layout placement stay. Declaration members that
420
+ * compile into rules — `required`, bounds and their evidence — belong to the old domain and are
421
+ * cleared, because a bound on a string is not a bound on an integer.
422
+ *
423
+ * A `record` is refused here: its members are its declaration, so a record is added and its old
424
+ * declaration removed rather than retyped underneath the members that depend on it.
425
+ */
426
+ export interface FieldPrimitiveSpec {
427
+ readonly primitive: ScalarPrimitive | 'array';
428
+ readonly control?: Control;
429
+ readonly items?: ItemPrimitive;
430
+ readonly currency?: string;
431
+ readonly scale?: number;
432
+ /** A `quantity` declaration's unit domain, as `addField` states it. */
433
+ readonly units?: readonly string[];
434
+ /** A `duration` declaration's unit, as `addField` states it. */
435
+ readonly unit?: DurationUnit;
436
+ /** An option-bearing array's closed domain; a scalar field's options are stated here too. */
437
+ readonly options?: readonly AddOptionSpec[];
438
+ /** How an array's rows are identified; required on a freeform array. */
439
+ readonly rowKey?: AuthoringRowKey;
440
+ /** A `signature_ref`'s bound targets, as `addField` states them. */
441
+ readonly covers?: readonly string[];
442
+ }
443
+ /**
444
+ * One rule's new payload, as an edit states it.
445
+ *
446
+ * The rule's `ruleId`, `kind` and `scope` are its identity (`RULES-1.1.2`): an edit keeps all
447
+ * three, so a case, a gate override or a layout step that names the rule keeps naming it. A rule
448
+ * whose kind has to change is a second rule with its own id.
449
+ *
450
+ * An absent member is left alone and a `null` removes it, matching `EditFieldSpec`. `gate`,
451
+ * `reasons` and `testCases` replace the whole list they state: a gate item or a screen reason is
452
+ * identified by its own id, and reusing the id the rule already stated keeps its message key and
453
+ * its translations.
454
+ */
455
+ export interface EditRuleSpec {
456
+ /** The expression the editor now holds; the printer stores a visual form as canonical source. */
457
+ readonly expression?: RuleExpression;
458
+ readonly evaluateOn?: 'client' | 'server';
459
+ readonly severity?: 'block' | 'warn' | 'info' | null;
460
+ readonly fieldId?: string | null;
461
+ readonly fieldIds?: readonly string[] | null;
462
+ readonly targetFieldId?: string | null;
463
+ /** The literal text under `rule.<ruleId>`; `null` removes the key. */
464
+ readonly message?: string | null;
465
+ readonly params?: Readonly<Record<string, string>> | null;
466
+ readonly referWhen?: RuleExpression | null;
467
+ /** A screen's reasons, replacing the list; a reason whose code it already stated keeps its text. */
468
+ readonly reasons?: readonly ScreenReasonSpec[] | null;
469
+ readonly overrideFieldId?: string | null;
470
+ /** A gate's items and policy, replacing the payload; a gate keeps its own message key. */
471
+ readonly gate?: GateEditSpec | null;
472
+ /** The alternatives the rule offers on `FAIL`, replacing the list; `null` removes it. */
473
+ readonly suggests?: readonly SuggestionSpec[] | null;
474
+ /** The vectors embedded on the rule, replacing the list; `null` removes it. */
475
+ readonly testCases?: readonly TestCaseSpec[] | null;
476
+ }
477
+ /** A gate payload as an edit states it. */
478
+ export interface GateEditSpec {
479
+ readonly items: readonly [GateItemSpec, ...GateItemSpec[]];
480
+ readonly hard: boolean;
481
+ readonly activeWhen?: RuleExpression | null;
482
+ readonly onReadOnlyError?: 'defer' | 'warn' | 'block' | null;
483
+ }
484
+ /** One read-only evaluation root, `schema.v1.json` `contextRoot`. */
485
+ export interface ContextRootSpec {
486
+ readonly path: string;
487
+ readonly primitive: Primitive;
488
+ readonly nullability?: 'required' | 'optional';
489
+ /** A scalar or attachment array root's item domain, as a field declares one. */
490
+ readonly items?: AuthoringItem;
491
+ /**
492
+ * The value domain a `money`, `quantity` or `duration` root declares, spelled as a field spells
493
+ * it: a currency and scale, a unit domain and scale, or a duration unit. A host fact is read
494
+ * against this domain, so a number where the root declares `money<AUD, 2>` is a host bug the
495
+ * engine names rather than a value it coerces.
496
+ */
497
+ readonly currency?: string;
498
+ readonly scale?: number;
499
+ readonly units?: readonly string[];
500
+ readonly unit?: 'minutes' | 'hours' | 'seconds';
501
+ }
502
+ /** One table a document names, with the version it was compiled against. */
503
+ export interface DatasetPinSpec {
504
+ readonly tableId: string;
505
+ readonly tableVersion: number;
506
+ }
507
+ interface AddFieldCommand {
508
+ readonly kind: 'addField';
509
+ readonly field: AddFieldSpec;
510
+ }
511
+ interface AddOptionCommand {
512
+ readonly kind: 'addOption';
513
+ readonly fieldId: string;
514
+ readonly code: string | number;
515
+ readonly label: string;
516
+ }
517
+ /** Edits one declared field's metadata. */
518
+ export interface EditFieldCommand {
519
+ readonly kind: 'editField';
520
+ readonly fieldId: string;
521
+ readonly field: EditFieldSpec;
522
+ }
523
+ /**
524
+ * Retires one option of a field's domain.
525
+ *
526
+ * A code is an identity: existing records and signatures name it, so an option is retired rather
527
+ * than deleted, and a renderer keeps showing it as retired.
528
+ */
529
+ export interface DeprecateOptionCommand {
530
+ readonly kind: 'deprecateOption';
531
+ readonly fieldId: string;
532
+ readonly code: string | number;
533
+ }
534
+ /**
535
+ * Moves one declared option to a position in its field's domain.
536
+ *
537
+ * The code is the option's identity and never changes: a record, a signature or a rule names it,
538
+ * so reordering is presentation and the domain's members move while their values stay. A code the
539
+ * field does not declare is refused; an index is clamped to the domain, exactly as a layout move
540
+ * clamps its destination.
541
+ */
542
+ interface MoveOptionCommand {
543
+ readonly kind: 'moveOption';
544
+ readonly fieldId: string;
545
+ readonly code: string | number;
546
+ readonly index: number;
547
+ }
548
+ export interface AddRuleCommand {
549
+ readonly kind: 'addRule';
550
+ readonly rule: AddRuleSpec;
551
+ }
552
+ /** Appends one embedded vector to a declared rule. */
553
+ export interface AddRuleTestCaseCommand {
554
+ readonly kind: 'addRuleTestCase';
555
+ readonly ruleId: string;
556
+ readonly testCase: TestCaseSpec;
557
+ }
558
+ /** Replaces one declared rule's expression: the visual or source form the editor now holds. */
559
+ export interface SetRuleExprCommand {
560
+ readonly kind: 'setRuleExpr';
561
+ readonly ruleId: string;
562
+ readonly expression: RuleExpression;
563
+ }
564
+ /**
565
+ * Replaces one declared rule's author-facing note.
566
+ *
567
+ * The note documents why the rule exists; it is never rendered, never translated and is not a
568
+ * message key. A blank note is refused at the member (`MALFORMED_COMMAND`), so this command
569
+ * cannot empty the documentation it exists to write.
570
+ */
571
+ export interface SetRuleNoteCommand {
572
+ readonly kind: 'setRuleNote';
573
+ readonly ruleId: string;
574
+ readonly note: string;
575
+ }
576
+ /**
577
+ * Replaces one declared rule's payload, keeping its id, kind and scope.
578
+ *
579
+ * This is the command that makes a gate item's condition, a gate's `hard` flag, a screen's reasons
580
+ * and a rule's severity editable after `addRule`. The store refuses an edit whose result would
581
+ * still be two rules with one id, and a rule the caller's published baseline names is edited here
582
+ * on purpose: moving behaviour is what a new edition is for, and the publish diff refuses the
583
+ * same version. Removing a published rule is refused instead (`removeRule`).
584
+ */
585
+ export interface EditRuleCommand {
586
+ readonly kind: 'editRule';
587
+ readonly ruleId: string;
588
+ readonly rule: EditRuleSpec;
589
+ }
590
+ /** Removes one declared rule; a published rule id is permanent and is refused. */
591
+ export interface RemoveRuleCommand {
592
+ readonly kind: 'removeRule';
593
+ readonly ruleId: string;
594
+ }
595
+ interface SetMessageTextCommand {
596
+ readonly kind: 'setMessageText';
597
+ readonly messageKey: string;
598
+ readonly locale: string;
599
+ readonly text: string;
600
+ }
601
+ interface DeprecateFieldCommand {
602
+ readonly kind: 'deprecateField';
603
+ readonly fieldId: string;
604
+ }
605
+ /**
606
+ * Removes one unpublished declaration and every layout reference to it.
607
+ *
608
+ * `EVOL-3.1.2` forbids deleting a declaration the published revision states, so a field the
609
+ * baseline names is refused: a published field is retired with `deprecateField`, which keeps the
610
+ * declaration and the values recorded under it readable. For a draft's own field removal is safe
611
+ * only while nothing else names it, so a rule read or target, a signature's coverage, another
612
+ * field's option source or row key, and an unreadable expression slot are all refused first.
613
+ */
614
+ export interface RemoveFieldCommand {
615
+ readonly kind: 'removeField';
616
+ readonly fieldId: string;
617
+ }
618
+ /** Changes one unpublished declaration's value domain, keeping its id and copy. */
619
+ export interface SetFieldPrimitiveCommand {
620
+ readonly kind: 'setFieldPrimitive';
621
+ readonly fieldId: string;
622
+ readonly field: FieldPrimitiveSpec;
623
+ }
624
+ interface AddLayoutNodeCommand {
625
+ readonly kind: 'addLayoutNode';
626
+ /** The node as the layout grammar spells it; the compiler's walk is the authority on it. */
627
+ readonly node: AuthoringLayoutNode;
628
+ readonly parent?: LayoutPath;
629
+ }
630
+ interface SetGroupColumnsCommand {
631
+ readonly kind: 'setGroupColumns';
632
+ readonly group: LayoutPath;
633
+ readonly columns: number;
634
+ }
635
+ /**
636
+ * Edits the members of the layout node at a path.
637
+ *
638
+ * The node's members are merged over the node that is there, so a caller states what it changed:
639
+ * an absent member is left as it is and a `null` removes it, which is how an author clears a
640
+ * conditional or a label they set earlier. Three members are not editable here because each has a
641
+ * command that owns it: `kind` is the node's identity, `children` is the tree below it
642
+ * (`addLayoutNode`, `removeLayoutNode`), and a group's `columns` narrows its children and reports
643
+ * what it narrowed (`setGroupColumns`).
644
+ */
645
+ export interface EditLayoutNodeCommand {
646
+ readonly kind: 'editLayoutNode';
647
+ readonly target: LayoutPath;
648
+ readonly node: AuthoringLayoutNode;
649
+ }
650
+ /** Removes the layout node at a path, and everything below it. */
651
+ export interface RemoveLayoutNodeCommand {
652
+ readonly kind: 'removeLayoutNode';
653
+ readonly target: LayoutPath;
654
+ }
655
+ /** Places a declared field that has no layout leaf yet. */
656
+ export interface PlaceFieldCommand {
657
+ readonly kind: 'placeField';
658
+ readonly fieldId: string;
659
+ readonly parent?: LayoutPath;
660
+ readonly colSpan?: number;
661
+ }
662
+ /** Removes the node at `target` and places it under `parent` at `index` (append when absent). */
663
+ export interface MoveLayoutNodeCommand {
664
+ readonly kind: 'moveLayoutNode';
665
+ readonly target: LayoutPath;
666
+ readonly parent?: LayoutPath;
667
+ /** The position among the destination's children after the node has been removed. */
668
+ readonly index?: number;
669
+ }
670
+ /**
671
+ * Replaces the document's locale policy: the set every catalogue entry is complete in, and the one
672
+ * a renderer shows by default.
673
+ *
674
+ * The two members are one fact — the default has to be one of the set — so one command states both
675
+ * and no intermediate state can declare a default the set does not carry. Adding a language, moving
676
+ * the default and dropping a language are the same edit with different arguments.
677
+ */
678
+ export interface SetLocalesCommand {
679
+ readonly kind: 'setLocales';
680
+ readonly locales: readonly string[];
681
+ readonly defaultLocale: string;
682
+ }
683
+ export interface AddRecordArrayCommand {
684
+ readonly kind: 'addRecordArray';
685
+ readonly array: AddRecordArraySpec;
686
+ }
687
+ interface AddRowMemberCommand {
688
+ readonly kind: 'addRowMember';
689
+ readonly arrayFieldId: string;
690
+ readonly member: MemberSpec;
691
+ }
692
+ interface AddRecordMemberCommand {
693
+ readonly kind: 'addRecordMember';
694
+ readonly parentFieldId: string;
695
+ readonly member: MemberSpec;
696
+ }
697
+ interface SetRowKeyCommand {
698
+ readonly kind: 'setRowKey';
699
+ readonly fieldId: string;
700
+ readonly rowKey: AuthoringRowKey;
701
+ }
702
+ interface SetSchemaVersionCommand {
703
+ readonly kind: 'setSchemaVersion';
704
+ /** The edition the draft now states; it must advance past the version it holds. */
705
+ readonly schemaVersion: number;
706
+ }
707
+ interface ImportTranslationsCommand {
708
+ readonly kind: 'importTranslations';
709
+ readonly translations: readonly TranslationEntry[];
710
+ }
711
+ /** Declares or repoints a section's primary designation. */
712
+ export interface SetPrimaryCommand {
713
+ readonly kind: 'setPrimary';
714
+ readonly ruleKind: 'gate' | 'screen';
715
+ readonly ruleId: string;
716
+ }
717
+ /** Declares a table version this document resolves against (`schema.v1.json` `datasetRef`). */
718
+ export interface PinDatasetCommand {
719
+ readonly kind: 'pinDataset';
720
+ readonly tableId: string;
721
+ readonly tableVersion: number;
722
+ }
723
+ /** Removes a dataset pin by table id. */
724
+ export interface UnpinDatasetCommand {
725
+ readonly kind: 'unpinDataset';
726
+ readonly tableId: string;
727
+ }
728
+ /** Declares or replaces one read-only evaluation root. */
729
+ export interface SetContextRootCommand {
730
+ readonly kind: 'setContextRoot';
731
+ readonly root: ContextRootSpec;
732
+ }
733
+ /** Removes a declared context root by path. */
734
+ export interface RemoveContextRootCommand {
735
+ readonly kind: 'removeContextRoot';
736
+ readonly path: string;
737
+ }
738
+ /** Replaces the document-level hiding policy, or clears it when `null`. */
739
+ export interface SetOnHideCommand {
740
+ readonly kind: 'setOnHide';
741
+ readonly onHide: OnHidePolicy | null;
742
+ }
743
+ /** Sets the document's title, minted under the `title` message key. */
744
+ export interface SetDocumentTitleCommand {
745
+ readonly kind: 'setDocumentTitle';
746
+ readonly text: string;
747
+ }
748
+ /** Binds a `signature_ref` declaration to the field ids it signs (`field.covers`). */
749
+ export interface SetSignatureCoversCommand {
750
+ readonly kind: 'setSignatureCovers';
751
+ readonly fieldId: string;
752
+ readonly covers: readonly string[];
753
+ }
754
+ /** Every intent the store accepts. */
755
+ export type AuthoringCommand = AddFieldCommand | AddOptionCommand | EditFieldCommand | SetFieldDeclarationCommand | DeprecateOptionCommand | MoveOptionCommand | SetOptionAvailabilityCommand | AddRuleCommand | AddRuleTestCaseCommand | SetRuleExprCommand | SetRuleNoteCommand | SetRuleSuggestsCommand | EditRuleCommand | RemoveRuleCommand | SetMessageTextCommand | DeprecateFieldCommand | RemoveFieldCommand | SetFieldPrimitiveCommand | AddLayoutNodeCommand | EditLayoutNodeCommand | RemoveLayoutNodeCommand | SetGroupColumnsCommand | PlaceFieldCommand | MoveLayoutNodeCommand | AddRecordArrayCommand | AddRowMemberCommand | AddRecordMemberCommand | SetRowKeyCommand | SetLocalesCommand | SetSchemaVersionCommand | ImportTranslationsCommand | SetPrimaryCommand | PinDatasetCommand | UnpinDatasetCommand | SetContextRootCommand | RemoveContextRootCommand | SetOnHideCommand | SetDocumentTitleCommand | SetSignatureCoversCommand;
756
+ /**
757
+ * One typed cell a command writes.
758
+ *
759
+ * The `kind` is the declared column's primitive, so the command states the type it means and the
760
+ * store compares it with the column rather than coercing text into whatever the column holds. A
761
+ * value is the canonical wire spelling of that primitive; `parseDatasetCommand` is the only
762
+ * constructor of one, so a half-typed grid cell is refused at the member before it reaches a table.
763
+ */
764
+ export type DatasetCellInput = {
765
+ readonly kind: 'string';
766
+ readonly value: string;
767
+ } | {
768
+ readonly kind: 'boolean';
769
+ readonly value: boolean;
770
+ } | {
771
+ readonly kind: 'integer';
772
+ readonly value: number;
773
+ } | {
774
+ readonly kind: 'decimal';
775
+ readonly value: string;
776
+ } | {
777
+ readonly kind: 'money';
778
+ readonly value: MoneyValue;
779
+ }
780
+ /**
781
+ * A measured quantity, `MODEL-2.1.21`.
782
+ *
783
+ * A quantity is a dataset scalar (`dataset.v1.json` `$defs.scalarPrimitive`) and a column may
784
+ * declare one, so the cell kind is the same vocabulary the column states. The required
785
+ * `unit` is the value's own; the column's declared unit domain and scale are checked against
786
+ * this pair where the cell is read, not left to the compile.
787
+ */
788
+ | {
789
+ readonly kind: 'quantity';
790
+ readonly value: QuantityValue;
791
+ } | {
792
+ readonly kind: 'date';
793
+ readonly value: string;
794
+ } | {
795
+ readonly kind: 'instant';
796
+ readonly value: string;
797
+ };
798
+ /**
799
+ * One row a command adds or replaces.
800
+ *
801
+ * Every member the metaschema's `row` states is here: the identity, the composite key and — when
802
+ * the table kind states them — the verdict and the output. Which of `outcome`/`output` the table
803
+ * requires is the table's answer, so the store decides it against the table it holds and refuses
804
+ * with `INVALID_ROW` rather than parsing the same rule twice.
805
+ */
806
+ export interface DatasetRowSpec {
807
+ readonly rowId: string;
808
+ /** One cell per key column, in declaration order (`DATA-1.2.3`). */
809
+ readonly key: readonly DatasetCellInput[];
810
+ /** A decision row's verdict; absent on a lookup row. */
811
+ readonly outcome?: Outcome;
812
+ /** The output record's cells, keyed by each output column's `columnId`. */
813
+ readonly output?: Readonly<Record<string, DatasetCellInput>>;
814
+ }
815
+ /** Appends one row to a keyed table. */
816
+ export interface AddDatasetRowCommand {
817
+ readonly kind: 'addDatasetRow';
818
+ readonly tableId: string;
819
+ readonly row: DatasetRowSpec;
820
+ }
821
+ /** Replaces one row's key, verdict and output, addressed by its `rowId`. */
822
+ export interface ReplaceDatasetRowCommand {
823
+ readonly kind: 'replaceDatasetRow';
824
+ readonly tableId: string;
825
+ readonly rowId: string;
826
+ readonly row: DatasetRowSpec;
827
+ }
828
+ /** Removes one row, addressed by its `rowId`. */
829
+ export interface RemoveDatasetRowCommand {
830
+ readonly kind: 'removeDatasetRow';
831
+ readonly tableId: string;
832
+ readonly rowId: string;
833
+ }
834
+ /** Writes one cell of one row, with the typed value its column's primitive requires. */
835
+ export interface SetDatasetCellCommand {
836
+ readonly kind: 'setDatasetCell';
837
+ readonly tableId: string;
838
+ readonly rowId: string;
839
+ readonly columnId: string;
840
+ readonly input: DatasetCellInput;
841
+ }
842
+ /** Declares a keyed table's columns, and with them its composite key (`DATA-1.2.2`). */
843
+ export interface SetDatasetColumnsCommand {
844
+ readonly kind: 'setDatasetColumns';
845
+ readonly tableId: string;
846
+ readonly columns: readonly DatasetColumn[];
847
+ }
848
+ /** Replaces a set table's closed membership domain. */
849
+ export interface SetDatasetValuesCommand {
850
+ readonly kind: 'setDatasetValues';
851
+ readonly tableId: string;
852
+ readonly values: readonly ScalarWireValue[];
853
+ }
854
+ /** States a keyed table's hit policy and, for `COLLECT`, its cap (`DATA-3.1.5`). */
855
+ export interface SetDatasetHitPolicyCommand {
856
+ readonly kind: 'setDatasetHitPolicy';
857
+ readonly tableId: string;
858
+ readonly policy: AuthoredHitPolicy;
859
+ }
860
+ /** States a `data` table's half-open effective range (`DATA-2.1.3`). */
861
+ export interface SetDatasetEffectiveRangeCommand {
862
+ readonly kind: 'setDatasetEffectiveRange';
863
+ readonly tableId: string;
864
+ readonly effectiveFrom: string;
865
+ readonly effectiveTo: string;
866
+ }
867
+ /** Every intent a dataset store accepts. */
868
+ export type DatasetCommand = AddDatasetRowCommand | ReplaceDatasetRowCommand | RemoveDatasetRowCommand | SetDatasetCellCommand | SetDatasetColumnsCommand | SetDatasetValuesCommand | SetDatasetHitPolicyCommand | SetDatasetEffectiveRangeCommand;
869
+ /**
870
+ * The coalescing identity of a dataset command, or `undefined` when it never coalesces.
871
+ *
872
+ * Typing into one grid cell is one edit however many values the field reports while the author
873
+ * types, so consecutive `setDatasetCell` commands for the same `(tableId, rowId, columnId)` merge
874
+ * into one undo step. Nothing else merges: a row replacement is a discrete decision, not a
875
+ * keystroke.
876
+ */
877
+ export declare function datasetCoalesceKeyOf(command: DatasetCommand): string | undefined;
878
+ /**
879
+ * The coalescing identity of a command, or `undefined` when it never coalesces.
880
+ *
881
+ * Typing into one field's text produces one undo entry however many keystrokes arrive: the store
882
+ * merges consecutive `setMessageText` for the same `(messageKey, locale)` because each keystroke
883
+ * is a revision of one edit. Nothing else merges, and there is no clock — the key is the whole
884
+ * identity, so a replayed sequence coalesces the same way it did live.
885
+ */
886
+ export declare function coalesceKeyOf(command: AuthoringCommand): string | undefined;
887
+ /** Every command kind, as the vocabulary a refusal and the coverage gate read. */
888
+ export declare const COMMAND_KINDS: readonly AuthoringCommand['kind'][];
889
+ /** Every dataset command kind, as the vocabulary a refusal and the coverage gate read. */
890
+ export declare const DATASET_COMMAND_KINDS: readonly DatasetCommand['kind'][];
891
+ /**
892
+ * The dataset vocabulary as a total map.
893
+ *
894
+ * A new member of `DatasetCommand` is a missing key here, which is a typecheck failure, so the
895
+ * refusal text and the test that counts kinds cannot drift from the union. An extra key is an
896
+ * excess-property error, so the map cannot claim a command the union does not declare.
897
+ */
898
+ export declare const DATASET_COMMAND_KIND_SET: Readonly<Record<DatasetCommand['kind'], true>>;
899
+ export {};
900
+ //# sourceMappingURL=shapes.d.ts.map