Chore(medusa,utils,types,inventory,stock-location): remove core dependency modules (#3531)
This commit is contained in:
committed by
GitHub
parent
bfef22b33e
commit
4e9d257d3b
@@ -1,4 +1,8 @@
|
||||
import { ModuleDefinition, MODULE_RESOURCE_TYPE, MODULE_SCOPE } from "./types"
|
||||
import {
|
||||
ModuleDefinition,
|
||||
MODULE_RESOURCE_TYPE,
|
||||
MODULE_SCOPE,
|
||||
} from "@medusajs/types"
|
||||
|
||||
export const MODULE_DEFINITIONS: ModuleDefinition[] = [
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export * from "@medusajs/types/dist/modules-sdk"
|
||||
export * from "./definitions"
|
||||
export * from "./loaders"
|
||||
export * from "./medusa-module"
|
||||
export * from "./module-helper"
|
||||
export * from "./types"
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import { AwilixContainer, ClassOrFunctionReturning, Resolver } from "awilix"
|
||||
import { createMedusaContainer } from "medusa-core-utils"
|
||||
import { EOL } from "os"
|
||||
import {
|
||||
ModuleResolution,
|
||||
MODULE_RESOURCE_TYPE,
|
||||
MODULE_SCOPE,
|
||||
} from "../../types"
|
||||
|
||||
} from "@medusajs/types"
|
||||
import { AwilixContainer, ClassOrFunctionReturning, Resolver } from "awilix"
|
||||
import { createMedusaContainer } from "medusa-core-utils"
|
||||
import { EOL } from "os"
|
||||
import { moduleLoader } from "../module-loader"
|
||||
import { trackInstallation } from "../__mocks__/medusa-telemetry"
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import MODULE_DEFINITIONS from "../../definitions"
|
||||
import {
|
||||
InternalModuleDeclaration,
|
||||
ModuleDefinition,
|
||||
MODULE_RESOURCE_TYPE,
|
||||
MODULE_SCOPE,
|
||||
} from "../../types"
|
||||
} from "@medusajs/types"
|
||||
import MODULE_DEFINITIONS from "../../definitions"
|
||||
import { registerModules } from "../register-modules"
|
||||
|
||||
const RESOLVED_PACKAGE = "@medusajs/test-service-resolved"
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import { asValue } from "awilix"
|
||||
import { EOL } from "os"
|
||||
import { loadInternalModule } from "./utils"
|
||||
|
||||
import {
|
||||
Logger,
|
||||
MedusaContainer,
|
||||
ModuleResolution,
|
||||
MODULE_SCOPE,
|
||||
} from "../types"
|
||||
|
||||
} from "@medusajs/types"
|
||||
import { asValue } from "awilix"
|
||||
import { EOL } from "os"
|
||||
import { ModulesHelper } from "../module-helper"
|
||||
import { loadInternalModule } from "./utils"
|
||||
|
||||
export const moduleHelper = new ModulesHelper()
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import resolveCwd from "resolve-cwd"
|
||||
|
||||
import MODULE_DEFINITIONS from "../definitions"
|
||||
import {
|
||||
ExternalModuleDeclaration,
|
||||
InternalModuleDeclaration,
|
||||
ModuleDefinition,
|
||||
ModuleResolution,
|
||||
MODULE_SCOPE,
|
||||
} from "../types"
|
||||
} from "@medusajs/types"
|
||||
import resolveCwd from "resolve-cwd"
|
||||
import MODULE_DEFINITIONS from "../definitions"
|
||||
|
||||
export const registerModules = (
|
||||
modules?: Record<
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import { asFunction, asValue } from "awilix"
|
||||
import { createMedusaContainer } from "medusa-core-utils"
|
||||
import { trackInstallation } from "medusa-telemetry"
|
||||
import {
|
||||
Constructor,
|
||||
InternalModuleDeclaration,
|
||||
@@ -10,7 +7,10 @@ import {
|
||||
ModuleResolution,
|
||||
MODULE_RESOURCE_TYPE,
|
||||
MODULE_SCOPE,
|
||||
} from "../../types"
|
||||
} from "@medusajs/types"
|
||||
import { createMedusaContainer } from "@medusajs/utils"
|
||||
import { asFunction, asValue } from "awilix"
|
||||
import { trackInstallation } from "medusa-telemetry"
|
||||
|
||||
export async function loadInternalModule(
|
||||
container: MedusaContainer,
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { asValue } from "awilix"
|
||||
import { createMedusaContainer } from "medusa-core-utils"
|
||||
import { moduleLoader, registerMedusaModule } from "./loaders"
|
||||
import { loadModuleMigrations } from "./loaders/utils"
|
||||
import {
|
||||
ExternalModuleDeclaration,
|
||||
InternalModuleDeclaration,
|
||||
MODULE_RESOURCE_TYPE,
|
||||
MODULE_SCOPE,
|
||||
} from "./types"
|
||||
} from "@medusajs/types"
|
||||
import { createMedusaContainer } from "@medusajs/utils"
|
||||
import { asValue } from "awilix"
|
||||
import { moduleLoader, registerMedusaModule } from "./loaders"
|
||||
import { loadModuleMigrations } from "./loaders/utils"
|
||||
|
||||
const logger: any = {
|
||||
log: (a) => console.log(a),
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ModuleResolution, ModulesResponse } from "./types"
|
||||
import { ModuleResolution, ModulesResponse } from "@medusajs/types"
|
||||
|
||||
export class ModulesHelper {
|
||||
private modules_: Record<string, ModuleResolution> = {}
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
import { MedusaContainer as coreMedusaContainer } from "medusa-core-utils"
|
||||
import { Logger as _Logger } from "winston"
|
||||
|
||||
export type MedusaContainer = coreMedusaContainer
|
||||
export type Constructor<T> = new (...args: any[]) => T
|
||||
|
||||
export type LogLevel =
|
||||
| "query"
|
||||
| "schema"
|
||||
| "error"
|
||||
| "warn"
|
||||
| "info"
|
||||
| "log"
|
||||
| "migration"
|
||||
export type LoggerOptions = boolean | "all" | LogLevel[]
|
||||
|
||||
export type Logger = _Logger & {
|
||||
progress: (activityId: string, msg: string) => void
|
||||
info: (msg: string) => void
|
||||
warn: (msg: string) => void
|
||||
}
|
||||
|
||||
export enum MODULE_SCOPE {
|
||||
INTERNAL = "internal",
|
||||
EXTERNAL = "external",
|
||||
}
|
||||
|
||||
export enum MODULE_RESOURCE_TYPE {
|
||||
SHARED = "shared",
|
||||
ISOLATED = "isolated",
|
||||
}
|
||||
|
||||
export type InternalModuleDeclaration = {
|
||||
scope: MODULE_SCOPE.INTERNAL
|
||||
resources: MODULE_RESOURCE_TYPE
|
||||
dependencies?: string[]
|
||||
resolve?: string
|
||||
options?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export type ExternalModuleDeclaration = {
|
||||
scope: MODULE_SCOPE.EXTERNAL
|
||||
server: {
|
||||
type: "http"
|
||||
url: string
|
||||
keepAlive: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export type ModuleResolution = {
|
||||
resolutionPath: string | false
|
||||
definition: ModuleDefinition
|
||||
options?: Record<string, unknown>
|
||||
dependencies?: string[]
|
||||
moduleDeclaration?: InternalModuleDeclaration | ExternalModuleDeclaration
|
||||
}
|
||||
|
||||
export type ModuleDefinition = {
|
||||
key: string
|
||||
registrationName: string
|
||||
defaultPackage: string | false
|
||||
label: string
|
||||
canOverride?: boolean
|
||||
isRequired?: boolean
|
||||
dependencies?: string[]
|
||||
defaultModuleDeclaration:
|
||||
| InternalModuleDeclaration
|
||||
| ExternalModuleDeclaration
|
||||
}
|
||||
|
||||
export type LoaderOptions<TOptions = Record<string, unknown>> = {
|
||||
container: MedusaContainer
|
||||
options?: TOptions
|
||||
logger?: Logger
|
||||
}
|
||||
|
||||
export type ModuleLoaderFunction = (
|
||||
options: LoaderOptions,
|
||||
moduleDeclaration?: InternalModuleDeclaration
|
||||
) => Promise<void>
|
||||
|
||||
export type ModulesResponse = {
|
||||
module: string
|
||||
resolution: string | false
|
||||
}[]
|
||||
|
||||
export type ModuleExports = {
|
||||
service: Constructor<any>
|
||||
loaders?: ModuleLoaderFunction[]
|
||||
migrations?: any[]
|
||||
models?: Constructor<any>[]
|
||||
runMigrations?(
|
||||
options: LoaderOptions,
|
||||
moduleDeclaration: InternalModuleDeclaration
|
||||
): Promise<void>
|
||||
revertMigration?(
|
||||
options: LoaderOptions,
|
||||
moduleDeclaration: InternalModuleDeclaration
|
||||
): Promise<void>
|
||||
}
|
||||
Reference in New Issue
Block a user