dino-core
Version:
A dependency injection framework for NodeJS applications
76 lines (75 loc) • 2.79 kB
TypeScript
import { type Provider } from 'nconf';
import { Injectable } from '../model/injectable';
import { Resolver } from '../model/resolver';
import { Scope } from '../model/scope';
import { type ContextConfig } from './../context/ContextConfigurationProvider';
/**
* Collection of utility functions
* @typedef Helper
* @public
*/
export declare abstract class Helper {
private static readonly supportedInjectableTypeNames;
/**
* Load the context configuration or defaults to.
* `{ injectionMode: 'proxy', contextScan: true, components: [], configurations: [] }`
* @param config the configuration path or object
* @returns the context configuration
*/
static loadConfig(config?: string | ContextConfig): ContextConfig;
/**
* Load all the source files found starting form the provided root directory.
* @param {String} dir the directly to scan for source files
* @returns {Generator<String>}
*
* @public
* @static
*/
static loadSources(dir: string): string[];
/**
* Find a source file starting from the requested directory.
* @param {String} dir the start directory for the search
* @param {String} name the name of the file source to find
*/
static findSource(dir: string, name: string): string;
/**
* Allows to retrieve a variable from the configuration or as environment variable, supports
* both `:` and `_` notation.
* @param {Environment} environment the configuration container
* @param {string} key the key for the variable to retrieve
* @param {any} _default the default value if the variable is nt defined.
*/
static getVariable(environment: Provider, key: string, _default: any): any;
static getContextRoot(config: any): string;
static isPath(_string: string): boolean;
static fileNameFromPath(_path: string): string;
/**
* Convert the required scope to Scope
* @param {String|Scope} scope the scope required for the component
* @returns {Scope}
*
* @static
* @public
*/
static asLifetime(scope: Scope | string | undefined): Scope;
/**
* Convert the required resolver to Resolver
* @param {String|Resolver} resolver the resolver required for the component
* @returns {Resolver}
*
* @static
* @public
*/
static asResolver(resolver: Resolver | string | undefined): Resolver;
static isInjectable(obj: any): boolean;
static isConfiguration(obj: Injectable): boolean;
/**
* Imports all modules declared as part of the specified path
* @param {string} path the module path
* @returns Array<Injectable>
*
* @public
* @static
*/
static dynamicallyImport(path: string): Promise<Injectable[]>;
}