@adaas/a-concept 0.0.27 → 0.0.29
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/examples/simple/concept.js +2 -2
- package/dist/examples/simple/concept.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.container.d.ts +3 -2
- package/dist/src/base/A-Config/A-Config.container.js +23 -5
- package/dist/src/base/A-Config/A-Config.container.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.context.d.ts +1 -1
- package/dist/src/base/A-Config/A-Config.context.js +1 -0
- package/dist/src/base/A-Config/A-Config.context.js.map +1 -1
- package/dist/src/base/A-Config/components/ConfigReader.component.d.ts +9 -0
- package/dist/src/base/A-Config/components/ConfigReader.component.js +35 -0
- package/dist/src/base/A-Config/components/ConfigReader.component.js.map +1 -1
- package/dist/src/base/A-Logger/A-Logger.component.d.ts +1 -0
- package/dist/src/base/A-Logger/A-Logger.component.js +7 -2
- package/dist/src/base/A-Logger/A-Logger.component.js.map +1 -1
- package/dist/src/base/A-Polyfill/A-Polyfill.component.d.ts +5 -0
- package/dist/src/base/A-Polyfill/A-Polyfill.component.js +34 -0
- package/dist/src/base/A-Polyfill/A-Polyfill.component.js.map +1 -0
- package/dist/src/decorators/A-Stage/A-Stage.decorator.d.ts +2 -1
- package/dist/src/decorators/A-Stage/A-Stage.decorator.js +24 -7
- package/dist/src/decorators/A-Stage/A-Stage.decorator.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.types.d.ts +2 -1
- package/dist/src/global/A-Component/A-Component.types.js +1 -0
- package/dist/src/global/A-Component/A-Component.types.js.map +1 -1
- package/dist/src/global/A-Concept/A_Concept.class.d.ts +7 -7
- package/examples/simple/concept.ts +2 -2
- package/package.json +1 -1
- package/src/base/A-Config/A-Config.container.ts +11 -8
- package/src/base/A-Config/A-Config.context.ts +1 -0
- package/src/base/A-Config/components/ConfigReader.component.ts +41 -0
- package/src/base/A-Logger/A-Logger.component.ts +8 -2
- package/src/base/A-Polyfill/A-Polyfill.component.ts +18 -0
- package/src/decorators/A-Stage/A-Stage.decorator.ts +38 -11
- package/src/global/A-Component/A-Component.types.ts +1 -0
|
@@ -61,8 +61,8 @@ const ENVConfigReader_component_1 = require("../../src/base/A-Config/components/
|
|
|
61
61
|
ENVConfigReader_component_1.ENVConfigReader
|
|
62
62
|
]
|
|
63
63
|
});
|
|
64
|
-
yield configLoader.
|
|
65
|
-
yield configLoader.readVariables();
|
|
64
|
+
yield configLoader.prepare(configContext);
|
|
65
|
+
yield configLoader.readVariables(configContext);
|
|
66
66
|
const container = new Main_container_1.MainContainer({
|
|
67
67
|
name: 'MainContainer',
|
|
68
68
|
components: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"concept.js","sourceRoot":"","sources":["../../../examples/simple/concept.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,gEAA4D;AAC5D,0DAAsD;AACtD,0DAAsD;AACtD,0FAA6E;AAC7E,qEAAgE;AAChE,qEAAgE;AAChE,sFAA2E;AAC3E,0FAAmF;AACnF,mHAAsG;AAEtG,CAAC,GAAS,EAAE;IAER,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAErB,+CAA+C;IAE/C,IAAI;IAGJ,wCAAwC;IACxC,8BAA8B;IAC9B,mBAAmB;IACnB,yBAAyB;IACzB,0CAA0C;IAC1C,0BAA0B;IAC1B,wBAAwB;IACxB,gBAAgB;IAChB,cAAc;IACd,yBAAyB;IACzB,wBAAwB;IACxB,oBAAoB;IACpB,0CAA0C;IAC1C,8CAA8C;IAC9C,yCAAyC;IACzC,oBAAoB;IACpB,gBAAgB;IAChB,aAAa;IACb,SAAS;IACT,oBAAoB;IAEpB,sBAAsB;IACtB,QAAQ;IACR,MAAM;IAEN,sBAAsB;IACtB,kCAAkC;IAElC,MAAM,aAAa,GAAG,IAAI,2BAAQ,CAAC;QAC/B,SAAS,EAAE,CAAC,gBAAgB,CAAC;QAC7B,QAAQ,EAAE;YACN,gBAAgB,EAAE,IAAI;SACzB;KACJ,CAAC,CAAC;IAGH,MAAM,YAAY,GAAG,IAAI,mCAAc,CAAC;QACpC,SAAS,EAAE;YACP,aAAa;SAChB;QACD,UAAU,EAAE;YACR,2CAAe;SAClB;KACJ,CAAC,CAAC;IAEH,MAAM,YAAY,CAAC,
|
|
1
|
+
{"version":3,"file":"concept.js","sourceRoot":"","sources":["../../../examples/simple/concept.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,gEAA4D;AAC5D,0DAAsD;AACtD,0DAAsD;AACtD,0FAA6E;AAC7E,qEAAgE;AAChE,qEAAgE;AAChE,sFAA2E;AAC3E,0FAAmF;AACnF,mHAAsG;AAEtG,CAAC,GAAS,EAAE;IAER,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAErB,+CAA+C;IAE/C,IAAI;IAGJ,wCAAwC;IACxC,8BAA8B;IAC9B,mBAAmB;IACnB,yBAAyB;IACzB,0CAA0C;IAC1C,0BAA0B;IAC1B,wBAAwB;IACxB,gBAAgB;IAChB,cAAc;IACd,yBAAyB;IACzB,wBAAwB;IACxB,oBAAoB;IACpB,0CAA0C;IAC1C,8CAA8C;IAC9C,yCAAyC;IACzC,oBAAoB;IACpB,gBAAgB;IAChB,aAAa;IACb,SAAS;IACT,oBAAoB;IAEpB,sBAAsB;IACtB,QAAQ;IACR,MAAM;IAEN,sBAAsB;IACtB,kCAAkC;IAElC,MAAM,aAAa,GAAG,IAAI,2BAAQ,CAAC;QAC/B,SAAS,EAAE,CAAC,gBAAgB,CAAC;QAC7B,QAAQ,EAAE;YACN,gBAAgB,EAAE,IAAI;SACzB;KACJ,CAAC,CAAC;IAGH,MAAM,YAAY,GAAG,IAAI,mCAAc,CAAC;QACpC,SAAS,EAAE;YACP,aAAa;SAChB;QACD,UAAU,EAAE;YACR,2CAAe;SAClB;KACJ,CAAC,CAAC;IAEH,MAAM,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,YAAY,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAGhD,MAAM,SAAS,GAAG,IAAI,8BAAa,CAAC;QAChC,IAAI,EAAE,eAAe;QACrB,UAAU,EAAE;YACR,6BAAQ;YACR,wBAAU;YACV,wBAAU;SACb;QACD,SAAS,EAAE;YACP,aAAa;YACb,IAAI,qCAAgB,EAAE;YACtB,IAAI,qCAAgB,EAAE;SACzB;KACJ,CAAC,CAAC;IAEH,oCAAoC;IACpC,MAAM,SAAS,CAAC,QAAQ,EAAE,CAAC;AAC/B,CAAC,CAAA,CAAC,EAAE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { A_Container } from "../../global/A-Container/A-Container.class";
|
|
2
|
+
import { A_Config } from "./A-Config.context";
|
|
2
3
|
export declare class A_ConfigLoader extends A_Container<['load', 'read']> {
|
|
3
4
|
private reader;
|
|
4
|
-
|
|
5
|
-
readVariables(): Promise<void>;
|
|
5
|
+
prepare(config: A_Config): Promise<void>;
|
|
6
|
+
readVariables(config: A_Config): Promise<void>;
|
|
6
7
|
}
|
|
@@ -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) {
|
|
@@ -11,15 +20,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
21
|
exports.A_ConfigLoader = void 0;
|
|
13
22
|
const A_Container_class_1 = require("../../global/A-Container/A-Container.class");
|
|
23
|
+
const A_Inject_decorator_1 = require("../../decorators/A-Inject/A-Inject.decorator");
|
|
14
24
|
const a_utils_1 = require("@adaas/a-utils");
|
|
15
25
|
const A_Context_class_1 = require("../../global/A-Context/A-Context.class");
|
|
16
26
|
const FileConfigReader_component_1 = require("./components/FileConfigReader.component");
|
|
17
27
|
const ENVConfigReader_component_1 = require("./components/ENVConfigReader.component");
|
|
28
|
+
const A_Concept_class_1 = require("../../global/A-Concept/A_Concept.class");
|
|
29
|
+
const A_Config_context_1 = require("./A-Config.context");
|
|
18
30
|
class A_ConfigLoader extends A_Container_class_1.A_Container {
|
|
19
|
-
|
|
31
|
+
prepare(config) {
|
|
20
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
// OR Inject the logger by calling Context Provider
|
|
22
|
-
// const logger2 = await this.CP.resolve(A_LoggerContext);
|
|
23
33
|
const fs = yield a_utils_1.A_Polyfills.fs();
|
|
24
34
|
switch (true) {
|
|
25
35
|
case A_Context_class_1.A_Context.environment === 'server' && !!fs.existsSync(`${this.Scope.name}.conf.json`):
|
|
@@ -37,12 +47,20 @@ class A_ConfigLoader extends A_Container_class_1.A_Container {
|
|
|
37
47
|
}
|
|
38
48
|
});
|
|
39
49
|
}
|
|
40
|
-
readVariables() {
|
|
50
|
+
readVariables(config) {
|
|
41
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
|
|
52
|
+
yield this.reader.inject(config);
|
|
43
53
|
});
|
|
44
54
|
}
|
|
45
55
|
}
|
|
46
56
|
exports.A_ConfigLoader = A_ConfigLoader;
|
|
57
|
+
__decorate([
|
|
58
|
+
A_Concept_class_1.A_Concept.Load(),
|
|
59
|
+
__param(0, (0, A_Inject_decorator_1.A_Inject)(A_Config_context_1.A_Config))
|
|
60
|
+
], A_ConfigLoader.prototype, "prepare", null);
|
|
61
|
+
__decorate([
|
|
62
|
+
A_Concept_class_1.A_Concept.Load(),
|
|
63
|
+
__param(0, (0, A_Inject_decorator_1.A_Inject)(A_Config_context_1.A_Config))
|
|
64
|
+
], A_ConfigLoader.prototype, "readVariables", null);
|
|
47
65
|
const foo = new A_ConfigLoader({});
|
|
48
66
|
//# sourceMappingURL=A-Config.container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Config.container.js","sourceRoot":"","sources":["../../../../src/base/A-Config/A-Config.container.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"A-Config.container.js","sourceRoot":"","sources":["../../../../src/base/A-Config/A-Config.container.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,6FAAoF;AAGpF,gGAAmF;AACnF,4CAA6C;AAC7C,uFAA8E;AAC9E,wFAA2E;AAC3E,sFAAyE;AAEzE,uFAA8E;AAC9E,yDAA8C;AAM9C,MAAa,cAAe,SAAQ,+BAA6B;IAMvD,OAAO,CACW,MAAgB;;YAEpC,MAAM,EAAE,GAAG,MAAM,qBAAW,CAAC,EAAE,EAAE,CAAC;YAElC,QAAQ,IAAI,EAAE,CAAC;gBAEX,KAAK,2BAAS,CAAC,WAAW,KAAK,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC;oBACtF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,6CAAgB,CAAC,CAAC;oBACnD,MAAM;gBAEV,KAAK,2BAAS,CAAC,WAAW,KAAK,QAAQ;oBAAE,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,YAAY,CAAC,CAAA;oBACnF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,2CAAe,CAAC,CAAC;oBAClD,MAAM;gBAEV,KAAK,2BAAS,CAAC,WAAW,KAAK,SAAS;oBACpC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,2CAAe,CAAC,CAAC;oBAClD,MAAM;gBAEV;oBACI,MAAM,IAAI,KAAK,CAAC,eAAe,2BAAS,CAAC,WAAW,mBAAmB,CAAC,CAAC;YACjF,CAAC;QAEL,CAAC;KAAA;IAKK,aAAa,CACK,MAAgB;;YAEpC,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;KAAA;CAEJ;AAxCD,wCAwCC;AAlCS;IADL,2BAAS,CAAC,IAAI,EAAE;IAEZ,WAAA,IAAA,6BAAQ,EAAC,2BAAQ,CAAC,CAAA;6CAsBtB;AAKK;IADL,2BAAS,CAAC,IAAI,EAAE;IAEZ,WAAA,IAAA,6BAAQ,EAAC,2BAAQ,CAAC,CAAA;mDAGtB;AAML,MAAM,GAAG,GAAG,IAAI,cAAc,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -5,7 +5,7 @@ export declare class A_Config<T extends string = any> extends A_Fragment {
|
|
|
5
5
|
config: A_TYPES__ConfigContainerConstructor<T>;
|
|
6
6
|
private VARIABLES;
|
|
7
7
|
CONFIG_PROPERTIES: T[];
|
|
8
|
-
protected DEFAULT_ALLOWED_TO_READ_PROPERTIES: readonly ["CONFIG_SDK_VALIDATION", "CONFIG_VERBOSE", "CONFIG_IGNORE_ERRORS"];
|
|
8
|
+
protected DEFAULT_ALLOWED_TO_READ_PROPERTIES: readonly ["CONFIG_SDK_VALIDATION", "CONFIG_VERBOSE", "CONFIG_IGNORE_ERRORS", "CONCEPT_ROOT_FOLDER"];
|
|
9
9
|
constructor(config: A_TYPES__Required<Partial<A_TYPES__ConfigContainerConstructor<T>>, ['variables']>);
|
|
10
10
|
protected onInit(): Promise<void>;
|
|
11
11
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Config.context.js","sourceRoot":"","sources":["../../../../src/base/A-Config/A-Config.context.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAmE;AAEnE,0FAAiF;AAGjF,MAAa,QAEX,SAAQ,6BAAU;
|
|
1
|
+
{"version":3,"file":"A-Config.context.js","sourceRoot":"","sources":["../../../../src/base/A-Config/A-Config.context.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAmE;AAEnE,0FAAiF;AAGjF,MAAa,QAEX,SAAQ,6BAAU;IAiBhB,YACI,MAAyF;QAEzF,KAAK,CAAC,MAAM,CAAC,CAAC;QAhBlB,oBAAoB;QACZ,cAAS,GAAqB,IAAI,GAAG,EAAe,CAAC;QAE7D,sBAAiB,GAAQ,EAAE,CAAC;QAElB,uCAAkC,GAAG;YAC3C,uBAAuB;YACvB,gBAAgB;YAChB,sBAAsB;YACtB,qBAAqB;SACf,CAAC;QAQP,IAAI,CAAC,MAAM,GAAG,wBAAc,CAAC,iBAAiB,CAAyC,MAAa,EAAE;YAClG,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,KAAK;YACb,QAAQ,EAAE,EAAoB;YAC9B,SAAS,EAAE,EAAS;SACvB,CAAC,CAAC;QAEH,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IAChF,CAAC;IAEe,MAAM;;YAClB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;gBACvC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,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C,GAAG,CAAC,QAAkB,EAAE,WAAW,CAAC,CAAC;QACxD,CAAC;IACL,CAAC;CACJ;AA/GD,4BA+GC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { A_Scope } from "../../../global/A-Scope/A-Scope.class";
|
|
2
2
|
import { A_Component } from "../../../global/A-Component/A-Component.class";
|
|
3
|
+
import { A_Config } from "../A-Config.context";
|
|
3
4
|
/**
|
|
4
5
|
* Config Reader
|
|
5
6
|
*/
|
|
6
7
|
export declare class ConfigReader extends A_Component {
|
|
7
8
|
protected scope: A_Scope;
|
|
8
9
|
constructor(scope: A_Scope);
|
|
10
|
+
inject(config: A_Config): Promise<void>;
|
|
9
11
|
/**
|
|
10
12
|
* Get the configuration property by Name
|
|
11
13
|
* @param property
|
|
@@ -17,4 +19,11 @@ export declare class ConfigReader extends A_Component {
|
|
|
17
19
|
* @returns
|
|
18
20
|
*/
|
|
19
21
|
read<T extends string>(variables?: Array<T>): Promise<Record<T, any>>;
|
|
22
|
+
/**
|
|
23
|
+
* Finds the root directory of the project by locating the folder containing package.json
|
|
24
|
+
*
|
|
25
|
+
* @param {string} startPath - The initial directory to start searching from (default is __dirname)
|
|
26
|
+
* @returns {string|null} - The path to the root directory or null if package.json is not found
|
|
27
|
+
*/
|
|
28
|
+
protected getProjectRoot(startPath?: string): Promise<string>;
|
|
20
29
|
}
|
|
@@ -22,6 +22,8 @@ exports.ConfigReader = void 0;
|
|
|
22
22
|
const A_Scope_class_1 = require("../../../global/A-Scope/A-Scope.class");
|
|
23
23
|
const A_Inject_decorator_1 = require("../../../decorators/A-Inject/A-Inject.decorator");
|
|
24
24
|
const A_Component_class_1 = require("../../../global/A-Component/A-Component.class");
|
|
25
|
+
const A_Concept_class_1 = require("../../../global/A-Concept/A_Concept.class");
|
|
26
|
+
const A_Config_context_1 = require("../A-Config.context");
|
|
25
27
|
/**
|
|
26
28
|
* Config Reader
|
|
27
29
|
*/
|
|
@@ -30,6 +32,14 @@ let ConfigReader = class ConfigReader extends A_Component_class_1.A_Component {
|
|
|
30
32
|
super();
|
|
31
33
|
this.scope = scope;
|
|
32
34
|
}
|
|
35
|
+
inject(config) {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const data = this.read(config.CONFIG_PROPERTIES);
|
|
38
|
+
config.set(data);
|
|
39
|
+
const rootDir = yield this.getProjectRoot();
|
|
40
|
+
config.set('CONCEPT_ROOT_FOLDER', rootDir);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
33
43
|
/**
|
|
34
44
|
* Get the configuration property by Name
|
|
35
45
|
* @param property
|
|
@@ -47,8 +57,33 @@ let ConfigReader = class ConfigReader extends A_Component_class_1.A_Component {
|
|
|
47
57
|
return {};
|
|
48
58
|
});
|
|
49
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Finds the root directory of the project by locating the folder containing package.json
|
|
62
|
+
*
|
|
63
|
+
* @param {string} startPath - The initial directory to start searching from (default is __dirname)
|
|
64
|
+
* @returns {string|null} - The path to the root directory or null if package.json is not found
|
|
65
|
+
*/
|
|
66
|
+
getProjectRoot() {
|
|
67
|
+
return __awaiter(this, arguments, void 0, function* (startPath = __dirname) {
|
|
68
|
+
// let currentPath = startPath;
|
|
69
|
+
// const fs = await A_Polyfills.fs();
|
|
70
|
+
// while (!fs.existsSync(`${currentPath}/package.json`)) {
|
|
71
|
+
// const parentPath = currentPath.substring(0, currentPath.lastIndexOf('/'));
|
|
72
|
+
// if (parentPath === currentPath || parentPath === '') {
|
|
73
|
+
// // Reached the root of the filesystem without finding package.json
|
|
74
|
+
// return null;
|
|
75
|
+
// }
|
|
76
|
+
// currentPath = parentPath;
|
|
77
|
+
// }
|
|
78
|
+
return process.cwd();
|
|
79
|
+
});
|
|
80
|
+
}
|
|
50
81
|
};
|
|
51
82
|
exports.ConfigReader = ConfigReader;
|
|
83
|
+
__decorate([
|
|
84
|
+
A_Concept_class_1.A_Concept.Load(),
|
|
85
|
+
__param(0, (0, A_Inject_decorator_1.A_Inject)(A_Config_context_1.A_Config))
|
|
86
|
+
], ConfigReader.prototype, "inject", null);
|
|
52
87
|
exports.ConfigReader = ConfigReader = __decorate([
|
|
53
88
|
__param(0, (0, A_Inject_decorator_1.A_Inject)(A_Scope_class_1.A_Scope))
|
|
54
89
|
], ConfigReader);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigReader.component.js","sourceRoot":"","sources":["../../../../../src/base/A-Config/components/ConfigReader.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,iFAAwE;AACxE,gGAAmF;AACnF,6FAAoF;
|
|
1
|
+
{"version":3,"file":"ConfigReader.component.js","sourceRoot":"","sources":["../../../../../src/base/A-Config/components/ConfigReader.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,iFAAwE;AACxE,gGAAmF;AACnF,6FAAoF;AAEpF,uFAA8E;AAC9E,0DAA+C;AAI/C;;GAEG;AACI,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,+BAAW;IAEzC,YACiC,KAAc;QAE3C,KAAK,EAAE,CAAC;QAFqB,UAAK,GAAL,KAAK,CAAS;IAG/C,CAAC;IAIK,MAAM,CACY,MAAgB;;YAEpC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;YAEjD,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAEjB,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAE5C,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,OAAO,CAAC,CAAC;QAC/C,CAAC;KAAA;IAGD;;;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,+BAA+B;YAE/B,qCAAqC;YAErC,0DAA0D;YAC1D,iFAAiF;YACjF,6DAA6D;YAC7D,6EAA6E;YAC7E,uBAAuB;YACvB,QAAQ;YACR,gCAAgC;YAChC,IAAI;YAEJ,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;QACzB,CAAC;KAAA;CACJ,CAAA;AAjEY,oCAAY;AAUf;IADL,2BAAS,CAAC,IAAI,EAAE;IAEZ,WAAA,IAAA,6BAAQ,EAAC,2BAAQ,CAAC,CAAA;0CAStB;uBApBQ,YAAY;IAGhB,WAAA,IAAA,6BAAQ,EAAC,uBAAO,CAAC,CAAA;GAHb,YAAY,CAiExB"}
|
|
@@ -19,6 +19,7 @@ export declare class A_Logger extends A_Component {
|
|
|
19
19
|
};
|
|
20
20
|
get scopeLength(): number;
|
|
21
21
|
compile(color: keyof typeof this.colors, ...args: any[]): Array<string>;
|
|
22
|
+
protected get allowedToLog(): boolean;
|
|
22
23
|
log(color: keyof typeof this.colors, ...args: any[]): any;
|
|
23
24
|
log(...args: any[]): any;
|
|
24
25
|
warning(...args: any[]): void;
|
|
@@ -62,8 +62,13 @@ let A_Logger = class A_Logger extends A_Component_class_1.A_Component {
|
|
|
62
62
|
: '\x1b[0m')
|
|
63
63
|
];
|
|
64
64
|
}
|
|
65
|
+
get allowedToLog() {
|
|
66
|
+
return this.config.get('CONFIG_VERBOSE') !== undefined
|
|
67
|
+
&& this.config.get('CONFIG_VERBOSE') !== 'false'
|
|
68
|
+
&& this.config.get('CONFIG_VERBOSE') !== false;
|
|
69
|
+
}
|
|
65
70
|
log(param1, ...args) {
|
|
66
|
-
if (!this.
|
|
71
|
+
if (!this.allowedToLog)
|
|
67
72
|
return;
|
|
68
73
|
if (typeof param1 === 'string' && this.colors[param1]) {
|
|
69
74
|
console.log(...this.compile(param1, ...args));
|
|
@@ -74,7 +79,7 @@ let A_Logger = class A_Logger extends A_Component_class_1.A_Component {
|
|
|
74
79
|
}
|
|
75
80
|
}
|
|
76
81
|
warning(...args) {
|
|
77
|
-
if (!this.
|
|
82
|
+
if (!this.allowedToLog)
|
|
78
83
|
return;
|
|
79
84
|
console.log(...this.compile('yellow', ...args));
|
|
80
85
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Logger.component.js","sourceRoot":"","sources":["../../../../src/base/A-Logger/A-Logger.component.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gGAAmF;AACnF,4CAAyC;AACzC,mEAAwD;AACxD,iFAAwE;AACxE,6FAAoF;AAI7E,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,+BAAW;IAErC,YACuB,KAAwB,EACvB,MAA0B;QAE9C,KAAK,EAAE,CAAC;QAHqB,UAAK,GAAL,KAAK,CAAS;QACb,WAAM,GAAN,MAAM,CAAU;QAKzC,WAAM,GAAG;YACd,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;YACV,GAAG,EAAE,IAAI;YACT,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,IAAI;YACV,KAAK,EAAE,IAAI;YACX,IAAI,EAAE,IAAI;SACJ,CAAA;IAZV,CAAC;IAeD,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;IAClC,CAAC;IAGD,OAAO,CACH,KAA+B,EAC/B,GAAG,IAAW;QAGd,OAAO;YACH,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,IAAI,MAAM,IAAI,CAAC,OAAO,EAAE,GAAG;YACrE,CACI,IAAI,CAAC,MAAM,GAAG,CAAC;gBACX,CAAC,CAAC,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,kCAAkC;gBAC9E,CAAC,CAAC,EAAE,CAEX;YACD,GAAG,CAAC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GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,EACxF,IAAI,CAAC,IAAI,CAAC;SAElB,EAAE,IAAI,EAAE,CAAC,CAAC;aACN,OAAO,CAAC,KAAK,EAAE,IAAI,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,IAAI,CAAC;aAC9D,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAC9B,CAAC;IAIS,OAAO;QACb,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QACpE,OAAO,GAAG,OAAO,IAAI,OAAO,IAAI,YAAY,EAAE,CAAC;IACnD,CAAC;CACJ,CAAA;AAxLY,4BAAQ;mBAAR,QAAQ;IAGZ,WAAA,IAAA,6BAAQ,EAAC,uBAAO,CAAC,CAAA;IACjB,WAAA,IAAA,6BAAQ,EAAC,2BAAQ,CAAC,CAAA;GAJd,QAAQ,CAwLpB"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.A_Polyfill = void 0;
|
|
19
|
+
const A_Component_class_1 = require("../../global/A-Component/A-Component.class");
|
|
20
|
+
const A_Concept_class_1 = require("../../global/A-Concept/A_Concept.class");
|
|
21
|
+
const a_utils_1 = require("@adaas/a-utils");
|
|
22
|
+
class A_Polyfill extends A_Component_class_1.A_Component {
|
|
23
|
+
load() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
const fs = yield a_utils_1.A_Polyfills.fs();
|
|
26
|
+
this.fs = fs;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.A_Polyfill = A_Polyfill;
|
|
31
|
+
__decorate([
|
|
32
|
+
A_Concept_class_1.A_Concept.Load()
|
|
33
|
+
], A_Polyfill.prototype, "load", null);
|
|
34
|
+
//# sourceMappingURL=A-Polyfill.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"A-Polyfill.component.js","sourceRoot":"","sources":["../../../../src/base/A-Polyfill/A-Polyfill.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,6FAAoF;AACpF,uFAA8E;AAC9E,4CAA6C;AAI7C,MAAa,UAAW,SAAQ,+BAAW;IAMjC,IAAI;;YACN,MAAM,EAAE,GAAG,MAAM,qBAAW,CAAC,EAAE,EAAE,CAAC;YAElC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACjB,CAAC;KAAA;CACJ;AAXD,gCAWC;AALS;IADL,2BAAS,CAAC,IAAI,EAAE;sCAKhB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { A_Component } from "../../global/A-Component/A-Component.class";
|
|
1
2
|
import { A_TYPES__A_StageDecoratorConfig, A_TYPES__A_StageDecoratorDescriptor } from "./A-Stage.decorator.types";
|
|
2
3
|
import { A_Container } from "../../global/A-Container/A-Container.class";
|
|
3
4
|
import { A_TYPES__ConceptStage } from "../../global/A-Concept/A_Concept.types";
|
|
@@ -9,4 +10,4 @@ import { A_TYPES__ConceptStage } from "../../global/A-Concept/A_Concept.types";
|
|
|
9
10
|
* @param params
|
|
10
11
|
* @returns
|
|
11
12
|
*/
|
|
12
|
-
export declare function A_Stage(method: A_TYPES__ConceptStage): (config?: Partial<A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any
|
|
13
|
+
export declare function A_Stage(method: A_TYPES__ConceptStage): (config?: Partial<A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any> | A_Component, propertyKey: string, descriptor: A_TYPES__A_StageDecoratorDescriptor) => void;
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.A_Stage = A_Stage;
|
|
4
|
+
const A_Component_class_1 = require("../../global/A-Component/A-Component.class");
|
|
5
|
+
const A_Component_types_1 = require("../../global/A-Component/A-Component.types");
|
|
4
6
|
const A_Context_class_1 = require("../../global/A-Context/A-Context.class");
|
|
7
|
+
const A_Container_class_1 = require("../../global/A-Container/A-Container.class");
|
|
5
8
|
const A_Container_types_1 = require("../../global/A-Container/A-Container.types");
|
|
6
9
|
/**
|
|
7
10
|
* A_Stage Decorator uses to extend basic A-Concept Stage methods inside Containers.
|
|
@@ -14,21 +17,35 @@ const A_Container_types_1 = require("../../global/A-Container/A-Container.types"
|
|
|
14
17
|
function A_Stage(method) {
|
|
15
18
|
return function A_Stage(config = {}) {
|
|
16
19
|
return function (target, propertyKey, descriptor) {
|
|
20
|
+
const meta = A_Context_class_1.A_Context.meta(target);
|
|
21
|
+
let metaKey;
|
|
22
|
+
const StageKey = `CONCEPT_STAGE::${method}`;
|
|
23
|
+
switch (true) {
|
|
24
|
+
case target instanceof A_Container_class_1.A_Container:
|
|
25
|
+
metaKey = A_Container_types_1.A_TYPES__ContainerMetaKey.STAGES;
|
|
26
|
+
break;
|
|
27
|
+
case target instanceof A_Component_class_1.A_Component:
|
|
28
|
+
metaKey = A_Component_types_1.A_TYPES__ComponentMetaKey.STAGES;
|
|
29
|
+
break;
|
|
30
|
+
default:
|
|
31
|
+
throw new Error(`A-Feature cannot be defined on the ${target} level`);
|
|
32
|
+
}
|
|
17
33
|
// Get the existed metadata or create a new one
|
|
18
|
-
const existedMeta =
|
|
19
|
-
.meta(target)
|
|
20
|
-
.get(A_Container_types_1.A_TYPES__ContainerMetaKey.STAGES)
|
|
34
|
+
const existedMeta = meta.get(metaKey)
|
|
21
35
|
|| new Map();
|
|
22
36
|
// Set the metadata of the method to define a custom Stage with name
|
|
23
|
-
existedMeta
|
|
24
|
-
|
|
25
|
-
|
|
37
|
+
const existedMetaValue = existedMeta.get(StageKey) || [];
|
|
38
|
+
// Add the new method to the metadata
|
|
39
|
+
existedMetaValue.push({
|
|
40
|
+
name: StageKey,
|
|
26
41
|
handler: propertyKey,
|
|
27
42
|
});
|
|
43
|
+
// Set the metadata of the method to define a custom Feature with name
|
|
44
|
+
existedMeta.set(StageKey, existedMetaValue);
|
|
28
45
|
// Update the metadata of the container with the new Stage definition
|
|
29
46
|
A_Context_class_1.A_Context
|
|
30
47
|
.meta(target)
|
|
31
|
-
.set(
|
|
48
|
+
.set(metaKey, existedMeta);
|
|
32
49
|
};
|
|
33
50
|
};
|
|
34
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Stage.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/A-Stage/A-Stage.decorator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"A-Stage.decorator.js","sourceRoot":"","sources":["../../../../src/decorators/A-Stage/A-Stage.decorator.ts"],"names":[],"mappings":";;AAwBA,0BA2DC;AAnFD,6FAAoF;AAKpF,6FAAkG;AAClG,uFAA8E;AAC9E,6FAAoF;AACpF,6FAAkG;AAQlG;;;;;;;GAOG;AACH,SAAgB,OAAO,CACnB,MAA6B;IAI7B,OAAO,SAAS,OAAO,CACnB,SAAmD,EAAE;QAErD,OAAO,UACH,MAAsC,EACtC,WAAmB,EACnB,UAA+C;YAG/C,MAAM,IAAI,GAAsC,2BAAS,CAAC,IAAI,CAAC,MAAa,CAAC,CAAC;YAE9E,IAAI,OAAO,CAAC;YAEZ,MAAM,QAAQ,GAAG,kBAAkB,MAAM,EAAE,CAAA;YAE3C,QAAQ,IAAI,EAAE,CAAC;gBACX,KAAK,MAAM,YAAY,+BAAW;oBAC9B,OAAO,GAAG,6CAAyB,CAAC,MAAM,CAAA;oBAC1C,MAAM;gBACV,KAAK,MAAM,YAAY,+BAAW;oBAC9B,OAAO,GAAG,6CAAyB,CAAC,MAAM,CAAA;oBAC1C,MAAM;gBACV;oBACI,MAAM,IAAI,KAAK,CAAC,sCAAsC,MAAM,QAAQ,CAAC,CAAC;YAC9E,CAAC;YAED,+CAA+C;YAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;mBAC9B,IAAI,GAAG,EAAE,CAAC;YAEjB,oEAAoE;YAEpE,MAAM,gBAAgB,GAAG,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YAEzD,qCAAqC;YACrC,gBAAgB,CAAC,IAAI,CAAC;gBAClB,IAAI,EAAE,QAAQ;gBACd,OAAO,EAAE,WAAW;aACvB,CAAC,CAAC;YAEH,sEAAsE;YACtE,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YAG5C,sEAAsE;YACtE,2BAAS;iBACJ,IAAI,CAAC,MAAa,CAAC;iBACnB,GAAG,CACA,OAAO,EACP,WAAW,CACd,CAAC;QAEV,CAAC,CAAC;IACN,CAAC,CAAA;AACL,CAAC"}
|
|
@@ -35,7 +35,8 @@ export type A_TYPES__ComponentMeta = {
|
|
|
35
35
|
export declare enum A_TYPES__ComponentMetaKey {
|
|
36
36
|
EXTENSIONS = "a-component-extensions",
|
|
37
37
|
FEATURES = "a-component-features",
|
|
38
|
-
INJECTIONS = "a-component-injections"
|
|
38
|
+
INJECTIONS = "a-component-injections",
|
|
39
|
+
STAGES = "a-component-stages"
|
|
39
40
|
}
|
|
40
41
|
export type A_TYPES__ComponentMetaExtension = {
|
|
41
42
|
/**
|
|
@@ -6,6 +6,7 @@ var A_TYPES__ComponentMetaKey;
|
|
|
6
6
|
A_TYPES__ComponentMetaKey["EXTENSIONS"] = "a-component-extensions";
|
|
7
7
|
A_TYPES__ComponentMetaKey["FEATURES"] = "a-component-features";
|
|
8
8
|
A_TYPES__ComponentMetaKey["INJECTIONS"] = "a-component-injections";
|
|
9
|
+
A_TYPES__ComponentMetaKey["STAGES"] = "a-component-stages";
|
|
9
10
|
})(A_TYPES__ComponentMetaKey || (exports.A_TYPES__ComponentMetaKey = A_TYPES__ComponentMetaKey = {}));
|
|
10
11
|
// |
|
|
11
12
|
// typeof A_Fragment
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Component.types.js","sourceRoot":"","sources":["../../../../src/global/A-Component/A-Component.types.ts"],"names":[],"mappings":";;;AA0CA,IAAY,
|
|
1
|
+
{"version":3,"file":"A-Component.types.js","sourceRoot":"","sources":["../../../../src/global/A-Component/A-Component.types.ts"],"names":[],"mappings":";;;AA0CA,IAAY,yBAKX;AALD,WAAY,yBAAyB;IACjC,kEAAqC,CAAA;IACrC,8DAAiC,CAAA;IACjC,kEAAqC,CAAA;IACrC,0DAA6B,CAAA;AACjC,CAAC,EALW,yBAAyB,yCAAzB,yBAAyB,QAKpC;AA2CD,KAAK;AACL,oBAAoB;AACpB,uBAAuB;AACvB,oCAAoC;AACpC,mBAAmB;AACnB,sBAAsB"}
|
|
@@ -18,36 +18,36 @@ export declare class A_Concept<_Features extends A_Container<any>[] = any> {
|
|
|
18
18
|
/**
|
|
19
19
|
* Load the concept. This step runs before any other steps to ensure that all components are loaded.
|
|
20
20
|
*/
|
|
21
|
-
static get Load(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any
|
|
21
|
+
static get Load(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any> | import("../A-Component/A-Component.class").A_Component, propertyKey: string, descriptor: import("../../..").A_TYPES__A_StageDecoratorDescriptor) => void;
|
|
22
22
|
/**
|
|
23
23
|
* Publish the concept to ADAAS platform. (Or any other place defined in the concept)
|
|
24
24
|
*
|
|
25
25
|
* [!] To extend the logic just create a custom containers and override the default behavior.
|
|
26
26
|
*/
|
|
27
|
-
static get Publish(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any
|
|
27
|
+
static get Publish(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any> | import("../A-Component/A-Component.class").A_Component, propertyKey: string, descriptor: import("../../..").A_TYPES__A_StageDecoratorDescriptor) => void;
|
|
28
28
|
/**
|
|
29
29
|
* Deploy the concept to the environment.
|
|
30
30
|
*/
|
|
31
|
-
static get Deploy(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any
|
|
31
|
+
static get Deploy(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any> | import("../A-Component/A-Component.class").A_Component, propertyKey: string, descriptor: import("../../..").A_TYPES__A_StageDecoratorDescriptor) => void;
|
|
32
32
|
/**
|
|
33
33
|
* Compiles the Concept in case there are some containers that require that.
|
|
34
34
|
*
|
|
35
35
|
* Can be used for static websites or any other concept that requires a build step.
|
|
36
36
|
*
|
|
37
37
|
*/
|
|
38
|
-
static get Build(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any
|
|
38
|
+
static get Build(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any> | import("../A-Component/A-Component.class").A_Component, propertyKey: string, descriptor: import("../../..").A_TYPES__A_StageDecoratorDescriptor) => void;
|
|
39
39
|
/**
|
|
40
40
|
* Main execution of the concept.
|
|
41
41
|
*/
|
|
42
|
-
static get Run(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any
|
|
42
|
+
static get Run(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any> | import("../A-Component/A-Component.class").A_Component, propertyKey: string, descriptor: import("../../..").A_TYPES__A_StageDecoratorDescriptor) => void;
|
|
43
43
|
/**
|
|
44
44
|
* Start the concept. Uses for servers or any other background services.
|
|
45
45
|
*/
|
|
46
|
-
static get Start(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any
|
|
46
|
+
static get Start(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any> | import("../A-Component/A-Component.class").A_Component, propertyKey: string, descriptor: import("../../..").A_TYPES__A_StageDecoratorDescriptor) => void;
|
|
47
47
|
/**
|
|
48
48
|
* Stop the concept. Uses for servers or any other background services.
|
|
49
49
|
*/
|
|
50
|
-
static get Stop(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any
|
|
50
|
+
static get Stop(): (config?: Partial<import("../../..").A_TYPES__A_StageDecoratorConfig>) => (target: A_Container<any> | import("../A-Component/A-Component.class").A_Component, propertyKey: string, descriptor: import("../../..").A_TYPES__A_StageDecoratorDescriptor) => void;
|
|
51
51
|
protected containers: A_Container<any>[];
|
|
52
52
|
constructor(props: A_TYPES__IConceptConstructor<_Features>);
|
|
53
53
|
get namespace(): string;
|
|
@@ -62,8 +62,8 @@ import { ENVConfigReader } from "@adaas/a-concept/base/A-Config/components/ENVCo
|
|
|
62
62
|
]
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
await configLoader.
|
|
66
|
-
await configLoader.readVariables();
|
|
65
|
+
await configLoader.prepare(configContext);
|
|
66
|
+
await configLoader.readVariables(configContext);
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
const container = new MainContainer({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-concept",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.29",
|
|
4
4
|
"description": "A-Concept is a framework to build new Applications within or outside the ADAAS ecosystem. This framework is designed to be modular structure regardless environment and program goal.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -7,6 +7,8 @@ import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
|
7
7
|
import { FileConfigReader } from "./components/FileConfigReader.component";
|
|
8
8
|
import { ENVConfigReader } from "./components/ENVConfigReader.component";
|
|
9
9
|
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
10
|
+
import { A_Concept } from "@adaas/a-concept/global/A-Concept/A_Concept.class";
|
|
11
|
+
import { A_Config } from "./A-Config.context";
|
|
10
12
|
|
|
11
13
|
|
|
12
14
|
|
|
@@ -17,12 +19,10 @@ export class A_ConfigLoader extends A_Container<['load', 'read']> {
|
|
|
17
19
|
private reader!: ConfigReader
|
|
18
20
|
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
async
|
|
22
|
+
@A_Concept.Load()
|
|
23
|
+
async prepare(
|
|
24
|
+
@A_Inject(A_Config) config: A_Config,
|
|
22
25
|
) {
|
|
23
|
-
// OR Inject the logger by calling Context Provider
|
|
24
|
-
// const logger2 = await this.CP.resolve(A_LoggerContext);
|
|
25
|
-
|
|
26
26
|
const fs = await A_Polyfills.fs();
|
|
27
27
|
|
|
28
28
|
switch (true) {
|
|
@@ -31,7 +31,6 @@ export class A_ConfigLoader extends A_Container<['load', 'read']> {
|
|
|
31
31
|
this.reader = this.Scope.resolve(FileConfigReader);
|
|
32
32
|
break;
|
|
33
33
|
|
|
34
|
-
|
|
35
34
|
case A_Context.environment === 'server': !fs.existsSync(`${this.Scope.name}.conf.json`)
|
|
36
35
|
this.reader = this.Scope.resolve(ENVConfigReader);
|
|
37
36
|
break;
|
|
@@ -43,12 +42,16 @@ export class A_ConfigLoader extends A_Container<['load', 'read']> {
|
|
|
43
42
|
default:
|
|
44
43
|
throw new Error(`Environment ${A_Context.environment} is not supported`);
|
|
45
44
|
}
|
|
45
|
+
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
async readVariables() {
|
|
49
|
-
// const config = await this.reader.read(this.namespace.CONFIG_PROPERTIES);
|
|
50
48
|
|
|
51
49
|
|
|
50
|
+
@A_Concept.Load()
|
|
51
|
+
async readVariables(
|
|
52
|
+
@A_Inject(A_Config) config: A_Config,
|
|
53
|
+
) {
|
|
54
|
+
await this.reader.inject(config);
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
2
2
|
import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator";
|
|
3
3
|
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
4
|
+
import { A_Polyfills } from "@adaas/a-utils";
|
|
5
|
+
import { A_Concept } from "@adaas/a-concept/global/A-Concept/A_Concept.class";
|
|
6
|
+
import { A_Config } from "../A-Config.context";
|
|
4
7
|
|
|
5
8
|
|
|
6
9
|
|
|
@@ -16,6 +19,20 @@ export class ConfigReader extends A_Component {
|
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
|
|
22
|
+
@A_Concept.Load()
|
|
23
|
+
async inject(
|
|
24
|
+
@A_Inject(A_Config) config: A_Config
|
|
25
|
+
) {
|
|
26
|
+
const data = this.read(config.CONFIG_PROPERTIES);
|
|
27
|
+
|
|
28
|
+
config.set(data);
|
|
29
|
+
|
|
30
|
+
const rootDir = await this.getProjectRoot();
|
|
31
|
+
|
|
32
|
+
config.set('CONCEPT_ROOT_FOLDER', rootDir);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
19
36
|
/**
|
|
20
37
|
* Get the configuration property by Name
|
|
21
38
|
* @param property
|
|
@@ -34,4 +51,28 @@ export class ConfigReader extends A_Component {
|
|
|
34
51
|
): Promise<Record<T, any>> {
|
|
35
52
|
return {} as Record<T, any>;
|
|
36
53
|
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Finds the root directory of the project by locating the folder containing package.json
|
|
58
|
+
*
|
|
59
|
+
* @param {string} startPath - The initial directory to start searching from (default is __dirname)
|
|
60
|
+
* @returns {string|null} - The path to the root directory or null if package.json is not found
|
|
61
|
+
*/
|
|
62
|
+
protected async getProjectRoot(startPath = __dirname) {
|
|
63
|
+
// let currentPath = startPath;
|
|
64
|
+
|
|
65
|
+
// const fs = await A_Polyfills.fs();
|
|
66
|
+
|
|
67
|
+
// while (!fs.existsSync(`${currentPath}/package.json`)) {
|
|
68
|
+
// const parentPath = currentPath.substring(0, currentPath.lastIndexOf('/'));
|
|
69
|
+
// if (parentPath === currentPath || parentPath === '') {
|
|
70
|
+
// // Reached the root of the filesystem without finding package.json
|
|
71
|
+
// return null;
|
|
72
|
+
// }
|
|
73
|
+
// currentPath = parentPath;
|
|
74
|
+
// }
|
|
75
|
+
|
|
76
|
+
return process.cwd();
|
|
77
|
+
}
|
|
37
78
|
}
|
|
@@ -76,6 +76,12 @@ export class A_Logger extends A_Component {
|
|
|
76
76
|
]
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
protected get allowedToLog() {
|
|
80
|
+
return this.config.get('CONFIG_VERBOSE') !== undefined
|
|
81
|
+
&& this.config.get('CONFIG_VERBOSE') !== 'false'
|
|
82
|
+
&& this.config.get('CONFIG_VERBOSE') !== false
|
|
83
|
+
}
|
|
84
|
+
|
|
79
85
|
|
|
80
86
|
log(
|
|
81
87
|
color: keyof typeof this.colors,
|
|
@@ -88,7 +94,7 @@ export class A_Logger extends A_Component {
|
|
|
88
94
|
param1: any,
|
|
89
95
|
...args: any[]
|
|
90
96
|
) {
|
|
91
|
-
if (!this.
|
|
97
|
+
if (!this.allowedToLog)
|
|
92
98
|
return;
|
|
93
99
|
|
|
94
100
|
if (typeof param1 === 'string' && this.colors[param1]) {
|
|
@@ -101,7 +107,7 @@ export class A_Logger extends A_Component {
|
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
warning(...args) {
|
|
104
|
-
if (!this.
|
|
110
|
+
if (!this.allowedToLog)
|
|
105
111
|
return;
|
|
106
112
|
|
|
107
113
|
console.log(...this.compile('yellow', ...args));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
2
|
+
import { A_Concept } from "@adaas/a-concept/global/A-Concept/A_Concept.class";
|
|
3
|
+
import { A_Polyfills } from "@adaas/a-utils";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export class A_Polyfill extends A_Component {
|
|
8
|
+
|
|
9
|
+
private fs!: any;
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@A_Concept.Load()
|
|
13
|
+
async load() {
|
|
14
|
+
const fs = await A_Polyfills.fs();
|
|
15
|
+
|
|
16
|
+
this.fs = fs;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -8,6 +8,8 @@ import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
|
8
8
|
import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
9
9
|
import { A_TYPES__ContainerMetaKey } from "@adaas/a-concept/global/A-Container/A-Container.types";
|
|
10
10
|
import { A_TYPES__ConceptStage } from "@adaas/a-concept/global/A-Concept/A_Concept.types";
|
|
11
|
+
import { A_ContainerMeta } from "@adaas/a-concept/global/A-Container/A-Container.meta";
|
|
12
|
+
import { A_ComponentMeta } from "@adaas/a-concept/global/A-Component/A-Component.meta";
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
|
|
@@ -29,28 +31,53 @@ export function A_Stage(
|
|
|
29
31
|
config: Partial<A_TYPES__A_StageDecoratorConfig> = {}
|
|
30
32
|
) {
|
|
31
33
|
return function (
|
|
32
|
-
target: A_Container<any
|
|
34
|
+
target: A_Container<any> | A_Component,
|
|
33
35
|
propertyKey: string,
|
|
34
36
|
descriptor: A_TYPES__A_StageDecoratorDescriptor
|
|
35
37
|
) {
|
|
36
38
|
|
|
39
|
+
const meta: A_ContainerMeta | A_ComponentMeta = A_Context.meta(target as any);
|
|
40
|
+
|
|
41
|
+
let metaKey;
|
|
42
|
+
|
|
43
|
+
const StageKey = `CONCEPT_STAGE::${method}`
|
|
44
|
+
|
|
45
|
+
switch (true) {
|
|
46
|
+
case target instanceof A_Container:
|
|
47
|
+
metaKey = A_TYPES__ContainerMetaKey.STAGES
|
|
48
|
+
break;
|
|
49
|
+
case target instanceof A_Component:
|
|
50
|
+
metaKey = A_TYPES__ComponentMetaKey.STAGES
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
throw new Error(`A-Feature cannot be defined on the ${target} level`);
|
|
54
|
+
}
|
|
55
|
+
|
|
37
56
|
// Get the existed metadata or create a new one
|
|
38
|
-
const existedMeta =
|
|
39
|
-
.meta(target)
|
|
40
|
-
.get(A_TYPES__ContainerMetaKey.STAGES)
|
|
57
|
+
const existedMeta = meta.get(metaKey)
|
|
41
58
|
|| new Map();
|
|
42
59
|
|
|
43
60
|
// Set the metadata of the method to define a custom Stage with name
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
61
|
+
|
|
62
|
+
const existedMetaValue = existedMeta.get(StageKey) || [];
|
|
63
|
+
|
|
64
|
+
// Add the new method to the metadata
|
|
65
|
+
existedMetaValue.push({
|
|
66
|
+
name: StageKey,
|
|
67
|
+
handler: propertyKey,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Set the metadata of the method to define a custom Feature with name
|
|
71
|
+
existedMeta.set(StageKey, existedMetaValue);
|
|
72
|
+
|
|
49
73
|
|
|
50
74
|
// Update the metadata of the container with the new Stage definition
|
|
51
75
|
A_Context
|
|
52
|
-
.meta(target)
|
|
53
|
-
.set(
|
|
76
|
+
.meta(target as any)
|
|
77
|
+
.set(
|
|
78
|
+
metaKey,
|
|
79
|
+
existedMeta
|
|
80
|
+
);
|
|
54
81
|
|
|
55
82
|
};
|
|
56
83
|
}
|