import { AsyncService, Class } from '@spinajs/di'; /** * App version struct */ export interface IFrameworkVersion { minor: number; major: number; } export interface IConfigLike { [val: string]: unknown; onConfigLoad(config: any): Promise | undefined; } export interface IConfigurationSchema { $configurationModule: string; } export interface IConfigurable { configure(this: Configuration): void; } export interface ConfigurationOptions { /** * application name, pass it when you run in application mode */ app?: string; /** * configuration base dir, where to look for application configs */ appBaseDir?: string; /** * custom cfg paths eg. to load config from non standard folders ( usefull in tests ) */ cfgCustomPaths?: string[]; /** * Should watch for changes in config files */ watchFileChanges?: boolean; } export declare abstract class Configuration extends AsyncService { /** * Root config object, contains whole app configuration */ abstract get RootConfig(): IConfigLike; /** * Current running app name */ RunApp: string; /** * Apps configuration base dir, where to look for app config */ AppBaseDir: string; /** * Get config value for given property. Returns any if value is present, default value if provided or null when empty * * @param path - path to property eg. ["system","dirs"] or "system" or "system.dirs" */ abstract get(path: string[] | string, defaultValue?: T): T; /** * Sets at given path configuration value. Use when you want to override config * loaded from files programatically * * @param path - config path * @param value - value to set */ abstract set(path: string[] | string, value: unknown): void; /** * Merge existing config value with new options instead overriding * * @param path - cfg path * @param value - value to merge */ abstract merge(path: string[] | string, value: unknown): void; /** * * Loads & merge configuration loaded from specific source. * Use it when you want load configuration not at startup * eg. becouse it depends on other module, or some runtime action * * When there is need for load configuration from source at startup, * simply decorate ConfigurationSource class with 'Autoinject' decorator. * it will be registered in container and configuration module will resolve and * load it automatically * * @param source - configuration source to load from */ abstract mergeSource(source: Class): Promise; /** * loads configuration from all avaible sources */ abstract load(): Promise; /** * * Called after configuration reload. * Use it to merge custom configuration in custom configuration module. * Usefull when writting tests * */ protected abstract onLoad(): unknown; } export declare abstract class ConfigurationSource { /** * Order of cfg sources loading. * Some sources need to be loaded before others eg. load db configuration * from json, then load config from database using credentials * from loaded file */ abstract get Order(): number; abstract Load(configuration: Configuration): Promise; } export interface IConfigEntryOptions { defaultValue?: unknown; required?: boolean; } /** * wrapper for lazy load config vars from protocols * it allow to calculate vars only when needed / all modules are resolved */ export declare class ConfigVar { protected lazyVal: () => any; protected cache: any; constructor(lazyVal: () => any); get(): any; } export declare abstract class ConfigVarProtocol extends AsyncService { /** * Protocol to handle eg. aws:// or db:// */ abstract get Protocol(): string; /** * * * * @param path var path to load eg. secretmanager:someval * @param configuration - acces to whole configuration object ( sometimes we need to use other config vars to access it) */ abstract getVar(path: string, configuration: any): Promise; } //# sourceMappingURL=definitions.d.ts.map