Skip to content

Commit 2958f17

Browse files
fix(auth): label the external organization role objectstack#25515 added, so the console type-checks against objectstack main (objectui#13427) (#13429)
<!-- claude-projects-attribution: {"github_login":"os-sales"} --> _Requested by **Sales** · [project thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuCB2j33nwkf8zRiRLVnonR8)_ Closes #13427 Clause-②: yes (follows objectstack#25515's widening: a new `ORG_ROLE_EXTERNAL` export and `ORG_ROLE_LABELS` row in `@object-ui/auth`, a new `organization.roles.external` key in each shipped pack; no acceptance set of objectui's own widens) ## What changed objectstack#25515 (objectstack#25233 stage 1, ruling of record 6355206139, letter B) added `external` to `@objectstack/spec`'s `BUILTIN_MEMBERSHIP_ROLES`. `ORG_ROLE_LABELS` is a `Record` over that vocabulary, so the console stopped type-checking against objectstack `main` (`TS2741` at `packages/auth/src/org-roles.ts:67`), and objectstack's Console Pin Gate and Spec Shape Gate went red. This PR makes the console know the role: - `packages/auth/src/org-roles.ts`: a new `ORG_ROLE_EXTERNAL` export, its label row (`organization.roles.external`, "External"), and the any-issuer rule for invitations (below). - Every pack in `packages/i18n/src/locales/` carries `organization.roles.external`. zh is 外部成员, ja 外部メンバー and es Externo, the words objectstack's own `sys_member.role` option uses; de, fr, ko, pt, ru and ar follow each pack's word for `member`. ## The two choices the card asked for 1. **Where the role shows.** `ORG_ROLES` stays the spec list unfiltered, so `external` appears in the invite dialog and in the members page's role menu wherever the spec lists it. The invite offer for an issuer below admin grade (a delegated admin, or a caller whose membership has not loaded) becomes `member` and `external`. That mirrors the framework's invitation cap: in the spec's grant table (`INVITATION_ROLE_GRANTORS`) both rows read `'any'`, because `external` confers less than a member (ruling E3). An owner or admin may also set it from the members page, as better-auth's `update-member-role` allows. Two server refusals are not pre-empted, because the screen cannot see what they read: a role list mixing `external` with another role (E5; the menu sets one role) and re-roling a member who is placed in a business unit (E6). 2. **Where it sits on the grade ladder.** At `member` grade, as objectstack's own cap ladder (`invitation-role-cap.ts`) grades it. The console ladder answers only "is this an administrative grade", so `external` never unlocks invite, remove, cancel or re-role. That it reaches less than a member is enforced server-side; a rung below `member` here would have no reader. ## Why the pin does not move, and the literal Importing the spec's `MEMBERSHIP_ROLE_EXTERNAL` needs objectui's own `.objectstack-sha` past objectstack#25515. Any such pin also carries objectstack#25483, PR1 of objectstack#25251, whose PR2 (spec lane) has not landed; this project keeps objectui's pin before #25483 until it does. So the pin stays at `915e9404`, and the console compiles against both vocabularies: - `ORG_ROLE_EXTERNAL = 'external'` is spelled locally, with a docblock pointing at objectstack#25515. - `ORG_ROLE_LABELS` is typed `Record<OrgRole | typeof ORG_ROLE_EXTERNAL, …>`. Against `main` the union is `OrgRole` itself, so the table stays exhaustive there. - A tripwire test (`spells external itself only while the pin predates objectstack#25515`) goes red on the pin move that brings #25515. Its message lists the follow-up: import the constant, drop the union, add `external` to the role lists that `InviteMemberDialog.roleCap.test.tsx` and `org-i18n-holdouts-4474.test.tsx` expect, and delete the tripwire. ## Tests - `org-roles.test.ts`: the external label row; external grades as `member` and below admin; an external actor may re-role nobody; an admin may re-role an existing external; and the invite offer equals what the spec's grant table admits, for owner, admin and every below-admin issuer. That last pin holds at either spec, and against `main` it asserts `['member', 'external']` for a delegate. - `org-i18n-holdouts-4474.test.tsx`: every pack defines `organization.roles.external`, and an external member's badge reads 外部成员 in zh and External in en. ## Verification Measured in this container, in the worktree on this branch: - **Against objectstack `main` `5ea211cc`** (the pin built at that commit, nothing committed): `turbo run build --filter=@object-ui/auth --filter=@object-ui/i18n`, then `turbo run type-check` for `@object-ui/console`, `@object-ui/auth`, `@object-ui/app-shell`, `@object-ui/i18n`: exit 0, 39/39 tasks (console runs `tsc --noEmit` and `tsc -b tsconfig.node.json`, app-shell its test tsconfig too). `vitest run` on `org-roles.test.ts` plus `console/organizations/__tests__/`: 159 passed, 6 failed, all six expected. The tripwire is one of them. The other five are the existing literal role lists, whose received values show the new behaviour: owner offered 5 roles, delegate and unloaded offered `['member', 'external']`, and the zh and en dropdowns ending in 外部成员 and External. Ablation on the same build: restoring the old below-admin offer (`[ORG_ROLE_MEMBER]`) turns `offers exactly what the spec grant table admits` red. - **At the pin `915e9404`** (after `pnpm run setup`; `objectstack-pin status` reads the cache at the pin): the same build and type-check, exit 0, 39/39 tasks; `vitest run packages/auth/src/__tests__/ packages/app-shell/src/console/organizations/ packages/i18n/ apps/console/src/pages/system/`: 168 files, 2019 passed, 13 skipped, 0 failed. `eslint` on the changed files: 0 errors (17 warnings, all pre-existing `any` lines in the holdouts test's mocks). - Repo checks, each exit 0: `check:i18n-keys`, `check:i18n-drift`, `check:i18n-dead-keys`, `check:changeset-claims`, `check:pending-changeset-literals`, `check:spec-symbols`, `check:new-line-citations`, `check:control-bytes`, `check:installed-pin-claims`, `check:vi-mock-specifiers`, `check:vi-mock-inherit`, `check:vi-mock-override-shape`, `check:test-path-roots`. `check:readme-exports` answered exit 1 as a prerequisite, not a verdict: 27 packages were unbuilt, so its population collapsed below its floors. CI runs it after the build. ## Notes - Branch `claude/issue-13427-external-role-label`, worktree `objectui-issue-13427`, claim 6374956587 (Seat: `domain:ui#1`). - After this merges, #25537 moves objectstack's `.objectui-sha` past it, which greens Console Pin Gate and Spec Shape Gate. - Not changed, outside the surface: the profile page's access word is two-way (admin or member, from `useWorkspaceAdminStatus`), so an external user reads 成员 / Member there. `orgRoleLabel.ts`'s docblock still says "the four" roles. - [x] Adds no product-specific widget, dialog, hook or string (see AGENTS.md › Product-neutral renderer) Session: `https://claude.ai/code/session_01JtDJkBUiZnD9NWnDqYuhq7` --- _Generated by [Claude Code](https://claude.ai/code/session_01JtDJkBUiZnD9NWnDqYuhq7)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01JtDJkBUiZnD9NWnDqYuhq7 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4eeb174 commit 2958f17

14 files changed

Lines changed: 177 additions & 19 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@object-ui/auth': minor
3+
'@object-ui/i18n': patch
4+
---
5+
6+
The console knows the `external` organization role that objectstack#25515 added to `@objectstack/spec`'s membership vocabulary (objectui#13427). Without it `ORG_ROLE_LABELS` no longer type-checked against an `@objectstack/spec` that lists the role.
7+
8+
`@object-ui/auth` exports `ORG_ROLE_EXTERNAL` and labels it (`organization.roles.external`, "External"). Every pack in `@object-ui/i18n` carries the key; zh reads 外部成员, as the server's own `sys_member.role` option does. Wherever the installed spec lists the role, the invite dialog offers it to every issuer who can invite, a delegated admin included, because objectstack's invitation cap admits it from any issuer: it confers less than a member. Owners and admins can also set it from the members page. On the grade ladder it sits with `member`, as it does in objectstack's cap, so it never unlocks an administrative affordance.

‎packages/app-shell/src/console/organizations/__tests__/org-i18n-holdouts-4474.test.tsx‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ describe('#4474 family 1 — role names come from ONE map and resolve in zh', ()
241241
for (const lang of Object.keys(builtInLocales) as Array<keyof typeof builtInLocales>) {
242242
const roles = (builtInLocales[lang] as any).organization?.roles;
243243
expect(roles, `${lang} has no organization.roles`).toBeDefined();
244-
for (const k of ['owner', 'admin', 'delegatedAdmin', 'member']) {
244+
for (const k of ['owner', 'admin', 'delegatedAdmin', 'member', 'external']) {
245245
expect(typeof roles?.[k], `${lang}.organization.roles.${k}`).toBe('string');
246246
}
247247
}
@@ -304,6 +304,19 @@ describe('#4474 family 1 — role names come from ONE map and resolve in zh', ()
304304
expect(labels).toEqual(['Owner', 'Admin', 'Delegated Admin', 'Member']);
305305
});
306306

307+
it('an external member\'s badge reads 外部成员 in zh and External in en (objectui#13427)', async () => {
308+
getMembers.mockResolvedValue([
309+
{ id: 'm-7', role: 'external', userId: 'u-7', user: { name: 'Pat', email: 'pat@supplier.test' } },
310+
]);
311+
const { unmount } = renderIn('zh', <MembersPage />);
312+
await waitFor(() => expect(screen.getByTestId('members-page')).toBeInTheDocument());
313+
expect(screen.getByTestId('member-role-badge-m-7')).toHaveTextContent('外部成员');
314+
unmount();
315+
renderIn('en', <MembersPage />);
316+
await waitFor(() => expect(screen.getByTestId('members-page')).toBeInTheDocument());
317+
expect(screen.getByTestId('member-role-badge-m-7')).toHaveTextContent('External');
318+
});
319+
307320
it('MUST NOT CHANGE — en members badges read Owner / Member', async () => {
308321
renderIn('en', <MembersPage />);
309322
await waitFor(() => expect(screen.getByTestId('members-page')).toBeInTheDocument());

‎packages/auth/src/__tests__/org-roles.test.ts‎

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
*
99
* - `invitableOrgRoles` ↔ the framework's `beforeCreateInvitation` role cap
1010
* (framework#3697): never above your own grade, and a below-admin issuer may
11-
* invite as `member` only.
11+
* invite as `member` or `external` only — the rows of the spec's grant table
12+
* that any issuer may confer (pinned to that table below).
1213
* - `assignableOrgRoles` ↔ better-auth's `update-member-role` route: needs
1314
* `member:["update"]` (owner/admin only), and only an owner may set `owner`
1415
* or re-role an existing owner.
@@ -19,15 +20,31 @@
1920
*/
2021

2122
import { describe, it, expect } from 'vitest';
23+
import * as spec from '@objectstack/spec';
24+
import { INVITATION_ROLE_ANY_ISSUER, INVITATION_ROLE_GRANTORS } from '@objectstack/spec/identity';
2225
import {
2326
ORG_ROLES,
2427
ORG_ROLE_LABELS,
2528
ORG_ROLE_DELEGATED_ADMIN,
29+
ORG_ROLE_EXTERNAL,
2630
orgRoleGrade,
2731
invitableOrgRoles,
2832
assignableOrgRoles,
2933
} from '../org-roles';
3034

35+
/**
36+
* What the framework's invitation cap admits for one issuer role, read off the
37+
* spec's grant table: a below-admin issuer gets the `'any'` rows only, an
38+
* administrative issuer every row that is `'any'` or names its role.
39+
*/
40+
function grantTableOffer(issuer: 'owner' | 'admin' | 'below-admin'): string[] {
41+
return ORG_ROLES.filter((role) => {
42+
const grantors = (INVITATION_ROLE_GRANTORS as Record<string, unknown>)[role];
43+
if (grantors === INVITATION_ROLE_ANY_ISSUER) return true;
44+
return issuer !== 'below-admin' && (grantors as readonly string[]).includes(issuer);
45+
});
46+
}
47+
3148
describe('vocabulary', () => {
3249
it('offers the spec vocabulary WHOLE — including the delegated issuer grade', () => {
3350
// The names themselves derive from `@objectstack/spec`
@@ -45,6 +62,29 @@ describe('vocabulary', () => {
4562
expect(ORG_ROLE_LABELS[role]?.defaultValue).toBeTruthy();
4663
}
4764
});
65+
66+
it('labels the external grade (objectui#13427)', () => {
67+
// objectstack#25515 added `external` to BUILTIN_MEMBERSHIP_ROLES; the
68+
// exhaustive label table is what stopped the console compiling there.
69+
expect(ORG_ROLE_EXTERNAL).toBe('external');
70+
expect(ORG_ROLE_LABELS[ORG_ROLE_EXTERNAL]).toEqual({
71+
key: 'organization.roles.external',
72+
defaultValue: 'External',
73+
});
74+
});
75+
76+
it('spells external itself only while the pin predates objectstack#25515', () => {
77+
// [tripwire] `org-roles.ts` spells the role because `.objectstack-sha`
78+
// names a spec without it. The pin move that brings #25515 turns this red,
79+
// which is the reminder to swap the literal for the spec's constant.
80+
expect(
81+
(spec as Record<string, unknown>).MEMBERSHIP_ROLE_EXTERNAL,
82+
'the pin now carries objectstack#25515: in org-roles.ts import MEMBERSHIP_ROLE_EXTERNAL as ' +
83+
'ORG_ROLE_EXTERNAL instead of the literal and drop `| typeof ORG_ROLE_EXTERNAL` from ' +
84+
'ORG_ROLE_LABELS; then add external to the role lists InviteMemberDialog.roleCap.test.tsx ' +
85+
'and org-i18n-holdouts-4474.test.tsx expect, and delete this test',
86+
).toBeUndefined();
87+
});
4888
});
4989

5090
describe('orgRoleGrade', () => {
@@ -58,6 +98,13 @@ describe('orgRoleGrade', () => {
5898
expect(orgRoleGrade('sales_manager')).toBe(orgRoleGrade('member'));
5999
});
60100

101+
it('external grades no higher than a member — never an administrative grade', () => {
102+
// The framework cap's ladder grades it as `member`; what it reaches below a
103+
// member is enforced server-side, not on this ladder.
104+
expect(orgRoleGrade(ORG_ROLE_EXTERNAL)).toBe(orgRoleGrade('member'));
105+
expect(orgRoleGrade(ORG_ROLE_EXTERNAL)).toBeLessThan(orgRoleGrade('admin'));
106+
});
107+
61108
it('a comma list takes the HIGHEST grade', () => {
62109
expect(orgRoleGrade('member,admin')).toBe(orgRoleGrade('admin'));
63110
});
@@ -82,15 +129,31 @@ describe('invitableOrgRoles — mirrors the invitation role cap', () => {
82129
expect(roles).not.toContain('owner');
83130
});
84131

85-
it('a DELEGATE may invite as member only — the escalation chain, closed in the UI too', () => {
86-
expect(invitableOrgRoles(ORG_ROLE_DELEGATED_ADMIN)).toEqual(['member']);
132+
it('a DELEGATE may invite as member, and as nothing that carries authority — the escalation chain, closed in the UI too', () => {
133+
const roles = invitableOrgRoles(ORG_ROLE_DELEGATED_ADMIN);
134+
expect(roles).toContain('member');
135+
for (const r of ['owner', 'admin', ORG_ROLE_DELEGATED_ADMIN]) expect(roles).not.toContain(r);
87136
});
88137

89-
it('an unresolvable caller is offered member alone, never nothing', () => {
138+
it('an unresolvable caller is offered the any-issuer roles alone, never nothing', () => {
90139
// Offering nothing would break the ordinary invite for a caller whose
91-
// membership simply has not loaded yet; the server still allows `member`.
140+
// membership simply has not loaded yet; the cap still admits a single
141+
// `member` (or, once the spec lists it, `external`) invitation from an
142+
// unverified issuer.
92143
for (const v of [null, undefined, '']) {
93-
expect(invitableOrgRoles(v)).toEqual(['member']);
144+
expect(invitableOrgRoles(v)).toContain('member');
145+
expect(invitableOrgRoles(v)).toEqual(invitableOrgRoles(ORG_ROLE_DELEGATED_ADMIN));
146+
}
147+
});
148+
149+
it('offers exactly what the spec grant table admits, for every issuer grade', () => {
150+
// The table the framework cap reads (`@objectstack/spec/identity`). A row
151+
// the spec adds or moves turns this red before the console offers a role
152+
// the server refuses, or hides one it admits.
153+
expect(invitableOrgRoles('owner')).toEqual(grantTableOffer('owner'));
154+
expect(invitableOrgRoles('admin')).toEqual(grantTableOffer('admin'));
155+
for (const issuer of [ORG_ROLE_DELEGATED_ADMIN, 'member', ORG_ROLE_EXTERNAL, null]) {
156+
expect(invitableOrgRoles(issuer)).toEqual(grantTableOffer('below-admin'));
94157
}
95158
});
96159
});
@@ -110,6 +173,17 @@ describe('assignableOrgRoles — mirrors update-member-role', () => {
110173
expect(assignableOrgRoles('admin', 'owner')).toEqual([]);
111174
});
112175

176+
it('an admin may re-role an existing external to anything but owner', () => {
177+
expect(assignableOrgRoles('admin', ORG_ROLE_EXTERNAL)).toEqual(
178+
ORG_ROLES.filter((r) => r !== 'owner'),
179+
);
180+
});
181+
182+
it('an external may re-role NOBODY — it holds no organization permission at all', () => {
183+
expect(assignableOrgRoles(ORG_ROLE_EXTERNAL, 'member')).toEqual([]);
184+
expect(assignableOrgRoles(ORG_ROLE_EXTERNAL, ORG_ROLE_EXTERNAL)).toEqual([]);
185+
});
186+
113187
it('a delegate may re-role NOBODY — they hold no member:update permission', () => {
114188
expect(assignableOrgRoles(ORG_ROLE_DELEGATED_ADMIN, 'member')).toEqual([]);
115189
expect(assignableOrgRoles('member', 'member')).toEqual([]);

‎packages/auth/src/org-roles.ts‎

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*
1818
* ## The vocabulary is CLOSED — and derived, not mirrored
1919
*
20-
* [framework ADR-0108 / objectstack#3723] These four names are the WHOLE list,
21-
* and the framework owns them. An application cannot add a fifth: the server
20+
* [framework ADR-0108 / objectstack#3723] The spec's names are the WHOLE list,
21+
* and the framework owns them. An application cannot add one: the server
2222
* used to register every declared `position` / `permission` name as an
2323
* organization role, and that was retired, because every value stored in
2424
* `sys_member.role` is projected into `current_user.positions` — so a business
@@ -58,20 +58,44 @@ import {
5858
// console by `describeDelegableScope()`.
5959
export { ORG_ROLE_OWNER, ORG_ROLE_ADMIN, ORG_ROLE_DELEGATED_ADMIN, ORG_ROLE_MEMBER };
6060

61+
/**
62+
* The external population's grade (objectstack#25233, ruling of record
63+
* 6355206139, letter B): portal users admitted through the organization
64+
* invite, who reach less than a `member` — no organization endpoint, no member
65+
* directory, data only through explicit grants. It is exclusive (the server
66+
* refuses it beside any other role) and never placed in a business unit.
67+
*
68+
* ⚠️ SPELLED HERE, not imported, for now. `@objectstack/spec` exports it as
69+
* `MEMBERSHIP_ROLE_EXTERNAL` since objectstack#25515, and this console must
70+
* compile against that spec (objectstack builds it at its own `main`). But
71+
* this repo's pin, `.objectstack-sha`, still names a commit from before
72+
* #25515, held there until objectstack#25251's spec PR lands (its two PRs ship
73+
* in one objectstack release). So the console has to compile against both
74+
* vocabularies: the literal here, and `OrgRole | typeof ORG_ROLE_EXTERNAL`
75+
* below, which is `OrgRole` itself once the pin carries #25515. When the pin
76+
* moves past #25515, import the constant like the four above and drop the
77+
* union: `org-roles.test.ts` goes red on that move and says so.
78+
*/
79+
export const ORG_ROLE_EXTERNAL = 'external';
80+
6181
export type OrgRole = BuiltinMembershipRole;
6282

6383
/** Display order: most privileged first, as the spec ships it and the screens list it. */
6484
export const ORG_ROLES: readonly OrgRole[] = [...BUILTIN_MEMBERSHIP_ROLES];
6585

6686
/** i18n key + English fallback for a role, so every screen labels it identically. */
67-
export const ORG_ROLE_LABELS: Record<OrgRole, { key: string; defaultValue: string }> = {
87+
export const ORG_ROLE_LABELS: Record<
88+
OrgRole | typeof ORG_ROLE_EXTERNAL,
89+
{ key: string; defaultValue: string }
90+
> = {
6891
[ORG_ROLE_OWNER]: { key: 'organization.roles.owner', defaultValue: 'Owner' },
6992
[ORG_ROLE_ADMIN]: { key: 'organization.roles.admin', defaultValue: 'Admin' },
7093
[ORG_ROLE_DELEGATED_ADMIN]: {
7194
key: 'organization.roles.delegatedAdmin',
7295
defaultValue: 'Delegated Admin',
7396
},
7497
[ORG_ROLE_MEMBER]: { key: 'organization.roles.member', defaultValue: 'Member' },
98+
[ORG_ROLE_EXTERNAL]: { key: 'organization.roles.external', defaultValue: 'External' },
7599
};
76100

77101
const GRADE_UNRESOLVED = 0;
@@ -81,9 +105,19 @@ const GRADE_OWNER = 3;
81105

82106
/**
83107
* Grade ladder, mirroring the framework's invitation role cap. Anything
84-
* unrecognized — `member`, `delegated_admin`, an app-registered role — grades
85-
* as an ordinary member; only better-auth's two administrative roles outrank
86-
* it, because only they are auto-elevated to `organization_admin` server-side.
108+
* unrecognized — `member`, `delegated_admin`, `external`, an app-registered
109+
* role — grades as an ordinary member; only better-auth's two administrative
110+
* roles outrank it, because only they are auto-elevated to
111+
* `organization_admin` server-side.
112+
*
113+
* `external` gets no rung of its own, on purpose. The ladder answers one
114+
* question — does this role carry administrative authority — and the cap's
115+
* ladder (plugin-auth `invitation-role-cap.ts`) grades `external` exactly as
116+
* it grades `member`. That it reaches LESS than a member is enforced where it
117+
* is decided, server-side (no endpoint statement, the external baseline set);
118+
* a rung below `member` here would have no reader, and every reader that
119+
* exists compares against the admin and owner grades, which `external` never
120+
* reaches.
87121
*
88122
* An absent/unreadable role grades BELOW a plain member: the fail-closed floor,
89123
* so an unverified caller is offered nothing privileged.
@@ -103,24 +137,36 @@ export function orgRoleGrade(raw: unknown): number {
103137
return grade;
104138
}
105139

140+
/**
141+
* The roles every issuer may confer — the rows of the spec's invitation grant
142+
* table (`INVITATION_ROLE_GRANTORS`, `@objectstack/spec/identity`) that read
143+
* `'any'`. `member` confers nothing to cap; `external` confers less than
144+
* `member` (ruling 6355206139, E3). The test pins the offer this set produces
145+
* to that table for every issuer grade, so the copy here cannot drift from the
146+
* cap without going red.
147+
*/
148+
const ANY_ISSUER_ROLES: ReadonlySet<string> = new Set([ORG_ROLE_MEMBER, ORG_ROLE_EXTERNAL]);
149+
106150
/**
107151
* The roles `issuerRole` may confer through an INVITATION — mirroring the
108152
* framework's `beforeCreateInvitation` role cap:
109153
*
110154
* - an invited role may never outrank the issuer's own;
111-
* - an issuer below admin grade may invite as `member` only (an app-registered
112-
* role projects into `current_user.positions` and may be bound to permission
113-
* sets, so it is a capability channel too — a delegate's channel for
114-
* capability is the invitation's *placement*, which the D12 gate allowlists).
155+
* - an issuer below admin grade may invite as `member` or `external` only, the
156+
* two roles any issuer may confer (an app-registered role projects into
157+
* `current_user.positions` and may be bound to permission sets, so it is a
158+
* capability channel too — a delegate's channel for capability is the
159+
* invitation's *placement*, which the D12 gate allowlists).
115160
*
116161
* Same property as the placement picker: this NARROWS, it does not decide. The
117162
* server re-checks and rejects out-of-cap invitations, so the console is free to
118163
* be helpful without being load-bearing — and it fails toward *less*: an
119-
* unresolvable issuer role offers `member` alone.
164+
* unresolvable issuer role offers the any-issuer roles alone, which the cap
165+
* admits for an unverified issuer too.
120166
*/
121167
export function invitableOrgRoles(issuerRole: unknown): OrgRole[] {
122168
const grade = orgRoleGrade(issuerRole);
123-
if (grade < GRADE_ADMIN) return [ORG_ROLE_MEMBER];
169+
if (grade < GRADE_ADMIN) return ORG_ROLES.filter((r) => ANY_ISSUER_ROLES.has(r));
124170
return ORG_ROLES.filter((r) => orgRoleGrade(r) <= grade);
125171
}
126172

@@ -135,6 +181,13 @@ export function invitableOrgRoles(issuerRole: unknown): OrgRole[] {
135181
* - only an owner may SET `owner`, and only an owner may modify a member who
136182
* already IS one (better-auth's `creatorRole` protection).
137183
*
184+
* `external` is offered like any other role. Two framework refusals are not
185+
* pre-empted here, because this screen cannot see what they read: a role list
186+
* that carries `external` beside another role (the picker sets one role, so it
187+
* never builds one), and re-roling to `external` a member who is placed in a
188+
* business unit (ruling 6355206139, E5 and E6). The server's refusal reaches
189+
* the screen through the same error path as any other.
190+
*
138191
* Returns an empty list when the actor may not re-role at all, so the screen can
139192
* omit the affordance instead of offering items that would 403.
140193
*/

‎packages/i18n/src/locales/ar.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,6 +3251,7 @@ const ar = {
32513251
admin: 'المسؤول',
32523252
delegatedAdmin: 'مسؤول مفوَّض',
32533253
member: 'عضو',
3254+
external: 'عضو خارجي',
32543255
},
32553256
errors: {
32563257
notAllowedToInvite: 'لا يُسمح لك بدعوة مستخدمين إلى هذه المؤسسة.',

‎packages/i18n/src/locales/de.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3022,6 +3022,7 @@ const de = {
30223022
admin: 'Administrator',
30233023
delegatedAdmin: 'Delegierter Administrator',
30243024
member: 'Mitglied',
3025+
external: 'Externes Mitglied',
30253026
},
30263027
errors: {
30273028
notAllowedToInvite: 'Sie dürfen keine Benutzer in diese Organisation einladen.',

‎packages/i18n/src/locales/en.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3720,6 +3720,7 @@ const en = {
37203720
admin: 'Admin',
37213721
delegatedAdmin: 'Delegated Admin',
37223722
member: 'Member',
3723+
external: 'External',
37233724
},
37243725
errors: {
37253726
notAllowedToInvite: 'You are not allowed to invite users to this organization',

‎packages/i18n/src/locales/es.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,6 +3080,7 @@ const es = {
30803080
admin: 'Administrador',
30813081
delegatedAdmin: 'Administrador delegado',
30823082
member: 'Miembro',
3083+
external: 'Externo',
30833084
},
30843085
errors: {
30853086
notAllowedToInvite: 'No tiene permiso para invitar usuarios a esta organización.',

‎packages/i18n/src/locales/fr.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,7 @@ const fr = {
30763076
admin: 'Administrateur',
30773077
delegatedAdmin: 'Administrateur délégué',
30783078
member: 'Membre',
3079+
external: 'Membre externe',
30793080
},
30803081
errors: {
30813082
notAllowedToInvite: "Vous n'êtes pas autorisé à inviter des utilisateurs dans cette organisation.",

‎packages/i18n/src/locales/ja.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,6 +3024,7 @@ const ja = {
30243024
admin: '管理者',
30253025
delegatedAdmin: '委任管理者',
30263026
member: 'メンバー',
3027+
external: '外部メンバー',
30273028
},
30283029
errors: {
30293030
notAllowedToInvite: 'この組織にユーザーを招待する権限がありません。',

0 commit comments

Comments
 (0)