import { CreateRoleInput, DeletionResponse, Permission, UpdateRoleInput } from '@subit/common/lib/generated-types'; import { ID, PaginatedList } from '@subit/common/lib/shared-types'; import { RequestContext } from '../../api/common/request-context'; import { ListQueryOptions } from '../../common/types/common-types'; import { ConfigService } from '../../config/config.service'; import { Channel } from '../../entity/channel/channel.entity'; import { Role } from '../../entity/role/role.entity'; import { ListQueryBuilder } from '../helpers/list-query-builder/list-query-builder'; import { TransactionalConnection } from '../transaction/transactional-connection'; import { ChannelService } from './channel.service'; export declare class RoleService { private connection; private channelService; private listQueryBuilder; private configService; constructor(connection: TransactionalConnection, channelService: ChannelService, listQueryBuilder: ListQueryBuilder, configService: ConfigService); initRoles(): Promise; findAll(ctx: RequestContext, options?: ListQueryOptions): Promise>; findOne(ctx: RequestContext, roleId: ID): Promise; getChannelsForRole(ctx: RequestContext, roleId: ID): Promise; getSuperAdminRole(): Promise; getCustomerRole(): Promise; /** * Returns all the valid Permission values */ getAllPermissions(): string[]; /** * Returns true if the User has the specified permission on that Channel */ userHasPermissionOnChannel(ctx: RequestContext, channelId: ID, permission: Permission): Promise; create(ctx: RequestContext, input: CreateRoleInput): Promise; update(ctx: RequestContext, input: UpdateRoleInput): Promise; delete(ctx: RequestContext, id: ID): Promise; assignRoleToChannel(ctx: RequestContext, roleId: ID, channelId: ID): Promise; private getPermittedChannels; private checkPermissionsAreValid; private getRoleByCode; /** * Ensure that the SuperAdmin role exists and that it has all possible Permissions. */ private ensureSuperAdminRoleExists; /** * The Customer Role is a special case which must always exist. */ private ensureCustomerRoleExists; /** * Since custom permissions can be added and removed by config, there may exist one or more Roles with * invalid permissions (i.e. permissions that were set previously to a custom permission, which has been * subsequently removed from config). This method should run on startup to ensure that any such invalid * permissions are removed from those Roles. */ private ensureRolesHaveValidPermissions; private createRoleForChannels; private getAllAssignablePermissions; }