Skip to content

Commit 2740711

Browse files
committed
test(platform-objects): type the principal binding in the action-state pins
Claude-Session: https://claude.ai/code/session_01VXimSk38NSs68ntncNxKS8 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 23a31f1 commit 2740711

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎packages/platform-objects/src/identity/action-state-visibility.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ import { celEngine } from '@objectstack/formula';
2020
import { SysUser } from './sys-user.object.js';
2121
import { SysApiKey } from './sys-api-key.object.js';
2222

23-
const ADMIN = { id: 'u_admin', email: 'admin@example.com', positions: [], isPlatformAdmin: true };
24-
const MEMBER = { id: 'u_member', email: 'member@example.com', positions: ['org_owner'], isPlatformAdmin: false };
23+
type Principal = { id: string; email: string; positions: string[]; isPlatformAdmin: boolean };
24+
25+
const ADMIN: Principal = { id: 'u_admin', email: 'admin@example.com', positions: [], isPlatformAdmin: true };
26+
const MEMBER: Principal = { id: 'u_member', email: 'member@example.com', positions: ['org_owner'], isPlatformAdmin: false };
2527
const FEATURES = { admin: true, apiKey: true };
2628

2729
function visibleOf(def: { actions?: unknown }, name: string): string {
@@ -34,7 +36,7 @@ function visibleOf(def: { actions?: unknown }, name: string): string {
3436
}
3537

3638
/** The verdict, or the fault spelled out so a faulting predicate fails loudly. */
37-
function offered(source: string, record: Record<string, unknown>, user = ADMIN): boolean | string {
39+
function offered(source: string, record: Record<string, unknown>, user: Principal = ADMIN): boolean | string {
3840
const r = celEngine.evaluate(
3941
{ dialect: 'cel', source },
4042
{ record, extra: { current_user: user, user, ctx: { user }, features: FEATURES } },

0 commit comments

Comments
 (0)