Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .changeset/37524-milestone-summary-translations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@objectstack/spec': minor
'@objectstack/plugin-audit': patch
'@objectstack/lint': patch
---

feat(spec,plugin-audit): an activity milestone's timeline row reads in the reader's language — `objects.<object>._milestones.<field>.<value>.summary`

Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: follow-up #37585

- **Translation slot.** An object translation accepts `_milestones`, keyed by an `activityMilestones` entry's watched `field` and then the `value` it fires on, each carrying `summary`: the milestone's template in that language, with the same `{field}` tokens. `milestones` and `activityMilestones` are accepted as aliases of the group. `resolveObjectMilestoneSummary` (`@objectstack/spec/system`) reads it along the locale chain.
- **Timeline rows.** A fired milestone's `sys_activity` row now stores a summary code (`metadata.summary_message`, `key: 'activityMilestone'`): the pair, and each interpolated token's value with the select option it matched. On a read whose caller has a locale, a language that translates the milestone serves the row's `summary` composed from its template, a select token named by the option label in that language. The stored `summary` is unchanged — the authored sentence — and a language with no entry, a read with no locale, and every row written before this change read it as stored. A tenant that reworded a packaged milestone's `summary` keeps its words. The field redaction still judges the composed text by the fields the row was composed from.
- **Extraction and references.** `os i18n extract` scaffolds the key for each milestone pair (the first entry of a repeated pair, the one that fires), and the translation-reference rule flags a `_milestones` key over a pair no milestone of the object declares.
- **Docs.** `content/docs/ui/translations.mdx` and the i18n standard's reference table name the key.
1 change: 1 addition & 0 deletions content/docs/protocol/kernel/i18n-standard.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,7 @@ beneath an action entry are judged the same way under either.
| `objects.{object}._tabs.{tab}` | a filter-preset tab's `name` in `interfaceConfig.userFilters.tabs` on a page over that object (`interfaceConfig.source`, else the page's `object`) — a list view's own `tabs` has no renderer and is not resolvable |
| `objects.{object}._relatedLists.{list}` | the `list` of an object-form `relatedLists` entry on that object that authors a `label` — a dotted `object.field` is one key; a key over an entry with no `label`, a bare-string entry or a built-in tab is an orphan, because that tab's title is the child lookup field's `relatedListTitle`, translated on the child |
| `objects.{object}._validations.{rule}` | a validation rule's `name` in that object's `validations[]` or in an `objectExtensions[]` entry aimed at it — a `conditional` rule's `then` / `otherwise` branch included |
| `objects.{object}._milestones.{field}.{value}` | an `activityMilestones[]` entry of that object watching `field` and firing on `value` |
| `objects.{object}._actions.{action}` | an action bound to that object: one in its `actions`, or a stack-level action whose `objectName` is that object |
| `globalActions.{action}` | an action with **no** `objectName` — a key naming a bound action is an error whose message names the `objects.{owner}._actions.{action}` key to write instead, `{owner}` being the action's own `objectName` |
| `{action}.params.{param}` | a param's `name` on that action |
Expand Down
11 changes: 11 additions & 0 deletions content/docs/references/system/translation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Translation data for a single object
| **_tabs** | `Record<string, { label?: string }>` | optional | Filter-preset tab translations keyed by tab name |
| **_relatedLists** | `Record<string, { label?: string }>` | optional | Record-page related list titles keyed by the relatedLists entry list name |
| **_validations** | `Record<string, { message?: string }>` | optional | Custom validation-rule messages keyed by rule name (`ValidationRuleSchema.name`) |
| **_milestones** | `Record<string, Record<string, { summary?: string }>>` | optional | Activity-milestone summary translations keyed by the watched field, then by the value the milestone fires on |

### Nested Shape: `ObjectTranslationData.fields[string]`

Expand Down Expand Up @@ -169,6 +170,12 @@ Translation data for a single field
| :--- | :--- | :--- | :--- |
| **message** | `string` | optional | Translated rejection message — overlays the rule's authored `message` on every rejected write |

### Nested Shape: `ObjectTranslationData._milestones[string][string]`

| Property | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| **summary** | `string` | optional | Translated milestone summary template — the same `{field}` tokens as the milestone's authored `summary` |


---

Expand Down Expand Up @@ -224,6 +231,7 @@ Translation data for a single object
| **_tabs** | `Record<string, { label?: string }>` | optional | Filter-preset tab translations keyed by tab name |
| **_relatedLists** | `Record<string, { label?: string }>` | optional | Record-page related list titles keyed by the relatedLists entry list name |
| **_validations** | `Record<string, { message?: string }>` | optional | Custom validation-rule messages keyed by rule name (`ValidationRuleSchema.name`) |
| **_milestones** | `Record<string, Record<string, { summary?: string }>>` | optional | Activity-milestone summary translations keyed by the watched field, then by the value the milestone fires on |

### Nested Shape: `PlatformTranslationData.picklists[string]`

Expand Down Expand Up @@ -415,6 +423,7 @@ Translation data for a single object
| **_tabs** | `Record<string, { label?: string }>` | optional | Filter-preset tab translations keyed by tab name |
| **_relatedLists** | `Record<string, { label?: string }>` | optional | Record-page related list titles keyed by the relatedLists entry list name |
| **_validations** | `Record<string, { message?: string }>` | optional | Custom validation-rule messages keyed by rule name (`ValidationRuleSchema.name`) |
| **_milestones** | `Record<string, Record<string, { summary?: string }>>` | optional | Activity-milestone summary translations keyed by the watched field, then by the value the milestone fires on |

### Nested Shape: `ServedTranslationData.picklists[string]`

Expand Down Expand Up @@ -669,6 +678,7 @@ Translation data for a single object
| **_tabs** | `Record<string, { label?: string }>` | optional | Filter-preset tab translations keyed by tab name |
| **_relatedLists** | `Record<string, { label?: string }>` | optional | Record-page related list titles keyed by the relatedLists entry list name |
| **_validations** | `Record<string, { message?: string }>` | optional | Custom validation-rule messages keyed by rule name (`ValidationRuleSchema.name`) |
| **_milestones** | `Record<string, Record<string, { summary?: string }>>` | optional | Activity-milestone summary translations keyed by the watched field, then by the value the milestone fires on |

### Nested Shape: `TranslationData.picklists[string]`

Expand Down Expand Up @@ -892,6 +902,7 @@ Translation data for a single object
| **_tabs** | `Record<string, { label?: string }>` | optional | Filter-preset tab translations keyed by tab name |
| **_relatedLists** | `Record<string, { label?: string }>` | optional | Record-page related list titles keyed by the relatedLists entry list name |
| **_validations** | `Record<string, { message?: string }>` | optional | Custom validation-rule messages keyed by rule name (`ValidationRuleSchema.name`) |
| **_milestones** | `Record<string, Record<string, { summary?: string }>>` | optional | Activity-milestone summary translations keyed by the watched field, then by the value the milestone fires on |

### Nested Shape: `TranslationItem.picklists[string]`

Expand Down
1 change: 1 addition & 0 deletions content/docs/ui/translations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default defineStack({
| Column headers of a table in an action's result dialog or preflight panel | `objects.<name>._actions.<action>.resultDialog.columns.<field path>.<column path>` / `.preflight.columns.<field path>.<column path>` — a sibling of `fields`, both paths written literally, dots included |
| Form sections | `objects.<name>._sections.<section>` |
| Custom validation-rule messages | `objects.<name>._validations.<rule>.message` |
| Activity-milestone timeline rows | `objects.<name>._milestones.<field>.<value>.summary` — keyed by the milestone's watched `field` and the `value` it fires on; the template keeps the authored `{field}` tokens, and a reader in that language reads the row composed from it, a select token named by its translated option label. A language with no entry reads the authored `summary` |
| App navigation | `apps.<app>.navigation.<id>.label` |
| Dashboard label / description | `dashboards.<name>.label` / `description` |
| Dashboard widget title / description (the card-header subtitle) | `dashboards.<name>.widgets.<widgetId>.title` / `description` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ hand-patch a number here** — fix the code or the verdict and regenerate.

| Dir | Sites |
|---|---|
| `system/` | 409 |
| `system/` | 410 |
7 changes: 7 additions & 0 deletions examples/app-showcase/src/system/translations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,13 @@ export const ShowcaseTranslationBundle = {
_validations: {
task_status_flow: { message: '任务状态流转无效。' },
},
// The object's one activity milestone (`status` → `done`), keyed by
// the pair that fires it; `{title}` is the authored template's token.
// A zh-CN reader's timeline row reads this; the stored row keeps the
// authored English sentence for every other reader.
_milestones: {
status: { done: { summary: '✅ 任务已完成:{title}' } },
},
_views: {
// The default list — keyed `default`, see showcase_project above.
default: { label: '全部任务' },
Expand Down
68 changes: 68 additions & 0 deletions packages/lint/src/i18n-milestones-37524.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
//
// `objects.<object>._milestones.<field>.<value>.summary` on the two lint
// readers every object translation group has: the extractor walk that
// scaffolds and gates the key, and the orphan rule that refuses a key nothing
// reads. Both key on the pair an `activityMilestones` entry fires on.

import { describe, it, expect } from 'vitest';
import { collectExpectedEntries } from './i18n-walk.js';
import { validateTranslationReferences, TRANSLATION_TARGET_UNKNOWN } from './validate-translation-references.js';

const CASE = {
name: 'crm_case',
label: 'Case',
fields: {
subject: { name: 'subject', type: 'text', label: 'Subject' },
status: { name: 'status', type: 'select', label: 'Status', options: [{ value: 'open', label: 'Open' }, { value: 'closed', label: 'Closed' }] },
},
activityMilestones: [
{ field: 'status', value: 'closed', summary: 'Case closed — {subject}' },
// The same pair again: the writer fires the first, so this one is never rendered.
{ field: 'status', value: 'closed', summary: 'Never shown' },
{ field: 'status', value: 'open', summary: 'Case reopened — {subject}' },
],
};

describe('collectExpectedEntries — an activity milestone\'s summary (#37524)', () => {
const entries = collectExpectedEntries({ objects: [CASE] }, { warnedGroups: new Set() });
const milestoneEntries = entries.filter((e) => e.path[2] === '_milestones');

it('emits one key per fired pair, seeded with the authored template, tokens and all', () => {
expect(milestoneEntries.map((e) => [e.path, e.sourceValue])).toEqual([
[['objects', 'crm_case', '_milestones', 'status', 'closed', 'summary'], 'Case closed — {subject}'],
[['objects', 'crm_case', '_milestones', 'status', 'open', 'summary'], 'Case reopened — {subject}'],
]);
expect(milestoneEntries.every((e) => e.source === 'object' && e.objectName === 'crm_case')).toBe(true);
});
});

describe('validateTranslationReferences — _milestones (#37524)', () => {
const stackWith = (milestones: Record<string, unknown>) => ({
objects: [CASE],
translations: [{ 'zh-CN': { objects: { crm_case: { _milestones: milestones } } } }],
});

it('resolves a key over each declared pair', () => {
expect(validateTranslationReferences(stackWith({
status: { closed: { summary: '工单已关闭 — {subject}' }, open: { summary: '工单已重开 — {subject}' } },
}))).toEqual([]);
});

it('flags a value no milestone of the field fires on, and a field no milestone watches', () => {
const findings = validateTranslationReferences(stackWith({
status: { close: { summary: '已关闭' } },
priority: { high: { summary: '高' } },
}));
expect(findings.map((f) => [f.rule, f.severity, f.path])).toEqual([
[TRANSLATION_TARGET_UNKNOWN, 'error', 'translations[0]["zh-CN"].objects.crm_case._milestones.status.close'],
[TRANSLATION_TARGET_UNKNOWN, 'error', 'translations[0]["zh-CN"].objects.crm_case._milestones.priority.high'],
]);
// A misspelt value is pointed at the declared one it nearly names.
expect(findings[0].message).toContain('"closed"');
for (const f of findings) {
expect(f.message.length, f.message).toBeLessThanOrEqual(200);
expect(f.hint.length, f.hint).toBeLessThanOrEqual(200);
}
});
});
30 changes: 30 additions & 0 deletions packages/lint/src/i18n-walk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
* ^ a bulk param spells its hint `help`; an ACTION param spells the same
* idea `helpText` (`ui/bulk-action.zod.ts`'s known divergence)
* objects.<name>._validations.<rule>.message
* objects.<name>._milestones.<field>.<value>.summary (an `activityMilestones`
* entry's summary template)
* objects.<name>._relatedLists.<list>.label (an object-form `relatedLists`
* entry that authors a `label`)
* objects.<name>._actions.<action>.label
Expand Down Expand Up @@ -1002,6 +1004,28 @@ function pushValidationMessages(
}
}

/**
* Emit `objects.<object>._milestones.<field>.<value>.summary` for each
* `activityMilestones` entry (ADR-0052 §5b.2), seeded with its authored
* template, `{field}` tokens and all. Only the first entry of a `field` +
* `value` pair is emitted: the writer fires the first match, so a later
* entry's template is never rendered.
*/
function pushMilestoneSummaries(out: ExpectedEntry[], objectName: string, milestones: unknown): void {
if (!Array.isArray(milestones)) return;
const seen = new Set<string>();
for (const m of milestones) {
if (!m || typeof m !== 'object') continue;
const field = (m as any).field;
const value = (m as any).value;
if (typeof field !== 'string' || field.length === 0 || typeof value !== 'string' || value.length === 0) continue;
const pair = `${field}\u0000${value}`;
if (seen.has(pair)) continue;
seen.add(pair);
pushEntry(out, ['objects', objectName, '_milestones', field, value, 'summary'], (m as any).summary, 'object', { objectName });
}
}

/**
* Emit `objects.<object>._relatedLists.<list>.label` for every object-form
* `relatedLists` entry of an object that authors a `label` (the record page's
Expand Down Expand Up @@ -1653,6 +1677,12 @@ export function collectExpectedEntries(
// Custom validation-rule rejection messages (`_validations.<rule>.message`).
pushValidationMessages(out, objectName, obj.validations, 0);

// Activity-milestone summary templates (`_milestones.<field>.<value>.summary`,
// #37524): keyed by the watched field and the value the milestone fires on,
// the address `resolveObjectMilestoneSummary` reads. The first milestone
// declared for a pair is the one that fires, so a later duplicate gets no key.
pushMilestoneSummaries(out, objectName, obj.activityMilestones);

// Record-page related-list titles (`_relatedLists.<list>.label`): the
// `label` an object-form `relatedLists` entry authors on this parent,
// keyed by the entry's literal `list` (`object.field` is one key).
Expand Down
7 changes: 7 additions & 0 deletions packages/lint/src/validate-translation-references.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3855,6 +3855,7 @@ describe('validateTranslationReferences — object-branch coverage vs the schema
fieldGroups: [{ key: 'basics', label: 'Basics' }],
actions: [{ name: 'convert_lead', label: 'Convert' }],
validations: [{ name: 'lead_needs_name', type: 'script', message: 'Name is required' }],
activityMilestones: [{ field: 'name', value: 'won', summary: 'Lead won: {name}' }],
},
],
views: [{ name: 'open_leads', objectName: 'crm_lead', label: 'Open Leads' }],
Expand Down Expand Up @@ -3920,6 +3921,11 @@ describe('validateTranslationReferences — object-branch coverage vs the schema
ghost: { _validations: { ghost_rule: { message: 'Ghost' } } },
path: 'translations[0].en.objects.crm_lead._validations.ghost_rule',
},
_milestones: {
kind: 'reference-checked',
ghost: { _milestones: { name: { ghost_value: { summary: 'Ghost' } } } },
path: 'translations[0].en.objects.crm_lead._milestones.name.ghost_value',
},
};

it('classifies every key `ObjectTranslationDataSchema` declares, and no key it does not', () => {
Expand Down Expand Up @@ -3955,6 +3961,7 @@ describe('validateTranslationReferences — object-branch coverage vs the schema
_actions: { convert_lead: { label: 'Convert' } },
_tabs: { urgent: { label: 'Urgent' } },
_validations: { lead_needs_name: { message: 'A name is required' } },
_milestones: { name: { won: { summary: 'Lead won: {name}' } } },
}),
);
expect(findings).toEqual([]);
Expand Down
Loading
Loading