chore(core-flows): [6] export types and types, add basic TSDocs (#8512)
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 6/n
This commit is contained in:
1 parent
4af82aab32
commit
0bfe31e594
22 files changed
+70
-2
No files matched your search
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|||||||
import { MathBN, ModuleRegistrationName } from "@medusajs/utils"
|
import { MathBN, ModuleRegistrationName } from "@medusajs/utils"
|
||||||
|
|
||||||
export const adjustInventoryLevelsStepId = "adjust-inventory-levels-step"
|
export const adjustInventoryLevelsStepId = "adjust-inventory-levels-step"
|
||||||
|
/**
|
||||||
|
* This step adjusts one or more inventory levels.
|
||||||
|
*/
|
||||||
export const adjustInventoryLevelsStep = createStep(
|
export const adjustInventoryLevelsStep = createStep(
|
||||||
adjustInventoryLevelsStepId,
|
adjustInventoryLevelsStepId,
|
||||||
async (
|
async (
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { InventoryItemDTO } from "@medusajs/types"
|
|||||||
|
|
||||||
export const attachInventoryItemToVariantsStepId =
|
export const attachInventoryItemToVariantsStepId =
|
||||||
"attach-inventory-items-to-variants-step"
|
"attach-inventory-items-to-variants-step"
|
||||||
|
/**
|
||||||
|
* This step creates one or more links between variant and inventory item records.
|
||||||
|
*/
|
||||||
export const attachInventoryItemToVariants = createStep(
|
export const attachInventoryItemToVariants = createStep(
|
||||||
attachInventoryItemToVariantsStepId,
|
attachInventoryItemToVariantsStepId,
|
||||||
async (
|
async (
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { IInventoryService, InventoryTypes } from "@medusajs/types"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
|
|
||||||
export const createInventoryItemsStepId = "create-inventory-items"
|
export const createInventoryItemsStepId = "create-inventory-items"
|
||||||
|
/**
|
||||||
|
* This step creates one or more inventory items.
|
||||||
|
*/
|
||||||
export const createInventoryItemsStep = createStep(
|
export const createInventoryItemsStep = createStep(
|
||||||
createInventoryItemsStepId,
|
createInventoryItemsStepId,
|
||||||
async (data: InventoryTypes.CreateInventoryItemInput[], { container }) => {
|
async (data: InventoryTypes.CreateInventoryItemInput[], { container }) => {
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
|
|
||||||
export const createInventoryLevelsStepId = "create-inventory-levels"
|
export const createInventoryLevelsStepId = "create-inventory-levels"
|
||||||
|
/**
|
||||||
|
* This step creates one or more inventory levels.
|
||||||
|
*/
|
||||||
export const createInventoryLevelsStep = createStep(
|
export const createInventoryLevelsStep = createStep(
|
||||||
createInventoryLevelsStepId,
|
createInventoryLevelsStepId,
|
||||||
async (data: InventoryTypes.CreateInventoryLevelInput[], { container }) => {
|
async (data: InventoryTypes.CreateInventoryLevelInput[], { container }) => {
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
|
|
||||||
export const deleteInventoryItemStepId = "delete-inventory-item-step"
|
export const deleteInventoryItemStepId = "delete-inventory-item-step"
|
||||||
|
/**
|
||||||
|
* This step deletes one or more inventory items.
|
||||||
|
*/
|
||||||
export const deleteInventoryItemStep = createStep(
|
export const deleteInventoryItemStep = createStep(
|
||||||
deleteInventoryItemStepId,
|
deleteInventoryItemStepId,
|
||||||
async (ids: string[], { container }) => {
|
async (ids: string[], { container }) => {
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
|
|
||||||
export const deleteInventoryLevelsStepId = "delete-inventory-levels-step"
|
export const deleteInventoryLevelsStepId = "delete-inventory-levels-step"
|
||||||
|
/**
|
||||||
|
* This step deletes one or more inventory levels.
|
||||||
|
*/
|
||||||
export const deleteInventoryLevelsStep = createStep(
|
export const deleteInventoryLevelsStep = createStep(
|
||||||
deleteInventoryLevelsStepId,
|
deleteInventoryLevelsStepId,
|
||||||
async (ids: string[], { container }) => {
|
async (ids: string[], { container }) => {
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ import { MedusaError } from "@medusajs/utils"
|
|||||||
|
|
||||||
export const deleteInventoryLevelsFromItemAndLocationsStepId =
|
export const deleteInventoryLevelsFromItemAndLocationsStepId =
|
||||||
"delete-inventory-levels-from-item-and-location-step"
|
"delete-inventory-levels-from-item-and-location-step"
|
||||||
|
/**
|
||||||
|
* This step removes one or more inventory levels by their associated inventory item and location.
|
||||||
|
*/
|
||||||
export const deleteInventoryLevelsFromItemAndLocationsStep = createStep(
|
export const deleteInventoryLevelsFromItemAndLocationsStep = createStep(
|
||||||
deleteInventoryLevelsFromItemAndLocationsStepId,
|
deleteInventoryLevelsFromItemAndLocationsStepId,
|
||||||
async (
|
async (
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
|
|
||||||
export const updateInventoryItemsStepId = "update-inventory-items-step"
|
export const updateInventoryItemsStepId = "update-inventory-items-step"
|
||||||
|
/**
|
||||||
|
* This step updates one or more inventory items.
|
||||||
|
*/
|
||||||
export const updateInventoryItemsStep = createStep(
|
export const updateInventoryItemsStep = createStep(
|
||||||
updateInventoryItemsStepId,
|
updateInventoryItemsStepId,
|
||||||
async (input: InventoryTypes.UpdateInventoryItemInput[], { container }) => {
|
async (input: InventoryTypes.UpdateInventoryItemInput[], { container }) => {
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
|
|
||||||
export const updateInventoryLevelsStepId = "update-inventory-levels-step"
|
export const updateInventoryLevelsStepId = "update-inventory-levels-step"
|
||||||
|
/**
|
||||||
|
* This step updates one or more inventory levels.
|
||||||
|
*/
|
||||||
export const updateInventoryLevelsStep = createStep(
|
export const updateInventoryLevelsStep = createStep(
|
||||||
updateInventoryLevelsStepId,
|
updateInventoryLevelsStepId,
|
||||||
async (
|
async (
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import {
|
|||||||
import { createStep } from "@medusajs/workflows-sdk"
|
import { createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
export const validateInventoryItemsId = "validate-inventory-items-step"
|
export const validateInventoryItemsId = "validate-inventory-items-step"
|
||||||
|
/**
|
||||||
|
* This step ensures that the inventory items with the specified IDs exist.
|
||||||
|
*/
|
||||||
export const validateInventoryItems = createStep(
|
export const validateInventoryItems = createStep(
|
||||||
validateInventoryItemsId,
|
validateInventoryItemsId,
|
||||||
async (id: string[], { container }) => {
|
async (id: string[], { container }) => {
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ import { InventoryTypes } from "@medusajs/types"
|
|||||||
import { createStep } from "@medusajs/workflows-sdk"
|
import { createStep } from "@medusajs/workflows-sdk"
|
||||||
|
|
||||||
export const validateInventoryLocationsStepId = "validate-inventory-levels-step"
|
export const validateInventoryLocationsStepId = "validate-inventory-levels-step"
|
||||||
|
/**
|
||||||
|
* This step ensures that the inventory levels exist for each specified pair of inventory item and location.
|
||||||
|
*/
|
||||||
export const validateInventoryLocationsStep = createStep(
|
export const validateInventoryLocationsStep = createStep(
|
||||||
validateInventoryLocationsStepId,
|
validateInventoryLocationsStepId,
|
||||||
async (data: InventoryTypes.CreateInventoryLevelInput[], { container }) => {
|
async (data: InventoryTypes.CreateInventoryLevelInput[], { container }) => {
|
||||||
|
|||||||
+3
@@ -7,6 +7,9 @@ import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
|||||||
|
|
||||||
export const validateInventoryItemsForCreateStepId =
|
export const validateInventoryItemsForCreateStepId =
|
||||||
"validate-inventory-items-for-create-step"
|
"validate-inventory-items-for-create-step"
|
||||||
|
/**
|
||||||
|
* This step checks whether a variant already has an inventory item.
|
||||||
|
*/
|
||||||
export const validateInventoryItemsForCreate = createStep(
|
export const validateInventoryItemsForCreate = createStep(
|
||||||
validateInventoryItemsForCreateStepId,
|
validateInventoryItemsForCreateStepId,
|
||||||
async (
|
async (
|
||||||
|
|||||||
@@ -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 createInviteStepId = "create-invite-step"
|
export const createInviteStepId = "create-invite-step"
|
||||||
|
/**
|
||||||
|
* This step creates one or more invites.
|
||||||
|
*/
|
||||||
export const createInviteStep = createStep(
|
export const createInviteStep = createStep(
|
||||||
createInviteStepId,
|
createInviteStepId,
|
||||||
async (input: CreateInviteDTO[], { container }) => {
|
async (input: CreateInviteDTO[], { container }) => {
|
||||||
|
|||||||
@@ -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 deleteInvitesStepId = "delete-invites-step"
|
export const deleteInvitesStepId = "delete-invites-step"
|
||||||
|
/**
|
||||||
|
* This step deletes one or more invites.
|
||||||
|
*/
|
||||||
export const deleteInvitesStep = createStep(
|
export const deleteInvitesStep = createStep(
|
||||||
deleteInvitesStepId,
|
deleteInvitesStepId,
|
||||||
async (input: string[], { container }) => {
|
async (input: string[], { container }) => {
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
|||||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||||
|
|
||||||
export const refreshInviteTokensStepId = "refresh-invite-tokens-step"
|
export const refreshInviteTokensStepId = "refresh-invite-tokens-step"
|
||||||
|
/**
|
||||||
|
* This step refreshes the tokens of one or more invites.
|
||||||
|
*/
|
||||||
export const refreshInviteTokensStep = createStep(
|
export const refreshInviteTokensStep = createStep(
|
||||||
refreshInviteTokensStepId,
|
refreshInviteTokensStepId,
|
||||||
async (input: string[], { container }) => {
|
async (input: string[], { container }) => {
|
||||||
|
|||||||
@@ -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 validateTokenStepId = "validate-invite-token-step"
|
export const validateTokenStepId = "validate-invite-token-step"
|
||||||
|
/**
|
||||||
|
* This step validates a specified token and returns its associated invite.
|
||||||
|
*/
|
||||||
export const validateTokenStep = createStep(
|
export const validateTokenStep = createStep(
|
||||||
validateTokenStepId,
|
validateTokenStepId,
|
||||||
async (input: string, { container }) => {
|
async (input: string, { container }) => {
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import { validateTokenStep } from "../steps/validate-token"
|
|||||||
import { setAuthAppMetadataStep } from "../../auth"
|
import { setAuthAppMetadataStep } from "../../auth"
|
||||||
|
|
||||||
export const acceptInviteWorkflowId = "accept-invite-workflow"
|
export const acceptInviteWorkflowId = "accept-invite-workflow"
|
||||||
|
/**
|
||||||
|
* This workflow accepts an invite and creates a user.
|
||||||
|
*/
|
||||||
export const acceptInviteWorkflow = createWorkflow(
|
export const acceptInviteWorkflow = createWorkflow(
|
||||||
acceptInviteWorkflowId,
|
acceptInviteWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -7,6 +7,9 @@ import { createInviteStep } from "../steps"
|
|||||||
import { InviteDTO, InviteWorkflow } from "@medusajs/types"
|
import { InviteDTO, InviteWorkflow } from "@medusajs/types"
|
||||||
|
|
||||||
export const createInvitesWorkflowId = "create-invite-step"
|
export const createInvitesWorkflowId = "create-invite-step"
|
||||||
|
/**
|
||||||
|
* This workflow creates one or more invites.
|
||||||
|
*/
|
||||||
export const createInvitesWorkflow = createWorkflow(
|
export const createInvitesWorkflow = createWorkflow(
|
||||||
createInvitesWorkflowId,
|
createInvitesWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import { deleteInvitesStep } from "../steps"
|
|||||||
import { InviteWorkflow, UserWorkflow } from "@medusajs/types"
|
import { InviteWorkflow, UserWorkflow } from "@medusajs/types"
|
||||||
|
|
||||||
export const deleteInvitesWorkflowId = "delete-invites-workflow"
|
export const deleteInvitesWorkflowId = "delete-invites-workflow"
|
||||||
|
/**
|
||||||
|
* This workflow deletes one or more invites.
|
||||||
|
*/
|
||||||
export const deleteInvitesWorkflow = createWorkflow(
|
export const deleteInvitesWorkflow = createWorkflow(
|
||||||
deleteInvitesWorkflowId,
|
deleteInvitesWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import {
|
|||||||
import { refreshInviteTokensStep } from "../steps/refresh-invite-tokens"
|
import { refreshInviteTokensStep } from "../steps/refresh-invite-tokens"
|
||||||
|
|
||||||
export const refreshInviteTokensWorkflowId = "refresh-invite-tokens-workflow"
|
export const refreshInviteTokensWorkflowId = "refresh-invite-tokens-workflow"
|
||||||
|
/**
|
||||||
|
* This workflow refreshes the token of one or more invites.
|
||||||
|
*/
|
||||||
export const refreshInviteTokensWorkflow = createWorkflow(
|
export const refreshInviteTokensWorkflow = createWorkflow(
|
||||||
refreshInviteTokensWorkflowId,
|
refreshInviteTokensWorkflowId,
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { INotificationModuleService } 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 NotifyOnFailureStepInput = {
|
export type NotifyOnFailureStepInput = {
|
||||||
to: string
|
to: string
|
||||||
channel: string
|
channel: string
|
||||||
template: string
|
template: string
|
||||||
@@ -16,6 +16,11 @@ type NotifyOnFailureStepInput = {
|
|||||||
}[]
|
}[]
|
||||||
|
|
||||||
export const notifyOnFailureStepId = "notify-on-failure"
|
export const notifyOnFailureStepId = "notify-on-failure"
|
||||||
|
/**
|
||||||
|
* This step sends one or more notification when a workflow fails. This
|
||||||
|
* step can be used in a workflow for its compensation function. When the workflow fails,
|
||||||
|
* its compensation function is triggered to send the notification.
|
||||||
|
*/
|
||||||
export const notifyOnFailureStep = createStep(
|
export const notifyOnFailureStep = createStep(
|
||||||
notifyOnFailureStepId,
|
notifyOnFailureStepId,
|
||||||
async (data: NotifyOnFailureStepInput) => {
|
async (data: NotifyOnFailureStepInput) => {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { INotificationModuleService } 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 SendNotificationsStepInput = {
|
export type SendNotificationsStepInput = {
|
||||||
to: string
|
to: string
|
||||||
channel: string
|
channel: string
|
||||||
template: string
|
template: string
|
||||||
@@ -16,6 +16,9 @@ type SendNotificationsStepInput = {
|
|||||||
}[]
|
}[]
|
||||||
|
|
||||||
export const sendNotificationsStepId = "send-notifications"
|
export const sendNotificationsStepId = "send-notifications"
|
||||||
|
/**
|
||||||
|
* This step sends one or more notifications.
|
||||||
|
*/
|
||||||
export const sendNotificationsStep = createStep(
|
export const sendNotificationsStep = createStep(
|
||||||
sendNotificationsStepId,
|
sendNotificationsStepId,
|
||||||
async (data: SendNotificationsStepInput, { container }) => {
|
async (data: SendNotificationsStepInput, { container }) => {
|
||||||
|
|||||||
Reference in new issue
Block a user