UNPKG

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