Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
8 changes: 8 additions & 0 deletions .changeset/27944-action-keys-submit-text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@object-ui/core': patch
---

`SPEC_ACTION_KEYS` lists `submitText`, the key `@objectstack/spec` adds to `ActionSchema` for the param dialog's submit button label. An action that carries it is not counted as having an unknown key, and the inventory pin stays green.

Clause-②: no
Metadata-protocol: none
28 changes: 28 additions & 0 deletions .changeset/27944-action-submit-text.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
'@objectstack/spec': minor
---

feat(spec): an action's param dialog can name its own submit verb — `submitText`

Clause-②: yes (widening)
Metadata-protocol: added

`ActionSchema` gains one optional key, `submitText`: the label of the submit button in the dialog an action opens to collect its `params`. The button says "Confirm" today for every such action. With the key, a send-email action can say "Send" and a log-call action "Log Call". An action that does not declare it parses exactly as before.

```ts
defineAction({
name: 'log_call',
label: 'Log Call',
objectName: 'crm_contact',
target: 'logCall',
submitText: 'Log Call',
params: [{ name: 'subject', label: 'Subject', type: 'text', required: true }],
});
```

- **An `I18nLabel`.** A plain string or an inline locale map (`{ en, 'zh-CN' }`). A blank string is refused at parse: `''` or whitespace only. Omit the key to keep "Confirm". `submitLabel` and `confirmLabel` (the same button's spelling on a view's `bulkActionDefs`) are refused with a rename to `submitText`, on the action and in a translation bundle.
- **Actions with `params` only.** The param dialog opens only for a non-empty `params`, so `submitText` on any other registered action is refused at parse, naming the key. It is not `confirmText`, the message of the confirm dialog a param-less action opens.
- **Translated like `description`.** The slot is `objects.OBJECT._actions.ACTION.submitText` (`globalActions.ACTION.submitText` for an action with no `objectName`). `translateAction` overlays it for an action that declares `params`, and never gives a button to an action without them.
- **The name.** `submitText` is the protocol's existing word for a submit button's copy: the `object-form` component's `submitText`, beside its `cancelText`.

Nothing draws the key yet. The console's param dialog reads it in a follow-up change. Until then the liveness ledger marks it `planned` with `authorWarn`, so `os validate` warns an author who declares it that the button still says "Confirm".
8 changes: 8 additions & 0 deletions .changeset/27944-lint-submit-text-translation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@objectstack/lint': patch
---

`validateTranslationReferences` judges an action translation's new `submitText` key (`@objectstack/spec`'s param dialog submit label). Under an action that declares no `params`, at `objects.OBJECT._actions.ACTION.submitText` or `globalActions.ACTION.submitText`, it reports `translation-target-unknown` at `error`: such an action opens no param dialog, so nothing reads the label. Under an action that declares `params` the key is accepted.

Clause-②: no
Metadata-protocol: none
25 changes: 25 additions & 0 deletions content/docs/protocol/objectui/actions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ interface Action {
patch?: Record<string, unknown>; // Static field values for operation: 'update', merged under params
body?: HookBody; // Inline logic for type: 'script'
params?: ActionParam[]; // Inputs collected before execution
submitText?: I18nLabel; // The param dialog's submit button verb (default "Confirm")
method?: 'POST' | 'PATCH' | 'PUT' | 'DELETE'; // for type: 'api'

// UX
Expand Down Expand Up @@ -514,6 +515,30 @@ params:

`ActionParam` fields: `name`, `field`, `objectOverride`, `label`, `type`, `required` (default `false`), `options`, `placeholder`, `helpText`, `defaultValue`, `defaultFromRow`, `visible` (CEL predicate — the dialog omits the param when false), `requiresFeature` (capability gate, lowered into `visible` — see [Capability gates](#capability-gates-requiresfeature)).

### Naming the submit button: `submitText`

An action with `params` collects them in a dialog whose submit button says **Confirm**. `submitText` gives that button the action's own verb, so a send-email action can say **Send** and a log-call action **Log Call**. The dialog's other copy stays where it was: the title is the action's `label`, and the line under it is `description`.

```yaml
name: log_call
label: Log Call
objectName: crm_contact
type: script
target: logCall
description: Record a call with this contact.
submitText: Log Call
params:
- { name: subject, label: Subject, type: text, required: true }
- { name: notes, label: Notes, type: textarea }
```

- It is an `I18nLabel`: a plain string, translated at `objects.<object>._actions.<action>.submitText` (`globalActions.<action>.submitText` for an action with no `objectName`), or an inline locale map.
- **Actions with `params` only.** An action with no `params` (or an empty list) opens no param dialog, so `submitText` there is refused at parse, and a translation of it under such an action is reported by `os validate` (`translation-target-unknown`).
- It is not `confirmText`. `confirmText` is the message of the confirm dialog a param-less action opens; `submitText` is the button of the param dialog an action with params opens instead.
- A blank string (`''` or whitespace only) is refused at parse. Omit the key to keep **Confirm**.
- `submitLabel` and `confirmLabel` (the button's spelling on a view's `bulkActionDefs`) are refused with a rename to `submitText`.
- The console does not draw it yet: until its param dialog reads the key, the button says **Confirm**, and `os validate` warns an author who declares it.

## AI Tool Exposure (ADR-0011)

An action can be exposed as an AI-callable tool. Exposure is **opt-in and default off** — set `ai.exposed: true`, which then **requires** `ai.description` (≥ 40 chars, the LLM-facing contract).
Expand Down
1 change: 1 addition & 0 deletions content/docs/references/data/object.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ const result = ApiMethod.parse(data);
| **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`). |
| **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`). |
| **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" (declared ahead of its console reader: no renderer shows it yet) — 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. |
| **variant** | `Enum<'primary' \| 'secondary' \| 'danger' \| 'ghost' \| 'link'>` | optional | Button visual variant for styling (primary = highlighted, danger = destructive, ghost = transparent) |
| **order** | `number` | optional | Sort order within a location group (lower = higher). Promotes/demotes an action toward the record_header primary button; stable, so actions without `order` keep their registration order. |
| **confirmText** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object } \| string \| Record<string, string>` | optional | Confirmation message before execution — 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), and — only when the action's `params` is an object of static values — `params` (`{{ params.tier }}`); an input list binds nothing, since its values are collected after the confirmation. Formatters come from the template engine's whitelist (`TEMPLATE_FORMATTERS`, `@objectstack/formula`); a hole holds no logic (no CEL, no arithmetic). Example: 'Delete `{{ 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. On a registered action, pairing this with a non-empty `params` is refused — that opens a second dialog for one decision; put the question on `description` instead. Correct on a param-LESS action, where the confirm is the only dialog there is. |
Expand Down
1 change: 1 addition & 0 deletions content/docs/references/kernel/metadata-plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ const result = MetadataBulkResultSchema.parse(data);
| **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`). |
| **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`). |
| **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" (declared ahead of its console reader: no renderer shows it yet) — 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. |
| **variant** | `Enum<'primary' \| 'secondary' \| 'danger' \| 'ghost' \| 'link'>` | optional | Button visual variant for styling (primary = highlighted, danger = destructive, ghost = transparent) |
| **order** | `number` | optional | Sort order within a location group (lower = higher). Promotes/demotes an action toward the record_header primary button; stable, so actions without `order` keep their registration order. |
| **confirmText** | `string \| { dialect: 'template'; source?: string; ast?: any; meta?: object } \| string \| Record<string, string>` | optional | Confirmation message before execution — 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), and — only when the action's `params` is an object of static values — `params` (`{{ params.tier }}`); an input list binds nothing, since its values are collected after the confirmation. Formatters come from the template engine's whitelist (`TEMPLATE_FORMATTERS`, `@objectstack/formula`); a hole holds no logic (no CEL, no arithmetic). Example: 'Delete `{{ 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. On a registered action, pairing this with a non-empty `params` is refused — that opens a second dialog for one decision; put the question on `description` instead. Correct on a param-LESS action, where the confirm is the only dialog there is. |
Expand Down
5 changes: 5 additions & 0 deletions content/docs/references/system/translation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Translation data for a single field
| **confirmText** | `string` | optional | Translated confirmation prompt |
| **successMessage** | `string` | optional | Translated success toast/message |
| **disabledReason** | `string` | optional | Translated reason a greyed action shows (hover title and accessible description) while its `disabled` predicate is TRUE |
| **submitText** | `string` | optional | Translated label of the submit button in the action's param dialog (the action must declare `params`; no renderer shows it yet) |
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
Expand Down Expand Up @@ -232,6 +233,7 @@ Translation data for a single object
| **confirmText** | `string` | optional | Translated confirmation prompt |
| **successMessage** | `string` | optional | Translated success toast/message |
| **disabledReason** | `string` | optional | Translated reason a greyed action shows (hover title and accessible description) while its `disabled` predicate is TRUE |
| **submitText** | `string` | optional | Translated label of the submit button in the action's param dialog (the action must declare `params`; no renderer shows it yet) |
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
Expand Down Expand Up @@ -406,6 +408,7 @@ Translation data for a single object
| **confirmText** | `string` | optional | Translated confirmation prompt |
| **successMessage** | `string` | optional | Translated success toast/message |
| **disabledReason** | `string` | optional | Translated reason a greyed action shows (hover title and accessible description) while its `disabled` predicate is TRUE |
| **submitText** | `string` | optional | Translated label of the submit button in the action's param dialog (the action must declare `params`; no renderer shows it yet) |
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
Expand Down Expand Up @@ -642,6 +645,7 @@ Translation data for a single object
| **confirmText** | `string` | optional | Translated confirmation prompt |
| **successMessage** | `string` | optional | Translated success toast/message |
| **disabledReason** | `string` | optional | Translated reason a greyed action shows (hover title and accessible description) while its `disabled` predicate is TRUE |
| **submitText** | `string` | optional | Translated label of the submit button in the action's param dialog (the action must declare `params`; no renderer shows it yet) |
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
Expand Down Expand Up @@ -847,6 +851,7 @@ Translation data for a single object
| **confirmText** | `string` | optional | Translated confirmation prompt |
| **successMessage** | `string` | optional | Translated success toast/message |
| **disabledReason** | `string` | optional | Translated reason a greyed action shows (hover title and accessible description) while its `disabled` predicate is TRUE |
| **submitText** | `string` | optional | Translated label of the submit button in the action's param dialog (the action must declare `params`; no renderer shows it yet) |
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
Expand Down
Loading
Loading