chore: fix documentation links in TSDocs (#10511)
This commit is contained in:
@@ -23,7 +23,7 @@ export type Hook<Name extends string, Input> = {
|
||||
*
|
||||
* A handler hook can later be registered to consume the hook and perform custom functionality.
|
||||
*
|
||||
* Learn more in [this documentation](https://docs.medusajs.com/advanced-development/workflows/add-workflow-hook).
|
||||
* Learn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks).
|
||||
*
|
||||
* @param name - The hook's name. This is used when the hook handler is registered to consume the workflow.
|
||||
* @param input - The input to pass to the hook handler.
|
||||
|
||||
@@ -42,7 +42,7 @@ global[OrchestrationUtils.SymbolMedusaWorkflowComposerContext] = null
|
||||
* createWorkflow,
|
||||
* WorkflowResponse
|
||||
* } from "@medusajs/framework/workflows-sdk"
|
||||
* import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
|
||||
* import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
|
||||
* import {
|
||||
* createProductStep,
|
||||
* getProductStep,
|
||||
|
||||
@@ -229,7 +229,7 @@ export type ReturnWorkflow<TData, TResult, THooks extends any[]> = {
|
||||
/**
|
||||
* This method executes the workflow as a step. Useful when running a workflow within another.
|
||||
*
|
||||
* Learn more in [this documentation](https://docs.medusajs.com/advanced-development/workflows/execute-another-workflow).
|
||||
* Learn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/workflows/execute-another-workflow).
|
||||
*
|
||||
* @param param0 - The options to execute the workflow.
|
||||
* @returns The workflow's result
|
||||
@@ -266,7 +266,7 @@ export type ReturnWorkflow<TData, TResult, THooks extends any[]> = {
|
||||
/**
|
||||
* The workflow's exposed hooks, used to register a handler to consume the hook.
|
||||
*
|
||||
* Learn more in [this documentation](https://docs.medusajs.com/advanced-development/workflows/add-workflow-hook#how-to-consume-a-hook).
|
||||
* Learn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/workflows/workflow-hooks#how-to-consume-a-hook).
|
||||
*/
|
||||
hooks: ConvertHooksToFunctions<THooks>
|
||||
}
|
||||
|
||||
@@ -19,6 +19,48 @@ type ThenFunc = <ThenResolver extends () => any>(
|
||||
? WorkflowData<ReturnedWorkflowData> | undefined
|
||||
: ReturnType<ThenResolver>
|
||||
|
||||
/**
|
||||
* This function allows you to execute steps only if a condition is satisfied. As you can't use if conditions in
|
||||
* a workflow's constructor function, use `when-then` instead.
|
||||
*
|
||||
* Learn more about why you can't use if conditions and `when-then` in [this documentation](https://docs.medusajs.com/learn/fundamentals/workflows/conditions).
|
||||
*
|
||||
* @param values - The data to pass to the second parameter function.
|
||||
* @param condition - A function that returns a boolean value, indicating whether the steps in `then` should be executed.
|
||||
*
|
||||
* @example
|
||||
* import {
|
||||
* createWorkflow,
|
||||
* WorkflowResponse,
|
||||
* when,
|
||||
* } from "@medusajs/framework/workflows-sdk"
|
||||
* // step imports...
|
||||
*
|
||||
* const workflow = createWorkflow(
|
||||
* "workflow",
|
||||
* function (input: {
|
||||
* is_active: boolean
|
||||
* }) {
|
||||
*
|
||||
* const result = when(
|
||||
* input,
|
||||
* (input) => {
|
||||
* return input.is_active
|
||||
* }
|
||||
* ).then(() => {
|
||||
* const stepResult = isActiveStep()
|
||||
* return stepResult
|
||||
* })
|
||||
*
|
||||
* // executed without condition
|
||||
* const anotherStepResult = anotherStep(result)
|
||||
*
|
||||
* return new WorkflowResponse(
|
||||
* anotherStepResult
|
||||
* )
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
export function when<T extends object | WorkflowData, Then extends Function>(
|
||||
values: T,
|
||||
condition: ConditionFunction<T>
|
||||
@@ -26,6 +68,9 @@ export function when<T extends object | WorkflowData, Then extends Function>(
|
||||
then: ThenFunc
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function when<T extends object | WorkflowData, Then extends Function>(
|
||||
name: string,
|
||||
values: T,
|
||||
@@ -34,6 +79,9 @@ export function when<T extends object | WorkflowData, Then extends Function>(
|
||||
then: ThenFunc
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export function when(...args) {
|
||||
let [name, input, condition] = args
|
||||
if (args.length === 2) {
|
||||
|
||||
Reference in New Issue
Block a user