dino-core
Version:
A dependency injection framework for NodeJS applications
74 lines (73 loc) • 2.85 kB
TypeScript
import { type InjectionModeType } from 'awilix';
import { ComponentDescriptor } from '../model/ComponentDescriptor';
/**
* The provider of the application context configuration.
* Configuration must have the following yaml format:
* injectionMode: transient
* components:
* - name: (mandatory) the name of the component, will act as a reference for injection
* - source: (mandatory) the source file of the component class relative to the root of the project or a module name
* - scope: (optional) the resolution scope for the component, defaults to singleton
* - resolver: (optional) the resolver to use available are class, value, function; if omitted class resolver wil be used
* @typedef {ContextConfigurationProvider}
* @public
* @since 0.2.2
*/
export declare class ContextConfigurationProvider {
private readonly activeProfiles;
private readonly contextRoots;
private readonly conf;
private readonly selectedComponentNames;
/**
* Constructor for ConfigurationProvider
* @param {Any} conf the application context configuration
* @param {array} activeProfiles the profiles that are considered active for the current run
*
* @private
*/
constructor(conf: any, activeProfiles?: string[]);
getContextRoots(): string[];
/**
* Provide the mode the injection will be performed, if mode is not defined "proxy" will be used.
* Supported injection mode are:
* - CLASSIC
* - PROXY
*
* @returns {awilix.InjectionMode} the injection mode
* @public
*/
mode(): InjectionModeType;
/**
* Normalize the source path
* @param {String} source the configured source location
*
* @private
*/
normalizePath(source: string): string;
/**
* Create a new instance of ConfigurationProvider
* @param {String} path the path of the configuration relative to the root of the project,
* if not provided a scan will be performed to collect all entities defined.
* @param {array} activeProfiles the profiles that are considered active for the current run
* @returns {ContextConfigurationProvider}
*
* @public
* @static
*/
static create(path?: string, activeProfiles?: string[]): ContextConfigurationProvider;
/**
* Create the component descriptors based on the provided configuration or context
*
* @returns {Promise<Array<ComponentDescriptor>>} a promise resolved with an array of component descriptors
* @public
*/
createComponentDescriptors(): Promise<ComponentDescriptor[]>;
private doBuildComponentDescriptorFromSource;
/**
*
* @param {String} name the name of the component to validate
* @private
*/
private throwExceptionIfComponentNameIsNotProvidedOrNotAvailable;
private profileIsActive;
}