Pārlūkot izejas kodu

Merge pull request #2538 from medusajs/feat/update-seed-script

update seed script for v2.1.4 + README updates
Shahed Nasser 5 mēneši atpakaļ
vecāks
revīzija
dcc3f3ef84

+ 1 - 3
src/api/README.md

@@ -82,14 +82,12 @@ import type {
   MedusaRequest,
   MedusaResponse,
 } from "@medusajs/framework/http"
-import { Modules } from "@medusajs/framework/utils"
 
 export const GET = async (
   req: MedusaRequest,
   res: MedusaResponse
 ) => {
-  const productModuleService =
-    req.scope.resolve(Modules.PRODUCT)
+  const productModuleService = req.scope.resolve("product")
 
   const [, count] = await productModuleService.listAndCount()
 

+ 1 - 1
src/api/admin/custom/route.ts

@@ -3,6 +3,6 @@ import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http";
 export async function GET(
   req: MedusaRequest,
   res: MedusaResponse
-): Promise<void> {
+) {
   res.sendStatus(200);
 }

+ 1 - 1
src/api/store/custom/route.ts

@@ -3,6 +3,6 @@ import { MedusaRequest, MedusaResponse } from "@medusajs/framework/http";
 export async function GET(
   req: MedusaRequest,
   res: MedusaResponse
-): Promise<void> {
+) {
   res.sendStatus(200);
 }

+ 1 - 3
src/jobs/README.md

@@ -8,13 +8,11 @@ For example, create the file `src/jobs/hello-world.ts` with the following conten
 
 ```ts
 import {
-  IProductModuleService,
   MedusaContainer
 } from "@medusajs/framework/types";
-import { Modules } from "@medusajs/framework/utils";
 
 export default async function myCustomJob(container: MedusaContainer) {
-  const productService: IProductModuleService = container.resolve(Modules.PRODUCT)
+  const productService = container.resolve("product")
 
   const products = await productService.listAndCountProducts();
 

+ 1 - 1
src/links/README.md

@@ -17,4 +17,4 @@ export default defineLink(
 
 This defines a link between the Product Module's `product` data model and the Hello Module (custom module)'s `myCustom` data model.
 
-Learn more about links in [this documentation](https://docs.medusajs.com/learn/advanced-development/module-links)
+Learn more about links in [this documentation](https://docs.medusajs.com/learn/fundamentals/module-links)

+ 5 - 7
src/modules/README.md

@@ -28,7 +28,7 @@ For example, create the file `src/modules/hello/index.ts` with the following con
 import HelloModuleService from "./service"
 import { Module } from "@medusajs/framework/utils"
 
-export const HELLO_MODULE = "helloModuleService"
+export const HELLO_MODULE = "hello"
 
 export default Module(HELLO_MODULE, {
   service: HelloModuleService,
@@ -46,16 +46,14 @@ import { HELLO_MODULE } from "./src/modules/hello"
 
 module.exports = defineConfig({
   // ...
-  modules: {
-    [HELLO_MODULE]: {
+  modules: [
+    {
       resolve: "./modules/hello",
-    },
-  },
+    }
+  ]
 })
 ```
 
-Its key (`helloModuleService` or `HELLO_MODULE`) is the name of the module’s main service. It will be registered in the Medusa container with that name.
-
 ## Use Module
 
 You can resolve the main service of the module in other resources, such as an API route:

+ 1 - 4
src/scripts/README.md

@@ -11,15 +11,12 @@ For example, create the file `src/scripts/my-script.ts` with the following conte
 ```ts title="src/scripts/my-script.ts"
 import { 
   ExecArgs,
-  IProductModuleService
 } from "@medusajs/framework/types"
-import { Modules } from "@medusajs/framework/utils"
 
 export default async function myScript ({
   container
 }: ExecArgs) {
-  const productModuleService: IProductModuleService = 
-    container.resolve(Modules.PRODUCT)
+  const productModuleService = container.resolve("product")
 
   const [, count] = await productModuleService.listAndCountProducts()
 

+ 3 - 3
src/scripts/seed.ts

@@ -22,7 +22,7 @@ import {
 
 export default async function seedDemoData({ container }: ExecArgs) {
   const logger = container.resolve(ContainerRegistrationKeys.LOGGER);
-  const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK);
+  const link = container.resolve(ContainerRegistrationKeys.LINK);
   const query = container.resolve(ContainerRegistrationKeys.QUERY);
   const fulfillmentModuleService = container.resolve(Modules.FULFILLMENT);
   const salesChannelModuleService = container.resolve(Modules.SALES_CHANNEL);
@@ -112,7 +112,7 @@ export default async function seedDemoData({ container }: ExecArgs) {
   });
   const stockLocation = stockLocationResult[0];
 
-  await remoteLink.create({
+  await link.create({
     [Modules.STOCK_LOCATION]: {
       stock_location_id: stockLocation.id,
     },
@@ -175,7 +175,7 @@ export default async function seedDemoData({ container }: ExecArgs) {
     ],
   });
 
-  await remoteLink.create({
+  await link.create({
     [Modules.STOCK_LOCATION]: {
       stock_location_id: stockLocation.id,
     },

+ 1 - 4
src/subscribers/README.md

@@ -39,8 +39,6 @@ import type {
   SubscriberArgs,
   SubscriberConfig,
 } from "@medusajs/framework"
-import { IProductModuleService } from "@medusajs/framework/types"
-import { Modules } from "@medusajs/framework/utils"
 
 export default async function productCreateHandler({
   event: { data },
@@ -48,8 +46,7 @@ export default async function productCreateHandler({
 }: SubscriberArgs<{ id: string }>) {
   const productId = data.id
 
-  const productModuleService: IProductModuleService =
-    container.resolve(Modules.PRODUCT)
+  const productModuleService = container.resolve("product")
 
   const product = await productModuleService.retrieveProduct(productId)
 

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 309 - 301
yarn.lock


Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels