1 | import { ConfigChangeEvent } from './interfaces/config-change-event.interface';
|
2 | import { NoInferType, Path, PathValue } from './types';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | type ValidatedResult<WasValidated extends boolean, T> = WasValidated extends true ? T : T | undefined;
|
10 |
|
11 |
|
12 |
|
13 | export interface ConfigGetOptions {
|
14 | |
15 |
|
16 |
|
17 |
|
18 |
|
19 | infer: true;
|
20 | }
|
21 | type KeyOf<T> = keyof T extends never ? string : keyof T;
|
22 |
|
23 |
|
24 |
|
25 | export declare class ConfigService<K = Record<string, unknown>, WasValidated extends boolean = false> {
|
26 | private readonly internalConfig;
|
27 | private set isCacheEnabled(value);
|
28 | private get isCacheEnabled();
|
29 | private readonly cache;
|
30 | private readonly _changes$;
|
31 | private _isCacheEnabled;
|
32 | private envFilePaths;
|
33 | constructor(internalConfig?: Record<string, any>);
|
34 | /**
|
35 | * Returns a stream of configuration changes.
|
36 | * Each event contains the attribute path, the old value and the new value.
|
37 | */
|
38 | get changes$(): import("rxjs").Observable<ConfigChangeEvent<any, any>>;
|
39 | /**
|
40 | * Get a configuration value (either custom configuration or process environment variable)
|
41 | * based on property path (you can use dot notation to traverse nested object, e.g. "database.host").
|
42 | * @param propertyPath
|
43 | */
|
44 | get<T = any>(propertyPath: KeyOf<K>): ValidatedResult<WasValidated, T>;
|
45 | /**
|
46 | * Get a configuration value (either custom configuration or process environment variable)
|
47 | * based on property path (you can use dot notation to traverse nested object, e.g. "database.host").
|
48 | * @param propertyPath
|
49 | * @param options
|
50 | */
|
51 | get<T = K, P extends Path<T> = any, R = PathValue<T, P>>(propertyPath: P, options: ConfigGetOptions): ValidatedResult<WasValidated, R>;
|
52 | /**
|
53 | * Get a configuration value (either custom configuration or process environment variable)
|
54 | * based on property path (you can use dot notation to traverse nested object, e.g. "database.host").
|
55 | * It returns a default value if the key does not exist.
|
56 | * @param propertyPath
|
57 | * @param defaultValue
|
58 | */
|
59 | get<T = any>(propertyPath: KeyOf<K>, defaultValue: NoInferType<T>): T;
|
60 | /**
|
61 | * Get a configuration value (either custom configuration or process environment variable)
|
62 | * based on property path (you can use dot notation to traverse nested object, e.g. "database.host").
|
63 | * It returns a default value if the key does not exist.
|
64 | * @param propertyPath
|
65 | * @param defaultValue
|
66 | * @param options
|
67 | */
|
68 | get<T = K, P extends Path<T> = any, R = PathValue<T, P>>(propertyPath: P, defaultValue: NoInferType<R>, options: ConfigGetOptions): Exclude<R, undefined>;
|
69 | /**
|
70 | * Get a configuration value (either custom configuration or process environment variable)
|
71 | * based on property path (you can use dot notation to traverse nested object, e.g. "database.host").
|
72 | * @param propertyPath
|
73 | */
|
74 | getOrThrow<T = any>(propertyPath: KeyOf<K>): Exclude<T, undefined>;
|
75 | /**
|
76 | * Get a configuration value (either custom configuration or process environment variable)
|
77 | * based on property path (you can use dot notation to traverse nested object, e.g. "database.host").
|
78 | * @param propertyPath
|
79 | * @param options
|
80 | */
|
81 | getOrThrow<T = K, P extends Path<T> = any, R = PathValue<T, P>>(propertyPath: P, options: ConfigGetOptions): Exclude<R, undefined>;
|
82 | /**
|
83 | * Get a configuration value (either custom configuration or process environment variable)
|
84 | * based on property path (you can use dot notation to traverse nested object, e.g. "database.host").
|
85 | * It returns a default value if the key does not exist.
|
86 | * If the default value is undefined an exception will be thrown.
|
87 | * @param propertyPath
|
88 | * @param defaultValue
|
89 | */
|
90 | getOrThrow<T = any>(propertyPath: KeyOf<K>, defaultValue: NoInferType<T>): Exclude<T, undefined>;
|
91 | /**
|
92 | * Get a configuration value (either custom configuration or process environment variable)
|
93 | * based on property path (you can use dot notation to traverse nested object, e.g. "database.host").
|
94 | * It returns a default value if the key does not exist.
|
95 | * If the default value is undefined an exception will be thrown.
|
96 | * @param propertyPath
|
97 | * @param defaultValue
|
98 | * @param options
|
99 | */
|
100 | getOrThrow<T = K, P extends Path<T> = any, R = PathValue<T, P>>(propertyPath: P, defaultValue: NoInferType<R>, options: ConfigGetOptions): Exclude<R, undefined>;
|
101 | /**
|
102 | * Sets a configuration value based on property path.
|
103 | * @param propertyPath
|
104 | * @param value
|
105 | */
|
106 | set<T = any>(propertyPath: KeyOf<K>, value: T): void;
|
107 | /**
|
108 | * Sets env file paths from `config.module.ts` to parse.
|
109 | * @param paths
|
110 | */
|
111 | setEnvFilePaths(paths: string[]): void;
|
112 | private getFromCache;
|
113 | private getFromValidatedEnv;
|
114 | private getFromProcessEnv;
|
115 | private getFromInternalConfig;
|
116 | private setInCacheIfDefined;
|
117 | private isGetOptionsObject;
|
118 | private updateInterpolatedEnv;
|
119 | }
|
120 | export {};
|