1 parent
95c538c675
commit
5a8a889c6d
57 files changed
+1286
-423
No files matched your search
@@ -12,7 +12,7 @@ describe("models loader", () => {
|
||||
|
||||
beforeAll(async () => {
|
||||
try {
|
||||
models = modelsLoader({
|
||||
models = await modelsLoader({
|
||||
container,
|
||||
isTest: true,
|
||||
coreTestPathGlob: "../models/{product,product-variant}.ts",
|
||||
@@ -30,9 +30,9 @@ describe("models loader", () => {
|
||||
})
|
||||
|
||||
it("ensure that the product model is an extended model", () => {
|
||||
const productModel = container.resolve("productModel")
|
||||
const productModel = models.find((model) => model.name === "Product")
|
||||
|
||||
expect(productModel.custom_attribute).toEqual("test")
|
||||
expect(new productModel().custom_attribute).toEqual("test")
|
||||
})
|
||||
|
||||
it("ensure that the extended product model is registered in db_entities", () => {
|
||||
|
||||
@@ -8,7 +8,6 @@ import path from "path"
|
||||
import { ClassConstructor, MedusaContainer } from "../types/global"
|
||||
import { EntitySchema } from "typeorm"
|
||||
import { asClass, asValue } from "awilix"
|
||||
import { upperCaseFirst } from "@medusajs/utils"
|
||||
|
||||
type ModelLoaderParams = {
|
||||
container: MedusaContainer
|
||||
@@ -63,9 +62,8 @@ export default (
|
||||
// If an extension file is found, override it with that instead
|
||||
if (mappedExtensionModel) {
|
||||
const coreModel = require(modelPath)
|
||||
const modelName = upperCaseFirst(
|
||||
const modelName =
|
||||
formatRegistrationNameWithoutNamespace(modelPath)
|
||||
)
|
||||
|
||||
coreModel[modelName] = mappedExtensionModel
|
||||
val = mappedExtensionModel
|
||||
|
||||
@@ -1,19 +1,3 @@
|
||||
import { SearchUtils, upperCaseFirst } from "@medusajs/utils"
|
||||
import { aliasTo, asFunction, asValue, Lifetime } from "awilix"
|
||||
import { Express } from "express"
|
||||
import fs from "fs"
|
||||
import { sync as existsSync } from "fs-exists-cached"
|
||||
import glob from "glob"
|
||||
import _ from "lodash"
|
||||
import { createRequireFromPath } from "medusa-core-utils"
|
||||
import {
|
||||
FileService,
|
||||
FulfillmentService,
|
||||
OauthService,
|
||||
} from "medusa-interfaces"
|
||||
import { trackInstallation } from "medusa-telemetry"
|
||||
import path from "path"
|
||||
import { EntitySchema } from "typeorm"
|
||||
import {
|
||||
AbstractTaxService,
|
||||
isBatchJobStrategy,
|
||||
@@ -23,23 +7,40 @@ import {
|
||||
isPriceSelectionStrategy,
|
||||
isTaxCalculationStrategy,
|
||||
} from "../interfaces"
|
||||
import { MiddlewareService } from "../services"
|
||||
import {
|
||||
ClassConstructor,
|
||||
ConfigModule,
|
||||
Logger,
|
||||
MedusaContainer,
|
||||
} from "../types/global"
|
||||
import {
|
||||
FileService,
|
||||
FulfillmentService,
|
||||
OauthService,
|
||||
} from "medusa-interfaces"
|
||||
import { Lifetime, aliasTo, asFunction, asValue } from "awilix"
|
||||
import { SearchUtils, upperCaseFirst } from "@medusajs/utils"
|
||||
import {
|
||||
formatRegistrationName,
|
||||
formatRegistrationNameWithoutNamespace,
|
||||
} from "../utils/format-registration-name"
|
||||
import { getModelExtensionsMap } from "./helpers/get-model-extension-map"
|
||||
import {
|
||||
registerPaymentProcessorFromClass,
|
||||
registerPaymentServiceFromClass,
|
||||
} from "./helpers/plugins"
|
||||
|
||||
import { EntitySchema } from "typeorm"
|
||||
import { Express } from "express"
|
||||
import { MiddlewareService } from "../services"
|
||||
import _ from "lodash"
|
||||
import { createRequireFromPath } from "medusa-core-utils"
|
||||
import { sync as existsSync } from "fs-exists-cached"
|
||||
import fs from "fs"
|
||||
import { getModelExtensionsMap } from "./helpers/get-model-extension-map"
|
||||
import glob from "glob"
|
||||
import logger from "./logger"
|
||||
import path from "path"
|
||||
import { trackInstallation } from "medusa-telemetry"
|
||||
|
||||
type Options = {
|
||||
rootDirectory: string
|
||||
|
||||
Reference in new issue
Block a user