UNPKG

@tsclean/core

Version:

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

81 lines 4.02 kB
import { ContainerIoC } from './container'; import { Injector } from './injector'; import { InstanceLinksHost } from './instance-links-host'; import { ContextId } from './instance-wrapper'; import { Module } from './module'; import { Type } from '../../contracts'; import { AbstractInstanceResolver } from './abstract-instance-resolver'; import { IntrospectionResult } from '../../contracts/introspection-result'; export interface ModuleRefGetOrResolveOpts { strict?: boolean; each?: boolean; } export declare abstract class ModuleRef extends AbstractInstanceResolver { protected readonly container: ContainerIoC; protected readonly injector: Injector; private _instanceLinksHost; protected get instanceLinksHost(): InstanceLinksHost; constructor(container: ContainerIoC); abstract get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | string | symbol, options?: { strict: boolean; }): TResult; abstract get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options: { /** * If enabled, lookup will only be performed in the host module. * @default true */ strict?: boolean; /** This indicates that only the first instance registered will be returned. */ each?: undefined | false; }): TResult; abstract get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options: { /** * If enabled, lookup will only be performed in the host module. * @default true */ strict?: boolean; /** This indicates that a list of instances will be returned. */ each: true; }): Array<TResult>; abstract get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options?: ModuleRefGetOrResolveOpts): TResult | Array<TResult>; abstract resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol): Promise<TResult>; /** * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception. * @returns {Array<TResult>} */ abstract resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: { id: number; }): Promise<TResult>; /** * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception. * @returns {Array<TResult>} */ abstract resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: { id: number; }, options?: { strict?: boolean; each?: undefined | false; }): Promise<TResult>; /** * Resolves transient or request-scoped instances of either injectables or controllers, otherwise, throws exception. * @returns {Array<TResult>} */ abstract resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: { id: number; }, options?: { strict?: boolean; each: true; }): Promise<Array<TResult>>; /** * Resolves transient or request-scoped instance (or a list of instances) of either injectable or controller, otherwise, throws exception. * @returns {Promise<TResult | Array<TResult>>} */ abstract resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: { id: number; }, options?: ModuleRefGetOrResolveOpts): Promise<TResult | Array<TResult>>; abstract create<T = any>(type: Type<T>, contextId?: ContextId): Promise<T>; introspect<T = any>(token: Type<T> | string | symbol): IntrospectionResult; registerRequestByContextId<T = any>(request: T, contextId: ContextId): void; protected instantiateClass<T = any>(type: Type<T>, moduleRef: Module, contextId?: ContextId): Promise<T>; } //# sourceMappingURL=module-ref.d.ts.map