UNPKG

3.52 kBTypeScriptView Raw
1import { Provider, Scope, Type } from '@nestjs/common';
2import { FactoryProvider } from '@nestjs/common/interfaces';
3import { InstanceToken, Module } from './module';
4export declare const INSTANCE_METADATA_SYMBOL: unique symbol;
5export declare const INSTANCE_ID_SYMBOL: unique symbol;
6export interface HostComponentInfo {
7 /**
8 * Injection token (or class reference)
9 */
10 token: InstanceToken;
11 /**
12 * Flag that indicates whether DI subtree is durable
13 */
14 isTreeDurable: boolean;
15}
16export interface ContextId {
17 readonly id: number;
18 payload?: unknown;
19 getParent?(info: HostComponentInfo): ContextId;
20}
21export interface InstancePerContext<T> {
22 instance: T;
23 isResolved?: boolean;
24 isPending?: boolean;
25 donePromise?: Promise<unknown>;
26}
27export interface PropertyMetadata {
28 key: symbol | string;
29 wrapper: InstanceWrapper;
30}
31export declare class InstanceWrapper<T = any> {
32 readonly name: any;
33 readonly token: InstanceToken;
34 readonly async?: boolean;
35 readonly host?: Module;
36 readonly isAlias: boolean;
37 scope?: Scope;
38 metatype: Type<T> | Function;
39 inject?: FactoryProvider['inject'];
40 forwardRef?: boolean;
41 durable?: boolean;
42 private static logger;
43 private readonly values;
44 private readonly [INSTANCE_METADATA_SYMBOL];
45 private readonly [INSTANCE_ID_SYMBOL];
46 private transientMap?;
47 private isTreeStatic;
48 private isTreeDurable;
49 constructor(metadata?: Partial<InstanceWrapper<T>> & Partial<InstancePerContext<T>>);
50 get id(): string;
51 set instance(value: T);
52 get instance(): T;
53 get isNotMetatype(): boolean;
54 get isTransient(): boolean;
55 getInstanceByContextId(contextId: ContextId, inquirerId?: string): InstancePerContext<T>;
56 getInstanceByInquirerId(contextId: ContextId, inquirerId: string): InstancePerContext<T>;
57 setInstanceByContextId(contextId: ContextId, value: InstancePerContext<T>, inquirerId?: string): void;
58 setInstanceByInquirerId(contextId: ContextId, inquirerId: string, value: InstancePerContext<T>): void;
59 addCtorMetadata(index: number, wrapper: InstanceWrapper): void;
60 getCtorMetadata(): InstanceWrapper[];
61 addPropertiesMetadata(key: symbol | string, wrapper: InstanceWrapper): void;
62 getPropertiesMetadata(): PropertyMetadata[];
63 addEnhancerMetadata(wrapper: InstanceWrapper): void;
64 getEnhancersMetadata(): InstanceWrapper[];
65 isDependencyTreeDurable(lookupRegistry?: string[]): boolean;
66 introspectDepsAttribute(callback: (collection: InstanceWrapper[], lookupRegistry: string[]) => boolean, lookupRegistry?: string[]): boolean;
67 isDependencyTreeStatic(lookupRegistry?: string[]): boolean;
68 cloneStaticInstance(contextId: ContextId): InstancePerContext<T>;
69 cloneTransientInstance(contextId: ContextId, inquirerId: string): InstancePerContext<T>;
70 createPrototype(contextId: ContextId): any;
71 isInRequestScope(contextId: ContextId, inquirer?: InstanceWrapper | undefined): boolean;
72 isLazyTransient(contextId: ContextId, inquirer: InstanceWrapper | undefined): boolean;
73 isExplicitlyRequested(contextId: ContextId, inquirer?: InstanceWrapper): boolean;
74 isStatic(contextId: ContextId, inquirer: InstanceWrapper | undefined): boolean;
75 getStaticTransientInstances(): InstancePerContext<T>[];
76 mergeWith(provider: Provider): void;
77 private isNewable;
78 private initialize;
79 private printIntrospectedAsRequestScoped;
80 private printIntrospectedAsDurable;
81 private isDebugMode;
82}