import { IAutoinjectOptions, IInjectDescriptor } from './interfaces.js'; import { Class } from './types.js'; import { TypedArray } from './array.js'; export declare const DI_DESCRIPTION_SYMBOL = "__DI_INJECTION_DESCRIPTOR__"; export declare function AddDependencyForProperty(callback?: (descriptor: IInjectDescriptor, target: Class, propertyKey: string | symbol, indexOrDescriptor: number | PropertyDescriptor) => void): any; export declare function AddDependency(callback?: (descriptor: IInjectDescriptor, target: Class, propertyKey: string | symbol, indexOrDescriptor: number | PropertyDescriptor) => void): any; /** * * Class with this decorator is automatically registered in DI container an can be resolved. * NOTE: we dont need to register class before resolving. Injectable decorator is mainly used in extensions & plugins * to register implementation that can be resolved by framework or other parts without knowing about specific implementations eg. * avaible database drivers. * * @param as - register class in DI container as something else. * * @example * ```typescript * * @Injectable(OrmDriver) * class MysqlOrmDriver{ * * // implementation ... * } * * * // somewhere else in code * const avaibleDrivers = DI.resolve(Array.of(OrmDriver)); * * * ``` * */ export declare function Injectable(as?: Class | string): (target: Class) => void; /** * Sets dependency injection guidelines - what to inject for specified class. If multiple instances are registered at specified type, * only first one is resolved and injected * @param args - what to inject - class definitions * @example * ```javascript * * @Inject(Bar) * class Foo{ * * @Inject(Bar) * barInstance : Bar; * * constructor(bar : Bar){ * // bar is injected when Foo is created via DI container * this.barInstance = bar; * } * * someFunc(){ * * this._barInstance.doSmth(); * } * } * * ``` */ export declare function Inject(...args: (Class | TypedArray)[]): any; /** * Automatically injects dependency based on reflected property type. Uses experimental typescript reflection api * If decorator is applied to array property all registered type instances are injected, otherwise only first / only that exists * * @param injectType - when injecting array of some type, type must be explicitly provided. Typescript reflection cant reflect declared array types * @param mapFunc - when injecting array we sometimes need services mapped by some kind of key, so later we dont need to search o(n) elements for specific service, but reference by key/name * @example * ```javascript * class Foo{ * * @Autoinject * barInstance : Bar; * * constructor(){ * // .... * } * * someFunc(){ * * // automatically injected dependency is avaible now * this.barInstance.doSmth(); * } * } * * ``` */ export declare function Autoinject(typeOrOptions?: Class | IAutoinjectOptions, options?: IAutoinjectOptions): any; /** * Lazy injects service to object. Use only with class properties * * @param service - class or name of service to inject * * @example * ```javascript * * class Foo{ * ... * * @LazyInject(Bar) * _barInstance : Bar; // _barInstance is not yet resolved * * someFunc(){ * // barInstance is resolved only when first accessed * this._barInstance.doSmth(); * } * } * * ``` */ export declare function LazyInject(service?: Class | string): (target: any, key: string) => void; /** * Per child instance injection decorator - object is resolved once per container - child containers have own instances. */ export declare function PerChildInstance(): any; /** * NewInstance injection decorator - every time class is injected - its created from scratch */ export declare function NewInstance(): any; /** * If we have multiple registered types at one base type * we can resolve only one by default. Per instance means, that * we can resolve all types registered at base type once. Limitaiton is * that, you should call resolve not on base type, but on target type. * * In comparison, Singleton flag means that only one instance can be resolved * for base class */ export declare function PerInstance(): any; /** * * Before resolve, check function on all resolved instances of given type is called with creation options * It is used for ensuring that for eg. only one instance of service with provided * options is resolved, but allow to create with other option set * * @returns */ export declare function PerInstanceCheck(): any; /** * Singleton injection decorator - every time class is resolved - its created only once globally ( even in child DI containers ) */ export declare function Singleton(): any; //# sourceMappingURL=decorators.d.ts.map