feat: added hook for createApiKeysWorkflow (#10909)
* added hook for createApiKeysWorkflow * fix types * fixed typings for createApiKeysWorkflow
This commit is contained in:
@@ -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<CreateApiKeysWorkflowInput>
|
||||
): WorkflowResponse<CreateApiKeysWorkflowOutput> => {
|
||||
return new WorkflowResponse(createApiKeysStep(input))
|
||||
(input: WorkflowData<CreateApiKeysWorkflowInput>) => {
|
||||
const apiKeys = createApiKeysStep(input)
|
||||
|
||||
const apiKeysCreated = createHook("apiKeysCreated", {
|
||||
apiKeys,
|
||||
})
|
||||
|
||||
return new WorkflowResponse(apiKeys, {
|
||||
hooks: [apiKeysCreated],
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user