Skip to content

Commit 758bbe7

Browse files
feat(spec,lint,i18n): translation bundle key for an action answer table's column headers (#34915)
Fixes #34652 <!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwB5Q5XDchqCqfEmNMpqTSQr1)_ Clause-②: yes (widening) Metadata-protocol: added Skills-docs: follow-up #34917 ## 维护者速读 - 改了什么:动作结果弹窗和预检面板里「表格」的列标题现在有翻译键 `resultDialog.columns.字段路径.列路径`(预检同理),与 `fields` 并列;抽取、校验、服务端翻译和控制台叠加都按这个键走,平台包里「导入用户」结果表的 9 个列标题已译成全部 10 种语言。 - 为什么改:PR #34647 让结果弹窗能画表格,但列标题没有翻译键,中文等语言界面下表头一直是英文。 - 风险与回滚:只加不减。旧翻译包一字不改照样通过、照样显示;没有列键时列标题保持作者原文。回滚即撤销本 PR。 - 先看:`packages/spec/src/system/translation.zod.ts`(新的 `columns` 形状)、`packages/spec/src/system/i18n-resolver.ts`(`overlayAnswerColumnLabels`)、`ui/packages/i18n/src/useObjectLabel.ts`(控制台叠加)。 - 两分钟验证:`pnpm --filter @objectstack/spec exec vitest run src/system/i18n-resolver.test.ts -t "answer table column labels"`,预期 7 条全绿。 - 需要你做的:无,席位落地。 ## What changes **The key, and why it is a sibling map.** `ActionResultDialogTranslationSchema` and the module-local `ActionPreflightTranslationSchema` each gain an optional `columns`: `Record<fieldPath, Record<columnPath, string>>`, both keys the LITERAL paths from the action metadata (dots included, indexed directly, never split). The bundle reads ```ts resultDialog: { fields: { rows: '逐行结果' }, columns: { rows: { email: '邮箱', 'error.message': '未添加的原因' } }, } ``` The card suggested nesting the column map under the field entry (`fields.PATH.columns.COL`). I chose the sibling map instead: a `fields.PATH` value stays the field's label string, so no existing bundle, generated file or resolver ever sees a field entry that is sometimes a string and sometimes an object; every bundle that parses today parses unchanged and reads the same, and nothing about a table field's own label key moves. The shared shape is one module-local `ActionAnswerColumnLabelsSchema` (no new export, so the published skills' reference indexes do not move). **Threaded through.** - `packages/spec/src/system/i18n-resolver.ts`: `resolveActionResultDialog` and `resolveActionPreflight` (so `translateAction` and every served object) overlay each declared column's `label` from the bundle through the locale chain; a column with no key keeps its authored label, a field with no `columns` is the same reference. `ResultDialogLike` / `PreflightLike` rows gain an optional typed `columns`. - `packages/lint/src/i18n-walk.ts`: `pushAnswerTableColumns` emits `…resultDialog.columns.PATH.COL` and `…preflight.columns.PATH.COL` for every labelled column (an unlabelled column draws its path and gets no key, as an unlabelled field row gets none), so `os i18n extract` and the coverage gate list them. - `packages/lint/src/validate-translation-references.ts`: `checkActionAnswerTableColumns` refuses (`translation-target-unknown`, error) a `columns` key naming a field that is not a declared `format: 'table'` field with `columns`, a column path its `columns` does not list, or a block the action does not declare; the coverage pin classifies both new keys as reference-checked with a ghost leg at both addresses. `rule-explanations.ts` names the two keys. - `ui/packages/i18n/src/useObjectLabel.ts`: `actionResultDialog` and `actionPreflight` read the `columns` node whole (`returnObjects`) and overlay declared columns only. `ActionResultDialog.tsx`'s `TableBlock` already draws `resolveInlineI18nLabel(column.label)` from the overlaid rows, so it is unchanged. - `packages/platform-objects/src/apps/translations/*`: regenerated with `node scripts/check-i18n-bundles.mjs --write`; `sys_user.import_sso_users`'s nine result-table headers are translated by hand in zh-CN, zh-Hant, ja-JP, ko, es-ES, pt-BR, fr, de, ru and ar (no source-hash echo rows remain). - Docs: `content/docs/references/system/translation.mdx` (regenerated), `content/docs/protocol/kernel/i18n-standard.mdx` (the resolvable-key table), `content/docs/ui/translations.mdx` (the key table and the result-dialog callout). **Measured on the surface.** `packages/spec/authorable-surface/system.json` gains one row, `system/ActionResultDialogTranslation:columns` (regenerated in e839d61; `check:authorable-surface` green on it). The preflight node has no row, because `ActionPreflightTranslationSchema` is module-local and not on the walk. `Metadata-protocol: added` follows from that row and from the new key a bundle author can write; the spec changeset is `minor`. ## Tests - Spec `src/system/i18n-resolver.test.ts`, new `describe('answer table column labels …')` (7 cases): a column header resolved in zh-CN (a dotted column path as one key, an unlabelled column gaining one), the en bundle read in en with authored headers kept where en has no key, a bundle without any column key answering exactly as before and still parsing, the fallback chain per column, the preflight block, `translateAction` on both blocks, and the schema refusing a flat string where the per-field map belongs. - Lint `src/i18n-walk.test.ts`, new `describe('collectExpectedEntries — answer table column labels')`: the walk lists one key per labelled column beside the field key, inline locale maps kept, for `resultDialog` and `preflight`. - Lint `src/validate-translation-references.test.ts`, new `describe('resultDialog.columns / preflight.columns')` (3 cases) plus the two new rows in the action-shape coverage pin and the real-instance control. - Console `ui/packages/i18n/src/__tests__/useObjectLabel-actionResultDialog.test.tsx`, new top-level `describe` (2 cases): headers drawn from the zh-CN bundle and from the en bundle after a language switch, the preflight overlay, and a bundle with no column key keeping every authored header. Package suites, local, at `6a8399c1` (each under `scripts/pm/os-verify-lock.sh`, `VERDICT command-exit 0`): <details><summary>Suite readings</summary> - `pnpm --filter @objectstack/spec test`: Test Files 848 passed (848), Tests 27189 passed, 1 todo. - `pnpm --filter @objectstack/lint test`: Test Files 216 passed (216), Tests 9163 passed. - `pnpm --filter @objectstack/platform-objects test`: Test Files 123 passed (123), Tests 2046 passed. - `pnpm --dir ui --filter @object-ui/i18n test`: Test Files 102 passed (102), Tests 1896 passed, 13 skipped. - `pnpm --filter @objectstack/spec typecheck`, `pnpm --filter @objectstack/lint typecheck`, `@object-ui/i18n type-check`: exit 0. </details> <details><summary>Ablations (one per tested behaviour, through scripts/ablation-replace.mjs; each restore proved blob == HEAD and git diff HEAD empty)</summary> - `i18n-resolver.ts` `overlayAnswerColumnLabels`, the lookup replaced by `undefined`: `i18n-resolver.test.ts` 5 failed / 526 passed (the five column cases that read a translated header; the two that assert authored headers and parsing stay green, as they should). - `i18n-walk.ts` `pushAnswerTableColumns` returning at once: `i18n-walk.test.ts` 2 failed / 8 passed. - `validate-translation-references.ts` `checkActionAnswerTableColumns` returning at once: 3 failed / 247 passed (the two refusal cases and the coverage pin's ghost legs). - `useObjectLabel.ts` `overlayColumnLabels`, the lookup replaced by `undefined`: `useObjectLabel-actionResultDialog.test.tsx` 1 failed / 4 passed. </details> ## Acceptance notes - **Live reading needed a stand-in for one hop, because of a separate defect.** On current `main` the console's Import Users action answers `400 INVALID_REQUEST` "Unknown field(s): organizationId": the action door (`packages/runtime/src/action-execution.ts`, the identity-route `organizationId` stamp) adds a key the import door (`packages/plugins/plugin-auth/src/pending-sso-users.ts`) refuses. Filed as #34912 by the seat; not touched here. For the reading, a Playwright route re-sent the dialog's own params to the import door itself (`POST /api/v1/auth/admin/import-sso-users`), so the answer the dialog drew is the door's real one; nothing else was stubbed. - The result table's headers wrap one character per line in the narrow reveal dialog when nine columns are drawn (visible in the zh-CN reading); that is the existing dialog width, not the labels, and it is the same in en with longer words. Noted, not filed. - On the Users list the `source` option `idp_pending` draws "Pending SSO Sign-In" in zh-CN. Noted, outside this card. - `Skills-docs`: `skills/objectstack-i18n/SKILL.md` teaches every action bundle key and should gain the two `columns` keys; filed as #34917 (a `domain:skills` follow-up, governed surface). - No review was requested on this pull: under the seat order the assignee is the claim's `Account:` and the seat hands over reviews. ## Verification **Live, zh-CN, the real console** (Vite from this branch over `@objectstack/example-showcase` booted `--fresh` with `OS_CLOUD_MANAGED=1` so the managed action is offered; Playwright, locale `zh-CN`): Setup → 用户 → overflow → 导入用户, CSV with one good and one bad row, 确认. The result dialog titled 导入完成 drew the `rows` table with headers `["行","邮箱","成功","已在待激活中,已再次通知","已通知托管组织","未通知的原因","未添加的原因","未应用(请在记录上设置)","上级"]` and the same run in `en` drew `["Row","Email","Succeeded","Already pending, told again","Hosting organization told","Why not told","Not added because","Not applied (set these on the record)","Manager"]`. Not run live on `main`: there the bundles carry no `columns` key and the overlay reads none, so the table draws the authored English headers in every locale (the card's premise, read in source). **Server half:** `GET /api/v1/meta/object/sys_user` with `Accept-Language: zh-CN` serves `import_sso_users.resultDialog.fields[rows].columns[].label` as the nine Chinese headers above; with `en`, the authored English. <details><summary>Derived gates (dispatch-gates --commands at 6a8399c: 120 families, all run locally)</summary> - 116 exited 0 on the first pass, including `check:i18n`, `check:i18n-walk-parity`, `check:i18n-stale-fill`, spec `check:generated` (all 14 current), `check:authorable-surface`, `check:liveness`, `check:docs`, `check:nul-bytes`, `check:test-source-alias`. - `spec check:api-surface` and `spec check:skill-examples` refused with exit 3 (dist older than a source file an ablation restore had rewritten); after the rebuild both exit 0 ("public API surface + factory signatures unchanged", "347 prose examples type-check"). - `check:watch-hint-literal` exited 1 on a temp file another gate run deleted under it (ENOENT on an `i18n-extract.config.bundled_*.mjs`); rerun alone: exit 0. - `node scripts/check-plugin-teardown-shape.mjs --self-test`: exit 3, the shallow clone cannot reach its pinned positive-control commit. NOT MEASURED locally; CI's checkout runs it. - Outside the derived list: `pnpm check:i18n-coverage` exit 0 ("14 config(s), 423 baselined untranslated string(s), none new"). - `dispatch-gates --ran`: 120 of 120 accounted. - Size: 26 files, +825 / -51 against `main`; no governed path. `main` moved 11 commits since the branch point, none in a file this diff touches and none in `packages/spec`. </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzfRcWkapqoXk7QZVob <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzfRcWkapqoXk7QZVob --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 28a733e commit 758bbe7

26 files changed

Lines changed: 825 additions & 51 deletions
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/lint': patch
4+
'@objectstack/platform-objects': patch
5+
'@object-ui/i18n': patch
6+
---
7+
8+
feat(spec, lint, i18n): an action answer table's column headers have a translation bundle key
9+
10+
Clause-②: yes (widening) — `ActionResultDialogTranslationSchema` and the action `preflight` translation node accept a new optional `columns` map, `columns.<field path>.<column path>` (both keys literal, dots included), beside `fields`; every bundle that parsed before parses unchanged and reads the same.
11+
Metadata-protocol: added
12+
Skills-docs: follow-up owed — skills/objectstack-i18n/SKILL.md
13+
14+
A `format: 'table'` field in an action's `resultDialog.fields` or `preflight.fields` declares `columns: [{ path, label }]`, and each column's `label` is translatable, but no bundle key carried it, so a table's headers stayed in the authored language in every locale. The key is `objects.<object>._actions.<action>.resultDialog.columns.<field path>.<column path>` (and `….preflight.columns.…`; `globalActions.<action>.…` for an object-less action):
15+
16+
```ts
17+
resultDialog: {
18+
fields: { rows: '逐行结果' },
19+
columns: { rows: { email: '邮箱', 'error.message': '未添加的原因' } },
20+
}
21+
```
22+
23+
- `os i18n extract` lists one key per labelled column, `os validate` refuses a column key that names no declared table field or column (`translation-target-unknown`), and `resolveActionResultDialog` / `resolveActionPreflight` (so `translateAction` and the served metadata) and the console's `useObjectLabel` overlay the translated header; a column with no key keeps its authored label.
24+
- The platform bundles carry the nine column headers of `sys_user.import_sso_users`'s result table in every shipped locale.

‎content/docs/protocol/kernel/i18n-standard.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,7 @@ beneath an action entry are judged the same way under either.
11551155
| `{action}.params.{param}.options.{value}` | an option's stored **`value`** in that param's inline `options` — a warning, as on a field. A param that references a `field` and declares no inline `options` takes the field's list when the dialog renders, so its option keys are not judged |
11561156
| `{action}.outcomeMessages.{outcome}` | an outcome the action's own `outcomeMessages` declares |
11571157
| `{action}.resultDialog.fields.{path}` | the literal `path` of a field the action's `resultDialog.fields[]` declares — dots included, so `client.secret` is one key |
1158+
| `{action}.resultDialog.columns.{path}.{column}` / `{action}.preflight.columns.{path}.{column}` | a column header of a table: `{path}` the literal `path` of a `format: 'table'` field in that block's `fields[]`, `{column}` the literal `path` of one of its `columns[]` — dots included at both levels, so `columns.rows["error.message"]` is two keys deep, not three |
11581159
| `{action}.resultDialog.title` / `.description` / `.acknowledge` | an action that declares a `resultDialog`, whether or not the dialog sets that text itself — for an action that declares none, nothing reads the dialog's copy |
11591160
| `apps.{app}` | an app declared, or one a `navigationContributions` entry anywhere in the artifact contributes into — including an app owned outside the artifact; under an app that is only contributed into, `apps.{app}.label` may be left out (the owning package's label survives the merge) |
11601161
| `apps.{app}.navigation.{id}` | a navigation item `id` the app declares (nested `children` and `areas[]` included) or one contributed into it; under an app that is only contributed into, the contributed ids alone |

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

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Translations for an action result dialog
3434
| **description** | `string` | optional | Translated result dialog description |
3535
| **acknowledge** | `string` | optional | Translated acknowledge button label |
3636
| **fields** | `Record<string, string>` | optional | Result field labels keyed by the literal field path declared in the action metadata (keys may contain dots) |
37+
| **columns** | `Record<string, Record<string, string>>` | optional | Table column header labels: keyed by the literal path of a `format: 'table'` field, then by the literal path of one of its `columns[]` (keys may contain dots) |
3738

3839

3940
---
@@ -136,8 +137,8 @@ Translation data for a single field
136137
| **cancelText** | `string` | optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
137138
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
138139
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
139-
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
140-
| **preflight** | `{ fields?: Record<string, string> }` | optional | Translations for the action preflight panel |
140+
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
141+
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
141142

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

@@ -241,8 +242,8 @@ Translation data for a single object
241242
| **cancelText** | `string` | optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
242243
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
243244
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
244-
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
245-
| **preflight** | `{ fields?: Record<string, string> }` | optional | Translations for the action preflight panel |
245+
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
246+
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
246247

247248
### Nested Shape: `PlatformTranslationData.dashboards[string]`
248249

@@ -421,8 +422,8 @@ Translation data for a single object
421422
| **cancelText** | `string` | optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
422423
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
423424
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
424-
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
425-
| **preflight** | `{ fields?: Record<string, string> }` | optional | Translations for the action preflight panel |
425+
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
426+
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
426427

427428
### Nested Shape: `ServedTranslationData.dashboards[string]`
428429

@@ -664,8 +665,8 @@ Translation data for a single object
664665
| **cancelText** | `string` | optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
665666
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
666667
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
667-
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
668-
| **preflight** | `{ fields?: Record<string, string> }` | optional | Translations for the action preflight panel |
668+
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
669+
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
669670

670671
### Nested Shape: `TranslationData.dashboards[string]`
671672

@@ -876,8 +877,8 @@ Translation data for a single object
876877
| **cancelText** | `string` | optional | Translated label of the dismiss button on the action's confirm or param dialog (the action must declare `confirmText` or `params`) |
877878
| **outcomeMessages** | `Record<string, string>` | optional | Translated success copy per handler outcome, keyed by the snake_case outcome name the action's `outcomeMessages` declares |
878879
| **params** | `Record<string, { label?: string; helpText?: string; placeholder?: string; options?: Record<string, string> }>` | optional | Action parameter translations keyed by parameter name |
879-
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string> }` | optional | Translations for the action result dialog |
880-
| **preflight** | `{ fields?: Record<string, string> }` | optional | Translations for the action preflight panel |
880+
| **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record<string, string>; … }` | optional | Translations for the action result dialog |
881+
| **preflight** | `{ fields?: Record<string, string>; columns?: Record<string, Record<string, string>> }` | optional | Translations for the action preflight panel |
881882

882883
### Nested Shape: `TranslationItem.dashboards[string]`
883884

‎content/docs/ui/translations.mdx‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export default defineStack({
7676
| Bulk-action copy on a list view (button, confirm prompt, dialog fields) | `objects.<name>._views.<view>.bulkActions.<def>.label` / `.confirmText` / `.confirmLabel` / `.params.<param>.label` / `.help` / `.placeholder` — a bulk param's hint is `help`, not `helpText` |
7777
| Action labels, confirm text, success messages, disabled reasons, param dialog submit labels, confirm and param dialog dismiss labels | `objects.<name>._actions.<action>` |
7878
| Action result dialogs (title / description / acknowledge / field labels) | `objects.<name>._actions.<action>.resultDialog` |
79+
| Column headers of a table in an action's result dialog or preflight panel | `objects.<name>._actions.<action>.resultDialog.columns.<field path>.<column path>` / `.preflight.columns.<field path>.<column path>` — a sibling of `fields`, both paths written literally, dots included |
7980
| Form sections | `objects.<name>._sections.<section>` |
8081
| Custom validation-rule messages | `objects.<name>._validations.<rule>.message` |
8182
| App navigation | `apps.<app>.navigation.<id>.label` |
@@ -159,7 +160,9 @@ is resolved by this one rule.
159160
`resultDialog` shown by actions like `create_user` (temporary password), 2FA
160161
backup codes, and OAuth client-secret rotation carries its own
161162
`_actions.<action>.resultDialog` slot (`title` / `description` / `acknowledge`
162-
and `fields` keyed by the literal result-field path, e.g. `"user.email"`).
163+
and `fields` keyed by the literal result-field path, e.g. `"user.email"`; a
164+
`format: 'table'` field's column headers sit beside `fields` under
165+
`columns.<field path>.<column path>`).
163166
`os i18n extract` emits these keys; the shipped platform dialogs ship
164167
en / zh-CN / ja-JP / es-ES copy. Separately, **platform notification and
165168
storage strings localize to the recipient's locale** — collaboration

‎packages/lint/src/i18n-walk.test.ts‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,72 @@ describe('collectExpectedEntries — preflight field labels', () => {
153153
expect(preflightKeys(['objects', 'sys_package', '_actions', 'install_bare'])).toEqual([]);
154154
});
155155
});
156+
157+
/**
158+
* [#34652] `resultDialog.columns.<path>.<column_path>` and
159+
* `preflight.columns.<path>.<column_path>` — one key per labelled column of a
160+
* `format: 'table'` field, beside the field's own `fields.<path>` key, both
161+
* levels keyed by the literal path (a dotted path stays ONE segment).
162+
*/
163+
describe('collectExpectedEntries — answer table column labels', () => {
164+
const table = {
165+
path: 'rows',
166+
label: 'Result per row',
167+
format: 'table',
168+
columns: [
169+
{ path: 'email', label: 'Email' },
170+
{ path: 'error.message', label: { en: 'Not added because', 'zh-CN': '未添加的原因' } },
171+
{ path: 'row', format: 'json' },
172+
],
173+
};
174+
const stack = {
175+
objects: [
176+
{
177+
name: 'sys_user',
178+
label: 'User',
179+
fields: {},
180+
actions: [
181+
{
182+
name: 'import_users',
183+
label: 'Import',
184+
type: 'api',
185+
params: [{ name: 'csv', type: 'text' }],
186+
resultDialog: { title: 'Done', fields: [{ path: 'summary.added', label: 'Added' }, table] },
187+
preflight: { read: { url: '/api/v1/x' }, fields: [table] },
188+
},
189+
],
190+
},
191+
],
192+
};
193+
const entries = collectExpectedEntries(stack, { warnedGroups: new Set() });
194+
const root = ['objects', 'sys_user', '_actions', 'import_users'];
195+
const blockKeys = (block: string) =>
196+
entries
197+
.filter((e) => root.every((seg, i) => e.path[i] === seg) && e.path[root.length] === block)
198+
.map((e) => e.path.slice(root.length));
199+
200+
it('lists a key per labelled column beside the field key, an unlabelled column none', () => {
201+
expect(blockKeys('resultDialog')).toEqual([
202+
// The optional prose slots are listed whether authored or not.
203+
['resultDialog', 'title'],
204+
['resultDialog', 'description'],
205+
['resultDialog', 'acknowledge'],
206+
['resultDialog', 'fields', 'summary.added'],
207+
['resultDialog', 'fields', 'rows'],
208+
['resultDialog', 'columns', 'rows', 'email'],
209+
['resultDialog', 'columns', 'rows', 'error.message'],
210+
]);
211+
const email = entries.find((e) => e.path.join('\u0000') === [...root, 'resultDialog', 'columns', 'rows', 'email'].join('\u0000'));
212+
expect(email).toMatchObject({ sourceValue: 'Email', inline: 'Email', source: 'action', objectName: 'sys_user' });
213+
const reason = entries.find((e) => e.path.join('\u0000') === [...root, 'resultDialog', 'columns', 'rows', 'error.message'].join('\u0000'));
214+
expect(reason?.inlineLocales).toEqual({ en: 'Not added because', 'zh-CN': '未添加的原因' });
215+
});
216+
217+
it('lists the same column keys under a preflight table field', () => {
218+
expect(blockKeys('preflight')).toEqual([
219+
['preflight', 'fields', 'rows'],
220+
['preflight', 'columns', 'rows', 'email'],
221+
['preflight', 'columns', 'rows', 'error.message'],
222+
]);
223+
});
224+
});

‎packages/lint/src/i18n-walk.ts‎

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,15 @@
9797
* objects.<name>._actions.<action>.params.<param>.options.<value>
9898
* objects.<name>._actions.<action>.resultDialog.title / .description / .acknowledge
9999
* objects.<name>._actions.<action>.resultDialog.fields.<path>
100+
* objects.<name>._actions.<action>.resultDialog.columns.<path>.<column_path>
100101
* objects.<name>._actions.<action>.preflight.fields.<path>
102+
* objects.<name>._actions.<action>.preflight.columns.<path>.<column_path>
101103
* globalActions.<action>.label / .description / .confirmText / .successMessage
102104
* / .disabledReason / .submitText (beside a non-empty `params`)
103105
* / .cancelText (beside `confirmText` or a non-empty `params`)
104106
* globalActions.<action>.outcomeMessages.<outcome>
105107
* globalActions.<action>.params.<param>.* / .resultDialog.* / .preflight.fields.<path>
108+
* / .preflight.columns.<path>.<column_path>
106109
* (same shape as object actions)
107110
* apps.<app>.label / .description
108111
* apps.<app>.navigation.<id>.label
@@ -767,8 +770,9 @@ function pushActionParams(
767770
}
768771

769772
/**
770-
* Emit `resultDialog.{title,description,acknowledge}` and
771-
* `resultDialog.fields.<path>` entries under an action's translation root.
773+
* Emit `resultDialog.{title,description,acknowledge}`,
774+
* `resultDialog.fields.<path>` and `resultDialog.columns.<path>.<column_path>`
775+
* entries under an action's translation root.
772776
* Mirrors `ActionResultDialogTranslationSchema` in @objectstack/spec and the
773777
* client-side `actionResultDialog` resolver. Field entries are keyed by the
774778
* LITERAL result-field path (`"user.email"`) — the dot stays inside a single
@@ -814,10 +818,37 @@ function pushActionResultDialog(
814818
if (!field || typeof field !== 'object') continue;
815819
if (typeof field.path !== 'string' || field.path.length === 0) continue;
816820
pushEntry(out, [...base, 'fields', field.path], field.label, kind, { objectName });
821+
pushAnswerTableColumns(out, base, field, kind, objectName);
817822
}
818823
}
819824
}
820825

826+
/**
827+
* [#34652] Emit `columns.<path>.<column_path>` entries beside `fields` under an
828+
* answer block's root (`…resultDialog` or `…preflight`) — one per labelled
829+
* column of a `format: 'table'` field. Both levels are keyed by the LITERAL
830+
* path (`"error.message"` is one segment), the address
831+
* `ActionResultDialogTranslationSchema.columns` declares and
832+
* `resolveActionResultDialog` / `resolveActionPreflight` read. A column with
833+
* no `label` draws its `path` as the header and gets no key, as a field row
834+
* with no `label` gets none; the format is not re-judged here — a `columns`
835+
* list beside any other format is refused at parse.
836+
*/
837+
function pushAnswerTableColumns(
838+
out: ExpectedEntry[],
839+
blockRoot: string[],
840+
field: any,
841+
kind: ExpectedEntry['source'],
842+
objectName?: string,
843+
): void {
844+
if (!Array.isArray(field.columns)) return;
845+
for (const column of field.columns) {
846+
if (!column || typeof column !== 'object') continue;
847+
if (typeof column.path !== 'string' || column.path.length === 0) continue;
848+
pushEntry(out, [...blockRoot, 'columns', field.path, column.path], column.label, kind, { objectName });
849+
}
850+
}
851+
821852
/**
822853
* Emit `preflight.fields.<path>` entries under an action's translation root —
823854
* one per field the action's `preflight.fields[]` declares, keyed by the
@@ -840,6 +871,7 @@ function pushActionPreflight(
840871
if (!field || typeof field !== 'object') continue;
841872
if (typeof field.path !== 'string' || field.path.length === 0) continue;
842873
pushEntry(out, [...actionRoot, 'preflight', 'fields', field.path], field.label, kind, { objectName });
874+
pushAnswerTableColumns(out, [...actionRoot, 'preflight'], field, kind, objectName);
843875
}
844876
}
845877

0 commit comments

Comments
 (0)