Browse Source

Merge pull request #2536 from medusajs/fix/build-fail-typescript

Shahed Nasser 6 months ago
parent
commit
a8e0285737
1 changed files with 20 additions and 20 deletions
  1. 20 20
      src/scripts/seed.ts

+ 20 - 20
src/scripts/seed.ts

@@ -13,21 +13,17 @@ import {
   linkSalesChannelsToStockLocationWorkflow,
   linkSalesChannelsToStockLocationWorkflow,
   updateStoresWorkflow,
   updateStoresWorkflow,
 } from "@medusajs/medusa/core-flows";
 } from "@medusajs/medusa/core-flows";
-import {
-  ExecArgs,
-} from "@medusajs/framework/types";
+import { CreateInventoryLevelInput, ExecArgs } from "@medusajs/framework/types";
 import {
 import {
   ContainerRegistrationKeys,
   ContainerRegistrationKeys,
   Modules,
   Modules,
-  ProductStatus
+  ProductStatus,
 } from "@medusajs/framework/utils";
 } from "@medusajs/framework/utils";
 
 
 export default async function seedDemoData({ container }: ExecArgs) {
 export default async function seedDemoData({ container }: ExecArgs) {
   const logger = container.resolve(ContainerRegistrationKeys.LOGGER);
   const logger = container.resolve(ContainerRegistrationKeys.LOGGER);
-  const remoteLink = container.resolve(
-    ContainerRegistrationKeys.REMOTE_LINK
-  );
-  const query = container.resolve(ContainerRegistrationKeys.QUERY)
+  const remoteLink = container.resolve(ContainerRegistrationKeys.REMOTE_LINK);
+  const query = container.resolve(ContainerRegistrationKeys.QUERY);
   const fulfillmentModuleService = container.resolve(Modules.FULFILLMENT);
   const fulfillmentModuleService = container.resolve(Modules.FULFILLMENT);
   const salesChannelModuleService = container.resolve(Modules.SALES_CHANNEL);
   const salesChannelModuleService = container.resolve(Modules.SALES_CHANNEL);
   const storeModuleService = container.resolve(Modules.STORE);
   const storeModuleService = container.resolve(Modules.STORE);
@@ -335,7 +331,7 @@ export default async function seedDemoData({ container }: ExecArgs) {
         {
         {
           title: "Medusa T-Shirt",
           title: "Medusa T-Shirt",
           category_ids: [
           category_ids: [
-            categoryResult.find((cat) => cat.name === "Shirts").id,
+            categoryResult.find((cat) => cat.name === "Shirts")!.id,
           ],
           ],
           description:
           description:
             "Reimagine the feeling of a classic T-shirt. With our cotton T-shirts, everyday essentials no longer have to be ordinary.",
             "Reimagine the feeling of a classic T-shirt. With our cotton T-shirts, everyday essentials no longer have to be ordinary.",
@@ -521,7 +517,7 @@ export default async function seedDemoData({ container }: ExecArgs) {
         {
         {
           title: "Medusa Sweatshirt",
           title: "Medusa Sweatshirt",
           category_ids: [
           category_ids: [
-            categoryResult.find((cat) => cat.name === "Sweatshirts").id,
+            categoryResult.find((cat) => cat.name === "Sweatshirts")!.id,
           ],
           ],
           description:
           description:
             "Reimagine the feeling of a classic sweatshirt. With our cotton sweatshirt, everyday essentials no longer have to be ordinary.",
             "Reimagine the feeling of a classic sweatshirt. With our cotton sweatshirt, everyday essentials no longer have to be ordinary.",
@@ -620,7 +616,9 @@ export default async function seedDemoData({ container }: ExecArgs) {
         },
         },
         {
         {
           title: "Medusa Sweatpants",
           title: "Medusa Sweatpants",
-          category_ids: [categoryResult.find((cat) => cat.name === "Pants").id],
+          category_ids: [
+            categoryResult.find((cat) => cat.name === "Pants")!.id,
+          ],
           description:
           description:
             "Reimagine the feeling of classic sweatpants. With our cotton sweatpants, everyday essentials no longer have to be ordinary.",
             "Reimagine the feeling of classic sweatpants. With our cotton sweatpants, everyday essentials no longer have to be ordinary.",
           handle: "sweatpants",
           handle: "sweatpants",
@@ -718,7 +716,9 @@ export default async function seedDemoData({ container }: ExecArgs) {
         },
         },
         {
         {
           title: "Medusa Shorts",
           title: "Medusa Shorts",
-          category_ids: [categoryResult.find((cat) => cat.name === "Merch").id],
+          category_ids: [
+            categoryResult.find((cat) => cat.name === "Merch")!.id,
+          ],
           description:
           description:
             "Reimagine the feeling of classic shorts. With our cotton shorts, everyday essentials no longer have to be ordinary.",
             "Reimagine the feeling of classic shorts. With our cotton shorts, everyday essentials no longer have to be ordinary.",
           handle: "shorts",
           handle: "shorts",
@@ -822,25 +822,25 @@ export default async function seedDemoData({ container }: ExecArgs) {
   logger.info("Seeding inventory levels.");
   logger.info("Seeding inventory levels.");
 
 
   const { data: inventoryItems } = await query.graph({
   const { data: inventoryItems } = await query.graph({
-    entity: 'inventory_item',
-    fields: ['id']
-  })
+    entity: "inventory_item",
+    fields: ["id"],
+  });
 
 
-  const inventoryLevels = []
+  const inventoryLevels: CreateInventoryLevelInput[] = [];
   for (const inventoryItem of inventoryItems) {
   for (const inventoryItem of inventoryItems) {
     const inventoryLevel = {
     const inventoryLevel = {
       location_id: stockLocation.id,
       location_id: stockLocation.id,
       stocked_quantity: 1000000,
       stocked_quantity: 1000000,
       inventory_item_id: inventoryItem.id,
       inventory_item_id: inventoryItem.id,
-    }
-    inventoryLevels.push(inventoryLevel)
+    };
+    inventoryLevels.push(inventoryLevel);
   }
   }
 
 
   await createInventoryLevelsWorkflow(container).run({
   await createInventoryLevelsWorkflow(container).run({
     input: {
     input: {
-      inventory_levels: inventoryLevels
+      inventory_levels: inventoryLevels,
     },
     },
-  })
+  });
 
 
   logger.info("Finished seeding inventory levels data.");
   logger.info("Finished seeding inventory levels data.");
 }
 }