@adaas/a-concept 0.0.39 → 0.0.41

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 (72) hide show
  1. package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js +1 -0
  2. package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js.map +1 -1
  3. package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js +10 -0
  4. package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
  5. package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +1 -0
  6. package/dist/src/global/A-Abstraction/A-Abstraction.class.d.ts +8 -2
  7. package/dist/src/global/A-Abstraction/A-Abstraction.class.js +5 -1
  8. package/dist/src/global/A-Abstraction/A-Abstraction.class.js.map +1 -1
  9. package/dist/src/global/A-Abstraction/A-Abstraction.types.d.ts +13 -4
  10. package/dist/src/global/A-Abstraction/A-Abstraction.types.js.map +1 -1
  11. package/dist/src/global/A-Component/A-Component.class.d.ts +11 -4
  12. package/dist/src/global/A-Component/A-Component.class.js +13 -4
  13. package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
  14. package/dist/src/global/A-Concept/A_Concept.class.d.ts +11 -10
  15. package/dist/src/global/A-Concept/A_Concept.class.js +24 -20
  16. package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
  17. package/dist/src/global/A-Concept/A_Concept.meta.d.ts +4 -4
  18. package/dist/src/global/A-Concept/A_Concept.meta.js +14 -6
  19. package/dist/src/global/A-Concept/A_Concept.meta.js.map +1 -1
  20. package/dist/src/global/A-Container/A-Container.class.d.ts +3 -4
  21. package/dist/src/global/A-Container/A-Container.class.js +8 -8
  22. package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
  23. package/dist/src/global/A-Context/A-Context.class.d.ts +6 -11
  24. package/dist/src/global/A-Context/A-Context.class.js +32 -32
  25. package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
  26. package/dist/src/global/A-Entity/A-Entity.class.d.ts +2 -2
  27. package/dist/src/global/A-Entity/A-Entity.class.js +4 -4
  28. package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
  29. package/dist/src/global/A-Feature/A-Feature.class.d.ts +10 -8
  30. package/dist/src/global/A-Feature/A-Feature.class.js +20 -28
  31. package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
  32. package/dist/src/global/A-Feature/A-Feature.types.d.ts +13 -2
  33. package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
  34. package/dist/src/global/A-Meta/A-Meta.class.d.ts +6 -0
  35. package/dist/src/global/A-Meta/A-Meta.class.js +8 -0
  36. package/dist/src/global/A-Meta/A-Meta.class.js.map +1 -1
  37. package/dist/src/global/A-Scope/A-Scope.class.d.ts +14 -0
  38. package/dist/src/global/A-Scope/A-Scope.class.js +48 -5
  39. package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
  40. package/dist/src/global/A-Stage/A-Stage.class.d.ts +3 -2
  41. package/dist/src/global/A-Stage/A-Stage.class.js +18 -5
  42. package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -1
  43. package/dist/src/global/A-Stage/A-Stage.error.d.ts +3 -0
  44. package/dist/src/global/A-Stage/A-Stage.error.js +8 -0
  45. package/dist/src/global/A-Stage/A-Stage.error.js.map +1 -0
  46. package/dist/src/helpers/StepsManager.class.d.ts +17 -0
  47. package/dist/src/helpers/StepsManager.class.js +41 -3
  48. package/dist/src/helpers/StepsManager.class.js.map +1 -1
  49. package/examples/simple/components/A.component.ts +12 -3
  50. package/examples/simple/concept.ts +10 -4
  51. package/examples/simple/containers/Main.container.ts +6 -5
  52. package/examples/simple-http-server/concept.ts +1 -0
  53. package/examples/simple-http-server/containers/http-server.container.ts +4 -2
  54. package/package.json +1 -1
  55. package/src/decorators/A-Feature/A-Feature-Define.decorator.ts +1 -0
  56. package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +17 -0
  57. package/src/decorators/A-Feature/A-Feature.decorator.types.ts +1 -0
  58. package/src/global/A-Abstraction/A-Abstraction.class.ts +11 -3
  59. package/src/global/A-Abstraction/A-Abstraction.types.ts +13 -6
  60. package/src/global/A-Component/A-Component.class.ts +12 -7
  61. package/src/global/A-Concept/A_Concept.class.ts +29 -21
  62. package/src/global/A-Concept/A_Concept.meta.ts +8 -15
  63. package/src/global/A-Container/A-Container.class.ts +13 -11
  64. package/src/global/A-Context/A-Context.class.ts +37 -99
  65. package/src/global/A-Entity/A-Entity.class.ts +5 -4
  66. package/src/global/A-Feature/A-Feature.class.ts +40 -36
  67. package/src/global/A-Feature/A-Feature.types.ts +14 -2
  68. package/src/global/A-Meta/A-Meta.class.ts +10 -0
  69. package/src/global/A-Scope/A-Scope.class.ts +61 -5
  70. package/src/global/A-Stage/A-Stage.class.ts +34 -11
  71. package/src/global/A-Stage/A-Stage.error.ts +9 -0
  72. package/src/helpers/StepsManager.class.ts +63 -3
@@ -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.
@@ -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(param2);
429
+ const featureDefinition = allFeatures.get(feature);
437
430
 
438
431
  if (!featureDefinition)
439
- throw new Error(`[!] A-Concept Context: Feature ${param2} not found. for Component ${component.constructor.name}`);
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(feature)
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
- return {
474
- name: feature,
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
- scope: A_Scope,
491
- entity: A_Entity,
492
- feature: A_TYPES__ConceptStage,
493
- params?: Partial<A_TYPES__ScopeConstructor>
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 component = param1;
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(param2) || []
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(feature)
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,11 @@ export class A_Context {
577
535
  * @returns
578
536
  */
579
537
  static feature<T extends Array<string>>(
580
- scope: A_Scope,
581
- entity: A_Entity<any, any>,
582
- feature: A_TYPES__EntityBaseMethod | string | T[number] | RegExp,
583
- params?: Partial<A_TYPES__ScopeConstructor>
584
- ): A_Feature
585
- static feature<T extends Array<string>>(
586
- scope: A_Scope,
587
- container: A_Container,
588
- feature: T[number],
589
- params?: Partial<A_TYPES__ScopeConstructor>
590
- ): A_Feature
591
- static feature(
592
- scope: A_Scope,
593
- component: A_Component,
594
- feature: string,
595
- params?: Partial<A_TYPES__ScopeConstructor>
596
- ): A_Feature
597
- static feature<T extends Array<string>>(
598
- scope: A_Scope,
599
- param1: A_Component | A_Container | A_Entity<any, any>,
600
- param2: string | T[number],
601
- param3?: Partial<A_TYPES__ScopeConstructor>
538
+ component: A_Component | A_Container | A_Entity<any, any>,
539
+ feature: string | T[number]| RegExp,
540
+ scope: A_Scope
602
541
  ): A_Feature {
603
-
604
- const featureConstructor = this.featureDefinition(scope, param1, param2, param3);
542
+ const featureConstructor = this.featureDefinition(component, feature, scope);
605
543
 
606
544
  const newFeature = new A_Feature(featureConstructor);
607
545
 
@@ -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
- async call(
139
+ async call(
139
140
  feature: string,
140
- params: Partial<A_TYPES__FeatureCallParams> = {}
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(A_Context.scope(this), this, feature, params);
146
+ const newFeature = A_Context.feature(this, feature, scope);
146
147
 
147
148
  return await newFeature.process();
148
149
  }
@@ -6,6 +6,8 @@ import { A_Error, A_TYPES__Required } from "@adaas/a-utils";
6
6
  import { A_TYPES__A_Feature_Extend } from "@adaas/a-concept/decorators/A-Feature/A-Feature.decorator.types";
7
7
  import { A_Stage } from "../A-Stage/A-Stage.class";
8
8
  import { StepsManager } from "@adaas/a-concept/helpers/StepsManager.class";
9
+ import { A_Scope } from "../A-Scope/A-Scope.class";
10
+ import { A_StageError } from "../A-Stage/A-Stage.error";
9
11
 
10
12
  /**
11
13
  * A_Feature is representing a feature that can be executed across multiple components
@@ -46,11 +48,14 @@ export class A_Feature {
46
48
  error?: A_Error
47
49
 
48
50
  readonly name: string;
51
+ readonly Scope!: A_Scope;
52
+
49
53
 
50
54
  constructor(
51
- params: A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps']>
55
+ params: A_TYPES__FeatureConstructor
52
56
  ) {
53
57
  this.name = params.name || this.constructor.name;
58
+ this.Scope = params.scope
54
59
 
55
60
  this.SM = new StepsManager(params.steps);
56
61
 
@@ -58,7 +63,17 @@ export class A_Feature {
58
63
 
59
64
  this._current = this.stages[0];
60
65
 
61
- A_Context.allocate(this, params);
66
+
67
+ this.Scope.printInheritanceChain();
68
+ }
69
+
70
+
71
+ /**
72
+ * Returns the current A-Feature Stage
73
+ *
74
+ */
75
+ get stage(): A_Stage | undefined {
76
+ return this._current;
62
77
  }
63
78
 
64
79
 
@@ -93,14 +108,6 @@ export class A_Feature {
93
108
  }
94
109
 
95
110
 
96
- /**
97
- * Returns the current A-Feature Stage
98
- *
99
- */
100
- get stage(): A_Stage | undefined {
101
- return this._current;
102
- }
103
-
104
111
 
105
112
 
106
113
  /**
@@ -144,7 +151,7 @@ export class A_Feature {
144
151
  */
145
152
  async completed<T extends any>(): Promise<T> {
146
153
 
147
- this.result = A_Context.scope(this).toJSON();
154
+ this.result = this.Scope.toJSON();
148
155
 
149
156
  this.state = A_TYPES__FeatureState.COMPLETED;
150
157
 
@@ -173,7 +180,12 @@ export class A_Feature {
173
180
  * This method processes the feature by executing all the stages
174
181
  *
175
182
  */
176
- async process() {
183
+ async process(
184
+ scope?: A_Scope
185
+ ) {
186
+
187
+ console.log('Processing feature:', this.name);
188
+
177
189
  if (this.isDone()) {
178
190
  return this.result;
179
191
  }
@@ -182,43 +194,35 @@ export class A_Feature {
182
194
  this.state = A_TYPES__FeatureState.PROCESSING;
183
195
 
184
196
  for (const stage of this.stages) {
197
+ console.log('Processing stage:', stage.name);
198
+
185
199
  await stage.process();
186
- }
187
200
 
188
- await this.completed();
201
+ console.log('Stage processed:', stage.name, 'Status:', stage.status);
202
+ }
203
+
204
+
205
+ return await this.completed();
206
+
189
207
 
190
208
  } catch (error) {
191
- await this.failed(error);
209
+
210
+ return await this.failed(error);
192
211
  }
193
-
212
+
194
213
  }
195
214
 
196
215
 
197
216
  protected async errorHandler(error: Error | A_Error | unknown) {
217
+ console.log('Feature failed with error:', this.name);
218
+
198
219
  switch (true) {
220
+ case error instanceof A_StageError:
221
+ return; // Do nothing, already handled in the stage
222
+
199
223
  case error instanceof A_Error:
200
224
  throw error;
201
225
 
202
-
203
- case error instanceof Error
204
- && error.message === 'FEATURE_PROCESSING_INTERRUPTED'
205
- && this.state === A_TYPES__FeatureState.FAILED:
206
- throw new A_Error({
207
- message: 'FEATURE_PROCESSING_INTERRUPTED',
208
- code: 'FEATURE_PROCESSING_INTERRUPTED',
209
- data: {
210
- feature: this
211
- }
212
- });
213
-
214
-
215
- case error instanceof Error
216
- && error.message === 'FEATURE_PROCESSING_INTERRUPTED'
217
- && this.state === A_TYPES__FeatureState.COMPLETED:
218
-
219
- // Do nothing
220
- break;
221
-
222
226
  default:
223
227
  throw error;
224
228
  }
@@ -2,6 +2,7 @@ import { A_TYPES__ScopeConfig, A_TYPES__ScopeConstructor } from "../A-Scope/A-Sc
2
2
  import { A_TYPES__A_StageStep } from "../A-Stage/A-Stage.types"
3
3
  import { A_Fragment } from "../A-Fragment/A-Fragment.class"
4
4
  import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class"
5
+ import { A_Scope } from "../A-Scope/A-Scope.class"
5
6
 
6
7
 
7
8
  export type A_TYPES__FeatureIteratorReturn<T extends any = any> = () => Promise<T>
@@ -16,8 +17,19 @@ export type A_TYPES__FeatureCallParams = {
16
17
 
17
18
 
18
19
  export type A_TYPES__FeatureConstructor = {
19
- steps: A_TYPES__A_StageStep[]
20
- } & A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig
20
+ /**
21
+ * Name of the A-Feature
22
+ */
23
+ name:string,
24
+ /**
25
+ * Steps that compose the A-Feature
26
+ */
27
+ steps: A_TYPES__A_StageStep[],
28
+ /**
29
+ * Scope in which the A-Feature will be executed
30
+ */
31
+ scope: A_Scope
32
+ }
21
33
 
22
34
  export enum A_TYPES__FeatureState {
23
35
  INITIALIZED = "INITIALIZED",