@@ -36,17 +36,14 @@ import { useAdapter, useDataInvalidation, useMetadata, useRecordContext } from '
3636import type { ObjectStackAdapter } from '@object-ui/data-objectstack' ;
3737import { AlertCircle , ShieldCheck } from 'lucide-react' ;
3838import { catalogEntries } from '../../views/setup/peopleAssignments.js' ;
39-
40- type Translate = ( key : string , options ?: Record < string , unknown > ) => string ;
41-
42- type DescribeEffectiveAccess = ReturnType < ObjectStackAdapter [ 'getClient' ] > [ 'security' ] [ 'describeEffectiveAccess' ] ;
43- /** The answer (`EffectiveAccess` of `@objectstack/spec/contracts`, through the client). */
44- export type EffectiveAccessAnswer = Awaited < ReturnType < DescribeEffectiveAccess > > ;
45- /** One way a set reaches the person (`EffectivePermissionSetOrigin`). */
46- export type EffectiveAccessOrigin = EffectiveAccessAnswer [ 'permissionSets' ] [ number ] [ 'origins' ] [ number ] ;
47-
48- /** The object whose record pages this widget belongs on. */
49- export const EFFECTIVE_ACCESS_OBJECT = 'sys_user' ;
39+ import {
40+ EFFECTIVE_ACCESS_OBJECT ,
41+ describeOrigin ,
42+ failureText ,
43+ httpStatusOf ,
44+ originKey ,
45+ type EffectiveAccessAnswer ,
46+ } from './effectiveAccess.js' ;
5047
5148/** The registry type the set labels are read from. */
5249const PERMISSION_SET_TYPE = 'permission' ;
@@ -58,45 +55,6 @@ type Read =
5855 | { state : 'unserved' }
5956 | { state : 'failed' ; message : string } ;
6057
61- /** The status the client stamps on a refused call (`httpStatus`, from `res.status`). */
62- function httpStatusOf ( err : unknown ) : number | undefined {
63- const status = ( err as { httpStatus ?: unknown } | null | undefined ) ?. httpStatus ;
64- return typeof status === 'number' ? status : undefined ;
65- }
66-
67- function failureText ( err : unknown ) : string {
68- const message = ( err as { message ?: unknown } | null | undefined ) ?. message ;
69- return typeof message === 'string' && message ? message : String ( err ) ;
70- }
71-
72- /** Where one origin says the set comes from. */
73- export function describeOrigin ( origin : EffectiveAccessOrigin , t : Translate ) : string {
74- switch ( origin . kind ) {
75- case 'direct' :
76- return t ( 'effectiveAccess.origin.direct' ) ;
77- case 'position' :
78- return t ( 'effectiveAccess.origin.position' , { position : origin . position } ) ;
79- case 'default' :
80- return t ( 'effectiveAccess.origin.default' ) ;
81- case 'derived' :
82- return origin . source === 'platform_admin_config'
83- ? t ( 'effectiveAccess.origin.derivedPlatformAdmin' )
84- : t ( 'effectiveAccess.origin.derivedAiAccess' ) ;
85- }
86- }
87-
88- /** A stable key for one origin of a row. */
89- function originKey ( origin : EffectiveAccessOrigin ) : string {
90- switch ( origin . kind ) {
91- case 'position' :
92- return `position-${ origin . position } ` ;
93- case 'derived' :
94- return `derived-${ origin . source } ` ;
95- default :
96- return origin . kind ;
97- }
98- }
99-
10058export interface UserEffectiveAccessProps {
10159 /** Carries the scope class of the node's `responsiveStyles`. */
10260 className ?: string ;
0 commit comments