Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .changeset/36496-selection-bulk-actions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@objectstack/spec': minor
'@objectstack/lint': minor
'@objectstack/platform-objects': patch
'@object-ui/types': minor
'@object-ui/plugin-grid': minor
'@object-ui/plugin-list': minor
'@object-ui/plugin-view': patch
'@object-ui/i18n': patch
---

feat(spec)!: actions that act on many records are placed at `selection`; the object's `actionLayout.selection` orders the selection bar, and a list view's `bulkActions` is retired

Clause-②: yes (narrowing)
Metadata-protocol: narrowed

<!-- adr-0087: registered view-bulk-actions-to-action-selection -->

**BREAKING** for metadata that lists bulk actions on a list view:

- **`view.list.bulkActions` / `object.listViews.*.bulkActions` is refused at parse** (and authoring it is a `tsc` error). FROM `list: { bulkActions: ['mark_done', 'recalc'] }` TO `locations: [..., 'selection']` on the actions `mark_done` and `recalc`; when the order the lists gave is not the default (by `order`, then declaration order), also `actionLayout: { selection: { pinned: [...], more: [...] } }` on the object. Fix: run `os migrate meta --from 18` to list the edits; `--write` applies the ones it can prove (strip the key, add `'selection'`, write the arm), and hands back as a TODO an object whose lists name `delete`, disagree on order, or need an arm on an object the stack does not declare.
- **Multi-select now shows the same actions on every grid view of an object**: every action placed at `selection`, in the arm's order, with a view's own `bulkActionDefs` first (an authored def claims its name). A view that listed none of them now draws them too. The built-in Delete keeps its place wherever the object allows a delete; `actionLayout.selection.pinned: []` moves it, and every other action, into the bar's 「More」.
- **`@object-ui/types` `ListViewSchema.bulkActions` is `never`**, and the `list-view` block's `bulkActions` input is removed. The `object-grid` block's own `bulkActions` / `batchActions` props are unchanged.
- **`action-dispatch-contract-mismatch`** now judges an action placed at `selection` (one dispatch per selected record) against its declared `execution`; an action placed at `selection` that declares `execution: 'aggregate'` is refused, with the fix "move it from `selection` to an aggregate `bulkActionDefs` entry".

The retirement kit: the tombstone's prescription (parse and `tsc`), the protocol-19 conversion `view-bulk-actions-to-action-selection`, the `RETIRED_KEYS_BY_MAJOR` entries `ui/ListView:bulkActions` and `ui/ObjectListView:bulkActions`, and the semantic entry `view-bulk-actions-declared-on-the-action`. A stored `view` row arrives without its object's actions, so the conversion leaves it as stored and reports a TODO; sources and package artifacts that carry the actions beside the views are rewritten.
4 changes: 2 additions & 2 deletions content/docs/deployment/validating-metadata.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ no declared page, **fails** validation; a `url` path whose
The same gate covers the reference sites that are plain strings in the schema:
an action param's record-picker target, a dashboard filter's options source, a
navigation capability gate, and every surface that binds an action **by name**
(`bulkActions` / `rowActions`, a page's `record:quick_actions`, a nav action item).
(`rowActions`, an aggregate `bulkActionDefs` entry, a page's `record:quick_actions`, a nav action item).

```ts
// ✗ the platform user object is `sys_user` — `user` resolves to nothing → error
{ name: 'owner', type: 'lookup', reference: 'user' }

// ✗ no action named `mass_update` is defined anywhere → error
defineView({ /* … */ bulkActions: ['mass_update', 'mass_delete'] })
defineView({ /* … */ list: { rowActions: ['mass_update', 'mass_delete'] } })

// ⚠ platform-shaped, but no known package registers it → warning
{ id: 'nav_approvals', type: 'object', objectName: 'sys_approval_process',
Expand Down
14 changes: 8 additions & 6 deletions content/docs/references/data/object.mdx

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions content/docs/references/ui/action.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const result = ActionSchema.parse(data);
| **description** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object } \| string \| Record<string, string>` | optional | Explanatory line shown under the title in the action's param dialog. Carries the confirm question for an action that collects params (one dialog, not two). Not the LLM-facing `ai.description`. It is a `template` slot (ADR-0032): a bare string is shorthand for `{ dialect: 'template', source }`, and text with no hole is shown as written. Holes are `{{ path }}` or `{{ path \| formatter[:arg] }}` over `record`, the record the action runs against (the clicked row on a list, else the page's record); the values the dialog collects are not bound, since the line shows before they exist. Formatters come from the template engine's whitelist (`TEMPLATE_FORMATTERS`, `@objectstack/formula`); a hole holds no logic (no CEL, no arithmetic). Example: 'Choose the new role for `{{ record.name }}`.'. A hole over any other root, a `${…}` or single-brace `{x}` token (each named with its `{{ }}` spelling), a hole holding logic or an unknown formatter, and a blank sentence are named and refused at `objectstack validate`, `compile` and the publish gate; the text still parses, so a stored one loads until its next save. An inline locale map (`{ en, "zh-CN" }`) is accepted too, each value such a sentence. |
| **objectName** | `string` | optional | Target object this action belongs to. When set, the action is auto-merged into the object's actions array by defineStack(). |
| **icon** | `string` | optional | Icon name |
| **locations** | `Enum<'list' \| 'record' \| 'record_page' \| 'record_row' \| 'record_related' \| 'record_section'>[]` | optional | Locations where this action is visible. `record_section` is drawn only by an authored record page block that renders it; the standard record page (on a phone, in the side preview, and for an object with no authored page) does not draw it, so an action that must reach every surface adds `record_page` as well, with `component: 'action:menu'` to sit in the record page's ⋯ menu rather than be a header button. `list` acts on no record (the list page toolbar); `record` acts on one record, on the record page and on each list row; `record_page` and `record_row` are one of those two only. |
| **locations** | `Enum<'list' \| 'record' \| 'record_page' \| 'record_row' \| 'record_related' \| 'record_section' \| 'selection'>[]` | optional | Locations where this action is visible. `record_section` is drawn only by an authored record page block that renders it; the standard record page (on a phone, in the side preview, and for an object with no authored page) does not draw it, so an action that must reach every surface adds `record_page` as well, with `component: 'action:menu'` to sit in the record page's ⋯ menu rather than be a header button. `list` acts on no record (the list page toolbar); `record` acts on one record, on the record page and on each list row; `record_page` and `record_row` are one of those two only. `selection` acts on many records: the selection bar a grid shows once two or more rows are selected, on every grid view of the object, run once per selected record (the object's `actionLayout.selection` orders that bar). |
| **component** | `Enum<'action:button' \| 'action:icon' \| 'action:menu' \| 'action:group'>` | optional | Visual component override |
| **type** | `Enum<'script' \| 'url' \| 'modal' \| 'flow' \| 'api' \| 'form'>` | optional (default: `"script"`) | Action functionality type — the dispatch route. The declarative single-record field write is not a type: it is `operation: 'update'` + `patch` on the default `script` route. |
| **target** | `string` | optional | URL, Script Name, Flow ID, or API Endpoint. Supports $`{param.X}` and $`{ctx.X}` interpolation. For type:'url': an http:// or https:// URL, a mailto: address, or an in-app path starting with / or ./ (a console route; a record is /apps/APP/OBJECT/record/ID, APP being the app's route segment — see onSuccess.navigate) — every other scheme and a protocol-relative //host are refused. |
Expand All @@ -58,7 +58,7 @@ const result = ActionSchema.parse(data);
| **texts** | `Record<string, { message: string; params?: string[] }>` | optional | Texts the action's js body writes into records, keyed by the snake_case key it asks for with ctx.text(KEY, params): `{ message, params? }`. ctx.text answers the sentence in the organization's language (the Localization setting when somebody set it, else the app's i18n.defaultLocale), translated through objects.`<object>`._actions.`<action>`.texts.`<key>`.message (globalActions.`<action>`.texts.`<key>`.message for an object-less action) with the declared message as the fallback, its holes filled from params. A key not declared here is refused — at save when the body asks for it literally, otherwise at run time. Only a type: 'script' action with a js body declares one |
| **operation** | `Enum<'update'>` | optional | The declarative single-record field write, mirroring a list view's `bulkActionDefs`: `'update'` applies `patch` (merged under the collected `params`) to the current record on the data plane AS THE CALLER — never system-elevated — so the caller's permissions, the object's hooks and its validations fire as for a user edit. `type` stays at its default `'script'` (the platform action route the write is performed on); `target`/`body`/`method`/`bodyExtra` are refused beside it. `'delete'` and `'custom'` have no row-level form. |
| **patch** | `Record<string, any>` | optional | For `operation: 'update'` — static field values written to the current record, merged UNDER the user-supplied `params` so a fixed value can be declared without exposing it in the dialog. Written on the data plane as the caller: object permissions, hooks and validations fire as for a user edit. Refused on an action without `operation: 'update'` (it would be silently dropped). |
| **execution** | `Enum<'perRecord' \| 'aggregate'>` | optional | The bulk dispatch contract this action's BODY is written for, in `bulkActionDefs`' own vocabulary: 'perRecord' = one dispatch per selected row carrying that row's `recordId` (the view's `bulkActions: ['<name>']` bare-string form); 'aggregate' = ONE dispatch for the whole selection carrying every id in `params._selectedIds` (a `bulkActionDefs` entry with `execution: 'aggregate'`). Optional with NO default — omit it only when the body genuinely serves both. A list view wiring a declared action under the other contract is refused by `@objectstack/lint` (`action-dispatch-contract-mismatch`). |
| **execution** | `Enum<'perRecord' \| 'aggregate'>` | optional | The bulk dispatch contract this action's BODY is written for, in `bulkActionDefs`' own vocabulary: 'perRecord' = one dispatch per selected row carrying that row's `recordId` (the action placed at `selection`); 'aggregate' = ONE dispatch for the whole selection carrying every id in `params._selectedIds` (a `bulkActionDefs` entry with `execution: 'aggregate'`). Optional with NO default — omit it only when the body genuinely serves both. An action placed at `selection` that declares 'aggregate', or a list view wiring a declared action under the other contract, is refused by `@objectstack/lint` (`action-dispatch-contract-mismatch`). |
| **params** | `{ name?: string; field?: string; objectOverride?: string; label?: string \| Record<string, string>; … }[]` | optional | Input parameters required from user — an ActionParam[] DEFINITION array, never a payload map (a static request body goes in `bodyExtra`). A param name (its `name`, or the `field` a field-backed param reads) may repeat only for per-gate variants of ONE input (declarations that differ in `visible` / `requiresFeature`, e.g. one optional and one required); the params check treats the name as `required` only when EVERY declaration of it requires it, and judges its value by the FIRST declaration's shape (`type`, `multiple`, `options`), so keep that shape identical across them. |
| **submitText** | `string \| Record<string, string>` | optional | Label of the submit button in the action's param dialog, the verb the button performs (e.g. "Send", "Log Call"), in place of the default "Confirm" — the default-language string, or an inline locale map; translated at `objects.OBJECT._actions.ACTION.submitText` (`globalActions.ACTION.submitText` for an object-less action). Only on an action with a non-empty `params`: without one no param dialog opens, so it is refused. Not `confirmText`, which is the message of a param-less action's confirm dialog. A blank label is refused. |
| **cancelText** | `string \| Record<string, string>` | optional | Label of the dismiss button on the dialog the action opens before it runs — the confirm dialog of a param-less action that declares `confirmText`, or the param dialog of an action with a non-empty `params` — in place of the default "Cancel". Name what dismissing keeps where the action's own verb is "Cancel …" or "Close …" (e.g. "Keep invitation" beside "Cancel Invitation"). The default-language string, or an inline locale map; translated at `objects.OBJECT._actions.ACTION.cancelText` (`globalActions.ACTION.cancelText` for an object-less action). Only on an action that opens one of those dialogs: with neither `confirmText` nor a non-empty `params` no dialog opens, so it is refused. The dismiss twin of `submitText`, as on `object-form`. A blank label is refused. |
Expand Down Expand Up @@ -266,6 +266,7 @@ L2 sandboxed JS body — runs inside an isolated VM with declared capabilities
* `record_row`
* `record_related`
* `record_section`
* `selection`


---
Expand Down
Loading
Loading