docs: update imports and package names across docs (#9375)

* docs: update imports and package names across docs
+ reference configs

* generate files

* fix import

* change preview to rc
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-10-01 11:03:42 +02:00
1 parent c726ed54f5
commit 2e16949979
196 files changed
+1379 -1491

No files matched your search

@@ -114,7 +114,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminOrder>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminOrder>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -137,7 +137,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminOrder>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminOrder>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -160,7 +160,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminOrder>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminOrder>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -183,7 +183,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminOrder>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminOrder>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -254,7 +254,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminCustomer>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminCustomer>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -277,7 +277,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminCustomer>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminCustomer>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -334,7 +334,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminCustomerGroup>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminCustomerGroup>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -357,7 +357,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminCustomerGroup>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminCustomerGroup>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -428,7 +428,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminProduct>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminProduct>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -451,7 +451,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminProduct>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminProduct>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -474,7 +474,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminProduct>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminProduct>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -497,7 +497,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminProduct>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminProduct>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -554,7 +554,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminProductCollection>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminProductCollection>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -577,7 +577,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminProductCollection>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminProductCollection>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -634,7 +634,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminProductCategory>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminProductCategory>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -657,7 +657,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminProductCategory>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminProductCategory>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -680,7 +680,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminProductCategory>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminProductCategory>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -703,7 +703,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminProductCategory>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminProductCategory>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -774,7 +774,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<PriceListDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<PriceListDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -797,7 +797,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<PriceListDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<PriceListDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -820,7 +820,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<PriceListDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<PriceListDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -843,7 +843,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<PriceListDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<PriceListDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -914,7 +914,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<PromotionDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<PromotionDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -937,7 +937,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<PromotionDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<PromotionDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -960,7 +960,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<PromotionDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<PromotionDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -983,7 +983,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<PromotionDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<PromotionDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1040,7 +1040,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<CampaignDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<CampaignDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1063,7 +1063,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<CampaignDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<CampaignDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1086,7 +1086,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<CampaignDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<CampaignDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1109,7 +1109,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<CampaignDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<CampaignDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1182,7 +1182,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<UserDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<UserDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1205,7 +1205,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<UserDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<UserDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1242,7 +1242,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ExtendedStoreDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ExtendedStoreDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1265,7 +1265,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ExtendedStoreDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ExtendedStoreDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1302,7 +1302,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<UserDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<UserDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1325,7 +1325,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<UserDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<UserDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1396,7 +1396,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminRegion>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminRegion>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1419,7 +1419,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<AdminRegion>` imported from `@medusajs/types`
Type `DetailWidgetProps<AdminRegion>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1490,7 +1490,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ShippingProfileDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ShippingProfileDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1513,7 +1513,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ShippingProfileDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ShippingProfileDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1584,7 +1584,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ExtendedStockLocationDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ExtendedStockLocationDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1607,7 +1607,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ExtendedStockLocationDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ExtendedStockLocationDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1630,7 +1630,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ExtendedStockLocationDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ExtendedStockLocationDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1653,7 +1653,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ExtendedStockLocationDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ExtendedStockLocationDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1724,7 +1724,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<SalesChannelResponse>` imported from `@medusajs/types`
Type `DetailWidgetProps<SalesChannelResponse>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1747,7 +1747,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<SalesChannelResponse>` imported from `@medusajs/types`
Type `DetailWidgetProps<SalesChannelResponse>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1818,7 +1818,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ReservationItemDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ReservationItemDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1841,7 +1841,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ReservationItemDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ReservationItemDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1864,7 +1864,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ReservationItemDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ReservationItemDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1887,7 +1887,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ReservationItemDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<ReservationItemDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1958,7 +1958,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ApiKeyResponse>` imported from `@medusajs/types`
Type `DetailWidgetProps<ApiKeyResponse>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -1981,7 +1981,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<ApiKeyResponse>` imported from `@medusajs/types`
Type `DetailWidgetProps<ApiKeyResponse>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -2052,7 +2052,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<WorkflowExecutionDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<WorkflowExecutionDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -2075,7 +2075,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<WorkflowExecutionDTO>` imported from `@medusajs/types`
Type `DetailWidgetProps<WorkflowExecutionDTO>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -2146,7 +2146,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<TaxRegionResponse>` imported from `@medusajs/types`
Type `DetailWidgetProps<TaxRegionResponse>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -2169,7 +2169,7 @@ This documentation page includes the list of injection zones you can add Admin W
</Table.Cell>
<Table.Cell>
Type `DetailWidgetProps<TaxRegionResponse>` imported from `@medusajs/types`
Type `DetailWidgetProps<TaxRegionResponse>` imported from `@medusajs/framework/types`
```ts blockStyle="inline"
{
@@ -16,10 +16,10 @@ Start by creating a new directory for your module. For example, `src/modules/my-
Create the file `src/modules/my-cache/service.ts` that holds the implementation of the cache service.
The Cache Module's main service must implement the `ICacheService` interface imported from `@medusajs/types`:
The Cache Module's main service must implement the `ICacheService` interface imported from `@medusajs/framework/types`:
```ts title="src/modules/my-cache/service.ts"
import { ICacheService } from "@medusajs/types"
import { ICacheService } from "@medusajs/framework/types"
class MyCacheService implements ICacheService {
get<T>(key: string): Promise<T> {
@@ -135,7 +135,7 @@ Create the file `src/modules/my-cache/index.ts` with the following content:
```ts title="src/modules/my-cache/index.ts"
import MyCacheService from "./service"
import { Module } from "@medusajs/utils"
import { Module } from "@medusajs/framework/utils"
export default Module("my-cache", {
service: MyCacheService,
@@ -153,7 +153,7 @@ To use your Cache Module, add it to the `modules` object exported as part of the
For example:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -14,30 +14,18 @@ For production, it’s recommended to use modules like [Redis Cache Module](../r
---
## Install the In-Memory Cache Module
## Register the In-Memory Cache Module
<Note>
The In-Memory Cache Module is installed by default in your application.
The In-Memory Cache Module is registered by default in your application.
</Note>
To install the In-Memory Cache Module, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/cache-inmemory@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
Add the module into the `modules` property of the exported object in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -45,7 +33,7 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.CACHE]: {
resolve: "@medusajs/cache-inmemory",
resolve: "@medusajs/medusa/cache-inmemory",
options: {
// optional options
},
@@ -10,7 +10,7 @@ The Redis Cache Module uses Redis to cache data in your store. In production, it
---
## Install the Redis Cache Module
## Register the Redis Cache Module
<Prerequisites items={[
{
@@ -19,26 +19,14 @@ The Redis Cache Module uses Redis to cache data in your store. In production, it
}
]} />
To install Redis Cache Module, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/cache-redis@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
Add the module into the `modules` property of the exported object in `medusa-config.js`:
export const highlights = [
["11", "redisUrl", "The Redis connection URL."]
]
```js title="medusa-config.js" highlights={highlights}
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -46,7 +34,7 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.CACHE]: {
resolve: "@medusajs/cache-redis",
resolve: "@medusajs/medusa/cache-redis",
options: {
redisUrl: process.env.CACHE_REDIS_URL,
},
@@ -166,6 +154,8 @@ CACHE_REDIS_URL=<YOUR_REDIS_URL>
</Table.Body>
</Table>
---
## Test the Module
To test the module, start the Medusa application:
@@ -16,11 +16,11 @@ Start by creating a new directory for your module. For example, `src/modules/my-
Create the file `src/modules/my-event/service.ts` that holds the implementation of the event service.
The Event Module's main service must extend the `AbstractEventBusModuleService` class imported from `@medusajs/utils`:
The Event Module's main service must extend the `AbstractEventBusModuleService` class imported from `@medusajs/framework/utils`:
```ts title="src/modules/my-event/service.ts"
import { EmitData, Message } from "@medusajs/types"
import { AbstractEventBusModuleService } from "@medusajs/utils"
import { EmitData, Message } from "@medusajs/framework/types"
import { AbstractEventBusModuleService } from "@medusajs/framework/utils"
class MyEventService extends AbstractEventBusModuleService {
emit<T>(eventName: string, data: T, options: Record<string, unknown>): Promise<void>;
@@ -90,7 +90,7 @@ Create the file `src/modules/my-event/index.ts` with the following content:
```ts title="src/modules/my-event/index.ts"
import MyEventService from "./service"
import { Module } from "@medusajs/utils"
import { Module } from "@medusajs/framework/utils"
export default Module("my-event", {
service: MyEventService,
@@ -108,7 +108,7 @@ To use your Event Module, add it to the `modules` object exported as part of the
For example:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -12,30 +12,18 @@ For production, it’s recommended to use modules like [Redis Event Bus Module](
---
## Install the Local Event Bus Module
## Register the Local Event Bus Module
<Note>
The Local Event Bus Module is installed by default in your application.
The Local Event Bus Module is registered by default in your application.
</Note>
To install Local Event Bus Module, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/event-bus-local@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
Add the module into the `modules` property of the exported object in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -14,7 +14,7 @@ In production, it's recommended to use this module.
---
## Install the Redis Events Bus Module
## Register the Redis Events Bus Module
<Prerequisites items={[
{
@@ -23,26 +23,14 @@ In production, it's recommended to use this module.
}
]} />
To install Redis Event Bus Module, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/event-bus-redis@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
Add the module into the `modules` property of the exported object in `medusa-config.js`:
export const highlights = [
["11", "redisUrl", "The Redis connection URL."]
]
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -50,7 +38,7 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.EVENT_BUS]: {
resolve: "@medusajs/event-bus-redis",
resolve: "@medusajs/medusa/event-bus-redis",
options: {
redisUrl: process.env.EVENTS_REDIS_URL,
},
@@ -16,27 +16,15 @@ The Local File Module Provider is only for development purposes. Use the [S3 Fil
---
## Install the Local File Module
## Register the Local File Module
<Note>
The Local File Module is installed by default in your application.
The Local File Module Provider is registered by default in your application.
</Note>
To install the Local File Module Provider, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/file-local-next@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module into the `providers` array of the File Module:
Add the module into the `providers` array of the File Module:
<Note>
@@ -45,7 +33,7 @@ The File Module accepts one provider only.
</Note>
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -53,11 +41,11 @@ module.exports = {
// ...
modules: {
[Modules.FILE]: {
resolve: "@medusajs/file",
resolve: "@medusajs/medusa/file",
options: {
providers: [
{
resolve: "@medusajs/file-local-next",
resolve: "@medusajs/medusa/file-local-next",
id: "local",
options: {
// provider options...
@@ -102,15 +102,9 @@ The S3 File Module Provider integrates Amazon S3 and services following a compat
---
## Install the S3 File Module
## Register the S3 File Module
To install the S3 File Module Provider, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/file-s3@preview
```
Next, add the module into the `providers` array of the File Module:
Add the module into the `providers` array of the File Module:
<Note>
@@ -119,7 +113,7 @@ The File Module accepts one provider only.
</Note>
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -128,11 +122,11 @@ module.exports = {
modules: {
// ...
[Modules.FILE]: {
resolve: "@medusajs/file",
resolve: "@medusajs/medusa/file",
options: {
providers: [
{
resolve: "@medusajs/file-s3",
resolve: "@medusajs/medusa/file-s3",
id: "s3",
options: {
file_url: process.env.S3_FILE_URL,
@@ -360,11 +354,11 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.FILE]: {
resolve: "@medusajs/file",
resolve: "@medusajs/medusa/file",
options: {
providers: [
{
resolve: "@medusajs/file-s3",
resolve: "@medusajs/medusa/file-s3",
id: "s3",
options: {
// ...
@@ -10,27 +10,15 @@ The Local Notification Module Provider simulates sending a notification, but onl
---
## Install the Local Notification Module
## Register the Local Notification Module
<Note>
The Local Notification Module Provider is installed by default in your application.
The Local Notification Module Provider is registered by default in your application. It's configured to run on the `feed` channel.
</Note>
To install the Local Notification Module Provider, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/notification-local@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module into the `providers` array of the Notification Module:
Add the module into the `providers` array of the Notification Module:
<Note>
@@ -39,7 +27,7 @@ Only one provider can be defined for a channel.
</Note>
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -47,12 +35,12 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.NOTIFICATION]: {
resolve: "@medusajs/notification",
resolve: "@medusajs/medusa/notification",
options: {
providers: [
// ...
{
resolve: "@medusajs/notification-local",
resolve: "@medusajs/medusa/notification-local",
id: "local",
options: {
channels: ["email"],
@@ -31,7 +31,7 @@ When you send a notification, you specify the channel to send it through, such a
For example:
```js title="medusa-config.js" highlights={[["19"]]}
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -40,12 +40,12 @@ module.exports = {
modules: {
// ...
[Modules.NOTIFICATION]: {
resolve: "@medusajs/notification",
resolve: "@medusajs/medusa/notification",
options: {
providers: [
// ...
{
resolve: "@medusajs/notification-local",
resolve: "@medusajs/medusa/notification-local",
id: "notification",
options: {
channels: ["email"],
@@ -37,8 +37,8 @@ import type {
SubscriberArgs,
SubscriberConfig,
} from "@medusajs/medusa"
import { Modules } from "@medusajs/utils"
import { INotificationModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/framework/utils"
import { INotificationModuleService } from "@medusajs/framework/types"
export default async function productCreateHandler({
event: { data },
@@ -10,7 +10,7 @@ The SendGrid Notification Module Provider integrates [SendGrid](https://sendgrid
---
## Install the SendGrid Notification Module
## Register the SendGrid Notification Module
<Prerequisites
items={[
@@ -29,19 +29,7 @@ The SendGrid Notification Module Provider integrates [SendGrid](https://sendgrid
]}
/>
To install the SendGrid Notification Module Provider, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/notification-sendgrid@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module into the `providers` array of the Notification Module:
Add the module into the `providers` array of the Notification Module:
<Note>
@@ -50,7 +38,7 @@ Only one provider can be defined for a channel.
</Note>
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -58,12 +46,12 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.NOTIFICATION]: {
resolve: "@medusajs/notification",
resolve: "@medusajs/medusa/notification",
options: {
providers: [
// ...
{
resolve: "@medusajs/notification-sendgrid",
resolve: "@medusajs/medusa/notification-sendgrid",
id: "sendgrid",
options: {
channels: ["email"],
@@ -144,8 +132,8 @@ import type {
SubscriberArgs,
SubscriberConfig,
} from "@medusajs/medusa"
import { Modules } from "@medusajs/utils"
import { INotificationModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/framework/utils"
import { INotificationModuleService } from "@medusajs/framework/types"
export default async function productCreateHandler({
event: { data },
@@ -14,30 +14,18 @@ For production, it’s recommended to use modules like [Redis Workflow Engine Mo
---
## Install the In-Memory Workflow Engine Module
## Register the In-Memory Workflow Engine Module
<Note>
The In-Memory Workflow Engine Module is installed by default in your application.
The In-Memory Workflow Engine Module is registered by default in your application.
</Note>
To install the In-Memory Workflow Engine Module, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/workflow-engine-inmemory@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
Add the module into the `modules` property of the exported object in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -10,7 +10,7 @@ The Redis Workflow Engine Module uses Redis to track workflow executions and han
---
## Install the Redis Workflow Engine Module
## Register the Redis Workflow Engine Module
<Prerequisites items={[
{
@@ -19,26 +19,14 @@ The Redis Workflow Engine Module uses Redis to track workflow executions and han
}
]} />
To install Redis Workflow Engine Module, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/workflow-engine-redis@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module into the `modules` property of the exported object in `medusa-config.js`:
Add the module into the `modules` property of the exported object in `medusa-config.js`:
export const highlights = [
["12", "url", "The Redis connection URL."]
]
```js title="medusa-config.js" highlights={highlights}
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -15,8 +15,8 @@ In this guide, you’ll find common examples of how you can use the API Key Modu
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IApiKeyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IApiKeyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const apiKeyModuleService: IApiKeyModuleService = request.scope.resolve(
@@ -41,7 +41,7 @@ export async function POST(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeApiKeyModule } from "@medusajs/api-key"
import { initialize as initializeApiKeyModule } from "@medusajs/medusa/api-key"
export async function POST(request: Request) {
const apiKeyModuleService = await initializeApiKeyModule()
@@ -70,8 +70,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IApiKeyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IApiKeyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(request: MedusaRequest, res: MedusaResponse) {
const apiKeyModuleService: IApiKeyModuleService = request.scope.resolve(
@@ -90,7 +90,7 @@ export async function GET(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeApiKeyModule } from "@medusajs/api-key"
import { initialize as initializeApiKeyModule } from "@medusajs/medusa/api-key"
export async function GET(request: Request) {
const apiKeyModuleService = await initializeApiKeyModule()
@@ -113,8 +113,8 @@ export async function GET(request: Request) {
```ts collapsibleLines="1-9" expandButtonLabel="Show Imports"
import { AuthenticatedMedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IApiKeyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IApiKeyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: AuthenticatedMedusaRequest,
@@ -140,7 +140,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeApiKeyModule } from "@medusajs/api-key"
import { initialize as initializeApiKeyModule } from "@medusajs/medusa/api-key"
type ContextType = {
params: {
@@ -174,8 +174,8 @@ export async function POST(request: Request, { params }: ContextType) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IApiKeyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IApiKeyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const apiKeyModuleService: IApiKeyModuleService = request.scope.resolve(
@@ -198,7 +198,7 @@ export async function POST(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeApiKeyModule } from "@medusajs/api-key"
import { initialize as initializeApiKeyModule } from "@medusajs/medusa/api-key"
type ContextType = {
params: {
@@ -234,8 +234,8 @@ export async function POST(request: Request, { params }: ContextType) {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { IApiKeyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IApiKeyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: AuthenticatedMedusaRequest,
@@ -267,7 +267,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeApiKeyModule } from "@medusajs/api-key"
import { initialize as initializeApiKeyModule } from "@medusajs/medusa/api-key"
type ContextType = {
params: {
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The API Key Module is the `@medusajs/api-key` NPM package that provides API-key-related features in your Medusa and Node.js applications.
The API Key Module is the `@medusajs/medusa/api-key` NPM package that provides API-key-related features in your Medusa and Node.js applications.
## How to Use API Key Module's Service
You can use the API Key Module's main service by resolving from the Medusa container the resource `Modules.API_KEY` imported from `@medusajs/utils`.
You can use the API Key Module's main service by resolving from the Medusa container the resource `Modules.API_KEY` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IApiKeyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IApiKeyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IApiKeyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IApiKeyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const apiKeyModuleService: IApiKeyModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IApiKeyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IApiKeyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const apiKeyModuleService: IApiKeyModuleService = container.resolve(
@@ -12,26 +12,26 @@ Using the Emailpass auth module provider, you allow users to register and login
---
## Install the Emailpass Auth Module Provider
## Register the Emailpass Auth Module Provider
The Emailpass auth provider is registered by default with the Auth Module.
If you want to pass options to the provider, add the provider to the `providers` option of the Auth Module:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
const modules = {
// ...
[Modules.AUTH]: {
resolve: "@medusajs/auth",
resolve: "@medusajs/medusa/auth",
options: {
providers: [
// other providers...
{
resolve: "@medusajs/auth-emailpass",
resolve: "@medusajs/medusa/auth-emailpass",
id: "emailpass",
options: {
// options...
@@ -18,7 +18,7 @@ Learn about the authentication flow in [this guide](../../authentication-route/p
---
## Install the Github Auth Module Provider
## Register the Github Auth Module Provider
<Prerequisites
items={[
@@ -33,28 +33,22 @@ Learn about the authentication flow in [this guide](../../authentication-route/p
]}
/>
To install the GitHub auth module provider, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/auth-github@preview
```
Next, add the module to the array of providers passed to the Auth Module:
Add the module to the array of providers passed to the Auth Module:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
const modules = {
// ...
[Modules.AUTH]: {
resolve: "@medusajs/auth",
resolve: "@medusajs/medusa/auth",
options: {
providers: [
// other providers...
{
resolve: "@medusajs/auth-github",
resolve: "@medusajs/medusa/auth-github",
id: "github",
options: {
clientId: process.env.GITHUB_CLIENT_ID,
@@ -18,7 +18,7 @@ Learn about the authentication flow in [this guide](../../authentication-route/p
---
## Install the Google Auth Module Provider
## Register the Google Auth Module Provider
<Prerequisites
items={[
@@ -33,28 +33,22 @@ Learn about the authentication flow in [this guide](../../authentication-route/p
]}
/>
To install the Google auth module provider, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/auth-google@preview
```
Next, add the module to the array of providers passed to the Auth Module:
Add the module to the array of providers passed to the Auth Module:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
const modules = {
// ...
[Modules.AUTH]: {
resolve: "@medusajs/auth",
resolve: "@medusajs/medusa/auth",
options: {
providers: [
// other providers...
{
resolve: "@medusajs/auth-google",
resolve: "@medusajs/medusa/auth-google",
id: "google",
options: {
clientId: process.env.GOOGLE_CLIENT_ID,
@@ -13,7 +13,7 @@ Before creating an actor type, you must define a data model the actor type belon
The rest of this guide uses this `Manager` data model as an example:
```ts title="src/modules/manager/models/manager.ts"
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
const Manager = model.define("manager", {
id: model.id().primaryKey(),
@@ -49,10 +49,10 @@ import {
createStep,
StepResponse,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
setAuthAppMetadataStep,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
import ManagerModuleService from "../modules/manager/service"
type CreateManagerWorkflowInput = {
@@ -106,7 +106,7 @@ This workflow accepts the manager’s data and the associated auth identity’s
The workflow has two steps:
1. Create the manager using the `createManagerStep`.
2. Set the `app_metadata` property of the associated auth identity using the `setAuthAppMetadataStep` step imported from `@medusajs/core-flows`. You specify the actor type `manager` in the `actorType` property of the step’s input.
2. Set the `app_metadata` property of the associated auth identity using the `setAuthAppMetadataStep` step imported from `@medusajs/medusa/core-flows`. You specify the actor type `manager` in the `actorType` property of the step’s input.
---
@@ -127,7 +127,7 @@ import type {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import createManagerWorkflow from "../../workflows/create-manager"
type RequestBody = {
@@ -308,7 +308,7 @@ For example, create the following workflow that deletes a manager and updates it
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import ManagerModuleService from "../modules/manager/service"
export type DeleteManagerWorkflow = {
@@ -348,17 +348,17 @@ export const deleteHighlights = [
```ts title="src/workflows/delete-manager.ts" collapsibleLines="1-15" expandButtonLabel="Show Imports" highlights={deleteHighlights}
// other imports
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import {
WorkflowData,
WorkflowResponse,
createWorkflow,
transform,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
setAuthAppMetadataStep,
useRemoteQueryStep,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
// ...
@@ -24,9 +24,9 @@ This example uses the [jsonwebtoken NPM package](https://www.npmjs.com/package/j
import {
IAuthModuleService,
AuthenticationInput,
} from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { MedusaError } from "@medusajs/utils"
} from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { MedusaError } from "@medusajs/framework/utils"
import jwt from "jsonwebtoken"
export async function POST(
@@ -69,7 +69,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
export async function POST(request: Request) {
const authModuleService = await initializeAuthModule()
@@ -127,9 +127,9 @@ This example uses the [jsonwebtoken NPM package](https://www.npmjs.com/package/j
import {
IAuthModuleService,
AuthenticationInput,
} from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { MedusaError } from "@medusajs/utils"
} from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { MedusaError } from "@medusajs/framework/utils"
import jwt from "jsonwebtoken"
export async function POST(
@@ -174,7 +174,7 @@ export async function POST(
```ts collapsibleLines="1-7" expandButtonLabel="Show Imports"
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
export async function POST(request: Request) {
const authModuleService = await initializeAuthModule()
@@ -226,8 +226,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -253,7 +253,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
export async function POST(request: Request) {
const authModuleService = await initializeAuthModule()
@@ -282,8 +282,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -305,7 +305,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
export async function GET(request: Request) {
const authModuleService = await initializeAuthModule()
@@ -328,8 +328,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -358,7 +358,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
type ContextType = {
params: {
@@ -394,8 +394,8 @@ export async function POST(request: Request, { params }: ContextType) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
req: MedusaRequest,
@@ -417,7 +417,7 @@ export async function DELETE(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeAuthModule } from "@medusajs/auth"
import { initialize as initializeAuthModule } from "@medusajs/medusa/auth"
type ContextType = {
params: {
@@ -21,18 +21,18 @@ When the Medusa application starts, these providers are registered and can be us
For example:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
module.exports = defineConfig({
// ...
modules: {
resolve: "@medusajs/auth",
resolve: "@medusajs/medusa/auth",
options: {
providers: [
{
resolve: "@medusajs/auth-emailpass",
resolve: "@medusajs/medusa/auth-emailpass",
id: "emailpass",
options: {
// provider options...
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Auth Module is the `@medusajs/auth` NPM package that provides authentication-related features in your Medusa and Node.js applications.
The Auth Module is the `@medusajs/medusa/auth` NPM package that provides authentication-related features in your Medusa and Node.js applications.
## How to Use Auth Module's Service
You can use the Auth Module's main service by resolving from the Medusa container the resource `Modules.AUTH` imported from `@medusajs/utils`.
You can use the Auth Module's main service by resolving from the Medusa container the resource `Modules.AUTH` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const authModuleService: IAuthModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IAuthModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IAuthModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const authModuleService: IAuthModuleService = container.resolve(
@@ -15,8 +15,8 @@ In this guide, you’ll find common examples of how you can use the Cart Module
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -51,7 +51,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCartModule } from "@medusajs/cart"
import { initialize as initializeCartModule } from "@medusajs/medusa/cart"
export async function POST(request: Request) {
const cartModuleService = await initializeCartModule()
@@ -89,8 +89,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -112,7 +112,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCartModule } from "@medusajs/cart"
import { initialize as initializeCartModule } from "@medusajs/medusa/cart"
export async function GET(request: Request) {
const cartModuleService = await initializeCartModule()
@@ -137,8 +137,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -167,7 +167,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCartModule } from "@medusajs/cart"
import { initialize as initializeCartModule } from "@medusajs/medusa/cart"
export async function POST(request: Request) {
const cartModuleService = await initializeCartModule()
@@ -197,8 +197,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -226,7 +226,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCartModule } from "@medusajs/cart"
import { initialize as initializeCartModule } from "@medusajs/medusa/cart"
export async function POST(request: Request) {
const cartModuleService = await initializeCartModule()
@@ -255,8 +255,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -284,7 +284,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCartModule } from "@medusajs/cart"
import { initialize as initializeCartModule } from "@medusajs/medusa/cart"
export async function POST(request: Request) {
const cartModuleService = await initializeCartModule()
@@ -313,8 +313,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -343,7 +343,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCartModule } from "@medusajs/cart"
import { initialize as initializeCartModule } from "@medusajs/medusa/cart"
export async function POST(request: Request) {
const cartModuleService = await initializeCartModule()
@@ -373,8 +373,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
req: MedusaRequest,
@@ -396,7 +396,7 @@ export async function DELETE(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCartModule } from "@medusajs/cart"
import { initialize as initializeCartModule } from "@medusajs/medusa/cart"
export async function DELETE(request: Request) {
const cartModuleService = await initializeCartModule()
@@ -417,8 +417,8 @@ export async function DELETE(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
req: MedusaRequest,
@@ -439,8 +439,8 @@ export async function DELETE(
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
req: MedusaRequest,
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Cart Module is the `@medusajs/cart` NPM package that provides cart-related features in your Medusa and Node.js applications.
The Cart Module is the `@medusajs/medusa/cart` NPM package that provides cart-related features in your Medusa and Node.js applications.
## How to Use Cart Module's Service
You can use the Cart Module's main service by resolving from the Medusa container the resource `Modules.CART` imported from `@medusajs/utils`.
You can use the Cart Module's main service by resolving from the Medusa container the resource `Modules.CART` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const cartModuleService: ICartModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { ICartModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { ICartModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const cartModuleService: ICartModuleService = container.resolve(
@@ -47,7 +47,7 @@ import {
ComputeActionItemLine,
ComputeActionShippingLine,
// ...
} from "@medusajs/types"
} from "@medusajs/framework/types"
// retrieve the cart
const cart = await cartModuleService.retrieveCart("cart_123", {
@@ -106,7 +106,7 @@ import {
AddItemAdjustmentAction,
AddShippingMethodAdjustment,
// ...
} from "@medusajs/types"
} from "@medusajs/framework/types"
// ...
@@ -15,8 +15,8 @@ In this guide, you’ll find common examples of how you can use the Currency Mod
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICurrencyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICurrencyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -38,7 +38,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCurrencyModule } from "@medusajs/currency"
import { initialize as initializeCurrencyModule } from "@medusajs/medusa/currency"
export async function GET(request: Request) {
const currencyModuleService = await initializeCurrencyModule()
@@ -61,8 +61,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICurrencyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICurrencyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -86,7 +86,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCurrencyModule } from "@medusajs/currency"
import { initialize as initializeCurrencyModule } from "@medusajs/medusa/currency"
export async function GET(request: Request) {
const currencyModuleService = await initializeCurrencyModule()
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Currency Module is the `@medusajs/currency` NPM package that provides currency-related features in your Medusa and Node.js applications.
The Currency Module is the `@medusajs/medusa/currency` NPM package that provides currency-related features in your Medusa and Node.js applications.
## How to Use Currency Module's Service
You can use the Currency Module's main service by resolving from the Medusa container the resource `Modules.CURRENCY` imported from `@medusajs/utils`.
You can use the Currency Module's main service by resolving from the Medusa container the resource `Modules.CURRENCY` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICurrencyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICurrencyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { ICurrencyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICurrencyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const currencyModuleService: ICurrencyModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { ICurrencyModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { ICurrencyModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const currencyModuleService: ICurrencyModuleService = container.resolve(
@@ -15,8 +15,8 @@ In this guide, you’ll find common examples of how you can use the Customer Mod
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICustomerModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const customerModuleService: ICustomerModuleService = request.scope.resolve(
@@ -41,7 +41,7 @@ export async function POST(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCustomerModule } from "@medusajs/customer"
import { initialize as initializeCustomerModule } from "@medusajs/medusa/customer"
export async function POST(request: Request) {
const customerModuleService = await initializeCustomerModule()
@@ -70,8 +70,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICustomerModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const customerModuleService: ICustomerModuleService = request.scope.resolve(
@@ -94,7 +94,7 @@ export async function POST(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCustomerModule } from "@medusajs/customer"
import { initialize as initializeCustomerModule } from "@medusajs/medusa/customer"
export async function POST(request: Request) {
const customerModuleService = await initializeCustomerModule()
@@ -121,8 +121,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICustomerModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const customerModuleService: ICustomerModuleService = request.scope.resolve(
@@ -144,7 +144,7 @@ export async function POST(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeCustomerModule } from "@medusajs/customer"
import { initialize as initializeCustomerModule } from "@medusajs/medusa/customer"
export async function POST(request: Request) {
const customerModuleService = await initializeCustomerModule()
@@ -170,8 +170,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICustomerModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const customerModuleService: ICustomerModuleService = request.scope.resolve(
@@ -194,7 +194,7 @@ export async function POST(request: MedusaRequest, res: MedusaResponse) {
import { NextResponse } from "next/server"
// eslint-disable-next-line prettier/prettier
import { initialize as initializeCustomerModule } from "@medusajs/customer"
import { initialize as initializeCustomerModule } from "@medusajs/medusa/customer"
export async function POST(request: Request) {
const customerModuleService = await initializeCustomerModule()
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Customer Module is the `@medusajs/customer` NPM package that provides customer-related features in your Medusa and Node.js applications.
The Customer Module is the `@medusajs/medusa/customer` NPM package that provides customer-related features in your Medusa and Node.js applications.
## How to Use Customer Module's Service
You can use the Customer Module's main service by resolving from the Medusa container the resource `Modules.CUSTOMER` imported from `@medusajs/utils`.
You can use the Customer Module's main service by resolving from the Medusa container the resource `Modules.CUSTOMER` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICustomerModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(request: MedusaRequest, res: MedusaResponse) {
const customerModuleService: ICustomerModuleService = request.scope.resolve(
@@ -38,8 +38,8 @@ export async function GET(request: MedusaRequest, res: MedusaResponse) {
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { ICustomerModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ICustomerModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const customerModuleService: ICustomerModuleService = container.resolve(
@@ -54,9 +54,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { ICustomerModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { ICustomerModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const customerModuleService: ICustomerModuleService = container.resolve(
@@ -21,7 +21,7 @@ When the Medusa application starts, these providers are registered and can be us
For example:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -29,11 +29,11 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.FULFILLMENT]: {
resolve: "@medusajs/fulfillment",
resolve: "@medusajs/medusa/fulfillment",
options: {
providers: [
{
resolve: `@medusajs/fulfillment-manual`,
resolve: `@medusajs/medusa/fulfillment-manual`,
id: "manual",
options: {
// provider options...
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Fulfillment Module is the `@medusajs/fulfillment` NPM package that provides fulfillment-related features in your Medusa and Node.js applications.
The Fulfillment Module is the `@medusajs/medusa/fulfillment` NPM package that provides fulfillment-related features in your Medusa and Node.js applications.
## How to Use Fulfillment Module's Service
You can use the Fulfillment Module's main service by resolving from the Medusa container the resource `Modules.API_KEY` imported from `@medusajs/utils`.
You can use the Fulfillment Module's main service by resolving from the Medusa container the resource `Modules.API_KEY` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IFulfillmentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IFulfillmentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IFulfillmentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IFulfillmentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const fulfillmentModuleService: IFulfillmentModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IFulfillmentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IFulfillmentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const fulfillmentModuleService: IFulfillmentModuleService = container.resolve(
@@ -15,8 +15,8 @@ In this document, you’ll find common examples of how you can use the Inventory
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -42,7 +42,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeInventoryModule } from "@medusajs/inventory-next"
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
export async function POST(request: Request) {
const inventoryModuleService = await initializeInventoryModule({})
@@ -70,8 +70,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -93,7 +93,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeInventoryModule } from "@medusajs/inventory-next"
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
export async function GET(request: Request) {
const inventoryModuleService = await initializeInventoryModule({})
@@ -116,8 +116,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -141,7 +141,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeInventoryModule } from "@medusajs/inventory-next"
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
type ContextType = {
params: {
@@ -172,8 +172,8 @@ export async function GET(request: Request, { params }: ContextType) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -199,7 +199,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeInventoryModule } from "@medusajs/inventory-next"
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
export async function POST(request: Request) {
const inventoryModuleService = await initializeInventoryModule({})
@@ -227,8 +227,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -254,7 +254,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeInventoryModule } from "@medusajs/inventory-next"
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
export async function POST(request: Request) {
const inventoryModuleService = await initializeInventoryModule({})
@@ -282,8 +282,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -309,7 +309,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeInventoryModule } from "@medusajs/inventory-next"
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
export async function POST(request: Request) {
const inventoryModuleService = await initializeInventoryModule({})
@@ -337,8 +337,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -364,7 +364,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeInventoryModule } from "@medusajs/inventory-next"
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
export async function POST(request: Request) {
const inventoryModuleService = await initializeInventoryModule({})
@@ -394,8 +394,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -434,7 +434,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeInventoryModule } from "@medusajs/inventory-next"
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
type ContextType = {
params: {
@@ -481,8 +481,8 @@ export async function POST(request: Request, { params }: ContextType) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
request: MedusaRequest,
@@ -504,7 +504,7 @@ export async function DELETE(
<CodeTab label="Next.js App Router" value="nextjs">
```ts
import { initialize as initializeInventoryModule } from "@medusajs/inventory-next"
import { initialize as initializeInventoryModule } from "@medusajs/medusa/inventory-next"
type ContextType = {
params: {
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Inventory Module is the `@medusajs/inventory-next` NPM package that provides inventory-related features in your Medusa and Node.js applications.
The Inventory Module is the `@medusajs/medusa/inventory-next` NPM package that provides inventory-related features in your Medusa and Node.js applications.
## How to Use Inventory Module's Service
You can use the Inventory Module's main service by resolving from the Medusa container the resource `Modules.INVENTORY` imported from `@medusajs/utils`.
You can use the Inventory Module's main service by resolving from the Medusa container the resource `Modules.INVENTORY` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const inventoryModuleService: IInventoryService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IInventoryService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IInventoryService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const inventoryModuleService: IInventoryService = container.resolve(
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Order Module is the `@medusajs/order` NPM package that provides order-related features in your Medusa and Node.js applications.
The Order Module is the `@medusajs/medusa/order` NPM package that provides order-related features in your Medusa and Node.js applications.
## How to Use Order Module's Service
You can use the Order Module's main service by resolving from the Medusa container the resource `Modules.ORDER` imported from `@medusajs/utils`.
You can use the Order Module's main service by resolving from the Medusa container the resource `Modules.ORDER` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IOrderModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IOrderModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IOrderModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IOrderModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const orderModuleService: IOrderModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IOrderModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IOrderModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const orderModuleService: IOrderModuleService = container.resolve(
@@ -53,7 +53,7 @@ import {
ComputeActionItemLine,
ComputeActionShippingLine,
// ...
} from "@medusajs/types"
} from "@medusajs/framework/types"
// ...
@@ -116,7 +116,7 @@ import {
AddItemAdjustmentAction,
AddShippingMethodAdjustment,
// ...
} from "@medusajs/types"
} from "@medusajs/framework/types"
// ...
@@ -15,8 +15,8 @@ In this guide, you’ll find common examples of how you can use the Payment Modu
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPaymentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPaymentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -46,7 +46,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePaymentModule } from "@medusajs/payment"
import { initialize as initializePaymentModule } from "@medusajs/medusa/payment"
export async function POST(request: Request) {
const paymentModuleService = await initializePaymentModule()
@@ -77,8 +77,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPaymentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPaymentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -110,7 +110,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePaymentModule } from "@medusajs/payment"
import { initialize as initializePaymentModule } from "@medusajs/medusa/payment"
export async function POST(request: Request) {
const paymentModuleService = await initializePaymentModule()
@@ -143,8 +143,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPaymentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPaymentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -170,7 +170,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePaymentModule } from "@medusajs/payment"
import { initialize as initializePaymentModule } from "@medusajs/medusa/payment"
export async function POST(request: Request) {
const paymentModuleService = await initializePaymentModule()
@@ -197,8 +197,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPaymentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPaymentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -225,7 +225,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePaymentModule } from "@medusajs/payment"
import { initialize as initializePaymentModule } from "@medusajs/medusa/payment"
export async function POST(request: Request) {
const paymentModuleService = await initializePaymentModule()
@@ -253,8 +253,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPaymentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPaymentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -280,7 +280,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePaymentModule } from "@medusajs/payment"
import { initialize as initializePaymentModule } from "@medusajs/medusa/payment"
export async function GET(request: Request) {
const paymentModuleService = await initializePaymentModule()
@@ -307,8 +307,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPaymentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPaymentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -334,7 +334,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePaymentModule } from "@medusajs/payment"
import { initialize as initializePaymentModule } from "@medusajs/medusa/payment"
export async function POST(request: Request) {
const paymentModuleService = await initializePaymentModule()
@@ -102,7 +102,7 @@ When the Medusa application starts, these providers are registered and can be us
For example:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -110,11 +110,11 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.PAYMENT]: {
resolve: "@medusajs/payment",
resolve: "@medusajs/medusa/payment",
options: {
providers: [
{
resolve: "@medusajs/payment-stripe",
resolve: "@medusajs/medusa/payment-stripe",
id: "stripe",
options: {
// ...
@@ -7,11 +7,11 @@ export const metadata = {
# {metadata.title}
The Payment Module is the `@medusajs/payment` NPM package that provides payment-related features in your Medusa and Node.js applications.
The Payment Module is the `@medusajs/medusa/payment` NPM package that provides payment-related features in your Medusa and Node.js applications.
## How to Use Payment Module's Service
You can use the Payment Module's main service by resolving from the Medusa container the resource `Modules.PAYMENT` imported from `@medusajs/utils`.
You can use the Payment Module's main service by resolving from the Medusa container the resource `Modules.PAYMENT` imported from `@medusajs/framework/utils`.
For example:
@@ -20,8 +20,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPaymentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPaymentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -42,8 +42,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IPaymentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPaymentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const paymentModuleService: IPaymentModuleService = container.resolve(
@@ -59,9 +59,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IPaymentModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IPaymentModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const paymentModuleService: IPaymentModuleService = container.resolve(
@@ -30,7 +30,7 @@ The Payment Module provides a `system` payment provider that acts as a placehold
## How are Payment Providers Created?
A payment provider is a TypeScript or JavaScript class that extends the `AbstractPaymentProvider` imported from `@medusajs/utils`. It can then be exported as the main service of a module.
A payment provider is a TypeScript or JavaScript class that extends the `AbstractPaymentProvider` imported from `@medusajs/framework/utils`. It can then be exported as the main service of a module.
<Note title="Tip">
@@ -20,7 +20,7 @@ These features are also available in a safe test environment, allowing for a con
---
## Install the Stripe Module Provider
## Register the Stripe Module Provider
<Prerequisites items={[
{
@@ -37,22 +37,10 @@ These features are also available in a safe test environment, allowing for a con
}
]} />
To install the Stripe Module Provider, run the following command in the directory of your Medusa application:
```bash npm2yarn
npm install @medusajs/payment-stripe@preview
```
<Note>
Make sure that the version added in `package.json` is `preview` to avoid errors with installation and updates in the future.
</Note>
Next, add the module to the array of providers passed to the Payment Module:
Add the module to the array of providers passed to the Payment Module:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -60,11 +48,11 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.PAYMENT]: {
resolve: "@medusajs/payment",
resolve: "@medusajs/medusa/payment",
options: {
providers: [
{
resolve: "@medusajs/payment-stripe",
resolve: "@medusajs/medusa/payment-stripe",
id: "stripe",
options: {
apiKey: process.env.STRIPE_API_KEY,
@@ -15,8 +15,8 @@ In this document, you’ll find common examples of how you can use the Pricing M
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPricingModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPricingModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -50,7 +50,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePricingModule } from "@medusajs/pricing"
import { initialize as initializePricingModule } from "@medusajs/medusa/pricing"
export async function POST(request: Request) {
const pricingModuleService = await initializePricingModule()
@@ -86,8 +86,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPricingModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPricingModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -109,7 +109,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePricingModule } from "@medusajs/pricing"
import { initialize as initializePricingModule } from "@medusajs/medusa/pricing"
export async function GET(request: Request) {
const pricingModuleService = await initializePricingModule()
@@ -132,8 +132,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPricingModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPricingModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -155,7 +155,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePricingModule } from "@medusajs/pricing"
import { initialize as initializePricingModule } from "@medusajs/medusa/pricing"
export async function GET(request: Request) {
const pricingModuleService = await initializePricingModule()
@@ -178,8 +178,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPricingModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPricingModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -212,7 +212,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePricingModule } from "@medusajs/pricing"
import { initialize as initializePricingModule } from "@medusajs/medusa/pricing"
export async function POST(request: Request) {
const pricingModuleService = await initializePricingModule()
@@ -247,9 +247,9 @@ export async function POST(request: Request) {
```ts collapsibleLines="1-8" expandButtonLabel="Show Imports"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPricingModuleService } from "@medusajs/types"
import { PriceListType } from "@medusajs/utils"
import { Modules } from "@medusajs/utils"
import { IPricingModuleService } from "@medusajs/framework/types"
import { PriceListType } from "@medusajs/framework/utils"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -290,8 +290,8 @@ export async function POST(
import { NextResponse } from "next/server"
import { PriceListType } from "@medusajs/medusa"
import { initialize as initializePricingModule } from "@medusajs/pricing"
import { PriceListType } from "@medusajs/utils"
import { initialize as initializePricingModule } from "@medusajs/medusa/pricing"
import { PriceListType } from "@medusajs/framework/utils"
export async function POST(request: Request) {
const pricingModuleService = await initializePricingModule()
@@ -332,8 +332,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPricingModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPricingModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -364,7 +364,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePricingModule } from "@medusajs/pricing"
import { initialize as initializePricingModule } from "@medusajs/medusa/pricing"
export async function GET(request: Request) {
const pricingModuleService = await initializePricingModule()
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Pricing Module is the `@medusajs/pricing` NPM package that provides pricing-related features in your Medusa and Node.js applications.
The Pricing Module is the `@medusajs/medusa/pricing` NPM package that provides pricing-related features in your Medusa and Node.js applications.
## How to Use Pricing Module's Service
You can use the Pricing Module's main service by resolving from the Medusa container the resource `Modules.PRICING` imported from `@medusajs/utils`.
You can use the Pricing Module's main service by resolving from the Medusa container the resource `Modules.PRICING` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPricingModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPricingModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IPricingModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPricingModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const pricingModuleService: IPricingModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IPricingModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IPricingModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const pricingModuleService: IPricingModuleService = container.resolve(
@@ -15,8 +15,8 @@ In this guide, you’ll find common examples of how you can use the Product Modu
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IProductModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IProductModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const productModuleService: IProductModuleService = request.scope.resolve(
@@ -54,7 +54,7 @@ export async function POST(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeProductModule } from "@medusajs/product"
import { initialize as initializeProductModule } from "@medusajs/medusa/product"
export async function POST(request: Request) {
const productModuleService = await initializeProductModule()
@@ -96,8 +96,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IProductModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IProductModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(request: MedusaRequest, res: MedusaResponse) {
const productModuleService: IProductModuleService = request.scope.resolve(
@@ -116,7 +116,7 @@ export async function GET(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeProductModule } from "@medusajs/product"
import { initialize as initializeProductModule } from "@medusajs/medusa/product"
export async function GET(request: Request) {
const productModuleService = await initializeProductModule()
@@ -139,8 +139,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IProductModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IProductModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(request: MedusaRequest, res: MedusaResponse) {
const productModuleService: IProductModuleService = request.scope.resolve(
@@ -159,7 +159,7 @@ export async function GET(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeProductModule } from "@medusajs/product"
import { initialize as initializeProductModule } from "@medusajs/medusa/product"
export async function GET(
request: Request,
@@ -186,8 +186,8 @@ export async function GET(
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IProductModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IProductModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(request: MedusaRequest, res: MedusaResponse) {
const productModuleService: IProductModuleService = request.scope.resolve(
@@ -208,7 +208,7 @@ export async function GET(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeProductModule } from "@medusajs/product"
import { initialize as initializeProductModule } from "@medusajs/medusa/product"
export async function GET(request: Request) {
const productModuleService = await initializeProductModule()
@@ -233,8 +233,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IProductModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IProductModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const productModuleService: IProductModuleService = request.scope.resolve(
@@ -253,7 +253,7 @@ export async function POST(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeProductModule } from "@medusajs/product"
import { initialize as initializeProductModule } from "@medusajs/medusa/product"
export async function GET(request: Request) {
const productModuleService = await initializeProductModule()
@@ -276,8 +276,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IProductModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IProductModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(request: MedusaRequest, res: MedusaResponse) {
const productModuleService: IProductModuleService = request.scope.resolve(
@@ -298,7 +298,7 @@ export async function POST(request: MedusaRequest, res: MedusaResponse) {
```ts
import { NextResponse } from "next/server"
import { initialize as initializeProductModule } from "@medusajs/product"
import { initialize as initializeProductModule } from "@medusajs/medusa/product"
export async function GET(
request: Request,
@@ -22,7 +22,7 @@ You'll need the following resources for the taxes calculation:
import {
Modules,
ContainerRegistrationKeys,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
// In an API route, workflow step, etc...
const query = container.resolve(ContainerRegistrationKeys.QUERY)
@@ -38,7 +38,7 @@ const taxModuleService = container.resolve(
After resolving the resources, use Query to retrieve the products with the variants' prices for a context:
```ts
import { QueryContext } from "@medusajs/utils"
import { QueryContext } from "@medusajs/framework/utils"
// ...
@@ -80,7 +80,7 @@ To retrieve the tax line of each product, first, add the following utility metho
import {
HttpTypes,
TaxableItemDTO,
} from "@medusajs/types"
} from "@medusajs/framework/types"
// ...
const asTaxItem = (product: HttpTypes.StoreProduct): TaxableItemDTO[] => {
@@ -116,7 +116,7 @@ Then, use it when retrieving the tax lines of the products retrieved earlier:
// other imports...
import {
ItemTaxLineDTO,
} from "@medusajs/types"
} from "@medusajs/framework/types"
// ...
const taxLines = (await taxModuleService.getTaxLines(
@@ -179,7 +179,7 @@ export const calculateTaxHighlights = [
// other imports...
import {
calculateAmountsWithTax,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
// ...
products.forEach((product) => {
@@ -204,7 +204,7 @@ products.forEach((product) => {
For each product variant, you:
1. Retrieve its tax lines from the `taxLinesMap`.
2. Calculate its prices with and without taxes using the `calculateAmountsWithTax` function imported from `@medusajs/utils`.
2. Calculate its prices with and without taxes using the `calculateAmountsWithTax` function imported from `@medusajs/framework/utils`.
3. The `calculateAmountsWithTax` function returns an object having two properties:
- `priceWithTax`: The variant's price with the taxes applied.
- `priceWithoutTax`: The variant's price without taxes applied.
@@ -62,7 +62,7 @@ To retrieve calculated prices of variants based on a context, retrieve the produ
For example:
```ts highlights={[["6"], ["12"], ["13"], ["14"], ["15"], ["16"], ["17"]]}
import { QueryContext } from "@medusajs/utils"
import { QueryContext } from "@medusajs/framework/utils"
// ...
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Product Module is the `@medusajs/product` NPM package that provides product-related features in your Medusa and Node.js applications.
The Product Module is the `@medusajs/medusa/product` NPM package that provides product-related features in your Medusa and Node.js applications.
## How to Use Product Module's Service
You can use the Product Module's main service by resolving from the Medusa container the resource `Modules.PRODUCT` imported from `@medusajs/utils`.
You can use the Product Module's main service by resolving from the Medusa container the resource `Modules.PRODUCT` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IProductModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IProductModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(request: MedusaRequest, res: MedusaResponse) {
const productModuleService: IProductModuleService = request.scope.resolve(
@@ -38,8 +38,8 @@ export async function GET(request: MedusaRequest, res: MedusaResponse) {
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IProductModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IProductModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const productModuleService: IProductModuleService = container.resolve(
@@ -54,9 +54,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IProductModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IProductModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const productModuleService: IProductModuleService = container.resolve(
@@ -15,8 +15,8 @@ In this document, you’ll find common examples of how you can use the Promotion
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPromotionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPromotionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -47,7 +47,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePromotionModule } from "@medusajs/promotion"
import { initialize as initializePromotionModule } from "@medusajs/medusa/promotion"
export async function POST(request: Request) {
const promotionModuleService = await initializePromotionModule()
@@ -80,8 +80,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPromotionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPromotionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -108,7 +108,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePromotionModule } from "@medusajs/promotion"
import { initialize as initializePromotionModule } from "@medusajs/medusa/promotion"
export async function POST(request: Request) {
const promotionModuleService = await initializePromotionModule()
@@ -137,8 +137,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPromotionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPromotionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -176,7 +176,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePromotionModule } from "@medusajs/promotion"
import { initialize as initializePromotionModule } from "@medusajs/medusa/promotion"
export async function POST(request: Request) {
const promotionModuleService = await initializePromotionModule()
@@ -215,8 +215,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPromotionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPromotionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -238,7 +238,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializePromotionModule } from "@medusajs/promotion"
import { initialize as initializePromotionModule } from "@medusajs/medusa/promotion"
export async function GET(request: Request) {
const promotionModuleService = await initializePromotionModule()
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Promotion Module is the `@medusajs/promotion` NPM package that provides promotion-related features in your Medusa and Node.js applications.
The Promotion Module is the `@medusajs/medusa/promotion` NPM package that provides promotion-related features in your Medusa and Node.js applications.
## How to Use the Promotion Module's Service
You can use the Promotion Module's main service by resolving from the Medusa container the resource `Modules.PROMOTION` imported from `@medusajs/utils`.
You can use the Promotion Module's main service by resolving from the Medusa container the resource `Modules.PROMOTION` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IPromotionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPromotionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IPromotionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IPromotionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const promotionModuleService: IPromotionModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IPromotionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
import { IPromotionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
const step1 = createStep("step-1", async (_, { container }) => {
const promotionModuleService: IPromotionModuleService = container.resolve(
@@ -15,8 +15,8 @@ In this guide, you’ll find common examples of how you can use the Region Modul
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IRegionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -43,7 +43,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeRegionModule } from "@medusajs/region"
import { initialize as initializeRegionModule } from "@medusajs/medusa/region"
export async function POST(request: Request) {
const regionModuleService = await initializeRegionModule()
@@ -71,8 +71,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IRegionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -94,7 +94,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeRegionModule } from "@medusajs/region"
import { initialize as initializeRegionModule } from "@medusajs/medusa/region"
export async function GET(request: Request) {
const regionModuleService = await initializeRegionModule()
@@ -117,8 +117,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IRegionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -140,7 +140,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeRegionModule } from "@medusajs/region"
import { initialize as initializeRegionModule } from "@medusajs/medusa/region"
export async function GET(request: Request) {
const regionModuleService = await initializeRegionModule()
@@ -163,8 +163,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IRegionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -188,7 +188,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeRegionModule } from "@medusajs/region"
import { initialize as initializeRegionModule } from "@medusajs/medusa/region"
export async function POST(request: Request) {
const regionModuleService = await initializeRegionModule()
@@ -213,8 +213,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IRegionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
req: MedusaRequest,
@@ -236,7 +236,7 @@ export async function DELETE(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeRegionModule } from "@medusajs/region"
import { initialize as initializeRegionModule } from "@medusajs/medusa/region"
export async function DELETE(request: Request) {
const regionModuleService = await initializeRegionModule()
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Region Module is the `@medusajs/region` NPM package that provides region-related features in your Medusa and Node.js applications.
The Region Module is the `@medusajs/medusa/region` NPM package that provides region-related features in your Medusa and Node.js applications.
## How to Use Region Module's Service
You can use the Region Module's main service by resolving from the Medusa container the resource `Modules.REGION` imported from `@medusajs/utils`.
You can use the Region Module's main service by resolving from the Medusa container the resource `Modules.REGION` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IRegionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IRegionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IRegionModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const regionModuleService: IRegionModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IRegionModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
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(
@@ -15,8 +15,8 @@ In this guide, you’ll find common examples of how you can use the Sales Channe
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ISalesChannelModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -41,7 +41,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeSalesChannelModule } from "@medusajs/sales-channel"
import { initialize as initializeSalesChannelModule } from "@medusajs/medusa/sales-channel"
export async function POST(request: Request) {
const salesChannelModuleService = await initializeSalesChannelModule()
@@ -66,8 +66,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ISalesChannelModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -88,7 +88,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeSalesChannelModule } from "@medusajs/sales-channel"
import { initialize as initializeSalesChannelModule } from "@medusajs/medusa/sales-channel"
export async function GET(request: Request) {
const salesChannelModuleService = await initializeSalesChannelModule()
@@ -111,8 +111,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ISalesChannelModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -137,7 +137,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeSalesChannelModule } from "@medusajs/sales-channel"
import { initialize as initializeSalesChannelModule } from "@medusajs/medusa/sales-channel"
export async function GET(request: Request) {
const salesChannelModuleService = await initializeSalesChannelModule()
@@ -162,8 +162,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ISalesChannelModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -189,7 +189,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeSalesChannelModule } from "@medusajs/sales-channel"
import { initialize as initializeSalesChannelModule } from "@medusajs/medusa/sales-channel"
export async function POST(request: Request) {
const salesChannelModuleService = await initializeSalesChannelModule()
@@ -215,8 +215,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ISalesChannelModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
request: MedusaRequest,
@@ -237,7 +237,7 @@ export async function DELETE(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeSalesChannelModule } from "@medusajs/sales-channel"
import { initialize as initializeSalesChannelModule } from "@medusajs/medusa/sales-channel"
export async function DELETE(request: Request) {
const salesChannelModuleService = await initializeSalesChannelModule()
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Sales Channel Module is the `@medusajs/sales-channel` NPM package that provides sales-channel-related features in your Medusa and Node.js applications.
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.
## How to Use Sales Channel Module's Service
You can use the Sales Channel Module's main service by resolving from the Medusa container the resource `Modules.SALES_CHANNEL` imported from `@medusajs/utils`.
You can use the Sales Channel Module's main service by resolving from the Medusa container the resource `Modules.SALES_CHANNEL` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ISalesChannelModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -40,8 +40,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { ISalesChannelModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ISalesChannelModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const salesChannelModuleService: ISalesChannelModuleService =
@@ -55,9 +55,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { ISalesChannelModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
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 =
@@ -15,8 +15,8 @@ In this document, you’ll find common examples of how you can use the Stock Loc
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStockLocationService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -41,7 +41,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeStockLocationModule } from "@medusajs/stock-location-next"
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location-next"
export async function POST(request: Request) {
const stockLocationModuleService = await initializeStockLocationModule({})
@@ -66,8 +66,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStockLocationService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -88,7 +88,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeStockLocationModule } from "@medusajs/stock-location-next"
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location-next"
export async function GET(request: Request) {
const stockLocationModuleService = await initializeStockLocationModule({})
@@ -111,8 +111,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStockLocationService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -143,7 +143,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeStockLocationModule } from "@medusajs/stock-location-next"
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location-next"
export async function POST(request: Request) {
const stockLocationModuleService = await initializeStockLocationModule({})
@@ -176,8 +176,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStockLocationService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
request: MedusaRequest,
@@ -198,7 +198,7 @@ export async function DELETE(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeStockLocationModule } from "@medusajs/stock-location-next"
import { initialize as initializeStockLocationModule } from "@medusajs/medusa/stock-location-next"
export async function DELETE(request: Request) {
const stockLocationModuleService = await initializeStockLocationModule({})
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Stock Location Module is the `@medusajs/stock-location-next` NPM package that provides stock-location-related features in your Medusa and Node.js applications.
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.
## How to Use Stock Location Module's Service
You can use the Stock Location Module's main service by resolving from the Medusa container the resource `Modules.STOCK_LOCATION` imported from `@medusajs/utils`.
You can use the Stock Location Module's main service by resolving from the Medusa container the resource `Modules.STOCK_LOCATION` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStockLocationService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -40,8 +40,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IStockLocationService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStockLocationService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const stockLocationModuleService: IStockLocationService = container.resolve(
@@ -56,9 +56,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IStockLocationService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
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(
@@ -15,8 +15,8 @@ In this guide, you’ll find common examples of how you can use the Store Module
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -48,7 +48,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeStoreModule } from "@medusajs/store"
import { initialize as initializeStoreModule } from "@medusajs/medusa/store"
export async function POST(request: Request) {
const storeModuleService = await initializeStoreModule()
@@ -81,8 +81,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -104,7 +104,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeStoreModule } from "@medusajs/store"
import { initialize as initializeStoreModule } from "@medusajs/medusa/store"
export async function GET(request: Request) {
const storeModuleService = await initializeStoreModule()
@@ -129,8 +129,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -154,7 +154,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeStoreModule } from "@medusajs/store"
import { initialize as initializeStoreModule } from "@medusajs/medusa/store"
export async function GET(request: Request, { params }: ContextType) {
const storeModuleService = await initializeStoreModule()
@@ -177,8 +177,8 @@ export async function GET(request: Request, { params }: ContextType) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
request: MedusaRequest,
@@ -204,7 +204,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeStoreModule } from "@medusajs/store"
import { initialize as initializeStoreModule } from "@medusajs/medusa/store"
export async function POST(request: Request, { params }: ContextType) {
const storeModuleService = await initializeStoreModule()
@@ -229,8 +229,8 @@ export async function POST(request: Request, { params }: ContextType) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
request: MedusaRequest,
@@ -252,7 +252,7 @@ export async function DELETE(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeStoreModule } from "@medusajs/store"
import { initialize as initializeStoreModule } from "@medusajs/medusa/store"
export async function DELETE(request: Request, { params }: ContextType) {
const storeModuleService = await initializeStoreModule()
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Store Module is the `@medusajs/store` NPM package that provides store-related features in your Medusa and Node.js applications.
The Store Module is the `@medusajs/medusa/store` NPM package that provides store-related features in your Medusa and Node.js applications.
## How to Use Store Module's Service
You can use the Store Module's main service by resolving from the Medusa container the resource `Modules.STORE` imported from `@medusajs/utils`.
You can use the Store Module's main service by resolving from the Medusa container the resource `Modules.STORE` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
request: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IStoreModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IStoreModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const storeModuleService: IStoreModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IStoreModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
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(
@@ -15,8 +15,8 @@ In this guide, you’ll find common examples of how you can use the Tax Module i
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ITaxModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -46,7 +46,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeTaxModule } from "@medusajs/tax"
import { initialize as initializeTaxModule } from "@medusajs/medusa/tax"
export async function POST(request: Request) {
const taxModuleService = await initializeTaxModule()
@@ -77,8 +77,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ITaxModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -100,7 +100,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeTaxModule } from "@medusajs/tax"
import { initialize as initializeTaxModule } from "@medusajs/medusa/tax"
export async function GET(request: Request) {
const taxModuleService = await initializeTaxModule()
@@ -123,8 +123,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ITaxModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -162,7 +162,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeTaxModule } from "@medusajs/tax"
import { initialize as initializeTaxModule } from "@medusajs/medusa/tax"
export async function POST(request: Request) {
const taxModuleService = await initializeTaxModule()
@@ -201,8 +201,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ITaxModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -224,7 +224,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeTaxModule } from "@medusajs/tax"
import { initialize as initializeTaxModule } from "@medusajs/medusa/tax"
export async function GET(request: Request) {
const taxModuleService = await initializeTaxModule()
@@ -247,8 +247,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ITaxModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -296,7 +296,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeTaxModule } from "@medusajs/tax"
import { initialize as initializeTaxModule } from "@medusajs/medusa/tax"
export async function GET(request: Request) {
const taxModuleService = await initializeTaxModule()
@@ -19,7 +19,7 @@ The `providers` option is an array of either tax module providers, tax plugins,
When the Medusa application starts, these providers are registered and can be used to retrieve tax lines.
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -27,7 +27,7 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.TAX]: {
resolve: "@medusajs/tax",
resolve: "@medusajs/medusa/tax",
options: {
providers: [
{
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The Tax Module is the `@medusajs/tax` NPM package that provides tax-related features in your Medusa and Node.js applications.
The Tax Module is the `@medusajs/medusa/tax` NPM package that provides tax-related features in your Medusa and Node.js applications.
## How to Use Tax Module's Service
You can use the Tax Module's main service by resolving from the Medusa container the resource `Modules.TAX` imported from `@medusajs/utils`.
You can use the Tax Module's main service by resolving from the Medusa container the resource `Modules.TAX` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ITaxModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { ITaxModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { ITaxModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const taxModuleService: ITaxModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { ITaxModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
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(
@@ -15,8 +15,8 @@ In this guide, you’ll find common examples of how you can use the User Module
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IUserModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -42,7 +42,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeUserModule } from "@medusajs/user"
import { initialize as initializeUserModule } from "@medusajs/medusa/user"
export async function POST(request: Request) {
const userModuleService = await initializeUserModule()
@@ -71,8 +71,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IUserModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -94,7 +94,7 @@ export async function GET(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeUserModule } from "@medusajs/user"
import { initialize as initializeUserModule } from "@medusajs/medusa/user"
export async function GET(request: Request) {
const userModuleService = await initializeUserModule()
@@ -117,8 +117,8 @@ export async function GET(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IUserModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -143,7 +143,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeUserModule } from "@medusajs/user"
import { initialize as initializeUserModule } from "@medusajs/medusa/user"
export async function POST(request: Request) {
const userModuleService = await initializeUserModule()
@@ -171,8 +171,8 @@ export async function POST(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IUserModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function DELETE(
req: MedusaRequest,
@@ -192,7 +192,7 @@ export async function DELETE(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeUserModule } from "@medusajs/user"
import { initialize as initializeUserModule } from "@medusajs/medusa/user"
export async function DELETE(request: Request) {
const userModuleService = await initializeUserModule()
@@ -213,8 +213,8 @@ export async function DELETE(request: Request) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IUserModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -240,7 +240,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeUserModule } from "@medusajs/user"
import { initialize as initializeUserModule } from "@medusajs/medusa/user"
export async function POST(request: Request, { params }: ContextType) {
const userModuleService = await initializeUserModule()
@@ -267,8 +267,8 @@ export async function POST(request: Request, { params }: ContextType) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IUserModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -302,7 +302,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeUserModule } from "@medusajs/user"
import { initialize as initializeUserModule } from "@medusajs/medusa/user"
export async function POST(request: Request, { params }: ContextType) {
const userModuleService = await initializeUserModule()
@@ -337,8 +337,8 @@ export async function POST(request: Request, { params }: ContextType) {
```ts
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IUserModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function POST(
req: MedusaRequest,
@@ -362,7 +362,7 @@ export async function POST(
```ts
import { NextResponse } from "next/server"
import { initialize as initializeUserModule } from "@medusajs/user"
import { initialize as initializeUserModule } from "@medusajs/medusa/user"
export async function POST(request: Request, { params }: ContextType) {
const userModuleService = await initializeUserModule()
@@ -15,7 +15,7 @@ In this document, you'll learn about the options of the User Module.
## Module Options
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
// ...
@@ -23,7 +23,7 @@ module.exports = defineConfig({
// ...
modules: {
[Modules.USER]: {
resolve: "@medusajs/user",
resolve: "@medusajs/medusa/user",
options: {
jwt_secret: process.env.JWT_SECRET,
},
@@ -6,11 +6,11 @@ export const metadata = {
# {metadata.title}
The User Module is the `@medusajs/user` NPM package that provides user-related features in your Medusa and Node.js applications.
The User Module is the `@medusajs/medusa/user` NPM package that provides user-related features in your Medusa and Node.js applications.
## How to Use User Module's Service
You can use the User Module's main service by resolving from the Medusa container the resource `Modules.USER` imported from `@medusajs/utils`.
You can use the User Module's main service by resolving from the Medusa container the resource `Modules.USER` imported from `@medusajs/framework/utils`.
For example:
@@ -19,8 +19,8 @@ For example:
```ts title="src/api/store/custom/route.ts"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { IUserModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -41,8 +41,8 @@ export async function GET(
```ts title="src/subscribers/custom-handler.ts"
import { SubscriberArgs } from "@medusajs/medusa"
import { IUserModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { IUserModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
export default async function subscriberHandler({ container }: SubscriberArgs) {
const userModuleService: IUserModuleService = container.resolve(
@@ -57,9 +57,9 @@ export default async function subscriberHandler({ container }: SubscriberArgs) {
<CodeTab label="Workflow Step" value="workflow-step">
```ts title="src/workflows/hello-world/step1.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { IUserModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
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(
@@ -134,29 +134,29 @@ For example, add the following dependencies in `package.json` for the Cache, Eve
```json
"dependencies": {
// ...
"@medusajs/cache-redis": "preview",
"@medusajs/event-bus-redis": "preview",
"@medusajs/workflow-engine-redis": "preview"
"@medusajs/medusa/cache-redis": "rc",
"@medusajs/medusa/event-bus-redis": "rc",
"@medusajs/workflow-engine-redis": "rc"
}
```
Then, add these modules in `medusa-config.js`:
```js title="medusa-config.js"
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
module.exports = defineConfig({
// ...
modules: {
// ...
[Modules.CACHE]: {
resolve: "@medusajs/cache-redis",
resolve: "@medusajs/medusa/cache-redis",
options: {
redisUrl: process.env.REDIS_URL,
},
},
[Modules.EVENT_BUS]: {
resolve: "@medusajs/event-bus-redis",
resolve: "@medusajs/medusa/event-bus-redis",
options: {
redisUrl: process.env.REDIS_URL,
},
@@ -10,7 +10,7 @@ This documentation page includes the list of resources registered in the Medusa
<Note>
Use the `ContainerRegistrationKeys` enum imported from `@medusajs/utils` to resolve these resources' names.
Use the `ContainerRegistrationKeys` enum imported from `@medusajs/framework/utils` to resolve these resources' names.
</Note>
@@ -122,7 +122,7 @@ Use the `ContainerRegistrationKeys` enum imported from `@medusajs/utils` to reso
<Table.Cell>
- For custom modules, the registration name is the key of the module in the `modules` configuration.
- For Medusa's commerce modules, you can use the `Modules` enum imported from `@medusajs/utils`.
- For Medusa's commerce modules, you can use the `Modules` enum imported from `@medusajs/framework/utils`.
</Table.Cell>
</Table.Row>
@@ -8,6 +8,6 @@ export const metadata = {
This section of the documentation provides a reference to the workflows created by Medusa. These workflows are used in the Store and Admin API routes.
You can use these workflows in your customizations as well. They're available in the `@medusajs/core-flows` package.
You can use these workflows in your customizations as well. They're available in the `@medusajs/medusa/core-flows` package.
<ChildDocs childLevel={2} hideItems={["Overview", "Steps"]} />
+9 -9
View File
@@ -202,7 +202,7 @@ You can create a B2B module that adds necessary data models to represent a B2B c
Then, create the file `src/modules/b2b/models/company.ts` with the following content:
```ts title="src/modules/b2b/models/company.ts" highlights={[["8", "", "The property will be used to create a relationship to customer groups."]]}
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
const Company = model.define("company", {
id: model.id().primaryKey(),
@@ -239,7 +239,7 @@ You can create a B2B module that adds necessary data models to represent a B2B c
Then, create the module's main service at `src/modules/b2b/service.ts` with the following content:
```ts title="src/modules/b2b/service.ts"
import { MedusaService } from "@medusajs/utils"
import { MedusaService } from "@medusajs/framework/utils"
import Company from "./models/company"
class B2bModuleService extends MedusaService({
@@ -257,7 +257,7 @@ You can create a B2B module that adds necessary data models to represent a B2B c
```ts title="src/modules/b2b/index.ts"
import B2bModuleService from "./service"
import { Module } from "@medusajs/utils"
import { Module } from "@medusajs/framework/utils"
export default Module("b2b", {
service: B2bModuleService,
@@ -293,7 +293,7 @@ You can create a B2B module that adds necessary data models to represent a B2B c
Start by creating the file `src/types/b2b/index.ts` with some helper types:
```ts title="src/types/b2b/index.ts"
import { CustomerGroupDTO } from "@medusajs/types"
import { CustomerGroupDTO } from "@medusajs/framework/types"
export type CompanyDTO = {
id: string
@@ -327,11 +327,11 @@ export const workflowHighlights = [
StepResponse,
createStep,
createWorkflow,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
createCustomerGroupsWorkflow,
} from "@medusajs/core-flows"
import { CreateCustomerGroupDTO } from "@medusajs/types"
} from "@medusajs/medusa/core-flows"
import { CreateCustomerGroupDTO } from "@medusajs/framework/types"
import { CompanyDTO, CreateCompanyDTO } from "../types/b2b"
import B2bModuleService from "../modules/b2b/service"
@@ -609,8 +609,8 @@ export const checkCustomerHighlights = [
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { Modules } from "@medusajs/utils"
import { ICustomerModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/framework/utils"
import { ICustomerModuleService } from "@medusajs/framework/types"
import B2bModuleService from "../../../../modules/b2b/service"
export async function GET(
@@ -81,7 +81,7 @@ export const restockModelHighlights = [
]
```ts title="src/modules/restock-notification/models/restock-notification.ts" highlights={restockModelHighlights}
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
const RestockNotification = model.define("restock_notification", {
id: model.id().primaryKey(),
@@ -125,7 +125,7 @@ export const restockModelHighlights = [
Then, create the module's main service at `src/modules/restock-notification/service.ts` with the following content:
```ts title="src/modules/restock-notification/service.ts"
import { MedusaService } from "@medusajs/utils"
import { MedusaService } from "@medusajs/framework/utils"
import RestockNotification from "./models/restock-notification"
class RestockNotificationModuleService extends MedusaService({
@@ -143,7 +143,7 @@ export const restockModelHighlights = [
```ts title="src/modules/restock-notification/index.ts"
import RestockNotificationModuleService from "./service"
import { Module } from "@medusajs/utils"
import { Module } from "@medusajs/framework/utils"
export default Module("restock-notification", {
service: RestockNotificationModuleService,
@@ -247,15 +247,15 @@ export const subscriberHighlights = [
IInventoryService,
INotificationModuleService,
RemoteQueryFunction,
} from "@medusajs/types"
} from "@medusajs/framework/types"
import {
ContainerRegistrationKeys,
Modules,
remoteQueryObjectFromString,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import {
RemoteLink,
} from "@medusajs/modules-sdk"
} from "@medusajs/framework/modules-sdk"
import RestockNotificationModuleService
from "../modules/restock-notification/service"
@@ -462,18 +462,18 @@ export const syncProductsWorkflowHighlight = [
```ts title="src/workflows/sync-products.ts" highlights={syncProductsWorkflowHighlight} collapsibleLines="1-16" expandButtonLabel="Show Imports"
import {
Modules
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import {
IProductModuleService,
IStoreModuleService,
ProductDTO,
StoreDTO
} from "@medusajs/types"
} from "@medusajs/framework/types"
import {
StepResponse,
createStep,
createWorkflow,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
type RetrieveStoreStepInput = {
id: string
@@ -616,7 +616,7 @@ export const syncProductsWorkflowHighlight = [
Then, create a scheduled job at `src/jobs/sync-products.ts` that executes the workflow at the specified interval:
```ts
import { MedusaContainer } from "@medusajs/types"
import { MedusaContainer } from "@medusajs/framework/types"
import {
syncProductsWorkflow,
} from "../workflows/sync-products"
@@ -765,11 +765,11 @@ The `order.placed` event is currently not emitted.
} from "@medusajs/medusa"
import {
Modules,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import {
ICustomerModuleService,
IOrderModuleService,
} from "@medusajs/types"
} from "@medusajs/framework/types"
export default async function orderCreatedHandler({
event: { data },
@@ -879,13 +879,13 @@ export const newsletterHighlights = [
} from "@medusajs/medusa"
import {
Modules,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import {
ICustomerModuleService,
IProductModuleService,
IStoreModuleService,
INotificationModuleService,
} from "@medusajs/types"
} from "@medusajs/framework/types"
export default async function productCreateHandler({
container,
@@ -60,7 +60,7 @@ Create the directory `src/modules/digital-product`.
Create the file `src/modules/digital-product/models/digital-product.ts` with the following content:
```ts title="src/modules/digital-product/models/digital-product.ts"
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
import DigitalProductMedia from "./digital-product-media"
import DigitalProductOrder from "./digital-product-order"
@@ -90,7 +90,7 @@ export const dpmModelHighlights = [
]
```ts title="src/modules/digital-product/models/digital-product-media.ts" highlights={dpmModelHighlights}
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
import { MediaType } from "../types"
import DigitalProduct from "./digital-product"
@@ -123,7 +123,7 @@ This enum indicates that a digital product media can either be used to preview t
Next, create the file `src/modules/digital-product/models/digital-product-order.ts` with the following content:
```ts title="src/modules/digital-product/models/digital-product-order.ts"
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
import { OrderStatus } from "../types"
import DigitalProduct from "./digital-product"
@@ -154,7 +154,7 @@ export enum OrderStatus {
Next, create the main service of the module at `src/modules/digital-product/service.ts` with the following content:
```ts title="src/modules/digital-product/service.ts"
import { MedusaService } from "@medusajs/utils"
import { MedusaService } from "@medusajs/framework/utils"
import DigitalProduct from "./models/digital-product"
import DigitalProductOrder from "./models/digital-product-order"
import DigitalProductMedia from "./models/digital-product-media"
@@ -178,7 +178,7 @@ After that, create the module definition at `src/modules/digital-product/index.t
```ts title="src/modules/digital-product/index.ts"
import DigitalProductModuleService from "./service"
import { Module } from "@medusajs/utils"
import { Module } from "@medusajs/framework/utils"
export const DIGITAL_PRODUCT_MODULE = "digitalProductModuleService"
@@ -217,8 +217,8 @@ Start by creating the file `src/links/digital-product-variant.ts` with the follo
```ts title="src/links/digital-product-variant.ts"
import DigitalProductModule from "../modules/digital-product"
import ProductModule from "@medusajs/product"
import { defineLink } from "@medusajs/utils"
import ProductModule from "@medusajs/medusa/product"
import { defineLink } from "@medusajs/framework/utils"
export default defineLink(
DigitalProductModule.linkable.digitalProduct,
@@ -236,8 +236,8 @@ export const orderLinkHighlights = [
```ts title="src/links/digital-product-order.ts"
import DigitalProductModule from "../modules/digital-product"
import OrderModule from "@medusajs/order"
import { defineLink } from "@medusajs/utils"
import OrderModule from "@medusajs/medusa/order"
import { defineLink } from "@medusajs/framework/utils"
export default defineLink(
{
@@ -288,7 +288,7 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { ContainerRegistrationKeys } from "@medusajs/utils"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
export const GET = async (
req: AuthenticatedMedusaRequest,
@@ -379,10 +379,10 @@ graph TD
createDigitalProductMediasStep --> createRemoteLinkStep["createRemoteLinkStep (Medusa)"]
```
1. `createProductsWorkflow`: Create the Medusa product that the digital product is associated with its variant. Medusa provides this workflow through the `@medusajs/core-flows` package, which you can use as a step.
1. `createProductsWorkflow`: Create the Medusa product that the digital product is associated with its variant. Medusa provides this workflow through the `@medusajs/medusa/core-flows` package, which you can use as a step.
2. `createDigitalProductStep`: Create the digital product.
3. `createDigitalProductMediasStep`: Create the medias associated with the digital product.
4. `createRemoteLinkStep`: Create the link between the digital product and the product variant. Medusa provides this step through the `@medusajs/core-flows` package.
4. `createRemoteLinkStep`: Create the link between the digital product and the product variant. Medusa provides this step through the `@medusajs/medusa/core-flows` package.
You’ll implement the second and third steps.
@@ -400,7 +400,7 @@ export const createDpHighlights = [
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import DigitalProductModuleService from "../../../modules/digital-product/service"
import { DIGITAL_PRODUCT_MODULE } from "../../../modules/digital-product"
@@ -454,7 +454,7 @@ export const createDigitalProductMediaHighlights = [
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import DigitalProductModuleService from "../../../modules/digital-product/service"
import { DIGITAL_PRODUCT_MODULE } from "../../../modules/digital-product"
import { MediaType } from "../../../modules/digital-product/types"
@@ -520,17 +520,17 @@ import {
createWorkflow,
transform,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
CreateProductWorkflowInputDTO,
} from "@medusajs/types"
} from "@medusajs/framework/types"
import {
createProductsWorkflow,
createRemoteLinkStep,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
import {
Modules,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import createDigitalProductStep, {
CreateDigitalProductStepInput,
} from "./steps/create-digital-product"
@@ -744,8 +744,8 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { uploadFilesWorkflow } from "@medusajs/core-flows"
import { MedusaError } from "@medusajs/utils"
import { uploadFilesWorkflow } from "@medusajs/medusa/core-flows"
import { MedusaError } from "@medusajs/framework/utils"
export const POST = async (
req: AuthenticatedMedusaRequest,
@@ -779,7 +779,7 @@ export const POST = async (
This adds a `POST` API route at `/admin/digital-products/upload/[type]` where `[type]` is either `preview` or `main`.
In the route handler, you use the `uploadFilesWorkflow` imported from `@medusajs/core-flows` to upload the file. If the file type is `main`, it’s uploaded with private access, as only customers who purchased it can download it. Otherwise, it’s uploaded with `public` access.
In the route handler, you use the `uploadFilesWorkflow` imported from `@medusajs/medusa/core-flows` to upload the file. If the file type is `main`, it’s uploaded with private access, as only customers who purchased it can download it. Otherwise, it’s uploaded with `public` access.
Next, add to the file `src/api/middlewares.ts` the `multer` middleware on this API route:
@@ -814,7 +814,7 @@ In this step, you’ll add a UI route to the Medusa Admin that displays a list o
Before you create the UI route, create the file `src/admin/types/index.ts` that holds the following types:
```ts title="src/admin/types/index.ts"
import { ProductVariantDTO } from "@medusajs/types"
import { ProductVariantDTO } from "@medusajs/framework/types"
export enum MediaType {
MAIN = "main",
@@ -1435,7 +1435,7 @@ Start by creating the `src/modules/digital-product-fulfillment` directory.
Then, create the file `src/modules/digital-product-fulfillment/service.ts` with the following content:
```ts title="src/modules/digital-product-fulfillment/service.ts"
import { AbstractFulfillmentProviderService } from "@medusajs/utils"
import { AbstractFulfillmentProviderService } from "@medusajs/framework/utils"
class DigitalProductFulfillmentService extends AbstractFulfillmentProviderService {
static identifier = "digital"
@@ -1488,7 +1488,7 @@ The fulfillment provider registers one fulfillment option, and doesn't perform a
Then, create the module provider's definition in the file `src/modules/digital-product-fulfillment/index.ts`:
```ts title="src/modules/digital-product-fulfillment/index.ts"
import { ModuleProviderExports } from "@medusajs/types"
import { ModuleProviderExports } from "@medusajs/framework/types"
import DigitalProductFulfillmentService from "./service"
const services = [DigitalProductFulfillmentService]
@@ -1506,17 +1506,17 @@ Finally, register the module provider in `medusa-config.js`:
```js title="medusa-config.js"
// other imports...
const { Modules } = require("@medusajs/utils")
const { Modules } = require("@medusajs/framework/utils")
module.exports = defineConfig({
modules: {
// ...
[Modules.FULFILLMENT]: {
resolve: "@medusajs/fulfillment",
resolve: "@medusajs/medusa/fulfillment",
options: {
providers: [
{
resolve: "@medusajs/fulfillment-manual",
resolve: "@medusajs/medusa/fulfillment-manual",
id: "manual",
},
{
@@ -1560,13 +1560,13 @@ graph TD
The workflow has the following steps:
1. `completeCartWorkflow` to create a Medusa order from the cart. Medusa provides this workflow through the `@medusajs/core-flows` package and you can use it as a step.
2. `useRemoteQueryStep` to retrieve the order’s items with the digital products associated with the purchased product variants. Medusa provides this step through the `@medusajs/core-flows` package.
1. `completeCartWorkflow` to create a Medusa order from the cart. Medusa provides this workflow through the `@medusajs/medusa/core-flows` package and you can use it as a step.
2. `useRemoteQueryStep` to retrieve the order’s items with the digital products associated with the purchased product variants. Medusa provides this step through the `@medusajs/medusa/core-flows` package.
3. If the order has digital products, you:
1. create the digital product order.
2. link the digital product order with the Medusa order. Medusa provides a `createRemoteLinkStep` in the `@medusajs/core-flows` package that can be used here.
3. Create a fulfillment for the digital products in the order. Medusa provides a `createOrderFulfillmentWorkflow` in the `@medusajs/core-flows` package that you can use as a step here.
4. Emit the `digital_product_order.created` custom event to handle it later in a subscriber and send the customer an email. Medusa provides a `emitEventStep` in the `@medusajs/core-flows` that you can use as a step here.
2. link the digital product order with the Medusa order. Medusa provides a `createRemoteLinkStep` in the `@medusajs/medusa/core-flows` package that can be used here.
3. Create a fulfillment for the digital products in the order. Medusa provides a `createOrderFulfillmentWorkflow` in the `@medusajs/medusa/core-flows` package that you can use as a step here.
4. Emit the `digital_product_order.created` custom event to handle it later in a subscriber and send the customer an email. Medusa provides a `emitEventStep` in the `@medusajs/medusa/core-flows` that you can use as a step here.
You’ll only implement the `3.a` step of the workflow.
@@ -1585,12 +1585,12 @@ export const createDpoHighlights = [
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
OrderLineItemDTO,
ProductVariantDTO,
InferTypeOf,
} from "@medusajs/types"
} from "@medusajs/framework/types"
import { OrderStatus } from "../../../modules/digital-product/types"
import DigitalProductModuleService from "../../../modules/digital-product/service"
import { DIGITAL_PRODUCT_MODULE } from "../../../modules/digital-product"
@@ -1662,15 +1662,15 @@ import {
transform,
when,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
completeCartWorkflow,
useRemoteQueryStep,
createRemoteLinkStep,
createOrderFulfillmentWorkflow,
emitEventStep,
} from "@medusajs/core-flows"
import { Modules } from "@medusajs/utils"
} from "@medusajs/medusa/core-flows"
import { Modules } from "@medusajs/framework/utils"
import createDigitalProductOrderStep from "./steps/create-digital-product-order"
import { DIGITAL_PRODUCT_MODULE } from "../../modules/digital-product"
@@ -1823,7 +1823,7 @@ In this step, you'll create a workflow that fulfills a digital order by sending
The workflow has the following steps:
1. Retrieve the digital product order's details. For this, you'll use the `useRemoteQueryStep` imported from `@medusajs/core-flows`.
1. Retrieve the digital product order's details. For this, you'll use the `useRemoteQueryStep` imported from `@medusajs/medusa/core-flows`.
2. Send a notification to the customer with the digital products to download.
So, you only need to implement the second step.
@@ -1833,7 +1833,7 @@ So, you only need to implement the second step.
Before creating the step, add to `src/modules/digital-product/types/index.ts` the following:
```ts
import { OrderDTO, InferTypeOf } from "@medusajs/types"
import { OrderDTO, InferTypeOf } from "@medusajs/framework/types"
import DigitalProductOrder from "../models/digital-product-order"
// ...
@@ -1856,12 +1856,12 @@ To create the step, create the file `src/workflows/fulfill-digital-order/steps/s
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
INotificationModuleService,
IFileModuleService,
} from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
} from "@medusajs/framework/types"
import { ModuleRegistrationName } from "@medusajs/framework/utils"
import { DigitalProductOrder, MediaType } from "../../../modules/digital-product/types"
type SendDigitalOrderNotificationStepInput = {
@@ -1948,10 +1948,10 @@ export const fulfillWorkflowHighlights = [
import {
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
useRemoteQueryStep,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
import { sendDigitalOrderNotificationStep } from "./steps/send-digital-order-notification"
type FulfillDigitalOrderWorkflowInput = {
@@ -1991,7 +1991,7 @@ export const fulfillDigitalOrderWorkflow = createWorkflow(
In the workflow, you:
1. Retrieve the digital product order's details using the `useRemoteQueryStep` imported from `@medusajs/core-flows`.
1. Retrieve the digital product order's details using the `useRemoteQueryStep` imported from `@medusajs/medusa/core-flows`.
2. Send a notification to the customer with the digital product download links using the `sendDigitalOrderNotificationStep`.
### Configure Notification Module Provider
@@ -2008,11 +2008,11 @@ module.exports = defineConfig({
modules: {
// ...
[Modules.NOTIFICATION]: {
resolve: "@medusajs/notification",
resolve: "@medusajs/medusa/notification",
options: {
providers: [
{
resolve: "@medusajs/notification-local",
resolve: "@medusajs/medusa/notification-local",
id: "local",
options: {
name: "Local Notification Provider",
@@ -2094,7 +2094,7 @@ import {
} from "@medusajs/medusa"
import {
Modules,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import {
DIGITAL_PRODUCT_MODULE,
} from "../../../../../modules/digital-product"
@@ -2160,7 +2160,7 @@ import {
} from "@medusajs/medusa"
import {
ContainerRegistrationKeys,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
export const GET = async (
req: AuthenticatedMedusaRequest,
@@ -2218,7 +2218,7 @@ import {
Modules,
ContainerRegistrationKeys,
MedusaError,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
export const POST = async (
req: AuthenticatedMedusaRequest,
@@ -2312,7 +2312,7 @@ In this section, you’ll customize the [Next.js Starter storefront](../../../..
In `src/types/global.ts`, add the following types that you’ll use in your customizations:
```ts title="src/types/global.ts"
import { BaseProductVariant } from "@medusajs/types/dist/http/product/common"
import { BaseProductVariant } from "@medusajs/framework/types/dist/http/product/common"
// ...
@@ -32,7 +32,7 @@ Medusa provides all essential commerce features out-of-the-box. Businesses can g
Use the following command to install an ecommerce store with Medusa:
```bash
npx create-medusa-app@preview --with-nextjs-starter
npx create-medusa-app@rc --with-nextjs-starter
```
This installs:
@@ -53,7 +53,7 @@ export const serviceHighlights = [
```ts title="src/modules/erp/service.ts" highlights={serviceHighlights}
import axios, { AxiosInstance } from "axios"
import { ProductDTO } from "@medusajs/types"
import { ProductDTO } from "@medusajs/framework/types"
type ErpModuleOptions = {
apiKey: string
@@ -109,7 +109,7 @@ export const serviceHighlights = [
```ts title="src/modules/erp/index.ts"
import ErpModuleService from "./service"
import { Module } from "@medusajs/utils"
import { Module } from "@medusajs/framework/utils"
export default Module("erp", {
service: ErpModuleService,
@@ -180,9 +180,9 @@ export const workflowHighlights = [
StepResponse,
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
import { IProductModuleService } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
} from "@medusajs/framework/workflows-sdk"
import { IProductModuleService } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import ErpModuleService from "../modules/erp/service"
type WorkflowInput = {
@@ -313,10 +313,10 @@ For example, suppose an administrator changes the product data in the ERP system
import {
IProductModuleService,
UpdateProductDTO
} from "@medusajs/types"
} from "@medusajs/framework/types"
import {
Modules
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
type WebhookReq = {
id: string
@@ -74,7 +74,7 @@ Create the directory `src/modules/restaurant`.
Create the file `src/modules/restaurant/models/restaurant.ts` with the following content:
```ts title="src/modules/restaurant/models/restaurant.ts"
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
import { RestaurantAdmin } from "./restaurant-admin"
export const Restaurant = model.define("restaurant", {
@@ -100,7 +100,7 @@ It also has a relation to the `RestaurantAdmin` data model that you’ll define
Create the file `src/modules/restaurant/models/restaurant-admin.ts` with the following content:
```ts title="src/modules/restaurant/models/restaurant-admin.ts"
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
import { Restaurant } from "./restaurant"
export const RestaurantAdmin = model.define("restaurant_admin", {
@@ -124,7 +124,7 @@ This defines a `RestaurantAdmin` data model, which belongs to a restaurant. It r
Next, create the main service of the module at `src/modules/restaurant/service.ts` with the following content:
```ts title="src/modules/restaurant/service.ts"
import { MedusaService } from "@medusajs/utils"
import { MedusaService } from "@medusajs/framework/utils"
import { Restaurant } from "./models/restaurant"
import { RestaurantAdmin } from "./models/restaurant-admin"
@@ -144,7 +144,7 @@ Then, create the file `src/modules/restaurant/index.ts` that holds the module de
```ts title="src/modules/restaurant/index.ts"
import Service from "./service"
import { Module } from "@medusajs/utils"
import { Module } from "@medusajs/framework/utils"
export const RESTAURANT_MODULE = "restaurantModuleService"
@@ -197,7 +197,7 @@ export enum DeliveryStatus {
DELIVERED = "delivered",
}
declare module "@medusajs/types" {
declare module "@medusajs/framework/types" {
export interface ModuleImplementations {
deliveryModuleService: DeliveryModuleService;
}
@@ -211,7 +211,7 @@ This adds an enum that is used by the data models. It also adds a type for `deli
Create the file `src/modules/delivery/models/driver.ts` with the following content:
```ts title="src/modules/delivery/models/driver.ts"
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
import { Delivery } from "./delivery"
export const Driver = model.define("driver", {
@@ -237,7 +237,7 @@ It has a relation to a `Delivery` data model that you’ll create next.
Create the file `src/modules/delivery/models/delivery.ts` with the following content:
```ts title="src/modules/delivery/models/delivery.ts"
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
import { DeliveryStatus } from "../types/common"
import { Driver } from "./driver"
@@ -268,7 +268,7 @@ It also has a relation to the `Driver` data model, indicating the driver handlin
Then, create the main service of the Delivery Module at `src/modules/delivery/service.ts` with the following content:
```ts title="src/modules/delivery/service.ts"
import { MedusaService } from "@medusajs/utils"
import { MedusaService } from "@medusajs/framework/utils"
import { Delivery } from "./models/delivery"
import { Driver } from "./models/driver"
@@ -288,7 +288,7 @@ Next, create the file `src/modules/delivery/index.ts` holding the module’s def
```ts title="src/modules/delivery/index.ts"
import Service from "./service"
import { Module } from "@medusajs/utils"
import { Module } from "@medusajs/framework/utils"
export const DELIVERY_MODULE = "deliveryModuleService"
@@ -326,8 +326,8 @@ Create the file `src/links/restaurant-products.ts` with the following content:
```ts title="src/links/restaurant-products.ts"
import RestaurantModule from "../modules/restaurant"
import ProductModule from "@medusajs/product"
import { defineLink } from "@medusajs/utils"
import ProductModule from "@medusajs/medusa/product"
import { defineLink } from "@medusajs/framework/utils"
export default defineLink(
RestaurantModule.linkable.restaurant,
@@ -349,7 +349,7 @@ Create the file `src/links/restaurant-delivery.ts` with the following content:
```ts title="src/links/restaurant-delivery.ts"
import RestaurantModule from "../modules/restaurant"
import DeliveryModule from "../modules/delivery"
import { defineLink } from "@medusajs/utils"
import { defineLink } from "@medusajs/framework/utils"
export default defineLink(
RestaurantModule.linkable.restaurant,
@@ -371,8 +371,8 @@ Create the file `src/links/delivery-cart.ts` with the following content:
```ts title="src/links/delivery-cart.ts"
import DeliveryModule from "../modules/delivery"
import CartModule from "@medusajs/cart"
import { defineLink } from "@medusajs/utils"
import CartModule from "@medusajs/medusa/cart"
import { defineLink } from "@medusajs/framework/utils"
export default defineLink(
DeliveryModule.linkable.delivery,
@@ -388,8 +388,8 @@ Create the file `src/links/delivery-order.ts` with the following content:
```ts title="src/links/delivery-order.ts"
import DeliveryModule from "../modules/delivery"
import OrderModule from "@medusajs/order"
import { defineLink } from "@medusajs/utils"
import OrderModule from "@medusajs/medusa/order"
import { defineLink } from "@medusajs/framework/utils"
export default defineLink(
DeliveryModule.linkable.delivery,
@@ -435,7 +435,7 @@ Before implementing the functionalities, you’ll create type files in the Resta
Create the file `src/modules/restaurant/types/index.ts` with the following content:
```ts title="src/modules/restaurant/types/index.ts"
import { InferTypeOf } from "@medusajs/types"
import { InferTypeOf } from "@medusajs/framework/types"
import RestaurantModuleService from "../service"
import { Restaurant } from "../models/restaurant"
@@ -443,7 +443,7 @@ export type CreateRestaurant = Omit<
InferTypeOf<typeof Restaurant>, "id" | "admins"
>
declare module "@medusajs/types" {
declare module "@medusajs/framework/types" {
export interface ModuleImplementations {
restaurantModuleService: RestaurantModuleService;
}
@@ -454,7 +454,7 @@ This adds a type used for inputs in creating a restaurant. It also adds a type f
<Note title="Tip">
Since the `Restaurant` data model is a variable, use the `InferTypeOf` utility imported from `@medusajs/types` to infer its type.
Since the `Restaurant` data model is a variable, use the `InferTypeOf` utility imported from `@medusajs/framework/types` to infer its type.
</Note>
@@ -472,7 +472,7 @@ export const createRestaurantHighlight = [
]
```ts title="src/workflows/restaurant/steps/create-restaurant.ts" highlights={createRestaurantHighlight} collapsibleLines="1-6" expandMoreLabel="Show Imports"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
import {
CreateRestaurantDTO,
} from "../../../modules/restaurant/types/mutations"
@@ -507,7 +507,7 @@ Next, create the workflow at `src/workflows/restaurant/workflows/create-restaura
import {
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import { createRestaurantStep } from "../steps/create-restaurant"
import { CreateRestaurant } from "../../../modules/restaurant/types"
@@ -554,7 +554,7 @@ export const createRestaurantRouteHighlights = [
```ts title="src/api/restaurants/route.ts" highlights={createRestaurantRouteHighlights} collapsibleLines="1-10" expandMoreLabel="Show Imports"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import {
CreateRestaurantDTO,
} from "../../modules/restaurant/types/mutations"
@@ -633,7 +633,7 @@ import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import {
ContainerRegistrationKeys,
QueryContext,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
// ...
@@ -708,13 +708,13 @@ Medusa provides an authentication flow that allows you to authenticate custom us
Start by implementing the functionality to create a user in a workflow. The workflow has two steps:
1. Create the user in the database.
2. Set the actor type of the user’s authentication identity (created by the `/auth/{actor_type}/{provider}/register` API route). For this step, you’ll use the `setAuthAppMetadataStep` step imported from the `@medusajs/core-flows` package.
2. Set the actor type of the user’s authentication identity (created by the `/auth/{actor_type}/{provider}/register` API route). For this step, you’ll use the `setAuthAppMetadataStep` step imported from the `@medusajs/medusa/core-flows` package.
To implement the first step, create the file `src/workflows/user/steps/create-user.ts` with the following content:
```ts title="src/workflows/user/steps/create-user.ts" collapsibleLines="1-9" expandButtonLabel="Show Imports"
import { MedusaError } from "@medusajs/utils"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
import { MedusaError } from "@medusajs/framework/utils"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import {
CreateDriverInput,
CreateRestaurantAdminInput,
@@ -814,12 +814,12 @@ In the compensation function, if the `actor_type` is a restaurant, you delete th
Next, create the workflow in the file `src/workflows/user/workflows/create-user.ts`:
```ts title="src/workflows/user/workflows/create-user.ts" collapsibleLines="1-12" expandButtonLabel="Show Imports"
import { setAuthAppMetadataStep } from "@medusajs/core-flows"
import { setAuthAppMetadataStep } from "@medusajs/medusa/core-flows"
import {
createWorkflow,
transform,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
CreateDriverInput,
CreateRestaurantAdminInput,
@@ -878,7 +878,7 @@ In the workflow, you:
1. Use the `createUserStep` to create the user.
2. Use the `transform` utility function to create the input to be passed to the next step.
3. Use the `setAuthAppMetadataStep` imported from `@medusajs/core-flows` to update the authentication identity and associate it with the new user.
3. Use the `setAuthAppMetadataStep` imported from `@medusajs/medusa/core-flows` to update the authentication identity and associate it with the new user.
4. Return the created user.
### Create API Route
@@ -1056,7 +1056,7 @@ First, create the step that deletes the restaurant admin at `restaurant-marketpl
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import { RESTAURANT_MODULE } from "../../../modules/restaurant"
import { DeleteRestaurantAdminWorkflow } from "../workflows/delete-restaurant-admin"
@@ -1090,17 +1090,17 @@ In this step, you resolve the Restaurant Module's service and delete the admin.
Then, create the workflow that deletes the restaurant admin at `restaurant-marketplace/src/workflows/restaurant/workflows/delete-restaurant-admin.ts`:
```ts title="restaurant-marketplace/src/workflows/restaurant/workflows/delete-restaurant-admin.ts" collapsibleLines="1-13" expandButtonLabel="Show Imports"
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import {
WorkflowData,
WorkflowResponse,
createWorkflow,
transform,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
setAuthAppMetadataStep,
useRemoteQueryStep,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
import { deleteRestaurantAdminStep } from "../steps/delete-restaurant-admin"
export type DeleteRestaurantAdminWorkflow = {
@@ -1165,7 +1165,7 @@ After deleting the restaurant admin, you:
1. Retrieve its auth identity using Query. To do that, you filter its `app_metadata` property by checking that its `restaurant_id` property's value is the admin's ID. For drivers, you replace `restaurant_id` with `driver_id`.
2. Check that the auth identity exists using the `transform` utility. Otherwise, throw an error.
3. Unset the association between the auth identity and the restaurant admin using the `setAuthAppMetadataStep` imported from `@medusajs/core-flows`.
3. Unset the association between the auth identity and the restaurant admin using the `setAuthAppMetadataStep` imported from `@medusajs/medusa/core-flows`.
### Create API Route
@@ -1240,8 +1240,8 @@ In this step, you’ll create the API route that creates a product for a restaur
You’ll start by creating a workflow that creates the restaurant’s products. It has two steps:
1. Create the product using Medusa’s `createProductsWorkflow` as a step. It’s imported from the `@medusajs/core-flows` package.
2. Create a link between the restaurant and the products using the `createRemoateLinkStep` imported from the `@medusajs/core-flows` package.
1. Create the product using Medusa’s `createProductsWorkflow` as a step. It’s imported from the `@medusajs/medusa/core-flows` package.
2. Create a link between the restaurant and the products using the `createRemoateLinkStep` imported from the `@medusajs/medusa/core-flows` package.
So, create the workflow in the file `src/workflows/restaurant/workflows/create-restaurant-products.ts` with the following content:
@@ -1255,14 +1255,14 @@ export const createProductHighlights = [
import {
createProductsWorkflow,
createRemoteLinkStep,
} from "@medusajs/core-flows"
import { CreateProductDTO } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
} from "@medusajs/medusa/core-flows"
import { CreateProductDTO } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import {
WorkflowResponse,
createWorkflow,
transform,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import { RESTAURANT_MODULE } from "../../../modules/restaurant"
type WorkflowInput = {
@@ -1392,7 +1392,7 @@ The workflow to create a delivery has three steps:
1. `validateRestaurantStep` that checks whether a restaurant with the specified ID exists.
2. `createDeliveryStep` that creates the delivery.
3. `createRemoteLinkStep` that creates links between the different data model records. This step is imported from `@medusajs/core-flows`.
3. `createRemoteLinkStep` that creates links between the different data model records. This step is imported from `@medusajs/medusa/core-flows`.
### Create validateRestaurantStep
@@ -1401,7 +1401,7 @@ To create the first step, create the file `src/workflows/delivery/steps/validate
```ts title="src/workflows/delivery/steps/validate-restaurant.ts"
import {
createStep,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import { RESTAURANT_MODULE } from "../../../modules/restaurant"
type ValidateRestaurantStepInput = {
@@ -1435,7 +1435,7 @@ export const createDeliveryStepHighlights = [
]
```ts title="src/workflows/delivery/steps/create-delivery.ts" highlights={createDeliveryStepHighlights}
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
import { DELIVERY_MODULE } from "../../../modules/delivery"
export const createDeliveryStep = createStep(
@@ -1476,9 +1476,9 @@ import {
WorkflowResponse,
createWorkflow,
transform,
} from "@medusajs/workflows-sdk"
import { Modules } from "@medusajs/utils"
import { createRemoteLinkStep } from "@medusajs/core-flows"
} from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
import { DELIVERY_MODULE } from "../../../modules/delivery"
import { RESTAURANT_MODULE } from "../../../modules/restaurant"
import { validateRestaurantStep } from "../steps/validate-restaurant"
@@ -1589,7 +1589,7 @@ Steps that have a `*` next to their names are async steps.
{
type: "step",
name: "createRemoteLinkStep",
description: "Creates the links returned by the previous step between the order and delivery. This is imported from `@medusajs/core-flows`.",
description: "Creates the links returned by the previous step between the order and delivery. This is imported from `@medusajs/medusa/core-flows`.",
link: "/references/helper-steps/createRemoteLinkStep"
},
{
@@ -1638,7 +1638,7 @@ export const setTransactionIdStepHighlights = [
]
```ts title="src/workflows/delivery/steps/set-transaction-id.ts" highlights={setTransactionIdStepHighlights}
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
import { DELIVERY_MODULE } from "../../../modules/delivery"
export const setTransactionIdStep = createStep(
@@ -1683,8 +1683,8 @@ export const notifyRestaurantStepHighlights = [
import {
Modules,
ContainerRegistrationKeys,
} from "@medusajs/utils"
import { createStep } from "@medusajs/workflows-sdk"
} from "@medusajs/framework/utils"
import { createStep } from "@medusajs/framework/workflows-sdk"
export const notifyRestaurantStepId = "notify-restaurant-step"
export const notifyRestaurantStep = createStep(
@@ -1736,7 +1736,7 @@ A step is async if the `async` option is specified in the first object parameter
Create the file `src/workflows/delivery/steps/await-driver-claim.ts` with the following content:
```ts title="src/workflows/delivery/steps/await-driver-claim.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { createStep } from "@medusajs/framework/workflows-sdk"
export const awaitDriverClaimStepId = "await-driver-claim-step"
export const awaitDriverClaimStep = createStep(
@@ -1764,12 +1764,12 @@ export const createOrderStepHighlights1 = [
]
```ts title="src/workflows/delivery/steps/create-order.ts" highlights={createOrderStepHighlights1} collapsibleLines="1-9" expandButtonLabel="Show Imports"
import { CreateOrderShippingMethodDTO } from "@medusajs/types"
import { CreateOrderShippingMethodDTO } from "@medusajs/framework/types"
import {
Modules,
ContainerRegistrationKeys,
} from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
} from "@medusajs/framework/utils"
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
import { DELIVERY_MODULE } from "../../../modules/delivery"
export const createOrderStep = createStep(
@@ -1862,7 +1862,7 @@ You delete the order in the compensation function.
Create the file `src/workflows/delivery/steps/await-start-preparation.ts` with the following content:
```ts title="src/workflows/delivery/steps/await-start-preparation.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { createStep } from "@medusajs/framework/workflows-sdk"
export const awaitStartPreparationStepId = "await-start-preparation-step"
export const awaitStartPreparationStep = createStep(
@@ -1881,7 +1881,7 @@ This step is async and its only purpose is to wait until it’s marked as succes
Create the file `src/workflows/delivery/steps/await-preparation.ts` with the following content:
```ts title="src/workflows/delivery/steps/await-preparation.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { createStep } from "@medusajs/framework/workflows-sdk"
export const awaitPreparationStepId = "await-preparation-step"
export const awaitPreparationStep = createStep(
@@ -1905,9 +1905,9 @@ export const createFulfillmentStepHighlights = [
]
```ts title="src/workflows/delivery/steps/create-fulfillment.ts" highlights={createFulfillmentStepHighlights}
import { OrderDTO } from "@medusajs/types"
import { Modules } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
import { OrderDTO } from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
export const createFulfillmentStep = createStep(
"create-fulfillment-step",
@@ -1954,7 +1954,7 @@ In the compensation function, you cancel the fulfillment.
Create the file `src/workflows/delivery/steps/await-pick-up.ts` with the following content:
```ts title="src/workflows/delivery/steps/await-pick-up.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { createStep } from "@medusajs/framework/workflows-sdk"
export const awaitPickUpStepId = "await-pick-up-step"
export const awaitPickUpStep = createStep(
@@ -1974,7 +1974,7 @@ This step is async and its only purpose is to wait until it’s marked as succes
Create the file `src/workflows/delivery/steps/await-delivery.ts` with the following content:
```ts title="src/workflows/delivery/steps/await-delivery.ts"
import { createStep } from "@medusajs/workflows-sdk"
import { createStep } from "@medusajs/framework/workflows-sdk"
export const awaitDeliveryStepId = "await-delivery-step"
export const awaitDeliveryStep = createStep(
@@ -2001,8 +2001,8 @@ export const handleDeliveryWorkflowHighlights = [
import {
WorkflowResponse,
createWorkflow,
} from "@medusajs/workflows-sdk"
import { createRemoteLinkStep } from "@medusajs/core-flows"
} from "@medusajs/framework/workflows-sdk"
import { createRemoteLinkStep } from "@medusajs/medusa/core-flows"
import { setTransactionIdStep } from "../steps/set-transaction-id"
import { notifyRestaurantStep } from "../steps/notify-restaurant"
import { awaitDriverClaimStep } from "../steps/await-driver-claim"
@@ -2081,7 +2081,7 @@ export const createDeliveryRouteHighlights = [
```ts title="src/api/store/deliveries/route.ts" highlights={createDeliveryRouteHighlights} collapsibleLines="1-7" expandButtonLabel="Show Imports"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import zod from "zod"
import { DELIVERY_MODULE } from "../../../modules/delivery"
import { createDeliveryWorkflow } from "../../../workflows/delivery/workflows/create-delivery"
@@ -2261,7 +2261,7 @@ Before implementing the necessary functionalities, add the following types to `s
```ts title="src/modules/delivery/types/index.ts"
// other imports...
import { InferTypeOf } from "@medusajs/types"
import { InferTypeOf } from "@medusajs/framework/types"
import { Delivery } from "../models/delivery"
// ...
@@ -2277,7 +2277,7 @@ These types are useful in the upcoming implementation steps.
<Note title="Tip">
Since the `Delivery` data model is a variable, use the `InferTypeOf` utility imported from `@medusajs/types` to infer its type.
Since the `Delivery` data model is a variable, use the `InferTypeOf` utility imported from `@medusajs/framework/types` to infer its type.
</Note>
@@ -2300,7 +2300,7 @@ export const updateDeliveryStepHighlights = [
]
```ts title="src/workflows/delivery/steps/update-delivery.ts" highlights={updateDeliveryStepHighlights}
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { DELIVERY_MODULE } from "../../../modules/delivery"
import { UpdateDelivery } from "../../../modules/delivery/types"
@@ -2343,8 +2343,8 @@ export const setStepSuccessStepHighlights = [
import {
Modules,
TransactionHandlerType,
} from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
} from "@medusajs/framework/utils"
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
import { Delivery } from "../../../modules/delivery/types"
import { handleDeliveryWorkflowId } from "../workflows/handle-delivery"
@@ -2394,8 +2394,8 @@ export const setStepFailedStepHighlights = [
import {
Modules,
TransactionHandlerType,
} from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
} from "@medusajs/framework/utils"
import { StepResponse, createStep } from "@medusajs/framework/workflows-sdk"
import { Delivery } from "../../../modules/delivery/types"
import { handleDeliveryWorkflowId } from "../../delivery/workflows/handle-delivery"
@@ -2447,7 +2447,7 @@ import {
createWorkflow,
WorkflowResponse,
when,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import { setStepSuccessStep } from "../steps/set-step-success"
import { setStepFailedStep } from "../steps/set-step-failed"
import { updateDeliveryStep } from "../steps/update-delivery"
@@ -2510,7 +2510,7 @@ export const acceptRouteHighlights = [
```ts title="src/api/deliveries/[id]/accept/route.ts" highlights={acceptRouteHighlights} collapsibleLines="1-6" expandButtonLabel="Show Imports"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import { DeliveryStatus } from "../../../../modules/delivery/types"
import { notifyRestaurantStepId } from "../../../../workflows/delivery/steps/notify-restaurant"
import { updateDeliveryWorkflow } from "../../../../workflows/delivery/workflows/update-delivery"
@@ -2577,7 +2577,7 @@ import {
} from "@medusajs/medusa"
import {
ContainerRegistrationKeys,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import { RESTAURANT_MODULE } from "../../modules/restaurant"
export const isDeliveryRestaurant = async (
@@ -2709,7 +2709,7 @@ export const claimDeliveryWorkflowHighlights = [
import {
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import { DeliveryStatus } from "../../../modules/delivery/types"
import { awaitDriverClaimStepId } from "../steps/await-driver-claim"
import { setStepSuccessStep } from "../steps/set-step-success"
@@ -2844,7 +2844,7 @@ export const prepareRouteHighlights = [
```ts title="src/api/deliveries/[id]/prepare/route.ts" highlights={prepareRouteHighlights} collapsibleLines="1-10" expandButtonLabel="Show Imports"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import { DeliveryStatus } from "../../../../modules/delivery/types"
import {
updateDeliveryWorkflow,
@@ -2934,7 +2934,7 @@ export const readyRouteHighlights = [
```ts title="src/api/deliveries/[id]/ready/route.ts" highlights={readyRouteHighlights} collapsibleLines="1-10" expandButtonLabel="Show Imports"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import { DeliveryStatus } from "../../../../modules/delivery/types"
import {
updateDeliveryWorkflow,
@@ -3026,7 +3026,7 @@ export const pickUpRouteHighlights = [
```ts title="src/api/deliveries/[id]/pick-up/route.ts" highlights={pickUpRouteHighlights} collapsibleLines="1-10" expandButtonLabel="Show Imports"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import { DeliveryStatus } from "../../../../modules/delivery/types"
import {
updateDeliveryWorkflow,
@@ -3166,7 +3166,7 @@ export const completeRouteHighlights = [
```ts title="src/api/deliveries/[id]/complete/route.ts" highlights={completeRouteHighlights} collapsibleLines="1-10" expandButtonLabel="Show Imports"
import { MedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import { DeliveryStatus } from "../../../../modules/delivery/types"
import {
updateDeliveryWorkflow,
@@ -3261,7 +3261,7 @@ import {
} from "@medusajs/medusa"
import {
Modules,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import {
handleDeliveryWorkflowId,
} from "../../../../../workflows/delivery/workflows/handle-delivery"
@@ -59,7 +59,7 @@ Create the directory `src/modules/marketplace`.
Create the file `src/modules/marketplace/models/vendor.ts` with the following content:
```ts title="src/modules/marketplace/models/vendor.ts"
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
import VendorAdmin from "./vendor-admin"
const Vendor = model.define("vendor", {
@@ -80,7 +80,7 @@ Notice that the `Vendor` has many admins whose data model you’ll create next.
Create the file `src/modules/marketplace/models/vendor-admin.ts` with the following content:
```ts title="src/modules/marketplace/models/vendor-admin.ts"
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
import Vendor from "./vendor"
const VendorAdmin = model.define("vendor_admin", {
@@ -103,7 +103,7 @@ This creates a `VendorAdmin` data model, which represents an admin of a vendor.
Next, create the main service of the module at `src/modules/marketplace/service.ts` with the following content:
```ts title="src/modules/marketplace/service.ts"
import { MedusaService } from "@medusajs/utils"
import { MedusaService } from "@medusajs/framework/utils"
import Vendor from "./models/vendor"
import VendorAdmin from "./models/vendor-admin"
@@ -123,7 +123,7 @@ The service extends the [service factory](!docs!/advanced-development/modules/se
After that, create the module definition at `src/modules/marketplace/index.ts` with the following content:
```ts title="src/modules/marketplace/index.ts"
import { Module } from "@medusajs/utils"
import { Module } from "@medusajs/framework/utils"
import MarketplaceModuleService from "./service"
export const MARKETPLACE_MODULE = "marketplaceModuleService"
@@ -168,9 +168,9 @@ If your use case requires linking the vendor to other data models, such as `Sale
Create the file `src/links/vendor-product.ts` with the following content:
```ts title="src/links/vendor-product.ts"
import { defineLink } from "@medusajs/utils"
import { defineLink } from "@medusajs/framework/utils"
import MarketplaceModule from "../modules/marketplace"
import ProductModule from "@medusajs/product"
import ProductModule from "@medusajs/medusa/product"
export default defineLink(
MarketplaceModule.linkable.vendor,
@@ -186,9 +186,9 @@ This adds a list link between the `Vendor` and `Product` data models, indicating
Then, create the file `src/links/vendor-order.ts` with the following content:
```ts title="src/links/vendor-order.ts"
import { defineLink } from "@medusajs/utils"
import { defineLink } from "@medusajs/framework/utils"
import MarketplaceModule from "../modules/marketplace"
import OrderModule from "@medusajs/order"
import OrderModule from "@medusajs/medusa/order"
export default defineLink(
MarketplaceModule.linkable.vendor,
@@ -244,7 +244,7 @@ export const createVendorAdminStepHighlights = [
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import { CreateVendorAdminWorkflowInput } from ".."
import MarketplaceModuleService from "../../../../modules/marketplace/service"
import { MARKETPLACE_MODULE } from "../../../../modules/marketplace"
@@ -286,17 +286,17 @@ Then, create the workflow at `src/workflows/marketplace/create-vendor-admin/inde
export const vendorAdminWorkflowHighlights = [
["23", "createVendorAdminStep", "Create the vendor admin."],
["27", "setAuthAppMetadataStep", "Step is imported from `@medusajs/core-flows`."]
["27", "setAuthAppMetadataStep", "Step is imported from `@medusajs/medusa/core-flows`."]
]
```ts title="src/workflows/marketplace/create-vendor-admin/index.ts" highlights={vendorAdminWorkflowHighlights}
import {
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
setAuthAppMetadataStep,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
import createVendorAdminStep from "./steps/create-vendor-admin"
export type CreateVendorAdminWorkflowInput = {
@@ -332,7 +332,7 @@ export default createVendorAdminWorkflow
In this workflow, you run the following steps:
1. `createVendorAdminStep` to create the vendor admin.
2. `setAuthAppMetadataStep` to create the `vendor` actor type. This step is provided by Medusa in the `@medusajs/core-flows` package.
2. `setAuthAppMetadataStep` to create the `vendor` actor type. This step is provided by Medusa in the `@medusajs/medusa/core-flows` package.
You return the created vendor admin.
@@ -360,7 +360,7 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
import { MedusaError } from "@medusajs/framework/utils"
import { z } from "zod"
import MarketplaceModuleService from "../../modules/marketplace/service"
import createVendorAdminWorkflow from "../../workflows/marketplace/create-vendor-admin"
@@ -570,7 +570,7 @@ export const retrieveProductHighlights = [
import { AuthenticatedMedusaRequest, MedusaResponse } from "@medusajs/medusa"
import {
ContainerRegistrationKeys,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import MarketplaceModuleService from "../../../modules/marketplace/service"
import { MARKETPLACE_MODULE } from "../../../modules/marketplace"
@@ -614,16 +614,16 @@ export const createProducts1Highlights = [
```ts title="src/api/vendors/products/route.ts" highlights={createProducts1Highlights}
// other imports...
import { createProductsWorkflow } from "@medusajs/core-flows"
import { createProductsWorkflow } from "@medusajs/medusa/core-flows"
import {
CreateProductWorkflowInputDTO,
IProductModuleService,
ISalesChannelModuleService,
} from "@medusajs/types"
} from "@medusajs/framework/types"
import {
Modules,
Modules,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
// GET method...
@@ -795,11 +795,11 @@ graph TD
createVendorOrdersStep --> createRemoteLinkStep["Create Links (createRemoteLinkStep from Medusa)"]
```
1. Retrieve the cart using its ID. Medusa provides a `useRemoteQueryStep` in the `@medusajs/core-flows` package that you can use.
2. Create a parent order for the cart and its items. Medusa also has a `completeCartWorkflow` in the `@medusajs/core-flows` package that you can use as a step.
1. Retrieve the cart using its ID. Medusa provides a `useRemoteQueryStep` in the `@medusajs/medusa/core-flows` package that you can use.
2. Create a parent order for the cart and its items. Medusa also has a `completeCartWorkflow` in the `@medusajs/medusa/core-flows` package that you can use as a step.
3. Group the cart items by their product’s associated vendor.
4. For each vendor, create a child order with the cart items of their products, and return the orders with the links to be created.
5. Create the links created by the previous step. Medusa provides a `createRemoteLinkStep` in the `@medusajs/core-flows` package that you can use.
5. Create the links created by the previous step. Medusa provides a `createRemoteLinkStep` in the `@medusajs/medusa/core-flows` package that you can use.
You'll implement the third and fourth steps.
@@ -811,9 +811,9 @@ Create the third step in the file `src/workflows/marketplace/create-vendor-order
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
import { CartDTO, CartLineItemDTO } from "@medusajs/types"
import { ContainerRegistrationKeys } from "@medusajs/utils"
} from "@medusajs/framework/workflows-sdk"
import { CartDTO, CartLineItemDTO } from "@medusajs/framework/types"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
type StepInput = {
cart: CartDTO
@@ -870,18 +870,18 @@ export const vendorOrder1Highlights = [
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
CartLineItemDTO,
OrderDTO,
LinkDefinition,
InferTypeOf,
} from "@medusajs/types"
import { Modules } from "@medusajs/utils"
} from "@medusajs/framework/types"
import { Modules } from "@medusajs/framework/utils"
import {
createOrdersWorkflow,
cancelOrderWorkflow,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
import MarketplaceModuleService from "../../../../modules/marketplace/service"
import { MARKETPLACE_MODULE } from "../../../../modules/marketplace"
import Vendor from "../../../../modules/marketplace/models/vendor"
@@ -1036,7 +1036,7 @@ try {
In this snippet, you create multiple child orders for each vendor and link the orders to the vendors.
If an error occurs, the created orders in the `createdOrders` array are canceled using Medusa's `cancelOrderWorkflow` from the `@medusajs/core-flows` package.
If an error occurs, the created orders in the `createdOrders` array are canceled using Medusa's `cancelOrderWorkflow` from the `@medusajs/medusa/core-flows` package.
The order's data is formatted using the `prepareOrderData` function. Replace its definition with the following:
@@ -1112,7 +1112,7 @@ await Promise.all(created_orders.map((createdOrder) => {
}))
```
The compensation function cancels all child orders received from the step. It uses the `cancelOrderWorkflow` that Medusa provides in the `@medusajs/core-flows` package.
The compensation function cancels all child orders received from the step. It uses the `cancelOrderWorkflow` that Medusa provides in the `@medusajs/medusa/core-flows` package.
### Create Workflow
@@ -1130,13 +1130,13 @@ export const createVendorOrdersWorkflowHighlights = [
import {
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
useRemoteQueryStep,
createRemoteLinkStep,
completeCartWorkflow,
} from "@medusajs/core-flows"
import { CartDTO } from "@medusajs/types"
} from "@medusajs/medusa/core-flows"
import { CartDTO } from "@medusajs/framework/types"
import groupVendorItemsStep from "./steps/group-vendor-items"
import createVendorOrdersStep from "./steps/create-vendor-orders"
@@ -1250,8 +1250,8 @@ export const getOrderHighlights = [
```ts title="src/api/vendors/orders/route.ts" highlights={getOrderHighlights} collapsibleLines="1-6" expandMoreLabel="Show Imports"
import { AuthenticatedMedusaRequest, MedusaResponse } from "@medusajs/medusa"
import { ContainerRegistrationKeys } from "@medusajs/utils"
import { getOrdersListWorkflow } from "@medusajs/core-flows"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
import { getOrdersListWorkflow } from "@medusajs/medusa/core-flows"
import MarketplaceModuleService from "../../../modules/marketplace/service"
import { MARKETPLACE_MODULE } from "../../../modules/marketplace"
+3 -3
View File
@@ -77,9 +77,9 @@ Here’s an example of creating a custom API Route at `/store/pos/search-barcode
MedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { MedusaError } from "@medusajs/utils"
import { Modules } from "@medusajs/utils"
import { IProductModuleService } from "@medusajs/types"
import { MedusaError } from "@medusajs/framework/utils"
import { Modules } from "@medusajs/framework/utils"
import { IProductModuleService } from "@medusajs/framework/types"
export const GET = async (req: MedusaRequest, res: MedusaResponse) => {
const barcode = (req.query.barcode as string) || ""
@@ -71,7 +71,7 @@ export const subscriptionHighlights = [
]
```ts title="src/modules/subscription/models/subscription.ts" highlights={subscriptionHighlights}
import { model } from "@medusajs/utils"
import { model } from "@medusajs/framework/utils"
import { SubscriptionInterval, SubscriptionStatus } from "../types"
const Subscription = model.define("subscription", {
@@ -121,7 +121,7 @@ export enum SubscriptionInterval {
Create the module’s main service in the file `src/modules/subscription/service.ts` with the following content:
```ts title="src/modules/subscription/service.ts"
import { MedusaService } from "@medusajs/utils"
import { MedusaService } from "@medusajs/framework/utils"
import Subscription from "./models/subscription"
class SubscriptionModuleService extends MedusaService({
@@ -139,7 +139,7 @@ The main service extends the service factory to provide data-management features
Create the file `src/modules/subscription/index.ts` that holds the module’s definition:
```ts title="src/modules/subscription/index.ts"
import { Module } from "@medusajs/utils"
import { Module } from "@medusajs/framework/utils"
import SubscriptionModuleService from "./service"
export const SUBSCRIPTION_MODULE = "subscriptionModuleService"
@@ -183,9 +183,9 @@ In this step, you’ll define links between the Subscription Module’s `Subscri
To link a subscription to the cart used to make the purchase, create the file `src/links/subscription-cart.ts` with the following content:
```ts title="src/links/subscription-cart.ts"
import { defineLink } from "@medusajs/utils"
import { defineLink } from "@medusajs/framework/utils"
import SubscriptionModule from "../modules/subscription"
import CartModule from "@medusajs/cart"
import CartModule from "@medusajs/medusa/cart"
export default defineLink(
SubscriptionModule.linkable.subscription,
@@ -206,9 +206,9 @@ When you create a new order for the subscription, you’ll retrieve the linked c
To link a subscription to the customer who purchased it, create the file `src/links/subscription-customer.ts` with the following content:
```ts title="src/links/subscription-customer.ts"
import { defineLink } from "@medusajs/utils"
import { defineLink } from "@medusajs/framework/utils"
import SubscriptionModule from "../modules/subscription"
import CustomerModule from "@medusajs/customer"
import CustomerModule from "@medusajs/medusa/customer"
export default defineLink(
{
@@ -226,9 +226,9 @@ This defines a list link to the `Subscription` data model, since a customer may
To link a subscription to the orders created for it, create the file `src/links/subscription-order.ts` with the following content:
```ts title="src/links/subscription-order.ts"
import { defineLink } from "@medusajs/utils"
import { defineLink } from "@medusajs/framework/utils"
import SubscriptionModule from "../modules/subscription"
import OrderModule from "@medusajs/order"
import OrderModule from "@medusajs/medusa/order"
export default defineLink(
SubscriptionModule.linkable.subscription,
@@ -363,7 +363,7 @@ The `getExpirationDate` method accepts a subscription’s date, interval, and pe
Before overriding the `createSubscriptions` method, add the following types to `src/modules/subscription/types/index.ts`:
```ts title="src/modules/subscription/types/index.ts"
import { InferTypeOf } from "@medusajs/types"
import { InferTypeOf } from "@medusajs/framework/types"
import Subscription from "../models/subscription"
// ...
@@ -381,7 +381,7 @@ export type SubscriptionData = InferTypeOf<typeof Subscription>
<Note title="Tip">
Since the `Subscription` data model is a variable, use the `InferTypeOf` utility imported from `@medusajs/types` to infer its type.
Since the `Subscription` data model is a variable, use the `InferTypeOf` utility imported from `@medusajs/framework/types` to infer its type.
</Note>
@@ -444,7 +444,7 @@ The workflow accepts a cart’s ID, and it has three steps:
2. Create a subscription.
3. Link the subscription to the order, cart, and customer.
Medusa provides the first and last steps in the `@medusajs/core-flows` package, so you only need to implement the second step.
Medusa provides the first and last steps in the `@medusajs/medusa/core-flows` package, so you only need to implement the second step.
### Create a Subscription Step (Second Step)
@@ -458,9 +458,9 @@ export const createSubscriptionsHighlights = [
]
```ts title="src/workflows/create-subscription/steps/create-subscription.ts" highlights={createSubscriptionsHighlights} collapsibleLines="1-7" expandMoreLabel="Show Imports"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
import { Modules } from "@medusajs/utils"
import { LinkDefinition } from "@medusajs/types"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import { Modules } from "@medusajs/framework/utils"
import { LinkDefinition } from "@medusajs/framework/types"
import { SubscriptionInterval } from "../../../modules/subscription/types"
import SubscriptionModuleService from "../../../modules/subscription/service"
import { SUBSCRIPTION_MODULE } from "../../../modules/subscription"
@@ -584,11 +584,11 @@ export const createSubscriptionWorkflowHighlights = [
import {
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
createRemoteLinkStep,
completeCartWorkflow,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
import {
SubscriptionInterval,
} from "../../modules/subscription/types"
@@ -632,9 +632,9 @@ export default createSubscriptionWorkflow
This workflow accepts the cart’s ID, along with the subscription details. It executes the following steps:
1. `completeCartWorkflow` from `@medusajs/core-flows` that completes a cart and creates an order.
1. `completeCartWorkflow` from `@medusajs/medusa/core-flows` that completes a cart and creates an order.
2. `createSubscriptionStep`, which is the step you created previously.
3. `createRemoteLinkStep` from `@medusajs/core-flows`, which accepts links to create. These links are in the `linkDefs` array returned by the previous step.
3. `createRemoteLinkStep` from `@medusajs/medusa/core-flows`, which accepts links to create. These links are in the `linkDefs` array returned by the previous step.
The workflow returns the created subscription and order.
@@ -666,7 +666,7 @@ import {
import {
ContainerRegistrationKeys,
MedusaError,
} from "@medusajs/utils"
} from "@medusajs/framework/utils"
import createSubscriptionWorkflow from "../../../../../workflows/create-subscription"
export const POST = async (
@@ -728,7 +728,7 @@ After installation, create the file `src/modules/checkout/components/subscriptio
```tsx title="src/modules/checkout/components/subscriptions/index.tsx" badgeLabel="Storefront" badgeColor="orange" collapsibleLines="1-13" expandMoreLabel="Show Imports"
"use client"
import { StoreCart } from "@medusajs/types"
import { StoreCart } from "@medusajs/framework/types"
import { Button, clx, Heading, Text } from "@medusajs/ui"
import { CheckCircleSolid } from "@medusajs/icons"
import { usePathname, useRouter, useSearchParams } from "next/navigation"
@@ -978,7 +978,7 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { ContainerRegistrationKeys } from "@medusajs/utils"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
export const GET = async (
req: AuthenticatedMedusaRequest,
@@ -1039,7 +1039,7 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { ContainerRegistrationKeys } from "@medusajs/utils"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
export const GET = async (
req: AuthenticatedMedusaRequest,
@@ -1089,7 +1089,7 @@ Before creating the UI routes, create the file `src/admin/types/index.ts` that h
import {
OrderDTO,
CustomerDTO,
} from "@medusajs/types"
} from "@medusajs/framework/types"
export enum SubscriptionStatus {
ACTIVE = "active",
@@ -1452,13 +1452,13 @@ graph TD
capturePaymentStep["capturePaymentStep (Medusa)"] --> updateSubscriptionStep
```
1. Retrieve the subscription’s linked cart. Medusa provides a `useRemoteQueryStep` in the `@medusajs/core-flows` package that can be used as a step.
2. Create a payment collection for the new order. Medusa provides a `createPaymentCollectionsStep` in the `@medusajs/core-flows` package that you can use.
3. Create payment sessions in the payment collection. Medusa provides a `createPaymentSessionsWorkflow` in the `@medusajs/core-flows` package that can be used as a step.
4. Authorize the payment session. Medusa also provides the `authorizePaymentSessionStep` in the `@medusajs/core-flows` package, which can be used.
1. Retrieve the subscription’s linked cart. Medusa provides a `useRemoteQueryStep` in the `@medusajs/medusa/core-flows` package that can be used as a step.
2. Create a payment collection for the new order. Medusa provides a `createPaymentCollectionsStep` in the `@medusajs/medusa/core-flows` package that you can use.
3. Create payment sessions in the payment collection. Medusa provides a `createPaymentSessionsWorkflow` in the `@medusajs/medusa/core-flows` package that can be used as a step.
4. Authorize the payment session. Medusa also provides the `authorizePaymentSessionStep` in the `@medusajs/medusa/core-flows` package, which can be used.
5. Create the subscription’s new order.
6. Create links between the subscription and the order using the `createRemoteLinkStep` provided in the `@medusajs/core-flows` package.
7. Capture the order’s payment using the `capturePaymentStep` provided by Medusa in the `@medusajs/core-flows` package.
6. Create links between the subscription and the order using the `createRemoteLinkStep` provided in the `@medusajs/medusa/core-flows` package.
7. Capture the order’s payment using the `capturePaymentStep` provided by Medusa in the `@medusajs/medusa/core-flows` package.
8. Update the subscription’s `last_order_date` and `next_order_date` properties.
You’ll only implement the fifth and eighth steps.
@@ -1481,17 +1481,17 @@ export const createSubscriptionOrderStep1Highlights = [
]
```ts title="src/workflows/create-subscription-order/steps/create-subscription-order.ts" highlights={createSubscriptionOrderStep1Highlights} collapsibleLines="1-15" expandMoreLabel="Show Imports"
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import {
CartWorkflowDTO,
PaymentCollectionDTO,
IOrderModuleService,
LinkDefinition,
} from "@medusajs/types"
} from "@medusajs/framework/types"
import {
Modules,
} from "@medusajs/utils"
import { createOrdersWorkflow } from "@medusajs/core-flows"
} from "@medusajs/framework/utils"
import { createOrdersWorkflow } from "@medusajs/medusa/core-flows"
import { SubscriptionData } from "../../../modules/subscription/types"
import { SUBSCRIPTION_MODULE } from "../../../modules/subscription"
@@ -1536,7 +1536,7 @@ const createSubscriptionOrderStep = createStep(
export default createSubscriptionOrderStep
```
This creates a `createSubscriptionOrderStep` that uses the `createOrdersWorkflow`, which Medusa provides in the `@medusajs/core-flows` package. The step returns the created order and an array of links to be created.
This creates a `createSubscriptionOrderStep` that uses the `createOrdersWorkflow`, which Medusa provides in the `@medusajs/medusa/core-flows` package. The step returns the created order and an array of links to be created.
In this step, you use a `getOrderData` function to format the order’s input data.
@@ -1666,7 +1666,7 @@ export const updateSubscriptionStepHighlights = [
import {
createStep,
StepResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
SUBSCRIPTION_MODULE,
} from "../../../modules/subscription"
@@ -1750,25 +1750,25 @@ export const createSubscriptionOrderWorkflowHighlights = [
import {
createWorkflow,
WorkflowResponse,
} from "@medusajs/workflows-sdk"
} from "@medusajs/framework/workflows-sdk"
import {
useRemoteQueryStep,
createPaymentSessionsWorkflow,
createRemoteLinkStep,
capturePaymentStep,
} from "@medusajs/core-flows"
} from "@medusajs/medusa/core-flows"
import {
CartWorkflowDTO,
} from "@medusajs/types"
} from "@medusajs/framework/types"
import {
SubscriptionData,
} from "../../modules/subscription/types"
import {
authorizePaymentSessionStep,
} from "@medusajs/core-flows/dist/payment/steps/authorize-payment-session"
} from "@medusajs/medusa/core-flows/dist/payment/steps/authorize-payment-session"
import {
createPaymentCollectionsStep,
} from "@medusajs/core-flows/dist/definition/cart/steps/create-payment-collection"
} from "@medusajs/medusa/core-flows/dist/cart/steps/create-payment-collection"
import createSubscriptionOrderStep from "./steps/create-subscription-order"
import updateSubscriptionStep from "./steps/update-subscription"
@@ -1889,7 +1889,7 @@ export const createSubscriptionOrdersJob1Highlights = [
]
```ts title="src/jobs/create-subscription-orders.ts" highlights={createSubscriptionOrdersJob1Highlights} collapsibleLines="1-7" expandMoreLabel="Show Imports"
import { MedusaContainer } from "@medusajs/types"
import { MedusaContainer } from "@medusajs/framework/types"
import SubscriptionModuleService from "../modules/subscription/service"
import { SUBSCRIPTION_MODULE } from "../modules/subscription"
import moment from "moment"
@@ -2033,7 +2033,7 @@ export const expireSubscriptionOrdersJobHighlights = [
]
```ts title="src/jobs/expire-subscription-orders.ts" highlights={expireSubscriptionOrdersJobHighlights} collapsibleLines="1-6" expandMoreLabel="Show Imports"
import { MedusaContainer } from "@medusajs/types"
import { MedusaContainer } from "@medusajs/framework/types"
import SubscriptionModuleService from "../modules/subscription/service"
import { SUBSCRIPTION_MODULE } from "../modules/subscription"
import moment from "moment"
@@ -2120,7 +2120,7 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "@medusajs/medusa"
import { ContainerRegistrationKeys } from "@medusajs/utils"
import { ContainerRegistrationKeys } from "@medusajs/framework/utils"
export const GET = async (
req: AuthenticatedMedusaRequest,
@@ -29,7 +29,7 @@ The `@medusajs/types` package provide API routes' request and response types.
If you're not using the JS Client or Medusa React, install `@medusajs/types` to use the correct request and response types:
```bash npm2yarn
npm install @medusajs/types@preview
npm install @medusajs/types@rc
```
---
@@ -1,9 +1,9 @@
If you've installed a preview version of a package, such as `@medusajs/file-s3`, make sure its version in `package.json` is set to `preview`:
If you've installed an `rc` version of a package, such as `@medusajs/medusa/file-s3`, make sure its version in `package.json` is set to `rc`:
```json title="package.json"
"dependencies": {
// ...
"@medusajs/file-s3": "preview"
"@medusajs/medusa/file-s3": "rc"
}
```
@@ -8,7 +8,7 @@ export const metadata = {
## Update Medusa Version
While Medusa v2 is still in active development, a version is released every three hours under the `preview` tag.
While Medusa v2 is still in active development, a version is released every three hours under the `rc` tag.
If you run into issues during your development, try first to remove the `node_modules` directory and `yarn.lock` file (or `package-lock.json`) and re-install the dependencies:
@@ -18,7 +18,7 @@ rm yarn.lock # or package-lock.json
yarn install # or npm install
```
This updates the Medusa v2 dependencies to the latest `preview` version, which may have resolved your issue.
This updates the Medusa v2 dependencies to the latest `rc` version, which may have resolved your issue.
If your issue still persists, check out the troubleshooting guides below or [create a GitHub issue](https://github.com/medusajs/medusa/issues/new?assignees=&labels=status:+needs+triaging,+version:+2.0&projects=&template=bug_report_v2.md&title=).