UNPKG

dino-core

Version:

A dependency injection framework for NodeJS applications

95 lines (94 loc) 3.29 kB
import { type CacheContext } from './cache/cache.context'; import { Scope } from './scope'; import { StereotypeProxyHandlerFactory } from './stereotype.proxy.handler.factory'; /** * An abstract class to represent injectable resources. * * When contextScan is set to true, classes extending this class will be * automatically discovered and injected on the application context. * * @public * @abstract */ export declare abstract class Injectable { name: string; prototype: any; constructor(); /** * Define the scope for this component, by default each component will be define with * singleton scope, implementation may decide to override this method and define * a different scope * * @returns {Scope} the {@link Scope} that this component lifecycle is bound. * * @default Scope.SINGLETON * @public */ scope(): Scope; /** * Define the profile name this component should be activated for, return null for all * * @returns {String} a string representing the name this component should be activated for. * * @default null * @public */ profile(): string | null | undefined; /** * Define if this component should be lazily loaded, false by default * * @returns {Boolean} a boolean flag defining i this component should be loaded lazily, true, or not false * * @default false * @public */ lazy(): boolean; /** * Defines a list of dependencies that this component should wait before start its initialisation. * * @returns {Array<String>} and array of strings containing the names of the components to wait for, * if left empty the component will be initialised on loading order. * * @default [] * @public */ dependsOn(): string[]; /** * Indicates that the results of the invocation of methods on this class can be cached. * * The method returns a CacheContext which describes which method and how is subject to caching. * @returns {CacheContext} the context that describes the cache to create * * @default null * @public */ cacheable(): CacheContext | null | undefined; /** * A utility method that allows to control if the injectable should be registered * as part of the application context during context scan. * * This method is useful when loading of injectable is contingent on conditions or when * the injectable needs to be excluded from loading, i.e. if represent an abstract class. * * By default this method will return true which means that all Injectables are eligible * for auto-loading. * * @returns a flag indicating if this Injectable should be auto-loaded, default to true */ autoLoad(): boolean; __call(method: string, _args: any): void; /** * define the type name, i.e. Injectable, used this as a hook to load the proper handling proxy * @returns string * @private */ getTypeName(): string; /** * Extension method allows to provide a custom proxy handler factory * * @returns StereotypeProxyHandlerFactory * * @private */ protected getStereotypeProxyHandler(): StereotypeProxyHandlerFactory; }