@adaas/a-concept 0.1.24 → 0.1.26

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 (227) hide show
  1. package/dist/index.cjs +3 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.mts +3961 -0
  4. package/dist/index.d.ts +3961 -50
  5. package/dist/index.mjs +3 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +5 -6
  8. package/src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts +2 -1
  9. package/src/global/A-Context/A-Context.class.ts +81 -7
  10. package/src/global/A-Context/A-Context.error.ts +4 -0
  11. package/src/global/A-Dependency/A-Dependency-Default.decorator.ts +75 -0
  12. package/src/global/A-Dependency/A-Dependency-Load.decorator.ts +80 -0
  13. package/src/global/A-Dependency/A-Dependency-Require.decorator.ts +68 -0
  14. package/src/global/A-Dependency/A-Dependency.class.ts +33 -0
  15. package/src/global/A-Dependency/A-Dependency.error.ts +13 -0
  16. package/src/global/A-Dependency/A-Dependency.types.ts +28 -0
  17. package/src/global/A-Feature/A-Feature-Define.decorator.ts +2 -1
  18. package/src/global/A-Feature/A-Feature-Extend.decorator.ts +2 -1
  19. package/src/global/A-Feature/A-Feature.class.ts +11 -0
  20. package/src/global/A-Inject/A-Inject.decorator.ts +4 -2
  21. package/src/global/A-Inject/A-Inject.types.ts +5 -3
  22. package/src/global/A-Scope/A-Scope.class.ts +85 -57
  23. package/src/global/A-Stage/A-Stage.class.ts +22 -2
  24. package/src/global/A-Stage/A-Stage.error.ts +2 -0
  25. package/src/helpers/A_Common.helper.ts +101 -0
  26. package/src/helpers/A_TypeGuards.helper.ts +8 -0
  27. package/src/index.ts +88 -0
  28. package/tests/A-Component.test.ts +1 -1
  29. package/tests/A-Concept.test.ts +5 -6
  30. package/tests/A-Dependency.test.ts +93 -0
  31. package/tests/A-Feature.test.ts +7 -7
  32. package/tests/A-Scope.test.ts +10 -10
  33. package/tsconfig.json +2 -2
  34. package/tsup.config.ts +32 -0
  35. package/dist/index.js +0 -112
  36. package/dist/index.js.map +0 -1
  37. package/dist/src/constants/env.constants.d.ts +0 -33
  38. package/dist/src/constants/env.constants.js +0 -47
  39. package/dist/src/constants/env.constants.js.map +0 -1
  40. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.d.ts +0 -23
  41. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js +0 -96
  42. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js.map +0 -1
  43. package/dist/src/global/A-Abstraction/A-Abstraction.class.d.ts +0 -74
  44. package/dist/src/global/A-Abstraction/A-Abstraction.class.js +0 -130
  45. package/dist/src/global/A-Abstraction/A-Abstraction.class.js.map +0 -1
  46. package/dist/src/global/A-Abstraction/A-Abstraction.error.d.ts +0 -7
  47. package/dist/src/global/A-Abstraction/A-Abstraction.error.js +0 -12
  48. package/dist/src/global/A-Abstraction/A-Abstraction.error.js.map +0 -1
  49. package/dist/src/global/A-Abstraction/A-Abstraction.types.d.ts +0 -38
  50. package/dist/src/global/A-Abstraction/A-Abstraction.types.js +0 -3
  51. package/dist/src/global/A-Abstraction/A-Abstraction.types.js.map +0 -1
  52. package/dist/src/global/A-Caller/A_Caller.class.d.ts +0 -33
  53. package/dist/src/global/A-Caller/A_Caller.class.js +0 -44
  54. package/dist/src/global/A-Caller/A_Caller.class.js.map +0 -1
  55. package/dist/src/global/A-Caller/A_Caller.error.d.ts +0 -7
  56. package/dist/src/global/A-Caller/A_Caller.error.js +0 -12
  57. package/dist/src/global/A-Caller/A_Caller.error.js.map +0 -1
  58. package/dist/src/global/A-Caller/A_Caller.types.d.ts +0 -18
  59. package/dist/src/global/A-Caller/A_Caller.types.js +0 -3
  60. package/dist/src/global/A-Caller/A_Caller.types.js.map +0 -1
  61. package/dist/src/global/A-Component/A-Component.class.d.ts +0 -34
  62. package/dist/src/global/A-Component/A-Component.class.js +0 -56
  63. package/dist/src/global/A-Component/A-Component.class.js.map +0 -1
  64. package/dist/src/global/A-Component/A-Component.constants.d.ts +0 -6
  65. package/dist/src/global/A-Component/A-Component.constants.js +0 -11
  66. package/dist/src/global/A-Component/A-Component.constants.js.map +0 -1
  67. package/dist/src/global/A-Component/A-Component.meta.d.ts +0 -34
  68. package/dist/src/global/A-Component/A-Component.meta.js +0 -78
  69. package/dist/src/global/A-Component/A-Component.meta.js.map +0 -1
  70. package/dist/src/global/A-Component/A-Component.types.d.ts +0 -76
  71. package/dist/src/global/A-Component/A-Component.types.js +0 -4
  72. package/dist/src/global/A-Component/A-Component.types.js.map +0 -1
  73. package/dist/src/global/A-Concept/A-Concept.class.d.ts +0 -153
  74. package/dist/src/global/A-Concept/A-Concept.class.js +0 -260
  75. package/dist/src/global/A-Concept/A-Concept.class.js.map +0 -1
  76. package/dist/src/global/A-Concept/A-Concept.constants.d.ts +0 -33
  77. package/dist/src/global/A-Concept/A-Concept.constants.js +0 -39
  78. package/dist/src/global/A-Concept/A-Concept.constants.js.map +0 -1
  79. package/dist/src/global/A-Concept/A-Concept.meta.d.ts +0 -6
  80. package/dist/src/global/A-Concept/A-Concept.meta.js +0 -12
  81. package/dist/src/global/A-Concept/A-Concept.meta.js.map +0 -1
  82. package/dist/src/global/A-Concept/A-Concept.types.d.ts +0 -66
  83. package/dist/src/global/A-Concept/A-Concept.types.js +0 -3
  84. package/dist/src/global/A-Concept/A-Concept.types.js.map +0 -1
  85. package/dist/src/global/A-Container/A-Container.class.d.ts +0 -52
  86. package/dist/src/global/A-Container/A-Container.class.js +0 -78
  87. package/dist/src/global/A-Container/A-Container.class.js.map +0 -1
  88. package/dist/src/global/A-Container/A-Container.constants.d.ts +0 -6
  89. package/dist/src/global/A-Container/A-Container.constants.js +0 -11
  90. package/dist/src/global/A-Container/A-Container.constants.js.map +0 -1
  91. package/dist/src/global/A-Container/A-Container.meta.d.ts +0 -35
  92. package/dist/src/global/A-Container/A-Container.meta.js +0 -76
  93. package/dist/src/global/A-Container/A-Container.meta.js.map +0 -1
  94. package/dist/src/global/A-Container/A-Container.types.d.ts +0 -75
  95. package/dist/src/global/A-Container/A-Container.types.js +0 -4
  96. package/dist/src/global/A-Container/A-Container.types.js.map +0 -1
  97. package/dist/src/global/A-Context/A-Context.class.d.ts +0 -361
  98. package/dist/src/global/A-Context/A-Context.class.js +0 -603
  99. package/dist/src/global/A-Context/A-Context.class.js.map +0 -1
  100. package/dist/src/global/A-Context/A-Context.error.d.ts +0 -20
  101. package/dist/src/global/A-Context/A-Context.error.js +0 -25
  102. package/dist/src/global/A-Context/A-Context.error.js.map +0 -1
  103. package/dist/src/global/A-Context/A-Context.types.d.ts +0 -5
  104. package/dist/src/global/A-Context/A-Context.types.js +0 -3
  105. package/dist/src/global/A-Context/A-Context.types.js.map +0 -1
  106. package/dist/src/global/A-Dependency/A-DependencyReference.class.d.ts +0 -0
  107. package/dist/src/global/A-Dependency/A-DependencyReference.class.js +0 -49
  108. package/dist/src/global/A-Dependency/A-DependencyReference.class.js.map +0 -1
  109. package/dist/src/global/A-Dependency/A-DependencyReference.types.d.ts +0 -0
  110. package/dist/src/global/A-Dependency/A-DependencyReference.types.js +0 -58
  111. package/dist/src/global/A-Dependency/A-DependencyReference.types.js.map +0 -1
  112. package/dist/src/global/A-Entity/A-Entity.class.d.ts +0 -214
  113. package/dist/src/global/A-Entity/A-Entity.class.js +0 -282
  114. package/dist/src/global/A-Entity/A-Entity.class.js.map +0 -1
  115. package/dist/src/global/A-Entity/A-Entity.constants.d.ts +0 -11
  116. package/dist/src/global/A-Entity/A-Entity.constants.js +0 -17
  117. package/dist/src/global/A-Entity/A-Entity.constants.js.map +0 -1
  118. package/dist/src/global/A-Entity/A-Entity.error.d.ts +0 -7
  119. package/dist/src/global/A-Entity/A-Entity.error.js +0 -12
  120. package/dist/src/global/A-Entity/A-Entity.error.js.map +0 -1
  121. package/dist/src/global/A-Entity/A-Entity.meta.d.ts +0 -11
  122. package/dist/src/global/A-Entity/A-Entity.meta.js +0 -18
  123. package/dist/src/global/A-Entity/A-Entity.meta.js.map +0 -1
  124. package/dist/src/global/A-Entity/A-Entity.types.d.ts +0 -56
  125. package/dist/src/global/A-Entity/A-Entity.types.js +0 -5
  126. package/dist/src/global/A-Entity/A-Entity.types.js.map +0 -1
  127. package/dist/src/global/A-Error/A_Error.class.d.ts +0 -229
  128. package/dist/src/global/A-Error/A_Error.class.js +0 -296
  129. package/dist/src/global/A-Error/A_Error.class.js.map +0 -1
  130. package/dist/src/global/A-Error/A_Error.constants.d.ts +0 -5
  131. package/dist/src/global/A-Error/A_Error.constants.js +0 -9
  132. package/dist/src/global/A-Error/A_Error.constants.js.map +0 -1
  133. package/dist/src/global/A-Error/A_Error.types.d.ts +0 -93
  134. package/dist/src/global/A-Error/A_Error.types.js +0 -3
  135. package/dist/src/global/A-Error/A_Error.types.js.map +0 -1
  136. package/dist/src/global/A-Feature/A-Feature-Define.decorator.d.ts +0 -15
  137. package/dist/src/global/A-Feature/A-Feature-Define.decorator.js +0 -76
  138. package/dist/src/global/A-Feature/A-Feature-Define.decorator.js.map +0 -1
  139. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.d.ts +0 -56
  140. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js +0 -128
  141. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js.map +0 -1
  142. package/dist/src/global/A-Feature/A-Feature.class.d.ts +0 -175
  143. package/dist/src/global/A-Feature/A-Feature.class.js +0 -318
  144. package/dist/src/global/A-Feature/A-Feature.class.js.map +0 -1
  145. package/dist/src/global/A-Feature/A-Feature.error.d.ts +0 -25
  146. package/dist/src/global/A-Feature/A-Feature.error.js +0 -33
  147. package/dist/src/global/A-Feature/A-Feature.error.js.map +0 -1
  148. package/dist/src/global/A-Feature/A-Feature.types.d.ts +0 -334
  149. package/dist/src/global/A-Feature/A-Feature.types.js +0 -26
  150. package/dist/src/global/A-Feature/A-Feature.types.js.map +0 -1
  151. package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +0 -36
  152. package/dist/src/global/A-Fragment/A-Fragment.class.js +0 -46
  153. package/dist/src/global/A-Fragment/A-Fragment.class.js.map +0 -1
  154. package/dist/src/global/A-Fragment/A-Fragment.types.d.ts +0 -21
  155. package/dist/src/global/A-Fragment/A-Fragment.types.js +0 -6
  156. package/dist/src/global/A-Fragment/A-Fragment.types.js.map +0 -1
  157. package/dist/src/global/A-Inject/A-Inject.decorator.d.ts +0 -80
  158. package/dist/src/global/A-Inject/A-Inject.decorator.js +0 -49
  159. package/dist/src/global/A-Inject/A-Inject.decorator.js.map +0 -1
  160. package/dist/src/global/A-Inject/A-Inject.error.d.ts +0 -5
  161. package/dist/src/global/A-Inject/A-Inject.error.js +0 -10
  162. package/dist/src/global/A-Inject/A-Inject.error.js.map +0 -1
  163. package/dist/src/global/A-Inject/A-Inject.types.d.ts +0 -42
  164. package/dist/src/global/A-Inject/A-Inject.types.js +0 -3
  165. package/dist/src/global/A-Inject/A-Inject.types.js.map +0 -1
  166. package/dist/src/global/A-Meta/A-Meta.class.d.ts +0 -97
  167. package/dist/src/global/A-Meta/A-Meta.class.js +0 -164
  168. package/dist/src/global/A-Meta/A-Meta.class.js.map +0 -1
  169. package/dist/src/global/A-Meta/A-Meta.types.d.ts +0 -14
  170. package/dist/src/global/A-Meta/A-Meta.types.js +0 -3
  171. package/dist/src/global/A-Meta/A-Meta.types.js.map +0 -1
  172. package/dist/src/global/A-Scope/A-Scope.class.d.ts +0 -466
  173. package/dist/src/global/A-Scope/A-Scope.class.js +0 -791
  174. package/dist/src/global/A-Scope/A-Scope.class.js.map +0 -1
  175. package/dist/src/global/A-Scope/A-Scope.error.d.ts +0 -8
  176. package/dist/src/global/A-Scope/A-Scope.error.js +0 -13
  177. package/dist/src/global/A-Scope/A-Scope.error.js.map +0 -1
  178. package/dist/src/global/A-Scope/A-Scope.types.d.ts +0 -81
  179. package/dist/src/global/A-Scope/A-Scope.types.js +0 -3
  180. package/dist/src/global/A-Scope/A-Scope.types.js.map +0 -1
  181. package/dist/src/global/A-Stage/A-Stage.class.d.ts +0 -112
  182. package/dist/src/global/A-Stage/A-Stage.class.js +0 -240
  183. package/dist/src/global/A-Stage/A-Stage.class.js.map +0 -1
  184. package/dist/src/global/A-Stage/A-Stage.error.d.ts +0 -4
  185. package/dist/src/global/A-Stage/A-Stage.error.js +0 -11
  186. package/dist/src/global/A-Stage/A-Stage.error.js.map +0 -1
  187. package/dist/src/global/A-Stage/A-Stage.types.d.ts +0 -101
  188. package/dist/src/global/A-Stage/A-Stage.types.js +0 -43
  189. package/dist/src/global/A-Stage/A-Stage.types.js.map +0 -1
  190. package/dist/src/global/A-StepManager/A-StepManager.class.d.ts +0 -20
  191. package/dist/src/global/A-StepManager/A-StepManager.class.js +0 -112
  192. package/dist/src/global/A-StepManager/A-StepManager.class.js.map +0 -1
  193. package/dist/src/global/A-StepManager/A-StepManager.error.d.ts +0 -4
  194. package/dist/src/global/A-StepManager/A-StepManager.error.js +0 -9
  195. package/dist/src/global/A-StepManager/A-StepManager.error.js.map +0 -1
  196. package/dist/src/global/ASEID/ASEID.class.d.ts +0 -130
  197. package/dist/src/global/ASEID/ASEID.class.js +0 -167
  198. package/dist/src/global/ASEID/ASEID.class.js.map +0 -1
  199. package/dist/src/global/ASEID/ASEID.constants.d.ts +0 -0
  200. package/dist/src/global/ASEID/ASEID.constants.js +0 -2
  201. package/dist/src/global/ASEID/ASEID.constants.js.map +0 -1
  202. package/dist/src/global/ASEID/ASEID.error.d.ts +0 -5
  203. package/dist/src/global/ASEID/ASEID.error.js +0 -10
  204. package/dist/src/global/ASEID/ASEID.error.js.map +0 -1
  205. package/dist/src/global/ASEID/ASEID.types.d.ts +0 -65
  206. package/dist/src/global/ASEID/ASEID.types.js +0 -5
  207. package/dist/src/global/ASEID/ASEID.types.js.map +0 -1
  208. package/dist/src/helpers/A_Common.helper.d.ts +0 -28
  209. package/dist/src/helpers/A_Common.helper.js +0 -170
  210. package/dist/src/helpers/A_Common.helper.js.map +0 -1
  211. package/dist/src/helpers/A_Formatter.helper.d.ts +0 -35
  212. package/dist/src/helpers/A_Formatter.helper.js +0 -62
  213. package/dist/src/helpers/A_Formatter.helper.js.map +0 -1
  214. package/dist/src/helpers/A_Identity.helper.d.ts +0 -29
  215. package/dist/src/helpers/A_Identity.helper.js +0 -43
  216. package/dist/src/helpers/A_Identity.helper.js.map +0 -1
  217. package/dist/src/helpers/A_TypeGuards.helper.d.ts +0 -207
  218. package/dist/src/helpers/A_TypeGuards.helper.js +0 -296
  219. package/dist/src/helpers/A_TypeGuards.helper.js.map +0 -1
  220. package/dist/src/types/A_Common.types.d.ts +0 -36
  221. package/dist/src/types/A_Common.types.js +0 -3
  222. package/dist/src/types/A_Common.types.js.map +0 -1
  223. package/index.ts +0 -81
  224. package/src/global/A-Dependency/A-DependencyReference.class.ts +0 -61
  225. package/src/global/A-Dependency/A-DependencyReference.types.ts +0 -61
  226. package/trace-require.js +0 -46
  227. package/tsconfig.build.json +0 -58
@@ -0,0 +1,93 @@
1
+ import { A_Component, A_Dependency, A_Entity, A_Error, A_Inject, A_Scope, A_ScopeError } from "../src";
2
+
3
+
4
+
5
+ describe('A-Dependency tests', () => {
6
+
7
+ it('Should Allow to define a dependency', async () => {
8
+
9
+ class Test extends A_Component {
10
+ constructor(
11
+ @A_Dependency.Required()
12
+ @A_Inject(A_Component) component: A_Component,
13
+ ) {
14
+ super();
15
+ expect(component).toBeInstanceOf(A_Component);
16
+ }
17
+ }
18
+ });
19
+ it('Should Resolve a component with undefined dependency', async () => {
20
+ class DependencyRequiredComponent extends A_Component { }
21
+
22
+ class Test extends A_Component {
23
+ constructor(
24
+ @A_Inject(DependencyRequiredComponent) public component?: A_Component,
25
+ ) {
26
+ super();
27
+ }
28
+ }
29
+
30
+ const scope = new A_Scope({ components: [Test] });
31
+ const instance = scope.resolve(Test);
32
+
33
+ expect(instance).toBeDefined();
34
+ expect(instance).toBeInstanceOf(Test);
35
+ expect(instance!.component).toBeUndefined();
36
+
37
+ });
38
+ it('Should throw an error if required dependency is not provided', async () => {
39
+ class DependencyRequiredComponent extends A_Component { }
40
+
41
+ class Test extends A_Component {
42
+ constructor(
43
+ @A_Dependency.Required()
44
+ @A_Inject(DependencyRequiredComponent) component: A_Component,
45
+ ) {
46
+ super();
47
+ }
48
+ }
49
+
50
+ const scope = new A_Scope({ components: [Test] });
51
+
52
+ try {
53
+ scope.resolve(Test);
54
+ } catch (error) {
55
+ expect(error).toBeInstanceOf(A_ScopeError);
56
+ expect((error as A_ScopeError).title).toBe(A_ScopeError.ResolutionError);
57
+ }
58
+
59
+ const dependency = scope.resolve(DependencyRequiredComponent);
60
+
61
+ expect(dependency).toBeUndefined();
62
+ });
63
+ it('Should resolve a component if it has default constructor for dependency', async () => {
64
+ class MyCustomEntity extends A_Entity<{ foo: string }> {
65
+ foo!: string;
66
+
67
+ fromNew(newEntity: { foo: string; }): void {
68
+ super.fromNew(newEntity);
69
+ this.foo = newEntity.foo;
70
+ }
71
+ }
72
+
73
+ class TestC extends A_Component {
74
+ constructor(
75
+ @A_Dependency.Default({ foo: 'bar' })
76
+ @A_Dependency.Required()
77
+ @A_Inject(MyCustomEntity) public component: MyCustomEntity,
78
+ ) {
79
+ super();
80
+ }
81
+ }
82
+
83
+ const scope = new A_Scope({ components: [TestC], entities: [MyCustomEntity] });
84
+
85
+ const instance = scope.resolve(TestC);
86
+
87
+ expect(instance).toBeDefined();
88
+ expect(instance).toBeInstanceOf(TestC);
89
+ expect(instance!.component).toBeInstanceOf(MyCustomEntity);
90
+ expect(instance!.component.foo).toBe('bar');
91
+ });
92
+
93
+ });
@@ -82,7 +82,7 @@ describe('A-Feature tests', () => {
82
82
  scope.register(MyComponent);
83
83
 
84
84
  // 4) create an instance of the component from the scope
85
- const myComponent = scope.resolve(MyComponent);
85
+ const myComponent = scope.resolve(MyComponent)!;
86
86
  expect(myComponent).toBeInstanceOf(MyComponent);
87
87
  expect(myComponent.sum).toBe(0);
88
88
 
@@ -129,7 +129,7 @@ describe('A-Feature tests', () => {
129
129
  scope.register(MyComponent2);
130
130
 
131
131
  // 4) create an instance of the component from the scope
132
- const myComponent = scope.resolve(MyComponent2);
132
+ const myComponent = scope.resolve(MyComponent2)!;
133
133
  expect(myComponent).toBeInstanceOf(MyComponent2);
134
134
  expect(myComponent.sum).toBe(0);
135
135
 
@@ -179,7 +179,7 @@ describe('A-Feature tests', () => {
179
179
  const scope = new A_Scope({ name: 'TestScope', components: [My_Component] });
180
180
 
181
181
  // 3) create an instance of the component from the scope
182
- const myComponent = scope.resolve(My_Component);
182
+ const myComponent = scope.resolve(My_Component)!;
183
183
  expect(myComponent).toBeInstanceOf(My_Component);
184
184
 
185
185
  // 4) call the feature caller to execute the feature
@@ -220,7 +220,7 @@ describe('A-Feature tests', () => {
220
220
  const scope = new A_Scope({ name: 'TestScope', components: [My_Component] });
221
221
 
222
222
  // 3) create an instance of the component from the scope
223
- const myComponent = scope.resolve(My_Component);
223
+ const myComponent = scope.resolve(My_Component)!;
224
224
  expect(myComponent).toBeInstanceOf(My_Component);
225
225
 
226
226
  // 4) call the feature caller to execute the feature
@@ -271,7 +271,7 @@ describe('A-Feature tests', () => {
271
271
  const scope = new A_Scope({ name: 'TestScope', components: [My_Component] });
272
272
 
273
273
  // 3) create an instance of the component from the scope
274
- const myComponent = scope.resolve(My_Component);
274
+ const myComponent = scope.resolve(My_Component)!;
275
275
  expect(myComponent).toBeInstanceOf(My_Component);
276
276
 
277
277
  // 4) call the feature caller to execute the feature
@@ -313,7 +313,7 @@ describe('A-Feature tests', () => {
313
313
  const scope = new A_Scope({ name: 'TestScope', components: [My_Child_Component] });
314
314
 
315
315
  // 3) create an instance of the component from the scope
316
- const myComponent = scope.resolve(My_Child_Component);
316
+ const myComponent = scope.resolve(My_Child_Component)!;
317
317
  expect(myComponent).toBeInstanceOf(My_Child_Component);
318
318
 
319
319
  await myComponent.feature1();
@@ -357,7 +357,7 @@ describe('A-Feature tests', () => {
357
357
  const scope = new A_Scope({ name: 'TestScope', components: [My_Child_Component] });
358
358
 
359
359
  // 3) create an instance of the component from the scope
360
- const myComponent = scope.resolve(My_Child_Component);
360
+ const myComponent = scope.resolve(My_Child_Component)!;
361
361
  expect(myComponent).toBeInstanceOf(My_Child_Component);
362
362
 
363
363
  await myComponent.feature1();
@@ -32,9 +32,10 @@ describe('A-Scope tests', () => {
32
32
  const resolved = scope.resolve(A_Component);
33
33
  expect(resolved).toBe(component);
34
34
  });
35
- it('Should return an error when resolving a non-registered component', async () => {
35
+ it('Should return an undefined when resolving a non-registered component', async () => {
36
36
  const scope = new A_Scope({ name: 'TestScope' });
37
- expect(() => scope.resolve(A_Component)).toThrowError();
37
+ const resolved = scope.resolve(A_Component);
38
+ expect(resolved).toBeUndefined();
38
39
  });
39
40
  it('Should allow to register and resolve a component with dependencies', async () => {
40
41
  class DependentComponent extends A_Component {
@@ -50,7 +51,7 @@ describe('A-Scope tests', () => {
50
51
  scope.register(component);
51
52
  scope.register(new DependentComponent(component));
52
53
 
53
- const resolved = scope.resolve(DependentComponent);
54
+ const resolved = scope.resolve(DependentComponent)!;
54
55
  expect(resolved).toBeInstanceOf(DependentComponent);
55
56
  expect(resolved.dependency).toBe(component);
56
57
  });
@@ -188,11 +189,10 @@ describe('A-Scope tests', () => {
188
189
  expect(resolved2).toBe(MyEntity);
189
190
  expect(resolved3).toBe(MyEntity);
190
191
 
191
- expect(() => {
192
- const res = scope.resolveConstructor<MyEntity>('mya__entity');
192
+ const wrongConstructor = scope.resolveConstructor<MyEntity>('mya__entity');
193
+
194
+ expect(wrongConstructor).toBeUndefined();
193
195
 
194
- console.log('RESOLVED:::: ', res)
195
- }).toThrow();
196
196
 
197
197
  const instance = new resolved();
198
198
 
@@ -221,9 +221,9 @@ describe('A-Scope tests', () => {
221
221
  expect(resolved2).toBe(MyEntity);
222
222
  expect(resolved3).toBe(MyEntity);
223
223
 
224
- expect(() => {
225
- scope.resolveConstructor<MyEntity>('myS-entity');
226
- }).toThrow();
224
+ const wrongConstructor = scope.resolveConstructor<MyEntity>('myS-entity');
225
+
226
+ expect(wrongConstructor).toBeUndefined();
227
227
 
228
228
 
229
229
  const instance = new resolved({ foo: 'bar' });
package/tsconfig.json CHANGED
@@ -50,8 +50,8 @@
50
50
  "src/**/*",
51
51
  "tests/**/*",
52
52
  "examples/**/*",
53
- "index.ts"
54
- , "../adaas-a-utils/src/lib" ],
53
+ "src/index.ts"
54
+ ],
55
55
  "exclude": [
56
56
  "node_modules/**/*",
57
57
  "dist/**/*",
package/tsup.config.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig((options) => ({
4
+ entry: ["src/index.ts"],
5
+ format: ["esm", "cjs"],
6
+ dts: true,
7
+ clean: !options.watch,
8
+ sourcemap: true,
9
+ target: "es2020",
10
+ minify: !options.watch,
11
+ treeshake: "recommended",
12
+ skipNodeModulesBundle: true,
13
+ splitting: false,
14
+ silent: false,
15
+ platform: "neutral",
16
+ // Add hash to filenames for cache busting in production builds
17
+ outExtension({ format }) {
18
+ return {
19
+ js: format === "esm" ? `.mjs` : `.cjs`,
20
+ };
21
+ },
22
+ // Extra optimization options (for 2025 esbuild)
23
+ esbuildOptions(options) {
24
+ options.keepNames = true; // Preserve class/function names for better debugging
25
+ options.charset = "utf8";
26
+ },
27
+
28
+ // Enable minification for output size (production only)
29
+ minifyWhitespace: !options.watch,
30
+ minifyIdentifiers: !options.watch,
31
+ minifySyntax: !options.watch,
32
+ }));
package/dist/index.js DELETED
@@ -1,112 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.A_TypeGuards = exports.A_StepManagerError = exports.A_StepsManager = exports.A_IdentityHelper = exports.A_FormatterHelper = exports.A_CommonHelper = exports.A_Abstraction_Extend = exports.A_Feature_Extend = exports.A_Feature_Define = exports.A_Inject = exports.A_Fragment = exports.A_Meta = exports.A_ScopeError = exports.A_Scope = exports.A_StageError = exports.A_Stage = exports.A_FeatureError = exports.A_Feature = exports.ASEID_Error = exports.ASEID = exports.A_Error = exports.A_CallerError = exports.A_Caller = exports.A_AbstractionError = exports.A_Abstraction = exports.A_Entity = exports.A_ComponentMeta = exports.A_Component = exports.A_ContainerMeta = exports.A_Container = exports.A_ConceptMeta = exports.A_Concept = exports.A_Context = void 0;
18
- // =================================================================================================
19
- // ============================= Export Framework Components =======================================
20
- // =================================================================================================
21
- __exportStar(require("./src/constants/env.constants"), exports);
22
- __exportStar(require("./src/types/A_Common.types"), exports);
23
- // ---------------------- Major Components ----------------------
24
- var A_Context_class_1 = require("./src/global/A-Context/A-Context.class");
25
- Object.defineProperty(exports, "A_Context", { enumerable: true, get: function () { return A_Context_class_1.A_Context; } });
26
- __exportStar(require("./src/global/A-Context/A-Context.types"), exports);
27
- var A_Concept_class_1 = require("./src/global/A-Concept/A-Concept.class");
28
- Object.defineProperty(exports, "A_Concept", { enumerable: true, get: function () { return A_Concept_class_1.A_Concept; } });
29
- var A_Concept_meta_1 = require("./src/global/A-Concept/A-Concept.meta");
30
- Object.defineProperty(exports, "A_ConceptMeta", { enumerable: true, get: function () { return A_Concept_meta_1.A_ConceptMeta; } });
31
- __exportStar(require("./src/global/A-Concept/A-Concept.types"), exports);
32
- var A_Container_class_1 = require("./src/global/A-Container/A-Container.class");
33
- Object.defineProperty(exports, "A_Container", { enumerable: true, get: function () { return A_Container_class_1.A_Container; } });
34
- var A_Container_meta_1 = require("./src/global/A-Container/A-Container.meta");
35
- Object.defineProperty(exports, "A_ContainerMeta", { enumerable: true, get: function () { return A_Container_meta_1.A_ContainerMeta; } });
36
- __exportStar(require("./src/global/A-Container/A-Container.class"), exports);
37
- var A_Component_class_1 = require("./src/global/A-Component/A-Component.class");
38
- Object.defineProperty(exports, "A_Component", { enumerable: true, get: function () { return A_Component_class_1.A_Component; } });
39
- var A_Component_meta_1 = require("./src/global/A-Component/A-Component.meta");
40
- Object.defineProperty(exports, "A_ComponentMeta", { enumerable: true, get: function () { return A_Component_meta_1.A_ComponentMeta; } });
41
- __exportStar(require("./src/global/A-Component/A-Component.types"), exports);
42
- var A_Entity_class_1 = require("./src/global/A-Entity/A-Entity.class");
43
- Object.defineProperty(exports, "A_Entity", { enumerable: true, get: function () { return A_Entity_class_1.A_Entity; } });
44
- __exportStar(require("./src/global/A-Entity/A-Entity.types"), exports);
45
- // ---------------------- Common Components ----------------------
46
- var A_Abstraction_class_1 = require("./src/global/A-Abstraction/A-Abstraction.class");
47
- Object.defineProperty(exports, "A_Abstraction", { enumerable: true, get: function () { return A_Abstraction_class_1.A_Abstraction; } });
48
- var A_Abstraction_error_1 = require("./src/global/A-Abstraction/A-Abstraction.error");
49
- Object.defineProperty(exports, "A_AbstractionError", { enumerable: true, get: function () { return A_Abstraction_error_1.A_AbstractionError; } });
50
- __exportStar(require("./src/global/A-Abstraction/A-Abstraction.types"), exports);
51
- var A_Caller_class_1 = require("./src/global/A-Caller/A_Caller.class");
52
- Object.defineProperty(exports, "A_Caller", { enumerable: true, get: function () { return A_Caller_class_1.A_Caller; } });
53
- var A_Caller_error_1 = require("./src/global/A-Caller/A_Caller.error");
54
- Object.defineProperty(exports, "A_CallerError", { enumerable: true, get: function () { return A_Caller_error_1.A_CallerError; } });
55
- __exportStar(require("./src/global/A-Caller/A_Caller.types"), exports);
56
- var A_Error_class_1 = require("./src/global/A-Error/A_Error.class");
57
- Object.defineProperty(exports, "A_Error", { enumerable: true, get: function () { return A_Error_class_1.A_Error; } });
58
- __exportStar(require("./src/global/A-Error/A_Error.types"), exports);
59
- var ASEID_class_1 = require("./src/global/ASEID/ASEID.class");
60
- Object.defineProperty(exports, "ASEID", { enumerable: true, get: function () { return ASEID_class_1.ASEID; } });
61
- var ASEID_error_1 = require("./src/global/ASEID/ASEID.error");
62
- Object.defineProperty(exports, "ASEID_Error", { enumerable: true, get: function () { return ASEID_error_1.ASEID_Error; } });
63
- __exportStar(require("./src/global/ASEID/ASEID.types"), exports);
64
- var A_Feature_class_1 = require("./src/global/A-Feature/A-Feature.class");
65
- Object.defineProperty(exports, "A_Feature", { enumerable: true, get: function () { return A_Feature_class_1.A_Feature; } });
66
- var A_Feature_error_1 = require("./src/global/A-Feature/A-Feature.error");
67
- Object.defineProperty(exports, "A_FeatureError", { enumerable: true, get: function () { return A_Feature_error_1.A_FeatureError; } });
68
- __exportStar(require("./src/global/A-Feature/A-Feature.types"), exports);
69
- var A_Stage_class_1 = require("./src/global/A-Stage/A-Stage.class");
70
- Object.defineProperty(exports, "A_Stage", { enumerable: true, get: function () { return A_Stage_class_1.A_Stage; } });
71
- var A_Stage_error_1 = require("./src/global/A-Stage/A-Stage.error");
72
- Object.defineProperty(exports, "A_StageError", { enumerable: true, get: function () { return A_Stage_error_1.A_StageError; } });
73
- __exportStar(require("./src/global/A-Stage/A-Stage.types"), exports);
74
- var A_Scope_class_1 = require("./src/global/A-Scope/A-Scope.class");
75
- Object.defineProperty(exports, "A_Scope", { enumerable: true, get: function () { return A_Scope_class_1.A_Scope; } });
76
- var A_Scope_error_1 = require("./src/global/A-Scope/A-Scope.error");
77
- Object.defineProperty(exports, "A_ScopeError", { enumerable: true, get: function () { return A_Scope_error_1.A_ScopeError; } });
78
- __exportStar(require("./src/global/A-Scope/A-Scope.types"), exports);
79
- var A_Meta_class_1 = require("./src/global/A-Meta/A-Meta.class");
80
- Object.defineProperty(exports, "A_Meta", { enumerable: true, get: function () { return A_Meta_class_1.A_Meta; } });
81
- __exportStar(require("./src/global/A-Meta/A-Meta.types"), exports);
82
- var A_Fragment_class_1 = require("./src/global/A-Fragment/A-Fragment.class");
83
- Object.defineProperty(exports, "A_Fragment", { enumerable: true, get: function () { return A_Fragment_class_1.A_Fragment; } });
84
- __exportStar(require("./src/global/A-Fragment/A-Fragment.types"), exports);
85
- // =================================================================================================
86
- // =============================== Export Decorators ===============================================
87
- // =================================================================================================
88
- var A_Inject_decorator_1 = require("./src/global/A-Inject/A-Inject.decorator");
89
- Object.defineProperty(exports, "A_Inject", { enumerable: true, get: function () { return A_Inject_decorator_1.A_Inject; } });
90
- __exportStar(require("./src/global/A-Inject/A-Inject.types"), exports);
91
- var A_Feature_Define_decorator_1 = require("./src/global/A-Feature/A-Feature-Define.decorator");
92
- Object.defineProperty(exports, "A_Feature_Define", { enumerable: true, get: function () { return A_Feature_Define_decorator_1.A_Feature_Define; } });
93
- var A_Feature_Extend_decorator_1 = require("./src/global/A-Feature/A-Feature-Extend.decorator");
94
- Object.defineProperty(exports, "A_Feature_Extend", { enumerable: true, get: function () { return A_Feature_Extend_decorator_1.A_Feature_Extend; } });
95
- var A_Abstraction_Extend_decorator_1 = require("./src/global/A-Abstraction/A-Abstraction-Extend.decorator");
96
- Object.defineProperty(exports, "A_Abstraction_Extend", { enumerable: true, get: function () { return A_Abstraction_Extend_decorator_1.A_Abstraction_Extend; } });
97
- // =================================================================================================
98
- // =============================== Export Helpers ================================================
99
- // =================================================================================================
100
- var A_Common_helper_1 = require("./src/helpers/A_Common.helper");
101
- Object.defineProperty(exports, "A_CommonHelper", { enumerable: true, get: function () { return A_Common_helper_1.A_CommonHelper; } });
102
- var A_Formatter_helper_1 = require("./src/helpers/A_Formatter.helper");
103
- Object.defineProperty(exports, "A_FormatterHelper", { enumerable: true, get: function () { return A_Formatter_helper_1.A_FormatterHelper; } });
104
- var A_Identity_helper_1 = require("./src/helpers/A_Identity.helper");
105
- Object.defineProperty(exports, "A_IdentityHelper", { enumerable: true, get: function () { return A_Identity_helper_1.A_IdentityHelper; } });
106
- var A_StepManager_class_1 = require("./src/global/A-StepManager/A-StepManager.class");
107
- Object.defineProperty(exports, "A_StepsManager", { enumerable: true, get: function () { return A_StepManager_class_1.A_StepsManager; } });
108
- var A_StepManager_error_1 = require("./src/global/A-StepManager/A-StepManager.error");
109
- Object.defineProperty(exports, "A_StepManagerError", { enumerable: true, get: function () { return A_StepManager_error_1.A_StepManagerError; } });
110
- var A_TypeGuards_helper_1 = require("./src/helpers/A_TypeGuards.helper");
111
- Object.defineProperty(exports, "A_TypeGuards", { enumerable: true, get: function () { return A_TypeGuards_helper_1.A_TypeGuards; } });
112
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,oGAAoG;AACpG,oGAAoG;AACpG,oGAAoG;AACpG,gEAA8C;AAC9C,6DAA2C;AAE3C,iEAAiE;AACjE,0EAAmE;AAA1D,4GAAA,SAAS,OAAA;AAClB,yEAAuD;AAEvD,0EAAmE;AAA1D,4GAAA,SAAS,OAAA;AAClB,wEAAsE;AAA7D,+GAAA,aAAa,OAAA;AACtB,yEAAuD;AAEvD,gFAAyE;AAAhE,gHAAA,WAAW,OAAA;AACpB,8EAA4E;AAAnE,mHAAA,eAAe,OAAA;AACxB,6EAA2D;AAE3D,gFAAyE;AAAhE,gHAAA,WAAW,OAAA;AACpB,8EAA4E;AAAnE,mHAAA,eAAe,OAAA;AACxB,6EAA2D;AAE3D,uEAAgE;AAAvD,0GAAA,QAAQ,OAAA;AACjB,uEAAqD;AAGrD,kEAAkE;AAClE,sFAA+E;AAAtE,oHAAA,aAAa,OAAA;AACtB,sFAAoF;AAA3E,yHAAA,kBAAkB,OAAA;AAC3B,iFAA+D;AAE/D,uEAAgE;AAAvD,0GAAA,QAAQ,OAAA;AACjB,uEAAqE;AAA5D,+GAAA,a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[!] Provided name will be used for all aseids in the application by default
8
- */
9
- readonly A_CONCEPT_NAME: "A_CONCEPT_NAME";
10
- /**
11
- * Root scope of the application
12
- *
13
- * DEFAULT value is 'root'
14
- *
15
- * [!] Provided name will be used for all aseids in the application by default
16
- */
17
- readonly A_CONCEPT_ROOT_SCOPE: "A_CONCEPT_ROOT_SCOPE";
18
- /**
19
- * Environment of the application e.g. development, production, staging
20
- */
21
- readonly A_CONCEPT_ENVIRONMENT: "A_CONCEPT_ENVIRONMENT";
22
- /**
23
- * Root folder of the application
24
- * [!] Automatically set by A-Concept when the application starts
25
- */
26
- readonly A_CONCEPT_ROOT_FOLDER: "A_CONCEPT_ROOT_FOLDER";
27
- /**
28
- * Allows to define a default error description for errors thrown without a description
29
- */
30
- readonly A_ERROR_DEFAULT_DESCRIPTION: "A_ERROR_DEFAULT_DESCRIPTION";
31
- };
32
- export type A_TYPES__ConceptENVVariables = (typeof A_CONSTANTS__DEFAULT_ENV_VARIABLES)[keyof typeof A_CONSTANTS__DEFAULT_ENV_VARIABLES][];
33
- export declare const A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY: readonly ["A_CONCEPT_NAME", "A_CONCEPT_ROOT_SCOPE", "A_CONCEPT_ENVIRONMENT", "A_CONCEPT_ROOT_FOLDER", "A_ERROR_DEFAULT_DESCRIPTION"];
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY = exports.A_CONSTANTS__DEFAULT_ENV_VARIABLES = void 0;
4
- exports.A_CONSTANTS__DEFAULT_ENV_VARIABLES = {
5
- // ----------------------------------------------------------
6
- // A-Concept Core Environment Variables
7
- // ----------------------------------------------------------
8
- // These environment variables are used by A-Concept core to configure the application
9
- // ----------------------------------------------------------
10
- /**
11
- * Name of the application
12
- *
13
- * DEFAULT value is 'a-concept'
14
- *
15
- * [!] Provided name will be used for all aseids in the application by default
16
- */
17
- A_CONCEPT_NAME: 'A_CONCEPT_NAME',
18
- /**
19
- * Root scope of the application
20
- *
21
- * DEFAULT value is 'root'
22
- *
23
- * [!] Provided name will be used for all aseids in the application by default
24
- */
25
- A_CONCEPT_ROOT_SCOPE: 'A_CONCEPT_ROOT_SCOPE',
26
- /**
27
- * Environment of the application e.g. development, production, staging
28
- */
29
- A_CONCEPT_ENVIRONMENT: 'A_CONCEPT_ENVIRONMENT',
30
- /**
31
- * Root folder of the application
32
- * [!] Automatically set by A-Concept when the application starts
33
- */
34
- A_CONCEPT_ROOT_FOLDER: 'A_CONCEPT_ROOT_FOLDER',
35
- /**
36
- * Allows to define a default error description for errors thrown without a description
37
- */
38
- A_ERROR_DEFAULT_DESCRIPTION: 'A_ERROR_DEFAULT_DESCRIPTION',
39
- };
40
- exports.A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY = [
41
- exports.A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_NAME,
42
- exports.A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_ROOT_SCOPE,
43
- exports.A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_ENVIRONMENT,
44
- exports.A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_ROOT_FOLDER,
45
- exports.A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_ERROR_DEFAULT_DESCRIPTION,
46
- ];
47
- //# sourceMappingURL=env.constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"env.constants.js","sourceRoot":"","sources":["../../../src/constants/env.constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,kCAAkC,GAAG;IAC9C,6DAA6D;IAC7D,uCAAuC;IACvC,6DAA6D;IAC7D,sFAAsF;IACtF,6DAA6D;IAC7D;;;;;;OAMG;IACH,cAAc,EAAE,gBAAgB;IAChC;;;;;;OAMG;IACH,oBAAoB,EAAE,sBAAsB;IAC5C;;OAEG;IACH,qBAAqB,EAAE,uBAAuB;IAC9C;;;OAGG;IACH,qBAAqB,EAAE,uBAAuB;IAC9C;;OAEG;IACH,2BAA2B,EAAE,6BAA6B;CACpD,CAAA;AAOG,QAAA,wCAAwC,GAAG;IACpD,0CAAkC,CAAC,cAAc;IACjD,0CAAkC,CAAC,oBAAoB;IACvD,0CAAkC,CAAC,qBAAqB;IACxD,0CAAkC,CAAC,qBAAqB;IAExD,0CAAkC,CAAC,2BAA2B;CACxD,CAAC"}
@@ -1,23 +0,0 @@
1
- import { A_TYPES__AbstractionDecoratorConfig, A_TYPES__AbstractionDecoratorDescriptor } from "./A-Abstraction.types";
2
- import { A_Component } from "../A-Component/A-Component.class";
3
- import { A_Container } from "../A-Container/A-Container.class";
4
- import { A_TYPES__ConceptAbstractions } from "../A-Concept/A-Concept.constants";
5
- /**
6
- * A-Abstraction Extend decorator allows to extends behavior of each concept abstraction execution.
7
- * In case some components or containers requires to extend the behavior of the abstraction like 'start', 'build' or 'deploy'
8
- * for example, this decorator allows to do so.
9
- *
10
- * @param name - abstraction name
11
- * @param config - configuration of the abstraction extension
12
- * @returns
13
- */
14
- export declare function A_Abstraction_Extend(
15
- /**
16
- * Name of the Concept Abstraction to extend
17
- */
18
- name: A_TYPES__ConceptAbstractions,
19
- /**
20
- * Configuration of the Abstraction Extension
21
- *
22
- */
23
- config?: Partial<A_TYPES__AbstractionDecoratorConfig>): (target: A_Container | A_Component, propertyKey: string, descriptor: A_TYPES__AbstractionDecoratorDescriptor) => void;
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.A_Abstraction_Extend = A_Abstraction_Extend;
4
- const A_Context_class_1 = require("../A-Context/A-Context.class");
5
- const A_Meta_class_1 = require("../A-Meta/A-Meta.class");
6
- const A_Container_constants_1 = require("../A-Container/A-Container.constants");
7
- const A_Component_constants_1 = require("../A-Component/A-Component.constants");
8
- const A_Abstraction_error_1 = require("./A-Abstraction.error");
9
- const A_TypeGuards_helper_1 = require("../../helpers/A_TypeGuards.helper");
10
- /**
11
- * A-Abstraction Extend decorator allows to extends behavior of each concept abstraction execution.
12
- * In case some components or containers requires to extend the behavior of the abstraction like 'start', 'build' or 'deploy'
13
- * for example, this decorator allows to do so.
14
- *
15
- * @param name - abstraction name
16
- * @param config - configuration of the abstraction extension
17
- * @returns
18
- */
19
- function A_Abstraction_Extend(
20
- /**
21
- * Name of the Concept Abstraction to extend
22
- */
23
- name,
24
- /**
25
- * Configuration of the Abstraction Extension
26
- *
27
- */
28
- config = {}) {
29
- return function (target, propertyKey, descriptor) {
30
- var _a;
31
- // for error messages
32
- const componentName = ((_a = target === null || target === void 0 ? void 0 : target.constructor) === null || _a === void 0 ? void 0 : _a.name) || String(target) || 'UnknownComponent';
33
- if (!name)
34
- throw new A_Abstraction_error_1.A_AbstractionError(A_Abstraction_error_1.A_AbstractionError.AbstractionExtensionError, `Abstraction name must be provided to extend abstraction for '${componentName}'.`);
35
- // Only Containers and Components can extend Concept Abstractions
36
- if (!A_TypeGuards_helper_1.A_TypeGuards.isConstructorAvailableForAbstraction(target)) {
37
- throw new A_Abstraction_error_1.A_AbstractionError(A_Abstraction_error_1.A_AbstractionError.AbstractionExtensionError, `Unable to extend Abstraction '${name}' for '${componentName}'. Only A-Containers and A-Components can extend Abstractions.`);
38
- }
39
- let metaKey;
40
- const meta = A_Context_class_1.A_Context.meta(target);
41
- switch (true) {
42
- case A_TypeGuards_helper_1.A_TypeGuards.isContainerConstructor(target) || A_TypeGuards_helper_1.A_TypeGuards.isContainerInstance(target):
43
- metaKey = A_Container_constants_1.A_TYPES__ContainerMetaKey.ABSTRACTIONS;
44
- break;
45
- case A_TypeGuards_helper_1.A_TypeGuards.isComponentConstructor(target) || A_TypeGuards_helper_1.A_TypeGuards.isComponentInstance(target):
46
- metaKey = A_Component_constants_1.A_TYPES__ComponentMetaKey.ABSTRACTIONS;
47
- break;
48
- }
49
- const setName = `CONCEPT_ABSTRACTION::${name}`;
50
- // Get the existed metadata or create a new one
51
- const existedMeta = meta.get(metaKey) ?
52
- new A_Meta_class_1.A_Meta().from(meta.get(metaKey))
53
- : new A_Meta_class_1.A_Meta();
54
- // Set the metadata of the method to define a custom Stage with name
55
- const existedMetaValue = [
56
- ...(existedMeta.get(setName) || [])
57
- ];
58
- const existedIndex = existedMetaValue.findIndex(item => item.handler === propertyKey);
59
- const abstraction = {
60
- name: setName,
61
- handler: propertyKey,
62
- behavior: config.behavior || 'sync',
63
- throwOnError: config.throwOnError !== undefined ? config.throwOnError : true,
64
- before: A_TypeGuards_helper_1.A_TypeGuards.isArray(config.before)
65
- ? new RegExp(`^${config.before.join('|').replace(/\./g, '\\.')}$`).source
66
- : config.before instanceof RegExp
67
- ? config.before.source
68
- : '',
69
- after: A_TypeGuards_helper_1.A_TypeGuards.isArray(config.after)
70
- ? new RegExp(`^${config.after.join('|').replace(/\./g, '\\.')}$`).source
71
- : config.after instanceof RegExp
72
- ? config.after.source
73
- : '',
74
- override: A_TypeGuards_helper_1.A_TypeGuards.isArray(config.override)
75
- ? new RegExp(`^${config.override.join('|').replace(/\./g, '\\.')}$`).source
76
- : config.after instanceof RegExp
77
- ? config.after.source
78
- : '',
79
- };
80
- if (existedIndex !== -1) {
81
- // Update the existing method in the metadata
82
- existedMetaValue[existedIndex] = abstraction;
83
- }
84
- else {
85
- // Add the new method to the metadata
86
- existedMetaValue.push(abstraction);
87
- }
88
- // Set the metadata of the method to define a custom Feature with name
89
- existedMeta.set(setName, existedMetaValue);
90
- // Update the metadata of the container with the new Stage definition
91
- A_Context_class_1.A_Context
92
- .meta(target)
93
- .set(metaKey, existedMeta);
94
- };
95
- }
96
- //# sourceMappingURL=A-Abstraction-Extend.decorator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"A-Abstraction-Extend.decorator.js","sourceRoot":"","sources":["../../../../src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts"],"names":[],"mappings":";;AA2BA,oDAuGC;AA7HD,uFAA8E;AAI9E,8EAAqE;AAErE,qGAAsG;AACtG,q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