chore: fixes to http and request types for orders (2) (#13823)
This commit is contained in:
@@ -100,8 +100,17 @@ export interface AdminCancelOrderFulfillment {
|
||||
}
|
||||
|
||||
export interface AdminRequestOrderTransfer {
|
||||
/**
|
||||
* The ID of the customer to transfer the order to.
|
||||
*/
|
||||
customer_id: string
|
||||
/**
|
||||
* An internal note viewed by admins only.
|
||||
*/
|
||||
internal_note?: string
|
||||
/**
|
||||
* A description for the transfer request.
|
||||
*/
|
||||
description?: string
|
||||
}
|
||||
|
||||
@@ -161,3 +170,22 @@ export interface OrderAddress {
|
||||
*/
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
export interface AdminCreateOrderCreditLine {
|
||||
/**
|
||||
* The amount of the credit line.
|
||||
*/
|
||||
amount: number
|
||||
/**
|
||||
* The name of the table this credit line is associated with.
|
||||
*/
|
||||
reference: string
|
||||
/**
|
||||
* The ID of the reference entity in the reference table.
|
||||
*/
|
||||
reference_id: string
|
||||
/**
|
||||
* Key-value pairs of custom data.
|
||||
*/
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { OperatorMap } from "../../../dal"
|
||||
import { FindParams } from "../../common"
|
||||
import { FindParams, SelectParams } from "../../common"
|
||||
import { BaseOrderChangesFilters, BaseOrderFilters } from "../common"
|
||||
|
||||
export interface AdminOrderFilters extends FindParams, BaseOrderFilters {
|
||||
@@ -33,7 +33,7 @@ export interface AdminOrderFilters extends FindParams, BaseOrderFilters {
|
||||
updated_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
export interface AdminOrderItemsFilters extends FindParams {
|
||||
export interface AdminOrderItemsFilters extends SelectParams {
|
||||
/**
|
||||
* Filter by order item ID(s).
|
||||
*/
|
||||
@@ -48,6 +48,26 @@ export interface AdminOrderItemsFilters extends FindParams {
|
||||
version?: number[] | number
|
||||
}
|
||||
|
||||
export interface AdminOrderChangesFilters extends BaseOrderChangesFilters {}
|
||||
export interface AdminOrderChangesFilters extends BaseOrderChangesFilters, SelectParams {
|
||||
/**
|
||||
* Apply filters on the change's creation date.
|
||||
*/
|
||||
created_at?: OperatorMap<string>
|
||||
/**
|
||||
* Apply filters on the change's update date.
|
||||
*/
|
||||
updated_at?: OperatorMap<string>
|
||||
/**
|
||||
* Apply filters on the change's deletion date.
|
||||
*/
|
||||
deleted_at?: OperatorMap<string>
|
||||
}
|
||||
|
||||
export interface AdminGetOrderShippingOptionList {}
|
||||
export interface AdminGetOrderParams extends SelectParams {}
|
||||
export interface AdminGetOrderDetailsParams extends SelectParams {
|
||||
/**
|
||||
* The version of the order to retrieve details for.
|
||||
*/
|
||||
version?: number
|
||||
}
|
||||
@@ -3,7 +3,10 @@ import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
|
||||
export const POST = async (req: MedusaRequest, res: MedusaResponse) => {
|
||||
export const POST = async (
|
||||
req: MedusaRequest<HttpTypes.AdminDraftOrderParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
|
||||
|
||||
await convertDraftOrderWorkflow(req.scope).run({
|
||||
|
||||
@@ -10,10 +10,9 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||
import { AdminUpdateDraftOrderType } from "../validators"
|
||||
|
||||
export const GET = async (
|
||||
req: MedusaRequest,
|
||||
req: MedusaRequest<HttpTypes.AdminDraftOrderParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminDraftOrderResponse>
|
||||
) => {
|
||||
const workflow = getOrderDetailWorkflow(req.scope)
|
||||
@@ -32,7 +31,10 @@ export const GET = async (
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminUpdateDraftOrderType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminUpdateDraftOrder,
|
||||
HttpTypes.AdminDraftOrderParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminDraftOrderResponse>
|
||||
) => {
|
||||
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
|
||||
|
||||
@@ -19,7 +19,6 @@ import {
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { refetchOrder } from "./helpers"
|
||||
import { AdminCreateDraftOrderType } from "./validators"
|
||||
|
||||
export const GET = async (
|
||||
req: MedusaRequest<HttpTypes.AdminOrderFilters>,
|
||||
@@ -54,7 +53,10 @@ export const GET = async (
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminCreateDraftOrderType & AdditionalData>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminCreateDraftOrder & AdditionalData,
|
||||
HttpTypes.AdminDraftOrderParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminDraftOrderResponse>
|
||||
) => {
|
||||
const input = req.validatedBody
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminGetOrderParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from "@medusajs/framework/utils"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminGetOrderParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<HttpTypes.AdminOrderChangesFilters>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderChangesResponse>
|
||||
) => {
|
||||
const { id } = req.params
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdditionalData>,
|
||||
req: AuthenticatedMedusaRequest<AdditionalData, HttpTypes.AdminGetOrderParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
@@ -5,10 +5,12 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||
import { AdminCreateOrderCreditLinesType } from "../../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminCreateOrderCreditLinesType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminCreateOrderCreditLine,
|
||||
HttpTypes.AdminGetOrderParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminGetOrderParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
const { id: orderId, fulfillment_id: fulfillmentId } = req.params
|
||||
|
||||
@@ -7,12 +7,12 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminOrderCreateShipmentType } from "../../../../validators"
|
||||
import { AdditionalData, HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<
|
||||
AdminOrderCreateShipmentType & AdditionalData
|
||||
HttpTypes.AdminCreateOrderShipment & AdditionalData,
|
||||
HttpTypes.AdminGetOrderParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
|
||||
@@ -8,11 +8,11 @@ import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminOrderCreateFulfillmentType } from "../../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<
|
||||
AdminOrderCreateFulfillmentType & AdditionalData
|
||||
HttpTypes.AdminCreateOrderFulfillment & AdditionalData,
|
||||
HttpTypes.AdminGetOrderParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
|
||||
@@ -8,13 +8,11 @@ import {
|
||||
} from "@medusajs/framework/http"
|
||||
import { AdminOrder, HttpTypes } from "@medusajs/framework/types"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||
import {
|
||||
AdminGetOrdersOrderParamsType,
|
||||
AdminUpdateOrderType,
|
||||
} from "../validators"
|
||||
|
||||
export const GET = async (
|
||||
req: AuthenticatedMedusaRequest<AdminGetOrdersOrderParamsType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminGetOrderDetailsParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
const workflow = getOrderDetailWorkflow(req.scope)
|
||||
@@ -30,7 +28,10 @@ export const GET = async (
|
||||
}
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminUpdateOrderType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminUpdateOrder,
|
||||
HttpTypes.AdminGetOrderDetailsParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
|
||||
|
||||
@@ -7,7 +7,7 @@ import { AdminOrder, HttpTypes } from "@medusajs/framework/types"
|
||||
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest,
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminGetOrderParams>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
const query = req.scope.resolve(ContainerRegistrationKeys.QUERY)
|
||||
|
||||
@@ -8,10 +8,12 @@ import {
|
||||
ContainerRegistrationKeys,
|
||||
remoteQueryObjectFromString,
|
||||
} from "@medusajs/framework/utils"
|
||||
import { AdminTransferOrderType } from "../../validators"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<AdminTransferOrderType>,
|
||||
req: AuthenticatedMedusaRequest<
|
||||
HttpTypes.AdminRequestOrderTransfer,
|
||||
HttpTypes.AdminGetOrderParams
|
||||
>,
|
||||
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||
) => {
|
||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||
|
||||
@@ -9,12 +9,7 @@ import {
|
||||
|
||||
export const AdminGetOrdersOrderParams = createSelectParams().merge(
|
||||
z.object({
|
||||
id: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
status: z.union([z.string(), z.array(z.string())]).optional(),
|
||||
version: z.number().optional(),
|
||||
created_at: createOperatorMap().optional(),
|
||||
updated_at: createOperatorMap().optional(),
|
||||
deleted_at: createOperatorMap().optional(),
|
||||
})
|
||||
)
|
||||
|
||||
@@ -31,7 +26,7 @@ export const AdminGetOrdersOrderItemsParams = createSelectParams().merge(
|
||||
)
|
||||
|
||||
export type AdminGetOrdersOrderItemsParamsType = z.infer<
|
||||
typeof AdminGetOrdersOrderParams
|
||||
typeof AdminGetOrdersOrderItemsParams
|
||||
>
|
||||
|
||||
export const AdminGetOrderShippingOptionList = z.object({})
|
||||
|
||||
Reference in New Issue
Block a user