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