feat(types, medusa, core-flows): add delete-stock-location endpoint to api-v2 (#6801)
* initial create * add changeset * redo changes for stock locatino module' * initial delete stock location * add changeset * pr prep * propagate deletion with common step * move integration tests --------- Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
|
||||
return new StepResponse(void 0, input)
|
||||
},
|
||||
async (deletedLocaitonIds, { container }) => {
|
||||
if (!deletedLocaitonIds?.length) {
|
||||
return
|
||||
}
|
||||
const service = container.resolve(ModuleRegistrationName.STOCK_LOCATION)
|
||||
|
||||
await service.restore(deletedLocaitonIds)
|
||||
}
|
||||
)
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./create-stock-locations"
|
||||
export * from "./delete-stock-locations"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
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"
|
||||
|
||||
interface WorkflowInput {
|
||||
ids: string[]
|
||||
}
|
||||
|
||||
export const deleteStockLocationsWorkflowId = "delete-stock-locations-workflow"
|
||||
export const deleteStockLocationsWorkflow = createWorkflow(
|
||||
deleteStockLocationsWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>) => {
|
||||
deleteStockLocationsStep(input.ids)
|
||||
|
||||
removeRemoteLinkStep({
|
||||
[Modules.STOCK_LOCATION]: { stock_location_id: input.ids },
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -1 +1,2 @@
|
||||
export * from "./create-stock-locations"
|
||||
export * from "./delete-stock-locations"
|
||||
|
||||
Reference in New Issue
Block a user