RoleService

RoleService

Contains methods relating to Role entities.

Signature

class RoleService {
  constructor(connection: TransactionalConnection, channelService: ChannelService, listQueryBuilder: ListQueryBuilder, configService: ConfigService)
  async initRoles() => ;
  findAll(ctx: RequestContext, options?: ListQueryOptions<Role>) => Promise<PaginatedList<Role>>;
  findOne(ctx: RequestContext, roleId: ID) => Promise<Role | undefined>;
  getChannelsForRole(ctx: RequestContext, roleId: ID) => Promise<Channel[]>;
  getSuperAdminRole() => Promise<Role>;
  getCustomerRole() => Promise<Role>;
  getAllPermissions() => string[];
  async userHasPermissionOnChannel(ctx: RequestContext, channelId: ID, permission: 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) => RoleService

initRoles

async method
type:
() =>

findAll

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

findOne

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

getChannelsForRole

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

getSuperAdminRole

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

getCustomerRole

method
type:
() => 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

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) =>