@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
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@adaas/a-concept",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
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",
7
7
  "types": "./dist/index.d.ts",
8
+ "sideEffects": false,
8
9
  "nodemonConfig": {
9
10
  "ignore": [
10
11
  "**/*.test.ts",
@@ -23,16 +24,13 @@
23
24
  "test": "jest ",
24
25
  "start": "nodemon ./tests/example-usage.ts",
25
26
  "example:simple": "nodemon ./examples/simple/concept.ts",
26
- "example:simple:trace": "node -r tsconfig-paths/register -r ts-node/register -r ./trace-require.js ./examples/simple/concept.ts",
27
27
  "example:http": "nodemon ./examples/simple-http-server/concept.ts",
28
28
  "example:entity": "nodemon ./examples/entity/concept.ts",
29
- "example:http:trace": "node -r tsconfig-paths/register -r ts-node/register -r ./trace-require.js ./examples/simple-http-server/concept.ts",
30
29
  "publish": "npm run test && npm run build && git add . && git commit -m \"new version created :: $(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g')\" && npm version patch && npm publish --access public",
31
- "preversion": "echo test",
32
30
  "version": "echo git add .",
33
31
  "postversion": "git push --no-verify && git push --tags --no-verify && echo \"\n======Version Pushed Successfully=====\n\" ",
34
32
  "echo-version": "echo $npm_package_version",
35
- "build": "rm -rf ./dist && tsc --declaration --project tsconfig.build.json && tscpaths -p tsconfig.build.json -s ./ -o ./dist",
33
+ "build": "tsup --config tsup.config.ts",
36
34
  "test:simple": "nodemon ./examples/simple/concept.ts"
37
35
  },
38
36
  "repository": {
@@ -63,7 +61,8 @@
63
61
  "ts-jest": "^29.1.2",
64
62
  "ts-node": "^10.9.2",
65
63
  "tsconfig-paths": "^4.2.0",
66
- "tscpaths": "^0.0.9"
64
+ "tscpaths": "^0.0.9",
65
+ "tsup": "^8.5.0"
67
66
  },
68
67
  "directories": {
69
68
  "doc": "docs",
@@ -14,6 +14,7 @@ import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A
14
14
  import { A_TYPES__ConceptAbstraction } from "@adaas/a-concept/global/A-Concept/A-Concept.types";
15
15
  import { A_AbstractionError } from "./A-Abstraction.error";
16
16
  import { A_TypeGuards } from "@adaas/a-concept/helpers/A_TypeGuards.helper";
17
+ import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
17
18
 
18
19
 
19
20
  /**
@@ -42,7 +43,7 @@ export function A_Abstraction_Extend(
42
43
  descriptor: A_TYPES__AbstractionDecoratorDescriptor
43
44
  ) {
44
45
  // for error messages
45
- const componentName = (target as any)?.constructor?.name || String(target) || 'UnknownComponent';
46
+ const componentName = A_CommonHelper.getComponentName(target)
46
47
 
47
48
  if (!name)
48
49
  throw new A_AbstractionError(
@@ -37,6 +37,7 @@ import { A_Fragment } from "../A-Fragment/A-Fragment.class";
37
37
  import { A_TYPES__InjectableTargets } from "../A-Inject/A-Inject.types";
38
38
  import { A_TYPES__ConceptAbstraction } from "../A-Concept/A-Concept.types";
39
39
  import { A_TYPES__ConceptAbstractions } from "../A-Concept/A-Concept.constants";
40
+ import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
40
41
 
41
42
 
42
43
 
@@ -172,16 +173,18 @@ export class A_Context {
172
173
 
173
174
  ): A_Scope {
174
175
  // uses only for error messages
175
- const componentName = (component as any)?.constructor?.name || String(component);
176
+ const componentName = A_CommonHelper.getComponentName(component);
176
177
 
177
178
  const instance = this.getInstance();
178
179
 
179
180
  if (!component) throw new A_ContextError(
180
181
  A_ContextError.InvalidRegisterParameterError,
181
182
  `Unable to register component. Component cannot be null or undefined.`);
183
+
182
184
  if (!scope) throw new A_ContextError(
183
185
  A_ContextError.InvalidRegisterParameterError,
184
186
  `Unable to register component. Scope cannot be null or undefined.`);
187
+
185
188
  if (!this.isAllowedToBeRegistered(component)) throw new A_ContextError(
186
189
  A_ContextError.NotAllowedForScopeAllocationError,
187
190
  `Component ${componentName} is not allowed for scope allocation.`);
@@ -191,6 +194,32 @@ export class A_Context {
191
194
  return scope;
192
195
  }
193
196
 
197
+ /**
198
+ * Deregister method allows to deregister a component from the context.
199
+ *
200
+ * @param component - Component to deregister from the context.
201
+ */
202
+ static deregister(
203
+ /**
204
+ * Provide a component that needs to be deregistered from the context.
205
+ */
206
+ component: A_TYPES_ScopeDependentComponents,
207
+ ): void {
208
+ // uses only for error messages
209
+ const componentName = A_CommonHelper.getComponentName(component);
210
+
211
+ const instance = this.getInstance();
212
+
213
+ if (!component) throw new A_ContextError(
214
+ A_ContextError.InvalidDeregisterParameterError,
215
+ `Unable to deregister component. Component cannot be null or undefined.`);
216
+
217
+ if (!instance._scopeStorage.has(component)) throw new A_ContextError(
218
+ A_ContextError.ComponentNotRegisteredError,
219
+ `Unable to deregister component. Component ${componentName} is not registered.`);
220
+
221
+ instance._scopeStorage.delete(component);
222
+ }
194
223
 
195
224
  /**
196
225
  * Allocate method instantiates a new scope for the given component and registers it in the context.
@@ -231,7 +260,7 @@ export class A_Context {
231
260
  importing?: Partial<A_TYPES__Scope_Init & A_TYPES__ScopeConfig> | A_Scope
232
261
  ): A_Scope {
233
262
  // uses only for error messages
234
- const componentName = (component as any)?.constructor?.name || String(component);
263
+ const componentName = A_CommonHelper.getComponentName(component);
235
264
 
236
265
  // ---------------------------------------------------------------------
237
266
  // ----------------------Input Validation-------------------------------
@@ -266,6 +295,51 @@ export class A_Context {
266
295
  return newScope;
267
296
  }
268
297
 
298
+ /**
299
+ * Deallocate method removes the scope allocation for the given component from the context.
300
+ *
301
+ * @param component
302
+ * @returns
303
+ */
304
+ static deallocate(
305
+ /**
306
+ * A Scope that needs to be deallocated.
307
+ */
308
+ scope: A_Scope,
309
+ )
310
+ static deallocate(
311
+ /**
312
+ * Provide a component that needs to have its scope deallocated.
313
+ */
314
+ component: A_TYPES__ScopeLinkedComponents,
315
+ )
316
+ static deallocate(
317
+ /**
318
+ * Provide a component that needs to have its scope deallocated.
319
+ */
320
+ param1: A_TYPES__ScopeLinkedComponents | A_Scope,
321
+ ) {
322
+ const instance = this.getInstance();
323
+
324
+
325
+ const scope = A_TypeGuards.isScopeInstance(param1)
326
+ ? param1
327
+ : instance._registry.get(param1);
328
+
329
+ if (!scope) return;
330
+
331
+ try {
332
+ const component = A_TypeGuards.isComponentInstance(param1)
333
+ ? param1
334
+ : this.issuer(scope);
335
+
336
+ instance._registry.delete(component);
337
+ instance._scopeIssuers.delete(scope);
338
+ } catch (error) {
339
+ return
340
+ }
341
+ }
342
+
269
343
 
270
344
 
271
345
  /**
@@ -338,7 +412,7 @@ export class A_Context {
338
412
  ): A_Meta<T> {
339
413
 
340
414
  // Get the component name for error messages
341
- const componentName = (param1 as any)?.constructor?.name || String(param1);
415
+ const componentName = A_CommonHelper.getComponentName(param1);
342
416
  // Get the instance of the context
343
417
  const instance = this.getInstance();
344
418
 
@@ -581,7 +655,7 @@ export class A_Context {
581
655
  scope: A_Scope = this.scope(component)
582
656
  ): Array<A_TYPES__A_StageStep> {
583
657
  // name for error messages
584
- const componentName = (component as any)?.constructor?.name || String(component);
658
+ const componentName = A_CommonHelper.getComponentName(component);
585
659
 
586
660
  // Input validation
587
661
  if (!component) throw new A_ContextError(A_ContextError.InvalidFeatureTemplateParameterError, `Unable to get feature template. Component cannot be null or undefined.`);
@@ -629,7 +703,7 @@ export class A_Context {
629
703
 
630
704
  const instance = this.getInstance();
631
705
  // name for error messages
632
- const componentName = (component as any)?.constructor?.name || String(component);
706
+ const componentName = A_CommonHelper.getComponentName(component);
633
707
 
634
708
  // Input validation
635
709
  if (!component) throw new A_ContextError(A_ContextError.InvalidFeatureExtensionParameterError, `Unable to get feature template. Component cannot be null or undefined.`);
@@ -779,7 +853,7 @@ export class A_Context {
779
853
  component: A_TYPES__FeatureAvailableComponents,
780
854
  ): Array<A_TYPES__A_StageStep> {
781
855
  // name for error messages
782
- const componentName = (component as any)?.constructor?.name || String(component);
856
+ const componentName = (A_CommonHelper.getComponentName(component));
783
857
 
784
858
  // Input validation
785
859
  if (!component) throw new A_ContextError(
@@ -822,7 +896,7 @@ export class A_Context {
822
896
  ): Array<A_TYPES__A_StageStep> {
823
897
  const instance = this.getInstance();
824
898
  // name for error messages
825
- const componentName = (component as any)?.constructor?.name || String(component);
899
+ const componentName = A_CommonHelper.getComponentName(component);
826
900
 
827
901
  // Input validation
828
902
  if (!component) throw new A_ContextError(
@@ -41,4 +41,8 @@ export class A_ContextError extends A_Error {
41
41
 
42
42
 
43
43
  static InvalidComponentParameterError = 'Invalid component provided';
44
+
45
+ static ComponentNotRegisteredError = 'Component not registered in the context';
46
+
47
+ static InvalidDeregisterParameterError = 'Invalid parameter provided to deregister component';
44
48
  }
@@ -0,0 +1,75 @@
1
+
2
+ import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
3
+ import { A_Meta } from "@adaas/a-concept/global/A-Meta/A-Meta.class";
4
+ import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.constants";
5
+ import { A_TYPES__ContainerMetaKey } from "@adaas/a-concept/global/A-Container/A-Container.constants";
6
+ import { A_TypeGuards } from "@adaas/a-concept/helpers/A_TypeGuards.helper";
7
+ import { A_TYPES__A_InjectDecorator_Meta, A_TYPES__InjectableTargets } from "../A-Inject/A-Inject.types";
8
+ import { A_TYPES__A_Dependency_DefaultDecoratorReturn } from "./A-Dependency.types";
9
+ import { A_DependencyError } from "./A-Dependency.error";
10
+ import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
11
+
12
+
13
+ /**
14
+ * Should indicate which Default is required
15
+ */
16
+ export function A_Dependency_Default(
17
+ /**
18
+ * Constructor Parameters that will be used to create the default instance
19
+ */
20
+ ...args: any[]
21
+ ): A_TYPES__A_Dependency_DefaultDecoratorReturn {
22
+
23
+
24
+ return function (
25
+ target: A_TYPES__InjectableTargets,
26
+ methodName: string | symbol | undefined,
27
+ parameterIndex: number
28
+ ) {
29
+ // for Error handling purposes
30
+ const componentName = A_CommonHelper.getComponentName(target)
31
+
32
+ if (!A_TypeGuards.isTargetAvailableForInjection(target)) {
33
+ throw new A_DependencyError(
34
+ A_DependencyError.InvalidDefaultTarget,
35
+ `A-Default cannot be used on the target of type ${typeof target} (${componentName})`
36
+ );
37
+ }
38
+
39
+ // determine the method name or 'constructor' for constructor injections
40
+ const method = methodName ? String(methodName) : 'constructor';
41
+ let metaKey;
42
+
43
+ switch (true) {
44
+ case A_TypeGuards.isComponentConstructor(target) || A_TypeGuards.isComponentInstance(target):
45
+ metaKey = A_TYPES__ComponentMetaKey.INJECTIONS;
46
+ break;
47
+
48
+ case A_TypeGuards.isContainerInstance(target):
49
+ metaKey = A_TYPES__ContainerMetaKey.INJECTIONS;
50
+ break;
51
+ }
52
+
53
+ // get existing meta or create a new one
54
+ const existedMeta = A_Context.meta(target).get(metaKey) || new A_Meta();
55
+ // get existing injections for the method or create a new array
56
+ const paramsArray: A_TYPES__A_InjectDecorator_Meta = existedMeta.get(method) || [];
57
+
58
+ // set the parameter injection info
59
+ paramsArray[parameterIndex] = {
60
+ ...(paramsArray[parameterIndex] || {}),
61
+ defaultArgs: args,
62
+ create: true
63
+ }
64
+ // save back the updated injections array
65
+ existedMeta.set(method, paramsArray);
66
+
67
+ // save back the updated meta info
68
+ A_Context
69
+ .meta(target)
70
+ .set(
71
+ metaKey,
72
+ existedMeta
73
+ );
74
+ }
75
+ }
@@ -0,0 +1,80 @@
1
+
2
+ import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
3
+ import { A_Meta } from "@adaas/a-concept/global/A-Meta/A-Meta.class";
4
+ import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.constants";
5
+ import { A_TYPES__ContainerMetaKey } from "@adaas/a-concept/global/A-Container/A-Container.constants";
6
+ import { A_TypeGuards } from "@adaas/a-concept/helpers/A_TypeGuards.helper";
7
+ import { A_TYPES__A_InjectDecorator_Meta, A_TYPES__InjectableTargets } from "../A-Inject/A-Inject.types";
8
+ import { A_TYPES__A_Dependency_LoadDecoratorReturn } from "./A-Dependency.types";
9
+ import { A_DependencyError } from "./A-Dependency.error";
10
+ import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
11
+
12
+
13
+ /**
14
+ * Should indicate which Load is required
15
+ */
16
+ export function A_Dependency_Load(
17
+ /**
18
+ * Path to load the dependency from
19
+ */
20
+ path: string
21
+ ): A_TYPES__A_Dependency_LoadDecoratorReturn {
22
+
23
+ if (!path || typeof path !== 'string') {
24
+ throw new A_DependencyError(
25
+ A_DependencyError.InvalidLoadPath,
26
+ `A-Load decorator requires a valid path string to the dependency`
27
+ );
28
+ }
29
+
30
+ return function (
31
+ target: A_TYPES__InjectableTargets,
32
+ methodName: string | symbol | undefined,
33
+ parameterIndex: number
34
+ ) {
35
+ // for Error handling purposes
36
+ const componentName = A_CommonHelper.getComponentName(target);
37
+
38
+ if (!A_TypeGuards.isTargetAvailableForInjection(target)) {
39
+ throw new A_DependencyError(
40
+ A_DependencyError.InvalidLoadTarget,
41
+ `A-Load cannot be used on the target of type ${typeof target} (${componentName})`
42
+ );
43
+ }
44
+
45
+ // determine the method name or 'constructor' for constructor injections
46
+ const method = methodName ? String(methodName) : 'constructor';
47
+ let metaKey;
48
+
49
+ switch (true) {
50
+ case A_TypeGuards.isComponentConstructor(target) || A_TypeGuards.isComponentInstance(target):
51
+ metaKey = A_TYPES__ComponentMetaKey.INJECTIONS;
52
+ break;
53
+
54
+ case A_TypeGuards.isContainerInstance(target):
55
+ metaKey = A_TYPES__ContainerMetaKey.INJECTIONS;
56
+ break;
57
+ }
58
+
59
+ // get existing meta or create a new one
60
+ const existedMeta = A_Context.meta(target).get(metaKey) || new A_Meta();
61
+ // get existing injections for the method or create a new array
62
+ const paramsArray: A_TYPES__A_InjectDecorator_Meta = existedMeta.get(method) || [];
63
+
64
+ // set the parameter injection info
65
+ paramsArray[parameterIndex] = {
66
+ ...(paramsArray[parameterIndex] || {}),
67
+ load: path
68
+ }
69
+ // save back the updated injections array
70
+ existedMeta.set(method, paramsArray);
71
+
72
+ // save back the updated meta info
73
+ A_Context
74
+ .meta(target)
75
+ .set(
76
+ metaKey,
77
+ existedMeta
78
+ );
79
+ }
80
+ }
@@ -0,0 +1,68 @@
1
+
2
+ import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
3
+ import { A_Meta } from "@adaas/a-concept/global/A-Meta/A-Meta.class";
4
+ import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.constants";
5
+ import { A_TYPES__ContainerMetaKey } from "@adaas/a-concept/global/A-Container/A-Container.constants";
6
+ import { A_TypeGuards } from "@adaas/a-concept/helpers/A_TypeGuards.helper";
7
+ import { A_TYPES__A_InjectDecorator_Meta, A_TYPES__InjectableTargets } from "../A-Inject/A-Inject.types";
8
+ import { A_TYPES__A_Dependency_RequireDecoratorReturn } from "./A-Dependency.types";
9
+ import { A_DependencyError } from "./A-Dependency.error";
10
+ import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
11
+
12
+
13
+ /**
14
+ * Should indicate which dependency is required
15
+ */
16
+ export function A_Dependency_Require(): A_TYPES__A_Dependency_RequireDecoratorReturn {
17
+
18
+ return function (
19
+ target: A_TYPES__InjectableTargets,
20
+ methodName: string | symbol | undefined,
21
+ parameterIndex: number
22
+ ) {
23
+ // for Error handling purposes
24
+ const componentName = A_CommonHelper.getComponentName(target)
25
+
26
+ if (!A_TypeGuards.isTargetAvailableForInjection(target)) {
27
+ throw new A_DependencyError(
28
+ A_DependencyError.InvalidDependencyTarget,
29
+ `A-Dependency cannot be used on the target of type ${typeof target} (${componentName})`
30
+ );
31
+ }
32
+
33
+ // determine the method name or 'constructor' for constructor injections
34
+ const method = methodName ? String(methodName) : 'constructor';
35
+ let metaKey;
36
+
37
+ switch (true) {
38
+ case A_TypeGuards.isComponentConstructor(target) || A_TypeGuards.isComponentInstance(target):
39
+ metaKey = A_TYPES__ComponentMetaKey.INJECTIONS;
40
+ break;
41
+
42
+ case A_TypeGuards.isContainerInstance(target):
43
+ metaKey = A_TYPES__ContainerMetaKey.INJECTIONS;
44
+ break;
45
+ }
46
+
47
+ // get existing meta or create a new one
48
+ const existedMeta = A_Context.meta(target).get(metaKey) || new A_Meta();
49
+ // get existing injections for the method or create a new array
50
+ const paramsArray: A_TYPES__A_InjectDecorator_Meta = existedMeta.get(method) || [];
51
+
52
+ // set the parameter injection info
53
+ paramsArray[parameterIndex] = {
54
+ ...(paramsArray[parameterIndex] || {}),
55
+ require: true
56
+ }
57
+ // save back the updated injections array
58
+ existedMeta.set(method, paramsArray);
59
+
60
+ // save back the updated meta info
61
+ A_Context
62
+ .meta(target)
63
+ .set(
64
+ metaKey,
65
+ existedMeta
66
+ );
67
+ }
68
+ }
@@ -0,0 +1,33 @@
1
+ import { A_Dependency_Default } from "./A-Dependency-Default.decorator";
2
+ import { A_Dependency_Load } from "./A-Dependency-Load.decorator";
3
+ import { A_Dependency_Require } from "./A-Dependency-Require.decorator";
4
+
5
+
6
+ export class A_Dependency {
7
+ /**
8
+ * Allows to indicate which Injected parameter is required
9
+ *
10
+ * [!] If parameter marked as required is not provided, an error will be thrown
11
+ *
12
+ * @returns
13
+ */
14
+ static get Required(): typeof A_Dependency_Require {
15
+ return A_Dependency_Require;
16
+ }
17
+ /**
18
+ * Allows to indicate which dependency should be loaded from a specific path
19
+ *
20
+ * @returns
21
+ */
22
+ static get Loaded(): typeof A_Dependency_Load {
23
+ return A_Dependency_Load;
24
+ }
25
+ /**
26
+ * Allows to indicate which dependency default parameters should be used
27
+ *
28
+ * @returns
29
+ */
30
+ static get Default(): typeof A_Dependency_Default {
31
+ return A_Dependency_Default;
32
+ }
33
+ }
@@ -0,0 +1,13 @@
1
+ import { A_Error } from "../A-Error/A_Error.class";
2
+
3
+ export class A_DependencyError extends A_Error {
4
+
5
+ static readonly InvalidDependencyTarget = 'Invalid Dependency Target';
6
+
7
+ static readonly InvalidLoadTarget = 'Invalid Load Target';
8
+
9
+ static readonly InvalidLoadPath = 'Invalid Load Path';
10
+
11
+
12
+ static readonly InvalidDefaultTarget = 'Invalid Default Target';
13
+ }
@@ -0,0 +1,28 @@
1
+
2
+
3
+ /**
4
+ * A-Dependency require decorator return type
5
+ */
6
+ export type A_TYPES__A_Dependency_RequireDecoratorReturn<T = any> = (
7
+ target: T,
8
+ propertyKey: string | symbol | undefined,
9
+ parameterIndex: number
10
+ ) => void
11
+
12
+ /**
13
+ * A-Dependency load decorator return type
14
+ */
15
+ export type A_TYPES__A_Dependency_LoadDecoratorReturn<T = any> = (
16
+ target: T,
17
+ propertyKey: string | symbol | undefined,
18
+ parameterIndex: number
19
+ ) => void
20
+
21
+ /**
22
+ * A-Dependency default decorator return type
23
+ */
24
+ export type A_TYPES__A_Dependency_DefaultDecoratorReturn<T = any> = (
25
+ target: T,
26
+ propertyKey: string | symbol | undefined,
27
+ parameterIndex: number
28
+ ) => void
@@ -14,6 +14,7 @@ import { A_TYPES__ContainerMetaKey } from "@adaas/a-concept/global/A-Container/A
14
14
  import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.constants";
15
15
  import { A_TypeGuards } from "@adaas/a-concept/helpers/A_TypeGuards.helper";
16
16
  import { A_FeatureError } from "./A-Feature.error";
17
+ import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
17
18
 
18
19
  /**
19
20
  * A-Feature decorator
@@ -37,7 +38,7 @@ export function A_Feature_Define(
37
38
  descriptor: A_TYPES__FeatureDefineDecoratorDescriptor
38
39
  ) {
39
40
  // for error messages
40
- const componentName = (target as any)?.constructor?.name || String(target) || 'Unknown';
41
+ const componentName = A_CommonHelper.getComponentName(target)
41
42
 
42
43
 
43
44
  if (!A_TypeGuards.isAllowedForFeatureDefinition(target))
@@ -4,6 +4,7 @@ import { A_TYPES__FeatureExtendDecoratorConfig, A_TYPES__FeatureExtendDecoratorD
4
4
  import { A_TypeGuards } from "@adaas/a-concept/helpers/A_TypeGuards.helper";
5
5
  import { A_TYPES__ComponentMetaKey } from "../A-Component/A-Component.constants";
6
6
  import { A_FeatureError } from "./A-Feature.error";
7
+ import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
7
8
 
8
9
 
9
10
 
@@ -64,7 +65,7 @@ export function A_Feature_Extend(
64
65
  descriptor: A_TYPES__FeatureExtendDecoratorDescriptor
65
66
  ) {
66
67
  // for error messages
67
- const componentName = (target as any)?.constructor?.name || String(target) || 'Unknown';
68
+ const componentName = A_CommonHelper.getComponentName(target)
68
69
 
69
70
  if (!A_TypeGuards.isAllowedForFeatureExtension(target))
70
71
  throw new A_FeatureError(
@@ -135,6 +135,12 @@ export class A_Feature<T extends A_TYPES__FeatureAvailableComponents = A_TYPES__
135
135
  * The Scope allocated for the Feature Execution
136
136
  */
137
137
  get scope(): A_Scope { return A_Context.scope(this); }
138
+ /**
139
+ * The number of stages in the feature
140
+ */
141
+ get size(): number {
142
+ return this._stages.length;
143
+ }
138
144
 
139
145
  /**
140
146
  * This method checks if the A-Feature is done
@@ -357,7 +363,10 @@ export class A_Feature<T extends A_TYPES__FeatureAvailableComponents = A_TYPES__
357
363
  * @returns
358
364
  */
359
365
  async completed(): Promise<void> {
366
+
360
367
  this._state = A_TYPES__FeatureState.COMPLETED;
368
+
369
+ this.scope.destroy();
361
370
  }
362
371
  /**
363
372
  * This method marks the feature as failed and throws an error
@@ -390,6 +399,8 @@ export class A_Feature<T extends A_TYPES__FeatureAvailableComponents = A_TYPES__
390
399
  }
391
400
 
392
401
  this._state = A_TYPES__FeatureState.INTERRUPTED;
402
+
403
+ this.scope.destroy();
393
404
  }
394
405
 
395
406
 
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  A_TYPES__A_InjectDecorator_EntityInjectionInstructions,
3
+ A_TYPES__A_InjectDecorator_Meta,
3
4
  A_TYPES__A_InjectDecoratorReturn,
4
5
  A_TYPES__InjectableConstructors,
5
6
  A_TYPES__InjectableTargets
@@ -21,6 +22,7 @@ import { A_TYPES__Fragment_Constructor } from "@adaas/a-concept/global/A-Fragmen
21
22
  import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
22
23
  import { A_TYPES__Scope_Constructor } from "@adaas/a-concept/global/A-Scope/A-Scope.types";
23
24
  import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
25
+ import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
24
26
 
25
27
 
26
28
  /**
@@ -120,7 +122,7 @@ export function A_Inject(
120
122
  parameterIndex: number
121
123
  ) {
122
124
  // for Error handling purposes
123
- const componentName = (target as any).name || (target.constructor && (target.constructor as any).name);
125
+ const componentName = A_CommonHelper.getComponentName(target)
124
126
 
125
127
  if (!A_TypeGuards.isTargetAvailableForInjection(target)) {
126
128
  throw new A_InjectError(
@@ -146,7 +148,7 @@ export function A_Inject(
146
148
  // get existing meta or create a new one
147
149
  const existedMeta = A_Context.meta(target).get(metaKey) || new A_Meta();
148
150
  // get existing injections for the method or create a new array
149
- const paramsArray = existedMeta.get(method) || [];
151
+ const paramsArray: A_TYPES__A_InjectDecorator_Meta = existedMeta.get(method) || [];
150
152
 
151
153
  // set the parameter injection info
152
154
  paramsArray[parameterIndex] = {
@@ -32,9 +32,11 @@ export type A_TYPES__A_InjectDecoratorReturn<T = any> = (
32
32
 
33
33
  export type A_TYPES__A_InjectDecorator_Meta = Array<{
34
34
  target: A_TYPES__InjectableConstructors
35
- } | {
36
- target: A_TYPES__Entity_Constructor,
37
- instructions: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>
35
+ require?: boolean
36
+ load?: string
37
+ defaultArgs?: any,
38
+ create?: boolean
39
+ instructions?: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>,
38
40
  }>;
39
41
 
40
42
  /**