diff --git a/packages/core/core-flows/src/order/workflows/claim/begin-order-claim.ts b/packages/core/core-flows/src/order/workflows/claim/begin-order-claim.ts index 8bf61dd37f..3ceda84272 100644 --- a/packages/core/core-flows/src/order/workflows/claim/begin-order-claim.ts +++ b/packages/core/core-flows/src/order/workflows/claim/begin-order-claim.ts @@ -11,7 +11,10 @@ import { createOrderClaimsStep } from "../../steps/claim/create-claims" import { createOrderChangeStep } from "../../steps/create-order-change" import { throwIfIsCancelled } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that the order associated with the claim isn't canceled. + */ +export const beginClaimOrderValidationStep = createStep( "begin-claim-order-validation", async function ({ order }: { order: OrderDTO }) { throwIfIsCancelled(order, "Order") @@ -19,6 +22,9 @@ const validationStep = createStep( ) export const beginClaimOrderWorkflowId = "begin-claim-order" +/** + * This workflow creates an order claim in requested state. + */ export const beginClaimOrderWorkflow = createWorkflow( beginClaimOrderWorkflowId, function ( @@ -32,7 +38,7 @@ export const beginClaimOrderWorkflow = createWorkflow( throw_if_key_not_found: true, }) - validationStep({ order }) + beginClaimOrderValidationStep({ order }) const created = createOrderClaimsStep([ { diff --git a/packages/core/core-flows/src/order/workflows/claim/cancel-begin-order-claim.ts b/packages/core/core-flows/src/order/workflows/claim/cancel-begin-order-claim.ts index fd39a3a25e..b17186a7f0 100644 --- a/packages/core/core-flows/src/order/workflows/claim/cancel-begin-order-claim.ts +++ b/packages/core/core-flows/src/order/workflows/claim/cancel-begin-order-claim.ts @@ -19,11 +19,15 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -type WorkflowInput = { +export type CancelBeginOrderClaimWorkflowInput = { claim_id: string } -const validationStep = createStep( +/** + * This step validates that the requested claim can be canceled by checking that it's not canceled, + * its order isn't canceled, and it hasn't been confirmed. + */ +export const cancelBeginOrderClaimValidationStep = createStep( "validate-cancel-begin-order-claim", async function ({ order, @@ -41,9 +45,12 @@ const validationStep = createStep( ) export const cancelBeginOrderClaimWorkflowId = "cancel-begin-order-claim" +/** + * This workflow cancels a requested order claim. + */ export const cancelBeginOrderClaimWorkflow = createWorkflow( cancelBeginOrderClaimWorkflowId, - function (input: WorkflowInput): WorkflowData { + function (input: CancelBeginOrderClaimWorkflowInput): WorkflowData { const orderClaim: OrderClaimDTO = useRemoteQueryStep({ entry_point: "order_claim", fields: ["id", "status", "order_id", "return_id", "canceled_at"], @@ -73,7 +80,7 @@ export const cancelBeginOrderClaimWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, orderClaim, orderChange }) + cancelBeginOrderClaimValidationStep({ order, orderClaim, orderChange }) const shippingToRemove = transform( { orderChange, input }, diff --git a/packages/core/core-flows/src/order/workflows/claim/cancel-claim.ts b/packages/core/core-flows/src/order/workflows/claim/cancel-claim.ts index 5883d75dbb..d9aa3ecd27 100644 --- a/packages/core/core-flows/src/order/workflows/claim/cancel-claim.ts +++ b/packages/core/core-flows/src/order/workflows/claim/cancel-claim.ts @@ -14,7 +14,10 @@ import { cancelOrderClaimStep } from "../../steps" import { throwIfIsCancelled } from "../../utils/order-validation" import { cancelReturnWorkflow } from "../return/cancel-return" -const validateOrder = createStep( +/** + * This step validates that a confirmed claim can be canceled. + */ +export const cancelClaimValidateOrderStep = createStep( "validate-claim", ({ orderClaim, @@ -49,6 +52,9 @@ const validateOrder = createStep( ) export const cancelOrderClaimWorkflowId = "cancel-claim" +/** + * This workflow cancels a confirmed order claim. + */ export const cancelOrderClaimWorkflow = createWorkflow( cancelOrderClaimWorkflowId, ( @@ -70,7 +76,7 @@ export const cancelOrderClaimWorkflow = createWorkflow( throw_if_key_not_found: true, }) - validateOrder({ orderClaim, input }) + cancelClaimValidateOrderStep({ orderClaim, input }) const lineItemIds = transform({ orderClaim }, ({ orderClaim }) => { return orderClaim.additional_items?.map((i) => i.item_id) diff --git a/packages/core/core-flows/src/order/workflows/claim/claim-add-new-item.ts b/packages/core/core-flows/src/order/workflows/claim/claim-add-new-item.ts index 28f59e64c0..fd27ef4f57 100644 --- a/packages/core/core-flows/src/order/workflows/claim/claim-add-new-item.ts +++ b/packages/core/core-flows/src/order/workflows/claim/claim-add-new-item.ts @@ -21,7 +21,10 @@ import { } from "../../utils/order-validation" import { addOrderLineItemsWorkflow } from "../add-line-items" -const validationStep = createStep( +/** + * This step validates that a new item can be added to the claim. + */ +export const orderClaimAddNewItemValidationStep = createStep( "claim-add-new-item-validation", async function ({ order, @@ -39,6 +42,9 @@ const validationStep = createStep( ) export const orderClaimAddNewItemWorkflowId = "claim-add-new-item" +/** + * This workflow adds a new item to a claim. + */ export const orderClaimAddNewItemWorkflow = createWorkflow( orderClaimAddNewItemWorkflowId, function ( @@ -73,7 +79,7 @@ export const orderClaimAddNewItemWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ + orderClaimAddNewItemValidationStep({ order, orderClaim, orderChange, diff --git a/packages/core/core-flows/src/order/workflows/claim/claim-item.ts b/packages/core/core-flows/src/order/workflows/claim/claim-item.ts index 4465f9b273..87065eaf3f 100644 --- a/packages/core/core-flows/src/order/workflows/claim/claim-item.ts +++ b/packages/core/core-flows/src/order/workflows/claim/claim-item.ts @@ -20,7 +20,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that claim items can be added to a claim. + */ +export const orderClaimItemValidationStep = createStep( "claim-item-validation", async function ({ order, @@ -38,6 +41,9 @@ const validationStep = createStep( ) export const orderClaimItemWorkflowId = "claim-item" +/** + * This workflow adds claim items to a claim. + */ export const orderClaimItemWorkflow = createWorkflow( orderClaimItemWorkflowId, function ( @@ -72,7 +78,7 @@ export const orderClaimItemWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ + orderClaimItemValidationStep({ order, orderClaim, orderChange, diff --git a/packages/core/core-flows/src/order/workflows/claim/claim-request-item-return.ts b/packages/core/core-flows/src/order/workflows/claim/claim-request-item-return.ts index 5b62b4034c..045c3bd053 100644 --- a/packages/core/core-flows/src/order/workflows/claim/claim-request-item-return.ts +++ b/packages/core/core-flows/src/order/workflows/claim/claim-request-item-return.ts @@ -25,7 +25,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that items can be requested to return as part of a claim. + */ +export const orderClaimRequestItemReturnValidationStep = createStep( "claim-request-item-return-validation", async function ({ order, @@ -49,6 +52,9 @@ const validationStep = createStep( ) export const orderClaimRequestItemReturnWorkflowId = "claim-request-item-return" +/** + * This workflow requests one or more items to be returned as part of a claim. + */ export const orderClaimRequestItemReturnWorkflow = createWorkflow( orderClaimRequestItemReturnWorkflowId, function ( @@ -115,7 +121,7 @@ export const orderClaimRequestItemReturnWorkflow = createWorkflow( name: "order-change-query", }) - validationStep({ + orderClaimRequestItemReturnValidationStep({ order, items: input.items, orderClaim, diff --git a/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts b/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts index 70c14820fc..8ff3c686ea 100644 --- a/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts +++ b/packages/core/core-flows/src/order/workflows/claim/confirm-claim-request.ts @@ -32,11 +32,14 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -type WorkflowInput = { +export type ConfirmClaimRequestWorkflowInput = { claim_id: string } -const validationStep = createStep( +/** + * This step validates that a requested claim can be confirmed. + */ +export const confirmClaimRequestValidationStep = createStep( "validate-confirm-claim-request", async function ({ order, @@ -173,9 +176,12 @@ function extractShippingOption({ orderPreview, orderClaim, returnId }) { } export const confirmClaimRequestWorkflowId = "confirm-claim-request" +/** + * This workflow confirms a requested claim. + */ export const confirmClaimRequestWorkflow = createWorkflow( confirmClaimRequestWorkflowId, - function (input: WorkflowInput): WorkflowResponse { + function (input: ConfirmClaimRequestWorkflowInput): WorkflowResponse { const orderClaim: OrderClaimDTO = useRemoteQueryStep({ entry_point: "order_claim", fields: ["id", "status", "order_id", "canceled_at"], @@ -225,7 +231,7 @@ export const confirmClaimRequestWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, orderClaim, orderChange }) + confirmClaimRequestValidationStep({ order, orderClaim, orderChange }) const { claimItems, returnItems } = transform( { orderChange }, diff --git a/packages/core/core-flows/src/order/workflows/claim/create-claim-shipping-method.ts b/packages/core/core-flows/src/order/workflows/claim/create-claim-shipping-method.ts index 5586d6b8f7..2a2da7c6aa 100644 --- a/packages/core/core-flows/src/order/workflows/claim/create-claim-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/claim/create-claim-shipping-method.ts @@ -20,7 +20,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step confirms that a shipping method can be created for a claim. + */ +export const createClaimShippingMethodValidationStep = createStep( "validate-create-claim-shipping-method", async function ({ order, @@ -39,6 +42,9 @@ const validationStep = createStep( export const createClaimShippingMethodWorkflowId = "create-claim-shipping-method" +/** + * This workflow creates a shipping method for a claim. + */ export const createClaimShippingMethodWorkflow = createWorkflow( createClaimShippingMethodWorkflowId, function (input: { @@ -92,7 +98,7 @@ export const createClaimShippingMethodWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, orderClaim, orderChange }) + createClaimShippingMethodValidationStep({ order, orderClaim, orderChange }) const shippingMethodInput = transform( { diff --git a/packages/core/core-flows/src/order/workflows/claim/remove-claim-add-item-action.ts b/packages/core/core-flows/src/order/workflows/claim/remove-claim-add-item-action.ts index 048fb1c293..17181f91c5 100644 --- a/packages/core/core-flows/src/order/workflows/claim/remove-claim-add-item-action.ts +++ b/packages/core/core-flows/src/order/workflows/claim/remove-claim-add-item-action.ts @@ -22,7 +22,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that new items can be removed from a claim. + */ +export const removeClaimAddItemActionValidationStep = createStep( "remove-item-claim-add-action-validation", async function ({ order, @@ -54,6 +57,9 @@ const validationStep = createStep( ) export const removeAddItemClaimActionWorkflowId = "remove-item-claim-add-action" +/** + * This workflow removes new items from a claim. + */ export const removeAddItemClaimActionWorkflow = createWorkflow( removeAddItemClaimActionWorkflowId, function ( @@ -88,7 +94,7 @@ export const removeAddItemClaimActionWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, input, orderClaim, orderChange }) + removeClaimAddItemActionValidationStep({ order, input, orderClaim, orderChange }) deleteOrderChangeActionsStep({ ids: [input.action_id] }) diff --git a/packages/core/core-flows/src/order/workflows/claim/remove-claim-item-action.ts b/packages/core/core-flows/src/order/workflows/claim/remove-claim-item-action.ts index 64cb5d9ffe..7432ab80b8 100644 --- a/packages/core/core-flows/src/order/workflows/claim/remove-claim-item-action.ts +++ b/packages/core/core-flows/src/order/workflows/claim/remove-claim-item-action.ts @@ -22,7 +22,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step confirms that a claim's items can be removed. + */ +export const removeClaimItemActionValidationStep = createStep( "remove-item-claim-action-validation", async function ({ order, @@ -54,6 +57,9 @@ const validationStep = createStep( ) export const removeItemClaimActionWorkflowId = "remove-item-claim-action" +/** + * This workflow removes claim items. + */ export const removeItemClaimActionWorkflow = createWorkflow( removeItemClaimActionWorkflowId, function ( @@ -88,7 +94,7 @@ export const removeItemClaimActionWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, input, orderClaim, orderChange }) + removeClaimItemActionValidationStep({ order, input, orderClaim, orderChange }) deleteOrderChangeActionsStep({ ids: [input.action_id] }) diff --git a/packages/core/core-flows/src/order/workflows/claim/remove-claim-shipping-method.ts b/packages/core/core-flows/src/order/workflows/claim/remove-claim-shipping-method.ts index 36befa2226..5658e0a5dd 100644 --- a/packages/core/core-flows/src/order/workflows/claim/remove-claim-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/claim/remove-claim-shipping-method.ts @@ -23,7 +23,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that a claim's shipping method can be removed. + */ +export const removeClaimShippingMethodValidationStep = createStep( "validate-remove-claim-shipping-method", async function ({ orderChange, @@ -55,6 +58,9 @@ const validationStep = createStep( export const removeClaimShippingMethodWorkflowId = "remove-claim-shipping-method" +/** + * This workflow removes the shipping method of a claim. + */ export const removeClaimShippingMethodWorkflow = createWorkflow( removeClaimShippingMethodWorkflowId, function ( @@ -81,7 +87,7 @@ export const removeClaimShippingMethodWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ orderClaim, orderChange, input }) + removeClaimShippingMethodValidationStep({ orderClaim, orderChange, input }) const dataToRemove = transform( { orderChange, input }, diff --git a/packages/core/core-flows/src/order/workflows/claim/update-claim-add-item.ts b/packages/core/core-flows/src/order/workflows/claim/update-claim-add-item.ts index da71fc95f1..0fef60d07c 100644 --- a/packages/core/core-flows/src/order/workflows/claim/update-claim-add-item.ts +++ b/packages/core/core-flows/src/order/workflows/claim/update-claim-add-item.ts @@ -23,7 +23,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that a claim's new item can be updated. + */ +export const updateClaimAddItemValidationStep = createStep( "update-claim-add-item-validation", async function ( { @@ -58,6 +61,9 @@ const validationStep = createStep( ) export const updateClaimAddItemWorkflowId = "update-claim-add-item" +/** + * This workflow updates a claim's new item. + */ export const updateClaimAddItemWorkflow = createWorkflow( updateClaimAddItemWorkflowId, function ( @@ -92,7 +98,7 @@ export const updateClaimAddItemWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, input, orderClaim, orderChange }) + updateClaimAddItemValidationStep({ order, input, orderClaim, orderChange }) const updateData = transform( { orderChange, input }, diff --git a/packages/core/core-flows/src/order/workflows/claim/update-claim-item.ts b/packages/core/core-flows/src/order/workflows/claim/update-claim-item.ts index 0fe5d79051..fd96189222 100644 --- a/packages/core/core-flows/src/order/workflows/claim/update-claim-item.ts +++ b/packages/core/core-flows/src/order/workflows/claim/update-claim-item.ts @@ -23,7 +23,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that a claim's item can be updated. + */ +export const updateClaimItemValidationStep = createStep( "update-claim-item-validation", async function ( { @@ -58,6 +61,9 @@ const validationStep = createStep( ) export const updateClaimItemWorkflowId = "update-claim-item" +/** + * This workflow updates a claim item. + */ export const updateClaimItemWorkflow = createWorkflow( updateClaimItemWorkflowId, function ( @@ -92,7 +98,7 @@ export const updateClaimItemWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, input, orderClaim, orderChange }) + updateClaimItemValidationStep({ order, input, orderClaim, orderChange }) const updateData = transform( { orderChange, input }, diff --git a/packages/core/core-flows/src/order/workflows/claim/update-claim-shipping-method.ts b/packages/core/core-flows/src/order/workflows/claim/update-claim-shipping-method.ts index c4b07d5cb7..7406ca2e34 100644 --- a/packages/core/core-flows/src/order/workflows/claim/update-claim-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/claim/update-claim-shipping-method.ts @@ -25,7 +25,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that a claim's shipping method can be updated. + */ +export const updateClaimShippingMethodValidationStep = createStep( "validate-update-claim-shipping-method", async function ({ orderChange, @@ -57,6 +60,9 @@ const validationStep = createStep( export const updateClaimShippingMethodWorkflowId = "update-claim-shipping-method" +/** + * This workflow updates a claim's shipping method. + */ export const updateClaimShippingMethodWorkflow = createWorkflow( updateClaimShippingMethodWorkflowId, function ( @@ -83,7 +89,7 @@ export const updateClaimShippingMethodWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ orderClaim, orderChange, input }) + updateClaimShippingMethodValidationStep({ orderClaim, orderChange, input }) const updateData = transform( { orderChange, input }, diff --git a/packages/core/core-flows/src/order/workflows/exchange/begin-order-exchange.ts b/packages/core/core-flows/src/order/workflows/exchange/begin-order-exchange.ts index 8990891ad7..7819bdc222 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/begin-order-exchange.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/begin-order-exchange.ts @@ -11,7 +11,10 @@ import { createOrderChangeStep } from "../../steps/create-order-change" import { createOrderExchangesStep } from "../../steps/exchange/create-exchange" import { throwIfOrderIsCancelled } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that an exchange can be requested for an order. + */ +export const beginOrderExchangeValidationStep = createStep( "begin-exchange-order-validation", async function ({ order }: { order: OrderDTO }) { throwIfOrderIsCancelled({ order }) @@ -19,6 +22,9 @@ const validationStep = createStep( ) export const beginExchangeOrderWorkflowId = "begin-exchange-order" +/** + * This workflow requests an order exchange. + */ export const beginExchangeOrderWorkflow = createWorkflow( beginExchangeOrderWorkflowId, function ( @@ -32,7 +38,7 @@ export const beginExchangeOrderWorkflow = createWorkflow( throw_if_key_not_found: true, }) - validationStep({ order }) + beginOrderExchangeValidationStep({ order }) const created = createOrderExchangesStep([ { diff --git a/packages/core/core-flows/src/order/workflows/exchange/cancel-begin-order-exchange.ts b/packages/core/core-flows/src/order/workflows/exchange/cancel-begin-order-exchange.ts index 1407d8c2f2..849d81de99 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/cancel-begin-order-exchange.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/cancel-begin-order-exchange.ts @@ -19,11 +19,14 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -type WorkflowInput = { +export type CancelBeginOrderExchangeWorkflowInput = { exchange_id: string } -const validationStep = createStep( +/** + * This step validates that a requested exchange can be canceled. + */ +export const cancelBeginOrderExchangeValidationStep = createStep( "validate-cancel-begin-order-exchange", async function ({ order, @@ -41,9 +44,12 @@ const validationStep = createStep( ) export const cancelBeginOrderExchangeWorkflowId = "cancel-begin-order-exchange" +/** + * This workflow cancels a requested order exchange. + */ export const cancelBeginOrderExchangeWorkflow = createWorkflow( cancelBeginOrderExchangeWorkflowId, - function (input: WorkflowInput): WorkflowData { + function (input: CancelBeginOrderExchangeWorkflowInput): WorkflowData { const orderExchange: OrderExchangeDTO = useRemoteQueryStep({ entry_point: "order_exchange", fields: ["id", "status", "order_id", "return_id", "canceled_at"], @@ -73,7 +79,7 @@ export const cancelBeginOrderExchangeWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, orderExchange, orderChange }) + cancelBeginOrderExchangeValidationStep({ order, orderExchange, orderChange }) const shippingToRemove = transform( { orderChange, input }, diff --git a/packages/core/core-flows/src/order/workflows/exchange/cancel-exchange.ts b/packages/core/core-flows/src/order/workflows/exchange/cancel-exchange.ts index 515a9c7f92..49a62ecc46 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/cancel-exchange.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/cancel-exchange.ts @@ -18,7 +18,10 @@ import { cancelOrderExchangeStep } from "../../steps" import { throwIfIsCancelled } from "../../utils/order-validation" import { cancelReturnWorkflow } from "../return/cancel-return" -const validateOrder = createStep( +/** + * This step validates that an exchange can be canceled. + */ +export const cancelExchangeValidateOrder = createStep( "validate-exchange", ({ orderExchange, @@ -53,6 +56,9 @@ const validateOrder = createStep( ) export const cancelOrderExchangeWorkflowId = "cancel-exchange" +/** + * This workflow cancels a confirmed exchange. + */ export const cancelOrderExchangeWorkflow = createWorkflow( cancelOrderExchangeWorkflowId, ( @@ -74,7 +80,7 @@ export const cancelOrderExchangeWorkflow = createWorkflow( throw_if_key_not_found: true, }) - validateOrder({ orderExchange, input }) + cancelExchangeValidateOrder({ orderExchange, input }) const lineItemIds = transform({ orderExchange }, ({ orderExchange }) => { return orderExchange.additional_items?.map((i) => i.item_id) diff --git a/packages/core/core-flows/src/order/workflows/exchange/confirm-exchange-request.ts b/packages/core/core-flows/src/order/workflows/exchange/confirm-exchange-request.ts index 42b6d2f37e..0eae43d5c4 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/confirm-exchange-request.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/confirm-exchange-request.ts @@ -27,11 +27,14 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -type WorkflowInput = { +export type ConfirmExchangeRequestWorkflowInput = { exchange_id: string } -const validationStep = createStep( +/** + * This step validates that a requested exchange can be confirmed. + */ +export const confirmExchangeRequestValidationStep = createStep( "validate-confirm-exchange-request", async function ({ order, @@ -165,9 +168,12 @@ function extractShippingOption({ orderPreview, orderExchange, returnId }) { } export const confirmExchangeRequestWorkflowId = "confirm-exchange-request" +/** + * This workflow confirms an exchange request. + */ export const confirmExchangeRequestWorkflow = createWorkflow( confirmExchangeRequestWorkflowId, - function (input: WorkflowInput): WorkflowResponse { + function (input: ConfirmExchangeRequestWorkflowInput): WorkflowResponse { const orderExchange: OrderExchangeDTO = useRemoteQueryStep({ entry_point: "order_exchange", fields: ["id", "status", "order_id", "canceled_at"], @@ -217,7 +223,7 @@ export const confirmExchangeRequestWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, orderExchange, orderChange }) + confirmExchangeRequestValidationStep({ order, orderExchange, orderChange }) const { exchangeItems, returnItems } = transform( { orderChange }, diff --git a/packages/core/core-flows/src/order/workflows/exchange/create-exchange-shipping-method.ts b/packages/core/core-flows/src/order/workflows/exchange/create-exchange-shipping-method.ts index 78e95b08ff..fea6e30957 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/create-exchange-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/create-exchange-shipping-method.ts @@ -20,7 +20,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that a shipping method can be created for an exchange. + */ +export const createExchangeShippingMethodValidationStep = createStep( "validate-create-exchange-shipping-method", async function ({ order, @@ -39,6 +42,9 @@ const validationStep = createStep( export const createExchangeShippingMethodWorkflowId = "create-exchange-shipping-method" +/** + * This workflow creates a shipping method for an exchange. + */ export const createExchangeShippingMethodWorkflow = createWorkflow( createExchangeShippingMethodWorkflowId, function (input: { @@ -92,7 +98,7 @@ export const createExchangeShippingMethodWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, orderExchange, orderChange }) + createExchangeShippingMethodValidationStep({ order, orderExchange, orderChange }) const shippingMethodInput = transform( { diff --git a/packages/core/core-flows/src/order/workflows/exchange/exchange-add-new-item.ts b/packages/core/core-flows/src/order/workflows/exchange/exchange-add-new-item.ts index 0a90f58d73..ea9df232d2 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/exchange-add-new-item.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/exchange-add-new-item.ts @@ -21,7 +21,10 @@ import { } from "../../utils/order-validation" import { addOrderLineItemsWorkflow } from "../add-line-items" -const validationStep = createStep( +/** + * This step validates that new items can be added to an exchange. + */ +export const exchangeAddNewItemValidationStep = createStep( "exchange-add-new-item-validation", async function ({ order, @@ -39,6 +42,9 @@ const validationStep = createStep( ) export const orderExchangeAddNewItemWorkflowId = "exchange-add-new-item" +/** + * This workflow adds new items to an exchange. + */ export const orderExchangeAddNewItemWorkflow = createWorkflow( orderExchangeAddNewItemWorkflowId, function ( @@ -73,7 +79,7 @@ export const orderExchangeAddNewItemWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ + exchangeAddNewItemValidationStep({ order, orderExchange, orderChange, diff --git a/packages/core/core-flows/src/order/workflows/exchange/exchange-request-item-return.ts b/packages/core/core-flows/src/order/workflows/exchange/exchange-request-item-return.ts index ce720e8509..4fb9eb2680 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/exchange-request-item-return.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/exchange-request-item-return.ts @@ -25,7 +25,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that items can be returned as part of an exchange. + */ +export const exchangeRequestItemReturnValidationStep = createStep( "exchange-request-item-return-validation", async function ({ order, @@ -50,6 +53,9 @@ const validationStep = createStep( export const orderExchangeRequestItemReturnWorkflowId = "exchange-request-item-return" +/** + * This workflow adds items to be retuned as part of the exchange. + */ export const orderExchangeRequestItemReturnWorkflow = createWorkflow( orderExchangeRequestItemReturnWorkflowId, function ( @@ -117,7 +123,7 @@ export const orderExchangeRequestItemReturnWorkflow = createWorkflow( status: [OrderChangeStatus.PENDING, OrderChangeStatus.REQUESTED], }) - validationStep({ + exchangeRequestItemReturnValidationStep({ order, items: input.items, orderExchange, diff --git a/packages/core/core-flows/src/order/workflows/exchange/remove-exchange-item-action.ts b/packages/core/core-flows/src/order/workflows/exchange/remove-exchange-item-action.ts index 027ef3c2b4..fce5c73387 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/remove-exchange-item-action.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/remove-exchange-item-action.ts @@ -22,7 +22,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that a new item can be removed from an exchange. + */ +export const removeExchangeItemActionValidationStep = createStep( "remove-item-exchange-action-validation", async function ({ order, @@ -54,6 +57,9 @@ const validationStep = createStep( ) export const removeItemExchangeActionWorkflowId = "remove-item-exchange-action" +/** + * This workflow removes a new item in an exchange. + */ export const removeItemExchangeActionWorkflow = createWorkflow( removeItemExchangeActionWorkflowId, function ( @@ -88,7 +94,7 @@ export const removeItemExchangeActionWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, input, orderExchange, orderChange }) + removeExchangeItemActionValidationStep({ order, input, orderExchange, orderChange }) deleteOrderChangeActionsStep({ ids: [input.action_id] }) diff --git a/packages/core/core-flows/src/order/workflows/exchange/remove-exchange-shipping-method.ts b/packages/core/core-flows/src/order/workflows/exchange/remove-exchange-shipping-method.ts index 0c92221a40..6039a9445d 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/remove-exchange-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/remove-exchange-shipping-method.ts @@ -23,7 +23,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that a shipping method can be removed from an exchange. + */ +export const removeExchangeShippingMethodValidationStep = createStep( "validate-remove-exchange-shipping-method", async function ({ orderChange, @@ -55,6 +58,9 @@ const validationStep = createStep( export const removeExchangeShippingMethodWorkflowId = "remove-exchange-shipping-method" +/** + * This workflow removes a shipping method of an exchange. + */ export const removeExchangeShippingMethodWorkflow = createWorkflow( removeExchangeShippingMethodWorkflowId, function ( @@ -81,7 +87,7 @@ export const removeExchangeShippingMethodWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ orderExchange, orderChange, input }) + removeExchangeShippingMethodValidationStep({ orderExchange, orderChange, input }) const dataToRemove = transform( { orderChange, input }, diff --git a/packages/core/core-flows/src/order/workflows/exchange/update-exchange-add-item.ts b/packages/core/core-flows/src/order/workflows/exchange/update-exchange-add-item.ts index c6c93e45e9..6f9571d536 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/update-exchange-add-item.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/update-exchange-add-item.ts @@ -23,7 +23,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that a new item can be removed from an exchange. + */ +export const updateExchangeAddItemValidationStep = createStep( "update-exchange-add-item-validation", async function ( { @@ -58,6 +61,9 @@ const validationStep = createStep( ) export const updateExchangeAddItemWorkflowId = "update-exchange-add-item" +/** + * This workflow updates a new item in the exchange. + */ export const updateExchangeAddItemWorkflow = createWorkflow( updateExchangeAddItemWorkflowId, function ( @@ -92,7 +98,7 @@ export const updateExchangeAddItemWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ order, input, orderExchange, orderChange }) + updateExchangeAddItemValidationStep({ order, input, orderExchange, orderChange }) const updateData = transform( { orderChange, input }, diff --git a/packages/core/core-flows/src/order/workflows/exchange/update-exchange-shipping-method.ts b/packages/core/core-flows/src/order/workflows/exchange/update-exchange-shipping-method.ts index 9e19551337..44a2379466 100644 --- a/packages/core/core-flows/src/order/workflows/exchange/update-exchange-shipping-method.ts +++ b/packages/core/core-flows/src/order/workflows/exchange/update-exchange-shipping-method.ts @@ -25,7 +25,10 @@ import { throwIfOrderChangeIsNotActive, } from "../../utils/order-validation" -const validationStep = createStep( +/** + * This step validates that an exchange's shipping method can be updated. + */ +export const updateExchangeShippingMethodValidationStep = createStep( "validate-update-exchange-shipping-method", async function ({ orderChange, @@ -57,6 +60,9 @@ const validationStep = createStep( export const updateExchangeShippingMethodWorkflowId = "update-exchange-shipping-method" +/** + * This workflow updates an exchange's shipping method. + */ export const updateExchangeShippingMethodWorkflow = createWorkflow( updateExchangeShippingMethodWorkflowId, function ( @@ -83,7 +89,7 @@ export const updateExchangeShippingMethodWorkflow = createWorkflow( list: false, }).config({ name: "order-change-query" }) - validationStep({ orderExchange, orderChange, input }) + updateExchangeShippingMethodValidationStep({ orderExchange, orderChange, input }) const updateData = transform( { orderChange, input },