feat(core-flows, order): add workflow to create change order actions (#8056)
what: - adds workflow to create change order actions
This commit is contained in:
1 parent
04ec8e758f
commit
bec2dcd667
37 files changed
+290
-46
No files matched your search
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
CreateOrderChangeActionDTO,
|
||||
IOrderModuleService,
|
||||
} from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createOrderChangeActionsStepId = "create-order-change-actions"
|
||||
export const createOrderChangeActionsStep = createStep(
|
||||
createOrderChangeActionsStepId,
|
||||
async (data: CreateOrderChangeActionDTO[], { container }) => {
|
||||
const service = container.resolve<IOrderModuleService>(
|
||||
ModuleRegistrationName.ORDER
|
||||
)
|
||||
|
||||
const created = await service.addOrderAction(data)
|
||||
|
||||
return new StepResponse(
|
||||
created,
|
||||
created.map((c) => c.id)
|
||||
)
|
||||
},
|
||||
async (ids, { container }) => {
|
||||
if (!ids?.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const service = container.resolve<IOrderModuleService>(
|
||||
ModuleRegistrationName.ORDER
|
||||
)
|
||||
|
||||
await service.deleteOrderChangeActions(ids)
|
||||
}
|
||||
)
|
||||
@@ -6,6 +6,7 @@ export * from "./cancel-orders"
|
||||
export * from "./cancel-return"
|
||||
export * from "./complete-orders"
|
||||
export * from "./create-order-change"
|
||||
export * from "./create-order-change-actions"
|
||||
export * from "./create-orders"
|
||||
export * from "./decline-order-change"
|
||||
export * from "./delete-order-change"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import {
|
||||
CreateOrderChangeActionDTO,
|
||||
OrderChangeActionDTO,
|
||||
} from "@medusajs/types"
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { createOrderChangeActionsStep } from "../steps"
|
||||
|
||||
export const createOrderChangeActionsWorkflowId = "create-order-change-actions"
|
||||
export const createOrderChangeActionsWorkflow = createWorkflow(
|
||||
createOrderChangeActionsWorkflowId,
|
||||
(
|
||||
input: WorkflowData<CreateOrderChangeActionDTO[]>
|
||||
): WorkflowData<OrderChangeActionDTO[]> => {
|
||||
return createOrderChangeActionsStep(input)
|
||||
}
|
||||
)
|
||||
@@ -6,6 +6,7 @@ export * from "./cancel-return"
|
||||
export * from "./complete-orders"
|
||||
export * from "./create-fulfillment"
|
||||
export * from "./create-order-change"
|
||||
export * from "./create-order-change-actions"
|
||||
export * from "./create-orders"
|
||||
export * from "./create-return"
|
||||
export * from "./create-shipment"
|
||||
|
||||
@@ -1544,6 +1544,42 @@ export interface IOrderModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<OrderChangeActionDTO[]>
|
||||
|
||||
/**
|
||||
* This method deletes {return type} by its ID.
|
||||
*
|
||||
* @param {string[]} actionId - The list of {summary}
|
||||
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||
* @returns {Promise<void>} Resolves when {summary}
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* await orderModuleService.deleteOrderActions(["12345abc", "67890def"]);
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
deleteOrderChangeActions(
|
||||
actionId: string[],
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
|
||||
/**
|
||||
* This method deletes {return type} by its ID.
|
||||
*
|
||||
* @param {string} orderId - The order action's ID.
|
||||
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||
* @returns {Promise<void>} Resolves when {summary}
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* await orderModuleService.deleteOrderActions("orderActionId");
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
deleteOrderChangeActions(
|
||||
actionId: string,
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
|
||||
softDeleteAddresses<TReturnableLinkableKeys extends string = string>(
|
||||
ids: string[],
|
||||
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export * from "./events"
|
||||
export * from "./order-change-action"
|
||||
export * from "./status"
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
export enum ChangeActionType {
|
||||
CANCEL = "CANCEL",
|
||||
FULFILL_ITEM = "FULFILL_ITEM",
|
||||
CANCEL_ITEM_FULFILLMENT = "CANCEL_ITEM_FULFILLMENT",
|
||||
ITEM_ADD = "ITEM_ADD",
|
||||
ITEM_REMOVE = "ITEM_REMOVE",
|
||||
RECEIVE_DAMAGED_RETURN_ITEM = "RECEIVE_DAMAGED_RETURN_ITEM",
|
||||
RECEIVE_RETURN_ITEM = "RECEIVE_RETURN_ITEM",
|
||||
RETURN_ITEM = "RETURN_ITEM",
|
||||
CANCEL_RETURN_ITEM = "CANCEL_RETURN_ITEM",
|
||||
SHIPPING_ADD = "SHIPPING_ADD",
|
||||
SHIPPING_REMOVE = "SHIPPING_REMOVE",
|
||||
SHIP_ITEM = "SHIP_ITEM",
|
||||
WRITE_OFF_ITEM = "WRITE_OFF_ITEM",
|
||||
REINSTATE_ITEM = "REINSTATE_ITEM",
|
||||
}
|
||||
Reference in new issue
Block a user