@creditkarma/dynamic-config
Version:
Dynamic Config for Node.js backed by Consul and Vault
63 lines (62 loc) • 2.61 kB
TypeScript
import { IConfigOptions, IDynamicConfig, ISource, IVariable, ObjectType } from './types';
export declare class DynamicConfig implements IDynamicConfig {
private configLoader;
private remoteOptions;
private promisedConfig;
private initializedResolvers;
private resolvers;
private resolversByName;
private translator;
private schemas;
private errorMap;
/**
* The observerMap is a cache of the Observer for a specified key. There is no need to create
* more than one Observer for a given key.
*/
private observerMap;
constructor({ configPath, configEnv, remoteOptions, resolvers, loaders, translators, schemas, }?: IConfigOptions);
/**
* Gets a given key from the config. There are not guarantees that the config is already
* loaded, so we must return a Promise.
*
* @param key The key to look up. Dot notation may be used to access nested properties.
*/
get<T = any>(key?: string): Promise<T>;
watch<T>(key: string): IVariable<T>;
/**
* Get n number of keys from the config and return a Promise of an Array of those values.
*/
getAll(...args: Array<string>): Promise<Array<any>>;
/**
* Looks up a key in the config. If the key cannot be found the default is returned.
*
* @param key The key to look up. Dot notation may be used to access nested properties.
* @param defaultVal The value to return if the get fails.
*/
getWithDefault<T = any>(key: string, defaultVal: T): Promise<T>;
getRemoteValue<T>(key: string, type?: ObjectType): Promise<T>;
getSecretValue<T>(key: string, type?: ObjectType): Promise<T>;
source(key: string): Promise<ISource>;
private buildDefaultForPlaceholder;
private getRemotePlaceholder;
/**
* I personally think this is gross, a function that exists only to mutate one
* of its arguments. Shh, it's a private function. We'll keep it a secret.
*/
private appendUpdatesForObject;
private collectConfigPlaceholders;
/**
* When a config value is requested there is a chance that the value currently in the
* resolved config is a placeholder, or, in the more complex case, the requested value
* is an object that contains placeholders within nested keys. We need to find and resolve
* any placeholders that remain in the config
*/
private replaceConfigPlaceholders;
private loadConfigs;
private setConfig;
private getConfig;
private initializeResolvers;
private getValueFromResolver;
private getResolverForValue;
private register;
}