chore(medusa,types): [9] Add request types to API routes (#8566)
This commit is contained in:
1 parent
6d210c67b1
commit
61cbc8c0be
28 files changed
+197
-174
No files matched your search
@@ -1,65 +0,0 @@
|
|||||||
import { AdminPaymentCollection } from "../payment/admin"
|
|
||||||
import {
|
|
||||||
BaseOrder,
|
|
||||||
BaseOrderAddress,
|
|
||||||
BaseOrderChange,
|
|
||||||
BaseOrderChangeAction,
|
|
||||||
BaseOrderFilters,
|
|
||||||
BaseOrderLineItem,
|
|
||||||
BaseOrderShippingMethod,
|
|
||||||
} from "./common"
|
|
||||||
|
|
||||||
export interface AdminOrder extends BaseOrder {
|
|
||||||
payment_collections: AdminPaymentCollection[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminOrderLineItem extends BaseOrderLineItem {}
|
|
||||||
export interface AdminOrderFilters extends BaseOrderFilters {}
|
|
||||||
export interface AdminOrderAddress extends BaseOrderAddress {}
|
|
||||||
export interface AdminOrderShippingMethod extends BaseOrderShippingMethod {}
|
|
||||||
|
|
||||||
export interface AdminOrderResponse {
|
|
||||||
order: AdminOrder
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminOrdersResponse {
|
|
||||||
orders: AdminOrder[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminCreateOrderFulfillment {
|
|
||||||
items: { id: string; quantity: number }[]
|
|
||||||
location_id?: string
|
|
||||||
no_notification?: boolean
|
|
||||||
metadata?: Record<string, any>
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminCreateOrderShipment {
|
|
||||||
items: { id: string; quantity: number }[]
|
|
||||||
labels?: {
|
|
||||||
tracking_number: string
|
|
||||||
tracking_url: string
|
|
||||||
label_url: string
|
|
||||||
}[]
|
|
||||||
no_notification?: boolean
|
|
||||||
metadata?: Record<string, any>
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminCancelOrderFulfillment {
|
|
||||||
no_notification?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
// Order Preview
|
|
||||||
|
|
||||||
export interface AdminOrderPreview
|
|
||||||
extends Omit<AdminOrder, "items" | "shipping_methods"> {
|
|
||||||
return_requested_total: number
|
|
||||||
order_change: BaseOrderChange
|
|
||||||
items: (BaseOrderLineItem & { actions?: BaseOrderChangeAction[] })[]
|
|
||||||
shipping_methods: (BaseOrderShippingMethod & {
|
|
||||||
actions?: BaseOrderChangeAction[]
|
|
||||||
})[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminOrderPreviewResponse {
|
|
||||||
order: AdminOrderPreview
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import { AdminPaymentCollection } from "../../payment/admin"
|
||||||
|
import {
|
||||||
|
BaseOrder,
|
||||||
|
BaseOrderAddress,
|
||||||
|
BaseOrderChange,
|
||||||
|
BaseOrderChangeAction,
|
||||||
|
BaseOrderLineItem,
|
||||||
|
BaseOrderShippingMethod,
|
||||||
|
} from "../common"
|
||||||
|
|
||||||
|
export interface AdminOrder extends BaseOrder {
|
||||||
|
payment_collections: AdminPaymentCollection[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AdminOrderLineItem extends BaseOrderLineItem {}
|
||||||
|
export interface AdminOrderAddress extends BaseOrderAddress {}
|
||||||
|
export interface AdminOrderShippingMethod extends BaseOrderShippingMethod {}
|
||||||
|
export interface AdminOrderPreview
|
||||||
|
extends Omit<AdminOrder, "items" | "shipping_methods"> {
|
||||||
|
return_requested_total: number
|
||||||
|
order_change: BaseOrderChange
|
||||||
|
items: (BaseOrderLineItem & { actions?: BaseOrderChangeAction[] })[]
|
||||||
|
shipping_methods: (BaseOrderShippingMethod & {
|
||||||
|
actions?: BaseOrderChangeAction[]
|
||||||
|
})[]
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export * from "./entities"
|
||||||
|
export * from "./payload"
|
||||||
|
export * from "./queries"
|
||||||
|
export * from "./responses"
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
export interface AdminCreateOrderFulfillment {
|
||||||
|
items: { id: string; quantity: number }[]
|
||||||
|
location_id?: string
|
||||||
|
no_notification?: boolean
|
||||||
|
metadata?: Record<string, any>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AdminCreateOrderShipment {
|
||||||
|
items: { id: string; quantity: number }[]
|
||||||
|
labels?: {
|
||||||
|
tracking_number: string
|
||||||
|
tracking_url: string
|
||||||
|
label_url: string
|
||||||
|
}[]
|
||||||
|
no_notification?: boolean
|
||||||
|
metadata?: Record<string, any>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AdminCancelOrderFulfillment {
|
||||||
|
no_notification?: boolean
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
import { BaseOrderFilters } from "../common";
|
||||||
|
|
||||||
|
export interface AdminOrderFilters extends BaseOrderFilters {}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import { PaginatedResponse } from "../../common"
|
||||||
|
import { AdminOrder, AdminOrderPreview } from "./entities"
|
||||||
|
|
||||||
|
export interface AdminOrderResponse {
|
||||||
|
order: AdminOrder
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AdminOrderListResponse = PaginatedResponse<{
|
||||||
|
orders: AdminOrder[]
|
||||||
|
}>
|
||||||
|
|
||||||
|
export interface AdminOrderPreviewResponse {
|
||||||
|
order: AdminOrderPreview
|
||||||
|
}
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
import { BaseFilterable } from "../../dal"
|
|
||||||
import {
|
|
||||||
BasePayment,
|
|
||||||
BasePaymentCollection,
|
|
||||||
BasePaymentCollectionFilters,
|
|
||||||
BasePaymentFilters,
|
|
||||||
BasePaymentProvider,
|
|
||||||
BasePaymentProviderFilters,
|
|
||||||
BasePaymentSession,
|
|
||||||
BasePaymentSessionFilters,
|
|
||||||
BaseRefund,
|
|
||||||
RefundReason,
|
|
||||||
} from "./common"
|
|
||||||
|
|
||||||
export interface AdminPaymentProvider extends BasePaymentProvider {
|
|
||||||
is_enabled: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminPayment extends BasePayment {}
|
|
||||||
export interface AdminPaymentCollection extends BasePaymentCollection {}
|
|
||||||
export interface AdminPaymentSession extends BasePaymentSession {}
|
|
||||||
|
|
||||||
export interface AdminPaymentProviderFilters
|
|
||||||
extends BasePaymentProviderFilters {
|
|
||||||
is_enabled?: boolean
|
|
||||||
}
|
|
||||||
export interface AdminPaymentCollectionFilters
|
|
||||||
extends BasePaymentCollectionFilters {}
|
|
||||||
export interface AdminPaymentSessionFilters extends BasePaymentSessionFilters {}
|
|
||||||
|
|
||||||
export interface AdminCapturePayment {
|
|
||||||
amount?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminRefundPayment {
|
|
||||||
amount?: number
|
|
||||||
refund_reason_id?: string | null
|
|
||||||
note?: string | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminPaymentResponse {
|
|
||||||
payment: AdminPayment
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminPaymentsResponse {
|
|
||||||
payments: AdminPayment[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminPaymentFilters extends BasePaymentFilters {}
|
|
||||||
|
|
||||||
// Refund
|
|
||||||
|
|
||||||
export interface AdminRefund extends BaseRefund {}
|
|
||||||
export interface RefundFilters extends BaseFilterable<AdminRefund> {
|
|
||||||
id?: string | string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminRefundResponse {
|
|
||||||
refund_reason: AdminRefund
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminRefundsResponse {
|
|
||||||
refund_reasons: AdminRefund[]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Refund reason
|
|
||||||
|
|
||||||
export interface AdminRefundReason extends RefundReason {}
|
|
||||||
export interface RefundReasonFilters extends BaseFilterable<AdminRefundReason> {
|
|
||||||
id?: string | string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RefundReasonResponse {
|
|
||||||
refund_reason: AdminRefundReason
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RefundReasonsResponse {
|
|
||||||
refund_reasons: AdminRefundReason[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AdminCreateRefundReason {
|
|
||||||
label: string
|
|
||||||
description?: string
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import {
|
||||||
|
BasePayment,
|
||||||
|
BasePaymentCollection,
|
||||||
|
BasePaymentProvider,
|
||||||
|
BasePaymentSession,
|
||||||
|
BaseRefund,
|
||||||
|
RefundReason,
|
||||||
|
} from "../common"
|
||||||
|
|
||||||
|
export interface AdminPaymentProvider extends BasePaymentProvider {
|
||||||
|
is_enabled: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AdminPayment extends BasePayment {}
|
||||||
|
export interface AdminPaymentCollection extends BasePaymentCollection {}
|
||||||
|
export interface AdminPaymentSession extends BasePaymentSession {}
|
||||||
|
export interface AdminRefund extends BaseRefund {}
|
||||||
|
export interface AdminRefundReason extends RefundReason {}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
export * from "./entities"
|
||||||
|
export * from "./payloads"
|
||||||
|
export * from "./queries"
|
||||||
|
export * from "./responses"
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
export interface AdminCapturePayment {
|
||||||
|
amount?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AdminRefundPayment {
|
||||||
|
amount?: number
|
||||||
|
refund_reason_id?: string | null
|
||||||
|
note?: string | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AdminCreateRefundReason {
|
||||||
|
label: string
|
||||||
|
description?: string
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { BaseFilterable } from "../../../dal"
|
||||||
|
import {
|
||||||
|
BasePaymentCollectionFilters,
|
||||||
|
BasePaymentFilters,
|
||||||
|
BasePaymentProviderFilters,
|
||||||
|
BasePaymentSessionFilters,
|
||||||
|
} from "../common"
|
||||||
|
import { AdminRefund, AdminRefundReason } from "./entities"
|
||||||
|
|
||||||
|
export interface AdminPaymentProviderFilters
|
||||||
|
extends BasePaymentProviderFilters {
|
||||||
|
is_enabled?: boolean
|
||||||
|
}
|
||||||
|
export interface AdminPaymentCollectionFilters
|
||||||
|
extends BasePaymentCollectionFilters {}
|
||||||
|
export interface AdminPaymentSessionFilters extends BasePaymentSessionFilters {}
|
||||||
|
|
||||||
|
export interface AdminPaymentFilters extends BasePaymentFilters {}
|
||||||
|
|
||||||
|
export interface RefundFilters extends BaseFilterable<AdminRefund> {
|
||||||
|
id?: string | string[]
|
||||||
|
}
|
||||||
|
export interface RefundReasonFilters extends BaseFilterable<AdminRefundReason> {
|
||||||
|
id?: string | string[]
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { PaginatedResponse } from "../../common"
|
||||||
|
import { AdminPayment, AdminPaymentProvider, AdminRefund, AdminRefundReason } from "./entities"
|
||||||
|
|
||||||
|
export interface AdminPaymentResponse {
|
||||||
|
payment: AdminPayment
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AdminPaymentsResponse = PaginatedResponse<{
|
||||||
|
payments: AdminPayment[]
|
||||||
|
}>
|
||||||
|
|
||||||
|
export interface AdminRefundResponse {
|
||||||
|
refund_reason: AdminRefund
|
||||||
|
}
|
||||||
|
|
||||||
|
export type AdminRefundsResponse = PaginatedResponse<{
|
||||||
|
refund_reasons: AdminRefund[]
|
||||||
|
}>
|
||||||
|
|
||||||
|
export interface RefundReasonResponse {
|
||||||
|
refund_reason: AdminRefundReason
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RefundReasonsResponse = PaginatedResponse<{
|
||||||
|
refund_reasons: AdminRefundReason[]
|
||||||
|
}>
|
||||||
|
|
||||||
|
export type AdminPaymentProviderListResponse = PaginatedResponse<{
|
||||||
|
payment_providers: AdminPaymentProvider[]
|
||||||
|
}>
|
||||||
@@ -4,10 +4,11 @@ import {
|
|||||||
} from "../../../../types/routing"
|
} from "../../../../types/routing"
|
||||||
import { AdminGetNotificationParamsType } from "../validators"
|
import { AdminGetNotificationParamsType } from "../validators"
|
||||||
import { refetchEntity } from "../../../utils/refetch-entity"
|
import { refetchEntity } from "../../../utils/refetch-entity"
|
||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminGetNotificationParamsType>,
|
req: AuthenticatedMedusaRequest<AdminGetNotificationParamsType>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminNotificationResponse>
|
||||||
) => {
|
) => {
|
||||||
const notification = await refetchEntity(
|
const notification = await refetchEntity(
|
||||||
"notification",
|
"notification",
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import {
|
|||||||
} from "../../../types/routing"
|
} from "../../../types/routing"
|
||||||
import { AdminGetNotificationsParamsType } from "./validators"
|
import { AdminGetNotificationsParamsType } from "./validators"
|
||||||
import { refetchEntities } from "../../utils/refetch-entity"
|
import { refetchEntities } from "../../utils/refetch-entity"
|
||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminGetNotificationsParamsType>,
|
req: AuthenticatedMedusaRequest<AdminGetNotificationsParamsType>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminNotificationListResponse>
|
||||||
) => {
|
) => {
|
||||||
const { rows: notifications, metadata } = await refetchEntities(
|
const { rows: notifications, metadata } = await refetchEntities(
|
||||||
"notification",
|
"notification",
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../../../types/routing"
|
} from "../../../../../types/routing"
|
||||||
import { AdminArchiveOrderType } from "../../validators"
|
import { AdminArchiveOrderType } from "../../validators"
|
||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminArchiveOrderType>,
|
req: AuthenticatedMedusaRequest<AdminArchiveOrderType>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import {
|
|||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../../../types/routing"
|
} from "../../../../../types/routing"
|
||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest,
|
req: AuthenticatedMedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { AdditionalData } from "@medusajs/types"
|
import { AdditionalData, HttpTypes } from "@medusajs/types"
|
||||||
import { completeOrderWorkflow } from "@medusajs/core-flows"
|
import { completeOrderWorkflow } from "@medusajs/core-flows"
|
||||||
import {
|
import {
|
||||||
ContainerRegistrationKeys,
|
ContainerRegistrationKeys,
|
||||||
@@ -12,7 +12,7 @@ import { AdminCompleteOrderType } from "../../validators"
|
|||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCompleteOrderType & AdditionalData>,
|
req: AuthenticatedMedusaRequest<AdminCompleteOrderType & AdditionalData>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|||||||
+2
-2
@@ -8,13 +8,13 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../../../../../types/routing"
|
} from "../../../../../../../types/routing"
|
||||||
import { AdminOrderCancelFulfillmentType } from "../../../../validators"
|
import { AdminOrderCancelFulfillmentType } from "../../../../validators"
|
||||||
import { AdditionalData } from "@medusajs/types"
|
import { AdditionalData, HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<
|
req: AuthenticatedMedusaRequest<
|
||||||
AdminOrderCancelFulfillmentType & AdditionalData
|
AdminOrderCancelFulfillmentType & AdditionalData
|
||||||
>,
|
>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -8,13 +8,13 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../../../../../types/routing"
|
} from "../../../../../../../types/routing"
|
||||||
import { AdminOrderCreateShipmentType } from "../../../../validators"
|
import { AdminOrderCreateShipmentType } from "../../../../validators"
|
||||||
import { AdditionalData } from "@medusajs/types"
|
import { AdditionalData, HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<
|
req: AuthenticatedMedusaRequest<
|
||||||
AdminOrderCreateShipmentType & AdditionalData
|
AdminOrderCreateShipmentType & AdditionalData
|
||||||
>,
|
>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../../../types/routing"
|
} from "../../../../../types/routing"
|
||||||
import { AdminOrderCreateFulfillmentType } from "../../validators"
|
import { AdminOrderCreateFulfillmentType } from "../../validators"
|
||||||
import { AdditionalData } from "@medusajs/types"
|
import { AdditionalData, HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<
|
req: AuthenticatedMedusaRequest<
|
||||||
AdminOrderCreateFulfillmentType & AdditionalData
|
AdminOrderCreateFulfillmentType & AdditionalData
|
||||||
>,
|
>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
|
|
||||||
|
|||||||
@@ -3,17 +3,20 @@ import {
|
|||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../../../types/routing"
|
} from "../../../../../types/routing"
|
||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest,
|
req: AuthenticatedMedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminOrderPreviewResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|
||||||
// NOTE: Consider replacing with remoteQuery when possible
|
// NOTE: Consider replacing with remoteQuery when possible
|
||||||
const orderModuleService = req.scope.resolve(ModuleRegistrationName.ORDER)
|
const orderModuleService = req.scope.resolve(ModuleRegistrationName.ORDER)
|
||||||
|
|
||||||
const order = await orderModuleService.previewOrderChange(id)
|
const order = (await orderModuleService.previewOrderChange(
|
||||||
|
id
|
||||||
|
)) as unknown as HttpTypes.AdminOrderPreview
|
||||||
|
|
||||||
res.status(200).json({ order })
|
res.status(200).json({ order })
|
||||||
}
|
}
|
||||||
@@ -7,10 +7,11 @@ import {
|
|||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../../types/routing"
|
} from "../../../../types/routing"
|
||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest,
|
req: AuthenticatedMedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||||
) => {
|
) => {
|
||||||
const workflow = getOrderDetailWorkflow(req.scope)
|
const workflow = getOrderDetailWorkflow(req.scope)
|
||||||
const { result } = await workflow.run({
|
const { result } = await workflow.run({
|
||||||
@@ -20,12 +21,12 @@ export const GET = async (
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
res.status(200).json({ order: result })
|
res.status(200).json({ order: result as HttpTypes.AdminOrder })
|
||||||
}
|
}
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest,
|
req: AuthenticatedMedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminOrderResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { getOrdersListWorkflow } from "@medusajs/core-flows"
|
import { getOrdersListWorkflow } from "@medusajs/core-flows"
|
||||||
import { OrderDTO } from "@medusajs/types"
|
import { HttpTypes, OrderDTO } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest,
|
req: AuthenticatedMedusaRequest,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminOrderListResponse>
|
||||||
) => {
|
) => {
|
||||||
const variables = {
|
const variables = {
|
||||||
filters: {
|
filters: {
|
||||||
@@ -30,7 +30,7 @@ export const GET = async (
|
|||||||
metadata: any
|
metadata: any
|
||||||
}
|
}
|
||||||
res.json({
|
res.json({
|
||||||
orders: rows,
|
orders: rows as unknown as HttpTypes.AdminOrder[],
|
||||||
count: metadata.count,
|
count: metadata.count,
|
||||||
offset: metadata.skip,
|
offset: metadata.skip,
|
||||||
limit: metadata.take,
|
limit: metadata.take,
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import {
|
|||||||
} from "../../../../../types/routing"
|
} from "../../../../../types/routing"
|
||||||
import { refetchPayment } from "../../helpers"
|
import { refetchPayment } from "../../helpers"
|
||||||
import { AdminCreatePaymentCaptureType } from "../../validators"
|
import { AdminCreatePaymentCaptureType } from "../../validators"
|
||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCreatePaymentCaptureType>,
|
req: AuthenticatedMedusaRequest<AdminCreatePaymentCaptureType>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminPaymentResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
|
|
||||||
|
|||||||
@@ -5,10 +5,11 @@ import {
|
|||||||
} from "../../../../../types/routing"
|
} from "../../../../../types/routing"
|
||||||
import { refetchPayment } from "../../helpers"
|
import { refetchPayment } from "../../helpers"
|
||||||
import { AdminCreatePaymentRefundType } from "../../validators"
|
import { AdminCreatePaymentRefundType } from "../../validators"
|
||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const POST = async (
|
export const POST = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminCreatePaymentRefundType>,
|
req: AuthenticatedMedusaRequest<AdminCreatePaymentRefundType>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminPaymentResponse>
|
||||||
) => {
|
) => {
|
||||||
const { id } = req.params
|
const { id } = req.params
|
||||||
await refundPaymentWorkflow(req.scope).run({
|
await refundPaymentWorkflow(req.scope).run({
|
||||||
|
|||||||
@@ -4,10 +4,11 @@ import {
|
|||||||
} from "../../../../types/routing"
|
} from "../../../../types/routing"
|
||||||
import { AdminGetPaymentParamsType } from "../validators"
|
import { AdminGetPaymentParamsType } from "../validators"
|
||||||
import { refetchPayment } from "../helpers"
|
import { refetchPayment } from "../helpers"
|
||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminGetPaymentParamsType>,
|
req: AuthenticatedMedusaRequest<AdminGetPaymentParamsType>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminPaymentResponse>
|
||||||
) => {
|
) => {
|
||||||
const payment = await refetchPayment(
|
const payment = await refetchPayment(
|
||||||
req.params.id,
|
req.params.id,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
import {
|
import {
|
||||||
AuthenticatedMedusaRequest,
|
AuthenticatedMedusaRequest,
|
||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
@@ -10,7 +11,7 @@ import {
|
|||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminGetPaymentProvidersParamsType>,
|
req: AuthenticatedMedusaRequest<AdminGetPaymentProvidersParamsType>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminPaymentProviderListResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
const queryObject = remoteQueryObjectFromString({
|
const queryObject = remoteQueryObjectFromString({
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import {
|
|||||||
MedusaResponse,
|
MedusaResponse,
|
||||||
} from "../../../types/routing"
|
} from "../../../types/routing"
|
||||||
import { AdminGetPaymentsParamsType } from "./validators"
|
import { AdminGetPaymentsParamsType } from "./validators"
|
||||||
|
import { HttpTypes } from "@medusajs/types"
|
||||||
|
|
||||||
export const GET = async (
|
export const GET = async (
|
||||||
req: AuthenticatedMedusaRequest<AdminGetPaymentsParamsType>,
|
req: AuthenticatedMedusaRequest<AdminGetPaymentsParamsType>,
|
||||||
res: MedusaResponse
|
res: MedusaResponse<HttpTypes.AdminPaymentsResponse>
|
||||||
) => {
|
) => {
|
||||||
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)
|
||||||
const queryObject = remoteQueryObjectFromString({
|
const queryObject = remoteQueryObjectFromString({
|
||||||
|
|||||||
Reference in new issue
Block a user