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

This commit is contained in:
Oli Juhl
2024-05-03 16:32:07 +00:00
committed by GitHub
parent 1366e2efad
commit 2f7b53488d
20 changed files with 232 additions and 114 deletions
@@ -24,12 +24,12 @@ export const associateFulfillmentSetsWithLocationStep = createStep(
.map((link) => {
return link.fulfillment_set_ids.map((id) => {
return {
[Modules.FULFILLMENT]: {
fulfillment_set_id: id,
},
[Modules.STOCK_LOCATION]: {
stock_location_id: link.location_id,
},
[Modules.FULFILLMENT]: {
fulfillment_set_id: id,
},
}
})
})
@@ -1,16 +1,24 @@
import {
DeleteEntityInput,
ModuleRegistrationName,
Modules,
} from "@medusajs/modules-sdk"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
export const deleteStockLocationsStepId = "delete-stock-locations-step"
export const deleteStockLocationsStep = createStep(
deleteStockLocationsStepId,
async (input: string[], { container }) => {
const service = container.resolve(ModuleRegistrationName.STOCK_LOCATION)
await service.softDelete(input)
const softDeletedEntities = await service.softDelete(input)
return new StepResponse(void 0, input)
return new StepResponse(
{
[Modules.STOCK_LOCATION]: softDeletedEntities,
} as DeleteEntityInput,
input
)
},
async (deletedLocationIds, { container }) => {
if (!deletedLocationIds?.length) {
@@ -1,8 +1,7 @@
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
import { Modules } from "@medusajs/modules-sdk"
import { deleteStockLocationsStep } from "../steps"
import { removeRemoteLinkStep } from "../../common/steps/remove-remote-links"
import { deleteStockLocationsStep } from "../steps"
interface WorkflowInput {
ids: string[]
@@ -12,10 +11,8 @@ export const deleteStockLocationsWorkflowId = "delete-stock-locations-workflow"
export const deleteStockLocationsWorkflow = createWorkflow(
deleteStockLocationsWorkflowId,
(input: WorkflowData<WorkflowInput>) => {
deleteStockLocationsStep(input.ids)
const softDeletedEntities = deleteStockLocationsStep(input.ids)
removeRemoteLinkStep({
[Modules.STOCK_LOCATION]: { stock_location_id: input.ids },
})
removeRemoteLinkStep(softDeletedEntities)
}
)