chore(docs): Generated References (#8400)
Generated the following references: - `api_key` - `auth` - `auth_provider` - `cart` - `currency` - `customer` - `dml` - `file` - `fulfillment` - `fulfillment_provider` - `inventory_next` - `medusa` - `modules` - `modules_sdk` - `notification` - `order` - `order_models` - `payment` - `payment_models` - `payment_provider` - `pricing` - `product` - `promotion` - `region` - `sales_channel` - `stock_location_next` - `store` - `tax` - `types` - `user` - `workflows`
This commit is contained in:
1 parent
c2faca1e8b
commit
71f0d24359
336 files changed
+53078
-49461
No files matched your search
@@ -9,20 +9,47 @@ import { TypeList } from "docs-ui"
|
||||
|
||||
This documentation provides a reference to the `createHook` . It belongs to the `@medusajs/workflows-sdk` package.
|
||||
|
||||
Define a workflow hook to be executed within steps. The created hook
|
||||
is exposed publicly for the workflow consumers to inject and run
|
||||
custom logic.
|
||||
Expose a hook in your workflow where you can inject custom functionality as a step function.
|
||||
|
||||
Hooks behaves like steps
|
||||
A handler hook can later be registered to consume the hook and perform custom functionality.
|
||||
|
||||
Learn more in [this documentation](https://docs.medusajs.com/v2/advanced-development/workflows/add-workflow-hook).
|
||||
|
||||
## Example
|
||||
|
||||
```ts
|
||||
import {
|
||||
createStep,
|
||||
createHook,
|
||||
createWorkflow,
|
||||
WorkflowResponse,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { createProductStep } from "./steps/create-product"
|
||||
|
||||
export const myWorkflow = createWorkflow(
|
||||
"my-workflow",
|
||||
function (input) {
|
||||
const product = createProductStep(input)
|
||||
const productCreatedHook = createHook(
|
||||
"productCreated",
|
||||
{ productId: product.id }
|
||||
)
|
||||
|
||||
return new WorkflowResponse(product, {
|
||||
hooks: [productCreatedHook],
|
||||
})
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
## Type Parameters
|
||||
|
||||
<TypeList types={[{"name":"Name","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TInvokeInput","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createHook"/>
|
||||
<TypeList types={[{"name":"Name","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"TInvokeInput","type":"`object`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createHook"/>
|
||||
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"name","type":"Name","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"input","type":"TInvokeInput","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createHook"/>
|
||||
<TypeList types={[{"name":"name","type":"Name","description":"The hook's name. This is used when the hook handler is registered to consume the workflow.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"input","type":"TInvokeInput","description":"The input to pass to the hook handler.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createHook"/>
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[{"name":"Hook","type":"[Hook](../../types/workflows.Hook/page.mdx)<Name, TInvokeInput>","optional":false,"defaultValue":"","description":"Define a workflow hook to be executed within steps. The created hook\nis exposed publicly for the workflow consumers to inject and run\ncustom logic.\n\nHooks behaves like steps","expandable":false,"children":[]}]} sectionTitle="createHook"/>
|
||||
<TypeList types={[{"name":"Hook","type":"[Hook](../../types/workflows.Hook/page.mdx)<Name, TInvokeInput>","optional":false,"defaultValue":"","description":"A workflow hook.","expandable":false,"children":[]}]} sectionTitle="createHook"/>
|
||||
@@ -55,7 +55,7 @@ export const createProductStep = createStep(
|
||||
|
||||
## Type Parameters
|
||||
|
||||
<TypeList types={[{"name":"TInvokeInput","type":"`object`","description":"The type of the expected input parameter to the invocation function.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TInvokeResultOutput","type":"`object`","description":"The type of the expected output parameter of the invocation function.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TInvokeResultCompensateInput","type":"`object`","description":"The type of the expected input parameter to the compensation function.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createStep"/>
|
||||
<TypeList types={[{"name":"TInvokeInput","type":"`object`","description":"The type of the expected input parameter to the invocation function.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"TInvokeResultOutput","type":"`object`","description":"The type of the expected output parameter of the invocation function.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"TInvokeResultCompensateInput","type":"`object`","description":"The type of the expected input parameter to the compensation function.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createStep"/>
|
||||
|
||||
## Parameters
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ export async function GET(
|
||||
|
||||
## Type Parameters
|
||||
|
||||
<TypeList types={[{"name":"TData","type":"`object`","description":"The type of the input passed to the composer function.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TResult","type":"`object`","description":"The type of the output returned by the composer function.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"THooks","type":"`any`[]","description":"The type of hooks defined in the workflow.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createWorkflow"/>
|
||||
<TypeList types={[{"name":"TData","type":"`object`","description":"The type of the input passed to the composer function.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"TResult","type":"`object`","description":"The type of the output returned by the composer function.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"THooks","type":"`any`[]","description":"The type of hooks defined in the workflow.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createWorkflow"/>
|
||||
|
||||
## Parameters
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ const myWorkflow = createWorkflow<
|
||||
|
||||
## Type Parameters
|
||||
|
||||
<TypeList types={[{"name":"TResult","type":"[WorkflowData](../../types/workflows.WorkflowData/page.mdx)[]","description":"The type of the expected result.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="parallelize"/>
|
||||
<TypeList types={[{"name":"TResult","type":"[WorkflowData](../../types/workflows.WorkflowData/page.mdx)[]","description":"The type of the expected result.","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="parallelize"/>
|
||||
|
||||
## Parameters
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ const myWorkflow = createWorkflow<
|
||||
|
||||
## Type Parameters
|
||||
|
||||
<TypeList types={[{"name":"T","type":"`object` \\| [WorkflowData](../../types/workflows.WorkflowData/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"RFinal","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="transform"/>
|
||||
<TypeList types={[{"name":"T","type":"`object` \\| [WorkflowData](../../types/workflows.WorkflowData/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"RFinal","type":"`object`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="transform"/>
|
||||
|
||||
## Parameters
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ This documentation provides a reference to the `when` . It belongs to the `@medu
|
||||
|
||||
## Type Parameters
|
||||
|
||||
<TypeList types={[{"name":"T","type":"`object` \\| [WorkflowData](../../types/workflows.WorkflowData/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"Then","type":"`Function`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="when"/>
|
||||
<TypeList types={[{"name":"T","type":"`object` \\| [WorkflowData](../../types/workflows.WorkflowData/page.mdx)","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"Then","type":"`Function`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="when"/>
|
||||
|
||||
## Parameters
|
||||
|
||||
|
||||
Reference in new issue
Block a user