docs: fixes following QA testing (#9690)
This commit is contained in:
@@ -23,4 +23,4 @@ Refer to the [Medusa UI documentation](https://docs.medusajs.com/ui) to learn ho
|
||||
|
||||
## Admin Components List
|
||||
|
||||
To build admin customizations that match the Medusa Admin's designs and layouts, refer to [this guide](!resources!/admin-component) to find common components.
|
||||
To build admin customizations that match the Medusa Admin's designs and layouts, refer to [this guide](!resources!/admin-components) to find common components.
|
||||
|
||||
@@ -165,4 +165,4 @@ If you run the Medusa application and go to `localhost:9000/app/custom/123`, you
|
||||
|
||||
## Admin Components List
|
||||
|
||||
To build admin customizations that match the Medusa Admin's designs and layouts, refer to [this guide](!resources!/admin-component) to find common components.
|
||||
To build admin customizations that match the Medusa Admin's designs and layouts, refer to [this guide](!resources!/admin-components) to find common components.
|
||||
|
||||
@@ -147,7 +147,7 @@ import { Modules } from "@medusajs/framework/utils"
|
||||
|
||||
createProductsWorkflow.hooks.productsCreated(
|
||||
async ({ products, additional_data }, { container }) => {
|
||||
if (!additional_data.brand) {
|
||||
if (!additional_data?.brand) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -204,4 +204,4 @@ createProductsWorkflow.hooks.productsCreated(
|
||||
)
|
||||
```
|
||||
|
||||
This updates the product to their original state before adding the brand to their `metadata` property.
|
||||
This updates the products to their original state before adding the brand to their `metadata` property.
|
||||
|
||||
@@ -68,7 +68,7 @@ export default defineMiddlewares({
|
||||
The `authenticate` middleware function accepts three parameters:
|
||||
|
||||
1. The type of user authenticating. Use `user` for authenticating admin users, and `customer` for authenticating customers. You can also pass `*` to allow all types of users.
|
||||
2. An array of the types of authentication methods allowed. Both `user` and `customer` scopes support `session` and `bearer`. The `admin` scope also supports the `api-key` authentication method.
|
||||
2. An array of types of authentication methods allowed. Both `user` and `customer` scopes support `session` and `bearer`. The `admin` scope also supports the `api-key` authentication method.
|
||||
3. An optional object of configurations accepting the following property:
|
||||
- `allowUnauthenticated`: (default: `false`) A boolean indicating whether authentication is required. For example, you may have an API route where you want to access the logged-in customer if available, but guest customers can still access it too.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ export const metadata = {
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
In this chapter, you'll learn how create and execute custom scripts from Medusa's CLI tool.
|
||||
In this chapter, you'll learn how to create and execute custom scripts from Medusa's CLI tool.
|
||||
|
||||
## What is a Custom CLI Script?
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ In the example above, you pass the `user` property when creating or updating an
|
||||
|
||||
When you create a record of a data model that has one of another, pass the ID of the other data model's record in the relation property.
|
||||
|
||||
For example, assuming you have the [User and Email data models from the previous chapter](../relationships/page.mdx#one-to-one-relationship), set an user's email ID as follows:
|
||||
For example, assuming you have the [User and Email data models from the previous chapter](../relationships/page.mdx#one-to-one-relationship), set a user's email ID as follows:
|
||||
|
||||
export const hasOneHighlights = [
|
||||
["4", "email", "The ID of the email that the user has."],
|
||||
|
||||
@@ -34,7 +34,7 @@ A one-to-one relationship indicates that one record of a data model belongs to o
|
||||
|
||||
To define a one-to-one relationship, create relationship properties in the data models using the following methods:
|
||||
|
||||
1. `hasOne`: indicates that the model has one record of the specified model.
|
||||
1. `hasOne`: indicates that the model has one records of the specified model.
|
||||
2. `belongsTo`: indicates that the model belongs to one record of the specified model.
|
||||
|
||||
For example:
|
||||
|
||||
@@ -8,7 +8,7 @@ In this chapter, you'll learn how to add custom columns to a link definition and
|
||||
|
||||
## How to Add Custom Columns to a Link's Table?
|
||||
|
||||
The `defineLink` function used to define a link accepts a third paramter, which is an object of options.
|
||||
The `defineLink` function used to define a link accepts a third parameter, which is an object of options.
|
||||
|
||||
To add custom columns to a link's table, pass in the third parameter of `defineLink` a `database` property:
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ So, resources in the module, such as services or loaders, can only resolve other
|
||||
|
||||
### List of Registered Resources
|
||||
|
||||
Find a list of resources or dependencies registered in a module's container in [this Learning Resources reference](!resoures!/medusa-container-resources).
|
||||
Find a list of resources or dependencies registered in a module's container in [this Development Resources reference](!resources!/medusa-container-resources).
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -161,9 +161,9 @@ Refer to [MikroORM's reference](https://mikro-orm.io/api/5.9/knex/class/EntityMa
|
||||
|
||||
### Why Wrap a Transactional Method
|
||||
|
||||
The variables in the transactional method (for example, `update_`) hold values that are uncomitted to the database. They're only committed once the method finishes execution.
|
||||
The variables in the transactional method (for example, `update_`) hold values that are uncommitted to the database. They're only committed once the method finishes execution.
|
||||
|
||||
So, if in your method you perform database operations, then use their result to perform other actions, such as connect to a third-party service, you'll be working with uncommitted data.
|
||||
So, if in your method you perform database operations, then use their result to perform other actions, such as connecting to a third-party service, you'll be working with uncommitted data.
|
||||
|
||||
By placing only the database operations in a method that has the `InjectTransactionManager` and using it in a wrapper method, the wrapper method receives the committed result of the transactional method.
|
||||
|
||||
@@ -201,7 +201,7 @@ In this case, only the `update_` method is wrapped in a transaction. The returne
|
||||
|
||||
### Using Methods in Transactional Methods
|
||||
|
||||
If your transactional method uses other methods that accept a Medusa context, pass the shared context to those method.
|
||||
If your transactional method uses other methods that accept a Medusa context, pass the shared context to those methods.
|
||||
|
||||
For example:
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ This chapter lists constraints to keep in mind when creating a service.
|
||||
|
||||
## Use Async Methods
|
||||
|
||||
Medusa wraps service method executions to inject useful context or transactions. However, since Medusa can't detect whether the method is asynchronus, it always executes methods in the wrapper with the `await` keyword.
|
||||
Medusa wraps service method executions to inject useful context or transactions. However, since Medusa can't detect whether the method is asynchronous, it always executes methods in the wrapper with the `await` keyword.
|
||||
|
||||
For example, if you have a synchronous `getMessage` method, and you use it other resources like workflows, Medusa executes it as an async method:
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export const metadata = {
|
||||
|
||||
In the previous chapters, you got a brief introduction to Medusa’s basic concepts. However, to build a custom commerce application, you need a deeper understanding of how you utilize these concepts for your business use case.
|
||||
|
||||
The next chapters dive deeper into each concept, and explores Medusa's architecture. By the end of these chapters, you’ll be able to:
|
||||
The next chapters dive deeper into each concept, and explore Medusa's architecture. By the end of these chapters, you’ll be able to:
|
||||
|
||||
- Expose API routes with control over authentication.
|
||||
- Build sophisticated business logic in modules and manage links between them.
|
||||
|
||||
+1
-1
@@ -41,7 +41,7 @@ const workflow = createWorkflow(
|
||||
)
|
||||
```
|
||||
|
||||
Instead of invoking the workflow, passing it the container, you use its `runAsStep` method and pass it an object as a parameter.
|
||||
Instead of invoking the workflow and passing it the container, you use its `runAsStep` method and pass it an object as a parameter.
|
||||
|
||||
The object has an `input` property to pass input to the workflow.
|
||||
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ export const metadata = {
|
||||
|
||||
In this chapter, you'll learn how to manipulate variables in a workflow using the transform utility.
|
||||
|
||||
## Why Variable Manipulation isn't Allowed in Worflows?
|
||||
## Why Variable Manipulation isn't Allowed in Workflows?
|
||||
|
||||
Medusa creates an internal representation of the workflow definition you pass to `createWorkflow` to track and store its steps.
|
||||
|
||||
@@ -29,7 +29,7 @@ const str1 = step1()
|
||||
const str2 = step2()
|
||||
```
|
||||
|
||||
To concatinate the strings, you create a new variable `str3` using the `transform` function:
|
||||
To concatenate the strings, you create a new variable `str3` using the `transform` function:
|
||||
|
||||
export const highlights = [
|
||||
["14", "str3", "Holds the result returned by `transform`'s second parameter function."],
|
||||
|
||||
@@ -61,4 +61,4 @@ Then, open a product’s details page in the Medusa Admin. You’ll find your cu
|
||||
|
||||
## Admin Components List
|
||||
|
||||
To build admin customizations that match the Medusa Admin's designs and layouts, refer to [this guide](!resources!/admin-component) to find common components.
|
||||
To build admin customizations that match the Medusa Admin's designs and layouts, refer to [this guide](!resources!/admin-components) to find common components.
|
||||
|
||||
@@ -40,7 +40,7 @@ export const config: SubscriberConfig = {
|
||||
|
||||
A subscriber file must export:
|
||||
|
||||
- A subscriber function that is an asynchronous function executed whenever the associated event is triggered.
|
||||
- An asynchronous subscriber function that's executed whenever the associated event is triggered.
|
||||
- A configuration object defining the event this subscriber is listening to.
|
||||
|
||||
The above subscriber listens to the `product.created` event. Whenever the event is emitted, it logs in the terminal `A product is created`.
|
||||
|
||||
@@ -10,7 +10,7 @@ In this chapter, you’ll learn about loaders and how to use them.
|
||||
|
||||
A loader is a function executed when the Medusa application starts. You define and export it in a module.
|
||||
|
||||
Loaders are useful to perform a task at the application start-up, such as to sync data between Medusa and a third-pary service.
|
||||
Loaders are useful to perform a task at the application start-up, such as to sync data between Medusa and a third-party service.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ Data models automatically have the date properties `created_at`, `updated_at`, a
|
||||
|
||||
### 2. Create Service
|
||||
|
||||
A module must define a service that implements its functionalities, such as manage the records of your custom data models in the database.
|
||||
A module must define a service that implements its functionalities, such as managing the records of your custom data models in the database.
|
||||
|
||||
A service is a TypeScript or JavaScript class defined in the `service.ts` file at the root of your module's directory.
|
||||
|
||||
@@ -140,11 +140,11 @@ module.exports = defineConfig({
|
||||
})
|
||||
```
|
||||
|
||||
Its value is an array of objects, each having a `resolve` property, whose value is either a path to module's directory, or an `npm` package’s name.
|
||||
Its value is an array of objects, each having a `resolve` property, whose value is either a path to the module's directory, or an `npm` package’s name.
|
||||
|
||||
### 5. Generate Migrations
|
||||
|
||||
A migration is a TypeScript or JavaScript file that defines database changes made by your module, such as create the `my_custom` table for the `MyCustom` data model.
|
||||
A migration is a TypeScript or JavaScript file that defines database changes made by your module, such as creating the `my_custom` table for the `MyCustom` data model.
|
||||
|
||||
To generate a migration for the data models in your module, run the following command:
|
||||
|
||||
@@ -160,7 +160,7 @@ The module name `helloModuleService` is the key used when registering the module
|
||||
|
||||
</Note>
|
||||
|
||||
The above command creates a migration file at the directory `src/modules/hello/migrations` similar to the following:
|
||||
The above command creates a migration file in the directory `src/modules/hello/migrations` similar to the following:
|
||||
|
||||
```ts
|
||||
import { Migration } from "@mikro-orm/migrations"
|
||||
|
||||
@@ -4,15 +4,15 @@ export const metadata = {
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
In the next chapters, you’ll learn about the basic concepts of Medusa that are central in your development.
|
||||
In the next chapters, you’ll learn about the basic concepts of Medusa that are central to your development.
|
||||
|
||||
By the end of these chapter, you’ll be able to:
|
||||
By the end of these chapters, you’ll be able to:
|
||||
|
||||
- Expose your custom functionalities through endpoints.
|
||||
- Create custom modules that define custom business logic.
|
||||
- Create custom tables in the database through data models.
|
||||
- Execute scripts when the Medusa application starts.
|
||||
- Perform asynchronus actions when an event occurs.
|
||||
- Perform asynchronous actions when an event occurs.
|
||||
- Run tasks at a specified time or pattern during the Medusa application's runtime.
|
||||
- Create custom flows as a series of steps involving multiple services.
|
||||
- Customize the admin dashboard to inject components on existing pages or add new pages.
|
||||
|
||||
@@ -267,4 +267,4 @@ const myWorkflow = createWorkflow(
|
||||
export default myWorkflow
|
||||
```
|
||||
|
||||
In the step, you resolve the Product Module's main service and use it to retrieve the product count.
|
||||
In `step1`, you resolve the Product Module's main service and use it to retrieve the product count.
|
||||
|
||||
@@ -76,7 +76,7 @@ This method accepts as a first parameter filters to apply on the retrieved data,
|
||||
|
||||
<Note>
|
||||
|
||||
Learn more about the `listAndCount` method and its parameters in [this reference](!resources!service-factory-reference/methods/listAndCount).
|
||||
Learn more about the `listAndCount` method and its parameters in [this reference](!resources!/service-factory-reference/methods/listAndCount).
|
||||
|
||||
</Note>
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ import BrandModuleService from "../../modules/brand/service"
|
||||
|
||||
createProductsWorkflow.hooks.productsCreated(
|
||||
(async ({ products, additional_data }, { container }) => {
|
||||
if (!additional_data.brand_id) {
|
||||
if (!additional_data?.brand_id) {
|
||||
return new StepResponse([], [])
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ In the Medusa application's logs, you'll find the message `Linked brand to produ
|
||||
|
||||
---
|
||||
|
||||
## Worflows and API Routes References
|
||||
## Workflows and API Routes References
|
||||
|
||||
Medusa exposes hooks in many of its workflows that you can consume to add custom logic.
|
||||
|
||||
|
||||
@@ -140,7 +140,7 @@ In the compensation function, you undo the step's action using the `deleteBrand`
|
||||
|
||||
### Add Step to Workflow
|
||||
|
||||
Finally, add the step to the `syncBrandToSystemWorkflow` in `src/workflows/sync-brand-to-system/index.ts`:
|
||||
Finally, add this step to the `syncBrandToSystemWorkflow` in `src/workflows/sync-brand-to-system/index.ts`:
|
||||
|
||||
```ts title="src/workflows/sync-brand-to-system/index.ts"
|
||||
// other imports...
|
||||
|
||||
@@ -6,7 +6,7 @@ export const metadata = {
|
||||
|
||||
The previous examples under the Customization chapter explained more about customizing Medusa for a realistic use case.
|
||||
|
||||
Your learning journey doesn't end here, and this only presents some of Medusa's powerful feature.
|
||||
Your learning journey doesn't end here, and this only presents some of Medusa's powerful features.
|
||||
|
||||
This chapter guides you into how to continue your learning journey, and what resources will be helpful for you during your development.
|
||||
|
||||
@@ -33,6 +33,6 @@ Some of these guides and references are:
|
||||
|
||||
## More Examples in Recipes
|
||||
|
||||
In the Development Resources documentation, you'll also find step-by-step guides of different use cases, such as building a marketplace, digital products, and more.
|
||||
In the Development Resources documentation, you'll also find step-by-step guides for different use cases, such as building a marketplace, digital products, and more.
|
||||
|
||||
Refer to the [Recipes](!resources!/recipes) documentation to learn more.
|
||||
|
||||
@@ -148,7 +148,7 @@ If you check traces in your exporter, you'll find new traces reported.
|
||||
Trace span names start with the following keywords based on what it's reporting:
|
||||
|
||||
- `{methodName} {URL}` when reporting HTTP requests, where `{methodName}` is the HTTP method, and `{URL}` is the URL the request is sent to.
|
||||
- `route:` when reporting route handlers running on an HTTP requests.
|
||||
- `route:` when reporting route handlers running on an HTTP request.
|
||||
- `middleware:` when reporting a middleware running on an HTTP request.
|
||||
- `workflow:` when reporting a workflow execution.
|
||||
- `step:` when reporting a step in a workflow execution.
|
||||
|
||||
@@ -4,7 +4,7 @@ export const metadata = {
|
||||
|
||||
# {metadata.title}
|
||||
|
||||
In this chapter, you’ll learn about the approach to deploy your Medusa application.
|
||||
In this chapter, you’ll learn the general approach to deploying the Medusa application.
|
||||
|
||||
<Note title="Important">
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { TriangleRightMini } from "@medusajs/icons"
|
||||
import clsx from "clsx"
|
||||
import {
|
||||
CalendarRefreshIcon,
|
||||
|
||||
@@ -475,7 +475,7 @@ export const sidebar = numberSidebarItems(
|
||||
children: [
|
||||
{
|
||||
type: "link",
|
||||
path: "/advanced-development/custom-cli-scripts/seed-data",
|
||||
path: "/learn/advanced-development/custom-cli-scripts/seed-data",
|
||||
title: "Seed Data",
|
||||
},
|
||||
],
|
||||
@@ -589,11 +589,6 @@ export const sidebar = numberSidebarItems(
|
||||
path: "/learn/more-resources/cheatsheet",
|
||||
title: "Cheat Sheet",
|
||||
},
|
||||
{
|
||||
type: "link",
|
||||
path: "/learn/more-resources/examples",
|
||||
title: "Examples",
|
||||
},
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user