docs: fix limit text length code (#13752)

This commit is contained in:
Shahed Nasser
2025-10-16 08:23:29 +03:00
committed by GitHub
parent 8642d41aac
commit a5df43cde7
3 changed files with 48 additions and 15 deletions

View File

@@ -76,7 +76,10 @@ const Post = model.define("post", {
// ...
})
.checks([
(columns) => `${columns.name.length} <= 50`,
{
name: "limit_name_length",
expression: (columns) => `LENGTH(${columns.name}) <= 50`,
}
])
export default Post

View File

@@ -115,7 +115,7 @@ export const generatedEditDates = {
"app/learn/configurations/ts-aliases/page.mdx": "2025-07-23T15:32:18.008Z",
"app/learn/production/worker-mode/page.mdx": "2025-07-18T15:19:45.352Z",
"app/learn/fundamentals/module-links/read-only/page.mdx": "2025-08-15T11:52:13.403Z",
"app/learn/fundamentals/data-models/properties/page.mdx": "2025-07-31T08:22:20.431Z",
"app/learn/fundamentals/data-models/properties/page.mdx": "2025-10-15T05:36:40.576Z",
"app/learn/fundamentals/framework/page.mdx": "2025-06-26T14:26:22.120Z",
"app/learn/fundamentals/api-routes/retrieve-custom-links/page.mdx": "2025-07-14T10:24:32.582Z",
"app/learn/fundamentals/workflows/errors/page.mdx": "2025-04-25T14:26:25.000Z",

View File

@@ -10850,7 +10850,10 @@ const Post = model.define("post", {
// ...
})
.checks([
(columns) => `${columns.name.length} <= 50`,
{
name: "limit_name_length",
expression: (columns) => `LENGTH(${columns.name}) <= 50`,
}
])
export default Post
@@ -55193,8 +55196,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.
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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
***
## Step 3: Send Product Feed
@@ -55521,6 +55522,8 @@ 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:
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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
```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"
@@ -59555,6 +59558,8 @@ 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:
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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
```ts title="src/workflows/steps/update-invoice-config.ts" highlights={updateInvoiceConfigHighlights}
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { INVOICE_MODULE } from "../../modules/invoice-generator"
@@ -62040,6 +62045,8 @@ 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:
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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
```ts title="src/workflows/steps/deduct-purchase-points.ts" highlights={deductStepHighlights} collapsibleLines="1-7" expandButtonLabel="Show Imports"
import {
createStep,
@@ -65770,8 +65777,11 @@ 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:
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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
```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"
@@ -65787,7 +65797,7 @@ export const updatePreorderVariantStep = createStep(
"update-preorder-variant",
async (input: StepInput, { container }) => {
const preorderModuleService = container.resolve(
"preorder"
PREORDER_MODULE
)
const oldData = await preorderModuleService.retrievePreorderVariant(
@@ -65806,7 +65816,7 @@ export const updatePreorderVariantStep = createStep(
}
const preorderModuleService = container.resolve(
"preorder"
PREORDER_MODULE
)
await preorderModuleService.updatePreorderVariants({
@@ -65847,6 +65857,7 @@ To create the step, create the file `src/workflows/steps/create-preorder-variant
```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
@@ -65857,7 +65868,7 @@ export const createPreorderVariantStep = createStep(
"create-preorder-variant",
async (input: StepInput, { container }) => {
const preorderModuleService = container.resolve(
"preorder"
PREORDER_MODULE
)
const preorderVariant = await preorderModuleService.createPreorderVariants(
@@ -65872,7 +65883,7 @@ export const createPreorderVariantStep = createStep(
}
const preorderModuleService = container.resolve(
"preorder"
PREORDER_MODULE
)
await preorderModuleService.deletePreorderVariants(preorderVariantId)
@@ -66103,6 +66114,7 @@ Create the file `src/workflows/steps/disable-preorder-variant.ts` with the follo
```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"
@@ -66114,7 +66126,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)
@@ -66130,7 +66142,7 @@ export const disablePreorderVariantStep = createStep(
return
}
const preorderModuleService = container.resolve("preorder")
const preorderModuleService = container.resolve(PREORDER_MODULE)
await preorderModuleService.updatePreorderVariants({
id: preorderVariant.id,
@@ -66730,6 +66742,7 @@ Create the file `src/workflows/steps/create-preorders.ts` with the following con
```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[]
@@ -66742,7 +66755,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) => ({
@@ -66758,7 +66771,7 @@ export const createPreordersStep = createStep(
return
}
const preorderModuleService = container.resolve("preorder")
const preorderModuleService = container.resolve(PREORDER_MODULE)
await preorderModuleService.deletePreorders(preorderIds)
}
@@ -67665,6 +67678,7 @@ Create the file `src/workflows/steps/update-preorders.ts` with the following con
```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
@@ -67676,7 +67690,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),
@@ -67693,7 +67707,7 @@ export const updatePreordersStep = createStep(
return
}
const preorderModuleService = container.resolve("preorder")
const preorderModuleService = container.resolve(PREORDER_MODULE)
await preorderModuleService.updatePreorders(
preorders.map((preorder) => ({
@@ -69085,6 +69099,8 @@ 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:
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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
```ts title="src/workflows/steps/create-product-builder.ts" highlights={createProductBuilderStepHighlights}
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { PRODUCT_BUILDER_MODULE } from "../../modules/product-builder"
@@ -75209,6 +75225,8 @@ 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:
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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
```ts title="src/workflows/steps/create-review.ts" highlights={createReviewHighlights}
import {
createStep,
@@ -78469,6 +78487,8 @@ In the second step of the workflow, you create or update indexes in Algolia for
To create the step, create the file `src/workflows/steps/sync-products.ts` with the following content:
If you get a type error on resolving the Algolia 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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
```ts title="src/workflows/steps/sync-products.ts"
import { ProductDTO } from "@medusajs/framework/types"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
@@ -80509,6 +80529,8 @@ In the second step, you create the retrieved products in Contentful.
To create the step, create the file `src/workflows/steps/create-products-contentful.ts` with the following content:
If you get a type error on resolving the Contentful 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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
```ts title="src/workflows/steps/create-products-contentful.ts" highlights={createProductsContentfulStepHighlights}
import { ProductDTO } from "@medusajs/framework/types"
import { CONTENTFUL_MODULE } from "../../modules/contentful"
@@ -82775,6 +82797,8 @@ The first step of the workflow retrieves and returns the products from Magento.
In your plugin, create the file `src/workflows/steps/get-magento-products.ts` with the following content:
If you get a type error on resolving the Magento 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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
![Diagram showcasing the get-magento-products file to create](https://res.cloudinary.com/dza7lstvk/image/upload/v1739349590/Medusa%20Resources/magento-5_ueb4wn.jpg)
```ts title="src/workflows/steps/get-magento-products.ts"
@@ -84777,6 +84801,8 @@ In the second step of the workflow, you create or update indexes in Meilisearch
To create the step, create the file `src/workflows/steps/sync-products.ts` with the following content:
If you get a type error on resolving the Meilisearch 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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
```ts title="src/workflows/steps/sync-products.ts"
import { ProductDTO } from "@medusajs/framework/types"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
@@ -86966,6 +86992,8 @@ The `createPayloadItemsStep` will create an item in a Payload collection, such a
To create the step, create the file `src/workflows/steps/create-payload-items.ts` with the following content:
If you get a type error on resolving the Payload 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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
```ts title="src/workflows/steps/create-payload-items.ts" badgeLabel="Medusa application" badgeColor="green" highlights={createPayloadItemsStepHighlights}
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { PayloadUpsertData } from "../../modules/payload/types"
@@ -90755,6 +90783,8 @@ The syncing workflow will have a single step that syncs products provided as an
So, to implement that step, create the file `src/workflows/sanity-sync-products/steps/sync.ts` with the following content:
If you get a type error on resolving the Sanity 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](https://docs.medusajs.com/docs/learn/fundamentals/generated-types/index.html.md).
```ts title="src/workflows/sanity-sync-products/steps/sync.ts" highlights={syncStepHighlights}
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { ProductDTO } from "@medusajs/framework/types"