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 = boolean | Promise | WhenFunction ;
export type NormalizedWhenFn = (params: P) => Promise {
name: string;
regex: RegExp;
when: NormalizedWhenFn | true;
}
export interface Role {
can: Array = Record {
direct: Set [];
/**
* `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 = Record {
can: (role: string, operation: string | RegExp, params?: P) => Promise ) => void;
addRole: (roleName: string, role: Role ) => void;
}