fix(dashboard, js-sdk, types, medusa): separate between delete response with and without parent (#8852)
- Separate the previous `DeleteResponse` to `DeleteResponse` and `DeleteResponseWithParent`, as not every API route's delete response returns a parent. This ensures more accurate types shown in OAS / documentation. - Use `DeleteResponse` or `DeleteResponseWithParent` in response API routes based on what they return - Remove direct usage of `DeleteResponse` in API route, and instead create a type in the `type` package specific for the route / domain. - Use the new types in the `js-sdk` and `dashboard`.
This commit is contained in:
@@ -2,7 +2,7 @@ import {
|
||||
deleteLineItemsWorkflow,
|
||||
updateLineItemInCartWorkflow,
|
||||
} from "@medusajs/core-flows"
|
||||
import { DeleteResponse, HttpTypes } from "@medusajs/types"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { MedusaError } from "@medusajs/utils"
|
||||
import { MedusaRequest, MedusaResponse } from "../../../../../../types/routing"
|
||||
import { prepareListQuery } from "../../../../../../utils/get-query-config"
|
||||
@@ -60,7 +60,7 @@ export const POST = async (
|
||||
|
||||
export const DELETE = async (
|
||||
req: MedusaRequest,
|
||||
res: MedusaResponse<DeleteResponse<"line-item">>
|
||||
res: MedusaResponse<HttpTypes.StoreLineItemDeleteResponse>
|
||||
) => {
|
||||
const id = req.params.line_id
|
||||
|
||||
|
||||
@@ -6,8 +6,7 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "../../../../../../types/routing"
|
||||
|
||||
import { DeleteResponse, HttpTypes, MedusaContainer } from "@medusajs/types"
|
||||
import { HttpTypes, MedusaContainer } from "@medusajs/types"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
MedusaError,
|
||||
@@ -71,7 +70,7 @@ export const POST = async (
|
||||
|
||||
export const DELETE = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
res: MedusaResponse<DeleteResponse<"address">>
|
||||
res: MedusaResponse<HttpTypes.StoreCustomerAddressDeleteResponse>
|
||||
) => {
|
||||
const id = req.auth_context.actor_id
|
||||
await validateCustomerAddress(req.scope, id, req.params.address_id)
|
||||
|
||||
Reference in New Issue
Block a user