fix: Accept filters in softDelete + fulfillment location clean-up (#7198)
This commit is contained in:
@@ -14,17 +14,17 @@ import {
|
||||
UpdateServiceZoneDTO,
|
||||
} from "@medusajs/types"
|
||||
import {
|
||||
arrayDifference,
|
||||
EmitEvents,
|
||||
FulfillmentUtils,
|
||||
getSetDifference,
|
||||
InjectManager,
|
||||
InjectTransactionManager,
|
||||
isString,
|
||||
MedusaContext,
|
||||
MedusaError,
|
||||
Modules,
|
||||
ModulesSdkUtils,
|
||||
arrayDifference,
|
||||
getSetDifference,
|
||||
isString,
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import moduleSchema from "./schema"
|
||||
|
||||
export const LinkableKeys = {
|
||||
stock_location_id: StockLocation.name,
|
||||
location_id: StockLocation.name,
|
||||
}
|
||||
|
||||
const entityLinkableKeysMap: MapToConfig = {}
|
||||
@@ -21,10 +22,7 @@ export const entityNameToLinkableKeysMap: MapToConfig = entityLinkableKeysMap
|
||||
export const joinerConfig: ModuleJoinerConfig = {
|
||||
serviceName: Modules.STOCK_LOCATION,
|
||||
primaryKeys: ["id"],
|
||||
linkableKeys: {
|
||||
stock_location_id: StockLocation.name,
|
||||
location_id: StockLocation.name,
|
||||
},
|
||||
linkableKeys: LinkableKeys,
|
||||
schema: moduleSchema,
|
||||
alias: [
|
||||
{
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import {
|
||||
DALUtils,
|
||||
Searchable,
|
||||
createPsqlIndexStatementHelper,
|
||||
generateEntityId,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
BeforeCreate,
|
||||
Entity,
|
||||
Filter,
|
||||
ManyToOne,
|
||||
OnInit,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
} from "@mikro-orm/core"
|
||||
import {
|
||||
createPsqlIndexStatementHelper,
|
||||
generateEntityId,
|
||||
Searchable,
|
||||
} from "@medusajs/utils"
|
||||
|
||||
import { StockLocationAddress } from "./stock-location-address"
|
||||
|
||||
@@ -21,6 +23,7 @@ const StockLocationDeletedAtIndex = createPsqlIndexStatementHelper({
|
||||
})
|
||||
|
||||
@Entity()
|
||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||
export class StockLocation {
|
||||
@PrimaryKey({ columnType: "text" })
|
||||
id: string
|
||||
|
||||
Reference in New Issue
Block a user