fix: Accept filters in softDelete + fulfillment location clean-up (#7198)

This commit is contained in:
Oli Juhl
2024-05-03 18:32:07 +02:00
committed by GitHub
parent 1366e2efad
commit 2f7b53488d
20 changed files with 232 additions and 114 deletions

View File

@@ -2,54 +2,42 @@ import { Modules } from "@medusajs/modules-sdk"
import { ModuleJoinerConfig } from "@medusajs/types"
import { LINKS } from "@medusajs/utils"
export const FulfillmentSetLocation: ModuleJoinerConfig = {
serviceName: LINKS.FulfillmentSetLocation,
export const LocationFulfillmentSet: ModuleJoinerConfig = {
serviceName: LINKS.LocationFulfillmentSet,
isLink: true,
databaseConfig: {
tableName: "fulfillment_set_location",
idPrefix: "fsloc",
tableName: "location_fulfillment_set",
idPrefix: "locfs",
},
alias: [
{
name: ["fulfillment_set_location", "fulfillment_set_locations"],
name: ["location_fulfillment_set", "location_fulfillment_sets"],
args: {
entity: "LinkFulfillmentSetLocation",
entity: "LinkLocationFulfillmentSet",
},
},
],
primaryKeys: ["id", "fulfillment_set_id", "stock_location_id"],
primaryKeys: ["id", "stock_location_id", "fulfillment_set_id"],
relationships: [
{
serviceName: Modules.FULFILLMENT,
primaryKey: "id",
foreignKey: "fulfillment_set_id",
alias: "fulfillment_set",
},
{
serviceName: Modules.STOCK_LOCATION,
primaryKey: "id",
foreignKey: "stock_location_id",
alias: "location",
},
{
serviceName: Modules.FULFILLMENT,
primaryKey: "id",
foreignKey: "fulfillment_set_id",
alias: "fulfillment_set",
deleteCascade: true,
},
],
extends: [
{
serviceName: Modules.FULFILLMENT,
fieldAlias: {
stock_locations: "locations_link.location",
},
relationship: {
serviceName: LINKS.FulfillmentSetLocation,
primaryKey: "fulfillment_set_id",
foreignKey: "id",
alias: "locations_link",
isList: true,
},
},
{
serviceName: Modules.STOCK_LOCATION,
relationship: {
serviceName: LINKS.FulfillmentSetLocation,
serviceName: LINKS.LocationFulfillmentSet,
primaryKey: "stock_location_id",
foreignKey: "id",
alias: "fulfillment_set_link",
@@ -59,5 +47,14 @@ export const FulfillmentSetLocation: ModuleJoinerConfig = {
fulfillment_sets: "fulfillment_set_link.fulfillment_set",
},
},
{
serviceName: Modules.FULFILLMENT,
relationship: {
serviceName: LINKS.LocationFulfillmentSet,
primaryKey: "fulfillment_set_id",
foreignKey: "id",
alias: "locations_link",
},
},
],
}

View File

@@ -3,8 +3,8 @@ export * from "./cart-payment-collection"
export * from "./cart-promotion"
export * from "./cart-region"
export * from "./cart-sales-channel"
export * from "./fulfillment-set-location"
export * from "./inventory-level-stock-location"
export * from "./location-fulfillment-set"
export * from "./order-customer"
export * from "./order-promotion"
export * from "./order-region"
@@ -18,3 +18,4 @@ export * from "./region-payment-provider"
export * from "./sales-channel-location"
export * from "./shipping-option-price-set"
export * from "./store-default-currency"

View File

@@ -0,0 +1,60 @@
import { Modules } from "@medusajs/modules-sdk"
import { ModuleJoinerConfig } from "@medusajs/types"
import { LINKS } from "@medusajs/utils"
export const LocationFulfillmentSet: ModuleJoinerConfig = {
serviceName: LINKS.LocationFulfillmentSet,
isLink: true,
databaseConfig: {
tableName: "location_fulfillment_set",
idPrefix: "locfs",
},
alias: [
{
name: ["location_fulfillment_set", "location_fulfillment_sets"],
args: {
entity: "LinkLocationFulfillmentSet",
},
},
],
primaryKeys: ["id", "stock_location_id", "fulfillment_set_id"],
relationships: [
{
serviceName: Modules.STOCK_LOCATION,
primaryKey: "id",
foreignKey: "stock_location_id",
alias: "location",
},
{
serviceName: Modules.FULFILLMENT,
primaryKey: "id",
foreignKey: "fulfillment_set_id",
alias: "fulfillment_set",
deleteCascade: true,
},
],
extends: [
{
serviceName: Modules.STOCK_LOCATION,
relationship: {
serviceName: LINKS.LocationFulfillmentSet,
primaryKey: "stock_location_id",
foreignKey: "id",
alias: "fulfillment_set_link",
isList: true,
},
fieldAlias: {
fulfillment_sets: "fulfillment_set_link.fulfillment_set",
},
},
{
serviceName: Modules.FULFILLMENT,
relationship: {
serviceName: LINKS.LocationFulfillmentSet,
primaryKey: "fulfillment_set_id",
foreignKey: "id",
alias: "locations_link",
},
},
],
}