Skip to content

Commit 227ae36

Browse files
feat(spec, runtime, lint): an action body refuses in the caller's language through a declared refusal catalogue (#34719)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBFyg5B2muWbKZjA9phXVWse)_ Fixes #34273 Clause-②: yes (widening) — an action may now declare `refusals` (`ActionRefusalSchema`); translation bundles accept `objects.<object>._actions.<action>.refusals.<CODE>.message` and `globalActions.<action>.refusals.<CODE>.message` (with `….reasons.<REASON>.message`); `@objectstack/spec` exports `ActionRefusalSchema` and the `ActionRefusal` type (`ui`), `actionRefusalMessageKey` (`system`), and `ACTION_REFUSAL_MESSAGE_HOLE_REFUSED`, `actionRefusalsWithoutSandboxedBody`, `undeclaredActionRefusalCodeAtSave`, `undeclaredActionRefusalReasonAtSave`, `undeclaredActionRefusalAtRun` and `undeclaredActionRefusalReasonAtRun` (`data`); `@objectstack/runtime` adds no export: the action body runner answers through `resolveActionRefusal` internally. Nothing that was accepted before is refused Metadata-protocol: added Skills-docs: follow-up #34824 — `skills/objectstack-i18n/SKILL.md` lists the hook refusal key only and `skills/objectstack-ui/rules/actions.md` teaches no action `refusals`; `content/docs/ui/actions.mdx` and `content/docs/ui/translations.mdx` gain the section and the key row here ## 维护者速读 - 改了什么:动作(`type: 'script'` 的 `js` 体)可以像钩子一样声明拒绝语目录 `refusals`,体里只抛代码(`throw { code: 'NOT_DRAFT' }`),服务器按调用者语言回出声明的句子(放在 `userMessage` 上)和声明的状态码;译文和动作的其他文案放一处:`objects.<对象>._actions.<动作>.refusals.<CODE>.message`,无对象的动作在 `globalActions.<动作>.refusals.…`。 - 为什么改:动作体里 `throw new Error('英文句子')` 给中文、日文用户看到的永远是作者写的那句;钩子早有拒绝语目录(#26170 / #33214),动作没有。 - 风险与回滚:纯新增,没写 `refusals` 的动作行为完全不变(有对照测试);钩子的拒绝语与 texts 的已发布 schema 一字不变(共享工厂按主体出词)。回滚即 revert。 - 先看:`packages/spec/src/data/declared-entry.zod.ts`(共享的声明条目工厂,钩子拒绝、动作拒绝、钩子 texts 三种条目都由它造,#34374 动作半直接加一行),然后 `packages/runtime/src/sandbox/hook-refusal-catalogue.ts` 的 `resolveActionRefusal`。 - 两分钟验证:`pnpm --filter @objectstack/runtime exec vitest run src/sandbox/action-refusal-catalogue.test.ts`,预期 16 条全过(含经真实 `/actions` 门回 409 + 中文 `userMessage`)。 - 需要你做的:无,席位落地;需契约复审(`Metadata-protocol: added`)。 ## What changes - **Spec — `ActionSchema.refusals`** (`packages/spec/src/ui/action.zod.ts`): the hook catalogue's twin, keyed by SCREAMING_SNAKE code: `{ message, status?, reasons?, params? }`. Save-time checks: a catalogue on an action that runs no `js` body of its own (another `type`, an `expression` body, no body) is refused at `refusals`; a code, or a reason under a code that declares `reasons`, that the body throws literally and the catalogue does not declare is refused at `body.source` (comments and strings masked, a computed code left to the run). `ActionRefusalSchema` is exported beside the action schema. - **Spec — one declared-entry factory** (`packages/spec/src/data/declared-entry.zod.ts`, new, not on a barrel): `declaredRefusalEntrySchema(subject)` builds `HookRefusalSchema` and `ActionRefusalSchema`; `declaredTextEntrySchema(subject)` builds `HookTextSchema` (#34374 PR1). One core (`message`, `params`, the plain-text / closed-scope hole rule, the duplicate-param check); the words per subject are table rows. Every hook sentence is byte-identical to before, so the published hook JSON Schemas and reference pages do not move. The action half of #34374 adds its `texts` row to the text table. - **Spec — sentences and keys** (`hook-refusal-codes.ts`, `i18n-resolver.ts`, `translation.zod.ts`): the save-time and run-time refusal sentences are one subject-parameterised core with the hook exports unchanged and action twins added; `actionRefusalMessageKey(objectName, action, code, reason?)`; the action translation node accepts `refusals` (alias `refusal`), one factory shared with `hooks.<hook>.refusals`. - **Runtime — `resolveActionRefusal`** (`hook-refusal-catalogue.ts`, `body-runner.ts`, `app-plugin.ts`, `app-artifact-handlers.ts`): the action body runner hands every body throw to it; one answer for a hook's and an action's catalogue (`resolveSandboxedRefusal`): a declared code is answered with the entry's sentence in the caller's `executionContext.locale` (negotiated as a hook's is), its holes filled through the same template renderer, its status and the code on the wire; any other deliberate throw is a fault naming the action and the code. The action's own object is read by the one owner-key ladder (`standaloneActionOwnerKey` / `isObjectLessActionKey`, `@objectstack/objectql`), so a bound action never reads `globalActions` and an object-less one never reads an object's group. Both default action-runner bindings now pass the `i18n` reader. - **Lint**: `objectstack validate` refuses an action refusal translation over a code or reason the action does not declare (`checkActionRefusals`, nearest code offered); `os i18n extract` scaffolds the keys (`pushActionRefusals`); the compile half of a sentence with `params` judges action catalogues too (`actionRefusalTemplateIssues`, on the collections the action copy pass reads) — logic, an unknown formatter, an empty hole and `currency` with no code are errors at `validate`, `compile` and the publish gate's `action` write. - **Docs**: `ui/actions.mdx` (new subsection under Path A), `ui/translations.mdx` (key row). - **Generated**: dropped-refinements baseline (`ui/ActionRefusal` and the `….refusals.valueType` sites; header recomputed 270 / 1135), liveness row `action.refusals` (drilled to its four keys) and the `hook.refusals.params` producer re-anchored at the factory, a strictness-ledger row for `declared-entry.zod.ts`, and the `check:generated --fix` outputs (api-surface, export-origins, declaration-map, reference docs, liveness counts, ledger counts, and the two generator-owned `skills/*/references/_index.md` lines). ## Tests - **`packages/runtime/src/sandbox/action-refusal-catalogue.test.ts`** (new, 16): the real `actionBodyRunnerFactory` + `QuickJSScriptRunner`, read off `mapDataError` and the real `/actions` door (`HttpDispatcher.handleActions`): declared message/status/code with the body's own text withheld; 400 default and the body's status not read; zh-CN at the bound key; `zh` negotiated to `zh-CN`; an object-less action at `globalActions`; CONTROL fallbacks (no translation, no locale, no service); reason + params filled, reason translation filled after; undeclared reason / code / no code → 500 fault naming the action; CONTROL: no `refusals` answered as before, a crash stays a crash, a host error passes through; the door answers 409 with the translated `userMessage` (CONTROL: no catalogue keeps the body's 400 and no `userMessage`). - **`packages/spec/src/ui/action-refusals.test.ts`** (new, 29): acceptance, code pattern, empty message, 5xx refused, refused on no body / expression body / `url` / `flow`, omitted `type` accepted, `httpStatus` rename; literal undeclared code and reason at `body.source` with CONTROLs (declared, computed, no catalogue); reasons/params hole rules in the action's words; the hook and action entries accept and refuse the same documents; each subject keeps its own sentences; the text entry has no `status`/`reasons`; run-time sentences; both translation addresses, bundle acceptance and the `refusal` rename. - **Lint**: `validate-hook-refusal-templates.test.ts` (+12: CONTROLs, three refusals, currency in the action's words, reasons at their own path, one judgement for an action met twice, the stack pass, the publish gate's `action` write with CONTROL); `validate-translation-references.test.ts` (+4: CONTROL, undeclared code with suggestion, a key on an action with no `refusals`, undeclared reason and a reason under a code with none); `i18n-walk.test.ts` (+3: bound key, reason key, `globalActions` key). - **Forced test changes**: `packages/spec/src/type-alias-convention.pin.test.ts` pins `ActionRefusalSchema` as an isomorphic alias (857 → 858, with its history line); `packages/spec/src/system/metadata-form-zod-reconciliation.test.ts` (a root omit row for `action.refusals` — the Studio form row is a follow-up, as `hook.texts`'s was); `packages/metadata-protocol/src/protocol.meta-types-degenerate-derivation.test.ts` (`action` serves 54 top-level properties, was 53; the sample names `refusals`); `packages/lint/src/validate-translation-references.test.ts` (the action-translation coverage table gains a `refusals` row and the real-instance leg a declared catalogue); `packages/lint/src/authored-site-expression.test.ts` (the new walk pass `actionRefusalTemplateIssues` classified). No other existing test was changed. ## Acceptance notes - **Contract fork** (recorded on the claim): the refusal sits on the action like `HookSchema.refusals` (precedent named by the seat); final public names are the seat's call: `refusals`, `ActionRefusalSchema`, `actionRefusalMessageKey`, the runtime-internal `resolveActionRefusal` (not a package export), and the factory module `data/declared-entry.zod.ts` (`declaredRefusalEntrySchema`, `declaredTextEntrySchema`). - **Serial with #34374**: PR1 (#34545) is merged and this branch starts from it; `HookTextSchema` now comes from the shared factory (byte-identical published schema) so PR2 adds one text row for actions. - **Not covered**: a string `target` with no body (an imperative host handler) is not answered against the catalogue — `refusals` is refused there at save, so nothing promises it. The Studio action form gets no `refusals` row (it needs the eleven metadata-forms bundles); the reconciliation ledger records the omission, owed to #34823, as the skills teaching is to #34824 (`Skills-docs:` above). - The `skills/objectstack-ui|data/references/_index.md` lines are pure `gen:skill-refs` output (the generator lists a module's first exports; `ActionRefusalSchema` now precedes `ActionSchema` in `action.zod.ts` because it must be declared before the lazy `ActionSchema` evaluates it under `OS_EAGER_SCHEMAS=1`). - Needs a contract-tier review (`Metadata-protocol: added`). ## Verification Every heavy run went under `os-verify-lock`. - `@objectstack/spec`: 940 files, 28752 passed (the one red case on the first run was the reconciliation row added in this PR, green on its rerun with the pin test, 79/79). `check:generated` 14/14 (`check:test-typecheck` needs `NODE_OPTIONS=--max-old-space-size=8192` on this box; the default heap OOMs in `tsc`, nothing measured). - `@objectstack/lint`: 214 files, 9126 passed after the walk classification; `tsc --noEmit` exit 0. - `@objectstack/runtime` sandbox + app-artifact-handlers: 53 files, 665 passed; `tsc --noEmit` exit 0. `@objectstack/metadata-protocol` derivation test 18/18. - **Ablation** (`scripts/ablation-replace.mjs`, restored, blob == HEAD, `git diff HEAD` empty): the action runner's `resolveActionRefusal(…)` replaced by the raw throw ⇒ 12 of 16 runtime cases red; the 4 that stay green are the pass-through CONTROLs (no catalogue, a crash, a host error) and the door CONTROL. - The spec test caught one wording slip during the work ("A action refusal"), fixed with a per-subject article; the hook sentences are unchanged. - Gates: `dispatch-gates --commands` derived 128 families; all ran at the merge of main (116 exit 0; 12 exit 3/1 on the first pass: a stale spec `dist`, an unbuilt workspace, a shallow clone, and two findings fixed in the head commit — `packages/spec/llms.txt` counts the new module, and the new runtime test pays the `@objectstack/metadata` load at collection). After a full `turbo run build` (119/119) and the fixes, the 12 reran exit 0. The per-command ledger at head is on the card's os-dev report. Taken over by repo:objectstack#3 area o3-J (claim 6948521290 on #34273, seat 2 hand-off 6948316290); L1 delta ACCEPT 6948575381 at `0169fc10`. --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzfr1xZSFZzCR8HnqXX <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzfr1xZSFZzCR8HnqXX --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 99bd220 commit 227ae36

51 files changed

Lines changed: 2037 additions & 316 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
'@objectstack/spec': minor
3+
'@objectstack/runtime': minor
4+
'@objectstack/lint': minor
5+
'@object-ui/core': patch
6+
---
7+
8+
feat(actions): an action body refuses in the caller's language through a declared refusal catalogue
9+
10+
Clause-②: yes (widening) — an action may now declare `refusals` (`ActionRefusalSchema`); translation bundles accept `objects.<object>._actions.<action>.refusals.<CODE>.message` and `globalActions.<action>.refusals.<CODE>.message` (with `….reasons.<REASON>.message`); `@objectstack/spec` exports `ActionRefusalSchema` and the `ActionRefusal` type (`ui`), `actionRefusalMessageKey` (`system`), and `ACTION_REFUSAL_MESSAGE_HOLE_REFUSED`, `actionRefusalsWithoutSandboxedBody`, `undeclaredActionRefusalCodeAtSave`, `undeclaredActionRefusalReasonAtSave`, `undeclaredActionRefusalAtRun` and `undeclaredActionRefusalReasonAtRun` (`data`); `@objectstack/runtime` adds no export: the action body runner answers through `resolveActionRefusal` internally. Nothing that was accepted before is refused
11+
Metadata-protocol: added
12+
Skills-docs: follow-up #34824 — `skills/objectstack-i18n/SKILL.md` lists the hook refusal key only and `skills/objectstack-ui/rules/actions.md` teaches no action `refusals`; `content/docs/ui/actions.mdx` and `content/docs/ui/translations.mdx` gain the section and the key row here
13+
14+
A `script` action's `js` body can now refuse the way a hook does: declare the refusals it may throw, keyed by code, and throw the code instead of the sentence — `refusals: { NOT_DRAFT: { message: 'Only a draft invoice can be signed off.', status: 409 } }`, then `throw { code: 'NOT_DRAFT' }`. The server answers with the entry's sentence in the caller's locale (the request's `executionContext.locale`), else the declared one, on the refusal's `userMessage`, with the entry's status (400 when it names none). The entry is the hook catalogue's, built by one shared factory: optional `reasons` (further sentences under one code) and `params` (the names a `{{ }}` hole may fill), under the same rules.
15+
16+
- The translation sits beside the action's other copy: `objects.<object>._actions.<action>.refusals.<CODE>.message` for an action bound to an object, `globalActions.<action>.refusals.<CODE>.message` for an object-less one. `os i18n extract` scaffolds the keys and the coverage check counts them; `objectstack validate` refuses a translation over a code or reason the action does not declare.
17+
- A code the catalogue does not declare, a reason a code with `reasons` does not declare, or a throw with no code is refused: at save when the body names it literally, otherwise when it runs, as a fault naming the action and the code. An error a `ctx.api` call raised and the body let through unchanged passes through as before, and so does a crash.
18+
- `refusals` is read only for a `type: 'script'` action with a `js` body (an inline `target` function is lowered to one by `os build`); on any other action, or with no body, it is refused at save.
19+
- A sentence with `params` is compiled like a hook's: `objectstack validate`, `compile` and the publish gate refuse a hole holding logic, an unknown formatter, an empty hole and `{{ amount | currency }}` with no code.
20+
- An action without `refusals` is answered exactly as before.
21+
22+
The shared declared-entry factory (`packages/spec/src/data/declared-entry.zod.ts`) now builds `HookRefusalSchema`, `ActionRefusalSchema` and `HookTextSchema`; the published hook schemas are unchanged.
23+
24+
`@object-ui/core` lists `refusals` among the spec's declared action keys, so an action carrying a catalogue is not reported as having an unknown key; the console reads nothing new, because the refusal arrives already rendered on `userMessage`.

‎content/docs/protocol/objectui/actions.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ interface Action {
229229
operation?: 'update'; // Declarative single-record field write (rides the default script route)
230230
patch?: Record<string, unknown>; // Static field values for operation: 'update', merged under params
231231
body?: HookBody; // Inline logic for type: 'script'
232+
refusals?: Record<string, ActionRefusal>; // Codes the js body may throw, answered with a declared sentence in the caller's locale
232233
params?: ActionParam[]; // Inputs collected before execution
233234
submitText?: I18nLabel; // The param dialog's submit button verb (default "Confirm")
234235
cancelText?: I18nLabel; // The confirm or param dialog's dismiss button label (default "Cancel")

‎content/docs/references/data/object.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ const result = ApiMethod.parse(data);
500500
| **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. |
501501
| **openIn** | `Enum<'self' \| 'new-tab'>` | optional | For type:'url' — where to open `target`. 'new-tab' opens a new browser tab; 'self' navigates in place. When omitted, external/absolute URLs open in a new tab and relative URLs navigate in place. Static execution option — keep it OUT of `params` (which is user-input-collection only). |
502502
| **body** | `{ language: 'expression'; source: string } \| { language: 'js'; source: string; capabilities?: Enum<'api.read' \| 'api.write' \| 'api.transaction' \| 'crypto.uuid' \| 'log' \| …>[]; timeoutMs?: integer; … }` | optional | Action body — expression (L1) or sandboxed JS (L2). Only used when type is `script`. An action body runs as system, and its update, transfer, delete, purge or restore of an object declared managedBy: 'append-only' is refused with PERMISSION_DENIED; an insert is not judged by this rule. |
503+
| **refusals** | `Record<string, { message: string; status?: integer; reasons?: Record<string, object>; params?: string[] }>` | optional | Refusal catalogue keyed by the SCREAMING_SNAKE code the action's js body throws: `{ message, status?, reasons?, params? }`. The body refuses by code only, optionally with a declared reason and params; the runtime answers with the declared message (translated through objects.`<object>`._actions.`<action>`.refusals.`<CODE>`.message, or globalActions.`<action>`.refusals.`<CODE>`.message for an object-less action, ….reasons.`<REASON>`.message for a reason, in the caller's locale, holes filled from params) and status. A code not declared here, or a reason a code with reasons does not declare, is refused loudly — at save when the body throws it literally, otherwise at run time. Only a type: 'script' action with a js body declares one |
503504
| **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. |
504505
| **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). |
505506
| **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`). |

‎content/docs/references/index.mdx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Protocol reference — every schema by module
33
navTitle: Protocol Reference
4-
description: Every schema published by @objectstack/spec — 1670 schemas across 14 protocol modules
4+
description: Every schema published by @objectstack/spec — 1671 schemas across 14 protocol modules
55
---
66

77
{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}
@@ -33,8 +33,8 @@ counts are sums of the rows they head. Regenerate with
3333
| [Shared Protocol](/docs/references/shared) | 10 | 31 | Primitives used across every protocol — identifiers, HTTP, expressions, error maps, enums. |
3434
| [Studio Protocol](/docs/references/studio) | 3 | 35 | Studio designer metadata — the authoring surfaces for the protocols above. |
3535
| [System Protocol](/docs/references/system) | 40 | 297 | The runtime environment — logging, jobs, cache, metrics, notifications, i18n and compliance. |
36-
| [UI Protocol](/docs/references/ui) | 16 | 177 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. |
37-
| **Total** | **218** | **1670** | 14 protocol modules |
36+
| [UI Protocol](/docs/references/ui) | 16 | 178 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. |
37+
| **Total** | **218** | **1671** | 14 protocol modules |
3838

3939
---
4040

@@ -385,13 +385,13 @@ The runtime environment — logging, jobs, cache, metrics, notifications, i18n a
385385

386386
## UI Protocol
387387

388-
**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 177 schemas**
388+
**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 178 schemas**
389389

390390
Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer.
391391

392392
| File | Schemas |
393393
| :--- | :--- |
394-
| [`action.zod.ts`](/docs/references/ui/action) | `Action`, `ActionAi`, `ActionLocation`, `ActionParam`, `ActionType`, `InlineAction` |
394+
| [`action.zod.ts`](/docs/references/ui/action) | `Action`, `ActionAi`, `ActionLocation`, `ActionParam`, `ActionRefusal`, `ActionType`, `InlineAction` |
395395
| [`action-params.zod.ts`](/docs/references/ui/action-params) | `ActionSession` |
396396
| [`app.zod.ts`](/docs/references/ui/app) | `ActionNavItem`, `App`, `AppBranding`, `AppContextSelector`, `AppLandingEntry`, `ComponentNavItem`, `DashboardNavItem`, `DocNavItem`, `GroupNavItem`, `NavigationArea`, `NavigationContribution`, `NavigationItem`, `ObjectNavItem`, `PageNavItem`, `ReportNavItem`, `UrlNavItem` |
397397
| [`bulk-action.zod.ts`](/docs/references/ui/bulk-action) | `BulkActionDef`, `BulkActionExecution`, `BulkActionOperation`, `BulkActionParam`, `BulkActionResult` |

‎content/docs/references/kernel/metadata-plugin.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ const result = MetadataBulkResultSchema.parse(data);
331331
| **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. |
332332
| **openIn** | `Enum<'self' \| 'new-tab'>` | optional | For type:'url' — where to open `target`. 'new-tab' opens a new browser tab; 'self' navigates in place. When omitted, external/absolute URLs open in a new tab and relative URLs navigate in place. Static execution option — keep it OUT of `params` (which is user-input-collection only). |
333333
| **body** | `{ language: 'expression'; source: string } \| { language: 'js'; source: string; capabilities?: Enum<'api.read' \| 'api.write' \| 'api.transaction' \| 'crypto.uuid' \| 'log' \| …>[]; timeoutMs?: integer; … }` | optional | Action body — expression (L1) or sandboxed JS (L2). Only used when type is `script`. An action body runs as system, and its update, transfer, delete, purge or restore of an object declared managedBy: 'append-only' is refused with PERMISSION_DENIED; an insert is not judged by this rule. |
334+
| **refusals** | `Record<string, { message: string; status?: integer; reasons?: Record<string, object>; params?: string[] }>` | optional | Refusal catalogue keyed by the SCREAMING_SNAKE code the action's js body throws: `{ message, status?, reasons?, params? }`. The body refuses by code only, optionally with a declared reason and params; the runtime answers with the declared message (translated through objects.`<object>`._actions.`<action>`.refusals.`<CODE>`.message, or globalActions.`<action>`.refusals.`<CODE>`.message for an object-less action, ….reasons.`<REASON>`.message for a reason, in the caller's locale, holes filled from params) and status. A code not declared here, or a reason a code with reasons does not declare, is refused loudly — at save when the body throws it literally, otherwise at run time. Only a type: 'script' action with a js body declares one |
334335
| **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. |
335336
| **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). |
336337
| **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`). |

‎content/docs/references/system/translation.mdx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ Translation data for a single field
139139
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
140140
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
141141
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
142+
| **refusals** | `Record<string, { message?: string; reasons?: Record<string, object> }>` | optional | Refusal translations keyed by the code the action's `refusals` declares |
142143

143144
### Nested Shape: `ObjectTranslationData._sections[string]`
144145

@@ -244,6 +245,7 @@ Translation data for a single object
244245
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
245246
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
246247
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
248+
| **refusals** | `Record<string, { message?: string; reasons?: Record<string, object> }>` | optional | Refusal translations keyed by the code the action's `refusals` declares |
247249

248250
### Nested Shape: `PlatformTranslationData.dashboards[string]`
249251

@@ -424,6 +426,7 @@ Translation data for a single object
424426
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
425427
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
426428
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
429+
| **refusals** | `Record<string, { message?: string; reasons?: Record<string, object> }>` | optional | Refusal translations keyed by the code the action's `refusals` declares |
427430

428431
### Nested Shape: `ServedTranslationData.dashboards[string]`
429432

@@ -667,6 +670,7 @@ Translation data for a single object
667670
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
668671
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
669672
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
673+
| **refusals** | `Record<string, { message?: string; reasons?: Record<string, object> }>` | optional | Refusal translations keyed by the code the action's `refusals` declares |
670674

671675
### Nested Shape: `TranslationData.dashboards[string]`
672676

@@ -879,6 +883,7 @@ Translation data for a single object
879883
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
880884
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
881885
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
886+
| **refusals** | `Record<string, { message?: string; reasons?: Record<string, object> }>` | optional | Refusal translations keyed by the code the action's `refusals` declares |
882887

883888
### Nested Shape: `TranslationItem.dashboards[string]`
884889

0 commit comments

Comments
 (0)