import { EPermissionType, IGraphData, IPermission, IPrivilege, IResource, IResourcePermission, IResourcesByPermission, ISanitized, TById, TRawData, TRole, TRolesDict, TSanitizedPrivilege } from './types'; /** * pushes uniquely list of items * @param array input array * @param args list of elements to add to the array * @returns an array containing unique fields */ export declare function uniquePush(array: T[], ...args: T[]): T[]; /** * Sanitize a privileges array * @param data unsanitized data * @returns sanitized data */ export declare function sanitizePrivileges(data: IPrivilege[]): TById; /** * sort list of sanitized pivileges * @param dict sanitized data * @returns sorted privileges */ export declare function sort(dict: TById): TSanitizedPrivilege[]; /** * Lists the parents of a specific element * @param id identifier of the current element * @param dict sanitized privileges * @returns parents of the current element */ export declare function parents(id: string, dict: TById): string[]; /** * Lists the children of a specific element * @param id identifier of the current element * @param dict sanitized privileges * @returns children of the current element */ export declare function children(id: string, dict: TById): string[]; /** * Calculates from a sanitized privileges dictionary the list of allowed to include children * @param id identifier of the current element * @param dict sanitized privileges * @returns allowed to include privileges */ export declare function allowed(id: string, dict: TById): string[]; /** * Removes an element from a sanitized dictionary * @param id identifier of the current element * @param dict sanitized privileges * @returns new dictionary containing the initialone except the one with "id" */ export declare function remove(id: string, dict: TById): TById; /** * Adds an existing node as a child of another node * @param parentId the parent identifier * @param childId the child identifer * @param dict sanitized privileges dictionary * @returns the new dictionary */ export declare function addIn(parentId: string, childId: string, dict: TById): TById; /** * Removes an existing node from its (specified) parent * @param parentId the parent identifier * @param childId the child identifer * @param dict sanitized privileges dictionary * @returns the new dictionary */ export declare function removeFrom(parentId: string, childId: string, dict: TById): TById; /** * Create a new privilege * @param name the privilege name * @param dict sanitized privileges dictionary * @returns the new dictionary */ export declare function create(name: string, dict: TById): TById; export declare function createWithResource(name: string, resource: string, type: EPermissionType, action: IResourcePermission['name'], dict: TById): TById; /** * Renames an existing node * @param name the new name * @param id the node identifier * @param dict sanitized privileges dictionary * @returns the new dictionary */ export declare function rename(name: string, id: string, dict: TById): TById; /** * Populates a list privileges IDs * @param ids the identifiers of privileges to populate * @param dict sanitized privileges dictionary * @returns populated privileges */ export declare function populateShallow(ids: string[], dict: TById): (IPrivilege | null)[]; /** * Get the privilege object from its identifier * @param id the identifier of the node * @param dict sanitized privileges dictionary * @returns populated privilege */ export declare function getPrivilegeById(id: string, dict: TById): TSanitizedPrivilege | null; /** * Maps the privileges to their permissions * @param param0 the raw permission object * @returns an object mapping the privilege to its permission */ export declare function actionsToPrivs({ applyTo, type, ...actions }: IPermission): { [privName: string]: string[]; }; /** * Converts a raw permission to a resource * @param item a permission * @returns the resource object */ export declare function getResourceFromType(item: IPermission): IResource; /** * Sanitizes the raw permissions * @param data list of raw permissions * @param byKey dictionary * @returns a new dictionary containing the sanitized permissions */ export declare function sanitizePermissions(data: IPermission[], byKey: TById): TById; /** * Converts a dictionary indexed by id to a new one indexed by name * @param dict dictioanry * @returns a new dictionary indexed by privilege name */ export declare function getDictByName(dict: TById): TById; /** * Sanitizes the content of roles.json file * @param data raw data * @returns sanitized data */ export declare function sanitize(data: TRawData): ISanitized; /** * Converts sanitized data to a valid API payload * @param data sanitized dictionary * @returns raw data */ export declare function toAPI(data: ISanitized): TRawData; export declare function getGraphData(id: string, dict: TById): IGraphData; /** * * @param id privilege id * @param permission * @param dict */ export declare function addPermission(id: string, permission: IPermission, dict: TById): TById; /** * * @param id * @param permission * @param dict */ export declare function removePermission(id: string, permission: IPermission, dict: TById): TById; /** * @param resourcesByPermission * @param dict */ export declare function removeMultiplePermissions(resourcesByPermission: IResourcesByPermission, dict: TById): TById; /** * * @param id * @param permission * @param dict */ export declare function resetResources(id: string, dict: TById): TById; /** * * @param id privilege id * @param resource resource name * @param type resource type * @param permission permission name * @param dict privileges dictionary * @returns */ export declare function togglePrivilegePermission(id: string, resource: string, type: EPermissionType, permission: IResourcePermission['name'], dict: TById): TById; /** * * @param id * @param permission * @param dict */ export declare function togglePermission(id: string, resource: IResource, permission: IResourcePermission, dict: TById): TById; export declare function getPromotions(id: string, dict: TById): Record; export declare function getInheritedResources(id: string, dict: TById): IResource[]; export declare const toState: (rolesArray: TRole[]) => TRolesDict; export declare const removeRole: (id: string, roles: TRolesDict) => TRolesDict; export declare const editRole: (id: string, newName: string, roles: TRolesDict) => TRolesDict; export declare const createRole: (id: string, name: string, roles: TRolesDict) => TRolesDict; export declare const saveRole: (role: TRole, roles: TRolesDict) => TRolesDict;