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:
@@ -21,7 +21,7 @@ Start by creating the directory `src/modules/brand` that will hold the Brand Mod
|
||||
To create a data model that represents a new `brand` table in the database, create the file `src/modules/brand/models/brand.ts` with the following content:
|
||||
|
||||
```ts title="src/modules/brand/models/brand.ts"
|
||||
import { model } from "@medusajs/utils"
|
||||
import { model } from "@medusajs/framework/utils"
|
||||
|
||||
export const Brand = model.define("brand", {
|
||||
id: model.id().primaryKey(),
|
||||
@@ -44,7 +44,7 @@ export const serviceHighlights = [
|
||||
]
|
||||
|
||||
```ts title="src/modules/brand/service.ts" highlights={serviceHighlights}
|
||||
import { MedusaService } from "@medusajs/utils"
|
||||
import { MedusaService } from "@medusajs/framework/utils"
|
||||
import { Brand } from "./models/brand"
|
||||
|
||||
class BrandModuleService extends MedusaService({
|
||||
@@ -56,7 +56,7 @@ class BrandModuleService extends MedusaService({
|
||||
export default BrandModuleService
|
||||
```
|
||||
|
||||
The `BrandModuleService` extends a `MedusaService` function imported from `@medusajs/utils` which is a service factory.
|
||||
The `BrandModuleService` extends a `MedusaService` function imported from `@medusajs/framework/utils` which is a service factory.
|
||||
|
||||
The `MedusaService` function receives an object of the module's data models as a parameter, and generates methods to manage those data models, such as `createBrands` and `updateBrands`.
|
||||
|
||||
@@ -75,7 +75,7 @@ Find a reference of the generated methods in [this guide](!resources!/service-fa
|
||||
To export the module's definition, create the file `src/modules/brand/index.ts` with the following content:
|
||||
|
||||
```ts title="src/modules/brand/index.ts"
|
||||
import { Module } from "@medusajs/utils"
|
||||
import { Module } from "@medusajs/framework/utils"
|
||||
import BrandModuleService from "./service"
|
||||
|
||||
export const BRAND_MODULE = "brandModuleService"
|
||||
|
||||
@@ -45,7 +45,7 @@ Create the file `src/workflows/create-brand/index.ts` with the following content
|
||||
import {
|
||||
createWorkflow,
|
||||
WorkflowResponse,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
|
||||
export type CreateBrandInput = {
|
||||
name: string
|
||||
@@ -71,7 +71,7 @@ Create the file `src/workflows/create-brand/steps/create-brand.ts` with the foll
|
||||
import {
|
||||
createStep,
|
||||
StepResponse,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import { CreateBrandInput } from ".."
|
||||
import { BRAND_MODULE } from "../../../modules/brand"
|
||||
import BrandModuleService from "../../../modules/brand/service"
|
||||
|
||||
@@ -34,7 +34,7 @@ export const highlights = [
|
||||
|
||||
```tsx title="src/admin/widgets/product-brand.tsx" highlights={highlights}
|
||||
import { defineWidgetConfig } from "@medusajs/admin-sdk"
|
||||
import { DetailWidgetProps, AdminProduct } from "@medusajs/types"
|
||||
import { DetailWidgetProps, AdminProduct } from "@medusajs/framework/types"
|
||||
import { useEffect, useState } from "react"
|
||||
import { Container, Heading } from "@medusajs/ui"
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ export const stepHighlights = [
|
||||
import {
|
||||
createStep,
|
||||
StepResponse,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import {
|
||||
Modules,
|
||||
ContainerRegistrationKeys,
|
||||
} from "@medusajs/utils"
|
||||
} from "@medusajs/framework/utils"
|
||||
import { BRAND_MODULE } from "../../modules/brand"
|
||||
|
||||
type LinkProductToBrandStepInput = {
|
||||
@@ -71,7 +71,7 @@ The `create` method accepts as a parameter an object whose properties are the na
|
||||
|
||||
<Note title="Tip">
|
||||
|
||||
Use the `Modules` enum imported from `@medusajs/utils` to for the commerce module's names.
|
||||
Use the `Modules` enum imported from `@medusajs/framework/utils` to for the commerce module's names.
|
||||
|
||||
</Note>
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ This chapter covers how to define a link between the `Brand` and `Product`data m
|
||||
]}
|
||||
/>
|
||||
|
||||
Links are defined in a TypeScript or JavaScript file under the `src/links` directory. The file defines and exports the link using the `defineLink` function imported from `@medusajs/utils`.
|
||||
Links are defined in a TypeScript or JavaScript file under the `src/links` directory. The file defines and exports the link using the `defineLink` function imported from `@medusajs/framework/utils`.
|
||||
|
||||
So, create the file `src/links/product-brand.ts` with the following content:
|
||||
|
||||
@@ -34,8 +34,8 @@ export const highlights = [
|
||||
|
||||
```ts title="src/links/product-brand.ts" highlights={highlights}
|
||||
import BrandModule from "../modules/brand"
|
||||
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(
|
||||
{
|
||||
|
||||
@@ -86,9 +86,9 @@ export const hookHighlights = [
|
||||
]
|
||||
|
||||
```ts title="src/workflows/hooks/created-product.ts" highlights={hookHighlights}
|
||||
import { createProductsWorkflow } from "@medusajs/core-flows"
|
||||
import { StepResponse } from "@medusajs/workflows-sdk"
|
||||
import { Modules, ContainerRegistrationKeys } from "@medusajs/utils"
|
||||
import { createProductsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
import { StepResponse } from "@medusajs/framework/workflows-sdk"
|
||||
import { Modules, ContainerRegistrationKeys } from "@medusajs/framework/utils"
|
||||
import { BRAND_MODULE } from "../../modules/brand"
|
||||
import BrandModuleService from "../../modules/brand/service"
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ import {
|
||||
} from "@medusajs/medusa"
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
} from "@medusajs/utils"
|
||||
} from "@medusajs/framework/utils"
|
||||
|
||||
export const GET = async (
|
||||
req: MedusaRequest,
|
||||
|
||||
@@ -25,7 +25,7 @@ This chapter covers how to emit an event when a brand is created, listen to that
|
||||
|
||||
To handle brand-creation event, you'll emit a custom event when a brand is created.
|
||||
|
||||
In the `createBrandWorkflow` defined in `src/workflows/create-brand/index.ts`, use the `emitEventStep` helper step imported from `@medusajs/core-flows` after the `createBrandStep`:
|
||||
In the `createBrandWorkflow` defined in `src/workflows/create-brand/index.ts`, use the `emitEventStep` helper step imported from `@medusajs/medusa/core-flows` after the `createBrandStep`:
|
||||
|
||||
export const eventHighlights = [
|
||||
["13", "emitEventStep", "Emit an event."],
|
||||
@@ -37,7 +37,7 @@ export const eventHighlights = [
|
||||
// other imports...
|
||||
import {
|
||||
emitEventStep,
|
||||
} from "@medusajs/core-flows"
|
||||
} from "@medusajs/medusa/core-flows"
|
||||
|
||||
// ...
|
||||
|
||||
@@ -75,7 +75,7 @@ Create the file `src/workflows/sync-brand-to-system/index.ts` with the following
|
||||
import {
|
||||
createWorkflow,
|
||||
WorkflowResponse,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
|
||||
export type SyncBrandToSystemInput = {
|
||||
id: string
|
||||
@@ -104,7 +104,7 @@ export const stepHighlights = [
|
||||
import {
|
||||
createStep,
|
||||
StepResponse,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import { SyncBrandToSystemInput } from ".."
|
||||
import BrandModuleService from "../../../modules/brand/service"
|
||||
import { BRAND_MODULE } from "../../../modules/brand"
|
||||
|
||||
@@ -39,7 +39,7 @@ To create the step that retrieves the brands from the third-party service, creat
|
||||
import {
|
||||
createStep,
|
||||
StepResponse,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import BrandModuleService from "../../../modules/brand/service"
|
||||
import { BRAND_MODULE } from "../../../modules/brand"
|
||||
|
||||
@@ -74,8 +74,8 @@ export const createBrandsHighlights = [
|
||||
import {
|
||||
createStep,
|
||||
StepResponse,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { InferTypeOf } from "@medusajs/types"
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import { InferTypeOf } from "@medusajs/framework/types"
|
||||
import BrandModuleService from "../../../modules/brand/service"
|
||||
import { BRAND_MODULE } from "../../../modules/brand"
|
||||
import { Brand } from "../../../modules/brand/models/brand"
|
||||
@@ -109,7 +109,7 @@ This step receives the brands to create as input.
|
||||
|
||||
<Note title="Tip">
|
||||
|
||||
Since a data model is a variable, use the `InferTypeOf` utility imported from `@medusajs/types` to infer its type.
|
||||
Since a data model is a variable, use the `InferTypeOf` utility imported from `@medusajs/framework/types` to infer its type.
|
||||
|
||||
</Note>
|
||||
|
||||
@@ -131,8 +131,8 @@ export const updateBrandsHighlights = [
|
||||
import {
|
||||
createStep,
|
||||
StepResponse,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { InferTypeOf } from "@medusajs/types"
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import { InferTypeOf } from "@medusajs/framework/types"
|
||||
import BrandModuleService from "../../../modules/brand/service"
|
||||
import { BRAND_MODULE } from "../../../modules/brand"
|
||||
import { Brand } from "../../../modules/brand/models/brand"
|
||||
@@ -181,8 +181,8 @@ import {
|
||||
createWorkflow,
|
||||
WorkflowResponse,
|
||||
transform,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { InferTypeOf } from "@medusajs/types"
|
||||
} from "@medusajs/framework/workflows-sdk"
|
||||
import { InferTypeOf } from "@medusajs/framework/types"
|
||||
import { retrieveBrandsFromSystemStep } from "./steps/retrieve-brands-from-system"
|
||||
import { createBrandsStep } from "./steps/create-brands"
|
||||
import { updateBrandsStep } from "./steps/update-brands"
|
||||
@@ -206,7 +206,7 @@ Next, you need to identify which brands must be created or updated.
|
||||
|
||||
Since workflows are constructed internally and are only evaluated during execution, you can't access any data's value to perform data manipulation or checks.
|
||||
|
||||
Instead, use the `transform` utility function imported from `@medusajs/workflows-sdk`, which gives you access to the real-time values of the data to perfrom actions on them.
|
||||
Instead, use the `transform` utility function imported from `@medusajs/framework/workflows-sdk`, which gives you access to the real-time values of the data to perfrom actions on them.
|
||||
|
||||
So, replace the `TODO` with the following:
|
||||
|
||||
@@ -275,7 +275,7 @@ Then, you return the created and updated brands.
|
||||
To schedule a task that syncs brands from the third-party system, create a scheduled job at `src/jobs/sync-brands-from-system.ts`:
|
||||
|
||||
```ts title="src/jobs/sync-brands-from-system.ts"
|
||||
import { MedusaContainer } from "@medusajs/types"
|
||||
import { MedusaContainer } from "@medusajs/framework/types"
|
||||
import { syncBrandsFromSystemWorkflow } from "../workflows/sync-brands-from-system"
|
||||
|
||||
export default async function (container: MedusaContainer) {
|
||||
|
||||
@@ -32,7 +32,7 @@ export const serviceHighlights = [
|
||||
]
|
||||
|
||||
```ts title="src/modules/brand/services/client.ts" highlights={serviceHighlights}
|
||||
import { Logger, ConfigModule } from "@medusajs/types"
|
||||
import { Logger, ConfigModule } from "@medusajs/framework/types"
|
||||
import { BRAND_MODULE } from ".."
|
||||
|
||||
export type BrandClientOptions = {
|
||||
@@ -88,7 +88,7 @@ export const methodsHighlights = [
|
||||
|
||||
```ts title="src/modules/brand/services/client.ts" highlights={methodsHighlights}
|
||||
// other imports...
|
||||
import { InferTypeOf } from "@medusajs/types"
|
||||
import { InferTypeOf } from "@medusajs/framework/types"
|
||||
import { Brand } from "../models/brand"
|
||||
|
||||
export class BrandClient {
|
||||
@@ -125,7 +125,7 @@ The `sendRequest` method is a dummy method to simulate sending a request to a th
|
||||
|
||||
You also add three methods that use the `sendRequest` method:
|
||||
|
||||
- `createBrand` that creates a brand in the third-party system. To reference a brand's type, you use the `InferTypeOf` utility imported from `@medusajs/types`. This transforms a data model, which is a variable, to its equivalent type.
|
||||
- `createBrand` that creates a brand in the third-party system. To reference a brand's type, you use the `InferTypeOf` utility imported from `@medusajs/framework/types`. This transforms a data model, which is a variable, to its equivalent type.
|
||||
- `deleteBrand` that deletes the brand in the third-party system.
|
||||
- `retrieveBrands` to retrieve a brand from the third-party system.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user