UNPKG

@medusajs/core-flows

Version:

Set of workflow definitions for Medusa

86 lines 3.5 kB
import { AdditionalData, FulfillmentDTO, OrderDTO, OrderWorkflow } from "@medusajs/framework/types"; import { WorkflowData } from "@medusajs/framework/workflows-sdk"; /** * The data to validate the order fulfillment cancelation. */ export type CancelOrderFulfillmentValidateOrderStep = { /** * The order to cancel the fulfillment for. */ order: OrderDTO & { /** * The order's fulfillments. */ fulfillments: FulfillmentDTO[]; }; /** * The cancelation details. */ input: OrderWorkflow.CancelOrderFulfillmentWorkflowInput; }; /** * This step validates that an order fulfillment can be canceled. If * the fulfillment doesn't exist, or it has already been shipped, the step throws an error. * * :::note * * You can retrieve an order and fulfillment 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 = cancelOrderFulfillmentValidateOrder({ * order: { * id: "order_123", * fulfillments: [ * { * id: "ful_123", * // other fulfillment details... * } * ] * // other order details... * }, * input: { * order_id: "order_123", * fulfillment_id: "ful_123" * } * }) */ export declare const cancelOrderFulfillmentValidateOrder: import("@medusajs/framework/workflows-sdk").StepFunction<CancelOrderFulfillmentValidateOrderStep, unknown>; /** * The data to cancel an order's fulfillment, along with custom data that's passed to the workflow's hooks. */ export type CancelOrderFulfillmentWorkflowInput = OrderWorkflow.CancelOrderFulfillmentWorkflowInput & AdditionalData; export declare const cancelOrderFulfillmentWorkflowId = "cancel-order-fulfillment"; /** * This workflow cancels an order's fulfillment. It's used by the [Cancel Order's Fulfillment Admin API Route](https://docs.medusajs.com/api/admin#orders_postordersidfulfillmentsfulfillment_idcancel). * * This workflow has a hook that allows you to perform custom actions on the canceled fulfillment. For example, you can pass under `additional_data` custom data that * allows you to update custom data models linked to the fulfillment. * * You can also use this workflow within your customizations or your own custom workflows, allowing you to wrap custom logic around canceling a fulfillment. * * @example * const { result } = await cancelOrderFulfillmentWorkflow(container) * .run({ * input: { * order_id: "order_123", * fulfillment_id: "ful_123", * additional_data: { * reason: "Customer changed their mind" * } * } * }) * * @summary * * Cancel an order's fulfillment. * * @property hooks.orderFulfillmentCanceled - This hook is executed after the fulfillment is canceled. You can consume this hook to perform custom actions on the canceled fulfillment. */ export declare const cancelOrderFulfillmentWorkflow: import("@medusajs/framework/workflows-sdk").ReturnWorkflow<CancelOrderFulfillmentWorkflowInput, undefined, [import("@medusajs/framework/workflows-sdk").Hook<"orderFulfillmentCanceled", { fulfillment: WorkflowData<FulfillmentDTO>; additional_data: ((Record<string, unknown> | WorkflowData<Record<string, unknown> | undefined>) & Record<string, unknown>) | undefined; }, unknown>]>; //# sourceMappingURL=cancel-order-fulfillment.d.ts.map