Repository navigation
Expand file tree
/
Copy pathi18n-extract.config.ts
More file actions
340 lines (320 loc) · 16.4 KB
/
Copy pathi18n-extract.config.ts
File metadata and controls
340 lines (320 loc) · 16.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
/**
* Synthetic stack config for `os i18n extract`.
*
* Imports every sys_* platform object plus the Setup app's existing
* translations so that `os i18n extract` (and `os i18n check`) can be
* pointed at this file via `bundle-require`:
*
* os i18n extract packages/platform-objects/scripts/i18n-extract.config.ts \
* --locales=zh-CN,ja-JP,es-ES \
* --fill=default \
* --source-hashes \
* --out=packages/platform-objects/src/apps/translations
*
* `--source-hashes` also emits `<locale>.source-hashes.generated.ts` — the
* provenance companion from maintainer ruling #12069 Option A (commit 09b4f4e4e). Without
* it, a leaf filled from the source and then left behind when the source was
* revised is indistinguishable BY VALUE from a real translation, so it publishes
* a superseded draft under a green `check:i18n` forever. This package opts in;
* the other eight bundle sets do not yet, and until they do their generated
* leaves stay legacy-trusted (never reported, never wrong about).
*
* From the repo root that is `pnpm i18n:extract`, and `pnpm check:i18n` is the
* same run with `--check`: it writes nothing and fails if the committed
* bundles differ from a fresh extract. CI runs the latter (lint.yml), so a
* schema change that adds, removes or renames a label now fails the build
* instead of silently rotting the bundles until someone re-runs this by hand
* (#3670).
*
* The config is **build-time only** — it is not deployed and not used at
* runtime. The Setup App still ships its own bundle via plugin-auth.
*
* NOTE: `translations` is the merge baseline — what a re-run treats as
* ALREADY TRANSLATED. It must therefore carry everything this config
* declares, from both halves of this package's i18n:
*
* - `objects` / `metadataForms` — GENERATED. Emitted by this command into
* `<locale>.objects.generated.ts` / `<locale>.metadata-forms.generated.ts`
* and gated by `pnpm check:i18n`, which fails when the committed bundle
* differs from a fresh extract.
* - `apps` / `dashboards` / `pages` — HAND-AUTHORED in `<locale>.ts`, and
* they have to stay that way. The Setup app is a shell of empty group
* anchors (ADR-0029 D7); its ~25 menu entries are contributed at RUNTIME
* by `SETUP_NAV_CONTRIBUTIONS` and by capability plugins, so a bundle
* generated from a static walk of `SETUP_APP` would be structurally
* incomplete — regenerating over it would DELETE 40 live nav
* translations per locale. The gate for `apps` / `dashboards` is
* `pnpm check:app-nav-i18n` (`packages/cli/scripts/check-app-nav-i18n.mjs`),
* which boots the real composition and judges the MERGED app — not the
* bundle-drift gate, and not the coverage ratchet. `pages` is judged by
* `packages/cli/test/platform-page-i18n-parity.test.ts` instead: it moved
* off that roster on #15743, because a NAV roster (every entry must land a
* nav id, and `@objectstack/plugin-auth` cannot) is structurally unable to
* reach two of the six pages the platform ships.
*
* This paragraph used to end "Their gate is the coverage ratchet
* (`scripts/check-i18n-coverage.mjs`), baselined at 0 for this package",
* and that sentence was half of the #5750 defect. The ratchet runs
* `os lint` over STATIC configs — the same static walk two lines up says
* is structurally incomplete for Setup — so it could never see a
* runtime-contributed label. Its 0 for this package meant "not looked at
* here", not "checked, clean", while `app-nav-translation-parity.test.ts`
* excluded Setup and pointed at the ratchet from the other side. Four
* `zh-CN` nav labels were missing under a fully green build. The ratchet
* still gates this package's STATIC declared surface and its 0 is real for
* that; it simply is not the owner of the runtime half.
*
* The SAME `0` carries the same ambiguity for a SECOND runtime-composed
* surface, and this config is why: it declares no `pages` key at all. The
* three shipped record pages -- `sys_user_detail`,
* `sys_organization_detail` (plugin-auth) and `sys_position_detail`
* (plugin-security) -- reach the platform through those plugins, so they
* are in no extract config's population and the ratchet never looked at
* them either. Declaring them here would not by itself fix that, which is
* the part worth writing down: measured through the real
* `collectExpectedEntries`, the three offer exactly THREE keys between
* them (one page-level `label` each). All three author `regions: []` and
* put every component under `slots.*`. Since #16772 the shared walk
* (`walkAddressedPageComponents`, `@objectstack/spec/system`) roots at
* `slots.<slot>` as well as `regions[].components[]`, so it now REACHES
* every one of those components -- and not one of them carries an `id`,
* so none is addressable by `pages.<name>.components.<id>`: the 45
* further authored copy sites, every one an inline `{ en, 'zh-CN', ... }`
* locale map, still have no bundle face to be counted against. A
* config-only change would declare pages that offer nothing beyond their
* label: it would look like a fix and measure nothing.
*
* Their gate is `packages/cli/test/platform-page-i18n-parity.test.ts`,
* which owns both halves from the other side -- a `pages.*` bundle entry
* per shipped locale for every page the
* `@objectstack/platform-objects/pages` barrel exports, and a completeness
* check over every inline locale map on those documents, which is the half
* no extractor can reach. Whether the extractor SHOULD reach inline maps is
* a maintainer decision open on #14749; the inline map itself is the ruled
* authoring route (2026-08-06), not a workaround.
*
* Omitting the hand-authored half was a measurable bug, not a style choice:
* this config declares SETUP_APP / STUDIO_APP / ACCOUNT_APP and
* SystemOverviewDashboard, so coverage counted all 77 `apps.*`/`dashboards.*`
* keys as untranslated in every locale — 231 strings of phantom debt — while
* 76 of the 77 had been translated for months. Only
* `apps.studio.navigation.nav_app_builder.label` was genuinely missing.
*
* Still do NOT add `SetupAppTranslations` or `MetadataFormsTranslations`:
* those are the outer wrappers. Import the per-locale assembler (`en.js`,
* `zh-CN.js`, …) and pin `objects`/`metadataForms` to the generated files
* explicitly, as below.
*/
import { defineStack, type ObjectStackDefinition } from '@objectstack/spec';
// ── Identity ──────────────────────────────────────────────────────────────
import {
SysUser,
SysSession,
SysAccount,
SysVerification,
SysOrganization,
SysMember,
SysInvitation,
SysTeam,
SysTeamMember,
SysBusinessUnit,
SysBusinessUnitMember,
SysApiKey,
SysTwoFactor,
SysDeviceCode,
SysUserPreference,
SysPersonalView,
SysOauthApplication,
SysOauthAccessToken,
SysOauthRefreshToken,
SysOauthConsent,
SysOauthResource,
SysOauthClientResource,
SysOauthClientAssertion,
SysJwks,
SysSsoProvider,
SysScimConnectionBinding,
SysScimConnectionCredential,
SysScimGroup,
SysScimGroupMember,
SysScimIdentityTombstone,
SysScimProjectionGrant,
SysScimSubject,
SysScimUser,
} from '../src/identity/index.js';
// ── Security ──────────────────────────────────────────────────────────────
// RBAC objects moved to @objectstack/plugin-security and sharing objects to
// @objectstack/plugin-sharing (ADR-0029 K2 / D8). Their i18n extraction must
// move to those plugins before the next regeneration; existing generated
// bundles keep working until then.
// ── Audit ─────────────────────────────────────────────────────────────────
// sys_audit_log / sys_activity / sys_comment moved to @objectstack/plugin-audit
// and sys_presence to @objectstack/service-realtime (ADR-0029 K2 / D8). Their
// i18n extraction lives in those packages (each has its own
// scripts/i18n-extract.config.ts + src/translations bundles) and the leftover
// copies here were pruned in the #2834 ⑤ regeneration — verified line-by-line
// against the owning plugins' bundles before committing. The
// bundle-ownership test guards this invariant from here on: this package's
// bundles carry ONLY this package's objects. sys_attachment stays here
// pending the storage-domain decomposition (it belongs with service-storage).
import {
SysNotification,
SysAttachment,
SysEmail,
SysEmailTemplate,
// sys_approval_* moved to @objectstack/plugin-approvals (ADR-0029 K2.b / D8).
SysJob,
SysJobRun,
SysJobQueue,
SysImportJob,
} from '../src/audit/index.js';
// ── Integration ───────────────────────────────────────────────────────────
// sys_webhook moved to @objectstack/plugin-webhooks per ADR-0029 (K2.a).
// Its i18n extraction must move to that plugin before the next regeneration
// (ADR-0029 D8); existing generated bundles keep working until then.
// ── Metadata ──────────────────────────────────────────────────────────────
import {
SysMetadataObject,
SysMetadataHistoryObject,
SysMetadataAuditObject,
} from '../src/metadata/index.js';
// ── System ────────────────────────────────────────────────────────────────
import { SysSetting, SysSecret, SysSettingAudit, SysMigration, SysExchangeRate } from '../src/system/index.js';
// ── Existing Setup app + dashboards + translations ────────────────────────
import { SETUP_APP } from '../src/apps/setup.app.js';
import { STUDIO_APP } from '../src/apps/studio.app.js';
import { ACCOUNT_APP } from '../src/apps/account.app.js';
import {
SystemOverviewDashboard,
} from '../src/apps/dashboards/index.js';
// ── Existing generated translations (merge baseline) ──────────────────────
// Import the generated files DIRECTLY (not via SetupAppTranslations, which
// would also pull in `apps.setup.*` hand-edits and is therefore safe — but
// using the generated files alone keeps the loop self-contained and lets
// `os i18n extract --merge` preserve every hand-translated string that
// already exists in `zh-CN.objects.generated.ts`, `zh-CN.metadata-forms.
// generated.ts`, etc. New schema keys are filled per `--fill`; existing
// keys are never overwritten.
import { enObjects } from '../src/apps/translations/en.objects.generated.js';
import { zhCNObjects } from '../src/apps/translations/zh-CN.objects.generated.js';
import { jaJPObjects } from '../src/apps/translations/ja-JP.objects.generated.js';
import { esESObjects } from '../src/apps/translations/es-ES.objects.generated.js';
import { enMetadataForms } from '../src/apps/translations/en.metadata-forms.generated.js';
import { zhCNMetadataForms } from '../src/apps/translations/zh-CN.metadata-forms.generated.js';
import { jaJPMetadataForms } from '../src/apps/translations/ja-JP.metadata-forms.generated.js';
import { esESMetadataForms } from '../src/apps/translations/es-ES.metadata-forms.generated.js';
// ── Existing hand-authored app/dashboard/page translations ────────────────
// The per-locale assemblers, NOT the `SetupAppTranslations` wrapper. Each one
// already re-exports the generated `objects` bundle above and adds the
// hand-written `apps` / `dashboards` / `pages` subtrees.
//
// These must be in the baseline for the same reason the generated bundles are,
// and the omission was measurable: `apps.*` and `dashboards.*` are declared by
// this config (it lists SETUP_APP / STUDIO_APP / ACCOUNT_APP and
// SystemOverviewDashboard) but their translations were not, so coverage
// reported all 77 as untranslated. 76 of them had been translated for months —
// only `apps.studio.navigation.nav_app_builder.label` was genuinely missing.
// The whole 231 in the ratchet baseline was that artifact, not a real debt.
//
// Safe for the emit, which is the reason the split existed: `--objects-only`
// writes `data.objects` alone, so nothing here can reach
// `<locale>.objects.generated.ts`. It only changes what MERGE and COVERAGE
// consider already-translated, which is exactly what was wrong.
import { en } from '../src/apps/translations/en.js';
import { zhCN } from '../src/apps/translations/zh-CN.js';
import { jaJP } from '../src/apps/translations/ja-JP.js';
import { esES } from '../src/apps/translations/es-ES.js';
/**
* The annotation is load-bearing, not decoration (#10868). `defineStack`
* already RETURNS `ObjectStackDefinition`, but that type is
* `z.input<typeof ObjectStackDefinitionSchema>` — a generic instantiation the
* declaration emitter does not preserve as an alias, so an un-annotated
* `export default` is emitted as the STRUCTURAL expansion instead. That
* expansion mentions `FormFieldInput` / `NavigationItemInput` /
* `StateNodeConfig`, which the root `@objectstack/spec` entry does not
* re-export, so tsc falls back to naming them through the file that physically
* declares them — a hash-named internal dist chunk it cannot address through
* the package's `exports` map (TS2883, "likely not portable"). Naming the
* public root-entry type here is what the diagnostic asks for and costs no
* precision: the annotated type is the function's own return type.
*/
const config: ObjectStackDefinition = defineStack({
objects: [
// Identity
SysUser,
SysSession,
SysAccount,
SysVerification,
SysOrganization,
SysMember,
SysInvitation,
SysTeam,
SysTeamMember,
SysBusinessUnit,
SysBusinessUnitMember,
SysApiKey,
SysTwoFactor,
SysDeviceCode,
SysUserPreference,
SysPersonalView,
SysOauthApplication,
SysOauthAccessToken,
SysOauthRefreshToken,
SysOauthConsent,
SysOauthResource,
SysOauthClientResource,
SysOauthClientAssertion,
SysJwks,
SysSsoProvider,
// Stable @better-auth/scim 1.7.x model set + the ObjectStack-owned
// credential store (#3653). The rc.1-era SysScimProvider retired under
// commit 4d25d22d4.
SysScimConnectionBinding,
SysScimConnectionCredential,
SysScimGroup,
SysScimGroupMember,
SysScimIdentityTombstone,
SysScimProjectionGrant,
SysScimSubject,
SysScimUser,
// Security: RBAC moved to @objectstack/plugin-security, sharing to
// @objectstack/plugin-sharing (ADR-0029 K2 / D8).
// Audit (sys_audit_log / sys_activity / sys_comment moved to
// @objectstack/plugin-audit; sys_presence to @objectstack/service-realtime;
// sys_attachment stays pending storage-domain decomposition)
SysNotification,
SysAttachment,
SysEmail,
SysEmailTemplate,
// sys_approval_* moved to @objectstack/plugin-approvals (ADR-0029 K2.b / D8).
SysJob,
SysJobRun,
SysJobQueue,
SysImportJob,
// Integration: sys_webhook moved to @objectstack/plugin-webhooks (ADR-0029 D8).
// Metadata
SysMetadataObject,
SysMetadataHistoryObject,
SysMetadataAuditObject,
// System
SysSetting,
SysSecret,
SysSettingAudit,
SysMigration,
SysExchangeRate,
] as any,
apps: [SETUP_APP, STUDIO_APP, ACCOUNT_APP] as any,
dashboards: [SystemOverviewDashboard] as any,
translations: [
// `...en` supplies the hand-authored apps/dashboards/pages; `objects` and
// `metadataForms` are then pinned to the generated files explicitly, so the
// merge baseline is the committed artifact rather than whatever the
// assembler happens to re-export.
{ en: { ...en, objects: enObjects, metadataForms: enMetadataForms } },
{ 'zh-CN': { ...zhCN, objects: zhCNObjects, metadataForms: zhCNMetadataForms } },
{ 'ja-JP': { ...jaJP, objects: jaJPObjects, metadataForms: jaJPMetadataForms } },
{ 'es-ES': { ...esES, objects: esESObjects, metadataForms: esESMetadataForms } },
],
});
export default config;