**What** Update the `MedusaService` class, factory and types to remove the concept of main modules. The idea being that all method will be explicitly named and suffixes to represent the object you are trying to manipulate. This pr also includes various fixes in different modules Co-authored-by: Stevche Radevski <4820812+sradevski@users.noreply.github.com> Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { generateCreateShippingOptionsData } from "./shipping-options"
|
|
import { generateCreateFulfillmentData } from "./fulfillment"
|
|
import { IFulfillmentModuleService } from "@medusajs/types"
|
|
|
|
export * from "./shipping-options"
|
|
export * from "./fulfillment"
|
|
export * from "./events"
|
|
|
|
export async function createFullDataStructure(
|
|
service: IFulfillmentModuleService,
|
|
{
|
|
providerId,
|
|
}: {
|
|
providerId: string
|
|
}
|
|
) {
|
|
const randomString = Math.random().toString(36).substring(7)
|
|
|
|
const shippingProfile = await service.createShippingProfiles({
|
|
// generate random string
|
|
name: "test_" + randomString,
|
|
type: "default",
|
|
})
|
|
const fulfillmentSet = await service.createFulfillmentSets({
|
|
name: "test_" + randomString,
|
|
type: "test-type",
|
|
})
|
|
const serviceZone = await service.createServiceZones({
|
|
name: "test_" + randomString,
|
|
fulfillment_set_id: fulfillmentSet.id,
|
|
geo_zones: [
|
|
{
|
|
type: "country",
|
|
country_code: "US_" + randomString,
|
|
},
|
|
],
|
|
})
|
|
|
|
const shippingOption = await service.createShippingOptions(
|
|
generateCreateShippingOptionsData({
|
|
provider_id: providerId,
|
|
service_zone_id: serviceZone.id,
|
|
shipping_profile_id: shippingProfile.id,
|
|
})
|
|
)
|
|
|
|
await service.createFulfillment(
|
|
generateCreateFulfillmentData({
|
|
provider_id: providerId,
|
|
shipping_option_id: shippingOption.id,
|
|
})
|
|
)
|
|
}
|