import BaseFulfillmentService from "medusa-interfaces"; import { EntityManager } from "typeorm"; import { TransactionBaseService } from "../interfaces"; import { Cart, Fulfillment, FulfillmentProvider, LineItem, Order, ShippingMethod, ShippingOption } from "../models"; import { FulfillmentProviderRepository } from "../repositories/fulfillment-provider"; import { CreateFulfillmentOrder } from "../types/fulfillment"; import { CreateReturnType, FulfillmentOptions } from "../types/fulfillment-provider"; import { MedusaContainer } from "../types/global"; type FulfillmentProviderKey = `fp_${string}`; type FulfillmentProviderContainer = MedusaContainer & { fulfillmentProviderRepository: typeof FulfillmentProviderRepository; manager: EntityManager; } & { [key in `${FulfillmentProviderKey}`]: typeof BaseFulfillmentService; }; type CalculateOptionPriceInput = { provider_id: string; data: Record; }; /** * Helps retrive fulfillment providers */ declare class FulfillmentProviderService extends TransactionBaseService { protected readonly container_: FulfillmentProviderContainer; protected readonly fulfillmentProviderRepository_: typeof FulfillmentProviderRepository; constructor(container: FulfillmentProviderContainer); registerInstalledProviders(providers: string[]): Promise; list(): Promise; listFulfillmentOptions(providerIds: string[]): Promise; /** * @param providerId - the provider id * @return the payment fulfillment provider */ retrieveProvider(providerId: string): typeof BaseFulfillmentService; createFulfillment(method: ShippingMethod, items: LineItem[], order: CreateFulfillmentOrder, fulfillment: Omit): Promise>; canCalculate(option: CalculateOptionPriceInput): Promise; validateFulfillmentData(option: ShippingOption, data: Record, cart: Cart | Record): Promise>; cancelFulfillment(fulfillment: Fulfillment): Promise; calculatePrice(option: ShippingOption, data: Record, cart?: Order | Cart): Promise; validateOption(option: ShippingOption): Promise; createReturn(returnOrder: CreateReturnType): Promise>; /** * Fetches documents from the fulfillment provider * @param providerId - the id of the provider * @param fulfillmentData - the data relating to the fulfillment * @param documentType - the typ of * @returns document to fetch */ retrieveDocuments(providerId: string, fulfillmentData: Record, documentType: "invoice" | "label"): Promise; } export default FulfillmentProviderService;