From b716d627e78dc144a8b9055b17147602e7f124a5 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 19:35:23 +0000 Subject: [PATCH 01/16] feat(spec): mappings translation group and translateMapping Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-Authored-By: Claude --- packages/spec/src/data/mapping.zod.ts | 2 +- packages/spec/src/system/i18n-resolver.ts | 68 +++++++++++++++++++++ packages/spec/src/system/translation.zod.ts | 53 ++++++++++++---- 3 files changed, 109 insertions(+), 14 deletions(-) diff --git a/packages/spec/src/data/mapping.zod.ts b/packages/spec/src/data/mapping.zod.ts index 8a5311cdef9..e313c815d22 100644 --- a/packages/spec/src/data/mapping.zod.ts +++ b/packages/spec/src/data/mapping.zod.ts @@ -409,7 +409,7 @@ export const MappingSchema = lazySchema(() => strictObject({ }, { /** Identity */ name: SnakeCaseIdentifierSchema.describe('Mapping unique name (lowercase snake_case)'), - label: z.string().optional(), + label: z.string().optional().describe('Display label, shown where the mapping is offered by name (the import wizard); translated per locale at `mappings..label` in the translation bundle'), /** Scope */ sourceFormat: z.enum(['csv', 'json', 'xml', 'sql']).default('csv'), diff --git a/packages/spec/src/system/i18n-resolver.ts b/packages/spec/src/system/i18n-resolver.ts index 91c1a2f052b..67567bb7f02 100644 --- a/packages/spec/src/system/i18n-resolver.ts +++ b/packages/spec/src/system/i18n-resolver.ts @@ -2043,6 +2043,10 @@ const METADATA_DOCUMENT_TRANSLATORS: Record< // its sidebar from `GET /meta/book`, and the tree route translates the book // it resolves through this same table (`createMetaBookTreeAnswer`). book: translateBook, + // A named import mapping's label: the console's import wizard offers each + // mapping by label from `GET /meta/mapping`, so registering here is the + // whole wiring. + mapping: translateMapping, }; /** @@ -2977,6 +2981,70 @@ export function translateBook( }; } +// ──────────────────────────────────────────────────────────────────────────── +// Import mapping resolver (label) +// ──────────────────────────────────────────────────────────────────────────── + +/** Minimal import-mapping shape consumed by {@link translateMapping}. */ +export interface MappingLike { + name: string; + label?: string; + [key: string]: any; +} + +function lookupMappingLabel( + bundle: TranslationBundle | undefined, + mappingName: string, + opts?: ResolveOptions, +): string | undefined { + if (!bundle) return undefined; + for (const code of localeChain(opts)) { + const candidate = pickData(bundle, code)?.mappings?.[mappingName]?.label; + if (typeof candidate === 'string' && candidate.length > 0) return candidate; + } + return undefined; +} + +/** + * Apply the active locale to an import-mapping metadata document — its + * `label` against `mappings..label`. The input document is not mutated; + * it comes back as the same reference when the bundle carries no label for + * it, and then the authored label stands. + * + * Registered in {@link METADATA_DOCUMENT_TRANSLATORS}, so the REST boundary + * localizes every served mapping (`GET /meta/mapping`, list and item) — the + * list the console's import wizard offers by name in its saved-mapping + * selector. A mapping's `fieldMapping` is not copy (column names and field + * names) and is left alone. + * + * ## An override's own label — ADR-0146 D2 + * + * A mapping is overridable from its base's paired `.custom` package, and the + * catalog translates the BASE's label. So the label follows + * {@link labelCatalogs}' order, judged against + * {@link TranslateDocumentOptions.packagedBase} by + * {@link valueOverridesPackagedBase}: a label the override changed reads only + * the pair's translations and otherwise keeps its own text; a label it left + * alone takes the pair's translation, then the base's. No base supplied: the + * catalog applies. + */ +export function translateMapping( + doc: T, + bundle: TranslationBundle | undefined, + opts?: TranslateDocumentOptions, +): T { + if (!doc || typeof doc !== 'object') return doc; + const mappingName = doc.name; + const catalogs = labelCatalogs(bundle, opts); + if (typeof mappingName !== 'string' || mappingName.length === 0 || !catalogs.unchanged) return doc; + const base = asRecord(opts?.packagedBase); + const label = lookupMappingLabel( + catalogFor(catalogs, valueOverridesPackagedBase(base, 'label', doc.label)), mappingName, opts, + ); + if (label === undefined) return doc; + return { ...doc, label }; +} + // ──────────────────────────────────────────────────────────────────────────── // Report metadata resolver (label + description) // ──────────────────────────────────────────────────────────────────────────── diff --git a/packages/spec/src/system/translation.zod.ts b/packages/spec/src/system/translation.zod.ts index 33b6bcbd203..9b74b27fb5c 100644 --- a/packages/spec/src/system/translation.zod.ts +++ b/packages/spec/src/system/translation.zod.ts @@ -994,10 +994,10 @@ const PER_APP_SETTINGS_PLATFORM_ONLY = + '(`@objectstack/service-settings`\'s `settingsBuiltinTranslations`, typed ' + '`PlatformTranslationData`); a key it does not translate falls back to the manifest\'s own ' + 'literal, so correct it there rather than filling the gap from an application. For an ' - + 'application\'s own copy use the sixteen groups this bundle does declare, in the order it ' + + 'application\'s own copy use the seventeen groups this bundle does declare, in the order it ' + "declares them — 'objects', 'picklists', 'apps', 'messages', 'globalActions', 'dashboards', " + "'datasets', 'reports', 'pages', 'flows', 'hooks', 'positions', 'permissions', 'books', " - + "'metadataForms', 'settingsCommon'. " + + "'mappings', 'metadataForms', 'settingsCommon'. " + "Note the last one: 'settingsCommon' IS " + 'on this face, so the Settings UI shell strings an application may translate (the source ' + 'badges, under `settingsCommon.sourceLabels`) are NOT what is being refused here — only the ' @@ -1039,7 +1039,7 @@ const ITEM_SETTINGS_PLATFORM_ONLY = + '(`@objectstack/service-settings`\'s `settingsBuiltinTranslations`, typed ' + '`PlatformTranslationData`); a key it does not translate falls back to the manifest\'s own ' + 'literal, so correct it there rather than overriding it from an application. For an ' - + 'application\'s own copy use the groups this item does declare — the same sixteen a per-app ' + + 'application\'s own copy use the groups this item does declare — the same seventeen a per-app ' + "bundle declares, 'settingsCommon' among them: the Settings UI shell strings an application " + 'may translate (the source badges, under `settingsCommon.sourceLabels`) are NOT what is being ' + "refused here — only the per-namespace manifest copy under 'settings' is. " @@ -1078,12 +1078,12 @@ const ITEM_TRANSLATION_KEY_GUIDANCE: Record = { */ /** * The translation groups an APPLICATION may author, as a shape rather than a - * schema. Sixteen groups — the seventeenth, `settings`, is platform-only and lives in + * schema. Seventeen groups — the eighteenth, `settings`, is platform-only and lives in * {@link platformSettingsShape}. * * Three schemas need exactly these keys: {@link TranslationDataSchema} (one - * entry of a per-app file-authored bundle — these sixteen and no more), - * {@link PlatformTranslationDataSchema} (these sixteen plus `settings`) and + * entry of a per-app file-authored bundle — these seventeen and no more), + * {@link PlatformTranslationDataSchema} (these seventeen plus `settings`) and * {@link TranslationItemSchema} (the registered `translation` metadata type — * the per-app face plus `locale`, its identity keys and the ADR-0010 * envelope; it carried the platform face's `settings` too until #19620). The item used to @@ -2303,6 +2303,33 @@ const appTranslationDataShape = () => ({ })).optional().describe('Group (section) translations keyed by the group `key`'), })).optional().describe('Doc-book translations keyed by book name'), + /** + * Import-mapping translations keyed by mapping name (`Mapping.name`, + * `data/mapping.zod.ts`, the stack's `mappings[]`). + * + * mappings..label → the mapping's own `label` + * + * A named import mapping is offered by name in the console's import wizard + * (the saved-mapping selector and the hints that name the chosen mapping), + * so its label is end-user copy. Overlaid by `translateMapping` + * (`i18n-resolver.ts`) on every served `mapping` document + * (`GET /meta/mapping`, the list the wizard reads). The face stops at the + * one string a mapping authors for a reader: its `fieldMapping` entries are + * column names and field names, and the target fields' labels translate + * under `objects..fields`. + */ + mappings: z.record(z.string(), strictObject({ + surface: 'this import mapping translation', + history: TRANSLATION_HISTORY, + aliases: { name: 'label', title: 'label' }, + guidance: { + description: 'an import mapping declares no `description` — only its `label` is shown to a reader, so `label` is the one key to translate', + fieldMapping: 'a mapping\'s `fieldMapping` holds column and field names, not copy — translate a target field\'s label under `objects..fields..label`', + }, + }, { + label: z.string().optional().describe("Translated import mapping label — overlays the mapping's own `label`"), + })).optional().describe('Import-mapping translations keyed by mapping name'), + /** * Translations for **metadata-type configuration forms** — the forms * used by admins to author objects, fields, agents, flows, etc. in the @@ -2562,10 +2589,10 @@ const platformSettingsShape = () => ({ * One locale of a PER-APP translation bundle — `stack.translations`, and * everything {@link defineTranslationBundle} builds. * - * Sixteen groups: every group the platform bundle declares EXCEPT `settings`, + * Seventeen groups: every group the platform bundle declares EXCEPT `settings`, * which is platform-only and is refused here by name with * {@link PER_APP_SETTINGS_PLATFORM_ONLY} as the remedy. See - * {@link PlatformTranslationDataSchema} for the seventeen-group face and for why + * {@link PlatformTranslationDataSchema} for the eighteen-group face and for why * the two are separate namespaces. */ export const TranslationDataSchema = lazySchema(() => strictObject({ @@ -2576,7 +2603,7 @@ export const TranslationDataSchema = lazySchema(() => strictObject({ // `settings`, and an alias prescribing a key the shape rejects is a // suggestion the author cannot take (the `alias-integrity` audit judges // exactly that). Both spellings are answered by `guidance` above instead. - aliases: { object: 'objects', fields: 'objects', app: 'apps', page: 'pages', dashboard: 'dashboards', dataset: 'datasets', report: 'reports', picklist: 'picklists', flow: 'flows', hook: 'hooks', position: 'positions', permission: 'permissions', permissionSets: 'permissions', book: 'books', message: 'messages', strings: 'messages', labels: 'messages', actions: 'globalActions' }, + aliases: { object: 'objects', fields: 'objects', app: 'apps', page: 'pages', dashboard: 'dashboards', dataset: 'datasets', report: 'reports', picklist: 'picklists', flow: 'flows', hook: 'hooks', position: 'positions', permission: 'permissions', permissionSets: 'permissions', book: 'books', mapping: 'mappings', message: 'messages', strings: 'messages', labels: 'messages', actions: 'globalActions' }, // `locale` lives on the ITEM, not on a bundle entry (the bundle keys ARE the // locales). Naming it keeps the suggestion useful for an author who moved a // `translation` item into a bundle and left the field behind. @@ -2586,7 +2613,7 @@ export const TranslationDataSchema = lazySchema(() => strictObject({ export type TranslationData = z.input; /** - * One locale of a PLATFORM translation bundle — the seventeen groups, `settings` + * One locale of a PLATFORM translation bundle — the eighteen groups, `settings` * included. * * The platform's own bundles are code, not authored metadata @@ -2621,7 +2648,7 @@ export const PlatformTranslationDataSchema = lazySchema(() => strictObject({ surface: 'this locale of the platform translation bundle', history: TRANSLATION_HISTORY, guidance: TRANSLATION_KEY_GUIDANCE, - aliases: { object: 'objects', fields: 'objects', app: 'apps', page: 'pages', dashboard: 'dashboards', dataset: 'datasets', report: 'reports', picklist: 'picklists', flow: 'flows', hook: 'hooks', position: 'positions', permission: 'permissions', permissionSets: 'permissions', book: 'books', setting: 'settings', message: 'messages', strings: 'messages', labels: 'messages', actions: 'globalActions' }, + aliases: { object: 'objects', fields: 'objects', app: 'apps', page: 'pages', dashboard: 'dashboards', dataset: 'datasets', report: 'reports', picklist: 'picklists', flow: 'flows', hook: 'hooks', position: 'positions', permission: 'permissions', permissionSets: 'permissions', book: 'books', mapping: 'mappings', setting: 'settings', message: 'messages', strings: 'messages', labels: 'messages', actions: 'globalActions' }, extraKeys: ['locale'], }, { ...appTranslationDataShape(), @@ -2830,7 +2857,7 @@ export type TranslationConfig = z.input; * to whoever — or whatever — authored it. * * `settings` is NOT on this door (#19620, ruling batch #210 item 2 letter B): - * the item takes the PER-APP face, the same sixteen groups as + * the item takes the PER-APP face, the same seventeen groups as * {@link TranslationDataSchema}, and refuses `settings` (and the singular * `setting`) by name with {@link ITEM_SETTINGS_PLATFORM_ONLY} as the remedy. * The file door and the item door are two authoring surfaces for one app @@ -2869,7 +2896,7 @@ export const TranslationItemSchema = lazySchema(() => strictObject({ // this door no longer declares `settings`, and an alias prescribing a key // the shape rejects is a suggestion the author cannot take. Both spellings // are answered by `guidance` above instead. - aliases: { object: 'objects', app: 'apps', page: 'pages', dataset: 'datasets', report: 'reports', picklist: 'picklists', flow: 'flows', hook: 'hooks', position: 'positions', permission: 'permissions', permissionSets: 'permissions', book: 'books', message: 'messages', strings: 'messages', labels: 'messages', actions: 'globalActions', lang: 'locale', language: 'locale' }, + aliases: { object: 'objects', app: 'apps', page: 'pages', dataset: 'datasets', report: 'reports', picklist: 'picklists', flow: 'flows', hook: 'hooks', position: 'positions', permission: 'permissions', permissionSets: 'permissions', book: 'books', mapping: 'mappings', message: 'messages', strings: 'messages', labels: 'messages', actions: 'globalActions', lang: 'locale', language: 'locale' }, }, { ...appTranslationDataShape(), locale: LocaleSchema.describe('BCP-47 locale this item translates (e.g. "zh-CN")'), From 16753ac20f8080548a4b87ecc7be965bbfde0d27 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 19:36:53 +0000 Subject: [PATCH 02/16] test(spec): mappings group doors, translateMapping and the ADR-0146 D2 precedence row Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-Authored-By: Claude --- packages/spec/authorable-surface/system.json | 4 + packages/spec/src/system/i18n-mapping.test.ts | 110 ++++++++++++++++++ .../spec/src/system/i18n-resolver.test.ts | 18 ++- 3 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 packages/spec/src/system/i18n-mapping.test.ts diff --git a/packages/spec/authorable-surface/system.json b/packages/spec/authorable-surface/system.json index af65c7d8aec..cf1759853e0 100644 --- a/packages/spec/authorable-surface/system.json +++ b/packages/spec/authorable-surface/system.json @@ -922,6 +922,7 @@ "system/PlatformTranslationData:flows", "system/PlatformTranslationData:globalActions", "system/PlatformTranslationData:hooks", + "system/PlatformTranslationData:mappings", "system/PlatformTranslationData:messages", "system/PlatformTranslationData:metadataForms", "system/PlatformTranslationData:objects", @@ -1062,6 +1063,7 @@ "system/ServedTranslationData:flows", "system/ServedTranslationData:globalActions", "system/ServedTranslationData:hooks", + "system/ServedTranslationData:mappings", "system/ServedTranslationData:messages", "system/ServedTranslationData:objects", "system/ServedTranslationData:pages", @@ -1371,6 +1373,7 @@ "system/TranslationData:flows", "system/TranslationData:globalActions", "system/TranslationData:hooks", + "system/TranslationData:mappings", "system/TranslationData:messages", "system/TranslationData:metadataForms", "system/TranslationData:objects", @@ -1403,6 +1406,7 @@ "system/TranslationItem:hooks", "system/TranslationItem:label", "system/TranslationItem:locale", + "system/TranslationItem:mappings", "system/TranslationItem:messages", "system/TranslationItem:metadataForms", "system/TranslationItem:name", diff --git a/packages/spec/src/system/i18n-mapping.test.ts b/packages/spec/src/system/i18n-mapping.test.ts new file mode 100644 index 00000000000..1ca7c8dff27 --- /dev/null +++ b/packages/spec/src/system/i18n-mapping.test.ts @@ -0,0 +1,110 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. +// +// `mappings..label` — a named import mapping's translation group, and +// the translator that overlays it on the served `mapping` document. +// +// Before this group existed a shipped import mapping showed its authored +// label in every locale: the console's import wizard offers mappings by label +// (`GET /meta/mapping`), the label is a plain string on the mapping, and the +// bundle had no key for it. + +import { describe, it, expect } from 'vitest'; +import { + TranslationDataSchema, + TranslationItemSchema, + PlatformTranslationDataSchema, + ServedTranslationDataSchema, + type TranslationBundle, +} from './translation.zod'; +import { translateMetadataDocument, translateMapping, TRANSLATABLE_METADATA_TYPES } from './i18n-resolver'; +// The fixture is PARSED by the authoring schema rather than hand-shaped, so a +// translator reading a member the schema does not carry cannot pass here. +import { MappingSchema } from '../data/mapping.zod'; + +const mapping = () => MappingSchema.parse({ + name: 'weekly_supply_import', + label: 'Weekly Supply Import (CSV)', + sourceFormat: 'csv', + targetObject: 'supply_plan', + fieldMapping: [ + { source: 'Week', target: 'supply_week' }, + { source: 'Reserved', target: 'domestic_reserved_qty' }, + ], +}) as any; + +const bundle: TranslationBundle = { + 'zh-CN': { mappings: { weekly_supply_import: { label: '每周供应导入(CSV)' } } }, +}; + +describe('TranslationDataSchema — mappings', () => { + it('opens at every door — bundle entry, platform bundle, served document and registered item', () => { + expect(TranslationDataSchema.safeParse(bundle['zh-CN']).success).toBe(true); + expect(PlatformTranslationDataSchema.safeParse(bundle['zh-CN']).success).toBe(true); + expect(ServedTranslationDataSchema.safeParse(bundle['zh-CN']).success).toBe(true); + expect(TranslationItemSchema.safeParse({ locale: 'zh-CN', ...bundle['zh-CN'] }).success).toBe(true); + }); + + it('closes the face at the mapping\'s `label`', () => { + const result = TranslationDataSchema.safeParse({ mappings: { weekly_supply_import: { icon: 'csv' } } }); + expect(result.success).toBe(false); + expect(result.error!.issues.map((i) => i.code)).toContain('unrecognized_keys'); + }); + + it('renames the singular and the label\'s aliases onto the declared keys', () => { + expect(() => TranslationDataSchema.parse({ mapping: { m: { label: 'x' } } })).toThrow(/mappings/); + expect(() => TranslationDataSchema.parse({ mappings: { m: { title: 'x' } } })).toThrow(/label/); + expect(() => TranslationItemSchema.parse({ locale: 'zh-CN', mapping: { m: { label: 'x' } } })).toThrow(/mappings/); + }); + + it('names why `description` and `fieldMapping` have no key, rather than suggesting one', () => { + const description = TranslationDataSchema.safeParse({ mappings: { m: { description: 'x' } } }); + expect(description.success).toBe(false); + expect(JSON.stringify(description.error!.issues)).toContain('declares no `description`'); + const fields = TranslationDataSchema.safeParse({ mappings: { m: { fieldMapping: {} } } }); + expect(fields.success).toBe(false); + expect(JSON.stringify(fields.error!.issues)).toContain('objects..fields..label'); + }); +}); + +describe('translateMapping', () => { + it('is registered in the dispatch table, so the REST boundary follows', () => { + // `TRANSLATABLE_METADATA_TYPES` is DERIVED from the dispatch table and + // `@objectstack/rest` reads it: `GET /meta/mapping` (list and item) is + // localized with no further wiring. + expect(TRANSLATABLE_METADATA_TYPES.has('mapping')).toBe(true); + }); + + it('a zh-CN reader gets the translated label; identity and field mapping ride through', () => { + const doc = mapping(); + const out = translateMetadataDocument('mapping', doc, bundle, { locale: 'zh-CN' }) as any; + expect(out.label).toBe('每周供应导入(CSV)'); + expect(out.name).toBe('weekly_supply_import'); + expect(out.fieldMapping).toBe(doc.fieldMapping); + }); + + it('an en-US reader is unchanged — the same reference, the authored label', () => { + const doc = mapping(); + expect(translateMapping(doc, bundle, { locale: 'en-US' })).toBe(doc); + expect(translateMapping(doc, undefined, { locale: 'zh-CN' })).toBe(doc); + }); + + it('reads only its own mapping\'s entry, and applies the BCP-47 ladder and the fallback chain', () => { + const other = MappingSchema.parse({ name: 'other_import', label: 'Other', targetObject: 'supply_plan', fieldMapping: [] }) as any; + expect(translateMapping(other, bundle, { locale: 'zh-CN' })).toBe(other); + expect((translateMapping(mapping(), bundle, { locale: 'zh' }) as any).label).toBe('每周供应导入(CSV)'); + expect((translateMapping(mapping(), bundle, { locale: 'fr-FR', fallbackChain: ['zh-CN'] }) as any).label).toBe('每周供应导入(CSV)'); + }); + + it('an empty translated label is no translation — the authored label stands', () => { + const doc = mapping(); + const empty: TranslationBundle = { 'zh-CN': { mappings: { weekly_supply_import: { label: '' } } } }; + expect(translateMapping(doc, empty, { locale: 'zh-CN' })).toBe(doc); + }); + + it('does not mutate the input', () => { + const doc = mapping(); + const before = JSON.parse(JSON.stringify(doc)); + translateMapping(doc, bundle, { locale: 'zh-CN' }); + expect(doc).toEqual(before); + }); +}); diff --git a/packages/spec/src/system/i18n-resolver.test.ts b/packages/spec/src/system/i18n-resolver.test.ts index 217bdc8bd07..858e9ecbcad 100644 --- a/packages/spec/src/system/i18n-resolver.test.ts +++ b/packages/spec/src/system/i18n-resolver.test.ts @@ -6462,6 +6462,7 @@ describe('resolveMetadataFormSchemaTitles — bundle labels overlaid as JSON Sch import { type TranslateDocumentOptions } from './i18n-resolver'; import { ReportSchema } from '../ui/report.zod'; import { BookSchema } from './book.zod'; +import { MappingSchema } from '../data/mapping.zod'; describe("label precedence on an overridden item — the pair's translation, then the override's label, then the base's translation (ADR-0146 D2)", () => { /** One translatable string of a served document, and the bundle address that translates it. */ @@ -6636,10 +6637,23 @@ describe("label precedence on an overridden item — the pair's translation, the ['books', 'crm_manual', 'groups', 'start', 'label'], '快速上手'), ], }, + // An import mapping is an ADR-0146 D2 listed overridable type too, and its + // one translatable string is its label. + mapping: { + base: () => MappingSchema.parse({ + name: 'crm_lead_feed', + label: 'Lead feed', + targetObject: 'crm_lead', + fieldMapping: [{ source: 'Company', target: 'company' }], + }), + slots: [ + slot('label', (d) => d.label, (d, t) => { d.label = t; }, ['mappings', 'crm_lead_feed', 'label'], '线索导入'), + ], + }, }; - it('covers every document translator the ruling names — all eight types', () => { - expect(Object.keys(CASES).sort()).toEqual(['app', 'book', 'dashboard', 'dataset', 'object', 'page', 'report', 'view']); + it('covers every document translator the ruling names — all nine types', () => { + expect(Object.keys(CASES).sort()).toEqual(['app', 'book', 'dashboard', 'dataset', 'mapping', 'object', 'page', 'report', 'view']); for (const type of Object.keys(CASES)) expect(TRANSLATABLE_METADATA_TYPES.has(type), type).toBe(true); }); From b9d00c0697d783c3e3c3feef85f12bd8a3d9826d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 19:37:27 +0000 Subject: [PATCH 03/16] chore(spec): seed the mappings translation group live in the liveness ledger Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-Authored-By: Claude --- packages/spec/liveness/state-counts/translation.md | 2 +- packages/spec/liveness/translation.json | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/spec/liveness/state-counts/translation.md b/packages/spec/liveness/state-counts/translation.md index ed523cd674d..60bf69c6bd3 100644 --- a/packages/spec/liveness/state-counts/translation.md +++ b/packages/spec/liveness/state-counts/translation.md @@ -12,4 +12,4 @@ committed anywhere: `check:liveness` sums the shards when it reads them. | Type | live | exp | elsewhere | dead | planned | classified | |---|---|---|---|---|---|---| -| `translation` | 46 | 0 | 0 | 0 | 2 | 48 | +| `translation` | 47 | 0 | 0 | 0 | 2 | 49 | diff --git a/packages/spec/liveness/translation.json b/packages/spec/liveness/translation.json index 2da338a1e24..66e10e7c2fe 100644 --- a/packages/spec/liveness/translation.json +++ b/packages/spec/liveness/translation.json @@ -388,6 +388,20 @@ } } }, + "mappings": { + "status": "live", + "verifiedAt": "2026-11-17", + "evidence": "packages/spec/src/system/i18n-resolver.ts#translateMapping (`mappings..label`, registered in METADATA_DOCUMENT_TRANSLATORS); packages/rest/src/meta-item-read-gate.ts#translateMetaList (the /meta list read that applies it per request locale)", + "note": "Seeded LIVE with its reader in the same change (the datasets precedent): a served `mapping` document is localized at the REST boundary, list and item, and `GET /meta/mapping` is what the console's import wizard offers by label in its saved-mapping selector. The face stops at the one string a mapping authors for a reader; its `fieldMapping` is column and field names.", + "children": { + "label": { + "status": "live", + "verifiedAt": "2026-11-17", + "evidence": "packages/spec/src/system/i18n-resolver.ts#lookupMappingLabel (`mappings..label`, read by translateMapping)", + "note": "Overlays the served mapping's own `label`." + } + } + }, "metadataForms": { "status": "live", "verifiedAt": "2026-08-28", From d3e28f4ac35a6437f28adf0686eac28416b9956f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 19:45:53 +0000 Subject: [PATCH 04/16] chore(spec): regenerate api-surface, export-origins, references docs and the strictness ledger counts Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-Authored-By: Claude --- content/docs/references/api/protocol.mdx | 1 + content/docs/references/data/mapping.mdx | 2 +- .../docs/references/system/translation.mdx | 28 +++++++++++++++++++ .../system.md | 2 +- packages/spec/api-surface/system.json | 2 ++ packages/spec/export-origins/system.json | 2 ++ 6 files changed, 35 insertions(+), 2 deletions(-) diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index af2a3808333..59e50ff8ec9 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1882,6 +1882,7 @@ The published metadata item body, opaque by ruling (1C). Shape is the item's own | **positions** | `Record` | optional | Position translations keyed by position name | | **permissions** | `Record` | optional | Permission-set translations keyed by permission-set name | | **books** | `Record }>` | optional | Doc-book translations keyed by book name | +| **mappings** | `Record` | optional | Import-mapping translations keyed by mapping name | | **settingsCommon** | `{ sourceLabels?: object }` | optional | Cross-namespace Settings UI strings | | **settings** | `Record; keys?: Record; … }>` | optional | Settings manifest translations keyed by namespace | diff --git a/content/docs/references/data/mapping.mdx b/content/docs/references/data/mapping.mdx index 9e9bc95663d..f14a3190a2c 100644 --- a/content/docs/references/data/mapping.mdx +++ b/content/docs/references/data/mapping.mdx @@ -43,7 +43,7 @@ const result = ImportFieldMappingSchema.parse(data); | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | | **name** | `string` | ✅ | Mapping unique name (lowercase snake_case) | -| **label** | `string` | optional | | +| **label** | `string` | optional | Display label, shown where the mapping is offered by name (the import wizard); translated per locale at `mappings..label` in the translation bundle | | **sourceFormat** | `Enum<'csv' \| 'json' \| 'xml' \| 'sql'>` | optional (default: `"csv"`) | | | **targetObject** | `string` | ✅ | Target Object Name | | **fieldMapping** | `{ source: string \| string[]; target: string \| string[]; transform?: Enum<'none' \| 'constant' \| 'lookup' \| 'split' \| 'join' \| 'javascript' \| 'map'>; params?: object }[]` | ✅ | | diff --git a/content/docs/references/system/translation.mdx b/content/docs/references/system/translation.mdx index 74ea9ae48be..8ffac79aeef 100644 --- a/content/docs/references/system/translation.mdx +++ b/content/docs/references/system/translation.mdx @@ -194,6 +194,7 @@ Platform translation data — the per-app groups plus the platform-only `setting | **positions** | `Record` | optional | Position translations keyed by position name | | **permissions** | `Record` | optional | Permission-set translations keyed by permission-set name | | **books** | `Record }>` | optional | Doc-book translations keyed by book name | +| **mappings** | `Record` | optional | Import-mapping translations keyed by mapping name | | **metadataForms** | `Record; fields?: Record }>` | optional | Translations for metadata-type configuration forms keyed by metadata type | | **settingsCommon** | `{ sourceLabels?: object }` | optional | Cross-namespace Settings UI strings | | **settings** | `Record; keys?: Record; … }>` | optional | Settings manifest translations keyed by namespace | @@ -324,6 +325,12 @@ Translation data for a single object | **description** | `string` | optional | Translated book description — overlays the book's own `description` | | **groups** | `Record` | optional | Group (section) translations keyed by the group `key` | +### Nested Shape: `PlatformTranslationData.mappings[string]` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **label** | `string` | optional | Translated import mapping label — overlays the mapping's own `label` | + ### Nested Shape: `PlatformTranslationData.metadataForms[string]` | Property | Type | Required | Description | @@ -375,6 +382,7 @@ Served translation data — the platform groups the browser reads, without the s | **positions** | `Record` | optional | Position translations keyed by position name | | **permissions** | `Record` | optional | Permission-set translations keyed by permission-set name | | **books** | `Record }>` | optional | Doc-book translations keyed by book name | +| **mappings** | `Record` | optional | Import-mapping translations keyed by mapping name | | **settingsCommon** | `{ sourceLabels?: object }` | optional | Cross-namespace Settings UI strings | | **settings** | `Record; keys?: Record; … }>` | optional | Settings manifest translations keyed by namespace | @@ -504,6 +512,12 @@ Translation data for a single object | **description** | `string` | optional | Translated book description — overlays the book's own `description` | | **groups** | `Record` | optional | Group (section) translations keyed by the group `key` | +### Nested Shape: `ServedTranslationData.mappings[string]` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **label** | `string` | optional | Translated import mapping label — overlays the mapping's own `label` | + ### Nested Shape: `ServedTranslationData.settingsCommon` | Property | Type | Required | Description | @@ -618,6 +632,7 @@ Per-app translation data for objects, apps, and UI messages | **positions** | `Record` | optional | Position translations keyed by position name | | **permissions** | `Record` | optional | Permission-set translations keyed by permission-set name | | **books** | `Record }>` | optional | Doc-book translations keyed by book name | +| **mappings** | `Record` | optional | Import-mapping translations keyed by mapping name | | **metadataForms** | `Record; fields?: Record }>` | optional | Translations for metadata-type configuration forms keyed by metadata type | | **settingsCommon** | `{ sourceLabels?: object }` | optional | Cross-namespace Settings UI strings | @@ -747,6 +762,12 @@ Translation data for a single object | **description** | `string` | optional | Translated book description — overlays the book's own `description` | | **groups** | `Record` | optional | Group (section) translations keyed by the group `key` | +### Nested Shape: `TranslationData.mappings[string]` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **label** | `string` | optional | Translated import mapping label — overlays the mapping's own `label` | + ### Nested Shape: `TranslationData.metadataForms[string]` | Property | Type | Required | Description | @@ -819,6 +840,7 @@ One locale of translations — the `translation` metadata type | **positions** | `Record` | optional | Position translations keyed by position name | | **permissions** | `Record` | optional | Permission-set translations keyed by permission-set name | | **books** | `Record }>` | optional | Doc-book translations keyed by book name | +| **mappings** | `Record` | optional | Import-mapping translations keyed by mapping name | | **metadataForms** | `Record; fields?: Record }>` | optional | Translations for metadata-type configuration forms keyed by metadata type | | **settingsCommon** | `{ sourceLabels?: object }` | optional | Cross-namespace Settings UI strings | | **locale** | `string` | ✅ | BCP-47 locale this item translates (e.g. "zh-CN") | @@ -959,6 +981,12 @@ Translation data for a single object | **description** | `string` | optional | Translated book description — overlays the book's own `description` | | **groups** | `Record` | optional | Group (section) translations keyed by the group `key` | +### Nested Shape: `TranslationItem.mappings[string]` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **label** | `string` | optional | Translated import mapping label — overlays the mapping's own `label` | + ### Nested Shape: `TranslationItem.metadataForms[string]` | Property | Type | Required | Description | diff --git a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md index 74a96565703..1df2ce1f97b 100644 --- a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md +++ b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/system.md @@ -19,4 +19,4 @@ hand-patch a number here** — fix the code or the verdict and regenerate. | Dir | Sites | |---|---| -| `system/` | 405 | +| `system/` | 406 | diff --git a/packages/spec/api-surface/system.json b/packages/spec/api-surface/system.json index 1ad698476d2..99f9f9fd61c 100644 --- a/packages/spec/api-surface/system.json +++ b/packages/spec/api-surface/system.json @@ -350,6 +350,7 @@ "METADATA_FORM_REGISTRY (const)", "MIGRATION_JOURNAL_KINDS (const)", "MIGRATION_JOURNAL_OBJECT (const)", + "MappingLike (interface)", "MaskingVisibilityRule (type)", "MaskingVisibilityRuleParsed (type)", "MaskingVisibilityRuleSchema (const)", @@ -938,6 +939,7 @@ "translateDashboard (function)", "translateDataset (function)", "translateFlow (function)", + "translateMapping (function)", "translateMetadataDocument (function)", "translateObject (function)", "translatePage (function)", diff --git a/packages/spec/export-origins/system.json b/packages/spec/export-origins/system.json index 3e6d27b4a2d..b0bb4bb7ae1 100644 --- a/packages/spec/export-origins/system.json +++ b/packages/spec/export-origins/system.json @@ -337,6 +337,7 @@ "METADATA_FORM_REGISTRY": "src/system/metadata-form-registry.ts#METADATA_FORM_REGISTRY (const)", "MIGRATION_JOURNAL_KINDS": "src/system/migration.zod.ts#MIGRATION_JOURNAL_KINDS (const)", "MIGRATION_JOURNAL_OBJECT": "src/system/migration.zod.ts#MIGRATION_JOURNAL_OBJECT (const)", + "MappingLike": "src/system/i18n-resolver.ts#MappingLike (interface)", "MaskingVisibilityRule": "src/system/security-context.zod.ts#MaskingVisibilityRule (type)", "MaskingVisibilityRuleParsed": "src/system/security-context.zod.ts#MaskingVisibilityRuleParsed (type)", "MaskingVisibilityRuleSchema": "src/system/security-context.zod.ts#MaskingVisibilityRuleSchema (const)", @@ -898,6 +899,7 @@ "translateDashboard": "src/system/i18n-resolver.ts#translateDashboard (function)", "translateDataset": "src/system/i18n-resolver.ts#translateDataset (function)", "translateFlow": "src/system/i18n-resolver.ts#translateFlow (function)", + "translateMapping": "src/system/i18n-resolver.ts#translateMapping (function)", "translateMetadataDocument": "src/system/i18n-resolver.ts#translateMetadataDocument (function)", "translateObject": "src/system/i18n-resolver.ts#translateObject (function)", "translatePage": "src/system/i18n-resolver.ts#translatePage (function)", From 5224fd5bd3c6aa34af0d77b2adb1253d68a3a0cc Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 19:47:25 +0000 Subject: [PATCH 05/16] feat(metadata-protocol,rest): an import mapping's packaged base feeds the ADR-0146 D2 label order Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs Co-Authored-By: Claude --- .../src/protocol-discovery-and-bases.ts | 14 +++++++++++--- packages/metadata-protocol/src/protocol.ts | 12 ++++++++++++ ...ol-custom-override-bare-slot-envelope.test.ts | 8 ++++---- ...dashboard-view-i18n-explicit-override.test.ts | 16 +++++++++++++--- packages/rest/src/meta-item-read-gate.ts | 9 ++++++--- 5 files changed, 46 insertions(+), 13 deletions(-) diff --git a/packages/metadata-protocol/src/protocol-discovery-and-bases.ts b/packages/metadata-protocol/src/protocol-discovery-and-bases.ts index fa6e75de9c2..2c4238cec23 100644 --- a/packages/metadata-protocol/src/protocol-discovery-and-bases.ts +++ b/packages/metadata-protocol/src/protocol-discovery-and-bases.ts @@ -15,7 +15,9 @@ * dataset, app and book packaged bases (`getPackagedPageBase`, * `getPackagedDatasetBase`, `getPackagedAppBase`, `getPackagedBookBase`), the * served-override reading of a served document (`servedOverrideBaseOf`) and the - * pair's own translations (`getPairTranslationBundle`). [#30504] The app base + * pair's own translations (`getPairTranslationBundle`). The import-mapping base + * (`getPackagedMappingBase`) joins them, the label `translateMapping` judges an + * override against. [#30504] The app base * carries the code layer's navigation contributions, folded once. * * A MOVE, not a redesign. `ProtocolDiscoveryAndBasesFacet` is a stateless facet over the host @@ -83,7 +85,7 @@ import type { ObjectStackProtocolImplementation } from './protocol.js'; * answers: the artifact item IS the packaged declaration for each (none has an * extension fold, unlike the object). */ -export type PackagedArtifactBaseType = 'dashboard' | 'view' | 'report' | 'page' | 'dataset' | 'app' | 'book'; +export type PackagedArtifactBaseType = 'dashboard' | 'view' | 'report' | 'page' | 'dataset' | 'app' | 'book' | 'mapping'; export class ProtocolDiscoveryAndBasesFacet { /** The body of `ObjectStackProtocolImplementation#getProjectId`; the method's docblock there is its contract. */ @@ -920,6 +922,11 @@ export class ProtocolDiscoveryAndBasesFacet { return host.packagedArtifactBase('book', name); } + /** The body of `ObjectStackProtocolImplementation#getPackagedMappingBase`; the method's docblock there is its contract. */ + static getPackagedMappingBase(host: Pick, name: string): unknown { + return host.packagedArtifactBase('mapping', name); + } + /** The body of `ObjectStackProtocolImplementation#servedOverrideBaseOf`; the method's docblock there is its contract. */ static servedOverrideBaseOf(type: string, document: unknown): string | undefined { return servedOverrideBaseOf(type, document); @@ -1056,7 +1063,8 @@ export class ProtocolDiscoveryAndBasesFacet { * The one body behind {@link getPackagedDashboardBase}, * {@link getPackagedViewBase}, {@link getPackagedReportBase} and * [#30062] {@link getPackagedPageBase}, {@link getPackagedDatasetBase}, - * {@link getPackagedAppBase} and {@link getPackagedBookBase}: + * {@link getPackagedAppBase}, {@link getPackagedBookBase} and + * {@link getPackagedMappingBase}: * {@link lookupArtifactItem}, and nothing wider, so only an item whose * `_packageId` marks a genuine code package answers, and an overlay * hydrated under the plain registry key never does. diff --git a/packages/metadata-protocol/src/protocol.ts b/packages/metadata-protocol/src/protocol.ts index ebfaff50fe1..218ac055d25 100644 --- a/packages/metadata-protocol/src/protocol.ts +++ b/packages/metadata-protocol/src/protocol.ts @@ -3049,6 +3049,18 @@ export class ObjectStackProtocolImplementation implements return ProtocolDiscoveryAndBasesFacet.getPackagedBookBase(protocolHost(this), name); } + /** + * The PACKAGED (code-layer) declaration of an IMPORT MAPPING, the fact + * `translateMapping` compares the served label against + * (`mappings..label`): a label a `.custom` override changed reads + * only the pair's translations, one it left alone reads the catalog + * (ADR-0146 D2). The mapping twin of {@link getPackagedBookBase}, + * answered the same way. Returns `undefined` on the same uncertainties. + */ + getPackagedMappingBase(name: string): unknown { + return ProtocolDiscoveryAndBasesFacet.getPackagedMappingBase(protocolHost(this), name); + } + /** * [#30062, ADR-0146 D2] The base package a SERVED metadata document is the * declared override of, or `undefined` when it is none — read off the diff --git a/packages/objectql/src/protocol-custom-override-bare-slot-envelope.test.ts b/packages/objectql/src/protocol-custom-override-bare-slot-envelope.test.ts index 8369474f7d3..a237dc490d7 100644 --- a/packages/objectql/src/protocol-custom-override-bare-slot-envelope.test.ts +++ b/packages/objectql/src/protocol-custom-override-bare-slot-envelope.test.ts @@ -610,9 +610,9 @@ async function boot2(environmentId: string | undefined, type: string, name: stri * hydration, the pair through its ensure door, the override through Studio's * draft save and publish): * - * - the PACKAGED base of a page, dataset, app and book + * - the PACKAGED base of a page, dataset, app, book and import mapping * (`getPackagedPageBase`, `getPackagedDatasetBase`, `getPackagedAppBase`, - * `getPackagedBookBase`) answers the base's own item while the pair's + * `getPackagedBookBase`, `getPackagedMappingBase`) answers the base's own item while the pair's * override is served, at once and after a restart, with and without a * metadata service — never the override it is compared against; * - the served override names its base (`servedOverrideBaseOf`), the base's @@ -624,10 +624,10 @@ async function boot2(environmentId: string | undefined, type: string, name: stri const PAIR_TRANSLATION = 'showcase_custom_zh_cn'; /** The `zh-CN` text each type's catalog group carries, keyed by the item's name. */ const zhGroup = (type: string, name: string, label: string): Record => { - const group = ({ page: 'pages', app: 'apps', dataset: 'datasets', book: 'books' } as Record)[type]; + const group = ({ page: 'pages', app: 'apps', dataset: 'datasets', book: 'books', mapping: 'mappings' } as Record)[type]; return { [group]: { [name]: { label } } }; }; -const LABEL_ORDER_TYPES = SEALED_TYPES.filter((t) => ['page', 'app', 'dataset', 'book'].includes(t.type)); +const LABEL_ORDER_TYPES = SEALED_TYPES.filter((t) => ['page', 'app', 'dataset', 'book', 'mapping'].includes(t.type)); const accessorOf = (type: string): string => `getPackaged${type[0].toUpperCase()}${type.slice(1)}Base`; describe('[#30062] a declared override\'s label order: the packaged base and the pair\'s own translations, on a real boot', () => { diff --git a/packages/rest/src/meta-dashboard-view-i18n-explicit-override.test.ts b/packages/rest/src/meta-dashboard-view-i18n-explicit-override.test.ts index cb6ed5fb721..f1d1282e04b 100644 --- a/packages/rest/src/meta-dashboard-view-i18n-explicit-override.test.ts +++ b/packages/rest/src/meta-dashboard-view-i18n-explicit-override.test.ts @@ -300,6 +300,8 @@ describe('#20730 §1 packagedObjectBaseOf — one per-type packaged-base resolve getPackagedDatasetBase: vi.fn((name: string) => ({ kind: 'dataset', name })), getPackagedAppBase: vi.fn((name: string) => ({ kind: 'app', name })), getPackagedBookBase: vi.fn((name: string) => ({ kind: 'book', name })), + // An import mapping is an ADR-0146 D2 listed overridable type as well. + getPackagedMappingBase: vi.fn((name: string) => ({ kind: 'mapping', name })), }); it('asks each type its own accessor, handing the served name through unchanged', () => { @@ -319,7 +321,8 @@ describe('#20730 §1 packagedObjectBaseOf — one per-type packaged-base resolve expect(packagedObjectBaseOf(p, 'dataset', 'opportunity_metrics')).toEqual({ kind: 'dataset', name: 'opportunity_metrics' }); expect(packagedObjectBaseOf(p, 'app', 'crm')).toEqual({ kind: 'app', name: 'crm' }); expect(packagedObjectBaseOf(p, 'book', 'crm_manual')).toEqual({ kind: 'book', name: 'crm_manual' }); - for (const accessor of ['getPackagedPageBase', 'getPackagedDatasetBase', 'getPackagedAppBase', 'getPackagedBookBase'] as const) { + expect(packagedObjectBaseOf(p, 'mapping', 'crm_lead_feed')).toEqual({ kind: 'mapping', name: 'crm_lead_feed' }); + for (const accessor of ['getPackagedPageBase', 'getPackagedDatasetBase', 'getPackagedAppBase', 'getPackagedBookBase', 'getPackagedMappingBase'] as const) { expect(p[accessor], accessor).toHaveBeenCalledTimes(1); } }); @@ -443,7 +446,8 @@ describe('#25788 §4 report — a published overlay on a packaged report is what * * - `packagedBase` — the BASE's item, for a page, a dataset, an app and a * book too (`getPackagedPageBase`, `getPackagedDatasetBase`, - * `getPackagedAppBase`, `getPackagedBookBase`), as the object, dashboard, + * `getPackagedAppBase`, `getPackagedBookBase`), and an import mapping + * (`getPackagedMappingBase`), as the object, dashboard, * view and report already had it; * - `pairBundle` — the translations the pair ships itself * (`servedOverrideBaseOf` + `getPairTranslationBundle`), for every served @@ -467,7 +471,7 @@ const PAIR_PKG = `${SHOWCASE_PKG}.custom`; const OVERRIDE_DECLARATION = { package: SHOWCASE_PKG, basedOn: '1.0.0' }; interface PrecedenceType { - readonly type: 'page' | 'dataset' | 'app' | 'book' | 'view'; + readonly type: 'page' | 'dataset' | 'app' | 'book' | 'mapping' | 'view'; readonly name: string; /** The base's item, as the code package ships it. */ readonly shipped: () => Record; @@ -501,6 +505,12 @@ const PRECEDENCE_TYPES: readonly PrecedenceType[] = [ shipped: () => ({ name: 'crm_manual', label: 'Manual', groups: [{ key: 'start', label: 'Start', pages: [] }] }), catalog: (label) => ({ books: { crm_manual: { label } } }), }, + // A named import mapping: the wizard's saved-mapping selector lists `GET /meta/mapping`. + { + type: 'mapping', name: 'crm_lead_feed', shippedZh: '线索导入', + shipped: () => ({ name: 'crm_lead_feed', label: 'Lead feed', targetObject: OBJ, sourceFormat: 'csv', mode: 'insert', fieldMapping: [{ source: 'Subject', target: 'subject' }] }), + catalog: (label) => ({ mappings: { crm_lead_feed: { label } } }), + }, // An existing type, for the pair's rank: the base was always handed over, the pair's translation never. { type: 'view', name: VIEW, shippedZh: '进行中', diff --git a/packages/rest/src/meta-item-read-gate.ts b/packages/rest/src/meta-item-read-gate.ts index 449c355dcd0..e52e82e503c 100644 --- a/packages/rest/src/meta-item-read-gate.ts +++ b/packages/rest/src/meta-item-read-gate.ts @@ -3323,7 +3323,9 @@ export function metaTranslateOptions( * ADR-0131 D6), but a `.custom` pair's declared override replaces the * base's item on every read (ADR-0146 D2), so the served document can * differ from the one the catalog translates (`getPackagedPageBase`, - * `getPackagedDatasetBase`, `getPackagedAppBase`, `getPackagedBookBase`). + * `getPackagedDatasetBase`, `getPackagedAppBase`, `getPackagedBookBase`); + * an import `mapping` is an ADR-0146 D2 listed overridable type as well + * (`getPackagedMappingBase`). * The label order the base feeds is ruling record 6631250894's: a * translation in the pair ({@link pairTranslationBundleOf}), then the * override's own label, then the base's translation. @@ -3344,6 +3346,7 @@ const PACKAGED_BASE_ACCESSORS: ReadonlyMap = new Map = new MapBase(name)`. + * `getPackagedReportBase(name)`, and [#30062] a `page`, `dataset`, `app`, + * `book` or `mapping` its own `getPackagedBase(name)`. * * `undefined` on every uncertainty — a type with no row, an empty name, a * protocol without the accessor (they are server-only extensions, so From 68f0cacccb4fa92d48f442c540a01d44aa0f6780 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 19:49:57 +0000 Subject: [PATCH 06/16] feat(lint,runtime): the i18n walk keys mappings.MAPPING.label; the meta list parity census carries the mapping type Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- packages/lint/src/i18n-walk.test.ts | 21 ++++++++++++++++ packages/lint/src/i18n-walk.ts | 24 +++++++++++++++++++ .../meta-list-projection-parity.test.ts | 13 +++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/packages/lint/src/i18n-walk.test.ts b/packages/lint/src/i18n-walk.test.ts index 3d474d43049..f52d961e6a6 100644 --- a/packages/lint/src/i18n-walk.test.ts +++ b/packages/lint/src/i18n-walk.test.ts @@ -82,6 +82,27 @@ describe('collectExpectedEntries — a hook\'s declared texts (#34374)', () => { }); }); +describe('collectExpectedEntries — a named import mapping\'s label', () => { + const entries = collectExpectedEntries({ + mappings: [ + { name: 'lead_feed', label: 'Lead feed', targetObject: 'lead', fieldMapping: [{ source: 'Company', target: 'company' }] }, + { name: 'unlabelled_feed', targetObject: 'lead', fieldMapping: [] }, + ], + }, { warnedGroups: new Set() }); + + it('yields mappings..label with the authored label, from the mapping', () => { + const entry = entries.find((e) => e.path.join('.') === 'mappings.lead_feed.label'); + expect(entry?.sourceValue).toBe('Lead feed'); + expect(entry?.source).toBe('mapping'); + }); + + it('keys nothing from the field mapping, and no authored text for a mapping with no label', () => { + const keys = entries.map((e) => e.path.join('.')); + expect(keys.filter((k) => k.startsWith('mappings.lead_feed.'))).toEqual(['mappings.lead_feed.label']); + expect(entries.find((e) => e.path.join('.') === 'mappings.unlabelled_feed.label')?.sourceValue).toBeUndefined(); + }); +}); + describe('authorWarnedTranslationGroups on the shipped ledger', () => { // A browser reads no ledger file, so there the default leaves no group out. // That matches the CLI only while the ledger warns on no translation group; diff --git a/packages/lint/src/i18n-walk.ts b/packages/lint/src/i18n-walk.ts index 18e669bec75..3c9d154724e 100644 --- a/packages/lint/src/i18n-walk.ts +++ b/packages/lint/src/i18n-walk.ts @@ -148,6 +148,7 @@ * permissions..label / .description * books..label / .description * books..groups..label (a doc book's section title, #26690) + * mappings..label (a named import mapping's label) * metadataForms..label / .description * metadataForms..sections.
.label / .description * metadataForms..fields..label / .helpText / .placeholder @@ -258,6 +259,7 @@ export interface ExpectedEntry { | 'position' | 'permission' | 'book' + | 'mapping' | 'metadataType' | 'metadataFormSection' | 'metadataFormField'; @@ -1741,6 +1743,9 @@ export function collectExpectedEntries( // ── Doc books (`books..…`) ────────────────────────────────── walkBooks(config, out); + // ── Import mappings (`mappings..label`) ───────────────────── + walkMappings(config, out); + // ── Pages + their `page:header` copy ────────────────────────────── const pages: any[] = Array.isArray(config?.pages) ? config.pages : []; for (const page of pages) { @@ -2093,6 +2098,25 @@ function walkBooks(config: any, out: ExpectedEntry[]): void { } } +// ─── Import mappings (`mappings..label`) ────────────────────────── + +/** + * Emit a named import mapping's label: `mappings..label`, the key + * `translateMapping` reads. The import wizard offers a mapping by this label. + * The label is optional on the schema, so it is recorded with + * {@link pushOptional}; a mapping's `fieldMapping` is column and field names, + * not copy, and has no key. + */ +function walkMappings(config: any, out: ExpectedEntry[]): void { + const mappings: any[] = Array.isArray(config?.mappings) ? config.mappings : []; + for (const mapping of mappings) { + if (!mapping || typeof mapping !== 'object') continue; + const name = mapping.name; + if (typeof name !== 'string' || name.length === 0) continue; + pushOptional(out, ['mappings', name, 'label'], mapping.label, 'mapping'); + } +} + // ─── Screen flows (`flows..screens..…`) ───────────────── /** diff --git a/packages/runtime/src/domains/meta-list-projection-parity.test.ts b/packages/runtime/src/domains/meta-list-projection-parity.test.ts index 3f5dfab6b32..e9b6662f7f1 100644 --- a/packages/runtime/src/domains/meta-list-projection-parity.test.ts +++ b/packages/runtime/src/domains/meta-list-projection-parity.test.ts @@ -167,6 +167,8 @@ const STORE: Record = { page: [{ name: 'home', label: 'Home', type: 'app' }], action: [{ name: 'close_case', label: 'Close case', objectName: 'case', type: 'script' }], dataset: [{ name: 'pipeline', label: 'Pipeline', object: 'opportunity' }], + // A named import mapping, offered by label in the import wizard. + mapping: [{ name: 'lead_feed', label: 'Lead feed', targetObject: 'lead', sourceFormat: 'csv', mode: 'insert', fieldMapping: [{ source: 'Company', target: 'company' }] }], picklist: [{ name: 'industry', label: 'Industry', options: [{ label: 'Technology', value: 'technology' }] }], flow: [{ name: 'on_lead', label: 'On lead', type: 'autolaunched' }], // [#25333] The `?include=grants` step describes each position. @@ -230,6 +232,8 @@ const BUNDLE: Record = { reports: { opps_by_stage: { label: '各阶段商机' } }, // [#26690] A doc book's title and section titles. books: { help_center: { label: '帮助中心', groups: { start: { label: '开始' } } } }, + // A named import mapping's label. + mappings: { lead_feed: { label: '线索导入' } }, }, }; @@ -567,7 +571,7 @@ const PARAM_AXIS = new Set(PARAM_PROBES.map((p) => p.param).filter((p): p is str const TYPE_CELLS: readonly string[] = [ 'app', 'apps', 'view', 'views', 'doc', 'docs', 'book', 'books', 'api', 'apis', 'object', 'objects', 'dashboard', 'dashboards', 'page', 'action', 'dataset', 'picklist', 'flow', - 'position', 'positions', 'permission', 'permissions', 'report', 'reports', + 'position', 'positions', 'permission', 'permissions', 'report', 'reports', 'mapping', 'mappings', // [#20408] A segment that names no metadata type: `RestServer` refuses it // (`refuseUnknownMetaListType`) rather than listing an empty collection. 'totally_invented_type', @@ -763,6 +767,11 @@ describe('[#20320] row A: the reference moves — each probe changes RestServer\ expect([zhHelp?.label, zhHelp?.groups?.map((g: any) => g.label)]).toEqual(['帮助中心', ['开始']]); const enHelp = (await read('/meta/book', {}, { 'accept-language': 'en-US' })).items?.find((b: any) => b.name === 'help_center'); expect([enHelp?.label, enHelp?.groups?.map((g: any) => g.label)]).toEqual(['Help Centre', ['Start']]); + // So is a named import mapping — the list the import wizard's saved-mapping selector reads. + const zhMappings = await read('/meta/mappings', {}, { 'accept-language': 'zh-CN' }); + expect(zhMappings.items?.find((m: any) => m.name === 'lead_feed')?.label).toBe('线索导入'); + const enMappings = await read('/meta/mapping', {}, { 'accept-language': 'en-US' }); + expect(enMappings.items?.find((m: any) => m.name === 'lead_feed')?.label).toBe('Lead feed'); }); }); @@ -936,6 +945,7 @@ const ITEM_CELLS: readonly string[] = [ '/meta/dashboard/ops', '/meta/dashboards/ops', '/meta/page/home', '/meta/action/close_case', '/meta/dataset/pipeline', '/meta/picklist/industry', '/meta/flow/on_lead', '/meta/api/crm_served', '/meta/position/sales_rep', '/meta/permission/crm_sales_user', '/meta/report/opps_by_stage', + '/meta/mapping/lead_feed', '/meta/mappings/lead_feed', ]; const ITEM_TYPE_AXIS = new Set(ITEM_CELLS.map((c) => singular(c.split('/')[2]))); const ITEM_CALLERS = ['holder', 'non-holder', 'builder', 'author'] as const satisfies readonly CallerName[]; @@ -1087,6 +1097,7 @@ describe('[#20408] the item read: the reference moves — each probe changes Res expect((await read('/meta/permission/crm_sales_user', {}, { 'accept-language': 'zh-CN' })).item?.label).toBe('销售用户'); expect((await read('/meta/report/opps_by_stage', {}, { 'accept-language': 'zh-CN' })).item?.label).toBe('各阶段商机'); expect((await read('/meta/book/help_center', {}, { 'accept-language': 'zh-CN' })).item?.groups?.[0]?.label).toBe('开始'); + expect((await read('/meta/mapping/lead_feed', {}, { 'accept-language': 'zh-CN' })).item?.label).toBe('线索导入'); const zhDoc = await read('/meta/doc/crm_intro', { locale: 'zh-CN' }); expect(zhDoc.item?.label).toBe('入门'); expect(text(zhDoc)).not.toContain('"translations"'); From 387070d423ed4b84ca9ef27592c71647a0d6d81f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 19:51:26 +0000 Subject: [PATCH 07/16] feat(lint,cli): mappings.MAPPING resolves against the stack's mappings; os i18n check reports i18n/missing-mapping Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- packages/cli/src/utils/i18n-coverage.ts | 6 ++ packages/cli/test/i18n-mapping-walk.test.ts | 60 +++++++++++++++++++ packages/lint/src/rule-explanations.ts | 3 +- .../validate-translation-references.test.ts | 36 +++++++++++ .../src/validate-translation-references.ts | 18 +++++- 5 files changed, 120 insertions(+), 3 deletions(-) create mode 100644 packages/cli/test/i18n-mapping-walk.test.ts diff --git a/packages/cli/src/utils/i18n-coverage.ts b/packages/cli/src/utils/i18n-coverage.ts index 33b59697b08..941dc4c17df 100644 --- a/packages/cli/src/utils/i18n-coverage.ts +++ b/packages/cli/src/utils/i18n-coverage.ts @@ -77,6 +77,7 @@ export interface CoverageIssue { | 'position' | 'permission' | 'book' + | 'mapping' | 'metadataForm'; /** Human-readable explanation. */ message: string; @@ -388,6 +389,9 @@ const COVERAGE_SOURCE: Record // `books..groups..label`) — the title and section titles of a docs // sidebar, reported as `i18n/missing-book` (#26690). book: 'book', + // A named import mapping's label (`mappings..label`) — the name the + // import wizard offers it by, reported as `i18n/missing-mapping` (#34939). + mapping: 'mapping', metadataType: 'metadataForm', metadataFormSection: 'metadataForm', metadataFormField: 'metadataForm', @@ -414,6 +418,7 @@ const SOURCE_NOUN: Record = { position: 'Position', permission: 'Permission set', book: 'Book', + mapping: 'Import mapping', metadataForm: 'Metadata form', }; @@ -461,6 +466,7 @@ const SOURCE_SURFACE: Record = { position: 'positions', permission: 'permission sets', book: 'doc books', + mapping: 'import mappings', metadataForm: 'metadata forms', }; diff --git a/packages/cli/test/i18n-mapping-walk.test.ts b/packages/cli/test/i18n-mapping-walk.test.ts new file mode 100644 index 00000000000..837d9e1fe5e --- /dev/null +++ b/packages/cli/test/i18n-mapping-walk.test.ts @@ -0,0 +1,60 @@ +// Copyright (c) 2026 ObjectStack contributors. Apache-2.0 license. +// +// `mappings..label` — the extractor walks a named import mapping's +// translation group (#34939). +// +// The import wizard offers a shipped mapping by its label, and +// `translateMapping` overlays it from the bundle. Without this walk +// `os i18n extract` would scaffold no key for it and `os i18n check` would +// measure a debt of zero while the wizard showed the authoring language. + +import { describe, it, expect } from 'vitest'; +import { collectExpectedEntries, extractTranslations } from '../src/utils/i18n-bundle-extract.js'; +import { computeI18nCoverage } from '../src/utils/i18n-coverage.js'; +import { TranslationDataSchema } from '@objectstack/spec/system'; + +const config = () => ({ + mappings: [ + { + name: 'lead_feed', + label: 'Lead feed (CSV)', + targetObject: 'lead', + fieldMapping: [{ source: 'Company', target: 'company' }], + }, + { name: 'contact_feed', label: 'Contact feed', targetObject: 'contact', fieldMapping: [] }, + // No label: nothing an author wrote, so nothing is demanded. + { name: 'unlabelled_feed', targetObject: 'lead', fieldMapping: [] }, + ], +}); + +describe('i18n extract — the `mappings` group', () => { + it('walks each mapping\'s label, and nothing of its field mapping', () => { + const keys = collectExpectedEntries(config()) + .filter((e) => e.path[0] === 'mappings') + .map((e) => e.path.join('.')) + .sort(); + expect(keys).toEqual(['mappings.contact_feed.label', 'mappings.lead_feed.label', 'mappings.unlabelled_feed.label']); + }); + + it('`TranslationDataSchema` accepts a bundle written at the extracted paths', () => { + const out = extractTranslations(config(), { locales: ['zh-CN'] }); + const zh = out.bundles['zh-CN'] as any; + expect(Object.keys(zh?.mappings ?? {}).sort()).toEqual(['contact_feed', 'lead_feed', 'unlabelled_feed']); + expect(TranslationDataSchema.safeParse({ mappings: zh.mappings }).success).toBe(true); + }); + + it('reports an untranslated label under its own bucket', () => { + const report = computeI18nCoverage({ + ...config(), + i18n: { supportedLocales: ['en', 'zh-CN'] }, + translations: [{ 'zh-CN': { mappings: { lead_feed: { label: '线索导入(CSV)' } } } }], + }); + const zhIssues = report.issues.filter((i) => i.locale === 'zh-CN'); + const missing = zhIssues.map((i) => i.key); + expect(missing).toContain('mappings.contact_feed.label'); + expect(missing).not.toContain('mappings.lead_feed.label'); + // Nothing authored ⇒ nothing to translate. + expect(missing).not.toContain('mappings.unlabelled_feed.label'); + expect(zhIssues.find((i) => i.key === 'mappings.contact_feed.label')?.source).toBe('mapping'); + }); +}); diff --git a/packages/lint/src/rule-explanations.ts b/packages/lint/src/rule-explanations.ts index 4f0a88033d8..7e911f656de 100644 --- a/packages/lint/src/rule-explanations.ts +++ b/packages/lint/src/rule-explanations.ts @@ -4332,7 +4332,8 @@ const TRANSLATION_TARGET_UNKNOWN_EXPLANATION: RuleExplanation = { 'set\'s `name` that a package of this stack declares. `reports.NAME` a report\'s `name` that ' + 'a package of this stack declares. `books.BOOK` a doc book\'s `name` that a package of this ' + 'stack declares, or a package id (its implicit book), and `.groups.KEY` a group `key` that ' + - 'book declares, not its label.', + 'book declares, not its label. `mappings.MAPPING` an import mapping\'s `name` that a ' + + 'package of this stack declares.', // The terminal toast keys are held to `FLOW_TERMINAL_MESSAGE_KEYS` by the rule's test. '`flows.FLOW` a flow\'s machine `name`; `.successMessage` / `.errorMessage` a toast the flow ' + 'itself authors (a bundle cannot add one); `.screens.NODE` the `id` of a `type: \'screen\'` ' + diff --git a/packages/lint/src/validate-translation-references.test.ts b/packages/lint/src/validate-translation-references.test.ts index b1cbbd157c1..7c1f0b151f2 100644 --- a/packages/lint/src/validate-translation-references.test.ts +++ b/packages/lint/src/validate-translation-references.test.ts @@ -4952,6 +4952,42 @@ describe('validateTranslationReferences — reports', () => { }); }); +describe('validateTranslationReferences — import mappings', () => { + const stack = (data: Record, extra: Record = {}) => ({ + mappings: [{ name: 'lead_feed', label: 'Lead feed', targetObject: 'lead', fieldMapping: [{ source: 'Company', target: 'company' }] }], + ...extra, + translations: [{ en: data }], + }); + + it('a declared name is clean', () => { + expect(validateTranslationReferences(stack({ mappings: { lead_feed: { label: 'Lead feed' } } }))).toEqual([]); + }); + + it('a name no package declares is translation-target-unknown, at the named-item groups\' error', () => { + const findings = validateTranslationReferences(stack({ mappings: { lead_fede: { label: 'x' } } })); + expect(findings.map((f) => [f.rule, f.severity, f.path, f.where])).toEqual([ + [TRANSLATION_TARGET_UNKNOWN, 'error', 'translations[0].en.mappings.lead_fede', 'locale "en" · import mapping "lead_fede"'], + ]); + expect(findings[0].message).toContain('Did you mean "lead_feed"?'); + }); + + it('judges the group against its own collection — a report name under `mappings` is an orphan', () => { + const findings = validateTranslationReferences(stack( + { mappings: { opps_by_stage: { label: 'x' } } }, + { reports: [{ name: 'opps_by_stage', label: 'Opportunities by Stage', type: 'summary', dataset: 'pipeline', values: ['amount'] }] }, + )); + expect(findings.map((f) => f.path)).toEqual(['translations[0].en.mappings.opps_by_stage']); + }); + + it('resolves a name a sibling package of the artifact declares', () => { + const findings = validateTranslationReferences(stack( + { mappings: { contact_feed: { label: 'Contact feed' } } }, + { packages: [{ manifest: { mappings: [{ name: 'contact_feed', targetObject: 'contact', fieldMapping: [] }] } }] }, + )); + expect(findings).toEqual([]); + }); +}); + describe('validateTranslationReferences — hook refusals (#26170)', () => { const creditStack = { hooks: [ diff --git a/packages/lint/src/validate-translation-references.ts b/packages/lint/src/validate-translation-references.ts index d98ab48bd2f..c0b1cbcc033 100644 --- a/packages/lint/src/validate-translation-references.ts +++ b/packages/lint/src/validate-translation-references.ts @@ -186,6 +186,14 @@ * id, one group keyed `all`) is what the tree serves where a package authors * no book of that name, so its keys resolve too. * + * ── Import mappings ────────────────────────────────────────────────────── + * + * `mappings.` resolves against `Mapping.name`, the name + * `translateMapping` looks a served mapping up by, with the reports verdict: + * a name no package of this stack declares is an orphan, + * `translation-target-unknown` (`error`). The one leaf key below the name is + * the schema's `label` (strict). + * * ── Cross-package objects ──────────────────────────────────────────────── * * A stack legitimately translates objects it does not define — `sys_user`'s @@ -231,7 +239,7 @@ * is a key whose `COMPOSE_KEY_DISPOSITIONS` disposition puts it inside an * ADR-0130 D4 entry's assembled body: `objects` (#19064) plus `views`, * `pages`, `actions`, `apps`, `dashboards` and `flows` (#19349), - * `positions` and `permissions`, `reports`, and `books`. + * `positions` and `permissions`, `reports`, `books`, and `mappings`. * * ⚠️ `apps` reads BOTH that carrier and `navigationContributions`, and they * answer different questions — what a sibling DECLARES, and what this package @@ -591,6 +599,8 @@ interface Universe { permissionSets: Set; /** Report names (`Report.name`) a `reports.` key may name. */ reports: Set; + /** Import-mapping names (`Mapping.name`) a `mappings.` key may name. */ + mappings: Set; /** * Book name (`Book.name`) → the group `key`s a `books..groups.` * key may name; the implicit per-package book included (#26690). @@ -1780,6 +1790,8 @@ function buildUniverse(stack: AnyRec): Universe { const permissionSets = namesOf('permissions'); // `reports` carries disposition `concat` too, so a sibling's reports resolve. const reports = namesOf('reports'); + // `mappings` carries disposition `concat` too, so a sibling's mappings resolve. + const mappings = namesOf('mappings'); // ── Doc books: the names `books.` may name, and their group keys (#26690) ── // @@ -1821,6 +1833,7 @@ function buildUniverse(stack: AnyRec): Universe { positions, permissionSets, reports, + mappings, books, pages, }; @@ -2314,11 +2327,12 @@ export function validateTranslationReferences(stack: AnyRec): TranslationRefFind }); } - // ── positions. / permissions. / reports. ──────── + // ── positions. / permissions. / reports. / mappings. ── const namedItemGroups = [ { group: 'positions', noun: 'position', known: universe.positions, hint: "Match the key to a position's `name`, or drop it." }, { group: 'permissions', noun: 'permission set', known: universe.permissionSets, hint: "Match the key to a permission set's `name`, or drop it." }, { group: 'reports', noun: 'report', known: universe.reports, hint: "Match the key to a report's `name`, or drop it." }, + { group: 'mappings', noun: 'import mapping', known: universe.mappings, hint: "Match the key to an import mapping's `name`, or drop it." }, ] as const; for (const { group, noun, known, hint } of namedItemGroups) { for (const name of Object.keys(asRecord(rawData[group]))) { From 12dbcdc386f7fe2e040d4a40cc99dd41d7c121c5 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 19:53:13 +0000 Subject: [PATCH 08/16] feat(app-shell,i18n): the translation preview and Studio translation table carry the mappings group; showcase translates its import mapping Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- examples/app-showcase/src/system/translations/index.ts | 5 +++++ scripts/fixtures/i18n-walk-parity/every-group.stack.json | 8 ++++++++ .../previews/TranslationPreview.categories-11765.test.tsx | 1 + .../views/metadata-admin/previews/TranslationPreview.tsx | 2 ++ .../previews/adminPreviews.i18n-10862-s2.test.tsx | 3 ++- .../src/views/studio-design/translationTable.test.ts | 4 ++-- .../app-shell/src/views/studio-design/translationTable.ts | 1 + ui/packages/i18n/src/namespaces/studio/en.ts | 1 + ui/packages/i18n/src/namespaces/studio/zh.ts | 1 + ui/packages/i18n/src/utils/spec-translations.ts | 3 +++ 10 files changed, 26 insertions(+), 3 deletions(-) diff --git a/examples/app-showcase/src/system/translations/index.ts b/examples/app-showcase/src/system/translations/index.ts index 24cb59700ce..9cecef47332 100644 --- a/examples/app-showcase/src/system/translations/index.ts +++ b/examples/app-showcase/src/system/translations/index.ts @@ -1499,5 +1499,10 @@ export const ShowcaseTranslationBundle = { }, }, }, + // The named import mapping, as the import wizard offers it by name. + // Counted by `check-i18n-coverage` like the groups above (#34939). + mappings: { + showcase_inquiry_feed: { label: '询盘导入(营销 CSV)' }, + }, }, }; diff --git a/scripts/fixtures/i18n-walk-parity/every-group.stack.json b/scripts/fixtures/i18n-walk-parity/every-group.stack.json index 5d42786413e..6036bfeaefb 100644 --- a/scripts/fixtures/i18n-walk-parity/every-group.stack.json +++ b/scripts/fixtures/i18n-walk-parity/every-group.stack.json @@ -195,5 +195,13 @@ "description": "How parity is measured", "groups": [{ "key": "basics", "label": "Basics", "include": "parity_*" }] } + ], + "mappings": [ + { + "name": "parity_feed", + "label": "Parity Feed", + "targetObject": "parity_object", + "fieldMapping": [{ "source": "Status", "target": "status" }] + } ] } diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.categories-11765.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.categories-11765.test.tsx index 55c37c066bb..6ef3bf7a96b 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.categories-11765.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.categories-11765.test.tsx @@ -79,6 +79,7 @@ const ONE_ENTRY: Record; key: string; ro key: 'crm_manual', row: () => keys(2), }, + mappings: { data: { lead_feed: { label: 'Import des pistes' } }, key: 'lead_feed', row: () => keys(1) }, metadataForms: { data: { object: { label: 'Objet' } }, key: 'object', row: () => keys(1) }, // `settingsCommon` is one strict object, not a record of author-named nodes: // its members (`sourceLabels`) are what the card counts and samples. diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.tsx index 350d5c14639..245c95e8824 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.tsx @@ -36,6 +36,7 @@ import { BookOpen, ClipboardList, Database, + FileInput, FileText, Gauge, Globe2, @@ -104,6 +105,7 @@ const CATEGORY_DEFS = { positions: { label: 'engine.translationPreview.category.positions', icon: Users, flat: false }, permissions: { label: 'engine.translationPreview.category.permissions', icon: ShieldCheck, flat: false }, books: { label: 'engine.translationPreview.category.books', icon: BookOpen, flat: false }, + mappings: { label: 'engine.translationPreview.category.mappings', icon: FileInput, flat: false }, metadataForms: { label: 'engine.translationPreview.category.metadataForms', icon: FileText, flat: false }, settingsCommon: { label: 'engine.translationPreview.category.settingsCommon', icon: Settings2, flat: false }, } satisfies Record>; diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/adminPreviews.i18n-10862-s2.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/adminPreviews.i18n-10862-s2.test.tsx index e8fa877042e..c25c2387c93 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/adminPreviews.i18n-10862-s2.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/adminPreviews.i18n-10862-s2.test.tsx @@ -474,6 +474,7 @@ describe('TranslationPreview reads the designer locale (objectui#10862)', () => { key: 'engine.translationPreview.category.positions' }, { key: 'engine.translationPreview.category.permissions' }, { key: 'engine.translationPreview.category.books' }, + { key: 'engine.translationPreview.category.mappings' }, { key: 'engine.translationPreview.category.metadataForms' }, { key: 'engine.translationPreview.category.settingsCommon' }, { key: 'engine.translationPreview.categoryEmpty' }, @@ -481,7 +482,7 @@ describe('TranslationPreview reads the designer locale (objectui#10862)', () => { key: 'engine.translationPreview.keyCountOne', vars: { count: 1 } }, ]); // The bundle's own locale is author data, not the designer's language. - expectAsWritten(['French', 'fr-FR', 'account', '"Un"', '2/16 (13%)']); + expectAsWritten(['French', 'fr-FR', 'account', '"Un"', '2/17 (12%)']); }); } }); diff --git a/ui/packages/app-shell/src/views/studio-design/translationTable.test.ts b/ui/packages/app-shell/src/views/studio-design/translationTable.test.ts index cdf5ae40c0a..bb6ea74ac5c 100644 --- a/ui/packages/app-shell/src/views/studio-design/translationTable.test.ts +++ b/ui/packages/app-shell/src/views/studio-design/translationTable.test.ts @@ -200,8 +200,8 @@ describe('readDeclaredStack', () => { expect((stack.views as Doc[])[0]).toMatchObject({ name: 'all_open', object: 'repair_ticket' }); // The owner the platform injects points at the user object, which is walked too. expect(objects.map((o) => o.name).at(-1)).toBe('sys_user'); - // 14 list reads, 11 item reads, 1 platform object. - expect(requests).toBe(14 + 11 + 1); + // 15 list reads, 11 item reads, 1 platform object. + expect(requests).toBe(15 + 11 + 1); expect(fake.calls).toHaveLength(requests); expect(fake.calls).toContain('layered object sys_user '); expect(fake.peak()).toBeLessThanOrEqual(DECLARED_STACK_READ_CONCURRENCY); diff --git a/ui/packages/app-shell/src/views/studio-design/translationTable.ts b/ui/packages/app-shell/src/views/studio-design/translationTable.ts index 622ec4018fc..e2073f2fd7c 100644 --- a/ui/packages/app-shell/src/views/studio-design/translationTable.ts +++ b/ui/packages/app-shell/src/views/studio-design/translationTable.ts @@ -56,6 +56,7 @@ export const WALKED_TYPE_STACK_KEYS = { position: 'positions', permission: 'permissions', book: 'books', + mapping: 'mappings', } as const; export type WalkedType = keyof typeof WALKED_TYPE_STACK_KEYS; diff --git a/ui/packages/i18n/src/namespaces/studio/en.ts b/ui/packages/i18n/src/namespaces/studio/en.ts index 580098f8830..f7499696c05 100644 --- a/ui/packages/i18n/src/namespaces/studio/en.ts +++ b/ui/packages/i18n/src/namespaces/studio/en.ts @@ -4581,6 +4581,7 @@ const STUDIO_EN: Record = { 'engine.translationPreview.category.positions': 'Positions', 'engine.translationPreview.category.permissions': 'Permission Sets', 'engine.translationPreview.category.books': 'Doc Books', + 'engine.translationPreview.category.mappings': 'Import Mappings', 'engine.translationPreview.category.metadataForms': 'Metadata Forms', 'engine.translationPreview.category.settingsCommon': 'Settings UI', 'engine.translationPreview.coverage': 'Category coverage:', diff --git a/ui/packages/i18n/src/namespaces/studio/zh.ts b/ui/packages/i18n/src/namespaces/studio/zh.ts index 7992ef84b4b..18931bff544 100644 --- a/ui/packages/i18n/src/namespaces/studio/zh.ts +++ b/ui/packages/i18n/src/namespaces/studio/zh.ts @@ -4115,6 +4115,7 @@ const STUDIO_ZH: Record = { 'engine.translationPreview.category.positions': '岗位', 'engine.translationPreview.category.permissions': '权限集', 'engine.translationPreview.category.books': '文档书', + 'engine.translationPreview.category.mappings': '导入映射', 'engine.translationPreview.category.metadataForms': '元数据表单', 'engine.translationPreview.category.settingsCommon': '设置界面', 'engine.translationPreview.coverage': '分类覆盖率:', diff --git a/ui/packages/i18n/src/utils/spec-translations.ts b/ui/packages/i18n/src/utils/spec-translations.ts index 51f02c8e43d..623bc5c5ffd 100644 --- a/ui/packages/i18n/src/utils/spec-translations.ts +++ b/ui/packages/i18n/src/utils/spec-translations.ts @@ -115,6 +115,9 @@ const SPEC_TRANSLATION_GROUPS = [ // objectstack #26690 serves `books` (a doc book's title, description and // section titles are translatable), copied through onto `app` the same way. 'books', + // objectstack #34939 serves `mappings` (a named import mapping's label, the + // name the import wizard offers it by), copied through onto `app` the same way. + 'mappings', ] as const; function isPlainObject(value: unknown): value is Record { From e2ac16438e6d0bffe9105059a5fc803928b9ea54 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 19:54:00 +0000 Subject: [PATCH 09/16] docs(i18n): the mappings group in the i18n standard, the translations page and import mappings; changeset Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- .changeset/34939-translation-mappings.md | 26 +++++++++++++++++++ .../docs/data-modeling/import-mappings.mdx | 2 +- .../docs/protocol/kernel/i18n-standard.mdx | 4 +-- content/docs/ui/translations.mdx | 3 ++- 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 .changeset/34939-translation-mappings.md diff --git a/.changeset/34939-translation-mappings.md b/.changeset/34939-translation-mappings.md new file mode 100644 index 00000000000..d46f1110ec3 --- /dev/null +++ b/.changeset/34939-translation-mappings.md @@ -0,0 +1,26 @@ +--- +'@objectstack/spec': minor +'@objectstack/metadata-protocol': minor +'@objectstack/rest': minor +'@objectstack/lint': minor +'@objectstack/cli': minor +'@object-ui/app-shell': minor +'@object-ui/i18n': minor +--- + +feat(spec): a named import mapping's label is translatable at `mappings.NAME.label` + +Clause-②: yes (widening) — a new optional translation group `mappings` (one key per mapping, `label`) on `TranslationDataSchema`, `PlatformTranslationDataSchema`, `ServedTranslationDataSchema` and `TranslationItemSchema`, a new `translateMapping` export from `@objectstack/spec/system` registered for the `mapping` type, and a new `MetadataProtocol.getPackagedMappingBase`; nothing that parsed before is refused +Metadata-protocol: added +Skills-docs: follow-up owed — #34962 (skills/objectstack-i18n/SKILL.md group list) + +An import mapping's `label` is the name the import wizard offers it by, and until now it showed the authored text in every locale: the bundle had no key for it. A bundle now translates it: + +```ts +'zh-CN': { mappings: { crm_lead_feed: { label: '线索导入' } } } +``` + +- `GET /meta/mapping` (list and item) serves the label in the reader's locale, by the same ADR-0146 D2 order as every other translated label: a tenant's own translation, then the package's shipped one, then the authored label. A mapping a package ships, read through its customization pair, keeps its packaged base. +- Only `label` has a key. A mapping declares no `description`, and its `fieldMapping` holds column and field names rather than copy — the refusal for either names where to translate instead (a target field's label is `objects.OBJECT.fields.FIELD.label`). The singular `mapping` and the label aliases `name` / `title` are refused with the declared spelling named. +- `os i18n extract` scaffolds the key, `os i18n check` reports a gap as `i18n/missing-mapping`, and `os validate` reports a key naming no mapping of the stack as `translation-target-unknown`, with the nearest name suggested. +- Studio's translation preview shows the group as **Import Mappings** (导入映射), and the Studio translation table walks it. diff --git a/content/docs/data-modeling/import-mappings.mdx b/content/docs/data-modeling/import-mappings.mdx index bbe84e562f6..548a4106050 100644 --- a/content/docs/data-modeling/import-mappings.mdx +++ b/content/docs/data-modeling/import-mappings.mdx @@ -116,7 +116,7 @@ mapping under its own name. | Key | Type | What it does | |:---|:---|:---| | `name` | `string` (snake_case) | The id `mappingName` resolves. Missing artifact → `404 MAPPING_NOT_FOUND`. | -| `label` | `string` | Display text in a saved-mapping picker. Falls back to `name`. | +| `label` | `string` | Display text in a saved-mapping picker (the import wizard). Falls back to `name`. Translated per locale at `mappings..label` in the app's translation bundle — see [Translations](/docs/ui/translations). | | `sourceFormat` | `'csv' \| 'json' \| 'xml' \| 'sql'` | Declared payload format, checked against what the request actually sent. Defaults to `csv`. See [the format gate](#rejections-before-any-row-is-read). | | `targetObject` | `string` | The object this mapping is for. Must equal the object in the URL. | | `fieldMapping` | `ImportFieldMapping[]` | The projection itself — one entry per target field. | diff --git a/content/docs/protocol/kernel/i18n-standard.mdx b/content/docs/protocol/kernel/i18n-standard.mdx index cf706e24f18..4d042a8fb50 100644 --- a/content/docs/protocol/kernel/i18n-standard.mdx +++ b/content/docs/protocol/kernel/i18n-standard.mdx @@ -493,7 +493,7 @@ Three rules the shape enforces, all of them closed since #4001: - **The top level is the declared group set and nothing else** — `objects`, `picklists`, `apps`, `messages`, `globalActions`, `dashboards`, `datasets`, `reports`, `pages`, `flows`, `hooks`, `positions`, `permissions`, `books`, - `metadataForms`, `settingsCommon`. A group invented beside them + `mappings`, `metadataForms`, `settingsCommon`. A group invented beside them (`"account"`, `"fields"`, `"list"`, `"industries"`) is rejected **by name** at both authoring doors, with the group to use instead named in the rejection. @@ -582,7 +582,7 @@ what the overlay writes back as the node's `title`. The contract is `t(key, locale, params?)` — the target locale is always passed explicitly, and the key itself is returned when no translation is found (there is no `defaultValue` option). The key is a **dot path into `TranslationData`**, -so it starts at one of the sixteen declared groups. +so it starts at one of the seventeen declared groups. ```typescript const i18n = kernel.getService('i18n'); diff --git a/content/docs/ui/translations.mdx b/content/docs/ui/translations.mdx index a155092825f..fcb0841ff4e 100644 --- a/content/docs/ui/translations.mdx +++ b/content/docs/ui/translations.mdx @@ -97,12 +97,13 @@ export default defineStack({ | Position label / description | `positions..label` / `description` — keyed by the position's `name`; overlaid on every served position, which is the list the console's position picker draws | | Permission-set label / description | `permissions..label` / `description` — the group is spelled as the stack spells the collection (`permissions[]`), keyed by the set's `name` | | Doc book title, description and section titles | `books..label` / `description` / `groups..label` — keyed by the book's `name` and each group's `key`; overlaid on every served book and on the book tree, which is what the docs sidebar draws. A doc's own title and body localize through `doc.translations` instead | +| Import mapping label | `mappings..label` — keyed by the mapping's `name`; overlaid on every served mapping, which is the list the import wizard offers by name. A mapping's `fieldMapping` holds column and field names, not copy: a target field's label is translated under `objects..fields..label` | | Global actions, messages | `globalActions`, `messages` | | Settings UI shell copy (the source badge on a settings row) | `settingsCommon.sourceLabels.` — the per-namespace settings copy under `settings` is **platform-only**: an app bundle carrying it is refused by name, and the platform's own strings are translated in `@objectstack/service-settings`'s bundle | | A label written as an inline locale map (`label: { en: 'Members', 'zh-CN': '成员' }`) | Nowhere — it is written on the metadata and resolved at render time; see **Current boundaries** below | The metadata types resolved per request are **object, view, action, app, -dashboard, dataset, report, page, picklist, position, permission and book** — a field's labels are translated as part of +dashboard, dataset, report, page, picklist, position, permission, book and mapping** — a field's labels are translated as part of its object document, and so are the labels of any actions the object declares inline (#3370). Before that, an object document went out with its authored action From 0663ffad1f1294b95d7649d9c526d8eaf62bd556 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 19:58:44 +0000 Subject: [PATCH 10/16] test(cli): an unlabelled mapping scaffolds no key Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- packages/cli/test/i18n-mapping-walk.test.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/cli/test/i18n-mapping-walk.test.ts b/packages/cli/test/i18n-mapping-walk.test.ts index 837d9e1fe5e..288cb7b0dea 100644 --- a/packages/cli/test/i18n-mapping-walk.test.ts +++ b/packages/cli/test/i18n-mapping-walk.test.ts @@ -39,7 +39,8 @@ describe('i18n extract — the `mappings` group', () => { it('`TranslationDataSchema` accepts a bundle written at the extracted paths', () => { const out = extractTranslations(config(), { locales: ['zh-CN'] }); const zh = out.bundles['zh-CN'] as any; - expect(Object.keys(zh?.mappings ?? {}).sort()).toEqual(['contact_feed', 'lead_feed', 'unlabelled_feed']); + // A mapping with no label has no source text to scaffold. + expect(Object.keys(zh?.mappings ?? {}).sort()).toEqual(['contact_feed', 'lead_feed']); expect(TranslationDataSchema.safeParse({ mappings: zh.mappings }).success).toBe(true); }); From 81f632222ce0139a60457e1313333e3a09b29c1e Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 20:10:32 +0000 Subject: [PATCH 11/16] docs(changeset): state the ADR-0146 D2 order for an overridden mapping's label precisely Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- .changeset/34939-translation-mappings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/34939-translation-mappings.md b/.changeset/34939-translation-mappings.md index d46f1110ec3..37245bc5e5b 100644 --- a/.changeset/34939-translation-mappings.md +++ b/.changeset/34939-translation-mappings.md @@ -20,7 +20,7 @@ An import mapping's `label` is the name the import wizard offers it by, and unti 'zh-CN': { mappings: { crm_lead_feed: { label: '线索导入' } } } ``` -- `GET /meta/mapping` (list and item) serves the label in the reader's locale, by the same ADR-0146 D2 order as every other translated label: a tenant's own translation, then the package's shipped one, then the authored label. A mapping a package ships, read through its customization pair, keeps its packaged base. +- `GET /meta/mapping` (list and item) serves the label in the reader's locale. A shipped mapping overridden through its `.custom` pair follows the ADR-0146 D2 order every other translated label follows: a label the override changed keeps its own text unless the pair translates it, and a label it left alone takes the pair's translation, then the package's. The packaged base is now available for `mapping` (`getPackagedMappingBase`), so the override's label is judged against it. - Only `label` has a key. A mapping declares no `description`, and its `fieldMapping` holds column and field names rather than copy — the refusal for either names where to translate instead (a target field's label is `objects.OBJECT.fields.FIELD.label`). The singular `mapping` and the label aliases `name` / `title` are refused with the declared spelling named. - `os i18n extract` scaffolds the key, `os i18n check` reports a gap as `i18n/missing-mapping`, and `os validate` reports a key naming no mapping of the stack as `translation-target-unknown`, with the nearest name suggested. - Studio's translation preview shows the group as **Import Mappings** (导入映射), and the Studio translation table walks it. From 24cab2353ff715732663e2d7c60541bdb6161acb Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 20:24:08 +0000 Subject: [PATCH 12/16] docs(metadata-protocol): a shorter contract for getPackagedMappingBase Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- packages/metadata-protocol/src/protocol.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/metadata-protocol/src/protocol.ts b/packages/metadata-protocol/src/protocol.ts index 218ac055d25..b2ea8398232 100644 --- a/packages/metadata-protocol/src/protocol.ts +++ b/packages/metadata-protocol/src/protocol.ts @@ -3051,11 +3051,8 @@ export class ObjectStackProtocolImplementation implements /** * The PACKAGED (code-layer) declaration of an IMPORT MAPPING, the fact - * `translateMapping` compares the served label against - * (`mappings..label`): a label a `.custom` override changed reads - * only the pair's translations, one it left alone reads the catalog - * (ADR-0146 D2). The mapping twin of {@link getPackagedBookBase}, - * answered the same way. Returns `undefined` on the same uncertainties. + * `translateMapping` compares the served label against (`mappings..label`, + * ADR-0146 D2). The mapping twin of {@link getPackagedBookBase}, answered the same way. */ getPackagedMappingBase(name: string): unknown { return ProtocolDiscoveryAndBasesFacet.getPackagedMappingBase(protocolHost(this), name); From 3a7c72e8a00f3f40fcd97226ef2e730082a935ac Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 20:37:01 +0000 Subject: [PATCH 13/16] test(app-shell): the preview category pins pay the validator's dynamic imports at collection Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- .../previews/TranslationPreview.categories-11765.test.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.categories-11765.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.categories-11765.test.tsx index 6ef3bf7a96b..b58983a49ce 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.categories-11765.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/previews/TranslationPreview.categories-11765.test.tsx @@ -27,6 +27,12 @@ import * as React from 'react'; import { describe, it, expect, afterEach } from 'vitest'; import { render, cleanup, screen } from '@testing-library/react'; import { TranslationDataSchema } from '@objectstack/spec/system'; +// `validateMetadataDraft` reaches dynamic `@objectstack/formula`, `@objectstack/lint` +// and `@object-ui/core` imports; their first load is paid here, at collection, +// never inside a case's clock (`check:test-source-alias`). +import '@objectstack/formula'; +import '@objectstack/lint'; +import '@object-ui/core'; import { validateMetadataDraft } from '../clientValidation'; import { t, tFormat } from '../i18n'; From ab48a19f39191102c033b67807dddf10e0e01248 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 20:49:21 +0000 Subject: [PATCH 14/16] docs(metadata-protocol): one shared contract for the page, dataset, app, book and mapping packaged-base accessors The five per-accessor docblocks are folded into one on getPackagedPageBase, which names each accessor and keeps every statement; the other four carry a one-line pointer. protocol.ts is back under its facade line ceiling with the mapping forwarder in. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- packages/metadata-protocol/src/protocol.ts | 86 ++++++++++------------ 1 file changed, 38 insertions(+), 48 deletions(-) diff --git a/packages/metadata-protocol/src/protocol.ts b/packages/metadata-protocol/src/protocol.ts index b2ea8398232..08c65f0af79 100644 --- a/packages/metadata-protocol/src/protocol.ts +++ b/packages/metadata-protocol/src/protocol.ts @@ -2987,73 +2987,63 @@ export class ObjectStackProtocolImplementation implements } /** - * [#30062] The PACKAGED (code-layer) declaration of a PAGE — the page a - * code package ships, before a `.custom` pair's declared override replaces - * it (ADR-0146 D2). The page twin of {@link getPackagedDashboardBase}, - * answered the same way, and the fact `translatePage` - * (`@objectstack/spec/system`) compares against as its `packagedBase`: the - * i18n catalog (`pages.`) is the packaged translation of exactly - * this body, so it may only replace a string the served page still carries - * unchanged from it (ruling record 6631250894: a translation in the pair, - * then the override's own label, then the base's translation). - * - * Measured before this existed: a pair's override of the CRM's - * `crm_welcome` labelled `OVpage` was served, and a `zh-CN` reader got the - * base's `欢迎页`, because the translation of the served page had no base to - * compare with. + * [#30062] The PACKAGED (code-layer) declarations of a PAGE, DATASET, APP, + * BOOK and IMPORT MAPPING — the item a code package ships, before a + * `.custom` pair's declared override replaces it (ADR-0146 D2). One + * contract for the five accessors below: the page is the twin of + * {@link getPackagedDashboardBase}, the other four are twins of the page + * (and of each other), all answered the same way, and each is the fact its + * translator (`@objectstack/spec/system`) compares against as its + * `packagedBase`: the i18n catalog entry is the packaged translation of + * exactly this body, so it may only replace a string the served item still + * carries unchanged from it (ruling record 6631250894: a translation in the + * pair, then the override's own label, then the base's translation). + * + * - `getPackagedPageBase`: `translatePage`, `pages.`. Measured before + * this existed: a pair's override of the CRM's `crm_welcome` labelled + * `OVpage` was served, and a `zh-CN` reader got the base's `欢迎页`, + * because the translation of the served page had no base to compare + * with. A page has no extension fold, so the artifact item IS the + * packaged declaration. + * - `getPackagedDatasetBase`: `translateDataset`, each string of + * `datasets.` (label, description, dimension and measure labels), + * for the page's reason: a pair's dataset override kept the base's + * translated label and measure labels over its own. + * - `getPackagedAppBase`: `translateApp`, each string of `apps.` + * (label, description and navigation labels, a node judged against the + * base's node of the same `id`). + * - `getPackagedBookBase`: `translateBook`, each string of `books.` + * (label, description and group labels, a group judged against the + * base's group of the same `key`). + * - `getPackagedMappingBase` (#34939): `translateMapping`, the served + * label only (`mappings..label`). * * Shadow-immune for the dashboard's reason: the override is served from its - * row, never as the artifact, so the body returned is the base's own. A - * page has no extension fold, so the artifact item IS the packaged - * declaration. Returns `undefined` for a page no code package ships, an - * unknown or empty name, and a registry double without the lookup — "no - * packaged baseline", read by the translator as the catalog applying - * unchanged. + * row, never as the artifact, so the body returned is the base's own. Each + * returns `undefined` for an item no code package ships, an unknown or + * empty name, and a registry double without the lookup — "no packaged + * baseline", read by the translator as the catalog applying unchanged. */ getPackagedPageBase(name: string): unknown { return ProtocolDiscoveryAndBasesFacet.getPackagedPageBase(protocolHost(this), name); } - /** - * [#30062] The PACKAGED (code-layer) declaration of a DATASET, the fact - * `translateDataset` compares each string against (`datasets.`: its - * label, description, dimension and measure labels). The dataset twin of - * {@link getPackagedPageBase}, answered the same way and for the same - * reason: a pair's dataset override kept the base's translated label and - * measure labels over its own. Returns `undefined` on the same - * uncertainties. - */ + /** Contract: the shared docblock on {@link getPackagedPageBase}. */ getPackagedDatasetBase(name: string): unknown { return ProtocolDiscoveryAndBasesFacet.getPackagedDatasetBase(protocolHost(this), name); } - /** - * [#30062] The PACKAGED (code-layer) declaration of an APP, the fact - * `translateApp` compares each string against (`apps.`: its label, - * description and navigation labels, a node judged against the base's node - * of the same `id`). The app twin of {@link getPackagedPageBase}, answered - * the same way. Returns `undefined` on the same uncertainties. - */ + /** Contract: the shared docblock on {@link getPackagedPageBase}. */ getPackagedAppBase(name: string): unknown { return ProtocolDiscoveryAndBasesFacet.getPackagedAppBase(protocolHost(this), name); } - /** - * [#30062] The PACKAGED (code-layer) declaration of a BOOK, the fact - * `translateBook` compares each string against (`books.`: its label, - * description and group labels, a group judged against the base's group of - * the same `key`). The book twin of {@link getPackagedPageBase}, answered - * the same way. Returns `undefined` on the same uncertainties. - */ + /** Contract: the shared docblock on {@link getPackagedPageBase}. */ getPackagedBookBase(name: string): unknown { return ProtocolDiscoveryAndBasesFacet.getPackagedBookBase(protocolHost(this), name); } - /** - * The PACKAGED (code-layer) declaration of an IMPORT MAPPING, the fact - * `translateMapping` compares the served label against (`mappings..label`, - * ADR-0146 D2). The mapping twin of {@link getPackagedBookBase}, answered the same way. - */ + /** Contract: the shared docblock on {@link getPackagedPageBase}. */ getPackagedMappingBase(name: string): unknown { return ProtocolDiscoveryAndBasesFacet.getPackagedMappingBase(protocolHost(this), name); } From 32942ddd5ca6e84e57bc12bcabac5b937785c84a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 21:29:35 +0000 Subject: [PATCH 15/16] docs(qa): the i18n surface matrix names the mappings group in its served vocabulary; the changeset names the protocol class i18n.surface-matrix revision 16: acceptance[7].clause counts eighteen / seventeen / seventeen groups and names `mappings`; the appTranslationDataShape source line names all seventeen app groups, `hooks` included. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- .changeset/34939-translation-mappings.md | 2 +- docs/qa/platform-checklist/areas/i18n.json | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.changeset/34939-translation-mappings.md b/.changeset/34939-translation-mappings.md index 37245bc5e5b..da8e19e63a0 100644 --- a/.changeset/34939-translation-mappings.md +++ b/.changeset/34939-translation-mappings.md @@ -10,7 +10,7 @@ feat(spec): a named import mapping's label is translatable at `mappings.NAME.label` -Clause-②: yes (widening) — a new optional translation group `mappings` (one key per mapping, `label`) on `TranslationDataSchema`, `PlatformTranslationDataSchema`, `ServedTranslationDataSchema` and `TranslationItemSchema`, a new `translateMapping` export from `@objectstack/spec/system` registered for the `mapping` type, and a new `MetadataProtocol.getPackagedMappingBase`; nothing that parsed before is refused +Clause-②: yes (widening) — a new optional translation group `mappings` (one key per mapping, `label`) on `TranslationDataSchema`, `PlatformTranslationDataSchema`, `ServedTranslationDataSchema` and `TranslationItemSchema`, a new `translateMapping` export from `@objectstack/spec/system` registered for the `mapping` type, and a new `ObjectStackProtocolImplementation.getPackagedMappingBase`; nothing that parsed before is refused Metadata-protocol: added Skills-docs: follow-up owed — #34962 (skills/objectstack-i18n/SKILL.md group list) diff --git a/docs/qa/platform-checklist/areas/i18n.json b/docs/qa/platform-checklist/areas/i18n.json index 4ebc7f6fa7e..c5d154bad2e 100644 --- a/docs/qa/platform-checklist/areas/i18n.json +++ b/docs/qa/platform-checklist/areas/i18n.json @@ -185,7 +185,7 @@ "title": "Every translatable surface localizes on a zh-CN session — one pass over the full translation-group vocabulary, plus the runtime i18n routes it resolves through", "since": "v15", "status": "active", - "revision": 15, + "revision": 16, "priority": "P1", "surface": "browser", "personas": ["admin on a zh-CN session"], @@ -268,7 +268,7 @@ "evidence": "the /i18n/locales response" }, { - "clause": "GET /i18n/translations/:locale returns a non-empty bundle whose key paths all sit within the declared translation-group vocabulary (ServedTranslationDataSchema — the SERVED document is the merged tree's platform face, PlatformTranslationDataSchema's seventeen groups (TranslationDataSchema's sixteen per-app groups, hooks included, plus the platform-only `settings`), less metadataForms, the one server-resolved group (SERVER_RESOLVED_TRANSLATION_GROUPS), so sixteen groups: apps, books, dashboards, datasets, flows, globalActions, hooks, messages, objects, pages, permissions, picklists, positions, reports, settings, settingsCommon) — a key outside the declared groups, or a raw dotted key handed to a consumer, is the silent-strip class", + "clause": "GET /i18n/translations/:locale returns a non-empty bundle whose key paths all sit within the declared translation-group vocabulary (ServedTranslationDataSchema — the SERVED document is the merged tree's platform face, PlatformTranslationDataSchema's eighteen groups (TranslationDataSchema's seventeen per-app groups, hooks and mappings included, plus the platform-only `settings`), less metadataForms, the one server-resolved group (SERVER_RESOLVED_TRANSLATION_GROUPS), so seventeen groups: apps, books, dashboards, datasets, flows, globalActions, hooks, mappings, messages, objects, pages, permissions, picklists, positions, reports, settings, settingsCommon) — a key outside the declared groups, or a raw dotted key handed to a consumer, is the silent-strip class", "oracle": "api", "verify": "translations for zh-CN is non-empty; spot-check that sampled keys resolve under objects/_views/_actions/_sections/apps.navigation/dashboards/pages/settings groups, not a fourth dialect", "evidence": "the /translations/zh-CN response + the key check" @@ -321,7 +321,7 @@ "ref": "objectui code under ui/, for acceptance[5]'s dialog COPY only: ui/packages/components/src/__tests__/page-header-action-i18n.test.tsx ('renders the translated button AND opens the confirm dialog with the translated body', 'passes the translated successMessage to the toast') + ui/packages/plugin-detail/src/renderers/__tests__/record-quick-actions.actionText-i18n.test.tsx ('resolves the button AND the confirm dialog body from the same bundle entry', 'resolves successMessage from the same entry'). Each runs the real ActionRunner under a real I18nProvider holding a zh-CN `_actions.NAME` entry, but the action handler, the confirm handler and the toast handler are vi.fn stubs: no request leaves the test, so acceptance[5]'s network clause (the toast attached to a real 2xx round-trip) stays the run's. Run them from this checkout's ui/ directory, where the vitest config lives: neither package carries its own, and each package's test script is `vitest run --root ../..`. The command is `cd ui && pnpm exec vitest run --maxWorkers=1 packages/components/src/__tests__/page-header-action-i18n.test.tsx packages/plugin-detail/src/renderers/__tests__/record-quick-actions.actionText-i18n.test.tsx` and cite the output naming the commit (QA run #23951 ran them in objectui at daeb77fc84dd, 2 files, 7/7). acceptance[6], [7] and [9] have no pin: packages/qa/dogfood/test/showcase-anonymous-deny-surfaces.dogfood.test.ts reaches the i18n routes over HTTP (I18N_FACES, the signed-in member's 200 control), but asserts only that en and zh-CN are among the locales and one translated label, never the exact locale set, the group vocabulary or the zz-ZZ empty-map shape. Every other clause still needs the run" }, "source": [ - "packages/spec/src/system/translation.zod.ts#appTranslationDataShape (appTranslationDataShape — the fifteen-group vocabulary an APPLICATION may author: objects (with _views/_actions/_sections), picklists, apps (navigation), messages, globalActions, dashboards, datasets, reports, pages, flows, positions, permissions, books, metadataForms, settingsCommon. `settings` is platform-only since #15178 and lives in platformSettingsShape, spread into PlatformTranslationDataSchema only — TranslationItemSchema refuses it too since #19620)", + "packages/spec/src/system/translation.zod.ts#appTranslationDataShape (appTranslationDataShape — the seventeen-group vocabulary an APPLICATION may author: objects (with _views/_actions/_sections), picklists, apps (navigation), messages, globalActions, dashboards, datasets, reports, pages, flows, hooks, positions, permissions, books, mappings, metadataForms, settingsCommon. `settings` is platform-only since #15178 and lives in platformSettingsShape, spread into PlatformTranslationDataSchema only — TranslationItemSchema refuses it too since #19620)", "examples/app-showcase/src/system/translations/index.ts (full-column coverage rationale)", "packages/services/service-i18n/src/i18n-service-plugin.ts#i18n (GET /i18n/locales | /translations/:locale | /labels/:object/:locale; { success, data } envelope #3636/#3675; resolveObjectFieldLabels nested shape #3778/#3833; the plugin mount and the dispatcher /i18n domain serve the same routes interchangeably)", "packages/services/service-i18n/src/file-i18n-adapter.ts#getLocales (getLocales / getTranslations — unloaded locale → {}; fallbackLocale applies per-KEY in t(), not to the bulk route)", @@ -368,6 +368,12 @@ "date": "2026-11-15", "change": "verify-, step- and fixture-text correction, no clause change. acceptance[2].verify: the showcase's coverage baseline reads 317, not 414. fixtures.knownGaps[3]: the revoke confirm has now been driven live. steps[18]: the task record page draws no activity timeline; the feed is read on the inbox popover's 活动动态 tab or GET /api/v1/data/sys_activity. Read from source at base 895783a1. Source records: QA record #33853 (comment 6894307378) on #33761. Batch D of the #33761 close-out, card #33966", "ref": "#33984" + }, + { + "revision": 16, + "date": "2026-11-17", + "change": "acceptance[7].clause and the appTranslationDataShape source line: count-and-list correction, no change of the clause's meaning. The clause still scores every served key against the declared vocabulary; that vocabulary gained the `mappings` group (a named import mapping's label, mappings.NAME.label), so the served platform face is eighteen groups, the per-app face seventeen, and the scored set seventeen with mappings named. The source line also named fifteen groups without hooks, stale before this change; it now names all seventeen. The showcase bundle serves mappings.showcase_inquiry_feed, which the old list would have scored as outside the vocabulary. Read from source at base 0465f4aa", + "ref": "#34939" } ] }, From 2842767b2acffbdccdd85ad9d700a229d61fbe6c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 22:49:06 +0000 Subject: [PATCH 16/16] chore(spec): regenerate export-origins, api-surface and the references docs on the merged tree The os-regen driver kept the branch side of these four artifacts in the merge of origin/main; regenerated from the merged tree they carry main's actionRefusalMessageKey and action refusal translations beside the mappings group. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- content/docs/references/api/protocol.mdx | 2 +- content/docs/references/system/translation.mdx | 5 +++++ packages/spec/api-surface/system.json | 1 + packages/spec/export-origins/system.json | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 59e50ff8ec9..353c2277019 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -1531,7 +1531,7 @@ This schema accepts one of the following structures: | **resettable** | `boolean` | optional | Whether the item can be reset to its packaged default — true iff it is artifact-backed, i.e. there is a baseline to reset TO. | | **version** | `string \| null` | optional | ADR-0008 version token of the STORED row a save to this item compares against, at this read's scope (the environment's partition and `?package=`) and lifecycle (`?state=draft` reads the draft row, the plain read the active row). The same keyed token a save receipt's `version` serves for that row: send it back as the `If-Match` request header on `PUT /meta/:type/:name` (with `?mode=draft` for the draft) and a concurrent edit is refused 409 `METADATA_CONFLICT` instead of overwritten. `null` when no stored row is there — an item served from code or a package artifact, or from a row in another scope (a package-less row a package read falls back to) — so the next save creates one: pin it with `If-None-Match: *`. A `null` beside `editable: false` is no such invitation: that item takes no save at this address, so no pin is prescribed for it. ABSENT on the cached published-value branch and on a `?preview=draft` read, which publish no version: absence means "not published here", never "no row". Opaque — echo it verbatim, never parse it. | | **registration** | `{ state: 'registered' } \| { state: 'refused'; reason: object } \| { state: 'unregistered' }` | optional | The automation engine's verdict on this flow (see `FlowRegistrationSchema`): `registered`, or `refused` with the engine's `reason` verbatim, or `unregistered`. Present only on a `flow` read answered by a process that runs an automation service; absent otherwise, and absence means no engine judged it, never `registered`. Unlike the protection keys it is published by the cached branch too, read live and never part of the ETag, so a cached read that carries it is never answered 304; it is absent on a draft read, whose pending body no engine holds. The verdict is the answering process's engine. Beside `item`, never inside it: the item's `status` stays what its author declared. | -| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off under Setup › Packaged Actions): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | +| **disabledActions** | `string[]` | optional | The names in `item.actions` that this deployment's activation ledger switches off (an administrator turned them off through the activation door, for example on the action in Studio): a call to any of them is refused 409 `ACTION_DISABLED`. Present only on an `object` read answered by a process whose data engine has an activation ledger attached, and then `[]` when none of this object's actions is switched off. Absent otherwise, and absence means no ledger answered, never that nothing is switched off. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag, so a cached read revalidates to 304 only while the switched-off set is unchanged; it is absent on a draft read. The ledger is the answering process's engine's. Beside `item`, never inside it: `item.actions` is served as declared, a switched-off action included. | | **cascadeDeleteObjects** | `string[]` | optional | The objects, by name, that deleting a record of this object can also delete: every object whose relation into it cascades (a `master_detail` by default, a `lookup`, `tree` or `user` field that declares `deleteBehavior: 'cascade'`), and the objects that cascade into those in turn, each once, in the order the delete reaches them. This object itself is named only when a cascading relation leads back to it. A `restrict` or `set_null` relation removes nothing and is not named. Read from the rule the delete runs, and object-level: it never says which records or how many. Present only on an `object` read answered by a process whose data engine answers it, and then `[]` when nothing cascades. Absent otherwise, and absence means no engine answered, never that nothing cascades. Unlike the protection keys it is published by the cached branch too, read live and folded into the ETag; it is absent on a draft read. Beside `item`, never inside it: it is derived from other objects' definitions and is not authorable. | | **draftChanges** | `{ path: string[]; by: Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>; actor: string \| null; client?: object; … }[]` | optional | Per-key provenance of the pending draft: which authoring surface last changed each key path of `item`, under which actor, and when. The draft save records it: each draft save is compared with the body that save replaced (the previous draft, or the stored published row for the draft's first save; a draft of an item with no stored published row is recorded as `[]`, the whole body). A `migrate-stored` rewrite of a draft row records nothing, since it is not authoring. The entries are kept from the first recorded save until the draft is published or discarded, which remove the draft row and the entries with it; and no two entries share a path: a save replaces every entry at or under each path it changes, so the last write to change a key is the entry whose `path` is the longest prefix of that key's path, and entries under a key's path are changes inside it. The entries name which writes changed what; they are not a list of every difference from the published body (compare the two bodies for that). Served only on a `?state=draft` read that answers a stored draft row. ABSENT on the active read, the cached branch and a `?preview=draft` read, and for a draft row whose saves recorded none: absence means "not recorded", never "no changes". | diff --git a/content/docs/references/system/translation.mdx b/content/docs/references/system/translation.mdx index 8ffac79aeef..a798e21c4e9 100644 --- a/content/docs/references/system/translation.mdx +++ b/content/docs/references/system/translation.mdx @@ -139,6 +139,7 @@ Translation data for a single field | **params** | `Record }>` | optional | Action parameter translations keyed by parameter name | | **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record; … }` | optional | Translations for the action result dialog | | **preflight** | `{ fields?: Record; columns?: Record> }` | optional | Translations for the action preflight panel | +| **refusals** | `Record }>` | optional | Refusal translations keyed by the code the action's `refusals` declares | ### Nested Shape: `ObjectTranslationData._sections[string]` @@ -245,6 +246,7 @@ Translation data for a single object | **params** | `Record }>` | optional | Action parameter translations keyed by parameter name | | **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record; … }` | optional | Translations for the action result dialog | | **preflight** | `{ fields?: Record; columns?: Record> }` | optional | Translations for the action preflight panel | +| **refusals** | `Record }>` | optional | Refusal translations keyed by the code the action's `refusals` declares | ### Nested Shape: `PlatformTranslationData.dashboards[string]` @@ -432,6 +434,7 @@ Translation data for a single object | **params** | `Record }>` | optional | Action parameter translations keyed by parameter name | | **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record; … }` | optional | Translations for the action result dialog | | **preflight** | `{ fields?: Record; columns?: Record> }` | optional | Translations for the action preflight panel | +| **refusals** | `Record }>` | optional | Refusal translations keyed by the code the action's `refusals` declares | ### Nested Shape: `ServedTranslationData.dashboards[string]` @@ -682,6 +685,7 @@ Translation data for a single object | **params** | `Record }>` | optional | Action parameter translations keyed by parameter name | | **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record; … }` | optional | Translations for the action result dialog | | **preflight** | `{ fields?: Record; columns?: Record> }` | optional | Translations for the action preflight panel | +| **refusals** | `Record }>` | optional | Refusal translations keyed by the code the action's `refusals` declares | ### Nested Shape: `TranslationData.dashboards[string]` @@ -901,6 +905,7 @@ Translation data for a single object | **params** | `Record }>` | optional | Action parameter translations keyed by parameter name | | **resultDialog** | `{ title?: string; description?: string; acknowledge?: string; fields?: Record; … }` | optional | Translations for the action result dialog | | **preflight** | `{ fields?: Record; columns?: Record> }` | optional | Translations for the action preflight panel | +| **refusals** | `Record }>` | optional | Refusal translations keyed by the code the action's `refusals` declares | ### Nested Shape: `TranslationItem.dashboards[string]` diff --git a/packages/spec/api-surface/system.json b/packages/spec/api-surface/system.json index 99f9f9fd61c..e44e9dbd6a7 100644 --- a/packages/spec/api-surface/system.json +++ b/packages/spec/api-surface/system.json @@ -851,6 +851,7 @@ "WorkerConfigSchema (const)", "WorkerStats (type)", "WorkerStatsSchema (const)", + "actionRefusalMessageKey (function)", "audienceAllows (function)", "audiencePermitsSelfRegistration (function)", "authorisesIrreversibleAction (function)", diff --git a/packages/spec/export-origins/system.json b/packages/spec/export-origins/system.json index b0bb4bb7ae1..281d89f8640 100644 --- a/packages/spec/export-origins/system.json +++ b/packages/spec/export-origins/system.json @@ -811,6 +811,7 @@ "WorkerConfigSchema": "src/system/worker.zod.ts#WorkerConfigSchema (const)", "WorkerStats": "src/system/worker.zod.ts#WorkerStats (type)", "WorkerStatsSchema": "src/system/worker.zod.ts#WorkerStatsSchema (const)", + "actionRefusalMessageKey": "src/system/i18n-resolver.ts#actionRefusalMessageKey (function)", "audienceAllows": "src/system/book.zod.ts#audienceAllows (function)", "audiencePermitsSelfRegistration": "src/system/auth-config.zod.ts#audiencePermitsSelfRegistration (function)", "authorisesIrreversibleAction": "src/system/migration.zod.ts#authorisesIrreversibleAction (function)",