UNPKG

rolet

Version:

Powerful user permission management

46 lines (45 loc) 1.08 kB
/** * Role tree * * Defines all roles and their abilities. */ export declare type T_roles<D = any, K extends string = string> = { [role in K]?: T_role<D, K>; }; export interface T_role<D = any, K extends string = string> { /** * List of abilities * * This node and all its descendents have these abilities. * * @example * `[ 'change_user_password' , 'refund_order' ]` * * @example * `[ 'user.changePassword' , 'order.refund' ]` * * * @example * `[ changePasswordFn , Order.refundMethod ]` */ actions?: T_actions; /** * Child nodes * * Its descendents, which will inherit all the abilities defined in `can`. */ children?: T_roles<D, K>; /** * Custom data * * All custom data should placed in here. */ custom?: D; /** * Same as key name * * This field will be auto generated when convert to rnode. */ role?: K; } export declare type T_actions = T_action[]; export declare type T_action = string | RegExp | Function;