feat: loosely typed container
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
Constructor,
|
||||
IModuleService,
|
||||
InternalModuleDeclaration,
|
||||
Logger,
|
||||
MedusaContainer,
|
||||
@@ -158,9 +159,9 @@ export async function loadInternalModule(
|
||||
|
||||
if (loaderOnly) {
|
||||
// The expectation is only to run the loader as standalone, so we do not need to register the service and we need to cleanup all services
|
||||
const service = container.resolve(registrationName)
|
||||
await service.__hooks?.onApplicationPrepareShutdown()
|
||||
await service.__hooks?.onApplicationShutdown()
|
||||
const service = container.resolve<IModuleService>(registrationName)
|
||||
await service.__hooks?.onApplicationPrepareShutdown?.()
|
||||
await service.__hooks?.onApplicationShutdown?.()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import type { Knex } from "knex"
|
||||
import { mergeTypeDefs } from "@graphql-tools/merge"
|
||||
import { makeExecutableSchema } from "@graphql-tools/schema"
|
||||
import { RemoteFetchDataCallback } from "@medusajs/orchestration"
|
||||
import {
|
||||
import type {
|
||||
ConfigModule,
|
||||
ExternalModuleDeclaration,
|
||||
InternalModuleDeclaration,
|
||||
LoadedModule,
|
||||
Logger,
|
||||
MedusaContainer,
|
||||
ModuleDefinition,
|
||||
ModuleExports,
|
||||
@@ -36,6 +39,16 @@ import { cleanGraphQLSchema } from "./utils"
|
||||
|
||||
const LinkModulePackage = MODULE_PACKAGE_NAMES[Modules.LINK]
|
||||
|
||||
declare module "@medusajs/types" {
|
||||
export interface ModuleImplementations {
|
||||
[ContainerRegistrationKeys.REMOTE_LINK]: RemoteLink
|
||||
[ContainerRegistrationKeys.CONFIG_MODULE]: ConfigModule
|
||||
[ContainerRegistrationKeys.PG_CONNECTION]: Knex<any>
|
||||
[ContainerRegistrationKeys.REMOTE_QUERY]: RemoteQueryFunction
|
||||
[ContainerRegistrationKeys.LOGGER]: Logger
|
||||
}
|
||||
}
|
||||
|
||||
export type RunMigrationFn = (
|
||||
options?: ModuleServiceInitializeOptions,
|
||||
injectedDependencies?: Record<any, any>
|
||||
|
||||
Reference in New Issue
Block a user