@adaas/a-concept 0.0.39 → 0.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/global/A-Abstraction/A-Abstraction.class.d.ts +8 -2
- package/dist/src/global/A-Abstraction/A-Abstraction.class.js +5 -1
- package/dist/src/global/A-Abstraction/A-Abstraction.class.js.map +1 -1
- package/dist/src/global/A-Abstraction/A-Abstraction.types.d.ts +13 -4
- package/dist/src/global/A-Abstraction/A-Abstraction.types.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.class.d.ts +11 -4
- package/dist/src/global/A-Component/A-Component.class.js +13 -4
- package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
- package/dist/src/global/A-Concept/A_Concept.class.d.ts +11 -10
- package/dist/src/global/A-Concept/A_Concept.class.js +24 -20
- package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
- package/dist/src/global/A-Concept/A_Concept.meta.d.ts +4 -4
- package/dist/src/global/A-Concept/A_Concept.meta.js +14 -6
- package/dist/src/global/A-Concept/A_Concept.meta.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.class.d.ts +3 -4
- package/dist/src/global/A-Container/A-Container.class.js +8 -8
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.class.d.ts +8 -10
- package/dist/src/global/A-Context/A-Context.class.js +26 -32
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.class.d.ts +2 -2
- package/dist/src/global/A-Entity/A-Entity.class.js +4 -4
- package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.class.d.ts +10 -8
- package/dist/src/global/A-Feature/A-Feature.class.js +11 -11
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +13 -2
- package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.class.d.ts +14 -0
- package/dist/src/global/A-Scope/A-Scope.class.js +48 -5
- package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
- package/dist/src/global/A-Stage/A-Stage.class.js +2 -2
- package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -1
- package/examples/simple/concept.ts +1 -0
- package/examples/simple/containers/Main.container.ts +6 -5
- package/examples/simple-http-server/concept.ts +1 -0
- package/examples/simple-http-server/containers/http-server.container.ts +4 -2
- package/package.json +1 -1
- package/src/global/A-Abstraction/A-Abstraction.class.ts +11 -3
- package/src/global/A-Abstraction/A-Abstraction.types.ts +13 -6
- package/src/global/A-Component/A-Component.class.ts +12 -7
- package/src/global/A-Concept/A_Concept.class.ts +29 -21
- package/src/global/A-Concept/A_Concept.meta.ts +8 -15
- package/src/global/A-Container/A-Container.class.ts +13 -11
- package/src/global/A-Context/A-Context.class.ts +38 -85
- package/src/global/A-Entity/A-Entity.class.ts +5 -4
- package/src/global/A-Feature/A-Feature.class.ts +22 -13
- package/src/global/A-Feature/A-Feature.types.ts +14 -2
- package/src/global/A-Scope/A-Scope.class.ts +61 -5
- package/src/global/A-Stage/A-Stage.class.ts +4 -2
|
@@ -5,6 +5,7 @@ import { A_Concept } from "@adaas/a-concept/global/A-Concept/A_Concept.class";
|
|
|
5
5
|
import { A_Config } from "@adaas/a-concept/base/A-Config/A-Config.context";
|
|
6
6
|
import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
|
|
7
7
|
import { HTTPRequest } from "../contexts/http-request.context";
|
|
8
|
+
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
@@ -42,11 +43,12 @@ export class HttpServer extends A_Container {
|
|
|
42
43
|
req: IncomingMessage,
|
|
43
44
|
res: ServerResponse
|
|
44
45
|
) {
|
|
45
|
-
return await this.call('onRequest', {
|
|
46
|
+
return await this.call('onRequest', new A_Scope({
|
|
47
|
+
name: `http-request::${Date.now()}`,
|
|
46
48
|
fragments: [
|
|
47
49
|
new HTTPRequest(req, res)
|
|
48
50
|
]
|
|
49
|
-
});
|
|
51
|
+
}));
|
|
50
52
|
}
|
|
51
53
|
|
|
52
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.40",
|
|
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",
|
|
@@ -2,6 +2,7 @@ import { A_Abstraction_Extend } from "@adaas/a-concept/decorators/A-Abstraction/
|
|
|
2
2
|
import { A_Feature } from "../A-Feature/A-Feature.class";
|
|
3
3
|
import { A_TYPES__A_AbstractionConstructor, A_TYPES__AbstractionState } from "./A-Abstraction.types";
|
|
4
4
|
import { A_Error, A_TYPES__Required } from "@adaas/a-utils";
|
|
5
|
+
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
export class A_Abstraction {
|
|
@@ -15,6 +16,7 @@ export class A_Abstraction {
|
|
|
15
16
|
error?: A_Error
|
|
16
17
|
|
|
17
18
|
|
|
19
|
+
readonly Scope!: A_Scope;
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* Define a new A-Abstraction
|
|
@@ -24,9 +26,14 @@ export class A_Abstraction {
|
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
constructor(
|
|
30
|
+
/**
|
|
31
|
+
* Parameters to define the A-Abstraction
|
|
32
|
+
*/
|
|
33
|
+
params: A_TYPES__A_AbstractionConstructor
|
|
34
|
+
) {
|
|
29
35
|
this.name = params.name;
|
|
36
|
+
|
|
30
37
|
this.features = params.features.map(def => new A_Feature(def));
|
|
31
38
|
|
|
32
39
|
this._current = this.features[0];
|
|
@@ -37,6 +44,7 @@ export class A_Abstraction {
|
|
|
37
44
|
return this._current;
|
|
38
45
|
}
|
|
39
46
|
|
|
47
|
+
|
|
40
48
|
[Symbol.iterator](): Iterator<A_Feature, any> {
|
|
41
49
|
return {
|
|
42
50
|
// Custom next method
|
|
@@ -110,7 +118,7 @@ export class A_Abstraction {
|
|
|
110
118
|
|
|
111
119
|
|
|
112
120
|
async process() {
|
|
113
|
-
if (this.isDone())
|
|
121
|
+
if (this.isDone())
|
|
114
122
|
return;
|
|
115
123
|
try {
|
|
116
124
|
this.state = A_TYPES__AbstractionState.PROCESSING;
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
-
import { A_TYPES__Required } from "@adaas/a-utils";
|
|
2
|
-
import { A_Container } from "../A-Container/A-Container.class";
|
|
3
1
|
import { A_TYPES__FeatureConstructor } from "../A-Feature/A-Feature.types";
|
|
4
|
-
import {
|
|
5
|
-
import { A_TYPES__A_StageStep } from "../A-Stage/A-Stage.types";
|
|
2
|
+
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
6
3
|
|
|
7
4
|
|
|
8
5
|
|
|
9
6
|
export type A_TYPES__A_AbstractionConstructor = {
|
|
7
|
+
/**
|
|
8
|
+
* Name of the A-Abstraction
|
|
9
|
+
*/
|
|
10
10
|
name: string,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Features that compose the A-Abstraction
|
|
13
|
+
*/
|
|
14
|
+
features: Array<A_TYPES__FeatureConstructor>
|
|
15
|
+
/**
|
|
16
|
+
* Scope in which the A-Abstraction will be executed
|
|
17
|
+
*/
|
|
18
|
+
scope: A_Scope
|
|
19
|
+
}
|
|
13
20
|
|
|
14
21
|
|
|
15
22
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { A_Context } from "../A-Context/A-Context.class";
|
|
2
2
|
import { A_TYPES__ComponentConstructor } from "./A-Component.types";
|
|
3
3
|
import { A_TYPES__FeatureCallParams } from "../A-Feature/A-Feature.types";
|
|
4
|
+
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
|
|
@@ -9,24 +10,28 @@ import { A_TYPES__FeatureCallParams } from "../A-Feature/A-Feature.types";
|
|
|
9
10
|
*
|
|
10
11
|
*/
|
|
11
12
|
export class A_Component {
|
|
12
|
-
constructor(
|
|
13
|
-
params?: Partial<A_TYPES__ComponentConstructor<any>>
|
|
14
|
-
) {
|
|
13
|
+
constructor() {
|
|
15
14
|
console.log('A-Component instance created', this);
|
|
16
15
|
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
|
|
20
19
|
async call(
|
|
20
|
+
/**
|
|
21
|
+
* Name of the feature to call
|
|
22
|
+
*/
|
|
21
23
|
feature: string,
|
|
22
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Scope in which the feature will be executed
|
|
26
|
+
*/
|
|
27
|
+
scope?: A_Scope,
|
|
23
28
|
) {
|
|
24
|
-
|
|
29
|
+
scope = scope ? scope.inherit(A_Context.scope(this)) : A_Context.scope(this);
|
|
30
|
+
|
|
31
|
+
const newFeature = A_Context.feature(this, feature, scope);
|
|
25
32
|
|
|
26
33
|
return await newFeature.process();
|
|
27
34
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
|
|
@@ -3,6 +3,7 @@ import { A_Container } from "../A-Container/A-Container.class";
|
|
|
3
3
|
import { A_Abstraction } from "../A-Abstraction/A-Abstraction.class";
|
|
4
4
|
import { A_ConceptMeta } from "./A_Concept.meta";
|
|
5
5
|
import { A_Abstraction_Extend } from "@adaas/a-concept/decorators/A-Abstraction/A-Abstraction-Extend.decorator";
|
|
6
|
+
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
// export type RunParams<T> = T extends A_Container<any, infer Params> ? Params : never;
|
|
@@ -98,18 +99,16 @@ export class A_Concept<
|
|
|
98
99
|
protected props: A_TYPES__IConceptConstructor<_Imports>
|
|
99
100
|
) {
|
|
100
101
|
this.sharedBase = new A_Container({
|
|
101
|
-
name: props.name
|
|
102
|
+
name: `${props.name}::base`,
|
|
102
103
|
fragments: props.fragments || [],
|
|
103
104
|
entities: props.entities || [],
|
|
104
|
-
// containers: props.containers
|
|
105
105
|
components: [
|
|
106
106
|
// A_Logger,
|
|
107
|
-
]
|
|
107
|
+
],
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
this.containers = (props.containers || []).map(container => {
|
|
111
111
|
container.Scope.parent(this.Scope);
|
|
112
|
-
|
|
113
112
|
return container;
|
|
114
113
|
});
|
|
115
114
|
|
|
@@ -136,9 +135,11 @@ export class A_Concept<
|
|
|
136
135
|
* Load the concept.
|
|
137
136
|
*/
|
|
138
137
|
async load(
|
|
139
|
-
|
|
138
|
+
scope?: A_Scope,
|
|
140
139
|
) {
|
|
141
|
-
|
|
140
|
+
scope = scope ? scope.inherit(this.Scope) : this.Scope;
|
|
141
|
+
|
|
142
|
+
const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Load, scope);
|
|
142
143
|
|
|
143
144
|
await abstraction.process();
|
|
144
145
|
}
|
|
@@ -149,11 +150,11 @@ export class A_Concept<
|
|
|
149
150
|
* Run the concept.
|
|
150
151
|
*/
|
|
151
152
|
async run(
|
|
152
|
-
|
|
153
|
+
scope?: A_Scope,
|
|
153
154
|
) {
|
|
154
|
-
|
|
155
|
+
scope = scope ? scope.inherit(this.Scope) : this.Scope;
|
|
155
156
|
|
|
156
|
-
const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Run,
|
|
157
|
+
const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Run, scope);
|
|
157
158
|
|
|
158
159
|
await abstraction.process();
|
|
159
160
|
}
|
|
@@ -165,11 +166,11 @@ export class A_Concept<
|
|
|
165
166
|
* @param params
|
|
166
167
|
*/
|
|
167
168
|
async start(
|
|
168
|
-
|
|
169
|
+
scope?: A_Scope,
|
|
169
170
|
) {
|
|
170
|
-
|
|
171
|
+
scope = scope ? scope.inherit(this.Scope) : this.Scope;
|
|
171
172
|
|
|
172
|
-
const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Start,
|
|
173
|
+
const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Start, scope);
|
|
173
174
|
|
|
174
175
|
await abstraction.process();
|
|
175
176
|
}
|
|
@@ -181,9 +182,11 @@ export class A_Concept<
|
|
|
181
182
|
* @param params
|
|
182
183
|
*/
|
|
183
184
|
async stop(
|
|
184
|
-
|
|
185
|
+
scope?: A_Scope,
|
|
185
186
|
) {
|
|
186
|
-
|
|
187
|
+
scope = scope ? scope.inherit(this.Scope) : this.Scope;
|
|
188
|
+
|
|
189
|
+
const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Stop, scope);
|
|
187
190
|
|
|
188
191
|
await abstraction.process();
|
|
189
192
|
}
|
|
@@ -193,9 +196,11 @@ export class A_Concept<
|
|
|
193
196
|
* Build the concept.
|
|
194
197
|
*/
|
|
195
198
|
async build(
|
|
196
|
-
|
|
199
|
+
scope?: A_Scope,
|
|
197
200
|
) {
|
|
198
|
-
|
|
201
|
+
scope = scope ? scope.inherit(this.Scope) : this.Scope;
|
|
202
|
+
|
|
203
|
+
const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Build, scope);
|
|
199
204
|
|
|
200
205
|
await abstraction.process();
|
|
201
206
|
}
|
|
@@ -205,9 +210,11 @@ export class A_Concept<
|
|
|
205
210
|
* Deploy the concept.
|
|
206
211
|
*/
|
|
207
212
|
async deploy(
|
|
208
|
-
|
|
213
|
+
scope?: A_Scope,
|
|
209
214
|
) {
|
|
210
|
-
|
|
215
|
+
scope = scope ? scope.inherit(this.Scope) : this.Scope;
|
|
216
|
+
|
|
217
|
+
const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Deploy, scope);
|
|
211
218
|
|
|
212
219
|
await abstraction.process();
|
|
213
220
|
|
|
@@ -218,9 +225,11 @@ export class A_Concept<
|
|
|
218
225
|
* Publish the concept.
|
|
219
226
|
*/
|
|
220
227
|
async publish(
|
|
221
|
-
|
|
228
|
+
scope?: A_Scope,
|
|
222
229
|
) {
|
|
223
|
-
|
|
230
|
+
scope = scope ? scope.inherit(this.Scope) : this.Scope;
|
|
231
|
+
|
|
232
|
+
const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Publish, scope);
|
|
224
233
|
|
|
225
234
|
await abstraction.process();
|
|
226
235
|
}
|
|
@@ -238,7 +247,6 @@ export class A_Concept<
|
|
|
238
247
|
K extends Record<_Imports[number]['name'], string>
|
|
239
248
|
>(
|
|
240
249
|
container: K[keyof K],
|
|
241
|
-
params?: Partial<A_TYPES__ConceptAbstractionCallParams>
|
|
242
250
|
) {
|
|
243
251
|
// const definition = this.meta.abstractionDefinition(A_TYPES__ConceptStage.Run, {
|
|
244
252
|
// components: params?.components,
|
|
@@ -9,6 +9,7 @@ import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
|
9
9
|
import { A_TYPES__A_FeatureDecoratorConfig } from "@adaas/a-concept/decorators/A-Feature/A-Feature.decorator.types";
|
|
10
10
|
import { A_TYPES__A_AbstractionConstructor } from "../A-Abstraction/A-Abstraction.types";
|
|
11
11
|
import { A_Abstraction } from "../A-Abstraction/A-Abstraction.class";
|
|
12
|
+
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
12
13
|
// import { A_TYPES__ComponentMeta } from "./A-Component.types";
|
|
13
14
|
|
|
14
15
|
|
|
@@ -24,21 +25,17 @@ export class A_ConceptMeta extends A_Meta<any> {
|
|
|
24
25
|
|
|
25
26
|
abstractionDefinition(
|
|
26
27
|
method: A_TYPES__ConceptStage,
|
|
27
|
-
|
|
28
|
-
):
|
|
28
|
+
scope: A_Scope
|
|
29
|
+
): A_TYPES__A_AbstractionConstructor {
|
|
29
30
|
|
|
30
31
|
const featureDefinitions = this.containers.map(container =>
|
|
31
|
-
A_Context.abstractionDefinition(container
|
|
32
|
+
A_Context.abstractionDefinition(container, method, scope)
|
|
32
33
|
);
|
|
33
34
|
|
|
34
|
-
|
|
35
35
|
const definition = {
|
|
36
|
-
...params,
|
|
37
36
|
name: `${this.base.name}.${method}`,
|
|
38
37
|
features: featureDefinitions,
|
|
39
|
-
|
|
40
|
-
components: params?.components || [],
|
|
41
|
-
fragments: params?.fragments || [],
|
|
38
|
+
scope
|
|
42
39
|
};
|
|
43
40
|
|
|
44
41
|
return definition;
|
|
@@ -48,12 +45,11 @@ export class A_ConceptMeta extends A_Meta<any> {
|
|
|
48
45
|
|
|
49
46
|
abstraction(
|
|
50
47
|
method: A_TYPES__ConceptStage,
|
|
51
|
-
|
|
48
|
+
scope: A_Scope
|
|
52
49
|
): A_Abstraction {
|
|
53
50
|
|
|
54
|
-
|
|
55
51
|
const featureDefinitions = this.containers.map(container => {
|
|
56
|
-
const definition = A_Context.abstractionDefinition(container
|
|
52
|
+
const definition = A_Context.abstractionDefinition(container, method, container.Scope);
|
|
57
53
|
|
|
58
54
|
return {
|
|
59
55
|
...definition,
|
|
@@ -63,12 +59,9 @@ export class A_ConceptMeta extends A_Meta<any> {
|
|
|
63
59
|
|
|
64
60
|
|
|
65
61
|
const definition = {
|
|
66
|
-
...params,
|
|
67
62
|
name: `${this.base.name}.${method}`,
|
|
68
63
|
features: featureDefinitions,
|
|
69
|
-
|
|
70
|
-
components: params?.components || [],
|
|
71
|
-
fragments: params?.fragments || [],
|
|
64
|
+
scope
|
|
72
65
|
};
|
|
73
66
|
|
|
74
67
|
return new A_Abstraction(definition);
|
|
@@ -44,20 +44,20 @@ export class A_Container {
|
|
|
44
44
|
) {
|
|
45
45
|
this.config = config;
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
A_Context.allocate(this, {
|
|
48
|
+
name: this.name,
|
|
49
|
+
...config
|
|
50
|
+
});
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
|
|
56
54
|
async call(
|
|
57
55
|
feature: string,
|
|
58
|
-
|
|
56
|
+
scope?: A_Scope,
|
|
59
57
|
) {
|
|
60
|
-
|
|
58
|
+
scope = scope ? scope.inherit(this.Scope) : this.Scope;
|
|
59
|
+
|
|
60
|
+
const newFeature = A_Context.feature(this, feature, scope);
|
|
61
61
|
|
|
62
62
|
return await newFeature.process();
|
|
63
63
|
}
|
|
@@ -70,10 +70,12 @@ export class A_Container {
|
|
|
70
70
|
*/
|
|
71
71
|
feature(
|
|
72
72
|
feature: string,
|
|
73
|
-
|
|
74
|
-
):
|
|
73
|
+
scope?: A_Scope,
|
|
74
|
+
): A_TYPES__FeatureConstructor {
|
|
75
|
+
|
|
76
|
+
scope = scope ? scope.inherit(this.Scope) : this.Scope;
|
|
75
77
|
|
|
76
|
-
return A_Context.featureDefinition(this
|
|
78
|
+
return A_Context.featureDefinition(this, feature, scope);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
|
|
@@ -118,22 +118,34 @@ export class A_Context {
|
|
|
118
118
|
component: any,
|
|
119
119
|
importing: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig>
|
|
120
120
|
): A_Scope
|
|
121
|
+
static allocate(
|
|
122
|
+
component: any,
|
|
123
|
+
importing: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig> | A_Scope
|
|
124
|
+
): A_Scope
|
|
121
125
|
static allocate(
|
|
122
126
|
feature: A_Feature,
|
|
123
127
|
importing: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig>
|
|
124
128
|
): A_Scope
|
|
129
|
+
static allocate(
|
|
130
|
+
feature: A_Feature,
|
|
131
|
+
importing: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig> | A_Scope
|
|
132
|
+
): A_Scope
|
|
125
133
|
static allocate(
|
|
126
134
|
container: A_Container,
|
|
127
135
|
importing: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig>
|
|
128
136
|
): A_Scope
|
|
137
|
+
static allocate(
|
|
138
|
+
container: A_Container,
|
|
139
|
+
importing: A_Scope
|
|
140
|
+
): A_Scope
|
|
129
141
|
static allocate(
|
|
130
142
|
param1: A_Container | A_Feature | A_Component | any,
|
|
131
|
-
param2: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig>
|
|
143
|
+
param2: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig> | A_Scope
|
|
132
144
|
): A_Scope {
|
|
133
145
|
|
|
134
146
|
const instance = this.getInstance();
|
|
135
147
|
|
|
136
|
-
const newScope = new A_Scope(param2, param2);
|
|
148
|
+
const newScope = param2 instanceof A_Scope ? param2 : new A_Scope(param2, param2);
|
|
137
149
|
|
|
138
150
|
switch (true) {
|
|
139
151
|
case param1 instanceof A_Container:
|
|
@@ -345,33 +357,14 @@ export class A_Context {
|
|
|
345
357
|
* @returns
|
|
346
358
|
*/
|
|
347
359
|
static featureDefinition(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
353
|
-
static featureDefinition(
|
|
354
|
-
scope: A_Scope,
|
|
355
|
-
container: A_Container,
|
|
356
|
-
feature: string,
|
|
357
|
-
params?: Partial<A_TYPES__ScopeConstructor>
|
|
358
|
-
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
359
|
-
static featureDefinition(
|
|
360
|
-
scope: A_Scope,
|
|
361
|
-
component: A_Component,
|
|
362
|
-
feature: string,
|
|
363
|
-
params?: Partial<A_TYPES__ScopeConstructor>
|
|
364
|
-
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
365
|
-
static featureDefinition(
|
|
366
|
-
scope: A_Scope,
|
|
367
|
-
param1: A_Component | A_Container | A_Entity,
|
|
368
|
-
param2: string,
|
|
369
|
-
param3?: Partial<A_TYPES__ScopeConstructor>
|
|
370
|
-
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']> {
|
|
360
|
+
component: A_Component | A_Container | A_Entity,
|
|
361
|
+
feature: string | RegExp,
|
|
362
|
+
scope: A_Scope
|
|
363
|
+
): A_TYPES__FeatureConstructor {
|
|
371
364
|
const instance = this.getInstance();
|
|
372
365
|
|
|
373
|
-
const
|
|
374
|
-
|
|
366
|
+
const name = `${component.constructor.name}.${feature}`;
|
|
367
|
+
|
|
375
368
|
|
|
376
369
|
/**
|
|
377
370
|
* Important NOTE::: Component Scope and Parent Scope are different things.
|
|
@@ -433,10 +426,10 @@ export class A_Context {
|
|
|
433
426
|
throw new Error(`[!] A-Concept Context: Features not found. for Component ${component.constructor.name}`);
|
|
434
427
|
|
|
435
428
|
|
|
436
|
-
const featureDefinition = allFeatures.get(
|
|
429
|
+
const featureDefinition = allFeatures.get(feature);
|
|
437
430
|
|
|
438
431
|
if (!featureDefinition)
|
|
439
|
-
throw new Error(`[!] A-Concept Context: Feature ${
|
|
432
|
+
throw new Error(`[!] A-Concept Context: Feature ${feature} not found. for Component ${component.constructor.name}`);
|
|
440
433
|
|
|
441
434
|
|
|
442
435
|
const steps: A_TYPES__A_StageStep[] = [
|
|
@@ -449,7 +442,6 @@ export class A_Context {
|
|
|
449
442
|
// scope: scope.name
|
|
450
443
|
// }).toString();
|
|
451
444
|
|
|
452
|
-
const feature = `${component.constructor.name}.${param2}`;
|
|
453
445
|
|
|
454
446
|
// Now we need to resolve the method from all registered components
|
|
455
447
|
|
|
@@ -460,7 +452,7 @@ export class A_Context {
|
|
|
460
452
|
if (scope.has(constructor))
|
|
461
453
|
// Get all extensions for the feature
|
|
462
454
|
meta
|
|
463
|
-
.extensions(
|
|
455
|
+
.extensions(name)
|
|
464
456
|
.forEach((declaration) => {
|
|
465
457
|
steps.push({
|
|
466
458
|
component: constructor,
|
|
@@ -470,14 +462,8 @@ export class A_Context {
|
|
|
470
462
|
});
|
|
471
463
|
|
|
472
464
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
fragments: config.fragments || [],
|
|
476
|
-
components: config.components || [],
|
|
477
|
-
entities: config.entities || [],
|
|
478
|
-
steps,
|
|
479
|
-
parent: scope
|
|
480
|
-
};
|
|
465
|
+
|
|
466
|
+
return { name, steps, scope };
|
|
481
467
|
}
|
|
482
468
|
|
|
483
469
|
/**
|
|
@@ -487,33 +473,13 @@ export class A_Context {
|
|
|
487
473
|
* @returns
|
|
488
474
|
*/
|
|
489
475
|
static abstractionDefinition(
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
495
|
-
static abstractionDefinition(
|
|
496
|
-
scope: A_Scope,
|
|
497
|
-
container: A_Container,
|
|
498
|
-
feature: A_TYPES__ConceptStage,
|
|
499
|
-
params?: Partial<A_TYPES__ScopeConstructor>
|
|
500
|
-
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
501
|
-
static abstractionDefinition(
|
|
502
|
-
scope: A_Scope,
|
|
503
|
-
component: A_Component,
|
|
504
|
-
feature: A_TYPES__ConceptStage,
|
|
505
|
-
params?: Partial<A_TYPES__ScopeConstructor>
|
|
506
|
-
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
507
|
-
static abstractionDefinition(
|
|
508
|
-
scope: A_Scope,
|
|
509
|
-
param1: A_Component | A_Container | A_Entity,
|
|
510
|
-
param2: A_TYPES__ConceptStage,
|
|
511
|
-
param3?: Partial<A_TYPES__ScopeConstructor>
|
|
512
|
-
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']> {
|
|
476
|
+
component: A_Component | A_Container | A_Entity,
|
|
477
|
+
abstraction: A_TYPES__ConceptStage,
|
|
478
|
+
scope: A_Scope
|
|
479
|
+
): A_TYPES__FeatureConstructor {
|
|
513
480
|
const instance = this.getInstance();
|
|
514
481
|
|
|
515
|
-
const
|
|
516
|
-
const config = param3 || {};
|
|
482
|
+
const name = `${component.constructor.name}.${abstraction}`;
|
|
517
483
|
|
|
518
484
|
let metaKey;
|
|
519
485
|
|
|
@@ -534,14 +500,13 @@ export class A_Context {
|
|
|
534
500
|
|
|
535
501
|
const featureDefinition = this.meta(component)
|
|
536
502
|
.get(metaKey)
|
|
537
|
-
.get(
|
|
503
|
+
.get(abstraction) || []
|
|
538
504
|
|
|
539
505
|
|
|
540
506
|
const steps: A_TYPES__A_StageStep[] = [
|
|
541
507
|
...featureDefinition
|
|
542
508
|
];
|
|
543
509
|
|
|
544
|
-
const feature = `${component.constructor.name}.${param2}`;
|
|
545
510
|
|
|
546
511
|
// We need to get all components that has extensions for the feature in component
|
|
547
512
|
instance.componentsMeta
|
|
@@ -550,7 +515,7 @@ export class A_Context {
|
|
|
550
515
|
if (scope.has(constructor))
|
|
551
516
|
// Get all extensions for the feature
|
|
552
517
|
meta
|
|
553
|
-
.abstractions(
|
|
518
|
+
.abstractions(name)
|
|
554
519
|
.forEach((declaration) => {
|
|
555
520
|
steps.push({
|
|
556
521
|
component: constructor,
|
|
@@ -560,14 +525,7 @@ export class A_Context {
|
|
|
560
525
|
});
|
|
561
526
|
|
|
562
527
|
|
|
563
|
-
return {
|
|
564
|
-
name: feature,
|
|
565
|
-
fragments: config.fragments || [],
|
|
566
|
-
components: config.components || [],
|
|
567
|
-
entities: config.entities || [],
|
|
568
|
-
steps,
|
|
569
|
-
parent: scope
|
|
570
|
-
};
|
|
528
|
+
return { name, steps, scope };
|
|
571
529
|
}
|
|
572
530
|
|
|
573
531
|
/**
|
|
@@ -577,31 +535,26 @@ export class A_Context {
|
|
|
577
535
|
* @returns
|
|
578
536
|
*/
|
|
579
537
|
static feature<T extends Array<string>>(
|
|
580
|
-
scope: A_Scope,
|
|
581
538
|
entity: A_Entity<any, any>,
|
|
582
539
|
feature: A_TYPES__EntityBaseMethod | string | T[number] | RegExp,
|
|
583
|
-
|
|
540
|
+
scope: A_Scope
|
|
584
541
|
): A_Feature
|
|
585
542
|
static feature<T extends Array<string>>(
|
|
586
|
-
scope: A_Scope,
|
|
587
543
|
container: A_Container,
|
|
588
544
|
feature: T[number],
|
|
589
|
-
|
|
545
|
+
scope: A_Scope
|
|
590
546
|
): A_Feature
|
|
591
547
|
static feature(
|
|
592
|
-
scope: A_Scope,
|
|
593
548
|
component: A_Component,
|
|
594
549
|
feature: string,
|
|
595
|
-
|
|
550
|
+
scope: A_Scope
|
|
596
551
|
): A_Feature
|
|
597
552
|
static feature<T extends Array<string>>(
|
|
598
|
-
scope: A_Scope,
|
|
599
553
|
param1: A_Component | A_Container | A_Entity<any, any>,
|
|
600
554
|
param2: string | T[number],
|
|
601
|
-
param3
|
|
555
|
+
param3: A_Scope
|
|
602
556
|
): A_Feature {
|
|
603
|
-
|
|
604
|
-
const featureConstructor = this.featureDefinition(scope, param1, param2, param3);
|
|
557
|
+
const featureConstructor = this.featureDefinition(param1, param2, param3);
|
|
605
558
|
|
|
606
559
|
const newFeature = new A_Feature(featureConstructor);
|
|
607
560
|
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
import { A_CONSTANTS__DEFAULT_ERRORS } from "@adaas/a-utils/dist/src/constants/errors.constants";
|
|
11
11
|
import { A_Context } from "../A-Context/A-Context.class";
|
|
12
12
|
import { A_TYPES__FeatureCallParams } from "../A-Feature/A-Feature.types";
|
|
13
|
+
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
@@ -135,14 +136,14 @@ export class A_Entity<
|
|
|
135
136
|
* @param lifecycleMethod
|
|
136
137
|
* @param args
|
|
137
138
|
*/
|
|
138
|
-
|
|
139
|
+
async call(
|
|
139
140
|
feature: string,
|
|
140
|
-
|
|
141
|
+
scope?: A_Scope,
|
|
141
142
|
) {
|
|
142
|
-
params.entities = params.entities || [this];
|
|
143
143
|
|
|
144
|
+
scope = scope ? scope.inherit(A_Context.scope(this)) : A_Context.scope(this);
|
|
144
145
|
|
|
145
|
-
const newFeature = A_Context.feature(
|
|
146
|
+
const newFeature = A_Context.feature(this, feature, scope);
|
|
146
147
|
|
|
147
148
|
return await newFeature.process();
|
|
148
149
|
}
|