nestjs-config-extended 1.2.7 → 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 (94) hide show
  1. package/README.md +255 -48
  2. package/dist/config-namespace.d.ts +2 -0
  3. package/dist/config-namespace.js +9 -0
  4. package/dist/config.constants.d.ts +7 -0
  5. package/dist/config.constants.js +8 -1
  6. package/dist/exceptions/extended-config-exception.d.ts +9 -0
  7. package/dist/exceptions/extended-config-exception.js +21 -0
  8. package/dist/exceptions/index.d.ts +5 -0
  9. package/dist/exceptions/index.js +10 -1
  10. package/dist/exceptions/invalid-loader-exception.d.ts +3 -2
  11. package/dist/exceptions/invalid-loader-exception.js +4 -3
  12. package/dist/exceptions/invalid-reload-interval-exception.d.ts +4 -0
  13. package/dist/exceptions/invalid-reload-interval-exception.js +11 -0
  14. package/dist/exceptions/invalid-schedule-exception.d.ts +3 -2
  15. package/dist/exceptions/invalid-schedule-exception.js +4 -3
  16. package/dist/exceptions/invalid-transformer-exception.d.ts +3 -2
  17. package/dist/exceptions/invalid-transformer-exception.js +4 -3
  18. package/dist/exceptions/invalid-validator-exception.d.ts +3 -2
  19. package/dist/exceptions/invalid-validator-exception.js +4 -3
  20. package/dist/exceptions/loading-exception.d.ts +3 -2
  21. package/dist/exceptions/loading-exception.js +4 -3
  22. package/dist/exceptions/missing-config-exception.d.ts +5 -0
  23. package/dist/exceptions/missing-config-exception.js +11 -0
  24. package/dist/exceptions/process-env-assignment-exception.d.ts +4 -0
  25. package/dist/exceptions/process-env-assignment-exception.js +11 -0
  26. package/dist/exceptions/schema-validation-exception.d.ts +6 -0
  27. package/dist/exceptions/schema-validation-exception.js +23 -0
  28. package/dist/exceptions/transformation-exception.d.ts +3 -2
  29. package/dist/exceptions/transformation-exception.js +4 -3
  30. package/dist/exceptions/validation-exception.d.ts +3 -2
  31. package/dist/exceptions/validation-exception.js +4 -3
  32. package/dist/extended-config.health.d.ts +13 -0
  33. package/dist/extended-config.health.js +50 -0
  34. package/dist/extended-config.module.d.ts +3 -0
  35. package/dist/extended-config.module.js +57 -28
  36. package/dist/extended-config.service.d.ts +41 -18
  37. package/dist/extended-config.service.js +324 -139
  38. package/dist/index.d.ts +3 -0
  39. package/dist/index.js +11 -1
  40. package/dist/interfaces/config-change-event.interface.d.ts +5 -0
  41. package/dist/interfaces/config-change-event.interface.js +2 -0
  42. package/dist/interfaces/config-loader-strategy.interface.d.ts +16 -7
  43. package/dist/interfaces/config-module-options.interface.d.ts +7 -2
  44. package/dist/interfaces/config-path.interface.d.ts +9 -0
  45. package/dist/interfaces/config-path.interface.js +2 -0
  46. package/dist/interfaces/config-status.interface.d.ts +13 -0
  47. package/dist/interfaces/config-status.interface.js +2 -0
  48. package/dist/interfaces/cron-scheduler.interface.d.ts +10 -0
  49. package/dist/interfaces/cron-scheduler.interface.js +2 -0
  50. package/dist/interfaces/index.d.ts +6 -0
  51. package/dist/interfaces/index.js +11 -1
  52. package/dist/interfaces/redact-options.interface.d.ts +4 -0
  53. package/dist/interfaces/redact-options.interface.js +2 -0
  54. package/dist/interfaces/standard-schema.interface.d.ts +33 -0
  55. package/dist/interfaces/standard-schema.interface.js +2 -0
  56. package/dist/strategies/dotEnv/dot-env.strategy.d.ts +1 -1
  57. package/dist/strategies/dotEnv/dot-env.strategy.js +36 -18
  58. package/dist/strategies/dotEnv/index.js +5 -1
  59. package/dist/strategies/file/file.interface.d.ts +5 -0
  60. package/dist/strategies/file/file.interface.js +2 -0
  61. package/dist/strategies/file/index.d.ts +3 -0
  62. package/dist/strategies/file/index.js +19 -0
  63. package/dist/strategies/file/json-file.strategy.d.ts +2 -0
  64. package/dist/strategies/file/json-file.strategy.js +6 -0
  65. package/dist/strategies/file/read-config-file.util.d.ts +2 -0
  66. package/dist/strategies/file/read-config-file.util.js +60 -0
  67. package/dist/strategies/file/yaml-file.strategy.d.ts +2 -0
  68. package/dist/strategies/file/yaml-file.strategy.js +17 -0
  69. package/dist/strategies/index.d.ts +1 -0
  70. package/dist/strategies/index.js +6 -1
  71. package/dist/util/clone.util.d.ts +1 -0
  72. package/dist/util/clone.util.js +24 -0
  73. package/dist/util/config-proxy.util.d.ts +1 -0
  74. package/dist/util/config-proxy.util.js +35 -0
  75. package/dist/util/deep-equal.util.d.ts +1 -0
  76. package/dist/util/deep-equal.util.js +26 -0
  77. package/dist/util/duration.util.d.ts +1 -0
  78. package/dist/util/duration.util.js +22 -0
  79. package/dist/util/identifier.util.d.ts +1 -0
  80. package/dist/util/identifier.util.js +6 -0
  81. package/dist/util/is-undefined.util.js +1 -2
  82. package/dist/util/loader.util.d.ts +4 -3
  83. package/dist/util/loader.util.js +67 -27
  84. package/dist/util/object.util.js +9 -4
  85. package/dist/util/redact.util.d.ts +4 -0
  86. package/dist/util/redact.util.js +47 -0
  87. package/index.d.mts +1 -0
  88. package/index.mjs +4 -0
  89. package/llms.txt +102 -0
  90. package/package.json +114 -45
  91. package/index.d.ts +0 -1
  92. package/index.js +0 -6
  93. package/logo.png +0 -0
  94. package/sonar-project.properties +0 -18
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InvalidValidatorException = void 0;
4
- const config_constants_1 = require("../config.constants");
5
- class InvalidValidatorException extends Error {
4
+ const extended_config_exception_1 = require("./extended-config-exception");
5
+ const identifier_util_1 = require("../util/identifier.util");
6
+ class InvalidValidatorException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(identifier) {
7
- super(`${identifier || config_constants_1.NOT_IDENTIFIED} 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 {
2
- constructor(reason: Error | string, identifier?: string | Symbol);
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class LoadingException extends ExtendedConfigException {
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 config_constants_1 = require("../config.constants");
5
- class LoadingException extends Error {
4
+ const extended_config_exception_1 = require("./extended-config-exception");
5
+ const identifier_util_1 = require("../util/identifier.util");
6
+ class LoadingException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(reason, identifier) {
7
- super(`${identifier || config_constants_1.NOT_IDENTIFIED} 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;
@@ -0,0 +1,5 @@
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class MissingConfigException extends ExtendedConfigException {
3
+ readonly path: string;
4
+ constructor(path: string);
5
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MissingConfigException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
5
+ class MissingConfigException extends extended_config_exception_1.ExtendedConfigException {
6
+ constructor(path) {
7
+ super(`Configuration value "${path}" is not defined`);
8
+ this.path = path;
9
+ }
10
+ }
11
+ exports.MissingConfigException = MissingConfigException;
@@ -0,0 +1,4 @@
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class ProcessEnvAssignmentException extends ExtendedConfigException {
3
+ constructor(reason: string, identifier?: string | symbol);
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProcessEnvAssignmentException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
5
+ const identifier_util_1 = require("../util/identifier.util");
6
+ class ProcessEnvAssignmentException extends extended_config_exception_1.ExtendedConfigException {
7
+ constructor(reason, identifier) {
8
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's variables cannot be stored on process.env (cache disabled) due "${reason}"`, { identifier });
9
+ }
10
+ }
11
+ exports.ProcessEnvAssignmentException = ProcessEnvAssignmentException;
@@ -0,0 +1,6 @@
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ import { StandardSchemaV1 } from '../interfaces/standard-schema.interface';
3
+ export declare class SchemaValidationException extends ExtendedConfigException {
4
+ readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;
5
+ constructor(issues: ReadonlyArray<StandardSchemaV1.Issue>, identifier?: string | symbol);
6
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SchemaValidationException = void 0;
4
+ const extended_config_exception_1 = require("./extended-config-exception");
5
+ const identifier_util_1 = require("../util/identifier.util");
6
+ const formatPath = (issue) => (issue.path || [])
7
+ .map(segment => String(typeof segment === 'object' && segment !== null
8
+ ? segment.key
9
+ : segment))
10
+ .join('.');
11
+ class SchemaValidationException extends extended_config_exception_1.ExtendedConfigException {
12
+ constructor(issues, identifier) {
13
+ const details = issues
14
+ .map(issue => {
15
+ const path = formatPath(issue);
16
+ return path ? `${path}: ${issue.message}` : issue.message;
17
+ })
18
+ .join('; ');
19
+ super(`${(0, identifier_util_1.formatIdentifier)(identifier)} strategy's variables do not match the schema: ${details}`, { identifier });
20
+ this.issues = issues;
21
+ }
22
+ }
23
+ exports.SchemaValidationException = SchemaValidationException;
@@ -1,3 +1,4 @@
1
- export declare class TransformationException extends Error {
2
- constructor(reason: Error | string, identifier?: string | Symbol);
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class TransformationException extends ExtendedConfigException {
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 config_constants_1 = require("../config.constants");
5
- class TransformationException extends Error {
4
+ const extended_config_exception_1 = require("./extended-config-exception");
5
+ const identifier_util_1 = require("../util/identifier.util");
6
+ class TransformationException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(reason, identifier) {
7
- super(`${identifier || config_constants_1.NOT_IDENTIFIED} 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 {
2
- constructor(reason: Error | string, identifier?: string | Symbol);
1
+ import { ExtendedConfigException } from './extended-config-exception';
2
+ export declare class ValidationException extends ExtendedConfigException {
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 config_constants_1 = require("../config.constants");
5
- class ValidationException extends Error {
4
+ const extended_config_exception_1 = require("./extended-config-exception");
5
+ const identifier_util_1 = require("../util/identifier.util");
6
+ class ValidationException extends extended_config_exception_1.ExtendedConfigException {
6
7
  constructor(reason, identifier) {
7
- super(`${identifier || config_constants_1.NOT_IDENTIFIED} 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;
@@ -0,0 +1,13 @@
1
+ import { ExtendedConfigService } from './extended-config.service';
2
+ export interface ExtendedConfigHealthOptions {
3
+ maxConsecutiveFailures?: number;
4
+ }
5
+ export type ExtendedConfigHealthResult = Record<string, {
6
+ status: 'up' | 'down';
7
+ [details: string]: unknown;
8
+ }>;
9
+ export declare class ExtendedConfigHealthIndicator {
10
+ private readonly config;
11
+ constructor(config: ExtendedConfigService);
12
+ isHealthy(key?: string, options?: ExtendedConfigHealthOptions): ExtendedConfigHealthResult;
13
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ExtendedConfigHealthIndicator = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const extended_config_service_1 = require("./extended-config.service");
15
+ let ExtendedConfigHealthIndicator = class ExtendedConfigHealthIndicator {
16
+ constructor(config) {
17
+ this.config = config;
18
+ }
19
+ isHealthy(key = 'config', options = {}) {
20
+ var _a;
21
+ const maxConsecutiveFailures = Math.max(1, (_a = options.maxConsecutiveFailures) !== null && _a !== void 0 ? _a : 1);
22
+ const { loaded, strategies } = this.config.getStatus();
23
+ const enabled = strategies.filter(strategy => !strategy.disabled);
24
+ const healthy = loaded &&
25
+ enabled.every(strategy => strategy.loaded &&
26
+ strategy.consecutiveFailures < maxConsecutiveFailures);
27
+ return {
28
+ [key]: {
29
+ status: healthy ? 'up' : 'down',
30
+ loaded,
31
+ strategies: enabled.map(strategy => {
32
+ var _a, _b;
33
+ return ({
34
+ identifier: strategy.identifier,
35
+ loaded: strategy.loaded,
36
+ consecutiveFailures: strategy.consecutiveFailures,
37
+ lastSuccessAt: (_a = strategy.lastSuccessAt) === null || _a === void 0 ? void 0 : _a.toISOString(),
38
+ lastFailureAt: (_b = strategy.lastFailureAt) === null || _b === void 0 ? void 0 : _b.toISOString(),
39
+ lastError: strategy.lastError,
40
+ });
41
+ }),
42
+ },
43
+ };
44
+ }
45
+ };
46
+ exports.ExtendedConfigHealthIndicator = ExtendedConfigHealthIndicator;
47
+ exports.ExtendedConfigHealthIndicator = ExtendedConfigHealthIndicator = __decorate([
48
+ (0, common_1.Injectable)(),
49
+ __metadata("design:paramtypes", [extended_config_service_1.ExtendedConfigService])
50
+ ], ExtendedConfigHealthIndicator);
@@ -1,11 +1,14 @@
1
1
  import { DynamicModule } from '@nestjs/common';
2
2
  import { ExtendedConfigService } from './extended-config.service';
3
3
  import { ExtendedConfigModuleSyncOptions, ExtendedConfigModuleAsyncOptions } from './interfaces';
4
+ export declare class ExtendedConfigFeatureModule {
5
+ }
4
6
  export declare class ExtendedConfigModule {
5
7
  private extendedConfigService;
6
8
  constructor(extendedConfigService: ExtendedConfigService);
7
9
  static forRoot(options: ExtendedConfigModuleSyncOptions): Promise<DynamicModule>;
8
10
  static forRootAsync(options: ExtendedConfigModuleAsyncOptions): DynamicModule;
11
+ static forFeature(namespaces: string | string[]): DynamicModule;
9
12
  private static createAsyncProviders;
10
13
  protected onModuleInit(): Promise<void>;
11
14
  }
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -17,13 +21,23 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
17
21
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
18
22
  return c > 3 && r && Object.defineProperty(target, key, r), r;
19
23
  };
20
- var __importStar = (this && this.__importStar) || function (mod) {
21
- if (mod && mod.__esModule) return mod;
22
- var result = {};
23
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24
- __setModuleDefault(result, mod);
25
- return result;
26
- };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
27
41
  var __metadata = (this && this.__metadata) || function (k, v) {
28
42
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
29
43
  };
@@ -38,35 +52,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
38
52
  };
39
53
  var ExtendedConfigModule_1;
40
54
  Object.defineProperty(exports, "__esModule", { value: true });
41
- exports.ExtendedConfigModule = void 0;
55
+ exports.ExtendedConfigModule = exports.ExtendedConfigFeatureModule = void 0;
42
56
  const common_1 = require("@nestjs/common");
43
57
  const config_constants_1 = require("./config.constants");
44
58
  const extended_config_service_1 = require("./extended-config.service");
45
59
  const cron = __importStar(require("node-cron"));
46
60
  const loader_util_1 = require("./util/loader.util");
47
- const object_util_1 = require("./util/object.util");
61
+ const config_namespace_1 = require("./config-namespace");
62
+ const config_proxy_util_1 = require("./util/config-proxy.util");
63
+ let ExtendedConfigFeatureModule = class ExtendedConfigFeatureModule {
64
+ };
65
+ exports.ExtendedConfigFeatureModule = ExtendedConfigFeatureModule;
66
+ exports.ExtendedConfigFeatureModule = ExtendedConfigFeatureModule = __decorate([
67
+ (0, common_1.Module)({})
68
+ ], ExtendedConfigFeatureModule);
48
69
  let ExtendedConfigModule = ExtendedConfigModule_1 = class ExtendedConfigModule {
49
70
  constructor(extendedConfigService) {
50
71
  this.extendedConfigService = extendedConfigService;
51
72
  }
52
73
  static forRoot(options) {
53
74
  return __awaiter(this, void 0, void 0, function* () {
54
- let preLoadedVariables = null;
75
+ let preLoadedResults = null;
55
76
  if (options === null || options === void 0 ? void 0 : options.preload) {
56
- preLoadedVariables = {};
77
+ preLoadedResults = [];
57
78
  for (const strategy of options.strategies || []) {
58
- const { registerAs, disable } = strategy;
59
- if (!disable) {
60
- const variables = yield loader_util_1.retrieveVariablesByStrategy(strategy);
61
- if (registerAs) {
62
- object_util_1.setOn(preLoadedVariables, registerAs, variables);
63
- }
64
- else {
65
- Object.keys(variables).forEach((key) => {
66
- object_util_1.setOn(preLoadedVariables, key, variables[key]);
67
- });
68
- }
69
- }
79
+ preLoadedResults.push(strategy.disable
80
+ ? undefined
81
+ : Object.assign({}, (yield (0, loader_util_1.retrieveVariablesByStrategy)(strategy))));
70
82
  }
71
83
  }
72
84
  return {
@@ -79,7 +91,7 @@ let ExtendedConfigModule = ExtendedConfigModule_1 = class ExtendedConfigModule {
79
91
  },
80
92
  {
81
93
  provide: config_constants_1.PRE_LOADED_VALUES,
82
- useValue: preLoadedVariables,
94
+ useValue: preLoadedResults,
83
95
  },
84
96
  extended_config_service_1.ExtendedConfigService,
85
97
  ],
@@ -96,6 +108,21 @@ let ExtendedConfigModule = ExtendedConfigModule_1 = class ExtendedConfigModule {
96
108
  imports: options.imports,
97
109
  };
98
110
  }
111
+ static forFeature(namespaces) {
112
+ const providers = (Array.isArray(namespaces) ? namespaces : [namespaces]).map(namespace => ({
113
+ provide: (0, config_namespace_1.getConfigToken)(namespace),
114
+ useFactory: (service) => __awaiter(this, void 0, void 0, function* () {
115
+ yield service.load(true);
116
+ return (0, config_proxy_util_1.createConfigProxy)(() => service.get(namespace));
117
+ }),
118
+ inject: [extended_config_service_1.ExtendedConfigService],
119
+ }));
120
+ return {
121
+ module: ExtendedConfigFeatureModule,
122
+ providers,
123
+ exports: providers.map(provider => provider.provide),
124
+ };
125
+ }
99
126
  static createAsyncProviders(options) {
100
127
  if (options.useFactory) {
101
128
  return [
@@ -115,8 +142,9 @@ let ExtendedConfigModule = ExtendedConfigModule_1 = class ExtendedConfigModule {
115
142
  });
116
143
  }
117
144
  };
118
- ExtendedConfigModule = ExtendedConfigModule_1 = __decorate([
119
- common_1.Module({
145
+ exports.ExtendedConfigModule = ExtendedConfigModule;
146
+ exports.ExtendedConfigModule = ExtendedConfigModule = ExtendedConfigModule_1 = __decorate([
147
+ (0, common_1.Module)({
120
148
  providers: [
121
149
  common_1.Logger,
122
150
  {
@@ -131,8 +159,9 @@ ExtendedConfigModule = ExtendedConfigModule_1 = __decorate([
131
159
  provide: config_constants_1.PRE_LOADED_VALUES,
132
160
  useValue: null,
133
161
  },
162
+ extended_config_service_1.ExtendedConfigService,
134
163
  ],
164
+ exports: [extended_config_service_1.ExtendedConfigService],
135
165
  }),
136
166
  __metadata("design:paramtypes", [extended_config_service_1.ExtendedConfigService])
137
167
  ], ExtendedConfigModule);
138
- exports.ExtendedConfigModule = ExtendedConfigModule;
@@ -1,34 +1,57 @@
1
- import { Logger } from '@nestjs/common';
2
- import { ExtendedConfigModuleOptions } from './interfaces';
3
- import cron from 'node-cron';
4
- export declare class ExtendedConfigService<K = Record<string, any>> {
1
+ import { Logger, OnModuleDestroy } from '@nestjs/common';
2
+ import { Observable } from 'rxjs';
3
+ import { ConfigChangeEvent, ConfigStatus, ConfigPath, ConfigPathValue, CronScheduler, ExtendedConfigModuleOptions } from './interfaces';
4
+ export declare class ExtendedConfigService<K = Record<string, any>> implements OnModuleDestroy {
5
5
  private readonly options;
6
6
  private readonly scheduler;
7
7
  private readonly logger;
8
8
  private loaded;
9
- private loading;
10
- private readonly cache;
11
- constructor(options: ExtendedConfigModuleOptions, scheduler: typeof cron, logger: Logger, preLoadedValues?: Record<string, any>);
9
+ private loadingPromise?;
10
+ private cache;
11
+ private results;
12
+ private processEnvKeys;
13
+ private readonly scheduledTasks;
14
+ private readonly intervals;
15
+ private readonly configuredSchedulers;
16
+ private readonly inFlight;
17
+ private current;
18
+ private readonly version$;
19
+ private readonly changes$;
20
+ private readonly statuses;
21
+ constructor(options: ExtendedConfigModuleOptions, scheduler: CronScheduler, logger: Logger, preLoadedResults?: (Record<string, any> | undefined)[] | null);
12
22
  private get isLoaded();
13
23
  private set isLoaded(value);
14
- private get isLoading();
15
- private set isLoading(value);
16
24
  load(ensureLoad?: boolean): Promise<void>;
17
- get<T = any>(propertyPath: keyof K, defaultValue?: T): T | undefined;
18
- getProxyOf<T = any>(propertyPath: keyof K, defaultValue?: T): T | undefined;
19
- private getFromCache;
20
- private getFromProcessEnv;
21
- private hasOnCache;
22
- private hasOnProcessEnv;
23
- has(propertyPath: keyof K): boolean;
24
- private set;
25
+ get<P extends ConfigPath<K>>(propertyPath: P): ConfigPathValue<K, P> | undefined;
26
+ get<P extends ConfigPath<K>>(propertyPath: P, defaultValue: ConfigPathValue<K, P>): ConfigPathValue<K, P>;
27
+ get<T = never>(propertyPath: ConfigPath<K>, defaultValue?: NoInfer<T>): T | undefined;
28
+ getOrThrow<P extends ConfigPath<K>>(propertyPath: P): NonNullable<ConfigPathValue<K, P>>;
29
+ getOrThrow<T = any>(propertyPath: ConfigPath<K>): T;
30
+ getProxyOf<P extends ConfigPath<K>>(propertyPath: P, defaultValue?: ConfigPathValue<K, P>): ConfigPathValue<K, P> | undefined;
31
+ getProxyOf<T = never>(propertyPath: ConfigPath<K>, defaultValue?: NoInfer<T>): T | undefined;
32
+ has(propertyPath: ConfigPath<K>): boolean;
25
33
  private get isCacheEnabled();
26
34
  private loadVariables;
27
35
  private configureSchedulerOnPreload;
28
36
  private configureScheduler;
29
- reload(strategyIdentifier?: string | Symbol): Promise<void>;
37
+ private runBackgroundReload;
38
+ onModuleDestroy(): void;
39
+ reload(strategyIdentifier?: string | symbol): Promise<void>;
40
+ watch<P extends ConfigPath<K>>(propertyPath: P): Observable<ConfigPathValue<K, P> | undefined>;
41
+ watch<T = any>(propertyPath: ConfigPath<K>): Observable<T | undefined>;
42
+ toJSON(): Record<string, any>;
43
+ getStatus(): ConfigStatus;
44
+ private markSuccess;
45
+ private markFailure;
46
+ changes(): Observable<ConfigChangeEvent>;
30
47
  private loadVariablesByStrategy;
48
+ private loadStrategy;
31
49
  private retrieveVariables;
50
+ private applyResults;
51
+ private notifyChanges;
52
+ private handleReloadError;
53
+ private runHook;
32
54
  private assignVariables;
55
+ private toProcessEnvValues;
33
56
  private debug;
34
57
  }