@adaas/a-concept 0.0.38 → 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.
Files changed (50) hide show
  1. package/dist/src/global/A-Abstraction/A-Abstraction.class.d.ts +8 -2
  2. package/dist/src/global/A-Abstraction/A-Abstraction.class.js +5 -1
  3. package/dist/src/global/A-Abstraction/A-Abstraction.class.js.map +1 -1
  4. package/dist/src/global/A-Abstraction/A-Abstraction.types.d.ts +13 -4
  5. package/dist/src/global/A-Abstraction/A-Abstraction.types.js.map +1 -1
  6. package/dist/src/global/A-Component/A-Component.class.d.ts +11 -4
  7. package/dist/src/global/A-Component/A-Component.class.js +13 -4
  8. package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
  9. package/dist/src/global/A-Concept/A_Concept.class.d.ts +11 -10
  10. package/dist/src/global/A-Concept/A_Concept.class.js +24 -20
  11. package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
  12. package/dist/src/global/A-Concept/A_Concept.meta.d.ts +4 -4
  13. package/dist/src/global/A-Concept/A_Concept.meta.js +14 -6
  14. package/dist/src/global/A-Concept/A_Concept.meta.js.map +1 -1
  15. package/dist/src/global/A-Container/A-Container.class.d.ts +3 -4
  16. package/dist/src/global/A-Container/A-Container.class.js +8 -8
  17. package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
  18. package/dist/src/global/A-Context/A-Context.class.d.ts +8 -10
  19. package/dist/src/global/A-Context/A-Context.class.js +32 -34
  20. package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
  21. package/dist/src/global/A-Entity/A-Entity.class.d.ts +2 -2
  22. package/dist/src/global/A-Entity/A-Entity.class.js +4 -4
  23. package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
  24. package/dist/src/global/A-Feature/A-Feature.class.d.ts +10 -8
  25. package/dist/src/global/A-Feature/A-Feature.class.js +11 -11
  26. package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
  27. package/dist/src/global/A-Feature/A-Feature.types.d.ts +13 -2
  28. package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
  29. package/dist/src/global/A-Scope/A-Scope.class.d.ts +14 -0
  30. package/dist/src/global/A-Scope/A-Scope.class.js +48 -5
  31. package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
  32. package/dist/src/global/A-Stage/A-Stage.class.js +2 -2
  33. package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -1
  34. package/examples/simple/concept.ts +1 -0
  35. package/examples/simple/containers/Main.container.ts +6 -5
  36. package/examples/simple-http-server/concept.ts +1 -0
  37. package/examples/simple-http-server/containers/http-server.container.ts +4 -2
  38. package/package.json +1 -1
  39. package/src/global/A-Abstraction/A-Abstraction.class.ts +11 -3
  40. package/src/global/A-Abstraction/A-Abstraction.types.ts +13 -6
  41. package/src/global/A-Component/A-Component.class.ts +12 -7
  42. package/src/global/A-Concept/A_Concept.class.ts +29 -21
  43. package/src/global/A-Concept/A_Concept.meta.ts +8 -15
  44. package/src/global/A-Container/A-Container.class.ts +13 -11
  45. package/src/global/A-Context/A-Context.class.ts +49 -87
  46. package/src/global/A-Entity/A-Entity.class.ts +5 -4
  47. package/src/global/A-Feature/A-Feature.class.ts +22 -13
  48. package/src/global/A-Feature/A-Feature.types.ts +14 -2
  49. package/src/global/A-Scope/A-Scope.class.ts +61 -5
  50. package/src/global/A-Stage/A-Stage.class.ts +4 -2
@@ -28,6 +28,7 @@ import { HTTPRequestHandler } from "./components/http-request-handler.component"
28
28
  })
29
29
 
30
30
 
31
+ await simpleConcept.load();
31
32
 
32
33
  await simpleConcept.start();
33
34
 
@@ -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.38",
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
- constructor(params: A_TYPES__Required<Partial<A_TYPES__A_AbstractionConstructor>, ['name', 'features']>) {
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 { A_TYPES__ScopeConstructor } from "../A-Scope/A-Scope.types";
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
- features: Array<A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps']>>
12
- } & A_TYPES__ScopeConstructor
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
- params: Partial<A_TYPES__FeatureCallParams> = {}
24
+ /**
25
+ * Scope in which the feature will be executed
26
+ */
27
+ scope?: A_Scope,
23
28
  ) {
24
- const newFeature = A_Context.feature(A_Context.scope(this), this, feature, params);
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
- params?: Partial<A_TYPES__ConceptAbstractionCallParams>
138
+ scope?: A_Scope,
140
139
  ) {
141
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Load, params);
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
- params?: Partial<A_TYPES__ConceptAbstractionCallParams>
153
+ scope?: A_Scope,
153
154
  ) {
154
- await this.load(params);
155
+ scope = scope ? scope.inherit(this.Scope) : this.Scope;
155
156
 
156
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Run, params);
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
- params?: Partial<A_TYPES__ConceptAbstractionCallParams>
169
+ scope?: A_Scope,
169
170
  ) {
170
- await this.load(params);
171
+ scope = scope ? scope.inherit(this.Scope) : this.Scope;
171
172
 
172
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Start, params);
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
- params?: Partial<A_TYPES__ConceptAbstractionCallParams>
185
+ scope?: A_Scope,
185
186
  ) {
186
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Stop, params);
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
- params?: Partial<A_TYPES__ConceptAbstractionCallParams>
199
+ scope?: A_Scope,
197
200
  ) {
198
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Build, params);
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
- params?: Partial<A_TYPES__ConceptAbstractionCallParams>
213
+ scope?: A_Scope,
209
214
  ) {
210
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Deploy, params);
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
- params?: Partial<A_TYPES__ConceptAbstractionCallParams>
228
+ scope?: A_Scope,
222
229
  ) {
223
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Publish, params);
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
- params?: Partial<A_TYPES__ConceptAbstractionCallParams>
28
- ): A_TYPES__Required<Partial<A_TYPES__A_AbstractionConstructor>, ['features']> {
28
+ scope: A_Scope
29
+ ): A_TYPES__A_AbstractionConstructor {
29
30
 
30
31
  const featureDefinitions = this.containers.map(container =>
31
- A_Context.abstractionDefinition(container.Scope, container, method, params)
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
- parent: this.base.Scope,
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
- params?: Partial<A_TYPES__ConceptAbstractionCallParams>
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.Scope, container, method, params);
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
- parent: this.base.Scope,
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
- const components = config.components || [];
48
- const fragments = config.fragments || [];
49
-
50
- A_Context.allocate(this, config);
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
- params: Partial<A_TYPES__FeatureCallParams> = {}
56
+ scope?: A_Scope,
59
57
  ) {
60
- const newFeature = A_Context.feature(this.Scope, this, feature, params);
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
- params: Partial<A_TYPES__FeatureCallParams> = {}
74
- ): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']> {
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.Scope, this, feature, params);
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
- scope: A_Scope,
349
- entity: A_Entity,
350
- feature: A_TYPES__EntityBaseMethod | string | RegExp,
351
- params?: Partial<A_TYPES__ScopeConstructor>
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 component = param1;
374
- const config = param3 || {};
366
+ const name = `${component.constructor.name}.${feature}`;
367
+
375
368
 
376
369
  /**
377
370
  * Important NOTE::: Component Scope and Parent Scope are different things.
@@ -421,13 +414,22 @@ export class A_Context {
421
414
  throw new Error(`A-Feature cannot be defined on the ${component} level`);
422
415
  }
423
416
 
417
+ const meta = this.meta(component);
424
418
 
425
- const featureDefinition = this.meta(component)
426
- .get(metaKey)
427
- .get(param2);
419
+ if (!meta)
420
+ throw new Error(`[!] A-Concept Context: Meta not found. for Component ${component.constructor.name}`);
421
+
422
+
423
+ const allFeatures = meta.get(metaKey)
424
+
425
+ if (!allFeatures)
426
+ throw new Error(`[!] A-Concept Context: Features not found. for Component ${component.constructor.name}`);
427
+
428
+
429
+ const featureDefinition = allFeatures.get(feature);
428
430
 
429
431
  if (!featureDefinition)
430
- throw new Error(`[!] A-Concept Context: Feature not found.`);
432
+ throw new Error(`[!] A-Concept Context: Feature ${feature} not found. for Component ${component.constructor.name}`);
431
433
 
432
434
 
433
435
  const steps: A_TYPES__A_StageStep[] = [
@@ -440,7 +442,6 @@ export class A_Context {
440
442
  // scope: scope.name
441
443
  // }).toString();
442
444
 
443
- const feature = `${component.constructor.name}.${param2}`;
444
445
 
445
446
  // Now we need to resolve the method from all registered components
446
447
 
@@ -451,7 +452,7 @@ export class A_Context {
451
452
  if (scope.has(constructor))
452
453
  // Get all extensions for the feature
453
454
  meta
454
- .extensions(feature)
455
+ .extensions(name)
455
456
  .forEach((declaration) => {
456
457
  steps.push({
457
458
  component: constructor,
@@ -461,14 +462,8 @@ export class A_Context {
461
462
  });
462
463
 
463
464
 
464
- return {
465
- name: feature,
466
- fragments: config.fragments || [],
467
- components: config.components || [],
468
- entities: config.entities || [],
469
- steps,
470
- parent: scope
471
- };
465
+
466
+ return { name, steps, scope };
472
467
  }
473
468
 
474
469
  /**
@@ -478,33 +473,13 @@ export class A_Context {
478
473
  * @returns
479
474
  */
480
475
  static abstractionDefinition(
481
- scope: A_Scope,
482
- entity: A_Entity,
483
- feature: A_TYPES__ConceptStage,
484
- params?: Partial<A_TYPES__ScopeConstructor>
485
- ): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
486
- static abstractionDefinition(
487
- scope: A_Scope,
488
- container: A_Container,
489
- feature: A_TYPES__ConceptStage,
490
- params?: Partial<A_TYPES__ScopeConstructor>
491
- ): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
492
- static abstractionDefinition(
493
- scope: A_Scope,
494
- component: A_Component,
495
- feature: A_TYPES__ConceptStage,
496
- params?: Partial<A_TYPES__ScopeConstructor>
497
- ): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
498
- static abstractionDefinition(
499
- scope: A_Scope,
500
- param1: A_Component | A_Container | A_Entity,
501
- param2: A_TYPES__ConceptStage,
502
- param3?: Partial<A_TYPES__ScopeConstructor>
503
- ): 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 {
504
480
  const instance = this.getInstance();
505
481
 
506
- const component = param1;
507
- const config = param3 || {};
482
+ const name = `${component.constructor.name}.${abstraction}`;
508
483
 
509
484
  let metaKey;
510
485
 
@@ -525,14 +500,13 @@ export class A_Context {
525
500
 
526
501
  const featureDefinition = this.meta(component)
527
502
  .get(metaKey)
528
- .get(param2) || []
503
+ .get(abstraction) || []
529
504
 
530
505
 
531
506
  const steps: A_TYPES__A_StageStep[] = [
532
507
  ...featureDefinition
533
508
  ];
534
509
 
535
- const feature = `${component.constructor.name}.${param2}`;
536
510
 
537
511
  // We need to get all components that has extensions for the feature in component
538
512
  instance.componentsMeta
@@ -541,7 +515,7 @@ export class A_Context {
541
515
  if (scope.has(constructor))
542
516
  // Get all extensions for the feature
543
517
  meta
544
- .abstractions(feature)
518
+ .abstractions(name)
545
519
  .forEach((declaration) => {
546
520
  steps.push({
547
521
  component: constructor,
@@ -551,14 +525,7 @@ export class A_Context {
551
525
  });
552
526
 
553
527
 
554
- return {
555
- name: feature,
556
- fragments: config.fragments || [],
557
- components: config.components || [],
558
- entities: config.entities || [],
559
- steps,
560
- parent: scope
561
- };
528
+ return { name, steps, scope };
562
529
  }
563
530
 
564
531
  /**
@@ -568,31 +535,26 @@ export class A_Context {
568
535
  * @returns
569
536
  */
570
537
  static feature<T extends Array<string>>(
571
- scope: A_Scope,
572
538
  entity: A_Entity<any, any>,
573
539
  feature: A_TYPES__EntityBaseMethod | string | T[number] | RegExp,
574
- params?: Partial<A_TYPES__ScopeConstructor>
540
+ scope: A_Scope
575
541
  ): A_Feature
576
542
  static feature<T extends Array<string>>(
577
- scope: A_Scope,
578
543
  container: A_Container,
579
544
  feature: T[number],
580
- params?: Partial<A_TYPES__ScopeConstructor>
545
+ scope: A_Scope
581
546
  ): A_Feature
582
547
  static feature(
583
- scope: A_Scope,
584
548
  component: A_Component,
585
549
  feature: string,
586
- params?: Partial<A_TYPES__ScopeConstructor>
550
+ scope: A_Scope
587
551
  ): A_Feature
588
552
  static feature<T extends Array<string>>(
589
- scope: A_Scope,
590
553
  param1: A_Component | A_Container | A_Entity<any, any>,
591
554
  param2: string | T[number],
592
- param3?: Partial<A_TYPES__ScopeConstructor>
555
+ param3: A_Scope
593
556
  ): A_Feature {
594
-
595
- const featureConstructor = this.featureDefinition(scope, param1, param2, param3);
557
+ const featureConstructor = this.featureDefinition(param1, param2, param3);
596
558
 
597
559
  const newFeature = new A_Feature(featureConstructor);
598
560