@adaas/a-concept 0.0.28 → 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 (179) 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-Config/components/ConfigReader.component.d.ts +2 -1
  47. package/dist/src/base/A-Config/components/ConfigReader.component.js +12 -12
  48. package/dist/src/base/A-Config/components/ConfigReader.component.js.map +1 -1
  49. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.d.ts +14 -0
  50. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.js +53 -0
  51. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.js.map +1 -0
  52. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.d.ts +2 -0
  53. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js +3 -0
  54. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js.map +1 -0
  55. package/dist/src/decorators/A-Connect/A-Connect.decorator.d.ts +19 -0
  56. package/dist/src/decorators/A-Connect/A-Connect.decorator.js +31 -0
  57. package/dist/src/decorators/A-Connect/A-Connect.decorator.js.map +1 -0
  58. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.d.ts +1 -0
  59. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js +3 -0
  60. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js.map +1 -0
  61. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.d.ts +1 -0
  62. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js +8 -0
  63. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js.map +1 -0
  64. package/dist/src/decorators/A-Entity/A-Entity.decorator.types.d.ts +14 -0
  65. package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js +3 -0
  66. package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js.map +1 -0
  67. package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js +9 -0
  68. package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
  69. package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +28 -0
  70. package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +2 -3
  71. package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -1
  72. package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +44 -0
  73. package/dist/src/global/A-Channel/A-Channel.class.d.ts +8 -10
  74. package/dist/src/global/A-Channel/A-Channel.class.js +12 -26
  75. package/dist/src/global/A-Channel/A-Channel.class.js.map +1 -1
  76. package/dist/src/global/A-Channel/A-Channel.types.d.ts +32 -0
  77. package/dist/src/global/A-Component/A-Component.class.d.ts +2 -1
  78. package/dist/src/global/A-Component/A-Component.class.js +1 -0
  79. package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
  80. package/dist/src/global/A-Component/A-Component.meta.d.ts +8 -0
  81. package/dist/src/global/A-Component/A-Component.meta.js +27 -1
  82. package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
  83. package/dist/src/global/A-Component/A-Component.types.d.ts +19 -34
  84. package/dist/src/global/A-Component/A-Component.types.js +1 -7
  85. package/dist/src/global/A-Component/A-Component.types.js.map +1 -1
  86. package/dist/src/global/A-Concept/A_Concept.class.d.ts +7 -7
  87. package/dist/src/global/A-Concept/A_Concept.class.js +30 -30
  88. package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
  89. package/dist/src/global/A-Concept/A_Concept.types.d.ts +42 -2
  90. package/dist/src/global/A-Concept/A_Concept.types.js.map +1 -1
  91. package/dist/src/global/A-Container/A-Container.class.d.ts +1 -8
  92. package/dist/src/global/A-Container/A-Container.class.js +1 -31
  93. package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
  94. package/dist/src/global/A-Container/A-Container.meta.d.ts +8 -0
  95. package/dist/src/global/A-Container/A-Container.meta.js +29 -0
  96. package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
  97. package/dist/src/global/A-Container/A-Container.types.d.ts +23 -7
  98. package/dist/src/global/A-Container/A-Container.types.js +2 -1
  99. package/dist/src/global/A-Container/A-Container.types.js.map +1 -1
  100. package/dist/src/global/A-Context/A-Context.class.js +6 -35
  101. package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
  102. package/dist/src/global/A-Entity/A-Entity.class.d.ts +1 -2
  103. package/dist/src/global/A-Entity/A-Entity.class.js +6 -7
  104. package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
  105. package/dist/src/global/A-Entity/A-Entity.types.d.ts +4 -5
  106. package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -1
  107. package/dist/src/global/A-Feature/A-Feature.class.d.ts +30 -6
  108. package/dist/src/global/A-Feature/A-Feature.class.js +49 -40
  109. package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
  110. package/dist/src/global/A-Feature/A-Feature.types.d.ts +2 -24
  111. package/dist/src/global/A-Feature/A-Feature.types.js +21 -0
  112. package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
  113. package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +8 -0
  114. package/dist/src/global/A-Fragment/A-Fragment.class.js +10 -0
  115. package/dist/src/global/A-Fragment/A-Fragment.class.js.map +1 -1
  116. package/dist/src/global/A-Scope/A-Scope.class.d.ts +7 -5
  117. package/dist/src/global/A-Scope/A-Scope.class.js +33 -10
  118. package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
  119. package/dist/src/global/A-Scope/A-Scope.types.d.ts +2 -1
  120. package/dist/src/global/A-Stage/A-Stage.class.d.ts +69 -0
  121. package/dist/src/global/A-Stage/A-Stage.class.js +176 -0
  122. package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -0
  123. package/dist/src/global/A-Stage/A-Stage.types.d.ts +83 -0
  124. package/dist/src/global/A-Stage/A-Stage.types.js +59 -0
  125. package/dist/src/global/A-Stage/A-Stage.types.js.map +1 -0
  126. package/dist/src/helpers/StepsManager.class.d.ts +15 -0
  127. package/dist/src/helpers/StepsManager.class.js +85 -0
  128. package/dist/src/helpers/StepsManager.class.js.map +1 -0
  129. package/examples/fe-be/channels/Test.channel.ts +24 -0
  130. package/examples/fe-be/components/BE-Controller.component.ts +20 -0
  131. package/examples/fe-be/components/FE.component.ts +13 -0
  132. package/examples/fe-be/concept.ts +0 -0
  133. package/examples/fe-be/containers/ServerApp.container.ts +8 -0
  134. package/examples/fe-be/containers/WebApp.container.ts +13 -0
  135. package/examples/multi-container/channels/Direct.channel.ts +39 -0
  136. package/examples/multi-container/concept.ts +0 -0
  137. package/examples/multi-container/containers/Command.container.ts +41 -0
  138. package/examples/multi-container/containers/Schedule.container.ts +57 -0
  139. package/examples/simple/components/A.component.ts +2 -1
  140. package/examples/simple/containers/Main.container.ts +11 -3
  141. package/examples/simple/entities/EntityA.entity.ts +16 -0
  142. package/examples/simple-http-server/contexts/http-request.context.ts +6 -6
  143. package/index.ts +12 -3
  144. package/package.json +1 -1
  145. package/src/base/A-Config/components/ConfigReader.component.ts +12 -11
  146. package/src/decorators/A-Abstraction/A-Abstraction.decorator.ts +82 -0
  147. package/src/decorators/{A-Stage/A-Stage.decorator.types.ts → A-Abstraction/A-Abstraction.decorator.types.ts} +1 -3
  148. package/src/decorators/A-Connect/A-Connect.decorator.ts +71 -0
  149. package/src/decorators/A-Connect/A-Connect.decorator.types.ts +6 -0
  150. package/src/decorators/A-Entity/A-Entity-List.decorator.ts +12 -0
  151. package/src/decorators/A-Entity/A-Entity.decorator.types.ts +18 -0
  152. package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +10 -0
  153. package/src/decorators/A-Feature/A-Feature.decorator.types.ts +36 -0
  154. package/src/decorators/A-Inject/A-Inject.decorator.ts +7 -7
  155. package/src/decorators/A-Inject/A-Inject.decorator.types.ts +47 -1
  156. package/src/global/A-Channel/A-Channel.class.ts +25 -28
  157. package/src/global/A-Channel/A-Channel.types.ts +53 -0
  158. package/src/global/A-Component/A-Component.class.ts +10 -2
  159. package/src/global/A-Component/A-Component.meta.ts +42 -1
  160. package/src/global/A-Component/A-Component.types.ts +20 -40
  161. package/src/global/A-Concept/A_Concept.class.ts +52 -31
  162. package/src/global/A-Concept/A_Concept.types.ts +48 -3
  163. package/src/global/A-Container/A-Container.class.ts +3 -39
  164. package/src/global/A-Container/A-Container.meta.ts +41 -4
  165. package/src/global/A-Container/A-Container.types.ts +28 -7
  166. package/src/global/A-Context/A-Context.class.ts +9 -49
  167. package/src/global/A-Entity/A-Entity.class.ts +8 -6
  168. package/src/global/A-Entity/A-Entity.types.ts +4 -5
  169. package/src/global/A-Feature/A-Feature.class.ts +73 -61
  170. package/src/global/A-Feature/A-Feature.types.ts +24 -23
  171. package/src/global/A-Fragment/A-Fragment.class.ts +15 -0
  172. package/src/global/A-Scope/A-Scope.class.ts +58 -25
  173. package/src/global/A-Scope/A-Scope.types.ts +2 -1
  174. package/src/global/A-Stage/A-Stage.class.ts +225 -0
  175. package/src/global/A-Stage/A-Stage.types.ts +106 -0
  176. package/src/helpers/StepsManager.class.ts +104 -0
  177. package/tests/channel.ts +213 -0
  178. package/tests/log.ts +88 -40
  179. package/src/decorators/A-Stage/A-Stage.decorator.ts +0 -84
@@ -0,0 +1,20 @@
1
+ import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
2
+ import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
3
+
4
+
5
+
6
+ export class BEController extends A_Component {
7
+
8
+
9
+
10
+ @A_Feature.Define({
11
+ name: 'getOrdersCount',
12
+ // channel
13
+ })
14
+ getOrdersCount() {
15
+
16
+ return 0;
17
+ }
18
+
19
+
20
+ }
@@ -0,0 +1,13 @@
1
+ import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
2
+ import { A_Concept } from "@adaas/a-concept/global/A-Concept/A_Concept.class";
3
+
4
+
5
+
6
+ export class FEComponent extends A_Component {
7
+
8
+
9
+ @A_Concept.Load()
10
+ async renderHomePage() {
11
+
12
+ }
13
+ }
File without changes
@@ -0,0 +1,8 @@
1
+ import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
2
+
3
+
4
+ export class ServerApp extends A_Container {
5
+
6
+
7
+
8
+ }
@@ -0,0 +1,13 @@
1
+ import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
2
+
3
+
4
+
5
+ export class WebApp extends A_Container {
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+ }
@@ -0,0 +1,39 @@
1
+ import { A_Channel } from "@adaas/a-concept/global/A-Channel/A-Channel.class";
2
+ import { A_TYPES__A_ChannelAggregateMethods, A_TYPES__A_ChannelCallParams } from "@adaas/a-concept/global/A-Channel/A-Channel.types";
3
+ import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
4
+ import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
5
+
6
+
7
+ export class DirectChannel<
8
+ T extends A_Container<any>,
9
+ > extends A_Channel<[T]> {
10
+
11
+ protected instance: T
12
+
13
+ constructor(
14
+ public container: T
15
+ ) {
16
+ super({
17
+ id: `direct-channel--${container.name}`
18
+ });
19
+
20
+ this.instance = container;
21
+ }
22
+
23
+
24
+ async call<_Resp extends unknown>(
25
+ prop: A_TYPES__A_ChannelAggregateMethods<[T]>,
26
+ params?: Partial<A_TYPES__A_ChannelCallParams>
27
+ ): Promise<_Resp> {
28
+
29
+ if (!this.instance[prop]) {
30
+ throw new Error(`Method ${prop} not found in ${this.instance.name}`);
31
+ }
32
+
33
+ return await (this.instance[prop] as any)(params) as Promise<_Resp>;
34
+ }
35
+
36
+ }
37
+
38
+
39
+
File without changes
@@ -0,0 +1,41 @@
1
+ import { A_Connect } from "@adaas/a-concept/decorators/A-Connect/A-Connect.decorator";
2
+ import { A_Channel } from "@adaas/a-concept/global/A-Channel/A-Channel.class";
3
+ import { A_TYPES__A_ChannelCallParams } from "@adaas/a-concept/global/A-Channel/A-Channel.types";
4
+ import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
5
+ import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
6
+ import { ScheduleContainer } from "./Schedule.container";
7
+
8
+
9
+
10
+ export class CommandContainer extends A_Container<[
11
+ 'execute',
12
+ ]> {
13
+
14
+ constructor() {
15
+ super({});
16
+ }
17
+
18
+
19
+
20
+ @A_Feature.Define({
21
+ name: 'execute',
22
+ // channels: []
23
+ })
24
+ async execute(
25
+ arg: Partial<A_TYPES__A_ChannelCallParams>
26
+ ) {
27
+ console.log('CommandContainer -> command()');
28
+ }
29
+
30
+
31
+
32
+
33
+ async doSomething(
34
+ @A_Connect(A_Channel, '') schedule: A_Channel<[ScheduleContainer]>
35
+ ) {
36
+
37
+ schedule.call('schedule', {});
38
+
39
+ }
40
+
41
+ }
@@ -0,0 +1,57 @@
1
+ import { A_Connect } from "@adaas/a-concept/decorators/A-Connect/A-Connect.decorator";
2
+ import { A_Feature_Define } from "@adaas/a-concept/decorators/A-Feature/A-Feature-Define.decorator";
3
+ import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator";
4
+ import { A_Channel } from "@adaas/a-concept/global/A-Channel/A-Channel.class";
5
+ import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
6
+ import { CommandContainer } from "./Command.container";
7
+ import { A_TYPES__A_ExecutableMethods } from "@adaas/a-concept/global/A-Channel/A-Channel.types";
8
+
9
+
10
+ export class ScheduleContainer extends A_Container<[
11
+ 'schedule',
12
+ 'start',
13
+ 'stop',
14
+ 'pause',
15
+ ]> {
16
+
17
+ private tasks = [];
18
+
19
+
20
+ constructor() {
21
+ super({});
22
+ }
23
+
24
+
25
+
26
+ @A_Feature_Define({
27
+ name: 'schedule',
28
+ // channels: []
29
+ })
30
+ async schedule(
31
+ // @A_Inject('task') task: any
32
+ ) {
33
+ console.log('ScheduleContainer -> schedule()');
34
+ }
35
+
36
+
37
+
38
+ @A_Feature_Define({
39
+ name: 'start',
40
+ // channels: []
41
+ })
42
+ async start() {
43
+ console.log('ScheduleContainer -> start()');
44
+ }
45
+
46
+
47
+
48
+ async onExecution(
49
+ @A_Connect(A_Channel, '') commands: A_Channel<[CommandContainer]>
50
+ ) {
51
+ const result = await commands.call('execute', {
52
+ fragments: []
53
+ });
54
+
55
+ }
56
+
57
+ }
@@ -16,7 +16,8 @@ export class ComponentA extends A_Component {
16
16
  @A_Feature.Extend()
17
17
  async method_A(
18
18
  @A_Inject(ContextFragmentA) fragmentA: ContextFragmentA,
19
- @A_Inject(A_Logger) logger: A_Logger
19
+ @A_Inject(A_Logger) logger: A_Logger,
20
+
20
21
  ) {
21
22
  logger.log('red', 'Component A -> method_A()');
22
23
  fragmentA.decrement();
@@ -7,6 +7,7 @@ import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorato
7
7
  import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
8
8
  import { A_Logger } from "@adaas/a-concept/base/A-Logger/A-Logger.component";
9
9
  import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
10
+ import { EntityA } from "../entities/EntityA.entity";
10
11
 
11
12
 
12
13
 
@@ -49,6 +50,13 @@ export class MainContainer extends A_Container<
49
50
  ) {
50
51
  console.log('Method B', A_Context.root);
51
52
 
53
+ const entity = new EntityA('test@test:test:0000000001');
54
+
55
+ this.Scope.register(entity);
56
+
57
+ await entity.doSomething();
58
+
59
+
52
60
  const logger = this.Scope.resolve(A_Logger);
53
61
 
54
62
  // or you can manually call the feature
@@ -57,10 +65,10 @@ export class MainContainer extends A_Container<
57
65
  fragments: [new ContextFragmentA(), new ContextFragmentB()]
58
66
  });
59
67
 
60
- for (const step of feature) {
61
- logger.log('Manual Loop Execution Step', feature.current);
68
+ for (const stage of feature) {
69
+ logger.log('Manual Loop Execution Step', feature.stage);
62
70
 
63
- await step();
71
+ await stage.process();
64
72
  }
65
73
  }
66
74
  }
@@ -0,0 +1,16 @@
1
+ import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class";
2
+ import { A_TYPES__EntityBaseMethods } from "@adaas/a-concept/global/A-Entity/A-Entity.types";
3
+
4
+
5
+
6
+ export class EntityA extends A_Entity<any, any, [
7
+ ...A_TYPES__EntityBaseMethods,
8
+ 'doSomething'
9
+ ]> {
10
+
11
+
12
+
13
+ async doSomething() {
14
+ await this.call('doSomething');
15
+ }
16
+ }
@@ -33,13 +33,13 @@ export class HTTPRequest extends A_Fragment {
33
33
  }
34
34
 
35
35
 
36
- async toJSON<T extends any>(): Promise<T> {
37
- if (!this._body) {
38
- this._body = await this.parseBody();
39
- }
36
+ // async toJSON<T extends any>(): Promise<T> {
37
+ // if (!this._body) {
38
+ // this._body = await this.parseBody();
39
+ // }
40
40
 
41
- return this._body;
42
- }
41
+ // return this._body;
42
+ // }
43
43
 
44
44
  private parseBody(): Promise<any> {
45
45
  return new Promise((resolve, reject) => {
package/index.ts CHANGED
@@ -1,7 +1,7 @@
1
-
2
1
  // =================================================================================================
3
2
  // ============================= Export Framework Components =======================================
4
3
  // =================================================================================================
4
+
5
5
  // ---------------------- Major Components ----------------------
6
6
  export { A_Context } from './src/global/A-Context/A-Context.class';
7
7
  // export * from './src/global/A-Context/A-Context.types';
@@ -23,9 +23,15 @@ export * from './src/global/A-Entity/A-Entity.types';
23
23
 
24
24
 
25
25
  // ---------------------- Common Components ----------------------
26
+ export { A_Channel } from './src/global/A-Channel/A-Channel.class';
27
+ export * from './src/global/A-Channel/A-Channel.types';
28
+
26
29
  export { A_Feature } from './src/global/A-Feature/A-Feature.class';
27
30
  export * from './src/global/A-Feature/A-Feature.types';
28
31
 
32
+ export { A_Stage } from './src/global/A-Stage/A-Stage.class';
33
+ export * from './src/global/A-Stage/A-Stage.types';
34
+
29
35
  export { A_Scope } from './src/global/A-Scope/A-Scope.class';
30
36
  export * from './src/global/A-Scope/A-Scope.types';
31
37
 
@@ -47,8 +53,11 @@ export { A_Feature_Define } from './src/decorators/A-Feature/A-Feature-Define.de
47
53
  export { A_Feature_Extend } from './src/decorators/A-Feature/A-Feature-Extend.decorator';
48
54
  export * from './src/decorators/A-Feature/A-Feature.decorator.types';
49
55
 
50
- export { A_Stage } from './src/decorators/A-Stage/A-Stage.decorator';
51
- export * from './src/decorators/A-Stage/A-Stage.decorator.types';
56
+ export { A_Abstraction } from './src/decorators/A-Abstraction/A-Abstraction.decorator';
57
+ export * from './src/decorators/A-Abstraction/A-Abstraction.decorator.types';
58
+
59
+ export { A_Connect } from './src/decorators/A-Connect/A-Connect.decorator';
60
+ export * from './src/decorators/A-Connect/A-Connect.decorator.types';
52
61
 
53
62
 
54
63
  // =================================================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaas/a-concept",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "description": "A-Concept is a framework to build new Applications within or outside the ADAAS ecosystem. This framework is designed to be modular structure regardless environment and program goal.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -55,23 +55,24 @@ export class ConfigReader extends A_Component {
55
55
 
56
56
  /**
57
57
  * Finds the root directory of the project by locating the folder containing package.json
58
+ *
58
59
  * @param {string} startPath - The initial directory to start searching from (default is __dirname)
59
60
  * @returns {string|null} - The path to the root directory or null if package.json is not found
60
61
  */
61
62
  protected async getProjectRoot(startPath = __dirname) {
62
- let currentPath = startPath;
63
+ // let currentPath = startPath;
63
64
 
64
- const fs = await A_Polyfills.fs();
65
+ // const fs = await A_Polyfills.fs();
65
66
 
66
- while (!fs.existsSync(`${currentPath}/package.json`)) {
67
- const parentPath = currentPath.substring(0, currentPath.lastIndexOf('/'));
68
- if (parentPath === currentPath || parentPath === '') {
69
- // Reached the root of the filesystem without finding package.json
70
- return null;
71
- }
72
- currentPath = parentPath;
73
- }
67
+ // while (!fs.existsSync(`${currentPath}/package.json`)) {
68
+ // const parentPath = currentPath.substring(0, currentPath.lastIndexOf('/'));
69
+ // if (parentPath === currentPath || parentPath === '') {
70
+ // // Reached the root of the filesystem without finding package.json
71
+ // return null;
72
+ // }
73
+ // currentPath = parentPath;
74
+ // }
74
75
 
75
- return currentPath;
76
+ return process.cwd();
76
77
  }
77
78
  }
@@ -0,0 +1,82 @@
1
+ import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
2
+ import {
3
+ A_TYPES__A_AbstractionDecoratorDescriptor,
4
+ } from "./A-Abstraction.decorator.types";
5
+ import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.types";
6
+ import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
7
+ import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
8
+ import { A_TYPES__ContainerMetaKey } from "@adaas/a-concept/global/A-Container/A-Container.types";
9
+ import { A_TYPES__ConceptAbstraction, A_TYPES__ConceptStage } from "@adaas/a-concept/global/A-Concept/A_Concept.types";
10
+ import { A_ContainerMeta } from "@adaas/a-concept/global/A-Container/A-Container.meta";
11
+ import { A_ComponentMeta } from "@adaas/a-concept/global/A-Component/A-Component.meta";
12
+ import { A_Meta } from "@adaas/a-concept/global/A-Meta/A-Meta.class";
13
+ import { A_TYPES__A_ExtendDecoratorConfig } from "../A-Feature/A-Feature.decorator.types";
14
+
15
+
16
+ /**
17
+ * A_Stage Decorator uses to extend basic A-Concept Stage methods inside Containers.
18
+ *
19
+ * Using this decorator you can define extend a logic and sequence of the Container Stage methods execution.
20
+ *
21
+ * @param params
22
+ * @returns
23
+ */
24
+ export function A_Abstraction(
25
+ method: A_TYPES__ConceptStage,
26
+ config: Partial<A_TYPES__A_ExtendDecoratorConfig> = {}
27
+ ) {
28
+ return function (
29
+ target: A_Container<any> | A_Component,
30
+ propertyKey: string,
31
+ descriptor: A_TYPES__A_AbstractionDecoratorDescriptor
32
+ ) {
33
+
34
+ const meta: A_ContainerMeta | A_ComponentMeta = A_Context.meta(target as any);
35
+
36
+ let metaKey;
37
+
38
+ const StageKey = `CONCEPT_ABSTRACTION::${method}`;
39
+
40
+ switch (true) {
41
+ case target instanceof A_Container:
42
+ metaKey = A_TYPES__ContainerMetaKey.ABSTRACTIONS
43
+ break;
44
+ case target instanceof A_Component:
45
+ metaKey = A_TYPES__ComponentMetaKey.ABSTRACTIONS
46
+ break;
47
+ default:
48
+ throw new Error(`Concept Stage cannot be defined on the ${target} level`);
49
+ }
50
+
51
+ // Get the existed metadata or create a new one
52
+ const existedMeta: A_Meta<{
53
+ [Key: string]: A_TYPES__ConceptAbstraction[];
54
+ }> = meta.get(metaKey) || new A_Meta();
55
+
56
+ // Set the metadata of the method to define a custom Stage with name
57
+ const existedMetaValue = existedMeta.get(StageKey) || [];
58
+
59
+
60
+ // Add the new method to the metadata
61
+ existedMetaValue.push({
62
+ name: method,
63
+ handler: propertyKey,
64
+ before: config.before || [],
65
+ after: config.after || [],
66
+ behavior: config.behavior || 'sync'
67
+ });
68
+
69
+ // Set the metadata of the method to define a custom Feature with name
70
+ existedMeta.set(StageKey, existedMetaValue);
71
+
72
+
73
+ // Update the metadata of the container with the new Stage definition
74
+ A_Context
75
+ .meta(target as any)
76
+ .set(
77
+ metaKey,
78
+ existedMeta
79
+ );
80
+
81
+ };
82
+ }
@@ -1,7 +1,5 @@
1
- import { A_Concept } from "@adaas/a-concept/global/A-Concept/A_Concept.class"
2
- import { A_TYPES__ConceptStage } from "@adaas/a-concept/global/A-Concept/A_Concept.types"
3
1
 
4
- export type A_TYPES__A_StageDecoratorDescriptor =
2
+ export type A_TYPES__A_AbstractionDecoratorDescriptor =
5
3
 
6
4
  TypedPropertyDescriptor<() => any>
7
5
  |
@@ -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
+ }
@@ -57,6 +57,9 @@ export function A_Feature_Extend(
57
57
  ) {
58
58
 
59
59
  let targetRegexp: RegExp;
60
+ let behavior: 'sync' | 'async' = 'sync';
61
+ let before: string[] = [];
62
+ let after: string[] = [];
60
63
 
61
64
 
62
65
  // Check if the config is a RegExp
@@ -70,6 +73,10 @@ export function A_Feature_Extend(
70
73
  .join('|')})`
71
74
  : '.*'
72
75
  }\\.${param1.name || propertyKey}$`);
76
+
77
+ behavior = param1.behavior || behavior;
78
+ before = param1.before || before;
79
+ after = param1.after || after;
73
80
  }
74
81
  else {
75
82
  targetRegexp = new RegExp(`^.*\\.${propertyKey}$`);
@@ -88,6 +95,9 @@ export function A_Feature_Extend(
88
95
  existedMetaValue.push({
89
96
  name: targetRegexp.source,
90
97
  handler: propertyKey,
98
+ behavior,
99
+ before,
100
+ after
91
101
  });
92
102
 
93
103
  // Set the metadata of the method to define a custom Feature with name
@@ -64,9 +64,45 @@ export type A_TYPES__A_ExtendDecoratorConfig = {
64
64
  | { new(...args: any[]): A_Entity }
65
65
  | { new(...args: any[]): A_Component }
66
66
  >
67
+ } & A_TYPES__A_ExtendDecorator_BehaviorConfig
68
+
69
+
70
+ export type A_TYPES__A_ExtendDecorator_BehaviorConfig = {
71
+ /**
72
+ * The behavior of the method.
73
+ * In case its async it will be executed independently from the main thread.
74
+ *
75
+ * [!] However, in case of sync, it will be executed in the main thread.in the order of the declaration.
76
+ *
77
+ */
78
+ behavior: 'async' | 'sync'
79
+
80
+
81
+ /**
82
+ * Allows to define the order of the execution of the method.
83
+ *
84
+ * [!] In case the method has circular dependencies it will Throw an error.
85
+ *
86
+ */
87
+ before: string[]
88
+
89
+ /**
90
+ * Allows to define the order of the execution of the method.
91
+ *
92
+ * [!] In case the method has circular dependencies it will Throw an error.
93
+ *
94
+ */
95
+ after: string[]
67
96
  }
68
97
 
69
98
 
70
99
 
100
+ export type A_TYPES__A_ExtendDecorator_Meta = {
101
+ name: string,
102
+ handler: string
103
+ } & A_TYPES__A_ExtendDecorator_BehaviorConfig
104
+
105
+
106
+
71
107
 
72
108