/** * Add/remove roles based on other roles */ export type RoleComposition = { /** * Add or remove a role * - add: Add the role if the condition is satisfied, otherwise leave the role as is * - remove: Remove the role if the condition is satisfied, otherwise leave the role as is * - addOrRemove: Add the role if the condition is satisfied, otherwise remove the role * - removeOrAdd: Remove the role if the condition is satisfied, otherwise add the role */ action: 'add' | 'remove' | 'addOrRemove' | 'removeOrAdd'; /** * Role id to be added/removed */ roleId: string; /** * AND/OR condition for the */ operator: 'and' | 'or'; /** * An object of roleId => state mapping as the predicate * * @example * ```ts * { * 'role1': true, * 'role2': false * } * ``` */ condition: Record; }; /** * Sort rules based on the dependencies * @param rules - A list of rules * @returns */ export declare function sortRoleCompositions(rules: RoleComposition[]): RoleComposition[]; /** * Apply role composition rules with the initial list of roles * @param rules - Rules to apply * @param roles - Initial list of roles * @param updatedRoles - Roles are being updated in this process * @returns */ export declare function applyRoleCompositions(rules: RoleComposition[], roles: Record, updatedRoles?: Set): Record;