UNPKG

4.18 kBTypeScriptView Raw
1import { IntrospectionResult, Type } from '@nestjs/common';
2import { GetOrResolveOptions } from '@nestjs/common/interfaces';
3import { AbstractInstanceResolver } from './abstract-instance-resolver';
4import { NestContainer } from './container';
5import { Injector } from './injector';
6import { InstanceLinksHost } from './instance-links-host';
7import { ContextId } from './instance-wrapper';
8import { Module } from './module';
9export declare abstract class ModuleRef extends AbstractInstanceResolver {
10 protected readonly container: NestContainer;
11 protected readonly injector: Injector;
12 private _instanceLinksHost;
13 protected get instanceLinksHost(): InstanceLinksHost;
14 constructor(container: NestContainer);
15 /**
16 * Retrieves an instance of either injectable or controller, otherwise, throws exception.
17 * @returns {TResult}
18 */
19 abstract get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol): TResult;
20 /**
21 * Retrieves an instance of either injectable or controller, otherwise, throws exception.
22 * @returns {TResult}
23 */
24 abstract get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options: {
25 strict?: boolean;
26 each?: undefined | false;
27 }): TResult;
28 /**
29 * Retrieves a list of instances of either injectables or controllers, otherwise, throws exception.
30 * @returns {Array<TResult>}
31 */
32 abstract get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options: {
33 strict?: boolean;
34 each: true;
35 }): Array<TResult>;
36 /**
37 * Retrieves an instance (or a list of instances) of either injectable or controller, otherwise, throws exception.
38 * @returns {TResult | Array<TResult>}
39 */
40 abstract get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, options?: GetOrResolveOptions): TResult | Array<TResult>;
41 /**
42 * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
43 * @returns {Array<TResult>}
44 */
45 abstract resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol): Promise<TResult>;
46 /**
47 * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
48 * @returns {Array<TResult>}
49 */
50 abstract resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
51 id: number;
52 }): Promise<TResult>;
53 /**
54 * Resolves transient or request-scoped instance of either injectable or controller, otherwise, throws exception.
55 * @returns {Array<TResult>}
56 */
57 abstract resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
58 id: number;
59 }, options?: {
60 strict?: boolean;
61 each?: undefined | false;
62 }): Promise<TResult>;
63 /**
64 * Resolves transient or request-scoped instances of either injectables or controllers, otherwise, throws exception.
65 * @returns {Array<TResult>}
66 */
67 abstract resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
68 id: number;
69 }, options?: {
70 strict?: boolean;
71 each: true;
72 }): Promise<Array<TResult>>;
73 /**
74 * Resolves transient or request-scoped instance (or a list of instances) of either injectable or controller, otherwise, throws exception.
75 * @returns {Promise<TResult | Array<TResult>>}
76 */
77 abstract resolve<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Function | string | symbol, contextId?: {
78 id: number;
79 }, options?: GetOrResolveOptions): Promise<TResult | Array<TResult>>;
80 abstract create<T = any>(type: Type<T>): Promise<T>;
81 introspect<T = any>(token: Type<T> | string | symbol): IntrospectionResult;
82 registerRequestByContextId<T = any>(request: T, contextId: ContextId): void;
83 protected instantiateClass<T = any>(type: Type<T>, moduleRef: Module): Promise<T>;
84}