import { FindConfig, QuerySelector, Selector } from "../types/common"; import { CreateSalesChannelInput, UpdateSalesChannelInput } from "../types/sales-channels"; import { EntityManager } from "typeorm"; import { TransactionBaseService } from "../interfaces"; import { SalesChannel } from "../models"; import { SalesChannelRepository } from "../repositories/sales-channel"; import EventBusService from "./event-bus"; import StoreService from "./store"; type InjectedDependencies = { salesChannelRepository: typeof SalesChannelRepository; eventBusService: EventBusService; manager: EntityManager; storeService: StoreService; }; declare class SalesChannelService extends TransactionBaseService { static Events: { UPDATED: string; CREATED: string; DELETED: string; }; protected readonly salesChannelRepository_: typeof SalesChannelRepository; protected readonly eventBusService_: EventBusService; protected readonly storeService_: StoreService; constructor({ salesChannelRepository, eventBusService, storeService, }: InjectedDependencies); /** * A generic retrieve used to find a sales channel by different attributes. * * @param selector - SC selector * @param config - find config * @returns a single SC matching the query or throws */ protected retrieve_(selector: Selector, config?: FindConfig): Promise; /** * Retrieve a SalesChannel by id * * @param salesChannelId - id of the channel to retrieve * @param config - SC config * @experimental This feature is under development and may change in the future. * To use this feature please enable the corresponding feature flag in your medusa backend project. * @returns a sales channel */ retrieve(salesChannelId: string, config?: FindConfig): Promise; /** * Find a sales channel by name. * * @param name of the sales channel * @param config - find config * @return a sales channel with matching name */ retrieveByName(name: string, config?: FindConfig): Promise; /** * Lists sales channels based on the provided parameters and includes the count of * sales channels that match the query. * @return an array containing the sales channels as * the first element and the total count of sales channels that matches the query * as the second element. */ listAndCount(selector: QuerySelector, config?: FindConfig): Promise<[SalesChannel[], number]>; /** * Creates a SalesChannel * * @experimental This feature is under development and may change in the future. * To use this feature please enable the corresponding feature flag in your medusa backend project. * @returns the created channel */ create(data: CreateSalesChannelInput): Promise; update(salesChannelId: string, data: UpdateSalesChannelInput): Promise; /** * Deletes a sales channel from * @experimental This feature is under development and may change in the future. * To use this feature please enable the corresponding feature flag in your medusa backend project. * @param salesChannelId - the id of the sales channel to delete */ delete(salesChannelId: string): Promise; /** * Creates a default sales channel, if this does not already exist. * @return the sales channel */ createDefault(): Promise; /** * Retrieves the default sales channel. * @return the sales channel */ retrieveDefault(): Promise; /** * Remove a batch of product from a sales channel * @param salesChannelId - The id of the sales channel on which to remove the products * @param productIds - The products ids to remove from the sales channel * @return the sales channel on which the products have been removed */ removeProducts(salesChannelId: string, productIds: string[]): Promise; /** * Add a batch of product to a sales channel * @param salesChannelId - The id of the sales channel on which to add the products * @param productIds - The products ids to attach to the sales channel * @return the sales channel on which the products have been added */ addProducts(salesChannelId: string, productIds: string[]): Promise; } export default SalesChannelService;