diff --git a/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts b/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts index 9efb2ef593..cd91d2c00a 100644 --- a/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts +++ b/packages/core/core-flows/src/api-key/workflows/create-api-keys.ts @@ -2,6 +2,7 @@ import { ApiKeyDTO, CreateApiKeyDTO } from "@medusajs/framework/types" import { WorkflowData, WorkflowResponse, + createHook, createWorkflow, } from "@medusajs/framework/workflows-sdk" import { createApiKeysStep } from "../steps" @@ -9,7 +10,7 @@ import { createApiKeysStep } from "../steps" /** * The data to create API keys. */ -export type CreateApiKeysWorkflowInput = { +export type CreateApiKeysWorkflowInput = { /** * The API keys to create. */ @@ -23,12 +24,12 @@ export type CreateApiKeysWorkflowOutput = ApiKeyDTO[] export const createApiKeysWorkflowId = "create-api-keys" /** - * This workflow creates one or more API keys, which can be secret or publishable. It's used by the + * This workflow creates one or more API keys, which can be secret or publishable. It's used by the * [Create API Key Admin API Route](https://docs.medusajs.com/api/admin#api-keys_postapikeys). - * + * * You can use this workflow within your customizations or your own custom workflows, allowing you to * create API keys within your custom flows. - * + * * @example * const { result } = await createApiKeysWorkflow(container) * .run({ @@ -42,16 +43,22 @@ export const createApiKeysWorkflowId = "create-api-keys" * ] * } * }) - * + * * @summary - * + * * Create secret or publishable API keys. */ export const createApiKeysWorkflow = createWorkflow( createApiKeysWorkflowId, - ( - input: WorkflowData - ): WorkflowResponse => { - return new WorkflowResponse(createApiKeysStep(input)) + (input: WorkflowData) => { + const apiKeys = createApiKeysStep(input) + + const apiKeysCreated = createHook("apiKeysCreated", { + apiKeys, + }) + + return new WorkflowResponse(apiKeys, { + hooks: [apiKeysCreated], + }) } )