chore(core-flows, types): add tsdocs for draft orders workflows (#12279)
This commit is contained in:
1 parent
7d498227d1
commit
71a5dc448d
34 files changed
+917
-35
No files matched your search
+25
-1
@@ -8,11 +8,35 @@ import {
|
|||||||
export const createDraftOrderLineItemAdjustmentsStepId =
|
export const createDraftOrderLineItemAdjustmentsStepId =
|
||||||
"create-draft-order-line-item-adjustments"
|
"create-draft-order-line-item-adjustments"
|
||||||
|
|
||||||
interface CreateDraftOrderLineItemAdjustmentsStepInput {
|
/**
|
||||||
|
* The details of the line item adjustments to create.
|
||||||
|
*/
|
||||||
|
export interface CreateDraftOrderLineItemAdjustmentsStepInput {
|
||||||
|
/**
|
||||||
|
* The ID of the draft order to create the line item adjustments for.
|
||||||
|
*/
|
||||||
order_id: string
|
order_id: string
|
||||||
|
/**
|
||||||
|
* The line item adjustments to create.
|
||||||
|
*/
|
||||||
lineItemAdjustmentsToCreate: CreateLineItemAdjustmentDTO[]
|
lineItemAdjustmentsToCreate: CreateLineItemAdjustmentDTO[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step creates line item adjustments for a draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = createDraftOrderLineItemAdjustmentsStep({
|
||||||
|
* order_id: "order_123",
|
||||||
|
* lineItemAdjustmentsToCreate: [
|
||||||
|
* {
|
||||||
|
* item_id: "orli_123",
|
||||||
|
* code: "PROMO_123",
|
||||||
|
* amount: 10,
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const createDraftOrderLineItemAdjustmentsStep = createStep(
|
export const createDraftOrderLineItemAdjustmentsStep = createStep(
|
||||||
createDraftOrderLineItemAdjustmentsStepId,
|
createDraftOrderLineItemAdjustmentsStepId,
|
||||||
async function (
|
async function (
|
||||||
|
|||||||
+21
-1
@@ -8,10 +8,30 @@ import {
|
|||||||
export const createDraftOrderShippingMethodAdjustmentsStepId =
|
export const createDraftOrderShippingMethodAdjustmentsStepId =
|
||||||
"create-draft-order-shipping-method-adjustments"
|
"create-draft-order-shipping-method-adjustments"
|
||||||
|
|
||||||
interface CreateDraftOrderShippingMethodAdjustmentsStepInput {
|
/**
|
||||||
|
* The details of the shipping method adjustments to create.
|
||||||
|
*/
|
||||||
|
export interface CreateDraftOrderShippingMethodAdjustmentsStepInput {
|
||||||
|
/**
|
||||||
|
* The shipping method adjustments to create.
|
||||||
|
*/
|
||||||
shippingMethodAdjustmentsToCreate: CreateShippingMethodAdjustmentDTO[]
|
shippingMethodAdjustmentsToCreate: CreateShippingMethodAdjustmentDTO[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step creates shipping method adjustments for a draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = createDraftOrderShippingMethodAdjustmentsStep({
|
||||||
|
* shippingMethodAdjustmentsToCreate: [
|
||||||
|
* {
|
||||||
|
* shipping_method_id: "sm_123",
|
||||||
|
* code: "PROMO_123",
|
||||||
|
* amount: 10,
|
||||||
|
* }
|
||||||
|
* ]
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const createDraftOrderShippingMethodAdjustmentsStep = createStep(
|
export const createDraftOrderShippingMethodAdjustmentsStep = createStep(
|
||||||
createDraftOrderShippingMethodAdjustmentsStepId,
|
createDraftOrderShippingMethodAdjustmentsStepId,
|
||||||
async function (
|
async function (
|
||||||
|
|||||||
+25
-1
@@ -2,10 +2,34 @@ import { Modules } from "@medusajs/framework/utils"
|
|||||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||||
import { IOrderModuleService, OrderDTO } from "@medusajs/types"
|
import { IOrderModuleService, OrderDTO } from "@medusajs/types"
|
||||||
|
|
||||||
interface GetDraftOrderPromotionContextStepInput {
|
/**
|
||||||
|
* The details of the draft order to get the promotion context for.
|
||||||
|
*/
|
||||||
|
export interface GetDraftOrderPromotionContextStepInput {
|
||||||
|
/**
|
||||||
|
* The draft order to get the promotion context for.
|
||||||
|
*/
|
||||||
order: OrderDTO
|
order: OrderDTO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step gets the promotion context for a draft order.
|
||||||
|
*
|
||||||
|
* :::note
|
||||||
|
*
|
||||||
|
* You can retrieve a draft order's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
|
||||||
|
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
|
||||||
|
*
|
||||||
|
* :::
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = getDraftOrderPromotionContextStep({
|
||||||
|
* order: {
|
||||||
|
* id: "order_123",
|
||||||
|
* // other order details...
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const getDraftOrderPromotionContextStep = createStep(
|
export const getDraftOrderPromotionContextStep = createStep(
|
||||||
"get-draft-order-promotion-context",
|
"get-draft-order-promotion-context",
|
||||||
async ({ order }: GetDraftOrderPromotionContextStepInput, { container }) => {
|
async ({ order }: GetDraftOrderPromotionContextStepInput, { container }) => {
|
||||||
|
|||||||
+15
-1
@@ -4,10 +4,24 @@ import { IOrderModuleService } from "@medusajs/types"
|
|||||||
export const removeDraftOrderLineItemAdjustmentsStepId =
|
export const removeDraftOrderLineItemAdjustmentsStepId =
|
||||||
"remove-draft-order-line-item-adjustments"
|
"remove-draft-order-line-item-adjustments"
|
||||||
|
|
||||||
interface RemoveDraftOrderLineItemAdjustmentsStepInput {
|
/**
|
||||||
|
* The details of the line item adjustments to remove.
|
||||||
|
*/
|
||||||
|
export interface RemoveDraftOrderLineItemAdjustmentsStepInput {
|
||||||
|
/**
|
||||||
|
* The IDs of the line item adjustments to remove.
|
||||||
|
*/
|
||||||
lineItemAdjustmentIdsToRemove: string[]
|
lineItemAdjustmentIdsToRemove: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step removes line item adjustments from a draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = removeDraftOrderLineItemAdjustmentsStep({
|
||||||
|
* lineItemAdjustmentIdsToRemove: ["adj_123", "adj_456"],
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const removeDraftOrderLineItemAdjustmentsStep = createStep(
|
export const removeDraftOrderLineItemAdjustmentsStep = createStep(
|
||||||
removeDraftOrderLineItemAdjustmentsStepId,
|
removeDraftOrderLineItemAdjustmentsStepId,
|
||||||
async function (
|
async function (
|
||||||
|
|||||||
+15
-1
@@ -5,10 +5,24 @@ import { IOrderModuleService } from "@medusajs/types"
|
|||||||
export const removeDraftOrderShippingMethodAdjustmentsStepId =
|
export const removeDraftOrderShippingMethodAdjustmentsStepId =
|
||||||
"remove-draft-order-shipping-method-adjustments"
|
"remove-draft-order-shipping-method-adjustments"
|
||||||
|
|
||||||
interface RemoveDraftOrderShippingMethodAdjustmentsStepInput {
|
/**
|
||||||
|
* The details of the shipping method adjustments to remove.
|
||||||
|
*/
|
||||||
|
export interface RemoveDraftOrderShippingMethodAdjustmentsStepInput {
|
||||||
|
/**
|
||||||
|
* The IDs of the shipping method adjustments to remove.
|
||||||
|
*/
|
||||||
shippingMethodAdjustmentIdsToRemove: string[]
|
shippingMethodAdjustmentIdsToRemove: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step removes shipping method adjustments from a draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = removeDraftOrderShippingMethodAdjustmentsStep({
|
||||||
|
* shippingMethodAdjustmentIdsToRemove: ["adj_123", "adj_456"],
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const removeDraftOrderShippingMethodAdjustmentsStep = createStep(
|
export const removeDraftOrderShippingMethodAdjustmentsStep = createStep(
|
||||||
removeDraftOrderShippingMethodAdjustmentsStepId,
|
removeDraftOrderShippingMethodAdjustmentsStepId,
|
||||||
async function (
|
async function (
|
||||||
|
|||||||
+49
-1
@@ -5,20 +5,68 @@ import { BigNumberInput, IOrderModuleService } from "@medusajs/types"
|
|||||||
export const restoreDraftOrderShippingMethodsStepId =
|
export const restoreDraftOrderShippingMethodsStepId =
|
||||||
"restore-draft-order-shipping-methods"
|
"restore-draft-order-shipping-methods"
|
||||||
|
|
||||||
interface RestoreDraftOrderShippingMethodsStepInput {
|
/**
|
||||||
|
* The details of the shipping methods to restore.
|
||||||
|
*/
|
||||||
|
export interface RestoreDraftOrderShippingMethodsStepInput {
|
||||||
|
/**
|
||||||
|
* The shipping methods to restore.
|
||||||
|
*/
|
||||||
shippingMethods: {
|
shippingMethods: {
|
||||||
|
/**
|
||||||
|
* The ID of the shipping method.
|
||||||
|
*/
|
||||||
id: string
|
id: string
|
||||||
|
/**
|
||||||
|
* The shipping method's details before the edit.
|
||||||
|
*/
|
||||||
before: {
|
before: {
|
||||||
|
/**
|
||||||
|
* The ID of the shipping option.
|
||||||
|
*/
|
||||||
shipping_option_id: string
|
shipping_option_id: string
|
||||||
|
/**
|
||||||
|
* The amount of the shipping method.
|
||||||
|
*/
|
||||||
amount: BigNumberInput
|
amount: BigNumberInput
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* The shipping method's details after the edit.
|
||||||
|
*/
|
||||||
after: {
|
after: {
|
||||||
|
/**
|
||||||
|
* The ID of the shipping option.
|
||||||
|
*/
|
||||||
shipping_option_id: string
|
shipping_option_id: string
|
||||||
|
/**
|
||||||
|
* The amount of the shipping method.
|
||||||
|
*/
|
||||||
amount: BigNumberInput
|
amount: BigNumberInput
|
||||||
}
|
}
|
||||||
}[]
|
}[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step restores the shipping methods of a draft order.
|
||||||
|
* It's useful when you need to revert changes made by a canceled draft order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = restoreDraftOrderShippingMethodsStep({
|
||||||
|
* shippingMethods: [
|
||||||
|
* {
|
||||||
|
* id: "shipping_method_123",
|
||||||
|
* before: {
|
||||||
|
* shipping_option_id: "shipping_option_123",
|
||||||
|
* amount: 10
|
||||||
|
* },
|
||||||
|
* after: {
|
||||||
|
* shipping_option_id: "shipping_option_123",
|
||||||
|
* amount: 10
|
||||||
|
* }
|
||||||
|
* },
|
||||||
|
* ],
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const restoreDraftOrderShippingMethodsStep = createStep(
|
export const restoreDraftOrderShippingMethodsStep = createStep(
|
||||||
restoreDraftOrderShippingMethodsStepId,
|
restoreDraftOrderShippingMethodsStepId,
|
||||||
async function (
|
async function (
|
||||||
|
|||||||
@@ -8,12 +8,39 @@ import { IPromotionModuleService } from "@medusajs/types"
|
|||||||
|
|
||||||
export const updateDraftOrderPromotionsStepId = "update-draft-order-promotions"
|
export const updateDraftOrderPromotionsStepId = "update-draft-order-promotions"
|
||||||
|
|
||||||
interface UpdateDraftOrderPromotionsStepInput {
|
/**
|
||||||
|
* The details of the promotions to update in a draft order.
|
||||||
|
*/
|
||||||
|
export interface UpdateDraftOrderPromotionsStepInput {
|
||||||
|
/**
|
||||||
|
* The ID of the draft order.
|
||||||
|
*/
|
||||||
id: string
|
id: string
|
||||||
|
/**
|
||||||
|
* The promo codes to add, replace, or remove from the draft order.
|
||||||
|
*/
|
||||||
promo_codes: string[]
|
promo_codes: string[]
|
||||||
|
/**
|
||||||
|
* The action to perform on the promotions. You can either:
|
||||||
|
*
|
||||||
|
* - Add the promotions to the draft order.
|
||||||
|
* - Replace the existing promotions with the new ones.
|
||||||
|
* - Remove the promotions from the draft order.
|
||||||
|
*/
|
||||||
action?: PromotionActions
|
action?: PromotionActions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step updates the promotions of a draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = updateDraftOrderPromotionsStep({
|
||||||
|
* id: "order_123",
|
||||||
|
* promo_codes: ["PROMO_123", "PROMO_456"],
|
||||||
|
* // Import from "@medusajs/framework/utils"
|
||||||
|
* action: PromotionActions.ADD,
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const updateDraftOrderPromotionsStep = createStep(
|
export const updateDraftOrderPromotionsStep = createStep(
|
||||||
updateDraftOrderPromotionsStepId,
|
updateDraftOrderPromotionsStepId,
|
||||||
async function (data: UpdateDraftOrderPromotionsStepInput, { container }) {
|
async function (data: UpdateDraftOrderPromotionsStepInput, { container }) {
|
||||||
|
|||||||
+29
-1
@@ -5,14 +5,42 @@ import { BigNumberInput, IOrderModuleService } from "@medusajs/types"
|
|||||||
export const updateDraftOrderShippingMethodStepId =
|
export const updateDraftOrderShippingMethodStepId =
|
||||||
"update-draft-order-shipping-method"
|
"update-draft-order-shipping-method"
|
||||||
|
|
||||||
interface UpdateDraftOrderShippingMethodStepInput {
|
/**
|
||||||
|
* The details of the shipping method to update in a draft order.
|
||||||
|
*/
|
||||||
|
export interface UpdateDraftOrderShippingMethodStepInput {
|
||||||
|
/**
|
||||||
|
* The ID of the draft order.
|
||||||
|
*/
|
||||||
order_id: string
|
order_id: string
|
||||||
|
/**
|
||||||
|
* The ID of the shipping method to update.
|
||||||
|
*/
|
||||||
shipping_method_id: string
|
shipping_method_id: string
|
||||||
|
/**
|
||||||
|
* The ID of the shipping method's option.
|
||||||
|
*/
|
||||||
shipping_option_id?: string
|
shipping_option_id?: string
|
||||||
|
/**
|
||||||
|
* The amount of the shipping method.
|
||||||
|
*/
|
||||||
amount?: BigNumberInput
|
amount?: BigNumberInput
|
||||||
|
/**
|
||||||
|
* The metadata of the shipping method.
|
||||||
|
*/
|
||||||
metadata?: Record<string, unknown> | null
|
metadata?: Record<string, unknown> | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step updates the shipping method of a draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = updateDraftOrderShippingMethodStep({
|
||||||
|
* order_id: "order_123",
|
||||||
|
* shipping_method_id: "sm_123",
|
||||||
|
* amount: 10,
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const updateDraftOrderShippingMethodStep = createStep(
|
export const updateDraftOrderShippingMethodStep = createStep(
|
||||||
updateDraftOrderShippingMethodStepId,
|
updateDraftOrderShippingMethodStepId,
|
||||||
async function (
|
async function (
|
||||||
|
|||||||
@@ -3,13 +3,45 @@ import { OrderChangeDTO, OrderDTO } from "@medusajs/types"
|
|||||||
import { throwIfOrderChangeIsNotActive } from "../../order/utils/order-validation"
|
import { throwIfOrderChangeIsNotActive } from "../../order/utils/order-validation"
|
||||||
import { throwIfNotDraftOrder } from "../utils/validation"
|
import { throwIfNotDraftOrder } from "../utils/validation"
|
||||||
|
|
||||||
interface ValidateDraftOrderChangeStepInput {
|
/**
|
||||||
|
* The details of the draft order and its change to validate.
|
||||||
|
*/
|
||||||
|
export interface ValidateDraftOrderChangeStepInput {
|
||||||
|
/**
|
||||||
|
* The draft order to validate.
|
||||||
|
*/
|
||||||
order: OrderDTO
|
order: OrderDTO
|
||||||
|
/**
|
||||||
|
* The order change to validate.
|
||||||
|
*/
|
||||||
orderChange: OrderChangeDTO
|
orderChange: OrderChangeDTO
|
||||||
}
|
}
|
||||||
|
|
||||||
export const validateDraftOrderChangeStepId = "validate-draft-order-change"
|
export const validateDraftOrderChangeStepId = "validate-draft-order-change"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step validates that a draft order and its change are valid. It throws an error if the
|
||||||
|
* order is not a draft order or the order change is not active.
|
||||||
|
*
|
||||||
|
* :::note
|
||||||
|
*
|
||||||
|
* You can retrieve a draft order and its change's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
|
||||||
|
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
|
||||||
|
*
|
||||||
|
* :::
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = validateDraftOrderChangeStep({
|
||||||
|
* order: {
|
||||||
|
* id: "order_123",
|
||||||
|
* // other order details...
|
||||||
|
* },
|
||||||
|
* orderChange: {
|
||||||
|
* id: "orch_123",
|
||||||
|
* // other order change details...
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const validateDraftOrderChangeStep = createStep(
|
export const validateDraftOrderChangeStep = createStep(
|
||||||
validateDraftOrderChangeStepId,
|
validateDraftOrderChangeStepId,
|
||||||
async function ({ order, orderChange }: ValidateDraftOrderChangeStepInput) {
|
async function ({ order, orderChange }: ValidateDraftOrderChangeStepInput) {
|
||||||
|
|||||||
+32
@@ -4,11 +4,43 @@ import { ChangeActionType, MedusaError } from "@medusajs/framework/utils"
|
|||||||
import { createStep } from "@medusajs/framework/workflows-sdk"
|
import { createStep } from "@medusajs/framework/workflows-sdk"
|
||||||
import { OrderChangeDTO, OrderWorkflow } from "@medusajs/types"
|
import { OrderChangeDTO, OrderWorkflow } from "@medusajs/types"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the draft order and its change to validate.
|
||||||
|
*/
|
||||||
export interface ValidateDraftOrderUpdateActionItemStepInput {
|
export interface ValidateDraftOrderUpdateActionItemStepInput {
|
||||||
|
/**
|
||||||
|
* The details of the item removal action.
|
||||||
|
*/
|
||||||
input: OrderWorkflow.DeleteOrderEditItemActionWorkflowInput
|
input: OrderWorkflow.DeleteOrderEditItemActionWorkflowInput
|
||||||
|
/**
|
||||||
|
* The order change to validate.
|
||||||
|
*/
|
||||||
orderChange: OrderChangeDTO
|
orderChange: OrderChangeDTO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step validates that an item change can be removed from a draft order edit. It throws an error if the
|
||||||
|
* item change is not in the draft order edit, or if the item change is not adding or updating an item.
|
||||||
|
*
|
||||||
|
* :::note
|
||||||
|
*
|
||||||
|
* You can retrieve a draft order change's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
|
||||||
|
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
|
||||||
|
*
|
||||||
|
* :::
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = validateDraftOrderRemoveActionItemStep({
|
||||||
|
* input: {
|
||||||
|
* action_id: "action_123",
|
||||||
|
* order_id: "order_123",
|
||||||
|
* },
|
||||||
|
* orderChange: {
|
||||||
|
* id: "orch_123",
|
||||||
|
* // other order change details...
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const validateDraftOrderRemoveActionItemStep = createStep(
|
export const validateDraftOrderRemoveActionItemStep = createStep(
|
||||||
"validate-draft-order-remove-action-item",
|
"validate-draft-order-remove-action-item",
|
||||||
async function ({
|
async function ({
|
||||||
|
|||||||
+32
@@ -6,11 +6,43 @@ import {
|
|||||||
OrderWorkflow,
|
OrderWorkflow,
|
||||||
} from "@medusajs/types"
|
} from "@medusajs/types"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the draft order and its change to validate.
|
||||||
|
*/
|
||||||
export interface ValidateDraftOrderShippingMethodActionStepInput {
|
export interface ValidateDraftOrderShippingMethodActionStepInput {
|
||||||
|
/**
|
||||||
|
* The details of the shipping method removal action.
|
||||||
|
*/
|
||||||
input: OrderWorkflow.DeleteOrderEditShippingMethodWorkflowInput
|
input: OrderWorkflow.DeleteOrderEditShippingMethodWorkflowInput
|
||||||
|
/**
|
||||||
|
* The order change to validate.
|
||||||
|
*/
|
||||||
orderChange: OrderChangeDTO
|
orderChange: OrderChangeDTO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step validates that a shipping method change can be removed from a draft order edit. It throws an error if the
|
||||||
|
* shipping method change is not in the draft order edit, or if the shipping method change is not adding a shipping method.
|
||||||
|
*
|
||||||
|
* :::note
|
||||||
|
*
|
||||||
|
* You can retrieve a draft order change's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
|
||||||
|
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
|
||||||
|
*
|
||||||
|
* :::
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = validateDraftOrderShippingMethodActionStep({
|
||||||
|
* input: {
|
||||||
|
* action_id: "action_123",
|
||||||
|
* order_id: "order_123",
|
||||||
|
* },
|
||||||
|
* orderChange: {
|
||||||
|
* id: "orch_123",
|
||||||
|
* // other order change details...
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const validateDraftOrderShippingMethodActionStep = createStep(
|
export const validateDraftOrderShippingMethodActionStep = createStep(
|
||||||
"validate-draft-order-shipping-method-action",
|
"validate-draft-order-shipping-method-action",
|
||||||
async function ({
|
async function ({
|
||||||
|
|||||||
+32
@@ -4,11 +4,43 @@ import { ChangeActionType, MedusaError } from "@medusajs/framework/utils"
|
|||||||
import { createStep } from "@medusajs/framework/workflows-sdk"
|
import { createStep } from "@medusajs/framework/workflows-sdk"
|
||||||
import { OrderChangeDTO, OrderWorkflow } from "@medusajs/types"
|
import { OrderChangeDTO, OrderWorkflow } from "@medusajs/types"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the draft order and its change to validate.
|
||||||
|
*/
|
||||||
export interface ValidateDraftOrderUpdateActionItemStepInput {
|
export interface ValidateDraftOrderUpdateActionItemStepInput {
|
||||||
|
/**
|
||||||
|
* The details of updating a new item in a draft order edit.
|
||||||
|
*/
|
||||||
input: OrderWorkflow.UpdateOrderEditAddNewItemWorkflowInput
|
input: OrderWorkflow.UpdateOrderEditAddNewItemWorkflowInput
|
||||||
|
/**
|
||||||
|
* The order change to validate.
|
||||||
|
*/
|
||||||
orderChange: OrderChangeDTO
|
orderChange: OrderChangeDTO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step validates that a new item can be updated in a draft order edit. It throws an error if the
|
||||||
|
* item change is not in the draft order edit, or if the item change is not adding an item.
|
||||||
|
*
|
||||||
|
* :::note
|
||||||
|
*
|
||||||
|
* You can retrieve a draft order change's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
|
||||||
|
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
|
||||||
|
*
|
||||||
|
* :::
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = validateDraftOrderUpdateActionItemStep({
|
||||||
|
* input: {
|
||||||
|
* action_id: "action_123",
|
||||||
|
* order_id: "order_123",
|
||||||
|
* },
|
||||||
|
* orderChange: {
|
||||||
|
* id: "orch_123",
|
||||||
|
* // other order change details...
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const validateDraftOrderUpdateActionItemStep = createStep(
|
export const validateDraftOrderUpdateActionItemStep = createStep(
|
||||||
"validate-draft-order-update-action-item",
|
"validate-draft-order-update-action-item",
|
||||||
async function ({
|
async function ({
|
||||||
|
|||||||
@@ -2,10 +2,34 @@ import { MedusaError, OrderStatus } from "@medusajs/framework/utils"
|
|||||||
import { createStep } from "@medusajs/framework/workflows-sdk"
|
import { createStep } from "@medusajs/framework/workflows-sdk"
|
||||||
import { OrderDTO } from "@medusajs/types"
|
import { OrderDTO } from "@medusajs/types"
|
||||||
|
|
||||||
interface ValidateDraftOrderStepInput {
|
/**
|
||||||
|
* The details of the draft order to validate.
|
||||||
|
*/
|
||||||
|
export interface ValidateDraftOrderStepInput {
|
||||||
|
/**
|
||||||
|
* The draft order to validate.
|
||||||
|
*/
|
||||||
order: OrderDTO
|
order: OrderDTO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step validates that an order is a draft order. It throws an error otherwise.
|
||||||
|
*
|
||||||
|
* :::note
|
||||||
|
*
|
||||||
|
* You can retrieve a draft order's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
|
||||||
|
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
|
||||||
|
*
|
||||||
|
* :::
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = validateDraftOrderStep({
|
||||||
|
* order: {
|
||||||
|
* id: "order_123",
|
||||||
|
* // other order details...
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const validateDraftOrderStep = createStep(
|
export const validateDraftOrderStep = createStep(
|
||||||
"validate-draft-order",
|
"validate-draft-order",
|
||||||
async function ({ order }: ValidateDraftOrderStepInput) {
|
async function ({ order }: ValidateDraftOrderStepInput) {
|
||||||
|
|||||||
@@ -7,11 +7,43 @@ import {
|
|||||||
|
|
||||||
export const validatePromoCodesToAddId = "validate-promo-codes-to-add"
|
export const validatePromoCodesToAddId = "validate-promo-codes-to-add"
|
||||||
|
|
||||||
interface ValidatePromoCodesToAddStepInput {
|
/**
|
||||||
|
* The details of the promo codes to add to a draft order.
|
||||||
|
*/
|
||||||
|
export interface ValidatePromoCodesToAddStepInput {
|
||||||
|
/**
|
||||||
|
* The promo codes to add to the draft order.
|
||||||
|
*/
|
||||||
promo_codes: string[]
|
promo_codes: string[]
|
||||||
|
/**
|
||||||
|
* The promotions to add to the draft order.
|
||||||
|
*/
|
||||||
promotions: PromotionDTO[]
|
promotions: PromotionDTO[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step validates that the promo codes to add to a draft order are valid. It throws an error if the
|
||||||
|
* promo codes don't exist or are inactive.
|
||||||
|
*
|
||||||
|
* :::note
|
||||||
|
*
|
||||||
|
* You can retrieve a promotion's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
|
||||||
|
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
|
||||||
|
*
|
||||||
|
* :::
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = validatePromoCodesToAddStep({
|
||||||
|
* promo_codes: ["PROMO_123", "PROMO_456"],
|
||||||
|
* promotions: [{
|
||||||
|
* id: "promo_123",
|
||||||
|
* code: "PROMO_123"
|
||||||
|
* }, {
|
||||||
|
* id: "promo_456",
|
||||||
|
* code: "PROMO_456"
|
||||||
|
* }],
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const validatePromoCodesToAddStep = createStep(
|
export const validatePromoCodesToAddStep = createStep(
|
||||||
validatePromoCodesToAddId,
|
validatePromoCodesToAddId,
|
||||||
async function (input: ValidatePromoCodesToAddStepInput) {
|
async function (input: ValidatePromoCodesToAddStepInput) {
|
||||||
|
|||||||
@@ -4,11 +4,43 @@ import { throwIfCodesAreMissing } from "../utils/validation"
|
|||||||
|
|
||||||
export const validatePromoCodesToRemoveId = "validate-promo-codes-to-remove"
|
export const validatePromoCodesToRemoveId = "validate-promo-codes-to-remove"
|
||||||
|
|
||||||
interface ValidatePromoCodesToRemoveStepInput {
|
/**
|
||||||
|
* The details of the promo codes removal to validate.
|
||||||
|
*/
|
||||||
|
export interface ValidatePromoCodesToRemoveStepInput {
|
||||||
|
/**
|
||||||
|
* The promo codes to remove from the draft order.
|
||||||
|
*/
|
||||||
promo_codes: string[]
|
promo_codes: string[]
|
||||||
|
/**
|
||||||
|
* The promotions to remove from the draft order.
|
||||||
|
*/
|
||||||
promotions: PromotionDTO[]
|
promotions: PromotionDTO[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This step validates that the promo codes can be removed from a draft order. It throws an error if the promo
|
||||||
|
* codes don't exist.
|
||||||
|
*
|
||||||
|
* :::note
|
||||||
|
*
|
||||||
|
* You can retrieve a promotion's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
|
||||||
|
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
|
||||||
|
*
|
||||||
|
* :::
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = validatePromoCodesToRemoveStep({
|
||||||
|
* promo_codes: ["PROMO_123", "PROMO_456"],
|
||||||
|
* promotions: [{
|
||||||
|
* id: "promo_123",
|
||||||
|
* code: "PROMO_123"
|
||||||
|
* }, {
|
||||||
|
* id: "promo_456",
|
||||||
|
* code: "PROMO_456"
|
||||||
|
* }],
|
||||||
|
* })
|
||||||
|
*/
|
||||||
export const validatePromoCodesToRemoveStep = createStep(
|
export const validatePromoCodesToRemoveStep = createStep(
|
||||||
validatePromoCodesToRemoveId,
|
validatePromoCodesToRemoveId,
|
||||||
async function (input: ValidatePromoCodesToRemoveStepInput) {
|
async function (input: ValidatePromoCodesToRemoveStepInput) {
|
||||||
|
|||||||
@@ -24,6 +24,29 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
|
|
||||||
export const addDraftOrderItemsWorkflowId = "add-draft-order-items"
|
export const addDraftOrderItemsWorkflowId = "add-draft-order-items"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow adds items to a draft order. It's used by the
|
||||||
|
* [Add Item to Draft Order Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersidedititems).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around adding items to
|
||||||
|
* a draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await addDraftOrderItemsWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* items: [{
|
||||||
|
* variant_id: "variant_123",
|
||||||
|
* quantity: 1
|
||||||
|
* }]
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Add items to a draft order.
|
||||||
|
*/
|
||||||
export const addDraftOrderItemsWorkflow = createWorkflow(
|
export const addDraftOrderItemsWorkflow = createWorkflow(
|
||||||
addDraftOrderItemsWorkflowId,
|
addDraftOrderItemsWorkflowId,
|
||||||
function (
|
function (
|
||||||
|
|||||||
@@ -22,11 +22,40 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
|
|
||||||
export const addDraftOrderPromotionWorkflowId = "add-draft-order-promotion"
|
export const addDraftOrderPromotionWorkflowId = "add-draft-order-promotion"
|
||||||
|
|
||||||
interface AddDraftOrderPromotionWorkflowInput {
|
/**
|
||||||
|
* The details of the promotions to add to a draft order.
|
||||||
|
*/
|
||||||
|
export interface AddDraftOrderPromotionWorkflowInput {
|
||||||
|
/**
|
||||||
|
* The ID of the draft order to add the promotions to.
|
||||||
|
*/
|
||||||
order_id: string
|
order_id: string
|
||||||
|
/**
|
||||||
|
* The codes of the promotions to add to the draft order.
|
||||||
|
*/
|
||||||
promo_codes: string[]
|
promo_codes: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow adds promotions to a draft order. It's used by the
|
||||||
|
* [Add Promotion to Draft Order Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersideditpromotions).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around adding promotions to
|
||||||
|
* a draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await addDraftOrderPromotionWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* promo_codes: ["PROMO_CODE_1", "PROMO_CODE_2"]
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Add promotions to a draft order.
|
||||||
|
*/
|
||||||
export const addDraftOrderPromotionWorkflow = createWorkflow(
|
export const addDraftOrderPromotionWorkflow = createWorkflow(
|
||||||
addDraftOrderPromotionWorkflowId,
|
addDraftOrderPromotionWorkflowId,
|
||||||
function (input: WorkflowData<AddDraftOrderPromotionWorkflowInput>) {
|
function (input: WorkflowData<AddDraftOrderPromotionWorkflowInput>) {
|
||||||
|
|||||||
+28
-3
@@ -26,21 +26,46 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
export const addDraftOrderShippingMethodsWorkflowId =
|
export const addDraftOrderShippingMethodsWorkflowId =
|
||||||
"add-draft-order-shipping-methods"
|
"add-draft-order-shipping-methods"
|
||||||
|
|
||||||
interface AddDraftOrderShippingMethodsWorkflowInput {
|
/**
|
||||||
|
* The details of the shipping methods to add to a draft order.
|
||||||
|
*/
|
||||||
|
export interface AddDraftOrderShippingMethodsWorkflowInput {
|
||||||
/**
|
/**
|
||||||
* The ID of the draft order to add the shipping methods to.
|
* The ID of the draft order to add the shipping methods to.
|
||||||
*/
|
*/
|
||||||
order_id: string
|
order_id: string
|
||||||
/**
|
/**
|
||||||
* The ID of the shipping option to add the shipping methods from.
|
* The ID of the shipping option to add as a shipping method.
|
||||||
*/
|
*/
|
||||||
shipping_option_id: string
|
shipping_option_id: string
|
||||||
/**
|
/**
|
||||||
* The custom amount to add the shipping methods with.
|
* The custom amount to add the shipping method with.
|
||||||
|
* If not specified, the shipping option's fixed or calculated price will be used.
|
||||||
*/
|
*/
|
||||||
custom_amount?: BigNumberInput | null
|
custom_amount?: BigNumberInput | null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow adds shipping methods to a draft order. It's used by the
|
||||||
|
* [Add Shipping Method to Draft Order Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersideditshippingmethods).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around adding shipping methods to
|
||||||
|
* a draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await addDraftOrderShippingMethodsWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* shipping_option_id: "so_123",
|
||||||
|
* custom_amount: 10
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Add shipping methods to a draft order.
|
||||||
|
*/
|
||||||
export const addDraftOrderShippingMethodsWorkflow = createWorkflow(
|
export const addDraftOrderShippingMethodsWorkflow = createWorkflow(
|
||||||
addDraftOrderShippingMethodsWorkflowId,
|
addDraftOrderShippingMethodsWorkflowId,
|
||||||
function (input: WorkflowData<AddDraftOrderShippingMethodsWorkflowInput>) {
|
function (input: WorkflowData<AddDraftOrderShippingMethodsWorkflowInput>) {
|
||||||
|
|||||||
@@ -11,6 +11,27 @@ import { validateDraftOrderStep } from "../steps"
|
|||||||
|
|
||||||
export const beginDraftOrderEditWorkflowId = "begin-draft-order-edit"
|
export const beginDraftOrderEditWorkflowId = "begin-draft-order-edit"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow begins a draft order edit. It's used by the
|
||||||
|
* [Create Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersidedit).
|
||||||
|
*
|
||||||
|
* The draft order edit can later be requested using {@link requestDraftOrderEditWorkflow} or confirmed using {@link confirmDraftOrderEditWorkflow}.
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* creating a draft order edit request.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await beginDraftOrderEditWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Create a draft order edit request.
|
||||||
|
*/
|
||||||
export const beginDraftOrderEditWorkflow = createWorkflow(
|
export const beginDraftOrderEditWorkflow = createWorkflow(
|
||||||
beginDraftOrderEditWorkflowId,
|
beginDraftOrderEditWorkflowId,
|
||||||
function (input: WorkflowData<OrderWorkflow.BeginorderEditWorkflowInput>) {
|
function (input: WorkflowData<OrderWorkflow.BeginorderEditWorkflowInput>) {
|
||||||
|
|||||||
@@ -20,10 +20,35 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
|
|
||||||
export const cancelDraftOrderEditWorkflowId = "cancel-draft-order-edit"
|
export const cancelDraftOrderEditWorkflowId = "cancel-draft-order-edit"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the draft order edit to cancel.
|
||||||
|
*/
|
||||||
export interface CancelDraftOrderEditWorkflowInput {
|
export interface CancelDraftOrderEditWorkflowInput {
|
||||||
|
/**
|
||||||
|
* The ID of the draft order to cancel the edit for.
|
||||||
|
*/
|
||||||
order_id: string
|
order_id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow cancels a draft order edit. It's used by the
|
||||||
|
* [Cancel Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_deletedraftordersidedit).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* cancelling a draft order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await cancelDraftOrderEditWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Cancel a draft order edit.
|
||||||
|
*/
|
||||||
export const cancelDraftOrderEditWorkflow = createWorkflow(
|
export const cancelDraftOrderEditWorkflow = createWorkflow(
|
||||||
cancelDraftOrderEditWorkflowId,
|
cancelDraftOrderEditWorkflowId,
|
||||||
function (input: WorkflowData<CancelDraftOrderEditWorkflowInput>) {
|
function (input: WorkflowData<CancelDraftOrderEditWorkflowInput>) {
|
||||||
|
|||||||
@@ -33,6 +33,26 @@ export interface ConfirmDraftOrderEditWorkflowInput {
|
|||||||
confirmed_by: string
|
confirmed_by: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow confirms a draft order edit. It's used by the
|
||||||
|
* [Confirm Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersideditconfirm).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* confirming a draft order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await confirmDraftOrderEditWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* confirmed_by: "user_123",
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Confirm a draft order edit.
|
||||||
|
*/
|
||||||
export const confirmDraftOrderEditWorkflow = createWorkflow(
|
export const confirmDraftOrderEditWorkflow = createWorkflow(
|
||||||
confirmDraftOrderEditWorkflowId,
|
confirmDraftOrderEditWorkflowId,
|
||||||
function (input: ConfirmDraftOrderEditWorkflowInput) {
|
function (input: ConfirmDraftOrderEditWorkflowInput) {
|
||||||
|
|||||||
@@ -16,23 +16,30 @@ import { validateDraftOrderStep } from "../steps/validate-draft-order"
|
|||||||
|
|
||||||
const convertDraftOrderWorkflowId = "convert-draft-order"
|
const convertDraftOrderWorkflowId = "convert-draft-order"
|
||||||
|
|
||||||
interface ConvertDraftOrderWorkflowInput {
|
/**
|
||||||
|
* The details of the draft order to convert to an order.
|
||||||
|
*/
|
||||||
|
export interface ConvertDraftOrderWorkflowInput {
|
||||||
|
/**
|
||||||
|
* The ID of the draft order to convert to an order.
|
||||||
|
*/
|
||||||
id: string
|
id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ConvertDraftOrderStepInput {
|
/**
|
||||||
|
* The details of the draft order to convert to an order.
|
||||||
|
*/
|
||||||
|
export interface ConvertDraftOrderStepInput {
|
||||||
|
/**
|
||||||
|
* The ID of the draft order to convert to an order.
|
||||||
|
*/
|
||||||
id: string
|
id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This step converts a draft order to a pending order.
|
* This step converts a draft order to a pending order.
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```typescript
|
|
||||||
* const order = await convertDraftOrderStep({ id: "order_123" })
|
|
||||||
* ```
|
|
||||||
*/
|
*/
|
||||||
const convertDraftOrderStep = createStep(
|
export const convertDraftOrderStep = createStep(
|
||||||
"convert-draft-order",
|
"convert-draft-order",
|
||||||
async function ({ id }: ConvertDraftOrderStepInput, { container }) {
|
async function ({ id }: ConvertDraftOrderStepInput, { container }) {
|
||||||
const service = container.resolve<IOrderModuleService>(Modules.ORDER)
|
const service = container.resolve<IOrderModuleService>(Modules.ORDER)
|
||||||
@@ -69,12 +76,23 @@ const convertDraftOrderStep = createStep(
|
|||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This workflow converts a draft order to a pending order.
|
* This workflow converts a draft order to a pending order. It's used by the
|
||||||
|
* [Convert Draft Order to Order Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersidconverttoorder).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* converting a draft order to a pending order.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* ```typescript
|
* const { result } = await convertDraftOrderWorkflow(container)
|
||||||
* const order = await convertDraftOrderWorkflow({ id: "order_123" })
|
* .run({
|
||||||
* ```
|
* input: {
|
||||||
|
* id: "order_123",
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Convert a draft order to a pending order.
|
||||||
*/
|
*/
|
||||||
export const convertDraftOrderWorkflow = createWorkflow(
|
export const convertDraftOrderWorkflow = createWorkflow(
|
||||||
convertDraftOrderWorkflowId,
|
convertDraftOrderWorkflowId,
|
||||||
|
|||||||
+41
-1
@@ -20,12 +20,52 @@ import { updateDraftOrderPromotionsStep } from "../steps/update-draft-order-prom
|
|||||||
export const refreshDraftOrderAdjustmentsWorkflowId =
|
export const refreshDraftOrderAdjustmentsWorkflowId =
|
||||||
"refresh-draft-order-adjustments"
|
"refresh-draft-order-adjustments"
|
||||||
|
|
||||||
interface RefreshDraftOrderAdjustmentsWorkflowInput {
|
/**
|
||||||
|
* The details of the draft order to refresh the adjustments for.
|
||||||
|
*/
|
||||||
|
export interface RefreshDraftOrderAdjustmentsWorkflowInput {
|
||||||
|
/**
|
||||||
|
* The draft order to refresh the adjustments for.
|
||||||
|
*/
|
||||||
order: OrderDTO
|
order: OrderDTO
|
||||||
|
/**
|
||||||
|
* The promo codes to add or remove from the draft order.
|
||||||
|
*/
|
||||||
promo_codes: string[]
|
promo_codes: string[]
|
||||||
|
/**
|
||||||
|
* The action to apply with the promo codes. You can
|
||||||
|
* either:
|
||||||
|
*
|
||||||
|
* - Add the promo codes to the draft order.
|
||||||
|
* - Remove the promo codes from the draft order.
|
||||||
|
* - Replace the existing promo codes with the new ones.
|
||||||
|
*/
|
||||||
action: PromotionActions
|
action: PromotionActions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow refreshes the adjustments or promotions for a draft order. It's used by other workflows
|
||||||
|
* like {@link addDraftOrderItemsWorkflow} to refresh the promotions whenever changes
|
||||||
|
* are made to the draft order.
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* refreshing the adjustments or promotions for a draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await refreshDraftOrderAdjustmentsWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order: order,
|
||||||
|
* promo_codes: ["PROMO_CODE_1", "PROMO_CODE_2"],
|
||||||
|
* // imported from "@medusajs/framework/utils"
|
||||||
|
* action: PromotionActions.ADD,
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Refresh the promotions in a draft order.
|
||||||
|
*/
|
||||||
export const refreshDraftOrderAdjustmentsWorkflow = createWorkflow(
|
export const refreshDraftOrderAdjustmentsWorkflow = createWorkflow(
|
||||||
refreshDraftOrderAdjustmentsWorkflowId,
|
refreshDraftOrderAdjustmentsWorkflowId,
|
||||||
function (input: WorkflowData<RefreshDraftOrderAdjustmentsWorkflowInput>) {
|
function (input: WorkflowData<RefreshDraftOrderAdjustmentsWorkflowInput>) {
|
||||||
|
|||||||
@@ -25,6 +25,26 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
export const removeDraftOrderActionItemWorkflowId =
|
export const removeDraftOrderActionItemWorkflowId =
|
||||||
"remove-draft-order-action-item"
|
"remove-draft-order-action-item"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow removes an item that was added or updated in a draft order edit. It's used by the
|
||||||
|
* [Remove Item from Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_deletedraftordersidedititemsaction_id).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* removing an item from a draft order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await removeDraftOrderActionItemWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* action_id: "action_123",
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Remove an item from a draft order edit.
|
||||||
|
*/
|
||||||
export const removeDraftOrderActionItemWorkflow = createWorkflow(
|
export const removeDraftOrderActionItemWorkflow = createWorkflow(
|
||||||
removeDraftOrderActionItemWorkflowId,
|
removeDraftOrderActionItemWorkflowId,
|
||||||
function (
|
function (
|
||||||
|
|||||||
+20
@@ -29,6 +29,26 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
export const removeDraftOrderActionShippingMethodWorkflowId =
|
export const removeDraftOrderActionShippingMethodWorkflowId =
|
||||||
"remove-draft-order-action-shipping-method"
|
"remove-draft-order-action-shipping-method"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow removes a shipping method that was added to an edited draft order. It's used by the
|
||||||
|
* [Remove Shipping Method from Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_deletedraftordersideditshippingmethodsaction_id).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* removing a shipping method from an edited draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await removeDraftOrderActionShippingMethodWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* action_id: "action_123",
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Remove a shipping method from an edited draft order.
|
||||||
|
*/
|
||||||
export const removeDraftOrderActionShippingMethodWorkflow = createWorkflow(
|
export const removeDraftOrderActionShippingMethodWorkflow = createWorkflow(
|
||||||
removeDraftOrderActionShippingMethodWorkflowId,
|
removeDraftOrderActionShippingMethodWorkflowId,
|
||||||
function (
|
function (
|
||||||
|
|||||||
+30
-1
@@ -23,11 +23,40 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
export const removeDraftOrderPromotionsWorkflowId =
|
export const removeDraftOrderPromotionsWorkflowId =
|
||||||
"remove-draft-order-promotions"
|
"remove-draft-order-promotions"
|
||||||
|
|
||||||
interface RemoveDraftOrderPromotionsWorkflowInput {
|
/**
|
||||||
|
* The details of the promotions to remove from a draft order.
|
||||||
|
*/
|
||||||
|
export interface RemoveDraftOrderPromotionsWorkflowInput {
|
||||||
|
/**
|
||||||
|
* The ID of the draft order to remove the promotions from.
|
||||||
|
*/
|
||||||
order_id: string
|
order_id: string
|
||||||
|
/**
|
||||||
|
* The codes of the promotions to remove from the draft order.
|
||||||
|
*/
|
||||||
promo_codes: string[]
|
promo_codes: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow removes promotions from a draft order edit. It's used by the
|
||||||
|
* [Remove Promotions from Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_deletedraftordersideditpromotions).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* removing promotions from a draft order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await removeDraftOrderPromotionsWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* promo_codes: ["PROMO_CODE_1", "PROMO_CODE_2"],
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Remove promotions from a draft order edit.
|
||||||
|
*/
|
||||||
export const removeDraftOrderPromotionsWorkflow = createWorkflow(
|
export const removeDraftOrderPromotionsWorkflow = createWorkflow(
|
||||||
removeDraftOrderPromotionsWorkflowId,
|
removeDraftOrderPromotionsWorkflowId,
|
||||||
function (input: WorkflowData<RemoveDraftOrderPromotionsWorkflowInput>) {
|
function (input: WorkflowData<RemoveDraftOrderPromotionsWorkflowInput>) {
|
||||||
|
|||||||
+25
-2
@@ -24,9 +24,12 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
export const removeDraftOrderShippingMethodWorkflowId =
|
export const removeDraftOrderShippingMethodWorkflowId =
|
||||||
"remove-draft-order-shipping-method"
|
"remove-draft-order-shipping-method"
|
||||||
|
|
||||||
interface RemoveDraftOrderShippingMethodWorkflowInput {
|
|
||||||
/**
|
/**
|
||||||
* The ID of the draft order to add the shipping methods to.
|
* The details of the shipping method to remove from a draft order.
|
||||||
|
*/
|
||||||
|
export interface RemoveDraftOrderShippingMethodWorkflowInput {
|
||||||
|
/**
|
||||||
|
* The ID of the draft order to remove the shipping method from.
|
||||||
*/
|
*/
|
||||||
order_id: string
|
order_id: string
|
||||||
/**
|
/**
|
||||||
@@ -35,6 +38,26 @@ interface RemoveDraftOrderShippingMethodWorkflowInput {
|
|||||||
shipping_method_id: string
|
shipping_method_id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow removes an existing shipping method from a draft order edit. It's used by the
|
||||||
|
* [Remove Shipping Method from Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_deletedraftordersideditshippingmethodsmethodmethod_id).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* removing a shipping method from a draft order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await removeDraftOrderShippingMethodWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* shipping_method_id: "sm_123",
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Remove an existing shipping method from a draft order edit.
|
||||||
|
*/
|
||||||
export const removeDraftOrderShippingMethodWorkflow = createWorkflow(
|
export const removeDraftOrderShippingMethodWorkflow = createWorkflow(
|
||||||
removeDraftOrderShippingMethodWorkflowId,
|
removeDraftOrderShippingMethodWorkflowId,
|
||||||
function (input: WorkflowData<RemoveDraftOrderShippingMethodWorkflowInput>) {
|
function (input: WorkflowData<RemoveDraftOrderShippingMethodWorkflowInput>) {
|
||||||
|
|||||||
@@ -48,6 +48,26 @@ export type RequestDraftOrderEditWorkflowInput = {
|
|||||||
requested_by?: string
|
requested_by?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow requests a draft order edit. It's used by the
|
||||||
|
* [Request Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersideditrequest).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* requesting a draft order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await requestDraftOrderEditWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* requested_by: "user_123",
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Request a draft order edit.
|
||||||
|
*/
|
||||||
export const requestDraftOrderEditWorkflow = createWorkflow(
|
export const requestDraftOrderEditWorkflow = createWorkflow(
|
||||||
requestDraftOrderEditId,
|
requestDraftOrderEditId,
|
||||||
function (input: RequestDraftOrderEditWorkflowInput) {
|
function (input: RequestDraftOrderEditWorkflowInput) {
|
||||||
|
|||||||
@@ -25,6 +25,29 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
|
|
||||||
export const updateDraftOrderActionItemId = "update-draft-order-action-item"
|
export const updateDraftOrderActionItemId = "update-draft-order-action-item"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow updates a new item that was added to a draft order edit. It's used by the
|
||||||
|
* [Update New Item in Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersidedititemsaction_id).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* updating a new item in a draft order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await updateDraftOrderActionItemWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* action_id: "action_123",
|
||||||
|
* data: {
|
||||||
|
* quantity: 2,
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Update a new item in a draft order edit.
|
||||||
|
*/
|
||||||
export const updateDraftOrderActionItemWorkflow = createWorkflow(
|
export const updateDraftOrderActionItemWorkflow = createWorkflow(
|
||||||
updateDraftOrderActionItemId,
|
updateDraftOrderActionItemId,
|
||||||
function (
|
function (
|
||||||
|
|||||||
+23
@@ -30,6 +30,29 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
export const updateDraftOrderActionShippingMethodWorkflowId =
|
export const updateDraftOrderActionShippingMethodWorkflowId =
|
||||||
"update-draft-order-action-shipping-method"
|
"update-draft-order-action-shipping-method"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow updates a new shipping method that was added to a draft order edit. It's used by the
|
||||||
|
* [Update New Shipping Method in Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersideditshippingmethodsaction_id).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* updating a new shipping method in a draft order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await updateDraftOrderActionShippingMethodWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* action_id: "action_123",
|
||||||
|
* data: {
|
||||||
|
* custom_amount: 10,
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Update a new shipping method in a draft order edit.
|
||||||
|
*/
|
||||||
export const updateDraftOrderActionShippingMethodWorkflow = createWorkflow(
|
export const updateDraftOrderActionShippingMethodWorkflow = createWorkflow(
|
||||||
updateDraftOrderActionShippingMethodWorkflowId,
|
updateDraftOrderActionShippingMethodWorkflowId,
|
||||||
function (
|
function (
|
||||||
|
|||||||
@@ -30,6 +30,26 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
|
|
||||||
export const updateDraftOrderItemWorkflowId = "update-draft-order-item"
|
export const updateDraftOrderItemWorkflowId = "update-draft-order-item"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow updates an item in a draft order edit. It's used by the
|
||||||
|
* [Update Item in Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersidedititemsitemitem_id).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* updating an item in a draft order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await updateDraftOrderItemWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* items: [{ id: "orli_123", quantity: 2 }],
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Update an item in a draft order edit.
|
||||||
|
*/
|
||||||
export const updateDraftOrderItemWorkflow = createWorkflow(
|
export const updateDraftOrderItemWorkflow = createWorkflow(
|
||||||
updateDraftOrderItemWorkflowId,
|
updateDraftOrderItemWorkflowId,
|
||||||
function (
|
function (
|
||||||
|
|||||||
+27
-1
@@ -25,6 +25,9 @@ import { refreshDraftOrderAdjustmentsWorkflow } from "./refresh-draft-order-adju
|
|||||||
export const updateDraftOrderShippingMethodWorkflowId =
|
export const updateDraftOrderShippingMethodWorkflowId =
|
||||||
"update-draft-order-shipping-method"
|
"update-draft-order-shipping-method"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the shipping method to update in the order edit.
|
||||||
|
*/
|
||||||
export interface UpdateDraftOrderShippingMethodWorkflowInput {
|
export interface UpdateDraftOrderShippingMethodWorkflowInput {
|
||||||
/**
|
/**
|
||||||
* The ID of the order to update the shipping method in its edit.
|
* The ID of the order to update the shipping method in its edit.
|
||||||
@@ -36,7 +39,7 @@ export interface UpdateDraftOrderShippingMethodWorkflowInput {
|
|||||||
*/
|
*/
|
||||||
shipping_method_id: string
|
shipping_method_id: string
|
||||||
/**
|
/**
|
||||||
* The ID of the shipping option to associate with the shipping method.
|
* The ID of the shipping method's option.
|
||||||
*/
|
*/
|
||||||
shipping_option_id?: string
|
shipping_option_id?: string
|
||||||
/**
|
/**
|
||||||
@@ -50,6 +53,29 @@ export interface UpdateDraftOrderShippingMethodWorkflowInput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow updates an existing shipping method in a draft order edit. It's used by the
|
||||||
|
* [Update Shipping Method in Draft Order Edit Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersideditshippingmethodsmethodmethod_id).
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* updating an existing shipping method in a draft order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await updateDraftOrderShippingMethodWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* order_id: "order_123",
|
||||||
|
* data: {
|
||||||
|
* shipping_method_id: "sm_123",
|
||||||
|
* custom_amount: 10,
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Update an existing shipping method in a draft order edit.
|
||||||
|
*/
|
||||||
export const updateDraftOrderShippingMethodWorkflow = createWorkflow(
|
export const updateDraftOrderShippingMethodWorkflow = createWorkflow(
|
||||||
updateDraftOrderShippingMethodWorkflowId,
|
updateDraftOrderShippingMethodWorkflowId,
|
||||||
function (input: WorkflowData<UpdateDraftOrderShippingMethodWorkflowInput>) {
|
function (input: WorkflowData<UpdateDraftOrderShippingMethodWorkflowInput>) {
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ import { validateDraftOrderStep } from "../steps/validate-draft-order"
|
|||||||
|
|
||||||
export const updateDraftOrderWorkflowId = "update-draft-order"
|
export const updateDraftOrderWorkflowId = "update-draft-order"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The details of the draft order to update.
|
||||||
|
*/
|
||||||
export interface UpdateDraftOrderWorkflowInput {
|
export interface UpdateDraftOrderWorkflowInput {
|
||||||
/**
|
/**
|
||||||
* The ID of the draft order to update.
|
* The ID of the draft order to update.
|
||||||
@@ -55,12 +58,42 @@ export interface UpdateDraftOrderWorkflowInput {
|
|||||||
metadata?: Record<string, unknown> | null
|
metadata?: Record<string, unknown> | null
|
||||||
}
|
}
|
||||||
|
|
||||||
interface UpdateDraftOrderStepInput {
|
/**
|
||||||
|
* The input for the update draft order step.
|
||||||
|
*/
|
||||||
|
export interface UpdateDraftOrderStepInput {
|
||||||
|
/**
|
||||||
|
* The draft order to update.
|
||||||
|
*/
|
||||||
order: OrderDTO
|
order: OrderDTO
|
||||||
|
/**
|
||||||
|
* The details to update in the draft order.
|
||||||
|
*/
|
||||||
input: UpdateOrderDTO
|
input: UpdateOrderDTO
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateDraftOrderStep = createStep(
|
/**
|
||||||
|
* This step updates a draft order's details.
|
||||||
|
*
|
||||||
|
* :::note
|
||||||
|
*
|
||||||
|
* You can retrieve a draft order's details using [Query](https://docs.medusajs.com/learn/fundamentals/module-links/query),
|
||||||
|
* or [useQueryGraphStep](https://docs.medusajs.com/resources/references/medusa-workflows/steps/useQueryGraphStep).
|
||||||
|
*
|
||||||
|
* :::
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const data = updateDraftOrderStep({
|
||||||
|
* order: {
|
||||||
|
* id: "order_123",
|
||||||
|
* // other order details...
|
||||||
|
* },
|
||||||
|
* input: {
|
||||||
|
* // details to update...
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*/
|
||||||
|
export const updateDraftOrderStep = createStep(
|
||||||
"update-draft-order",
|
"update-draft-order",
|
||||||
async ({ order, input }: UpdateDraftOrderStepInput, { container }) => {
|
async ({ order, input }: UpdateDraftOrderStepInput, { container }) => {
|
||||||
const service = container.resolve<IOrderModuleService>(Modules.ORDER)
|
const service = container.resolve<IOrderModuleService>(Modules.ORDER)
|
||||||
@@ -87,6 +120,32 @@ const updateDraftOrderStep = createStep(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This workflow updates a draft order's details. It's used by the
|
||||||
|
* [Update Draft Order Admin API Route](https://docs.medusajs.com/api/admin#draft-orders_postdraftordersid).
|
||||||
|
*
|
||||||
|
* This workflow doesn't update the draft order's items, shipping methods, or promotions. Instead, you have to
|
||||||
|
* create a draft order edit using {@link beginDraftOrderEditWorkflow} and make updates in the draft order edit.
|
||||||
|
* Then, you can confirm the draft order edit using {@link confirmDraftOrderEditWorkflow} or request a draft order edit
|
||||||
|
* using {@link requestDraftOrderEditWorkflow}.
|
||||||
|
*
|
||||||
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around
|
||||||
|
* updating a draft order.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* const { result } = await updateDraftOrderWorkflow(container)
|
||||||
|
* .run({
|
||||||
|
* input: {
|
||||||
|
* id: "order_123",
|
||||||
|
* user_id: "user_123",
|
||||||
|
* customer_id: "cus_123",
|
||||||
|
* }
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @summary
|
||||||
|
*
|
||||||
|
* Update a draft order's details.
|
||||||
|
*/
|
||||||
export const updateDraftOrderWorkflow = createWorkflow(
|
export const updateDraftOrderWorkflow = createWorkflow(
|
||||||
updateDraftOrderWorkflowId,
|
updateDraftOrderWorkflowId,
|
||||||
function (input: WorkflowData<UpdateDraftOrderWorkflowInput>) {
|
function (input: WorkflowData<UpdateDraftOrderWorkflowInput>) {
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ export interface BeginorderEditWorkflowInput {
|
|||||||
order_id: string
|
order_id: string
|
||||||
/**
|
/**
|
||||||
* The ID of the user requesting the order edit.
|
* The ID of the user requesting the order edit.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* "user_123"
|
||||||
*/
|
*/
|
||||||
created_by?: string
|
created_by?: string
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user