@cratis/pi 7.176.1 → 7.177.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -104,6 +104,8 @@ const handleSubmit = async () => {
104
104
 
105
105
  ---
106
106
 
107
+ Before handling command failures, read `.cratis/ai/skills/cratis-arc-command/references/command-result.md` for the complete result decision table, protected-read recovery and safe feedback. The success-only example above is not a failure-handling policy.
108
+
107
109
  ## Query usage pattern (with paging)
108
110
 
109
111
  ```tsx
@@ -40,8 +40,8 @@ The package root exports **only** setup (`CratisComponentsProvider`, configurati
40
40
  | CSS foundation / area sheets | layer order / structural CSS | `@cratis/components/styles/base`, `<subpath>/styles` |
41
41
  | Shared types | `JsonSchema`, `Json`, … | `@cratis/components/types` |
42
42
 
43
- At Components 4.26.4, React and React DOM are `^19.0.0`, Arc and Arc React are
44
- `>=20.3.1 <23`, Fundamentals is `^7.10.3`, and `reflect-metadata` `0.2.2` is required
43
+ The declared peers for React and React DOM are `^19.0.0`, Arc and Arc React are
44
+ `>=20.3.1 <24`, Fundamentals is `^7.10.3`, and `reflect-metadata` `0.2.2` is required
45
45
  (import it at the entry point). `tsyringe` `4.10.0` is optional for Components;
46
46
  Arc React installs it. `Canvas` and `PivotViewer` need the optional `pixi.js ^8.20.0`
47
47
  peer; ordinary pages do not. No `motion-dom` or `motion-utils` resolution pin is needed.
@@ -126,8 +126,8 @@ import { DataPage, MenuItem, Column } from '@cratis/components/DataPage';
126
126
 
127
127
  `MenuItem` is a declarative Components element read by `DataPage.MenuItems` (use `command`, not
128
128
  `onClick`); `disableOnUnselected` greys it out until a row is selected; its `icon` is a **React
129
- component type** (e.g. a `react-icons` icon), not an `Icon`. See the **cratis-arc-react-page** skill
130
- for the full page workflow.
129
+ component type** (e.g. a `react-icons` icon), not an `Icon`.
130
+ Read the **cratis-arc-react-page** skill's `references/data-page.md` for typed menu selection, reconciliation, search/server mapping and `landmark`.
131
131
 
132
132
  ## Composition over Monoliths
133
133
 
@@ -133,28 +133,10 @@ const result = await command.execute();
133
133
 
134
134
  Inside dialogs, use `CommandDialog` + CommandForm fields rather than driving the command by hand — see [dialogs.md](./dialogs.instructions.md).
135
135
 
136
- ### Read `CommandResult` by the granular flag — not just `isSuccess`
136
+ ### Read command outcomes before choosing feedback
137
137
 
138
- | Flag | Meaning | UX response |
139
- |---|---|---|
140
- | `isSuccess` | `isAuthorized && isValid && !hasExceptions` | happy path |
141
- | `isAuthorized` | `[Roles]`/policy rejected | redirect to login / "not allowed" |
142
- | `isValid` | validation failed — `validationResults` has per-field messages | render inline field errors |
143
- | `hasExceptions` | `Provide()`/`Handle()` threw — `exceptionMessages` carry diagnostics | generic error toast + log; never show stack traces |
144
-
145
- `CommandDialog` handles all of this automatically; the flags matter most when executing a command **outside** a dialog. `validate()` returns the same shape with `response == null` (handler did not run). `result.validationResults` is a `ValidationResult[]` of `{ severity, message, members: string[], state, reason, reasonDetail? }` — `members` names the affected properties — render per-field UI from it, but **never branch on raw `.message` text**. `exceptionMessages`/`exceptionStackTrace` are for logging, never for users.
146
-
147
- Out-of-dialog execution branches in this order:
148
-
149
- ```tsx
150
- const result = await command.execute();
151
- if (!result.isAuthorized) { redirectToLogin(); return; }
152
- if (!result.isValid) { /* validationResults → inline field errors */ return; }
153
- if (result.hasExceptions) { toast.error({ title: 'Something went wrong' }); console.error(result.exceptionMessages); return; }
154
- // happy path — refresh queries, close, etc.
155
- ```
156
-
157
- `toastCommandResult(result, opts)` from `@cratis/components/Notifications` collapses this whole branch into one call (with a `<Toaster />` mounted) — success/not-authorized/validation/exception → the right toast, no stack traces shown.
138
+ Read `.cratis/ai/skills/cratis-arc-command/references/command-result.md` for the complete result decision table, protected-read refusals and message safety; do not replace it with an `isSuccess`-only branch.
139
+ Read the **cratis-arc-react-page** skill's `references/queries-and-commands.md` for `/validate` feedback under read protection, and `references/availability.md` for presentation-only availability.
158
140
 
159
141
  ### Command helpers
160
142
 
@@ -99,6 +99,8 @@ const handleSubmit = async () => {
99
99
 
100
100
  ---
101
101
 
102
+ Before handling command failures, read `.cratis/ai/skills/cratis-arc-command/references/command-result.md` for the complete result decision table, protected-read recovery and safe feedback. The success-only example above is not a failure-handling policy.
103
+
102
104
  ## Query usage pattern (with paging)
103
105
 
104
106
  ```tsx
@@ -39,8 +39,8 @@ The package root exports **only** setup (`CratisComponentsProvider`, configurati
39
39
  | CSS foundation / area sheets | layer order / structural CSS | `@cratis/components/styles/base`, `<subpath>/styles` |
40
40
  | Shared types | `JsonSchema`, `Json`, … | `@cratis/components/types` |
41
41
 
42
- At Components 4.26.4, React and React DOM are `^19.0.0`, Arc and Arc React are
43
- `>=20.3.1 <23`, Fundamentals is `^7.10.3`, and `reflect-metadata` `0.2.2` is required
42
+ The declared peers for React and React DOM are `^19.0.0`, Arc and Arc React are
43
+ `>=20.3.1 <24`, Fundamentals is `^7.10.3`, and `reflect-metadata` `0.2.2` is required
44
44
  (import it at the entry point). `tsyringe` `4.10.0` is optional for Components;
45
45
  Arc React installs it. `Canvas` and `PivotViewer` need the optional `pixi.js ^8.20.0`
46
46
  peer; ordinary pages do not. No `motion-dom` or `motion-utils` resolution pin is needed.
@@ -125,8 +125,8 @@ import { DataPage, MenuItem, Column } from '@cratis/components/DataPage';
125
125
 
126
126
  `MenuItem` is a declarative Components element read by `DataPage.MenuItems` (use `command`, not
127
127
  `onClick`); `disableOnUnselected` greys it out until a row is selected; its `icon` is a **React
128
- component type** (e.g. a `react-icons` icon), not an `Icon`. See the **cratis-arc-react-page** skill
129
- for the full page workflow.
128
+ component type** (e.g. a `react-icons` icon), not an `Icon`.
129
+ Read the **cratis-arc-react-page** skill's `references/data-page.md` for typed menu selection, reconciliation, search/server mapping and `landmark`.
130
130
 
131
131
  ## Composition over Monoliths
132
132
 
@@ -132,28 +132,10 @@ const result = await command.execute();
132
132
 
133
133
  Inside dialogs, use `CommandDialog` + CommandForm fields rather than driving the command by hand — see [dialogs.md](./dialogs.md).
134
134
 
135
- ### Read `CommandResult` by the granular flag — not just `isSuccess`
135
+ ### Read command outcomes before choosing feedback
136
136
 
137
- | Flag | Meaning | UX response |
138
- |---|---|---|
139
- | `isSuccess` | `isAuthorized && isValid && !hasExceptions` | happy path |
140
- | `isAuthorized` | `[Roles]`/policy rejected | redirect to login / "not allowed" |
141
- | `isValid` | validation failed — `validationResults` has per-field messages | render inline field errors |
142
- | `hasExceptions` | `Provide()`/`Handle()` threw — `exceptionMessages` carry diagnostics | generic error toast + log; never show stack traces |
143
-
144
- `CommandDialog` handles all of this automatically; the flags matter most when executing a command **outside** a dialog. `validate()` returns the same shape with `response == null` (handler did not run). `result.validationResults` is a `ValidationResult[]` of `{ severity, message, members: string[], state, reason, reasonDetail? }` — `members` names the affected properties — render per-field UI from it, but **never branch on raw `.message` text**. `exceptionMessages`/`exceptionStackTrace` are for logging, never for users.
145
-
146
- Out-of-dialog execution branches in this order:
147
-
148
- ```tsx
149
- const result = await command.execute();
150
- if (!result.isAuthorized) { redirectToLogin(); return; }
151
- if (!result.isValid) { /* validationResults → inline field errors */ return; }
152
- if (result.hasExceptions) { toast.error({ title: 'Something went wrong' }); console.error(result.exceptionMessages); return; }
153
- // happy path — refresh queries, close, etc.
154
- ```
155
-
156
- `toastCommandResult(result, opts)` from `@cratis/components/Notifications` collapses this whole branch into one call (with a `<Toaster />` mounted) — success/not-authorized/validation/exception → the right toast, no stack traces shown.
137
+ Read `.cratis/ai/skills/cratis-arc-command/references/command-result.md` for the complete result decision table, protected-read refusals and message safety; do not replace it with an `isSuccess`-only branch.
138
+ Read the **cratis-arc-react-page** skill's `references/queries-and-commands.md` for `/validate` feedback under read protection, and `references/availability.md` for presentation-only availability.
157
139
 
158
140
  ### Command helpers
159
141
 
@@ -27,6 +27,8 @@ Sources: `Source/DotNET/Arc.Core/Commands/CommandResult.cs`,
27
27
  | `ExceptionMessages` | `IEnumerable<string>` | |
28
28
  | `ExceptionStackTrace` | `string` | |
29
29
  | `AuthorizationFailureReason` | `string` | |
30
+ | `IsRetryable` | `bool` | Temporary refusal; defaults to `false` |
31
+ | `IsMissingHandler` | `bool` | No handler: execution/validation did not run; defaults to `false` |
30
32
 
31
33
  `CommandResult<TResult>` adds a `Response` of `TResult`.
32
34
 
@@ -94,6 +96,8 @@ readonly isSuccess: boolean;
94
96
  readonly isAuthorized: boolean;
95
97
  readonly isValid: boolean;
96
98
  readonly hasExceptions: boolean;
99
+ readonly isRetryable?: boolean;
100
+ readonly isMissingHandler?: boolean;
97
101
  readonly validationResults: ValidationResult[];
98
102
  readonly exceptionMessages: string[];
99
103
  readonly authorizationFailureReason: string;
@@ -117,22 +121,51 @@ failure to one or more `members`, and `severity` is the numeric
117
121
  `ValidationResultSeverity` enum. Code that reads `v.propertyName` or compares
118
122
  `v.severity === 'Error'` is reading fields that do not exist.
119
123
 
120
- Match a failure to a field through `members`, and branch on `reasonDetail`
121
- rather than parsing `message` — the message is prose written for a human and is
122
- free to change, while `reasonDetail` is the identity of the specific thing that
123
- rejected the command (a constraint name, for instance).
124
-
125
- ```tsx
126
- const result = await command.execute();
127
-
128
- if (!result.isAuthorized) { /* the caller is not allowed to do this */ }
129
- else if (!result.isValid) {
130
- const errorFor = (property: string) =>
131
- result.validationResults.find(v => v.members.includes(property))?.message;
132
- }
133
- else if (result.hasExceptions) { /* server fault */ }
134
- else { /* result.response */ }
135
- ```
124
+ Validator refusals, explicit `ValidationResult` outcomes from `Provide()`/`Handle()`,
125
+ and `IEnumerable<ValidationResult>` outcomes from `Provide()` share
126
+ `validationResults`, subject to blocking severity. Validators own refusals when
127
+ usable facts exist; `Provide()` short-circuits only when acquisition yields
128
+ nothing usable, and `Handle()` must not duplicate business validation.
129
+
130
+ ### Result decision table
131
+
132
+ Check `isMissingHandler` and `isRetryable` before the ordinary success path;
133
+ do not recompute success from only authorization, validity and exceptions.
134
+ The server's computed `IsSuccess` formula above does not include those flags.
135
+ Use `response` only after classifying the result as successful. The two interface
136
+ flags are optional: absence is not a positive retry or missing-handler signal.
137
+
138
+ | Outcome | Application response |
139
+ | --- | --- |
140
+ | `isMissingHandler === true` | safe unavailable-action feedback; log the integration/configuration fault, not field errors |
141
+ | `isRetryable === true` | temporary refusal, not a permanent denial or invalid input; preserve the draft and offer deliberate retry |
142
+ | `isSuccess` after those checks | use the typed response, then close/refresh |
143
+ | `!isAuthorized` | distinguish unavailable from forbidden via `isNotAvailable(result)` from `@cratis/arc/availability`; do not automatically redirect every refusal to login |
144
+ | `!isValid` with a protected-read refusal below | retain the draft, re-read, then let the user deliberately retry |
145
+ | `!isValid` with authored `rule` results | match approved user-facing rule copy to fields through `members` |
146
+ | Other invalid results | choose safe application copy by `reason`/`reasonDetail`, never parse `.message` |
147
+ | `hasExceptions` | generic fault feedback; diagnostics belong in logs |
148
+
149
+ A retryable flag does not imply that a protected-read result carries that flag:
150
+ classify the known reason pair independently, before generic field-error display.
151
+
152
+ ### Protected-read refusals
153
+
154
+ `ValidationResultReason` is an open string set. Recognize only these exact pairs:
155
+
156
+ | `reason` | `reasonDetail` | Meaning |
157
+ | --- | --- | --- |
158
+ | `concurrencyViolation` | `ReadChanged` | the guarded read changed before effects could commit |
159
+ | `concurrencyViolation` | `ReadIncomplete` | a required read did not complete; no effects committed |
160
+
161
+ For both, keep the draft and dialog open, re-read the relevant state and allow a
162
+ **deliberate retry**. Never mark the user's input invalid or clear fields for
163
+ these refusals. They are not authored business-rule failures. Framework-composed
164
+ messages are developer English, not localized user-facing copy: never show them
165
+ raw. Do not render read state, keys or conflicting-event details in visible UI
166
+ or announcements. Choose application copy by the pair, not by parsing the
167
+ message. Unknown reasons or details are not automatically protected-read refusals or framework
168
+ errors; use a safe fallback unless the application explicitly approves their copy.
136
169
 
137
170
  `members` is **camelCased on purpose**, so a form can match a server failure to
138
171
  the field that caused it without transforming anything. A nested member is a
@@ -143,8 +176,27 @@ and names the field the same way.
143
176
 
144
177
  `reason` also distinguishes a genuine rejection from a validator that threw
145
178
  while validating hostile or partial input: the latter arrives as a single result
146
- with a `ValidatorFailed` reason and a generic message, replacing every message
179
+ with a `ValidatorFailed` (`validatorFailed`) reason and a generic message, replacing every message
147
180
  the validator's author wrote. Do not read the message to tell the two apart.
181
+ Other framework reasons include `dependencyUnavailable` (facts unavailable before
182
+ rules), `concurrencyViolation`, `constraintViolation` and `frameworkFailure`.
183
+ Use safe application feedback for these non-rule diagnostics, not blanket
184
+ field-error rendering. `reasonDetail` can identify a constraint; `state` is
185
+ application data, not proof that a message is safe. Never show
186
+ `exceptionMessages`/`exceptionStackTrace` to users.
187
+
188
+ ### Feedback helpers are not sanitizers
189
+
190
+ `CommandForm` renders raw validation messages; `toastCommandResult` joins them
191
+ into its invalid-result toast. Neither sanitizes non-rule diagnostics. Use
192
+ application-owned feedback. `showErrors={false}` suppresses built-in form error
193
+ display, not every dialog announcement. `CommandDialog`'s default validation
194
+ announcement also includes a raw message; use application-owned safe
195
+ `validationAnnouncement` text when needed. `onValidationFailure` alone does not
196
+ suppress either display. See the React page skill's
197
+ [dialogs.md](../../cratis-arc-react-page/references/dialogs.md) for form composition,
198
+ and [queries-and-commands.md](../../cratis-arc-react-page/references/queries-and-commands.md)
199
+ for `/validate` feedback under read protection.
148
200
 
149
201
  ## Executing with a severity
150
202
 
@@ -25,7 +25,7 @@ This skill follows the `@cratis/components` package manifest (`exports`, peers),
25
25
  `Source/DataTables/*`, `Source/Dialogs/*`, `Source/CommandDialog/*` and `Source/MIGRATION.md`.
26
26
  Peers declared by `@cratis/components`: `@cratis/arc` and `@cratis/arc.react` and `react`.
27
27
 
28
- Requires `@cratis/arc` and `@cratis/arc.react` 20.3.1 or later (below 23) and `react` 19 or later, as `@cratis/components` declares them peers.
28
+ Read the [Components compatibility rule](../../rules/components.md) for the declared peer ranges before choosing package versions; it is the compatibility owner.
29
29
 
30
30
  `@cratis/arc.react.mvvm` ships with `@cratis/arc.react` and is an explicit
31
31
  application dependency.
@@ -147,7 +147,8 @@ compound members; `MenuItem` and `Column` are also **named exports** of the
147
147
  subpath (there is no `DataPage.Column`). Pass `dataKey` whenever the read model has an
148
148
  identity.
149
149
 
150
- Read [data-page.md](references/data-page.md) when configuring DataPage props; it lists every prop, and
150
+ Read [data-page.md](references/data-page.md) when configuring typed menu selection,
151
+ reconciliation, search/server mapping or Page/DataPage landmarks, and
151
152
  [data-tables.md](references/data-tables.md) when you need a table without the
152
153
  page chrome.
153
154
 
@@ -182,6 +183,11 @@ Render the wrapper returned by `useDialog` once in the tree. Read
182
183
 
183
184
  ## Step 5 — Command dialogs
184
185
 
186
+ Read the owning [CommandResult reference](../cratis-arc-command/references/command-result.md)
187
+ for the complete result decision table, protected-read refusals and safe feedback.
188
+ Read [queries-and-commands.md](references/queries-and-commands.md) for `/validate`
189
+ and `autoServerValidate` feedback under read protection, not a promise of execution.
190
+
185
191
  A dialog that runs a command is its own component built on `CommandDialog`.
186
192
  Bind each input with a `CommandForm` field whose `value` accessor selects the
187
193
  command property; the label prop is `title`.
@@ -281,6 +287,13 @@ props handling, or teardown.
281
287
  | Complex page state | `withViewModel` |
282
288
  | A `.play` `screen` or `form` is the spec | [from-screenplay.md](references/from-screenplay.md) |
283
289
 
290
+ ## Availability
291
+
292
+ Read [availability.md](references/availability.md) when offering navigation,
293
+ screens or actions conditionally with `@cratis/arc.react/availability`.
294
+ It is presentation only: keep unknown, errors and not opted in distinct, and
295
+ leave authorization and enforcement to the server.
296
+
284
297
  ## Verify
285
298
 
286
299
  - Every Cratis Components import uses a subpath, not the root barrel.
@@ -291,7 +304,12 @@ props handling, or teardown.
291
304
  - Columns sit in `<DataPage.Columns>`; menu items sit in
292
305
  `<DataPage.MenuItems>` and use `command`, not `onClick`.
293
306
  - No component pre-fetches rows and passes them to `DataPage` as an array.
294
- - Every command value in a dialog is bound through a `CommandForm` field.
307
+ - Every command value in a dialog is bound through a `CommandForm` field;
308
+ use `AutoCommandFields` for generated fields inside an existing form/dialog
309
+ ([dialogs.md](references/dialogs.md)), not a nested `AutoCommandForm`.
310
+ - Page/DataPage has one main landmark owner; use `landmark={false}` inside it.
311
+ - Availability presentation distinguishes loading/unknown from denial and errors;
312
+ it never replaces server authorization.
295
313
  - Values required for validity come from `initialValues`, not
296
314
  `onBeforeExecute`.
297
315
  - Confirmations and busy indicators are raised by hook, registered once at the
@@ -299,11 +317,12 @@ props handling, or teardown.
299
317
  - Every `showBusy()` has a matching close in a `finally`.
300
318
  - Every displayed or captured value has an origin from the Step 2 table; none
301
319
  is computed from another query on the client.
302
- - Each page's states are designed: empty (`emptyMessage`), loading, a command
303
- that fails (read through the granular `CommandResult` flags in
304
- [queries-and-commands.md](references/queries-and-commands.md)), denied (a
305
- persona that can reach the page but whose policy refuses the action), and the
306
- state after success.
320
+ - Each page's states are designed: empty (`emptyMessage`), loading, command
321
+ refusal/retry/fault (use the owning
322
+ [CommandResult table](../cratis-arc-command/references/command-result.md)),
323
+ denied (a persona that can reach the page but whose policy refuses the action),
324
+ and the state after success. Protected-read refusals retain the draft;
325
+ preflight validation is feedback only.
307
326
  - When a `.play` model describes the page, the page matches it element by
308
327
  element and adds no data or action the model lacks
309
328
  ([from-screenplay.md](references/from-screenplay.md)).
@@ -0,0 +1,65 @@
1
+ # Availability presentation
2
+
3
+ Use `@cratis/arc.react/availability` to offer navigation, screens or actions only
4
+ when that part is available to the current tenant or user. This is presentation
5
+ only, never authorization or a replacement for server enforcement. Availability
6
+ decides what is offered; authorization decides what the caller may do. The
7
+ server remains authoritative for every command and query.
8
+
9
+ ## Provider and states
10
+
11
+ The subpath exports `AvailabilityContext`, `AvailabilityProvider`,
12
+ `RequireAvailable`, `useAvailability`, `useAvailableItems`,
13
+ `AvailabilityProviderProps` and `RequireAvailableProps`.
14
+ Mount `AvailabilityProvider` below `Arc` when the host opts
15
+ in. It observes the server's unavailable-parts query and updates live.
16
+
17
+ Keep these states distinct:
18
+
19
+ | State | Presentation |
20
+ | --- | --- |
21
+ | Not opted in: no provider | the default context is `Availability.everything`; everything is offered |
22
+ | Unknown: provider mounted, no successful decision yet | `isKnown` is false; no part is reported available; show loading, not a denial |
23
+ | Known decision | parts not listed as unavailable are available |
24
+ | Later query error | keep the last successful decision; an error is not a denial |
25
+
26
+ If the first query fails, availability stays unknown. The hook does not expose
27
+ an error state or error slot: unknown, error and not opted in are not synonyms.
28
+ Do not turn an observation failure into a permanent denial or blanket login
29
+ redirect.
30
+
31
+ ## Gate a screen or part
32
+
33
+ ```tsx
34
+ import { AvailabilityProvider, RequireAvailable } from '@cratis/arc.react/availability';
35
+ import { AllAccounts } from './AllAccounts';
36
+
37
+ // Render below Arc; AccountsPage, Loading and NotAvailable are application UI.
38
+ <AvailabilityProvider>
39
+ <RequireAvailable part={AllAccounts} whileLoading={<Loading />} unavailable={<NotAvailable />}>
40
+ <AccountsPage />
41
+ </RequireAvailable>
42
+ </AvailabilityProvider>
43
+ ```
44
+
45
+ `RequireAvailable` takes `part` and `children`; optional `whileLoading` and
46
+ `unavailable` both default to nothing. `part` is an `AvailabilityPart` from
47
+ `@cratis/arc/availability`: a full server command/read-model name, or a generated
48
+ proxy class/instance. Strings match the full name; proxies match their slice
49
+ location. Missing slice metadata is not an authorization grant.
50
+
51
+ ## Navigation and decisions in code
52
+
53
+ `useAvailability()` returns the `Availability` decision: `isKnown`,
54
+ `isAvailable(part)` and `filter(items, partOf)`. `useAvailableItems(items, partOf)`
55
+ filters navigation entries live; `partOf(item)` returns a part or `undefined`.
56
+ An entry without a part is always kept, including while the decision is unknown.
57
+ Keep the entries and selector stable (outside render or memoized).
58
+
59
+ For command/query refusal feedback, use `isNotAvailable(result)` from
60
+ `@cratis/arc/availability` to distinguish unavailable from forbidden. It checks
61
+ unauthorized plus `authorizationFailureReason === 'NotAvailable'`. A temporary
62
+ `isRetryable` outcome is not a permanent denial. Read the owning
63
+ [CommandResult reference](../../cratis-arc-command/references/command-result.md)
64
+ for the result decision table and safe feedback; hiding a control does not
65
+ make execution authorized or guaranteed to succeed.
@@ -4,8 +4,11 @@
4
4
 
5
5
  - Compound members
6
6
  - `DataPageProps`
7
+ - Page landmarks
7
8
  - Snapshot versus observable
8
- - `MenuItemProps`
9
+ - Selection reconciliation
10
+ - Search and server queries
11
+ - `MenuItemProps<TDataType>`
9
12
  - `IDetailsComponentProps<TDataType>`
10
13
  - `Column`
11
14
  - Type name caution
@@ -38,18 +41,22 @@ Three static members exist:
38
41
  | Prop | Type | Notes |
39
42
  | --- | --- | --- |
40
43
  | `title` | `string` | required — menubar title |
44
+ | `landmark` | `boolean` | defaults to `true`; use `false` inside an existing main landmark |
41
45
  | `query` | `Constructor<TQuery>` | required — a snapshot **or** observable query proxy |
42
46
  | `emptyMessage` | `string` | required — only a real empty result |
43
47
  | `loadingMessage` / `failureMessage` / `unauthorizedMessage` | `ReactNode` | query-state rows; defaults from `messages.dataTable.loading/failed/unauthorized` |
44
48
  | `children` | `ReactNode` | required — `DataPage.Columns` and optionally `DataPage.MenuItems` |
45
49
  | `queryArguments` | `TArguments` | forwarded to the query |
46
50
  | `dataKey` | `string \| undefined` | row identity; pass whenever the read model has one |
47
- | `selection` | `any \| undefined \| null` | controlled single selection |
51
+ | `selection` | `TDataType \| undefined \| null` | controlled single selection |
48
52
  | `selectionMode` | `'single' \| 'multiple'` | default single |
49
53
  | `selectedItems` / `onSelectedItemsChange` | `TDataType[]` / `(items: TDataType[]) => void` | multiple selection; omit `selectedItems` for internal state |
50
- | `onSelectionChange` | `(event: DataTableSelectionChangeEvent<any>) => void` | `event.value` is the row or `null` |
51
- | `detailsComponent` | `React.FC<IDetailsComponentProps<any>>` | rendered beside the table for the selected row |
54
+ | `onSelectionChange` | `(event: DataTableSelectionChangeEvent<TDataType>) => void` | `event.value` is the row or `null`; accept it for controlled selection |
55
+ | `detailsComponent` | `React.FC<IDetailsComponentProps<TDataType>>` | rendered beside the table for the selected row |
52
56
  | `globalFilterFields` | `string[] \| undefined` | enables the global search box over these fields |
57
+ | `filteredEmptyMessage` | `ReactNode` | separate copy for an active search/filter with no shown rows |
58
+ | `onGlobalFilterChange` | `(globalFilter: string) => void` | notifies every search-text change |
59
+ | `serverQuery` | `DataTableServerQuery<TArguments>` | caller maps search/filter/sort state to backend query arguments; see below |
53
60
  | `defaultFilters` | `DataTableFilterMeta` | initial per-column filter state |
54
61
  | `onRefresh` | `() => void` | forwarded unchanged to details; DataPage never invokes it or refetches |
55
62
  | `actionsAriaLabel` | `string` | accessible name of the actions menubar, default `'Actions'` |
@@ -62,6 +69,14 @@ Three static members exist:
62
69
  | `paginatorPt` | `TablePaginatorParts` | per-part attributes on the paginator |
63
70
  | `clientFiltering` | `boolean` | **deprecated and a no-op** — do not use in new code |
64
71
 
72
+ ## Page landmarks
73
+
74
+ `Page` from `@cratis/components/Common` renders its content as `<main>` by
75
+ default. `landmark={false}` switches that content region to `<div>`, for a page
76
+ already inside the application's main landmark. `DataPage` forwards its
77
+ `landmark` prop to Page. Choose the main owner and avoid nested main landmarks;
78
+ `showTitle` controls Page's heading separately, not its landmark.
79
+
65
80
  ## Snapshot versus observable
66
81
 
67
82
  There is no `observableQuery` prop. `DataPage` inspects the query prototype at
@@ -76,15 +91,70 @@ and unauthorized results show a failure row; `empty-row` means a real empty
76
91
  result. While refreshing, the table marks `aria-busy`. Style status rows with
77
92
  `tablePt.loadingRow/loadingCell/failureRow/failureCell`.
78
93
 
79
- ## `MenuItemProps`
94
+ ## Selection reconciliation
95
+
96
+ On a ready query result, single selection follows the replacement row with the
97
+ same stringified `dataKey` value; if it disappears, `event.value` becomes `null`.
98
+ Without `dataKey`, matching is by reference. DataPage updates its internal
99
+ selection automatically; a controlled consumer must accept `event.value` in
100
+ `onSelectionChange`, otherwise its stale selection and details remain. The event
101
+ is `DataTableSelectionChangeEvent<TDataType>` (`value: TDataType | null`, optional
102
+ `originalEvent`). Do not assume the same reconciliation contract for multiple
103
+ selection.
104
+
105
+ ## Search and server queries
106
+
107
+ Without `serverQuery`, filtering, global search and sorting operate only on the
108
+ loaded page, not the whole dataset. Default filtered-empty copy says that only
109
+ the loaded page was searched; `filteredEmptyMessage` overrides it.
110
+ `onGlobalFilterChange` reports each typed change.
111
+
112
+ `DataTableServerQuery<TArguments>` and `DataTableServerQueryState` are exported
113
+ from `@cratis/components/DataTables`. The state contains `globalFilter`, `filters`
114
+ and `sort`; the contract is:
115
+
116
+ ```ts
117
+ interface DataTableServerQuery<TArguments> {
118
+ mapQueryArguments: (state: DataTableServerQueryState, baseArguments: TArguments | undefined) => TArguments;
119
+ debounceMs?: number; // defaults to 250
120
+ }
121
+ ```
122
+
123
+ The caller must map that state into real backend arguments whose query implements
124
+ the search/filter/sort. With `serverQuery`, the table disables local filtering
125
+ and sorting and resets paging when effective server arguments change; it does
126
+ not invent backend search semantics. Global search text is debounced; column
127
+ filters and sorting apply immediately. The default filtered-empty copy becomes
128
+ neutral ("No rows match the search.").
129
+
130
+ ## `MenuItemProps<TDataType>`
80
131
 
81
132
  | Prop | Type | Notes |
82
133
  | --- | --- | --- |
83
134
  | `icon` | `React.ComponentType<{ className?: string }>` | a **component**, not an icon class string |
84
135
  | `label` | `string` | menu label |
85
- | `command` | `() => void` | the action — **not** `onClick` |
86
- | `disabled` | `boolean` | unconditionally disabled |
87
- | `disableOnUnselected` | `boolean` | disabled until a row is selected |
136
+ | `command` | `(selection: DataPageSelection<TDataType>) => void` | the action — **not** `onClick`; zero-argument callbacks remain valid |
137
+ | `disabled` | `boolean \| ((selection: DataPageSelection<TDataType>) => boolean)` | unconditional or selection-aware disabling |
138
+ | `disableOnUnselected` | `boolean` | disabled until a row is selected; combined with `disabled` |
139
+
140
+ `DataPageSelection<TDataType>` (exported from `@cratis/components/DataPage`) is a
141
+ readonly discriminated union: `{ selectionMode: 'single', selectedItem: TDataType | null | undefined }`
142
+ or `{ selectionMode: 'multiple', selectedItems: readonly TDataType[] }`. Both
143
+ callbacks receive the immutable, committed selection, not a click event. The
144
+ container and multiple-selection array are frozen, but row objects are not
145
+ deep-frozen. A disabled item cannot dispatch its command. JSX does not infer the row type from
146
+ DataPage's generic; supply it explicitly:
147
+
148
+ ```tsx
149
+ <DataPage.MenuItem<AccountSummary>
150
+ label='Edit'
151
+ disabled={selection => selection.selectionMode !== 'single' || !selection.selectedItem}
152
+ command={selection => {
153
+ if (selection.selectionMode === 'single' && selection.selectedItem) {
154
+ showEditAccount({ accountId: selection.selectedItem.id });
155
+ }
156
+ }} />
157
+ ```
88
158
 
89
159
  `MenuItem` renders nothing on its own; it is a marker that `DataPage.MenuItems`
90
160
  reads. Icons are usually a small inline component:
@@ -132,6 +132,15 @@ The command then executes, and on failure calls `onValidationFailure(result.vali
132
132
  or `onFailed(result)` and **keeps the dialog open**. On success it calls
133
133
  `onSuccess(result.response)` and then the close gate.
134
134
 
135
+ Read the owning [CommandResult reference](../../cratis-arc-command/references/command-result.md)
136
+ for result classification, protected-read recovery and message safety. A refusal
137
+ keeps the draft and dialog open, not a successful response to close over.
138
+ `onValidationFailure` alone does not suppress built-in feedback. `showErrors={false}`
139
+ is forwarded to `CommandForm`; the dialog's separate `validationAnnouncement`
140
+ also needs application-owned safe copy when results carry diagnostics. See
141
+ [queries-and-commands.md](queries-and-commands.md) for `autoServerValidate` and
142
+ `/validate` as feedback under read protection, not a guarantee of execution.
143
+
135
144
  ### `initialValues` versus `onBeforeExecute`
136
145
 
137
146
  Validation runs against the pre-transform values, so a required value seeded in
@@ -195,6 +204,21 @@ requires Arc and Arc React >=22.16.0:
195
204
  <AutoCommandForm command={RegisterInvoice} exclude={['invoiceId']} />
196
205
  ```
197
206
 
207
+ `AutoCommandFields` from `@cratis/components/CommandForm` renders generated
208
+ fields **inside an existing** `CommandForm` or `CommandDialog`; unlike
209
+ `AutoCommandForm`, it creates no form shell. It accepts
210
+ `exclude?: (keyof TCommand)[]`. It requires the form context and has no fields
211
+ without generated property descriptors. Steppers and column layouts are not
212
+ supported. Keep one shell:
213
+
214
+ ```tsx
215
+ <CommandDialog command={RegisterInvoice} title='Register invoice'>
216
+ <AutoCommandFields<RegisterInvoice> exclude={['invoiceId']} />
217
+ </CommandDialog>
218
+ ```
219
+
220
+ Use `AutoCommandForm` when it owns the shell; do not nest it in another form.
221
+
198
222
  ## `Dialog` — data without a command
199
223
 
200
224
  ```tsx
@@ -170,60 +170,32 @@ const result = await command.execute();
170
170
  `validate()`, `clear()`, `setInitialValues(values)`, `revertChanges()`, and
171
171
  `hasChanges`.
172
172
 
173
- ### Read the result by the granular flag
173
+ ### Command result handling
174
174
 
175
- | Flag | Meaning | Response |
176
- | --- | --- | --- |
177
- | `isSuccess` | authorized, valid, and no exception | happy path |
178
- | `isAuthorized` | roles or policy rejected the call | redirect to login, or "not allowed" |
179
- | `isValid` | validation failed — `validationResults` carries the messages | render inline field errors |
180
- | `hasExceptions` | the handler threw — `exceptionMessages` carries diagnostics | generic error, and log it |
175
+ Read the owning [CommandResult reference](../../cratis-arc-command/references/command-result.md)
176
+ before choosing success, refusal, retry or fault feedback. It owns the complete
177
+ result shape, protected-read reason pairs and message-safety decision table;
178
+ do not infer success from only authorization/validity/exception flags. Mount a
179
+ `<Toaster />` near the app root when using notifications.
181
180
 
182
- The result also carries `correlationId`, `authorizationFailureReason`,
183
- `exceptionStackTrace`, and the typed `response`. Fluent callbacks
184
- `onSuccess`, `onFailed`, `onException`, `onUnauthorized`, and
185
- `onValidationFailure` each return the result for chaining.
181
+ ### Validation feedback under read protection
186
182
 
187
- ```tsx
188
- const result = await command.execute();
189
- if (!result.isAuthorized) { redirectToLogin(); return; }
190
- if (!result.isValid) { /* validationResults -> inline field errors */ return; }
191
- if (result.hasExceptions) { console.error(result.exceptionMessages); return; }
192
- ```
183
+ `command.validate()` calls `{url}/validate`; `CommandForm`'s `autoServerValidate`
184
+ is opt-in and defaults to `false`. When enabled, it runs throttled server
185
+ validation as values change (default `autoServerValidateThrottle` is 500 ms).
186
+ These are form feedback, not a reservation or permission to execute.
193
187
 
194
- A validation result is:
195
-
196
- ```ts
197
- class ValidationResult {
198
- severity: ValidationResultSeverity; // Unknown 0, Information 1, Warning 2, Error 3
199
- message: string;
200
- members: string[]; // the properties the message applies to
201
- state: unknown;
202
- reason: ValidationResultReason; // 'rule' by default
203
- reasonDetail?: string;
204
- }
205
- ```
206
-
207
- Render per-field errors from `members` and `message`. Never branch on the raw
208
- message text. `exceptionMessages` and `exceptionStackTrace` are for logging,
209
- never for users.
210
-
211
- `toastCommandResult(result, options)` from `@cratis/components/Notifications`
212
- collapses the whole branch into one call — mount a `<Toaster />` near the app
213
- root and it maps every flag to the right toast without showing stack traces. It
214
- returns `true` when the command succeeded:
215
-
216
- ```tsx
217
- if (toastCommandResult(result, { successTitle: 'Account registered' })) refresh();
218
- ```
188
+ Under read protection `On`, `/validate` runs filters and validators with fresh
189
+ reads, but does not call `Provide()` or `Handle()`, guard a commit, or write
190
+ anything. Execution reads its own fresh state and guards from that position;
191
+ it cannot reuse the earlier validation fold. A successful preflight does not
192
+ promise execution success. Handle protected-read refusals using the owning
193
+ result table, preserving the draft rather than marking input invalid.
219
194
 
220
195
  For ad-hoc notifications the imperative `toast.success/info/warn/error` each
221
196
  take an **options object**, not a bare string:
222
197
  `toast.info({ title: 'Saved', description: 'Your changes were saved.' })`.
223
198
 
224
- `CommandDialog` performs all of this itself — the flags matter most when
225
- executing a command outside a dialog.
226
-
227
199
  ### Command scope
228
200
 
229
201
  `CommandScope` plus `useCommandScope()` (`@cratis/arc.react/commands`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.176.1",
3
+ "version": "7.177.0",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [