import { CreateRoleInput, DeletionResponse, Permission, UpdateRoleInput } from '@vendure/common/lib/generated-types'; import { ID, PaginatedList } from '@vendure/common/lib/shared-types'; import { RequestContext } from '../../api/common/request-context'; import { RelationPaths } from '../../api/decorators/relations.decorator'; import { CacheService } from '../../cache'; import { RequestContextCacheService } from '../../cache/request-context-cache.service'; import { ListQueryOptions } from '../../common/types/common-types'; import { ConfigService } from '../../config/config.service'; import { TransactionalConnection } from '../../connection/transactional-connection'; import { Channel } from '../../entity/channel/channel.entity'; import { Role } from '../../entity/role/role.entity'; import { EventBus } from '../../event-bus'; import { ListQueryBuilder } from '../helpers/list-query-builder/list-query-builder'; import { ChannelService } from './channel.service'; /** * @description * Contains methods relating to {@link Role} entities. * * @docsCategory services */ export declare class RoleService { private connection; private channelService; private listQueryBuilder; private configService; private eventBus; private requestContextCache; private cacheService; private rolesCacheKey; private rolesCache; constructor(connection: TransactionalConnection, channelService: ChannelService, listQueryBuilder: ListQueryBuilder, configService: ConfigService, eventBus: EventBus, requestContextCache: RequestContextCacheService, cacheService: CacheService); initRoles(): Promise; findAll(ctx: RequestContext, options?: ListQueryOptions, relations?: RelationPaths): Promise>; findOne(ctx: RequestContext, roleId: ID, relations?: RelationPaths): Promise; getChannelsForRole(ctx: RequestContext, roleId: ID): Promise; /** * @description * Returns the special SuperAdmin Role, which always exists in Vendure. */ getSuperAdminRole(ctx?: RequestContext): Promise; /** * @description * Returns the special Customer Role, which always exists in Vendure. */ getCustomerRole(ctx?: RequestContext): Promise; /** * @description * Returns all the valid Permission values */ getAllPermissions(): string[]; /** * @description * Returns true if the User has the specified permission on that Channel */ userHasPermissionOnChannel(ctx: RequestContext, channelId: ID, permission: Permission): Promise; /** * @description * Returns true if the User has any of the specified permissions on that Channel */ userHasAnyPermissionsOnChannel(ctx: RequestContext, channelId: ID, permissions: Permission[]): Promise; private activeUserCanReadRole; private getAllRolesWithChannels; /** * @description * Returns true if the User has all the specified permissions on that Channel */ userHasAllPermissionsOnChannel(ctx: RequestContext, channelId: ID, permissions: Permission[]): Promise; private getActiveUserPermissionsOnChannel; 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; /** * @description * Checks that the active User has sufficient Permissions on the target Channels to create * a Role with the given Permissions. The rule is that an Administrator may only grant * Permissions that they themselves already possess. */ private checkActiveUserHasSufficientPermissions; 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; }