UNPKG

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