chore(core-flows): [2] export types and types, add basic TSDocs (#8505)
This PR exports types and steps from the core-flows package, and adds simple TSDocs for workflows / steps. This is essential for the workflows reference. PR 2/n
This commit is contained in:
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
|||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
export const createCustomerGroupsStepId = "create-customer-groups"
|
export const createCustomerGroupsStepId = "create-customer-groups"
|
||||||
|
/**
|
||||||
|
* This step creates one or more customer groups.
|
||||||
|
*/
|
||||||
export const createCustomerGroupsStep = createStep(
|
export const createCustomerGroupsStep = createStep(
|
||||||
createCustomerGroupsStepId,
|
createCustomerGroupsStepId,
|
||||||
async (data: CreateCustomerGroupDTO[], { container }) => {
|
async (data: CreateCustomerGroupDTO[], { container }) => {
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|||||||
|
|
||||||
export const deleteCustomerGroupCustomersStepId =
|
export const deleteCustomerGroupCustomersStepId =
|
||||||
"delete-customer-group-customers"
|
"delete-customer-group-customers"
|
||||||
|
/**
|
||||||
|
* This step removes customers from groups.
|
||||||
|
*/
|
||||||
export const deleteCustomerGroupCustomersStep = createStep(
|
export const deleteCustomerGroupCustomersStep = createStep(
|
||||||
deleteCustomerGroupCustomersStepId,
|
deleteCustomerGroupCustomersStepId,
|
||||||
async (data: GroupCustomerPair[], { container }) => {
|
async (data: GroupCustomerPair[], { container }) => {
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ import { ICustomerModuleService } from "@medusajs/types"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
type DeleteCustomerGroupStepInput = string[]
|
|
||||||
|
|
||||||
export const deleteCustomerGroupStepId = "delete-customer-groups"
|
export const deleteCustomerGroupStepId = "delete-customer-groups"
|
||||||
|
/**
|
||||||
|
* This step deletes one or more customer groups.
|
||||||
|
*/
|
||||||
export const deleteCustomerGroupStep = createStep(
|
export const deleteCustomerGroupStep = createStep(
|
||||||
deleteCustomerGroupStepId,
|
deleteCustomerGroupStepId,
|
||||||
async (ids: DeleteCustomerGroupStepInput, { container }) => {
|
async (ids: string[], { container }) => {
|
||||||
const service = container.resolve<ICustomerModuleService>(
|
const service = container.resolve<ICustomerModuleService>(
|
||||||
ModuleRegistrationName.CUSTOMER
|
ModuleRegistrationName.CUSTOMER
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|||||||
|
|
||||||
export const linkCustomersToCustomerGroupStepId =
|
export const linkCustomersToCustomerGroupStepId =
|
||||||
"link-customers-to-customer-group"
|
"link-customers-to-customer-group"
|
||||||
|
/**
|
||||||
|
* This step creates one or more links between customer and customer group records.
|
||||||
|
*/
|
||||||
export const linkCustomersToCustomerGroupStep = createStep(
|
export const linkCustomersToCustomerGroupStep = createStep(
|
||||||
linkCustomersToCustomerGroupStepId,
|
linkCustomersToCustomerGroupStepId,
|
||||||
async (data: LinkWorkflowInput, { container }) => {
|
async (data: LinkWorkflowInput, { container }) => {
|
||||||
|
|||||||
@@ -10,12 +10,15 @@ import {
|
|||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
type UpdateCustomerGroupStepInput = {
|
export type UpdateCustomerGroupStepInput = {
|
||||||
selector: FilterableCustomerGroupProps
|
selector: FilterableCustomerGroupProps
|
||||||
update: CustomerGroupUpdatableFields
|
update: CustomerGroupUpdatableFields
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateCustomerGroupStepId = "update-customer-groups"
|
export const updateCustomerGroupStepId = "update-customer-groups"
|
||||||
|
/**
|
||||||
|
* This step updates one or more customer groups.
|
||||||
|
*/
|
||||||
export const updateCustomerGroupsStep = createStep(
|
export const updateCustomerGroupsStep = createStep(
|
||||||
updateCustomerGroupStepId,
|
updateCustomerGroupStepId,
|
||||||
async (data: UpdateCustomerGroupStepInput, { container }) => {
|
async (data: UpdateCustomerGroupStepInput, { container }) => {
|
||||||
|
|||||||
@@ -6,13 +6,16 @@ import {
|
|||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { createCustomerGroupsStep } from "../steps"
|
import { createCustomerGroupsStep } from "../steps"
|
||||||
|
|
||||||
type WorkflowInput = { customersData: CreateCustomerGroupDTO[] }
|
export type CreateCustomerGroupsWorkflowInput = { customersData: CreateCustomerGroupDTO[] }
|
||||||
|
|
||||||
export const createCustomerGroupsWorkflowId = "create-customer-groups"
|
export const createCustomerGroupsWorkflowId = "create-customer-groups"
|
||||||
|
/**
|
||||||
|
* This workflow creates one or more customer groups.
|
||||||
|
*/
|
||||||
export const createCustomerGroupsWorkflow = createWorkflow(
|
export const createCustomerGroupsWorkflow = createWorkflow(
|
||||||
createCustomerGroupsWorkflowId,
|
createCustomerGroupsWorkflowId,
|
||||||
(
|
(
|
||||||
input: WorkflowData<WorkflowInput>
|
input: WorkflowData<CreateCustomerGroupsWorkflowInput>
|
||||||
): WorkflowResponse<CustomerGroupDTO[]> => {
|
): WorkflowResponse<CustomerGroupDTO[]> => {
|
||||||
return new WorkflowResponse(createCustomerGroupsStep(input.customersData))
|
return new WorkflowResponse(createCustomerGroupsStep(input.customersData))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||||
import { deleteCustomerGroupStep } from "../steps"
|
import { deleteCustomerGroupStep } from "../steps"
|
||||||
|
|
||||||
type WorkflowInput = { ids: string[] }
|
export type DeleteCustomerGroupsWorkflowInput = { ids: string[] }
|
||||||
|
|
||||||
export const deleteCustomerGroupsWorkflowId = "delete-customer-groups"
|
export const deleteCustomerGroupsWorkflowId = "delete-customer-groups"
|
||||||
|
/**
|
||||||
|
* This workflow deletes one or more customer groups.
|
||||||
|
*/
|
||||||
export const deleteCustomerGroupsWorkflow = createWorkflow(
|
export const deleteCustomerGroupsWorkflow = createWorkflow(
|
||||||
deleteCustomerGroupsWorkflowId,
|
deleteCustomerGroupsWorkflowId,
|
||||||
(input: WorkflowData<WorkflowInput>): WorkflowData<void> => {
|
(input: WorkflowData<DeleteCustomerGroupsWorkflowInput>): WorkflowData<void> => {
|
||||||
return deleteCustomerGroupStep(input.ids)
|
return deleteCustomerGroupStep(input.ids)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { linkCustomersToCustomerGroupStep } from "../steps"
|
|||||||
|
|
||||||
export const linkCustomersToCustomerGroupWorkflowId =
|
export const linkCustomersToCustomerGroupWorkflowId =
|
||||||
"link-customers-to-customer-group"
|
"link-customers-to-customer-group"
|
||||||
|
/**
|
||||||
|
* This workflow creates one or more links between customer and customer group records.
|
||||||
|
*/
|
||||||
export const linkCustomersToCustomerGroupWorkflow = createWorkflow(
|
export const linkCustomersToCustomerGroupWorkflow = createWorkflow(
|
||||||
linkCustomersToCustomerGroupWorkflowId,
|
linkCustomersToCustomerGroupWorkflowId,
|
||||||
(input: WorkflowData<LinkWorkflowInput>): WorkflowData<void> => {
|
(input: WorkflowData<LinkWorkflowInput>): WorkflowData<void> => {
|
||||||
|
|||||||
@@ -10,16 +10,19 @@ import {
|
|||||||
} from "@medusajs/workflows-sdk"
|
} from "@medusajs/workflows-sdk"
|
||||||
import { updateCustomerGroupsStep } from "../steps"
|
import { updateCustomerGroupsStep } from "../steps"
|
||||||
|
|
||||||
type WorkflowInput = {
|
export type UpdateCustomerGroupsWorkflowInput = {
|
||||||
selector: FilterableCustomerGroupProps
|
selector: FilterableCustomerGroupProps
|
||||||
update: CustomerGroupUpdatableFields
|
update: CustomerGroupUpdatableFields
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateCustomerGroupsWorkflowId = "update-customer-groups"
|
export const updateCustomerGroupsWorkflowId = "update-customer-groups"
|
||||||
|
/**
|
||||||
|
* This workflow updates one or more customer groups.
|
||||||
|
*/
|
||||||
export const updateCustomerGroupsWorkflow = createWorkflow(
|
export const updateCustomerGroupsWorkflow = createWorkflow(
|
||||||
updateCustomerGroupsWorkflowId,
|
updateCustomerGroupsWorkflowId,
|
||||||
(
|
(
|
||||||
input: WorkflowData<WorkflowInput>
|
input: WorkflowData<UpdateCustomerGroupsWorkflowInput>
|
||||||
): WorkflowResponse<CustomerGroupDTO[]> => {
|
): WorkflowResponse<CustomerGroupDTO[]> => {
|
||||||
return new WorkflowResponse(updateCustomerGroupsStep(input))
|
return new WorkflowResponse(updateCustomerGroupsStep(input))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ type CreateDefaultStoreStepInput = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const createDefaultStoreStepId = "create-default-store"
|
export const createDefaultStoreStepId = "create-default-store"
|
||||||
|
/**
|
||||||
|
* This step creates a default store.
|
||||||
|
*/
|
||||||
export const createDefaultStoreStep = createStep(
|
export const createDefaultStoreStep = createStep(
|
||||||
createDefaultStoreStepId,
|
createDefaultStoreStepId,
|
||||||
async (data: CreateDefaultStoreStepInput, { container }) => {
|
async (data: CreateDefaultStoreStepInput, { container }) => {
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import { createDefaultSalesChannelStep } from "../../sales-channel"
|
|||||||
import { createDefaultStoreStep } from "../steps/create-default-store"
|
import { createDefaultStoreStep } from "../steps/create-default-store"
|
||||||
|
|
||||||
export const createDefaultsWorkflowID = "create-defaults"
|
export const createDefaultsWorkflowID = "create-defaults"
|
||||||
|
/**
|
||||||
|
* This workflow creates default data for a Medusa application.
|
||||||
|
*/
|
||||||
export const createDefaultsWorkflow = createWorkflow(
|
export const createDefaultsWorkflow = createWorkflow(
|
||||||
createDefaultsWorkflowID,
|
createDefaultsWorkflowID,
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
@@ -2,14 +2,17 @@ import { CreateShippingMethodDTO, ICartModuleService } from "@medusajs/types"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
export interface AddShippingMethodToCartStepInput {
|
||||||
shipping_methods: CreateShippingMethodDTO[]
|
shipping_methods: CreateShippingMethodDTO[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addShippingMethodToCartStepId = "add-shipping-method-to-cart-step"
|
export const addShippingMethodToCartStepId = "add-shipping-method-to-cart-step"
|
||||||
|
/**
|
||||||
|
* This step adds shipping methods to a cart.
|
||||||
|
*/
|
||||||
export const addShippingMethodToCartStep = createStep(
|
export const addShippingMethodToCartStep = createStep(
|
||||||
addShippingMethodToCartStepId,
|
addShippingMethodToCartStepId,
|
||||||
async (data: StepInput, { container }) => {
|
async (data: AddShippingMethodToCartStepInput, { container }) => {
|
||||||
const cartService = container.resolve<ICartModuleService>(
|
const cartService = container.resolve<ICartModuleService>(
|
||||||
ModuleRegistrationName.CART
|
ModuleRegistrationName.CART
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
} from "@medusajs/utils"
|
} from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
export interface ConfirmVariantInventoryStepInput {
|
||||||
items: {
|
items: {
|
||||||
inventory_item_id: string
|
inventory_item_id: string
|
||||||
required_quantity: number
|
required_quantity: number
|
||||||
@@ -18,9 +18,12 @@ interface StepInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const confirmInventoryStepId = "confirm-inventory-step"
|
export const confirmInventoryStepId = "confirm-inventory-step"
|
||||||
|
/**
|
||||||
|
* This step confirms for one or more variants that their inventory has a required quantity.
|
||||||
|
*/
|
||||||
export const confirmInventoryStep = createStep(
|
export const confirmInventoryStep = createStep(
|
||||||
confirmInventoryStepId,
|
confirmInventoryStepId,
|
||||||
async (data: StepInput, { container }) => {
|
async (data: ConfirmVariantInventoryStepInput, { container }) => {
|
||||||
const inventoryService = container.resolve<IInventoryService>(
|
const inventoryService = container.resolve<IInventoryService>(
|
||||||
ModuleRegistrationName.INVENTORY
|
ModuleRegistrationName.INVENTORY
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
|||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
export const createCartsStepId = "create-carts"
|
export const createCartsStepId = "create-carts"
|
||||||
|
/**
|
||||||
|
* This step creates a cart.
|
||||||
|
*/
|
||||||
export const createCartsStep = createStep(
|
export const createCartsStep = createStep(
|
||||||
createCartsStepId,
|
createCartsStepId,
|
||||||
async (data: CreateCartDTO[], { container }) => {
|
async (data: CreateCartDTO[], { container }) => {
|
||||||
|
|||||||
@@ -5,14 +5,17 @@ import {
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
export interface CreateLineItemAdjustmentsCartStepInput {
|
||||||
lineItemAdjustmentsToCreate: CreateLineItemAdjustmentDTO[]
|
lineItemAdjustmentsToCreate: CreateLineItemAdjustmentDTO[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createLineItemAdjustmentsStepId = "create-line-item-adjustments"
|
export const createLineItemAdjustmentsStepId = "create-line-item-adjustments"
|
||||||
|
/**
|
||||||
|
* This step creates line item adjustments in a cart.
|
||||||
|
*/
|
||||||
export const createLineItemAdjustmentsStep = createStep(
|
export const createLineItemAdjustmentsStep = createStep(
|
||||||
createLineItemAdjustmentsStepId,
|
createLineItemAdjustmentsStepId,
|
||||||
async (data: StepInput, { container }) => {
|
async (data: CreateLineItemAdjustmentsCartStepInput, { container }) => {
|
||||||
const { lineItemAdjustmentsToCreate = [] } = data
|
const { lineItemAdjustmentsToCreate = [] } = data
|
||||||
const cartModuleService: ICartModuleService = container.resolve(
|
const cartModuleService: ICartModuleService = container.resolve(
|
||||||
ModuleRegistrationName.CART
|
ModuleRegistrationName.CART
|
||||||
|
|||||||
@@ -2,15 +2,18 @@ import { CreateLineItemForCartDTO, ICartModuleService } from "@medusajs/types"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
export interface CreateLineItemsCartStepInput {
|
||||||
id: string
|
id: string
|
||||||
items: CreateLineItemForCartDTO[]
|
items: CreateLineItemForCartDTO[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createLineItemsStepId = "create-line-items-step"
|
export const createLineItemsStepId = "create-line-items-step"
|
||||||
|
/**
|
||||||
|
* This step creates line item in a cart.
|
||||||
|
*/
|
||||||
export const createLineItemsStep = createStep(
|
export const createLineItemsStep = createStep(
|
||||||
createLineItemsStepId,
|
createLineItemsStepId,
|
||||||
async (data: StepInput, { container }) => {
|
async (data: CreateLineItemsCartStepInput, { container }) => {
|
||||||
const cartModule = container.resolve<ICartModuleService>(
|
const cartModule = container.resolve<ICartModuleService>(
|
||||||
ModuleRegistrationName.CART
|
ModuleRegistrationName.CART
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { BigNumberInput, IPaymentModuleService } from "@medusajs/types"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
type StepInput = {
|
export type CreatePaymentCollectionCartStepInput = {
|
||||||
region_id: string
|
region_id: string
|
||||||
currency_code: string
|
currency_code: string
|
||||||
amount: BigNumberInput
|
amount: BigNumberInput
|
||||||
@@ -10,9 +10,12 @@ type StepInput = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const createPaymentCollectionsStepId = "create-payment-collections"
|
export const createPaymentCollectionsStepId = "create-payment-collections"
|
||||||
|
/**
|
||||||
|
* This step creates payment collections in a cart.
|
||||||
|
*/
|
||||||
export const createPaymentCollectionsStep = createStep(
|
export const createPaymentCollectionsStep = createStep(
|
||||||
createPaymentCollectionsStepId,
|
createPaymentCollectionsStepId,
|
||||||
async (data: StepInput[], { container }) => {
|
async (data: CreatePaymentCollectionCartStepInput[], { container }) => {
|
||||||
const service = container.resolve<IPaymentModuleService>(
|
const service = container.resolve<IPaymentModuleService>(
|
||||||
ModuleRegistrationName.PAYMENT
|
ModuleRegistrationName.PAYMENT
|
||||||
)
|
)
|
||||||
|
|||||||
+5
-2
@@ -5,15 +5,18 @@ import {
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
interface StepInput {
|
export interface CreateShippingMethodAdjustmentsStepInput {
|
||||||
shippingMethodAdjustmentsToCreate: CreateShippingMethodAdjustmentDTO[]
|
shippingMethodAdjustmentsToCreate: CreateShippingMethodAdjustmentDTO[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createShippingMethodAdjustmentsStepId =
|
export const createShippingMethodAdjustmentsStepId =
|
||||||
"create-shipping-method-adjustments"
|
"create-shipping-method-adjustments"
|
||||||
|
/**
|
||||||
|
* This step creates shipping method adjustments for a cart.
|
||||||
|
*/
|
||||||
export const createShippingMethodAdjustmentsStep = createStep(
|
export const createShippingMethodAdjustmentsStep = createStep(
|
||||||
createShippingMethodAdjustmentsStepId,
|
createShippingMethodAdjustmentsStepId,
|
||||||
async (data: StepInput, { container }) => {
|
async (data: CreateShippingMethodAdjustmentsStepInput, { container }) => {
|
||||||
const { shippingMethodAdjustmentsToCreate = [] } = data
|
const { shippingMethodAdjustmentsToCreate = [] } = data
|
||||||
const cartModuleService: ICartModuleService = container.resolve(
|
const cartModuleService: ICartModuleService = container.resolve(
|
||||||
ModuleRegistrationName.CART
|
ModuleRegistrationName.CART
|
||||||
|
|||||||
+4
-1
@@ -13,7 +13,7 @@ import { refreshCartPromotionsStep } from "../steps/refresh-cart-promotions"
|
|||||||
import { updateTaxLinesStep } from "../steps/update-tax-lines"
|
import { updateTaxLinesStep } from "../steps/update-tax-lines"
|
||||||
import { cartFieldsForRefreshSteps } from "../utils/fields"
|
import { cartFieldsForRefreshSteps } from "../utils/fields"
|
||||||
|
|
||||||
interface AddShippingMethodToCartWorkflowInput {
|
export interface AddShippingMethodToCartWorkflowInput {
|
||||||
cart_id: string
|
cart_id: string
|
||||||
options: {
|
options: {
|
||||||
id: string
|
id: string
|
||||||
@@ -22,6 +22,9 @@ interface AddShippingMethodToCartWorkflowInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const addShippingMethodToCartWorkflowId = "add-shipping-method-to-cart"
|
export const addShippingMethodToCartWorkflowId = "add-shipping-method-to-cart"
|
||||||
|
/**
|
||||||
|
* This workflow adds shipping methods to a cart.
|
||||||
|
*/
|
||||||
export const addShippingMethodToWorkflow = createWorkflow(
|
export const addShippingMethodToWorkflow = createWorkflow(
|
||||||
addShippingMethodToCartWorkflowId,
|
addShippingMethodToCartWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ import { confirmVariantInventoryWorkflow } from "./confirm-variant-inventory"
|
|||||||
import { refreshPaymentCollectionForCartWorkflow } from "./refresh-payment-collection"
|
import { refreshPaymentCollectionForCartWorkflow } from "./refresh-payment-collection"
|
||||||
|
|
||||||
export const addToCartWorkflowId = "add-to-cart"
|
export const addToCartWorkflowId = "add-to-cart"
|
||||||
|
/**
|
||||||
|
* This workflow adds items to a cart.
|
||||||
|
*/
|
||||||
export const addToCartWorkflow = createWorkflow(
|
export const addToCartWorkflow = createWorkflow(
|
||||||
addToCartWorkflowId,
|
addToCartWorkflowId,
|
||||||
(input: WorkflowData<AddToCartWorkflowInputDTO>) => {
|
(input: WorkflowData<AddToCartWorkflowInputDTO>) => {
|
||||||
|
|||||||
@@ -24,10 +24,17 @@ import {
|
|||||||
prepareTaxLinesData,
|
prepareTaxLinesData,
|
||||||
} from "../utils/prepare-line-item-data"
|
} from "../utils/prepare-line-item-data"
|
||||||
|
|
||||||
|
export type CompleteCartWorkflowInput = {
|
||||||
|
id: string
|
||||||
|
}
|
||||||
|
|
||||||
export const completeCartWorkflowId = "complete-cart"
|
export const completeCartWorkflowId = "complete-cart"
|
||||||
|
/**
|
||||||
|
* This workflow completes a cart.
|
||||||
|
*/
|
||||||
export const completeCartWorkflow = createWorkflow(
|
export const completeCartWorkflow = createWorkflow(
|
||||||
completeCartWorkflowId,
|
completeCartWorkflowId,
|
||||||
(input: WorkflowData<any>): WorkflowResponse<OrderDTO> => {
|
(input: WorkflowData<CompleteCartWorkflowInput>): WorkflowResponse<OrderDTO> => {
|
||||||
const cart = useRemoteQueryStep({
|
const cart = useRemoteQueryStep({
|
||||||
entry_point: "cart",
|
entry_point: "cart",
|
||||||
fields: completeCartFields,
|
fields: completeCartFields,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
import { confirmInventoryStep } from "../steps"
|
import { confirmInventoryStep } from "../steps"
|
||||||
import { prepareConfirmInventoryInput } from "../utils/prepare-confirm-inventory-input"
|
import { prepareConfirmInventoryInput } from "../utils/prepare-confirm-inventory-input"
|
||||||
|
|
||||||
interface Output {
|
export interface ConfirmVariantInventoryWorkflowOutput {
|
||||||
items: {
|
items: {
|
||||||
id?: string
|
id?: string
|
||||||
inventory_item_id: string
|
inventory_item_id: string
|
||||||
@@ -20,11 +20,14 @@ interface Output {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const confirmVariantInventoryWorkflowId = "confirm-item-inventory"
|
export const confirmVariantInventoryWorkflowId = "confirm-item-inventory"
|
||||||
|
/**
|
||||||
|
* This workflow confirms for one or more variants that their inventory has a required quantity.
|
||||||
|
*/
|
||||||
export const confirmVariantInventoryWorkflow = createWorkflow(
|
export const confirmVariantInventoryWorkflow = createWorkflow(
|
||||||
confirmVariantInventoryWorkflowId,
|
confirmVariantInventoryWorkflowId,
|
||||||
(
|
(
|
||||||
input: WorkflowData<ConfirmVariantInventoryWorkflowInputDTO>
|
input: WorkflowData<ConfirmVariantInventoryWorkflowInputDTO>
|
||||||
): WorkflowResponse<Output> => {
|
): WorkflowResponse<ConfirmVariantInventoryWorkflowOutput> => {
|
||||||
const confirmInventoryInput = transform(
|
const confirmInventoryInput = transform(
|
||||||
{ input },
|
{ input },
|
||||||
prepareConfirmInventoryInput
|
prepareConfirmInventoryInput
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ import { refreshPaymentCollectionForCartWorkflow } from "./refresh-payment-colle
|
|||||||
// - Refresh/delete shipping methods (fulfillment module)
|
// - Refresh/delete shipping methods (fulfillment module)
|
||||||
|
|
||||||
export const createCartWorkflowId = "create-cart"
|
export const createCartWorkflowId = "create-cart"
|
||||||
|
/**
|
||||||
|
* This workflow creates a cart.
|
||||||
|
*/
|
||||||
export const createCartWorkflow = createWorkflow(
|
export const createCartWorkflow = createWorkflow(
|
||||||
createCartWorkflowId,
|
createCartWorkflowId,
|
||||||
(input: WorkflowData<CreateCartWorkflowInputDTO & AdditionalData>) => {
|
(input: WorkflowData<CreateCartWorkflowInputDTO & AdditionalData>) => {
|
||||||
|
|||||||
+3
@@ -24,6 +24,9 @@ const validateExistingPaymentCollection = createStep(
|
|||||||
|
|
||||||
export const createPaymentCollectionForCartWorkflowId =
|
export const createPaymentCollectionForCartWorkflowId =
|
||||||
"create-payment-collection-for-cart"
|
"create-payment-collection-for-cart"
|
||||||
|
/**
|
||||||
|
* This workflow creates a payment collection for a cart.
|
||||||
|
*/
|
||||||
export const createPaymentCollectionForCartWorkflow = createWorkflow(
|
export const createPaymentCollectionForCartWorkflow = createWorkflow(
|
||||||
createPaymentCollectionForCartWorkflowId,
|
createPaymentCollectionForCartWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
+3
@@ -10,6 +10,9 @@ import { useRemoteQueryStep } from "../../../common/steps/use-remote-query"
|
|||||||
|
|
||||||
export const listShippingOptionsForCartWorkflowId =
|
export const listShippingOptionsForCartWorkflowId =
|
||||||
"list-shipping-options-for-cart"
|
"list-shipping-options-for-cart"
|
||||||
|
/**
|
||||||
|
* This workflow lists the shipping options of a cart.
|
||||||
|
*/
|
||||||
export const listShippingOptionsForCartWorkflow = createWorkflow(
|
export const listShippingOptionsForCartWorkflow = createWorkflow(
|
||||||
listShippingOptionsForCartWorkflowId,
|
listShippingOptionsForCartWorkflowId,
|
||||||
(input: WorkflowData<ListShippingOptionsForCartWorkflowInputDTO>) => {
|
(input: WorkflowData<ListShippingOptionsForCartWorkflowInputDTO>) => {
|
||||||
|
|||||||
+5
-2
@@ -10,15 +10,18 @@ import { useRemoteQueryStep } from "../../../common/steps/use-remote-query"
|
|||||||
import { updatePaymentCollectionStep } from "../../../payment-collection"
|
import { updatePaymentCollectionStep } from "../../../payment-collection"
|
||||||
import { deletePaymentSessionsWorkflow } from "../../../payment-collection/workflows/delete-payment-sessions"
|
import { deletePaymentSessionsWorkflow } from "../../../payment-collection/workflows/delete-payment-sessions"
|
||||||
|
|
||||||
type WorklowInput = {
|
export type RefreshPaymentCollectionForCartWorklowInput = {
|
||||||
cart_id: string
|
cart_id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const refreshPaymentCollectionForCartWorkflowId =
|
export const refreshPaymentCollectionForCartWorkflowId =
|
||||||
"refresh-payment-collection-for-cart"
|
"refresh-payment-collection-for-cart"
|
||||||
|
/**
|
||||||
|
* This workflow refreshes the payment collections of a cart.
|
||||||
|
*/
|
||||||
export const refreshPaymentCollectionForCartWorkflow = createWorkflow(
|
export const refreshPaymentCollectionForCartWorkflow = createWorkflow(
|
||||||
refreshPaymentCollectionForCartWorkflowId,
|
refreshPaymentCollectionForCartWorkflowId,
|
||||||
(input: WorkflowData<WorklowInput>): WorkflowData<void> => {
|
(input: WorkflowData<RefreshPaymentCollectionForCartWorklowInput>): WorkflowData<void> => {
|
||||||
const cart = useRemoteQueryStep({
|
const cart = useRemoteQueryStep({
|
||||||
entry_point: "cart",
|
entry_point: "cart",
|
||||||
fields: [
|
fields: [
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import {
|
|||||||
import { updateCartPromotionsStep } from "../steps/update-cart-promotions"
|
import { updateCartPromotionsStep } from "../steps/update-cart-promotions"
|
||||||
import { cartFieldsForRefreshSteps } from "../utils/fields"
|
import { cartFieldsForRefreshSteps } from "../utils/fields"
|
||||||
|
|
||||||
type WorkflowInput = {
|
export type UpdateCartPromotionsWorkflowInput = {
|
||||||
promoCodes: string[]
|
promoCodes: string[]
|
||||||
cartId: string
|
cartId: string
|
||||||
action?:
|
action?:
|
||||||
@@ -27,9 +27,12 @@ type WorkflowInput = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const updateCartPromotionsWorkflowId = "update-cart-promotions"
|
export const updateCartPromotionsWorkflowId = "update-cart-promotions"
|
||||||
|
/**
|
||||||
|
* This workflow updates a cart's promotions.
|
||||||
|
*/
|
||||||
export const updateCartPromotionsWorkflow = createWorkflow(
|
export const updateCartPromotionsWorkflow = createWorkflow(
|
||||||
updateCartPromotionsWorkflowId,
|
updateCartPromotionsWorkflowId,
|
||||||
(input: WorkflowData<WorkflowInput>): WorkflowData<void> => {
|
(input: WorkflowData<UpdateCartPromotionsWorkflowInput>): WorkflowData<void> => {
|
||||||
const cart = useRemoteQueryStep({
|
const cart = useRemoteQueryStep({
|
||||||
entry_point: "cart",
|
entry_point: "cart",
|
||||||
fields: cartFieldsForRefreshSteps,
|
fields: cartFieldsForRefreshSteps,
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ import { cartFieldsForRefreshSteps } from "../utils/fields"
|
|||||||
import { refreshPaymentCollectionForCartWorkflow } from "./refresh-payment-collection"
|
import { refreshPaymentCollectionForCartWorkflow } from "./refresh-payment-collection"
|
||||||
|
|
||||||
export const updateCartWorkflowId = "update-cart"
|
export const updateCartWorkflowId = "update-cart"
|
||||||
|
/**
|
||||||
|
* This workflow updates a cart.
|
||||||
|
*/
|
||||||
export const updateCartWorkflow = createWorkflow(
|
export const updateCartWorkflow = createWorkflow(
|
||||||
updateCartWorkflowId,
|
updateCartWorkflowId,
|
||||||
(input: WorkflowData<UpdateCartWorkflowInputDTO & AdditionalData>) => {
|
(input: WorkflowData<UpdateCartWorkflowInputDTO & AdditionalData>) => {
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ import { refreshPaymentCollectionForCartWorkflow } from "./refresh-payment-colle
|
|||||||
// - Validate shipping methods for new items (fulfillment module)
|
// - Validate shipping methods for new items (fulfillment module)
|
||||||
|
|
||||||
export const updateLineItemInCartWorkflowId = "update-line-item-in-cart"
|
export const updateLineItemInCartWorkflowId = "update-line-item-in-cart"
|
||||||
|
/**
|
||||||
|
* This workflow updates a cart's line item.
|
||||||
|
*/
|
||||||
export const updateLineItemInCartWorkflow = createWorkflow(
|
export const updateLineItemInCartWorkflow = createWorkflow(
|
||||||
updateLineItemInCartWorkflowId,
|
updateLineItemInCartWorkflowId,
|
||||||
(input: WorkflowData<UpdateLineItemInCartWorkflowInputDTO>) => {
|
(input: WorkflowData<UpdateLineItemInCartWorkflowInputDTO>) => {
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ const cartFields = [
|
|||||||
"shipping_address.province",
|
"shipping_address.province",
|
||||||
]
|
]
|
||||||
|
|
||||||
type WorkflowInput = {
|
export type UpdateTaxLinesWorkflowInput = {
|
||||||
cart_or_cart_id: string | CartWorkflowDTO
|
cart_or_cart_id: string | CartWorkflowDTO
|
||||||
items?: CartLineItemDTO[]
|
items?: CartLineItemDTO[]
|
||||||
shipping_methods?: CartShippingMethodDTO[]
|
shipping_methods?: CartShippingMethodDTO[]
|
||||||
@@ -68,9 +68,12 @@ type WorkflowInput = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const updateTaxLinesWorkflowId = "update-tax-lines"
|
export const updateTaxLinesWorkflowId = "update-tax-lines"
|
||||||
|
/**
|
||||||
|
* This workflow updates a cart's tax lines.
|
||||||
|
*/
|
||||||
export const updateTaxLinesWorkflow = createWorkflow(
|
export const updateTaxLinesWorkflow = createWorkflow(
|
||||||
updateTaxLinesWorkflowId,
|
updateTaxLinesWorkflowId,
|
||||||
(input: WorkflowData<WorkflowInput>): WorkflowData<void> => {
|
(input: WorkflowData<UpdateTaxLinesWorkflowInput>): WorkflowData<void> => {
|
||||||
const cart = retrieveCartWithLinksStep({
|
const cart = retrieveCartWithLinksStep({
|
||||||
cart_or_cart_id: input.cart_or_cart_id,
|
cart_or_cart_id: input.cart_or_cart_id,
|
||||||
fields: cartFields,
|
fields: cartFields,
|
||||||
|
|||||||
Reference in New Issue
Block a user