@adaas/a-concept 0.0.29 → 0.0.31

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 (185) 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/base/A-Errors/A-Error.entity.d.ts +3 -0
  47. package/dist/src/base/A-Errors/A-Error.entity.js +8 -0
  48. package/dist/src/base/A-Errors/A-Error.entity.js.map +1 -0
  49. package/dist/src/base/A-Errors/A-Errors.context.js +1 -1
  50. package/dist/src/base/A-Errors/A-Errors.context.js.map +1 -1
  51. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.d.ts +14 -0
  52. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.js +53 -0
  53. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.js.map +1 -0
  54. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.d.ts +2 -0
  55. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js +3 -0
  56. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js.map +1 -0
  57. package/dist/src/decorators/A-Connect/A-Connect.decorator.d.ts +19 -0
  58. package/dist/src/decorators/A-Connect/A-Connect.decorator.js +31 -0
  59. package/dist/src/decorators/A-Connect/A-Connect.decorator.js.map +1 -0
  60. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.d.ts +1 -0
  61. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js +3 -0
  62. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js.map +1 -0
  63. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.d.ts +1 -0
  64. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js +8 -0
  65. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js.map +1 -0
  66. package/dist/src/decorators/A-Entity/A-Entity.decorator.types.d.ts +14 -0
  67. package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js +3 -0
  68. package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js.map +1 -0
  69. package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js +7 -5
  70. package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js.map +1 -1
  71. package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js +9 -0
  72. package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
  73. package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +36 -0
  74. package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +2 -3
  75. package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -1
  76. package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +44 -0
  77. package/dist/src/global/A-Channel/A-Channel.class.d.ts +8 -10
  78. package/dist/src/global/A-Channel/A-Channel.class.js +12 -26
  79. package/dist/src/global/A-Channel/A-Channel.class.js.map +1 -1
  80. package/dist/src/global/A-Channel/A-Channel.types.d.ts +32 -0
  81. package/dist/src/global/A-Component/A-Component.class.d.ts +2 -1
  82. package/dist/src/global/A-Component/A-Component.class.js +1 -0
  83. package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
  84. package/dist/src/global/A-Component/A-Component.meta.d.ts +16 -0
  85. package/dist/src/global/A-Component/A-Component.meta.js +37 -3
  86. package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
  87. package/dist/src/global/A-Component/A-Component.types.d.ts +26 -38
  88. package/dist/src/global/A-Component/A-Component.types.js +1 -7
  89. package/dist/src/global/A-Component/A-Component.types.js.map +1 -1
  90. package/dist/src/global/A-Concept/A_Concept.class.d.ts +7 -7
  91. package/dist/src/global/A-Concept/A_Concept.class.js +30 -30
  92. package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
  93. package/dist/src/global/A-Concept/A_Concept.types.d.ts +42 -2
  94. package/dist/src/global/A-Concept/A_Concept.types.js.map +1 -1
  95. package/dist/src/global/A-Container/A-Container.class.d.ts +1 -8
  96. package/dist/src/global/A-Container/A-Container.class.js +1 -31
  97. package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
  98. package/dist/src/global/A-Container/A-Container.meta.d.ts +8 -0
  99. package/dist/src/global/A-Container/A-Container.meta.js +29 -0
  100. package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
  101. package/dist/src/global/A-Container/A-Container.types.d.ts +32 -8
  102. package/dist/src/global/A-Container/A-Container.types.js +2 -1
  103. package/dist/src/global/A-Container/A-Container.types.js.map +1 -1
  104. package/dist/src/global/A-Context/A-Context.class.js +29 -36
  105. package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
  106. package/dist/src/global/A-Entity/A-Entity.class.d.ts +1 -2
  107. package/dist/src/global/A-Entity/A-Entity.class.js +6 -7
  108. package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
  109. package/dist/src/global/A-Entity/A-Entity.types.d.ts +12 -6
  110. package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -1
  111. package/dist/src/global/A-Feature/A-Feature.class.d.ts +30 -6
  112. package/dist/src/global/A-Feature/A-Feature.class.js +49 -40
  113. package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
  114. package/dist/src/global/A-Feature/A-Feature.types.d.ts +2 -24
  115. package/dist/src/global/A-Feature/A-Feature.types.js +21 -0
  116. package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
  117. package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +8 -0
  118. package/dist/src/global/A-Fragment/A-Fragment.class.js +10 -0
  119. package/dist/src/global/A-Fragment/A-Fragment.class.js.map +1 -1
  120. package/dist/src/global/A-Scope/A-Scope.class.d.ts +7 -5
  121. package/dist/src/global/A-Scope/A-Scope.class.js +33 -10
  122. package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
  123. package/dist/src/global/A-Scope/A-Scope.types.d.ts +2 -1
  124. package/dist/src/global/A-Stage/A-Stage.class.d.ts +69 -0
  125. package/dist/src/global/A-Stage/A-Stage.class.js +181 -0
  126. package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -0
  127. package/dist/src/global/A-Stage/A-Stage.types.d.ts +78 -0
  128. package/dist/src/global/A-Stage/A-Stage.types.js +59 -0
  129. package/dist/src/global/A-Stage/A-Stage.types.js.map +1 -0
  130. package/dist/src/helpers/StepsManager.class.d.ts +15 -0
  131. package/dist/src/helpers/StepsManager.class.js +85 -0
  132. package/dist/src/helpers/StepsManager.class.js.map +1 -0
  133. package/examples/fe-be/channels/Test.channel.ts +24 -0
  134. package/examples/fe-be/components/BE-Controller.component.ts +20 -0
  135. package/examples/fe-be/components/FE.component.ts +13 -0
  136. package/examples/fe-be/concept.ts +0 -0
  137. package/examples/fe-be/containers/ServerApp.container.ts +8 -0
  138. package/examples/fe-be/containers/WebApp.container.ts +13 -0
  139. package/examples/multi-container/channels/Direct.channel.ts +39 -0
  140. package/examples/multi-container/concept.ts +0 -0
  141. package/examples/multi-container/containers/Command.container.ts +41 -0
  142. package/examples/multi-container/containers/Schedule.container.ts +57 -0
  143. package/examples/simple/components/A.component.ts +2 -1
  144. package/examples/simple/containers/Main.container.ts +11 -3
  145. package/examples/simple/entities/EntityA.entity.ts +16 -0
  146. package/examples/simple-http-server/contexts/http-request.context.ts +6 -6
  147. package/index.ts +12 -3
  148. package/package.json +1 -1
  149. package/src/base/A-Errors/A-Error.entity.ts +10 -0
  150. package/src/base/A-Errors/A-Errors.context.ts +2 -2
  151. package/src/decorators/A-Abstraction/A-Abstraction.decorator.ts +82 -0
  152. package/src/decorators/{A-Stage/A-Stage.decorator.types.ts → A-Abstraction/A-Abstraction.decorator.types.ts} +1 -3
  153. package/src/decorators/A-Connect/A-Connect.decorator.ts +71 -0
  154. package/src/decorators/A-Connect/A-Connect.decorator.types.ts +6 -0
  155. package/src/decorators/A-Entity/A-Entity-List.decorator.ts +12 -0
  156. package/src/decorators/A-Entity/A-Entity.decorator.types.ts +18 -0
  157. package/src/decorators/A-Feature/A-Feature-Define.decorator.ts +16 -9
  158. package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +10 -2
  159. package/src/decorators/A-Feature/A-Feature.decorator.types.ts +46 -0
  160. package/src/decorators/A-Inject/A-Inject.decorator.ts +7 -7
  161. package/src/decorators/A-Inject/A-Inject.decorator.types.ts +47 -1
  162. package/src/global/A-Channel/A-Channel.class.ts +25 -28
  163. package/src/global/A-Channel/A-Channel.types.ts +53 -0
  164. package/src/global/A-Component/A-Component.class.ts +10 -2
  165. package/src/global/A-Component/A-Component.meta.ts +59 -6
  166. package/src/global/A-Component/A-Component.types.ts +28 -45
  167. package/src/global/A-Concept/A_Concept.class.ts +52 -31
  168. package/src/global/A-Concept/A_Concept.types.ts +48 -3
  169. package/src/global/A-Container/A-Container.class.ts +3 -39
  170. package/src/global/A-Container/A-Container.meta.ts +41 -4
  171. package/src/global/A-Container/A-Container.types.ts +36 -8
  172. package/src/global/A-Context/A-Context.class.ts +37 -50
  173. package/src/global/A-Entity/A-Entity.class.ts +8 -6
  174. package/src/global/A-Entity/A-Entity.types.ts +13 -6
  175. package/src/global/A-Feature/A-Feature.class.ts +73 -61
  176. package/src/global/A-Feature/A-Feature.types.ts +24 -23
  177. package/src/global/A-Fragment/A-Fragment.class.ts +15 -0
  178. package/src/global/A-Scope/A-Scope.class.ts +58 -25
  179. package/src/global/A-Scope/A-Scope.types.ts +2 -1
  180. package/src/global/A-Stage/A-Stage.class.ts +234 -0
  181. package/src/global/A-Stage/A-Stage.types.ts +101 -0
  182. package/src/helpers/StepsManager.class.ts +104 -0
  183. package/tests/channel.ts +213 -0
  184. package/tests/log.ts +88 -40
  185. package/src/decorators/A-Stage/A-Stage.decorator.ts +0 -84
@@ -0,0 +1,71 @@
1
+ import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
2
+ import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
3
+ import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
4
+ import { A_ContainerMeta } from "@adaas/a-concept/global/A-Container/A-Container.meta";
5
+ import { A_ComponentMeta } from "@adaas/a-concept/global/A-Component/A-Component.meta";
6
+ import { A_Channel } from "@adaas/a-concept/global/A-Channel/A-Channel.class";
7
+
8
+
9
+ /**
10
+ * A_Connect decorators allows to establish a connection between the Containers.
11
+ *
12
+ * Depending on the A-Channel implementation the connection could be established in different ways like:
13
+ * - Direct connection (Async Module import)
14
+ * - Remote connection (HTTP, WebSockets)
15
+ * - Local connection (Shared Memory, IPC)
16
+ * - Event-based connection (EventEmitter, PubSub)
17
+ *
18
+ *
19
+ * @param params
20
+ * @returns
21
+ */
22
+ export function A_Connect(
23
+ channel: typeof A_Channel,
24
+ /**
25
+ * Connection name
26
+ */
27
+ id: string
28
+ )
29
+ export function A_Connect(
30
+ channel: typeof A_Channel,
31
+ config?: any | string
32
+ ) {
33
+ return function (
34
+ target: A_Container<any> | A_Component,
35
+ methodName: string | symbol | undefined,
36
+ parameterIndex: number
37
+ ) {
38
+
39
+ const meta: A_ContainerMeta | A_ComponentMeta = A_Context.meta(target as any);
40
+
41
+ let metaKey;
42
+
43
+
44
+ // // Get the existed metadata or create a new one
45
+ // const existedMeta: A_Meta<{
46
+ // [Key: string]: A_TYPES__ContainerMeta_StageExtension[];
47
+ // }> = meta.get(metaKey) || new A_Meta();
48
+
49
+ // // Set the metadata of the method to define a custom Stage with name
50
+ // const existedMetaValue = existedMeta.get(StageKey) || [];
51
+
52
+ // // Add the new method to the metadata
53
+ // existedMetaValue.push({
54
+ // name: method,
55
+ // handler: propertyKey,
56
+ // });
57
+
58
+ // // Set the metadata of the method to define a custom Feature with name
59
+ // existedMeta.set(StageKey, existedMetaValue);
60
+
61
+
62
+ // // Update the metadata of the container with the new Stage definition
63
+ // A_Context
64
+ // .meta(target as any)
65
+ // .set(
66
+ // metaKey,
67
+ // existedMeta
68
+ // );
69
+
70
+ };
71
+ }
@@ -0,0 +1,6 @@
1
+
2
+ export type A_TYPES__A_ConnectDecoratorConfig = {
3
+ }
4
+
5
+
6
+
@@ -0,0 +1,12 @@
1
+
2
+
3
+ export function A_EntityListDecorator(...args: any[]): any {
4
+
5
+ return function (
6
+ target: any,
7
+ propertyKey: string,
8
+ descriptor: PropertyDescriptor
9
+ ) {
10
+
11
+ }
12
+ }
@@ -0,0 +1,18 @@
1
+ import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class"
2
+ import { ASEID } from "@adaas/a-utils"
3
+
4
+
5
+
6
+ export type A_TYPES__EntityListDecoratorQuery = {
7
+ aseid: string | ASEID,
8
+ id: string,
9
+ type: { new(...args: any[]): A_Entity<any, any, any> },
10
+ entity: string
11
+ }
12
+
13
+
14
+
15
+ export type A_TYPES__EntityListDecoratorPagination = {
16
+ limit: number,
17
+ offset: number
18
+ }
@@ -1,10 +1,11 @@
1
1
  import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
2
2
  import {
3
+ A_TYPES__A_DefineDecorator_Meta,
3
4
  A_TYPES__A_FeatureDecoratorConfig,
4
5
  A_TYPES__A_FeatureDecoratorDescriptor,
5
6
  } from "./A-Feature.decorator.types";
6
7
  import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
7
- import { A_TYPES__ContainerMetaKey } from "@adaas/a-concept/global/A-Container/A-Container.types";
8
+ import { A_TYPES__ContainerMeta_FeatureItem, A_TYPES__ContainerMetaKey } from "@adaas/a-concept/global/A-Container/A-Container.types";
8
9
  import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
9
10
  import { A_EntityMeta } from "@adaas/a-concept/global/A-Entity/A-Entity.meta";
10
11
  import { A_ContainerMeta } from "@adaas/a-concept/global/A-Container/A-Container.meta";
@@ -12,6 +13,7 @@ import { A_ComponentMeta } from "@adaas/a-concept/global/A-Component/A-Component
12
13
  import { A_TYPES__EntityMetaKey } from "@adaas/a-concept/global/A-Entity/A-Entity.types";
13
14
  import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.types";
14
15
  import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class";
16
+ import { A_Meta } from "@adaas/a-concept/global/A-Meta/A-Meta.class";
15
17
 
16
18
 
17
19
  /**
@@ -36,7 +38,7 @@ export function A_Feature_Define(
36
38
  descriptor: A_TYPES__A_FeatureDecoratorDescriptor
37
39
  ) {
38
40
 
39
- const meta: A_EntityMeta | A_ContainerMeta | A_ComponentMeta = A_Context.meta(target as any);
41
+ const meta: A_EntityMeta | A_ContainerMeta | A_ComponentMeta = A_Context.meta(target.constructor);
40
42
 
41
43
  let metaKey;
42
44
 
@@ -57,22 +59,27 @@ export function A_Feature_Define(
57
59
 
58
60
 
59
61
  // Get the existed metadata or create a new one
60
- const existedMeta = meta.get(metaKey)
61
- || new Map();
62
+ const existedMeta: A_Meta<{
63
+ /**
64
+ * Where Key is the name of the feature
65
+ *
66
+ * Where value is the list of features
67
+ */
68
+ [Key: string]: A_TYPES__A_DefineDecorator_Meta
69
+ }> = meta.get(metaKey) || new A_Meta();
62
70
 
63
71
 
64
72
  // Set the metadata of the method to define a custom Feature with name
65
73
  existedMeta.set(propertyKey, {
66
74
  handler: propertyKey,
67
- config: {
68
- ...config,
69
- name: `${target.constructor.name}.${propertyKey || config.name}`,
70
- }
75
+ name: `${target.constructor.name}.${propertyKey || config.name}`,
76
+ template: config.template || [],
77
+ channel: config.channel || []
71
78
  });
72
79
 
73
80
  // Update the metadata of the container with the new Feature definition
74
81
  A_Context
75
- .meta(target as any)
82
+ .meta(target.constructor)
76
83
  .set(
77
84
  metaKey,
78
85
  existedMeta
@@ -5,8 +5,6 @@ import {
5
5
  } from "./A-Feature.decorator.types";
6
6
  import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.types";
7
7
  import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
8
- import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
9
- import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class";
10
8
  import { A_Meta } from "@adaas/a-concept/global/A-Meta/A-Meta.class";
11
9
 
12
10
 
@@ -57,6 +55,9 @@ export function A_Feature_Extend(
57
55
  ) {
58
56
 
59
57
  let targetRegexp: RegExp;
58
+ let behavior: 'sync' | 'async' = 'sync';
59
+ let before: string[] = [];
60
+ let after: string[] = [];
60
61
 
61
62
 
62
63
  // Check if the config is a RegExp
@@ -70,6 +71,10 @@ export function A_Feature_Extend(
70
71
  .join('|')})`
71
72
  : '.*'
72
73
  }\\.${param1.name || propertyKey}$`);
74
+
75
+ behavior = param1.behavior || behavior;
76
+ before = param1.before || before;
77
+ after = param1.after || after;
73
78
  }
74
79
  else {
75
80
  targetRegexp = new RegExp(`^.*\\.${propertyKey}$`);
@@ -88,6 +93,9 @@ export function A_Feature_Extend(
88
93
  existedMetaValue.push({
89
94
  name: targetRegexp.source,
90
95
  handler: propertyKey,
96
+ behavior,
97
+ before,
98
+ after
91
99
  });
92
100
 
93
101
  // Set the metadata of the method to define a custom Feature with name
@@ -1,6 +1,8 @@
1
+ import { A_Channel } from "@adaas/a-concept/global/A-Channel/A-Channel.class";
1
2
  import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class"
2
3
  import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class"
3
4
  import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class"
5
+ import { A_TYPES__A_StageStep } from "@adaas/a-concept/global/A-Stage/A-Stage.types";
4
6
 
5
7
 
6
8
  export type A_TYPES__A_Feature_Extend = {
@@ -26,8 +28,16 @@ export type A_TYPES__A_FeatureDecoratorDescriptor =
26
28
 
27
29
  export type A_TYPES__A_FeatureDecoratorConfig = {
28
30
  name: string,
31
+ channel: Array<typeof A_Channel>
32
+ template: Array<A_TYPES__A_StageStep>
29
33
  }
30
34
 
35
+ export type A_TYPES__A_FeatureTemplateItem = A_TYPES__A_StageStep
36
+
37
+
38
+ export type A_TYPES__A_DefineDecorator_Meta = {
39
+ handler: string
40
+ } & A_TYPES__A_FeatureDecoratorConfig
31
41
 
32
42
 
33
43
  export type A_TYPES__A_ExtendDecoratorDescriptor =
@@ -64,9 +74,45 @@ export type A_TYPES__A_ExtendDecoratorConfig = {
64
74
  | { new(...args: any[]): A_Entity }
65
75
  | { new(...args: any[]): A_Component }
66
76
  >
77
+ } & A_TYPES__A_ExtendDecorator_BehaviorConfig
78
+
79
+
80
+ export type A_TYPES__A_ExtendDecorator_BehaviorConfig = {
81
+ /**
82
+ * The behavior of the method.
83
+ * In case its async it will be executed independently from the main thread.
84
+ *
85
+ * [!] However, in case of sync, it will be executed in the main thread.in the order of the declaration.
86
+ *
87
+ */
88
+ behavior: 'async' | 'sync'
89
+
90
+
91
+ /**
92
+ * Allows to define the order of the execution of the method.
93
+ *
94
+ * [!] In case the method has circular dependencies it will Throw an error.
95
+ *
96
+ */
97
+ before: string[]
98
+
99
+ /**
100
+ * Allows to define the order of the execution of the method.
101
+ *
102
+ * [!] In case the method has circular dependencies it will Throw an error.
103
+ *
104
+ */
105
+ after: string[]
67
106
  }
68
107
 
69
108
 
70
109
 
110
+ export type A_TYPES__A_ExtendDecorator_Meta = {
111
+ name: string,
112
+ handler: string
113
+ } & A_TYPES__A_ExtendDecorator_BehaviorConfig
114
+
115
+
116
+
71
117
 
72
118
 
@@ -1,9 +1,12 @@
1
1
  import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
2
- import { A_TYPES__A_InjectDecoratorReturn } from "./A-Inject.decorator.types";
2
+ import {
3
+ A_TYPES__A_InjectDecorator_EntityInjectionInstructions,
4
+ A_TYPES__A_InjectDecoratorReturn
5
+ } from "./A-Inject.decorator.types";
3
6
  import { A_Fragment } from "@adaas/a-concept/global/A-Fragment/A-Fragment.class";
4
7
  import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
5
8
  import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
6
- import { A_TYPES__ComponentMeta_EntityInjectionInstructions, A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.types";
9
+ import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.types";
7
10
  import { A_Meta } from "@adaas/a-concept/global/A-Meta/A-Meta.class";
8
11
  import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
9
12
  import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class";
@@ -42,7 +45,7 @@ export function A_Inject(
42
45
 
43
46
  export function A_Inject(
44
47
  entity: { new(...args: any[]): A_Entity },
45
- config: Partial<A_TYPES__ComponentMeta_EntityInjectionInstructions>
48
+ config: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>
46
49
  ): A_TYPES__A_InjectDecoratorReturn
47
50
 
48
51
  // ====================== BASE FUNCTION ======================
@@ -52,10 +55,7 @@ export function A_Inject(
52
55
  | { new(...args: any[]): A_Component }
53
56
  | { new(...args: any[]): A_Fragment }
54
57
  | { new(...args: any[]): A_Entity },
55
- param2?: {
56
- aseid?: string,
57
- id?: string,
58
- }
58
+ param2?: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>
59
59
  ): A_TYPES__A_InjectDecoratorReturn {
60
60
  return function (
61
61
  target: A_Component,
@@ -1,3 +1,10 @@
1
+ import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
2
+ import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
3
+ import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class";
4
+ import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
5
+ import { A_Fragment } from "@adaas/a-concept/global/A-Fragment/A-Fragment.class";
6
+ import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
7
+ import { ASEID } from "@adaas/a-utils";
1
8
 
2
9
  export type A_TYPES__A_InjectDecoratorDescriptor = TypedPropertyDescriptor<(
3
10
  ...args: any[]
@@ -34,4 +41,43 @@ export type A_TYPES__A_InjectDecoratorStorageInstruction = Array<
34
41
  // | Array<typeof A_Container>
35
42
  // | Array<typeof A_ContextFragment>
36
43
  | { new(...args: any[]): any }
37
- >
44
+ >
45
+
46
+
47
+
48
+ export type A_TYPES__A_InjectDecorator_Meta = Array<{
49
+ target: A_TYPES__A_InjectDecorator_Injectable
50
+ } | {
51
+ target: { new(...args: any[]): A_Entity },
52
+ instructions: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>
53
+ }>;
54
+
55
+
56
+ export type A_TYPES__A_InjectDecorator_Injectable =
57
+ { new(...args: any[]): A_Fragment }
58
+ | { new(...args: any[]): A_Component }
59
+ | { new(...args: any[]): A_Container<any> }
60
+ | { new(...args: any[]): A_Scope }
61
+ | { new(...args: any[]): A_Feature }
62
+ | { new(...args: any[]): A_Entity<any, any, any> };
63
+
64
+
65
+ export type A_TYPES__A_InjectDecorator_EntityInjectionInstructions = {
66
+ query: Partial<A_TYPES__A_InjectDecorator_EntityInjectionQuery>,
67
+ pagination: Partial<A_TYPES__A_InjectDecorator_EntityInjectionPagination>
68
+ }
69
+
70
+
71
+ export type A_TYPES__A_InjectDecorator_EntityInjectionQuery = {
72
+ aseid: string | ASEID,
73
+ id: string,
74
+ type: { new(...args: any[]): A_Entity<any, any, any> },
75
+ entity: string
76
+ }
77
+
78
+
79
+ export type A_TYPES__A_InjectDecorator_EntityInjectionPagination = {
80
+ count: number,
81
+ from: 'start' | 'end'
82
+ }
83
+
@@ -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,5 @@
1
+ import { A_TYPES__A_InjectDecorator_Meta } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator.types";
2
+ import { A_TYPES__ConceptAbstractionMeta, A_TYPES__ConceptStage } from "../A-Concept/A_Concept.types";
1
3
  import { A_Meta } from "../A-Meta/A-Meta.class";
2
4
  import { A_TYPES__ComponentMeta, A_TYPES__ComponentMetaExtension, A_TYPES__ComponentMetaKey } from "./A-Component.types";
3
5
 
@@ -6,6 +8,23 @@ export class A_ComponentMeta extends A_Meta<A_TYPES__ComponentMeta> {
6
8
 
7
9
 
8
10
 
11
+ /**
12
+ * Allows to get all the injections for a given handler
13
+ *
14
+ * @param handler
15
+ * @returns
16
+ */
17
+ injections(
18
+ handler: string
19
+ ): A_TYPES__A_InjectDecorator_Meta {
20
+ const injections = this.get(A_TYPES__ComponentMetaKey.INJECTIONS);
21
+
22
+ const args = injections?.get(handler) || [];
23
+
24
+ return args;
25
+ }
26
+
27
+
9
28
 
10
29
  /**
11
30
  * Allows to get all the extensions for a given feature
@@ -21,21 +40,18 @@ export class A_ComponentMeta extends A_Meta<A_TYPES__ComponentMeta> {
21
40
  const extensions = this.get(A_TYPES__ComponentMetaKey.EXTENSIONS);
22
41
  const injections = this.get(A_TYPES__ComponentMetaKey.INJECTIONS);
23
42
 
24
- // const constructor = A_Context.component(this);
25
-
26
-
27
43
  extensions
28
44
  // returns all extensions that match the feature
29
45
  ?.find(feature)
30
46
  .forEach(([handler, extensions]) => {
31
47
  extensions.forEach(extension => {
32
- const args = injections?.get(extension.handler) || [];
33
-
34
48
  steps.push({
35
49
  // component: constructor,
36
50
  name: extension.name,
37
51
  handler: extension.handler,
38
- args
52
+ behavior: extension.behavior,
53
+ before: extension.before || [],
54
+ after: extension.after || []
39
55
  });
40
56
 
41
57
  });
@@ -45,4 +61,41 @@ export class A_ComponentMeta extends A_Meta<A_TYPES__ComponentMeta> {
45
61
  return steps;
46
62
  }
47
63
 
64
+
65
+ /**
66
+ * Returns a set of instructions to run proper methods in Component during A-Concept Stage
67
+ *
68
+ * @param stage
69
+ * @returns
70
+ */
71
+ abstractions(
72
+ abstraction: A_TYPES__ConceptStage
73
+ ): A_TYPES__ConceptAbstractionMeta[] {
74
+ const steps: A_TYPES__ConceptAbstractionMeta[] = [];
75
+
76
+ const abstractions = this.get(A_TYPES__ComponentMetaKey.ABSTRACTIONS);
77
+ const injections = this.get(A_TYPES__ComponentMetaKey.INJECTIONS);
78
+
79
+ // const constructor = A_Context.component(this);
80
+
81
+
82
+ abstractions
83
+ // returns all extensions that match the feature
84
+ ?.find(`CONCEPT_ABSTRACTION::${abstraction}`)
85
+ .forEach(([handler, extensions]) => {
86
+ extensions.forEach(extension => {
87
+ const args = injections?.get(extension.handler) || [];
88
+
89
+ steps.push({
90
+ ...extension,
91
+ // component: constructor,
92
+ args,
93
+ });
94
+
95
+ });
96
+ });
97
+
98
+
99
+ return steps;
100
+ }
48
101
  }