import { Type } from '../common/cli-types'; import { Injector } from '../dependency-injection/injector'; import { ProviderRef } from '../dependency-injection/provider-refs/provider-ref'; import { ConfiguredModule } from './module-models'; import { Provider } from '../dependency-injection/providers'; import { EvaluatedArgumentsContext } from '../parser/arguments-context'; import { GlobalComponentsRegistry } from '../app/global-components-registry'; import { RegisteredRoute } from '../command/registered-route'; import { OptionsLink } from '../options/options-link'; /** * An internal reference to a module that is responsable for creating the underlying module components and executing cli command calls */ export declare class ModuleRef extends Injector { /** * Parent injector of the module where the module is a sub command module and is not a shared module */ parent: ModuleRef; /** * Providers within the module's dependency injection scope */ providers: ProviderRef[]; /** * Both direct an imported routes within the module */ routes: RegisteredRoute[]; /** * Options supplied directly within the module or imported from other modules, that are applicable to all * commands and or sub commands within the module */ options: OptionsLink[]; /** * Providers that are shared with other modules that import this module */ providerExports: ProviderRef[]; /** * Modules that are shared with other modules that import this module */ moduleExports: ModuleRef[]; /** * Routes that are shared with other modules that import this module */ routeExports: RegisteredRoute[]; /** * Options that are shared with other modules that import this module */ optionExports: OptionsLink[]; /** * Instance of the module class */ instance: T; /** * All module references imported into this module */ imports: ModuleRef[]; /** * Route resolved from the raw arguments */ activeRoute: RegisteredRoute; /** * A reference to the global registry for registering imports, global provider, commands and options */ private registry; /** * Creates a new instance of the module ref and configures the components of the module * @param constructorRef Module class * @param registry The global components registery for modules, commands, options and global providers * @param parentModule Parent module where a sub command module * @param configuredModule Configured module where applicable */ constructor(constructorRef: Type, registry: GlobalComponentsRegistry, parentModule: ModuleRef, configuredModule?: ConfiguredModule); /** * Gets a reference to the root module */ get rootModule(): ModuleRef; /** * All parents */ get parents(): ModuleRef[]; /** * Validates the module throught the parser module */ validate(): Promise; /** * Attempts to resolve the cli call signature to a route in the module, continuing down the application graph until the call is matched to a * command route * @param rawArgsOrContext raw cli arguments or an evaluated context from a parent in the application graph */ execute(rawArgsOrContext: string[] | EvaluatedArgumentsContext): Promise; /** * Executes a command after instantiating all option containers and modules within the execution path, and triggered the command * hooks of the modules both before and after the command is executed */ private executeCommand; /** * Creates an instance of the module, adding the option providers to the modules injection scope if the function is called for the first time */ resolve(): Promise; /** * Executes the command hooks on all modules within a command's execution path * @param moduleInstances Modules within the execution path * @param command Command that is going to be executed * @param commandInstance Instance of the command * @param defintionsFn Function that returns which hooks must be executed */ private handleCommandMiddleWare; /** * Filters the module exports for a specific component type * @param moduleExports Module exports * @param type Component to filter for */ private filterExports; /** * Registers the modules options, considering options declared directly within the metadata, options exported from the module and options imported * from other modules. Validates for duplicate declarations in both exports and imports. Registers the options in the global components registry * @param options Options declared directly in the options metadata * @param optionExports Options exported from the module * @param imports Imported modules */ private processOptions; /** * Registers the providers modules providers, considering direct declarations, exports and imports. Providers declared and exported with the * same token are treated as a single provider. Validates for duplicate declarations * @param moduleProviders Providers declared directly in the modules metadata * @param providerExports Providers exported from the module * @param imports Imported modules */ private processProviders; registerProviders(providers: Provider[], parent: Injector): ProviderRef[]; /** * Registers the imported modules, registering shared modules with the global component registry. Where the same module is imported and exported both declarations * refer to the same module * @param imports Imports declared in the modules metadata * @param moduleExports Modules exported from the module */ private processImports; /** * Registers the modules routes, considering imports and exports. Instantiates and registers command modules in global components registry * @param commands Commands declared directly in the modules metadata * @param exportedCommands Commands exported from the module * @param imports Imported modules */ private processRoutes; /** * Merges the components specified in a configured module with the modules metadata, filtering out direct declarations of the components that are also * supplied with the configured module * @param definition The modules original metadata * @param configuredModule The configured module to merge with the metadata */ private mergeConfiguredModule; /** * Retrieves and validates that the parser module is supplied in the root module. When valid it returns an instance of * the parse module * @param imports The modules imports * @param parentModule Parent module of the current module */ private resolveParserModule; /** * Looks to find a help module in the current module, else it looks for the help module in parent modules. Where a module * is found it returns an instance of the module, else it returns null * @param imports The modules imports * @param parentModule Parent module of the current module */ private resolveHelpModule; /** * Handles an errors thrown during module execution and calls the approach help implementations * when application * @param err Error that was through * @param helpModule Instance of the help module * @param route Current route at which the error was thrown */ private handleError; }