@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,9 +3,88 @@
|
|
|
3
3
|
*
|
|
4
4
|
* [!] Meta can be different depending on the type of input data
|
|
5
5
|
*/
|
|
6
|
-
export declare class A_Meta<_StorageItems extends Record<string, any>> {
|
|
6
|
+
export declare class A_Meta<_StorageItems extends Record<string, any>> implements Iterable<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> {
|
|
7
7
|
protected meta: Map<keyof _StorageItems, _StorageItems[keyof _StorageItems]>;
|
|
8
|
+
/**
|
|
9
|
+
* Method to get the iterator for the meta object
|
|
10
|
+
*
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
[Symbol.iterator](): Iterator<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]>;
|
|
14
|
+
/**
|
|
15
|
+
* Allows to replicate received meta object by replacing internal meta to the received one
|
|
16
|
+
*
|
|
17
|
+
* @param meta
|
|
18
|
+
* @returns
|
|
19
|
+
*/
|
|
8
20
|
from(meta: A_Meta<_StorageItems>): A_Meta<_StorageItems>;
|
|
21
|
+
/**
|
|
22
|
+
* Method to set values in the map
|
|
23
|
+
*
|
|
24
|
+
* @param key
|
|
25
|
+
* @param value
|
|
26
|
+
*/
|
|
9
27
|
set<K extends keyof _StorageItems>(key: K, value: _StorageItems[K]): void;
|
|
28
|
+
/**
|
|
29
|
+
* Method to get values from the map
|
|
30
|
+
*
|
|
31
|
+
* @param key
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
10
34
|
get<K extends keyof _StorageItems>(key: K): _StorageItems[K] | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Method to delete values from the map
|
|
37
|
+
*
|
|
38
|
+
* @param key
|
|
39
|
+
* @returns
|
|
40
|
+
*/
|
|
41
|
+
delete(key: keyof _StorageItems): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* This method is needed to convert the key to a regular expression and cover cases like:
|
|
44
|
+
*
|
|
45
|
+
* simple * e.g. "a*" instead of "a.*"
|
|
46
|
+
*
|
|
47
|
+
* simple ? e.g. "a?" instead of "a."
|
|
48
|
+
*
|
|
49
|
+
* etc.
|
|
50
|
+
*
|
|
51
|
+
* @param key
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
private convertToRegExp;
|
|
55
|
+
/**
|
|
56
|
+
* Method to find values in the map by name.
|
|
57
|
+
*
|
|
58
|
+
* Converts the Key in Map to a regular expression and then compares to the name
|
|
59
|
+
*
|
|
60
|
+
* @param name
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
find(name: string): [keyof _StorageItems, _StorageItems[keyof _StorageItems]][];
|
|
64
|
+
/**
|
|
65
|
+
* Method to find values in the map by regular expression
|
|
66
|
+
*
|
|
67
|
+
* Compares Map Key to the input regular expression
|
|
68
|
+
*
|
|
69
|
+
* @param regex
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
findByRegex(regex: RegExp): Array<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]>;
|
|
73
|
+
/**
|
|
74
|
+
* Method to check if the map has a specific key
|
|
75
|
+
*
|
|
76
|
+
* @param key
|
|
77
|
+
* @returns
|
|
78
|
+
*/
|
|
79
|
+
has(key: keyof _StorageItems): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Method to get the size of the map
|
|
82
|
+
*
|
|
83
|
+
* @returns
|
|
84
|
+
*/
|
|
85
|
+
entries(): IterableIterator<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]>;
|
|
86
|
+
/**
|
|
87
|
+
* Method to clear the map
|
|
88
|
+
*/
|
|
89
|
+
clear(): void;
|
|
11
90
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
//
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
//
|
|
6
|
+
//
|
|
7
|
+
//
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.A_Meta = void 0;
|
|
4
10
|
/**
|
|
@@ -10,14 +16,36 @@ class A_Meta {
|
|
|
10
16
|
constructor() {
|
|
11
17
|
this.meta = new Map();
|
|
12
18
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Method to get the iterator for the meta object
|
|
21
|
+
*
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
[Symbol.iterator]() {
|
|
25
|
+
const iterator = this.meta.entries();
|
|
26
|
+
return {
|
|
27
|
+
next: () => iterator.next()
|
|
28
|
+
};
|
|
16
29
|
}
|
|
17
30
|
// ===================================================================================================
|
|
18
31
|
// ================================ META OPERATIONS ==================================================
|
|
19
32
|
// ===================================================================================================
|
|
20
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Allows to replicate received meta object by replacing internal meta to the received one
|
|
35
|
+
*
|
|
36
|
+
* @param meta
|
|
37
|
+
* @returns
|
|
38
|
+
*/
|
|
39
|
+
from(meta) {
|
|
40
|
+
this.meta = new Map(meta.meta);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Method to set values in the map
|
|
45
|
+
*
|
|
46
|
+
* @param key
|
|
47
|
+
* @param value
|
|
48
|
+
*/
|
|
21
49
|
set(key, value) {
|
|
22
50
|
const inheritedValue = this.meta.get(key)
|
|
23
51
|
|| Array.isArray(value)
|
|
@@ -34,10 +62,98 @@ class A_Meta {
|
|
|
34
62
|
: Object.assign({}, inheritedValue);
|
|
35
63
|
this.meta.set(key, value);
|
|
36
64
|
}
|
|
37
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Method to get values from the map
|
|
67
|
+
*
|
|
68
|
+
* @param key
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
38
71
|
get(key) {
|
|
39
72
|
return this.meta.get(key);
|
|
40
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Method to delete values from the map
|
|
76
|
+
*
|
|
77
|
+
* @param key
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
delete(key) {
|
|
81
|
+
return this.meta.delete(key);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* This method is needed to convert the key to a regular expression and cover cases like:
|
|
85
|
+
*
|
|
86
|
+
* simple * e.g. "a*" instead of "a.*"
|
|
87
|
+
*
|
|
88
|
+
* simple ? e.g. "a?" instead of "a."
|
|
89
|
+
*
|
|
90
|
+
* etc.
|
|
91
|
+
*
|
|
92
|
+
* @param key
|
|
93
|
+
* @returns
|
|
94
|
+
*/
|
|
95
|
+
convertToRegExp(key) {
|
|
96
|
+
return key instanceof RegExp
|
|
97
|
+
? key
|
|
98
|
+
: new RegExp(key);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Method to find values in the map by name.
|
|
102
|
+
*
|
|
103
|
+
* Converts the Key in Map to a regular expression and then compares to the name
|
|
104
|
+
*
|
|
105
|
+
* @param name
|
|
106
|
+
* @returns
|
|
107
|
+
*/
|
|
108
|
+
find(name) {
|
|
109
|
+
const results = [];
|
|
110
|
+
for (const [key, value] of this.meta.entries()) {
|
|
111
|
+
if (this.convertToRegExp(name).test(key)) {
|
|
112
|
+
results.push([key, value]);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return results;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Method to find values in the map by regular expression
|
|
119
|
+
*
|
|
120
|
+
* Compares Map Key to the input regular expression
|
|
121
|
+
*
|
|
122
|
+
* @param regex
|
|
123
|
+
* @returns
|
|
124
|
+
*/
|
|
125
|
+
findByRegex(regex) {
|
|
126
|
+
const results = [];
|
|
127
|
+
for (const [key, value] of this.meta.entries()) {
|
|
128
|
+
if (regex.test(String(key))) {
|
|
129
|
+
results.push([key, value]);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return results;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Method to check if the map has a specific key
|
|
136
|
+
*
|
|
137
|
+
* @param key
|
|
138
|
+
* @returns
|
|
139
|
+
*/
|
|
140
|
+
has(key) {
|
|
141
|
+
return this.meta.has(key);
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Method to get the size of the map
|
|
145
|
+
*
|
|
146
|
+
* @returns
|
|
147
|
+
*/
|
|
148
|
+
entries() {
|
|
149
|
+
return this.meta.entries();
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Method to clear the map
|
|
153
|
+
*/
|
|
154
|
+
clear() {
|
|
155
|
+
this.meta.clear();
|
|
156
|
+
}
|
|
41
157
|
}
|
|
42
158
|
exports.A_Meta = A_Meta;
|
|
43
159
|
//# sourceMappingURL=A-Meta.class.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Meta.class.js","sourceRoot":"","sources":["../../../../src/global/A-Meta/A-Meta.class.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"A-Meta.class.js","sourceRoot":"","sources":["../../../../src/global/A-Meta/A-Meta.class.ts"],"names":[],"mappings":";AAAA,GAAG;AACH,GAAG;AACH,GAAG;AACH,GAAG;AACH,GAAG;AACH,GAAG;;;AAGH;;;;GAIG;AACH,MAAa,MAAM;IAAnB;QAKc,SAAI,GAAiE,IAAI,GAAG,EAAE,CAAC;IAyK7F,CAAC;IAtKG;;;;OAIG;IACH,CAAC,MAAM,CAAC,QAAQ,CAAC;QACb,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACrC,OAAO;YACH,IAAI,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE;SAC9B,CAAC;IACN,CAAC;IAID,sGAAsG;IACtG,sGAAsG;IACtG,sGAAsG;IACtG;;;;;OAKG;IACH,IAAI,CACA,IAA2B;QAE3B,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE/B,OAAO,IAAI,CAAC;IAChB,CAAC;IAGD;;;;;OAKG;IACH,GAAG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C7C,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAa,CAAC,EAAE,CAAC;gBACjD,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAGD;;;;;;;OAOG;IACH,WAAW,CAAC,KAAa;QACrB,MAAM,OAAO,GAAqE,EAAE,CAAC;QACrF,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YAC7C,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC1B,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;IAGD;;;;;OAKG;IACH,GAAG,CAAC,GAAwB;QACxB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAGD;;;;OAIG;IACH,OAAO;QACH,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;IAGD;;OAEG;IACH,KAAK;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;CACJ;AA9KD,wBA8KC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { A_TYPES__ScopeConfig, A_TYPES__ScopeConstructor } from "./A-Scope.types";
|
|
2
2
|
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
3
|
+
import { A_TYPES__ComponentMeta_InjectionParam } from "../A-Component/A-Component.types";
|
|
4
|
+
import { A_Component } from "../A-Component/A-Component.class";
|
|
5
|
+
import { A_Entity } from "../A-Entity/A-Entity.class";
|
|
3
6
|
/**
|
|
4
7
|
*
|
|
5
8
|
*
|
|
@@ -17,6 +20,7 @@ export declare class A_Scope {
|
|
|
17
20
|
name: string;
|
|
18
21
|
private _components;
|
|
19
22
|
private _fragments;
|
|
23
|
+
private _entities;
|
|
20
24
|
private parent?;
|
|
21
25
|
protected params: A_TYPES__ScopeConstructor;
|
|
22
26
|
constructor(params: Partial<A_TYPES__ScopeConstructor>, config?: Partial<A_TYPES__ScopeConfig>);
|
|
@@ -39,13 +43,18 @@ export declare class A_Scope {
|
|
|
39
43
|
* @param component
|
|
40
44
|
* @returns
|
|
41
45
|
*/
|
|
42
|
-
resolve<T extends
|
|
43
|
-
|
|
44
|
-
}>(component: T): InstanceType<T>;
|
|
45
|
-
resolve<T extends {
|
|
46
|
-
new (...args: any[]): any;
|
|
47
|
-
}>(component: Array<T>): Array<InstanceType<T>>;
|
|
46
|
+
resolve<T extends A_TYPES__ComponentMeta_InjectionParam>(component: T): InstanceType<T>;
|
|
47
|
+
resolve<T extends A_TYPES__ComponentMeta_InjectionParam>(component: Array<T>): Array<InstanceType<T>>;
|
|
48
48
|
private resolveOnce;
|
|
49
49
|
private resolveFragment;
|
|
50
|
+
private resolveScope;
|
|
51
|
+
private resolveComponent;
|
|
52
|
+
/**
|
|
53
|
+
* This method is used to register the component in the scope
|
|
54
|
+
*
|
|
55
|
+
* @param fragment
|
|
56
|
+
*/
|
|
57
|
+
register(fragment: A_Entity): void;
|
|
58
|
+
register(fragment: A_Component): void;
|
|
50
59
|
register(fragment: A_Fragment): void;
|
|
51
60
|
}
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.A_Scope = void 0;
|
|
4
4
|
const a_utils_1 = require("@adaas/a-utils");
|
|
5
|
-
const A_Inject_storage_1 = require("../../storage/A_Inject.storage");
|
|
6
5
|
const A_Fragment_class_1 = require("../A-Fragment/A-Fragment.class");
|
|
6
|
+
const A_Context_class_1 = require("../A-Context/A-Context.class");
|
|
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");
|
|
7
10
|
/**
|
|
8
11
|
*
|
|
9
12
|
*
|
|
@@ -22,6 +25,7 @@ class A_Scope {
|
|
|
22
25
|
this.name = '';
|
|
23
26
|
this._components = new WeakMap();
|
|
24
27
|
this._fragments = new WeakMap();
|
|
28
|
+
this._entities = new Map();
|
|
25
29
|
this.name = params.name || this.constructor.name;
|
|
26
30
|
// TODO: move to defaults
|
|
27
31
|
const defaultParams = {
|
|
@@ -97,23 +101,14 @@ class A_Scope {
|
|
|
97
101
|
case a_utils_1.A_CommonHelper.isInheritedFrom(component, A_Fragment_class_1.A_Fragment): {
|
|
98
102
|
return this.resolveFragment(component);
|
|
99
103
|
}
|
|
100
|
-
case
|
|
101
|
-
return this.
|
|
104
|
+
case a_utils_1.A_CommonHelper.isInheritedFrom(component, A_Scope): {
|
|
105
|
+
return this.resolveScope(component);
|
|
102
106
|
}
|
|
103
|
-
case
|
|
104
|
-
|
|
105
|
-
let resolvedArgs = [];
|
|
106
|
-
if (argsMeta)
|
|
107
|
-
resolvedArgs = (argsMeta.get('constructor') || [])
|
|
108
|
-
.map(arg => this.resolve(arg));
|
|
109
|
-
this._components.set(component, new component());
|
|
110
|
-
return this._components.get(component);
|
|
111
|
-
}
|
|
112
|
-
case !this.components.includes(component) && !!this.parent: {
|
|
113
|
-
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);
|
|
114
109
|
}
|
|
115
110
|
default:
|
|
116
|
-
throw new Error(`Component ${component
|
|
111
|
+
throw new Error(`Injected Component ${component} not found in the scope`);
|
|
117
112
|
}
|
|
118
113
|
}
|
|
119
114
|
resolveFragment(fragment) {
|
|
@@ -125,8 +120,57 @@ class A_Scope {
|
|
|
125
120
|
}
|
|
126
121
|
throw new Error(`Fragment ${fragment.name} not found in the scope ${this.name}`);
|
|
127
122
|
}
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
resolveScope(scope) {
|
|
124
|
+
if (a_utils_1.A_CommonHelper.isInheritedFrom(scope, this.constructor)) {
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
else if (this.parent) {
|
|
128
|
+
return this.parent.resolveScope(scope);
|
|
129
|
+
}
|
|
130
|
+
throw new Error(`Scope ${scope.name} not found in the scope ${this.name}`);
|
|
131
|
+
}
|
|
132
|
+
resolveComponent(component) {
|
|
133
|
+
if (this.components.includes(component) && this._components.has(component))
|
|
134
|
+
return this._components.get(component);
|
|
135
|
+
else if (this.components.includes(component) && !this._components.has(component)) {
|
|
136
|
+
const componentMeta = A_Context_class_1.A_Context.meta(component);
|
|
137
|
+
const argsMeta = componentMeta.get(A_Component_types_1.A_TYPES__ComponentMetaKey.INJECTIONS);
|
|
138
|
+
const resolvedArgs = ((argsMeta === null || argsMeta === void 0 ? void 0 : argsMeta.get('constructor')) || [])
|
|
139
|
+
.map(arg => this.resolve(arg));
|
|
140
|
+
const newComponent = new component(...resolvedArgs);
|
|
141
|
+
this.register(newComponent);
|
|
142
|
+
return this._components.get(component);
|
|
143
|
+
}
|
|
144
|
+
else if (!this.components.includes(component) && !!this.parent) {
|
|
145
|
+
return this.parent.resolveComponent(component);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
throw new Error(`Component ${component.name} not found in the scope`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
register(param1) {
|
|
152
|
+
switch (true) {
|
|
153
|
+
case param1 instanceof A_Fragment_class_1.A_Fragment && !this._fragments.has(param1.constructor): {
|
|
154
|
+
this._fragments.set(param1.constructor, 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_Entity_class_1.A_Entity && !this._entities.has(param1.aseid.toString()): {
|
|
160
|
+
this._entities.set(param1.aseid.toString(), 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
|
+
case param1 instanceof A_Component_class_1.A_Component: {
|
|
166
|
+
this._components.set(param1.constructor, param1);
|
|
167
|
+
// The same situation. Have not idea how to fix it
|
|
168
|
+
A_Context_class_1.A_Context.register(this, param1);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
default:
|
|
172
|
+
throw new Error('Invalid arguments provided');
|
|
173
|
+
}
|
|
130
174
|
}
|
|
131
175
|
}
|
|
132
176
|
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,
|
|
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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,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;gBAC5E,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;gBAChD,kDAAkD;gBAClD,2BAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAa,CAAC,CAAC;gBACxC,MAAM;YACV,CAAC;YAED,KAAK,MAAM,YAAY,yBAAQ,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC9E,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,MAAM,CAAC,CAAC;gBACpD,kDAAkD;gBAClD,2BAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAa,CAAC,CAAC;gBACxC,MAAM;YACV,CAAC;YAED,KAAK,MAAM,YAAY,+BAAW,CAAC,CAAC,CAAC;gBACjC,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;AAhQD,0BAgQC"}
|
|
@@ -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
|
})();
|