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:
@@ -26,8 +26,8 @@ For example, you saw this code snippet in the [Medusa container chapter](../medu
|
||||
|
||||
```ts highlights={[["10"]]}
|
||||
import type { 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 const GET = async (
|
||||
req: MedusaRequest,
|
||||
@@ -50,6 +50,6 @@ When you resolve the `Modules.PRODUCT` (or `productModuleService`) registration
|
||||
|
||||
<Note title="Tip">
|
||||
|
||||
To resolve the main service of any commerce module, use the registration name defined in the `Modules` enum imported from `@medusajs/utils`.
|
||||
To resolve the main service of any commerce module, use the registration name defined in the `Modules` enum imported from `@medusajs/framework/utils`.
|
||||
|
||||
</Note>
|
||||
|
||||
@@ -16,12 +16,12 @@ A data model is created in a module, and its record are managed in the database
|
||||
|
||||
## How to Create a Data Model?
|
||||
|
||||
A data model is created in a TypeScript or JavaScript file under a module's `models` directory. It's defined using the `model` utility imported from `@medusajs/utils`.
|
||||
A data model is created in a TypeScript or JavaScript file under a module's `models` directory. It's defined using the `model` utility imported from `@medusajs/framework/utils`.
|
||||
|
||||
For example, create the file `src/modules/hello/models/my-custom.ts` with the following content:
|
||||
|
||||
```ts title="src/modules/hello/models/my-custom.ts"
|
||||
import { model } from "@medusajs/utils"
|
||||
import { model } from "@medusajs/framework/utils"
|
||||
|
||||
const MyCustom = model.define("my_custom", {
|
||||
id: model.id().primaryKey(),
|
||||
|
||||
@@ -85,13 +85,13 @@ For example:
|
||||
export const highlights = [
|
||||
["7", "container", "Recieve the Medusa Container in the object parameter."],
|
||||
["10", "resolve", "Resolve the Product Module's main service."],
|
||||
["10", "Modules.PRODUCT", "The module's registration name imported from `@medusajs/utils`."]
|
||||
["10", "Modules.PRODUCT", "The module's registration name imported from `@medusajs/framework/utils`."]
|
||||
]
|
||||
|
||||
```ts title="src/subscribers/product-created.ts" highlights={highlights}
|
||||
import { SubscriberArgs, type SubscriberConfig } 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 productCreateHandler({
|
||||
event: { data },
|
||||
|
||||
@@ -19,14 +19,14 @@ export const highlights = [
|
||||
[
|
||||
"10",
|
||||
"Modules.PRODUCT",
|
||||
"The resource registration name imported from `@medusajs/utils`.",
|
||||
"The resource registration name imported from `@medusajs/framework/utils`.",
|
||||
],
|
||||
]
|
||||
|
||||
```ts highlights={highlights}
|
||||
import type { 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 const GET = async (
|
||||
req: MedusaRequest,
|
||||
|
||||
@@ -52,7 +52,7 @@ For example, create the file `src/modules/hello/index.ts` with the following con
|
||||
|
||||
```ts title="src/modules/hello/index.ts" highlights={[["7", "", "The main service of the module."]]}
|
||||
import HelloModuleService from "./service"
|
||||
import { Module } from "@medusajs/utils"
|
||||
import { Module } from "@medusajs/framework/utils"
|
||||
|
||||
export const HELLO_MODULE = "helloModuleService"
|
||||
|
||||
@@ -61,7 +61,7 @@ export default Module(HELLO_MODULE, {
|
||||
})
|
||||
```
|
||||
|
||||
You use the `Module` function imported from `@medusajs/utils` to create the module definition. It requires two parameters:
|
||||
You use the `Module` function imported from `@medusajs/framework/utils` to create the module definition. It requires two parameters:
|
||||
|
||||
1. The module's name.
|
||||
2. An object with a required property `service` indicating the module's main service.
|
||||
|
||||
@@ -87,15 +87,15 @@ For example:
|
||||
|
||||
export const highlights = [
|
||||
["11", "resolve", "Resolve the Product Module's main service."],
|
||||
["11", "Modules.PRODUCT", "The module's registration name imported from `@medusajs/utils`."]
|
||||
["11", "Modules.PRODUCT", "The module's registration name imported from `@medusajs/framework/utils`."]
|
||||
]
|
||||
|
||||
```ts title="src/jobs/hello-world.ts" highlights={highlights}
|
||||
import {
|
||||
IProductModuleService,
|
||||
MedusaContainer,
|
||||
} from "@medusajs/types"
|
||||
import { Modules } from "@medusajs/utils"
|
||||
} from "@medusajs/framework/types"
|
||||
import { Modules } from "@medusajs/framework/utils"
|
||||
|
||||
export default async function myCustomJob(
|
||||
container: MedusaContainer
|
||||
|
||||
@@ -22,12 +22,12 @@ By using a workflow, you can track its execution's progress, provide roll-back l
|
||||
|
||||
### 1. Create the Steps
|
||||
|
||||
A workflow is made of a series of steps. A step is created using the `createStep` utility function imported from `@medusajs/workflows-sdk`.
|
||||
A workflow is made of a series of steps. A step is created using the `createStep` utility function imported from `@medusajs/framework/workflows-sdk`.
|
||||
|
||||
Create the file `src/workflows/hello-world.ts` with the following content:
|
||||
|
||||
```ts title="src/workflows/hello-world.ts"
|
||||
import { createStep, StepResponse } from "@medusajs/workflows-sdk"
|
||||
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
|
||||
const step1 = createStep("step-1", async () => {
|
||||
return new StepResponse(`Hello from step one!`)
|
||||
@@ -59,7 +59,7 @@ import {
|
||||
// other imports...
|
||||
createWorkflow,
|
||||
WorkflowResponse,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
|
||||
// ...
|
||||
|
||||
@@ -127,8 +127,8 @@ To execute the workflow, invoke it passing the Medusa container as a parameter.
|
||||
type SubscriberArgs,
|
||||
} from "@medusajs/medusa"
|
||||
import myWorkflow from "../workflows/hello-world"
|
||||
import { Modules } from "@medusajs/utils"
|
||||
import { IUserModuleService } from "@medusajs/types"
|
||||
import { Modules } from "@medusajs/framework/utils"
|
||||
import { IUserModuleService } from "@medusajs/framework/types"
|
||||
|
||||
export default async function handleCustomerCreate({
|
||||
event: { data },
|
||||
@@ -160,7 +160,7 @@ To execute the workflow, invoke it passing the Medusa container as a parameter.
|
||||
<CodeTab label="Scheduled Job" value="scheduled-job">
|
||||
|
||||
```ts title="src/jobs/message-daily.ts" highlights={[["7"], ["8"], ["9"], ["10"], ["11"], ["12"]]}
|
||||
import { MedusaContainer } from "@medusajs/types"
|
||||
import { MedusaContainer } from "@medusajs/framework/types"
|
||||
import myWorkflow from "../workflows/hello-world"
|
||||
|
||||
export default async function myCustomJob(
|
||||
@@ -230,7 +230,7 @@ export const highlights = [
|
||||
[
|
||||
"12",
|
||||
"Modules.PRODUCT",
|
||||
"The resource registration name imported from `@medusajs/utils`.",
|
||||
"The resource registration name imported from `@medusajs/framework/utils`.",
|
||||
],
|
||||
]
|
||||
|
||||
@@ -240,9 +240,9 @@ import {
|
||||
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"
|
||||
|
||||
const step1 = createStep("step-1", async (_, context) => {
|
||||
const productModuleService: IProductModuleService =
|
||||
|
||||
Reference in New Issue
Block a user