@adaas/a-concept 0.0.29 → 0.0.30

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 (175) hide show
  1. package/dist/examples/fe-be/channels/Test.channel.d.ts +6 -0
  2. package/dist/examples/fe-be/channels/Test.channel.js +14 -0
  3. package/dist/examples/fe-be/channels/Test.channel.js.map +1 -0
  4. package/dist/examples/fe-be/components/BE-Controller.component.d.ts +4 -0
  5. package/dist/examples/fe-be/components/BE-Controller.component.js +24 -0
  6. package/dist/examples/fe-be/components/BE-Controller.component.js.map +1 -0
  7. package/dist/examples/fe-be/components/FE.component.d.ts +4 -0
  8. package/dist/examples/fe-be/components/FE.component.js +31 -0
  9. package/dist/examples/fe-be/components/FE.component.js.map +1 -0
  10. package/dist/examples/fe-be/components/UserActions.component.d.ts +5 -0
  11. package/dist/examples/fe-be/components/UserActions.component.js +25 -0
  12. package/dist/examples/fe-be/components/UserActions.component.js.map +1 -0
  13. package/dist/examples/fe-be/concept.d.ts +0 -0
  14. package/dist/examples/fe-be/concept.js +2 -0
  15. package/dist/examples/fe-be/concept.js.map +1 -0
  16. package/dist/examples/fe-be/containers/ServerApp.container.d.ts +3 -0
  17. package/dist/examples/fe-be/containers/ServerApp.container.js +8 -0
  18. package/dist/examples/fe-be/containers/ServerApp.container.js.map +1 -0
  19. package/dist/examples/fe-be/containers/WebApp.container.d.ts +3 -0
  20. package/dist/examples/fe-be/containers/WebApp.container.js +8 -0
  21. package/dist/examples/fe-be/containers/WebApp.container.js.map +1 -0
  22. package/dist/examples/multi-container/channels/Direct.channel.d.ts +9 -0
  23. package/dist/examples/multi-container/channels/Direct.channel.js +32 -0
  24. package/dist/examples/multi-container/channels/Direct.channel.js.map +1 -0
  25. package/dist/examples/multi-container/concept.d.ts +0 -0
  26. package/dist/examples/multi-container/concept.js +2 -0
  27. package/dist/examples/multi-container/concept.js.map +1 -0
  28. package/dist/examples/multi-container/containers/Command.container.d.ts +11 -0
  29. package/dist/examples/multi-container/containers/Command.container.js +51 -0
  30. package/dist/examples/multi-container/containers/Command.container.js.map +1 -0
  31. package/dist/examples/multi-container/containers/Schedule.container.d.ts +15 -0
  32. package/dist/examples/multi-container/containers/Schedule.container.js +67 -0
  33. package/dist/examples/multi-container/containers/Schedule.container.js.map +1 -0
  34. package/dist/examples/simple/components/A.component.js.map +1 -1
  35. package/dist/examples/simple/containers/Main.container.js +7 -3
  36. package/dist/examples/simple/containers/Main.container.js.map +1 -1
  37. package/dist/examples/simple/entities/EntityA.entity.d.ts +8 -0
  38. package/dist/examples/simple/entities/EntityA.entity.js +22 -0
  39. package/dist/examples/simple/entities/EntityA.entity.js.map +1 -0
  40. package/dist/examples/simple-http-server/contexts/http-request.context.d.ts +0 -1
  41. package/dist/examples/simple-http-server/contexts/http-request.context.js +6 -8
  42. package/dist/examples/simple-http-server/contexts/http-request.context.js.map +1 -1
  43. package/dist/index.d.ts +8 -2
  44. package/dist/index.js +16 -7
  45. package/dist/index.js.map +1 -1
  46. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.d.ts +14 -0
  47. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.js +53 -0
  48. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.js.map +1 -0
  49. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.d.ts +2 -0
  50. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js +3 -0
  51. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js.map +1 -0
  52. package/dist/src/decorators/A-Connect/A-Connect.decorator.d.ts +19 -0
  53. package/dist/src/decorators/A-Connect/A-Connect.decorator.js +31 -0
  54. package/dist/src/decorators/A-Connect/A-Connect.decorator.js.map +1 -0
  55. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.d.ts +1 -0
  56. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js +3 -0
  57. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js.map +1 -0
  58. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.d.ts +1 -0
  59. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js +8 -0
  60. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js.map +1 -0
  61. package/dist/src/decorators/A-Entity/A-Entity.decorator.types.d.ts +14 -0
  62. package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js +3 -0
  63. package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js.map +1 -0
  64. package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js +9 -0
  65. package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
  66. package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +28 -0
  67. package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +2 -3
  68. package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -1
  69. package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +44 -0
  70. package/dist/src/global/A-Channel/A-Channel.class.d.ts +8 -10
  71. package/dist/src/global/A-Channel/A-Channel.class.js +12 -26
  72. package/dist/src/global/A-Channel/A-Channel.class.js.map +1 -1
  73. package/dist/src/global/A-Channel/A-Channel.types.d.ts +32 -0
  74. package/dist/src/global/A-Component/A-Component.class.d.ts +2 -1
  75. package/dist/src/global/A-Component/A-Component.class.js +1 -0
  76. package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
  77. package/dist/src/global/A-Component/A-Component.meta.d.ts +8 -0
  78. package/dist/src/global/A-Component/A-Component.meta.js +27 -1
  79. package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
  80. package/dist/src/global/A-Component/A-Component.types.d.ts +19 -34
  81. package/dist/src/global/A-Component/A-Component.types.js +1 -7
  82. package/dist/src/global/A-Component/A-Component.types.js.map +1 -1
  83. package/dist/src/global/A-Concept/A_Concept.class.d.ts +7 -7
  84. package/dist/src/global/A-Concept/A_Concept.class.js +30 -30
  85. package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
  86. package/dist/src/global/A-Concept/A_Concept.types.d.ts +42 -2
  87. package/dist/src/global/A-Concept/A_Concept.types.js.map +1 -1
  88. package/dist/src/global/A-Container/A-Container.class.d.ts +1 -8
  89. package/dist/src/global/A-Container/A-Container.class.js +1 -31
  90. package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
  91. package/dist/src/global/A-Container/A-Container.meta.d.ts +8 -0
  92. package/dist/src/global/A-Container/A-Container.meta.js +29 -0
  93. package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
  94. package/dist/src/global/A-Container/A-Container.types.d.ts +23 -7
  95. package/dist/src/global/A-Container/A-Container.types.js +2 -1
  96. package/dist/src/global/A-Container/A-Container.types.js.map +1 -1
  97. package/dist/src/global/A-Context/A-Context.class.js +6 -35
  98. package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
  99. package/dist/src/global/A-Entity/A-Entity.class.d.ts +1 -2
  100. package/dist/src/global/A-Entity/A-Entity.class.js +6 -7
  101. package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
  102. package/dist/src/global/A-Entity/A-Entity.types.d.ts +4 -5
  103. package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -1
  104. package/dist/src/global/A-Feature/A-Feature.class.d.ts +30 -6
  105. package/dist/src/global/A-Feature/A-Feature.class.js +49 -40
  106. package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
  107. package/dist/src/global/A-Feature/A-Feature.types.d.ts +2 -24
  108. package/dist/src/global/A-Feature/A-Feature.types.js +21 -0
  109. package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
  110. package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +8 -0
  111. package/dist/src/global/A-Fragment/A-Fragment.class.js +10 -0
  112. package/dist/src/global/A-Fragment/A-Fragment.class.js.map +1 -1
  113. package/dist/src/global/A-Scope/A-Scope.class.d.ts +7 -5
  114. package/dist/src/global/A-Scope/A-Scope.class.js +33 -10
  115. package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
  116. package/dist/src/global/A-Scope/A-Scope.types.d.ts +2 -1
  117. package/dist/src/global/A-Stage/A-Stage.class.d.ts +69 -0
  118. package/dist/src/global/A-Stage/A-Stage.class.js +176 -0
  119. package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -0
  120. package/dist/src/global/A-Stage/A-Stage.types.d.ts +83 -0
  121. package/dist/src/global/A-Stage/A-Stage.types.js +59 -0
  122. package/dist/src/global/A-Stage/A-Stage.types.js.map +1 -0
  123. package/dist/src/helpers/StepsManager.class.d.ts +15 -0
  124. package/dist/src/helpers/StepsManager.class.js +85 -0
  125. package/dist/src/helpers/StepsManager.class.js.map +1 -0
  126. package/examples/fe-be/channels/Test.channel.ts +24 -0
  127. package/examples/fe-be/components/BE-Controller.component.ts +20 -0
  128. package/examples/fe-be/components/FE.component.ts +13 -0
  129. package/examples/fe-be/concept.ts +0 -0
  130. package/examples/fe-be/containers/ServerApp.container.ts +8 -0
  131. package/examples/fe-be/containers/WebApp.container.ts +13 -0
  132. package/examples/multi-container/channels/Direct.channel.ts +39 -0
  133. package/examples/multi-container/concept.ts +0 -0
  134. package/examples/multi-container/containers/Command.container.ts +41 -0
  135. package/examples/multi-container/containers/Schedule.container.ts +57 -0
  136. package/examples/simple/components/A.component.ts +2 -1
  137. package/examples/simple/containers/Main.container.ts +11 -3
  138. package/examples/simple/entities/EntityA.entity.ts +16 -0
  139. package/examples/simple-http-server/contexts/http-request.context.ts +6 -6
  140. package/index.ts +12 -3
  141. package/package.json +1 -1
  142. package/src/decorators/A-Abstraction/A-Abstraction.decorator.ts +82 -0
  143. package/src/decorators/{A-Stage/A-Stage.decorator.types.ts → A-Abstraction/A-Abstraction.decorator.types.ts} +1 -3
  144. package/src/decorators/A-Connect/A-Connect.decorator.ts +71 -0
  145. package/src/decorators/A-Connect/A-Connect.decorator.types.ts +6 -0
  146. package/src/decorators/A-Entity/A-Entity-List.decorator.ts +12 -0
  147. package/src/decorators/A-Entity/A-Entity.decorator.types.ts +18 -0
  148. package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +10 -0
  149. package/src/decorators/A-Feature/A-Feature.decorator.types.ts +36 -0
  150. package/src/decorators/A-Inject/A-Inject.decorator.ts +7 -7
  151. package/src/decorators/A-Inject/A-Inject.decorator.types.ts +47 -1
  152. package/src/global/A-Channel/A-Channel.class.ts +25 -28
  153. package/src/global/A-Channel/A-Channel.types.ts +53 -0
  154. package/src/global/A-Component/A-Component.class.ts +10 -2
  155. package/src/global/A-Component/A-Component.meta.ts +42 -1
  156. package/src/global/A-Component/A-Component.types.ts +20 -40
  157. package/src/global/A-Concept/A_Concept.class.ts +52 -31
  158. package/src/global/A-Concept/A_Concept.types.ts +48 -3
  159. package/src/global/A-Container/A-Container.class.ts +3 -39
  160. package/src/global/A-Container/A-Container.meta.ts +41 -4
  161. package/src/global/A-Container/A-Container.types.ts +28 -7
  162. package/src/global/A-Context/A-Context.class.ts +9 -49
  163. package/src/global/A-Entity/A-Entity.class.ts +8 -6
  164. package/src/global/A-Entity/A-Entity.types.ts +4 -5
  165. package/src/global/A-Feature/A-Feature.class.ts +73 -61
  166. package/src/global/A-Feature/A-Feature.types.ts +24 -23
  167. package/src/global/A-Fragment/A-Fragment.class.ts +15 -0
  168. package/src/global/A-Scope/A-Scope.class.ts +58 -25
  169. package/src/global/A-Scope/A-Scope.types.ts +2 -1
  170. package/src/global/A-Stage/A-Stage.class.ts +225 -0
  171. package/src/global/A-Stage/A-Stage.types.ts +106 -0
  172. package/src/helpers/StepsManager.class.ts +104 -0
  173. package/tests/channel.ts +213 -0
  174. package/tests/log.ts +88 -40
  175. package/src/decorators/A-Stage/A-Stage.decorator.ts +0 -84
@@ -1,3 +1,6 @@
1
+ import { A_Component } from "../A-Component/A-Component.class";
2
+ import { A_Container } from "../A-Container/A-Container.class";
3
+ import { A_TYPES__A_ChannelAggregated, A_TYPES__A_ChannelAggregateMethods, A_TYPES__A_ChannelCallParams, A_TYPES__A_ChannelConstructor } from "./A-Channel.types";
1
4
 
2
5
 
3
6
  /**
@@ -7,42 +10,36 @@
7
10
  * When One container needs to communicate with another container, it uses A_Channel.
8
11
  *
9
12
  */
10
- export class A_Channel<T> {
11
- private proxyInstance: T | null = null;
12
- private realInstance: T | null = null;
13
+ export class A_Channel<
14
+ T extends Array<A_Component | A_Container> = any[],
15
+ _Constructor extends A_TYPES__A_ChannelConstructor = A_TYPES__A_ChannelConstructor
16
+ > {
13
17
 
14
- constructor(
15
- private realClass: { new(...args: any[]): T },
16
- private args: any[]
17
- ) {
18
+ id: string;
18
19
 
19
- }
20
+ protected channel: A_TYPES__A_ChannelAggregated<T>;
20
21
 
21
- protected async loadInstance(): Promise<T> {
22
- if (!this.realInstance)
23
- this.realInstance = new this.realClass(...this.args);
24
22
 
25
- return this.realInstance;
26
- }
23
+ constructor(params: A_TYPES__A_ChannelConstructor) {
24
+ this.id = params.id;
27
25
 
26
+ this.channel = new Proxy(
27
+ {} as A_TYPES__A_ChannelAggregated<T>,
28
+ {
29
+ get: (target, prop) => {
30
+ return async (...args: any[]) => {
31
+ this.call(prop as A_TYPES__A_ChannelAggregateMethods<T>);
32
+ };
33
+ }
34
+ });
35
+ }
28
36
 
29
- public async resolve(): Promise<T> {
30
- if (!this.proxyInstance) {
31
- const realInstance = await this.loadInstance();
32
37
 
33
- this.proxyInstance = new Proxy({}, {
34
- get: (target, prop) => {
35
- const value = (realInstance as any)[prop];
38
+ async call<_Resp extends any>(prop: A_TYPES__A_ChannelAggregateMethods<T>, params?: Partial<A_TYPES__A_ChannelCallParams>): Promise<_Resp> {
39
+ // do HTTP Call or just inject class or whatever you want
36
40
 
37
- // If the property is a method, return a bound function
38
- if (typeof value === 'function') {
39
- return value.bind(realInstance);
40
- }
41
- return value;
42
- }
43
- }) as T;
44
- }
41
+ console.log('Calling method', prop);
45
42
 
46
- return this.proxyInstance;
43
+ return {} as _Resp;
47
44
  }
48
45
  }
@@ -1,3 +1,6 @@
1
+ import { A_Component } from "../A-Component/A-Component.class"
2
+ import { A_TYPES__ContainerCallParams } from "../A-Container/A-Container.types"
3
+ import { A_Fragment } from "../A-Fragment/A-Fragment.class"
1
4
 
2
5
 
3
6
  export type A_TYPES__A_DependencyReferenceConstructor = {
@@ -58,3 +61,53 @@ export type A_TYPES__A_DependencyReferenceConstructorConfig = {
58
61
  timeout: number
59
62
  }
60
63
  }
64
+
65
+
66
+ export type A_TYPES__A_ChannelCallParams = {
67
+ fragments: Array<A_Fragment>,
68
+ components: Array<typeof A_Component>
69
+ }
70
+
71
+
72
+ /**
73
+ * Returns a string set of possible methods that could be called on a provided A-Component
74
+ */
75
+ export type A_TYPES__A_ExecutableMethods<T> = {
76
+ [K in keyof T]: T[K] extends (...arg: Partial<A_TYPES__A_ChannelCallParams>[]) => Promise<any> ? K : never
77
+ }[keyof T];
78
+
79
+
80
+ /**
81
+ * Returns a string set of possible methods that could be called on a set of provided set of A-Components
82
+ */
83
+ export type A_TYPES__A_ChannelAggregateMethods<TClasses extends A_Component[]> = {
84
+ [K in keyof TClasses]: TClasses[K] extends infer Instance
85
+ ? A_TYPES__A_ExecutableMethods<Instance>
86
+ : never;
87
+ }[number];
88
+
89
+
90
+ /**
91
+ * Describes a type of proxy object and consists of all callable methods from a set opf provided components
92
+ */
93
+ export type A_TYPES__A_ChannelAggregated<TClasses extends any[]> = {
94
+ [Method in A_TYPES__A_ChannelAggregateMethods<TClasses>]: {
95
+ [Class in keyof TClasses]: TClasses[Class] extends infer Instance
96
+ ? Method extends keyof Instance
97
+ // Just put it here for possible cases with detailed params
98
+ // ? Instance[Method]
99
+ ? (params: Partial<A_TYPES__A_ChannelCallParams>) => Promise<any>
100
+ : never
101
+ : never;
102
+ }[number]; // Select the method signature from any matching class
103
+ };
104
+
105
+
106
+
107
+
108
+ /**
109
+ * A set of parameters are required to construct a new A-Channel
110
+ */
111
+ export type A_TYPES__A_ChannelConstructor = {
112
+ id: string,
113
+ }
@@ -1,8 +1,10 @@
1
1
  import { A_TYPES__Required } from "@adaas/a-utils";
2
2
  import { A_Context } from "../A-Context/A-Context.class";
3
- import { A_TYPES__ComponentCallParams } from "./A-Component.types";
3
+ import { A_TYPES__ComponentCallParams, A_TYPES__ComponentConstructor } from "./A-Component.types";
4
4
  import { A_Scope } from "../A-Scope/A-Scope.class";
5
5
 
6
+
7
+
6
8
  /**
7
9
  * This element only contains the specific code
8
10
  *
@@ -10,6 +12,9 @@ import { A_Scope } from "../A-Scope/A-Scope.class";
10
12
  export class A_Component<
11
13
  _FeatureNames extends Array<string> = any,
12
14
  > {
15
+ constructor(
16
+ params?: Partial<A_TYPES__ComponentConstructor<_FeatureNames>>
17
+ ) { }
13
18
 
14
19
 
15
20
  /**
@@ -62,4 +67,7 @@ export class A_Component<
62
67
 
63
68
  return await newFeature.process();
64
69
  }
65
- }
70
+ }
71
+
72
+
73
+
@@ -1,3 +1,4 @@
1
+ import { A_TYPES__ConceptAbstractionMeta, A_TYPES__ConceptStage } from "../A-Concept/A_Concept.types";
1
2
  import { A_Meta } from "../A-Meta/A-Meta.class";
2
3
  import { A_TYPES__ComponentMeta, A_TYPES__ComponentMetaExtension, A_TYPES__ComponentMetaKey } from "./A-Component.types";
3
4
 
@@ -35,7 +36,10 @@ export class A_ComponentMeta extends A_Meta<A_TYPES__ComponentMeta> {
35
36
  // component: constructor,
36
37
  name: extension.name,
37
38
  handler: extension.handler,
38
- args
39
+ args,
40
+ behavior: extension.behavior,
41
+ before: extension.before || [],
42
+ after: extension.after || []
39
43
  });
40
44
 
41
45
  });
@@ -45,4 +49,41 @@ export class A_ComponentMeta extends A_Meta<A_TYPES__ComponentMeta> {
45
49
  return steps;
46
50
  }
47
51
 
52
+
53
+ /**
54
+ * Returns a set of instructions to run proper methods in Component during A-Concept Stage
55
+ *
56
+ * @param stage
57
+ * @returns
58
+ */
59
+ abstractions(
60
+ abstraction: A_TYPES__ConceptStage
61
+ ): A_TYPES__ConceptAbstractionMeta[] {
62
+ const steps: A_TYPES__ConceptAbstractionMeta[] = [];
63
+
64
+ const abstractions = this.get(A_TYPES__ComponentMetaKey.ABSTRACTIONS);
65
+ const injections = this.get(A_TYPES__ComponentMetaKey.INJECTIONS);
66
+
67
+ // const constructor = A_Context.component(this);
68
+
69
+
70
+ abstractions
71
+ // returns all extensions that match the feature
72
+ ?.find(`CONCEPT_ABSTRACTION::${abstraction}`)
73
+ .forEach(([handler, extensions]) => {
74
+ extensions.forEach(extension => {
75
+ const args = injections?.get(extension.handler) || [];
76
+
77
+ steps.push({
78
+ ...extension,
79
+ // component: constructor,
80
+ args,
81
+ });
82
+
83
+ });
84
+ });
85
+
86
+
87
+ return steps;
88
+ }
48
89
  }
@@ -1,10 +1,12 @@
1
- import { A_Entity } from "../A-Entity/A-Entity.class"
2
- import { A_Feature } from "../A-Feature/A-Feature.class"
1
+ import { A_TYPES__A_InjectDecorator_Meta } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator.types"
3
2
  import { A_Fragment } from "../A-Fragment/A-Fragment.class"
4
3
  import { A_Meta } from "../A-Meta/A-Meta.class"
5
- import { A_Scope } from "../A-Scope/A-Scope.class"
6
- import { A_Component } from "./A-Component.class"
4
+ import { A_TYPES__A_ExtendDecorator_BehaviorConfig, A_TYPES__A_ExtendDecorator_Meta } from "@adaas/a-concept/decorators/A-Feature/A-Feature.decorator.types"
5
+ import { A_TYPES__ConceptAbstraction, A_TYPES__ConceptAbstractionMeta } from "../A-Concept/A_Concept.types"
7
6
 
7
+ export type A_TYPES__ComponentConstructor<_Exports extends Array<String>> = {
8
+ exports: _Exports,
9
+ }
8
10
 
9
11
  export type A_TYPES__ComponentCallParams<T extends string> = {
10
12
  name: T,
@@ -23,7 +25,7 @@ export type A_TYPES__ComponentMeta = {
23
25
  *
24
26
  * Where value is the extension instructions
25
27
  */
26
- [Key: string]: A_TYPES__ComponentMeta_ExtensionItem[]
28
+ [Key: string]: A_TYPES__A_ExtendDecorator_Meta[]
27
29
  }>,
28
30
 
29
31
 
@@ -36,7 +38,16 @@ export type A_TYPES__ComponentMeta = {
36
38
  *
37
39
  * Where value is the list of injections
38
40
  */
39
- [Key: string]: A_TYPES__ComponentMeta_InjectionParams
41
+ [Key: string]: A_TYPES__A_InjectDecorator_Meta
42
+ }>
43
+
44
+ [A_TYPES__ComponentMetaKey.ABSTRACTIONS]: A_Meta<{
45
+ /**
46
+ * Where Key is the name of the stage
47
+ *
48
+ * Where value is the list of injections
49
+ */
50
+ [Key: string]: A_TYPES__ConceptAbstraction[]
40
51
  }>
41
52
  }
42
53
 
@@ -44,7 +55,7 @@ export enum A_TYPES__ComponentMetaKey {
44
55
  EXTENSIONS = 'a-component-extensions',
45
56
  FEATURES = 'a-component-features',
46
57
  INJECTIONS = 'a-component-injections',
47
- STAGES = 'a-component-stages',
58
+ ABSTRACTIONS = 'a-component-abstractions',
48
59
  }
49
60
 
50
61
  export type A_TYPES__ComponentMetaExtension = {
@@ -59,39 +70,8 @@ export type A_TYPES__ComponentMetaExtension = {
59
70
  /**
60
71
  * The arguments that will be passed to the handler
61
72
  */
62
- args: A_TYPES__ComponentMeta_InjectionParams
63
- }
64
-
65
-
66
- export type A_TYPES__ComponentMeta_ExtensionItem = {
67
- name: string,
68
- handler: string,
69
- }
70
-
71
- export type A_TYPES__ComponentMeta_InjectionParams = Array<{
72
- target: A_TYPES__ComponentMeta_InjectionParam
73
- } | {
74
- target: { new(...args: any[]): A_Entity },
75
- instructions: Partial<A_TYPES__ComponentMeta_EntityInjectionInstructions>
76
- }>;
77
-
78
-
79
- export type A_TYPES__ComponentMeta_EntityInjectionInstructions = {
80
- aseid: string,
81
- id: string,
82
- }
73
+ args: A_TYPES__A_InjectDecorator_Meta
83
74
 
75
+ } & A_TYPES__A_ExtendDecorator_BehaviorConfig
84
76
 
85
- export type A_TYPES__ComponentMeta_InjectionParam =
86
- { new(...args: any[]): A_Fragment }
87
- | { new(...args: any[]): A_Component }
88
- // | { new(...args: any[]): any }
89
- | { new(...args: any[]): A_Scope }
90
- | { new(...args: any[]): A_Feature };
91
- // |
92
- // typeof A_Fragment
93
- // | typeof A_Component
94
- // // | { new(...args: any[]): any }
95
- // | typeof A_Scope
96
- // | typeof A_Feature;
97
77
 
@@ -4,7 +4,9 @@ import { A_Container } from "../A-Container/A-Container.class";
4
4
  // import { A_Logger } from "@adaas/a-concept/base/A-Logger/A-Logger.component";
5
5
  import { A_Fragment } from "../A-Fragment/A-Fragment.class";
6
6
  import { A_TYPES__ContainerMetaKey } from "../A-Container/A-Container.types";
7
- import { A_Stage } from "@adaas/a-concept/decorators/A-Stage/A-Stage.decorator";
7
+ import { A_Abstraction } from "@adaas/a-concept/decorators/A-Abstraction/A-Abstraction.decorator";
8
+ import { A_TYPES__A_StageStep } from "../A-Stage/A-Stage.types";
9
+ import { A_Channel } from "../A-Channel/A-Channel.class";
8
10
 
9
11
 
10
12
 
@@ -35,8 +37,8 @@ export class A_Concept<
35
37
  /**
36
38
  * Load the concept. This step runs before any other steps to ensure that all components are loaded.
37
39
  */
38
- static get Load() {
39
- return A_Stage(A_TYPES__ConceptStage.Load);
40
+ static Load() {
41
+ return A_Abstraction(A_TYPES__ConceptStage.Load);
40
42
  }
41
43
 
42
44
  /**
@@ -44,15 +46,15 @@ export class A_Concept<
44
46
  *
45
47
  * [!] To extend the logic just create a custom containers and override the default behavior.
46
48
  */
47
- static get Publish() {
48
- return A_Stage(A_TYPES__ConceptStage.Publish);
49
+ static Publish() {
50
+ return A_Abstraction(A_TYPES__ConceptStage.Publish);
49
51
  }
50
52
 
51
53
  /**
52
54
  * Deploy the concept to the environment.
53
55
  */
54
- static get Deploy() {
55
- return A_Stage(A_TYPES__ConceptStage.Deploy);
56
+ static Deploy() {
57
+ return A_Abstraction(A_TYPES__ConceptStage.Deploy);
56
58
  }
57
59
 
58
60
  /**
@@ -61,29 +63,29 @@ export class A_Concept<
61
63
  * Can be used for static websites or any other concept that requires a build step.
62
64
  *
63
65
  */
64
- static get Build() {
65
- return A_Stage(A_TYPES__ConceptStage.Build);
66
+ static Build() {
67
+ return A_Abstraction(A_TYPES__ConceptStage.Build);
66
68
  }
67
69
 
68
70
  /**
69
71
  * Main execution of the concept.
70
72
  */
71
- static get Run() {
72
- return A_Stage(A_TYPES__ConceptStage.Run);
73
+ static Run() {
74
+ return A_Abstraction(A_TYPES__ConceptStage.Run);
73
75
  }
74
76
 
75
77
  /**
76
78
  * Start the concept. Uses for servers or any other background services.
77
79
  */
78
- static get Start() {
79
- return A_Stage(A_TYPES__ConceptStage.Start);
80
+ static Start() {
81
+ return A_Abstraction(A_TYPES__ConceptStage.Start);
80
82
  }
81
83
 
82
84
  /**
83
85
  * Stop the concept. Uses for servers or any other background services.
84
86
  */
85
- static get Stop() {
86
- return A_Stage(A_TYPES__ConceptStage.Stop);
87
+ static Stop() {
88
+ return A_Abstraction(A_TYPES__ConceptStage.Stop);
87
89
  }
88
90
 
89
91
 
@@ -182,26 +184,46 @@ export class A_Concept<
182
184
  params: Partial<A_TYPES__ConceptStageParams>
183
185
  ) {
184
186
 
185
- const stages: any[] = [];
187
+ const abstractions: {
188
+ container: A_Container<any>,
189
+ runners: Array<A_TYPES__A_StageStep>
190
+ }[] = [];
191
+
186
192
 
187
193
  this.containers.map(container => {
188
194
  const meta = A_Context.meta(container);
189
195
 
190
- const containerStages = meta.get(A_TYPES__ContainerMetaKey.STAGES)
196
+ const containerAbstractions: Array<A_TYPES__A_StageStep> = meta
197
+ .abstractions(method)
198
+ .map(step => ({
199
+ component: container,
200
+ ...step
201
+ }));
202
+
203
+ const containerScope = A_Context.scope(container);
204
+
205
+ const componentsAbstractions = containerScope.components
206
+ .map(component => A_Context.meta(component).abstractions(method).map(step => ({
207
+ component,
208
+ ...step
209
+ })))
210
+ .flat();
211
+
212
+ abstractions.push({
213
+ container,
214
+ runners: [
215
+ ...containerAbstractions.map(step => ({
216
+ ...step,
217
+ component: container,
218
+ })),
219
+
220
+ ...componentsAbstractions
221
+ ]
222
+ });
223
+ });
191
224
 
192
225
 
193
- if (containerStages) {
194
- for (const [name, stage] of containerStages) {
195
- if (stage.name === method) {
196
- stages.push({
197
- name,
198
- container,
199
- });
200
- }
201
- }
202
226
 
203
- }
204
- });
205
227
 
206
228
  const scope = A_Context.allocate(this, {
207
229
  components: params.components,
@@ -209,9 +231,6 @@ export class A_Concept<
209
231
  parent: A_Context.scope(this)
210
232
  });
211
233
 
212
- for (const stage of stages) {
213
- await stage.container[stage.name](params);
214
- }
215
234
 
216
235
  }
217
236
 
@@ -235,3 +254,5 @@ export class A_Concept<
235
254
 
236
255
  }
237
256
 
257
+
258
+
@@ -1,5 +1,9 @@
1
+ import { A_TYPES__A_InjectDecorator_Meta } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator.types";
1
2
  import { A_Container } from "../A-Container/A-Container.class";
2
3
  import { A_Fragment } from "../A-Fragment/A-Fragment.class";
4
+ import { A_Entity } from "../A-Entity/A-Entity.class";
5
+ import { A_Component } from "../A-Component/A-Component.class";
6
+ import { A_TYPES__A_ExtendDecorator_BehaviorConfig } from "@adaas/a-concept/decorators/A-Feature/A-Feature.decorator.types";
3
7
 
4
8
 
5
9
  export enum A_TYPES__ConceptStage {
@@ -58,6 +62,42 @@ export interface A_TYPES__IConceptConstructor<
58
62
  }
59
63
 
60
64
 
65
+ /**
66
+ * Uses as a transfer object to pass configurations to Feature constructor
67
+ */
68
+ export type A_TYPES__ConceptAbstractionMeta = {
69
+ /**
70
+ * The name of original Extension Definition
71
+ */
72
+ name: string,
73
+ /**
74
+ * The name of the handler that will be used to apply the extension
75
+ */
76
+ handler: string,
77
+ /**
78
+ * The arguments that will be passed to the handler
79
+ */
80
+ args: A_TYPES__A_InjectDecorator_Meta
81
+ } & A_TYPES__A_ExtendDecorator_BehaviorConfig
82
+
83
+
84
+
85
+ /**
86
+ * Uses to define the extension that will be applied to the Concept
87
+ */
88
+ export type A_TYPES__ConceptAbstraction = {
89
+ /**
90
+ * The name of original Extension Definition
91
+ */
92
+ name: string,
93
+ /**
94
+ * The name of the handler that will be used to apply the extension
95
+ */
96
+ handler: string,
97
+ } & A_TYPES__A_ExtendDecorator_BehaviorConfig
98
+
99
+
100
+
61
101
 
62
102
 
63
103
  // =======================================================================
@@ -68,12 +108,17 @@ export interface A_TYPES__IConceptConstructor<
68
108
 
69
109
  export type A_TYPES__ConceptStageParams = {
70
110
  fragments: Array<A_Fragment>,
71
- components: Array<{ new(...args: any[]): any }>
111
+ components: Array<{ new(...args: any[]): A_Component }>,
112
+ entities: Array<{ new(...args: any[]): A_Entity }>
72
113
  }
73
114
 
74
115
 
75
116
  export type A_TYPES__ConceptCallParams<T extends string> = {
76
117
  name: T,
77
118
  fragments: Array<A_Fragment>,
78
- components: Array<{ new(...args: any[]): any }>
79
- }
119
+ components: Array<{ new(...args: any[]): A_Component }>,
120
+ entities: Array<{ new(...args: any[]): A_Entity<any, any, any> }>
121
+ }
122
+
123
+
124
+
@@ -18,7 +18,7 @@ import { A_TYPES__FeatureConstructor } from "../A-Feature/A-Feature.types";
18
18
  * - etc.
19
19
  */
20
20
  export class A_Container<
21
- _FeatureNames extends Array<string>
21
+ _FeatureNames extends Array<string> = any
22
22
  > {
23
23
  // scope!: A_Scope
24
24
 
@@ -55,46 +55,10 @@ export class A_Container<
55
55
 
56
56
  A_Context.allocate(this, config);
57
57
 
58
- /**
59
- * Run Async Initialization
60
- */
61
- this.init();
62
- }
63
-
64
-
65
- protected hasInherited(cl: { new(...args: any[]) }): boolean {
66
- return this.constructor === cl
67
- ? false
68
- : true
69
- }
70
-
71
-
72
- /**
73
- * Initializes the Namespace or can be used to reinitialize the Namespace
74
- */
75
- private async init() {
76
- if (!this.ready)
77
- this.ready = new Promise(async (resolve, reject) => {
78
- try {
79
- await this.onBeforeInit();
80
-
81
- await this.onInit();
82
-
83
- await this.onAfterInit();
84
58
 
85
-
86
- return resolve();
87
- } catch (error) {
88
- return reject(error);
89
- }
90
- });
91
- else
92
- await this.ready;
93
59
  }
94
60
 
95
-
96
-
97
-
61
+
98
62
 
99
63
  /**
100
64
  * This method allows to call the lifecycle method of the container as well as any other Feature defined for it
@@ -138,7 +102,7 @@ export class A_Container<
138
102
  ? param2 || {}
139
103
  : param1;
140
104
 
141
- const newFeature = A_Context.feature(this.Scope, this, feature, params);
105
+ const newFeature = A_Context.feature(A_Context.scope(this), this, feature, params);
142
106
 
143
107
  return await newFeature.process();
144
108
  }
@@ -1,8 +1,5 @@
1
- import { A_TYPES__ComponentMetaKey } from "../A-Component/A-Component.types";
2
- import { A_Context } from "../A-Context/A-Context.class";
3
- import { A_TYPES__FeatureStep } from "../A-Feature/A-Feature.types";
1
+ import { A_TYPES__ConceptAbstractionMeta, A_TYPES__ConceptStage } from "../A-Concept/A_Concept.types";
4
2
  import { A_Meta } from "../A-Meta/A-Meta.class";
5
- import { A_Container } from "./A-Container.class";
6
3
  import {
7
4
  A_TYPES__ContainerMeta,
8
5
  A_TYPES__ContainerMetaKey
@@ -13,4 +10,44 @@ import {
13
10
  export class A_ContainerMeta extends A_Meta<A_TYPES__ContainerMeta> {
14
11
 
15
12
 
13
+ /**
14
+ * Returns a set of instructions to run proper methods in Container during A-Concept Stage
15
+ *
16
+ * @param stage
17
+ * @returns
18
+ */
19
+ abstractions(
20
+ abstraction: A_TYPES__ConceptStage
21
+ ): A_TYPES__ConceptAbstractionMeta[] {
22
+ const steps: A_TYPES__ConceptAbstractionMeta[] = [];
23
+
24
+ const abstractions = this.get(A_TYPES__ContainerMetaKey.ABSTRACTIONS);
25
+ const injections = this.get(A_TYPES__ContainerMetaKey.INJECTIONS);
26
+
27
+ // const constructor = A_Context.component(this);
28
+
29
+
30
+ abstractions
31
+ // returns all extensions that match the feature
32
+ ?.find(`CONCEPT_ABSTRACTION::${abstraction}`)
33
+ .forEach(([handler, extensions]) => {
34
+ extensions.forEach(extension => {
35
+ const args = injections?.get(extension.handler) || [];
36
+
37
+ steps.push({
38
+ name: extension.name,
39
+ handler: extension.handler,
40
+ args,
41
+ before: extension.before,
42
+ behavior: extension.behavior,
43
+ after: extension.after
44
+ });
45
+
46
+ });
47
+ });
48
+
49
+
50
+ return steps;
51
+ }
52
+
16
53
  }