chore: fixes to http and request types for orders (1) (#13822)

This commit is contained in:
Shahed Nasser authored and GitHub committed 2025-10-28 11:14:43 +02:00
1 parent 25a20ca95f
commit fa93f18f7d
25 files changed
+217 -68

No files matched your search

@@ -109,6 +109,10 @@ export interface AdminCreateClaim {
* An internal note viewed by admin users only. * An internal note viewed by admin users only.
*/ */
internal_note?: string internal_note?: string
/**
* The ID of the associated reason.
*/
reason_id?: string | null
/** /**
* Key-value pairs of custom data. * Key-value pairs of custom data.
*/ */
@@ -116,13 +120,13 @@ export interface AdminCreateClaim {
} }
export interface AdminAddClaimItems extends AdminClaimAddItems {} export interface AdminAddClaimItems extends AdminClaimAddItems {}
export interface AdminUpdateClaimItem extends AdminClaimUpdateItem {} export interface AdminUpdateClaimItem extends Omit<AdminClaimUpdateItem, "description"> {}
export interface AdminAddClaimInboundItems extends AdminClaimAddItems {} export interface AdminAddClaimInboundItems extends AdminClaimAddItems {}
export interface AdminUpdateClaimInboundItem extends AdminClaimUpdateItem {} export interface AdminUpdateClaimInboundItem extends AdminClaimUpdateItem {}
export interface AdminAddClaimOutboundItems extends AdminClaimAddItems {} export interface AdminAddClaimOutboundItems extends AdminClaimAddItems {}
export interface AdminUpdateClaimOutboundItem extends AdminClaimUpdateItem {} export interface AdminUpdateClaimOutboundItem extends Omit<AdminClaimUpdateItem, "description"> {}
export interface AdminClaimAddInboundShipping export interface AdminClaimAddInboundShipping
extends AdminClaimAddShippingMethod {} extends AdminClaimAddShippingMethod {}
@@ -6,10 +6,48 @@ export interface AdminClaimListParams
extends BaseClaimListParams, extends BaseClaimListParams,
BaseFilterable<AdminClaimListParams> { } BaseFilterable<AdminClaimListParams> { }
export interface AdminClaimParams extends SelectParams { export interface AdminClaimActionsParams extends SelectParams {
/**
* Filter by claim ID(s).
*/
id?: string | string[] id?: string | string[]
/**
* Filter by claim status(es).
*/
status?: string | string[] status?: string | string[]
/**
* Apply filters on the claim's creation date.
*/
created_at?: OperatorMap<string> created_at?: OperatorMap<string>
/**
* Apply filters on the claim's update date.
*/
updated_at?: OperatorMap<string> updated_at?: OperatorMap<string>
/**
* Apply filters on the claim's deletion date.
*/
deleted_at?: OperatorMap<string>
}
export interface AdminClaimParams extends SelectParams {
/**
* Filter by claim ID(s).
*/
id?: string | string[]
/**
* Filter by claim status(es).
*/
status?: string | string[]
/**
* Apply filters on the claim's creation date.
*/
created_at?: OperatorMap<string>
/**
* Apply filters on the claim's update date.
*/
updated_at?: OperatorMap<string>
/**
* Apply filters on the claim's deletion date.
*/
deleted_at?: OperatorMap<string> deleted_at?: OperatorMap<string>
} }
@@ -1,36 +1,32 @@
enum ExchangeReason { export interface AdminAddExchangeOutboundItems {
MISSING_ITEM = "missing_item",
WRONG_ITEM = "wrong_item",
PRODUCTION_FAILURE = "production_failure",
OTHER = "other",
}
interface AdminExchangeAddItems {
/** /**
* The items to add to the exchange. * The items to add to the exchange.
*/ */
items: { items: {
/** /**
* If you're adding an inbound item, this is the ID of the order item returned. * The ID of the variant to add.
* If you're adding an outbound item, this is the ID of the variant to add.
*/ */
id: string variant_id: string
/** /**
* The item's quantity. * The item's quantity.
*/ */
quantity: number quantity: number
/** /**
* The reason the item is being returned / sent to the customer. * The item's unit price.
*/ */
reason?: ExchangeReason unit_price?: number
/**
* The item's description.
*/
description?: string
/** /**
* An internal note viewed by admin users only. * An internal note viewed by admin users only.
*/ */
internal_note?: string internal_note?: string
/**
* Whether to allow backorder for the item.
*/
allow_backorder?: boolean
/**
* Key-value pairs of custom data.
*/
metadata?: Record<string, unknown>
}[] }[]
} }
@@ -111,13 +107,46 @@ export interface AdminCreateExchange {
metadata?: Record<string, unknown> | null metadata?: Record<string, unknown> | null
} }
export interface AdminAddExchangeInboundItems extends AdminExchangeAddItems {} export interface AdminAddExchangeInboundItems {
/**
* The ID of the location the items are returned to.
*/
location_id?: string
/**
* The items to add to the exchange.
*/
items: {
/**
* The ID of the order item returned.
*/
id: string
/**
* The item's quantity.
*/
quantity: number
/**
* The description of why the item is being returned.
*/
description?: string
/**
* An internal note viewed by admin users only.
*/
internal_note?: string
/**
* The ID of the associated return reason.
*/
reason_id?: string
/**
* Key-value pairs of custom data.
*/
metadata?: Record<string, unknown>
}[]
}
export interface AdminUpdateExchangeInboundItem export interface AdminUpdateExchangeInboundItem
extends AdminExchangeUpdateItem {} extends AdminExchangeUpdateItem {}
export interface AdminAddExchangeOutboundItems extends AdminExchangeAddItems {}
export interface AdminUpdateExchangeOutboundItem export interface AdminUpdateExchangeOutboundItem
extends AdminExchangeUpdateItem {} extends Omit<AdminExchangeUpdateItem, "reason_id" | "description"> {}
export interface AdminExchangeAddInboundShipping export interface AdminExchangeAddInboundShipping
extends AdminExchangeAddShippingMethod {} extends AdminExchangeAddShippingMethod {}
@@ -1,11 +1,52 @@
import { OperatorMap } from "../../../dal" import { OperatorMap } from "../../../dal"
import { SelectParams } from "../../common" import { FindParams, SelectParams } from "../../common"
export interface AdminExchangeListParams extends SelectParams { export interface AdminExchangeListParams extends FindParams {
/**
* Filter by exchange ID(s).
*/
id?: string | string[] id?: string | string[]
/**
* Filter by order ID(s) to get their associated exchanges.
*/
order_id?: string | string[] order_id?: string | string[]
/**
* Filter by exchange status(es).
*/
status?: string | string[] status?: string | string[]
/**
* Apply filters on the exchange's creation date.
*/
created_at?: OperatorMap<string> created_at?: OperatorMap<string>
/**
* Apply filters on the exchange's update date.
*/
updated_at?: OperatorMap<string> updated_at?: OperatorMap<string>
/**
* Apply filters on the exchange's deletion date.
*/
deleted_at?: OperatorMap<string>
}
export interface AdminOrderExchangeListParams extends SelectParams {
/**
* Filter by exchange ID(s).
*/
id?: string | string[]
/**
* Filter by exchange status(es).
*/
status?: string | string[]
/**
* Apply filters on the exchange's creation date.
*/
created_at?: OperatorMap<string>
/**
* Apply filters on the exchange's update date.
*/
updated_at?: OperatorMap<string>
/**
* Apply filters on the exchange's deletion date.
*/
deleted_at?: OperatorMap<string> deleted_at?: OperatorMap<string>
} }
@@ -10,11 +10,13 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostClaimsItemsActionReqSchemaType } from "../../../validators"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostClaimsItemsActionReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateClaimItem,
HttpTypes.AdminClaimActionsParams
>,
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse> res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
) => { ) => {
const { id, action_id } = req.params const { id, action_id } = req.params
@@ -49,7 +51,7 @@ export const POST = async (
} }
export const DELETE = async ( export const DELETE = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminClaimActionsParams>,
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse> res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
) => { ) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
@@ -7,11 +7,13 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostClaimItemsReqSchemaType } from "../../validators"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostClaimItemsReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminAddClaimItems,
HttpTypes.AdminClaimActionsParams
>,
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse> res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -12,10 +12,12 @@ import {
remoteQueryObjectFromString, remoteQueryObjectFromString,
} from "@medusajs/framework/utils" } from "@medusajs/framework/utils"
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config" import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
import { AdminPostClaimsShippingActionReqSchemaType } from "../../../../validators"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostClaimsShippingActionReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminClaimUpdateInboundShipping,
HttpTypes.AdminClaimActionsParams
>,
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse> res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
) => { ) => {
const { id, action_id } = req.params const { id, action_id } = req.params
@@ -11,10 +11,12 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostClaimsItemsActionReqSchemaType } from "../../../../validators"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostClaimsItemsActionReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateClaimOutboundItem,
HttpTypes.AdminClaimActionsParams
>,
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse> res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
) => { ) => {
const { id, action_id } = req.params const { id, action_id } = req.params
@@ -49,7 +51,7 @@ export const POST = async (
} }
export const DELETE = async ( export const DELETE = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminClaimActionsParams>,
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse> res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
) => { ) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
@@ -8,11 +8,13 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostClaimsAddItemsReqSchemaType } from "../../../validators"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostClaimsAddItemsReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminAddClaimOutboundItems,
HttpTypes.AdminClaimActionsParams
>,
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse> res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -10,11 +10,13 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostClaimsShippingActionReqSchemaType } from "../../../../validators"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostClaimsShippingActionReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminClaimUpdateOutboundShipping,
HttpTypes.AdminClaimActionsParams
>,
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse> res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
) => { ) => {
const { id, action_id } = req.params const { id, action_id } = req.params
@@ -49,7 +51,7 @@ export const POST = async (
} }
export const DELETE = async ( export const DELETE = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminClaimActionsParams>,
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse> res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
) => { ) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
@@ -7,11 +7,13 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostClaimsShippingReqSchemaType } from "../../../validators"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostClaimsShippingReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminClaimAddOutboundShipping,
HttpTypes.AdminClaimActionsParams
>,
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse> res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -14,7 +14,7 @@ import {
import { defaultAdminDetailsReturnFields } from "../../../returns/query-config" import { defaultAdminDetailsReturnFields } from "../../../returns/query-config"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminClaimParams>,
res: MedusaResponse<HttpTypes.AdminClaimRequestResponse> res: MedusaResponse<HttpTypes.AdminClaimRequestResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -4,10 +4,10 @@ import {
refetchEntity, refetchEntity,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { MedusaError } from "@medusajs/framework/utils" import { MedusaError } from "@medusajs/framework/utils"
import { AdminClaimResponse } from "@medusajs/framework/types" import { AdminClaimResponse, HttpTypes } from "@medusajs/framework/types"
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<HttpTypes.AdminClaimActionsParams>,
res: MedusaResponse<AdminClaimResponse> res: MedusaResponse<AdminClaimResponse>
) => { ) => {
const claim = await refetchEntity({ const claim = await refetchEntity({
@@ -10,7 +10,6 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostOrderClaimsReqSchemaType } from "./validators"
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminClaimListParams>, req: AuthenticatedMedusaRequest<HttpTypes.AdminClaimListParams>,
@@ -40,7 +39,10 @@ export const GET = async (
} }
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostOrderClaimsReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateClaim,
HttpTypes.AdminClaimParams
>,
res: MedusaResponse<HttpTypes.AdminClaimOrderResponse> res: MedusaResponse<HttpTypes.AdminClaimOrderResponse>
) => { ) => {
const input = { const input = {
@@ -10,10 +10,12 @@ import {
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config" import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config"
import { AdminPostExchangesReturnRequestItemsReqSchemaType } from "../../../validators"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostExchangesReturnRequestItemsReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminAddExchangeInboundItems,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminExchangeReturnResponse> res: MedusaResponse<HttpTypes.AdminExchangeReturnResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -12,10 +12,12 @@ import {
remoteQueryObjectFromString, remoteQueryObjectFromString,
} from "@medusajs/framework/utils" } from "@medusajs/framework/utils"
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config" import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
import { AdminPostExchangesShippingActionReqSchemaType } from "../../../../validators"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostExchangesShippingActionReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminExchangeUpdateInboundShipping,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse> res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
) => { ) => {
const { id, action_id } = req.params const { id, action_id } = req.params
@@ -11,10 +11,12 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostExchangesItemsActionReqSchemaType } from "../../../../validators"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostExchangesItemsActionReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminUpdateExchangeOutboundItem,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse> res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
) => { ) => {
const { id, action_id } = req.params const { id, action_id } = req.params
@@ -49,7 +51,7 @@ export const POST = async (
} }
export const DELETE = async ( export const DELETE = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<{}, HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse> res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
) => { ) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
@@ -8,11 +8,13 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostExchangesAddItemsReqSchemaType } from "../../../validators"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostExchangesAddItemsReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminAddExchangeOutboundItems,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse> res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -10,11 +10,13 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostExchangesShippingActionReqSchemaType } from "../../../../validators"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostExchangesShippingActionReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminExchangeUpdateOutboundShipping,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse> res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
) => { ) => {
const { id, action_id } = req.params const { id, action_id } = req.params
@@ -49,7 +51,7 @@ export const POST = async (
} }
export const DELETE = async ( export const DELETE = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminOrderExchangeListParams>,
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse> res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
) => { ) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
@@ -7,11 +7,13 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostExchangesShippingReqSchemaType } from "../../../validators"
import { HttpTypes } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostExchangesShippingReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminExchangeAddOutboundShipping,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse> res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -14,7 +14,7 @@ import {
import { defaultAdminDetailsReturnFields } from "../../../returns/query-config" import { defaultAdminDetailsReturnFields } from "../../../returns/query-config"
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<{}, HttpTypes.SelectParams>,
res: MedusaResponse<HttpTypes.AdminExchangeRequestResponse> res: MedusaResponse<HttpTypes.AdminExchangeRequestResponse>
) => { ) => {
const { id } = req.params const { id } = req.params
@@ -1,4 +1,4 @@
import { AdminExchangeResponse } from "@medusajs/framework/types" import { HttpTypes } from "@medusajs/framework/types"
import { MedusaError } from "@medusajs/framework/utils" import { MedusaError } from "@medusajs/framework/utils"
import { import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
@@ -7,8 +7,8 @@ import {
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest, req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
res: MedusaResponse<AdminExchangeResponse> res: MedusaResponse<HttpTypes.AdminExchangeResponse>
) => { ) => {
const exchange = await refetchEntity({ const exchange = await refetchEntity({
entity: "order_exchange", entity: "order_exchange",
@@ -5,6 +5,7 @@ import {
} from "@medusajs/framework" } from "@medusajs/framework"
import * as QueryConfig from "./query-config" import * as QueryConfig from "./query-config"
import { import {
AdminGetExchangeParams,
AdminGetOrdersOrderParams, AdminGetOrdersOrderParams,
AdminGetOrdersParams, AdminGetOrdersParams,
AdminPostCancelExchangeReqSchema, AdminPostCancelExchangeReqSchema,
@@ -33,7 +34,7 @@ export const adminExchangeRoutesMiddlewares: MiddlewareRoute[] = [
matcher: "/admin/exchanges/:id", matcher: "/admin/exchanges/:id",
middlewares: [ middlewares: [
validateAndTransformQuery( validateAndTransformQuery(
AdminGetOrdersOrderParams, AdminGetExchangeParams,
QueryConfig.retrieveTransformQueryConfig QueryConfig.retrieveTransformQueryConfig
), ),
], ],
@@ -10,7 +10,6 @@ import {
AuthenticatedMedusaRequest, AuthenticatedMedusaRequest,
MedusaResponse, MedusaResponse,
} from "@medusajs/framework/http" } from "@medusajs/framework/http"
import { AdminPostOrderExchangesReqSchemaType } from "./validators"
export const GET = async ( export const GET = async (
req: AuthenticatedMedusaRequest<HttpTypes.AdminExchangeListParams>, req: AuthenticatedMedusaRequest<HttpTypes.AdminExchangeListParams>,
@@ -40,7 +39,10 @@ export const GET = async (
} }
export const POST = async ( export const POST = async (
req: AuthenticatedMedusaRequest<AdminPostOrderExchangesReqSchemaType>, req: AuthenticatedMedusaRequest<
HttpTypes.AdminCreateExchange,
HttpTypes.SelectParams
>,
res: MedusaResponse<HttpTypes.AdminExchangeOrderResponse> res: MedusaResponse<HttpTypes.AdminExchangeOrderResponse>
) => { ) => {
const input = { const input = {
@@ -5,6 +5,12 @@ import {
createSelectParams, createSelectParams,
} from "../../utils/validators" } from "../../utils/validators"
export const AdminGetExchangeParams = createSelectParams()
export type AdminGetExchangeParamsType = z.infer<
typeof AdminGetExchangeParams
>
export const AdminGetOrdersOrderParams = createSelectParams().merge( export const AdminGetOrdersOrderParams = createSelectParams().merge(
z.object({ z.object({
id: z.union([z.string(), z.array(z.string())]).optional(), id: z.union([z.string(), z.array(z.string())]).optional(),