UNPKG

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