ChannelService
ChannelService
Contains methods relating to Channel entities.
Signature
class ChannelService {
constructor(connection: TransactionalConnection, configService: ConfigService, globalSettingsService: GlobalSettingsService, customFieldRelationService: CustomFieldRelationService, eventBus: EventBus, listQueryBuilder: ListQueryBuilder)
async assignToCurrentChannel(entity: T, ctx: RequestContext) => Promise<T>;
async assignToChannels(ctx: RequestContext, entityType: Type<T>, entityId: ID, channelIds: ID[]) => Promise<T>;
async removeFromChannels(ctx: RequestContext, entityType: Type<T>, entityId: ID, channelIds: ID[]) => Promise<T | undefined>;
async getChannelFromToken(token: string) => Promise<Channel>;
async getChannelFromToken(ctx: RequestContext, token: string) => Promise<Channel>;
async getChannelFromToken(ctxOrToken: RequestContext | string, token?: string) => Promise<Channel>;
async getDefaultChannel(ctx?: RequestContext) => Promise<Channel>;
findAll(ctx: RequestContext, options?: ListQueryOptions<Channel>, relations?: RelationPaths<Channel>) => Promise<PaginatedList<Channel>>;
findOne(ctx: RequestContext, id: ID) => Promise<Channel | undefined>;
async create(ctx: RequestContext, input: CreateChannelInput) => Promise<ErrorResultUnion<CreateChannelResult, Channel>>;
async update(ctx: RequestContext, input: UpdateChannelInput) => Promise<ErrorResultUnion<UpdateChannelResult, Channel>>;
async delete(ctx: RequestContext, id: ID) => Promise<DeletionResponse>;
public isChannelAware(entity: VendureEntity) => entity is VendureEntity & ChannelAware;
}
Members
constructor
method
type:
(connection: TransactionalConnection, configService: ConfigService, globalSettingsService: GlobalSettingsService, customFieldRelationService: CustomFieldRelationService, eventBus: EventBus, listQueryBuilder: ListQueryBuilder) => ChannelService
assignToCurrentChannel
method
type:
(entity: T, ctx: RequestContext) => Promise<T>
Assigns a ChannelAware entity to the default Channel as well as any channel
specified in the RequestContext.
assignToChannels
method
type:
(ctx: RequestContext, entityType: Type<T>, entityId: ID, channelIds: ID[]) => Promise<T>
Assigns the entity to the given Channels and saves.
removeFromChannels
method
type:
(ctx: RequestContext, entityType: Type<T>, entityId: ID, channelIds: ID[]) => Promise<T | undefined>
Removes the entity from the given Channels and saves.
getChannelFromToken
method
type:
(token: string) => Promise<Channel>
Given a channel token, returns the corresponding Channel if it exists, else will throw
a ChannelNotFoundError.
getChannelFromToken
method
type:
(ctx: RequestContext, token: string) => Promise<Channel>
getChannelFromToken
method
type:
(ctxOrToken: RequestContext | string, token?: string) => Promise<Channel>
getDefaultChannel
method
type:
(ctx?: RequestContext) => Promise<Channel>
Returns the default Channel.
findAll
method
type:
(ctx: RequestContext, options?: ListQueryOptions<Channel>, relations?: RelationPaths<Channel>) => Promise<PaginatedList<Channel>>
findOne
method
type:
(ctx: RequestContext, id: ID) => Promise<Channel | undefined>
create
method
type:
(ctx: RequestContext, input: CreateChannelInput) => Promise<ErrorResultUnion<CreateChannelResult, Channel>>
update
method
type:
(ctx: RequestContext, input: UpdateChannelInput) => Promise<ErrorResultUnion<UpdateChannelResult, Channel>>
delete
method
type:
(ctx: RequestContext, id: ID) => Promise<DeletionResponse>
isChannelAware
method
type:
(entity: VendureEntity) => entity is VendureEntity & ChannelAware
Type guard method which returns true if the given entity is an
instance of a class which implements the ChannelAware interface.