docs: update imports and package names across docs (#9375)

* docs: update imports and package names across docs
+ reference configs

* generate files

* fix import

* change preview to rc
This commit is contained in:
Shahed Nasser
2024-10-01 11:03:42 +02:00
committed by GitHub
parent c726ed54f5
commit 2e16949979
196 changed files with 1379 additions and 1491 deletions
@@ -24,7 +24,7 @@ Your workflow isn't reusable by other applications. Use a step that performs wha
## How to Expose a Hook in a Workflow?
To expose a hook in your workflow, use the `createHook` function imported from `@medusajs/workflows-sdk`.
To expose a hook in your workflow, use the `createHook` function imported from `@medusajs/framework/workflows-sdk`.
For example:
@@ -41,7 +41,7 @@ import {
createHook,
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import { createProductStep } from "./steps/create-product"
export const myWorkflow = createWorkflow(
@@ -26,7 +26,7 @@ For example, create the file `src/workflows/hello-world.ts` with the following c
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
const step1 = createStep(
"step-1",
@@ -66,7 +66,7 @@ Then, create a workflow that uses the steps:
import {
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
// other imports...
// steps...
@@ -135,7 +135,7 @@ export const inputHighlights = [
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
const step1 = createStep(
"step-1",
@@ -172,8 +172,8 @@ export const containerHighlights = [
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
import { ContainerRegistrationKeys } from "@medusajs/utils"
} from "@medusajs/framework/workflows-sdk"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
const step1 = createStep(
"step-1",
@@ -37,7 +37,7 @@ import {
createWorkflow,
WorkflowResponse,
when,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
// step imports...
const workflow = createWorkflow(
@@ -70,7 +70,7 @@ In this code snippet, you execute the `isActiveStep` only if the `input.is_activ
### When Parameters
`when` utility is a function imported from `@medusajs/workflows-sdk`. It accepts the following parameters:
`when` utility is a function imported from `@medusajs/framework/workflows-sdk`. It accepts the following parameters:
1. The first parameter is either an object or the workflow's input. This data is passed as a parameter to the function in `when`'s second parameter.
2. The second parameter is a function that returns a boolean indicating whether to execute the action in `then`.
@@ -38,7 +38,7 @@ Learn more about why you can't manipulate variables [in this chapter](../conditi
</Note>
Instead, use the `transform` utility function imported from `@medusajs/workflows-sdk`:
Instead, use the `transform` utility function imported from `@medusajs/framework/workflows-sdk`:
export const highlights = [
["9", "", "Don't manipulate variables directly."],
@@ -89,7 +89,7 @@ Learn more about why you can't use if-conditions [in this chapter](../conditions
</Note>
Instead, use the when-then utility function imported from `@medusajs/workflows-sdk`:
Instead, use the when-then utility function imported from `@medusajs/framework/workflows-sdk`:
```ts
// Don't
@@ -129,7 +129,7 @@ Values of other types, such as Maps, aren't allowed.
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
const step1 = createStep(
"step-1",
@@ -148,7 +148,7 @@ const step1 = createStep(
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
const step1 = createStep(
"step-1",
@@ -20,10 +20,10 @@ export const workflowsHighlights = [
```ts highlights={workflowsHighlights} collapsibleLines="1-7" expandMoreButton="Show Imports"
import {
createWorkflow,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
createProductsWorkflow,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
const workflow = createWorkflow(
"hello-world",
@@ -49,7 +49,7 @@ The object has an `input` property to pass input to the workflow.
## Preparing Input Data
If you need to perform some data manipulation to prepare the other workflow's input data, use the `transform` utility function imported from `@medusajs/workflows-sdk`.
If you need to perform some data manipulation to prepare the other workflow's input data, use the `transform` utility function imported from `@medusajs/framework/workflows-sdk`.
<Note>
@@ -68,10 +68,10 @@ export const transformHighlights = [
import {
createWorkflow,
transform,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
createProductsWorkflow,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
type WorkflowInput = {
title: string
@@ -105,7 +105,7 @@ In this example, you use the `transform` function to prepend `Hello` to the titl
## Run Workflow Conditionally
To run a workflow in another based on a condition, use the when-then utility functions imported from `@medusajs/workflows-sdk`.
To run a workflow in another based on a condition, use the when-then utility functions imported from `@medusajs/framework/workflows-sdk`.
<Note>
@@ -124,13 +124,13 @@ export const whenHighlights = [
import {
createWorkflow,
when,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
createProductsWorkflow,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
import {
CreateProductWorkflowInputDTO,
} from "@medusajs/types"
} from "@medusajs/framework/types"
type WorkflowInput = {
product?: CreateProductWorkflowInputDTO
@@ -35,7 +35,7 @@ import {
createWorkflow,
WorkflowResponse,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
const step1 = createStep("step-1", async () => {
return new StepResponse({})
@@ -114,11 +114,11 @@ export const successStatusHighlights = [
import {
Modules,
TransactionHandlerType,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import {
StepResponse,
createStep,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
type SetStepSuccessStepInput = {
transactionId: string
@@ -232,11 +232,11 @@ export const failureStatusHighlights = [
import {
Modules,
TransactionHandlerType,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import {
StepResponse,
createStep,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
type SetStepFailureStepInput = {
transactionId: string
@@ -288,8 +288,8 @@ import type { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import myWorkflow from "../../../workflows/hello-world"
import {
IWorkflowEngineService,
} from "@medusajs/types"
import { Modules } from "@medusajs/utils"
} from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(req: MedusaRequest, res: MedusaResponse) {
const { transaction, result } = await myWorkflow(req.scope).run()
@@ -8,7 +8,7 @@ In this chapter, youll learn how to run workflow steps in parallel.
## parallelize Utility Function
If your workflow has steps that dont rely on one anothers results, run them in parallel using the `parallelize` utility function imported from the `@medusajs/workflows-sdk`.
If your workflow has steps that dont rely on one anothers results, run them in parallel using the `parallelize` utility function imported from the `@medusajs/framework/workflows-sdk`.
The workflow waits until all steps passed to the `parallelize` function finish executing before continuing to the next step.
@@ -24,7 +24,7 @@ import {
createWorkflow,
WorkflowResponse,
parallelize,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
createProductStep,
getProductStep,
@@ -19,7 +19,7 @@ import {
createStep,
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
const step1 = createStep(
{
@@ -43,7 +43,7 @@ import {
createWorkflow,
WorkflowResponse,
transform,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
// step imports...
const myWorkflow = createWorkflow(
@@ -62,7 +62,7 @@ const myWorkflow = createWorkflow(
)
```
The `transform` utility function is imported from `@medusajs/workflows-sdk`. It accepts two parameters:
The `transform` utility function is imported from `@medusajs/framework/workflows-sdk`. It accepts two parameters:
1. The first parameter is an object of variables to manipulate. The object is passed as a parameter to `transform`'s second parameter function.
2. The second parameter is the function performing the variable manipulation.
@@ -84,7 +84,7 @@ import {
createWorkflow,
WorkflowResponse,
transform,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
// step imports...
type WorkflowInput = {
@@ -43,7 +43,7 @@ export const handlerHighlights = [
]
```ts title="src/workflows/hooks/product-created.ts" highlights={handlerHighlights}
import { createProductsWorkflow } from "@medusajs/core-flows"
import { createProductsWorkflow } from "@medusajs/medusa/core-flows"
createProductsWorkflow.hooks.productsCreated(
async ({ products }, { container }) => {
@@ -83,7 +83,7 @@ Since the hook handler is a step function, you can set its compensation function
For example:
```ts title="src/workflows/hooks/product-created.ts"
import { createProductsWorkflow } from "@medusajs/core-flows"
import { createProductsWorkflow } from "@medusajs/medusa/core-flows"
createProductsWorkflow.productCreated(
async ({ productId }, { container }) => {
@@ -108,7 +108,7 @@ It also accepts as a second parameter an object holding a `container` property t
Medusa's workflows pass in the hook's input an `additional_data` property:
```ts title="src/workflows/hooks/product-created.ts" highlights={[["4", "additional_data"]]}
import { createProductsWorkflow } from "@medusajs/core-flows"
import { createProductsWorkflow } from "@medusajs/medusa/core-flows"
createProductsWorkflow.hooks.productsCreated(
async ({ products, additional_data }, { container }) => {
@@ -131,7 +131,7 @@ You can also pass that additional data when executing the workflow. Pass it as a
```ts title="src/workflows/hooks/product-created.ts" highlights={[["10", "additional_data"]]}
import type { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { createProductsWorkflow } from "@medusajs/core-flows"
import { createProductsWorkflow } from "@medusajs/medusa/core-flows"
export async function POST(req: MedusaRequest, res: MedusaResponse) {
await createProductsWorkflow(req.scope).run({
@@ -31,7 +31,7 @@ import {
createStep,
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
const step1 = createStep(
"step-1",