@adaas/a-concept 0.0.5 → 0.0.7
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/components/A.component.d.ts +4 -2
- package/dist/examples/simple/components/A.component.js +7 -4
- package/dist/examples/simple/components/A.component.js.map +1 -1
- package/dist/examples/simple/components/B.component.d.ts +6 -2
- package/dist/examples/simple/components/B.component.js +18 -7
- package/dist/examples/simple/components/B.component.js.map +1 -1
- package/dist/examples/simple/concept.js +59 -32
- package/dist/examples/simple/concept.js.map +1 -1
- package/dist/examples/simple/containers/Main.container.d.ts +1 -2
- package/dist/examples/simple/containers/Main.container.js +18 -5
- package/dist/examples/simple/containers/Main.container.js.map +1 -1
- package/dist/examples/simple-http-server/components/http-error-handler.component.d.ts +2 -1
- package/dist/examples/simple-http-server/components/http-error-handler.component.js +3 -1
- package/dist/examples/simple-http-server/components/http-error-handler.component.js.map +1 -1
- package/dist/examples/simple-http-server/components/http-request-handler.component.d.ts +2 -1
- package/dist/examples/simple-http-server/components/http-request-handler.component.js +2 -1
- package/dist/examples/simple-http-server/components/http-request-handler.component.js.map +1 -1
- package/dist/examples/simple-http-server/containers/http-server.container.d.ts +1 -2
- package/dist/index.d.ts +5 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.container.d.ts +1 -3
- package/dist/src/base/A-Config/A-Config.container.js +6 -22
- 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 -0
- package/dist/src/base/A-Config/A-Config.context.js +20 -2
- package/dist/src/base/A-Config/A-Config.context.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.types.d.ts +2 -2
- package/dist/src/base/A-Config/components/ConfigReader.component.d.ts +2 -1
- package/dist/src/base/A-Config/components/ConfigReader.component.js +3 -1
- package/dist/src/base/A-Config/components/ConfigReader.component.js.map +1 -1
- package/dist/src/base/A-Errors/A-Errors.component.d.ts +2 -1
- package/dist/src/base/A-Errors/A-Errors.component.js +3 -1
- package/dist/src/base/A-Errors/A-Errors.component.js.map +1 -1
- package/dist/src/base/A-Logger/A-Logger.component.d.ts +4 -2
- package/dist/src/base/A-Logger/A-Logger.component.js +11 -3
- package/dist/src/base/A-Logger/A-Logger.component.js.map +1 -1
- package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js.map +1 -1
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js +9 -9
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
- package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +0 -2
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js +4 -2
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.class.d.ts +28 -1
- package/dist/src/global/A-Component/A-Component.class.js +22 -0
- package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.meta.d.ts +8 -1
- package/dist/src/global/A-Component/A-Component.meta.js +26 -0
- package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.types.d.ts +43 -6
- package/dist/src/global/A-Component/A-Component.types.js +5 -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/dist/src/global/A-Concept/A_Concept.class.js +1 -2
- package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.class.d.ts +5 -4
- package/dist/src/global/A-Container/A-Container.class.js +13 -24
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.meta.d.ts +0 -3
- package/dist/src/global/A-Container/A-Container.meta.js +0 -46
- package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.class.d.ts +35 -5
- package/dist/src/global/A-Context/A-Context.class.js +135 -53
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.types.d.ts +0 -12
- package/dist/src/global/A-Context/A-Context.types.js +0 -1
- package/dist/src/global/A-Entity/A-Entity.class.d.ts +28 -4
- package/dist/src/global/A-Entity/A-Entity.class.js +23 -3
- package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.meta.d.ts +4 -0
- package/dist/src/global/A-Entity/A-Entity.meta.js +8 -0
- package/dist/src/global/A-Entity/A-Entity.meta.js.map +1 -0
- package/dist/src/global/A-Entity/A-Entity.types.d.ts +43 -0
- package/dist/src/global/A-Entity/A-Entity.types.js +13 -0
- package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.class.d.ts +11 -1
- package/dist/src/global/A-Feature/A-Feature.class.js +48 -12
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +5 -4
- package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
- package/dist/src/global/A-Fragment/A-Fragment.class.js +1 -2
- package/dist/src/global/A-Fragment/A-Fragment.class.js.map +1 -1
- package/dist/src/global/A-Meta/A-Meta.class.d.ts +75 -1
- package/dist/src/global/A-Meta/A-Meta.class.js +100 -10
- package/dist/src/global/A-Meta/A-Meta.class.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.class.d.ts +15 -6
- package/dist/src/global/A-Scope/A-Scope.class.js +53 -17
- package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
- package/examples/simple/components/A.component.ts +6 -3
- package/examples/simple/components/B.component.ts +19 -6
- package/examples/simple/concept.ts +65 -33
- package/examples/simple/containers/Main.container.ts +28 -7
- package/examples/simple-http-server/components/http-error-handler.component.ts +5 -2
- package/examples/simple-http-server/components/http-request-handler.component.ts +3 -1
- package/index.ts +6 -1
- package/package.json +1 -1
- package/src/base/A-Config/A-Config.container.ts +5 -8
- package/src/base/A-Config/A-Config.context.ts +10 -2
- package/src/base/A-Config/A-Config.types.ts +2 -2
- package/src/base/A-Config/components/ConfigReader.component.ts +5 -2
- package/src/base/A-Errors/A-Errors.component.ts +3 -2
- package/src/base/A-Logger/A-Logger.component.ts +21 -3
- package/src/decorators/A-Feature/A-Feature-Define.decorator.ts +0 -1
- package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +15 -10
- package/src/decorators/A-Inject/A-Inject.decorator.ts +13 -11
- package/src/global/A-Component/A-Component.class.ts +56 -1
- package/src/global/A-Component/A-Component.meta.ts +40 -1
- package/src/global/A-Component/A-Component.types.ts +51 -19
- package/src/global/A-Concept/A_Concept.class.ts +2 -2
- package/src/global/A-Container/A-Container.class.ts +22 -34
- package/src/global/A-Container/A-Container.meta.ts +0 -64
- package/src/global/A-Context/A-Context.class.ts +240 -79
- package/src/global/A-Context/A-Context.types.ts +0 -15
- package/src/global/A-Entity/A-Entity.class.ts +65 -8
- package/src/global/A-Entity/A-Entity.meta.ts +9 -0
- package/src/global/A-Entity/A-Entity.types.ts +58 -0
- package/src/global/A-Feature/A-Feature.class.ts +62 -20
- package/src/global/A-Feature/A-Feature.types.ts +8 -2
- package/src/global/A-Fragment/A-Fragment.class.ts +1 -5
- package/src/global/A-Meta/A-Meta.class.ts +114 -22
- package/src/global/A-Scope/A-Scope.class.ts +93 -33
|
@@ -5,6 +5,8 @@ const a_utils_1 = require("@adaas/a-utils");
|
|
|
5
5
|
const A_Fragment_class_1 = require("../A-Fragment/A-Fragment.class");
|
|
6
6
|
const A_Context_class_1 = require("../A-Context/A-Context.class");
|
|
7
7
|
const A_Component_types_1 = require("../A-Component/A-Component.types");
|
|
8
|
+
const A_Component_class_1 = require("../A-Component/A-Component.class");
|
|
9
|
+
const A_Entity_class_1 = require("../A-Entity/A-Entity.class");
|
|
8
10
|
/**
|
|
9
11
|
*
|
|
10
12
|
*
|
|
@@ -23,6 +25,7 @@ class A_Scope {
|
|
|
23
25
|
this.name = '';
|
|
24
26
|
this._components = new WeakMap();
|
|
25
27
|
this._fragments = new WeakMap();
|
|
28
|
+
this._entities = new Map();
|
|
26
29
|
this.name = params.name || this.constructor.name;
|
|
27
30
|
// TODO: move to defaults
|
|
28
31
|
const defaultParams = {
|
|
@@ -98,24 +101,14 @@ class A_Scope {
|
|
|
98
101
|
case a_utils_1.A_CommonHelper.isInheritedFrom(component, A_Fragment_class_1.A_Fragment): {
|
|
99
102
|
return this.resolveFragment(component);
|
|
100
103
|
}
|
|
101
|
-
case
|
|
102
|
-
return this.
|
|
104
|
+
case a_utils_1.A_CommonHelper.isInheritedFrom(component, A_Scope): {
|
|
105
|
+
return this.resolveScope(component);
|
|
103
106
|
}
|
|
104
|
-
case
|
|
105
|
-
|
|
106
|
-
const argsMeta = componentMeta.get(A_Component_types_1.A_TYPES__ComponentMetaKey.INJECTIONS);
|
|
107
|
-
let resolvedArgs = [];
|
|
108
|
-
if (argsMeta)
|
|
109
|
-
resolvedArgs = (argsMeta.get('constructor') || [])
|
|
110
|
-
.map(arg => this.resolve(arg));
|
|
111
|
-
this._components.set(component, new component());
|
|
112
|
-
return this._components.get(component);
|
|
113
|
-
}
|
|
114
|
-
case !this.components.includes(component) && !!this.parent: {
|
|
115
|
-
return this.parent.resolve(component);
|
|
107
|
+
case a_utils_1.A_CommonHelper.isInheritedFrom(component, A_Component_class_1.A_Component): {
|
|
108
|
+
return this.resolveComponent(component);
|
|
116
109
|
}
|
|
117
110
|
default:
|
|
118
|
-
throw new Error(`Component ${component
|
|
111
|
+
throw new Error(`Injected Component ${component} not found in the scope`);
|
|
119
112
|
}
|
|
120
113
|
}
|
|
121
114
|
resolveFragment(fragment) {
|
|
@@ -127,8 +120,51 @@ class A_Scope {
|
|
|
127
120
|
}
|
|
128
121
|
throw new Error(`Fragment ${fragment.name} not found in the scope ${this.name}`);
|
|
129
122
|
}
|
|
130
|
-
|
|
131
|
-
this
|
|
123
|
+
resolveScope(scope) {
|
|
124
|
+
return this;
|
|
125
|
+
}
|
|
126
|
+
resolveComponent(component) {
|
|
127
|
+
if (this.components.includes(component) && this._components.has(component))
|
|
128
|
+
return this._components.get(component);
|
|
129
|
+
else if (this.components.includes(component) && !this._components.has(component)) {
|
|
130
|
+
const componentMeta = A_Context_class_1.A_Context.meta(component);
|
|
131
|
+
const argsMeta = componentMeta.get(A_Component_types_1.A_TYPES__ComponentMetaKey.INJECTIONS);
|
|
132
|
+
const resolvedArgs = ((argsMeta === null || argsMeta === void 0 ? void 0 : argsMeta.get('constructor')) || [])
|
|
133
|
+
.map(arg => this.resolve(arg));
|
|
134
|
+
const newComponent = new component(...resolvedArgs);
|
|
135
|
+
this.register(newComponent);
|
|
136
|
+
return this._components.get(component);
|
|
137
|
+
}
|
|
138
|
+
else if (!this.components.includes(component) && !!this.parent) {
|
|
139
|
+
return this.parent.resolveComponent(component);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
throw new Error(`Component ${component.name} not found in the scope`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
register(param1) {
|
|
146
|
+
switch (true) {
|
|
147
|
+
case param1 instanceof A_Fragment_class_1.A_Fragment && !this._fragments.has(param1.constructor): {
|
|
148
|
+
this._fragments.set(param1.constructor, param1);
|
|
149
|
+
// The same situation. Have not idea how to fix it
|
|
150
|
+
A_Context_class_1.A_Context.register(this, param1);
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case param1 instanceof A_Entity_class_1.A_Entity && !this._entities.has(param1.aseid.toString()): {
|
|
154
|
+
this._entities.set(param1.aseid.toString(), param1);
|
|
155
|
+
// The same situation. Have not idea how to fix it
|
|
156
|
+
A_Context_class_1.A_Context.register(this, param1);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case param1 instanceof A_Component_class_1.A_Component: {
|
|
160
|
+
this._components.set(param1.constructor, param1);
|
|
161
|
+
// The same situation. Have not idea how to fix it
|
|
162
|
+
A_Context_class_1.A_Context.register(this, param1);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
default:
|
|
166
|
+
throw new Error('Invalid arguments provided');
|
|
167
|
+
}
|
|
132
168
|
}
|
|
133
169
|
}
|
|
134
170
|
exports.A_Scope = A_Scope;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Scope.class.js","sourceRoot":"","sources":["../../../../src/global/A-Scope/A-Scope.class.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD,qEAA4D;AAC5D,kEAAyD;AACzD,
|
|
1
|
+
{"version":3,"file":"A-Scope.class.js","sourceRoot":"","sources":["../../../../src/global/A-Scope/A-Scope.class.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD,qEAA4D;AAC5D,kEAAyD;AACzD,wEAAoH;AACpH,wEAA+D;AAC/D,+DAAsD;AAEtD;;;;;;;;;;;;GAYG;AACH,MAAa,OAAO;IAahB,YACI,MAA0C,EAC1C,SAAwC,EAAE;QAb9C,SAAI,GAAW,EAAE,CAAC;QAEV,gBAAW,GAAiD,IAAI,OAAO,EAAE,CAAC;QAC1E,eAAU,GAAgD,IAAI,OAAO,EAAE,CAAC;QACxE,cAAS,GAA0B,IAAI,GAAG,EAAE,CAAC;QAWjD,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAEjD,yBAAyB;QACzB,MAAM,aAAa,GAA8B;YAC7C,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;YACd,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE;SACb,CAAC;QAGF,IAAI,CAAC,MAAM,GAAG,wBAAc,CAAC,iBAAiB,CAA4B,MAAM,EAAE,aAAa,CAAC,CAAC;QAEjG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,IAAI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jC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;gBACjD,kDAAkD;gBAClD,2BAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAa,CAAC,CAAC;gBACxC,MAAM;YACV,CAAC;YAED;gBACI,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QACtD,CAAC;IAIL,CAAC;CACJ;AAzPD,0BAyPC"}
|
|
@@ -2,8 +2,10 @@ import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
|
|
|
2
2
|
import { ContextFragmentA } from "../context/Fragment_A.context";
|
|
3
3
|
import { ContextFragmentB } from "../context/Fragment_B.context";
|
|
4
4
|
import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator";
|
|
5
|
+
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
6
|
+
import { A_Logger } from "@adaas/a-concept/base/A-Logger/A-Logger.component";
|
|
5
7
|
|
|
6
|
-
export class ComponentA {
|
|
8
|
+
export class ComponentA extends A_Component {
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
@A_Feature.Extend()
|
|
@@ -13,9 +15,10 @@ export class ComponentA {
|
|
|
13
15
|
|
|
14
16
|
@A_Feature.Extend()
|
|
15
17
|
async method_A(
|
|
16
|
-
@A_Inject(ContextFragmentA) fragmentA: ContextFragmentA
|
|
18
|
+
@A_Inject(ContextFragmentA) fragmentA: ContextFragmentA,
|
|
19
|
+
@A_Inject(A_Logger) logger: A_Logger
|
|
17
20
|
) {
|
|
18
|
-
|
|
21
|
+
logger.log('red', 'Component A -> method_A()');
|
|
19
22
|
fragmentA.decrement();
|
|
20
23
|
}
|
|
21
24
|
|
|
@@ -2,9 +2,17 @@ import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorato
|
|
|
2
2
|
import { ContextFragmentB } from "../context/Fragment_B.context";
|
|
3
3
|
import { ContextFragmentA } from "../context/Fragment_A.context";
|
|
4
4
|
import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
|
|
5
|
+
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
6
|
+
import { A_Logger } from "@adaas/a-concept/base/A-Logger/A-Logger.component";
|
|
5
7
|
|
|
6
8
|
|
|
7
|
-
export class ComponentB {
|
|
9
|
+
export class ComponentB extends A_Component {
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
@A_Inject(A_Logger) private logger: A_Logger
|
|
13
|
+
) {
|
|
14
|
+
super();
|
|
15
|
+
}
|
|
8
16
|
|
|
9
17
|
|
|
10
18
|
@A_Feature.Extend()
|
|
@@ -14,15 +22,20 @@ export class ComponentB {
|
|
|
14
22
|
|
|
15
23
|
|
|
16
24
|
@A_Feature.Extend()
|
|
17
|
-
async method_B(
|
|
18
|
-
|
|
25
|
+
async method_B(
|
|
26
|
+
@A_Inject(A_Logger) logger: A_Logger
|
|
27
|
+
) {
|
|
28
|
+
logger.log('cyan', 'Component B -> method_B()');
|
|
19
29
|
}
|
|
20
30
|
|
|
21
31
|
@A_Feature.Extend({
|
|
22
32
|
name: 'method_B'
|
|
23
33
|
})
|
|
24
|
-
async someMethod(
|
|
25
|
-
|
|
34
|
+
async someMethod(
|
|
35
|
+
|
|
36
|
+
) {
|
|
37
|
+
this.logger.log('pink', 'Component B -> method_B() -> someMethod()');
|
|
38
|
+
this.logger.log('Component B -> method_B() -> someMethod()');
|
|
26
39
|
}
|
|
27
40
|
|
|
28
41
|
|
|
@@ -30,7 +43,7 @@ export class ComponentB {
|
|
|
30
43
|
name: 'method_B'
|
|
31
44
|
})
|
|
32
45
|
async someMethod2() {
|
|
33
|
-
|
|
46
|
+
this.logger.log('yellow', 'Component B -> method_B() -> someMethod2()');
|
|
34
47
|
}
|
|
35
48
|
|
|
36
49
|
@A_Feature.Extend({
|
|
@@ -1,53 +1,85 @@
|
|
|
1
|
-
import { A_Concept } from "@adaas/a-concept/global/A-Concept/A_Concept.class";
|
|
2
1
|
import { MainContainer } from "./containers/Main.container";
|
|
3
2
|
import { ComponentA } from "./components/A.component";
|
|
4
3
|
import { ComponentB } from "./components/B.component";
|
|
4
|
+
import { A_Logger } from "@adaas/a-concept/base/A-Logger/A-Logger.component";
|
|
5
|
+
import { ContextFragmentA } from "./context/Fragment_A.context";
|
|
6
|
+
import { ContextFragmentB } from "./context/Fragment_B.context";
|
|
5
7
|
import { A_Config } from "@adaas/a-concept/base/A-Config/A-Config.context";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
8
|
+
import { A_ConfigLoader } from "@adaas/a-concept/base/A-Config/A-Config.container";
|
|
9
|
+
import { ENVConfigReader } from "@adaas/a-concept/base/A-Config/components/ENVConfigReader.component";
|
|
9
10
|
|
|
10
11
|
(async () => {
|
|
11
12
|
|
|
12
13
|
console.log('Start');
|
|
13
14
|
|
|
14
|
-
class foo extends A_Container<['f', 'f2']> {
|
|
15
|
+
// class foo extends A_Container<['f', 'f2']> {
|
|
16
|
+
|
|
17
|
+
// }
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
// const simpleConcept = new A_Concept({
|
|
21
|
+
// name: 'simple-concept',
|
|
22
|
+
// fragments: [
|
|
23
|
+
// new A_Config({
|
|
24
|
+
// variables: ['A', 'B', 'C'],
|
|
25
|
+
// defaults: {
|
|
26
|
+
// A: 1,
|
|
27
|
+
// }
|
|
28
|
+
// }),
|
|
29
|
+
// new A_Errors({
|
|
30
|
+
// errors: [
|
|
31
|
+
// {
|
|
32
|
+
// code: 'some_error',
|
|
33
|
+
// description: 'Error 1',
|
|
34
|
+
// message: 'Error 1'
|
|
35
|
+
// }
|
|
36
|
+
// ]
|
|
37
|
+
// })
|
|
38
|
+
// ],
|
|
39
|
+
// containers: [
|
|
40
|
+
|
|
41
|
+
// new foo({})
|
|
42
|
+
// ]
|
|
43
|
+
// });
|
|
44
|
+
|
|
45
|
+
// console.log('Here')
|
|
46
|
+
// simpleConcept.call('method_B');
|
|
15
47
|
|
|
16
|
-
|
|
48
|
+
const configContext = new A_Config({
|
|
49
|
+
variables: ['CONFIG_VERBOSE'],
|
|
50
|
+
defaults: {
|
|
51
|
+
'CONFIG_VERBOSE': true
|
|
52
|
+
}
|
|
53
|
+
});
|
|
17
54
|
|
|
18
55
|
|
|
19
|
-
const
|
|
20
|
-
name: 'simple-concept',
|
|
56
|
+
const configLoader = new A_ConfigLoader({
|
|
21
57
|
fragments: [
|
|
22
|
-
|
|
23
|
-
variables: ['A', 'B', 'C'],
|
|
24
|
-
defaults: {
|
|
25
|
-
A: 1,
|
|
26
|
-
}
|
|
27
|
-
}),
|
|
28
|
-
new A_Errors({
|
|
29
|
-
errors: [
|
|
30
|
-
{
|
|
31
|
-
code: 'some_error',
|
|
32
|
-
description: 'Error 1',
|
|
33
|
-
message: 'Error 1'
|
|
34
|
-
}
|
|
35
|
-
]
|
|
36
|
-
})
|
|
58
|
+
configContext
|
|
37
59
|
],
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
components: [
|
|
41
|
-
ComponentA,
|
|
42
|
-
ComponentB
|
|
43
|
-
]
|
|
44
|
-
}),
|
|
45
|
-
new foo({})
|
|
60
|
+
components: [
|
|
61
|
+
ENVConfigReader
|
|
46
62
|
]
|
|
47
63
|
});
|
|
48
64
|
|
|
49
|
-
await
|
|
65
|
+
await configLoader.identifyReader();
|
|
66
|
+
await configLoader.readVariables();
|
|
67
|
+
|
|
50
68
|
|
|
51
|
-
|
|
69
|
+
const container = new MainContainer({
|
|
70
|
+
name: 'MainContainer',
|
|
71
|
+
components: [
|
|
72
|
+
A_Logger,
|
|
73
|
+
ComponentA,
|
|
74
|
+
ComponentB
|
|
75
|
+
],
|
|
76
|
+
fragments: [
|
|
77
|
+
configContext,
|
|
78
|
+
new ContextFragmentA(),
|
|
79
|
+
new ContextFragmentB()
|
|
80
|
+
]
|
|
81
|
+
});
|
|
52
82
|
|
|
83
|
+
// await container.call('method_B');
|
|
84
|
+
await container.method_B();
|
|
53
85
|
})();
|
|
@@ -4,6 +4,8 @@ import { ContextFragmentA } from "../context/Fragment_A.context";
|
|
|
4
4
|
import { ContextFragmentB } from "../context/Fragment_B.context";
|
|
5
5
|
import { A_Concept } from "@adaas/a-concept/global/A-Concept/A_Concept.class";
|
|
6
6
|
import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator";
|
|
7
|
+
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
8
|
+
import { A_Logger } from "@adaas/a-concept/base/A-Logger/A-Logger.component";
|
|
7
9
|
|
|
8
10
|
|
|
9
11
|
|
|
@@ -22,8 +24,10 @@ export class MainContainer extends A_Container<
|
|
|
22
24
|
) {
|
|
23
25
|
if (params) {
|
|
24
26
|
console.log('Start');
|
|
25
|
-
|
|
27
|
+
|
|
26
28
|
}
|
|
29
|
+
|
|
30
|
+
A_Context.feature(this, 'method_A');
|
|
27
31
|
}
|
|
28
32
|
|
|
29
33
|
|
|
@@ -32,16 +36,33 @@ export class MainContainer extends A_Container<
|
|
|
32
36
|
@A_Feature.Define()
|
|
33
37
|
async method_A() {
|
|
34
38
|
console.log('Method A');
|
|
35
|
-
|
|
36
|
-
fragments: [
|
|
39
|
+
await this.call('method_A', {
|
|
40
|
+
fragments: [
|
|
41
|
+
new ContextFragmentA(),
|
|
42
|
+
new ContextFragmentB()
|
|
43
|
+
]
|
|
37
44
|
});
|
|
38
|
-
|
|
39
|
-
await feature.process();
|
|
40
45
|
}
|
|
41
46
|
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
42
50
|
@A_Feature.Define()
|
|
43
51
|
async method_B() {
|
|
44
|
-
console.log('Method B');
|
|
45
|
-
|
|
52
|
+
console.log('Method B', A_Context.root);
|
|
53
|
+
|
|
54
|
+
const logger = this.Scope.resolve(A_Logger);
|
|
55
|
+
|
|
56
|
+
// or you can manually call the feature
|
|
57
|
+
|
|
58
|
+
const feature = A_Context.feature(this, 'method_B', {
|
|
59
|
+
fragments: [new ContextFragmentA(), new ContextFragmentB()]
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
for (const step of feature) {
|
|
63
|
+
logger.log('Manual Loop Execution Step', feature.current);
|
|
64
|
+
|
|
65
|
+
await step();
|
|
66
|
+
}
|
|
46
67
|
}
|
|
47
68
|
}
|
|
@@ -3,13 +3,16 @@ import { HTTPRequest } from "../contexts/http-request.context";
|
|
|
3
3
|
import { A_Logger } from "@adaas/a-concept/base/A-Logger/A-Logger.component";
|
|
4
4
|
import { HttpServer } from "../containers/http-server.container";
|
|
5
5
|
import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
|
|
6
|
+
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
export class HTTPErrorHandler {
|
|
9
|
+
export class HTTPErrorHandler extends A_Component {
|
|
9
10
|
|
|
10
11
|
constructor(
|
|
11
12
|
@A_Inject(A_Logger) private logger: A_Logger
|
|
12
|
-
) {
|
|
13
|
+
) {
|
|
14
|
+
super();
|
|
15
|
+
}
|
|
13
16
|
|
|
14
17
|
|
|
15
18
|
|
package/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// =================================================================================================
|
|
5
5
|
// ---------------------- Major Components ----------------------
|
|
6
6
|
export { A_Context } from './src/global/A-Context/A-Context.class';
|
|
7
|
-
export * from './src/global/A-Context/A-Context.types';
|
|
7
|
+
// export * from './src/global/A-Context/A-Context.types';
|
|
8
8
|
|
|
9
9
|
export { A_Concept } from './src/global/A-Concept/A_Concept.class';
|
|
10
10
|
export { A_ConceptMeta } from './src/global/A-Concept/A_Concept.meta';
|
|
@@ -43,7 +43,12 @@ export * from './src/global/A-Fragment/A-Fragment.types';
|
|
|
43
43
|
export { A_Inject } from './src/decorators/A-Inject/A-Inject.decorator';
|
|
44
44
|
export * from './src/decorators/A-Inject/A-Inject.decorator.types';
|
|
45
45
|
|
|
46
|
+
export { A_Feature_Define } from './src/decorators/A-Feature/A-Feature-Define.decorator';
|
|
47
|
+
export { A_Feature_Extend } from './src/decorators/A-Feature/A-Feature-Extend.decorator';
|
|
48
|
+
export * from './src/decorators/A-Feature/A-Feature.decorator.types';
|
|
46
49
|
|
|
50
|
+
export { A_Stage } from './src/decorators/A-Stage/A-Stage.decorator';
|
|
51
|
+
export * from './src/decorators/A-Stage/A-Stage.decorator.types';
|
|
47
52
|
|
|
48
53
|
|
|
49
54
|
// =================================================================================================
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-concept",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
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",
|
|
@@ -19,10 +19,7 @@ export class A_ConfigLoader extends A_Container<['load', 'read']> {
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
async identifyReader(
|
|
22
|
-
@A_Inject(A_Scope) scope: A_Scope,
|
|
23
|
-
@A_Inject(A_Logger) logger: A_Logger
|
|
24
22
|
) {
|
|
25
|
-
|
|
26
23
|
// OR Inject the logger by calling Context Provider
|
|
27
24
|
// const logger2 = await this.CP.resolve(A_LoggerContext);
|
|
28
25
|
|
|
@@ -30,17 +27,17 @@ export class A_ConfigLoader extends A_Container<['load', 'read']> {
|
|
|
30
27
|
|
|
31
28
|
switch (true) {
|
|
32
29
|
|
|
33
|
-
case A_Context.environment === 'server' && !!fs.existsSync(`${
|
|
34
|
-
this.reader =
|
|
30
|
+
case A_Context.environment === 'server' && !!fs.existsSync(`${this.Scope.name}.conf.json`):
|
|
31
|
+
this.reader = this.Scope.resolve(FileConfigReader);
|
|
35
32
|
break;
|
|
36
33
|
|
|
37
34
|
|
|
38
|
-
case A_Context.environment === 'server': !fs.existsSync(`${
|
|
39
|
-
this.reader =
|
|
35
|
+
case A_Context.environment === 'server': !fs.existsSync(`${this.Scope.name}.conf.json`)
|
|
36
|
+
this.reader = this.Scope.resolve(ENVConfigReader);
|
|
40
37
|
break;
|
|
41
38
|
|
|
42
39
|
case A_Context.environment === 'browser':
|
|
43
|
-
this.reader =
|
|
40
|
+
this.reader = this.Scope.resolve(ENVConfigReader);
|
|
44
41
|
break;
|
|
45
42
|
|
|
46
43
|
default:
|
|
@@ -28,12 +28,19 @@ export class A_Config<
|
|
|
28
28
|
|
|
29
29
|
this.config = A_CommonHelper.deepCloneAndMerge<A_TYPES__ConfigContainerConstructor<T>>(config as any, {
|
|
30
30
|
name: this.name,
|
|
31
|
-
defaults: {} as Record<T, any
|
|
31
|
+
defaults: {} as Record<T, any>,
|
|
32
|
+
variables: [] as T[]
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
this.CONFIG_PROPERTIES = this.config.variables ? this.config.variables : [];
|
|
35
36
|
}
|
|
36
37
|
|
|
38
|
+
protected async onInit(): Promise<void> {
|
|
39
|
+
this.config.variables.forEach((variable) => {
|
|
40
|
+
this.VARIABLES.set(variable, this.config.defaults[variable]);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
37
44
|
|
|
38
45
|
/**
|
|
39
46
|
* This method is used to get the configuration property by name
|
|
@@ -44,7 +51,8 @@ export class A_Config<
|
|
|
44
51
|
get<_OutType = any>(
|
|
45
52
|
property: T | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]
|
|
46
53
|
): _OutType {
|
|
47
|
-
if (this.CONFIG_PROPERTIES.includes(property as any)
|
|
54
|
+
if (this.CONFIG_PROPERTIES.includes(property as any)
|
|
55
|
+
|| this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(property as any))
|
|
48
56
|
return this.VARIABLES.get(property as string) as _OutType;
|
|
49
57
|
|
|
50
58
|
throw new Error('Property not exists or not allowed to read') as never;
|
|
@@ -11,12 +11,12 @@ export type A_TYPES__ConfigContainerConstructor<T extends string> = {
|
|
|
11
11
|
/**
|
|
12
12
|
* Allows to define the names of variable to be loaded
|
|
13
13
|
*/
|
|
14
|
-
variables
|
|
14
|
+
variables: Array<T>
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Allows to set the default values for the variables
|
|
18
18
|
*/
|
|
19
|
-
defaults
|
|
19
|
+
defaults: {
|
|
20
20
|
[key in T]?: any
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -1,16 +1,19 @@
|
|
|
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
|
+
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Config Reader
|
|
8
9
|
*/
|
|
9
|
-
export class ConfigReader {
|
|
10
|
+
export class ConfigReader extends A_Component {
|
|
10
11
|
|
|
11
12
|
constructor(
|
|
12
13
|
@A_Inject(A_Scope) protected scope: A_Scope
|
|
13
|
-
) {
|
|
14
|
+
) {
|
|
15
|
+
super();
|
|
16
|
+
}
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
/**
|
|
@@ -3,14 +3,15 @@ import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorato
|
|
|
3
3
|
import { A_Errors } from "./A-Errors.context";
|
|
4
4
|
import { A_CONSTANTS__ERROR_CODES, A_Error, A_ServerError, ASEID } from "@adaas/a-utils";
|
|
5
5
|
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
6
|
+
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
6
7
|
|
|
7
|
-
export class A_ErrorsManager {
|
|
8
|
+
export class A_ErrorsManager extends A_Component {
|
|
8
9
|
|
|
9
10
|
constructor(
|
|
10
11
|
@A_Inject(A_Scope) protected scope: A_Scope,
|
|
11
12
|
@A_Inject(A_Errors) protected errors: A_Errors
|
|
12
13
|
) {
|
|
13
|
-
|
|
14
|
+
super();
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
|
|
@@ -2,15 +2,17 @@ import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorato
|
|
|
2
2
|
import { A_Error } from "@adaas/a-utils";
|
|
3
3
|
import { A_Config } from "../A-Config/A-Config.context";
|
|
4
4
|
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
5
|
+
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
export class A_Logger {
|
|
9
|
+
export class A_Logger extends A_Component {
|
|
9
10
|
|
|
10
11
|
constructor(
|
|
11
12
|
@A_Inject(A_Scope) protected scope: A_Scope,
|
|
12
13
|
@A_Inject(A_Config) protected config: A_Config
|
|
13
14
|
) {
|
|
15
|
+
super();
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
readonly colors = {
|
|
@@ -75,11 +77,27 @@ export class A_Logger {
|
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
|
|
78
|
-
log(
|
|
80
|
+
log(
|
|
81
|
+
color: keyof typeof this.colors,
|
|
82
|
+
...args: any[]
|
|
83
|
+
)
|
|
84
|
+
log(
|
|
85
|
+
...args: any[]
|
|
86
|
+
)
|
|
87
|
+
log(
|
|
88
|
+
param1: any,
|
|
89
|
+
...args: any[]
|
|
90
|
+
) {
|
|
79
91
|
if (!this.config.get('CONFIG_VERBOSE'))
|
|
80
92
|
return;
|
|
81
93
|
|
|
82
|
-
|
|
94
|
+
if (typeof param1 === 'string' && this.colors[param1]) {
|
|
95
|
+
console.log(...this.compile(param1 as keyof typeof this.colors, ...args));
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
console.log(...this.compile('blue', param1, ...args));
|
|
100
|
+
}
|
|
83
101
|
}
|
|
84
102
|
|
|
85
103
|
warning(...args) {
|