From 24199fa47a8ae81e98082651a55726fca2473c99 Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Tue, 2 Sep 2025 09:07:07 +0300 Subject: [PATCH] docs: general updates and fixes (#13374) * docs: general updates and fixes * fix lint errors --- www/apps/book/public/llms-full.txt | 363 +++++++++--------- .../order/transactions/page.mdx | 2 +- .../payment/module-options/page.mdx | 10 +- .../payment/payment-collection/page.mdx | 6 +- .../pricing/concepts/page.mdx | 14 +- .../promotion/application-method/page.mdx | 38 +- .../stock-location/concepts/page.mdx | 8 +- .../user/module-options/page.mdx | 4 +- .../app/integrations/guides/payload/page.mdx | 42 +- .../app/medusa-cli/commands/build/page.mdx | 40 +- .../app/medusa-cli/commands/develop/page.mdx | 8 +- .../app/medusa-cli/commands/user/page.mdx | 26 +- .../methods/create/page.mdx | 8 +- .../methods/delete/page.mdx | 12 +- .../methods/list/page.mdx | 16 +- .../methods/listAndCount/page.mdx | 16 +- .../methods/restore/page.mdx | 30 +- .../methods/retrieve/page.mdx | 8 +- .../methods/soft-delete/page.mdx | 34 +- .../methods/update/page.mdx | 31 +- .../app/service-factory-reference/page.mdx | 16 +- .../medusaIntegrationTestRunner/page.mdx | 62 ++- .../moduleIntegrationTestRunner/page.mdx | 33 +- .../_sections/scheduled-jobs/not-running.mdx | 4 +- www/apps/resources/generated/edit-dates.mjs | 42 +- 25 files changed, 477 insertions(+), 396 deletions(-) diff --git a/www/apps/book/public/llms-full.txt b/www/apps/book/public/llms-full.txt index b9baacfa17..159d41a6d2 100644 --- a/www/apps/book/public/llms-full.txt +++ b/www/apps/book/public/llms-full.txt @@ -30887,7 +30887,7 @@ The order’s total amounts are stored in the `OrderSummary`'s `totals` property } ``` -To check the outstanding amount of the order, its transaction amounts are summed. Then, the following conditions are checked: +To check the outstanding amount of the order, its transaction amounts (from the `Transaction` records) are summed. Then, the following conditions are checked: |Condition|Result| |---|---|---| @@ -31344,7 +31344,7 @@ createRemoteLinkStep({ # Payment Module Options -In this document, you'll learn about the options of the Payment Module. +In this document, you'll learn about the options you can pass to the Payment Module. ## All Module Options @@ -31358,7 +31358,7 @@ In this document, you'll learn about the options of the Payment Module. ## providers Option -The `providers` option is an array of payment module providers. +The `providers` option is an array of payment module providers to be registered in your Medusa application. When the Medusa application starts, these providers are registered and can be used to process payments. @@ -31392,10 +31392,12 @@ module.exports = defineConfig({ The `providers` option is an array of objects that accept the following properties: -- `resolve`: A string indicating the package name of the module provider or the path to it relative to the `src` directory. +- `resolve`: A string indicating the package name of the module provider or the path to it. - `id`: A string indicating the provider's unique name or ID. - `options`: An optional object of the module provider's options. +Refer to the [Payment Module Providers](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-provider/index.html.md) documentation to learn more. + # Payment Module @@ -31604,7 +31606,7 @@ A payment collection stores payment details related to a resource, such as a car Every purchase or request for payment starts with a payment collection. The collection holds details necessary to complete the payment, including: -- The [payment sessions](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-session/index.html.md) that represents the payment amount to authorize. +- The [payment sessions](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-session/index.html.md) that represent the payment amount to authorize. - The [payments](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment/index.html.md) that are created when a payment session is authorized. They can be captured and refunded. - The [payment providers](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-provider/index.html.md) that handle the processing of each payment session, including the authorization, capture, and refund. @@ -31624,9 +31626,7 @@ You can use this to accept payments in increments or split payments across payme The Cart Module provides cart management features. However, it doesn’t provide any features related to accepting payment. -During checkout, the Medusa application links a cart to a payment collection, which will be used for further payment processing. - -It also implements the payment flow during checkout as explained in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-flow/index.html.md). +During checkout, the Medusa application links a cart to a payment collection, which will be used for further payment processing. It also implements the [payment flow](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/payment/payment-flow/index.html.md) during checkout. ![Diagram showcasing the relation between the Payment and Cart modules](https://res.cloudinary.com/dza7lstvk/image/upload/v1711537849/Medusa%20Resources/cart-payment_ixziqm.jpg) @@ -32188,13 +32188,13 @@ View the full flow of the webhook event processing in the [processPaymentWorkflo # Pricing Concepts -In this document, you’ll learn about the main concepts in the Pricing Module. +In this guide, you’ll learn about the main concepts in the Pricing Module. ## Price Data Model The [Price](https://docs.medusajs.com/references/pricing/models/Price/index.html.md) data model represents a specific price for a resource. For example, the price of a product variant in the USD currency. -The `Price` data model has an `amount` property that represents the monetary value of the price. It's stored as an integer in base units. For example, `$20.00` is stored as `20`. +The `Price` data model has an `amount` property that represents the monetary value of the price. It's stored as an integer in base or major units. For example, `$20.00` is stored as `20`, and `$20.5` is stored as `20.5`. The `Price` data model belongs to other data models like `PriceSet` and `PriceList` to provide a variety of pricing features, as explained below. @@ -32202,9 +32202,9 @@ The `Price` data model belongs to other data models like `PriceSet` and `PriceLi ## Price Set -A [PriceSet](https://docs.medusajs.com/references/pricing/models/PriceSet/index.html.md) represents a collection of prices that are linked to a resource (for example, a product variant or a shipping option). +A [PriceSet](https://docs.medusajs.com/references/pricing/models/PriceSet/index.html.md) represents a collection of prices that are linked to a resource. For example, a product variant can have a price set that includes prices in multiple currencies, such as USD and EUR. -Each of these prices is represented by the [Price data model](https://docs.medusajs.com/references/pricing/models/Price/index.html.md). +Each of these prices is represented by the [Price data model](#price-data-model). ![A diagram showcasing the relation between the price set and price](https://res.cloudinary.com/dza7lstvk/image/upload/v1709648650/Medusa%20Resources/price-set-money-amount_xeees0.jpg) @@ -32212,11 +32212,13 @@ Each of these prices is represented by the [Price data model](https://docs.medus ## Price List -A [PriceList](https://docs.medusajs.com/references/pricing/models/PriceList/index.html.md) is a group of prices only enabled if their conditions and rules are satisfied. +A [PriceList](https://docs.medusajs.com/references/pricing/models/PriceList/index.html.md) is a group of prices that are only enabled when their conditions and rules are satisfied. For example, you can apply special prices to customers in the VIP group. + +When the conditions are met, the prices in the price list override the default prices in a price set. A price list has optional `start_date` and `end_date` properties that indicate the date range in which a price list can be applied. -Its associated prices are represented by the `Price` data model. +Its associated prices are represented by the [Price data model](#price-data-model). # Links between Pricing Module and Other Modules @@ -34981,27 +34983,27 @@ Refer to [this reference](https://docs.medusajs.com/references/promotion/interfa # Application Method -In this document, you'll learn what an application method is. +In this guide, you'll learn what an application method is in the Promotion Module. ## What is an Application Method? -The [ApplicationMethod data model](https://docs.medusajs.com/references/promotion/models/ApplicationMethod/index.html.md) defines how a promotion is applied: +The [ApplicationMethod data model](https://docs.medusajs.com/references/promotion/models/ApplicationMethod/index.html.md) defines how a promotion is applied. It has the following properties that determine its behavior: -|Property|Purpose| -|---|---| -|\`type\`|Does the promotion discount a fixed amount or a percentage?| -|\`target\_type\`|Is the promotion applied on a cart item, shipping method, or the entire order?| -|\`allocation\`|Is the discounted amount applied on each item or split between the applicable items?| +|Property|Purpose|Possible Values| +|---|---|---| +|\`type\`|Does the promotion discount a fixed amount or a percentage?|\`fixed\`| +|\`target\_type\`|Is the promotion applied to a cart item, shipping method, or the entire order?|\`items\`| +|\`allocation\`|Is the discounted amount applied to each item or split between the applicable items?|\`each\`| ## Target Promotion Rules -When the promotion is applied to a cart item or a shipping method, you can restrict which items/shipping methods the promotion is applied to. +When the promotion is applied to a cart item or a shipping method (in other words, when `target_type` is `items` or `shipping_methods`), you can restrict which items/shipping methods the promotion is applied to. -The `ApplicationMethod` data model has a collection of `PromotionRule` records to restrict which items or shipping methods the promotion applies to. The `target_rules` property represents this relation. +The `ApplicationMethod` data model has a collection of [PromotionRule](https://docs.medusajs.com/references/promotion/models/PromotionRule/index.html.md) records to restrict which items or shipping methods the promotion applies to. The `target_rules` property in the `ApplicationMethod` represents this relation. ![A diagram showcasing the target\_rules relation between the ApplicationMethod and PromotionRule data models](https://res.cloudinary.com/dza7lstvk/image/upload/v1709898273/Medusa%20Resources/application-method-target-rules_hqaymz.jpg) -In this example, the promotion is only applied on products in the cart having the SKU `SHIRT`. +In this example, the promotion is only applied to product variants in the cart that have the SKU `SHIRT`. *** @@ -35009,11 +35011,11 @@ In this example, the promotion is only applied on products in the cart having th When the promotion’s type is `buyget`, you must specify the “buy X” condition. For example, a cart must have two shirts before the promotion can be applied. -The application method has a collection of `PromotionRule` items to define the “buy X” rule. The `buy_rules` property represents this relation. +The application method has a collection of `PromotionRule` items to define the “buy X” rule. The `buy_rules` property in the `ApplicationMethod` represents this relation. ![A diagram showcasing the buy\_rules relation between the ApplicationMethod and PromotionRule data models](https://res.cloudinary.com/dza7lstvk/image/upload/v1709898453/Medusa%20Resources/application-method-buy-rules_djjuhw.jpg) -In this example, the cart must have two products with the SKU `SHIRT` for the promotion to be applied. +In this example, the cart must have two product variants with the SKU `SHIRT` for the promotion to be applied. # Campaign @@ -36559,19 +36561,19 @@ Notice that the request object's type is `MedusaStoreRequest` instead of `Medusa # Stock Location Concepts -In this document, you’ll learn about the main concepts in the Stock Location Module. +In this guide, you’ll learn about the main concepts in the Stock Location Module. ## Stock Location -A stock location, represented by the `StockLocation` data model, represents a location where stock items are kept. For example, a warehouse. +A stock location, represented by the [StockLocation data model](https://docs.medusajs.com/references/stock-location-next/models/StockLocation/index.html.md), represents a location where stock items are kept. For example, a warehouse. -Medusa uses stock locations to provide inventory details, from the Inventory Module, per location. +Medusa uses stock locations to provide inventory details, stored and managed by the [Inventory Module](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/commerce-modules/inventory/concepts/index.html.md), per location. *** ## StockLocationAddress -The `StockLocationAddress` data model belongs to the `StockLocation` data model. It provides more detailed information of the location, such as country code or street address. +The [StockLocationAddress data model](https://docs.medusajs.com/references/stock-location-next/models/StockLocationAddress/index.html.md) belongs to the `StockLocation` data model. It provides more detailed information about the location, such as country code or street address. # Links between Stock Location Module and Other Modules @@ -37970,7 +37972,7 @@ class ResendNotificationProviderService extends AbstractNotificationProviderServ # User Module Options -In this document, you'll learn about the options of the User Module. +In this guide, you'll learn about the options you can pass to the User Module. ## Module Options @@ -37998,7 +38000,7 @@ module.exports = defineConfig({ ### Environment Variables -Make sure to add the necessary environment variables for the above options in `.env`: +Make sure to add the necessary environment variables for the above options to your `.env` file: ```bash JWT_SECRET=supersecret @@ -43274,56 +43276,26 @@ The following workflows emit this event when they're executed. These workflows a # build Command - Medusa CLI Reference -Create a standalone build of the Medusa application. +Create a standalone build of the Medusa application that you can deploy to production. This creates a build that: - Doesn't rely on the source TypeScript files. - Can be copied to a production server reliably. -The build is outputted to a new `.medusa/server` directory. +The build is output to a new `.medusa/server` directory. ```bash npx medusa build ``` -Refer to [this section](#run-built-medusa-application) for next steps. +Refer to the [Build Medusa Application](https://docs.medusajs.com/docs/learn/build/index.html.md) guide for next steps. ## Options |Option|Description| |---|---|---| -|\`--admin-only\`|Whether to only build the admin to host it separately. If this option is not passed, the admin is built to the | - -*** - -## Run Built Medusa Application - -After running the `build` command, use the following step to run the built Medusa application: - -- Change to the `.medusa/server` directory and install the dependencies: - -```bash npm2yarn -cd .medusa/server && npm install -``` - -- When running the application locally, make sure to copy the `.env` file from the root project's directory. In production, use system environment variables instead. - -```bash npm2yarn -cp .env .medusa/server/.env.production -``` - -- In the system environment variables, set `NODE_ENV` to `production`: - -```bash -NODE_ENV=production -``` - -- Use the `start` command to run the application: - -```bash npm2yarn -cd .medusa/server && npm run start -``` +|\`--admin-only\`|Whether to build only the admin to host it separately. If this option is not passed, the admin is built to the | *** @@ -43331,7 +43303,7 @@ cd .medusa/server && npm run start By default, the Medusa Admin is built to the `.medusa/server/public/admin` directory. -If you want a separate build to host the admin standalone, such as on Vercel, pass the `--admin-only` option as explained in the [Options](#options) section. This outputs the admin to the `.medusa/admin` directory instead. +If you want a separate build to host the admin as a standalone application, such as on Vercel, pass the `--admin-only` option as explained in the [Options](#options) section. This outputs the admin to the `.medusa/admin` directory instead. # db Commands - Medusa CLI Reference @@ -43456,7 +43428,9 @@ npx medusa db:sync-links # develop Command - Medusa CLI Reference -Start Medusa application in development. This command watches files for any changes, then rebuilds the files and restarts the Medusa application. +Start the Medusa application in development. + +This command watches files for any changes, then rebuilds the files and restarts the Medusa application. ```bash npx medusa develop @@ -43466,8 +43440,8 @@ npx medusa develop |Option|Description|Default| |---|---|---|---|---| -|\`-H \\`|Set host of the Medusa server.|\`localhost\`| -|\`-p \\`|Set port of the Medusa server.|\`9000\`| +|\`-H \\`|Set the host of the Medusa server.|\`localhost\`| +|\`-p \\`|Set the port of the Medusa server.|\`9000\`| # exec Command - Medusa CLI Reference @@ -43623,9 +43597,25 @@ npx medusa user --email [--password ] |---|---|---|---|---|---|---| |\`-e \\`|The user's email.|Yes|-| |\`-p \\`|The user's password.|No|-| -|\`-i \\`|The user's ID.|No|An automatically generated ID.| -|\`--invite\`|Whether to create an invite instead of a user. When using this option, you don't need to specify a password. -If ran successfully, you'll receive the invite token in the output.|No|\`false\`| +|\`-i \\`|The user's ID.|No|An automatically generated ID is used.| +|\`--invite\`|Whether to create a user invite instead of directly creating a user. Learn more in the |No|\`false\`| + +*** + +## Create User Invite with Medusa CLI + +The `user` command accepts the `--invite` option to create a user invite. The user must accept the invite before they can log into the Medusa Admin. + +For example: + +```bash +npx medusa user --email user@example.com --invite +``` + +The command will create a user invite and output the invite token. You can then either: + +- Accept the invite in the Medusa Admin at the path `/app/invite?token=` +- Accept the invite using the [Accept Invite API route](https://docs.medusajs.com/api/admin#invites_postinvitesaccept). # Medusa CLI Reference @@ -43653,56 +43643,26 @@ npx medusa --help # build Command - Medusa CLI Reference -Create a standalone build of the Medusa application. +Create a standalone build of the Medusa application that you can deploy to production. This creates a build that: - Doesn't rely on the source TypeScript files. - Can be copied to a production server reliably. -The build is outputted to a new `.medusa/server` directory. +The build is output to a new `.medusa/server` directory. ```bash npx medusa build ``` -Refer to [this section](#run-built-medusa-application) for next steps. +Refer to the [Build Medusa Application](https://docs.medusajs.com/docs/learn/build/index.html.md) guide for next steps. ## Options |Option|Description| |---|---|---| -|\`--admin-only\`|Whether to only build the admin to host it separately. If this option is not passed, the admin is built to the | - -*** - -## Run Built Medusa Application - -After running the `build` command, use the following step to run the built Medusa application: - -- Change to the `.medusa/server` directory and install the dependencies: - -```bash npm2yarn -cd .medusa/server && npm install -``` - -- When running the application locally, make sure to copy the `.env` file from the root project's directory. In production, use system environment variables instead. - -```bash npm2yarn -cp .env .medusa/server/.env.production -``` - -- In the system environment variables, set `NODE_ENV` to `production`: - -```bash -NODE_ENV=production -``` - -- Use the `start` command to run the application: - -```bash npm2yarn -cd .medusa/server && npm run start -``` +|\`--admin-only\`|Whether to build only the admin to host it separately. If this option is not passed, the admin is built to the | *** @@ -43710,7 +43670,7 @@ cd .medusa/server && npm run start By default, the Medusa Admin is built to the `.medusa/server/public/admin` directory. -If you want a separate build to host the admin standalone, such as on Vercel, pass the `--admin-only` option as explained in the [Options](#options) section. This outputs the admin to the `.medusa/admin` directory instead. +If you want a separate build to host the admin as a standalone application, such as on Vercel, pass the `--admin-only` option as explained in the [Options](#options) section. This outputs the admin to the `.medusa/admin` directory instead. # db Commands - Medusa CLI Reference @@ -43835,7 +43795,9 @@ npx medusa db:sync-links # develop Command - Medusa CLI Reference -Start Medusa application in development. This command watches files for any changes, then rebuilds the files and restarts the Medusa application. +Start the Medusa application in development. + +This command watches files for any changes, then rebuilds the files and restarts the Medusa application. ```bash npx medusa develop @@ -43845,8 +43807,8 @@ npx medusa develop |Option|Description|Default| |---|---|---|---|---| -|\`-H \\`|Set host of the Medusa server.|\`localhost\`| -|\`-p \\`|Set port of the Medusa server.|\`9000\`| +|\`-H \\`|Set the host of the Medusa server.|\`localhost\`| +|\`-p \\`|Set the port of the Medusa server.|\`9000\`| # exec Command - Medusa CLI Reference @@ -44002,9 +43964,25 @@ npx medusa user --email [--password ] |---|---|---|---|---|---|---| |\`-e \\`|The user's email.|Yes|-| |\`-p \\`|The user's password.|No|-| -|\`-i \\`|The user's ID.|No|An automatically generated ID.| -|\`--invite\`|Whether to create an invite instead of a user. When using this option, you don't need to specify a password. -If ran successfully, you'll receive the invite token in the output.|No|\`false\`| +|\`-i \\`|The user's ID.|No|An automatically generated ID is used.| +|\`--invite\`|Whether to create a user invite instead of directly creating a user. Learn more in the |No|\`false\`| + +*** + +## Create User Invite with Medusa CLI + +The `user` command accepts the `--invite` option to create a user invite. The user must accept the invite before they can log into the Medusa Admin. + +For example: + +```bash +npx medusa user --email user@example.com --invite +``` + +The command will create a user invite and output the invite token. You can then either: + +- Accept the invite in the Medusa Admin at the path `/app/invite?token=` +- Accept the invite using the [Accept Invite API route](https://docs.medusajs.com/api/admin#invites_postinvitesaccept). # Medusa CLI Reference @@ -93713,7 +93691,9 @@ These components allow you to use common Medusa Admin components in your custom # create Method - Service Factory Reference -This method creates one or more records of the data model. +This method of a module's service creates one or more records of a data model. + +The method's name is of the format `createDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Create One Record @@ -93727,7 +93707,7 @@ const post = await postModuleService.createPosts({ }) ``` -If an object is passed of the method, an object of the created record is also returned. +If an object is passed to the method, the created record object is returned. *** @@ -93746,12 +93726,14 @@ const posts = await postModuleService.createPosts([ ]) ``` -If an array is passed of the method, an array of the created records is also returned. +If an array of objects is passed to the method, an array containing the created records is returned. # delete Method - Service Factory Reference -This method deletes one or more records. +This method of a module's service deletes one or more records. + +The method's name is `deleteDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Delete One Record @@ -93759,7 +93741,7 @@ This method deletes one or more records. await postModuleService.deletePosts("123") ``` -To delete one record, pass its ID as a parameter of the method. +To delete one record, pass its ID as a parameter to the method. *** @@ -93772,7 +93754,7 @@ await postModuleService.deletePosts([ ]) ``` -To delete multiple records, pass an array of IDs as a parameter of the method. +To delete multiple records, pass an array of IDs as a parameter to the method. *** @@ -93784,14 +93766,16 @@ await postModuleService.deletePosts({ }) ``` -To delete records matching a set of filters, pass an object of filters as a parameter. +To delete records matching a set of filters, pass an object of filters as a parameter to the method. -Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md). +Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples. # list Method - Service Factory Reference -This method retrieves a list of records. +This method of a module's service retrieves a list of records. + +The method's name is `listDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Retrieve List of Records @@ -93813,9 +93797,9 @@ const posts = await postModuleService.listPosts({ ### Parameters -To retrieve records matching a set of filters, pass an object of the filters as a first parameter. +To retrieve records matching a set of filters, pass an object of the filters as the first parameter. -Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md). +Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples. ### Returns @@ -93835,7 +93819,7 @@ const posts = await postModuleService.listPosts({}, { ### Parameters -To retrieve records with their relations, pass as a second parameter an object having a `relations` property. `relations`'s value is an array of relation names. +To retrieve records with their relations, pass an object with a `relations` property as the second parameter. `relations`'s value is an array of relation names. ### Returns @@ -93853,7 +93837,7 @@ const posts = await postModuleService.listPosts({}, { ### Parameters -By default, retrieved records have all their properties. To select specific properties to retrieve, pass in the second object parameter a `select` property. +By default, retrieved records have all their properties. To select specific properties to retrieve, pass a `select` property in the second object parameter. `select`'s value is an array of property names to retrieve. @@ -93863,7 +93847,7 @@ The method returns an array of the first `15` records matching the filters. *** -## Paginate Relations +## Paginate Records ```ts const posts = await postModuleService.listPosts({}, { @@ -93897,7 +93881,7 @@ const posts = await postModuleService.listPosts({}, { ### Parameters -To sort records by one or more properties, pass to the second object parameter the `order` property. Its value is an object whose keys are the property names, and values can either be: +To sort records by one or more properties, pass an `order` property in the second object parameter. Its value is an object whose keys are the property names, and values can either be: - `ASC` to sort by this property in the ascending order. - `DESC` to sort by this property in the descending order. @@ -93909,7 +93893,9 @@ The method returns an array of the first `15` records matching the filters. # listAndCount Method - Service Factory Reference -This method retrieves a list of records with the total count. +This method of a module's service retrieves a list of records with the total count. + +The method's name is `listAndCountDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Retrieve List of Records @@ -93934,9 +93920,9 @@ const [posts, count] = await postModuleService.listAndCountPosts({ ### Parameters -To retrieve records matching a set of filters, pass an object of the filters as a first parameter. +To retrieve records matching a set of filters, pass an object of the filters as the first parameter. -Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md). +Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples. ### Returns @@ -93959,7 +93945,7 @@ const [posts, count] = await postModuleService.listAndCountPosts({}, { ### Parameters -To retrieve records with their relations, pass as a second parameter an object having a `relations` property. Its value is an array of relation names. +To retrieve records with their relations, pass an object with a `relations` property as the second parameter. Its value is an array of relation names. ### Returns @@ -93980,7 +93966,7 @@ const [posts, count] = await postModuleService.listAndCountPosts({}, { ### Parameters -By default, retrieved records have all their properties. To select specific properties to retrieve, pass in the second object parameter a `select` property. +By default, retrieved records have all their properties. To select specific properties to retrieve, pass a `select` property in the second object parameter. `select`'s value is an array of property names to retrieve. @@ -93993,7 +93979,7 @@ The method returns an array with two items: *** -## Paginate Relations +## Paginate Records ```ts const [posts, count] = await postModuleService.listAndCountPosts({}, { @@ -94030,7 +94016,7 @@ const [posts, count] = await postModuleService.listAndCountPosts({}, { ### Parameters -To sort records by one or more properties, pass to the second object parameter the `order` property. Its value is an object whose keys are the property names, and values can either be: +To sort records by one or more properties, pass an `order` property in the second object parameter. Its value is an object whose keys are the property names, and values can either be: - `ASC` to sort by this property in the ascending order. - `DESC` to sort by this property in the descending order. @@ -94045,7 +94031,9 @@ The method returns an array with two items: # restore Method - Service Factory Reference -This method restores one or more records of the data model that were [soft-deleted](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/methods/soft-delete/index.html.md). +This method of a module's service restores one or more records of a data model that were [soft-deleted](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/methods/soft-delete/index.html.md). + +The method's name is of the format `restoreDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Restore One Record @@ -94055,7 +94043,7 @@ const restoredPosts = await postModuleService.restorePosts("123") ### Parameters -To restore one record, pass its ID as a parameter of the method. +To restore one record, pass its ID as a parameter to the method. ### Returns @@ -94063,9 +94051,9 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: -```ts -restoredPosts = { - post_id: ["123"], +```json +{ + "post_id": ["123"], } ``` @@ -94082,7 +94070,7 @@ const restoredPosts = await postModuleService.restorePosts([ ### Parameters -To restore multiple records, pass an array of IDs as a parameter of the method. +To restore multiple records, pass an array of IDs as a parameter to the method. ### Returns @@ -94090,9 +94078,9 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: -```ts -restoredPosts = { - post_id: [ +```json +{ + "post_id": [ "123", "321", ], @@ -94111,9 +94099,9 @@ const restoredPosts = await postModuleService.restorePosts({ ### Parameters -To restore records matching a set of filters, pass an object of fitlers as a parameter of the method. +To restore records matching a set of filters, pass an object of filters as a parameter to the method. -Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md). +Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples. ### Returns @@ -94121,9 +94109,9 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: -```ts -restoredPosts = { - post_id: [ +```json +{ + "post_id": [ "123", ], } @@ -94132,7 +94120,9 @@ restoredPosts = { # retrieve Method - Service Factory Reference -This method retrieves one record of the data model by its ID. +This method retrieves one record of a data model by its ID. + +The method's name is `retrieveDataModel`, where `DataModel` is the singular pascal-case name of the data model. ## Retrieve a Record @@ -94162,7 +94152,7 @@ const post = await postModuleService.retrievePost("123", { ### Parameters -To retrieve the data model with relations, pass as a second parameter of the method an object with the property `relations`. `relations`'s value is an array of relation names. +To retrieve the data model with relations, pass an object with the property `relations` as the second parameter. `relations`'s value is an array of relation names. ### Returns @@ -94180,7 +94170,7 @@ const post = await postModuleService.retrievePost("123", { ### Parameters -By default, all of the record's properties are retrieved. To select specific ones, pass in the second object parameter a `select` property. Its value is an array of property names. +By default, all of the record's properties are retrieved. To select specific ones, pass a `select` property in the second object parameter. Its value is an array of property names. ### Returns @@ -94189,7 +94179,9 @@ The method returns the record as an object. # softDelete Method - Service Factory Reference -This method soft deletes one or more records of the data model. +This method of a module's service soft deletes one or more records of a data model. + +The method's name is of the format `softDeleteDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Soft Delete One Record @@ -94201,7 +94193,7 @@ const deletedPosts = await postModuleService.softDeletePosts( ### Parameters -To soft delete a record, pass its ID as a parameter of the method. +To soft delete a record, pass its ID as a parameter to the method. ### Returns @@ -94210,8 +94202,8 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: ```ts -deletedPosts = { - post_id: ["123"], +{ + "post_id": ["123"], } ``` @@ -94228,7 +94220,7 @@ const deletedPosts = await postModuleService.softDeletePosts([ ### Parameters -To soft delete multiple records, pass an array of IDs as a parameter of the method. +To soft delete multiple records, pass an array of IDs as a parameter to the method. ### Returns @@ -94237,8 +94229,8 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: ```ts -deletedPosts = { - post_id: [ +{ + "post_id": [ "123", "321", ], @@ -94257,9 +94249,9 @@ const deletedPosts = await postModuleService.softDeletePosts({ ### Parameters -To soft delete records matching a set of filters, pass an object of filters as a parameter. +To soft delete records matching a set of filters, pass an object of filters as a parameter to the method. -Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md). +Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples. ### Returns @@ -94268,15 +94260,17 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: ```ts -deletedPosts = { - post_id: ["123"], +{ + "post_id": ["123"], } ``` # update Method - Service Factory Reference -This method updates one or more records of the data model. +This method of a module's service updates one or more records. + +The method's name is `updateDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Update One Record @@ -94289,7 +94283,7 @@ const post = await postModuleService.updatePosts({ ### Parameters -To update one record, pass an object that at least has an `id` property, identifying the ID of the record to update. +To update one record, pass an object that has at least an `id` property, identifying the ID of the record to update. You can pass in the same object any other properties to update. @@ -94316,13 +94310,13 @@ const posts = await postModuleService.updatePosts([ ### Parameters -To update multiple records, pass an array of objects. Each object has at least an `id` property, identifying the ID of the record to update. +To update multiple records, pass an array of objects. Each object must have at least an `id` property, identifying the ID of the record to update. You can pass in each object any other properties to update. ### Returns -The method returns an array of objects of updated records. +The method returns an array of updated record objects. *** @@ -94341,18 +94335,18 @@ const posts = await postModuleService.updatePosts({ ### Parameters -To update records that match specified filters, pass as a parameter an object having two properties: +To update records that match specified filters, pass an object with two properties as a parameter: - `selector`: An object of filters that a record must match to be updated. - `data`: An object of the properties to update in every record that match the filters in `selector`. In the example above, you update the `published_at` property of every post record whose name is `My Post`. -Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md). +Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples. ### Returns -The method returns an array of objects of updated records. +The method returns an array of updated record objects. *** @@ -94390,17 +94384,17 @@ To update records matching different sets of filters, pass an array of objects, In the example above, you update the `published_at` property of post records whose name is `My Post`, and update the `metadata` property of post records whose name is `Another Post`. -Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md). +Refer to the [Filtering](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md) reference for more information on accepted filters and examples. ### Returns -The method returns an array of objects of updated records. +The method returns an array of updated record objects. *** ## Update a JSON Property -```ts +```ts highlights={highlights} const post = await postModuleService.updatePosts({ id: "123", name: "My Post", @@ -94411,13 +94405,14 @@ const post = await postModuleService.updatePosts({ }) ``` -When you have a JSON property in your data model, you can update it by adding, updating, or removing properties within that JSON object. Medusa will merge the properties you pass in the `update` method with the existing JSON object. +When you have a [JSON property](https://docs.medusajs.com/docs/learn/fundamentals/data-models/json-properties/index.html.md) in your data model, you can update it by adding, updating, or removing properties within that JSON object. Medusa will merge the properties you pass in the `update` method with the existing JSON object. ### Remove a Property from the JSON Property -```ts +```ts highlights={highlights} const post = await postModuleService.updatePosts({ id: "123", + name: "My Post", metadata: { is_featured: "", }, @@ -94441,22 +94436,22 @@ Refer to the [Service Factory](https://docs.medusajs.com/docs/learn/fundamentals When your module's main service extends the service factory, Medusa will: -1. Generate data-management methods in your main service for each of the data models passed to the `MedusaService` function. -2. Generate internal services for each of the data models passed to the `MedusaService` function, which can be resolved in loaders. +1. Generate [data-management methods in your main service](#main-service-methods) for each of the data models passed to the `MedusaService` function. +2. Generate [internal services](#internal-generated-service-methods) for each of the data models passed to the `MedusaService` function, which can be resolved in loaders. ### Main Service Methods -The names of the generated methods for a service extending the service factory are of the format `{operationName}_{dataModelName}`, where: +The names of the generated methods for a service extending the service factory are of the format `{operationName}{DataModelName}`, where: - `{operationName}` is the name of the operation. For example, `create`. -- `{dataModelName}` is the pascal-case version of the data model's key that's passed in the object parameter of `MedusaService`. The name is pluralized for all operations except the `retrieve` operation. +- `{DataModelName}` is the pascal-case version of the data model's key that's passed in the object parameter of `MedusaService`. The name is pluralized for all operations except the `retrieve` operation. Some examples of method names: -- `createPosts` -- `createMyPosts` -- `retrievePost` -- `listPosts` +- `createPosts` (`Post` data model) +- `createMyPosts` (`MyPost` data model) +- `retrievePost` (`Post` data model) +- `listPosts` (`Post` data model) ### Internal Generated Service Methods diff --git a/www/apps/resources/app/commerce-modules/order/transactions/page.mdx b/www/apps/resources/app/commerce-modules/order/transactions/page.mdx index 699916e018..5e440e0f71 100644 --- a/www/apps/resources/app/commerce-modules/order/transactions/page.mdx +++ b/www/apps/resources/app/commerce-modules/order/transactions/page.mdx @@ -32,7 +32,7 @@ The order’s total amounts are stored in the `OrderSummary`'s `totals` property } ``` -To check the outstanding amount of the order, its transaction amounts are summed. Then, the following conditions are checked: +To check the outstanding amount of the order, its transaction amounts (from the `Transaction` records) are summed. Then, the following conditions are checked: diff --git a/www/apps/resources/app/commerce-modules/payment/module-options/page.mdx b/www/apps/resources/app/commerce-modules/payment/module-options/page.mdx index f06a9abedc..c2391c8c31 100644 --- a/www/apps/resources/app/commerce-modules/payment/module-options/page.mdx +++ b/www/apps/resources/app/commerce-modules/payment/module-options/page.mdx @@ -10,7 +10,7 @@ export const metadata = { # {metadata.title} -In this document, you'll learn about the options of the Payment Module. +In this document, you'll learn about the options you can pass to the Payment Module. ## All Module Options @@ -97,7 +97,7 @@ In this document, you'll learn about the options of the Payment Module. ## providers Option -The `providers` option is an array of payment module providers. +The `providers` option is an array of payment module providers to be registered in your Medusa application. When the Medusa application starts, these providers are registered and can be used to process payments. @@ -131,6 +131,8 @@ module.exports = defineConfig({ The `providers` option is an array of objects that accept the following properties: -- `resolve`: A string indicating the package name of the module provider or the path to it relative to the `src` directory. +- `resolve`: A string indicating the package name of the module provider or the path to it. - `id`: A string indicating the provider's unique name or ID. -- `options`: An optional object of the module provider's options. \ No newline at end of file +- `options`: An optional object of the module provider's options. + +Refer to the [Payment Module Providers](../payment-provider/page.mdx) documentation to learn more. \ No newline at end of file diff --git a/www/apps/resources/app/commerce-modules/payment/payment-collection/page.mdx b/www/apps/resources/app/commerce-modules/payment/payment-collection/page.mdx index 149f866b4c..d95d8a2580 100644 --- a/www/apps/resources/app/commerce-modules/payment/payment-collection/page.mdx +++ b/www/apps/resources/app/commerce-modules/payment/payment-collection/page.mdx @@ -12,7 +12,7 @@ A payment collection stores payment details related to a resource, such as a car Every purchase or request for payment starts with a payment collection. The collection holds details necessary to complete the payment, including: -- The [payment sessions](../payment-session/page.mdx) that represents the payment amount to authorize. +- The [payment sessions](../payment-session/page.mdx) that represent the payment amount to authorize. - The [payments](../payment/page.mdx) that are created when a payment session is authorized. They can be captured and refunded. - The [payment providers](../payment-provider/page.mdx) that handle the processing of each payment session, including the authorization, capture, and refund. @@ -32,8 +32,6 @@ You can use this to accept payments in increments or split payments across payme The Cart Module provides cart management features. However, it doesn’t provide any features related to accepting payment. -During checkout, the Medusa application links a cart to a payment collection, which will be used for further payment processing. - -It also implements the payment flow during checkout as explained in [this documentation](../payment-flow/page.mdx). +During checkout, the Medusa application links a cart to a payment collection, which will be used for further payment processing. It also implements the [payment flow](../payment-flow/page.mdx) during checkout. ![Diagram showcasing the relation between the Payment and Cart modules](https://res.cloudinary.com/dza7lstvk/image/upload/v1711537849/Medusa%20Resources/cart-payment_ixziqm.jpg) diff --git a/www/apps/resources/app/commerce-modules/pricing/concepts/page.mdx b/www/apps/resources/app/commerce-modules/pricing/concepts/page.mdx index 6f8e068a0f..68f5420a8b 100644 --- a/www/apps/resources/app/commerce-modules/pricing/concepts/page.mdx +++ b/www/apps/resources/app/commerce-modules/pricing/concepts/page.mdx @@ -4,13 +4,13 @@ export const metadata = { # {metadata.title} -In this document, you’ll learn about the main concepts in the Pricing Module. +In this guide, you’ll learn about the main concepts in the Pricing Module. ## Price Data Model The [Price](/references/pricing/models/Price) data model represents a specific price for a resource. For example, the price of a product variant in the USD currency. -The `Price` data model has an `amount` property that represents the monetary value of the price. It's stored as an integer in base units. For example, `$20.00` is stored as `20`. +The `Price` data model has an `amount` property that represents the monetary value of the price. It's stored as an integer in base or major units. For example, `$20.00` is stored as `20`, and `$20.5` is stored as `20.5`. The `Price` data model belongs to other data models like `PriceSet` and `PriceList` to provide a variety of pricing features, as explained below. @@ -18,9 +18,9 @@ The `Price` data model belongs to other data models like `PriceSet` and `PriceLi ## Price Set -A [PriceSet](/references/pricing/models/PriceSet) represents a collection of prices that are linked to a resource (for example, a product variant or a shipping option). +A [PriceSet](/references/pricing/models/PriceSet) represents a collection of prices that are linked to a resource. For example, a product variant can have a price set that includes prices in multiple currencies, such as USD and EUR. -Each of these prices is represented by the [Price data model](/references/pricing/models/Price). +Each of these prices is represented by the [Price data model](#price-data-model). ![A diagram showcasing the relation between the price set and price](https://res.cloudinary.com/dza7lstvk/image/upload/v1709648650/Medusa%20Resources/price-set-money-amount_xeees0.jpg) @@ -28,8 +28,10 @@ Each of these prices is represented by the [Price data model](/references/pricin ## Price List -A [PriceList](/references/pricing/models/PriceList) is a group of prices only enabled if their conditions and rules are satisfied. +A [PriceList](/references/pricing/models/PriceList) is a group of prices that are only enabled when their conditions and rules are satisfied. For example, you can apply special prices to customers in the VIP group. + +When the conditions are met, the prices in the price list override the default prices in a price set. A price list has optional `start_date` and `end_date` properties that indicate the date range in which a price list can be applied. -Its associated prices are represented by the `Price` data model. \ No newline at end of file +Its associated prices are represented by the [Price data model](#price-data-model). \ No newline at end of file diff --git a/www/apps/resources/app/commerce-modules/promotion/application-method/page.mdx b/www/apps/resources/app/commerce-modules/promotion/application-method/page.mdx index 04f9f05811..d11fb49921 100644 --- a/www/apps/resources/app/commerce-modules/promotion/application-method/page.mdx +++ b/www/apps/resources/app/commerce-modules/promotion/application-method/page.mdx @@ -6,11 +6,11 @@ export const metadata = { # {metadata.title} -In this document, you'll learn what an application method is. +In this guide, you'll learn what an application method is in the Promotion Module. ## What is an Application Method? -The [ApplicationMethod data model](/references/promotion/models/ApplicationMethod) defines how a promotion is applied: +The [ApplicationMethod data model](/references/promotion/models/ApplicationMethod) defines how a promotion is applied. It has the following properties that determine its behavior:
@@ -24,6 +24,11 @@ The [ApplicationMethod data model](/references/promotion/models/ApplicationMetho Purpose + + + + Possible Values + @@ -38,6 +43,11 @@ The [ApplicationMethod data model](/references/promotion/models/ApplicationMetho Does the promotion discount a fixed amount or a percentage? + + + + `fixed`, `percentage` + @@ -48,7 +58,12 @@ The [ApplicationMethod data model](/references/promotion/models/ApplicationMetho - Is the promotion applied on a cart item, shipping method, or the entire order? + Is the promotion applied to a cart item, shipping method, or the entire order? + + + + + `items`, `shipping_methods`, `order` @@ -60,7 +75,12 @@ The [ApplicationMethod data model](/references/promotion/models/ApplicationMetho - Is the discounted amount applied on each item or split between the applicable items? + Is the discounted amount applied to each item or split between the applicable items? + + + + + `each`, `across` @@ -69,13 +89,13 @@ The [ApplicationMethod data model](/references/promotion/models/ApplicationMetho ## Target Promotion Rules -When the promotion is applied to a cart item or a shipping method, you can restrict which items/shipping methods the promotion is applied to. +When the promotion is applied to a cart item or a shipping method (in other words, when `target_type` is `items` or `shipping_methods`), you can restrict which items/shipping methods the promotion is applied to. -The `ApplicationMethod` data model has a collection of `PromotionRule` records to restrict which items or shipping methods the promotion applies to. The `target_rules` property represents this relation. +The `ApplicationMethod` data model has a collection of [PromotionRule](/references/promotion/models/PromotionRule) records to restrict which items or shipping methods the promotion applies to. The `target_rules` property in the `ApplicationMethod` represents this relation. ![A diagram showcasing the target_rules relation between the ApplicationMethod and PromotionRule data models](https://res.cloudinary.com/dza7lstvk/image/upload/v1709898273/Medusa%20Resources/application-method-target-rules_hqaymz.jpg) -In this example, the promotion is only applied on products in the cart having the SKU `SHIRT`. +In this example, the promotion is only applied to product variants in the cart that have the SKU `SHIRT`. --- @@ -83,8 +103,8 @@ In this example, the promotion is only applied on products in the cart having th When the promotion’s type is `buyget`, you must specify the “buy X” condition. For example, a cart must have two shirts before the promotion can be applied. -The application method has a collection of `PromotionRule` items to define the “buy X” rule. The `buy_rules` property represents this relation. +The application method has a collection of `PromotionRule` items to define the “buy X” rule. The `buy_rules` property in the `ApplicationMethod` represents this relation. ![A diagram showcasing the buy_rules relation between the ApplicationMethod and PromotionRule data models](https://res.cloudinary.com/dza7lstvk/image/upload/v1709898453/Medusa%20Resources/application-method-buy-rules_djjuhw.jpg) -In this example, the cart must have two products with the SKU `SHIRT` for the promotion to be applied. \ No newline at end of file +In this example, the cart must have two product variants with the SKU `SHIRT` for the promotion to be applied. \ No newline at end of file diff --git a/www/apps/resources/app/commerce-modules/stock-location/concepts/page.mdx b/www/apps/resources/app/commerce-modules/stock-location/concepts/page.mdx index 23928489a8..07e3f5efe0 100644 --- a/www/apps/resources/app/commerce-modules/stock-location/concepts/page.mdx +++ b/www/apps/resources/app/commerce-modules/stock-location/concepts/page.mdx @@ -4,16 +4,16 @@ export const metadata = { # {metadata.title} -In this document, you’ll learn about the main concepts in the Stock Location Module. +In this guide, you’ll learn about the main concepts in the Stock Location Module. ## Stock Location -A stock location, represented by the `StockLocation` data model, represents a location where stock items are kept. For example, a warehouse. +A stock location, represented by the [StockLocation data model](/references/stock-location-next/models/StockLocation), represents a location where stock items are kept. For example, a warehouse. -Medusa uses stock locations to provide inventory details, from the Inventory Module, per location. +Medusa uses stock locations to provide inventory details, stored and managed by the [Inventory Module](../../inventory/concepts/page.mdx), per location. --- ## StockLocationAddress -The `StockLocationAddress` data model belongs to the `StockLocation` data model. It provides more detailed information of the location, such as country code or street address. +The [StockLocationAddress data model](/references/stock-location-next/models/StockLocationAddress) belongs to the `StockLocation` data model. It provides more detailed information about the location, such as country code or street address. diff --git a/www/apps/resources/app/commerce-modules/user/module-options/page.mdx b/www/apps/resources/app/commerce-modules/user/module-options/page.mdx index bbf8ff243a..85bbb58983 100644 --- a/www/apps/resources/app/commerce-modules/user/module-options/page.mdx +++ b/www/apps/resources/app/commerce-modules/user/module-options/page.mdx @@ -10,7 +10,7 @@ export const metadata = { # {metadata.title} -In this document, you'll learn about the options of the User Module. +In this guide, you'll learn about the options you can pass to the User Module. ## Module Options @@ -63,7 +63,7 @@ module.exports = defineConfig({ ### Environment Variables -Make sure to add the necessary environment variables for the above options in `.env`: +Make sure to add the necessary environment variables for the above options to your `.env` file: ```bash JWT_SECRET=supersecret diff --git a/www/apps/resources/app/integrations/guides/payload/page.mdx b/www/apps/resources/app/integrations/guides/payload/page.mdx index 76f5a3a756..86b6976f74 100644 --- a/www/apps/resources/app/integrations/guides/payload/page.mdx +++ b/www/apps/resources/app/integrations/guides/payload/page.mdx @@ -760,9 +760,9 @@ Now that you've created the collections, you need to add them to Payload's confi In `src/payload.config.ts`, add the following imports at the top of the file: ```ts title="src/payload.config.ts" badgeLabel="Storefront" badgeColor="blue" -import { Users } from './collections/Users' -import { Products } from './collections/Products' -import { Media } from './collections/Media' +import { Users } from "./collections/Users" +import { Products } from "./collections/Products" +import { Media } from "./collections/Media" ``` Then, add the collections to the `collections` array of the `buildConfig` function: @@ -2626,9 +2626,9 @@ The `updatePayloadItemsStep` will update an item in a Payload collection, such a To create the step, create the file `src/workflows/steps/update-payload-items.ts` with the following content: ```ts title="src/workflows/steps/update-payload-items.ts" badgeLabel="Medusa application" badgeColor="green" -import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"; -import { PayloadItemResult, PayloadUpsertData } from "../../modules/payload/types"; -import { PAYLOAD_MODULE } from "../../modules/payload"; +import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk" +import { PayloadItemResult, PayloadUpsertData } from "../../modules/payload/types" +import { PAYLOAD_MODULE } from "../../modules/payload" type StepInput = { collection: string; @@ -2639,20 +2639,20 @@ export const updatePayloadItemsStep = createStep( "update-payload-items", async ({ items, collection }: StepInput, { container }) => { const payloadModuleService = container.resolve(PAYLOAD_MODULE) - const ids: string[] = items.map(item => item.id); + const ids: string[] = items.map((item) => item.id) const prevData = await payloadModuleService.find(collection, { where: { id: { - in: ids.join(",") - } - } + in: ids.join(","), + }, + }, }) const updatedItems: PayloadItemResult[] = [] for (const item of items) { - const { id, ...data } = item; + const { id, ...data } = item updatedItems.push( await payloadModuleService.update( collection, @@ -2660,16 +2660,16 @@ export const updatePayloadItemsStep = createStep( { where: { id: { - equals: id - } - } + equals: id, + }, + }, } ) ) } return new StepResponse({ - items: updatedItems.map(item => item.doc) + items: updatedItems.map((item) => item.doc), }, { prevData, collection, @@ -2677,11 +2677,11 @@ export const updatePayloadItemsStep = createStep( }, async (data, { container }) => { if (!data) { - return; + return } - const { prevData, collection } = data; + const { prevData, collection } = data - const payloadModuleService = container.resolve(PAYLOAD_MODULE); + const payloadModuleService = container.resolve(PAYLOAD_MODULE) await Promise.all( prevData.docs.map(async ({ @@ -2694,9 +2694,9 @@ export const updatePayloadItemsStep = createStep( { where: { id: { - equals: id - } - } + equals: id, + }, + }, } ) }) diff --git a/www/apps/resources/app/medusa-cli/commands/build/page.mdx b/www/apps/resources/app/medusa-cli/commands/build/page.mdx index b82b60ad39..719d354101 100644 --- a/www/apps/resources/app/medusa-cli/commands/build/page.mdx +++ b/www/apps/resources/app/medusa-cli/commands/build/page.mdx @@ -11,20 +11,20 @@ export const metadata = { # {metadata.title} -Create a standalone build of the Medusa application. +Create a standalone build of the Medusa application that you can deploy to production. This creates a build that: - Doesn't rely on the source TypeScript files. - Can be copied to a production server reliably. -The build is outputted to a new `.medusa/server` directory. +The build is output to a new `.medusa/server` directory. ```bash npx medusa build ``` -Refer to [this section](#run-built-medusa-application) for next steps. +Refer to the [Build Medusa Application](!docs!/learn/build) guide for next steps. ## Options @@ -44,7 +44,7 @@ Refer to [this section](#run-built-medusa-application) for next steps. - Whether to only build the admin to host it separately. If this option is not passed, the admin is built to the `.medusa/server/public/admin`. When this option is passed, the admin is built to the `.medusa/admin` directory instead. + Whether to build only the admin to host it separately. If this option is not passed, the admin is built to the `.medusa/server/public/admin` directory. When this option is passed, the admin is built to the `.medusa/admin` directory instead. @@ -53,38 +53,8 @@ Refer to [this section](#run-built-medusa-application) for next steps. --- -## Run Built Medusa Application - -After running the `build` command, use the following step to run the built Medusa application: - -- Change to the `.medusa/server` directory and install the dependencies: - -```bash npm2yarn -cd .medusa/server && npm install -``` - -- When running the application locally, make sure to copy the `.env` file from the root project's directory. In production, use system environment variables instead. - -```bash npm2yarn -cp .env .medusa/server/.env.production -``` - -- In the system environment variables, set `NODE_ENV` to `production`: - -```bash -NODE_ENV=production -``` - -- Use the `start` command to run the application: - -```bash npm2yarn -cd .medusa/server && npm run start -``` - ---- - ## Build Medusa Admin By default, the Medusa Admin is built to the `.medusa/server/public/admin` directory. -If you want a separate build to host the admin standalone, such as on Vercel, pass the `--admin-only` option as explained in the [Options](#options) section. This outputs the admin to the `.medusa/admin` directory instead. +If you want a separate build to host the admin as a standalone application, such as on Vercel, pass the `--admin-only` option as explained in the [Options](#options) section. This outputs the admin to the `.medusa/admin` directory instead. diff --git a/www/apps/resources/app/medusa-cli/commands/develop/page.mdx b/www/apps/resources/app/medusa-cli/commands/develop/page.mdx index f03029dbfd..89f693bef0 100644 --- a/www/apps/resources/app/medusa-cli/commands/develop/page.mdx +++ b/www/apps/resources/app/medusa-cli/commands/develop/page.mdx @@ -11,7 +11,9 @@ export const metadata = { # {metadata.title} -Start Medusa application in development. This command watches files for any changes, then rebuilds the files and restarts the Medusa application. +Start the Medusa application in development. + +This command watches files for any changes, then rebuilds the files and restarts the Medusa application. ```bash npx medusa develop @@ -36,7 +38,7 @@ npx medusa develop - Set host of the Medusa server. + Set the host of the Medusa server. @@ -53,7 +55,7 @@ npx medusa develop - Set port of the Medusa server. + Set the port of the Medusa server. diff --git a/www/apps/resources/app/medusa-cli/commands/user/page.mdx b/www/apps/resources/app/medusa-cli/commands/user/page.mdx index 9d85235227..f42729fe12 100644 --- a/www/apps/resources/app/medusa-cli/commands/user/page.mdx +++ b/www/apps/resources/app/medusa-cli/commands/user/page.mdx @@ -91,7 +91,7 @@ npx medusa user --email [--password ] - An automatically generated ID. + An automatically generated ID is used. @@ -103,9 +103,8 @@ npx medusa user --email [--password ] - Whether to create an invite instead of a user. When using this option, you don't need to specify a password. - If ran successfully, you'll receive the invite token in the output. - + Whether to create a user invite instead of directly creating a user. Learn more in the [Create User Invite](#create-user-invite-with-medusa-cli) section. + @@ -119,4 +118,21 @@ npx medusa user --email [--password ] -
\ No newline at end of file + + +--- + +## Create User Invite with Medusa CLI + +The `user` command accepts the `--invite` option to create a user invite. The user must accept the invite before they can log into the Medusa Admin. + +For example: + +```bash +npx medusa user --email user@example.com --invite +``` + +The command will create a user invite and output the invite token. You can then either: + +- Accept the invite in the Medusa Admin at the path `/app/invite?token=` +- Accept the invite using the [Accept Invite API route](!api!/admin#invites_postinvitesaccept). diff --git a/www/apps/resources/app/service-factory-reference/methods/create/page.mdx b/www/apps/resources/app/service-factory-reference/methods/create/page.mdx index 31cd83de04..3a6ae414be 100644 --- a/www/apps/resources/app/service-factory-reference/methods/create/page.mdx +++ b/www/apps/resources/app/service-factory-reference/methods/create/page.mdx @@ -8,7 +8,9 @@ export const metadata = { # {metadata.title} -This method creates one or more records of the data model. +This method of a module's service creates one or more records of a data model. + +The method's name is of the format `createDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Create One Record @@ -22,7 +24,7 @@ const post = await postModuleService.createPosts({ }) ``` -If an object is passed of the method, an object of the created record is also returned. +If an object is passed to the method, the created record object is returned. --- @@ -41,4 +43,4 @@ const posts = await postModuleService.createPosts([ ]) ``` -If an array is passed of the method, an array of the created records is also returned. +If an array of objects is passed to the method, an array containing the created records is returned. diff --git a/www/apps/resources/app/service-factory-reference/methods/delete/page.mdx b/www/apps/resources/app/service-factory-reference/methods/delete/page.mdx index 852eef29f4..119c74a8fe 100644 --- a/www/apps/resources/app/service-factory-reference/methods/delete/page.mdx +++ b/www/apps/resources/app/service-factory-reference/methods/delete/page.mdx @@ -8,7 +8,9 @@ export const metadata = { # {metadata.title} -This method deletes one or more records. +This method of a module's service deletes one or more records. + +The method's name is `deleteDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Delete One Record @@ -16,7 +18,7 @@ This method deletes one or more records. await postModuleService.deletePosts("123") ``` -To delete one record, pass its ID as a parameter of the method. +To delete one record, pass its ID as a parameter to the method. --- @@ -29,7 +31,7 @@ await postModuleService.deletePosts([ ]) ``` -To delete multiple records, pass an array of IDs as a parameter of the method. +To delete multiple records, pass an array of IDs as a parameter to the method. --- @@ -41,10 +43,10 @@ await postModuleService.deletePosts({ }) ``` -To delete records matching a set of filters, pass an object of filters as a parameter. +To delete records matching a set of filters, pass an object of filters as a parameter to the method. -Learn more about accepted filters in [this documentation](../../tips/filtering/page.mdx). +Refer to the [Filtering](../../tips/filtering/page.mdx) reference for more information on accepted filters and examples. \ No newline at end of file diff --git a/www/apps/resources/app/service-factory-reference/methods/list/page.mdx b/www/apps/resources/app/service-factory-reference/methods/list/page.mdx index a0212e3d81..9560509c00 100644 --- a/www/apps/resources/app/service-factory-reference/methods/list/page.mdx +++ b/www/apps/resources/app/service-factory-reference/methods/list/page.mdx @@ -8,7 +8,9 @@ export const metadata = { # {metadata.title} -This method retrieves a list of records. +This method of a module's service retrieves a list of records. + +The method's name is `listDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Retrieve List of Records @@ -30,11 +32,11 @@ const posts = await postModuleService.listPosts({ ### Parameters -To retrieve records matching a set of filters, pass an object of the filters as a first parameter. +To retrieve records matching a set of filters, pass an object of the filters as the first parameter. -Learn more about accepted filters in [this documentation](../../tips/filtering/page.mdx). +Refer to the [Filtering](../../tips/filtering/page.mdx) reference for more information on accepted filters and examples. @@ -60,7 +62,7 @@ const posts = await postModuleService.listPosts({}, { ### Parameters -To retrieve records with their relations, pass as a second parameter an object having a `relations` property. `relations`'s value is an array of relation names. +To retrieve records with their relations, pass an object with a `relations` property as the second parameter. `relations`'s value is an array of relation names. ### Returns @@ -78,7 +80,7 @@ const posts = await postModuleService.listPosts({}, { ### Parameters -By default, retrieved records have all their properties. To select specific properties to retrieve, pass in the second object parameter a `select` property. +By default, retrieved records have all their properties. To select specific properties to retrieve, pass a `select` property in the second object parameter. `select`'s value is an array of property names to retrieve. @@ -88,7 +90,7 @@ The method returns an array of the first `15` records matching the filters. --- -## Paginate Relations +## Paginate Records ```ts const posts = await postModuleService.listPosts({}, { @@ -122,7 +124,7 @@ const posts = await postModuleService.listPosts({}, { ### Parameters -To sort records by one or more properties, pass to the second object parameter the `order` property. Its value is an object whose keys are the property names, and values can either be: +To sort records by one or more properties, pass an `order` property in the second object parameter. Its value is an object whose keys are the property names, and values can either be: - `ASC` to sort by this property in the ascending order. - `DESC` to sort by this property in the descending order. diff --git a/www/apps/resources/app/service-factory-reference/methods/listAndCount/page.mdx b/www/apps/resources/app/service-factory-reference/methods/listAndCount/page.mdx index b46f5d41a5..745f749929 100644 --- a/www/apps/resources/app/service-factory-reference/methods/listAndCount/page.mdx +++ b/www/apps/resources/app/service-factory-reference/methods/listAndCount/page.mdx @@ -8,7 +8,9 @@ export const metadata = { # {metadata.title} -This method retrieves a list of records with the total count. +This method of a module's service retrieves a list of records with the total count. + +The method's name is `listAndCountDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Retrieve List of Records @@ -33,11 +35,11 @@ const [posts, count] = await postModuleService.listAndCountPosts({ ### Parameters -To retrieve records matching a set of filters, pass an object of the filters as a first parameter. +To retrieve records matching a set of filters, pass an object of the filters as the first parameter. -Learn more about accepted filters in [this documentation](../../tips/filtering/page.mdx). +Refer to the [Filtering](../../tips/filtering/page.mdx) reference for more information on accepted filters and examples. @@ -66,7 +68,7 @@ const [posts, count] = await postModuleService.listAndCountPosts({}, { ### Parameters -To retrieve records with their relations, pass as a second parameter an object having a `relations` property. Its value is an array of relation names. +To retrieve records with their relations, pass an object with a `relations` property as the second parameter. Its value is an array of relation names. ### Returns @@ -87,7 +89,7 @@ const [posts, count] = await postModuleService.listAndCountPosts({}, { ### Parameters -By default, retrieved records have all their properties. To select specific properties to retrieve, pass in the second object parameter a `select` property. +By default, retrieved records have all their properties. To select specific properties to retrieve, pass a `select` property in the second object parameter. `select`'s value is an array of property names to retrieve. @@ -100,7 +102,7 @@ The method returns an array with two items: --- -## Paginate Relations +## Paginate Records ```ts const [posts, count] = await postModuleService.listAndCountPosts({}, { @@ -137,7 +139,7 @@ const [posts, count] = await postModuleService.listAndCountPosts({}, { ### Parameters -To sort records by one or more properties, pass to the second object parameter the `order` property. Its value is an object whose keys are the property names, and values can either be: +To sort records by one or more properties, pass an `order` property in the second object parameter. Its value is an object whose keys are the property names, and values can either be: - `ASC` to sort by this property in the ascending order. - `DESC` to sort by this property in the descending order. diff --git a/www/apps/resources/app/service-factory-reference/methods/restore/page.mdx b/www/apps/resources/app/service-factory-reference/methods/restore/page.mdx index f9bfbc8a9d..00354dbd15 100644 --- a/www/apps/resources/app/service-factory-reference/methods/restore/page.mdx +++ b/www/apps/resources/app/service-factory-reference/methods/restore/page.mdx @@ -8,7 +8,9 @@ export const metadata = { # {metadata.title} -This method restores one or more records of the data model that were [soft-deleted](../soft-delete/page.mdx). +This method of a module's service restores one or more records of a data model that were [soft-deleted](../soft-delete/page.mdx). + +The method's name is of the format `restoreDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Restore One Record @@ -18,7 +20,7 @@ const restoredPosts = await postModuleService.restorePosts("123") ### Parameters -To restore one record, pass its ID as a parameter of the method. +To restore one record, pass its ID as a parameter to the method. ### Returns @@ -26,9 +28,9 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: -```ts -restoredPosts = { - post_id: ["123"], +```json +{ + "post_id": ["123"], } ``` @@ -45,7 +47,7 @@ const restoredPosts = await postModuleService.restorePosts([ ### Parameters -To restore multiple records, pass an array of IDs as a parameter of the method. +To restore multiple records, pass an array of IDs as a parameter to the method. ### Returns @@ -53,9 +55,9 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: -```ts -restoredPosts = { - post_id: [ +```json +{ + "post_id": [ "123", "321", ], @@ -74,11 +76,11 @@ const restoredPosts = await postModuleService.restorePosts({ ### Parameters -To restore records matching a set of filters, pass an object of fitlers as a parameter of the method. +To restore records matching a set of filters, pass an object of filters as a parameter to the method. -Learn more about accepted filters in [this documentation](../../tips/filtering/page.mdx). +Refer to the [Filtering](../../tips/filtering/page.mdx) reference for more information on accepted filters and examples. @@ -88,9 +90,9 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: -```ts -restoredPosts = { - post_id: [ +```json +{ + "post_id": [ "123", ], } diff --git a/www/apps/resources/app/service-factory-reference/methods/retrieve/page.mdx b/www/apps/resources/app/service-factory-reference/methods/retrieve/page.mdx index 958edf2856..c399310be0 100644 --- a/www/apps/resources/app/service-factory-reference/methods/retrieve/page.mdx +++ b/www/apps/resources/app/service-factory-reference/methods/retrieve/page.mdx @@ -8,7 +8,9 @@ export const metadata = { # {metadata.title} -This method retrieves one record of the data model by its ID. +This method retrieves one record of a data model by its ID. + +The method's name is `retrieveDataModel`, where `DataModel` is the singular pascal-case name of the data model. ## Retrieve a Record @@ -42,7 +44,7 @@ const post = await postModuleService.retrievePost("123", { ### Parameters -To retrieve the data model with relations, pass as a second parameter of the method an object with the property `relations`. `relations`'s value is an array of relation names. +To retrieve the data model with relations, pass an object with the property `relations` as the second parameter. `relations`'s value is an array of relation names. ### Returns @@ -60,7 +62,7 @@ const post = await postModuleService.retrievePost("123", { ### Parameters -By default, all of the record's properties are retrieved. To select specific ones, pass in the second object parameter a `select` property. Its value is an array of property names. +By default, all of the record's properties are retrieved. To select specific ones, pass a `select` property in the second object parameter. Its value is an array of property names. ### Returns diff --git a/www/apps/resources/app/service-factory-reference/methods/soft-delete/page.mdx b/www/apps/resources/app/service-factory-reference/methods/soft-delete/page.mdx index d820d43666..e55526421e 100644 --- a/www/apps/resources/app/service-factory-reference/methods/soft-delete/page.mdx +++ b/www/apps/resources/app/service-factory-reference/methods/soft-delete/page.mdx @@ -8,7 +8,9 @@ export const metadata = { # {metadata.title} -This method soft deletes one or more records of the data model. +This method of a module's service soft deletes one or more records of a data model. + +The method's name is of the format `softDeleteDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Soft Delete One Record @@ -20,7 +22,7 @@ const deletedPosts = await postModuleService.softDeletePosts( ### Parameters -To soft delete a record, pass its ID as a parameter of the method. +To soft delete a record, pass its ID as a parameter to the method. ### Returns @@ -28,9 +30,9 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: -```ts -deletedPosts = { - post_id: ["123"], +```json +{ + "post_id": ["123"] } ``` @@ -47,7 +49,7 @@ const deletedPosts = await postModuleService.softDeletePosts([ ### Parameters -To soft delete multiple records, pass an array of IDs as a parameter of the method. +To soft delete multiple records, pass an array of IDs as a parameter to the method. ### Returns @@ -55,12 +57,12 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: -```ts -deletedPosts = { - post_id: [ +```json +{ + "post_id": [ "123", - "321", - ], + "321" + ] } ``` @@ -76,11 +78,11 @@ const deletedPosts = await postModuleService.softDeletePosts({ ### Parameters -To soft delete records matching a set of filters, pass an object of filters as a parameter. +To soft delete records matching a set of filters, pass an object of filters as a parameter to the method. -Learn more about accepted filters in [this documentation](../../tips/filtering/page.mdx). +Refer to the [Filtering](../../tips/filtering/page.mdx) reference for more information on accepted filters and examples. @@ -90,8 +92,8 @@ The method returns an object, whose keys are of the format `{camel_case_data_mod For example, the returned object of the above example is: -```ts -deletedPosts = { - post_id: ["123"], +```json +{ + "post_id": ["123"] } ``` \ No newline at end of file diff --git a/www/apps/resources/app/service-factory-reference/methods/update/page.mdx b/www/apps/resources/app/service-factory-reference/methods/update/page.mdx index 18b85de1e7..498bb5e13c 100644 --- a/www/apps/resources/app/service-factory-reference/methods/update/page.mdx +++ b/www/apps/resources/app/service-factory-reference/methods/update/page.mdx @@ -8,7 +8,9 @@ export const metadata = { # {metadata.title} -This method updates one or more records of the data model. +This method of a module's service updates one or more records. + +The method's name is `updateDataModel`, where `DataModel` is the plural pascal-case name of the data model. ## Update One Record @@ -21,7 +23,7 @@ const post = await postModuleService.updatePosts({ ### Parameters -To update one record, pass an object that at least has an `id` property, identifying the ID of the record to update. +To update one record, pass an object that has at least an `id` property, identifying the ID of the record to update. You can pass in the same object any other properties to update. @@ -48,13 +50,13 @@ const posts = await postModuleService.updatePosts([ ### Parameters -To update multiple records, pass an array of objects. Each object has at least an `id` property, identifying the ID of the record to update. +To update multiple records, pass an array of objects. Each object must have at least an `id` property, identifying the ID of the record to update. You can pass in each object any other properties to update. ### Returns -The method returns an array of objects of updated records. +The method returns an array of updated record objects. --- @@ -73,7 +75,7 @@ const posts = await postModuleService.updatePosts({ ### Parameters -To update records that match specified filters, pass as a parameter an object having two properties: +To update records that match specified filters, pass an object with two properties as a parameter: - `selector`: An object of filters that a record must match to be updated. - `data`: An object of the properties to update in every record that match the filters in `selector`. @@ -82,13 +84,13 @@ In the example above, you update the `published_at` property of every post recor -Learn more about accepted filters in [this documentation](../../tips/filtering/page.mdx). +Refer to the [Filtering](../../tips/filtering/page.mdx) reference for more information on accepted filters and examples. ### Returns -The method returns an array of objects of updated records. +The method returns an array of updated record objects. --- @@ -128,19 +130,23 @@ In the example above, you update the `published_at` property of post records who -Learn more about accepted filters in [this documentation](../../tips/filtering/page.mdx). +Refer to the [Filtering](../../tips/filtering/page.mdx) reference for more information on accepted filters and examples. ### Returns -The method returns an array of objects of updated records. +The method returns an array of updated record objects. --- ## Update a JSON Property -```ts +export const highlights = [ + ["4", "metadata", "`metadata` is a JSON property."] +] + +```ts highlights={highlights} const post = await postModuleService.updatePosts({ id: "123", name: "My Post", @@ -151,13 +157,14 @@ const post = await postModuleService.updatePosts({ }) ``` -When you have a JSON property in your data model, you can update it by adding, updating, or removing properties within that JSON object. Medusa will merge the properties you pass in the `update` method with the existing JSON object. +When you have a [JSON property](!docs!/learn/fundamentals/data-models/json-properties) in your data model, you can update it by adding, updating, or removing properties within that JSON object. Medusa will merge the properties you pass in the `update` method with the existing JSON object. ### Remove a Property from the JSON Property -```ts +```ts highlights={highlights} const post = await postModuleService.updatePosts({ id: "123", + name: "My Post", metadata: { is_featured: "", }, diff --git a/www/apps/resources/app/service-factory-reference/page.mdx b/www/apps/resources/app/service-factory-reference/page.mdx index 40d7a88446..b303d1ac3d 100644 --- a/www/apps/resources/app/service-factory-reference/page.mdx +++ b/www/apps/resources/app/service-factory-reference/page.mdx @@ -18,22 +18,22 @@ Refer to the [Service Factory](!docs!/learn/fundamentals/modules/service-factory When your module's main service extends the service factory, Medusa will: -1. Generate data-management methods in your main service for each of the data models passed to the `MedusaService` function. -2. Generate internal services for each of the data models passed to the `MedusaService` function, which can be resolved in loaders. +1. Generate [data-management methods in your main service](#main-service-methods) for each of the data models passed to the `MedusaService` function. +2. Generate [internal services](#internal-generated-service-methods) for each of the data models passed to the `MedusaService` function, which can be resolved in loaders. ### Main Service Methods -The names of the generated methods for a service extending the service factory are of the format `{operationName}_{dataModelName}`, where: +The names of the generated methods for a service extending the service factory are of the format `{operationName}{DataModelName}`, where: - `{operationName}` is the name of the operation. For example, `create`. -- `{dataModelName}` is the pascal-case version of the data model's key that's passed in the object parameter of `MedusaService`. The name is pluralized for all operations except the `retrieve` operation. +- `{DataModelName}` is the pascal-case version of the data model's key that's passed in the object parameter of `MedusaService`. The name is pluralized for all operations except the `retrieve` operation. Some examples of method names: -- `createPosts` -- `createMyPosts` -- `retrievePost` -- `listPosts` +- `createPosts` (`Post` data model) +- `createMyPosts` (`MyPost` data model) +- `retrievePost` (`Post` data model) +- `listPosts` (`Post` data model) ### Internal Generated Service Methods diff --git a/www/apps/resources/app/test-tools-reference/medusaIntegrationTestRunner/page.mdx b/www/apps/resources/app/test-tools-reference/medusaIntegrationTestRunner/page.mdx index f9642ef9cf..262193c35f 100644 --- a/www/apps/resources/app/test-tools-reference/medusaIntegrationTestRunner/page.mdx +++ b/www/apps/resources/app/test-tools-reference/medusaIntegrationTestRunner/page.mdx @@ -6,7 +6,7 @@ export const metadata = { # {metadata.title} -This document provides a reference to the `medusaIntegrationTestRunner` function provided by the `@medusajs/test-utils` package. +This is a reference to the `medusaIntegrationTestRunner` function provided by the `@medusajs/test-utils` package. ## Example @@ -30,36 +30,69 @@ medusaIntegrationTestRunner({ description: "Object parameter of test options.", children: [ { - type: "`() => void`", + type: "`(options: MedusaSuiteOptions) => void`", name: "testSuite", - description: "The Jest tests to run.", - optional: false + description: "The Jest tests to run. It accepts [Test Suite Parameters](#test-suite-parameters)", }, { type: "`string`", name: "dbName", - description: "A name to use for the database. By default, a random name is generated.", + description: "A name to use for the database. If not specified, the database name will be of the format `medusa--integration-`.", + optional: true }, { type: "`string`", name: "schema", description: "The PostgreSQL schema that the database is created in.", + defaultValue: "public", + optional: true }, { type: "`Record`", name: "env", - description: "Environment variables to use in the test suite." + description: "Environment variables to pass to the test suite.", + optional: true }, { type: "`boolean`", name: "debug", description: "Whether to show database log messages.", - defaultValue: "false" + defaultValue: "false", + optional: true + }, + { + type: "`string`", + name: "moduleName", + description: "The name of the module being tested. If not specified, a random name will be generated.", + optional: true + }, + { + type: "`string`", + name: "medusaConfigFile", + description: "The path to the `medusa-config.ts` file, excluding `medusa-config.ts`. This path is used as the current working directory as well.", + defaultValue: "cwd (current working directory)", + optional: true + }, + { + type: "`object`", + name: "hooks", + description: "An object containing hooks to run at different points in the test lifecycle.", + optional: true, + children: [ + { + type: "`(container: MedusaContainer) => Promise`", + name: "beforeServerStart", + description: "A hook that runs before the Medusa server starts.", + optional: true + } + ] } ] } ]} + openedLevel={2} sectionTitle="Parameters" + /> ## Test Suite Parameters @@ -99,7 +132,7 @@ The function passed to `testSuite` accepts the following parameters: { type: "`() => MedusaContainer`", name: "getContainer", - description: "A name to use for the database. By default, a random name is generated.", + description: "A function that returns the Medusa container.", }, { type: "`Record`", @@ -144,9 +177,22 @@ The function passed to `testSuite` accepts the following parameters: description: "Drops a database." }, ] + }, + { + type: "`object`", + name: "utils", + description: "A set of utility functions for the test suite.", + children: [ + { + type: "`() => Promise`", + name: "waitWorkflowExecutions", + description: "Waits for all workflow executions to complete." + } + ] } ] } ]} sectionTitle="Test Suite Parameters" + openedLevel={2} /> diff --git a/www/apps/resources/app/test-tools-reference/moduleIntegrationTestRunner/page.mdx b/www/apps/resources/app/test-tools-reference/moduleIntegrationTestRunner/page.mdx index 34459538a4..da3df12bdf 100644 --- a/www/apps/resources/app/test-tools-reference/moduleIntegrationTestRunner/page.mdx +++ b/www/apps/resources/app/test-tools-reference/moduleIntegrationTestRunner/page.mdx @@ -6,7 +6,7 @@ export const metadata = { # {metadata.title} -This document provides a reference to the `moduleIntegrationTestRunner` function provided by the `@medusajs/test-utils` package. +This is a reference to the `moduleIntegrationTestRunner` function provided by the `@medusajs/test-utils` package. ## Example @@ -39,51 +39,59 @@ moduleIntegrationTestRunner({ type: "`string`", name: "moduleName", description: "The module's name.", - optional: false - }, - { - type: "DmlEntity[]", - name: "moduleModels", - description: "The module's data models.", - optional: false }, { type: "string", name: "resolve", description: "The path to the module relative to the `src` directory.", - optional: false }, { type: "`() => void`", name: "testSuite", description: "The Jest tests to run.", - optional: false + }, + { + type: "DmlEntity[]", + name: "moduleModels", + description: "The module's data models.", + optional: true }, { type: "`Record`", name: "moduleOptions", description: "Options to pass to the module.", + optional: true }, { type: "`Record`", name: "injectedDependencies", - description: "Dependencies to inject into the module's container. They key is the registration name, and the value is the instance of the dependency.", + description: "Dependencies to inject into the module's container. The key is the registration name, and the value is the instance of the dependency.", + optional: true }, { type: "`string`", name: "schema", description: "The PostgreSQL schema that the database is created in.", + optional: true }, { type: "`boolean`", name: "debug", description: "Whether to show database log messages.", - defaultValue: "false" + defaultValue: "false", + optional: true + }, + { + type: "`string`", + name: "cwd", + description: "The current working directory. If not set, the directory that you run the test command from is considered the current working directory.", + optional: true } ] } ]} sectionTitle="Parameters" + openedLevel={2} /> ## Test Suite Parameters @@ -151,4 +159,5 @@ The function passed to `testSuite` accepts the following parameters: } ]} sectionTitle="Test Suite Parameters" + openedLevel={2} /> diff --git a/www/apps/resources/app/troubleshooting/_sections/scheduled-jobs/not-running.mdx b/www/apps/resources/app/troubleshooting/_sections/scheduled-jobs/not-running.mdx index b3f9e3ec40..a5d9a7ceb7 100644 --- a/www/apps/resources/app/troubleshooting/_sections/scheduled-jobs/not-running.mdx +++ b/www/apps/resources/app/troubleshooting/_sections/scheduled-jobs/not-running.mdx @@ -28,8 +28,8 @@ export default async function greetingJob(container: MedusaContainer) { export const config = { name: "greeting-every-minute", schedule: { - interval: 60000 // 1 minute - } + interval: 60000, // 1 minute + }, } ``` diff --git a/www/apps/resources/generated/edit-dates.mjs b/www/apps/resources/generated/edit-dates.mjs index 6d634b107c..9aad26ab51 100644 --- a/www/apps/resources/generated/edit-dates.mjs +++ b/www/apps/resources/generated/edit-dates.mjs @@ -40,13 +40,13 @@ export const generatedEditDates = { "app/commerce-modules/order/promotion-adjustments/page.mdx": "2024-10-09T10:19:19.333Z", "app/commerce-modules/order/return/page.mdx": "2025-02-26T11:22:49.675Z", "app/commerce-modules/order/tax-lines/page.mdx": "2024-10-09T10:22:49.335Z", - "app/commerce-modules/order/transactions/page.mdx": "2024-10-09T10:23:36.485Z", + "app/commerce-modules/order/transactions/page.mdx": "2025-09-01T15:06:16.923Z", "app/commerce-modules/order/page.mdx": "2025-08-26T09:21:49.780Z", "app/commerce-modules/payment/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00", "app/commerce-modules/payment/_events/page.mdx": "2024-07-03T19:27:13+03:00", - "app/commerce-modules/payment/module-options/page.mdx": "2024-10-15T12:51:40.574Z", + "app/commerce-modules/payment/module-options/page.mdx": "2025-09-01T15:08:25.818Z", "app/commerce-modules/payment/payment/page.mdx": "2025-05-20T07:51:40.709Z", - "app/commerce-modules/payment/payment-collection/page.mdx": "2024-10-09T10:56:49.510Z", + "app/commerce-modules/payment/payment-collection/page.mdx": "2025-09-01T15:10:39.107Z", "app/commerce-modules/payment/payment-flow/page.mdx": "2025-05-20T07:51:40.708Z", "app/commerce-modules/payment/payment-provider/stripe/page.mdx": "2025-05-20T07:51:40.709Z", "app/commerce-modules/payment/payment-provider/page.mdx": "2025-05-20T07:51:40.708Z", @@ -55,7 +55,7 @@ export const generatedEditDates = { "app/commerce-modules/payment/page.mdx": "2025-04-17T08:48:11.702Z", "app/commerce-modules/pricing/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00", "app/commerce-modules/pricing/_events/page.mdx": "2024-07-03T19:27:13+03:00", - "app/commerce-modules/pricing/concepts/page.mdx": "2025-09-01T06:30:15.013Z", + "app/commerce-modules/pricing/concepts/page.mdx": "2025-09-01T15:15:07.227Z", "app/commerce-modules/pricing/price-calculation/page.mdx": "2025-09-01T06:32:07.141Z", "app/commerce-modules/pricing/price-rules/page.mdx": "2025-06-10T15:56:43.648Z", "app/commerce-modules/pricing/tax-inclusive-pricing/page.mdx": "2025-06-27T15:43:35.193Z", @@ -68,7 +68,7 @@ export const generatedEditDates = { "app/commerce-modules/promotion/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00", "app/commerce-modules/promotion/_events/page.mdx": "2024-07-03T19:27:13+03:00", "app/commerce-modules/promotion/actions/page.mdx": "2025-06-27T15:42:19.142Z", - "app/commerce-modules/promotion/application-method/page.mdx": "2024-06-26T07:55:59+00:00", + "app/commerce-modules/promotion/application-method/page.mdx": "2025-09-01T15:22:53.403Z", "app/commerce-modules/promotion/campaign/page.mdx": "2025-02-26T11:32:24.484Z", "app/commerce-modules/promotion/concepts/page.mdx": "2025-02-26T11:31:54.391Z", "app/commerce-modules/promotion/page.mdx": "2025-04-17T08:48:14.643Z", @@ -81,7 +81,7 @@ export const generatedEditDates = { "app/commerce-modules/sales-channel/page.mdx": "2025-04-17T08:48:22.065Z", "app/commerce-modules/stock-location/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00", "app/commerce-modules/stock-location/_events/page.mdx": "2024-07-03T19:27:13+03:00", - "app/commerce-modules/stock-location/concepts/page.mdx": "2024-10-15T14:32:21.875Z", + "app/commerce-modules/stock-location/concepts/page.mdx": "2025-09-01T15:25:14.233Z", "app/commerce-modules/stock-location/page.mdx": "2025-04-17T08:48:26.441Z", "app/commerce-modules/store/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00", "app/commerce-modules/store/_events/page.mdx": "2024-07-03T19:27:13+03:00", @@ -95,7 +95,7 @@ export const generatedEditDates = { "app/commerce-modules/tax/page.mdx": "2025-05-20T07:51:40.711Z", "app/commerce-modules/user/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00", "app/commerce-modules/user/_events/page.mdx": "2024-07-03T19:27:13+03:00", - "app/commerce-modules/user/module-options/page.mdx": "2024-09-30T08:43:53.171Z", + "app/commerce-modules/user/module-options/page.mdx": "2025-09-01T15:26:21.317Z", "app/commerce-modules/user/user-creation-flows/page.mdx": "2025-02-26T11:35:54.685Z", "app/commerce-modules/user/page.mdx": "2025-04-17T08:48:17.980Z", "app/commerce-modules/page.mdx": "2025-04-17T08:48:34.855Z", @@ -124,16 +124,16 @@ export const generatedEditDates = { "app/recipes/subscriptions/examples/standard/page.mdx": "2025-05-20T07:51:40.723Z", "app/recipes/subscriptions/page.mdx": "2025-05-20T07:51:40.723Z", "app/recipes/page.mdx": "2025-05-20T07:51:40.722Z", - "app/service-factory-reference/methods/create/page.mdx": "2024-07-31T17:01:33+03:00", - "app/service-factory-reference/methods/delete/page.mdx": "2024-07-31T17:01:33+03:00", - "app/service-factory-reference/methods/list/page.mdx": "2024-07-31T17:01:33+03:00", - "app/service-factory-reference/methods/listAndCount/page.mdx": "2024-07-31T17:01:33+03:00", - "app/service-factory-reference/methods/restore/page.mdx": "2024-07-31T17:01:33+03:00", - "app/service-factory-reference/methods/retrieve/page.mdx": "2024-07-31T17:01:33+03:00", - "app/service-factory-reference/methods/soft-delete/page.mdx": "2024-07-31T17:01:33+03:00", - "app/service-factory-reference/methods/update/page.mdx": "2025-07-31T08:24:03.685Z", + "app/service-factory-reference/methods/create/page.mdx": "2025-09-01T15:54:53.385Z", + "app/service-factory-reference/methods/delete/page.mdx": "2025-09-01T15:54:55.068Z", + "app/service-factory-reference/methods/list/page.mdx": "2025-09-01T15:54:57.079Z", + "app/service-factory-reference/methods/listAndCount/page.mdx": "2025-09-01T15:54:58.986Z", + "app/service-factory-reference/methods/restore/page.mdx": "2025-09-01T15:55:02.709Z", + "app/service-factory-reference/methods/retrieve/page.mdx": "2025-09-01T15:55:05.134Z", + "app/service-factory-reference/methods/soft-delete/page.mdx": "2025-09-01T15:55:07.905Z", + "app/service-factory-reference/methods/update/page.mdx": "2025-09-01T15:55:09.885Z", "app/service-factory-reference/tips/filtering/page.mdx": "2025-08-15T12:06:28.709Z", - "app/service-factory-reference/page.mdx": "2025-07-31T13:29:12.136Z", + "app/service-factory-reference/page.mdx": "2025-09-01T15:57:34.193Z", "app/storefront-development/cart/context/page.mdx": "2025-03-27T14:47:14.258Z", "app/storefront-development/cart/create/page.mdx": "2025-03-27T14:46:51.473Z", "app/storefront-development/cart/manage-items/page.mdx": "2025-03-26T15:54:31.446Z", @@ -563,12 +563,12 @@ export const generatedEditDates = { "references/types/interfaces/types.BaseProductCategory/page.mdx": "2025-04-11T09:04:47.879Z", "references/types/types.NotificationTypes/page.mdx": "2024-11-25T17:49:28.027Z", "app/medusa-cli/commands/db/page.mdx": "2025-01-16T07:34:08.014Z", - "app/medusa-cli/commands/develop/page.mdx": "2024-08-28T10:43:45.452Z", + "app/medusa-cli/commands/develop/page.mdx": "2025-09-01T15:31:35.072Z", "app/medusa-cli/commands/exec/page.mdx": "2025-01-16T09:51:17.050Z", "app/medusa-cli/commands/new/page.mdx": "2024-08-28T10:43:34.110Z", "app/medusa-cli/commands/start/page.mdx": "2025-04-08T11:56:15.522Z", "app/medusa-cli/commands/telemtry/page.mdx": "2025-01-16T09:51:24.323Z", - "app/medusa-cli/commands/user/page.mdx": "2024-08-28T10:44:52.489Z", + "app/medusa-cli/commands/user/page.mdx": "2025-09-01T15:36:38.978Z", "app/recipes/marketplace/examples/restaurant-delivery/page.mdx": "2025-08-25T07:30:37.299Z", "references/types/HttpTypes/interfaces/types.HttpTypes.AdminCreateCustomerGroup/page.mdx": "2024-12-09T13:21:33.569Z", "references/types/HttpTypes/interfaces/types.HttpTypes.AdminCreateReservation/page.mdx": "2025-04-11T09:04:47.498Z", @@ -690,8 +690,8 @@ export const generatedEditDates = { "references/types/HttpTypes/interfaces/types.HttpTypes.AdminWorkflowExecution/page.mdx": "2025-04-11T09:04:47.748Z", "references/types/HttpTypes/interfaces/types.HttpTypes.AdminWorkflowExecutionResponse/page.mdx": "2025-04-11T09:04:47.751Z", "references/types/interfaces/types.BaseReturnItem/page.mdx": "2025-04-11T09:04:47.951Z", - "app/test-tools-reference/medusaIntegrationTestRunner/page.mdx": "2024-10-16T15:47:38.579Z", - "app/test-tools-reference/moduleIntegrationTestRunner/page.mdx": "2025-03-18T15:19:56.773Z", + "app/test-tools-reference/medusaIntegrationTestRunner/page.mdx": "2025-09-01T16:10:30.965Z", + "app/test-tools-reference/moduleIntegrationTestRunner/page.mdx": "2025-09-01T16:13:56.959Z", "app/test-tools-reference/page.mdx": "2024-12-09T16:23:04.825Z", "references/types/HttpTypes/interfaces/types.HttpTypes.AdminGetInvitesParams/page.mdx": "2025-01-13T18:05:54.493Z", "references/types/HttpTypes/interfaces/types.HttpTypes.AdminInventoryLevel/page.mdx": "2024-12-23T13:57:05.362Z", @@ -2167,7 +2167,7 @@ export const generatedEditDates = { "app/commerce-modules/stock-location/links-to-other-modules/page.mdx": "2025-04-17T16:02:51.467Z", "app/commerce-modules/store/links-to-other-modules/page.mdx": "2025-04-17T16:03:16.419Z", "app/examples/page.mdx": "2025-07-16T09:53:26.163Z", - "app/medusa-cli/commands/build/page.mdx": "2024-11-11T11:00:49.665Z", + "app/medusa-cli/commands/build/page.mdx": "2025-09-01T15:30:05.995Z", "app/js-sdk/page.mdx": "2025-08-01T14:17:07.509Z", "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.apiKey/page.mdx": "2025-05-20T07:51:40.924Z", "references/js_sdk/admin/Admin/properties/js_sdk.admin.Admin.campaign/page.mdx": "2025-05-20T07:51:40.925Z",