Skip to content

Commit 7878cf0

Browse files
fix(service-storage): translate the storage_attachment_member permission set (#35796)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} --> _Requested by **Tesla** · [project thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoA1ALjVcUcAuAA15MyUocBx)_ Fixes #33986 Clause-②: no Metadata-protocol: none ## 维护者速读 - 中文控制台的管理员在「设置 → 权限集分配」里看到的附件成员权限集,名称和说明从英文变成中文,另外九种界面语言同样有了译文。 - 替使用非英文界面的管理员解决:存储服务带来的这个附件权限集漏了翻译,是列表里唯一一行英文。 - 出错时最多是某种语言的措辞不够贴切,权限本身和发放时机都不变,可以直接撤回。 - 无 ## What changes - `packages/services/service-storage/src/translations/permission-sets.ts` (new, hand-authored): the `permissions.storage_attachment_member.label` / `.description` translations for the ten locales the sibling built-in sets ship (zh-CN, ja-JP, es-ES, zh-Hant, ar, fr, pt-BR, ru, de, ko). zh-CN label: 附件:读取与添加(所有成员). - `packages/services/service-storage/src/translations/index.ts`: each translated locale of `StorageTranslations` now carries that `permissions` group beside its generated `objects`, the same shape plugin-security's `SecurityTranslations` uses. No generated file is touched. - Changeset: `@objectstack/service-storage` patch. ## Why The set is declared by service-storage (`attachment-member-grant.ts`) and contributed to the member baseline at runtime, so plugin-security's permission-set bundle never carried it: that bundle's own pin (`permission-set-descriptions.test.ts`, "translates exactly the built-in sets") limits it to the nine sets plugin-security declares. The owner of the set is the owner of its translation (ADR-0029 D8). Both bundles reach the i18n service through `loadTranslations`, which deep-merges, so the two `permissions` groups sit side by side and `translatePermissionSet` resolves either set on `GET /meta/permission`. ## Tests - New `src/translations/permission-sets.test.ts` (24 tests): per translated locale, the group holds exactly `storage_attachment_member`, label and description differ from the English, the label keeps the English label's shape, and `translateMetadataDocument('permission', …)` serves the translated label and description; `en` serves the set as declared (same reference); CONTROL: a stand-in sibling `member_default` group and this bundle loaded into `createMemoryI18n` in both orders, and both sets still resolve in zh-CN. - Ablation (one-off, not committed): deleting the `permissions:` line from `withSets` in `index.ts` through `scripts/ablation-replace.mjs` (anchor 1 -> 0, blob ab15c3d -> 6f1df31f0bcd) turns the file red, `Tests 12 failed | 12 passed (24)` (the ten per-locale group checks and both merge controls); restored, blob == HEAD, `git diff HEAD` empty. ## Acceptance notes - The label follows the English label's shape (`Attachments: read and attach (every member)`, a colon and no ` — `), the rule plugin-security's pin holds its own labels to, rather than the siblings' ` — ` split; the English source label is unchanged (this card changes translations only). - The English description is two sentences and names the object; the translations follow the source. The siblings' one-sentence description pin covers plugin-security's own sets only. - Untouched and binding: what the set grants and when it is contributed (maintainer ruling 6879388034, the ⛔ on `contributeAttachmentMemberGrant`). - `check:i18n-coverage` lints static stack configs and cannot see this runtime-contributed set; its count is unchanged. ## Verification Two-minute check: `pnpm --filter @objectstack/service-storage exec vitest run --maxWorkers=2 src/translations/permission-sets.test.ts` prints `Tests 24 passed (24)`. <details><summary>Local runs</summary> - `pnpm --filter '@objectstack/service-storage^...' build`: lock VERDICT command-exit 0. - `pnpm --filter @objectstack/service-storage test` + `typecheck`: `Test Files 87 passed (87)`, `Tests 1697 passed | 1 skipped (1698)`, `check:test-typecheck: OK`; VERDICT command-exit 0 (head 50a8e08). - Final head f6ce5b4: focused `permission-sets` + `bundle-ownership` + `attachment-member-grant` tests `Tests 36 passed (36)`, `typecheck`, `check:nul-bytes`, `check:i18n-stale-fill`: VERDICT command-exit 0. - `dispatch-gates --ran`: 63 of 65 derived families run, exit 0 each. NOT MEASURED locally: `check:i18n` and `check:dual-build-cjs-loads`, reason: both need the whole workspace build (exit 3, prerequisite not met); declared to CI. - `overlap-check --branch=HEAD`: VERDICT clean exit 0. </details> ## Human Minimum - [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic. - [x] 2. Every name I added uses the casing for its kind. - [x] 3. No formatter ran; `pnpm lint` passes (CI-owned run). - [x] 4. One issue, one branch off an up-to-date `main`, one pull request. - [x] 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset. - [x] 6. `packages/spec` touched: not touched. - [x] 7. No hand edits to `content/docs/references/`, `packages/*/CHANGELOG.md` or `content/docs/releases/`. - [x] 8. Title, body and comments are in English. - [x] The *Before Submitting* list in CONTRIBUTING.md is done. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01L9qibyy9KSA69EGZtjDj9c --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 1a21ce9 commit 7878cf0

4 files changed

Lines changed: 143 additions & 10 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/service-storage': patch
3+
---
4+
5+
fix(service-storage): translate the built-in `storage_attachment_member` permission set
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The permission set this service contributes to every member's baseline ("Attachments: read and attach (every member)") now ships its label and description in every locale the platform's other built-in sets ship (zh-CN, ja-JP, es-ES, zh-Hant, ar, fr, pt-BR, ru, de, ko). Setup's permission-set lists in a translated Console no longer show it as the one English row. What the set grants, and when it is contributed, is unchanged.

‎packages/services/service-storage/src/translations/index.ts‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { ptBRGeneratedSourceHashes } from './pt-BR.source-hashes.generated.js';
3535
import { ruGeneratedSourceHashes } from './ru.source-hashes.generated.js';
3636
import { deGeneratedSourceHashes } from './de.source-hashes.generated.js';
3737
import { koGeneratedSourceHashes } from './ko.source-hashes.generated.js';
38+
import { storagePermissionSets } from './permission-sets.js';
3839

3940
/**
4041
* ## The provenance companions are READ here, not merely recorded
@@ -65,16 +66,22 @@ import { koGeneratedSourceHashes } from './ko.source-hashes.generated.js';
6566
*/
6667
const enSource: TranslationData = { objects: enObjects };
6768

69+
/** The hand-authored `permissions` group sits outside `withSourceFallback`'s inputs. */
70+
const withSets = (locale: string, data: TranslationData): TranslationData => ({
71+
...data,
72+
permissions: storagePermissionSets[locale],
73+
});
74+
6875
export const StorageTranslations: TranslationBundle = {
6976
en: enSource,
70-
'zh-CN': withSourceFallback({ objects: zhCNObjects }, enSource, undefined, zhCNGeneratedSourceHashes),
71-
'ja-JP': withSourceFallback({ objects: jaJPObjects }, enSource, undefined, jaJPGeneratedSourceHashes),
72-
'es-ES': withSourceFallback({ objects: esESObjects }, enSource, undefined, esESGeneratedSourceHashes),
73-
'zh-Hant': withSourceFallback({ objects: zhHantObjects }, enSource, undefined, zhHantGeneratedSourceHashes),
74-
'ar': withSourceFallback({ objects: arObjects }, enSource, undefined, arGeneratedSourceHashes),
75-
'fr': withSourceFallback({ objects: frObjects }, enSource, undefined, frGeneratedSourceHashes),
76-
'pt-BR': withSourceFallback({ objects: ptBRObjects }, enSource, undefined, ptBRGeneratedSourceHashes),
77-
'ru': withSourceFallback({ objects: ruObjects }, enSource, undefined, ruGeneratedSourceHashes),
78-
'de': withSourceFallback({ objects: deObjects }, enSource, undefined, deGeneratedSourceHashes),
79-
'ko': withSourceFallback({ objects: koObjects }, enSource, undefined, koGeneratedSourceHashes),
77+
'zh-CN': withSets('zh-CN', withSourceFallback({ objects: zhCNObjects }, enSource, undefined, zhCNGeneratedSourceHashes)),
78+
'ja-JP': withSets('ja-JP', withSourceFallback({ objects: jaJPObjects }, enSource, undefined, jaJPGeneratedSourceHashes)),
79+
'es-ES': withSets('es-ES', withSourceFallback({ objects: esESObjects }, enSource, undefined, esESGeneratedSourceHashes)),
80+
'zh-Hant': withSets('zh-Hant', withSourceFallback({ objects: zhHantObjects }, enSource, undefined, zhHantGeneratedSourceHashes)),
81+
'ar': withSets('ar', withSourceFallback({ objects: arObjects }, enSource, undefined, arGeneratedSourceHashes)),
82+
'fr': withSets('fr', withSourceFallback({ objects: frObjects }, enSource, undefined, frGeneratedSourceHashes)),
83+
'pt-BR': withSets('pt-BR', withSourceFallback({ objects: ptBRObjects }, enSource, undefined, ptBRGeneratedSourceHashes)),
84+
'ru': withSets('ru', withSourceFallback({ objects: ruObjects }, enSource, undefined, ruGeneratedSourceHashes)),
85+
'de': withSets('de', withSourceFallback({ objects: deObjects }, enSource, undefined, deGeneratedSourceHashes)),
86+
'ko': withSets('ko', withSourceFallback({ objects: koObjects }, enSource, undefined, koGeneratedSourceHashes)),
8087
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
import { describe, it, expect } from 'vitest';
4+
import { createMemoryI18n } from '@objectstack/core';
5+
import { translateMetadataDocument } from '@objectstack/spec/system';
6+
import { ATTACHMENT_MEMBER_PERMISSION_SET as SET } from '../attachment-member-grant.js';
7+
import { StorageTranslations } from './index.js';
8+
9+
/**
10+
* The permission set this service declares is served in every locale this
11+
* service ships, beside the sets plugin-security translates: Setup's
12+
* permission-set list reads no English row for it in a translated Console.
13+
*/
14+
const LOCALES = Object.keys(StorageTranslations).filter((l) => l !== 'en');
15+
const SPLIT = ' — ';
16+
17+
describe('storage_attachment_member translations', () => {
18+
it('the bundle carries translated locales', () => {
19+
expect(LOCALES).toEqual(expect.arrayContaining(['zh-CN', 'ja-JP', 'es-ES']));
20+
});
21+
22+
describe.each(LOCALES)('%s', (locale) => {
23+
const group = StorageTranslations[locale]?.permissions ?? {};
24+
25+
it('translates exactly the set this service declares', () => {
26+
expect(Object.keys(group)).toEqual([SET.name]);
27+
const { label, description } = group[SET.name] ?? {};
28+
expect(label).not.toBe(SET.label);
29+
expect(description).not.toBe(SET.description);
30+
expect(label?.split(SPLIT).length, 'not in the English label shape').toBe(SET.label.split(SPLIT).length);
31+
});
32+
33+
it('is served in this locale', () => {
34+
const served = translateMetadataDocument('permission', SET, StorageTranslations, { locale });
35+
expect(served).toEqual({ ...SET, ...group[SET.name] });
36+
});
37+
});
38+
39+
it('the English locale serves the set as declared', () => {
40+
expect(translateMetadataDocument('permission', SET, StorageTranslations, { locale: 'en' })).toBe(SET);
41+
});
42+
43+
// The i18n service deep-merges every package's bundle: this group must sit
44+
// beside another package's `permissions` group, not replace it.
45+
it.each([false, true])('a sibling set still resolves after the merge (storage loaded first: %s)', (first) => {
46+
const i18n = createMemoryI18n();
47+
const sibling = { permissions: { member_default: { label: '成员 — 标准访问' } } };
48+
const loads = [sibling, StorageTranslations['zh-CN']!];
49+
for (const data of first ? loads.reverse() : loads) i18n.loadTranslations('zh-CN', data);
50+
const bundle = { 'zh-CN': i18n.getTranslations('zh-CN') };
51+
const member = { name: 'member_default', label: 'Member — Standard Access' };
52+
expect(translateMetadataDocument('permission', member, bundle, { locale: 'zh-CN' }).label).toBe('成员 — 标准访问');
53+
const served = translateMetadataDocument('permission', SET, bundle, { locale: 'zh-CN' });
54+
expect(served.label).toBe(StorageTranslations['zh-CN']?.permissions?.[SET.name]?.label);
55+
});
56+
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* The `permissions.<name>` translations of the one permission set this service
5+
* declares, `storage_attachment_member` (`../attachment-member-grant.ts`),
6+
* overlaid on the served set by `translatePermissionSet`. HAND-AUTHORED (the
7+
* extract runs objects-only): when the set's label or description changes,
8+
* re-translate every locale here in the same change; nothing marks one stale.
9+
*/
10+
11+
import type { TranslationData } from '@objectstack/spec/system';
12+
13+
type PermissionSetTranslations = NonNullable<TranslationData['permissions']>;
14+
15+
const entry = (label: string, description: string): PermissionSetTranslations => ({
16+
storage_attachment_member: { label, description },
17+
});
18+
19+
export const storagePermissionSets: Readonly<Record<string, PermissionSetTranslations>> = {
20+
'zh-CN': entry(
21+
'附件:读取与添加(所有成员)',
22+
'每位成员对附件(sys_attachment)的读取与新建权限,由存储服务随附件的行级访问检查一并提供。成员可为自己能编辑的记录添加文件,并查看自己能读取的记录的文件。',
23+
),
24+
'ja-JP': entry(
25+
'添付ファイル:参照と添付(全メンバー)',
26+
'すべてのメンバーに添付ファイル(sys_attachment)の参照と作成を許可し、ストレージサービスが添付ファイルの行チェックと合わせて付与します。メンバーは編集できるレコードにファイルを添付し、参照できるレコードのファイルを見られます。',
27+
),
28+
'es-ES': entry(
29+
'Adjuntos: leer y adjuntar (todos los miembros)',
30+
'Lectura y creación en sys_attachment para todo miembro, aportadas por el servicio de almacenamiento junto a los controles por fila de los adjuntos. Un miembro adjunta archivos a los registros que puede editar y ve los de los registros que puede leer.',
31+
),
32+
'zh-Hant': entry(
33+
'附件:讀取與新增(所有成員)',
34+
'每位成員對附件(sys_attachment)的讀取與建立權限,由儲存服務隨附件的逐筆存取檢查一併提供。成員可為自己能編輯的記錄新增檔案,並檢視自己能讀取的記錄的檔案。',
35+
),
36+
'ar': entry(
37+
'المرفقات: قراءة وإرفاق (كل الأعضاء)',
38+
'قراءة وإنشاء على sys_attachment لكل عضو، توفّرهما خدمة التخزين إلى جانب فحوص صفوف المرفقات. يرفق العضو ملفًا بسجل يمكنه تعديله ويرى ملفات السجل الذي يمكنه قراءته.',
39+
),
40+
'fr': entry(
41+
'Pièces jointes : lire et joindre (tous les membres)',
42+
'Lecture et création sur sys_attachment pour tout membre, apportées par le service de stockage avec les contrôles par ligne des pièces jointes. Un membre joint un fichier à un enregistrement qu’il peut modifier et voit ceux d’un enregistrement qu’il peut lire.',
43+
),
44+
'pt-BR': entry(
45+
'Anexos: ler e anexar (todos os membros)',
46+
'Leitura e criação em sys_attachment para todo membro, fornecidas pelo serviço de armazenamento junto às verificações por linha dos anexos. Um membro anexa arquivos aos registros que pode editar e vê os dos registros que pode ler.',
47+
),
48+
'ru': entry(
49+
'Вложения: чтение и прикрепление (все участники)',
50+
'Чтение и создание в sys_attachment для каждого участника, предоставляемые службой хранения вместе с построчными проверками вложений. Участник прикрепляет файл к записи, которую может изменять, и видит файлы записей, которые может читать.',
51+
),
52+
'de': entry(
53+
'Anhänge: lesen und anhängen (alle Mitglieder)',
54+
'Lesen und Anlegen in sys_attachment für jedes Mitglied, bereitgestellt vom Speicherdienst zusammen mit den zeilenweisen Prüfungen der Anhänge. Ein Mitglied hängt Dateien an Datensätze an, die es bearbeiten darf, und sieht die Dateien der Datensätze, die es lesen darf.',
55+
),
56+
'ko': entry(
57+
'첨부 파일: 읽기 및 첨부(모든 멤버)',
58+
'모든 멤버에게 sys_attachment의 읽기와 생성을 허용하며, 스토리지 서비스가 첨부 파일 행 검사와 함께 제공합니다. 멤버는 편집할 수 있는 레코드에 파일을 첨부하고 읽을 수 있는 레코드의 파일을 볼 수 있습니다.',
59+
),
60+
};

0 commit comments

Comments
 (0)