chore(core-flows): [4] export types and types, add basic TSDocs (#8509)
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 4/n
This commit is contained in:
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteLineItemsStepId = "delete-line-items"
|
||||
/**
|
||||
* This step deletes line items.
|
||||
*/
|
||||
export const deleteLineItemsStep = createStep(
|
||||
deleteLineItemsStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -7,15 +7,19 @@ import {
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
interface StepInput {
|
||||
export interface ListLineItemsStepInput {
|
||||
filters: FilterableLineItemProps
|
||||
config?: FindConfig<CartLineItemDTO>
|
||||
}
|
||||
|
||||
export const listLineItemsStepId = "list-line-items"
|
||||
/**
|
||||
* This step retrieves a list of a cart's line items
|
||||
* matching the specified filters.
|
||||
*/
|
||||
export const listLineItemsStep = createStep(
|
||||
listLineItemsStepId,
|
||||
async (data: StepInput, { container }) => {
|
||||
async (data: ListLineItemsStepInput, { container }) => {
|
||||
const service = container.resolve<ICartModuleService>(
|
||||
ModuleRegistrationName.CART
|
||||
)
|
||||
|
||||
@@ -12,6 +12,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const updateLineItemsStepWithSelectorId =
|
||||
"update-line-items-with-selector"
|
||||
/**
|
||||
* This step updates line items.
|
||||
*/
|
||||
export const updateLineItemsStepWithSelector = createStep(
|
||||
updateLineItemsStepWithSelectorId,
|
||||
async (input: UpdateLineItemWithSelectorDTO, { container }) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { refreshCartPromotionsStep } from "../../cart/steps/refresh-cart-promotions"
|
||||
import { deleteLineItemsStep } from "../steps/delete-line-items"
|
||||
|
||||
type WorkflowInput = { cart_id: string; ids: string[] }
|
||||
export type DeleteLineItemsWorkflowInput = { cart_id: string; ids: string[] }
|
||||
|
||||
// TODO: The DeleteLineItemsWorkflow are missing the following steps:
|
||||
// - Refresh/delete shipping methods (fulfillment module)
|
||||
@@ -10,9 +10,12 @@ type WorkflowInput = { cart_id: string; ids: string[] }
|
||||
// - Update payment sessions (payment module)
|
||||
|
||||
export const deleteLineItemsWorkflowId = "delete-line-items"
|
||||
/**
|
||||
* This workflow deletes line items from a cart.
|
||||
*/
|
||||
export const deleteLineItemsWorkflow = createWorkflow(
|
||||
deleteLineItemsWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>) => {
|
||||
(input: WorkflowData<DeleteLineItemsWorkflowInput>) => {
|
||||
deleteLineItemsStep(input.ids)
|
||||
|
||||
refreshCartPromotionsStep({ id: input.cart_id })
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteFilesStepId = "delete-files"
|
||||
/**
|
||||
* This step deletes one or more files.
|
||||
*/
|
||||
export const deleteFilesStep = createStep(
|
||||
{ name: deleteFilesStepId, noCompensation: true },
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { IFileModuleService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type UploadFilesStepInput = {
|
||||
export type UploadFilesStepInput = {
|
||||
files: {
|
||||
filename: string
|
||||
mimeType: string
|
||||
@@ -12,6 +12,9 @@ type UploadFilesStepInput = {
|
||||
}
|
||||
|
||||
export const uploadFilesStepId = "upload-files"
|
||||
/**
|
||||
* This step uploads one or more files.
|
||||
*/
|
||||
export const uploadFilesStep = createStep(
|
||||
uploadFilesStepId,
|
||||
async (data: UploadFilesStepInput, { container }) => {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { deleteFilesStep } from "../steps"
|
||||
|
||||
type WorkflowInput = { ids: string[] }
|
||||
export type DeleteFilesWorkflowInput = { ids: string[] }
|
||||
|
||||
export const deleteFilesWorkflowId = "delete-files"
|
||||
/**
|
||||
* This workflow deletes one or more files.
|
||||
*/
|
||||
export const deleteFilesWorkflow = createWorkflow(
|
||||
deleteFilesWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>): WorkflowData<void> => {
|
||||
(input: WorkflowData<DeleteFilesWorkflowInput>): WorkflowData<void> => {
|
||||
deleteFilesStep(input.ids)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { uploadFilesStep } from "../steps"
|
||||
|
||||
type WorkflowInput = {
|
||||
export type UploadFilesWorkflowInput = {
|
||||
files: {
|
||||
filename: string
|
||||
mimeType: string
|
||||
@@ -16,9 +16,12 @@ type WorkflowInput = {
|
||||
}
|
||||
|
||||
export const uploadFilesWorkflowId = "upload-files"
|
||||
/**
|
||||
* This workflow uploads one or more files.
|
||||
*/
|
||||
export const uploadFilesWorkflow = createWorkflow(
|
||||
uploadFilesWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>): WorkflowResponse<FileDTO[]> => {
|
||||
(input: WorkflowData<UploadFilesWorkflowInput>): WorkflowResponse<FileDTO[]> => {
|
||||
return new WorkflowResponse(uploadFilesStep(input))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -19,6 +19,9 @@ import {
|
||||
import { updateShippingOptionRulesStep } from "../steps/update-shipping-option-rules"
|
||||
|
||||
export const batchShippingOptionRulesWorkflowId = "batch-shipping-option-rules"
|
||||
/**
|
||||
* This workflow manages shipping option rules by creating, updating, or deleting them.
|
||||
*/
|
||||
export const batchShippingOptionRulesWorkflow = createWorkflow(
|
||||
batchShippingOptionRulesWorkflowId,
|
||||
(
|
||||
|
||||
@@ -2,6 +2,9 @@ import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { cancelFulfillmentStep } from "../steps"
|
||||
|
||||
export const cancelFulfillmentWorkflowId = "cancel-fulfillment-workflow"
|
||||
/**
|
||||
* This workflow cancels a fulfillment.
|
||||
*/
|
||||
export const cancelFulfillmentWorkflow = createWorkflow(
|
||||
cancelFulfillmentWorkflowId,
|
||||
(input: WorkflowData<{ id: string }>) => {
|
||||
|
||||
@@ -7,6 +7,9 @@ import {
|
||||
import { createFulfillmentStep } from "../steps"
|
||||
|
||||
export const createFulfillmentWorkflowId = "create-fulfillment-workflow"
|
||||
/**
|
||||
* This workflow creates a fulfillment.
|
||||
*/
|
||||
export const createFulfillmentWorkflow = createWorkflow(
|
||||
createFulfillmentWorkflowId,
|
||||
(
|
||||
|
||||
@@ -8,6 +8,9 @@ import { createReturnFulfillmentStep } from "../steps"
|
||||
|
||||
export const createReturnFulfillmentWorkflowId =
|
||||
"create-return-fulfillment-workflow"
|
||||
/**
|
||||
* This workflow creates a fulfillment for a return.
|
||||
*/
|
||||
export const createReturnFulfillmentWorkflow = createWorkflow(
|
||||
createReturnFulfillmentWorkflowId,
|
||||
(
|
||||
|
||||
@@ -7,6 +7,9 @@ import {
|
||||
import { createServiceZonesStep } from "../steps"
|
||||
|
||||
export const createServiceZonesWorkflowId = "create-service-zones-workflow"
|
||||
/**
|
||||
* This workflow creates one or more service zones.
|
||||
*/
|
||||
export const createServiceZonesWorkflow = createWorkflow(
|
||||
createServiceZonesWorkflowId,
|
||||
(
|
||||
|
||||
@@ -9,6 +9,9 @@ import { validateShipmentStep } from "../steps"
|
||||
import { updateFulfillmentWorkflow } from "./update-fulfillment"
|
||||
|
||||
export const createShipmentWorkflowId = "create-shipment-workflow"
|
||||
/**
|
||||
* This workflow creates shipments for a fulfillment.
|
||||
*/
|
||||
export const createShipmentWorkflow = createWorkflow(
|
||||
createShipmentWorkflowId,
|
||||
(input: WorkflowData<FulfillmentWorkflow.CreateShipmentWorkflowInput>) => {
|
||||
|
||||
@@ -14,6 +14,9 @@ import { validateFulfillmentProvidersStep } from "../steps/validate-fulfillment-
|
||||
|
||||
export const createShippingOptionsWorkflowId =
|
||||
"create-shipping-options-workflow"
|
||||
/**
|
||||
* This workflow creates one or more shipping options.
|
||||
*/
|
||||
export const createShippingOptionsWorkflow = createWorkflow(
|
||||
createShippingOptionsWorkflowId,
|
||||
(
|
||||
|
||||
@@ -8,6 +8,9 @@ import { createShippingProfilesStep } from "../steps"
|
||||
|
||||
export const createShippingProfilesWorkflowId =
|
||||
"create-shipping-profiles-workflow"
|
||||
/**
|
||||
* This workflow creates one or more shipping profiles.
|
||||
*/
|
||||
export const createShippingProfilesWorkflow = createWorkflow(
|
||||
createShippingProfilesWorkflowId,
|
||||
(
|
||||
|
||||
@@ -5,6 +5,9 @@ import { Modules } from "@medusajs/utils"
|
||||
|
||||
export const deleteFulfillmentSetsWorkflowId =
|
||||
"delete-fulfillment-sets-workflow"
|
||||
/**
|
||||
* This workflow deletes one or more fulfillment sets.
|
||||
*/
|
||||
export const deleteFulfillmentSetsWorkflow = createWorkflow(
|
||||
deleteFulfillmentSetsWorkflowId,
|
||||
(input: WorkflowData<{ ids: string[] }>) => {
|
||||
|
||||
@@ -2,6 +2,9 @@ import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { deleteServiceZonesStep } from "../steps"
|
||||
|
||||
export const deleteServiceZonesWorkflowId = "delete-service-zones-workflow"
|
||||
/**
|
||||
* This workflow deletes one or more service zones.
|
||||
*/
|
||||
export const deleteServiceZonesWorkflow = createWorkflow(
|
||||
deleteServiceZonesWorkflowId,
|
||||
(input: WorkflowData<{ ids: string[] }>) => {
|
||||
|
||||
@@ -5,6 +5,9 @@ import { removeRemoteLinkStep } from "../../common"
|
||||
|
||||
export const deleteShippingOptionsWorkflowId =
|
||||
"delete-shipping-options-workflow"
|
||||
/**
|
||||
* This workflow deletes one or more shipping options.
|
||||
*/
|
||||
export const deleteShippingOptionsWorkflow = createWorkflow(
|
||||
deleteShippingOptionsWorkflowId,
|
||||
(
|
||||
|
||||
@@ -7,6 +7,9 @@ import {
|
||||
import { updateFulfillmentStep } from "../steps"
|
||||
|
||||
export const updateFulfillmentWorkflowId = "update-fulfillment-workflow"
|
||||
/**
|
||||
* This workflow updates a fulfillment.
|
||||
*/
|
||||
export const updateFulfillmentWorkflow = createWorkflow(
|
||||
updateFulfillmentWorkflowId,
|
||||
(input: WorkflowData<FulfillmentWorkflow.UpdateFulfillmentWorkflowInput>) => {
|
||||
|
||||
@@ -7,6 +7,9 @@ import {
|
||||
import { updateServiceZonesStep } from "../steps/update-service-zones"
|
||||
|
||||
export const updateServiceZonesWorkflowId = "update-service-zones-workflow"
|
||||
/**
|
||||
* This workflow updates one or more service zones.
|
||||
*/
|
||||
export const updateServiceZonesWorkflow = createWorkflow(
|
||||
updateServiceZonesWorkflowId,
|
||||
(
|
||||
|
||||
@@ -13,6 +13,9 @@ import { validateFulfillmentProvidersStep } from "../steps/validate-fulfillment-
|
||||
|
||||
export const updateShippingOptionsWorkflowId =
|
||||
"update-shipping-options-workflow"
|
||||
/**
|
||||
* This workflow updates one or more shipping options.
|
||||
*/
|
||||
export const updateShippingOptionsWorkflow = createWorkflow(
|
||||
updateShippingOptionsWorkflowId,
|
||||
(
|
||||
|
||||
@@ -8,6 +8,9 @@ import { updateShippingProfilesStep } from "../steps/update-shipping-profiles"
|
||||
|
||||
export const updateShippingProfilesWorkflowId =
|
||||
"update-shipping-profiles-workflow"
|
||||
/**
|
||||
* This workflow updates one or more shipping profiles.
|
||||
*/
|
||||
export const updateShippingProfilesWorkflow = createWorkflow(
|
||||
updateShippingProfilesWorkflowId,
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user