UNPKG

@tsclean/core

Version:

Plugin for API Rest Full development, based on Clean Architecture, IoC and Dependency Injection.

61 lines 5.29 kB
import { ContextId, InstancePerContext, InstanceWrapper, PropertyMetadata } from './instance-wrapper'; import { Module } from './module'; import { Type } from '../../contracts'; import { ControllerType, InjectableType, InstanceTokenType } from '../../types'; export type InjectorDependency = Type<any> | Function | string | symbol; export interface PropertyDependency { key: string; name: InjectorDependency; isOptional?: boolean; instance?: any; } export interface InjectorDependencyContext { key?: string | symbol; name?: Function | string | symbol; index?: number; dependencies?: InjectorDependency[]; } export declare class Injector { private readonly options?; private logger; constructor(options?: { preview: boolean; }); loadPrototype<T>({ token }: InstanceWrapper<T>, collection: Map<InstanceTokenType, InstanceWrapper<T>>, contextId?: ContextId): void; loadInstance<T>(wrapper: InstanceWrapper<T>, collection: Map<InstanceTokenType, InstanceWrapper>, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<void>; loadMiddleware(wrapper: InstanceWrapper, collection: Map<InstanceTokenType, InstanceWrapper>, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<void>; loadController(wrapper: InstanceWrapper<ControllerType>, moduleRef: Module, contextId?: ContextId): Promise<void>; loadInjectable<T = any>(wrapper: InstanceWrapper<T>, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<void>; loadProvider(wrapper: InstanceWrapper<InjectableType>, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<void>; applyDoneHook<T>(wrapper: InstancePerContext<T>): () => void; resolveConstructorParams<T>(wrapper: InstanceWrapper<T>, moduleRef: Module, inject: InjectorDependency[], callback: (args: unknown[]) => void | Promise<void>, contextId?: ContextId, inquirer?: InstanceWrapper, parentInquirer?: InstanceWrapper): Promise<void>; reflectConstructorParams<T>(type: Type<T>): any[]; reflectOptionalParams<T>(type: Type<T>): any[]; reflectSelfParams<T>(type: Type<T>): any[]; resolveSingleParam<T>(wrapper: InstanceWrapper<T>, param: Type<any> | string | symbol | any, dependencyContext: InjectorDependencyContext, moduleRef: Module, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number): Promise<InstanceWrapper<any>>; resolveParamToken<T>(wrapper: InstanceWrapper<T>, param: Type<any> | string | symbol | any): any; resolveComponentInstance<T>(moduleRef: Module, token: InstanceTokenType, dependencyContext: InjectorDependencyContext, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number): Promise<InstanceWrapper>; resolveComponentHost<T>(moduleRef: Module, instanceWrapper: InstanceWrapper<T | Promise<T>>, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<InstanceWrapper>; lookupComponent<T = any>(providers: Map<Function | string | symbol, InstanceWrapper>, moduleRef: Module, dependencyContext: InjectorDependencyContext, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number): Promise<InstanceWrapper<T>>; lookupComponentInParentModules<T = any>(dependencyContext: InjectorDependencyContext, moduleRef: Module, wrapper: InstanceWrapper<T>, contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number): Promise<any>; lookupComponentInImports(moduleRef: Module, name: InstanceTokenType, wrapper: InstanceWrapper, moduleRegistry?: any[], contextId?: ContextId, inquirer?: InstanceWrapper, keyOrIndex?: string | number, isTraversing?: boolean): Promise<any>; resolveProperties<T>(wrapper: InstanceWrapper<T>, moduleRef: Module, inject?: InjectorDependency[], contextId?: ContextId, inquirer?: InstanceWrapper, parentInquirer?: InstanceWrapper): Promise<PropertyDependency[]>; reflectProperties<T>(type: Type<T>): PropertyDependency[]; applyProperties<T = any>(instance: T, properties: PropertyDependency[]): void; instantiateClass<T = any>(instances: any[], wrapper: InstanceWrapper, targetMetatype: InstanceWrapper, contextId?: ContextId, inquirer?: InstanceWrapper): Promise<T>; loadPerContext<T = any>(instance: T, moduleRef: Module, collection: Map<InstanceTokenType, InstanceWrapper>, ctx: ContextId, wrapper?: InstanceWrapper): Promise<T>; loadEnhancersPerContext(wrapper: InstanceWrapper, ctx: ContextId, inquirer?: InstanceWrapper): Promise<void>; loadCtorMetadata(metadata: InstanceWrapper<any>[], contextId: ContextId, inquirer?: InstanceWrapper, parentInquirer?: InstanceWrapper): Promise<any[]>; loadPropertiesMetadata(metadata: PropertyMetadata[], contextId: ContextId, inquirer?: InstanceWrapper): Promise<PropertyDependency[]>; private static getInquirerId; private resolveScopedComponentHost; private static isInquirerRequest; private static isInquirer; private static addDependencyMetadata; private static getTokenName; private printResolvingDependenciesLog; private printLookingForProviderLog; private printFoundInModuleLog; private static isDebugMode; } //# sourceMappingURL=injector.d.ts.map