@azx-pbc/axiom-form-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 +231 -2
- package/dist/bridge/index.d.ts +12 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +10 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/bridge/inspector-commands.d.ts +55 -0
- package/dist/bridge/inspector-commands.d.ts.map +1 -0
- package/dist/bridge/inspector-commands.js +532 -0
- package/dist/bridge/inspector-commands.js.map +1 -0
- package/dist/bridge/rule-context.d.ts +57 -0
- package/dist/bridge/rule-context.d.ts.map +1 -0
- package/dist/bridge/rule-context.js +302 -0
- package/dist/bridge/rule-context.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/inspector.d.ts +125 -0
- package/dist/inspector.d.ts.map +1 -0
- package/dist/inspector.js +2 -0
- package/dist/inspector.js.map +1 -0
- package/dist/reference/ReferencePicker.d.ts +59 -0
- package/dist/reference/ReferencePicker.d.ts.map +1 -0
- package/dist/reference/ReferencePicker.js +145 -0
- package/dist/reference/ReferencePicker.js.map +1 -0
- package/dist/reference/index.d.ts +13 -0
- package/dist/reference/index.d.ts.map +1 -0
- package/dist/reference/index.js +11 -0
- package/dist/reference/index.js.map +1 -0
- package/dist/reference/token.d.ts +44 -0
- package/dist/reference/token.d.ts.map +1 -0
- package/dist/reference/token.js +141 -0
- package/dist/reference/token.js.map +1 -0
- package/dist/reference/types.d.ts +49 -0
- package/dist/reference/types.d.ts.map +1 -0
- package/dist/reference/types.js +2 -0
- package/dist/reference/types.js.map +1 -0
- package/dist/rules/ConditionEditor.d.ts +38 -0
- package/dist/rules/ConditionEditor.d.ts.map +1 -0
- package/dist/rules/ConditionEditor.js +79 -0
- package/dist/rules/ConditionEditor.js.map +1 -0
- package/dist/rules/RuleBuilder.d.ts +76 -0
- package/dist/rules/RuleBuilder.d.ts.map +1 -0
- package/dist/rules/RuleBuilder.js +336 -0
- package/dist/rules/RuleBuilder.js.map +1 -0
- package/dist/rules/RuleList.d.ts +45 -0
- package/dist/rules/RuleList.d.ts.map +1 -0
- package/dist/rules/RuleList.js +62 -0
- package/dist/rules/RuleList.js.map +1 -0
- package/dist/rules/RuleMessageEditor.d.ts +38 -0
- package/dist/rules/RuleMessageEditor.d.ts.map +1 -0
- package/dist/rules/RuleMessageEditor.js +38 -0
- package/dist/rules/RuleMessageEditor.js.map +1 -0
- package/dist/rules/ValidationEditor.d.ts +60 -0
- package/dist/rules/ValidationEditor.d.ts.map +1 -0
- package/dist/rules/ValidationEditor.js +299 -0
- package/dist/rules/ValidationEditor.js.map +1 -0
- package/dist/rules/condition.d.ts +12 -0
- package/dist/rules/condition.d.ts.map +1 -0
- package/dist/rules/condition.js +46 -0
- package/dist/rules/condition.js.map +1 -0
- package/dist/rules/expression.d.ts +57 -0
- package/dist/rules/expression.d.ts.map +1 -0
- package/dist/rules/expression.js +286 -0
- package/dist/rules/expression.js.map +1 -0
- package/dist/rules/index.d.ts +28 -0
- package/dist/rules/index.d.ts.map +1 -0
- package/dist/rules/index.js +19 -0
- package/dist/rules/index.js.map +1 -0
- package/dist/rules/messages.d.ts +64 -0
- package/dist/rules/messages.d.ts.map +1 -0
- package/dist/rules/messages.js +114 -0
- package/dist/rules/messages.js.map +1 -0
- package/dist/rules/operators.d.ts +25 -0
- package/dist/rules/operators.d.ts.map +1 -0
- package/dist/rules/operators.js +128 -0
- package/dist/rules/operators.js.map +1 -0
- package/dist/rules/sentence.d.ts +151 -0
- package/dist/rules/sentence.d.ts.map +1 -0
- package/dist/rules/sentence.js +527 -0
- package/dist/rules/sentence.js.map +1 -0
- package/dist/rules/templates.d.ts +163 -0
- package/dist/rules/templates.d.ts.map +1 -0
- package/dist/rules/templates.js +560 -0
- package/dist/rules/templates.js.map +1 -0
- package/dist/rules/types.d.ts +209 -0
- package/dist/rules/types.d.ts.map +1 -0
- package/dist/rules/types.js +2 -0
- package/dist/rules/types.js.map +1 -0
- package/dist/rules/validation-editor-api.d.ts +12 -0
- package/dist/rules/validation-editor-api.d.ts.map +1 -0
- package/dist/rules/validation-editor-api.js +12 -0
- package/dist/rules/validation-editor-api.js.map +1 -0
- package/dist/rules/validation.d.ts +27 -0
- package/dist/rules/validation.d.ts.map +1 -0
- package/dist/rules/validation.js +184 -0
- package/dist/rules/validation.js.map +1 -0
- package/dist/styles.css +900 -0
- package/package.json +65 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AZX, PBC. Open Source
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,232 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @azx-pbc/axiom-form-builder
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The authoring **surfaces** for Axiom, as a package you mount in your own React 19 application. It is
|
|
4
|
+
the interface half of the pair whose store half is [`@azx-pbc/axiom-builder`](https://github.com/AZX-PBC-OSS/axiom/blob/main/packages/builder/README.md):
|
|
5
|
+
the rule builder, the rule list, the message editor, the condition and validation editors, and the
|
|
6
|
+
reference picker an expression inserts a field token from — plus the vocabulary a host's own
|
|
7
|
+
selected-row pane speaks.
|
|
8
|
+
|
|
9
|
+
It is not an editor application. A tray of question shapes, a canvas of rows and a selected-row rail
|
|
10
|
+
are pixels, keyboard models and a design system, and this package ships none of the three: no icon
|
|
11
|
+
set, no primitive library, no component-injection prop. The host's own components render over the
|
|
12
|
+
builder's store: [`examples/studio/src/editor`](https://github.com/AZX-PBC-OSS/axiom/tree/main/examples/studio/src/editor)
|
|
13
|
+
is the reference shell. That is what lets a host keep its kit and still take the authoring surfaces.
|
|
14
|
+
An opt-in editor package that owns a kit is a designed follow-up, not part of this release (see
|
|
15
|
+
"Accepted gaps" in [`spec/release/evidence.md`](https://github.com/AZX-PBC-OSS/axiom/blob/main/spec/release/evidence.md)).
|
|
16
|
+
|
|
17
|
+
The components are **controlled**. Each one reads the document (or the descriptors) it is handed
|
|
18
|
+
and reports what the author asked for; none of them creates a store, persists a draft, calls the
|
|
19
|
+
publish gate, or keeps a second copy of the document.
|
|
20
|
+
|
|
21
|
+
React `^19` is a peer dependency. The manifest states Node `>=24` for the build tools; the modules
|
|
22
|
+
themselves run wherever React 19 and a DOM do.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
pnpm add @azx-pbc/axiom-form-builder react@^19
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Three workspace siblings come with it: `@azx-pbc/axiom-builder` is the store the surfaces
|
|
31
|
+
dispatch to and the model their descriptors are projected from, `@azx-pbc/axiom-compiler` is the
|
|
32
|
+
expression parser and printer the rule editors read a source with, and `@azx-pbc/axiom-runtime`
|
|
33
|
+
supplies the expression evaluation those editors use. They install as one version.
|
|
34
|
+
|
|
35
|
+
The package publishes two doors: `.` (the surfaces and the vocabulary) and `./styles.css` (the
|
|
36
|
+
token contract and the surfaces' rules, one file). Import the stylesheet once, near your
|
|
37
|
+
application root:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import '@azx-pbc/axiom-form-builder/styles.css';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`sideEffects` is `["*.css"]`: every JavaScript module here is free of import-time work, and the
|
|
44
|
+
stylesheet is the one file a bundler must keep. The theme is a token contract — an adopter may
|
|
45
|
+
replace the file or override a token in place, and the `.ax-*` and `.axb-*` class hooks and state
|
|
46
|
+
attributes the surfaces render stay the same.
|
|
47
|
+
|
|
48
|
+
## What it exports
|
|
49
|
+
|
|
50
|
+
| Export | What it is | What it emits |
|
|
51
|
+
| ------------------- | -------------------------------------------------------------------------------------------------------- | ------------------------------------- |
|
|
52
|
+
| `RuleBuilder` | The when/then editor: a sentence template, the questions it reads, and the expression it builds. | A complete `EmittedRule` on commit. |
|
|
53
|
+
| `RuleList` | Every declared rule as one sentence, its own expression and its latest status. | Edit and remove callbacks by rule id. |
|
|
54
|
+
| `RuleMessageEditor` | One rule message per declared locale. | The next catalogue rows. |
|
|
55
|
+
| `ConditionEditor` | One condition, composed with `and`, `or` and `not`, as a sentence over the document's fields and tables. | The next condition draft. |
|
|
56
|
+
| `ValidationEditor` | One validation: operator, operands, severity and a message per locale. | A `ValidationDraft`. |
|
|
57
|
+
| `ReferencePicker` | The searchable field list an expression inserts a `$F1`-style token from. | The chosen field reference. |
|
|
58
|
+
|
|
59
|
+
Beside the components the door carries the vocabulary a host would otherwise re-derive:
|
|
60
|
+
|
|
61
|
+
- **The rule catalogue**: `RULE_TEMPLATES`, `ruleTemplateNeedsMessage`, `defaultRuleTemplateDraft`,
|
|
62
|
+
`defaultValidationDraft`, `defaultOperatorFor`, `validationExpression`, `withValidationField`,
|
|
63
|
+
`withValidationOperator`.
|
|
64
|
+
- **The projections a list and a message pane render**: `ruleSentence`,
|
|
65
|
+
`RuleSentenceLabels`/`DEFAULT_RULE_SENTENCE_LABELS`, `messageRows`, `missingMessageLocales`,
|
|
66
|
+
`copyMessageFromDefault`, `renameMessageKey`.
|
|
67
|
+
- **The tables a decision-table template reads**: `RuleTable` and `RuleTableColumn`.
|
|
68
|
+
- **The reference tokens an expression stores**: `referenceIndex`, `referenceTokenOf`,
|
|
69
|
+
`resolveReferenceField`, `resolveReferenceToken`, `insertReferenceAtCaret`,
|
|
70
|
+
`insertTokenAtCaret`, `resolveTokensInSource`.
|
|
71
|
+
- **The document-bridge helpers**: `ruleContextOf`, `readableRulesOf`, `commandsForRule`,
|
|
72
|
+
`commandsForInspectorChange`, `freshRuleId`, and `capabilityRuleId`, with their option and
|
|
73
|
+
outcome types (`RuleContextOptions`, `RuleCommandOptions`, `InspectorOutcome`,
|
|
74
|
+
`InspectorCommandOptions`, `GeneratedDeclarationMessages`, `InspectorCommandNotes`). They
|
|
75
|
+
connect an `@azx-pbc/axiom-builder` store to the controlled surfaces without duplicating mapping
|
|
76
|
+
code in each host, and accept optional localisation overrides for generated declaration messages
|
|
77
|
+
and refusal notes.
|
|
78
|
+
- **Controlled props and label catalogues**: every surface exports its `*Props` and `*Labels`
|
|
79
|
+
types (`RuleBuilderProps`, `RuleBuilderLabels`, `RuleListProps`, `RuleListLabels`,
|
|
80
|
+
`RuleMessageEditorProps`, `RuleMessageLabels`, `ConditionEditorProps`, `ConditionEditorLabels`,
|
|
81
|
+
`ValidationEditorProps`, `ValidationEditorLabels`, `ReferencePickerProps`,
|
|
82
|
+
`ReferencePickerLabels`, and `RuleSentenceLabels`), along with supporting draft types
|
|
83
|
+
(`ConditionDraft`, `MessageCatalogue`, `RuleProblem`, `RuleTemplateDefinition`). Pass
|
|
84
|
+
`referencePickerLabels` on `RuleBuilder`, `ConditionEditor`, or `ValidationEditor` to localise
|
|
85
|
+
every nested `ReferencePicker` without English fallback text.
|
|
86
|
+
- **The selected-row vocabulary**: `InspectorChange`, and the two draft types its arms carry:
|
|
87
|
+
`PaletteValidationDraft`/`PaletteValidationOperator` and
|
|
88
|
+
`PaletteColumnDraft`/`PaletteColumnType`. The `Palette` prefix is the published name these types
|
|
89
|
+
have carried since the palette was a component of this package; a host imports them by that name.
|
|
90
|
+
|
|
91
|
+
Every one of them is a projection of the builder's own model rather than a second model. See
|
|
92
|
+
[`docs/integration/admin-studio.md`](https://github.com/AZX-PBC-OSS/axiom/blob/main/docs/integration/admin-studio.md) for the store, the
|
|
93
|
+
command contract and the publish gate these components call into.
|
|
94
|
+
|
|
95
|
+
## Connecting to `AuthoringStore`
|
|
96
|
+
|
|
97
|
+
A host supplies the tray, the canvas and the rail, projects its `AuthoringDocument` through
|
|
98
|
+
`ruleContextOf` and `readableRulesOf`, and dispatches commands returned by `commandsForRule` and
|
|
99
|
+
`commandsForInspectorChange`:
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
import { useState } from 'react';
|
|
103
|
+
import type { AuthoringStore } from '@azx-pbc/axiom-builder';
|
|
104
|
+
import {
|
|
105
|
+
RuleBuilder,
|
|
106
|
+
RuleList,
|
|
107
|
+
commandsForInspectorChange,
|
|
108
|
+
commandsForRule,
|
|
109
|
+
defaultRuleTemplateDraft,
|
|
110
|
+
freshRuleId,
|
|
111
|
+
readableRulesOf,
|
|
112
|
+
ruleContextOf,
|
|
113
|
+
} from '@azx-pbc/axiom-form-builder';
|
|
114
|
+
import type {
|
|
115
|
+
EmittedRule,
|
|
116
|
+
InspectorChange,
|
|
117
|
+
InspectorCommandOptions,
|
|
118
|
+
ReferencePickerLabels,
|
|
119
|
+
RuleBuilderLabels,
|
|
120
|
+
RuleListLabels,
|
|
121
|
+
RuleTemplateDraft,
|
|
122
|
+
} from '@azx-pbc/axiom-form-builder';
|
|
123
|
+
|
|
124
|
+
export function RulesPane(props: {
|
|
125
|
+
readonly store: AuthoringStore;
|
|
126
|
+
readonly locale: string;
|
|
127
|
+
readonly labels?: Partial<RuleBuilderLabels>;
|
|
128
|
+
readonly listLabels?: Partial<RuleListLabels>;
|
|
129
|
+
readonly referencePickerLabels?: Partial<ReferencePickerLabels>;
|
|
130
|
+
readonly inspectorOptions?: InspectorCommandOptions;
|
|
131
|
+
}) {
|
|
132
|
+
const document = props.store.getState().document;
|
|
133
|
+
const context = ruleContextOf(document, props.locale);
|
|
134
|
+
const rules = readableRulesOf(document);
|
|
135
|
+
const [draft, setDraft] = useState<RuleTemplateDraft>(() =>
|
|
136
|
+
defaultRuleTemplateDraft('check', context),
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
const handleCommit = (rule: EmittedRule): void => {
|
|
140
|
+
const withId: EmittedRule = {
|
|
141
|
+
...rule,
|
|
142
|
+
ruleId: rule.ruleId ?? freshRuleId(document, `r_${rule.kind}`),
|
|
143
|
+
};
|
|
144
|
+
for (const command of commandsForRule(withId, 'Value failed validation.')) {
|
|
145
|
+
props.store.dispatch(command);
|
|
146
|
+
}
|
|
147
|
+
setDraft(defaultRuleTemplateDraft('check', context));
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const handleInspectorChange = (change: InspectorChange): string | undefined => {
|
|
151
|
+
const outcome = commandsForInspectorChange(
|
|
152
|
+
document,
|
|
153
|
+
change,
|
|
154
|
+
props.locale,
|
|
155
|
+
props.inspectorOptions,
|
|
156
|
+
);
|
|
157
|
+
for (const command of outcome.commands) {
|
|
158
|
+
props.store.dispatch(command);
|
|
159
|
+
}
|
|
160
|
+
return outcome.note;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
return (
|
|
164
|
+
<>
|
|
165
|
+
<RuleList
|
|
166
|
+
rules={rules}
|
|
167
|
+
context={context}
|
|
168
|
+
labels={props.listLabels}
|
|
169
|
+
onRemove={(ruleId) => props.store.dispatch({ kind: 'removeRule', ruleId })}
|
|
170
|
+
/>
|
|
171
|
+
<RuleBuilder
|
|
172
|
+
value={draft}
|
|
173
|
+
context={context}
|
|
174
|
+
labels={props.labels}
|
|
175
|
+
referencePickerLabels={props.referencePickerLabels}
|
|
176
|
+
onChange={setDraft}
|
|
177
|
+
onCommit={handleCommit}
|
|
178
|
+
/>
|
|
179
|
+
<button
|
|
180
|
+
type="button"
|
|
181
|
+
onClick={() =>
|
|
182
|
+
handleInspectorChange({
|
|
183
|
+
kind: 'required',
|
|
184
|
+
fieldId: 'f_amount',
|
|
185
|
+
required: true,
|
|
186
|
+
messageKey: 'f_amount.required',
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
>
|
|
190
|
+
Mark amount required
|
|
191
|
+
</button>
|
|
192
|
+
</>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Two vocabularies leave the surfaces, and both are named. A rule editor hands back a complete
|
|
198
|
+
`EmittedRule`; a selected-row pane hands back an `InspectorChange`. `commandsForRule` and
|
|
199
|
+
`commandsForInspectorChange` map both vocabularies to `AuthoringCommand` sequences using the
|
|
200
|
+
store's own contract, and `capabilityRuleId` derives collision-free rule identifiers for
|
|
201
|
+
section-level capability gates. When a host needs custom policy or a change has no store command
|
|
202
|
+
(such as replacing table columns after creation), `outcome.note` explains why and can be
|
|
203
|
+
localised through `InspectorCommandOptions`.
|
|
204
|
+
|
|
205
|
+
## What the host owns
|
|
206
|
+
|
|
207
|
+
Axiom draws the surfaces; your application owns everything an editor is embedded in.
|
|
208
|
+
|
|
209
|
+
- **The shell.** The tray, the canvas and the rail, their keyboard models and their design system.
|
|
210
|
+
`examples/studio/src/editor` is a complete reference: a 200px tray, a 40px-row canvas and a
|
|
211
|
+
340px rail, with every row action expressed as a builder command.
|
|
212
|
+
- **Storage and the draft.** Where the document comes from, how it is saved and who may open it.
|
|
213
|
+
`createAuthoringStore` from `@azx-pbc/axiom-builder` is the store these surfaces dispatch to;
|
|
214
|
+
persistence, autosave and revision history are the host's.
|
|
215
|
+
- **Publish transport.** Compiling, verifying scenario suites, diffing against the published
|
|
216
|
+
revision and uploading are `compile`, `verifyPublishReadiness` and `diffAgainstPublished` in the
|
|
217
|
+
builder and compiler packages. This package has no network code and no publish button.
|
|
218
|
+
- **Authentication and authorisation.** The surfaces render for whoever mounts them. The actor and
|
|
219
|
+
clock a dispatch records, the fields a role may change, and the route that guards the page are
|
|
220
|
+
yours.
|
|
221
|
+
- **Locale selection.** The editor's language is a prop; `document.locales` is what the document
|
|
222
|
+
declares. Which one a person sees, and whether a translation service is called, is the host's
|
|
223
|
+
decision — the surfaces never read `Intl`, a browser setting or a user profile.
|
|
224
|
+
- **Theme.** Import `styles.css`, replace it, or override the tokens. The class hooks and state
|
|
225
|
+
attributes are the contract.
|
|
226
|
+
|
|
227
|
+
## Reading the document back
|
|
228
|
+
|
|
229
|
+
The surfaces are views over `@azx-pbc/axiom-builder`'s readers rather than a second model:
|
|
230
|
+
`layoutIndex` is what a rule's field descriptors are projected from, `projectRule` is what a rule
|
|
231
|
+
editor shows, and `fieldCards`/`translationGaps` are what a host's own canvas and translation panes
|
|
232
|
+
read.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The document-bridge module's door.
|
|
3
|
+
*
|
|
4
|
+
* Pure, stateless helpers that project an `@azx-pbc/axiom-builder` document into the descriptors
|
|
5
|
+
* the authoring surfaces read and map their emitted rules and inspector changes back into builder
|
|
6
|
+
* commands.
|
|
7
|
+
*/
|
|
8
|
+
export { capabilityRuleId, commandsForRule, freshRuleId, readableRulesOf, ruleContextOf, } from './rule-context.js';
|
|
9
|
+
export type { RuleCommandOptions, RuleContextOptions } from './rule-context.js';
|
|
10
|
+
export { commandsForInspectorChange } from './inspector-commands.js';
|
|
11
|
+
export type { GeneratedDeclarationMessages, InspectorCommandNotes, InspectorCommandOptions, InspectorOutcome, } from './inspector-commands.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bridge/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AACrE,YAAY,EACV,4BAA4B,EAC5B,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The document-bridge module's door.
|
|
3
|
+
*
|
|
4
|
+
* Pure, stateless helpers that project an `@azx-pbc/axiom-builder` document into the descriptors
|
|
5
|
+
* the authoring surfaces read and map their emitted rules and inspector changes back into builder
|
|
6
|
+
* commands.
|
|
7
|
+
*/
|
|
8
|
+
export { capabilityRuleId, commandsForRule, freshRuleId, readableRulesOf, ruleContextOf, } from './rule-context.js';
|
|
9
|
+
export { commandsForInspectorChange } from './inspector-commands.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bridge/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,WAAW,EACX,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["/**\n * The document-bridge module's door.\n *\n * Pure, stateless helpers that project an `@azx-pbc/axiom-builder` document into the descriptors\n * the authoring surfaces read and map their emitted rules and inspector changes back into builder\n * commands.\n */\nexport {\n capabilityRuleId,\n commandsForRule,\n freshRuleId,\n readableRulesOf,\n ruleContextOf,\n} from './rule-context.js';\nexport type { RuleCommandOptions, RuleContextOptions } from './rule-context.js';\nexport { commandsForInspectorChange } from './inspector-commands.js';\nexport type {\n GeneratedDeclarationMessages,\n InspectorCommandNotes,\n InspectorCommandOptions,\n InspectorOutcome,\n} from './inspector-commands.js';\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AuthoringCommand, AuthoringDocument } from '@azx-pbc/axiom-builder';
|
|
2
|
+
import type { InspectorChange } from '../inspector.js';
|
|
3
|
+
import type { ExpressionProblem } from '../rules/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Pure, stateless mapping from `InspectorChange` intents to `@azx-pbc/axiom-builder` commands.
|
|
6
|
+
*
|
|
7
|
+
* The inspector vocabulary keeps no store: every edit reports an `InspectorChange`, and this
|
|
8
|
+
* bridge turns it into an ordered list of `AuthoringCommand` values (or an explanatory `note`
|
|
9
|
+
* when the intent cannot map to a command). Hosts targeting non-English authoring UIs pass
|
|
10
|
+
* `options.generatedText` and `options.notes` so no English sentence leaks into documents or UI.
|
|
11
|
+
*/
|
|
12
|
+
/** One mapping outcome: the commands to dispatch, or the sentence saying why there are none. */
|
|
13
|
+
export interface InspectorOutcome {
|
|
14
|
+
readonly commands: readonly AuthoringCommand[];
|
|
15
|
+
/** A sentence the host announces when the edit has no command behind it. */
|
|
16
|
+
readonly note?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Default catalogue sentences minted for newly declared field constraints. */
|
|
19
|
+
export interface GeneratedDeclarationMessages {
|
|
20
|
+
readonly required: string;
|
|
21
|
+
readonly minLength: string;
|
|
22
|
+
readonly maxLength: string;
|
|
23
|
+
readonly minimum: string;
|
|
24
|
+
readonly maximum: string;
|
|
25
|
+
}
|
|
26
|
+
/** Overridable host notes returned when an inspector change maps to no command. */
|
|
27
|
+
export interface InspectorCommandNotes {
|
|
28
|
+
readonly missingField: string;
|
|
29
|
+
readonly missingChoice: string;
|
|
30
|
+
readonly choiceAtBoundary: string;
|
|
31
|
+
readonly choiceRemovalRefused: string;
|
|
32
|
+
readonly choiceLabelKeyMissing: string;
|
|
33
|
+
readonly choicesUnchanged: string;
|
|
34
|
+
readonly unsupportedBound: string;
|
|
35
|
+
readonly columnsReadOnly: string;
|
|
36
|
+
readonly missingValidationMessage: string;
|
|
37
|
+
readonly validationProblem: (problem: ExpressionProblem) => string;
|
|
38
|
+
}
|
|
39
|
+
/** Optional localisation overrides for `commandsForInspectorChange`. */
|
|
40
|
+
export interface InspectorCommandOptions {
|
|
41
|
+
/** Default sentences minted for newly declared `required`, length, or value bounds. */
|
|
42
|
+
readonly generatedText?: Partial<GeneratedDeclarationMessages> | undefined;
|
|
43
|
+
/** Sentences returned in `outcome.note` when a change produces no commands. */
|
|
44
|
+
readonly notes?: Partial<InspectorCommandNotes> | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Maps one `InspectorChange` into the ordered `AuthoringCommand` list that applies it.
|
|
48
|
+
*
|
|
49
|
+
* `document` is read for edits relative to what the field already declares (options, moves, money
|
|
50
|
+
* control, and validation rule id allocation); `locale` is the language generated declaration
|
|
51
|
+
* messages and option label edits are written in. Supply `options.generatedText` and
|
|
52
|
+
* `options.notes` to localise generated messages and explanatory refusal notes.
|
|
53
|
+
*/
|
|
54
|
+
export declare function commandsForInspectorChange(document: AuthoringDocument, change: InspectorChange, locale: string, options?: InspectorCommandOptions): InspectorOutcome;
|
|
55
|
+
//# sourceMappingURL=inspector-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspector-commands.d.ts","sourceRoot":"","sources":["../../src/bridge/inspector-commands.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EAIlB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,eAAe,EAA0B,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,iBAAiB,EAAuC,MAAM,mBAAmB,CAAC;AAIhG;;;;;;;GAOG;AAEH,gGAAgG;AAChG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,+EAA+E;AAC/E,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,mFAAmF;AACnF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,MAAM,CAAC;CACpE;AAED,wEAAwE;AACxE,MAAM,WAAW,uBAAuB;IACtC,uFAAuF;IACvF,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC,4BAA4B,CAAC,GAAG,SAAS,CAAC;IAC3E,+EAA+E;IAC/E,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,qBAAqB,CAAC,GAAG,SAAS,CAAC;CAC7D;AA+SD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,eAAe,EACvB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,uBAAuB,GAChC,gBAAgB,CAuQlB"}
|