@cratis/pi 7.176.0 → 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.
- package/package/corpus/agents/frontend-developer.md +2 -0
- package/package/corpus/agents/spec-writer.md +3 -3
- package/package/corpus/harnesses/copilot/instructions/components.instructions.md +4 -4
- package/package/corpus/harnesses/copilot/instructions/react.instructions.md +3 -21
- package/package/corpus/harnesses/copilot/instructions/specs.csharp.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/specs.scenarios.csharp.instructions.md +5 -5
- package/package/corpus/harnesses/pi/agents/frontend-developer.md +2 -0
- package/package/corpus/harnesses/pi/agents/spec-writer.md +3 -3
- package/package/corpus/rules/components.md +4 -4
- package/package/corpus/rules/react.md +3 -21
- package/package/corpus/rules/specs.csharp.md +1 -1
- package/package/corpus/rules/specs.scenarios.csharp.md +5 -5
- package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +16 -13
- package/package/corpus/skills/cratis-application-slice-specifications/references/query-and-decision-scenarios.md +73 -26
- package/package/corpus/skills/cratis-arc-command/references/command-result.md +69 -17
- package/package/corpus/skills/cratis-arc-command/references/decisions-and-routing.md +16 -13
- package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +10 -5
- package/package/corpus/skills/cratis-arc-react-page/SKILL.md +27 -8
- package/package/corpus/skills/cratis-arc-react-page/references/availability.md +65 -0
- package/package/corpus/skills/cratis-arc-react-page/references/data-page.md +78 -8
- package/package/corpus/skills/cratis-arc-react-page/references/dialogs.md +24 -0
- package/package/corpus/skills/cratis-arc-react-page/references/queries-and-commands.md +17 -45
- package/package/corpus/skills/cratis-chronicle-decision-reads/SKILL.md +11 -6
- package/package/corpus/skills/cratis-chronicle-decision-reads/references/choosing-how-a-rule-holds.md +17 -14
- package/package/corpus/skills/cratis-code-review/SKILL.md +5 -1
- package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +12 -11
- package/package/corpus/skills/cratis-specifications-csharp/references/running-specs.md +62 -4
- package/package.json +1 -1
|
@@ -190,20 +190,23 @@ source id/type and stream route; reactor tuples/collections cannot mix it with e
|
|
|
190
190
|
## Decision specifications
|
|
191
191
|
|
|
192
192
|
Call `Handle()` and validators directly with read-model state for pure business
|
|
193
|
-
decisions
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
copies left rejects).
|
|
193
|
+
decisions; validators own refusals. `Provide()` acquires data and only short-circuits
|
|
194
|
+
(`ValidationResult`/`AuthorizationResult`) when acquisition yields nothing usable,
|
|
195
|
+
not for ordinary validation rules. Follow
|
|
196
|
+
the [scenario rule](../../../rules/specs.scenarios.csharp.md): ordinary application
|
|
197
|
+
specs do not re-prove Arc/Chronicle's platform concurrency, conflict-refusal or
|
|
198
|
+
isolation matrix. Typed scenarios select decision reads automatically;
|
|
199
|
+
`UseDecisionReads()` is obsolete. Keep one assembly-level shape-admission check;
|
|
200
|
+
explicit body reads need their own admission check or focused scenario. Never
|
|
201
|
+
weaken production guards for speed; report harness state-setup gaps upstream.
|
|
202
|
+
|
|
203
|
+
Add scenarios for pipeline/authorization wiring or constraints. Assert the business
|
|
204
|
+
outcome from supplied state (for example, no copies left rejects in the validator).
|
|
205
|
+
An unusual application-owned explicit guard policy may need a focused regression
|
|
206
|
+
a plain call cannot prove, not a generic race matrix. Read
|
|
205
207
|
[query and decision scenarios](../../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
206
|
-
for the
|
|
208
|
+
for the admission example, limits and advanced hook boundary. Keep shared
|
|
209
|
+
lifecycle on and measure the added cost.
|
|
207
210
|
|
|
208
211
|
## Sources
|
|
209
212
|
|
|
@@ -272,11 +272,16 @@ Every rule gets a failure specification: instantiate the validator with its
|
|
|
272
272
|
read-model state and validate directly, asserting the specific rejection. Add
|
|
273
273
|
`CommandScenario<TCommand>` only for pipeline/authorization wiring, constraints.
|
|
274
274
|
Follow the
|
|
275
|
-
[scenario rule](../../rules/specs.scenarios.csharp.md): application specs
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
application-shape admission
|
|
279
|
-
|
|
275
|
+
[scenario rule](../../rules/specs.scenarios.csharp.md): ordinary application specs
|
|
276
|
+
supply state, not a replay of the platform guard matrix. Typed scenarios select
|
|
277
|
+
decision reads automatically; `UseDecisionReads()` is obsolete. Keep one
|
|
278
|
+
assembly-level application-shape admission check; explicit body reads need their
|
|
279
|
+
own admission check or focused scenario. An unusual application-owned explicit
|
|
280
|
+
guard policy can justify a focused regression a plain call cannot prove; read the
|
|
281
|
+
[decision guidance](../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
282
|
+
for the example, limits and advanced hook boundary. Validators own refusals;
|
|
283
|
+
`Provide()` only short-circuits (`ValidationResult`/`AuthorizationResult`) when
|
|
284
|
+
acquisition yields nothing usable, not for ordinary validation rules. Report harness gaps upstream; never weaken
|
|
280
285
|
production guards for speed.
|
|
281
286
|
|
|
282
287
|
For a pipeline validation rejection, assert **both** that the command did not
|
|
@@ -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
|
-
|
|
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
|
|
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,
|
|
303
|
-
|
|
304
|
-
[
|
|
305
|
-
persona that can reach the page but whose policy refuses the action),
|
|
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
|
-
-
|
|
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` | `
|
|
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<
|
|
51
|
-
| `detailsComponent` | `React.FC<IDetailsComponentProps<
|
|
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
|
-
##
|
|
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` |
|
|
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
|
-
###
|
|
173
|
+
### Command result handling
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
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
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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`)
|
|
@@ -191,13 +191,18 @@ deciding writer is guarded or the rule is a constraint.
|
|
|
191
191
|
- Review production enrollment in the intended store, namespace and stream;
|
|
192
192
|
surface refusal and never replace it with an unprotected read. One owner completes.
|
|
193
193
|
- Application specs call `Handle()` or the validator directly with supplied state.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
[scenario rule](../../rules/specs.scenarios.csharp.md)
|
|
194
|
+
Keep one assembly-level `DecisionReadAdmissions.ShouldAdmitDecisionReadsIn(assembly)`
|
|
195
|
+
check of discoverable application shapes; explicit body reads need their own
|
|
196
|
+
admission check or focused scenario. See the
|
|
197
|
+
[scenario rule](../../rules/specs.scenarios.csharp.md) and
|
|
198
|
+
[decision guidance](../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
199
|
+
for the example, admission limits and advanced hook boundary.
|
|
198
200
|
- Arc/Chronicle specs alone prove platform conflict refusal, relevant/irrelevant
|
|
199
201
|
changes, absence guards, empty checked appends, isolation and commit lifecycle.
|
|
200
202
|
Their real-client/kernel integration proves the boundary; a default
|
|
201
203
|
`EventScenario` scope strategy returning `None` is not concurrency evidence.
|
|
202
|
-
-
|
|
203
|
-
|
|
204
|
+
- Ordinary application specs do not repeat that matrix. An unusual
|
|
205
|
+
application-owned explicit guard policy may need a focused regression a plain
|
|
206
|
+
call cannot prove, not a routine race template. Typed scenarios select decision
|
|
207
|
+
reads automatically; `UseDecisionReads()` is obsolete. Never weaken production
|
|
208
|
+
guards for spec speed.
|
|
@@ -340,20 +340,23 @@ justified opt-out, then remove the property and any per-command
|
|
|
340
340
|
## Specify the business decision
|
|
341
341
|
|
|
342
342
|
Start with a plain `Handle()` or validator call supplied with read-model state.
|
|
343
|
-
Follow the [scenario rule](../../../rules/specs.scenarios.csharp.md):
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
343
|
+
Follow the [scenario rule](../../../rules/specs.scenarios.csharp.md): ordinary
|
|
344
|
+
application specs prove the decision, not Arc/Chronicle's platform concurrency,
|
|
345
|
+
conflict-refusal or isolation matrix. Typed scenarios select decision reads
|
|
346
|
+
automatically; `UseDecisionReads()` is obsolete. Keep one assembly-level
|
|
347
|
+
`DecisionReadAdmissions.ShouldAdmitDecisionReadsIn(assembly)` check of discoverable
|
|
348
|
+
application models/projections. Explicit body reads need their own admission check
|
|
349
|
+
or focused scenario; see the
|
|
350
|
+
[decision guidance](../../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
351
|
+
for the example, limits and advanced hook boundary. Production protection stays
|
|
352
|
+
unchanged regardless of spec cost.
|
|
353
|
+
|
|
354
|
+
For two borrowers competing for the last copy, give no-copy state to the validator
|
|
355
|
+
and assert rejection; Arc/Chronicle prove the guard. `Provide()` acquires data and
|
|
356
|
+
only short-circuits (`ValidationResult`/`AuthorizationResult`) when acquisition
|
|
357
|
+
yields nothing usable, not for ordinary validation rules. An unusual application-owned explicit guard
|
|
358
|
+
policy may need a focused regression a plain call cannot prove, not a generic
|
|
359
|
+
race matrix. Report harness state gaps upstream rather than inventing guard doubles.
|
|
357
360
|
|
|
358
361
|
## Costs
|
|
359
362
|
|
|
@@ -164,7 +164,11 @@ degradations a reviewer can see without measuring:
|
|
|
164
164
|
per-artifact decision table of `specs.scenarios.csharp.md` (pipeline and
|
|
165
165
|
authorization, constraints, projection and reducer dispatch, reactor dispatch
|
|
166
166
|
and routing) and none beyond it. A rule that must hold under concurrent
|
|
167
|
-
writers is proven from supplied read-model state, not a race scenario
|
|
167
|
+
writers is proven from supplied read-model state, not a race scenario
|
|
168
|
+
re-proving the platform matrix. For an unusual application-owned explicit
|
|
169
|
+
guard policy, accept only a focused regression a plain call cannot prove;
|
|
170
|
+
check the [decision guidance](../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
171
|
+
for the assembly-level admission check, body-read limits and advanced hook boundary.
|
|
168
172
|
- Every State Change command has a happy-path specification.
|
|
169
173
|
- Every validation rule has a direct-call failure spec. Pipeline validation
|
|
170
174
|
specs assert **both** `ShouldNotBeSuccessful()` and `ShouldHaveValidationErrors()`.
|
|
@@ -90,22 +90,23 @@ before changing runner or package family.
|
|
|
90
90
|
The plain `Specification` base is the universal foundation and the dominant mode
|
|
91
91
|
in library and framework code. In applications, start pure decisions with a
|
|
92
92
|
plain call, including direct validator calls, and add the scenarios the
|
|
93
|
-
per-artifact decision table in `specs.scenarios.csharp.md` obligates. Keep shared lifecycle on;
|
|
94
|
-
[running-specs.md](references/running-specs.md). Read
|
|
93
|
+
per-artifact decision table in `specs.scenarios.csharp.md` obligates. Keep shared lifecycle on; diagnose runner startup, lifecycle and scenario cost
|
|
94
|
+
before rewriting, using [running-specs.md](references/running-specs.md). Read
|
|
95
95
|
[application-scenarios.md](references/application-scenarios.md) before using
|
|
96
96
|
one. Out-of-process integration specifications are an advanced case reserved for
|
|
97
97
|
boundaries the scenario helpers cannot reach — see
|
|
98
98
|
[integration-specs.md](references/integration-specs.md).
|
|
99
99
|
|
|
100
|
-
⚠️
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
⚠️ An unguarded in-process append using the default no-scope strategy is not
|
|
101
|
+
concurrency evidence: its no-conflict assertion can pass vacuously. This is not
|
|
102
|
+
a claim about every guarded scenario or explicit scope. Arc/Chronicle own the
|
|
103
|
+
platform concurrency/isolation matrix. Ordinary applications supply state in
|
|
104
|
+
plain `Handle()`/validator calls and keep one assembly-level admission check;
|
|
105
|
+
see the [scenario rule](../../rules/specs.scenarios.csharp.md). For an unusual
|
|
106
|
+
application-owned explicit guard policy, use only a focused regression that a
|
|
107
|
+
plain call cannot prove; read the
|
|
108
|
+
[decision guidance](../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
109
|
+
for admission limits and the advanced hook's boundary.
|
|
109
110
|
|
|
110
111
|
For a class-based `ReactorScenario<TReactor>` on a recent Chronicle (Requires Chronicle 19.46.0), seed each
|
|
111
112
|
handler read-model parameter with `Given.ForEventSourceId(id).ReadModel(instance)`
|