feat(order,core-flows): added order change create workflow (#8033)
what: - adds anorder change create workflow - remove order change service, brings validation to entry point service
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { CreateOrderChangeDTO, IOrderModuleService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createOrderChangeStepId = "create-order-change"
|
||||
export const createOrderChangeStep = createStep(
|
||||
createOrderChangeStepId,
|
||||
async (data: CreateOrderChangeDTO, { container }) => {
|
||||
const service = container.resolve<IOrderModuleService>(
|
||||
ModuleRegistrationName.ORDER
|
||||
)
|
||||
|
||||
const created = await service.createOrderChange(data)
|
||||
|
||||
return new StepResponse(created, created.id)
|
||||
},
|
||||
async (id, { container }) => {
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
|
||||
const service = container.resolve<IOrderModuleService>(
|
||||
ModuleRegistrationName.ORDER
|
||||
)
|
||||
|
||||
await service.deleteOrderChanges(id)
|
||||
}
|
||||
)
|
||||
@@ -4,6 +4,7 @@ export * from "./cancel-exchange"
|
||||
export * from "./cancel-orders"
|
||||
export * from "./cancel-return"
|
||||
export * from "./complete-orders"
|
||||
export * from "./create-order-change"
|
||||
export * from "./create-orders"
|
||||
export * from "./get-item-tax-lines"
|
||||
export * from "./register-fulfillment"
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { CreateOrderChangeDTO, OrderChangeDTO } from "@medusajs/types"
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { createOrderChangeStep } from "../steps"
|
||||
|
||||
export const createOrderChangeWorkflowId = "create-order-change"
|
||||
export const createOrderChangeWorkflow = createWorkflow(
|
||||
createOrderChangeWorkflowId,
|
||||
(input: WorkflowData<CreateOrderChangeDTO>): WorkflowData<OrderChangeDTO> => {
|
||||
return createOrderChangeStep(input)
|
||||
}
|
||||
)
|
||||
@@ -4,6 +4,7 @@ export * from "./cancel-order-fulfillment"
|
||||
export * from "./cancel-return"
|
||||
export * from "./complete-orders"
|
||||
export * from "./create-fulfillment"
|
||||
export * from "./create-order-change"
|
||||
export * from "./create-orders"
|
||||
export * from "./create-return"
|
||||
export * from "./create-shipment"
|
||||
|
||||
@@ -1127,6 +1127,42 @@ export interface IOrderModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<OrderChangeDTO | OrderChangeDTO[]>
|
||||
|
||||
/**
|
||||
* This method deletes order change by its ID.
|
||||
*
|
||||
* @param {string[]} orderChangeId - 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.deleteOrderChanges(["orderChangeId1", "orderChangeId2"]);
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
deleteOrderChanges(
|
||||
orderChangeId: string[],
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
|
||||
/**
|
||||
* This method deletes order change by its ID.
|
||||
*
|
||||
* @param {string} orderChangeId - The order'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.deleteOrderChanges("orderChangeId");
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
deleteOrderChanges(
|
||||
orderChangeId: string,
|
||||
sharedContext?: Context
|
||||
): Promise<void>
|
||||
|
||||
/**
|
||||
* This method Represents the completion of an asynchronous operation
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user