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