UNPKG

2.79 kBTypeScriptView Raw
1import { Provider, Scope, Type } from '@nestjs/common';
2import { InstanceToken, Module } from './module';
3export declare const INSTANCE_METADATA_SYMBOL: unique symbol;
4export declare const INSTANCE_ID_SYMBOL: unique symbol;
5export interface ContextId {
6 readonly id: number;
7}
8export interface InstancePerContext<T> {
9 instance: T;
10 isResolved?: boolean;
11 isPending?: boolean;
12 donePromise?: Promise<void>;
13}
14export interface PropertyMetadata {
15 key: string;
16 wrapper: InstanceWrapper;
17}
18export declare class InstanceWrapper<T = any> {
19 readonly name: any;
20 readonly token: InstanceToken;
21 readonly async?: boolean;
22 readonly host?: Module;
23 readonly isAlias: boolean;
24 scope?: Scope;
25 metatype: Type<T> | Function;
26 inject?: (string | symbol | Function | Type<any>)[];
27 forwardRef?: boolean;
28 private readonly values;
29 private readonly [INSTANCE_METADATA_SYMBOL];
30 private readonly [INSTANCE_ID_SYMBOL];
31 private transientMap?;
32 private isTreeStatic;
33 constructor(metadata?: Partial<InstanceWrapper<T>> & Partial<InstancePerContext<T>>);
34 get id(): string;
35 set instance(value: T);
36 get instance(): T;
37 get isNotMetatype(): boolean;
38 get isTransient(): boolean;
39 getInstanceByContextId(contextId: ContextId, inquirerId?: string): InstancePerContext<T>;
40 getInstanceByInquirerId(contextId: ContextId, inquirerId: string): InstancePerContext<T>;
41 setInstanceByContextId(contextId: ContextId, value: InstancePerContext<T>, inquirerId?: string): void;
42 setInstanceByInquirerId(contextId: ContextId, inquirerId: string, value: InstancePerContext<T>): void;
43 addCtorMetadata(index: number, wrapper: InstanceWrapper): void;
44 getCtorMetadata(): InstanceWrapper[];
45 addPropertiesMetadata(key: string, wrapper: InstanceWrapper): void;
46 getPropertiesMetadata(): PropertyMetadata[];
47 addEnhancerMetadata(wrapper: InstanceWrapper): void;
48 getEnhancersMetadata(): InstanceWrapper[];
49 isDependencyTreeStatic(lookupRegistry?: string[]): boolean;
50 cloneStaticInstance(contextId: ContextId): InstancePerContext<T>;
51 cloneTransientInstance(contextId: ContextId, inquirerId: string): InstancePerContext<T>;
52 createPrototype(contextId: ContextId): any;
53 isInRequestScope(contextId: ContextId, inquirer?: InstanceWrapper | undefined): boolean;
54 isLazyTransient(contextId: ContextId, inquirer: InstanceWrapper | undefined): boolean;
55 isExplicitlyRequested(contextId: ContextId, inquirer?: InstanceWrapper): boolean;
56 isStatic(contextId: ContextId, inquirer: InstanceWrapper | undefined): boolean;
57 getStaticTransientInstances(): InstancePerContext<T>[];
58 mergeWith(provider: Provider): void;
59 private isNewable;
60 private isWrapperListStatic;
61 private initialize;
62}