Skip to content

Commit 4ffe9d3

Browse files
feat(spec, runtime, lint): an action writes the sentences it declares in the organization's language (ctx.text) (#35085)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBQ3DFv6XZAspQRYGQoEWhr8)_ Fixes #34374 Clause-②: yes (widening: a new optional authorable key `ActionSchema.texts`, and new translation keys) Metadata-protocol: added Skills-docs: follow-up owed — skills/objectstack-ui/rules/actions.md, skills/objectstack-i18n/SKILL.md ## 维护者速读 - **改了什么**:脚本动作(`type: 'script'` + `js` body)现在可以像钩子一样在 `texts` 里声明要写进记录的句子,body 里用 `ctx.text('key', params)` 取用。运行时按组织语言作答。 - **为什么改**:HotCRM 的 `send_email` 这类动作以前把 `'Email: ' + subject` 硬编码进记录,非英文组织只能读到英文。钩子已经有 `ctx.text`(#34545),动作这一半此前缺失。 - **风险与回滚**:只做加法。没有 `texts` 的动作行为不变,钩子的 schema 与文案字节不变(`references/data/hook.mdx` 未动)。回滚 = revert 本 PR。旧记录不会被改写。 - **先看**:① `packages/runtime/src/sandbox/hook-text.ts`(钩子/动作共用的 `buildDeclaredTextSurface`,组织语言与回退逻辑都在这里);② `packages/spec/src/ui/action.zod.ts` 的 `refuseUndeclaredLiteralActionTextKey`(保存时拒收);③ `packages/runtime/src/sandbox/body-runner.ts` 的动作 handler 接线。 - **两分钟验证**:`pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/sandbox/action-text.integration.test.ts`,预期 8/8 通过。其中 ja-JP 用例写出日文句子,fr-FR 无译文时写出声明的原句。 - **需要你做的**:无,席位落地。 ## What changes This is PR2 of #34374, the action half, per split record 6931459308 and ruling 6913660232 (option B, parameter 7). PR1, the hook half, landed as #34545. **spec** - `ActionSchema.texts`: a record from snake_case keys to `ActionTextSchema`. `ActionTextSchema` is `declaredTextEntrySchema('action')`, the same shared factory and the same entry shape (`message`, `params`) as `HookTextSchema`. Only the words differ. - `DeclaredTextSubject` is now `'hook' | 'action'`. The `TEXT_WORDS.action` row's locale guidance names both translation addresses: `objects.OBJ._actions.ACT.texts.KEY.message` and `globalActions.ACT.texts.KEY.message`. - `hook-refusal-codes.ts`: the text sentences are now built per subject from private cores. The hook exports are byte-identical. New action exports: - `ACTION_TEXT_MESSAGE_HOLE_REFUSED` (the action-named hole refusal); - `undeclaredActionTextKeyAtSave`; - `undeclaredActionTextAtRun`; - `actionTextsWithoutRunnableCode`. - Two save-time refusals: - `texts` on any action that runs no `js` body of its own (url, flow, api, an expression body, or no body) is refused at `texts`; - a literal `ctx.text('key')` over an undeclared key is refused at `body.source`. - `i18n-resolver.ts`: new `actionTextMessageKey(objectName, actionName, key)`. It shares one node-key helper with `actionRefusalMessageKey`, so a bound action and an object-less one resolve through the same ladder. - `translation.zod.ts`: the action translation node accepts `texts` through the new `textTranslationsSchema('action')`, which also builds the hook translation node byte-identically. A loud `text` alias points to `texts`. **runtime** - `hook-text.ts` is rebuilt around one `TextOwner` core, `buildDeclaredTextSurface`, shared by `buildHookTextSurface` and the new `buildActionTextSurface`. The organization's language comes from `readOrganizationTextLocale`: - the Localization setting when somebody set it; - otherwise the app's `i18n.defaultLocale`; - never the language of the person who ran the action. - Fallback when no translation answers: - a missing translation, or no language to pick, writes the declared sentence filled with its params; - a translation whose holes do not render is dropped for the declared sentence, with a warning; - a Localization setting that cannot be read rejects the call. - `body-runner.ts`: the action handler passes `ctx.text` into the sandbox, so both binding sites (`app-artifact-handlers.ts` and `installDefaultActionBodyRunner`) receive it without change. - The action's own object is read through `actionOwnObject`, which `hook-refusal-catalogue.ts` now exports so the refusal and text surfaces share one owner ladder. **lint** - `i18n-walk.ts`: `os i18n extract` and the coverage check now see action texts, both inline object actions and top-level ones. - `validate-translation-references.ts`: a translation over a key the action does not declare under `texts` is refused, with `TRANSLATION_TARGET_UNKNOWN`. - `validate-hook-refusal-templates.ts`: action text templates are compiled like refusal templates. `validate`, `compile` and the publish gate refuse: - logic in a hole; - an unknown formatter; - an empty hole; - a `currency` formatter with no code. **Ripples, docs, changeset** - `@object-ui/core` `SPEC_ACTION_KEYS` gains `texts`. - `liveness/action.json` gains a `texts` row. - Counts and pins move: - the type-alias pin: 859 to 860; - the metadata-form reconciliation pin: a new omit row; - the degenerate-derivation pin: 54 to 55; - the dropped-refinements baseline: the build's corrected entries plus `ui/ActionText`. - Generated artifacts are regenerated by `check:generated --fix` and the spec build. None is hand-edited. - Docs: - `ui/actions.mdx`: a new `texts` subsection; - `ui/translations.mdx`: an "Action texts" row; - `protocol/objectui/actions.mdx`: the field line; - `automation/hook-bodies.mdx`: the `ctx.text` row said "hook bodies only", which this change made false. - Changeset: spec, runtime and lint `minor`; `@object-ui/core` `patch`. ## Tests - `packages/spec/src/ui/action-texts.test.ts` (new) covers: - parse; - the closed entry; - param identifiers and duplicates; - a hole with no params, or over an undeclared param, in the action's words; - near-miss aliases; - five non-script shapes refused; - literal undeclared keys at save, with controls for a comment, a string and a computed key; - parity between the hook and action factories; - the guidance naming both addresses, with no tracker number; - translation addresses and a bundle at both layouts. - `packages/runtime/src/sandbox/action-text.integration.test.ts` (new, 8 tests) uses a real ObjectQL, SqlDriver (better-sqlite3), QuickJS and memory i18n, through `engine.registerAction` and `executeAction`. Cases: - a bound action, with a `globalActions` control; - an object-less action; - ja-JP set in Localization, with a `source: 'default'` control; - fr-FR with no translation, which falls back; - an unrendered translation, which falls back with a warning, with a control; - an unregistered setting vs an unavailable store; - an undeclared key; - no texts declared. - lint tests: - `i18n-walk.test.ts`: 3 new tests; - `validate-translation-references.test.ts`: a `texts` coverage row plus 3 new tests; - `validate-hook-refusal-templates.test.ts`: about 11 new tests, including the publish gate. - HotCRM's `send_email` case, `ctx.text('email_subject', { subject })`, is the pinned fixture throughout. <details><summary>Red first on origin/main, then ablations (each restored, blob == HEAD, `git diff HEAD` empty)</summary> - **Red first:** with the runtime sandbox sources set back to BASE `4443014630`, `action-text.integration.test.ts` reads `Tests 8 failed (8)`. - **Ablation 1** replaces body-runner's `buildActionTextSurface(...)` with `undefined`: `Tests 8 failed (8)`. - **Ablation 2** replaces hook-text's `actionOwnObject(...)` with `undefined`: `Tests 4 failed | 4 passed (8)`. The 4 that pass are the cases that do not read the action's object (fallback, undeclared key, no texts, settings errors). - **Ablation 3** makes i18n-walk's `pushActionTexts` return early: `Tests 3 failed | 13 passed (16)`. The 3 new walk tests turn red and the rest of the file stays green. All three ablations went through `scripts/ablation-replace.mjs` with a trap restore and a check that the anchor landed on disk. </details> <details><summary>Package suites and typecheck (head 7d7241a, after merging origin/main)</summary> - spec `pnpm test`: `Test Files 853 passed (853)` · `Tests 27290 passed | 1 todo (27291)` - lint `pnpm test`: `Test Files 218 passed (218)` · `Tests 9250 passed (9250)` - runtime `src/sandbox` + `src/app-artifact-handlers`: `Test Files 54 passed (54)` · `Tests 676 passed (676)` - metadata-protocol degenerate-derivation pin: `Tests 18 passed (18)` - `@object-ui/core` actionKeys pin: `Tests 19 passed (19)` - `typecheck` for spec, runtime and lint: exit 0 each (`TC spec=0 runtime=0 lint=0`). </details> ## Acceptance notes - **Which actions run `ctx.text`.** Only `type: 'script'` actions with a `js` body get it, because they are the only ones that run a body. - An inline `target` function is lowered to such a body by `os build`. - `flow` and `api` actions dispatch on `target` and have no body context. A flow's record writes are the flow's own, translated under `flows.FLOW.records` (#34062). - **Studio.** The Studio action form shows no `texts` editor yet. The key is authorable in source, and the metadata-form reconciliation pin carries an explicit omit row for it. A form row is follow-up work. - **Skills docs.** The skills teaching (`skills/objectstack-ui/rules/actions.md`, `skills/objectstack-i18n/SKILL.md`) is owed as a follow-up, per the `Skills-docs:` line. This PR touches no `skills/**` file. ## Verification The branch merged origin/main at eb7b09d. The one hand conflict was the type-alias pin count: main's two `DatasetNextStep` pins (861) stack with `ActionTextSchema` (862). The generated artifacts the merge left stale were then regenerated with `scripts/pm/os-regen-merge.sh` and the spec generators. No main-side line of the generated files was dropped; only the schema counts moved. The derived gate set has 122 commands, from `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` at 7d7241a. All of them were run locally at that head after a full package build. `dispatch-gates --ran` reads: `122 derived, 122 run, 0 NOT-MEASURED, 0 UNRUN`. CI check-runs are cited in the report. <details><summary>Gate sweep at 7d7241a</summary> - 121 of 122 gates exit 0 on the first run. - `pnpm --dir ui exec vitest run scripts/` was SIGKILLed by the box's memory limit while running beside the other gates. Rerun alone, it exits 0 (`Tests 5077 passed | 2 skipped`). - `check:type-check-debt` ran under the verify lock: `0 raw tsc error(s) total, none above its recorded number`. - `check:dual-build-cjs-loads`: exit 0 (`124 published require entry point(s) across 72 package(s) load`). - `check:generated` (spec): `All 14 generated artifacts are up to date`. - `check-platform-checklist --changed-from origin/main`: exit 0 (`20 anchor(s) judged, 0 lost`). - `check-nul-bytes`: exit 0. - `check-governed-merges --branch`: `NOT governed`, 44 paths, +1312 / -92. - An earlier full sweep at d3e6adf, before the merge, had seven prerequisite refusals (shallow clone, missing dists, a lock queue-timeout). All seven were fixed and rerun green before this sweep. </details> **Dogfood battery:** n/a. The title has no `!` and Clause-② is a widening with no `(narrowing)` arm. --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzgNCAXyGfBQFZBwixH)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzgNCAXyGfBQFZBwixH --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent dfc6bbf commit 4ffe9d3

44 files changed

Lines changed: 1354 additions & 99 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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 writes the sentences it declares in the organization's language
9+
10+
Clause-②: yes (widening: a new optional authorable key `ActionSchema.texts`, and new translation keys)
11+
Metadata-protocol: added
12+
Skills-docs: follow-up owed — skills/objectstack-ui/rules/actions.md, skills/objectstack-i18n/SKILL.md
13+
14+
A `script` action's `js` body can now write a sentence into a record in the organization's language, the way a hook does: declare it under `texts`, keyed by a snake_case key, and ask for it by key — `texts: { email_subject: { message: 'Email: {{ subject }}', params: ['subject'] } }`, then `await ctx.text('email_subject', { subject })` where the body used to write `'Email: ' + subject`. The answer is in the organization's language, because everyone in the organization reads the record: the Localization setting (`localization.locale`) when somebody set it, else the app's declared `i18n.defaultLocale`. It is never the language of the person who ran the action. The translation is picked first, then its `{{ }}` holes are filled from `params`. The entry is the hook text's, built by the same shared factory.
15+
16+
- The translation sits beside the action's other copy: `objects.<object>._actions.<action>.texts.<key>.message` for an action bound to an object, `globalActions.<action>.texts.<key>.message` for an object-less one. `os i18n extract` scaffolds the keys and the existing coverage check counts them; `objectstack validate` refuses a translation over a key the action does not declare.
17+
- A missing translation, or no language to pick, answers the declared sentence, and the action goes on. A Localization setting that cannot be read rejects the call.
18+
- Only declared text is translated: a string the body builds itself is written as it is. A key `texts` does not declare is refused when the action is saved if the body asks for it literally (`ctx.text('key')`), otherwise when it runs, as a fault naming the action and the key.
19+
- `texts` 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. A `flow` action's record writes are the flow's own, marked and translated there (`flows.<flow>.records.…`).
20+
- A text with `params` is compiled like a hook's: a hole over another name is refused when the action is saved, and `objectstack validate`, `compile` and the publish gate refuse a hole holding logic, an unknown formatter, an empty hole and `{{ amount | currency }}` with no code. A translation whose holes do not render at run time is dropped for the declared sentence, filled.
21+
- Text is picked when it is written. Records already written are not changed. An action without `texts` runs exactly as before.
22+
23+
`@object-ui/core` lists `texts` among the spec's declared action keys, so an action carrying them is not reported as having an unknown key; the console reads nothing new, because the body stores the sentence already picked.
24+
25+
New exports: `@objectstack/spec` adds `ActionTextSchema` and the `ActionText` type (`ui`), `actionTextMessageKey` (`system`), and `ACTION_TEXT_MESSAGE_HOLE_REFUSED`, `actionTextsWithoutRunnableCode`, `undeclaredActionTextKeyAtSave` and `undeclaredActionTextAtRun` (`data`); `@objectstack/runtime` adds none. Nothing that was accepted before is refused.

‎content/docs/automation/hook-bodies.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ The script sees only what the surrounding `ctx` object exposes:
103103
| `ctx.api.object(name).insert\|update\|delete` | Cross-object writes. | `api.write` |
104104
| `ctx.title()` | This record's title — the object's `nameField`, **including when it is a `formula`** (evaluated server-side against the record already in hand: no extra read over the record's own columns, one read per lookup a title such as `record.book.title + ' · ' + record.reader.name` reads through). | none |
105105
| `ctx.title('<lookup field>')` | The related record's title, through a lookup / master_detail / user / tree column. Costs one `findOne` (plus the lookups that record's own title reads through). | `api.read` |
106-
| `ctx.text('<key>', params?)` | A sentence the hook declared under `texts`, in the **organization's** language (translated, holes filled from `params`), for a value it writes into a record. Hook bodies only. See [Writing a sentence people read](/docs/automation/hooks#writing-a-sentence-people-read--texts). | none |
106+
| `ctx.text('<key>', params?)` | A sentence the hook — or the `script` action — declared under `texts`, in the **organization's** language (translated, holes filled from `params`), for a value it writes into a record. Hook and action bodies; a job body has no `texts`. See [Writing a sentence people read](/docs/automation/hooks#writing-a-sentence-people-read--texts) and [Write in the organization's language](/docs/ui/actions#write-in-the-organizations-language--texts). | none |
107107
| `ctx.crypto.randomUUID()` | UUID generation. | `crypto.uuid` |
108108
| `ctx.log.{info,warn,error}` | Structured logging. | `log` |
109109
| `ctx.email.send({ to, subject, text })` | Sends mail through the mail service, from the configured sender, as the calling user and under the caller's organization. An action or a job body only: a hook body cannot send mail, because a message cannot be taken back if the write that runs the hook rolls back. A hook whose body is granted `email.send` is refused when it is saved, validated, built or bound, and the Console does not offer the grant on a hook. Send mail on a record change from an action, a job or a flow. See [Email service](/docs/kernel/runtime-services/email-service#from-a-script-body). | `email.send` |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ interface Action {
230230
patch?: Record<string, unknown>; // Static field values for operation: 'update', merged under params
231231
body?: HookBody; // Inline logic for type: 'script'
232232
refusals?: Record<string, ActionRefusal>; // Codes the js body may throw, answered with a declared sentence in the caller's locale
233+
texts?: Record<string, ActionText>; // Sentences the js body writes into records (ctx.text), in the organization's language
233234
params?: ActionParam[]; // Inputs collected before execution
234235
submitText?: I18nLabel; // The param dialog's submit button verb (default "Confirm")
235236
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
@@ -502,6 +502,7 @@ const result = ApiMethod.parse(data);
502502
| **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). |
503503
| **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. |
504504
| **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 |
505+
| **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 |
505506
| **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. |
506507
| **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). |
507508
| **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 — 1674 schemas across 14 protocol modules
4+
description: Every schema published by @objectstack/spec — 1675 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 | 179 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. |
37-
| **Total** | **218** | **1674** | 14 protocol modules |
36+
| [UI Protocol](/docs/references/ui) | 16 | 180 | Apps, pages, views, dashboards, reports, actions and themes — the ObjectUI layer. |
37+
| **Total** | **218** | **1675** | 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, 179 schemas**
388+
**Source:** `packages/spec/src/ui/` · **Import:** `@objectstack/spec/ui` · **16 pages, 180 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`, `ActionRefusal`, `ActionType`, `InlineAction` |
394+
| [`action.zod.ts`](/docs/references/ui/action) | `Action`, `ActionAi`, `ActionLocation`, `ActionParam`, `ActionRefusal`, `ActionText`, `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
@@ -332,6 +332,7 @@ const result = MetadataBulkResultSchema.parse(data);
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. |
334334
| **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 |
335+
| **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 |
335336
| **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. |
336337
| **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). |
337338
| **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`). |

0 commit comments

Comments
 (0)