import { ModuleAnnotation, ModuleLike } from "@alterior/di"; import { Injector, Provider } from "@alterior/di"; /** * Combines a module annotation and a target class into a single * object for storage purposes in Runtime and related objects. */ export interface ModuleDefinition { readonly metadata: ModuleAnnotation; readonly target: any; } /** * Represents a live instance of a module. * Contains both the module definition as well * as a reference to the module instance itself. */ export interface ModuleInstance { readonly definition: ModuleDefinition; readonly instance: any; } /** * Used to construct a runtime environment for a given entry module. * Handles resolving the module tree into an injector as well as constructing * the module instances and running lifecycle events. */ export declare class Runtime { constructor(entryModule: Function); definitions: ModuleDefinition[]; visited: ModuleLike[]; private _instances; get instances(): ModuleInstance[]; /** * Get a specific service from the dependency injector. * @param ctor */ getService(ctor: { new (...args: any[]): T; }): T; /** * Retrieve the providers that were collected from the * module graph and used to create the primary injector. */ providers: Provider[]; /** * Iterate over the module definitions which are part of this * runtime and append to the given array the set of dependency injection * providers which are specified in the module definitions. * * @param providers An array which will be populated */ contributeProviders(providers: Provider[]): void; /** * Perform runtime configuration steps */ configure(): void; private _selfTest; /** * True if the `--self-test` option was used to launch the application. */ get selfTest(): boolean; processCommandLine(args: string[]): void; /** * True if the runtime instance has been loaded. Becomes true after calling load(). */ get loaded(): boolean; /** * Fire an event to all modules which understand it. Should be upper-camel-case, meaning * to fire the altOnStart() method, send "OnStart". * @param eventName */ fireEvent(eventName: string): void; private _injector; /** * Get the runtime's dependency injector. This injector can provide all dependencies specified * in the imported modules' `providers` definitions. */ get injector(): Injector; /** * Instantiate the modules of this runtime using the given dependency injector. * The injector will be inherited into an injector that provides the dependencies * specified in the imported modules' `providers` definitions. * * @param injector */ load(injector: Injector): ModuleInstance[]; /** * Stop any services, as defined by imported modules of this runtime. For instance, if you import WebServerModule * from @alterior/web-server, calling this will instruct the module to stop serving on the configured port. * Also builds in a timeout to allow for all services and operations to stop before resolving. * * This will send the `OnStop` lifecycle event to all modules, which triggers the `altOnStop()` method of any module * which implements it to be called. It also instructs the RolesService to stop any roles which are currently running. * For more information about Roles, see the documentation for RolesService. */ stop(): Promise; /** * Start any services, as defined by modules. For instance, if you import WebServerModule from @alterior/web-server, * calling this will instruct the module to begin serving on the configured port. * * This will send the `OnStart` lifecycle event to all modules, which triggers the `altOnStart()` method of any module * which implements it to be called. It also instructs the RolesService to start roles as per it's configuration. * For more information about Roles, see the documentation for RolesService. */ start(): void; /** * Stop all running services and shut down the process */ shutdown(): Promise; /** * Retrieve the ModuleAnnotation for a given Module definition, whether it be a class annotated * with `@Module()` or a plain object with `$module` which configures a module class. * * This is an alias of ModuleAnnotation.getForClass(module) * * @param module */ getMetadataForModule(module: ModuleLike): ModuleAnnotation; /** * Resolves the given module, adding it to this runtime. * Calls itself for all imports. Visited modules are tracked per runtime, * so resolveModule() on the same runtime object will not work, preventing * loops. */ private resolveModule; } //# sourceMappingURL=modules.d.ts.map