UNPKG

4.42 kBTypeScriptView Raw
1import { DynamicModule, ForwardReference, Provider } from '@nestjs/common';
2import { EnhancerSubtype } from '@nestjs/common/constants';
3import { ClassProvider, Controller, ExistingProvider, FactoryProvider, Injectable, Type, ValueProvider } from '@nestjs/common/interfaces';
4import { ApplicationConfig } from './application-config';
5import { NestContainer } from './injector/container';
6import { InstanceWrapper } from './injector/instance-wrapper';
7import { Module } from './injector/module';
8import { GraphInspector } from './inspector/graph-inspector';
9import { ModuleDefinition } from './interfaces/module-definition.interface';
10import { ModuleOverride } from './interfaces/module-override.interface';
11import { MetadataScanner } from './metadata-scanner';
12interface ModulesScanParameters {
13 moduleDefinition: ModuleDefinition;
14 scope?: Type<unknown>[];
15 ctxRegistry?: (ForwardReference | DynamicModule | Type<unknown>)[];
16 overrides?: ModuleOverride[];
17 lazy?: boolean;
18}
19export declare class DependenciesScanner {
20 private readonly container;
21 private readonly metadataScanner;
22 private readonly graphInspector;
23 private readonly applicationConfig;
24 private readonly applicationProvidersApplyMap;
25 constructor(container: NestContainer, metadataScanner: MetadataScanner, graphInspector: GraphInspector, applicationConfig?: ApplicationConfig);
26 scan(module: Type<any>, options?: {
27 overrides?: ModuleOverride[];
28 }): Promise<void>;
29 scanForModules({ moduleDefinition, lazy, scope, ctxRegistry, overrides, }: ModulesScanParameters): Promise<Module[]>;
30 insertModule(moduleDefinition: any, scope: Type<unknown>[]): Promise<{
31 moduleRef: Module;
32 inserted: boolean;
33 } | undefined>;
34 scanModulesForDependencies(modules?: Map<string, Module>): Promise<void>;
35 reflectImports(module: Type<unknown>, token: string, context: string): Promise<void>;
36 reflectProviders(module: Type<any>, token: string): void;
37 reflectControllers(module: Type<any>, token: string): void;
38 reflectDynamicMetadata(cls: Type<Injectable>, token: string): void;
39 reflectExports(module: Type<unknown>, token: string): void;
40 reflectInjectables(component: Type<Injectable>, token: string, metadataKey: string): void;
41 reflectParamInjectables(component: Type<Injectable>, token: string, metadataKey: string): void;
42 reflectKeyMetadata(component: Type<Injectable>, key: string, methodKey: string): {
43 methodKey: string;
44 metadata: any;
45 } | undefined;
46 calculateModulesDistance(): void;
47 insertImport(related: any, token: string, context: string): Promise<void>;
48 isCustomProvider(provider: Provider): provider is ClassProvider | ValueProvider | FactoryProvider | ExistingProvider;
49 insertProvider(provider: Provider, token: string): string | symbol | Function | InstanceWrapper<unknown>;
50 insertInjectable(injectable: Type<Injectable> | object, token: string, host: Type<Injectable>, subtype: EnhancerSubtype, methodKey?: string): InstanceWrapper<any>;
51 insertExportedProvider(exportedProvider: Type<Injectable>, token: string): void;
52 insertController(controller: Type<Controller>, token: string): void;
53 private insertOrOverrideModule;
54 private getOverrideModuleByModule;
55 private overrideModule;
56 reflectMetadata<T = any>(metadataKey: string, metatype: Type<any>): T[];
57 registerCoreModule(overrides?: ModuleOverride[]): Promise<void>;
58 /**
59 * Add either request or transient globally scoped enhancers
60 * to all controllers metadata storage
61 */
62 addScopedEnhancersMetadata(): void;
63 applyApplicationProviders(): void;
64 getApplyProvidersMap(): {
65 [type: string]: Function;
66 };
67 getApplyRequestProvidersMap(): {
68 [type: string]: Function;
69 };
70 isDynamicModule(module: Type<any> | DynamicModule): module is DynamicModule;
71 /**
72 * @param metatype
73 * @returns `true` if `metatype` is annotated with the `@Injectable()` decorator.
74 */
75 private isInjectable;
76 /**
77 * @param metatype
78 * @returns `true` if `metatype` is annotated with the `@Controller()` decorator.
79 */
80 private isController;
81 /**
82 * @param metatype
83 * @returns `true` if `metatype` is annotated with the `@Catch()` decorator.
84 */
85 private isExceptionFilter;
86 private isForwardReference;
87 private isRequestOrTransient;
88}
89export {};