1 | import { ConfigPaths, ConfigPathValues, HasBeenAugmented } from "./utils";
|
2 |
|
3 | declare var c: c.IConfig;
|
4 |
|
5 | declare namespace c {
|
6 | // see https://github.com/lorenwest/node-config/wiki/Using-Config-Utilities
|
7 | interface IUtil {
|
8 | // Extend an object (and any object it contains) with one or more objects (and objects contained in them).
|
9 | extendDeep(mergeInto: any, mergeFrom: any, depth?: number): any;
|
10 | extendDeep(mergeInto: any, mergeFrom1: any, mergeFrom2: any, depth?: number): any;
|
11 | extendDeep(mergeInto: any, ...mergeFrom: any): any;
|
12 |
|
13 | // Return a deep copy of the specified object.
|
14 | cloneDeep(copyFrom: any, depth?: number): any;
|
15 |
|
16 | // Set objects given a path as a string list
|
17 | setPath(object: object, path: string[], value?: any): void;
|
18 |
|
19 | // Return true if two objects have equal contents.
|
20 | equalsDeep(object1: any, object2: any, dept?: number): boolean;
|
21 |
|
22 | // Returns an object containing all elements that differ between two objects.
|
23 | diffDeep(object1: any, object2: any, depth?: number): any;
|
24 |
|
25 | // Make a javascript object property immutable (assuring it cannot be changed from the current value).
|
26 | makeImmutable(object: any, propertyName?: string, propertyValue?: string): any;
|
27 |
|
28 | // Make an object property hidden so it doesn't appear when enumerating elements of the object.
|
29 | makeHidden(object: any, propertyName: string, propertyValue?: string): any;
|
30 |
|
31 | // Get the current value of a config environment variable
|
32 | getEnv(varName: string): string;
|
33 |
|
34 | // Return the config for the project based on directory param if not directory then return default one (config).
|
35 | loadFileConfigs(configDir?: string): any;
|
36 |
|
37 | // Return the sources for the configurations
|
38 | getConfigSources(): IConfigSource[];
|
39 |
|
40 | // Returns a new deep copy of the current config object, or any part of the config if provided.
|
41 | toObject(config?: any): any;
|
42 |
|
43 | /**
|
44 | * This allows module developers to attach their configurations onto the default configuration object
|
45 | * so they can be configured by the consumers of the module.
|
46 | */
|
47 | setModuleDefaults(moduleName: string, defaults: any): any;
|
48 | }
|
49 |
|
50 | /**
|
51 | * By augmenting this interface with your own config, you can greatly improve the IntelliSense for the `get` method:
|
52 | * - Dot notation paths for the `setting` parameter
|
53 | * - Correctly typed return values
|
54 | *
|
55 | * @example
|
56 | * declare module 'config' {
|
57 | * interface IConfig extends MyConfig {}
|
58 | * }
|
59 | *
|
60 | * @example
|
61 | * declare module 'config' {
|
62 | * interface IConfig {
|
63 | * myConfig: {
|
64 | * myString: string;
|
65 | * myNumber: number;
|
66 | * };
|
67 | * }
|
68 | * }
|
69 | *
|
70 | * @example
|
71 | * const knownToBeStringTyped = config.get('myConfig.myString');
|
72 | */
|
73 | interface IConfig {
|
74 | get: HasBeenAugmented<IConfig> extends true
|
75 | ? <T extends ConfigPaths<IConfig>>(setting: T) => ConfigPathValues<IConfig, T>
|
76 | : <T>(setting: string) => T;
|
77 | has(setting: ConfigPaths<IConfig>): boolean;
|
78 | has(setting: string): boolean;
|
79 | util: IUtil;
|
80 | }
|
81 |
|
82 | interface IConfigSource {
|
83 | name: string;
|
84 | original?: string | undefined;
|
85 | parsed: any;
|
86 | }
|
87 | }
|
88 |
|
89 | export = c;
|