import { ResolveType } from './enums.js'; import { Class, Factory, InferClassOrFactory, InferTypedArray, ResolveResult, ResolveArrayResult } from './types.js'; import { EventEmitter } from './events.js'; import { TypedArray } from './array.js'; import { Registry } from './registry.js'; import { ContainerCache } from './container-cache.js'; export interface IInstanceCheck { __checkInstance__(creationOptions: any): boolean; } /** * Class info structure */ export declare class ClassInfo { /** * Full file path of loaded class */ file: string; /** * Class name */ name: string; /** * Javascript class object */ type: any; /** * Resolved instance */ instance?: T; } /** * Interface to describe DI binding behaviour */ export interface IBind { /** * `as` binding (alias) * * @param type - base class that is being registered */ as(type: Class | string): this; /** * self bind, class should be resolved by its name. Its default behaviour. */ asSelf(): this; /** * Registers as value, it wont be resolved or called, just stored as is in container * @param type - name of type / key after whitch implementation will be resolved * @param override - if true, any value registered before is overriden by new one */ asValue(type: string, override: boolean): this; asValue(type: string): this; /** * * Add plain value to container, value is stored in hashmap for quick access * eg. we have multiple value converters and we wanc o(1) access, instead searching for * converter for specific type * * @param type - name of added value * @param key - hashmap key */ asMapValue(type: string, hashKey: string): this; /** * Registers object as single instance ( singleton ) */ singleInstance(): this; } export interface ResolvableObject { [key: string]: any; } export interface IContainer extends EventEmitter { Cache: ContainerCache; Registry: Registry; Parent: IContainer | undefined; clear(): void; clearRegistry(): void; clearCache(): void; register(implementation: Class | Factory | ResolvableObject): IBind; unregister(implementation: string | Class | Factory | ResolvableObject): void; uncache(source: string | Class | TypedArray, parent?: boolean): void; child(): IContainer; get(service: TypedArray, parent?: boolean): T[] | null; get(service: string | Class, parent?: boolean): T | null; get(service: string | Class | TypedArray, parent?: boolean): T | T[] | null; getRegisteredTypes(service: string | Class | TypedArray, parent?: boolean): Array | Factory>; isResolved(service: string | Class, parent?: boolean): boolean; hasRegistered(service: Class | string | TypedArray, parent?: boolean): boolean; hasRegisteredType(source: Class | string | TypedArray, type: Class | string | TypedArray | object, parent?: boolean): boolean; resolve(type: string, options?: unknown[], check?: boolean): T; resolve(type: string, check?: boolean): T; resolve(type: Class | Factory, check?: boolean): ResolveResult; resolve(type: Class | Factory, options?: unknown[] | boolean, check?: boolean): ResolveResult; resolve(type: TypedArray, check?: boolean): ResolveArrayResult; resolve(type: TypedArray, options?: unknown[] | boolean, check?: boolean): ResolveArrayResult; resolve | Factory>(type: T, options?: unknown[] | boolean, check?: boolean): ResolveResult>; resolve>(type: T, options?: unknown[] | boolean, check?: boolean): ResolveArrayResult>; resolve | Factory>(type: T, check?: boolean): ResolveResult>; resolve>(type: T, check?: boolean): ResolveArrayResult>; resolve(type: Class | TypedArray | string, options?: unknown[] | boolean, check?: boolean): unknown; dispose(): Promise; extractDescriptor(type: Class): IInjectDescriptor; } /** * Injection description definition structure */ export interface IInjectDescriptor { inject: IToInject[]; resolver: ResolveType; } export interface IToInject { inject: Class | TypedArray; autoinject: boolean; autoinjectKey: string | symbol; /** * additional data passed to DI when resolving */ data?: any; /** * Additional options passed to resolved options */ options?: any; /** * Callback used to resolve service * name of service we want to resolve * eg. we have multiple \@injectable registered * and we want specific one * * It is specifically for use with configuration module * where services can be changed in configuration files * and allows to use @AutoinjectService() decorator */ serviceFunc?: (data: string | any[], container: IContainer) => IServiceFuncResult | IServiceFuncResult[] | undefined; mapFunc?: (x: any) => string | undefined; } export interface IMappableService { ServiceName: string; } export interface IServiceFuncResult { service: string; options?: any; } export interface IResolvedInjection { instance: unknown; autoinject: boolean; autoinjectKey: string | symbol; } /** * Interface to describe DI resolve strategies. Strategies are used do * do some work at object creation eg. initialize objects that inherits from same class * specific way but without need for factory function. * * * @see FrameworkModuleSyncService implementation */ export declare class Service { protected resolved: boolean; get Resolved(): boolean; /** * Use to dispose service, relase all resources, stop timers etc. * */ dispose(): Promise; } export declare abstract class SyncService extends Service { resolve(): void; } export declare class AsyncService extends Service { resolve(): Promise; } export declare abstract class Bootstrapper { abstract bootstrap(): Promise | void; } export interface IAutoinjectOptions { mapFunc?: (x: T) => string; options?: any; } //# sourceMappingURL=interfaces.d.ts.map