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.
- package/README.md +255 -48
- package/dist/config-namespace.d.ts +2 -0
- package/dist/config-namespace.js +9 -0
- package/dist/config.constants.d.ts +7 -0
- package/dist/config.constants.js +8 -1
- package/dist/exceptions/extended-config-exception.d.ts +9 -0
- package/dist/exceptions/extended-config-exception.js +21 -0
- package/dist/exceptions/index.d.ts +5 -0
- package/dist/exceptions/index.js +10 -1
- package/dist/exceptions/invalid-loader-exception.d.ts +3 -2
- package/dist/exceptions/invalid-loader-exception.js +4 -3
- package/dist/exceptions/invalid-reload-interval-exception.d.ts +4 -0
- package/dist/exceptions/invalid-reload-interval-exception.js +11 -0
- package/dist/exceptions/invalid-schedule-exception.d.ts +3 -2
- package/dist/exceptions/invalid-schedule-exception.js +4 -3
- package/dist/exceptions/invalid-transformer-exception.d.ts +3 -2
- package/dist/exceptions/invalid-transformer-exception.js +4 -3
- package/dist/exceptions/invalid-validator-exception.d.ts +3 -2
- package/dist/exceptions/invalid-validator-exception.js +4 -3
- package/dist/exceptions/loading-exception.d.ts +3 -2
- package/dist/exceptions/loading-exception.js +4 -3
- package/dist/exceptions/missing-config-exception.d.ts +5 -0
- package/dist/exceptions/missing-config-exception.js +11 -0
- package/dist/exceptions/process-env-assignment-exception.d.ts +4 -0
- package/dist/exceptions/process-env-assignment-exception.js +11 -0
- package/dist/exceptions/schema-validation-exception.d.ts +6 -0
- package/dist/exceptions/schema-validation-exception.js +23 -0
- package/dist/exceptions/transformation-exception.d.ts +3 -2
- package/dist/exceptions/transformation-exception.js +4 -3
- package/dist/exceptions/validation-exception.d.ts +3 -2
- package/dist/exceptions/validation-exception.js +4 -3
- package/dist/extended-config.health.d.ts +13 -0
- package/dist/extended-config.health.js +50 -0
- package/dist/extended-config.module.d.ts +3 -0
- package/dist/extended-config.module.js +57 -28
- package/dist/extended-config.service.d.ts +41 -18
- package/dist/extended-config.service.js +324 -139
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -1
- package/dist/interfaces/config-change-event.interface.d.ts +5 -0
- package/dist/interfaces/config-change-event.interface.js +2 -0
- package/dist/interfaces/config-loader-strategy.interface.d.ts +16 -7
- package/dist/interfaces/config-module-options.interface.d.ts +7 -2
- package/dist/interfaces/config-path.interface.d.ts +9 -0
- package/dist/interfaces/config-path.interface.js +2 -0
- package/dist/interfaces/config-status.interface.d.ts +13 -0
- package/dist/interfaces/config-status.interface.js +2 -0
- package/dist/interfaces/cron-scheduler.interface.d.ts +10 -0
- package/dist/interfaces/cron-scheduler.interface.js +2 -0
- package/dist/interfaces/index.d.ts +6 -0
- package/dist/interfaces/index.js +11 -1
- package/dist/interfaces/redact-options.interface.d.ts +4 -0
- package/dist/interfaces/redact-options.interface.js +2 -0
- package/dist/interfaces/standard-schema.interface.d.ts +33 -0
- package/dist/interfaces/standard-schema.interface.js +2 -0
- package/dist/strategies/dotEnv/dot-env.strategy.d.ts +1 -1
- package/dist/strategies/dotEnv/dot-env.strategy.js +36 -18
- package/dist/strategies/dotEnv/index.js +5 -1
- package/dist/strategies/file/file.interface.d.ts +5 -0
- package/dist/strategies/file/file.interface.js +2 -0
- package/dist/strategies/file/index.d.ts +3 -0
- package/dist/strategies/file/index.js +19 -0
- package/dist/strategies/file/json-file.strategy.d.ts +2 -0
- package/dist/strategies/file/json-file.strategy.js +6 -0
- package/dist/strategies/file/read-config-file.util.d.ts +2 -0
- package/dist/strategies/file/read-config-file.util.js +60 -0
- package/dist/strategies/file/yaml-file.strategy.d.ts +2 -0
- package/dist/strategies/file/yaml-file.strategy.js +17 -0
- package/dist/strategies/index.d.ts +1 -0
- package/dist/strategies/index.js +6 -1
- package/dist/util/clone.util.d.ts +1 -0
- package/dist/util/clone.util.js +24 -0
- package/dist/util/config-proxy.util.d.ts +1 -0
- package/dist/util/config-proxy.util.js +35 -0
- package/dist/util/deep-equal.util.d.ts +1 -0
- package/dist/util/deep-equal.util.js +26 -0
- package/dist/util/duration.util.d.ts +1 -0
- package/dist/util/duration.util.js +22 -0
- package/dist/util/identifier.util.d.ts +1 -0
- package/dist/util/identifier.util.js +6 -0
- package/dist/util/is-undefined.util.js +1 -2
- package/dist/util/loader.util.d.ts +4 -3
- package/dist/util/loader.util.js +67 -27
- package/dist/util/object.util.js +9 -4
- package/dist/util/redact.util.d.ts +4 -0
- package/dist/util/redact.util.js +47 -0
- package/index.d.mts +1 -0
- package/index.mjs +4 -0
- package/llms.txt +102 -0
- package/package.json +114 -45
- package/index.d.ts +0 -1
- package/index.js +0 -6
- package/logo.png +0 -0
- 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
|
|
5
|
-
|
|
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(`${
|
|
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
|
-
|
|
2
|
-
|
|
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
|
|
5
|
-
|
|
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(`${
|
|
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,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,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
|
-
|
|
2
|
-
|
|
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
|
|
5
|
-
|
|
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(`${
|
|
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
|
-
|
|
2
|
-
|
|
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
|
|
5
|
-
|
|
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(`${
|
|
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.
|
|
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 (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
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
|
|
75
|
+
let preLoadedResults = null;
|
|
55
76
|
if (options === null || options === void 0 ? void 0 : options.preload) {
|
|
56
|
-
|
|
77
|
+
preLoadedResults = [];
|
|
57
78
|
for (const strategy of options.strategies || []) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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:
|
|
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 =
|
|
119
|
-
|
|
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 {
|
|
3
|
-
import
|
|
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
|
|
10
|
-
private
|
|
11
|
-
|
|
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<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
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
|
}
|