feat: added hook for createApiKeysWorkflow (#10909)
* added hook for createApiKeysWorkflow * fix types * fixed typings for createApiKeysWorkflow
This commit is contained in:
1 parent
dc94e62a6a
commit
1bf8766826
1 file changed
+17
-10
@@ -2,6 +2,7 @@ import { ApiKeyDTO, CreateApiKeyDTO } from "@medusajs/framework/types"
|
|||||||
import {
|
import {
|
||||||
WorkflowData,
|
WorkflowData,
|
||||||
WorkflowResponse,
|
WorkflowResponse,
|
||||||
|
createHook,
|
||||||
createWorkflow,
|
createWorkflow,
|
||||||
} from "@medusajs/framework/workflows-sdk"
|
} from "@medusajs/framework/workflows-sdk"
|
||||||
import { createApiKeysStep } from "../steps"
|
import { createApiKeysStep } from "../steps"
|
||||||
@@ -9,7 +10,7 @@ import { createApiKeysStep } from "../steps"
|
|||||||
/**
|
/**
|
||||||
* The data to create API keys.
|
* The data to create API keys.
|
||||||
*/
|
*/
|
||||||
export type CreateApiKeysWorkflowInput = {
|
export type CreateApiKeysWorkflowInput = {
|
||||||
/**
|
/**
|
||||||
* The API keys to create.
|
* The API keys to create.
|
||||||
*/
|
*/
|
||||||
@@ -23,12 +24,12 @@ export type CreateApiKeysWorkflowOutput = ApiKeyDTO[]
|
|||||||
|
|
||||||
export const createApiKeysWorkflowId = "create-api-keys"
|
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).
|
* [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
|
* You can use this workflow within your customizations or your own custom workflows, allowing you to
|
||||||
* create API keys within your custom flows.
|
* create API keys within your custom flows.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* const { result } = await createApiKeysWorkflow(container)
|
* const { result } = await createApiKeysWorkflow(container)
|
||||||
* .run({
|
* .run({
|
||||||
@@ -42,16 +43,22 @@ export const createApiKeysWorkflowId = "create-api-keys"
|
|||||||
* ]
|
* ]
|
||||||
* }
|
* }
|
||||||
* })
|
* })
|
||||||
*
|
*
|
||||||
* @summary
|
* @summary
|
||||||
*
|
*
|
||||||
* Create secret or publishable API keys.
|
* Create secret or publishable API keys.
|
||||||
*/
|
*/
|
||||||
export const createApiKeysWorkflow = createWorkflow(
|
export const createApiKeysWorkflow = createWorkflow(
|
||||||
createApiKeysWorkflowId,
|
createApiKeysWorkflowId,
|
||||||
(
|
(input: WorkflowData<CreateApiKeysWorkflowInput>) => {
|
||||||
input: WorkflowData<CreateApiKeysWorkflowInput>
|
const apiKeys = createApiKeysStep(input)
|
||||||
): WorkflowResponse<CreateApiKeysWorkflowOutput> => {
|
|
||||||
return new WorkflowResponse(createApiKeysStep(input))
|
const apiKeysCreated = createHook("apiKeysCreated", {
|
||||||
|
apiKeys,
|
||||||
|
})
|
||||||
|
|
||||||
|
return new WorkflowResponse(apiKeys, {
|
||||||
|
hooks: [apiKeysCreated],
|
||||||
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
Reference in new issue
Block a user