@adaas/a-utils 0.1.4 → 0.1.6
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/dist/src/lib/A-Config/A-Config.container.d.ts +0 -2
- package/dist/src/lib/A-Config/A-Config.container.js +14 -12
- package/dist/src/lib/A-Config/A-Config.container.js.map +1 -1
- package/dist/src/lib/A-Config/components/ConfigReader.component.d.ts +4 -4
- package/dist/src/lib/A-Config/components/ConfigReader.component.js +26 -8
- package/dist/src/lib/A-Config/components/ConfigReader.component.js.map +1 -1
- package/dist/src/lib/A-Config/components/ENVConfigReader.component.d.ts +4 -0
- package/dist/src/lib/A-Config/components/ENVConfigReader.component.js +36 -1
- package/dist/src/lib/A-Config/components/ENVConfigReader.component.js.map +1 -1
- package/dist/src/lib/A-Polyfill/A-Polyfill.component.d.ts +2 -2
- package/dist/src/lib/A-Polyfill/A-Polyfill.types.d.ts +2 -2
- package/dist/src/lib/A-Polyfill/A-Polyfill.types.js +1 -0
- package/dist/src/lib/A-Polyfill/A-Polyfills.class.d.ts +1 -0
- package/dist/src/lib/A-Polyfill/A-Polyfills.class.js.map +1 -1
- package/examples/config.ts +33 -0
- package/package.json +3 -2
- package/src/lib/A-Config/A-Config.container.ts +19 -14
- package/src/lib/A-Config/components/ConfigReader.component.ts +27 -8
- package/src/lib/A-Config/components/ENVConfigReader.component.ts +30 -2
- package/src/lib/A-Polyfill/A-Polyfill.types.ts +2 -2
- package/src/lib/A-Polyfill/A-Polyfills.class.ts +1 -0
- package/tests/A-Config.test.ts +1 -2
- package/tsconfig.json +1 -0
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { A_Container } from "@adaas/a-concept";
|
|
2
|
-
import { A_Config } from "./A-Config.context";
|
|
3
2
|
import { A_Polyfill } from "../A-Polyfill/A-Polyfill.component";
|
|
4
3
|
export declare class A_ConfigLoader extends A_Container {
|
|
5
4
|
private reader;
|
|
6
5
|
prepare(polyfill: A_Polyfill): Promise<void>;
|
|
7
|
-
readVariables(config: A_Config): Promise<void>;
|
|
8
6
|
}
|
|
@@ -25,9 +25,20 @@ const A_Polyfill_component_1 = require("../A-Polyfill/A-Polyfill.component");
|
|
|
25
25
|
const A_Config_error_1 = require("./A-Config.error");
|
|
26
26
|
const FileConfigReader_component_1 = require("./components/FileConfigReader.component");
|
|
27
27
|
const ENVConfigReader_component_1 = require("./components/ENVConfigReader.component");
|
|
28
|
+
const A_Config_constants_1 = require("./A-Config.constants");
|
|
28
29
|
class A_ConfigLoader extends a_concept_1.A_Container {
|
|
29
30
|
prepare(polyfill) {
|
|
30
31
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
if (!this.scope.has(A_Config_context_1.A_Config)) {
|
|
33
|
+
const newConfig = new A_Config_context_1.A_Config({
|
|
34
|
+
variables: [
|
|
35
|
+
...a_concept_1.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
36
|
+
...A_Config_constants_1.A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
|
|
37
|
+
],
|
|
38
|
+
defaults: {}
|
|
39
|
+
});
|
|
40
|
+
this.scope.register(newConfig);
|
|
41
|
+
}
|
|
31
42
|
const fs = yield polyfill.fs();
|
|
32
43
|
try {
|
|
33
44
|
switch (true) {
|
|
@@ -55,21 +66,12 @@ class A_ConfigLoader extends a_concept_1.A_Container {
|
|
|
55
66
|
}
|
|
56
67
|
});
|
|
57
68
|
}
|
|
58
|
-
readVariables(config) {
|
|
59
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
yield this.reader.inject(config);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
69
|
}
|
|
64
70
|
exports.A_ConfigLoader = A_ConfigLoader;
|
|
65
|
-
__decorate([
|
|
66
|
-
a_concept_1.A_Concept.Load(),
|
|
67
|
-
__param(0, (0, a_concept_1.A_Inject)(A_Polyfill_component_1.A_Polyfill))
|
|
68
|
-
], A_ConfigLoader.prototype, "prepare", null);
|
|
69
71
|
__decorate([
|
|
70
72
|
a_concept_1.A_Concept.Load({
|
|
71
|
-
|
|
73
|
+
before: [/.*/]
|
|
72
74
|
}),
|
|
73
|
-
__param(0, (0, a_concept_1.A_Inject)(
|
|
74
|
-
], A_ConfigLoader.prototype, "
|
|
75
|
+
__param(0, (0, a_concept_1.A_Inject)(A_Polyfill_component_1.A_Polyfill))
|
|
76
|
+
], A_ConfigLoader.prototype, "prepare", null);
|
|
75
77
|
//# sourceMappingURL=A-Config.container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Config.container.js","sourceRoot":"","sources":["../../../../src/lib/A-Config/A-Config.container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"A-Config.container.js","sourceRoot":"","sources":["../../../../src/lib/A-Config/A-Config.container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,gDAA0J;AAE1J,yDAA8C;AAC9C,6EAAgE;AAChE,qDAAiD;AACjD,wFAA2E;AAC3E,sFAAyE;AACzE,6DAA+E;AAG/E,MAAa,cAAe,SAAQ,uBAAW;IAQrC,OAAO,CACa,QAAoB;;YAE1C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,2BAAQ,CAAC,EAAE,CAAC;gBAC5B,MAAM,SAAS,GAAG,IAAI,2BAAQ,CAAC;oBAC3B,SAAS,EAAE;wBACP,GAAG,oDAAwC;wBAC3C,GAAG,4DAAuC;qBACpC;oBACV,QAAQ,EAAE,EAAE;iBACf,CAAC,CAAC;gBAEH,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YACnC,CAAC;YAGD,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC,EAAE,EAAE,CAAC;YAE/B,IAAI,CAAC;gBACD,QAAQ,IAAI,EAAE,CAAC;oBAEX,KAAK,qBAAS,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,CAAC,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_Config } from "../A-Config.context";
|
|
3
3
|
import { A_Polyfill } from "../../A-Polyfill/A-Polyfill.component";
|
|
4
4
|
/**
|
|
5
5
|
* Config Reader
|
|
6
6
|
*/
|
|
7
7
|
export declare class ConfigReader extends A_Component {
|
|
8
|
-
protected scope: A_Scope;
|
|
9
8
|
protected polyfill: A_Polyfill;
|
|
10
|
-
constructor(
|
|
11
|
-
|
|
9
|
+
constructor(polyfill: A_Polyfill);
|
|
10
|
+
attachContext(container: A_Container, feature: A_Feature): Promise<void>;
|
|
11
|
+
initialize(config: A_Config): Promise<void>;
|
|
12
12
|
/**
|
|
13
13
|
* Get the configuration property by Name
|
|
14
14
|
* @param property
|
|
@@ -27,12 +27,28 @@ const A_Polyfill_component_1 = require("../../A-Polyfill/A-Polyfill.component");
|
|
|
27
27
|
* Config Reader
|
|
28
28
|
*/
|
|
29
29
|
let ConfigReader = class ConfigReader extends a_concept_1.A_Component {
|
|
30
|
-
constructor(
|
|
30
|
+
constructor(polyfill) {
|
|
31
31
|
super();
|
|
32
|
-
this.scope = scope;
|
|
33
32
|
this.polyfill = polyfill;
|
|
34
33
|
}
|
|
35
|
-
|
|
34
|
+
attachContext(container, feature) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
if (!container.scope.has(A_Config_context_1.A_Config)) {
|
|
37
|
+
const newConfig = new A_Config_context_1.A_Config({
|
|
38
|
+
variables: [
|
|
39
|
+
...a_concept_1.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
40
|
+
...A_Config_constants_1.A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
|
|
41
|
+
],
|
|
42
|
+
defaults: {}
|
|
43
|
+
});
|
|
44
|
+
container.scope.register(newConfig);
|
|
45
|
+
}
|
|
46
|
+
const config = container.scope.resolve(A_Config_context_1.A_Config);
|
|
47
|
+
const rootDir = yield this.getProjectRoot();
|
|
48
|
+
config.set('A_CONCEPT_ROOT_FOLDER', rootDir);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
initialize(config) {
|
|
36
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
53
|
const data = yield this.read([
|
|
38
54
|
...config.CONFIG_PROPERTIES,
|
|
@@ -40,8 +56,6 @@ let ConfigReader = class ConfigReader extends a_concept_1.A_Component {
|
|
|
40
56
|
...A_Config_constants_1.A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
|
|
41
57
|
]);
|
|
42
58
|
config.set(data);
|
|
43
|
-
const rootDir = yield this.getProjectRoot();
|
|
44
|
-
config.set('A_CONCEPT_ROOT_FOLDER', rootDir);
|
|
45
59
|
});
|
|
46
60
|
}
|
|
47
61
|
/**
|
|
@@ -74,12 +88,16 @@ let ConfigReader = class ConfigReader extends a_concept_1.A_Component {
|
|
|
74
88
|
}
|
|
75
89
|
};
|
|
76
90
|
exports.ConfigReader = ConfigReader;
|
|
91
|
+
__decorate([
|
|
92
|
+
a_concept_1.A_Concept.Load(),
|
|
93
|
+
__param(0, (0, a_concept_1.A_Inject)(a_concept_1.A_Container)),
|
|
94
|
+
__param(1, (0, a_concept_1.A_Inject)(a_concept_1.A_Feature))
|
|
95
|
+
], ConfigReader.prototype, "attachContext", null);
|
|
77
96
|
__decorate([
|
|
78
97
|
a_concept_1.A_Concept.Load(),
|
|
79
98
|
__param(0, (0, a_concept_1.A_Inject)(A_Config_context_1.A_Config))
|
|
80
|
-
], ConfigReader.prototype, "
|
|
99
|
+
], ConfigReader.prototype, "initialize", null);
|
|
81
100
|
exports.ConfigReader = ConfigReader = __decorate([
|
|
82
|
-
__param(0, (0, a_concept_1.A_Inject)(
|
|
83
|
-
__param(1, (0, a_concept_1.A_Inject)(A_Polyfill_component_1.A_Polyfill))
|
|
101
|
+
__param(0, (0, a_concept_1.A_Inject)(A_Polyfill_component_1.A_Polyfill))
|
|
84
102
|
], ConfigReader);
|
|
85
103
|
//# sourceMappingURL=ConfigReader.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigReader.component.js","sourceRoot":"","sources":["../../../../../src/lib/A-Config/components/ConfigReader.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"ConfigReader.component.js","sourceRoot":"","sources":["../../../../../src/lib/A-Config/components/ConfigReader.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,gDAAsI;AACtI,0DAA+C;AAC/C,8DAAgF;AAChF,gFAAmE;AAEnE;;GAEG;AACI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,uBAAW;IAEzC,YACoC,QAAoB;QAEpD,KAAK,EAAE,CAAC;QAFwB,aAAQ,GAAR,QAAQ,CAAY;IAGxD,CAAC;IAGK,aAAa,CACQ,SAAsB,EACxB,OAAkB;;YAEvC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,2BAAQ,CAAC,EAAE,CAAC;gBACjC,MAAM,SAAS,GAAG,IAAI,2BAAQ,CAAC;oBAC3B,SAAS,EAAE;wBACP,GAAG,oDAAwC;wBAC3C,GAAG,4DAAuC;qBACpC;oBACV,QAAQ,EAAE,EAAE;iBACf,CAAC,CAAC;gBAEH,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YACxC,CAAC;YAGD,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAW,2BAAQ,CAAC,CAAC;YAE3D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAE5C,MAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC;KAAA;IAGK,UAAU,CACQ,MAAgB;;YAEpC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC;gBACzB,GAAG,MAAM,CAAC,iBAAiB;gBAC3B,GAAG,oDAAwC;gBAC3C,GAAG,4DAAuC;aAC7C,CAAC,CAAC;YAEH,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;KAAA;IAID;;;OAGG;IACH,OAAO,CAAoB,QAAgB;QACvC,OAAO,QAAuB,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACG,IAAI;6DACN,YAAsB,EAAE;YAExB,OAAO,EAAoB,CAAC;QAChC,CAAC;KAAA;IAGD;;;;;OAKG;IACa,cAAc;6DAAC,SAAS,GAAG,SAAS;YAChD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;QACzB,CAAC;KAAA;CACJ,CAAA;AA7EY,oCAAY;AASf;IADL,qBAAS,CAAC,IAAI,EAAE;IAEZ,WAAA,IAAA,oBAAQ,EAAC,uBAAW,CAAC,CAAA;IACrB,WAAA,IAAA,oBAAQ,EAAC,qBAAS,CAAC,CAAA;iDAoBvB;AAGK;IADL,qBAAS,CAAC,IAAI,EAAE;IAEZ,WAAA,IAAA,oBAAQ,EAAC,2BAAQ,CAAC,CAAA;8CAStB;uBA5CQ,YAAY;IAGhB,WAAA,IAAA,oBAAQ,EAAC,iCAAU,CAAC,CAAA;GAHhB,YAAY,CA6ExB"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { A_Feature, A_TYPES__ConceptENVVariables } from "@adaas/a-concept";
|
|
1
2
|
import { ConfigReader } from "./ConfigReader.component";
|
|
3
|
+
import { A_Config } from "../A-Config.context";
|
|
4
|
+
import { A_Polyfill } from "../../A-Polyfill/A-Polyfill.component";
|
|
2
5
|
export declare class ENVConfigReader extends ConfigReader {
|
|
6
|
+
readEnvFile(config: A_Config<A_TYPES__ConceptENVVariables>, polyfill: A_Polyfill, feature: A_Feature): Promise<void>;
|
|
3
7
|
/**
|
|
4
8
|
* Get the configuration property Name
|
|
5
9
|
* @param property
|
|
@@ -1,4 +1,13 @@
|
|
|
1
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
9
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
10
|
+
};
|
|
2
11
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
12
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
13
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -12,7 +21,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
21
|
exports.ENVConfigReader = void 0;
|
|
13
22
|
const a_concept_1 = require("@adaas/a-concept");
|
|
14
23
|
const ConfigReader_component_1 = require("./ConfigReader.component");
|
|
24
|
+
const A_Config_context_1 = require("../A-Config.context");
|
|
25
|
+
const A_Polyfill_component_1 = require("../../A-Polyfill/A-Polyfill.component");
|
|
15
26
|
class ENVConfigReader extends ConfigReader_component_1.ConfigReader {
|
|
27
|
+
readEnvFile(config, polyfill, feature) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const fs = yield polyfill.fs();
|
|
30
|
+
if (fs.existsSync('.env'))
|
|
31
|
+
fs.readFileSync(`${config.get('A_CONCEPT_ROOT_FOLDER')}/.env`, 'utf-8').split('\n').forEach(line => {
|
|
32
|
+
const [key, value] = line.split('=');
|
|
33
|
+
if (key && value) {
|
|
34
|
+
process.env[key.trim()] = value.trim();
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
16
39
|
/**
|
|
17
40
|
* Get the configuration property Name
|
|
18
41
|
* @param property
|
|
@@ -25,8 +48,12 @@ class ENVConfigReader extends ConfigReader_component_1.ConfigReader {
|
|
|
25
48
|
}
|
|
26
49
|
read() {
|
|
27
50
|
return __awaiter(this, arguments, void 0, function* (variables = []) {
|
|
51
|
+
const allVariables = [
|
|
52
|
+
...variables,
|
|
53
|
+
...Object.keys(process.env),
|
|
54
|
+
];
|
|
28
55
|
const config = {};
|
|
29
|
-
|
|
56
|
+
allVariables.forEach(variable => {
|
|
30
57
|
config[variable] = this.resolve(variable);
|
|
31
58
|
});
|
|
32
59
|
return config;
|
|
@@ -34,4 +61,12 @@ class ENVConfigReader extends ConfigReader_component_1.ConfigReader {
|
|
|
34
61
|
}
|
|
35
62
|
}
|
|
36
63
|
exports.ENVConfigReader = ENVConfigReader;
|
|
64
|
+
__decorate([
|
|
65
|
+
a_concept_1.A_Concept.Load({
|
|
66
|
+
before: ['ENVConfigReader.initialize']
|
|
67
|
+
}),
|
|
68
|
+
__param(0, (0, a_concept_1.A_Inject)(A_Config_context_1.A_Config)),
|
|
69
|
+
__param(1, (0, a_concept_1.A_Inject)(A_Polyfill_component_1.A_Polyfill)),
|
|
70
|
+
__param(2, (0, a_concept_1.A_Inject)(a_concept_1.A_Feature))
|
|
71
|
+
], ENVConfigReader.prototype, "readEnvFile", null);
|
|
37
72
|
//# sourceMappingURL=ENVConfigReader.component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ENVConfigReader.component.js","sourceRoot":"","sources":["../../../../../src/lib/A-Config/components/ENVConfigReader.component.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ENVConfigReader.component.js","sourceRoot":"","sources":["../../../../../src/lib/A-Config/components/ENVConfigReader.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,gDAAmH;AACnH,qEAAwD;AACxD,0DAA+C;AAC/C,gFAAmE;AAGnE,MAAa,eAAgB,SAAQ,qCAAY;IAMv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B,CAAC;KAAA;CACJ;AApDD,0CAoDC;AA9CS;IAHL,qBAAS,CAAC,IAAI,CAAC;QACZ,MAAM,EAAE,CAAC,4BAA4B,CAAC;KACzC,CAAC;IAEG,WAAA,IAAA,oBAAQ,EAAC,2BAAQ,CAAC,CAAA;IAClB,WAAA,IAAA,oBAAQ,EAAC,iCAAU,CAAC,CAAA;IACpB,WAAA,IAAA,oBAAQ,EAAC,qBAAS,CAAC,CAAA;kDAYvB"}
|
|
@@ -9,12 +9,12 @@ export declare class A_Polyfill extends A_Component {
|
|
|
9
9
|
*
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
|
-
fs(): Promise<Ifspolyfill>;
|
|
12
|
+
fs(): Promise<import("./A-Polyfill.types").Ifspolyfill>;
|
|
13
13
|
/**
|
|
14
14
|
* Allows to use the 'crypto' polyfill methods regardless of the environment
|
|
15
15
|
* This method loads the 'crypto' polyfill and returns its instance
|
|
16
16
|
*
|
|
17
17
|
* @returns
|
|
18
18
|
*/
|
|
19
|
-
crypto(): Promise<IcryptoInterface>;
|
|
19
|
+
crypto(): Promise<import("./A-Polyfill.types").IcryptoInterface>;
|
|
20
20
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
interface Ifspolyfill {
|
|
1
|
+
export interface Ifspolyfill {
|
|
2
2
|
readFileSync: (path: string, encoding: string) => string;
|
|
3
3
|
existsSync: (path: string) => boolean;
|
|
4
4
|
createReadStream: (path: string, options?: BufferEncoding) => any;
|
|
5
5
|
}
|
|
6
|
-
interface IcryptoInterface {
|
|
6
|
+
export interface IcryptoInterface {
|
|
7
7
|
createTextHash(text: string, algorithm: string): Promise<string>;
|
|
8
8
|
createFileHash(filePath: string, algorithm: string): Promise<string>;
|
|
9
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Polyfills.class.js","sourceRoot":"","sources":["../../../../src/lib/A-Polyfill/A-Polyfills.class.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;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AAC;gBAEF,IAAI,CAAC,OAAO,GAAG;oBACX,cAAc,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;oBACzC,cAAc,EAAE,CAAC,IAAY,EAAE,YAAoB,SAAS,EAAE,EAAE,CAAC,IAAI,OAAO,CAAS,CAAO,OAAO,EAAE,MAAM,EAAE,EAAE;wBAC3G,IAAI,CAAC;4BACD,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;4BAClC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;4BAClC,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;4BAC/D,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;4BACzD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,CAAQ,CAAC,CAAC,CAAC,CAAC;4BACzG,OAAO,OAAO,CAAC,GAAG,SAAS,IAAI,UAAU,EAAE,CAAC,CAAC;wBACjD,CAAC;wBAAC,OAAO,KAAK,EAAE,CAAC;4BACb,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;wBACzB,CAAC;oBACL,CAAC,CAAA,CAAC;iBACL,CAAC;YACN,CAAC;QACL,CAAC;KAAA;CACJ;AA9FD,0CA8FC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { A_Concept, A_Container } from "@adaas/a-concept"
|
|
2
|
+
import { A_ConfigLoader } from "@adaas/a-utils/lib/A-Config/A-Config.container";
|
|
3
|
+
import { A_Config } from "@adaas/a-utils/lib/A-Config/A-Config.context";
|
|
4
|
+
import { ENVConfigReader } from "@adaas/a-utils/lib/A-Config/components/ENVConfigReader.component";
|
|
5
|
+
import { A_Polyfill } from "@adaas/a-utils/lib/A-Polyfill/A-Polyfill.component";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
(async () => {
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
const service1 = new A_ConfigLoader({
|
|
13
|
+
name: 'ConfigLoaderContainer',
|
|
14
|
+
components: [
|
|
15
|
+
A_Polyfill, ENVConfigReader
|
|
16
|
+
]
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const concept = new A_Concept({
|
|
20
|
+
name: 'test-config',
|
|
21
|
+
containers: [service1],
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
await concept.load();
|
|
26
|
+
await concept.start();
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
const config = service1.scope.resolve<A_Config<['ADAAS_SSO_LOCATION']>>(A_Config);
|
|
30
|
+
|
|
31
|
+
console.log('config: ', config.get('ADAAS_SSO_LOCATION'))
|
|
32
|
+
|
|
33
|
+
})()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "A-Utils is a set of utilities that are used across the ADAAS ecosystem. This package is designed to be a collection of utilities that are used across the ADAAS ecosystem.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"scripts": {
|
|
27
27
|
"test": "jest ",
|
|
28
28
|
"start": "nodemon ./tests/log.ts",
|
|
29
|
+
"examples:config": "nodemon ./examples/config.ts",
|
|
29
30
|
"publish": "npm run test && npm run build && git add . && git commit -m \"new version created :: $(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g')\" && npm version patch && npm publish --access public",
|
|
30
31
|
"preversion": "echo test",
|
|
31
32
|
"version": "echo git add .",
|
|
@@ -49,7 +50,7 @@
|
|
|
49
50
|
},
|
|
50
51
|
"homepage": "https://github.com/ADAAS-org/adaas-adf-auth#readme",
|
|
51
52
|
"dependencies": {
|
|
52
|
-
"@adaas/a-concept": "^0.1.
|
|
53
|
+
"@adaas/a-concept": "^0.1.22"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@types/chai": "^4.3.14",
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { A_Concept, A_Container, A_Context, A_Inject, A_ScopeError } from "@adaas/a-concept";
|
|
1
|
+
import { A_Caller, A_Concept, A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY, A_Container, A_Context, A_Inject, A_Scope, A_ScopeError } from "@adaas/a-concept";
|
|
2
2
|
import { ConfigReader } from "./components/ConfigReader.component";
|
|
3
3
|
import { A_Config } from "./A-Config.context";
|
|
4
4
|
import { A_Polyfill } from "../A-Polyfill/A-Polyfill.component";
|
|
5
5
|
import { A_ConfigError } from "./A-Config.error";
|
|
6
6
|
import { FileConfigReader } from "./components/FileConfigReader.component";
|
|
7
7
|
import { ENVConfigReader } from "./components/ENVConfigReader.component";
|
|
8
|
+
import { A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY } from "./A-Config.constants";
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
export class A_ConfigLoader extends A_Container {
|
|
@@ -12,10 +13,25 @@ export class A_ConfigLoader extends A_Container {
|
|
|
12
13
|
private reader!: ConfigReader
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
@A_Concept.Load(
|
|
16
|
+
@A_Concept.Load({
|
|
17
|
+
before: [/.*/]
|
|
18
|
+
})
|
|
16
19
|
async prepare(
|
|
17
|
-
@A_Inject(A_Polyfill) polyfill: A_Polyfill
|
|
20
|
+
@A_Inject(A_Polyfill) polyfill: A_Polyfill
|
|
18
21
|
) {
|
|
22
|
+
if (!this.scope.has(A_Config)) {
|
|
23
|
+
const newConfig = new A_Config({
|
|
24
|
+
variables: [
|
|
25
|
+
...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
26
|
+
...A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
|
|
27
|
+
] as const,
|
|
28
|
+
defaults: {}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
this.scope.register(newConfig);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
19
35
|
const fs = await polyfill.fs();
|
|
20
36
|
|
|
21
37
|
try {
|
|
@@ -48,16 +64,5 @@ export class A_ConfigLoader extends A_Container {
|
|
|
48
64
|
})
|
|
49
65
|
}
|
|
50
66
|
}
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
@A_Concept.Load({
|
|
56
|
-
after: ['A_ConfigLoader.prepare']
|
|
57
|
-
})
|
|
58
|
-
async readVariables(
|
|
59
|
-
@A_Inject(A_Config) config: A_Config,
|
|
60
|
-
) {
|
|
61
|
-
await this.reader.inject(config);
|
|
62
67
|
}
|
|
63
68
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A_Component, A_Concept, A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
1
|
+
import { A_Component, A_Concept, A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY, A_Container, A_Feature, A_Inject } from "@adaas/a-concept";
|
|
2
2
|
import { A_Config } from "../A-Config.context";
|
|
3
3
|
import { A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY } from "../A-Config.constants";
|
|
4
4
|
import { A_Polyfill } from "../../A-Polyfill/A-Polyfill.component";
|
|
@@ -9,18 +9,40 @@ import { A_Polyfill } from "../../A-Polyfill/A-Polyfill.component";
|
|
|
9
9
|
export class ConfigReader extends A_Component {
|
|
10
10
|
|
|
11
11
|
constructor(
|
|
12
|
-
@A_Inject(A_Scope) protected scope: A_Scope,
|
|
13
12
|
@A_Inject(A_Polyfill) protected polyfill: A_Polyfill,
|
|
14
13
|
) {
|
|
15
14
|
super();
|
|
16
15
|
}
|
|
17
16
|
|
|
17
|
+
@A_Concept.Load()
|
|
18
|
+
async attachContext(
|
|
19
|
+
@A_Inject(A_Container) container: A_Container,
|
|
20
|
+
@A_Inject(A_Feature) feature: A_Feature,
|
|
21
|
+
) {
|
|
22
|
+
if (!container.scope.has(A_Config)) {
|
|
23
|
+
const newConfig = new A_Config({
|
|
24
|
+
variables: [
|
|
25
|
+
...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
26
|
+
...A_CONSTANTS__CONFIG_ENV_VARIABLES_ARRAY
|
|
27
|
+
] as const,
|
|
28
|
+
defaults: {}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
container.scope.register(newConfig);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
const config = container.scope.resolve<A_Config>(A_Config);
|
|
36
|
+
|
|
37
|
+
const rootDir = await this.getProjectRoot();
|
|
38
|
+
|
|
39
|
+
config.set('A_CONCEPT_ROOT_FOLDER', rootDir);
|
|
40
|
+
}
|
|
18
41
|
|
|
19
42
|
@A_Concept.Load()
|
|
20
|
-
async
|
|
43
|
+
async initialize(
|
|
21
44
|
@A_Inject(A_Config) config: A_Config,
|
|
22
45
|
) {
|
|
23
|
-
|
|
24
46
|
const data = await this.read([
|
|
25
47
|
...config.CONFIG_PROPERTIES,
|
|
26
48
|
...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY,
|
|
@@ -28,13 +50,10 @@ export class ConfigReader extends A_Component {
|
|
|
28
50
|
]);
|
|
29
51
|
|
|
30
52
|
config.set(data);
|
|
31
|
-
|
|
32
|
-
const rootDir = await this.getProjectRoot();
|
|
33
|
-
|
|
34
|
-
config.set('A_CONCEPT_ROOT_FOLDER', rootDir);
|
|
35
53
|
}
|
|
36
54
|
|
|
37
55
|
|
|
56
|
+
|
|
38
57
|
/**
|
|
39
58
|
* Get the configuration property by Name
|
|
40
59
|
* @param property
|
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
import { A_FormatterHelper } from "@adaas/a-concept";
|
|
1
|
+
import { A_Concept, A_Feature, A_FormatterHelper, A_Inject, A_TYPES__ConceptENVVariables } from "@adaas/a-concept";
|
|
2
2
|
import { ConfigReader } from "./ConfigReader.component";
|
|
3
|
+
import { A_Config } from "../A-Config.context";
|
|
4
|
+
import { A_Polyfill } from "../../A-Polyfill/A-Polyfill.component";
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
export class ENVConfigReader extends ConfigReader {
|
|
6
8
|
|
|
7
9
|
|
|
10
|
+
@A_Concept.Load({
|
|
11
|
+
before: ['ENVConfigReader.initialize']
|
|
12
|
+
})
|
|
13
|
+
async readEnvFile(
|
|
14
|
+
@A_Inject(A_Config) config: A_Config<A_TYPES__ConceptENVVariables>,
|
|
15
|
+
@A_Inject(A_Polyfill) polyfill: A_Polyfill,
|
|
16
|
+
@A_Inject(A_Feature) feature: A_Feature,
|
|
17
|
+
|
|
18
|
+
) {
|
|
19
|
+
const fs = await polyfill.fs();
|
|
20
|
+
|
|
21
|
+
if (fs.existsSync('.env'))
|
|
22
|
+
fs.readFileSync(`${config.get('A_CONCEPT_ROOT_FOLDER')}/.env`, 'utf-8').split('\n').forEach(line => {
|
|
23
|
+
const [key, value] = line.split('=');
|
|
24
|
+
if (key && value) {
|
|
25
|
+
process.env[key.trim()] = value.trim();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
8
31
|
/**
|
|
9
32
|
* Get the configuration property Name
|
|
10
33
|
* @param property
|
|
@@ -20,9 +43,14 @@ export class ENVConfigReader extends ConfigReader {
|
|
|
20
43
|
|
|
21
44
|
|
|
22
45
|
async read<T extends string>(variables: Array<T> = []): Promise<Record<T, any>> {
|
|
46
|
+
const allVariables = [
|
|
47
|
+
...variables,
|
|
48
|
+
...Object.keys(process.env),
|
|
49
|
+
]
|
|
50
|
+
|
|
23
51
|
const config: Record<T, any> = {} as Record<T, any>;
|
|
24
52
|
|
|
25
|
-
|
|
53
|
+
allVariables.forEach(variable => {
|
|
26
54
|
config[variable] = this.resolve(variable);
|
|
27
55
|
});
|
|
28
56
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
interface Ifspolyfill {
|
|
1
|
+
export interface Ifspolyfill {
|
|
2
2
|
readFileSync: (path: string, encoding: string) => string;
|
|
3
3
|
existsSync: (path: string) => boolean;
|
|
4
4
|
createReadStream: (path: string, options?: BufferEncoding) => any
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
interface IcryptoInterface {
|
|
7
|
+
export interface IcryptoInterface {
|
|
8
8
|
createTextHash(text: string, algorithm: string): Promise<string>
|
|
9
9
|
createFileHash(filePath: string, algorithm: string): Promise<string>
|
|
10
10
|
}
|
package/tests/A-Config.test.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { A_Polyfill } from '@adaas/a-utils/lib/A-Polyfill/A-Polyfill.component';
|
|
|
9
9
|
import { A_ConfigLoader } from '@adaas/a-utils/lib/A-Config/A-Config.container';
|
|
10
10
|
import { ENVConfigReader } from '@adaas/a-utils/lib/A-Config/components/ENVConfigReader.component';
|
|
11
11
|
import { FileConfigReader } from '@adaas/a-utils/lib/A-Config/components/FileConfigReader.component';
|
|
12
|
+
import { A_TYPES__ComponentMetaKey } from '@adaas/a-concept/dist/src/global/A-Component/A-Component.constants';
|
|
12
13
|
|
|
13
14
|
jest.retryTimes(0);
|
|
14
15
|
|
|
@@ -139,8 +140,6 @@ describe('A-Config tests', () => {
|
|
|
139
140
|
|
|
140
141
|
await concept.load();
|
|
141
142
|
|
|
142
|
-
|
|
143
|
-
|
|
144
143
|
expect(config.get('TEST_VAR1')).toBe('env1');
|
|
145
144
|
expect(config.get('TEST_VAR1')).toBe('env1');
|
|
146
145
|
|