chore: fixes to http and request types for orders (1) (#13822)
This commit is contained in:
@@ -10,11 +10,13 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostClaimsItemsActionReqSchemaType } from "../../../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostClaimsItemsActionReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminUpdateClaimItem,
|
||||
HttpTypes.AdminClaimActionsParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
|
||||
) => {
|
||||
const { id, action_id } = req.params
|
||||
@@ -49,7 +51,7 @@ export const POST = async (
|
||||
}
|
||||
|
||||
export const DELETE = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminClaimActionsParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
@@ -7,11 +7,13 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostClaimItemsReqSchemaType } from "../../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostClaimItemsReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminAddClaimItems,
|
||||
HttpTypes.AdminClaimActionsParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
+4
-2
@@ -12,10 +12,12 @@ import {
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
|
||||
import { AdminPostClaimsShippingActionReqSchemaType } from "../../../../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostClaimsShippingActionReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminClaimUpdateInboundShipping,
|
||||
HttpTypes.AdminClaimActionsParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
|
||||
) => {
|
||||
const { id, action_id } = req.params
|
||||
|
||||
@@ -11,10 +11,12 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostClaimsItemsActionReqSchemaType } from "../../../../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostClaimsItemsActionReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminUpdateClaimOutboundItem,
|
||||
HttpTypes.AdminClaimActionsParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
|
||||
) => {
|
||||
const { id, action_id } = req.params
|
||||
@@ -49,7 +51,7 @@ export const POST = async (
|
||||
}
|
||||
|
||||
export const DELETE = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminClaimActionsParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
@@ -8,11 +8,13 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostClaimsAddItemsReqSchemaType } from "../../../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostClaimsAddItemsReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminAddClaimOutboundItems,
|
||||
HttpTypes.AdminClaimActionsParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
+5
-3
@@ -10,11 +10,13 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostClaimsShippingActionReqSchemaType } from "../../../../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostClaimsShippingActionReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminClaimUpdateOutboundShipping,
|
||||
HttpTypes.AdminClaimActionsParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
|
||||
) => {
|
||||
const { id, action_id } = req.params
|
||||
@@ -49,7 +51,7 @@ export const POST = async (
|
||||
}
|
||||
|
||||
export const DELETE = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminClaimActionsParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
@@ -7,11 +7,13 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostClaimsShippingReqSchemaType } from "../../../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostClaimsShippingReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminClaimAddOutboundShipping,
|
||||
HttpTypes.AdminClaimActionsParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimPreviewResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
import { defaultAdminDetailsReturnFields } from "../../../returns/query-config"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminClaimParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimRequestResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -4,10 +4,10 @@ import {
|
||||
refetchEntity,
|
||||
} from "@medusajs/framework/http"
|
||||
import { MedusaError } from "@medusajs/framework/utils"
|
||||
import { AdminClaimResponse } from "@medusajs/framework/types"
|
||||
import { AdminClaimResponse, HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminClaimActionsParams>,
|
||||
res: MedusaResponse<AdminClaimResponse>
|
||||
) => {
|
||||
const claim = await refetchEntity({
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostOrderClaimsReqSchemaType } from "./validators"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminClaimListParams>,
|
||||
@@ -40,7 +39,10 @@ export const GET = async (
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostOrderClaimsReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminCreateClaim,
|
||||
HttpTypes.AdminClaimParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminClaimOrderResponse>
|
||||
) => {
|
||||
const input = {
|
||||
|
||||
@@ -10,10 +10,12 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import { defaultAdminDetailsReturnFields } from "../../../../returns/query-config"
|
||||
import { AdminPostExchangesReturnRequestItemsReqSchemaType } from "../../../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostExchangesReturnRequestItemsReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminAddExchangeInboundItems,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminExchangeReturnResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
+4
-2
@@ -12,10 +12,12 @@ import {
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { defaultAdminDetailsReturnFields } from "../../../../../returns/query-config"
|
||||
import { AdminPostExchangesShippingActionReqSchemaType } from "../../../../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostExchangesShippingActionReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminExchangeUpdateInboundShipping,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
|
||||
) => {
|
||||
const { id, action_id } = req.params
|
||||
|
||||
@@ -11,10 +11,12 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostExchangesItemsActionReqSchemaType } from "../../../../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostExchangesItemsActionReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminUpdateExchangeOutboundItem,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
|
||||
) => {
|
||||
const { id, action_id } = req.params
|
||||
@@ -49,7 +51,7 @@ export const POST = async (
|
||||
}
|
||||
|
||||
export const DELETE = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.SelectParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
@@ -8,11 +8,13 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostExchangesAddItemsReqSchemaType } from "../../../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostExchangesAddItemsReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminAddExchangeOutboundItems,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
+5
-3
@@ -10,11 +10,13 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostExchangesShippingActionReqSchemaType } from "../../../../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostExchangesShippingActionReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminExchangeUpdateOutboundShipping,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
|
||||
) => {
|
||||
const { id, action_id } = req.params
|
||||
@@ -49,7 +51,7 @@ export const POST = async (
|
||||
}
|
||||
|
||||
export const DELETE = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminOrderExchangeListParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
@@ -7,11 +7,13 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostExchangesShippingReqSchemaType } from "../../../validators"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostExchangesShippingReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminExchangeAddOutboundShipping,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminExchangePreviewResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
import { defaultAdminDetailsReturnFields } from "../../../returns/query-config"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.SelectParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminExchangeRequestResponse>
|
||||
) => {
|
||||
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 {
|
||||
AuthenticatedMedusaRequest,
|
||||
@@ -7,8 +7,8 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
res: MedusaResponse<AdminExchangeResponse>
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.SelectParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminExchangeResponse>
|
||||
) => {
|
||||
const exchange = await refetchEntity({
|
||||
entity: "order_exchange",
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
} from "@medusajs/framework"
|
||||
import * as QueryConfig from "./query-config"
|
||||
import {
|
||||
AdminGetExchangeParams,
|
||||
AdminGetOrdersOrderParams,
|
||||
AdminGetOrdersParams,
|
||||
AdminPostCancelExchangeReqSchema,
|
||||
@@ -33,7 +34,7 @@ export const adminExchangeRoutesMiddlewares: MiddlewareRoute[] = [
|
||||
matcher: "/admin/exchanges/:id",
|
||||
middlewares: [
|
||||
validateAndTransformQuery(
|
||||
AdminGetOrdersOrderParams,
|
||||
AdminGetExchangeParams,
|
||||
QueryConfig.retrieveTransformQueryConfig
|
||||
),
|
||||
],
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminPostOrderExchangesReqSchemaType } from "./validators"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminExchangeListParams>,
|
||||
@@ -40,7 +39,10 @@ export const GET = async (
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminPostOrderExchangesReqSchemaType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminCreateExchange,
|
||||
HttpTypes.SelectParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminExchangeOrderResponse>
|
||||
) => {
|
||||
const input = {
|
||||
|
||||
@@ -5,6 +5,12 @@ import {
|
||||
createSelectParams,
|
||||
} from "../../utils/validators"
|
||||
|
||||
export const AdminGetExchangeParams = createSelectParams()
|
||||
|
||||
export type AdminGetExchangeParamsType = z.infer<
|
||||
typeof AdminGetExchangeParams
|
||||
>
|
||||
|
||||
export const AdminGetOrdersOrderParams = createSelectParams().merge(
|
||||
z.object({
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
|
||||
Reference in New Issue
Block a user