@adaas/a-concept 0.0.4 → 0.0.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/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 +2 -3
- package/dist/examples/simple/containers/Main.container.js +28 -8
- 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 +7 -1
- package/dist/index.js +13 -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 +4 -2
- package/dist/src/base/A-Config/A-Config.types.js +4 -0
- package/dist/src/base/A-Config/A-Config.types.js.map +1 -1
- 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 +138 -54
- 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-Dependency/A-DependencyReference.class.d.ts +0 -17
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js +47 -65
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.class.d.ts +73 -2
- package/dist/src/global/A-Entity/A-Entity.class.js +107 -1
- 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 +56 -0
- package/dist/src/global/A-Entity/A-Entity.types.js +15 -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 +80 -1
- package/dist/src/global/A-Meta/A-Meta.class.js +121 -5
- 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 +61 -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 +36 -9
- 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 +9 -1
- package/jest.config.ts +0 -4
- 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 +8 -3
- 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 -12
- 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 -39
- package/src/global/A-Container/A-Container.meta.ts +0 -64
- package/src/global/A-Context/A-Context.class.ts +240 -80
- package/src/global/A-Context/A-Context.types.ts +0 -15
- package/src/global/A-Dependency/A-DependencyReference.class.ts +61 -61
- package/src/global/A-Entity/A-Entity.class.ts +184 -2
- package/src/global/A-Entity/A-Entity.meta.ts +9 -0
- package/src/global/A-Entity/A-Entity.types.ts +75 -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 +140 -12
- package/src/global/A-Scope/A-Scope.class.ts +101 -31
- package/tsconfig.json +0 -4
- package/src/storage/A_Component.storage.ts +0 -28
- package/src/storage/A_Concept.storage.ts +0 -49
- package/src/storage/A_Container.storage.ts +0 -21
- package/src/storage/A_Inject.storage.ts +0 -30
|
@@ -3,6 +3,9 @@ import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
|
|
|
3
3
|
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
|
+
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";
|
|
6
9
|
|
|
7
10
|
|
|
8
11
|
|
|
@@ -16,26 +19,50 @@ export class MainContainer extends A_Container<
|
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
@A_Concept.Start()
|
|
19
|
-
async start
|
|
20
|
-
|
|
22
|
+
async start(
|
|
23
|
+
@A_Inject(MainContainer) params?: any
|
|
24
|
+
) {
|
|
25
|
+
if (params) {
|
|
26
|
+
console.log('Start');
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
A_Context.feature(this, 'method_A');
|
|
21
31
|
}
|
|
22
32
|
|
|
23
33
|
|
|
24
|
-
|
|
34
|
+
|
|
25
35
|
|
|
26
36
|
@A_Feature.Define()
|
|
27
37
|
async method_A() {
|
|
28
38
|
console.log('Method A');
|
|
29
|
-
|
|
30
|
-
fragments: [
|
|
39
|
+
await this.call('method_A', {
|
|
40
|
+
fragments: [
|
|
41
|
+
new ContextFragmentA(),
|
|
42
|
+
new ContextFragmentB()
|
|
43
|
+
]
|
|
31
44
|
});
|
|
32
|
-
|
|
33
|
-
await feature.process();
|
|
34
45
|
}
|
|
35
46
|
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
36
50
|
@A_Feature.Define()
|
|
37
51
|
async method_B() {
|
|
38
|
-
console.log('Method B');
|
|
39
|
-
|
|
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
|
+
}
|
|
40
67
|
}
|
|
41
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';
|
|
@@ -18,6 +18,9 @@ export { A_Component } from './src/global/A-Component/A-Component.class';
|
|
|
18
18
|
export { A_ComponentMeta } from './src/global/A-Component/A-Component.meta';
|
|
19
19
|
export * from './src/global/A-Component/A-Component.types';
|
|
20
20
|
|
|
21
|
+
export { A_Entity } from './src/global/A-Entity/A-Entity.class';
|
|
22
|
+
export * from './src/global/A-Entity/A-Entity.types';
|
|
23
|
+
|
|
21
24
|
|
|
22
25
|
// ---------------------- Common Components ----------------------
|
|
23
26
|
export { A_Feature } from './src/global/A-Feature/A-Feature.class';
|
|
@@ -40,7 +43,12 @@ export * from './src/global/A-Fragment/A-Fragment.types';
|
|
|
40
43
|
export { A_Inject } from './src/decorators/A-Inject/A-Inject.decorator';
|
|
41
44
|
export * from './src/decorators/A-Inject/A-Inject.decorator.types';
|
|
42
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';
|
|
43
49
|
|
|
50
|
+
export { A_Stage } from './src/decorators/A-Stage/A-Stage.decorator';
|
|
51
|
+
export * from './src/decorators/A-Stage/A-Stage.decorator.types';
|
|
44
52
|
|
|
45
53
|
|
|
46
54
|
// =================================================================================================
|
package/jest.config.ts
CHANGED
|
@@ -13,10 +13,6 @@ const config: Config.InitialOptions = {
|
|
|
13
13
|
"@adaas/a-concept/types/(.*)": ["<rootDir>/src/types/$1"],
|
|
14
14
|
"@adaas/a-concept/helpers/(.*)": ["<rootDir>/src/helpers/$1"],
|
|
15
15
|
"@adaas/a-concept/decorators/(.*)": ["<rootDir>/src/decorators/$1"],
|
|
16
|
-
"@adaas/a-concept/managers/(.*)": ["<rootDir>/src/managers/$1"],
|
|
17
|
-
"@adaas/a-concept/providers/(.*)": ["<rootDir>/src/providers/$1"],
|
|
18
|
-
"@adaas/a-concept/modules/(.*)": ["<rootDir>/src/modules/$1"],
|
|
19
|
-
"@adaas/a-concept/storage/(.*)": ["<rootDir>/src/storage/$1"],
|
|
20
16
|
"@adaas/a-concept/base/(.*)": ["<rootDir>/src/base/$1"],
|
|
21
17
|
}
|
|
22
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-concept",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
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;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { A_TYPES__FragmentConstructor } from "@adaas/a-concept/global/A-Fragment/A-Fragment.types";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export enum A_TYPES__ConfigFeature {
|
|
5
|
+
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
|
|
4
9
|
export type A_TYPES__ConfigContainerConstructor<T extends string> = {
|
|
5
10
|
|
|
6
11
|
/**
|
|
7
12
|
* Allows to define the names of variable to be loaded
|
|
8
13
|
*/
|
|
9
|
-
variables
|
|
14
|
+
variables: Array<T>
|
|
10
15
|
|
|
11
16
|
/**
|
|
12
17
|
* Allows to set the default values for the variables
|
|
13
18
|
*/
|
|
14
|
-
defaults
|
|
19
|
+
defaults: {
|
|
15
20
|
[key in T]?: any
|
|
16
21
|
}
|
|
17
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) {
|
|
@@ -5,6 +5,9 @@ import {
|
|
|
5
5
|
} from "./A-Feature.decorator.types";
|
|
6
6
|
import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.types";
|
|
7
7
|
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
8
|
+
import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
9
|
+
import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class";
|
|
10
|
+
import { A_Meta } from "@adaas/a-concept/global/A-Meta/A-Meta.class";
|
|
8
11
|
|
|
9
12
|
|
|
10
13
|
|
|
@@ -31,27 +34,29 @@ export function A_Feature_Extend(
|
|
|
31
34
|
descriptor: A_TYPES__A_ExtendDecoratorDescriptor
|
|
32
35
|
) {
|
|
33
36
|
|
|
37
|
+
const extensionName = config.name || propertyKey
|
|
38
|
+
|
|
34
39
|
// Get the existed metadata or create a new one
|
|
35
40
|
const existedMeta = A_Context
|
|
36
41
|
.meta(target)
|
|
37
42
|
.get(A_TYPES__ComponentMetaKey.EXTENSIONS)
|
|
38
|
-
|| new
|
|
43
|
+
|| new A_Meta();
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
existedMeta.
|
|
42
|
-
|
|
45
|
+
|
|
46
|
+
const existedMetaValue = existedMeta.get(extensionName) || [];
|
|
47
|
+
|
|
48
|
+
// Add the new method to the metadata
|
|
49
|
+
existedMetaValue.push({
|
|
50
|
+
name: extensionName,
|
|
43
51
|
handler: propertyKey,
|
|
44
|
-
container: config.container
|
|
45
|
-
? typeof config.container === 'string'
|
|
46
|
-
? config.container
|
|
47
|
-
: config.container.name
|
|
48
|
-
: '*',
|
|
49
52
|
});
|
|
50
53
|
|
|
54
|
+
// Set the metadata of the method to define a custom Feature with name
|
|
55
|
+
existedMeta.set(extensionName, existedMetaValue);
|
|
56
|
+
|
|
51
57
|
// Update the metadata of the container with the new Feature definition
|
|
52
58
|
A_Context
|
|
53
59
|
.meta(target)
|
|
54
60
|
.set(A_TYPES__ComponentMetaKey.EXTENSIONS, existedMeta);
|
|
55
|
-
|
|
56
61
|
};
|
|
57
62
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
2
|
-
import {
|
|
3
|
-
import { A_TYPES__A_InjectDecoratorReturn, A_TYPES__A_InjectDecoratorStorageInstruction } from "./A-Inject.decorator.types";
|
|
4
|
-
import { A_STORAGE__A_Inject_Instructions } from "@adaas/a-concept/storage/A_Inject.storage";
|
|
2
|
+
import { A_TYPES__A_InjectDecoratorReturn } from "./A-Inject.decorator.types";
|
|
5
3
|
import { A_Fragment } from "@adaas/a-concept/global/A-Fragment/A-Fragment.class";
|
|
6
4
|
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
7
5
|
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
8
6
|
import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.types";
|
|
7
|
+
import { A_Meta } from "@adaas/a-concept/global/A-Meta/A-Meta.class";
|
|
8
|
+
import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -34,9 +34,9 @@ export function A_Inject(
|
|
|
34
34
|
): A_TYPES__A_InjectDecoratorReturn
|
|
35
35
|
|
|
36
36
|
// Allows to inject just one container
|
|
37
|
-
export function A_Inject(
|
|
38
|
-
|
|
39
|
-
): A_TYPES__A_InjectDecoratorReturn
|
|
37
|
+
// export function A_Inject(
|
|
38
|
+
// container: typeof A_Container
|
|
39
|
+
// ): A_TYPES__A_InjectDecoratorReturn
|
|
40
40
|
|
|
41
41
|
// Allows to inject just one Context Fragment
|
|
42
42
|
export function A_Inject(
|
|
@@ -51,10 +51,9 @@ export function A_Inject<
|
|
|
51
51
|
): A_TYPES__A_InjectDecoratorReturn
|
|
52
52
|
|
|
53
53
|
// ====================== BASE FUNCTION ======================
|
|
54
|
-
export function A_Inject
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
param1: T | typeof A_Fragment | typeof A_Component | typeof A_Container | typeof A_Fragment,
|
|
54
|
+
export function A_Inject(
|
|
55
|
+
param1: typeof A_Fragment | typeof A_Component | typeof A_Scope | typeof A_Feature,
|
|
56
|
+
|
|
58
57
|
): A_TYPES__A_InjectDecoratorReturn {
|
|
59
58
|
return function (
|
|
60
59
|
target: A_Component,
|
|
@@ -62,13 +61,15 @@ export function A_Inject<
|
|
|
62
61
|
parameterIndex: number
|
|
63
62
|
) {
|
|
64
63
|
|
|
65
|
-
const method = methodName ? methodName : 'constructor';
|
|
64
|
+
const method = methodName ? String(methodName) : 'constructor';
|
|
66
65
|
|
|
66
|
+
console.log('target: ', target);
|
|
67
67
|
|
|
68
68
|
const existedMeta = A_Context
|
|
69
69
|
.meta(target)
|
|
70
70
|
.get(A_TYPES__ComponentMetaKey.INJECTIONS)
|
|
71
|
-
|| new
|
|
71
|
+
|| new A_Meta();
|
|
72
|
+
|
|
72
73
|
|
|
73
74
|
const paramsArray = existedMeta.get(method) || [];
|
|
74
75
|
|
|
@@ -1,5 +1,60 @@
|
|
|
1
|
+
import { A_TYPES__Required } from "@adaas/a-utils";
|
|
2
|
+
import { A_Context } from "../A-Context/A-Context.class";
|
|
3
|
+
import { A_TYPES__ComponentCallParams } from "./A-Component.types";
|
|
4
|
+
|
|
1
5
|
/**
|
|
2
6
|
* This element only contains the specific code
|
|
3
7
|
*
|
|
4
8
|
*/
|
|
5
|
-
export class A_Component
|
|
9
|
+
export class A_Component<
|
|
10
|
+
_FeatureNames extends Array<string> = any,
|
|
11
|
+
> {
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Call a feature of the component
|
|
16
|
+
*
|
|
17
|
+
* @param lifecycleMethod
|
|
18
|
+
* @param args
|
|
19
|
+
*/
|
|
20
|
+
async call(
|
|
21
|
+
/**
|
|
22
|
+
* A-Feature method name to be called
|
|
23
|
+
*/
|
|
24
|
+
feature: _FeatureNames[number],
|
|
25
|
+
): Promise<any>
|
|
26
|
+
async call(
|
|
27
|
+
/**
|
|
28
|
+
* A-Feature name to be called
|
|
29
|
+
*/
|
|
30
|
+
params: A_TYPES__Required<Partial<A_TYPES__ComponentCallParams<_FeatureNames[number]>>, ['name']>,
|
|
31
|
+
): Promise<any>
|
|
32
|
+
|
|
33
|
+
async call(
|
|
34
|
+
/**
|
|
35
|
+
* A-Feature method name to be called
|
|
36
|
+
*/
|
|
37
|
+
feature: string,
|
|
38
|
+
/**
|
|
39
|
+
* Parameters to provide additional data to the feature
|
|
40
|
+
*/
|
|
41
|
+
params: Partial<A_TYPES__ComponentCallParams<_FeatureNames[number]>>,
|
|
42
|
+
): Promise<any>
|
|
43
|
+
|
|
44
|
+
async call(
|
|
45
|
+
param1: _FeatureNames[number] | A_TYPES__Required<Partial<A_TYPES__ComponentCallParams<_FeatureNames[number]>>, ['name']>,
|
|
46
|
+
param2?: Partial<A_TYPES__ComponentCallParams<_FeatureNames[number]>>
|
|
47
|
+
): Promise<any> {
|
|
48
|
+
|
|
49
|
+
const feature: string = typeof param1 === 'string'
|
|
50
|
+
? param1
|
|
51
|
+
: param1.name;
|
|
52
|
+
const params: Partial<A_TYPES__ComponentCallParams<_FeatureNames[number]>> = typeof param1 === 'string'
|
|
53
|
+
? param2 || {}
|
|
54
|
+
: param1;
|
|
55
|
+
|
|
56
|
+
const newFeature = A_Context.feature(this, feature, params);
|
|
57
|
+
|
|
58
|
+
return await newFeature.process();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -1,9 +1,48 @@
|
|
|
1
1
|
import { A_Meta } from "../A-Meta/A-Meta.class";
|
|
2
|
-
import { A_TYPES__ComponentMeta } from "./A-Component.types";
|
|
2
|
+
import { A_TYPES__ComponentMeta, A_TYPES__ComponentMetaExtension, A_TYPES__ComponentMetaKey } from "./A-Component.types";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
export class A_ComponentMeta extends A_Meta<A_TYPES__ComponentMeta> {
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Allows to get all the extensions for a given feature
|
|
12
|
+
*
|
|
13
|
+
* @param feature
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
extensions(
|
|
17
|
+
feature: string
|
|
18
|
+
): A_TYPES__ComponentMetaExtension[] {
|
|
19
|
+
const steps: A_TYPES__ComponentMetaExtension[] = [];
|
|
20
|
+
|
|
21
|
+
const extensions = this.get(A_TYPES__ComponentMetaKey.EXTENSIONS);
|
|
22
|
+
const injections = this.get(A_TYPES__ComponentMetaKey.INJECTIONS);
|
|
23
|
+
|
|
24
|
+
// const constructor = A_Context.component(this);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
extensions
|
|
28
|
+
// returns all extensions that match the feature
|
|
29
|
+
?.find(feature)
|
|
30
|
+
.forEach(([handler, extensions]) => {
|
|
31
|
+
extensions.forEach(extension => {
|
|
32
|
+
|
|
33
|
+
const args = injections?.get(extension.handler) || [];
|
|
34
|
+
|
|
35
|
+
steps.push({
|
|
36
|
+
// component: constructor,
|
|
37
|
+
handler: extension.handler,
|
|
38
|
+
args
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
return steps;
|
|
46
|
+
}
|
|
47
|
+
|
|
9
48
|
}
|
|
@@ -1,15 +1,42 @@
|
|
|
1
|
+
import { A_Feature } from "../A-Feature/A-Feature.class"
|
|
2
|
+
import { A_Fragment } from "../A-Fragment/A-Fragment.class"
|
|
3
|
+
import { A_Meta } from "../A-Meta/A-Meta.class"
|
|
4
|
+
import { A_Scope } from "../A-Scope/A-Scope.class"
|
|
5
|
+
import { A_Component } from "./A-Component.class"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export type A_TYPES__ComponentCallParams<T extends string> = {
|
|
9
|
+
name: T,
|
|
10
|
+
fragments: Array<A_Fragment>,
|
|
11
|
+
components: Array<{ new(...args: any[]): any }>
|
|
12
|
+
}
|
|
1
13
|
|
|
2
14
|
|
|
3
15
|
export type A_TYPES__ComponentMeta = {
|
|
4
|
-
[A_TYPES__ComponentMetaKey.EXTENSIONS]:
|
|
16
|
+
[A_TYPES__ComponentMetaKey.EXTENSIONS]: A_Meta<{
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Where Key the regexp for what to apply the extension
|
|
20
|
+
* A set of container names or a wildcard, or a regexp
|
|
21
|
+
*
|
|
22
|
+
*
|
|
23
|
+
* Where value is the extension instructions
|
|
24
|
+
*/
|
|
25
|
+
[Key: string]: A_TYPES__ComponentMeta_ExtensionItem[]
|
|
26
|
+
}>,
|
|
27
|
+
|
|
28
|
+
|
|
5
29
|
[A_TYPES__ComponentMetaKey.FEATURES]: any[],
|
|
6
|
-
[A_TYPES__ComponentMetaKey.INJECTIONS]: Map<
|
|
7
|
-
// Where key is method name
|
|
8
|
-
Symbol | string,
|
|
9
|
-
// And value is Injection instructions
|
|
10
|
-
A_TYPES__ComponentMeta_InjectionParams
|
|
11
|
-
>
|
|
12
30
|
|
|
31
|
+
|
|
32
|
+
[A_TYPES__ComponentMetaKey.INJECTIONS]: A_Meta<{
|
|
33
|
+
/**
|
|
34
|
+
* Where Key is the name of the injection
|
|
35
|
+
*
|
|
36
|
+
* Where value is the list of injections
|
|
37
|
+
*/
|
|
38
|
+
[Key: string]: Array<A_TYPES__ComponentMeta_InjectionParam>
|
|
39
|
+
}>
|
|
13
40
|
}
|
|
14
41
|
|
|
15
42
|
export enum A_TYPES__ComponentMetaKey {
|
|
@@ -18,23 +45,28 @@ export enum A_TYPES__ComponentMetaKey {
|
|
|
18
45
|
INJECTIONS = 'a-component-injections',
|
|
19
46
|
}
|
|
20
47
|
|
|
48
|
+
export type A_TYPES__ComponentMetaExtension = {
|
|
49
|
+
handler: string,
|
|
50
|
+
args: A_TYPES__ComponentMeta_InjectionParam[]
|
|
51
|
+
}
|
|
52
|
+
|
|
21
53
|
|
|
22
54
|
export type A_TYPES__ComponentMeta_ExtensionItem = {
|
|
23
55
|
name: string,
|
|
24
|
-
container: string,
|
|
25
56
|
handler: string,
|
|
26
57
|
}
|
|
27
58
|
|
|
28
59
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// |
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
60
|
+
|
|
61
|
+
export type A_TYPES__ComponentMeta_InjectionParam =
|
|
62
|
+
{ new(...args: any[]): A_Fragment }
|
|
63
|
+
| { new(...args: any[]): A_Component }
|
|
64
|
+
// | { new(...args: any[]): any }
|
|
65
|
+
| { new(...args: any[]): A_Scope }
|
|
66
|
+
| { new(...args: any[]): A_Feature };
|
|
67
|
+
// typeof A_Fragment
|
|
68
|
+
// | typeof A_Component
|
|
69
|
+
// // | { new(...args: any[]): any }
|
|
70
|
+
// | typeof A_Scope
|
|
71
|
+
// | typeof A_Feature;
|
|
40
72
|
|