fix(core-flows): export order-related utility workflows (#12380)

This commit is contained in:
Shahed Nasser
2025-05-07 12:02:08 +03:00
committed by GitHub
parent 5d3f1d0118
commit c4dd805849
15 changed files with 63 additions and 15 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/core-flows": patch
---
fix(core-flows): export order-related workflows
@@ -14,7 +14,7 @@ import { IOrderModuleService, OrderDTO } from "@medusajs/types"
import { emitEventStep, useRemoteQueryStep } from "../../common"
import { validateDraftOrderStep } from "../steps/validate-draft-order"
const convertDraftOrderWorkflowId = "convert-draft-order"
export const convertDraftOrderWorkflowId = "convert-draft-order"
/**
* The details of the draft order to convert to an order.
+1 -2
View File
@@ -1,3 +1,2 @@
export * from "./steps"
export * from "./workflows"
export * from "./utils/fetch-shipping-option"
export * from "./workflows"
@@ -23,7 +23,7 @@ import {
import { prepareShippingMethod } from "../../utils/prepare-shipping-method"
import { createOrderChangeActionsWorkflow } from "../create-order-change-actions"
import { updateOrderTaxLinesWorkflow } from "../update-tax-lines"
import { fetchShippingOptionForOrderWorkflow } from "../../utils/fetch-shipping-option"
import { fetchShippingOptionForOrderWorkflow } from "../fetch-shipping-option"
/**
* The data to validate that a shipping method can be created for a claim.
@@ -7,7 +7,7 @@ import {
when,
} from "@medusajs/framework/workflows-sdk"
import { maybeRefreshShippingMethodsWorkflow } from "../../utils/maybe-refresh-shipping-methods"
import { maybeRefreshShippingMethodsWorkflow } from "../maybe-refresh-shipping-methods"
import { useQueryGraphStep } from "../../../common"
/**
@@ -23,7 +23,7 @@ import {
import { prepareShippingMethod } from "../../utils/prepare-shipping-method"
import { createOrderChangeActionsWorkflow } from "../create-order-change-actions"
import { updateOrderTaxLinesWorkflow } from "../update-tax-lines"
import { fetchShippingOptionForOrderWorkflow } from "../../utils/fetch-shipping-option"
import { fetchShippingOptionForOrderWorkflow } from "../fetch-shipping-option"
/**
* The data to validate that a shipping method can be created for an exchange.
@@ -8,7 +8,7 @@ import {
when,
} from "@medusajs/framework/workflows-sdk"
import { maybeRefreshShippingMethodsWorkflow } from "../../utils/maybe-refresh-shipping-methods"
import { maybeRefreshShippingMethodsWorkflow } from "../maybe-refresh-shipping-methods"
import { useQueryGraphStep } from "../../../common"
/**
@@ -46,7 +46,7 @@ const COMMON_OPTIONS_FIELDS = [
/**
* The data to create a shipping method for an order edit.
*/
export type FetchShippingOptionForOrderWorkflowInput = {
export type FetchShippingOptionForOrderWorkflowInput = AdditionalData & {
/**
* The ID of the shipping option to fetch.
*/
@@ -165,7 +165,7 @@ export const fetchShippingOptionsForOrderWorkflowId = "fetch-shipping-option"
*/
export const fetchShippingOptionForOrderWorkflow = createWorkflow(
fetchShippingOptionsForOrderWorkflowId,
function (input: FetchShippingOptionForOrderWorkflowInput & AdditionalData) {
function (input: FetchShippingOptionForOrderWorkflowInput) {
const initialOption = useRemoteQueryStep({
entry_point: "shipping_option",
variables: { id: input.shipping_option_id },
@@ -30,6 +30,7 @@ export * from "./decline-order-change"
export * from "./delete-order-change"
export * from "./delete-order-change-actions"
export * from "./delete-order-payment-collection"
export * from "./fetch-shipping-option"
export * from "./exchange/begin-order-exchange"
export * from "./exchange/cancel-begin-order-exchange"
export * from "./exchange/cancel-exchange"
@@ -45,6 +46,7 @@ export * from "./get-order-detail"
export * from "./get-orders-list"
export * from "./mark-order-fulfillment-as-delivered"
export * from "./mark-payment-collection-as-paid"
export * from "./maybe-refresh-shipping-methods"
export * from "./order-edit/begin-order-edit"
export * from "./order-edit/cancel-begin-order-edit"
export * from "./order-edit/confirm-order-edit-request"
@@ -68,8 +68,34 @@ export type MaybeRefreshShippingMethodsWorkflowInput = {
export const maybeRefreshShippingMethodsWorkflowId =
"maybe-refresh-shipping-methods"
/**
* This workflows refreshes shipping method an order (used in RMA flows).
* The shipping method and the action is updated if the shipping option is calculated.
* This workflows refreshes shipping method prices of an order and its changes. It's used in Return Merchandise Authorization (RMA) flows. It's used
* by other workflows, such as {@link refreshExchangeShippingWorkflow}.
*
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
* refreshing shipping methods in your custom flows.
*
* @example
* const { result } = await maybeRefreshShippingMethodsWorkflow(container)
* .run({
* input: {
* shipping_method_id: "shipping_method_123",
* order_id: "order_123",
* action_id: "orchact_123",
* context: {
* return_id: "ret_123",
* return_items: [
* {
* id: "orli_123",
* quantity: 1,
* }
* ]
* }
* }
* })
*
* @summary
*
* Refreshes the shipping method prices of an order and its changes.
*/
export const maybeRefreshShippingMethodsWorkflow = createWorkflow(
maybeRefreshShippingMethodsWorkflowId,
@@ -22,7 +22,7 @@ import {
import { prepareShippingMethod } from "../../utils/prepare-shipping-method"
import { createOrderChangeActionsWorkflow } from "../create-order-change-actions"
import { updateOrderTaxLinesWorkflow } from "../update-tax-lines"
import { fetchShippingOptionForOrderWorkflow } from "../../utils/fetch-shipping-option"
import { fetchShippingOptionForOrderWorkflow } from "../fetch-shipping-option"
/**
* The data to validate that a shipping method can be created for a return.
@@ -8,7 +8,7 @@ import {
when,
} from "@medusajs/framework/workflows-sdk"
import { maybeRefreshShippingMethodsWorkflow } from "../../utils/maybe-refresh-shipping-methods"
import { maybeRefreshShippingMethodsWorkflow } from "../maybe-refresh-shipping-methods"
import { useQueryGraphStep } from "../../../common"
/**
@@ -9,7 +9,7 @@ import { capturePaymentWorkflow } from "./capture-payment"
/**
* The data to process a payment from a webhook action.
*/
interface ProcessPaymentWorkflowInput extends WebhookActionResult {}
export interface ProcessPaymentWorkflowInput extends WebhookActionResult {}
export const processPaymentWorkflowId = "process-payment-workflow"
/**
@@ -1,8 +1,24 @@
export interface RequestOrderTransferWorkflowInput {
/**
* The ID of the order to transfer.
*/
order_id: string
/**
* The ID of the customer to transfer the order to.
*/
customer_id: string
/**
* The ID of the logged in user requesting the transfer.
* Can be an admin user or a customer.
*/
logged_in_user: string
/**
* Details of the transfer request.
*/
description?: string
/**
* A note viewed by admin users only.
*/
internal_note?: string
}
+1 -1
View File
@@ -38,7 +38,7 @@ export const CartWorkflowEvents = {
CUSTOMER_UPDATED: "cart.customer_updated",
/**
* Emitted when the cart's region is updated. This
* event is emitted alongside the {@link CartWorkflowEvents.UPDATED} event.
* event is emitted alongside the `cart.updated` event.
*
* @eventPayload
* ```ts