feat: order export and upload stream (#14243)
* feat: order export * Merge branch 'develop' of https://github.com/medusajs/medusa into feat/order-export * normalize status * rm util * serialize totals * test * lock * comments * configurable order list
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { exportOrdersWorkflow } from "@medusajs/core-flows"
|
||||
import {
|
||||
AuthenticatedMedusaRequest,
|
||||
MedusaResponse,
|
||||
} from "@medusajs/framework/http"
|
||||
import { HttpTypes } from "@medusajs/framework/types"
|
||||
|
||||
export const POST = async (
|
||||
req: AuthenticatedMedusaRequest<{}, HttpTypes.AdminOrderFilters>,
|
||||
res: MedusaResponse<HttpTypes.AdminExportOrderResponse>
|
||||
) => {
|
||||
const selectFields = req.queryConfig.fields ?? []
|
||||
const input = { select: selectFields, filter: req.filterableFields }
|
||||
|
||||
const { transaction } = await exportOrdersWorkflow(req.scope).run({
|
||||
input,
|
||||
})
|
||||
|
||||
res.status(202).json({ transaction_id: transaction.transactionId })
|
||||
}
|
||||
@@ -32,6 +32,16 @@ export const adminOrderRoutesMiddlewares: MiddlewareRoute[] = [
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
method: ["POST"],
|
||||
matcher: "/admin/orders/export",
|
||||
middlewares: [
|
||||
validateAndTransformQuery(
|
||||
AdminGetOrdersParams,
|
||||
QueryConfig.exportTransformQueryConfig
|
||||
),
|
||||
],
|
||||
},
|
||||
{
|
||||
method: ["GET"],
|
||||
matcher: "/admin/orders/:id",
|
||||
|
||||
@@ -118,3 +118,33 @@ export const listShippingOptionsQueryConfig = {
|
||||
defaultLimit: 100,
|
||||
isList: true,
|
||||
}
|
||||
|
||||
export const defaultAdminExportOrderFields = [
|
||||
"id",
|
||||
"display_id",
|
||||
"status",
|
||||
"created_at",
|
||||
"updated_at",
|
||||
"email",
|
||||
"currency_code",
|
||||
"region_id",
|
||||
"subtotal",
|
||||
"tax_total",
|
||||
"shipping_total",
|
||||
"discount_total",
|
||||
"gift_card_total",
|
||||
"total",
|
||||
"*customer",
|
||||
"*shipping_address",
|
||||
"*billing_address",
|
||||
"*sales_channel",
|
||||
"*items",
|
||||
"*shipping_methods",
|
||||
"*payment_collections",
|
||||
"*fulfillments",
|
||||
]
|
||||
|
||||
export const exportTransformQueryConfig = {
|
||||
defaults: defaultAdminExportOrderFields,
|
||||
isList: true,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user