@adaas/a-concept 0.0.64 → 0.1.1

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 (416) hide show
  1. package/dist/index.d.ts +24 -32
  2. package/dist/index.js +35 -52
  3. package/dist/index.js.map +1 -1
  4. package/dist/src/constants/env.constants.d.ts +15 -8
  5. package/dist/src/constants/env.constants.js +17 -10
  6. package/dist/src/constants/env.constants.js.map +1 -1
  7. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.d.ts +23 -0
  8. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js +69 -0
  9. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js.map +1 -0
  10. package/dist/src/global/A-Abstraction/A-Abstraction.class.d.ts +47 -20
  11. package/dist/src/global/A-Abstraction/A-Abstraction.class.js +55 -48
  12. package/dist/src/global/A-Abstraction/A-Abstraction.class.js.map +1 -1
  13. package/dist/src/global/A-Abstraction/A-Abstraction.error.d.ts +7 -0
  14. package/dist/src/global/A-Abstraction/A-Abstraction.error.js +12 -0
  15. package/dist/src/global/A-Abstraction/A-Abstraction.error.js.map +1 -0
  16. package/dist/src/global/A-Abstraction/A-Abstraction.types.d.ts +27 -12
  17. package/dist/src/global/A-Abstraction/A-Abstraction.types.js +0 -8
  18. package/dist/src/global/A-Abstraction/A-Abstraction.types.js.map +1 -1
  19. package/dist/src/global/A-Caller/A_Caller.class.d.ts +33 -0
  20. package/dist/src/global/A-Caller/A_Caller.class.js +44 -0
  21. package/dist/src/global/A-Caller/A_Caller.class.js.map +1 -0
  22. package/dist/src/global/A-Caller/A_Caller.error.d.ts +7 -0
  23. package/dist/src/global/A-Caller/A_Caller.error.js +12 -0
  24. package/dist/src/global/A-Caller/A_Caller.error.js.map +1 -0
  25. package/dist/src/global/A-Caller/A_Caller.types.d.ts +18 -0
  26. package/dist/src/{base/A-Errors/A-Errors.types.js → global/A-Caller/A_Caller.types.js} +1 -1
  27. package/dist/src/global/A-Caller/A_Caller.types.js.map +1 -0
  28. package/dist/src/global/A-Component/A-Component.class.d.ts +20 -3
  29. package/dist/src/global/A-Component/A-Component.class.js +35 -19
  30. package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
  31. package/dist/src/global/A-Component/A-Component.constants.d.ts +6 -0
  32. package/dist/src/global/A-Component/A-Component.constants.js +11 -0
  33. package/dist/src/global/A-Component/A-Component.constants.js.map +1 -0
  34. package/dist/src/global/A-Component/A-Component.meta.d.ts +4 -4
  35. package/dist/src/global/A-Component/A-Component.meta.js +6 -8
  36. package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
  37. package/dist/src/global/A-Component/A-Component.types.d.ts +40 -22
  38. package/dist/src/global/A-Component/A-Component.types.js +1 -8
  39. package/dist/src/global/A-Component/A-Component.types.js.map +1 -1
  40. package/dist/src/global/A-Concept/A-Concept.class.d.ts +153 -0
  41. package/dist/src/global/A-Concept/A-Concept.class.js +260 -0
  42. package/dist/src/global/A-Concept/A-Concept.class.js.map +1 -0
  43. package/dist/src/global/A-Concept/A-Concept.constants.d.ts +33 -0
  44. package/dist/src/global/A-Concept/A-Concept.constants.js +39 -0
  45. package/dist/src/global/A-Concept/A-Concept.constants.js.map +1 -0
  46. package/dist/src/global/A-Concept/{A_Concept.meta.js → A-Concept.meta.js} +1 -2
  47. package/dist/src/global/A-Concept/A-Concept.meta.js.map +1 -0
  48. package/dist/src/global/A-Concept/A-Concept.types.d.ts +83 -0
  49. package/dist/src/global/{A-Channel/A-Channel.types.js → A-Concept/A-Concept.types.js} +1 -1
  50. package/dist/src/global/A-Concept/A-Concept.types.js.map +1 -0
  51. package/dist/src/global/A-Container/A-Container.class.d.ts +31 -35
  52. package/dist/src/global/A-Container/A-Container.class.js +34 -55
  53. package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
  54. package/dist/src/global/A-Container/A-Container.constants.d.ts +5 -0
  55. package/dist/src/global/A-Container/A-Container.constants.js +10 -0
  56. package/dist/src/global/A-Container/A-Container.constants.js.map +1 -0
  57. package/dist/src/global/A-Container/A-Container.meta.d.ts +6 -6
  58. package/dist/src/global/A-Container/A-Container.meta.js +5 -6
  59. package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
  60. package/dist/src/global/A-Container/A-Container.types.d.ts +31 -25
  61. package/dist/src/global/A-Container/A-Container.types.js +1 -7
  62. package/dist/src/global/A-Container/A-Container.types.js.map +1 -1
  63. package/dist/src/global/A-Context/A-Context.class.d.ts +302 -76
  64. package/dist/src/global/A-Context/A-Context.class.js +436 -244
  65. package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
  66. package/dist/src/global/A-Context/A-Context.error.d.ts +20 -0
  67. package/dist/src/global/A-Context/A-Context.error.js +25 -0
  68. package/dist/src/global/A-Context/A-Context.error.js.map +1 -0
  69. package/dist/src/global/A-Context/A-Context.types.d.ts +5 -0
  70. package/dist/src/global/A-Context/A-Context.types.js +1 -0
  71. package/dist/src/global/A-Entity/A-Entity.class.d.ts +18 -18
  72. package/dist/src/global/A-Entity/A-Entity.class.js +36 -43
  73. package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
  74. package/dist/src/global/A-Entity/A-Entity.constants.d.ts +11 -0
  75. package/dist/src/global/A-Entity/A-Entity.constants.js +17 -0
  76. package/dist/src/global/A-Entity/A-Entity.constants.js.map +1 -0
  77. package/dist/src/global/A-Entity/A-Entity.error.d.ts +7 -0
  78. package/dist/src/global/A-Entity/A-Entity.error.js +12 -0
  79. package/dist/src/global/A-Entity/A-Entity.error.js.map +1 -0
  80. package/dist/src/global/A-Entity/A-Entity.meta.d.ts +2 -2
  81. package/dist/src/global/A-Entity/A-Entity.meta.js +2 -2
  82. package/dist/src/global/A-Entity/A-Entity.meta.js.map +1 -1
  83. package/dist/src/global/A-Entity/A-Entity.types.d.ts +24 -29
  84. package/dist/src/global/A-Entity/A-Entity.types.js +1 -13
  85. package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -1
  86. package/dist/src/global/A-Error/A_Error.class.d.ts +219 -0
  87. package/dist/src/global/A-Error/A_Error.class.js +267 -0
  88. package/dist/src/global/A-Error/A_Error.class.js.map +1 -0
  89. package/dist/src/global/A-Error/A_Error.constants.d.ts +5 -0
  90. package/dist/src/global/A-Error/A_Error.constants.js +9 -0
  91. package/dist/src/global/A-Error/A_Error.constants.js.map +1 -0
  92. package/dist/src/global/A-Error/A_Error.types.d.ts +89 -0
  93. package/dist/src/{decorators/A-Inject/A-Inject.decorator.types.js → global/A-Error/A_Error.types.js} +1 -1
  94. package/dist/src/global/A-Error/A_Error.types.js.map +1 -0
  95. package/dist/src/global/A-Feature/A-Feature-Define.decorator.d.ts +15 -0
  96. package/dist/src/{decorators → global}/A-Feature/A-Feature-Define.decorator.js +21 -27
  97. package/dist/src/global/A-Feature/A-Feature-Define.decorator.js.map +1 -0
  98. package/dist/src/{decorators → global}/A-Feature/A-Feature-Extend.decorator.d.ts +26 -3
  99. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js +97 -0
  100. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js.map +1 -0
  101. package/dist/src/global/A-Feature/A-Feature.class.d.ts +120 -30
  102. package/dist/src/global/A-Feature/A-Feature.class.js +205 -73
  103. package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
  104. package/dist/src/global/A-Feature/A-Feature.error.d.ts +25 -0
  105. package/dist/src/global/A-Feature/A-Feature.error.js +33 -0
  106. package/dist/src/global/A-Feature/A-Feature.error.js.map +1 -0
  107. package/dist/src/global/A-Feature/A-Feature.types.d.ts +241 -18
  108. package/dist/src/global/A-Feature/A-Feature.types.js +16 -22
  109. package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
  110. package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +19 -27
  111. package/dist/src/global/A-Fragment/A-Fragment.class.js +21 -91
  112. package/dist/src/global/A-Fragment/A-Fragment.class.js.map +1 -1
  113. package/dist/src/global/A-Fragment/A-Fragment.types.d.ts +19 -1
  114. package/dist/src/global/A-Fragment/A-Fragment.types.js +3 -0
  115. package/dist/src/global/A-Fragment/A-Fragment.types.js.map +1 -1
  116. package/dist/src/global/A-Inject/A-Inject.decorator.d.ts +80 -0
  117. package/dist/src/global/A-Inject/A-Inject.decorator.js +49 -0
  118. package/dist/src/global/A-Inject/A-Inject.decorator.js.map +1 -0
  119. package/dist/src/global/A-Inject/A-Inject.error.d.ts +5 -0
  120. package/dist/src/global/A-Inject/A-Inject.error.js +10 -0
  121. package/dist/src/global/A-Inject/A-Inject.error.js.map +1 -0
  122. package/dist/src/global/A-Inject/A-Inject.types.d.ts +42 -0
  123. package/dist/src/{decorators/A-Entity/A-Entity.decorator.types.js → global/A-Inject/A-Inject.types.js} +1 -1
  124. package/dist/src/global/A-Inject/A-Inject.types.js.map +1 -0
  125. package/dist/src/global/A-Meta/A-Meta.class.d.ts +1 -1
  126. package/dist/src/global/A-Meta/A-Meta.types.d.ts +14 -0
  127. package/dist/src/global/A-Meta/A-Meta.types.js +1 -0
  128. package/dist/src/global/A-Scope/A-Scope.class.d.ts +124 -142
  129. package/dist/src/global/A-Scope/A-Scope.class.js +163 -209
  130. package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
  131. package/dist/src/global/A-Scope/A-Scope.error.d.ts +6 -0
  132. package/dist/src/global/A-Scope/A-Scope.error.js +11 -0
  133. package/dist/src/global/A-Scope/A-Scope.error.js.map +1 -0
  134. package/dist/src/global/A-Scope/A-Scope.types.d.ts +48 -13
  135. package/dist/src/global/A-Stage/A-Stage.class.d.ts +31 -23
  136. package/dist/src/global/A-Stage/A-Stage.class.js +100 -68
  137. package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -1
  138. package/dist/src/global/A-Stage/A-Stage.error.d.ts +2 -1
  139. package/dist/src/global/A-Stage/A-Stage.error.js +5 -2
  140. package/dist/src/global/A-Stage/A-Stage.error.js.map +1 -1
  141. package/dist/src/global/A-Stage/A-Stage.types.d.ts +4 -16
  142. package/dist/src/global/A-Stage/A-Stage.types.js +0 -16
  143. package/dist/src/global/A-Stage/A-Stage.types.js.map +1 -1
  144. package/dist/src/global/ASEID/ASEID.class.d.ts +130 -0
  145. package/dist/src/global/ASEID/ASEID.class.js +167 -0
  146. package/dist/src/global/ASEID/ASEID.class.js.map +1 -0
  147. package/dist/src/global/ASEID/ASEID.constants.js +2 -0
  148. package/dist/src/global/ASEID/ASEID.constants.js.map +1 -0
  149. package/dist/src/global/ASEID/ASEID.error.d.ts +5 -0
  150. package/dist/src/global/ASEID/ASEID.error.js +10 -0
  151. package/dist/src/global/ASEID/ASEID.error.js.map +1 -0
  152. package/dist/src/global/ASEID/ASEID.types.d.ts +65 -0
  153. package/dist/src/global/ASEID/ASEID.types.js +5 -0
  154. package/dist/src/global/ASEID/ASEID.types.js.map +1 -0
  155. package/dist/src/helpers/A_Common.helper.d.ts +28 -0
  156. package/dist/src/helpers/A_Common.helper.js +170 -0
  157. package/dist/src/helpers/A_Common.helper.js.map +1 -0
  158. package/dist/src/helpers/A_Formatter.helper.d.ts +35 -0
  159. package/dist/src/helpers/A_Formatter.helper.js +62 -0
  160. package/dist/src/helpers/A_Formatter.helper.js.map +1 -0
  161. package/dist/src/helpers/A_Identity.helper.d.ts +29 -0
  162. package/dist/src/helpers/A_Identity.helper.js +43 -0
  163. package/dist/src/helpers/A_Identity.helper.js.map +1 -0
  164. package/dist/src/helpers/{StepsManager.class.d.ts → A_StepsManager.class.d.ts} +4 -2
  165. package/dist/src/helpers/{StepsManager.class.js → A_StepsManager.class.js} +10 -5
  166. package/dist/src/helpers/A_StepsManager.class.js.map +1 -0
  167. package/dist/src/helpers/A_TypeGuards.helper.d.ts +205 -0
  168. package/dist/src/helpers/A_TypeGuards.helper.js +288 -0
  169. package/dist/src/helpers/A_TypeGuards.helper.js.map +1 -0
  170. package/dist/src/types/A_Common.types.d.ts +36 -0
  171. package/dist/src/types/A_Common.types.js +3 -0
  172. package/dist/src/types/A_Common.types.js.map +1 -0
  173. package/index.ts +27 -51
  174. package/jest.config.ts +1 -0
  175. package/package.json +1 -2
  176. package/src/constants/env.constants.ts +18 -11
  177. package/src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts +103 -0
  178. package/src/global/A-Abstraction/A-Abstraction.class.ts +71 -65
  179. package/src/global/A-Abstraction/A-Abstraction.error.ts +9 -0
  180. package/src/global/A-Abstraction/A-Abstraction.types.ts +52 -13
  181. package/src/global/A-Caller/A_Caller.class.ts +61 -0
  182. package/src/global/A-Caller/A_Caller.error.ts +10 -0
  183. package/src/global/A-Caller/A_Caller.types.ts +25 -0
  184. package/src/global/A-Component/A-Component.class.ts +26 -15
  185. package/src/global/A-Component/A-Component.constants.ts +9 -0
  186. package/src/global/A-Component/A-Component.meta.ts +6 -16
  187. package/src/global/A-Component/A-Component.types.ts +53 -28
  188. package/src/global/A-Concept/A-Concept.class.ts +316 -0
  189. package/src/global/A-Concept/A-Concept.constants.ts +36 -0
  190. package/src/global/A-Concept/A-Concept.meta.ts +17 -0
  191. package/src/global/A-Concept/A-Concept.types.ts +100 -0
  192. package/src/global/A-Container/A-Container.class.ts +42 -83
  193. package/src/global/A-Container/A-Container.constants.ts +5 -0
  194. package/src/global/A-Container/A-Container.meta.ts +7 -11
  195. package/src/global/A-Container/A-Container.types.ts +38 -34
  196. package/src/global/A-Context/A-Context.class.ts +648 -412
  197. package/src/global/A-Context/A-Context.error.ts +44 -0
  198. package/src/global/A-Context/A-Context.types.ts +14 -0
  199. package/src/global/A-Entity/A-Entity.class.ts +39 -52
  200. package/src/global/A-Entity/A-Entity.constants.ts +12 -0
  201. package/src/global/A-Entity/A-Entity.error.ts +12 -0
  202. package/src/global/A-Entity/A-Entity.meta.ts +4 -4
  203. package/src/global/A-Entity/A-Entity.types.ts +31 -36
  204. package/src/global/A-Error/A_Error.class.ts +408 -0
  205. package/src/global/A-Error/A_Error.constants.ts +11 -0
  206. package/src/global/A-Error/A_Error.types.ts +96 -0
  207. package/src/{decorators → global}/A-Feature/A-Feature-Define.decorator.ts +31 -37
  208. package/src/global/A-Feature/A-Feature-Extend.decorator.ts +187 -0
  209. package/src/global/A-Feature/A-Feature.class.ts +279 -122
  210. package/src/global/A-Feature/A-Feature.error.ts +33 -0
  211. package/src/global/A-Feature/A-Feature.types.ts +278 -40
  212. package/src/global/A-Fragment/A-Fragment.class.ts +29 -100
  213. package/src/global/A-Fragment/A-Fragment.types.ts +25 -3
  214. package/src/global/A-Inject/A-Inject.decorator.ts +167 -0
  215. package/src/global/A-Inject/A-Inject.error.ts +8 -0
  216. package/src/global/A-Inject/A-Inject.types.ts +75 -0
  217. package/src/global/A-Meta/A-Meta.class.ts +1 -1
  218. package/src/global/A-Meta/A-Meta.types.ts +21 -0
  219. package/src/global/A-Scope/A-Scope.class.ts +288 -299
  220. package/src/global/A-Scope/A-Scope.error.ts +13 -0
  221. package/src/global/A-Scope/A-Scope.types.ts +61 -27
  222. package/src/global/A-Stage/A-Stage.class.ts +142 -80
  223. package/src/global/A-Stage/A-Stage.error.ts +4 -2
  224. package/src/global/A-Stage/A-Stage.types.ts +4 -25
  225. package/src/global/ASEID/ASEID.class.ts +275 -0
  226. package/src/global/ASEID/ASEID.error.ts +12 -0
  227. package/src/global/ASEID/ASEID.types.ts +79 -0
  228. package/src/helpers/A_Common.helper.ts +204 -0
  229. package/src/helpers/A_Formatter.helper.ts +58 -0
  230. package/src/helpers/A_Identity.helper.ts +53 -0
  231. package/src/helpers/{StepsManager.class.ts → A_StepsManager.class.ts} +19 -3
  232. package/src/helpers/A_TypeGuards.helper.ts +318 -0
  233. package/src/types/A_Common.types.ts +79 -0
  234. package/tests/A-Common.test.ts +117 -0
  235. package/tests/A-Component.test.ts +11 -6
  236. package/tests/A-Concept.test.ts +19 -22
  237. package/tests/A-Entity.test.ts +24 -24
  238. package/tests/A-Error.test.ts +129 -0
  239. package/tests/A-Feature.test.ts +34 -25
  240. package/tests/A-Scope.test.ts +50 -22
  241. package/tests/ASEID.test.ts +74 -0
  242. package/tsconfig.build.json +2 -1
  243. package/tsconfig.json +3 -2
  244. package/dist/src/base/A-Config/A-Config.container.d.ts +0 -9
  245. package/dist/src/base/A-Config/A-Config.container.js +0 -69
  246. package/dist/src/base/A-Config/A-Config.container.js.map +0 -1
  247. package/dist/src/base/A-Config/A-Config.context.d.ts +0 -30
  248. package/dist/src/base/A-Config/A-Config.context.js +0 -60
  249. package/dist/src/base/A-Config/A-Config.context.js.map +0 -1
  250. package/dist/src/base/A-Config/A-Config.types.d.ts +0 -20
  251. package/dist/src/base/A-Config/A-Config.types.js +0 -7
  252. package/dist/src/base/A-Config/A-Config.types.js.map +0 -1
  253. package/dist/src/base/A-Config/components/ConfigReader.component.d.ts +0 -29
  254. package/dist/src/base/A-Config/components/ConfigReader.component.js +0 -84
  255. package/dist/src/base/A-Config/components/ConfigReader.component.js.map +0 -1
  256. package/dist/src/base/A-Config/components/ENVConfigReader.component.d.ts +0 -10
  257. package/dist/src/base/A-Config/components/ENVConfigReader.component.js +0 -37
  258. package/dist/src/base/A-Config/components/ENVConfigReader.component.js.map +0 -1
  259. package/dist/src/base/A-Config/components/FileConfigReader.component.d.ts +0 -11
  260. package/dist/src/base/A-Config/components/FileConfigReader.component.js +0 -48
  261. package/dist/src/base/A-Config/components/FileConfigReader.component.js.map +0 -1
  262. package/dist/src/base/A-Errors/A-Error.entity.d.ts +0 -3
  263. package/dist/src/base/A-Errors/A-Error.entity.js +0 -8
  264. package/dist/src/base/A-Errors/A-Error.entity.js.map +0 -1
  265. package/dist/src/base/A-Errors/A-Errors.component.d.ts +0 -19
  266. package/dist/src/base/A-Errors/A-Errors.component.js +0 -87
  267. package/dist/src/base/A-Errors/A-Errors.component.js.map +0 -1
  268. package/dist/src/base/A-Errors/A-Errors.context.d.ts +0 -27
  269. package/dist/src/base/A-Errors/A-Errors.context.js +0 -50
  270. package/dist/src/base/A-Errors/A-Errors.context.js.map +0 -1
  271. package/dist/src/base/A-Errors/A-Errors.types.d.ts +0 -5
  272. package/dist/src/base/A-Errors/A-Errors.types.js.map +0 -1
  273. package/dist/src/base/A-Logger/A-Logger.component.d.ts +0 -31
  274. package/dist/src/base/A-Logger/A-Logger.component.js +0 -155
  275. package/dist/src/base/A-Logger/A-Logger.component.js.map +0 -1
  276. package/dist/src/base/A-Logger/A-Logger.types.js +0 -2
  277. package/dist/src/base/A-Logger/A-Logger.types.js.map +0 -1
  278. package/dist/src/base/A-Polyfill/A-Polyfill.component.d.ts +0 -5
  279. package/dist/src/base/A-Polyfill/A-Polyfill.component.js +0 -34
  280. package/dist/src/base/A-Polyfill/A-Polyfill.component.js.map +0 -1
  281. package/dist/src/decorators/A-Abstraction/A-Abstraction-Extend.decorator.d.ts +0 -14
  282. package/dist/src/decorators/A-Abstraction/A-Abstraction-Extend.decorator.js +0 -53
  283. package/dist/src/decorators/A-Abstraction/A-Abstraction-Extend.decorator.js.map +0 -1
  284. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.d.ts +0 -2
  285. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js +0 -3
  286. package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js.map +0 -1
  287. package/dist/src/decorators/A-Connect/A-Connect.decorator.d.ts +0 -19
  288. package/dist/src/decorators/A-Connect/A-Connect.decorator.js +0 -31
  289. package/dist/src/decorators/A-Connect/A-Connect.decorator.js.map +0 -1
  290. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.d.ts +0 -1
  291. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js +0 -3
  292. package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js.map +0 -1
  293. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.d.ts +0 -1
  294. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js +0 -8
  295. package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js.map +0 -1
  296. package/dist/src/decorators/A-Entity/A-Entity.decorator.types.d.ts +0 -14
  297. package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js.map +0 -1
  298. package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.d.ts +0 -19
  299. package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js.map +0 -1
  300. package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js +0 -81
  301. package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +0 -1
  302. package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +0 -96
  303. package/dist/src/decorators/A-Feature/A-Feature.decorator.types.js +0 -3
  304. package/dist/src/decorators/A-Feature/A-Feature.decorator.types.js.map +0 -1
  305. package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +0 -30
  306. package/dist/src/decorators/A-Inject/A-Inject.decorator.js +0 -47
  307. package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +0 -1
  308. package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +0 -48
  309. package/dist/src/decorators/A-Inject/A-Inject.decorator.types.js.map +0 -1
  310. package/dist/src/global/A-Channel/A-Channel.class.d.ts +0 -16
  311. package/dist/src/global/A-Channel/A-Channel.class.js +0 -59
  312. package/dist/src/global/A-Channel/A-Channel.class.js.map +0 -1
  313. package/dist/src/global/A-Channel/A-Channel.types.d.ts +0 -68
  314. package/dist/src/global/A-Channel/A-Channel.types.js.map +0 -1
  315. package/dist/src/global/A-Command/A-Command.class.d.ts +0 -187
  316. package/dist/src/global/A-Command/A-Command.class.js +0 -349
  317. package/dist/src/global/A-Command/A-Command.class.js.map +0 -1
  318. package/dist/src/global/A-Command/A-Command.constants.d.ts +0 -17
  319. package/dist/src/global/A-Command/A-Command.constants.js +0 -22
  320. package/dist/src/global/A-Command/A-Command.constants.js.map +0 -1
  321. package/dist/src/global/A-Command/A-Command.meta.d.ts +0 -11
  322. package/dist/src/global/A-Command/A-Command.meta.js +0 -18
  323. package/dist/src/global/A-Command/A-Command.meta.js.map +0 -1
  324. package/dist/src/global/A-Command/A-Command.types.d.ts +0 -43
  325. package/dist/src/global/A-Command/A-Command.types.js +0 -10
  326. package/dist/src/global/A-Command/A-Command.types.js.map +0 -1
  327. package/dist/src/global/A-Command/context/A_Command.context.d.ts +0 -64
  328. package/dist/src/global/A-Command/context/A_Command.context.js +0 -85
  329. package/dist/src/global/A-Command/context/A_Command.context.js.map +0 -1
  330. package/dist/src/global/A-Concept/A_Concept.class.d.ts +0 -104
  331. package/dist/src/global/A-Concept/A_Concept.class.js +0 -217
  332. package/dist/src/global/A-Concept/A_Concept.class.js.map +0 -1
  333. package/dist/src/global/A-Concept/A_Concept.meta.js.map +0 -1
  334. package/dist/src/global/A-Concept/A_Concept.types.d.ts +0 -103
  335. package/dist/src/global/A-Concept/A_Concept.types.js +0 -28
  336. package/dist/src/global/A-Concept/A_Concept.types.js.map +0 -1
  337. package/dist/src/global/A-Feature/A-FeatureCaller.class.d.ts +0 -22
  338. package/dist/src/global/A-Feature/A-FeatureCaller.class.js +0 -26
  339. package/dist/src/global/A-Feature/A-FeatureCaller.class.js.map +0 -1
  340. package/dist/src/global/A-Scope/A-Scope.constants.d.ts +0 -2
  341. package/dist/src/global/A-Scope/A-Scope.constants.js +0 -11
  342. package/dist/src/global/A-Scope/A-Scope.constants.js.map +0 -1
  343. package/dist/src/helpers/StepsManager.class.js.map +0 -1
  344. package/dist/src/types/A_Module.types.d.ts +0 -17
  345. package/dist/src/types/A_Module.types.js +0 -22
  346. package/dist/src/types/A_Module.types.js.map +0 -1
  347. package/examples/entity/concept.ts +0 -68
  348. package/examples/entity/entities/Task.entity.ts +0 -110
  349. package/examples/entity/entities/User.entity.ts +0 -62
  350. package/examples/fe-be/channels/Test.channel.ts +0 -27
  351. package/examples/fe-be/components/BE-Controller.component.ts +0 -20
  352. package/examples/fe-be/components/FE.component.ts +0 -13
  353. package/examples/fe-be/containers/ServerApp.container.ts +0 -8
  354. package/examples/fe-be/containers/WebApp.container.ts +0 -13
  355. package/examples/multi-container/channels/Direct.channel.ts +0 -39
  356. package/examples/multi-container/concept.ts +0 -0
  357. package/examples/multi-container/containers/Command.container.ts +0 -41
  358. package/examples/multi-container/containers/Schedule.container.ts +0 -52
  359. package/examples/simple/components/A.component.ts +0 -71
  360. package/examples/simple/components/B.component.ts +0 -68
  361. package/examples/simple/concept.ts +0 -87
  362. package/examples/simple/containers/Main.container.ts +0 -88
  363. package/examples/simple/containers/Secondary.container.ts +0 -26
  364. package/examples/simple/context/Fragment_A.context.ts +0 -25
  365. package/examples/simple/context/Fragment_B.context.ts +0 -19
  366. package/examples/simple/entities/EntityA.entity.ts +0 -32
  367. package/examples/simple-http-server/components/http-error-handler.component.ts +0 -47
  368. package/examples/simple-http-server/components/http-request-handler.component.ts +0 -13
  369. package/examples/simple-http-server/concept.ts +0 -35
  370. package/examples/simple-http-server/containers/http-server.container.ts +0 -57
  371. package/examples/simple-http-server/contexts/http-request.context.ts +0 -59
  372. package/examples/simple-http-server/contexts/http-server.context.types.ts +0 -0
  373. package/examples/simple-http-server/controllers/orders.controller.ts +0 -20
  374. package/examples/simple-http-server/controllers/users.controller.ts +0 -104
  375. package/examples/simple-http-server/test.ts +0 -290
  376. package/src/base/A-Config/A-Config.container.ts +0 -68
  377. package/src/base/A-Config/A-Config.context.ts +0 -114
  378. package/src/base/A-Config/A-Config.types.ts +0 -28
  379. package/src/base/A-Config/components/ConfigReader.component.ts +0 -68
  380. package/src/base/A-Config/components/ENVConfigReader.component.ts +0 -31
  381. package/src/base/A-Config/components/FileConfigReader.component.ts +0 -41
  382. package/src/base/A-Errors/A-Error.entity.ts +0 -10
  383. package/src/base/A-Errors/A-Errors.component.ts +0 -103
  384. package/src/base/A-Errors/A-Errors.context.ts +0 -90
  385. package/src/base/A-Errors/A-Errors.types.ts +0 -6
  386. package/src/base/A-Logger/A-Logger.component.ts +0 -192
  387. package/src/base/A-Logger/A-Logger.types.ts +0 -0
  388. package/src/base/A-Polyfill/A-Polyfill.component.ts +0 -18
  389. package/src/decorators/A-Abstraction/A-Abstraction-Extend.decorator.ts +0 -81
  390. package/src/decorators/A-Abstraction/A-Abstraction.decorator.types.ts +0 -21
  391. package/src/decorators/A-Connect/A-Connect.decorator.ts +0 -71
  392. package/src/decorators/A-Connect/A-Connect.decorator.types.ts +0 -6
  393. package/src/decorators/A-Entity/A-Entity-List.decorator.ts +0 -12
  394. package/src/decorators/A-Entity/A-Entity.decorator.types.ts +0 -18
  395. package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +0 -151
  396. package/src/decorators/A-Feature/A-Feature.decorator.types.ts +0 -142
  397. package/src/decorators/A-Inject/A-Inject.decorator.ts +0 -119
  398. package/src/decorators/A-Inject/A-Inject.decorator.types.ts +0 -85
  399. package/src/global/A-Channel/A-Channel.class.ts +0 -111
  400. package/src/global/A-Channel/A-Channel.types.ts +0 -114
  401. package/src/global/A-Command/A-Command.class.ts +0 -419
  402. package/src/global/A-Command/A-Command.constants.ts +0 -27
  403. package/src/global/A-Command/A-Command.meta.ts +0 -22
  404. package/src/global/A-Command/A-Command.types.ts +0 -73
  405. package/src/global/A-Command/context/A_Command.context.ts +0 -114
  406. package/src/global/A-Concept/A_Concept.class.ts +0 -298
  407. package/src/global/A-Concept/A_Concept.meta.ts +0 -32
  408. package/src/global/A-Concept/A_Concept.types.ts +0 -143
  409. package/src/global/A-Feature/A-FeatureCaller.class.ts +0 -38
  410. package/src/global/A-Scope/A-Scope.constants.ts +0 -9
  411. package/src/types/A_Module.types.ts +0 -23
  412. package/tests/A-Command.test.ts +0 -133
  413. package/tests/A-Config.test.ts +0 -172
  414. /package/dist/src/global/A-Concept/{A_Concept.meta.d.ts → A-Concept.meta.d.ts} +0 -0
  415. /package/dist/src/{base/A-Logger/A-Logger.types.d.ts → global/ASEID/ASEID.constants.d.ts} +0 -0
  416. /package/{examples/fe-be/concept.ts → src/global/ASEID/ASEID.constants.ts} +0 -0
@@ -1,298 +1,413 @@
1
1
  import {
2
- A_CommonHelper,
3
- A_Error,
4
- A_Polyfills,
5
- } from "@adaas/a-utils";
2
+ A_TYPES__Scope_Init,
3
+ A_TYPES__ScopeConfig,
4
+ A_TYPES__ScopeLinkedComponents,
5
+ A_TYPES_ScopeDependentComponents
6
+ } from "../A-Scope/A-Scope.types";
7
+ import {
8
+ A_TYPES__MetaLinkedComponentConstructors,
9
+ A_TYPES__MetaLinkedComponents
10
+ } from "../A-Meta/A-Meta.types";
11
+ import {
12
+ A_TYPES__FeatureAvailableComponents,
13
+ A_TYPES__FeatureDefineDecoratorMeta
14
+ } from "../A-Feature/A-Feature.types";
6
15
  import { A_Component } from "../A-Component/A-Component.class";
7
- import { A_Fragment } from "../A-Fragment/A-Fragment.class";
8
16
  import { A_Feature } from "../A-Feature/A-Feature.class";
9
17
  import { A_Container } from "../A-Container/A-Container.class";
10
18
  import { A_Scope } from "../A-Scope/A-Scope.class";
11
- import { A_TYPES__ScopeConfig, A_TYPES__ScopeConstructor } from "../A-Scope/A-Scope.types";
12
19
  import { A_Meta } from "../A-Meta/A-Meta.class";
13
20
  import { A_ComponentMeta } from "../A-Component/A-Component.meta";
14
21
  import { A_ContainerMeta } from "../A-Container/A-Container.meta";
15
- import { A_TYPES__EntityMetaKey } from "../A-Entity/A-Entity.types";
16
22
  import { A_Entity } from "../A-Entity/A-Entity.class";
17
23
  import { A_EntityMeta } from "../A-Entity/A-Entity.meta";
18
- import { A_TYPES__FeatureConstructor } from "../A-Feature/A-Feature.types";
19
24
  import { A_TYPES__A_StageStep } from "../A-Stage/A-Stage.types";
20
- import { A_TYPES__ContainerMetaKey } from "../A-Container/A-Container.types";
21
- import { A_TYPES__ComponentMetaKey } from "../A-Component/A-Component.types";
22
- import { A_TYPES__ConceptStage } from "../A-Concept/A_Concept.types";
23
- import { A_TYPES__A_DefineDecorator_Meta } from "@adaas/a-concept/decorators/A-Feature/A-Feature.decorator.types";
24
25
  import { A_CONSTANTS__DEFAULT_ENV_VARIABLES } from "@adaas/a-concept/constants/env.constants";
25
- import { A_Command } from "../A-Command/A-Command.class";
26
- import { A_TYPES__CommandMetaKey } from "../A-Command/A-Command.types";
26
+ import { A_TYPES__EntityMetaKey } from "../A-Entity/A-Entity.constants";
27
+ import { A_TYPES__ContainerMetaKey } from "../A-Container/A-Container.constants";
28
+ import { A_TYPES__ComponentMetaKey } from "../A-Component/A-Component.constants";
29
+ import { A_TYPES__ContextEnvironment } from "./A-Context.types";
30
+ import { A_TypeGuards } from "@adaas/a-concept/helpers/A_TypeGuards.helper";
31
+ import { A_ContextError } from "./A-Context.error";
32
+ import { A_TYPES__Container_Constructor } from "../A-Container/A-Container.types";
33
+ import { A_TYPES__Entity_Constructor } from "../A-Entity/A-Entity.types";
34
+ import { A_TYPES__Component_Constructor } from "../A-Component/A-Component.types";
35
+ import { A_FormatterHelper } from "@adaas/a-concept/helpers/A_Formatter.helper";
36
+ import { A_Fragment } from "../A-Fragment/A-Fragment.class";
37
+ import { A_TYPES__InjectableTargets } from "../A-Inject/A-Inject.types";
38
+ import { A_TYPES__ConceptAbstraction } from "../A-Concept/A-Concept.types";
27
39
 
28
40
 
29
41
 
30
- /**
31
- * Namespace Provider is responsible for providing the Namespace to the Containers and other Namespaces.
32
- * This class stores all Namespaces across the Program.
33
- *
34
- * Namespace provider is a singleton class that is used to store all the Namespaces in the program.
35
- *
36
- */
37
42
  export class A_Context {
38
-
39
- static instance: A_Context;
40
-
43
+ // ====================================================================================================
44
+ // ================================ STATIC PROPERTIES =================================================
45
+ // ====================================================================================================
41
46
  /**
42
- * A set of globally registered containers.
47
+ * Default name of the application from environment variable A_CONCEPT_NAME
48
+ *
49
+ * [!] If environment variable is not set, it will default to 'a-concept'
43
50
  */
44
- protected containers: WeakMap<A_Container, A_Scope> = new WeakMap();
45
-
51
+ static get concept() {
52
+ return process.env[A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_NAME] || 'a-concept';
53
+ }
46
54
  /**
47
- * A set of globally registered features.
55
+ * Root scope of the application from environment variable A_CONCEPT_ROOT_SCOPE
56
+ *
57
+ * [!] If environment variable is not set, it will default to 'root'
48
58
  */
49
- protected features: WeakMap<A_Feature, A_Scope> = new WeakMap();
50
-
51
-
52
- protected commands: WeakMap<A_Command, A_Scope> = new WeakMap();
53
-
54
-
59
+ static get root(): A_Scope {
60
+ return this.getInstance()._root;
61
+ }
55
62
  /**
56
- * Uses to store the scope of every element in the program.
63
+ * Environment the application is running in.
64
+ * Can be either 'server' or 'browser'.
65
+ * [!] Determined by checking if 'window' object is available.
57
66
  */
58
- protected registry: WeakMap<
59
- A_Container |
60
- A_Feature |
61
- A_Component |
62
- A_Fragment |
63
- A_Entity,
64
- A_Scope
65
- > = new WeakMap();
66
-
67
+ static get environment(): A_TYPES__ContextEnvironment {
68
+ let testEnvironment: A_TYPES__ContextEnvironment = 'browser';
67
69
 
70
+ try {
71
+ testEnvironment = window.location ? 'browser' : 'server';
72
+ } catch (error) {
73
+ testEnvironment = 'server';
74
+ }
68
75
 
76
+ return testEnvironment;
77
+ }
69
78
 
70
79
  /**
71
- * A set of allocated scopes per every element in the program.
80
+ * Singleton instance of the Context
72
81
  */
73
- protected containersMeta: Map<typeof A_Container.constructor, A_ContainerMeta> = new Map();
74
- protected componentsMeta: Map<typeof A_Component, A_ComponentMeta> = new Map();
75
- protected entitiesMeta: Map<typeof A_Entity.constructor, A_EntityMeta> = new Map();
76
-
77
- // uses to allow to store custom meta data
78
- protected customMeta: Map<typeof A_Container.constructor, A_Meta<any>> = new Map();
79
-
80
-
82
+ private static _instance: A_Context;
83
+ // ====================================================================================================
84
+ // ================================ INTERNAL REGISTRY =================================================
85
+ // ====================================================================================================
81
86
  /**
82
- * Root Namespace is a Namespace that is used to run the program.
87
+ * Root Scope of the Concept and Environment
88
+ *
89
+ * Root scope is the top-level scope that all other scopes inherit from.
90
+ * It stores global configurations and settings and ALL SHAREABLE RESOURCES.
91
+ *
92
+ * [!] Root scope is created automatically when the Context is initialized.
93
+ * [!] Root scope name can be configured using environment variable A_CONCEPT_ROOT_SCOPE
83
94
  */
84
95
  private _root!: A_Scope
96
+ /**
97
+ * A registry that keeps track of scopes for all components (Containers, Features, Commands)
98
+ * Which can issue a scope allocation.
99
+ */
100
+ protected _registry: WeakMap<A_TYPES__ScopeLinkedComponents, A_Scope> = new WeakMap();
101
+ /**
102
+ * This is a registry that stores an issuer of each scope allocation.
103
+ * It helps to track which component (Container, Feature, Command) allocated a specific scope.
104
+ */
105
+ protected _scopeIssuers: WeakMap<A_Scope, A_TYPES__ScopeLinkedComponents> = new WeakMap();
106
+ /**
107
+ * Stores a context associated with a specific component that depends on a scope.
108
+ * uses for quick retrieval of the scope for the component.
109
+ */
110
+ protected _scopeStorage: WeakMap<A_TYPES_ScopeDependentComponents, A_Scope> = new WeakMap();
111
+ /**
112
+ * Stores meta information for different component types by their constructors.
113
+ * Meta provides to store extra information about the class behavior and configuration.
114
+ */
115
+ protected _metaStorage: Map<A_TYPES__MetaLinkedComponentConstructors, A_Meta> = new Map();
116
+
85
117
 
86
118
 
119
+ /**
120
+ * Private constructor to enforce singleton pattern.
121
+ *
122
+ * [!] This class should not be instantiated directly. Use A_Context.getInstance() instead.
123
+ */
87
124
  private constructor() {
88
- this._root = new A_Scope({
89
- name: process && process.env ? process.env[A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_NAMESPACE] || 'a-concept' : 'a-concept'
90
- });
91
- }
125
+ let name = 'root';
92
126
 
127
+ if (A_Context.environment === 'server')
128
+ name = process.env[A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_ROOT_SCOPE] || 'root';
93
129
 
130
+ if (A_Context.environment === 'browser')
131
+ name = (window as any)[A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_ROOT_SCOPE] || 'root';
94
132
 
95
- // ===================================================================================================
96
- // ================================ META OPERATIONS ==================================================
97
- // ===================================================================================================
133
+ this._root = new A_Scope({ name });
134
+ }
98
135
 
99
136
 
100
137
 
101
138
  /**
102
139
  * Get the instance of the Namespace Provider.
103
140
  *
141
+ * If the instance does not exist, it will be created.
142
+ *
104
143
  * @returns
105
144
  */
106
145
  static getInstance() {
107
- if (!A_Context.instance) {
108
- A_Context.instance = new A_Context();
146
+ if (!A_Context._instance) {
147
+ A_Context._instance = new A_Context();
109
148
  }
110
149
 
111
- return A_Context.instance;
150
+ return A_Context._instance;
112
151
  }
113
152
 
114
- static get root(): A_Scope {
115
- return this.getInstance()._root;
116
- }
117
153
 
118
- static get environment(): 'server' | 'browser' {
119
- return A_Polyfills.env;
120
- }
121
154
 
155
+ /**
156
+ * Register method allows to register a component with a specific scope in the context.
157
+ *
158
+ * @param component - Component to register with a specific scope. Can be either A_Container, A_Feature.
159
+ * @param scope - Scope to associate the component with.
160
+ * @returns
161
+ */
162
+ static register(
163
+ /**
164
+ * Provide the scope that will be associated with the component.
165
+ */
166
+ scope: A_Scope,
167
+ /**
168
+ * Provide a component that needs to be registered with a specific scope.
169
+ */
170
+ component: A_TYPES_ScopeDependentComponents,
122
171
 
172
+ ): A_Scope {
173
+ // uses only for error messages
174
+ const componentName = (component as any)?.constructor?.name || String(component);
123
175
 
176
+ const instance = this.getInstance();
177
+
178
+ if (!component) throw new A_ContextError(
179
+ A_ContextError.InvalidRegisterParameterError,
180
+ `Unable to register component. Component cannot be null or undefined.`);
181
+ if (!scope) throw new A_ContextError(
182
+ A_ContextError.InvalidRegisterParameterError,
183
+ `Unable to register component. Scope cannot be null or undefined.`);
184
+ if (!this.isAllowedToBeRegistered(component)) throw new A_ContextError(
185
+ A_ContextError.NotAllowedForScopeAllocationError,
186
+ `Component ${componentName} is not allowed for scope allocation.`);
187
+
188
+ instance._scopeStorage.set(component, scope);
189
+
190
+ return scope;
191
+ }
192
+
193
+
194
+ /**
195
+ * Allocate method instantiates a new scope for the given component and registers it in the context.
196
+ * It bounds the component (Container, Feature) to a new scope that can be configured and used independently.
197
+ *
198
+ *
199
+ * @param component - Component to allocate the scope for. Can be either A_Container, A_Feature.
200
+ * @param importing - Configuration of the scope that will be created for the component.
201
+ */
124
202
  static allocate(
125
- component: any,
126
- importing: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig>
127
- ): A_Scope
128
- static allocate(
129
- component: any,
130
- importing: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig> | A_Scope
131
- ): A_Scope
132
- static allocate(
133
- feature: A_Feature,
134
- importing: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig>
135
- ): A_Scope
136
- static allocate(
137
- feature: A_Feature,
138
- importing: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig> | A_Scope
203
+ /**
204
+ * Provide a component that needs a scope allocation.
205
+ */
206
+ component: A_TYPES__ScopeLinkedComponents,
139
207
  ): A_Scope
140
208
  static allocate(
141
- container: A_Container,
142
- importing: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig>
209
+ /**
210
+ * Provide a component that needs a scope allocation.
211
+ */
212
+ component: A_TYPES__ScopeLinkedComponents,
213
+ /**
214
+ * Provide the scope that will be used as a base for the new scope.
215
+ */
216
+ importing: A_Scope
143
217
  ): A_Scope
144
218
  static allocate(
145
- container: A_Container,
146
- importing: A_Scope
219
+ /**
220
+ * Provide a component that needs a scope allocation.
221
+ */
222
+ component: A_TYPES__ScopeLinkedComponents,
223
+ /**
224
+ * Provide configuration for the scope that will be created for the component.
225
+ */
226
+ config: Partial<A_TYPES__Scope_Init & A_TYPES__ScopeConfig>
147
227
  ): A_Scope
148
228
  static allocate(
149
- param1: A_Container | A_Feature | A_Component | any,
150
- param2: Partial<A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig> | A_Scope
229
+ component: A_TYPES__ScopeLinkedComponents,
230
+ importing?: Partial<A_TYPES__Scope_Init & A_TYPES__ScopeConfig> | A_Scope
151
231
  ): A_Scope {
152
-
232
+ // uses only for error messages
233
+ const componentName = (component as any)?.constructor?.name || String(component);
234
+
235
+ // ---------------------------------------------------------------------
236
+ // ----------------------Input Validation-------------------------------
237
+ // ---------------------------------------------------------------------
238
+ // 1) check if component is valid
239
+ if (!this.isAllowedForScopeAllocation(component))
240
+ throw new A_ContextError(A_ContextError.NotAllowedForScopeAllocationError, `Component of type ${componentName} is not allowed for scope allocation. Only A_Container, A_Feature are allowed.`);
153
241
  const instance = this.getInstance();
154
242
 
155
- const newScope = param2 instanceof A_Scope ? param2 : new A_Scope(param2, param2);
156
-
157
- if (!newScope.isInheritedFrom(A_Context.root)) {
158
- newScope.inherit(A_Context.root);
159
- }
160
-
161
- switch (true) {
162
- case param1 instanceof A_Container:
163
- instance.containers.set(param1, newScope);
164
-
165
- break;
166
-
167
- case param1 instanceof A_Feature:
168
- instance.features.set(param1, newScope);
169
-
170
- break;
243
+ // 2) check if component already has a scope allocated
244
+ if (instance._registry.has(component))
245
+ throw new A_ContextError(A_ContextError.ComponentAlreadyHasScopeAllocatedError, `Component ${componentName} already has a scope allocated.`);
171
246
 
172
- case param1 instanceof A_Command:
173
- instance.commands.set(param1, newScope);
174
247
 
175
- break;
248
+ // 3) Create a new scope for the component
249
+ const newScope = A_TypeGuards.isScopeInstance(importing)
250
+ ? importing
251
+ : new A_Scope(importing || {
252
+ name: componentName + '-scope'
253
+ }, importing);
176
254
 
177
- default:
178
- throw new Error(`[!] A-Concept Context: Unknown type of the parameter.`);
179
- }
255
+ // 4) Make sure that the new scope inherits from the root scope
256
+ if (!newScope.isInheritedFrom(A_Context.root))
257
+ newScope.inherit(A_Context.root);
180
258
 
259
+ // 5) Register the component in the appropriate storage
260
+ instance._registry.set(component, newScope);
261
+ // Also register the issuer of the scope for faster tracking
262
+ instance._scopeIssuers.set(newScope, component);
181
263
 
264
+ // 6) Return the newly created scope
182
265
  return newScope;
183
266
  }
184
267
 
185
268
 
186
269
 
187
-
188
270
  /**
189
- * Get or Create Meta for the specific class or instance.
190
- * This method will return the existing meta if it exists, or create a new one if it doesn't.
191
- *
192
- * Meta object contains custom metadata based on the class type.
193
- *
194
- * @param container
195
- */
271
+ * Get or Create Meta for the specific class or instance.
272
+ * This method will return the existing meta if it exists, or create a new one if it doesn't.
273
+ *
274
+ * Meta object contains custom metadata based on the class type.
275
+ *
276
+ * @param container
277
+ */
196
278
  static meta(
197
- container: typeof A_Container,
279
+ /**
280
+ * Get meta for the specific container class by constructor.
281
+ */
282
+ container: A_TYPES__Container_Constructor,
198
283
  ): A_ContainerMeta
199
284
  static meta(
285
+ /**
286
+ * Get meta for the specific container instance.
287
+ */
200
288
  container: A_Container,
201
289
  ): A_ContainerMeta
202
290
  static meta(
291
+ /**
292
+ * Get meta for the specific entity class by constructor.
293
+ */
294
+ entity: A_TYPES__Entity_Constructor,
295
+ ): A_EntityMeta
296
+ static meta(
297
+ /**
298
+ * Get meta for the specific entity instance.
299
+ */
203
300
  entity: A_Entity,
204
- ): A_ContainerMeta
301
+ ): A_EntityMeta
205
302
  static meta(
206
- entity: typeof A_Entity,
207
- ): A_ContainerMeta
303
+ /**
304
+ * Get meta for the specific component class by constructor.
305
+ */
306
+ component: A_TYPES__Component_Constructor,
307
+ ): A_ComponentMeta
208
308
  static meta(
209
- component: string,
309
+ /**
310
+ * Get meta for the specific component instance.
311
+ */
312
+ component: A_Component,
210
313
  ): A_ComponentMeta
211
314
  static meta(
212
- component: typeof A_Component,
315
+ /**
316
+ * Get meta for the specific component by its name.
317
+ */
318
+ component: string,
213
319
  ): A_ComponentMeta
214
320
  static meta(
215
- component: A_Component,
321
+ /**
322
+ * Get meta for the specific injectable target (class or instance).
323
+ */
324
+ target: A_TYPES__InjectableTargets,
216
325
  ): A_ComponentMeta
217
326
  static meta<T extends Record<string, any>>(
218
- constructor: typeof A_Component | typeof A_Container | A_Container
219
- | A_Component
220
- | A_Entity
221
- | typeof A_Entity
222
- | { new(...args: any[]): any }
223
- | string
327
+ /**
328
+ * Get meta for the specific class or instance
329
+ */
330
+ constructor: new (...args: any[]) => any
224
331
  ): A_Meta<T>
332
+
225
333
  static meta<T extends Record<string, any>>(
226
- param1: typeof A_Component | typeof A_Container | A_Container
227
- | A_Component
228
- | A_Entity
229
- | typeof A_Entity
230
- | { new(...args: any[]): any }
334
+ param1: A_TYPES__MetaLinkedComponentConstructors
335
+ | A_TYPES__MetaLinkedComponents
231
336
  | string
232
- ): A_ContainerMeta | A_ComponentMeta | A_Meta<T> {
337
+ ): A_Meta<T> {
233
338
 
339
+ // Get the component name for error messages
340
+ const componentName = (param1 as any)?.constructor?.name || String(param1);
341
+ // Get the instance of the context
234
342
  const instance = this.getInstance();
235
343
 
236
- let metaStorage: WeakMap<typeof A_Container.constructor, A_Meta<any>>;
237
- let property: Function;
238
- let metaType: typeof A_Meta<T> | typeof A_ContainerMeta | typeof A_ComponentMeta | typeof A_EntityMeta
344
+ if (!param1) throw new A_ContextError(A_ContextError.InvalidMetaParameterError, `Invalid parameter provided to get meta. Parameter cannot be null or undefined.`);
239
345
 
346
+ // Check if the parameter is allowed for meta storage
347
+ if (!(
348
+ this.isAllowedForMeta(param1)
349
+ || this.isAllowedForMetaConstructor(param1)
350
+ || A_TypeGuards.isString(param1)
351
+ || A_TypeGuards.isFunction(param1
352
+ ))
353
+ ) throw new A_ContextError(A_ContextError.InvalidMetaParameterError, `Invalid parameter provided to get meta. Component of type ${componentName} is not allowed for meta storage. Only A_Container, A_Component and A_Entity are allowed.`);
354
+
355
+ let property: A_TYPES__MetaLinkedComponentConstructors;
356
+ let metaType: typeof A_Meta<T> | typeof A_ContainerMeta | typeof A_ComponentMeta | typeof A_EntityMeta
240
357
 
241
358
  switch (true) {
242
359
  // 1) If param1 is instance of A_Container
243
- case param1 instanceof A_Container: {
244
-
245
- metaStorage = instance.containersMeta;
246
- property = param1.constructor;
360
+ case A_TypeGuards.isContainerInstance(param1): {
361
+ property = param1.constructor as A_TYPES__Container_Constructor;
247
362
  metaType = A_ContainerMeta;
248
363
 
249
364
  break;
250
365
  }
251
366
  // 2) If param1 is class of A_Container
252
- case A_CommonHelper.isInheritedFrom(param1, A_Container): {
253
- metaStorage = instance.containersMeta;
367
+ case A_TypeGuards.isContainerConstructor(param1): {
254
368
  property = param1 as typeof A_Container;
255
369
  metaType = A_ContainerMeta;
256
370
 
257
371
  break;
258
372
  }
259
373
  // 3) If param1 is instance of A_Component
260
- case param1 instanceof A_Component: {
261
- metaStorage = instance.componentsMeta;
262
- property = param1.constructor;
374
+ case A_TypeGuards.isComponentInstance(param1): {
375
+ property = param1.constructor as A_TYPES__Component_Constructor;
263
376
  metaType = A_ComponentMeta;
264
377
 
265
378
  break;
266
379
  }
267
380
  // 4) If param1 is class of A_Component
268
- case A_CommonHelper.isInheritedFrom(param1, A_Component): {
269
- metaStorage = instance.componentsMeta;
381
+ case A_TypeGuards.isComponentConstructor(param1): {
270
382
  property = param1 as typeof A_Component;
271
383
  metaType = A_ComponentMeta;
272
384
 
273
385
  break;
274
386
  }
275
387
  // 5) If param1 is instance of A_Entity
276
- case param1 instanceof A_Entity: {
277
- metaStorage = instance.entitiesMeta;
278
- property = param1.constructor;
388
+ case A_TypeGuards.isEntityInstance(param1): {
389
+ property = param1.constructor as A_TYPES__Entity_Constructor;
279
390
  metaType = A_ComponentMeta;
280
391
 
281
392
  break;
282
393
  }
283
394
  // 6) If param1 is class of A_Entity
284
- case A_CommonHelper.isInheritedFrom(param1, A_Entity): {
285
- metaStorage = instance.entitiesMeta;
286
- property = param1 as typeof A_Entity;
395
+ case A_TypeGuards.isEntityConstructor(param1): {
396
+ property = param1;
287
397
  metaType = A_EntityMeta;
288
398
 
289
399
  break;
290
400
  }
291
401
  // 7) If param1 is string then we need to find the component by its name
292
402
  case typeof param1 === 'string': {
293
- metaStorage = instance.componentsMeta;
294
- const found = Array.from(instance.componentsMeta).find(([c]) => c.name === param1)!;
295
- if (!(found && found.length)) throw new A_Error(`Component with name ${param1} not found`);
403
+ const found = Array.from(instance._metaStorage)
404
+ .find(([c]) => c.name === param1
405
+ || c.name === A_FormatterHelper.toKebabCase(param1)
406
+ || c.name === A_FormatterHelper.toPascalCase(param1)
407
+ )!;
408
+ if (!(found && found.length))
409
+ throw new A_ContextError(A_ContextError.InvalidMetaParameterError, `Invalid parameter provided to get meta. Component with name ${param1} not found in the meta storage.`);
410
+
296
411
  property = found[0];
297
412
  metaType = A_ComponentMeta;
298
413
 
@@ -300,22 +415,51 @@ export class A_Context {
300
415
  }
301
416
  // 8) If param1 is any other class or function
302
417
  default: {
303
- metaStorage = instance.customMeta;
304
- property = typeof (param1 as any) === 'function' ? param1 : param1.constructor;
418
+ property = param1;
305
419
  metaType = A_Meta;
306
420
 
307
421
  break;
308
422
  }
309
423
  }
310
424
 
311
-
312
- if (!metaStorage.has(property)) {
313
- const inheritMeta = metaStorage.get(Object.getPrototypeOf(property)) || new metaType();
314
- metaStorage.set(property, new metaType().from(inheritMeta as any));
425
+ // Check if the meta already exists for the property, if not create a new one
426
+ if (!instance._metaStorage.has(property)) {
427
+ const inheritMeta = instance._metaStorage.get(Object.getPrototypeOf(property)) || new metaType();
428
+ instance._metaStorage.set(property, new metaType().from(inheritMeta as any));
315
429
  }
316
430
 
431
+ // Return the meta for the property
432
+ return instance._metaStorage.get(property)!;
433
+ }
434
+
317
435
 
318
- return metaStorage.get(property)!;
436
+ /**
437
+ *
438
+ * This method allows to get the issuer of a specific scope.
439
+ *
440
+ * @param scope - Scope to get the issuer for.
441
+ * @returns - Component that issued the scope.
442
+ */
443
+ static issuer(
444
+ /**
445
+ * Provide the scope to get its issuer.
446
+ */
447
+ scope: A_Scope
448
+ ): A_TYPES__ScopeLinkedComponents {
449
+
450
+ const instance = this.getInstance();
451
+
452
+ if (!scope) throw new A_ContextError(
453
+ A_ContextError.InvalidComponentParameterError,
454
+ `Invalid parameter provided to get scope issuer. Parameter cannot be null or undefined.`
455
+ );
456
+
457
+ if (!instance._scopeIssuers.has(scope)) throw new A_ContextError(
458
+ A_ContextError.ScopeNotFoundError,
459
+ `Invalid parameter provided to get scope issuer. Provided scope does not have an issuer registered.`
460
+ );
461
+
462
+ return instance._scopeIssuers.get(scope)!;
319
463
  }
320
464
 
321
465
 
@@ -329,127 +473,221 @@ export class A_Context {
329
473
  *
330
474
  * @param entity
331
475
  */
332
- static scope(
333
- entity: A_Entity
476
+ static scope<T extends A_Entity>(
477
+ /**
478
+ * Provide an entity to get its scope.
479
+ */
480
+ entity: T
334
481
  ): A_Scope
335
- static scope(
336
- component: A_Component
482
+ static scope<T extends A_Component>(
483
+ /**
484
+ * Provide a component to get its scope.
485
+ */
486
+ component: T
337
487
  ): A_Scope
338
- static scope(
339
- container: A_Container
488
+ static scope<T extends A_Container>(
489
+ /**
490
+ * Provide a container to get its scope.
491
+ */
492
+ container: T
340
493
  ): A_Scope
341
- static scope(
342
- feature: A_Fragment
494
+ static scope<T extends A_Feature>(
495
+ /**
496
+ * Provide a feature to get its scope.
497
+ */
498
+ feature: T
343
499
  ): A_Scope
344
- static scope(
345
- feature: A_Feature
500
+ static scope<T extends A_Fragment>(
501
+ /**
502
+ * Provide a fragment to get its scope.
503
+ */
504
+ fragment: T
346
505
  ): A_Scope
347
- static scope(
348
- param1: A_Feature | A_Container | A_Component | A_Entity | A_Fragment
349
- ): A_Scope | undefined {
506
+ static scope<T extends A_TYPES__ScopeLinkedComponents | A_TYPES_ScopeDependentComponents>(
507
+ param1: T
508
+ ): A_Scope {
509
+
510
+ // for error messages
511
+ const name = (param1 as any)?.constructor?.name || String(param1);
350
512
 
513
+ // Get the instance of the context
351
514
  const instance = this.getInstance();
352
515
 
353
- switch (true) {
354
- case param1 instanceof A_Container:
355
- return instance.containers.get(param1);
516
+ // Input validation
517
+ if (!param1) throw new A_ContextError(A_ContextError.InvalidScopeParameterError, `Invalid parameter provided to get scope. Parameter cannot be null or undefined.`);
518
+
519
+ // Check if the parameter is allowed for scope allocation
520
+ if (!this.isAllowedForScopeAllocation(param1)
521
+ && !this.isAllowedToBeRegistered(param1)
522
+ )
523
+ throw new A_ContextError(A_ContextError.InvalidScopeParameterError, `Invalid parameter provided to get scope. Component of type ${name} is not allowed for scope allocation.`);
356
524
 
357
- case param1 instanceof A_Feature:
358
- return instance.features.get(param1);
525
+ switch (true) {
526
+ case this.isAllowedForScopeAllocation(param1):
359
527
 
360
- case param1 instanceof A_Entity:
361
- return instance.registry.get(param1);
528
+ // Check if the parameter has a scope allocated
529
+ if (!instance._registry.has(param1))
530
+ throw new A_ContextError(
531
+ A_ContextError.ScopeNotFoundError,
532
+ `Invalid parameter provided to get scope. Component of type ${name} does not have a scope allocated. Make sure to allocate a scope using A_Context.allocate() method before trying to get the scope.`
533
+ );
362
534
 
363
- case param1 instanceof A_Component:
364
- return instance.registry.get(param1);
535
+ // If the parameter is allowed for scope allocation, return the scope
536
+ return instance._registry.get(param1)!;
365
537
 
366
- case param1 instanceof A_Fragment:
367
- return instance.registry.get(param1);
538
+ case this.isAllowedToBeRegistered(param1):
368
539
 
369
- case param1 instanceof A_Command:
370
- return instance.commands.get(param1);
540
+ // Check if the parameter has a scope registered
541
+ if (!instance._scopeStorage.has(param1))
542
+ throw new A_ContextError(
543
+ A_ContextError.ScopeNotFoundError,
544
+ `Invalid parameter provided to get scope. Component of type ${name} does not have a scope registered. Make sure to register the component using A_Context.register() method before trying to get the scope.`
545
+ );
371
546
 
547
+ // If the parameter is allowed to be registered, return the scope from the storage
548
+ return instance._scopeStorage.get(param1)!;
372
549
  default:
373
- throw new Error(`[!] A-Concept Context: Unknown type of the parameter.`);
550
+ throw new A_ContextError(A_ContextError.InvalidScopeParameterError, `Invalid parameter provided to get scope. Component of type ${name} is not allowed to be registered.`);
374
551
  }
375
552
  }
376
553
 
377
554
 
555
+ // ==========================================================================================================
556
+ // ================================== FEATURE MANAGEMENT ====================================================
557
+ // ==========================================================================================================
558
+ // ----------------------------------------------------------------------------------------------------------
559
+ // -----------------------------------Primary Methods -------------------------------------------------------
560
+ // ----------------------------------------------------------------------------------------------------------
561
+ /**
562
+ * Returns a template of the feature that can be then used to create a new A-Feature Instance
563
+ *
564
+ * [!] Note: Steps/Stages included are fully dependent on the scope provided since it dictates which components are active and can provide extensions for the feature.
565
+ *
566
+ * @param name
567
+ */
568
+ static featureTemplate(
569
+ /**
570
+ * Provide the name of the feature to get the template for. Regular expressions are also supported to match multiple features.
571
+ */
572
+ name: string | RegExp,
573
+ /**
574
+ * Provide the component to get the feature template from.
575
+ */
576
+ component: A_TYPES__FeatureAvailableComponents,
577
+ /**
578
+ * Provide the scope that dictates which components are active and can provide extensions for the feature.
579
+ */
580
+ scope: A_Scope
581
+ ): Array<A_TYPES__A_StageStep> {
582
+ // name for error messages
583
+ const componentName = (component as any)?.constructor?.name || String(component);
584
+
585
+ // Input validation
586
+ if (!component) throw new A_ContextError(A_ContextError.InvalidFeatureTemplateParameterError, `Unable to get feature template. Component cannot be null or undefined.`);
587
+ if (!name) throw new A_ContextError(A_ContextError.InvalidFeatureTemplateParameterError, `Unable to get feature template. Feature name cannot be null or undefined.`);
588
+
589
+ // Check if the parameter is allowed for feature definition
590
+ if (!A_TypeGuards.isAllowedForFeatureDefinition(component))
591
+ throw new A_ContextError(A_ContextError.InvalidFeatureTemplateParameterError, `Unable to get feature template. Component of type ${componentName} is not allowed for feature definition.`);
592
+
593
+ const steps: A_TYPES__A_StageStep[] = [
594
+ // 1) Get the base feature definition from the component
595
+ ...this.featureDefinition(name, component),
596
+ // 2) Get all extensions for the feature from other components in the scope
597
+ ...this.featureExtensions(name, component, scope)
598
+ ];
599
+
600
+ return steps;
601
+ }
602
+ // ----------------------------------------------------------------------------------------------------------
603
+ // -----------------------------------Helper Methods --------------------------------------------------------
604
+ // ----------------------------------------------------------------------------------------------------------
378
605
  /**
379
- * This method returns a component by its meta.
606
+ * Returns all extensions for the specific feature in the specific component within the provided scope.
607
+ * Scope dictates which components are active and can provide extensions for the feature.
608
+ *
609
+ * [!] This method only returns extensions, not the base feature definition.
380
610
  *
381
- * @param meta
611
+ * @param scope
382
612
  * @returns
383
613
  */
384
- static component(
385
- meta: A_ComponentMeta
386
- ): typeof A_Component {
614
+ static featureExtensions(
615
+ /**
616
+ * Provide the name of the feature to get the template for. Regular expressions are also supported to match multiple features.
617
+ */
618
+ name: string | RegExp,
619
+ /**
620
+ * Provide the component to get the feature template from.
621
+ */
622
+ component: A_TYPES__FeatureAvailableComponents,
623
+ /**
624
+ * Provide the scope that dictates which components are active and can provide extensions for the feature.
625
+ */
626
+ scope: A_Scope
627
+ ): Array<A_TYPES__A_StageStep> {
628
+
387
629
  const instance = this.getInstance();
630
+ // name for error messages
631
+ const componentName = (component as any)?.constructor?.name || String(component);
388
632
 
389
- let component: typeof A_Component | undefined;
633
+ // Input validation
634
+ if (!component) throw new A_ContextError(A_ContextError.InvalidFeatureExtensionParameterError, `Unable to get feature template. Component cannot be null or undefined.`);
635
+ if (!name) throw new A_ContextError(A_ContextError.InvalidFeatureExtensionParameterError, `Unable to get feature template. Feature name cannot be null or undefined.`);
390
636
 
391
- instance.componentsMeta.forEach((meta, constructor) => {
392
- if (meta === meta) {
393
- component = constructor;
394
- }
395
- });
637
+ // Check if the parameter is allowed for feature definition
638
+ if (!A_TypeGuards.isAllowedForFeatureDefinition(component))
639
+ throw new A_ContextError(A_ContextError.InvalidFeatureExtensionParameterError, `Unable to get feature template. Component of type ${componentName} is not allowed for feature definition.`);
396
640
 
397
- if (!component) {
398
- throw new Error(`[!] A-Concept Context: Component not found.`);
399
- }
400
- return component;
401
- }
641
+ const callName = `${component.constructor.name}.${name}`;
402
642
 
643
+ const steps: A_TYPES__A_StageStep[] = [];
403
644
 
645
+ // We need to get all components that has extensions for the feature in component
646
+ for (const [component, meta] of instance._metaStorage) {
647
+ // Just try to make sure that component not only Indexed but also presented in scope
648
+ if (scope.has(component) && A_TypeGuards.isComponentMetaInstance(meta))
649
+ // Get all extensions for the feature
650
+ meta
651
+ .extensions(callName)
652
+ .forEach((declaration) => {
653
+ steps.push({
654
+ component,
655
+ ...declaration
656
+ });
657
+ });
658
+ }
659
+
660
+ return steps;
661
+ }
404
662
  /**
405
- * This method returns a constructor params to create a new feature
663
+ * This method returns the feature template definition without any extensions.
664
+ * It can be used to retrieve the base template for a feature before any modifications are applied.
406
665
  *
407
- * @param scope
666
+ * [!] This method does not consider extensions from other components.
667
+ *
668
+ * @param feature
669
+ * @param component
408
670
  * @returns
409
671
  */
410
672
  static featureDefinition(
411
- component: A_Component | A_Container | A_Entity,
673
+ /**
674
+ * Name of the feature to get the template for.
675
+ * Regular expressions are also supported to match multiple features.
676
+ */
412
677
  feature: string | RegExp,
413
- scope: A_Scope
414
- ): A_TYPES__FeatureConstructor {
415
- const instance = this.getInstance();
416
-
417
- const name = `${component.constructor.name}.${feature}`;
418
-
419
-
420
- /**
421
- * Important NOTE::: Component Scope and Parent Scope are different things.
422
- *
423
- * Component Scope is a scope where Component Registered.
424
- * Parent Scope is a scope From Where Feature Requested.
425
- *
426
- *
427
- * Example: ComponentA registered in ScopeA of ContainerA.
428
- * When FeatureA Requested from ContainerA, then Parent Scope is ScopeA For the FeatureA [!]
429
- * BUT In FeatureA may be used ComponentB with FeatureB.
430
- *
431
- *
432
- * ------------------------------Execution-----------------------------------------------------------
433
- * ContainerA -> FeatureA -> ComponentA -> FeatureB -> ComponentB
434
- * - Scope:ScopeA -> - Scope: FeatA -> - Scope: ScopeA -> - Scope: FeatB -> - Scope: ScopeA
435
- * - Parent: ScopeA -> - Parent: ROOT -> - Parent: FeatA -> - Parent: ROOT
436
- * --------------------------------------------------------------------------------------------------
437
- *
438
- * So ComponentA and ComponentB are registered in the SAME scope of ContainerA.
439
- * But Each Feature has its own Scope and Parent Scope.
440
- *
441
- *
442
- * Component AND Entity DO [!] NOT HAVE THEIR OWN SCOPE.
443
- *
444
- * Feature AND Container HAVE OWN SCOPE.
445
- *
446
- *
447
- * So Parent can come from the Container or from the Feature.
448
- * While Scope we use just to store the scope where the component registered.
449
- *
678
+ /**
679
+ * Component to get the feature template from.
450
680
  */
681
+ component: A_TYPES__FeatureAvailableComponents,
682
+ ): Array<A_TYPES__A_StageStep> {
451
683
  let metaKey;
452
684
 
685
+ if (!feature)
686
+ throw new A_ContextError(A_ContextError.InvalidFeatureTemplateParameterError, `Unable to get feature template. Feature name cannot be null or undefined.`);
687
+ if (!component)
688
+ throw new A_ContextError(A_ContextError.InvalidFeatureTemplateParameterError, `Unable to get feature template. Component cannot be null or undefined.`);
689
+
690
+
453
691
  switch (true) {
454
692
  case component instanceof A_Entity:
455
693
  metaKey = A_TYPES__EntityMetaKey.FEATURES;
@@ -460,210 +698,208 @@ export class A_Context {
460
698
  case component instanceof A_Component:
461
699
  metaKey = A_TYPES__ComponentMetaKey.FEATURES
462
700
  break;
463
- case component instanceof A_Command:
464
- metaKey = A_TYPES__CommandMetaKey.FEATURES
465
- break;
466
701
 
467
702
  default:
468
- throw new Error(`A-Feature cannot be defined on the ${component} level`);
703
+ throw new A_ContextError(A_ContextError.InvalidFeatureTemplateParameterError, `A-Feature cannot be defined on the ${component} level`);
469
704
  }
470
705
 
471
- const featureDefinition: A_TYPES__A_DefineDecorator_Meta | undefined = this
472
- .meta(component)
706
+ const featureDefinition: A_TYPES__FeatureDefineDecoratorMeta | undefined = this.meta(component)
473
707
  ?.get(metaKey)
474
708
  ?.get(feature);
475
709
 
476
-
477
- const steps: A_TYPES__A_StageStep[] = [
710
+ return [
478
711
  ...(featureDefinition?.template || [])
479
712
  ];
480
- // const feature: string = new ASEID({
481
- // id: `${param2}-${Math.random()}`,
482
- // entity: 'a-feature',
483
- // namespace: component.constructor.name,
484
- // scope: scope.name
485
- // }).toString();
486
-
487
-
488
- // Now we need to resolve the method from all registered components
489
-
490
- // We need to get all components that has extensions for the feature in component
491
- instance.componentsMeta
492
- .forEach((meta, constructor) => {
493
- // Just try to make sure that component not only Indexed but also presented in scope
494
- if (scope.has(constructor))
495
- // Get all extensions for the feature
496
- meta
497
- .extensions(name)
498
- .forEach((declaration) => {
499
- steps.push({
500
- component: constructor,
501
- ...declaration
502
- });
503
- });
504
- });
505
-
506
-
507
-
508
- return { name, steps, scope, caller: component };
509
713
  }
510
714
 
715
+ // ==========================================================================================================
716
+ // ================================== ABSTRACTION MANAGEMENT =================================================
717
+ // ==========================================================================================================
718
+ // ----------------------------------------------------------------------------------------------------------
719
+ // -----------------------------------Primary Methods -------------------------------------------------------
720
+ // ----------------------------------------------------------------------------------------------------------
511
721
  /**
512
- * This method returns a constructor params to create a new feature
722
+ * Returns a definition of the abstraction that can be then used to create a new A-Feature Instance
513
723
  *
514
- * @param scope
515
- * @returns
724
+ * [!] Note: Steps/Stages included are fully dependent on the scope provided since it dictates which components are active and can provide extensions for the abstraction.
725
+ *
726
+ * @param abstraction
516
727
  */
517
- static abstractionDefinition(
518
- component: A_Component | A_Container | A_Entity | A_Command,
519
- abstraction: A_TYPES__ConceptStage,
728
+ static abstractionTemplate(
729
+ /**
730
+ * Provide the abstraction stage to get the definition for.
731
+ */
732
+ abstraction: A_TYPES__ConceptAbstraction,
733
+ /**
734
+ * Provide the component to get the abstraction definition from.
735
+ */
736
+ component: A_TYPES__FeatureAvailableComponents,
737
+ /**
738
+ * Provide the scope that dictates which components are active and can provide extensions for the abstraction.
739
+ */
520
740
  scope: A_Scope
521
- ): A_TYPES__FeatureConstructor {
522
- const instance = this.getInstance();
741
+ ): Array<A_TYPES__A_StageStep> {
742
+ // name for error messages
743
+ const componentName = (component as any)?.constructor?.name || String(component);
523
744
 
524
- const name = `${component.constructor.name}.${abstraction}`;
525
-
526
- let metaKey;
527
-
528
- switch (true) {
529
- case component instanceof A_Entity:
530
- metaKey = A_TYPES__EntityMetaKey.FEATURES;
531
- break;
532
- case component instanceof A_Container:
533
- metaKey = A_TYPES__ContainerMetaKey.ABSTRACTIONS
534
- break;
535
- case component instanceof A_Component:
536
- metaKey = A_TYPES__ComponentMetaKey.ABSTRACTIONS
537
- break;
538
- case component instanceof A_Command:
539
- metaKey = A_TYPES__CommandMetaKey.ABSTRACTIONS
540
- break;
541
- default:
542
- throw new Error(`A-Feature cannot be defined on the ${component} level`);
543
- }
745
+ // Input validation
746
+ if (!component) throw new A_ContextError(
747
+ A_ContextError.InvalidAbstractionTemplateParameterError,
748
+ `Unable to get feature template. Component cannot be null or undefined.`);
544
749
 
545
- const featureDefinition = this.meta(component)
546
- .get(metaKey)
547
- .get(abstraction) || []
750
+ if (!abstraction) throw new A_ContextError(
751
+ A_ContextError.InvalidAbstractionTemplateParameterError,
752
+ `Unable to get feature template. Abstraction stage cannot be null or undefined.`);
548
753
 
754
+ // Check if the parameter is allowed for feature definition
755
+ if (!A_TypeGuards.isAllowedForAbstractionDefinition(component))
756
+ throw new A_ContextError(A_ContextError.InvalidAbstractionTemplateParameterError, `Unable to get feature template. Component of type ${componentName} is not allowed for feature definition.`);
549
757
 
550
758
  const steps: A_TYPES__A_StageStep[] = [
551
- ...featureDefinition
552
- ];
553
-
554
-
555
- // We need to get all components that has extensions for the feature in component
556
- instance.componentsMeta
557
- .forEach((meta, constructor) => {
558
- // Just try to make sure that component not only Indexed but also presented in scope
559
- if (scope.has(constructor))
560
- // Get all extensions for the feature
561
- meta
562
- .abstractions(name)
563
- .forEach((declaration) => {
564
- steps.push({
565
- component: constructor,
566
- ...declaration
567
- });
568
- });
569
- });
759
+ // 1) Get the base abstraction definition from the component
760
+ // [!] No abstraction Definitions -> They are limited to Concept Abstractions ONLY
761
+ // ...this.abstractionDefinition(abstraction, component),
570
762
 
763
+ // 2) Get all extensions for the abstraction from other components in the scope
764
+ ...this.abstractionExtensions(abstraction, component, scope)
765
+ ];
571
766
 
572
- return { name, steps, scope, caller: component };
767
+ return steps;
573
768
  }
574
769
 
575
- /**
576
- * This method returns a step-by-step instructions of feature implementation depending on the feature name and the class.
577
- *
578
- * @param scope
579
- * @returns
580
- */
581
- static feature<T extends Array<string>>(
582
- component: A_Component | A_Container | A_Entity<any, any>,
583
- feature: string | T[number] | RegExp,
770
+ // ----------------------------------------------------------------------------------------------------------
771
+ // -----------------------------------Helper Methods --------------------------------------------------------
772
+ // ----------------------------------------------------------------------------------------------------------
773
+
774
+ static abstractionExtensions(
775
+ /**
776
+ * Provide the abstraction name to get the definition for.
777
+ */
778
+ abstraction: A_TYPES__ConceptAbstraction,
779
+ /**
780
+ * Provide the component to get the abstraction definition from.
781
+ */
782
+ component: A_TYPES__FeatureAvailableComponents,
783
+ /**
784
+ * Provide the scope that dictates which components are active and can provide extensions for the abstraction.
785
+ */
584
786
  scope: A_Scope
585
- ): A_Feature {
586
- const featureConstructor = this.featureDefinition(component, feature, scope);
787
+ ): Array<A_TYPES__A_StageStep> {
788
+ const instance = this.getInstance();
789
+ // name for error messages
790
+ const componentName = (component as any)?.constructor?.name || String(component);
791
+
792
+ // Input validation
793
+ if (!component) throw new A_ContextError(
794
+ A_ContextError.InvalidAbstractionExtensionParameterError,
795
+ `Unable to get feature template. Component cannot be null or undefined.`
796
+ );
797
+ if (!abstraction) throw new A_ContextError(
798
+ A_ContextError.InvalidAbstractionExtensionParameterError,
799
+ `Unable to get feature template. Abstraction stage cannot be null or undefined.`
800
+ );
801
+ // Check if the parameter is allowed for feature definition
802
+ if (!A_TypeGuards.isAllowedForAbstractionDefinition(component))
803
+ throw new A_ContextError
804
+ (A_ContextError.InvalidAbstractionExtensionParameterError,
805
+ `Unable to get feature template. Component of type ${componentName} is not allowed for feature definition.`
806
+ );
807
+
808
+ const callName = `${component.constructor.name}.${abstraction}`;
809
+
810
+ const steps: A_TYPES__A_StageStep[] = [];
587
811
 
588
- const newFeature = new A_Feature(featureConstructor);
812
+ // We need to get all components that has extensions for the feature in component
813
+ for (const [component, meta] of instance._metaStorage) {
814
+ // Just try to make sure that component not only Indexed but also presented in scope
815
+ if (scope.has(component) && A_TypeGuards.isComponentMetaInstance(meta))
816
+ // Get all extensions for the feature
817
+ meta
818
+ .abstractions(callName)
819
+ .forEach((declaration) => {
820
+ steps.push({
821
+ component,
822
+ ...declaration
823
+ });
824
+ });
825
+ }
589
826
 
590
- return newFeature;
827
+ return steps;
591
828
  }
592
829
 
593
830
 
594
831
 
595
832
  /**
596
- * Register a Namespace in the provider.
597
- * @param Namespace
833
+ * Resets the Context to its initial state.
598
834
  */
599
- static register(
600
- scope: A_Scope,
601
- container: A_Container
602
- )
603
- static register(
604
- scope: A_Scope,
605
- entity: A_Entity
606
- )
607
- static register(
608
- scope: A_Scope,
609
- component: A_Component
610
- )
611
- static register(
612
- scope: A_Scope,
613
- fragment: A_Fragment
614
- )
615
- static register(
616
- scope: A_Scope,
617
- param1: A_Fragment | A_Container | A_Entity | A_Component
618
- ) {
619
- const instance = this.getInstance();
835
+ static reset() {
836
+ const instance = A_Context.getInstance();
620
837
 
621
- // if (!instance._root)
622
- // instance._root = scope.name;
838
+ instance._registry = new WeakMap();
839
+ instance._metaStorage = new Map();
623
840
 
624
- switch (true) {
625
- case param1 instanceof A_Component:
626
- instance.registry.set(param1, scope);
627
- break;
841
+ let name = 'root';
628
842
 
629
- case param1 instanceof A_Container:
630
- instance.registry.set(param1, scope);
631
- break;
843
+ if (A_Context.environment === 'server')
844
+ name = process.env[A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_ROOT_SCOPE] || 'root';
632
845
 
633
- case param1 instanceof A_Entity:
634
- instance.registry.set(param1, scope);
635
- break;
846
+ if (A_Context.environment === 'browser')
847
+ name = (window as any)[A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_ROOT_SCOPE] || 'root';
636
848
 
637
- case param1 instanceof A_Fragment && !instance.registry.has(param1):
638
- instance.registry.set(param1, scope);
639
- break;
849
+ instance._root = new A_Scope({ name });
850
+ }
640
851
 
641
- default:
642
- if (!instance.registry.has(param1))
643
- instance.registry.set(param1, scope);
644
852
 
645
- break;
646
- }
647
- }
648
853
 
649
854
 
855
+ // ====================================================================================================================
856
+ // ====================================== HELPERS & GUARDS ============================================================
857
+ // ====================================================================================================================
650
858
  /**
651
- * Resets the Context to its initial state.
859
+ * Type guard to check if the param is allowed for scope allocation.
860
+ *
861
+ * @param param
862
+ * @returns
652
863
  */
653
- static reset() {
654
- const instance = A_Context.getInstance();
864
+ static isAllowedForScopeAllocation(param: any): param is A_TYPES__ScopeLinkedComponents {
865
+ return A_TypeGuards.isContainerInstance(param)
866
+ || A_TypeGuards.isFeatureInstance(param);
867
+ }
868
+ /**
869
+ * Type guard to check if the param is allowed to be registered in the context.
870
+ *
871
+ * @param param
872
+ * @returns
873
+ */
874
+ static isAllowedToBeRegistered(param: any): param is A_TYPES_ScopeDependentComponents {
875
+ return A_TypeGuards.isEntityInstance(param)
876
+ || A_TypeGuards.isComponentInstance(param)
877
+ || A_TypeGuards.isFragmentInstance(param);
878
+ }
879
+
880
+ /**
881
+ * Type guard to check if the param is allowed for meta storage.
882
+ *
883
+ * @param param
884
+ * @returns
885
+ */
886
+ static isAllowedForMeta(param: any): param is A_TYPES__MetaLinkedComponents {
887
+ return A_TypeGuards.isContainerInstance(param)
888
+ || A_TypeGuards.isComponentInstance(param)
889
+ || A_TypeGuards.isEntityInstance(param);
890
+ }
891
+ /**
892
+ * Type guard to check if the param is allowed for meta storage by constructor.
893
+ *
894
+ * @param param
895
+ * @returns
896
+ */
897
+ static isAllowedForMetaConstructor(param: any): param is A_TYPES__MetaLinkedComponentConstructors {
898
+ return A_TypeGuards.isContainerConstructor(param)
899
+ || A_TypeGuards.isComponentConstructor(param)
900
+ || A_TypeGuards.isEntityConstructor(param);
901
+ }
655
902
 
656
- instance.containers = new WeakMap();
657
- instance.features = new WeakMap();
658
- instance.registry = new WeakMap();
659
- instance.containersMeta = new Map();
660
- instance.componentsMeta = new Map();
661
- instance.entitiesMeta = new Map();
662
- instance.customMeta = new Map();
663
903
 
664
- instance._root = new A_Scope({
665
- name: process && process.env ? process.env[A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_NAMESPACE] || 'a-concept' : 'a-concept'
666
- });
667
904
 
668
- }
669
905
  }