feat(fulfillment): Soft deletes (#6630)

**What**
- Ensure soft delete works properly according to the soft delete configuration and validate all relation of the entire data model
- Add is_enabled to the providers in order to manage new providers to enabled or disabled
- include joiner config update

FIXES CORE-1853
FIXES CORE-1830
FIXES CORE-1719
This commit is contained in:
Adrien de Peretti authored and GitHub committed 2024-03-11 15:56:08 +00:00
1 parent 78e5ec459a
commit d9d5afc3cf
23 files changed
+985 -696

No files matched your search

@@ -6,6 +6,8 @@ export function generateCreateFulfillmentData(
shipping_option_id: string
}
) {
const randomString = Math.random().toString(36).substring(7)
return {
location_id: "test-location",
packed_at: null,
@@ -17,28 +19,28 @@ export function generateCreateFulfillmentData(
shipping_option_id: data.shipping_option_id,
metadata: data.metadata ?? null,
delivery_address: data.delivery_address ?? {
address_1: "test-address",
address_2: "test-address",
city: "test-city",
postal_code: "test-postal-code",
country_code: "test-country-code",
province: "test-province",
phone: "test-phone",
full_name: "test-full-name",
address_1: "test-address_" + randomString,
address_2: "test-address_" + randomString,
city: "test-city_" + randomString,
postal_code: "test-postal-code_" + randomString,
country_code: "test-country-code_" + randomString,
province: "test-province_" + randomString,
phone: "test-phone_" + randomString,
full_name: "test-full-name_" + randomString,
},
items: data.items ?? [
{
title: "test-title",
sku: "test-sku",
title: "test-title_" + randomString,
sku: "test-sku_" + randomString,
quantity: 1,
barcode: "test-barcode",
barcode: "test-barcode_" + randomString,
},
],
labels: data.labels ?? [
{
tracking_number: "test-tracking-number",
tracking_url: "test-tracking-url",
label_url: "test-label-url",
tracking_number: "test-tracking-number_" + randomString,
tracking_url: "test-tracking-url_" + randomString,
label_url: "test-label-url_" + randomString,
},
],
order: data.order ?? {},
@@ -1,2 +1,52 @@
import { generateCreateShippingOptionsData } from "./shipping-options"
import { generateCreateFulfillmentData } from "./fulfillment"
import { IFulfillmentModuleService } from "@medusajs/types"
export * from "./shipping-options"
export * from "./fulfillment"
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.create({
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({
fulfillment_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,
})
)
}
@@ -14,14 +14,16 @@ export function generateCreateShippingOptionsData({
name?: string
type?: CreateShippingOptionDTO["type"]
}): Required<CreateShippingOptionDTO> {
const randomString = Math.random().toString(36).substring(7)
return {
service_zone_id: service_zone_id,
shipping_profile_id: shipping_profile_id,
fulfillment_provider_id: fulfillment_provider_id,
type: type ?? {
code: "test-type",
description: "test-description",
label: "test-label",
code: "test-type_" + randomString,
description: "test-description_" + randomString,
label: "test-label_" + randomString,
},
data: data ?? {
amount: 1000,