docs: add note to tutorials related to types (#13720)
This commit is contained in:
@@ -340,12 +340,6 @@ You also pass an `options` property with module options, including the signature
|
||||
|
||||
Your module is now ready for use. You'll build workflows around it in the following steps.
|
||||
|
||||
<Note title="Tip">
|
||||
|
||||
To avoid type errors when using the module's service in the next step, start the Medusa application once with the `npm run dev` or `yarn dev` command. This generates the necessary type definitions, as explained in the [Automatically Generated Types guide](!docs!/learn/fundamentals/generated-types).
|
||||
|
||||
</Note>
|
||||
|
||||
---
|
||||
|
||||
## Step 3: Send Product Feed
|
||||
@@ -703,6 +697,12 @@ The final step is `sendProductFeedStep`, which sends product feed XML to AI agen
|
||||
|
||||
Create the file `src/workflows/steps/send-product-feed.ts` with the following content:
|
||||
|
||||
<Note>
|
||||
|
||||
If you get a type error on resolving the Agentic Commerce Module, run the Medusa application once with the `npm run dev` or `yarn dev` command to generate the necessary type definitions, as explained in the [Automatically Generated Types guide](!docs!/learn/fundamentals/generated-types).
|
||||
|
||||
</Note>
|
||||
|
||||
```ts title="src/workflows/steps/send-product-feed.ts"
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
import { AGENTIC_COMMERCE_MODULE } from "../../modules/agentic-commerce"
|
||||
|
||||
@@ -435,6 +435,12 @@ The workflow that manages invoice configurations will have a single step that up
|
||||
|
||||
To create a step, create the file `src/workflows/steps/update-invoice-config.ts` with the following content:
|
||||
|
||||
<Note>
|
||||
|
||||
If you get a type error on resolving the Invoice Generator Module, run the Medusa application once with the `npm run dev` or `yarn dev` command to generate the necessary type definitions, as explained in the [Automatically Generated Types guide](!docs!/learn/fundamentals/generated-types).
|
||||
|
||||
</Note>
|
||||
|
||||
export const updateInvoiceConfigHighlights = [
|
||||
["19", "prevData", "Retrieve the invoice configurations before the update."],
|
||||
["23", "updatedData", "Update the invoice configurations with the new data."],
|
||||
|
||||
@@ -621,6 +621,12 @@ To return data from a step, you return an instance of `StepResponse` from the Wo
|
||||
|
||||
If the order's cart has a loyalty promotion, you need to deduct points from the customer's loyalty points. To do this, create the file `src/workflows/steps/deduct-purchase-points.ts` with the following content:
|
||||
|
||||
<Note>
|
||||
|
||||
If you get a type error on resolving the Loyalty Module, run the Medusa application once with the `npm run dev` or `yarn dev` command to generate the necessary type definitions, as explained in the [Automatically Generated Types guide](!docs!/learn/fundamentals/generated-types).
|
||||
|
||||
</Note>
|
||||
|
||||
export const deductStepHighlights = [
|
||||
["18", "loyaltyModuleService", "Resolve the Loyalty Module's service."],
|
||||
["22", "calculatePointsFromAmount", "Calculate the points to deduct from the promotion's amount."],
|
||||
|
||||
@@ -531,6 +531,12 @@ The `updatePreorderVariantStep` updates an existing pre-order variant.
|
||||
|
||||
To create the step, create the file `src/workflows/steps/update-preorder-variant.ts` with the following content:
|
||||
|
||||
<Note>
|
||||
|
||||
If you get a type error on resolving the Preorder Module, run the Medusa application once with the `npm run dev` or `yarn dev` command to generate the necessary type definitions, as explained in the [Automatically Generated Types guide](!docs!/learn/fundamentals/generated-types).
|
||||
|
||||
</Note>
|
||||
|
||||
export const updatePreorderVariantStepHighlights = [
|
||||
["16", "preorderModuleService", "Resolve the Preorder Module's service from the Medusa container."],
|
||||
["20", "oldData", "Retrieve existing record to undo updates if an error occurs."],
|
||||
@@ -542,6 +548,7 @@ export const updatePreorderVariantStepHighlights = [
|
||||
|
||||
```ts title="src/workflows/steps/update-preorder-variant.ts" highlights={updatePreorderVariantStepHighlights}
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
import { PREORDER_MODULE } from "../../modules/preorder"
|
||||
import {
|
||||
PreorderVariantStatus,
|
||||
} from "../../modules/preorder/models/preorder-variant"
|
||||
@@ -557,7 +564,7 @@ export const updatePreorderVariantStep = createStep(
|
||||
"update-preorder-variant",
|
||||
async (input: StepInput, { container }) => {
|
||||
const preorderModuleService = container.resolve(
|
||||
"preorder"
|
||||
PREORDER_MODULE
|
||||
)
|
||||
|
||||
const oldData = await preorderModuleService.retrievePreorderVariant(
|
||||
@@ -576,7 +583,7 @@ export const updatePreorderVariantStep = createStep(
|
||||
}
|
||||
|
||||
const preorderModuleService = container.resolve(
|
||||
"preorder"
|
||||
PREORDER_MODULE
|
||||
)
|
||||
|
||||
await preorderModuleService.updatePreorderVariants({
|
||||
@@ -624,6 +631,7 @@ export const createPreorderVariantStepHighlights = [
|
||||
|
||||
```ts title="src/workflows/steps/create-preorder-variant.ts" highlights={createPreorderVariantStepHighlights}
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
import { PREORDER_MODULE } from "../../modules/preorder"
|
||||
|
||||
type StepInput = {
|
||||
variant_id: string
|
||||
@@ -634,7 +642,7 @@ export const createPreorderVariantStep = createStep(
|
||||
"create-preorder-variant",
|
||||
async (input: StepInput, { container }) => {
|
||||
const preorderModuleService = container.resolve(
|
||||
"preorder"
|
||||
PREORDER_MODULE
|
||||
)
|
||||
|
||||
const preorderVariant = await preorderModuleService.createPreorderVariants(
|
||||
@@ -649,7 +657,7 @@ export const createPreorderVariantStep = createStep(
|
||||
}
|
||||
|
||||
const preorderModuleService = container.resolve(
|
||||
"preorder"
|
||||
PREORDER_MODULE
|
||||
)
|
||||
|
||||
await preorderModuleService.deletePreorderVariants(preorderVariantId)
|
||||
@@ -946,6 +954,7 @@ export const disablePreorderVariantStepHighlights = [
|
||||
|
||||
```ts title="src/workflows/steps/disable-preorder-variant.ts" highlights={disablePreorderVariantStepHighlights}
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
import { PREORDER_MODULE } from "../../modules/preorder"
|
||||
import {
|
||||
PreorderVariantStatus,
|
||||
} from "../../modules/preorder/models/preorder-variant"
|
||||
@@ -957,7 +966,7 @@ type StepInput = {
|
||||
export const disablePreorderVariantStep = createStep(
|
||||
"disable-preorder-variant",
|
||||
async ({ id }: StepInput, { container }) => {
|
||||
const preorderModuleService = container.resolve("preorder")
|
||||
const preorderModuleService = container.resolve(PREORDER_MODULE)
|
||||
|
||||
const oldData = await preorderModuleService.retrievePreorderVariant(id)
|
||||
|
||||
@@ -973,7 +982,7 @@ export const disablePreorderVariantStep = createStep(
|
||||
return
|
||||
}
|
||||
|
||||
const preorderModuleService = container.resolve("preorder")
|
||||
const preorderModuleService = container.resolve(PREORDER_MODULE)
|
||||
|
||||
await preorderModuleService.updatePreorderVariants({
|
||||
id: preorderVariant.id,
|
||||
@@ -1665,6 +1674,7 @@ export const createPreordersStepHighlights = [
|
||||
|
||||
```ts title="src/workflows/steps/create-preorders.ts" highlights={createPreordersStepHighlights}
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
import { PREORDER_MODULE } from "../../modules/preorder"
|
||||
|
||||
type StepInput = {
|
||||
preorder_variant_ids: string[]
|
||||
@@ -1677,7 +1687,7 @@ export const createPreordersStep = createStep(
|
||||
preorder_variant_ids,
|
||||
order_id,
|
||||
}: StepInput, { container }) => {
|
||||
const preorderModuleService = container.resolve("preorder")
|
||||
const preorderModuleService = container.resolve(PREORDER_MODULE)
|
||||
|
||||
const preorders = await preorderModuleService.createPreorders(
|
||||
preorder_variant_ids.map((id) => ({
|
||||
@@ -1693,7 +1703,7 @@ export const createPreordersStep = createStep(
|
||||
return
|
||||
}
|
||||
|
||||
const preorderModuleService = container.resolve("preorder")
|
||||
const preorderModuleService = container.resolve(PREORDER_MODULE)
|
||||
|
||||
await preorderModuleService.deletePreorders(preorderIds)
|
||||
}
|
||||
@@ -2700,6 +2710,7 @@ export const updatePreordersHighlights = [
|
||||
```ts title="src/workflows/steps/update-preorders.ts" highlights={updatePreordersHighlights}
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
import { PreorderStatus } from "../../modules/preorder/models/preorder"
|
||||
import { PREORDER_MODULE } from "../../modules/preorder"
|
||||
|
||||
type StepInput = {
|
||||
id: string
|
||||
@@ -2711,7 +2722,7 @@ type StepInput = {
|
||||
export const updatePreordersStep = createStep(
|
||||
"update-preorders",
|
||||
async (preorders: StepInput, { container }) => {
|
||||
const preorderModuleService = container.resolve("preorder")
|
||||
const preorderModuleService = container.resolve(PREORDER_MODULE)
|
||||
|
||||
const oldPreorders = await preorderModuleService.listPreorders({
|
||||
id: preorders.map((preorder) => preorder.id),
|
||||
@@ -2728,7 +2739,7 @@ export const updatePreordersStep = createStep(
|
||||
return
|
||||
}
|
||||
|
||||
const preorderModuleService = container.resolve("preorder")
|
||||
const preorderModuleService = container.resolve(PREORDER_MODULE)
|
||||
|
||||
await preorderModuleService.updatePreorders(
|
||||
preorders.map((preorder) => ({
|
||||
|
||||
@@ -711,6 +711,12 @@ The `createProductBuilderStep` creates a new product builder configuration.
|
||||
|
||||
To create the step, create the file `src/workflows/steps/create-product-builder.ts` with the following content:
|
||||
|
||||
<Note>
|
||||
|
||||
If you get a type error on resolving the Product Builder Module, run the Medusa application once with the `npm run dev` or `yarn dev` command to generate the necessary type definitions, as explained in the [Automatically Generated Types guide](!docs!/learn/fundamentals/generated-types).
|
||||
|
||||
</Note>
|
||||
|
||||
export const createProductBuilderStepHighlights = [
|
||||
["11", "productBuilderModuleService", "Resolve the module service from container."],
|
||||
["13", "productBuilder", "Create the product builder record."],
|
||||
|
||||
@@ -399,6 +399,12 @@ The `useQueryGraphStep` step is provided by Medusa in its `@medusajs/medusa/core
|
||||
|
||||
In the second step of the workflow, you create the review. To create a step, create the file `src/workflows/steps/create-review.ts` with the following content:
|
||||
|
||||
<Note>
|
||||
|
||||
If you get a type error on resolving the Product Review Module, run the Medusa application once with the `npm run dev` or `yarn dev` command to generate the necessary type definitions, as explained in the [Automatically Generated Types guide](!docs!/learn/fundamentals/generated-types).
|
||||
|
||||
</Note>
|
||||
|
||||
export const createReviewHighlights = [
|
||||
["22", "reviewModuleService", "Resolve the Review Module's service"],
|
||||
["26", "createReviews", "Create the review"],
|
||||
|
||||
Reference in New Issue
Block a user