docs: enhance how references are generated (#5805)

* adjusted configurations

* enhancements to tool and configurations

* change reference in docs

* fixed issue in workflows reference

* added project name

* more optimizations

* fix context error

* added a types reference

* resolved missing types

* fix reference reflection types not having children

* add an expand url parameter

* added new option to the README

* added details about new option
This commit is contained in:
Shahed Nasser
2023-12-05 15:29:41 +02:00
committed by GitHub
parent a418e6cebc
commit 892d737c1f
4358 changed files with 947876 additions and 534760 deletions
@@ -6,11 +6,11 @@ sidebar_label: createStep
import ParameterTypes from "@site/src/components/ParameterTypes"
# createStep - Workflows Reference
# createStep - Workflows API Reference
This documentation provides a reference to the `createStep` . It belongs to the `@medusajs/workflows-sdk` package.
This function creates a [StepFunction](../types/StepFunction.mdx) that can be used as a step in a workflow constructed by the [createWorkflow](createWorkflow.mdx) function.
This function creates a [StepFunction](../types/workflows.StepFunction.mdx) that can be used as a step in a workflow constructed by the [createWorkflow](workflows.createWorkflow.mdx) function.
## Example
@@ -100,8 +100,8 @@ export const createProductStep = createStep(
},
{
"name": "invokeFn",
"type": "[InvokeFn](../types/InvokeFn.mdx)<TInvokeInput, TInvokeResultOutput, TInvokeResultCompensateInput>",
"description": "An invocation function that will be executed when the workflow is executed. The function must return an instance of [StepResponse](../classes/StepResponse.mdx). The constructor of [StepResponse](../classes/StepResponse.mdx) accepts the output of the step as a first argument, and optionally as a second argument the data to be passed to the compensation function as a parameter.",
"type": "InvokeFn<TInvokeInput, TInvokeResultOutput, TInvokeResultCompensateInput>",
"description": "An invocation function that will be executed when the workflow is executed. The function must return an instance of [StepResponse](../classes/workflows.StepResponse.mdx). The constructor of [StepResponse](../classes/workflows.StepResponse.mdx)\naccepts the output of the step as a first argument, and optionally as a second argument the data to be passed to the compensation function as a parameter.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -109,8 +109,8 @@ export const createProductStep = createStep(
},
{
"name": "compensateFn",
"type": "[CompensateFn](../types/CompensateFn.mdx)<TInvokeResultCompensateInput>",
"description": "A compensation function that's executed if an error occurs in the workflow. It's used to roll-back actions when errors occur. It accepts as a parameter the second argument passed to the constructor of the [StepResponse](../classes/StepResponse.mdx) instance returned by the invocation function. If the invocation function doesn't pass the second argument to `StepResponse` constructor, the compensation function receives the first argument passed to the `StepResponse` constructor instead.",
"type": "CompensateFn<TInvokeResultCompensateInput>",
"description": "A compensation function that's executed if an error occurs in the workflow. It's used to roll-back actions when errors occur.\nIt accepts as a parameter the second argument passed to the constructor of the [StepResponse](../classes/workflows.StepResponse.mdx) instance returned by the invocation function. If the\ninvocation function doesn't pass the second argument to `StepResponse` constructor, the compensation function receives the first argument\npassed to the `StepResponse` constructor instead.",
"optional": true,
"defaultValue": "",
"expandable": false,
@@ -123,7 +123,7 @@ export const createProductStep = createStep(
<ParameterTypes parameters={[
{
"name": "StepFunction",
"type": "[StepFunction](../types/StepFunction.mdx)&#60;TInvokeInput, TInvokeResultOutput&#62;",
"type": "[StepFunction](../types/workflows.StepFunction.mdx)&#60;TInvokeInput, TInvokeResultOutput&#62;",
"optional": false,
"defaultValue": "",
"description": "A step function to be used in a workflow.",
@@ -6,13 +6,13 @@ sidebar_label: createWorkflow
import ParameterTypes from "@site/src/components/ParameterTypes"
# createWorkflow - Workflows Reference
# createWorkflow - Workflows API Reference
This documentation provides a reference to the `createWorkflow` . It belongs to the `@medusajs/workflows-sdk` package.
This function creates a workflow with the provided name and a constructor function.
The constructor function builds the workflow from steps created by the [createStep](createStep.mdx) function.
The returned workflow is an exported workflow of type [ReturnWorkflow](../types/ReturnWorkflow.mdx), meaning it's not executed right away. To execute it,
The constructor function builds the workflow from steps created by the [createStep](workflows.createStep.mdx) function.
The returned workflow is an exported workflow of type ReturnWorkflow, meaning it's not executed right away. To execute it,
invoke the exported workflow, then run its `run` method.
## Example
@@ -106,8 +106,8 @@ export async function GET(
},
{
"name": "composer",
"type": "(`input`: [WorkflowData](../types/WorkflowData.mdx)&#60;TData&#62;) => `void` \\| [WorkflowData](../types/WorkflowData.mdx)&#60;TResult&#62; \\| &#123; [K in string \\| number \\| symbol]: WorkflowDataProperties&#60;TResult[K]&#62; \\| WorkflowData&#60;TResult[K]&#62; &#125;",
"description": "The constructor function that is executed when the `run` method in [ReturnWorkflow](../types/ReturnWorkflow.mdx) is used. The function can't be an arrow function or an asynchronus function. It also can't directly manipulate data. You'll have to use the [transform](transform.mdx) function if you need to directly manipulate data.",
"type": "(`input`: [WorkflowData](../types/workflows.WorkflowData.mdx)&#60;TData&#62;) => `void` \\| [WorkflowData](../types/workflows.WorkflowData.mdx)&#60;TResult&#62; \\| &#123; [K in string \\| number \\| symbol]: WorkflowDataProperties&#60;TResult[K]&#62; \\| WorkflowData&#60;TResult[K]&#62; &#125;",
"description": "The constructor function that is executed when the `run` method in ReturnWorkflow is used.\nThe function can't be an arrow function or an asynchronus function. It also can't directly manipulate data.\nYou'll have to use the [transform](workflows.transform.mdx) function if you need to directly manipulate data.",
"optional": false,
"defaultValue": "",
"expandable": false,
@@ -120,7 +120,7 @@ export async function GET(
<ParameterTypes parameters={[
{
"name": "ReturnWorkflow",
"type": "[ReturnWorkflow](../types/ReturnWorkflow.mdx)&#60;TData, TResult, THooks&#62;",
"type": "ReturnWorkflow&#60;TData, TResult, THooks&#62;",
"optional": false,
"defaultValue": "",
"description": "The created workflow. You can later execute the workflow by invoking it, then using its `run` method.",
@@ -6,7 +6,7 @@ sidebar_label: parallelize
import ParameterTypes from "@site/src/components/ParameterTypes"
# parallelize - Workflows Reference
# parallelize - Workflows API Reference
This documentation provides a reference to the `parallelize` . It belongs to the `@medusajs/workflows-sdk` package.
@@ -45,13 +45,14 @@ const myWorkflow = createWorkflow<
return getProductStep(product.id)
}
)
```
## Type Parameters
<ParameterTypes parameters={[
{
"name": "TResult",
"type": "[WorkflowDataProperties](../types/WorkflowDataProperties.mdx)&#60;unknown&#62;[]",
"type": "[WorkflowDataProperties](../types/workflows.WorkflowDataProperties.mdx)&#60;unknown&#62;[]",
"description": "The type of the expected result.",
"optional": false,
"defaultValue": "",
@@ -6,13 +6,13 @@ sidebar_label: transform
import ParameterTypes from "@site/src/components/ParameterTypes"
# transform - Workflows Reference
# transform - Workflows API Reference
This documentation provides a reference to the `transform` . It belongs to the `@medusajs/workflows-sdk` package.
This function transforms the output of other utility functions.
For example, if you're using the value(s) of some step(s) as an input to a later step. As you can't directly manipulate data in the workflow constructor function passed to [createWorkflow](createWorkflow.mdx),
For example, if you're using the value(s) of some step(s) as an input to a later step. As you can't directly manipulate data in the workflow constructor function passed to [createWorkflow](workflows.createWorkflow.mdx),
the `transform` function provides access to the runtime value of the step(s) output so that you can manipulate them.
Another example is if you're using the runtime value of some step(s) as the output of a workflow.
@@ -58,7 +58,7 @@ const myWorkflow = createWorkflow<
<ParameterTypes parameters={[
{
"name": "T",
"type": "`object` \\| [WorkflowDataProperties](../types/WorkflowDataProperties.mdx)&#60;unknown&#62;",
"type": "`object` \\| [WorkflowDataProperties](../types/workflows.WorkflowDataProperties.mdx)&#60;unknown&#62;",
"description": "",
"optional": false,
"defaultValue": "",
@@ -90,7 +90,7 @@ const myWorkflow = createWorkflow<
},
{
"name": "func",
"type": "[[Func1](../types/Func1.mdx)&#60;T, RFinal&#62;]",
"type": "[Func1&#60;T, RFinal&#62;]",
"description": "The transform function used to perform action on the runtime values of the provided `values`.",
"optional": false,
"defaultValue": "",
@@ -104,7 +104,7 @@ const myWorkflow = createWorkflow<
<ParameterTypes parameters={[
{
"name": "WorkflowData",
"type": "[WorkflowData](../types/WorkflowData.mdx)&#60;RFinal&#62;",
"type": "[WorkflowData](../types/workflows.WorkflowData.mdx)&#60;RFinal&#62;",
"optional": false,
"defaultValue": "",
"description": "There's no expected value to be returned by the `transform` function.",