Skip to content

Commit

Permalink
chore(core-flows): add TSDocs to the emitEventStep
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Aug 2, 2024
1 parent e44332b commit 8c407a4
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion packages/core/core-flows/src/common/steps/emit-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8c407a4

Please sign in to comment.