@cosmicdrift/kumiko-framework 0.417.0 → 0.419.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/agents/api/framework-engine.md +1 -0
- package/agents/api/framework-ui-types.md +14 -5
- package/agents/api/renderer-web.md +4 -0
- package/agents/api/types.md +29 -4
- package/agents/api.md +2 -2
- package/agents/boot-rules.md +20 -0
- package/agents/examples/crypto-shredding-hr.md +2 -2
- package/agents/examples/list-table-options.md +275 -7
- package/agents/examples/pdf-letterhead.md +473 -0
- package/agents/examples.md +1 -0
- package/agents/features.md +12 -1
- package/agents/widgets.md +1 -0
- package/dist/api/server-boot-checks.d.ts +1 -0
- package/dist/api/server-boot-checks.js +25 -0
- package/dist/api/server-rate-limit-wiring.js +2 -1
- package/dist/engine/boot-validator/action-form-preview-rules.d.ts +22 -0
- package/dist/engine/boot-validator/action-form-preview-rules.js +22 -0
- package/dist/engine/boot-validator/action-form-preview.d.ts +2 -0
- package/dist/engine/boot-validator/action-form-preview.js +54 -0
- package/dist/engine/boot-validator/boot-rules.d.ts +76 -0
- package/dist/engine/boot-validator/boot-rules.js +2 -0
- package/dist/engine/boot-validator/config-key-rules.d.ts +5 -0
- package/dist/engine/boot-validator/config-key-rules.js +5 -0
- package/dist/engine/boot-validator/date-only-after-days.d.ts +4 -0
- package/dist/engine/boot-validator/date-only-after-days.js +32 -0
- package/dist/engine/boot-validator/entity-handler.d.ts +1 -0
- package/dist/engine/boot-validator/entity-handler.js +1 -1
- package/dist/engine/boot-validator/list-bulk-actions-rules.d.ts +40 -0
- package/dist/engine/boot-validator/list-bulk-actions-rules.js +40 -0
- package/dist/engine/boot-validator/list-bulk-actions.d.ts +2 -1
- package/dist/engine/boot-validator/list-bulk-actions.js +79 -9
- package/dist/engine/boot-validator/query-output-columns.js +25 -2
- package/dist/engine/boot-validator/query-refs.js +3 -0
- package/dist/engine/boot-validator/screens-actions.d.ts +6 -1
- package/dist/engine/boot-validator/screens-actions.js +2 -2
- package/dist/engine/boot-validator/screens-forms.js +2 -0
- package/dist/engine/boot-validator/screens-kind-entity-list.js +2 -2
- package/dist/engine/boot-validator/screens-kind-projection-list.js +1 -1
- package/dist/engine/boot-validator/screens-kind-shared.d.ts +1 -1
- package/dist/engine/boot-validator/screens-kind-shared.js +3 -1
- package/dist/engine/boot-validator/screens-lists-rules.d.ts +10 -0
- package/dist/engine/boot-validator/screens-lists-rules.js +10 -0
- package/dist/engine/boot-validator/screens-lists.js +13 -1
- package/dist/engine/boot-validator/url-prefill-fields.js +8 -1
- package/dist/engine/boot-validator/zod-shape.d.ts +1 -0
- package/dist/engine/boot-validator/zod-shape.js +7 -0
- package/dist/engine/build-config-feature-schema.js +5 -1
- package/dist/engine/registry-ingest.js +11 -0
- package/dist/engine/types/screen.d.ts +1 -1
- package/dist/engine/types/screen.js +1 -1
- package/dist/i18n/required-surface-keys.js +47 -13
- package/dist/ui-types/index.d.ts +1 -1
- package/package.json +3 -3
- package/src/changes.json +36 -0
|
@@ -300,6 +300,7 @@ type ActionFormScreenDefinition = {
|
|
|
300
300
|
successLinks?: ActionFormSuccessLink[]; // Links shown in the success box after a successful submit while the screen stays put.
|
|
301
301
|
successFacts?: ActionFormSuccessFact[]; // Key figures from the handler's success payload, shown in the success box while the screen stays put (e.g. charged/skipped/failed of a batch run).
|
|
302
302
|
successItems?: ActionFormSuccessItems; // One hint per entry of a success-payload array, each with its own link (e.g. "this file is already in the inbox" with "Open" per uploaded file).
|
|
303
|
+
preview?: ActionFormPreview; // Preview of what the submit will do, computed by a query from the current form values.
|
|
303
304
|
resetOnSuccess?: boolean; // Reset the form to its initial values after a successful submit (prefill kept, typed values cleared).
|
|
304
305
|
load?: ActionFormLoad; // Load the initial values from a query.
|
|
305
306
|
cancelTarget?: string | false; // Target of the Cancel button.
|
|
@@ -67,6 +67,17 @@ type ActionFormLoad = {
|
|
|
67
67
|
singleton?: boolean; // The query picks the row from the caller's tenant/session context, so the form loads without a record id and the query is called WITHOUT `idParam` (same semantics as `ProjectionDetailScreenDefinition.singleton`).
|
|
68
68
|
passPrefill?: boolean; // Sends the values a drawer opens the form with (row-action params, e.g. `vehicleId`) in the load payload next to `idParam`, so the query can pre-fill for the chosen item.
|
|
69
69
|
};
|
|
70
|
+
type ActionFormPreview = { // Preview panel above the submit button: runs a query over the current form values and shows what the submit would do.
|
|
71
|
+
query: string; // Query QN.
|
|
72
|
+
fields?: string[]; // Form fields sent to the query; they also trigger a rerun when they change.
|
|
73
|
+
title?: string; // Panel title (i18n key).
|
|
74
|
+
facts?: ActionFormSuccessFact[]; // Key figures from the query result, shown like the success box facts.
|
|
75
|
+
list?: ActionFormPreviewList; // Table of rows from the query result.
|
|
76
|
+
};
|
|
77
|
+
type ActionFormPreviewList = { // Rows of the preview panel, read from an array in the preview query's result.
|
|
78
|
+
field: string; // Flat field name of an array in the query result; an entry that is no object is skipped.
|
|
79
|
+
columns: { field: string; label: string; type?: ActionFormValueType; }[];
|
|
80
|
+
};
|
|
70
81
|
type ActionFormRedirect = { // Redirect target plus the success-payload field carrying the navigation id.
|
|
71
82
|
screen: string; // Same target forms as the string `redirect`: short screen ID (same-feature) or a fully-qualified cross-feature screen QN.
|
|
72
83
|
idFrom?: string; // Flat field name in the handler's success payload, e.g. "leaseId".
|
|
@@ -76,6 +87,7 @@ type ActionFormRedirect = { // Redirect target plus the success-payload field ca
|
|
|
76
87
|
type ActionFormSuccessFact = { // One key figure of the success box, read from the handler's success payload.
|
|
77
88
|
field: string; // Flat field name in the handler's success payload.
|
|
78
89
|
label: string; // Label (i18n key).
|
|
90
|
+
type?: ActionFormValueType; // Format of the value (a money object, a date string, a number); default `text`.
|
|
79
91
|
};
|
|
80
92
|
type ActionFormSuccessItems = { // Per-entry hints of the success box, read from an array in the handler's success payload.
|
|
81
93
|
field: string; // Flat field name of an array in the success payload.
|
|
@@ -86,6 +98,7 @@ type ActionFormSuccessLink = Omit<ActionFormRedirect, "idFrom" | "searchParams">
|
|
|
86
98
|
params?: Readonly<Record<string, string>>; // URL search params of the target, each read from a success-payload field (`{ cmd: "duplicateOfId" }` opens `?cmd=<duplicateOfId>`).
|
|
87
99
|
label: string; // Link text (i18n key).
|
|
88
100
|
};
|
|
101
|
+
type ActionFormValueType = "text" | "number" | "money" | "date" | "timestamp"; // How a preview value or success fact is formatted, by the same formatters a list cell uses.
|
|
89
102
|
type AppSchema = {
|
|
90
103
|
features: FeatureSchema[];
|
|
91
104
|
workspaces?: WorkspaceSchema[];
|
|
@@ -522,11 +535,7 @@ type FormDerivationScreen = {
|
|
|
522
535
|
type FormWidth = "3xl" | "4xl" | "full";
|
|
523
536
|
type Formality = "formal" | "informal";
|
|
524
537
|
type IconKey = NavIconKey;
|
|
525
|
-
type ListBulkAction =
|
|
526
|
-
id: string; // Stable id, kebab-case, unique among the screen's bulk actions.
|
|
527
|
-
rowAction: string; // Id of a writeHandler entry in the same screen's `rowActions`; it supplies handler, payload, label, style and `visible`.
|
|
528
|
-
confirm?: string; // i18n key of the one confirm dialog for the whole selection; gets `{count}` and `{action}`.
|
|
529
|
-
};
|
|
538
|
+
type ListBulkAction = ListBulkRowAction | ListBulkFormAction; // An action over checkbox-selected rows: a writeHandler row action per row (`rowAction`) or one form for all rows (`screen` + `idsField`).
|
|
530
539
|
type ListColumnHint = {
|
|
531
540
|
detailField?: string; // Row field with a second, muted line (e.g. the due date as text).
|
|
532
541
|
narrowDetailField?: string; // Row field shown as the detail line below `sm` instead of `detailField` (a shorter line, e.g. "5 days · Anna Schneider").
|
|
@@ -41,6 +41,7 @@ function EditorInfoBar(props: { tone: InfoBarTone; testId: string; origin?: Reac
|
|
|
41
41
|
function EditorLocaleSwitch(props: { testIdPrefix: string; locales: string[]; locale: string; onLocale: (locale: string) => void; }): ReactNode;
|
|
42
42
|
function EditorModeSwitch(props: { testIdPrefix: string; mode: EditorMode; onMode: (mode: EditorMode) => void; }): ReactNode;
|
|
43
43
|
function EditorPanel(props: EditorPanelProps): ReactNode;
|
|
44
|
+
function EditorToolbarPill(props: { children: ReactNode; }): ReactNode;
|
|
44
45
|
function EditorWorkbench(props: EditorWorkbenchProps): ReactNode;
|
|
45
46
|
function EmptyState(props: { icon?: ReactNode; title: string; description?: string; action?: ReactNode; testId?: string; }): ReactNode; // Empty state with an optional icon and CTA, using the dashed-box style of entityList empty states as a standalone widget for custom screens.
|
|
46
47
|
function ErrorState(props: { error: DispatcherError; onRetry?: () => void; testId?: string; }): ReactNode; // Error state based on the Banner primitive, with a retry button.
|
|
@@ -1042,6 +1043,8 @@ type MenuItemDef =
|
|
|
1042
1043
|
kind: "item";
|
|
1043
1044
|
id: string;
|
|
1044
1045
|
label: string;
|
|
1046
|
+
description?: string;
|
|
1047
|
+
testId?: string;
|
|
1045
1048
|
icon?: ReactNode; // Optional icon displayed before the label (16px).
|
|
1046
1049
|
shortcut?: string; // Display-only shortcut hint on the right (monospace, muted).
|
|
1047
1050
|
onSelect: () => void;
|
|
@@ -1377,6 +1380,7 @@ type RenderEditProps<TValues extends FormValues, TCtx = unknown> = {
|
|
|
1377
1380
|
}; // Record-view look of a projectionDetail; each key is opt-in.
|
|
1378
1381
|
fillScreenHeight?: boolean; // Screen body fills the shell height: the form gets `fillHeight` and `stickyActions` (sections scroll, footer pinned).
|
|
1379
1382
|
leadContent?: ReactNode; // Rendered first inside the form, above the sections, in the same column and rhythm — for content that belongs to the form but is no field (e.g. the secret a confirm step refers to).
|
|
1383
|
+
belowSections?: (values: Readonly<Record<string, unknown>>) => ReactNode; // Rendered after the sections, above the form actions, with the live form values.
|
|
1380
1384
|
submitBlocked?: boolean; // Blocks submit (button and Enter) while fields stay editable — unlike `disabled`, which locks the whole form.
|
|
1381
1385
|
formDerivation?: FormDerivationScreen; // actionForm `derive`: derived fields are recomputed into the form state on every change and render read-only.
|
|
1382
1386
|
actionFormScreenQn?: string; // QN of the actionForm screen this form renders; its file fields upload as pending for that screen.
|
package/agents/api/types.md
CHANGED
|
@@ -1825,13 +1825,19 @@ type DataTableBulk = {
|
|
|
1825
1825
|
actions: DataTableBulkAction[];
|
|
1826
1826
|
reload: () => Promise<void>; // Reloads the list once after a run.
|
|
1827
1827
|
};
|
|
1828
|
-
type DataTableBulkAction =
|
|
1828
|
+
type DataTableBulkAction = DataTableBulkWriteAction | DataTableBulkFormAction;
|
|
1829
|
+
type DataTableBulkActionBase = {
|
|
1829
1830
|
id: string;
|
|
1830
|
-
label: string; // Translated label of the underlying row action.
|
|
1831
|
+
label: string; // Translated label of the underlying row action or form action.
|
|
1831
1832
|
style?: "primary" | "secondary" | "danger";
|
|
1832
1833
|
icon?: IconKey;
|
|
1833
1834
|
confirmText?: (count: number) => string; // Present: one confirm dialog for the whole selection, with this text for `count` rows.
|
|
1834
1835
|
confirmLabel?: string;
|
|
1836
|
+
};
|
|
1837
|
+
type DataTableBulkFormAction = DataTableBulkActionBase & {
|
|
1838
|
+
openForm: (rows: ListRowViewModel[]) => void; // Hands the whole selection to one form instead of running writes in the table.
|
|
1839
|
+
};
|
|
1840
|
+
type DataTableBulkWriteAction = DataTableBulkActionBase & {
|
|
1835
1841
|
appliesTo: (row: ListRowViewModel) => boolean; // False: the row action's `visible` hides it for this row; the run skips the row.
|
|
1836
1842
|
writeRow: (row: ListRowViewModel) => Promise<BulkRowOutcome>; // Exactly one server write for one row.
|
|
1837
1843
|
};
|
|
@@ -2223,7 +2229,7 @@ type EditFieldViewModel = {
|
|
|
2223
2229
|
query: string;
|
|
2224
2230
|
payload: OptionsQueryPayload;
|
|
2225
2231
|
}; // Set for `type: "select"` / `"multiSelect"` when optionsAvailabilityQuery is set: the renderer loads `{ rows: { value, disabled?, hint?
|
|
2226
|
-
display?: "checkboxes" | "chips" | "dropdown" | "radio"; // Set for `type: "multiSelect"` when MultiSelectFieldDef.display is "checkboxes" — the renderer shows a checkbox grid with a select-all toggle instead of the default combobox dropdown.
|
|
2232
|
+
display?: "checkboxes" | "chips" | "dropdown" | "radio" | "count"; // Set for `type: "multiSelect"` when MultiSelectFieldDef.display is "checkboxes" — the renderer shows a checkbox grid with a select-all toggle instead of the default combobox dropdown.
|
|
2227
2233
|
optionTones?: Readonly<Partial<Record<string, SelectOptionTone>>>; // `type: "select"` only: tone per option, shown on the selected radio segment.
|
|
2228
2234
|
columns?: 1 | 2 | 3 | 4; // Set for `type: "multiSelect"` when MultiSelectFieldDef.columns is defined — column count for the checkbox grid at the widest breakpoint.
|
|
2229
2235
|
maxRows?: number; // Set for `type: "multiSelect"` when MultiSelectFieldDef.maxRows is defined — grid rows visible before the checkbox grid becomes scrollable.
|
|
@@ -2513,6 +2519,7 @@ type ActionMenuItemSpec = { // One item in an `ActionOverflowMenu` (header/row a
|
|
|
2513
2519
|
type ActionOverflowMenuProps = {
|
|
2514
2520
|
items: ActionMenuItemSpec[];
|
|
2515
2521
|
label: string; // aria-label for the three-dots trigger.
|
|
2522
|
+
triggerLabel?: string; // Renders a labelled button (plus icon, text, chevron) instead of the three-dots icon.
|
|
2516
2523
|
testId?: string;
|
|
2517
2524
|
};
|
|
2518
2525
|
type ButtonBaseProps = {
|
|
@@ -2658,6 +2665,7 @@ type ModalProps = { // Bare content shell for hosting an existing self-contained
|
|
|
2658
2665
|
title: string; // Screen-reader-only accessible title (required by the underlying dialog primitive) — not shown visually since the hosted content is expected to render its own heading.
|
|
2659
2666
|
children: ReactNode;
|
|
2660
2667
|
testId?: string;
|
|
2668
|
+
size?: "default" | "wide"; // "wide" suits content with lists beside actions; web caps it at the viewport.
|
|
2661
2669
|
};
|
|
2662
2670
|
type PageHeaderProps = { // Page title area rendered by the app shell's header instead of inside the screen: `title` replaces the last breadcrumb, `status` sits right after it, `actions` at the right edge.
|
|
2663
2671
|
title?: string;
|
|
@@ -3966,7 +3974,7 @@ type MultiSelectFieldDef<TOptions extends string[] = string[]> = PiiAndFieldStat
|
|
|
3966
3974
|
sensitive?: boolean;
|
|
3967
3975
|
default?: TOptions[number][]; // Default selection.
|
|
3968
3976
|
access?: FieldAccess;
|
|
3969
|
-
display?: "checkboxes" | "chips" | "dropdown"; // Renderer metadata: `"checkboxes"` renders every option as a visible checkbox with a select-all toggle.
|
|
3977
|
+
display?: "checkboxes" | "chips" | "dropdown" | "count"; // Renderer metadata: `"checkboxes"` renders every option as a visible checkbox with a select-all toggle.
|
|
3970
3978
|
columns?: 1 | 2 | 3 | 4; // Renderer metadata: column count for the `"checkboxes"` grid at the widest breakpoint; narrow viewports always collapse to one column.
|
|
3971
3979
|
maxRows?: number; // Renderer metadata: how many grid rows stay visible before the `"checkboxes"` grid becomes scrollable.
|
|
3972
3980
|
optionsAvailabilityQuery?: string; // Query returning `{ rows: { value, disabled?, hint?
|
|
@@ -5131,6 +5139,23 @@ type ExpandableRowGrouping = Omit<ListTableGrouping, "field" | "userChoice" | "f
|
|
|
5131
5139
|
};
|
|
5132
5140
|
```
|
|
5133
5141
|
|
|
5142
|
+
## packages/types/src/screen-list-bulk.ts
|
|
5143
|
+
|
|
5144
|
+
```ts
|
|
5145
|
+
type ListBulkFormAction = { // Opens an `actionForm` screen for the whole selection.
|
|
5146
|
+
id: string; // Stable id, kebab-case, unique among the screen's bulk actions.
|
|
5147
|
+
label: string; // i18n key of the button label.
|
|
5148
|
+
icon?: IconKey;
|
|
5149
|
+
screen: string; // Short id (same feature) or `<feature>:screen:<id>` of an `actionForm` screen.
|
|
5150
|
+
idsField: string; // Field of that form which receives the selected row ids: a `multiSelect` with `display: "count"`.
|
|
5151
|
+
};
|
|
5152
|
+
type ListBulkRowAction = { // Runs a writeHandler row action once per checkbox-selected row.
|
|
5153
|
+
id: string; // Stable id, kebab-case, unique among the screen's bulk actions.
|
|
5154
|
+
rowAction: string; // Id of a writeHandler entry in the same screen's `rowActions`; it supplies handler, payload, label, style and `visible`.
|
|
5155
|
+
confirm?: string; // i18n key of the one confirm dialog for the whole selection; gets `{count}` and `{action}`.
|
|
5156
|
+
};
|
|
5157
|
+
```
|
|
5158
|
+
|
|
5134
5159
|
## packages/types/src/screen-list-table.ts
|
|
5135
5160
|
|
|
5136
5161
|
```ts
|
package/agents/api.md
CHANGED
|
@@ -10,11 +10,11 @@ Format: one line per function or constant, object and options types as property
|
|
|
10
10
|
| --- | --- | --- |
|
|
11
11
|
| `@cosmicdrift/kumiko-framework/engine` | `api/framework-engine.md` | 446 |
|
|
12
12
|
| `@cosmicdrift/kumiko-framework/errors` | `api/framework-errors.md` | 27 |
|
|
13
|
-
| `@cosmicdrift/kumiko-framework/ui-types` | `api/framework-ui-types.md` |
|
|
13
|
+
| `@cosmicdrift/kumiko-framework/ui-types` | `api/framework-ui-types.md` | 193 |
|
|
14
14
|
| `@cosmicdrift/kumiko-framework/db` | `api/framework-db.md` | 157 |
|
|
15
15
|
| `@cosmicdrift/kumiko-framework/event-store` | `api/framework-event-store.md` | 41 |
|
|
16
16
|
| `@cosmicdrift/kumiko-framework/seeding` | `api/framework-seeding.md` | 6 |
|
|
17
|
-
| `@cosmicdrift/kumiko-renderer/web` | `api/renderer-web.md` |
|
|
17
|
+
| `@cosmicdrift/kumiko-renderer/web` | `api/renderer-web.md` | 380 |
|
|
18
18
|
| `@cosmicdrift/kumiko-testing/stack` | `api/testing-stack.md` | 23 |
|
|
19
19
|
| `@cosmicdrift/kumiko-testing/helpers` | `api/testing-helpers.md` | 72 |
|
|
20
20
|
| `@cosmicdrift/kumiko-dev-server/testing` | `api/dev-server-testing.md` | 5 |
|
package/agents/boot-rules.md
CHANGED
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
`validateBoot` reports every violation as `- [<id>] <message>`, followed by a `Fix:` and a `Rule:` line that links the entry below. Violations with an `unclassified/<check>` id have no entry yet. `kumiko-schema validate --json` returns the same ids.
|
|
6
6
|
|
|
7
|
+
## action-form-preview
|
|
8
|
+
|
|
9
|
+
| Rule | Summary | Fix | Source |
|
|
10
|
+
| --- | --- | --- | --- |
|
|
11
|
+
| <a id="action-form-preview-empty"></a>`action-form-preview/empty` | A preview shows facts or a list. | Add facts or list, or remove preview. | `packages/framework/src/engine/boot-validator/action-form-preview-rules.ts` |
|
|
12
|
+
| <a id="action-form-preview-field-unknown"></a>`action-form-preview/field-unknown` | preview.fields names fields of the form. | Name an existing field of the form, or drop fields to send all of them. | `packages/framework/src/engine/boot-validator/action-form-preview-rules.ts` |
|
|
13
|
+
| <a id="action-form-preview-label-missing"></a>`action-form-preview/label-missing` | Every preview fact and list column has a label. | Add label: the i18n key of the fact or column header. | `packages/framework/src/engine/boot-validator/action-form-preview-rules.ts` |
|
|
14
|
+
| <a id="action-form-preview-list-field-missing"></a>`action-form-preview/list-field-missing` | preview.list names the result field of its rows and at least one column. | Set list.field to the array in the query result and list the columns to show. | `packages/framework/src/engine/boot-validator/action-form-preview-rules.ts` |
|
|
15
|
+
|
|
7
16
|
## agent-effect
|
|
8
17
|
|
|
9
18
|
| Rule | Summary | Fix | Source |
|
|
@@ -112,6 +121,7 @@
|
|
|
112
121
|
| <a id="config-key-conditional-options"></a>`config-key/conditional-options` | A config key does not declare conditionalOptions, which only entity select fields support. | Remove conditionalOptions from the config key. | `packages/framework/src/engine/boot-validator/config-key-rules.ts` |
|
|
113
122
|
| <a id="config-key-default-above-max"></a>`config-key/default-above-max` | A config key's default is not above its bounds.max. | Lower the default or raise bounds.max. | `packages/framework/src/engine/boot-validator/config-key-rules.ts` |
|
|
114
123
|
| <a id="config-key-default-below-min"></a>`config-key/default-below-min` | A config key's default is not below its bounds.min. | Raise the default or lower bounds.min. | `packages/framework/src/engine/boot-validator/config-key-rules.ts` |
|
|
124
|
+
| <a id="config-key-mask-read-only-required"></a>`config-key/mask-read-only-required` | A config key is not both mask.readOnly and required, because nobody could fill it. | Drop required or mask.readOnly. | `packages/framework/src/engine/boot-validator/config-key-rules.ts` |
|
|
115
125
|
| <a id="config-key-options-and-options-query"></a>`config-key/options-and-options-query` | A config key declares either static options or optionsQuery, not both. | Remove options or optionsQuery. | `packages/framework/src/engine/boot-validator/config-key-rules.ts` |
|
|
116
126
|
| <a id="config-key-options-query-empty"></a>`config-key/options-query-empty` | A config key's optionsQuery is a non-empty query name when present. | Set it to a query name or remove it. | `packages/framework/src/engine/boot-validator/config-key-rules.ts` |
|
|
117
127
|
| <a id="config-key-options-query-not-select"></a>`config-key/options-query-not-select` | A config key declares optionsQuery only when its type is "select". | Change the key type to "select" or remove optionsQuery. | `packages/framework/src/engine/boot-validator/config-key-rules.ts` |
|
|
@@ -676,6 +686,8 @@
|
|
|
676
686
|
| <a id="list-column-renderer-component-invalid"></a>`list/column-renderer-component-invalid` | A column renderer's react.__component is a non-empty string. | Set react.__component to the name of a client columnRenderers entry. | `packages/framework/src/engine/boot-validator/screens-lists-rules.ts` |
|
|
677
687
|
| <a id="list-column-renderer-react-not-object"></a>`list/column-renderer-react-not-object` | A column renderer's react branch is an object. | Use { react: { __component: "Name" } }. | `packages/framework/src/engine/boot-validator/screens-lists-rules.ts` |
|
|
678
688
|
| <a id="list-column-sortable-inert"></a>`list/column-sortable-inert` | A column only sets sortable where the screen type honors it. | Remove sortable from the column. | `packages/framework/src/engine/boot-validator/screens-lists-rules.ts` |
|
|
689
|
+
| <a id="list-date-only-after-days-invalid"></a>`list/date-only-after-days-invalid` | A column's dateOnlyAfterDays is a non-negative whole number of days. | Set dateOnlyAfterDays to 0 or a positive integer. | `packages/framework/src/engine/boot-validator/screens-lists-rules.ts` |
|
|
690
|
+
| <a id="list-date-only-after-days-wrong-type"></a>`list/date-only-after-days-wrong-type` | dateOnlyAfterDays sits on a timestamp, locatedTimestamp or date column or a relativeTime column. | Remove dateOnlyAfterDays from the column or point it at a timestamp, locatedTimestamp or date field. | `packages/framework/src/engine/boot-validator/screens-lists-rules.ts` |
|
|
679
691
|
| <a id="list-empty-state-action-params"></a>`list/empty-state-action-params` | Empty-state actions set no params, because an empty list has no row to read them from. | Remove the params. | `packages/framework/src/engine/boot-validator/screens-lists-rules.ts` |
|
|
680
692
|
| <a id="list-enum-option-tones-invalid"></a>`list/enum-option-tones-invalid` | enumOption column tones are known select option tones. | Use only the allowed tones (SELECT_OPTION_TONES). | `packages/framework/src/engine/boot-validator/screens-lists-rules.ts` |
|
|
681
693
|
| <a id="list-facet-duplicate"></a>`list/facet-duplicate` | Each facet field is declared once. | Declare each facet field once. | `packages/framework/src/engine/boot-validator/screens-lists-rules.ts` |
|
|
@@ -727,6 +739,14 @@
|
|
|
727
739
|
| Rule | Summary | Fix | Source |
|
|
728
740
|
| --- | --- | --- | --- |
|
|
729
741
|
| <a id="list-bulk-entry-not-object"></a>`list-bulk/entry-not-object` | Every bulkActions entry is an object with id and rowAction. | Write each entry as { id, rowAction }. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
742
|
+
| <a id="list-bulk-form-ids-field-missing"></a>`list-bulk/form-ids-field-missing` | A bulk form action names the form field that receives the selected ids. | Set idsField to a field of the target form. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
743
|
+
| <a id="list-bulk-form-ids-field-not-list"></a>`list-bulk/form-ids-field-not-list` | A bulk form action's idsField is a multiSelect field with display: "count". | Declare the field as { type: "multiSelect", options: [], display: "count" } on the target form. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
744
|
+
| <a id="list-bulk-form-ids-field-not-rendered"></a>`list-bulk/form-ids-field-not-rendered` | A bulk form action's idsField is shown by the target form's layout and not sensitive. | Add the field to the form layout (visible: false hides it but keeps the value) and drop sensitive. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
745
|
+
| <a id="list-bulk-form-ids-field-unknown"></a>`list-bulk/form-ids-field-unknown` | A bulk form action's idsField is a field of the target form. | Declare the field on the target form or point idsField at a declared one. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
746
|
+
| <a id="list-bulk-form-label-missing"></a>`list-bulk/form-label-missing` | A bulk form action has a label (i18n key) for its button. | Set label to an i18n key. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
747
|
+
| <a id="list-bulk-form-screen-missing"></a>`list-bulk/form-screen-missing` | A bulk form action names the screen it opens in screen. | Set screen to the id of an actionForm screen. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
748
|
+
| <a id="list-bulk-form-screen-not-action-form"></a>`list-bulk/form-screen-not-action-form` | A bulk form action opens an actionForm screen. | Point screen at an actionForm screen. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
749
|
+
| <a id="list-bulk-form-screen-unresolved"></a>`list-bulk/form-screen-unresolved` | A bulk form action's screen resolves to a registered screen. | Use the id of a screen in this feature or a fully-qualified <feature>:screen:<id>. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
730
750
|
| <a id="list-bulk-id-duplicate"></a>`list-bulk/id-duplicate` | Bulk action ids are unique within a list. | Rename or remove the duplicate bulk action. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
731
751
|
| <a id="list-bulk-id-not-kebab"></a>`list-bulk/id-not-kebab` | A bulk action id is a kebab-case string. | Rename the id to kebab-case. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
732
752
|
| <a id="list-bulk-not-array"></a>`list-bulk/not-array` | bulkActions is a non-empty array. | Write bulkActions as [{ id: "archive", rowAction: "archive" }] or remove it. | `packages/framework/src/engine/boot-validator/list-bulk-actions-rules.ts` |
|
|
@@ -88,7 +88,7 @@ handler marked `agent: { risk: "high" }`. A job or an event consumer has no hand
|
|
|
88
88
|
`irreversibleWithoutEntryHandler` on `r.job` or `r.multiStreamProjection`, or the gate refuses with
|
|
89
89
|
`irreversible_operation_without_entry_handler`. The value names why no entry handler exists:
|
|
90
90
|
`rebuildable-derived-data` (the data is derived and a rebuild recreates it), `high-risk-or-cron-pipeline`
|
|
91
|
-
(a
|
|
91
|
+
(a manually started or cron pipeline that is high-risk by design, like `purge-archived-comments`) or
|
|
92
92
|
`per-dispatch-record-key` (the key belongs to one dispatch record). Hooks and routes never inherit the
|
|
93
93
|
declaration; they dispatch a `risk: "high"` handler instead.
|
|
94
94
|
|
|
@@ -365,7 +365,7 @@ export const hrFeature = defineFeature("hr", (r) => {
|
|
|
365
365
|
r.job(
|
|
366
366
|
"purge-archived-comments",
|
|
367
367
|
{
|
|
368
|
-
trigger: {
|
|
368
|
+
trigger: { manual: true },
|
|
369
369
|
runIn: "worker",
|
|
370
370
|
irreversibleWithoutEntryHandler: "high-risk-or-cron-pipeline",
|
|
371
371
|
},
|
|
@@ -29,7 +29,13 @@ the `table` block renders and behaves as before.
|
|
|
29
29
|
file; `maxRows` lowers the default limit of 10000 rows.
|
|
30
30
|
Reference columns export their label and timestamps use the browser time zone.
|
|
31
31
|
- `bulkActions`: row checkboxes and a selection bar. "Delete" runs the delete
|
|
32
|
-
row action once per selected row
|
|
32
|
+
row action once per selected row (done tasks are skipped); "Set status" opens
|
|
33
|
+
an actionForm once for the whole selection. Its `taskIds` field is a
|
|
34
|
+
`multiSelect` with `display: "count"`, and the `task:set-status` handler
|
|
35
|
+
updates every id in one write, bounded by `.max(MAX_BULK_SELECTION)` and
|
|
36
|
+
reading each id through the tenant-scoped executor. The form has a `preview`:
|
|
37
|
+
the `task:set-status-preview` query returns the affected tasks with old and
|
|
38
|
+
new status from the same plan function the handler applies.
|
|
33
39
|
- `table.grouping`: the server groups the list by status; each header shows the
|
|
34
40
|
group's count and estimate sum, "done" starts collapsed and the view menu
|
|
35
41
|
offers grouping by priority or none.
|
|
@@ -62,9 +68,9 @@ bun test
|
|
|
62
68
|
The test boots the feature through the boot validator and checks that a
|
|
63
69
|
misspelled key, a hidden column without the picker, an unknown density, a pinned column
|
|
64
70
|
without `pinning`, a width without `resizing` and a bulk action on a navigate
|
|
65
|
-
row action are rejected.
|
|
71
|
+
row action, a form bulk action whose `idsField` is no count list and a preview over an unknown query or field are rejected.
|
|
66
72
|
`workload.integration.test.ts` runs the hand-written query over HTTP and checks
|
|
67
|
-
the grouped sums and the filtered total.
|
|
73
|
+
the grouped sums and the filtered total, the preview query, and the handler's unknown-id and over-cap rejections.
|
|
68
74
|
|
|
69
75
|
## Source files
|
|
70
76
|
|
|
@@ -79,6 +85,7 @@ import {
|
|
|
79
85
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
80
86
|
import type { ListTableOptions } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
81
87
|
import { withBootValidatorFixture } from "@cosmicdrift/kumiko-testing/helpers";
|
|
88
|
+
import * as z from "zod";
|
|
82
89
|
import { createTaskBoardFeature, openAccess, taskEntity } from "../feature";
|
|
83
90
|
|
|
84
91
|
// The boot validator is the net for blocks the type system never sees (JS, generated features).
|
|
@@ -109,15 +116,79 @@ describe("list-table-options recipe", () => {
|
|
|
109
116
|
});
|
|
110
117
|
});
|
|
111
118
|
|
|
112
|
-
test("the bulk
|
|
119
|
+
test("the bulk actions resolve to the delete row action and the status form", () => {
|
|
113
120
|
const screen = createRegistry([createTaskBoardFeature()]).getScreen(
|
|
114
121
|
"task-board:screen:task-list",
|
|
115
122
|
);
|
|
116
123
|
expect(screen?.type === "entityList" ? screen.bulkActions : undefined).toEqual([
|
|
117
124
|
{ id: "delete", rowAction: "delete" },
|
|
125
|
+
{
|
|
126
|
+
id: "set-status",
|
|
127
|
+
label: "Set status",
|
|
128
|
+
icon: "pencil",
|
|
129
|
+
screen: "task-set-status",
|
|
130
|
+
idsField: "taskIds",
|
|
131
|
+
},
|
|
118
132
|
]);
|
|
119
133
|
});
|
|
120
134
|
|
|
135
|
+
test("the form bulk action boots and a missing count field is rejected", () => {
|
|
136
|
+
expect(() => validateBoot([createTaskBoardFeature()])).not.toThrow();
|
|
137
|
+
const feature = defineFeature("bulk-form-bad", (r) => {
|
|
138
|
+
r.crud("task", taskEntity, { write: openAccess, read: openAccess });
|
|
139
|
+
r.screen({
|
|
140
|
+
id: "task-list",
|
|
141
|
+
type: "entityList",
|
|
142
|
+
entity: "task",
|
|
143
|
+
columns: ["title"],
|
|
144
|
+
bulkActions: [{ id: "set", label: "Set", screen: "set-form", idsField: "taskIds" }],
|
|
145
|
+
access: openAccess.access,
|
|
146
|
+
});
|
|
147
|
+
r.screen({
|
|
148
|
+
id: "set-form",
|
|
149
|
+
type: "actionForm",
|
|
150
|
+
dormant: true,
|
|
151
|
+
handler: "bulk-form-bad:write:task:create",
|
|
152
|
+
fields: { taskIds: { type: "text" } },
|
|
153
|
+
layout: { sections: [{ fields: ["taskIds"] }] },
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
expect(() => validateBoot([feature])).toThrow(/idsField "taskIds", which is not a list field/);
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
test("a preview over an unknown query or an undeclared field is rejected", () => {
|
|
160
|
+
const withPreview = (preview: object) =>
|
|
161
|
+
defineFeature("preview-bad", (r) => {
|
|
162
|
+
r.queryHandler({
|
|
163
|
+
name: "task:p",
|
|
164
|
+
schema: z.object({ status: z.string().optional() }),
|
|
165
|
+
handler: async () => ({ count: 0 }),
|
|
166
|
+
access: openAccess.access,
|
|
167
|
+
});
|
|
168
|
+
r.writeHandler({
|
|
169
|
+
name: "task:noop",
|
|
170
|
+
schema: z.object({ status: z.string() }),
|
|
171
|
+
handler: async () => ({ isSuccess: true as const, data: {} }),
|
|
172
|
+
access: openAccess.access,
|
|
173
|
+
});
|
|
174
|
+
r.screen({
|
|
175
|
+
id: "noop-form",
|
|
176
|
+
type: "actionForm",
|
|
177
|
+
dormant: true,
|
|
178
|
+
handler: "preview-bad:write:task:noop",
|
|
179
|
+
fields: { status: { type: "text" } },
|
|
180
|
+
layout: { sections: [{ fields: ["status"] }] },
|
|
181
|
+
preview: { facts: [{ field: "count", label: "Count" }], ...preview },
|
|
182
|
+
} as never);
|
|
183
|
+
});
|
|
184
|
+
expect(() => validateBoot([withPreview({ query: "preview-bad:query:task:missing" })])).toThrow(
|
|
185
|
+
/Screen "noop-form" \(actionForm\) preview/,
|
|
186
|
+
);
|
|
187
|
+
expect(() =>
|
|
188
|
+
validateBoot([withPreview({ query: "preview-bad:query:task:p", fields: ["owner"] })]),
|
|
189
|
+
).toThrow(/sends field "owner"/);
|
|
190
|
+
});
|
|
191
|
+
|
|
121
192
|
test("a bulk action that points at a navigate row action is rejected", () => {
|
|
122
193
|
const feature = defineFeature("bulk-on-navigate", (r) => {
|
|
123
194
|
r.crud("task", taskEntity, { write: openAccess, read: openAccess });
|
|
@@ -193,6 +264,7 @@ describe("list-table-options recipe", () => {
|
|
|
193
264
|
```ts
|
|
194
265
|
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
|
|
195
266
|
import { createTestUser, testTenantId } from "@cosmicdrift/kumiko-framework/seeding";
|
|
267
|
+
import { MAX_BULK_SELECTION } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
196
268
|
import { setupTestStack, type TestStack } from "@cosmicdrift/kumiko-testing/stack";
|
|
197
269
|
import { createTaskBoardFeature } from "../feature";
|
|
198
270
|
|
|
@@ -258,6 +330,82 @@ describe("hand-written list query with aggregate", () => {
|
|
|
258
330
|
]);
|
|
259
331
|
});
|
|
260
332
|
});
|
|
333
|
+
|
|
334
|
+
describe("form bulk action handler", () => {
|
|
335
|
+
test("one write sets the status of every selected task", async () => {
|
|
336
|
+
const created = await Promise.all(
|
|
337
|
+
["Bulk A", "Bulk B"].map((title) =>
|
|
338
|
+
stack.http.writeOk<{ data: { id: string } }>(
|
|
339
|
+
"task-board:write:task:create",
|
|
340
|
+
{ title },
|
|
341
|
+
user,
|
|
342
|
+
),
|
|
343
|
+
),
|
|
344
|
+
);
|
|
345
|
+
const taskIds = created.map((task) => task.data.id);
|
|
346
|
+
await stack.http.writeOk(
|
|
347
|
+
"task-board:write:task:set-status",
|
|
348
|
+
{ taskIds, status: "blocked", note: "waiting" },
|
|
349
|
+
user,
|
|
350
|
+
);
|
|
351
|
+
const list = await stack.http.queryOk<{
|
|
352
|
+
rows: { title: string; status: string; note: string }[];
|
|
353
|
+
}>("task-board:query:task:list", { sort: "title" }, user);
|
|
354
|
+
expect(
|
|
355
|
+
list.rows.filter((row) => row.title.startsWith("Bulk")).map((row) => [row.status, row.note]),
|
|
356
|
+
).toEqual([
|
|
357
|
+
["blocked", "waiting"],
|
|
358
|
+
["blocked", "waiting"],
|
|
359
|
+
]);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
test("the preview query shows the same plan the handler applies", async () => {
|
|
363
|
+
const created = await Promise.all(
|
|
364
|
+
["Plan A", "Plan B"].map((title) =>
|
|
365
|
+
stack.http.writeOk<{ data: { id: string } }>(
|
|
366
|
+
"task-board:write:task:create",
|
|
367
|
+
{ title, status: title === "Plan B" ? "blocked" : "open" },
|
|
368
|
+
user,
|
|
369
|
+
),
|
|
370
|
+
),
|
|
371
|
+
);
|
|
372
|
+
const taskIds = created.map((task) => task.data.id);
|
|
373
|
+
const preview = await stack.http.queryOk<{
|
|
374
|
+
count: number;
|
|
375
|
+
tasks: { title: string; before: string; after: string }[];
|
|
376
|
+
}>("task-board:query:task:set-status-preview", { taskIds, status: "blocked" }, user);
|
|
377
|
+
expect(preview).toEqual({
|
|
378
|
+
count: 1,
|
|
379
|
+
tasks: [
|
|
380
|
+
{ title: "Plan A", before: "open", after: "blocked" },
|
|
381
|
+
{ title: "Plan B", before: "blocked", after: "blocked" },
|
|
382
|
+
],
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
test("an unknown id fails the whole write and a list above the cap is rejected", async () => {
|
|
387
|
+
const unknown = await stack.http.write(
|
|
388
|
+
"task-board:write:task:set-status",
|
|
389
|
+
{ taskIds: ["11111111-1111-4111-8111-111111111111"], status: "done" },
|
|
390
|
+
user,
|
|
391
|
+
);
|
|
392
|
+
const unknownBody = (await unknown.json()) as { isSuccess: boolean; error?: { code: string } };
|
|
393
|
+
expect(unknownBody.isSuccess).toBe(false);
|
|
394
|
+
expect(unknownBody.error?.code).toBe("not_found");
|
|
395
|
+
|
|
396
|
+
const tooMany = await stack.http.write(
|
|
397
|
+
"task-board:write:task:set-status",
|
|
398
|
+
{
|
|
399
|
+
taskIds: Array.from({ length: MAX_BULK_SELECTION + 1 }, () => crypto.randomUUID()),
|
|
400
|
+
status: "done",
|
|
401
|
+
},
|
|
402
|
+
user,
|
|
403
|
+
);
|
|
404
|
+
const tooManyBody = (await tooMany.json()) as { isSuccess: boolean; error?: { code: string } };
|
|
405
|
+
expect(tooManyBody.isSuccess).toBe(false);
|
|
406
|
+
expect(tooManyBody.error?.code).toBe("validation_error");
|
|
407
|
+
});
|
|
408
|
+
});
|
|
261
409
|
```
|
|
262
410
|
|
|
263
411
|
### src/feature.ts
|
|
@@ -280,7 +428,8 @@ import {
|
|
|
280
428
|
entityListSchema,
|
|
281
429
|
type FeatureDefinition,
|
|
282
430
|
} from "@cosmicdrift/kumiko-framework/engine";
|
|
283
|
-
import
|
|
431
|
+
import { failNotFound, NotFoundError } from "@cosmicdrift/kumiko-framework/errors";
|
|
432
|
+
import { type ListTableOptions, MAX_BULK_SELECTION } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
284
433
|
import { z } from "zod";
|
|
285
434
|
|
|
286
435
|
export const taskEntity = createEntity({
|
|
@@ -325,6 +474,39 @@ export const openAccess = {
|
|
|
325
474
|
},
|
|
326
475
|
} as const;
|
|
327
476
|
|
|
477
|
+
const setStatusInput = z.object({
|
|
478
|
+
taskIds: z.array(z.uuid()).min(1).max(MAX_BULK_SELECTION),
|
|
479
|
+
status: z.enum(taskEntity.fields.status.options),
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
type StatusPlanRow = {
|
|
483
|
+
readonly id: string;
|
|
484
|
+
readonly version: number;
|
|
485
|
+
readonly title: string;
|
|
486
|
+
readonly before: string;
|
|
487
|
+
readonly after: string;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
// The one rule behind the status form: the write handler applies it and the preview query shows it.
|
|
491
|
+
async function planStatusChanges(
|
|
492
|
+
taskIds: readonly string[],
|
|
493
|
+
status: string,
|
|
494
|
+
loadTask: (id: string) => Promise<Readonly<Record<string, unknown>> | null | undefined>,
|
|
495
|
+
): Promise<{ readonly rows: readonly StatusPlanRow[] } | { readonly missingId: string }> {
|
|
496
|
+
const rows: StatusPlanRow[] = [];
|
|
497
|
+
for (const id of taskIds) {
|
|
498
|
+
const task = await loadTask(id);
|
|
499
|
+
if (!task) return { missingId: id };
|
|
500
|
+
rows.push({
|
|
501
|
+
id,
|
|
502
|
+
version: Number(task["version"]),
|
|
503
|
+
title: String(task["title"]),
|
|
504
|
+
before: String(task["status"]),
|
|
505
|
+
after: status,
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
return { rows };
|
|
509
|
+
}
|
|
328
510
|
// Overridable so a test can feed the boot validator a block that must be rejected.
|
|
329
511
|
export function createTaskBoardFeature(
|
|
330
512
|
taskTable: ListTableOptions = {
|
|
@@ -408,8 +590,17 @@ export function createTaskBoardFeature(
|
|
|
408
590
|
visible: { field: "status", ne: "done" },
|
|
409
591
|
},
|
|
410
592
|
],
|
|
411
|
-
// Row checkboxes and a selection bar;
|
|
412
|
-
bulkActions: [
|
|
593
|
+
// Row checkboxes and a selection bar; delete writes once per row, set-status once for all.
|
|
594
|
+
bulkActions: [
|
|
595
|
+
{ id: "delete", rowAction: "delete" },
|
|
596
|
+
{
|
|
597
|
+
id: "set-status",
|
|
598
|
+
label: "Set status",
|
|
599
|
+
icon: "pencil",
|
|
600
|
+
screen: "task-set-status",
|
|
601
|
+
idsField: "taskIds",
|
|
602
|
+
},
|
|
603
|
+
],
|
|
413
604
|
access: openAccess.access,
|
|
414
605
|
});
|
|
415
606
|
|
|
@@ -505,6 +696,83 @@ export function createTaskBoardFeature(
|
|
|
505
696
|
},
|
|
506
697
|
});
|
|
507
698
|
|
|
699
|
+
// One write for the whole selection: the bulk action below opens this form and `taskIds`
|
|
700
|
+
// arrives as a string array. The client cap is no protection, so the schema bounds the list
|
|
701
|
+
// and every id is read through the tenant-scoped executor before anything is written.
|
|
702
|
+
r.writeHandler({
|
|
703
|
+
name: "task:set-status",
|
|
704
|
+
schema: setStatusInput.extend({ note: z.string().optional() }),
|
|
705
|
+
access: openAccess.access,
|
|
706
|
+
handler: async (event, ctx) => {
|
|
707
|
+
const { taskIds, status, note } = event.payload;
|
|
708
|
+
const plan = await planStatusChanges(taskIds, status, (id) =>
|
|
709
|
+
taskExecutor.detail({ id }, event.user, ctx.db),
|
|
710
|
+
);
|
|
711
|
+
if ("missingId" in plan) return failNotFound("task", plan.missingId);
|
|
712
|
+
const changed = plan.rows.filter((row) => row.before !== row.after);
|
|
713
|
+
for (const row of changed) {
|
|
714
|
+
const result = await taskExecutor.update(
|
|
715
|
+
{ id: row.id, version: row.version, changes: { status, note } },
|
|
716
|
+
event.user,
|
|
717
|
+
ctx.db,
|
|
718
|
+
);
|
|
719
|
+
if (!result.isSuccess) return result;
|
|
720
|
+
}
|
|
721
|
+
return { isSuccess: true as const, data: { count: changed.length } };
|
|
722
|
+
},
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
// The preview runs the same plan the write handler runs, so the two cannot drift apart.
|
|
726
|
+
r.queryHandler({
|
|
727
|
+
name: "task:set-status-preview",
|
|
728
|
+
schema: setStatusInput,
|
|
729
|
+
access: openAccess.access,
|
|
730
|
+
handler: async (query, ctx) => {
|
|
731
|
+
const { taskIds, status } = query.payload;
|
|
732
|
+
const plan = await planStatusChanges(taskIds, status, (id) =>
|
|
733
|
+
taskExecutor.detail({ id }, query.user, ctx.db),
|
|
734
|
+
);
|
|
735
|
+
if ("missingId" in plan) throw new NotFoundError("task");
|
|
736
|
+
return {
|
|
737
|
+
count: plan.rows.filter((row) => row.before !== row.after).length,
|
|
738
|
+
tasks: plan.rows.map(({ title, before, after }) => ({ title, before, after })),
|
|
739
|
+
};
|
|
740
|
+
},
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
r.screen({
|
|
744
|
+
id: "task-set-status",
|
|
745
|
+
type: "actionForm",
|
|
746
|
+
dormant: true,
|
|
747
|
+
handler: "task-board:write:task:set-status",
|
|
748
|
+
listScreenId: "task-list",
|
|
749
|
+
redirect: "task-list",
|
|
750
|
+
fields: {
|
|
751
|
+
taskIds: { type: "multiSelect", options: [], display: "count" },
|
|
752
|
+
status: createSelectField({
|
|
753
|
+
options: ["open", "inProgress", "blocked", "done"] as const,
|
|
754
|
+
required: true,
|
|
755
|
+
}),
|
|
756
|
+
note: createTextField({ personal: false, reason: "is_business_data" }),
|
|
757
|
+
},
|
|
758
|
+
layout: { sections: [{ fields: ["taskIds", "status", "note"] }] },
|
|
759
|
+
// Which tasks change and from what to what, shown before the user submits.
|
|
760
|
+
preview: {
|
|
761
|
+
query: "task-board:query:task:set-status-preview",
|
|
762
|
+
fields: ["taskIds", "status"],
|
|
763
|
+
title: "Preview",
|
|
764
|
+
facts: [{ field: "count", label: "Tasks that change" }],
|
|
765
|
+
list: {
|
|
766
|
+
field: "tasks",
|
|
767
|
+
columns: [
|
|
768
|
+
{ field: "title", label: "Task" },
|
|
769
|
+
{ field: "before", label: "Now" },
|
|
770
|
+
{ field: "after", label: "New" },
|
|
771
|
+
],
|
|
772
|
+
},
|
|
773
|
+
},
|
|
774
|
+
});
|
|
775
|
+
|
|
508
776
|
r.nav({ id: "tasks", label: "task-board:nav.tasks", icon: "list", order: 10 });
|
|
509
777
|
r.nav({
|
|
510
778
|
id: "task-list",
|