essential-config
Version:
Magically reads and writes config files for humans.
105 lines (102 loc) • 2.38 kB
TypeScript
/**
* @typedef {Object} Options
* @prop {Object<string, FieldDescription>} fields
* @prop {Object<string, *>} defaults
* @prop {string[]} secretKeys
*/
declare type Options = {
fields: {
[key: string]: FieldDescription;
};
defaults: {
[key: string]: any;
};
secretKeys: string[];
};
/**
* @typedef {Object<string, *>} FieldDescription
* @prop {*} defaultValue
* @prop {boolean} secret
*/
declare type FieldDescription = {
[key: string]: any;
};
/**
* @constructor
* @param {Options} options
*/
declare class _default {
constructor(options: Options);
/**
* @type {Object<string, FieldDescription>}
*/
fields: {
[key: string]: FieldDescription;
};
/**
* @return {string[]}
*/
getKeys(): string[];
/**
* @param {(field: FieldDescription, key: string) => boolean} filterFunction
* @return {string[]}
*/
getKeysBy(filterFunction: any): string[];
/**
* @return {string[]}
*/
getSecretKeys(): string[];
/**
* @return {string[]}
*/
getNonSecretKeys(): string[];
}
/** @module essential-config
*/
declare module "essential-config" {
/**
* @typedef {Object} Options
* @prop {Object<string, FieldDescription>} fields
* @prop {Object<string, *>} defaults
* @prop {string[]} secretKeys
*/
export type Options = {
fields: {
[key: string]: FieldDescription;
};
defaults: {
[key: string]: any;
};
secretKeys: string[];
};
/**
* @typedef {Object} Result
* @prop {Object<string, *>} config
* @prop {string} configFolder
* @prop {string[]} deprecatedKeys
* @prop {string[]} newKeys
* @prop {string[]} givenKeys
* @prop {ConfigPlan} configPlan
*/
export type Result = {
config: {
[key: string]: any;
};
configFolder: string;
deprecatedKeys: string[];
newKeys: string[];
givenKeys: string[];
configPlan: ConfigPlan;
};
/**
* @param {import("./ConfigPlan").Options} options
* @return {ConfigPlan}
*/
export function createConfigPlan(): ConfigPlan;
/**
* @param {string|string[]} name
* @param {Options} options
* @return {Result}
*/
export var createConfigPlan: any;
}