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:
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
import { MathBN, ModuleRegistrationName } from "@medusajs/utils"
|
||||
|
||||
export const adjustInventoryLevelsStepId = "adjust-inventory-levels-step"
|
||||
/**
|
||||
* This step adjusts one or more inventory levels.
|
||||
*/
|
||||
export const adjustInventoryLevelsStep = createStep(
|
||||
adjustInventoryLevelsStepId,
|
||||
async (
|
||||
|
||||
@@ -5,6 +5,9 @@ import { InventoryItemDTO } from "@medusajs/types"
|
||||
|
||||
export const attachInventoryItemToVariantsStepId =
|
||||
"attach-inventory-items-to-variants-step"
|
||||
/**
|
||||
* This step creates one or more links between variant and inventory item records.
|
||||
*/
|
||||
export const attachInventoryItemToVariants = createStep(
|
||||
attachInventoryItemToVariantsStepId,
|
||||
async (
|
||||
|
||||
@@ -4,6 +4,9 @@ import { IInventoryService, InventoryTypes } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
|
||||
export const createInventoryItemsStepId = "create-inventory-items"
|
||||
/**
|
||||
* This step creates one or more inventory items.
|
||||
*/
|
||||
export const createInventoryItemsStep = createStep(
|
||||
createInventoryItemsStepId,
|
||||
async (data: InventoryTypes.CreateInventoryItemInput[], { container }) => {
|
||||
|
||||
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
|
||||
export const createInventoryLevelsStepId = "create-inventory-levels"
|
||||
/**
|
||||
* This step creates one or more inventory levels.
|
||||
*/
|
||||
export const createInventoryLevelsStep = createStep(
|
||||
createInventoryLevelsStepId,
|
||||
async (data: InventoryTypes.CreateInventoryLevelInput[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
|
||||
export const deleteInventoryItemStepId = "delete-inventory-item-step"
|
||||
/**
|
||||
* This step deletes one or more inventory items.
|
||||
*/
|
||||
export const deleteInventoryItemStep = createStep(
|
||||
deleteInventoryItemStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
|
||||
export const deleteInventoryLevelsStepId = "delete-inventory-levels-step"
|
||||
/**
|
||||
* This step deletes one or more inventory levels.
|
||||
*/
|
||||
export const deleteInventoryLevelsStep = createStep(
|
||||
deleteInventoryLevelsStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -6,6 +6,9 @@ import { MedusaError } from "@medusajs/utils"
|
||||
|
||||
export const deleteInventoryLevelsFromItemAndLocationsStepId =
|
||||
"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(
|
||||
deleteInventoryLevelsFromItemAndLocationsStepId,
|
||||
async (
|
||||
|
||||
@@ -8,6 +8,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
|
||||
export const updateInventoryItemsStepId = "update-inventory-items-step"
|
||||
/**
|
||||
* This step updates one or more inventory items.
|
||||
*/
|
||||
export const updateInventoryItemsStep = createStep(
|
||||
updateInventoryItemsStepId,
|
||||
async (input: InventoryTypes.UpdateInventoryItemInput[], { container }) => {
|
||||
|
||||
@@ -8,6 +8,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
|
||||
export const updateInventoryLevelsStepId = "update-inventory-levels-step"
|
||||
/**
|
||||
* This step updates one or more inventory levels.
|
||||
*/
|
||||
export const updateInventoryLevelsStep = createStep(
|
||||
updateInventoryLevelsStepId,
|
||||
async (
|
||||
|
||||
@@ -7,6 +7,9 @@ import {
|
||||
import { createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const validateInventoryItemsId = "validate-inventory-items-step"
|
||||
/**
|
||||
* This step ensures that the inventory items with the specified IDs exist.
|
||||
*/
|
||||
export const validateInventoryItems = createStep(
|
||||
validateInventoryItemsId,
|
||||
async (id: string[], { container }) => {
|
||||
|
||||
@@ -9,6 +9,9 @@ import { InventoryTypes } from "@medusajs/types"
|
||||
import { createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
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(
|
||||
validateInventoryLocationsStepId,
|
||||
async (data: InventoryTypes.CreateInventoryLevelInput[], { container }) => {
|
||||
|
||||
+3
@@ -7,6 +7,9 @@ import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const validateInventoryItemsForCreateStepId =
|
||||
"validate-inventory-items-for-create-step"
|
||||
/**
|
||||
* This step checks whether a variant already has an inventory item.
|
||||
*/
|
||||
export const validateInventoryItemsForCreate = createStep(
|
||||
validateInventoryItemsForCreateStepId,
|
||||
async (
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createInviteStepId = "create-invite-step"
|
||||
/**
|
||||
* This step creates one or more invites.
|
||||
*/
|
||||
export const createInviteStep = createStep(
|
||||
createInviteStepId,
|
||||
async (input: CreateInviteDTO[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteInvitesStepId = "delete-invites-step"
|
||||
/**
|
||||
* This step deletes one or more invites.
|
||||
*/
|
||||
export const deleteInvitesStep = createStep(
|
||||
deleteInvitesStepId,
|
||||
async (input: string[], { container }) => {
|
||||
|
||||
@@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
|
||||
export const refreshInviteTokensStepId = "refresh-invite-tokens-step"
|
||||
/**
|
||||
* This step refreshes the tokens of one or more invites.
|
||||
*/
|
||||
export const refreshInviteTokensStep = createStep(
|
||||
refreshInviteTokensStepId,
|
||||
async (input: string[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const validateTokenStepId = "validate-invite-token-step"
|
||||
/**
|
||||
* This step validates a specified token and returns its associated invite.
|
||||
*/
|
||||
export const validateTokenStep = createStep(
|
||||
validateTokenStepId,
|
||||
async (input: string, { container }) => {
|
||||
|
||||
@@ -11,6 +11,9 @@ import { validateTokenStep } from "../steps/validate-token"
|
||||
import { setAuthAppMetadataStep } from "../../auth"
|
||||
|
||||
export const acceptInviteWorkflowId = "accept-invite-workflow"
|
||||
/**
|
||||
* This workflow accepts an invite and creates a user.
|
||||
*/
|
||||
export const acceptInviteWorkflow = createWorkflow(
|
||||
acceptInviteWorkflowId,
|
||||
(
|
||||
|
||||
@@ -7,6 +7,9 @@ import { createInviteStep } from "../steps"
|
||||
import { InviteDTO, InviteWorkflow } from "@medusajs/types"
|
||||
|
||||
export const createInvitesWorkflowId = "create-invite-step"
|
||||
/**
|
||||
* This workflow creates one or more invites.
|
||||
*/
|
||||
export const createInvitesWorkflow = createWorkflow(
|
||||
createInvitesWorkflowId,
|
||||
(
|
||||
|
||||
@@ -3,6 +3,9 @@ import { deleteInvitesStep } from "../steps"
|
||||
import { InviteWorkflow, UserWorkflow } from "@medusajs/types"
|
||||
|
||||
export const deleteInvitesWorkflowId = "delete-invites-workflow"
|
||||
/**
|
||||
* This workflow deletes one or more invites.
|
||||
*/
|
||||
export const deleteInvitesWorkflow = createWorkflow(
|
||||
deleteInvitesWorkflowId,
|
||||
(
|
||||
|
||||
@@ -8,6 +8,9 @@ import {
|
||||
import { refreshInviteTokensStep } from "../steps/refresh-invite-tokens"
|
||||
|
||||
export const refreshInviteTokensWorkflowId = "refresh-invite-tokens-workflow"
|
||||
/**
|
||||
* This workflow refreshes the token of one or more invites.
|
||||
*/
|
||||
export const refreshInviteTokensWorkflow = createWorkflow(
|
||||
refreshInviteTokensWorkflowId,
|
||||
(
|
||||
|
||||
@@ -2,7 +2,7 @@ import { INotificationModuleService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type NotifyOnFailureStepInput = {
|
||||
export type NotifyOnFailureStepInput = {
|
||||
to: string
|
||||
channel: string
|
||||
template: string
|
||||
@@ -16,6 +16,11 @@ type NotifyOnFailureStepInput = {
|
||||
}[]
|
||||
|
||||
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(
|
||||
notifyOnFailureStepId,
|
||||
async (data: NotifyOnFailureStepInput) => {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { INotificationModuleService } from "@medusajs/types"
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type SendNotificationsStepInput = {
|
||||
export type SendNotificationsStepInput = {
|
||||
to: string
|
||||
channel: string
|
||||
template: string
|
||||
@@ -16,6 +16,9 @@ type SendNotificationsStepInput = {
|
||||
}[]
|
||||
|
||||
export const sendNotificationsStepId = "send-notifications"
|
||||
/**
|
||||
* This step sends one or more notifications.
|
||||
*/
|
||||
export const sendNotificationsStep = createStep(
|
||||
sendNotificationsStepId,
|
||||
async (data: SendNotificationsStepInput, { container }) => {
|
||||
|
||||
Reference in New Issue
Block a user