import { Config } from 'convict'; import { CONFIG_FILE_UPDATED, NEW_CONFIG_VALUE_SET } from '@refinitiv-data/types'; import { BaseConfig } from './base-config'; /** * This class provides all the functionality to work with configuration files * within the project (TS library) * * Configuration levels: * 1. Default - hardcoded values in the config-schema.ts file. * (to make it possible come back to default configuration after config files changing and re-read them). * Can be overridden by the higher levels (2, 3 ...) * 2. User's Home directory level. For Unix - $HOME, Windows - %HOMEPATH%. Can be overridden by the higher levels (3, ...) * 3. Project Working Directory level - process.cwd(). Can be overridden by higher levels (env, args) * 4. Environment variables can't be overridden by config files, but can with the process arguments (node index.js --loglevel value) * 5. Process arguments can't be overridden. But you still can manipulate them programmatically in your code. * How to set up env variables and process arguments see 'convict npm => readme.md' * Default config is saved to config-schema.ts */ export declare class LibraryConfig extends BaseConfig { private get isBrowser(); /** * An array of paths to all the configuration files which are being monitoring */ private watchedFiles; constructor(schema: T); /** * Returns default event name. Is used as event name to notify that config * has been changed */ get CONFIG_FILE_UPDATED(): typeof CONFIG_FILE_UPDATED; /** * Event name for event when method set() is used to change a config */ get CONFIG_SET(): typeof NEW_CONFIG_VALUE_SET; set(name: K, value: K extends keyof T ? T[K] : any): Config; set(name: K, value: K2 extends keyof T[K] ? T[K][K2] : any): Config; set(name: K, value: K3 extends keyof T[K][K2] ? T[K][K2][K3] : any): Config; set(name: K, value: K4 extends keyof T[K][K2][K3] ? T[K][K2][K3][K4] : any): Config; /** * Returns path of configuration files to be monitored for changes * If the file does not exist - the path to the file will still be present in this list * The file with the higher index in the array has higher priority */ getConfigFilesPath(): string[]; /** * EventEmitter event to notify observes that any config file has been changed * @param {string} event Name of event to be emitted once any config file has been changed. Default - 'update'. * @param {ConfigSchema} data Configuration object. Default - full configuration object after merging all the config files. * @param {string} source Source of the configuration which has been changed (file path of 'default-config') */ notifyConfigUpdated(event?: string, data?: Partial, source?: string): boolean; /** * Watch for changes in the files and re-read config files on any changes (delete/add/change a file) */ watch(): void; /** * Remove configuration file watchers */ unwatch(): void; /** * Method to be used by developers to extend/override default library config to new defaults * @param configExtend Object to extend default configuration */ extendDefault(configExtend: { [key: string]: any; }): void; /** * Read and merge all the configuration files with appropriate priorities */ private init; /** * Default watcher for changes in config files * @param {Stats} current Current Stats of a watched file * @param {Stats} prev Previous Stats of a watched file * @param {string} source Source of the configuration which has been changed (file path of 'default-config') */ private configFileChangedHandler; }