export interface RBACConfig { logger?: (role: string, operation: string | RegExp, result: boolean, colorsEnabled?: boolean) => void; enableLogger?: boolean; colors?: boolean; } export type WhenCallback

= (params: P, done: (err: unknown, result?: boolean) => void) => void; export type WhenFunction

= (params: P) => boolean | Promise; export type When

= boolean | Promise | WhenCallback

| WhenFunction

; export type NormalizedWhenFn

= (params: P) => Promise; export interface PatternPermission

{ name: string; regex: RegExp; when: NormalizedWhenFn

| true; } export interface Role

{ can: Array; }>; inherits?: string[]; } export type Roles

= Record>; export interface MappedRole

{ direct: Set; conditional: Map>; patterns: PatternPermission

[]; /** * `resource:*` patterns indexed by their literal `resource:` prefix. This * is deliberately an additive index: `patterns` remains the source of * truth for regex/glob queries and complex glob syntax. */ simpleGlobs: Map[]>; inherits?: string[]; allOps: string[]; } export type MappedRoles

= Record>; export interface RBACInstance

{ can: (role: string, operation: string | RegExp, params?: P) => Promise; updateRoles: (roles: Roles

) => void; addRole: (roleName: string, role: Role

) => void; }