nestjs-config-extended 1.2.1 → 1.2.4
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/.releaserc +16 -9
- package/dist/config.constants.d.ts +1 -0
- package/dist/config.constants.js +8 -7
- package/dist/extended-config.module.js +3 -6
- package/dist/extended-config.service.js +5 -5
- package/dist/util/object.util.d.ts +1 -0
- package/dist/util/object.util.js +25 -0
- package/package.json +4 -5
package/.releaserc
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
+
"release": {
|
|
3
|
+
"branches": [
|
|
4
|
+
"master",
|
|
5
|
+
"next"
|
|
6
|
+
]
|
|
7
|
+
},
|
|
2
8
|
"plugins": [
|
|
3
9
|
[
|
|
4
10
|
"@semantic-release/commit-analyzer",
|
|
@@ -15,16 +21,17 @@
|
|
|
15
21
|
"release": "patch"
|
|
16
22
|
},
|
|
17
23
|
{
|
|
18
|
-
"
|
|
19
|
-
"release":
|
|
24
|
+
"scope": "no-release",
|
|
25
|
+
"release": false
|
|
20
26
|
}
|
|
21
|
-
]
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"@semantic-release/release-notes-generator",
|
|
31
|
+
[
|
|
32
|
+
"@semantic-release/npm",
|
|
33
|
+
{
|
|
34
|
+
"npmPublish": true
|
|
28
35
|
}
|
|
29
36
|
]
|
|
30
37
|
]
|
|
@@ -18,3 +18,4 @@ export declare const ASSIGNING_VARIABLES_TO_CACHE = "Assigning loaded variables
|
|
|
18
18
|
export declare const STARTING_RELOAD = "Starting variables reload";
|
|
19
19
|
export declare const ALL_STRATEGIES = "ALL";
|
|
20
20
|
export declare const NOT_LOADED_STRATEGY_DISABLED = "Variables not loaded since strategy is disabled";
|
|
21
|
+
export declare const DEBUG_LOG_PREFIX = "[Extended Config Module]";
|
package/dist/config.constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NOT_LOADED_STRATEGY_DISABLED = exports.ALL_STRATEGIES = exports.STARTING_RELOAD = exports.ASSIGNING_VARIABLES_TO_CACHE = exports.ASSIGNING_VARIABLES_TO_PROCESS_ENV = exports.TRANSFORMING_VARIABLES_FROM_STRATEGY = exports.VALIDATING_VARIABLES_FROM_STRATEGY = exports.RELOADING_VARIABLES_FROM_STRATEGY_BY_SCHEDULER = exports.RELOADING_VARIABLES_FROM_STRATEGY = exports.LOADING_VARIABLES_FROM_STRATEGY = exports.STARTING_STRATEGY = exports.INVALID_VARIABLES = exports.LOAD_REQUEST_IGNORED_DUE_IN_PROGRESS = exports.LOAD_REQUEST_IGNORED_DUE_ALREADY_LOADED = exports.FIRST_LOAD_REQUESTED = exports.VARIABLES_PRELOADED_BY_MODULE = exports.NOT_IDENTIFIED = exports.PRE_LOADED_VALUES = exports.EXTENDED_CONFIG_OPTIONS = exports.CRON_SCHEDULER = void 0;
|
|
3
|
+
exports.DEBUG_LOG_PREFIX = exports.NOT_LOADED_STRATEGY_DISABLED = exports.ALL_STRATEGIES = exports.STARTING_RELOAD = exports.ASSIGNING_VARIABLES_TO_CACHE = exports.ASSIGNING_VARIABLES_TO_PROCESS_ENV = exports.TRANSFORMING_VARIABLES_FROM_STRATEGY = exports.VALIDATING_VARIABLES_FROM_STRATEGY = exports.RELOADING_VARIABLES_FROM_STRATEGY_BY_SCHEDULER = exports.RELOADING_VARIABLES_FROM_STRATEGY = exports.LOADING_VARIABLES_FROM_STRATEGY = exports.STARTING_STRATEGY = exports.INVALID_VARIABLES = exports.LOAD_REQUEST_IGNORED_DUE_IN_PROGRESS = exports.LOAD_REQUEST_IGNORED_DUE_ALREADY_LOADED = exports.FIRST_LOAD_REQUESTED = exports.VARIABLES_PRELOADED_BY_MODULE = exports.NOT_IDENTIFIED = exports.PRE_LOADED_VALUES = exports.EXTENDED_CONFIG_OPTIONS = exports.CRON_SCHEDULER = void 0;
|
|
4
4
|
exports.CRON_SCHEDULER = 'CRON_SCHEDULER';
|
|
5
5
|
exports.EXTENDED_CONFIG_OPTIONS = 'EXTENDED_CONFIG_OPTIONS';
|
|
6
6
|
exports.PRE_LOADED_VALUES = 'PRE_LOADED_VALUES';
|
|
@@ -9,15 +9,16 @@ exports.VARIABLES_PRELOADED_BY_MODULE = 'Variables was preloaded by module from
|
|
|
9
9
|
exports.FIRST_LOAD_REQUESTED = 'Starting variables loading process';
|
|
10
10
|
exports.LOAD_REQUEST_IGNORED_DUE_ALREADY_LOADED = 'Load request was ignored since variables already was loaded';
|
|
11
11
|
exports.LOAD_REQUEST_IGNORED_DUE_IN_PROGRESS = 'Load request was ignored since a loading process is in progress at this moment';
|
|
12
|
-
exports.INVALID_VARIABLES =
|
|
12
|
+
exports.INVALID_VARIABLES = "Variables was not validated by strategy's validator.";
|
|
13
13
|
exports.STARTING_STRATEGY = 'Starting strategy';
|
|
14
|
-
exports.LOADING_VARIABLES_FROM_STRATEGY =
|
|
15
|
-
exports.RELOADING_VARIABLES_FROM_STRATEGY =
|
|
16
|
-
exports.RELOADING_VARIABLES_FROM_STRATEGY_BY_SCHEDULER =
|
|
17
|
-
exports.VALIDATING_VARIABLES_FROM_STRATEGY =
|
|
18
|
-
exports.TRANSFORMING_VARIABLES_FROM_STRATEGY =
|
|
14
|
+
exports.LOADING_VARIABLES_FROM_STRATEGY = "Loading variables from strategy's loader";
|
|
15
|
+
exports.RELOADING_VARIABLES_FROM_STRATEGY = "Reloading variables from strategy's loader";
|
|
16
|
+
exports.RELOADING_VARIABLES_FROM_STRATEGY_BY_SCHEDULER = "Reloading variables from strategy's loader by scheduler";
|
|
17
|
+
exports.VALIDATING_VARIABLES_FROM_STRATEGY = "Validating variables from strategy's validator";
|
|
18
|
+
exports.TRANSFORMING_VARIABLES_FROM_STRATEGY = "Transforming variables from strategy's transformer";
|
|
19
19
|
exports.ASSIGNING_VARIABLES_TO_PROCESS_ENV = 'Assigning loaded variables to process.env';
|
|
20
20
|
exports.ASSIGNING_VARIABLES_TO_CACHE = 'Assigning loaded variables to memory cache';
|
|
21
21
|
exports.STARTING_RELOAD = 'Starting variables reload';
|
|
22
22
|
exports.ALL_STRATEGIES = 'ALL';
|
|
23
23
|
exports.NOT_LOADED_STRATEGY_DISABLED = 'Variables not loaded since strategy is disabled';
|
|
24
|
+
exports.DEBUG_LOG_PREFIX = '[Extended Config Module]';
|
|
@@ -36,9 +36,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
36
36
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
-
};
|
|
42
39
|
var ExtendedConfigModule_1;
|
|
43
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
41
|
exports.ExtendedConfigModule = void 0;
|
|
@@ -47,7 +44,7 @@ const config_constants_1 = require("./config.constants");
|
|
|
47
44
|
const extended_config_service_1 = require("./extended-config.service");
|
|
48
45
|
const cron = __importStar(require("node-cron"));
|
|
49
46
|
const loader_util_1 = require("./util/loader.util");
|
|
50
|
-
const
|
|
47
|
+
const object_util_1 = require("./util/object.util");
|
|
51
48
|
let ExtendedConfigModule = ExtendedConfigModule_1 = class ExtendedConfigModule {
|
|
52
49
|
constructor(extendedConfigService) {
|
|
53
50
|
this.extendedConfigService = extendedConfigService;
|
|
@@ -62,11 +59,11 @@ let ExtendedConfigModule = ExtendedConfigModule_1 = class ExtendedConfigModule {
|
|
|
62
59
|
if (!disable) {
|
|
63
60
|
const variables = yield loader_util_1.retrieveVariablesByStrategy(strategy);
|
|
64
61
|
if (registerAs) {
|
|
65
|
-
|
|
62
|
+
object_util_1.setOn(preLoadedVariables, registerAs, variables);
|
|
66
63
|
}
|
|
67
64
|
else {
|
|
68
65
|
Object.keys(variables).forEach((key) => {
|
|
69
|
-
|
|
66
|
+
object_util_1.setOn(preLoadedVariables, key, variables[key]);
|
|
70
67
|
});
|
|
71
68
|
}
|
|
72
69
|
}
|
|
@@ -36,7 +36,7 @@ const common_1 = require("@nestjs/common");
|
|
|
36
36
|
const util_1 = require("util");
|
|
37
37
|
const lodash_get_1 = __importDefault(require("lodash.get"));
|
|
38
38
|
const lodash_has_1 = __importDefault(require("lodash.has"));
|
|
39
|
-
const
|
|
39
|
+
const object_util_1 = require("./util/object.util");
|
|
40
40
|
const config_constants_1 = require("./config.constants");
|
|
41
41
|
const exceptions_1 = require("./exceptions");
|
|
42
42
|
const loader_util_1 = require("./util/loader.util");
|
|
@@ -141,10 +141,10 @@ let ExtendedConfigService = class ExtendedConfigService {
|
|
|
141
141
|
}
|
|
142
142
|
set(propertyPath, value) {
|
|
143
143
|
if (this.isCacheEnabled) {
|
|
144
|
-
|
|
144
|
+
object_util_1.setOn(this.cache, propertyPath, value);
|
|
145
145
|
}
|
|
146
146
|
else {
|
|
147
|
-
|
|
147
|
+
object_util_1.setOn(process.env, propertyPath, value);
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
150
|
get isCacheEnabled() {
|
|
@@ -228,7 +228,7 @@ let ExtendedConfigService = class ExtendedConfigService {
|
|
|
228
228
|
var _a;
|
|
229
229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
230
230
|
return loader_util_1.retrieveVariablesByStrategy(strategy, ((_a = this.options) === null || _a === void 0 ? void 0 : _a.debug) ? (message, identifier) => {
|
|
231
|
-
this.logger.debug(
|
|
231
|
+
this.logger.debug(`${config_constants_1.DEBUG_LOG_PREFIX} ${identifier || config_constants_1.NOT_IDENTIFIED}: ${message}`);
|
|
232
232
|
}
|
|
233
233
|
: undefined);
|
|
234
234
|
});
|
|
@@ -253,7 +253,7 @@ let ExtendedConfigService = class ExtendedConfigService {
|
|
|
253
253
|
debug(message, identifier) {
|
|
254
254
|
var _a;
|
|
255
255
|
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.debug) {
|
|
256
|
-
this.logger.debug(
|
|
256
|
+
this.logger.debug(`${config_constants_1.DEBUG_LOG_PREFIX} ${identifier || config_constants_1.NOT_IDENTIFIED}: ${message}`);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
259
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const setOn: <T extends Record<string, unknown> = Record<string, unknown>>(obj: Record<keyof T, unknown>, path: number | symbol | string | string[], value: unknown) => Record<keyof T, unknown>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setOn = void 0;
|
|
4
|
+
const setOn = (obj, path, value) => {
|
|
5
|
+
const validPathCharactersRegex = /([^[.\]])+/g;
|
|
6
|
+
const pathArray = Array.isArray(path)
|
|
7
|
+
? path
|
|
8
|
+
: String(path).match(validPathCharactersRegex);
|
|
9
|
+
if (!pathArray)
|
|
10
|
+
return obj;
|
|
11
|
+
let nestedObj = obj;
|
|
12
|
+
for (let i = 0; i < pathArray.length; i++) {
|
|
13
|
+
const key = pathArray[i];
|
|
14
|
+
if (nestedObj[key] === undefined) {
|
|
15
|
+
const isIndex = isNaN(Number(pathArray[i + 1]));
|
|
16
|
+
nestedObj[key] = isIndex ? {} : [];
|
|
17
|
+
}
|
|
18
|
+
if (i === pathArray.length - 1) {
|
|
19
|
+
nestedObj[key] = value;
|
|
20
|
+
}
|
|
21
|
+
nestedObj = nestedObj[key];
|
|
22
|
+
}
|
|
23
|
+
return obj;
|
|
24
|
+
};
|
|
25
|
+
exports.setOn = setOn;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestjs-config-extended",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "Extended Configuration Module for Nest to load environment variables package",
|
|
5
5
|
"author": "Pedro Sodré",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"lodash.get": "4.4.2",
|
|
27
27
|
"lodash.has": "4.5.2",
|
|
28
28
|
"lodash.isfunction": "^3.0.9",
|
|
29
|
-
"lodash.set": "4.3.2",
|
|
30
29
|
"node-cron": "^2.0.3",
|
|
31
30
|
"rxjs": "^7.2.0",
|
|
32
31
|
"uuid": "8.3.2"
|
|
@@ -56,8 +55,8 @@
|
|
|
56
55
|
"typescript": "4.1.3"
|
|
57
56
|
},
|
|
58
57
|
"peerDependencies": {
|
|
59
|
-
"@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
60
|
-
"@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0",
|
|
58
|
+
"@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
|
|
59
|
+
"@nestjs/core": "^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0",
|
|
61
60
|
"reflect-metadata": "^0.1.12",
|
|
62
61
|
"rxjs": "^7.2.0"
|
|
63
62
|
},
|
|
@@ -86,4 +85,4 @@
|
|
|
86
85
|
"type": "git",
|
|
87
86
|
"url": "https://github.com/pedrosodre/nestjs-config-extended"
|
|
88
87
|
}
|
|
89
|
-
}
|
|
88
|
+
}
|