chore(): start moving some packages to the core directory (#7215)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { buildEventNamesFromEntityName } from "../event-bus"
|
||||
|
||||
const eventBaseNames: [
|
||||
"fulfillmentSet",
|
||||
"serviceZone",
|
||||
"geoZone",
|
||||
"shippingOption",
|
||||
"shippingProfile",
|
||||
"shippingOptionRule",
|
||||
"fulfillment"
|
||||
] = [
|
||||
"fulfillmentSet",
|
||||
"serviceZone",
|
||||
"geoZone",
|
||||
"shippingOption",
|
||||
"shippingProfile",
|
||||
"shippingOptionRule",
|
||||
"fulfillment",
|
||||
]
|
||||
|
||||
export const FulfillmentEvents = buildEventNamesFromEntityName(eventBaseNames)
|
||||
@@ -0,0 +1,6 @@
|
||||
export enum GeoZoneType {
|
||||
COUNTRY = "country",
|
||||
PROVINCE = "province",
|
||||
CITY = "city",
|
||||
ZIP = "zip",
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export * from "./geo-zone"
|
||||
export * from "./shipping-options"
|
||||
export * from "./provider"
|
||||
export * from "./events"
|
||||
@@ -0,0 +1,65 @@
|
||||
import { IFulfillmentProvider } from "@medusajs/types"
|
||||
|
||||
export class AbstractFulfillmentProviderService
|
||||
implements IFulfillmentProvider
|
||||
{
|
||||
static identifier: string
|
||||
|
||||
static _isFulfillmentService = true
|
||||
|
||||
static isFulfillmentService(obj) {
|
||||
return obj?.constructor?._isFulfillmentService
|
||||
}
|
||||
|
||||
getIdentifier() {
|
||||
return (this.constructor as any).identifier
|
||||
}
|
||||
|
||||
async getFulfillmentOptions(): Promise<Record<string, unknown>[]> {
|
||||
throw Error("getFulfillmentOptions must be overridden by the child class")
|
||||
}
|
||||
|
||||
async validateFulfillmentData(optionData, data, context): Promise<any> {
|
||||
throw Error("validateFulfillmentData must be overridden by the child class")
|
||||
}
|
||||
|
||||
async validateOption(data): Promise<boolean> {
|
||||
throw Error("validateOption must be overridden by the child class")
|
||||
}
|
||||
|
||||
async canCalculate(data) {
|
||||
throw Error("canCalculate must be overridden by the child class")
|
||||
}
|
||||
|
||||
async calculatePrice(optionData, data, cart) {
|
||||
throw Error("calculatePrice must be overridden by the child class")
|
||||
}
|
||||
|
||||
async createFulfillment(data, items, order, fulfillment): Promise<any> {
|
||||
throw Error("createFulfillment must be overridden by the child class")
|
||||
}
|
||||
|
||||
async cancelFulfillment(fulfillment): Promise<any> {
|
||||
throw Error("cancelFulfillment must be overridden by the child class")
|
||||
}
|
||||
|
||||
async getFulfillmentDocuments(data) {
|
||||
return []
|
||||
}
|
||||
|
||||
async createReturnFulfillment(fromData): Promise<any> {
|
||||
throw Error("createReturn must be overridden by the child class")
|
||||
}
|
||||
|
||||
async getReturnDocuments(data) {
|
||||
return []
|
||||
}
|
||||
|
||||
async getShipmentDocuments(data) {
|
||||
return []
|
||||
}
|
||||
|
||||
async retrieveDocuments(fulfillmentData, documentType) {
|
||||
throw Error("retrieveDocuments must be overridden by the child class")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
export enum ShippingOptionPriceType {
|
||||
CALCULATED = "calculated",
|
||||
FLAT = "flat",
|
||||
}
|
||||
Reference in New Issue
Block a user