🚨 Announcing Vendure v2 Beta

RoleService

RoleService

Contains methods relating to Role entities.

Signature

class RoleService {
  constructor(connection: TransactionalConnection, channelService: ChannelService, listQueryBuilder: ListQueryBuilder, configService: ConfigService, eventBus: EventBus)
  async initRoles() => ;
  findAll(ctx: RequestContext, options?: ListQueryOptions<Role>, relations?: RelationPaths<Role>) => Promise<PaginatedList<Role>>;
  findOne(ctx: RequestContext, roleId: ID, relations?: RelationPaths<Role>) => Promise<Role | undefined>;
  getChannelsForRole(ctx: RequestContext, roleId: ID) => Promise<Channel[]>;
  getSuperAdminRole(ctx?: RequestContext) => Promise<Role>;
  getCustomerRole(ctx?: RequestContext) => Promise<Role>;
  getAllPermissions() => string[];
  async userHasPermissionOnChannel(ctx: RequestContext, channelId: ID, permission: Permission) => Promise<boolean>;
  async userHasAnyPermissionsOnChannel(ctx: RequestContext, channelId: ID, permissions: Permission[]) => Promise<boolean>;
  async userHasAllPermissionsOnChannel(ctx: RequestContext, channelId: ID, permissions: Permission[]) => Promise<boolean>;
  async create(ctx: RequestContext, input: CreateRoleInput) => Promise<Role>;
  async update(ctx: RequestContext, input: UpdateRoleInput) => Promise<Role>;
  async delete(ctx: RequestContext, id: ID) => Promise<DeletionResponse>;
  async assignRoleToChannel(ctx: RequestContext, roleId: ID, channelId: ID) => ;
}

Members

constructor

method
type:
(connection: TransactionalConnection, channelService: ChannelService, listQueryBuilder: ListQueryBuilder, configService: ConfigService, eventBus: EventBus) => RoleService

initRoles

async method
type:
() =>

findAll

method
type:
(ctx: RequestContext, options?: ListQueryOptions<Role>, relations?: RelationPaths<Role>) => Promise<PaginatedList<Role>>

findOne

method
type:
(ctx: RequestContext, roleId: ID, relations?: RelationPaths<Role>) => Promise<Role | undefined>

getChannelsForRole

method
type:
(ctx: RequestContext, roleId: ID) => Promise<Channel[]>

getSuperAdminRole

method
type:
(ctx?: RequestContext) => Promise<Role>
Returns the special SuperAdmin Role, which always exists in Vendure.

getCustomerRole

method
type:
(ctx?: RequestContext) => Promise<Role>
Returns the special Customer Role, which always exists in Vendure.

getAllPermissions

method
type:
() => string[]
Returns all the valid Permission values

userHasPermissionOnChannel

async method
type:
(ctx: RequestContext, channelId: ID, permission: Permission) => Promise<boolean>
Returns true if the User has the specified permission on that Channel

userHasAnyPermissionsOnChannel

async method
type:
(ctx: RequestContext, channelId: ID, permissions: Permission[]) => Promise<boolean>
Returns true if the User has any of the specified permissions on that Channel

userHasAllPermissionsOnChannel

async method
type:
(ctx: RequestContext, channelId: ID, permissions: Permission[]) => Promise<boolean>
Returns true if the User has all the specified permissions on that Channel

create

async method
type:
(ctx: RequestContext, input: CreateRoleInput) => Promise<Role>

update

async method
type:
(ctx: RequestContext, input: UpdateRoleInput) => Promise<Role>

delete

async method
type:
(ctx: RequestContext, id: ID) => Promise<DeletionResponse>

assignRoleToChannel

async method
type:
(ctx: RequestContext, roleId: ID, channelId: ID) =>