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:
Philip Korsholm
2024-03-25 16:29:36 +01:00
committed by GitHub
co-authored by Riqwan Thamir
parent 71efa15088
commit deab12e27e
8 changed files with 163 additions and 1 deletions
@@ -0,0 +1,22 @@
import { MedusaRequest, MedusaResponse } from "../../../../types/routing"
import { deleteStockLocationsWorkflow } from "@medusajs/core-flows"
export const DELETE = async (req: MedusaRequest, res: MedusaResponse) => {
const { id } = req.params
const { errors } = await deleteStockLocationsWorkflow(req.scope).run({
input: { ids: [id] },
throwOnError: false,
})
if (Array.isArray(errors) && errors[0]) {
throw errors[0].error
}
res.status(200).json({
id,
object: "stock_location",
deleted: true,
})
}