import { ITabFlags } from '@qodly/shared'; export type TRawData = Partial<{ privileges: IPrivilege[]; roles: IRole[]; permissions: Partial<{ allowed: IPermission[]; }>; forceLogin: boolean; }>; export type TPermissionOption = Pick; export type TAction = 'read' | 'create' | 'update' | 'drop' | 'execute' | 'promote'; export type IRolesState = ISanitized & { flags: ITabFlags; date?: string; selectedTab: 'privileges' | 'roles'; }; export interface IPrivilege { id?: string; privilege: string; includes?: string[]; } export interface IRole { id?: string; role: string; privileges?: string[]; } export type TRole = Required; export declare enum EPermissionType { DATACLASS = "dataclass", METHOD = "method", DS_METHOD = "dsMethod", DATACLASS_METHOD = "dataclassMethod", ENTITY_METHOD = "entityMethod", ENTITY_SEL_METHOD = "entityselMethod", ATTRIBUTE = "attribute", DATASTORE = "datastore", SINGLETON = "singleton", SINGLETON_METHOD = "singletonMethod" } export interface IPermission { applyTo: string; type: EPermissionType; read?: string | string[]; create?: string | string[]; update?: string | string[]; drop?: string | string[]; execute?: string | string[]; promote?: string | string[]; } export interface IResourcesByPermission { [id: string]: { applyTo: IPermission['applyTo']; type: IPermission['type']; }[]; } /** * Sanitized data */ export interface ISanitized { privileges: TById; roles: TRolesDict; forceLogin?: boolean; } export interface IResourcePermission { name: TAction; from: string[]; checked?: boolean; info?: string; } export interface IResource { resource: string; type: EPermissionType; permissions: IResourcePermission[]; exists?: boolean; } export type TSanitizedPrivilege = Required & { parents: string[]; resources: IResource[]; }; export type TById = { [id: string]: TSanitizedPrivilege; }; export type TRolesDict = { [id: string]: TRole; }; export interface ILink { source: string; target: string; } export interface IGraphData { selected: string; parents: string[][]; children: string[][]; links: ILink[]; }