docs: improved commerce modules [5/5] (#9592)

- Improve remaining commerce modules
- Other: add a note about using methods of the modules' main services.
This commit is contained in:
Shahed Nasser
2024-10-16 13:25:21 +03:00
committed by GitHub
parent 6e856d3156
commit eed88c95ec
42 changed files with 594 additions and 582 deletions
@@ -8,6 +8,12 @@ export const metadata = {
In this guide, youll find common examples of how you can use the API Key Module in your application.
<Note>
You should only use the API Key Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create an API Key
<CodeTabs groupId="app-type">
@@ -8,6 +8,12 @@ export const metadata = {
In this guide, youll find common examples of how you can use the Auth Module in your application.
<Note>
You should only use the Auth Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Authenticate User
<Note>
@@ -8,6 +8,12 @@ export const metadata = {
In this guide, youll find common examples of how you can use the Cart Module in your application.
<Note>
You should only use the Cart Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create a Cart
<CodeTabs groupId="app-type">
@@ -8,6 +8,12 @@ export const metadata = {
In this guide, youll find common examples of how you can use the Currency Module in your application.
<Note>
You should only use the Currency Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## List Currencies
<CodeTabs groupId="app-type">
@@ -8,6 +8,12 @@ export const metadata = {
In this guide, youll find common examples of how you can use the Customer Module in your application.
<Note>
You should only use the Customer Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create a Customer
<CodeTabs groupId="app-type">
@@ -8,6 +8,12 @@ export const metadata = {
In this document, youll find common examples of how you can use the Inventory Module in your application.
<Note>
You should only use the Inventory Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create an Inventory Item
<CodeTabs groupId="app-type">
@@ -8,6 +8,12 @@ export const metadata = {
In this guide, youll find common examples of how you can use the Payment Module in your application.
<Note>
You should only use the Payment Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create a Payment Collection
<CodeTabs groupId="app-type">
@@ -8,6 +8,12 @@ export const metadata = {
In this document, youll find common examples of how you can use the Pricing Module in your application.
<Note>
You should only use the Pricing Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create a Price Set
<CodeTabs groupId="app-type">
@@ -8,6 +8,12 @@ export const metadata = {
In this guide, youll find common examples of how you can use the Product Module in your application.
<Note>
You should only use the Product Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create Product
<CodeTabs groupId="app-type">
@@ -8,6 +8,12 @@ export const metadata = {
In this document, youll find common examples of how you can use the Promotion Module in your application.
<Note>
You should only use the Promotion Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create a Promotion
<CodeTabs groupId="app-type">
@@ -8,21 +8,26 @@ export const metadata = {
In this guide, youll find common examples of how you can use the Region Module in your application.
<Note>
You should only use the Region Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create a Region
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)
@@ -69,16 +74,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)
@@ -115,16 +119,15 @@ export async function GET(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)
@@ -161,16 +164,15 @@ export async function GET(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)
@@ -211,16 +213,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)
@@ -0,0 +1,15 @@
export const metadata = {
title: `Links between Region Module and Other Modules`,
}
# {metadata.title}
This document showcases the module links defined between the Region Module and other commerce modules.
## Payment Module
You can specify for each region which payment providers are available for use.
Medusa defines a module link between the `PaymentProvider` and the `Region` data models.
![A diagram showcasing an example of how resources from the Payment and Region modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1711569520/Medusa%20Resources/payment-region_jyo2dz.jpg)
@@ -6,7 +6,7 @@ export const metadata = {
# {metadata.title}
The Region Module is the `@medusajs/medusa/region` NPM package that provides region-related features in your Medusa and Node.js applications.
The Region Module provides region-related features in your Medusa and Node.js applications.
## How to Use Region Module's Service
@@ -15,18 +15,33 @@ You can use the Region Module's main service by resolving from the Medusa contai
For example:
<CodeTabs groupId="resource-type">
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const regionModuleService = container.resolve(
Modules.REGION
)
const regions = await regionModuleService.listRegions()
})
```
</CodeTab>
<CodeTab label="API Route" value="api-route">
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const regionModuleService: IRegionModuleService = req.scope.resolve(
const regionModuleService = req.scope.resolve(
Modules.REGION
)
@@ -39,35 +54,17 @@ export async function GET(
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const regionModuleService: IRegionModuleService = container.resolve(
const regionModuleService = container.resolve(
Modules.REGION
)
const regions = await regionModuleService.listRegions()
}
```
</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const regionModuleService: IRegionModuleService = container.resolve(
Modules.REGION
)
const regions = await regionModuleService.listRegions()
})
```
</CodeTab>
@@ -1,31 +0,0 @@
export const metadata = {
title: `Relations between Region Module and Other Modules`,
}
# {metadata.title}
This document showcases the link modules defined between the Region Module and other commerce modules.
## Cart Module
Carts are associated with a region. Medusa defines a link module that builds a relationship between the `Region` and the `Cart` data models.
![A diagram showcasing an example of how resources from the API Key and Sales Channel modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716543714/Medusa%20Resources/customer-region_rtmymb.jpg)
The cart then uses the same currency as the region. During checkout, the cart's taxes, payment, and fulfillment providers are available based on the region's settings.
---
## Order Module
An order is associated with the customer's region. Medusa defines a link module that builds a relationship between the `Order` and `Region` data models.
![A diagram showcasing an example of how data models from the Order and Region modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716555119/Medusa%20Resources/order-region_ihkp2u.jpg)
---
## Payment Module
You can specify for each region which payment providers are available. Medusa defines a link module that builds a relationship between the `PaymentProvider` and the `Region` data models.
![A diagram showcasing an example of how resources from the Payment and Region modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1711569520/Medusa%20Resources/payment-region_jyo2dz.jpg)
@@ -8,21 +8,26 @@ export const metadata = {
In this guide, youll find common examples of how you can use the Sales Channel Module in your application.
<Note>
You should only use the Sales Channel Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create a Sales Channel
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const salesChannelModuleService: ISalesChannelModuleService =
const salesChannelModuleService =
request.scope.resolve(Modules.SALES_CHANNEL)
const salesChannel = await salesChannelModuleService.createSalesChannels({
@@ -64,16 +69,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const salesChannelModuleService: ISalesChannelModuleService =
const salesChannelModuleService =
request.scope.resolve(Modules.SALES_CHANNEL)
res.json({
@@ -109,16 +113,15 @@ export async function GET(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const salesChannelModuleService: ISalesChannelModuleService =
const salesChannelModuleService =
request.scope.resolve(Modules.SALES_CHANNEL)
const salesChannel = await salesChannelModuleService.retrieveSalesChannel(
@@ -160,16 +163,15 @@ export async function GET(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const salesChannelModuleService: ISalesChannelModuleService =
const salesChannelModuleService =
request.scope.resolve(Modules.SALES_CHANNEL)
const salesChannel = await salesChannelModuleService.updateSalesChannels({
@@ -213,16 +215,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const salesChannelModuleService: ISalesChannelModuleService =
const salesChannelModuleService =
request.scope.resolve(Modules.SALES_CHANNEL)
await salesChannelModuleService.deleteSalesChannels("sc_123")
@@ -0,0 +1,35 @@
export const metadata = {
title: `Links between Sales Channel Module and Other Modules`,
}
# {metadata.title}
This document showcases the module links defined between the Sales Channel Module and other commerce modules.
## API Key Module
A publishable API key allows you to easily specify the sales channel scope in a client request.
Medusa defines a link between the `ApiKey` and the `SalesChannel` data models.
![A diagram showcasing an example of how resources from the Sales Channel and API Key modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1709812064/Medusa%20Resources/sales-channel-api-key_zmqi2l.jpg)
---
## Product Module
A product has different availability for different sales channels. Medusa defines a link between the `Product` and the `SalesChannel` data models.
![A diagram showcasing an example of how resources from the Sales Channel and Product modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1709809833/Medusa%20Resources/product-sales-channel_t848ik.jpg)
A product can be available in more than one sales channel. You can retrieve only the products of a sales channel.
---
## Stock Location Module
A stock location is associated with a sales channel. This scopes inventory quantities associated with that stock location by the associated sales channel.
Medusa defines a link between the `SalesChannel` and `StockLocation` data models.
![A diagram showcasing an example of how resources from the Sales Channel and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716796872/Medusa%20Resources/sales-channel-location_cqrih1.jpg)
@@ -6,7 +6,7 @@ export const metadata = {
# {metadata.title}
The Sales Channel Module is the `@medusajs/medusa/sales-channel` NPM package that provides sales-channel-related features in your Medusa and Node.js applications.
The Sales Channel Module provides sales-channel-related features in your Medusa and Node.js applications.
## How to Use Sales Channel Module's Service
@@ -15,18 +15,32 @@ You can use the Sales Channel Module's main service by resolving from the Medusa
For example:
<CodeTabs groupId="resource-type">
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const salesChannelModuleService =
container.resolve(Modules.SALES_CHANNEL)
const salesChannels = await salesChannelModuleService.listSalesChannels()
})
```
</CodeTab>
<CodeTab label="API Route" value="api-route">
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const salesChannelModuleService: ISalesChannelModuleService =
const salesChannelModuleService =
request.scope.resolve(Modules.SALES_CHANNEL)
res.json({
@@ -38,33 +52,16 @@ export async function GET(
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const salesChannelModuleService: ISalesChannelModuleService =
const salesChannelModuleService =
container.resolve(Modules.SALES_CHANNEL)
const salesChannels = await salesChannelModuleService.listSalesChannels()
}
```
</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const salesChannelModuleService: ISalesChannelModuleService =
container.resolve(Modules.SALES_CHANNEL)
const salesChannels = await salesChannelModuleService.listSalesChannels()
})
```
</CodeTab>
@@ -74,7 +71,7 @@ const step1 = createStep("step-1", async (_, { container }) => {
## What's a Sales Channel?
A sales channel indicates an online or offline platform that you sell products on.
A sales channel indicates an online or offline channel that you sell products on.
Some use case examples for using a sales channel:
@@ -103,7 +100,7 @@ const salesChannels = await salesChannelModuleService.createSalesChannels([
### Product Availability
Medusa links the Product and Sales Channel modules, allowing merchants to specify a product's availability per sales channel.
Medusa uses the Product and Sales Channel modules to allow merchants to specify a product's availability per sales channel.
For example, B2B customers viewing products only see products in the B2B sales channel.
@@ -8,27 +8,19 @@ export const metadata = {
In this document, youll learn what publishable API keys are and how to use them with sales channels.
## Without Publishable API Keys
## Publishable API Keys with Sales Channels
When using multiple sales channels, youll need to specify the ID of a storefronts sales channel. This ensures that you retrieve the products available in that sales channel and associate the sales channel with the storefronts carts and orders.
A publishable API key, provided by the API Key Module, is a client key scoped to one or more sales channels.
The [Store API routes](!api!/store) accept the sales channels IDs differently depending on the API route's HTTP method. Some accept it as a query parameter whereas others accept it as a request body parameter.
This approach is tedious and error-prone as your storefront scales and as you develop multiple types of storefronts.
---
## Introducing Publishable API Keys
A publishable API key, provided by the API Key Module, is a client key scoped to one or more sales channels. When passed in the header of a request, the Medusa application infers the associated sales channels.
So, instead of the approach, indicated in the previous section, of manually passing the sales channels ID based on the API route, you always pass the publishable API key in the header of your requests:
When sending a request to a Store API route, you must pass a publishable API key in the header of the request:
```bash
curl http://localhost:9000/store/products \
x-publishable-api-key: {your_publishable_api_key}
```
The Medusa application infers the associated sales channels and ensures that only data relevant to the sales channel are used.
---
## How to Create a Publishable API Key?
@@ -1,55 +0,0 @@
export const metadata = {
title: `Relations between Sales Channel Module and Other Modules`,
}
# {metadata.title}
This document showcases the link modules defined between the Sales Channel Module and other commerce modules.
## API Key Module
A publishable API key allows you to easily specify the sales channel scope in a client request. Medusa defines a link module that builds a relationship between the `ApiKey` and the `SalesChannel` data models.
![A diagram showcasing an example of how resources from the Sales Channel and API Key modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1709812064/Medusa%20Resources/sales-channel-api-key_zmqi2l.jpg)
Using the API Key Module, you create a publishable key and associate it with a sales channel. Learn more in [this document](../publishable-api-keys/page.mdx)
---
## Cart Module
A cart is associated with the sales channel it's created in. Medusa defines a link module that builds a relationship between the `Cart` and the `SalesChannel` data models.
![A diagram showcasing an example of how data models from the Cart and Sales Channel modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1711538159/Medusa%20Resources/cart-sales-channel_n2oi0v.jpg)
For example, if a customer adds an item to the cart in a mobile app, the cart is associated with the mobile app's sales channel. However, if a customer adds an item to the cart in a web storefront, the cart is associated with the storefront's sales channel.
---
## Order Module
An order is associated with the sales channel it's created in. Medusa defines a link module that builds a relationship between the `Order` and the `SalesChannel` data models.
![A diagram showcasing an example of how resources from the Order and Sales Channel modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1712315409/Medusa%20Resources/order-sales-channel_dy72gx.jpg)
For example, if an order is created in a mobile app, it'll be associated with its sales channel. If another order is created through a POS system, it'll be associated with the POS's sales channel.
---
## Product Module
A product has different availability for different sales channels. Medusa defines a link module that builds a relationship between the `Product` and the `SalesChannel` data models.
A product can be available in more than one sales channel. Then, you can retrieve only the products of a sales channel.
![A diagram showcasing an example of how resources from the Sales Channel and Product modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1709809833/Medusa%20Resources/product-sales-channel_ciqj6i.jpg)
---
## Stock Location Module
A stock location is associated with a sales channel. This scopes inventory quantities associated with that stock location by the associated sales channel.
Medusa defines a link module that builds a relationship between the `SalesChannel` and `StockLocation` data models.
![A diagram showcasing an example of how resources from the Sales Channel and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716796872/Medusa%20Resources/sales-channel-location_cqrih1.jpg)
@@ -4,13 +4,13 @@ export const metadata = {
# {metadata.title}
In this document, youll learn about the main concepts in the Stock Location Module, and how data is stored and related.
In this document, youll 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.
The `InventoryLevel` and `ReservationItem` data models of the Inventory Module are associated with the `StockLocation` to provide inventory details per location. Learn more about this relation in [this guide](../relations-to-other-modules/page.mdx).
Medusa uses stock locations to provide inventory details, from the Inventory Module, per location.
---
@@ -8,21 +8,26 @@ export const metadata = {
In this document, youll find common examples of how you can use the Stock Location Module in your application.
<Note>
You should only use the Stock Location Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create a Stock Location
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const stockLocationModuleService: IStockLocationService =
const stockLocationModuleService =
request.scope.resolve(Modules.STOCK_LOCATION)
const stockLocation = await stockLocationModuleService.createStockLocations({
@@ -64,16 +69,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const stockLocationModuleService: IStockLocationService =
const stockLocationModuleService =
request.scope.resolve(Modules.STOCK_LOCATION)
res.json({
@@ -109,16 +113,15 @@ export async function GET(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const stockLocationModuleService: IStockLocationService =
const stockLocationModuleService =
request.scope.resolve(Modules.STOCK_LOCATION)
const stockLocation = await stockLocationModuleService.updateStockLocations({
@@ -174,16 +177,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const stockLocationModuleService: IStockLocationService =
const stockLocationModuleService =
request.scope.resolve(Modules.STOCK_LOCATION)
await stockLocationModuleService.deleteStockLocations("sloc_123")
@@ -0,0 +1,29 @@
export const metadata = {
title: `Links between Stock Location Module and Other Modules`,
}
# {metadata.title}
This document showcases the module links defined between the Stock Location Module and other commerce modules.
## Fulfillment Module
A fulfillment set can be conditioned to a specific stock location.
Medusa defines a link between the `FulfillmentSet` and `StockLocation` data models.
![A diagram showcasing an example of how data models from the Fulfillment and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1712567101/Medusa%20Resources/fulfillment-stock-location_nlkf7e.jpg)
Medusa also defines a link between the `FulfillmentProvider` and `StockLocation` data models to indicate the providers that can be used in a location.
![A diagram showcasing an example of how data models from the Fulfillment and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1728399492/Medusa%20Resources/fulfillment-provider-stock-location_b0mulo.jpg)
---
## Sales Channel Module
A stock location is associated with a sales channel. This scopes inventory quantities in a stock location by the associated sales channel.
Medusa defines a link between the `SalesChannel` and `StockLocation` data models.
![A diagram showcasing an example of how resources from the Sales Channel and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716796872/Medusa%20Resources/sales-channel-location_cqrih1.jpg)
@@ -6,7 +6,7 @@ export const metadata = {
# {metadata.title}
The Stock Location Module is the `@medusajs/medusa/stock-location-next` NPM package that provides stock-location-related features in your Medusa and Node.js applications.
The Stock Location Module provides stock-location-related features in your Medusa and Node.js applications.
## How to Use Stock Location Module's Service
@@ -15,18 +15,33 @@ You can use the Stock Location Module's main service by resolving from the Medus
For example:
<CodeTabs groupId="resource-type">
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const stockLocationModuleService = container.resolve(
Modules.STOCK_LOCATION
)
const stockLocations = await stockLocationModuleService.listStockLocations({})
})
```
</CodeTab>
<CodeTab label="API Route" value="api-route">
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const stockLocationModuleService: IStockLocationService =
const stockLocationModuleService =
request.scope.resolve(Modules.STOCK_LOCATION)
res.json({
@@ -38,35 +53,17 @@ export async function GET(
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const stockLocationModuleService: IStockLocationService = container.resolve(
const stockLocationModuleService = container.resolve(
Modules.STOCK_LOCATION
)
const stockLocations = await stockLocationModuleService.listStockLocations({})
}
```
</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const stockLocationModuleService: IStockLocationService = container.resolve(
Modules.STOCK_LOCATION
)
const stockLocations = await stockLocationModuleService.listStockLocations({})
})
```
</CodeTab>
@@ -1,33 +0,0 @@
export const metadata = {
title: `Relations between Stock Location Module and Other Modules`,
}
# {metadata.title}
This document showcases the link modules defined between the Stock Location Module and other commerce modules.
## Fulfillment Module
A fulfillment set can be conditioned to a specific stock location. Medusa defines a link module that builds a relationship between the `FulfillmentSet` and `StockLocation` data models.
![A diagram showcasing an example of how data models from the Fulfillment and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1712567101/Medusa%20Resources/fulfillment-stock-location_nlkf7e.jpg)
---
## Inventory Module
Reservation items and inventory items are associated with a location. Medusa defines a link module that builds a relationship between the `ReservationItem` and `StockLocation` data models, and the `InventoryLevel` and `StockLocation` data models.
![A diagram showcasing an example of how resources from the Stock Location and Inventory modules are linked.](https://res.cloudinary.com/dza7lstvk/image/upload/v1709660383/Medusa%20Resources/inventory-stock-location_yp26k3.jpg)
With this relation, stock and reserved quantity is specific to a location, providing you with more flexibility. The location can be as simple as having only a name, and more flexible by adding more address details to it.
---
## Sales Channel Module
A stock location is associated with a sales channel. This scopes inventory quantities associated with that stock location by the associated sales channel.
Medusa defines a link module that builds a relationship between the `SalesChannel` and `StockLocation` data models.
![A diagram showcasing an example of how resources from the Sales Channel and Stock Location modules are linked](https://res.cloudinary.com/dza7lstvk/image/upload/v1716796872/Medusa%20Resources/sales-channel-location_cqrih1.jpg)
@@ -8,21 +8,26 @@ export const metadata = {
In this guide, youll find common examples of how you can use the Store Module in your application.
<Note>
You should only use the Store Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create a Store
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const storeModuleService: IStoreModuleService = request.scope.resolve(
const storeModuleService = request.scope.resolve(
Modules.STORE
)
@@ -79,16 +84,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const storeModuleService: IStoreModuleService = request.scope.resolve(
const storeModuleService = request.scope.resolve(
Modules.STORE
)
@@ -127,16 +131,15 @@ export async function GET(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const storeModuleService: IStoreModuleService = request.scope.resolve(
const storeModuleService = request.scope.resolve(
Modules.STORE
)
@@ -175,16 +178,15 @@ export async function GET(request: Request, { params }: ContextType) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const storeModuleService: IStoreModuleService = request.scope.resolve(
const storeModuleService = request.scope.resolve(
Modules.STORE
)
@@ -227,16 +229,15 @@ export async function POST(request: Request, { params }: ContextType) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
request: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const storeModuleService: IStoreModuleService = request.scope.resolve(
const storeModuleService = request.scope.resolve(
Modules.STORE
)
@@ -6,7 +6,7 @@ export const metadata = {
# {metadata.title}
The Store Module is the `@medusajs/medusa/store` NPM package that provides store-related features in your Medusa and Node.js applications.
The Store Module provides store-related features in your Medusa and Node.js applications.
## How to Use Store Module's Service
@@ -15,12 +15,27 @@ You can use the Store Module's main service by resolving from the Medusa contain
For example:
<CodeTabs groupId="resource-type">
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const storeModuleService: IStoreModuleService = container.resolve(
Modules.STORE
)
const stores = await storeModuleService.listStores()
})
```
</CodeTab>
<CodeTab label="API Route" value="api-route">
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -39,10 +54,9 @@ export async function GET(
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const storeModuleService: IStoreModuleService = container.resolve(
@@ -51,23 +65,6 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
const stores = await storeModuleService.listStores()
}
```
</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const storeModuleService: IStoreModuleService = container.resolve(
Modules.STORE
)
const stores = await storeModuleService.listStores()
})
```
</CodeTab>
@@ -1,13 +0,0 @@
export const metadata = {
title: `Relations between Store Module and Other Modules`,
}
# {metadata.title}
This document showcases the link modules defined between the Store Module and other commerce modules.
## Currency Module
A store has a default currency. Medusa defines a link module that builds a relationship between the `Store` and `Currency` data models.
![A diagram showcasing an example of how resources from the Stock Location and Inventory modules are linked.](https://res.cloudinary.com/dza7lstvk/image/upload/v1716798146/Medusa%20Resources/store-currency_wzftwh.jpg)
@@ -8,21 +8,26 @@ export const metadata = {
In this guide, youll find common examples of how you can use the Tax Module in your application.
<Note>
You should only use the Tax Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create a Tax Region
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const taxModuleService: ITaxModuleService = req.scope.resolve(
const taxModuleService = req.scope.resolve(
Modules.TAX
)
@@ -75,16 +80,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const taxModuleService: ITaxModuleService = req.scope.resolve(
const taxModuleService = req.scope.resolve(
Modules.TAX
)
@@ -121,16 +125,15 @@ export async function GET(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const taxModuleService: ITaxModuleService = req.scope.resolve(
const taxModuleService = req.scope.resolve(
Modules.TAX
)
@@ -199,16 +202,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const taxModuleService: ITaxModuleService = req.scope.resolve(
const taxModuleService = req.scope.resolve(
Modules.TAX
)
@@ -245,16 +247,15 @@ export async function GET(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const taxModuleService: ITaxModuleService = req.scope.resolve(
const taxModuleService = req.scope.resolve(
Modules.TAX
)
@@ -14,7 +14,7 @@ In this document, you'll learn about the options of the Tax Module.
## providers
The `providers` option is an array of either tax module providers, tax plugins, or path to a file that defines a tax provider.
The `providers` option is an array of either tax module providers or path to a file that defines a tax provider.
When the Medusa application starts, these providers are registered and can be used to retrieve tax lines.
@@ -6,7 +6,7 @@ export const metadata = {
# {metadata.title}
The Tax Module is the `@medusajs/medusa/tax` NPM package that provides tax-related features in your Medusa and Node.js applications.
The Tax Module provides tax-related features in your Medusa and Node.js applications.
## How to Use Tax Module's Service
@@ -15,18 +15,33 @@ You can use the Tax Module's main service by resolving from the Medusa container
For example:
<CodeTabs groupId="resource-type">
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const taxModuleService = container.resolve(
Modules.TAX
)
const taxRegions = await taxModuleService.listTaxRegions()
})
```
</CodeTab>
<CodeTab label="API Route" value="api-route">
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const taxModuleService: ITaxModuleService = req.scope.resolve(
const taxModuleService = req.scope.resolve(
Modules.TAX
)
@@ -39,35 +54,17 @@ export async function GET(
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const taxModuleService: ITaxModuleService = container.resolve(
const taxModuleService = container.resolve(
Modules.TAX
)
const taxRegions = await taxModuleService.listTaxRegions()
}
```
</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const taxModuleService: ITaxModuleService = container.resolve(
Modules.TAX
)
const taxRegions = await taxModuleService.listTaxRegions()
})
```
</CodeTab>
@@ -116,7 +113,7 @@ const taxRates = await taxModuleService.createTaxRates([
### Retrieve Cart's Tax Lines
Calculate and retrieve the tax lines of a cart's line items and shipping methods with tax providers. Use different tax providers for each region to handle tax-line retrieval differently.
Calculate and retrieve the tax lines of a cart's line items and shipping methods with tax providers.
```ts
const taxLines = await taxModuleService.getTaxLines(
@@ -141,6 +138,8 @@ const taxLines = await taxModuleService.getTaxLines(
)
```
You can use different tax providers for each region to handle tax-line retrieval differently.
---
## Configure Tax Module
@@ -10,7 +10,7 @@ In this document, youll learn how tax lines are calculated and what a tax pro
Tax lines are calculated and retrieved using the [getTaxLines method of the Tax Modules main service](/references/tax/getTaxLines). It accepts an array of line items and shipping methods, and the context of the calculation.
It returns the tax lines that are used to adjust the carts tax and grand totals.
For example:
```ts
const taxLines = await taxModuleService.getTaxLines(
@@ -37,7 +37,28 @@ const taxLines = await taxModuleService.getTaxLines(
The context object is used to determine which tax regions and rates to use in the calculation. It includes properties related to the address and customer.
The example above returns the tax lines based on the tax region for the United States.
The example above retrieves the tax lines based on the tax region for the United States.
The method returns tax lines for the line item and shipping methods. For example:
```json
[
{
"line_item_id": "cali_123",
"rate_id": "txr_1",
"rate": 10,
"code": "XXX",
"name": "Tax Rate 1"
},
{
"shipping_line_id": "casm_123",
"rate_id": "txr_2",
"rate": 5,
"code": "YYY",
"name": "Tax Rate 2"
}
]
```
---
@@ -22,7 +22,9 @@ Then, when tax rates are retrieved for a taxable item in the child region, both
## Override Tax Rates with Rules
You can create tax rates that override the default for specific conditions or rules. For example, the default tax rate is 10%, but for products of type “Shirt” is %15.
You can create tax rates that override the default for specific conditions or rules.
For example, you can have a default tax rate is 10%, but for products of type “Shirt” is %15.
A tax region can have multiple tax rates, and each tax rate can have multiple tax rules. The [TaxRateRule data model](/references/tax/models/TaxRateRule) represents a tax rates rule.
@@ -8,7 +8,7 @@ In this document, youll learn about tax regions and how to use them with the
## What is a Tax Region?
A tax region, represented by the [TaxRegion data model](/references/tax/models/TaxRegion), stores settings related to a region that your store serves.
A tax region, represented by the [TaxRegion data model](/references/tax/models/TaxRegion), stores tax settings related to a region that your store serves.
Tax regions can inherit settings and rules from a parent tax region.
@@ -8,21 +8,26 @@ export const metadata = {
In this guide, youll find common examples of how you can use the User Module in your application.
<Note>
You should only use the User Module's main service when implementing complex customizations. For common cases, check out [available workflows instead](../../../medusa-workflows-reference/page.mdx).
</Note>
## Create a User
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const userModuleService: IUserModuleService = req.scope.resolve(
const userModuleService = req.scope.resolve(
Modules.USER
)
@@ -69,16 +74,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const userModuleService: IUserModuleService = req.scope.resolve(
const userModuleService = req.scope.resolve(
Modules.USER
)
@@ -115,16 +119,15 @@ export async function GET(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const userModuleService: IUserModuleService = req.scope.resolve(
const userModuleService = req.scope.resolve(
Modules.USER
)
@@ -169,16 +172,15 @@ export async function POST(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const userModuleService: IUserModuleService = req.scope.resolve(
const userModuleService = req.scope.resolve(
Modules.USER
)
@@ -211,16 +213,15 @@ export async function DELETE(request: Request) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const userModuleService: IUserModuleService = req.scope.resolve(
const userModuleService = req.scope.resolve(
Modules.USER
)
@@ -265,16 +266,15 @@ export async function POST(request: Request, { params }: ContextType) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const userModuleService: IUserModuleService = req.scope.resolve(
const userModuleService = req.scope.resolve(
Modules.USER
)
@@ -335,16 +335,15 @@ export async function POST(request: Request, { params }: ContextType) {
<CodeTabs groupId="app-type">
<CodeTab label="Medusa API Router" value="medusa">
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const userModuleService: IUserModuleService = req.scope.resolve(
const userModuleService = req.scope.resolve(
Modules.USER
)
@@ -6,7 +6,7 @@ export const metadata = {
# {metadata.title}
The User Module is the `@medusajs/medusa/user` NPM package that provides user-related features in your Medusa and Node.js applications.
The User Module provides user-related features in your Medusa and Node.js applications.
## How to Use User Module's Service
@@ -15,18 +15,33 @@ You can use the User Module's main service by resolving from the Medusa containe
For example:
<CodeTabs groupId="resource-type">
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const userModuleService = container.resolve(
Modules.USER
)
const users = await userModuleService.listUsers()
})
```
</CodeTab>
<CodeTab label="API Route" value="api-route">
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
res: MedusaResponse
): Promise<void> {
const userModuleService: IUserModuleService = req.scope.resolve(
const userModuleService = req.scope.resolve(
Modules.USER
)
@@ -39,35 +54,17 @@ export async function GET(
</CodeTab>
<CodeTab label="Subscriber" value="subscribers">
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/framework"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const userModuleService: IUserModuleService = container.resolve(
const userModuleService = container.resolve(
Modules.USER
)
const users = await userModuleService.listUsers()
}
```
</CodeTab>
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const userModuleService: IUserModuleService = container.resolve(
Modules.USER
)
const users = await userModuleService.listUsers()
})
```
</CodeTab>
@@ -4,21 +4,37 @@ export const metadata = {
# {metadata.title}
This document provides flows to create a user.
In this document, learn the different ways to create a user using the User Module.
## Straightforward User Creation
To create a user, use the [create method of the User Modules main service](/references/user/create):
```ts
const user = await userModuleService.createUsers({
email: "user@example.com",
})
```
You can pair this with the Auth Module to allow the user to authenticate, as explained in a [later section](#create-identity-with-the-auth-module).
---
## Invite Users
Another possible flow to create a user is by sending them an invite. Then, once they accept it, you create a new user for them:
To create a user, you can create an invite for them using the [createInvites method](/references/user/createInvites) of the User Module's main service:
```ts
// create invite
const invite = await userModuleService.createInvites({
email: "user@example.com",
})
```
// later, accept invite and create user
Later, you can accept the invite and create a new user for them:
```ts
const invite =
await userModuleService.validateInviteToken("secret123")
await userModuleService.validateInviteToken("secret_123")
await userModuleService.updateInvites({
id: invite.id,
@@ -32,7 +48,7 @@ const user = await userModuleService.createUsers({
### Invite Expiry
An invite has an expiry date. You can renew the expiry date and refresh the token using the `refreshInviteTokens` method:
An invite has an expiry date. You can renew the expiry date and refresh the token using the [refreshInviteTokens method](/references/user/refreshInviteTokens):
```ts
await userModuleService.refreshInviteTokens(["invite_123"])
@@ -40,17 +56,7 @@ await userModuleService.refreshInviteTokens(["invite_123"])
---
## Straightforward Creation
Finally, you can create a user using the [create method of the User Modules main service](/references/user/create):
```ts
const user = await userModuleService.createUsers({
email: "user@example.com",
})
```
### With the Auth Module
## Create Identity with the Auth Module
By combining the User and Auth Modules, you can use the Auth Module for authenticating users, and the User Module to manage those users.
@@ -62,7 +68,6 @@ const { success, authIdentity } =
// ...
})
// assuming authIdentity is defined
const [, count] = await userModuleService.listAndCountUsers({
email: authIdentity.entity_id,
})
+30 -30
View File
@@ -2,24 +2,24 @@ export const generatedEditDates = {
"app/commerce-modules/auth/auth-providers/emailpass/page.mdx": "2024-10-08T07:35:59.167Z",
"app/commerce-modules/auth/auth-providers/page.mdx": "2024-10-08T07:27:21.859Z",
"app/commerce-modules/auth/authentication-route/page.mdx": "2024-09-05T12:06:38.155Z",
"app/commerce-modules/auth/examples/page.mdx": "2024-10-07T15:36:17.212Z",
"app/commerce-modules/auth/examples/page.mdx": "2024-10-15T15:02:13.794Z",
"app/commerce-modules/auth/module-options/page.mdx": "2024-10-15T12:52:08.930Z",
"app/commerce-modules/auth/page.mdx": "2024-10-08T07:38:27.522Z",
"app/commerce-modules/cart/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/cart/_events/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/cart/concepts/page.mdx": "2024-10-08T07:49:03.737Z",
"app/commerce-modules/cart/examples/page.mdx": "2024-10-08T07:42:13.336Z",
"app/commerce-modules/cart/examples/page.mdx": "2024-10-15T14:59:11.331Z",
"app/commerce-modules/cart/promotions/page.mdx": "2024-10-08T07:54:31.120Z",
"app/commerce-modules/cart/tax-lines/page.mdx": "2024-10-08T07:57:19.168Z",
"app/commerce-modules/cart/page.mdx": "2024-10-08T07:41:22.711Z",
"app/commerce-modules/currency/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/currency/_events/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/currency/examples/page.mdx": "2024-10-08T15:06:26.492Z",
"app/commerce-modules/currency/examples/page.mdx": "2024-10-15T14:59:18.466Z",
"app/commerce-modules/currency/page.mdx": "2024-10-08T15:03:00.907Z",
"app/commerce-modules/customer/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/customer/_events/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/customer/customer-accounts/page.mdx": "2024-10-08T12:20:44.769Z",
"app/commerce-modules/customer/examples/page.mdx": "2024-10-08T15:05:59.722Z",
"app/commerce-modules/customer/examples/page.mdx": "2024-10-15T14:59:26.644Z",
"app/commerce-modules/customer/page.mdx": "2024-10-08T15:03:12.597Z",
"app/commerce-modules/fulfillment/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/fulfillment/_events/page.mdx": "2024-07-03T19:27:13+03:00",
@@ -32,7 +32,7 @@ export const generatedEditDates = {
"app/commerce-modules/inventory/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/inventory/_events/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/inventory/concepts/page.mdx": "2024-10-08T15:11:27.634Z",
"app/commerce-modules/inventory/examples/page.mdx": "2024-10-08T15:05:30.943Z",
"app/commerce-modules/inventory/examples/page.mdx": "2024-10-15T14:59:45.389Z",
"app/commerce-modules/inventory/inventory-in-flows/page.mdx": "2024-10-08T15:14:07.327Z",
"app/commerce-modules/inventory/page.mdx": "2024-10-08T15:02:50.635Z",
"app/commerce-modules/order/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00",
@@ -48,7 +48,7 @@ export const generatedEditDates = {
"app/commerce-modules/order/page.mdx": "2024-10-09T10:27:06.773Z",
"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/examples/page.mdx": "2024-10-09T10:50:04.128Z",
"app/commerce-modules/payment/examples/page.mdx": "2024-10-15T14:59:55.208Z",
"app/commerce-modules/payment/module-options/page.mdx": "2024-10-15T12:51:40.574Z",
"app/commerce-modules/payment/payment/page.mdx": "2024-10-09T10:59:08.463Z",
"app/commerce-modules/payment/payment-collection/page.mdx": "2024-10-09T10:56:49.510Z",
@@ -82,40 +82,36 @@ export const generatedEditDates = {
"app/commerce-modules/promotion/page.mdx": "2024-10-09T14:46:26.982Z",
"app/commerce-modules/region/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/region/_events/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/region/examples/page.mdx": "2024-09-30T08:43:53.166Z",
"app/commerce-modules/region/relations-to-other-modules/page.mdx": "2024-05-29T11:08:06+00:00",
"app/commerce-modules/region/page.mdx": "2024-09-30T08:43:53.167Z",
"app/commerce-modules/region/examples/page.mdx": "2024-10-15T15:00:24.388Z",
"app/commerce-modules/region/page.mdx": "2024-10-15T13:44:19.394Z",
"app/commerce-modules/sales-channel/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/sales-channel/_events/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/sales-channel/examples/page.mdx": "2024-09-30T08:43:53.167Z",
"app/commerce-modules/sales-channel/publishable-api-keys/page.mdx": "2024-05-29T11:08:06+00:00",
"app/commerce-modules/sales-channel/relations-to-other-modules/page.mdx": "2024-05-29T11:08:06+00:00",
"app/commerce-modules/sales-channel/page.mdx": "2024-09-30T08:43:53.167Z",
"app/commerce-modules/sales-channel/examples/page.mdx": "2024-10-15T15:00:33.322Z",
"app/commerce-modules/sales-channel/publishable-api-keys/page.mdx": "2024-10-15T14:21:38.353Z",
"app/commerce-modules/sales-channel/page.mdx": "2024-10-15T14:12:30.285Z",
"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-05-03T17:36:38+03:00",
"app/commerce-modules/stock-location/examples/page.mdx": "2024-09-30T08:43:53.168Z",
"app/commerce-modules/stock-location/relations-to-other-modules/page.mdx": "2024-05-29T11:08:06+00:00",
"app/commerce-modules/stock-location/page.mdx": "2024-09-30T08:43:53.168Z",
"app/commerce-modules/stock-location/concepts/page.mdx": "2024-10-15T14:32:21.875Z",
"app/commerce-modules/stock-location/examples/page.mdx": "2024-10-15T15:00:41.265Z",
"app/commerce-modules/stock-location/page.mdx": "2024-10-15T14:29:34.571Z",
"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",
"app/commerce-modules/store/examples/page.mdx": "2024-09-30T08:43:53.168Z",
"app/commerce-modules/store/relations-to-other-modules/page.mdx": "2024-05-29T11:08:06+00:00",
"app/commerce-modules/store/page.mdx": "2024-09-30T08:43:53.169Z",
"app/commerce-modules/store/examples/page.mdx": "2024-10-15T15:00:47.283Z",
"app/commerce-modules/store/page.mdx": "2024-10-15T14:44:35.707Z",
"app/commerce-modules/tax/_events/_events-table/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/tax/_events/page.mdx": "2024-07-03T19:27:13+03:00",
"app/commerce-modules/tax/examples/page.mdx": "2024-09-30T08:43:53.169Z",
"app/commerce-modules/tax/module-options/page.mdx": "2024-10-16T08:51:53.676Z",
"app/commerce-modules/tax/tax-calculation-with-provider/page.mdx": "2024-07-01T10:21:19+03:00",
"app/commerce-modules/tax/tax-rates-and-rules/page.mdx": "2024-06-26T07:55:59+00:00",
"app/commerce-modules/tax/tax-region/page.mdx": "2024-05-29T11:08:06+00:00",
"app/commerce-modules/tax/page.mdx": "2024-09-30T08:43:53.170Z",
"app/commerce-modules/tax/examples/page.mdx": "2024-10-15T15:00:52.899Z",
"app/commerce-modules/tax/module-options/page.mdx": "2024-10-15T14:35:46.117Z",
"app/commerce-modules/tax/tax-calculation-with-provider/page.mdx": "2024-10-15T14:43:00.700Z",
"app/commerce-modules/tax/tax-rates-and-rules/page.mdx": "2024-10-15T14:38:06.889Z",
"app/commerce-modules/tax/tax-region/page.mdx": "2024-10-15T14:36:47.028Z",
"app/commerce-modules/tax/page.mdx": "2024-10-15T14:44:27.953Z",
"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/examples/page.mdx": "2024-09-30T08:43:53.171Z",
"app/commerce-modules/user/examples/page.mdx": "2024-10-15T15:00:59.626Z",
"app/commerce-modules/user/module-options/page.mdx": "2024-09-30T08:43:53.171Z",
"app/commerce-modules/user/user-creation-flows/page.mdx": "2024-06-26T07:55:59+00:00",
"app/commerce-modules/user/page.mdx": "2024-09-30T08:43:53.172Z",
"app/commerce-modules/user/user-creation-flows/page.mdx": "2024-10-15T14:51:37.311Z",
"app/commerce-modules/user/page.mdx": "2024-10-15T14:44:19.628Z",
"app/commerce-modules/page.mdx": "2024-10-07T13:55:08.014Z",
"app/contribution-guidelines/_admin-translations/page.mdx": "2024-05-13T18:55:11+03:00",
"app/contribution-guidelines/docs/page.mdx": "2024-05-13T18:55:11+03:00",
@@ -219,7 +215,7 @@ export const generatedEditDates = {
"app/commerce-modules/auth/create-actor-type/page.mdx": "2024-10-08T07:31:11.256Z",
"app/architectural-modules/page.mdx": "2024-05-28T13:25:03+03:00",
"app/architectural-modules/workflow-engine/redis/page.mdx": "2024-10-15T12:50:59.507Z",
"app/commerce-modules/api-key/examples/page.mdx": "2024-10-07T13:58:49.457Z",
"app/commerce-modules/api-key/examples/page.mdx": "2024-10-15T14:58:58.994Z",
"app/architectural-modules/notification/sendgrid/page.mdx": "2024-10-15T12:51:25.569Z",
"app/commerce-modules/api-key/concepts/page.mdx": "2024-10-07T13:59:37.529Z",
"app/architectural-modules/workflow-engine/page.mdx": "2024-05-28T13:25:03+03:00",
@@ -2295,6 +2291,10 @@ export const generatedEditDates = {
"references/fulfillment/interfaces/fulfillment.IFulfillmentModuleService/page.mdx": "2024-10-14T15:28:22.238Z",
"references/types/CommonTypes/interfaces/types.CommonTypes.RequestQueryFields/page.mdx": "2024-10-14T15:27:49.882Z",
"references/utils/utils.ProductUtils/page.mdx": "2024-10-14T15:27:51.874Z",
"app/commerce-modules/region/links-to-other-modules/page.mdx": "2024-10-15T14:10:50.853Z",
"app/commerce-modules/sales-channel/links-to-other-modules/page.mdx": "2024-10-15T14:25:29.097Z",
"app/commerce-modules/stock-location/links-to-other-modules/page.mdx": "2024-10-15T14:33:11.483Z",
"app/commerce-modules/store/links-to-other-modules/page.mdx": "2024-06-26T07:19:49.931Z",
"app/examples/page.mdx": "2024-10-15T12:19:18.820Z",
"app/medusa-cli/commands/build/page.mdx": "2024-10-16T08:16:27.618Z"
}
+12 -16
View File
@@ -467,18 +467,22 @@ export const filesMap = [
"filePath": "/www/apps/resources/app/commerce-modules/region/examples/page.mdx",
"pathname": "/commerce-modules/region/examples"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/region/links-to-other-modules/page.mdx",
"pathname": "/commerce-modules/region/links-to-other-modules"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/region/page.mdx",
"pathname": "/commerce-modules/region"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/region/relations-to-other-modules/page.mdx",
"pathname": "/commerce-modules/region/relations-to-other-modules"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/sales-channel/examples/page.mdx",
"pathname": "/commerce-modules/sales-channel/examples"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/sales-channel/links-to-other-modules/page.mdx",
"pathname": "/commerce-modules/sales-channel/links-to-other-modules"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/sales-channel/page.mdx",
"pathname": "/commerce-modules/sales-channel"
@@ -487,10 +491,6 @@ export const filesMap = [
"filePath": "/www/apps/resources/app/commerce-modules/sales-channel/publishable-api-keys/page.mdx",
"pathname": "/commerce-modules/sales-channel/publishable-api-keys"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/sales-channel/relations-to-other-modules/page.mdx",
"pathname": "/commerce-modules/sales-channel/relations-to-other-modules"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/stock-location/concepts/page.mdx",
"pathname": "/commerce-modules/stock-location/concepts"
@@ -500,12 +500,12 @@ export const filesMap = [
"pathname": "/commerce-modules/stock-location/examples"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/stock-location/page.mdx",
"pathname": "/commerce-modules/stock-location"
"filePath": "/www/apps/resources/app/commerce-modules/stock-location/links-to-other-modules/page.mdx",
"pathname": "/commerce-modules/stock-location/links-to-other-modules"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/stock-location/relations-to-other-modules/page.mdx",
"pathname": "/commerce-modules/stock-location/relations-to-other-modules"
"filePath": "/www/apps/resources/app/commerce-modules/stock-location/page.mdx",
"pathname": "/commerce-modules/stock-location"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/store/examples/page.mdx",
@@ -515,10 +515,6 @@ export const filesMap = [
"filePath": "/www/apps/resources/app/commerce-modules/store/page.mdx",
"pathname": "/commerce-modules/store"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/store/relations-to-other-modules/page.mdx",
"pathname": "/commerce-modules/store/relations-to-other-modules"
},
{
"filePath": "/www/apps/resources/app/commerce-modules/tax/examples/page.mdx",
"pathname": "/commerce-modules/tax/examples"
+7 -23
View File
@@ -6445,8 +6445,8 @@ export const generatedSidebar = [
"loaded": true,
"isPathHref": true,
"type": "link",
"path": "/commerce-modules/region/relations-to-other-modules",
"title": "Relations to Other Modules",
"path": "/commerce-modules/region/links-to-other-modules",
"title": "Links to Modules",
"children": []
}
]
@@ -6654,8 +6654,8 @@ export const generatedSidebar = [
"loaded": true,
"isPathHref": true,
"type": "link",
"path": "/commerce-modules/sales-channel/relations-to-other-modules",
"title": "Relation to Modules",
"path": "/commerce-modules/sales-channel/links-to-other-modules",
"title": "Links to Modules",
"children": []
}
]
@@ -6831,8 +6831,8 @@ export const generatedSidebar = [
"loaded": true,
"isPathHref": true,
"type": "link",
"path": "/commerce-modules/stock-location/relations-to-other-modules",
"title": "Relation to Modules",
"path": "/commerce-modules/stock-location/links-to-other-modules",
"title": "Links to Modules",
"children": []
}
]
@@ -6998,22 +6998,6 @@ export const generatedSidebar = [
"title": "Examples",
"children": []
},
{
"loaded": true,
"isPathHref": true,
"type": "sub-category",
"title": "Concepts",
"children": [
{
"loaded": true,
"isPathHref": true,
"type": "link",
"path": "/commerce-modules/store/relations-to-other-modules",
"title": "Relation to Modules",
"children": []
}
]
},
{
"loaded": true,
"isPathHref": true,
@@ -7508,7 +7492,7 @@ export const generatedSidebar = [
"loaded": true,
"isPathHref": true,
"type": "sub-category",
"title": "Concepts",
"title": "Guides",
"children": [
{
"loaded": true,
+15
View File
@@ -74,6 +74,21 @@ const nextConfig = {
destination: "/commerce-modules/inventory/links-to-other-modules",
permanent: true,
},
{
source: "/commerce-modules/region/relations-to-other-modules",
destination: "/commerce-modules/region/links-to-other-modules",
permanent: true,
},
{
source: "/commerce-modules/sales-channel/relations-to-other-modules",
destination: "/commerce-modules/sales-channel/links-to-other-modules",
permanent: true,
},
{
source: "/commerce-modules/stock-location/relations-to-other-modules",
destination: "/commerce-modules/stock-location/links-to-other-modules",
permanent: true,
},
{
source: "/commerce-modules/pricing/relations-to-other-modules",
destination: "/commerce-modules/pricing/links-to-other-modules",
+7 -18
View File
@@ -1181,8 +1181,8 @@ export const sidebar = sidebarAttachHrefCommonOptions([
children: [
{
type: "link",
path: "/commerce-modules/region/relations-to-other-modules",
title: "Relations to Other Modules",
path: "/commerce-modules/region/links-to-other-modules",
title: "Links to Modules",
},
],
},
@@ -1249,8 +1249,8 @@ export const sidebar = sidebarAttachHrefCommonOptions([
},
{
type: "link",
path: "/commerce-modules/sales-channel/relations-to-other-modules",
title: "Relation to Modules",
path: "/commerce-modules/sales-channel/links-to-other-modules",
title: "Links to Modules",
},
],
},
@@ -1319,8 +1319,8 @@ export const sidebar = sidebarAttachHrefCommonOptions([
},
{
type: "link",
path: "/commerce-modules/stock-location/relations-to-other-modules",
title: "Relation to Modules",
path: "/commerce-modules/stock-location/links-to-other-modules",
title: "Links to Modules",
},
],
},
@@ -1379,17 +1379,6 @@ export const sidebar = sidebarAttachHrefCommonOptions([
path: "/commerce-modules/store/examples",
title: "Examples",
},
{
type: "sub-category",
title: "Concepts",
children: [
{
type: "link",
path: "/commerce-modules/store/relations-to-other-modules",
title: "Relation to Modules",
},
],
},
{
type: "sub-category",
title: "References",
@@ -1538,7 +1527,7 @@ export const sidebar = sidebarAttachHrefCommonOptions([
},
{
type: "sub-category",
title: "Concepts",
title: "Guides",
children: [
{
type: "link",
@@ -88,7 +88,13 @@ const mergerOptions: Partial<TypeDocOptions> = {
},
},
[`^${snakeCaseModuleName}/${moduleServiceName}/methods`]: {
reflectionDescription: `This documentation provides a reference to the \`{{alias}}\` {{kind}}. This belongs to the ${titleModuleName} Module.`,
reflectionDescription: `This documentation provides a reference to the \`{{alias}}\` {{kind}}. This belongs to the ${titleModuleName} Module.
<Note>
You should only use this methods when implementing complex customizations. For common cases, check out [available workflows instead](/medusa-workflows-reference).
</Note>`,
frontmatterData: {
displayed_sidebar: `${camelCaseModuleName}Reference`,
slug: `/references/${moduleName}/{{alias}}`,
@@ -101,7 +107,13 @@ const mergerOptions: Partial<TypeDocOptions> = {
},
},
[`^${snakeCaseModuleName}/.*${moduleServiceName}/page\\.mdx`]: {
reflectionDescription: `This section of the documentation provides a reference to the \`${moduleServiceName}\` interfaces methods. This is the interface developers use to use the functionalities provided by the ${titleModuleName} Module.`,
reflectionDescription: `This section of the documentation provides a reference to the \`${moduleServiceName}\` interfaces methods. This is the interface developers use to use the functionalities provided by the ${titleModuleName} Module.
<Note>
You should only use the methods in this reference when implementing complex customizations. For common cases, check out [available workflows instead](/medusa-workflows-reference).
</Note>`,
frontmatterData: {
displayed_sidebar: `${camelCaseModuleName}Reference`,
slug: `/references/${moduleName}`,