diff --git a/www/apps/book/app/advanced-development/data-models/configure-properties/page.mdx b/www/apps/book/app/advanced-development/data-models/configure-properties/page.mdx index f2f2b083c9..2366780f17 100644 --- a/www/apps/book/app/advanced-development/data-models/configure-properties/page.mdx +++ b/www/apps/book/app/advanced-development/data-models/configure-properties/page.mdx @@ -67,7 +67,7 @@ The `unique` method indicates that a property’s value must be unique in the da For example: export const uniqueHighlights = [ - ["5", "unique", "Configure the `email` property to allow unique values only."] + ["4", "unique", "Configure the `email` property to allow unique values only."] ] ```ts highlights={uniqueHighlights} diff --git a/www/apps/book/app/advanced-development/data-models/searchable-property/page.mdx b/www/apps/book/app/advanced-development/data-models/searchable-property/page.mdx index 55af3a7bd1..a125b7a810 100644 --- a/www/apps/book/app/advanced-development/data-models/searchable-property/page.mdx +++ b/www/apps/book/app/advanced-development/data-models/searchable-property/page.mdx @@ -20,7 +20,11 @@ The `searchable` method of the `model` utility indicates that a `text` property For example: -```ts +export const searchableHighlights = [ + ["4", "searchable", "Define the `name` property as searchable."] +] + +```ts highlights={searchableHighlights} import { model } from "@medusajs/utils" const MyCustom = model.define("my_custom", { diff --git a/www/apps/book/app/advanced-development/modules/container/page.mdx b/www/apps/book/app/advanced-development/modules/container/page.mdx index 9e2fb70f08..e5e21b7ef4 100644 --- a/www/apps/book/app/advanced-development/modules/container/page.mdx +++ b/www/apps/book/app/advanced-development/modules/container/page.mdx @@ -14,8 +14,6 @@ So, resources in the module, such as services or loaders, can only resolve other - `logger`: A utility to log message in the Medusa application's logs. -{/* TODO add other relevant resources, such as event bus */} - --- ## Resolve Resources diff --git a/www/apps/book/app/advanced-development/modules/isolation/page.mdx b/www/apps/book/app/advanced-development/modules/isolation/page.mdx new file mode 100644 index 0000000000..aaf2611fdb --- /dev/null +++ b/www/apps/book/app/advanced-development/modules/isolation/page.mdx @@ -0,0 +1,32 @@ +export const metadata = { + title: `${pageNumber} Module Isolation`, +} + +# {metadata.title} + +In this chapter, you'll learn about how modules are isolated, and what that means for your custom development. + + + +- Modules can't access resources, such as services, from other modules. +- You can use Medusa's tools, explained in the next chapters, to extend modules or implement features across modules. + + + +## How are Modules Isolated? + +A module is unaware of any resources other than its own, such as services or data models. This means it can't access these resources if they're implemented in another module. + +For example, your custom module can't resolve the Product Module's main service or have direct relationships from its data model to another module's data model. + +--- + +## Customize and Implement Features Across Modules + +In your Medusa application, you want to implement features that span across modules, or you want to extend existing modules to add new features. + +For example, you want to extend the Product Module to add new properties to the `Product` data model. + +Medusa provides the tools to implement these use cases while maintaining isolation between modules. + +The next chapters explain these tools and how to use them in your custom development. diff --git a/www/apps/book/app/advanced-development/modules/remote-query/page.mdx b/www/apps/book/app/advanced-development/modules/remote-query/page.mdx index 9d4471cf7e..96caad6008 100644 --- a/www/apps/book/app/advanced-development/modules/remote-query/page.mdx +++ b/www/apps/book/app/advanced-development/modules/remote-query/page.mdx @@ -73,7 +73,7 @@ export async function GET( const query = remoteQueryObjectFromString({ entryPoint: "my_custom", - fields: ["id", "test"], + fields: ["id", "name"], }) res.json({ diff --git a/www/apps/book/app/advanced-development/modules/service-factory/page.mdx b/www/apps/book/app/advanced-development/modules/service-factory/page.mdx index 02112f402d..5c43265bd6 100644 --- a/www/apps/book/app/advanced-development/modules/service-factory/page.mdx +++ b/www/apps/book/app/advanced-development/modules/service-factory/page.mdx @@ -172,3 +172,24 @@ For example, the following methods are generated for the code snippet above: Except for the `retrieve` method, the suffixed data model's name is plural. + +### Using a Constructor + +If you implement the `constructor` of your service, make sure to call `super` passing it `...arguments`. + +For example: + +```ts highlights={[["8"]]} +import { MedusaService } from "@medusajs/utils" +import MyCustom from "./models/my-custom" + +class HelloModuleService extends MedusaService({ + MyCustom, +}){ + constructor() { + super(...arguments) + } +} + +export default HelloModuleService +``` \ No newline at end of file diff --git a/www/apps/book/sidebar.mjs b/www/apps/book/sidebar.mjs index d60fc7a258..5b4068de6c 100644 --- a/www/apps/book/sidebar.mjs +++ b/www/apps/book/sidebar.mjs @@ -107,8 +107,8 @@ export const sidebar = sidebarAttachHrefCommonOptions( title: "Service Factory", }, { - path: "/advanced-development/modules/options", - title: "Module Options", + path: "/advanced-development/modules/isolation", + title: "Module Isolation", }, { path: "/advanced-development/modules/remote-query", @@ -122,6 +122,10 @@ export const sidebar = sidebarAttachHrefCommonOptions( path: "/advanced-development/modules/remote-link", title: "Remote Link", }, + { + path: "/advanced-development/modules/options", + title: "Module Options", + }, ], }, { @@ -143,10 +147,6 @@ export const sidebar = sidebarAttachHrefCommonOptions( path: "/advanced-development/data-models/relationships", title: "Relationships", }, - { - path: "/advanced-development/data-models/relationship-cascades", - title: "Relationship Cascades", - }, { path: "/advanced-development/data-models/indexes", title: "Data Model Index",