@pagamio/frontend-commons-lib
Version:
Pagamio library for Frontend reusable components like the form engine and table container
40 lines (39 loc) • 976 B
TypeScript
/**
* Role-Based Access Control (RBAC) types
*/
/**
* Configuration mapping roles to permissions
*/
export interface RBACConfig<P> {
[]: P[];
}
/**
* Generic user interface that can be extended by specific applications.
* Optionally supports multiple roles via the `roleNames` property.
*/
export interface RBACUser {
[]: unknown;
roleNames?: string[];
}
/**
* RBAC configuration options.
* Supports both single-role and multi-role users.
*/
export interface RBACOptions<P, U extends RBACUser = RBACUser> {
/**
* Configuration mapping roles to permissions
*/
rbacConfig: RBACConfig<P>;
/**
* The permission value that represents "ALL permissions"
*/
allPermissionValue: P;
/**
* Array of all available permissions
*/
allPermissions: P[];
/**
* The key in the user object that contains the role(s) - can be a string or array of strings
*/
roleKey?: keyof U;
}