nestjs-config-extended 2.0.0-next.1 → 2.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +25 -6
  2. package/dist/exceptions/extended-config-exception.d.ts +9 -0
  3. package/dist/exceptions/extended-config-exception.js +21 -0
  4. package/dist/exceptions/index.d.ts +1 -0
  5. package/dist/exceptions/index.js +1 -0
  6. package/dist/exceptions/invalid-loader-exception.d.ts +2 -1
  7. package/dist/exceptions/invalid-loader-exception.js +3 -2
  8. package/dist/exceptions/invalid-reload-interval-exception.d.ts +2 -1
  9. package/dist/exceptions/invalid-reload-interval-exception.js +3 -3
  10. package/dist/exceptions/invalid-schedule-exception.d.ts +2 -1
  11. package/dist/exceptions/invalid-schedule-exception.js +3 -2
  12. package/dist/exceptions/invalid-transformer-exception.d.ts +2 -1
  13. package/dist/exceptions/invalid-transformer-exception.js +3 -2
  14. package/dist/exceptions/invalid-validator-exception.d.ts +2 -1
  15. package/dist/exceptions/invalid-validator-exception.js +3 -2
  16. package/dist/exceptions/loading-exception.d.ts +2 -1
  17. package/dist/exceptions/loading-exception.js +3 -2
  18. package/dist/exceptions/missing-config-exception.d.ts +2 -1
  19. package/dist/exceptions/missing-config-exception.js +2 -2
  20. package/dist/exceptions/process-env-assignment-exception.d.ts +2 -1
  21. package/dist/exceptions/process-env-assignment-exception.js +3 -2
  22. package/dist/exceptions/schema-validation-exception.d.ts +2 -1
  23. package/dist/exceptions/schema-validation-exception.js +3 -3
  24. package/dist/exceptions/transformation-exception.d.ts +2 -1
  25. package/dist/exceptions/transformation-exception.js +3 -2
  26. package/dist/exceptions/validation-exception.d.ts +2 -1
  27. package/dist/exceptions/validation-exception.js +3 -2
  28. package/dist/extended-config.module.js +2 -0
  29. package/dist/extended-config.service.d.ts +2 -2
  30. package/dist/extended-config.service.js +1 -4
  31. package/dist/interfaces/config-path.interface.d.ts +4 -4
  32. package/dist/interfaces/cron-scheduler.interface.d.ts +1 -2
  33. package/llms.txt +2 -2
  34. package/package.json +2 -3
package/README.md CHANGED
@@ -37,11 +37,11 @@ Extended configuration module for [NestJS](https://nestjs.com), inspired by [Nes
37
37
 
38
38
  ## Compatibility
39
39
 
40
- | nestjs-config-extended | NestJS | Node.js |
41
- | ---------------------- | -------- | ------- |
42
- | 2.x | 11, 12 | 22.12+ |
43
- | 1.x | 8, 9, 10 | - |
44
- | 0.x | 7 | - |
40
+ | nestjs-config-extended | NestJS | Node.js | TypeScript |
41
+ | ---------------------- | -------- | ------- | ---------- |
42
+ | 2.x | 11, 12 | 22.12+ | 5.4+ |
43
+ | 1.x | 8, 9, 10 | - | - |
44
+ | 0.x | 7 | - | - |
45
45
 
46
46
  NestJS 12 is ESM-only. This package works with it from both CommonJS and ESM applications, relying on `require()` of ES modules, which Node.js supports without a flag since 22.12.
47
47
 
@@ -134,7 +134,7 @@ Based on key use cases, `ExtendedConfigModule` has some pre-made loaders. To use
134
134
 
135
135
  - `processEnvLoader`: loads variables from node's `process.env`.
136
136
  - `dotEnvLoader`: loads variables from `.env` files, based on loader options. You can specify file(s) `path` and `encoding`, and enable `expandVariables`.
137
- - `jsonFileLoader`: loads variables from a JSON file. Options: `path` (required, relative to `process.cwd()`), `encoding` and `optional` (a missing file loads nothing instead of failing).
137
+ - `jsonFileLoader`: loads variables from a JSON file. Options: `path` (required, relative to `process.cwd()`), `encoding` and `optional` (a missing file loads nothing instead of failing; combined with `registerAs`, the key then holds an empty object).
138
138
  - `yamlFileLoader`: loads variables from a YAML file, with the same options. Requires the optional [`yaml`](https://www.npmjs.com/package/yaml) package (`npm install yaml`).
139
139
 
140
140
  ```typescript
@@ -258,6 +258,8 @@ export class DatabaseService {
258
258
 
259
259
  `getConfigToken('database')` returns the injection token, for example to use it in other providers' `inject` arrays.
260
260
 
261
+ > **Note:** the first injection of a namespace triggers the first load while Nest creates providers, which is earlier than the module's `onModuleInit`. If a `forRootAsync()` loader is a provider that needs its own `onModuleInit` before it can load, make sure its dependencies are ready in its constructor or factory, or inject the namespace only in modules that are initialized after it.
262
+
261
263
  ### Reacting to changes
262
264
 
263
265
  Reloads (manual or scheduled) can change values while the application runs. `watch()` emits the current value of a key or dotted path and then every distinct change, and `changes()` emits an event with the top-level keys that changed:
@@ -302,6 +304,23 @@ export class HealthController {
302
304
  }
303
305
  ```
304
306
 
307
+ ### Errors
308
+
309
+ Every error thrown by the module extends `ExtendedConfigException`, so one `instanceof` check catches them all. Errors have a specific `name` (`LoadingException`, `SchemaValidationException`, `MissingConfigException`, ...), the strategy's `identifier` when one is involved, and the original loader, validator or transformer error as `cause`:
310
+
311
+ ```typescript
312
+ try {
313
+ await this.config.reload('REMOTE');
314
+ } catch (error) {
315
+ if (error instanceof ExtendedConfigException) {
316
+ this.logger.error(
317
+ `${error.name} in ${String(error.identifier)}`,
318
+ error.cause,
319
+ );
320
+ }
321
+ }
322
+ ```
323
+
305
324
  ### Typed configuration
306
325
 
307
326
  Pass your configuration type to the service to get autocompleted dotted paths and inferred return types (up to 5 levels deep). With a [schema](#schema-validation), use `InferConfig<typeof schema>`.
@@ -0,0 +1,9 @@
1
+ export interface ExtendedConfigExceptionOptions {
2
+ cause?: unknown;
3
+ identifier?: string | symbol;
4
+ }
5
+ export declare abstract class ExtendedConfigException extends Error {
6
+ readonly cause?: unknown;
7
+ readonly identifier?: string | symbol;
8
+ protected constructor(message: string, options?: ExtendedConfigExceptionOptions);
9
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExtendedConfigException = void 0;
4
+ class ExtendedConfigException extends Error {
5
+ constructor(message, options = {}) {
6
+ super(message);
7
+ this.name = new.target.name;
8
+ if (options.cause !== undefined) {
9
+ Object.defineProperty(this, 'cause', {
10
+ value: options.cause,
11
+ writable: true,
12
+ configurable: true,
13
+ enumerable: false,
14
+ });
15
+ }
16
+ if (options.identifier !== undefined) {
17
+ this.identifier = options.identifier;
18
+ }
19
+ }
20
+ }
21
+ exports.ExtendedConfigException = ExtendedConfigException;
@@ -1,3 +1,4 @@
1
+ export * from './extended-config-exception';
1
2
  export * from './invalid-loader-exception';
2
3
  export * from './invalid-transformer-exception';
3
4
  export * from './invalid-validator-exception';
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./extended-config-exception"), exports);
17
18
  __exportStar(require("./invalid-loader-exception"), exports);
18
19
  __exportStar(require("./invalid-transformer-exception"), exports);
19
20
  __exportStar(require("./invalid-validator-exception"), exports);
@@ -1,3 +1,4 @@
1
- export declare class InvalidLoaderException extends Error {
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class InvalidLoaderException extends ExtendedConfigException {
2
3
  constructor(identifier?: string | symbol);
3
4
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InvalidLoaderException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
4
5
  const identifier_util_1 = require("../util/identifier.util");
5
- class InvalidLoaderException extends Error {
6
+ class InvalidLoaderException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(identifier) {
7
- super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's loader is not an instance of LoaderMethod or LoaderClass`);
8
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's loader is not an instance of LoaderMethod or LoaderClass`, { identifier });
8
9
  }
9
10
  }
10
11
  exports.InvalidLoaderException = InvalidLoaderException;
@@ -1,3 +1,4 @@
1
- export declare class InvalidReloadIntervalException extends Error {
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class InvalidReloadIntervalException extends ExtendedConfigException {
2
3
  constructor(reason: string, identifier?: string | symbol);
3
4
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InvalidReloadIntervalException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
4
5
  const identifier_util_1 = require("../util/identifier.util");
5
- class InvalidReloadIntervalException extends Error {
6
+ class InvalidReloadIntervalException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(reason, identifier) {
7
- super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's reload interval is invalid due "${reason}"`);
8
- this.name = 'InvalidReloadIntervalException';
8
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's reload interval is invalid due "${reason}"`, { identifier });
9
9
  }
10
10
  }
11
11
  exports.InvalidReloadIntervalException = InvalidReloadIntervalException;
@@ -1,3 +1,4 @@
1
- export declare class InvalidScheduleException extends Error {
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class InvalidScheduleException extends ExtendedConfigException {
2
3
  constructor(identifier?: string | symbol);
3
4
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InvalidScheduleException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
4
5
  const identifier_util_1 = require("../util/identifier.util");
5
- class InvalidScheduleException extends Error {
6
+ class InvalidScheduleException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(identifier) {
7
- super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's schedule is not a valid cron syntax`);
8
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's schedule is not a valid cron syntax`, { identifier });
8
9
  }
9
10
  }
10
11
  exports.InvalidScheduleException = InvalidScheduleException;
@@ -1,3 +1,4 @@
1
- export declare class InvalidTransformerException extends Error {
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class InvalidTransformerException extends ExtendedConfigException {
2
3
  constructor(identifier?: string | symbol);
3
4
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InvalidTransformerException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
4
5
  const identifier_util_1 = require("../util/identifier.util");
5
- class InvalidTransformerException extends Error {
6
+ class InvalidTransformerException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(identifier) {
7
- super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's transformer is not an instance of TransformerClass or TransformerMethod`);
8
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's transformer is not an instance of TransformerClass or TransformerMethod`, { identifier });
8
9
  }
9
10
  }
10
11
  exports.InvalidTransformerException = InvalidTransformerException;
@@ -1,3 +1,4 @@
1
- export declare class InvalidValidatorException extends Error {
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class InvalidValidatorException extends ExtendedConfigException {
2
3
  constructor(identifier?: string | symbol);
3
4
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InvalidValidatorException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
4
5
  const identifier_util_1 = require("../util/identifier.util");
5
- class InvalidValidatorException extends Error {
6
+ class InvalidValidatorException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(identifier) {
7
- super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's validator is not an instance of ValidatorMethod or ValidatorClass`);
8
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's validator is not an instance of ValidatorMethod or ValidatorClass`, { identifier });
8
9
  }
9
10
  }
10
11
  exports.InvalidValidatorException = InvalidValidatorException;
@@ -1,3 +1,4 @@
1
- export declare class LoadingException extends Error {
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class LoadingException extends ExtendedConfigException {
2
3
  constructor(reason: Error | string, identifier?: string | symbol);
3
4
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LoadingException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
4
5
  const identifier_util_1 = require("../util/identifier.util");
5
- class LoadingException extends Error {
6
+ class LoadingException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(reason, identifier) {
7
- super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's loader was not able to load variables due "${reason}"`);
8
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's loader was not able to load variables due "${reason}"`, { cause: reason instanceof Error ? reason : undefined, identifier });
8
9
  }
9
10
  }
10
11
  exports.LoadingException = LoadingException;
@@ -1,4 +1,5 @@
1
- export declare class MissingConfigException extends Error {
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class MissingConfigException extends ExtendedConfigException {
2
3
  readonly path: string;
3
4
  constructor(path: string);
4
5
  }
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MissingConfigException = void 0;
4
- class MissingConfigException extends Error {
4
+ const extended_config_exception_1 = require("./extended-config-exception");
5
+ class MissingConfigException extends extended_config_exception_1.ExtendedConfigException {
5
6
  constructor(path) {
6
7
  super(`Configuration value "${path}" is not defined`);
7
8
  this.path = path;
8
- this.name = 'MissingConfigException';
9
9
  }
10
10
  }
11
11
  exports.MissingConfigException = MissingConfigException;
@@ -1,3 +1,4 @@
1
- export declare class ProcessEnvAssignmentException extends Error {
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class ProcessEnvAssignmentException extends ExtendedConfigException {
2
3
  constructor(reason: string, identifier?: string | symbol);
3
4
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ProcessEnvAssignmentException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
4
5
  const identifier_util_1 = require("../util/identifier.util");
5
- class ProcessEnvAssignmentException extends Error {
6
+ class ProcessEnvAssignmentException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(reason, identifier) {
7
- super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's variables cannot be stored on process.env (cache disabled) due "${reason}"`);
8
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's variables cannot be stored on process.env (cache disabled) due "${reason}"`, { identifier });
8
9
  }
9
10
  }
10
11
  exports.ProcessEnvAssignmentException = ProcessEnvAssignmentException;
@@ -1,5 +1,6 @@
1
+ import { ExtendedConfigException } from './extended-config-exception';
1
2
  import { StandardSchemaV1 } from '../interfaces/standard-schema.interface';
2
- export declare class SchemaValidationException extends Error {
3
+ export declare class SchemaValidationException extends ExtendedConfigException {
3
4
  readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;
4
5
  constructor(issues: ReadonlyArray<StandardSchemaV1.Issue>, identifier?: string | symbol);
5
6
  }
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SchemaValidationException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
4
5
  const identifier_util_1 = require("../util/identifier.util");
5
6
  const formatPath = (issue) => (issue.path || [])
6
7
  .map(segment => String(typeof segment === 'object' && segment !== null
7
8
  ? segment.key
8
9
  : segment))
9
10
  .join('.');
10
- class SchemaValidationException extends Error {
11
+ class SchemaValidationException extends extended_config_exception_1.ExtendedConfigException {
11
12
  constructor(issues, identifier) {
12
13
  const details = issues
13
14
  .map(issue => {
@@ -15,8 +16,7 @@ class SchemaValidationException extends Error {
15
16
  return path ? `${path}: ${issue.message}` : issue.message;
16
17
  })
17
18
  .join('; ');
18
- super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's variables do not match the schema: ${details}`);
19
- this.name = 'SchemaValidationException';
19
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's variables do not match the schema: ${details}`, { identifier });
20
20
  this.issues = issues;
21
21
  }
22
22
  }
@@ -1,3 +1,4 @@
1
- export declare class TransformationException extends Error {
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class TransformationException extends ExtendedConfigException {
2
3
  constructor(reason: Error | string, identifier?: string | symbol);
3
4
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TransformationException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
4
5
  const identifier_util_1 = require("../util/identifier.util");
5
- class TransformationException extends Error {
6
+ class TransformationException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(reason, identifier) {
7
- super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's transformer was not able to transform variables due "${reason}"`);
8
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's transformer was not able to transform variables due "${reason}"`, { cause: reason instanceof Error ? reason : undefined, identifier });
8
9
  }
9
10
  }
10
11
  exports.TransformationException = TransformationException;
@@ -1,3 +1,4 @@
1
- export declare class ValidationException extends Error {
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class ValidationException extends ExtendedConfigException {
2
3
  constructor(reason: Error | string, identifier?: string | symbol);
3
4
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ValidationException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
4
5
  const identifier_util_1 = require("../util/identifier.util");
5
- class ValidationException extends Error {
6
+ class ValidationException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(reason, identifier) {
7
- super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's loaded variables cannot be validated by validator due "${reason}"`);
8
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's loaded variables cannot be validated by validator due "${reason}"`, { cause: reason instanceof Error ? reason : undefined, identifier });
8
9
  }
9
10
  }
10
11
  exports.ValidationException = ValidationException;
@@ -159,7 +159,9 @@ exports.ExtendedConfigModule = ExtendedConfigModule = ExtendedConfigModule_1 = _
159
159
  provide: config_constants_1.PRE_LOADED_VALUES,
160
160
  useValue: null,
161
161
  },
162
+ extended_config_service_1.ExtendedConfigService,
162
163
  ],
164
+ exports: [extended_config_service_1.ExtendedConfigService],
163
165
  }),
164
166
  __metadata("design:paramtypes", [extended_config_service_1.ExtendedConfigService])
165
167
  ], ExtendedConfigModule);
@@ -24,11 +24,11 @@ export declare class ExtendedConfigService<K = Record<string, any>> implements O
24
24
  load(ensureLoad?: boolean): Promise<void>;
25
25
  get<P extends ConfigPath<K>>(propertyPath: P): ConfigPathValue<K, P> | undefined;
26
26
  get<P extends ConfigPath<K>>(propertyPath: P, defaultValue: ConfigPathValue<K, P>): ConfigPathValue<K, P>;
27
- get<T = any>(propertyPath: ConfigPath<K>, defaultValue?: T): T | undefined;
27
+ get<T = never>(propertyPath: ConfigPath<K>, defaultValue?: NoInfer<T>): T | undefined;
28
28
  getOrThrow<P extends ConfigPath<K>>(propertyPath: P): NonNullable<ConfigPathValue<K, P>>;
29
29
  getOrThrow<T = any>(propertyPath: ConfigPath<K>): T;
30
30
  getProxyOf<P extends ConfigPath<K>>(propertyPath: P, defaultValue?: ConfigPathValue<K, P>): ConfigPathValue<K, P> | undefined;
31
- getProxyOf<T = any>(propertyPath: ConfigPath<K>, defaultValue?: T): T | undefined;
31
+ getProxyOf<T = never>(propertyPath: ConfigPath<K>, defaultValue?: NoInfer<T>): T | undefined;
32
32
  has(propertyPath: ConfigPath<K>): boolean;
33
33
  private get isCacheEnabled();
34
34
  private loadVariables;
@@ -172,10 +172,7 @@ let ExtendedConfigService = class ExtendedConfigService {
172
172
  if (!this.scheduler.validate(schedule)) {
173
173
  throw new exceptions_1.InvalidScheduleException(identifier);
174
174
  }
175
- const task = this.scheduler.schedule(schedule, () => this.runBackgroundReload(strategy, config_constants_1.RELOADING_VARIABLES_FROM_STRATEGY_BY_SCHEDULER), {
176
- scheduled: true,
177
- timezone: scheduleTimezone,
178
- });
175
+ const task = this.scheduler.schedule(schedule, () => this.runBackgroundReload(strategy, config_constants_1.RELOADING_VARIABLES_FROM_STRATEGY_BY_SCHEDULER), { timezone: scheduleTimezone });
179
176
  if (task) {
180
177
  this.scheduledTasks.push(task);
181
178
  }
@@ -1,9 +1,9 @@
1
1
  type Primitive = string | number | boolean | bigint | symbol | null | undefined;
2
- type IsAny<T> = 0 extends 1 & T ? true : false;
2
+ type IsUntyped<T> = unknown extends T ? true : false;
3
3
  type Leaf = Primitive | ((...args: any[]) => any) | Date | RegExp | ReadonlyArray<any>;
4
4
  type PrevDepth = [never, 0, 1, 2, 3, 4, 5];
5
- export type ConfigPath<T, Depth extends number = 5> = IsAny<T> extends true ? string : [Depth] extends [never] ? never : T extends Leaf ? never : {
6
- [K in keyof T & string]: IsAny<T[K]> extends true ? K | `${K}.${string}` : NonNullable<T[K]> extends Leaf ? K : K | `${K}.${ConfigPath<NonNullable<T[K]>, PrevDepth[Depth]>}`;
5
+ export type ConfigPath<T, Depth extends number = 5> = IsUntyped<T> extends true ? string : [Depth] extends [never] ? never : T extends Leaf ? never : {
6
+ [K in keyof T & string]: IsUntyped<T[K]> extends true ? K | `${K}.${string}` : NonNullable<T[K]> extends Leaf ? K : K | `${K}.${ConfigPath<NonNullable<T[K]>, PrevDepth[Depth]>}`;
7
7
  }[keyof T & string];
8
- export type ConfigPathValue<T, P extends string> = IsAny<T> extends true ? any : P extends keyof T ? T[P] : P extends `${infer Head}.${infer Rest}` ? Head extends keyof T ? ConfigPathValue<NonNullable<T[Head]>, Rest> : unknown : unknown;
8
+ export type ConfigPathValue<T, P extends string> = IsUntyped<T> extends true ? any : P extends keyof T ? T[P] : P extends `${infer Head}.${infer Rest}` ? Head extends keyof T ? ConfigPathValue<NonNullable<T[Head]>, Rest> : unknown : unknown;
9
9
  export {};
@@ -1,8 +1,7 @@
1
1
  export interface CronScheduledTask {
2
- destroy(): void;
2
+ destroy(): void | Promise<void>;
3
3
  }
4
4
  export interface CronScheduleOptions {
5
- scheduled?: boolean;
6
5
  timezone?: string;
7
6
  }
8
7
  export interface CronScheduler {
package/llms.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  # nestjs-config-extended
2
2
 
3
- > NestJS configuration module (NestJS 11 and 12, Node.js 22.12+, CommonJS and ESM). It loads configuration from ordered strategies (environment variables, .env, JSON, YAML or custom loaders), validates it with any Standard Schema library, reloads it on demand, on a cron schedule or at an interval, and exposes it through `ExtendedConfigService`, `@InjectConfig()` namespaces and RxJS observables.
3
+ > NestJS configuration module (NestJS 11 and 12, Node.js 22.12+, TypeScript 5.4+, CommonJS and ESM). It loads configuration from ordered strategies (environment variables, .env, JSON, YAML or custom loaders), validates it with any Standard Schema library, reloads it on demand, on a cron schedule or at an interval, and exposes it through `ExtendedConfigService`, `@InjectConfig()` namespaces and RxJS observables.
4
4
 
5
5
  Import everything from the package root: `import { ... } from 'nestjs-config-extended'`. Deep imports are not supported.
6
6
 
@@ -94,7 +94,7 @@ Add `ExtendedConfigHealthIndicator` to a module's providers and call `this.confi
94
94
 
95
95
  ## Errors
96
96
 
97
- `LoadingException`, `ValidationException`, `TransformationException`, `SchemaValidationException` (with `issues`), `InvalidLoaderException`, `InvalidValidatorException`, `InvalidTransformerException`, `InvalidScheduleException`, `InvalidReloadIntervalException`, `ProcessEnvAssignmentException`, `MissingConfigException`.
97
+ All errors extend `ExtendedConfigException` (with `name`, optional `identifier` and the original error as `cause`): `LoadingException`, `ValidationException`, `TransformationException`, `SchemaValidationException` (with `issues`), `InvalidLoaderException`, `InvalidValidatorException`, `InvalidTransformerException`, `InvalidScheduleException`, `InvalidReloadIntervalException`, `ProcessEnvAssignmentException`, `MissingConfigException`.
98
98
 
99
99
  ## Links
100
100
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nestjs-config-extended",
3
- "version": "2.0.0-next.1",
3
+ "version": "2.0.0-next.2",
4
4
  "description": "Extended configuration module for NestJS: load, validate, reload and inject configuration from environment variables, .env, JSON, YAML or custom sources.",
5
5
  "author": "Pedro Sodré",
6
6
  "license": "MIT",
@@ -75,7 +75,7 @@
75
75
  "lodash.get": "4.4.2",
76
76
  "lodash.has": "4.5.2",
77
77
  "lodash.isfunction": "^3.0.9",
78
- "node-cron": "^2.0.3"
78
+ "node-cron": "4.6.0"
79
79
  },
80
80
  "devDependencies": {
81
81
  "@arethetypeswrong/cli": "0.18.5",
@@ -92,7 +92,6 @@
92
92
  "@types/lodash.has": "4.5.6",
93
93
  "@types/lodash.isfunction": "^3.0.6",
94
94
  "@types/node": "22.20.5",
95
- "@types/node-cron": "^2.0.3",
96
95
  "eslint": "9.39.5",
97
96
  "eslint-config-prettier": "10.1.8",
98
97
  "husky": "9.1.7",