chore(core-flows): add TSDocs to the emitEventStep (#8413)

This commit is contained in:
Shahed Nasser
2024-08-05 13:20:22 +03:00
committed by GitHub
parent 0dab340013
commit b37e976b9a

View File

@@ -2,18 +2,57 @@ import { EventBusTypes, IEventBusModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepExecutionContext, createStep } from "@medusajs/workflows-sdk"
/**
* The event's details.
*/
type Input = {
/**
* The event's name.
*/
eventName: string
/**
* Options to emit the event.
*/
options?: Record<string, any>
/**
* Metadata that the subscriber receives in the `metadata` property
* of its first parameter.
*/
metadata?: Record<string, any>
/**
* The data payload that the subscriber receives in the `data` property
* of its first parameter. Use this property to pass data relevant for the
* subscriber, such as the ID of a created record.
*/
data:
| ((context: StepExecutionContext) => Promise<Record<any, any>>)
| Record<any, any>
}
export const emitEventStepId = "emit-event-step"
/**
* @ignore
* Emit an event.
*
* @example
* import {
* createWorkflow
* } from "@medusajs/workflows-sdk"
* import {
* emitEventStep
* } from "@medusajs/core-flows"
*
* const helloWorldWorkflow = createWorkflow(
* "hello-world",
* () => {
* emitEventStep({
* eventName: "custom.created",
* data: {
* id: "123"
* }
* })
* }
* )
*/
export const emitEventStep = createStep(
emitEventStepId,