@adaas/a-concept 0.1.23 → 0.1.25

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 (234) hide show
  1. package/dist/index.cjs +3 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.mts +3952 -0
  4. package/dist/index.d.ts +3952 -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 +18 -13
  9. package/src/global/A-Component/A-Component.meta.ts +3 -2
  10. package/src/global/A-Container/A-Container.meta.ts +5 -8
  11. package/src/global/A-Context/A-Context.class.ts +81 -7
  12. package/src/global/A-Context/A-Context.error.ts +4 -0
  13. package/src/global/A-Dependency/A-Dependency-Default.decorator.ts +75 -0
  14. package/src/global/A-Dependency/A-Dependency-Load.decorator.ts +80 -0
  15. package/src/global/A-Dependency/A-Dependency-Require.decorator.ts +68 -0
  16. package/src/global/A-Dependency/A-Dependency.class.ts +33 -0
  17. package/src/global/A-Dependency/A-Dependency.error.ts +13 -0
  18. package/src/global/A-Dependency/A-Dependency.types.ts +28 -0
  19. package/src/global/A-Entity/A-Entity.class.ts +2 -1
  20. package/src/global/A-Feature/A-Feature-Define.decorator.ts +7 -4
  21. package/src/global/A-Feature/A-Feature-Extend.decorator.ts +23 -17
  22. package/src/global/A-Feature/A-Feature.class.ts +12 -1
  23. package/src/global/A-Feature/A-Feature.types.ts +33 -8
  24. package/src/global/A-Inject/A-Inject.decorator.ts +4 -2
  25. package/src/global/A-Inject/A-Inject.types.ts +5 -3
  26. package/src/global/A-Scope/A-Scope.class.ts +85 -57
  27. package/src/global/A-Stage/A-Stage.class.ts +22 -2
  28. package/src/global/A-Stage/A-Stage.error.ts +2 -0
  29. package/src/global/A-Stage/A-Stage.types.ts +7 -2
  30. package/src/global/A-StepManager/A-StepManager.class.ts +19 -13
  31. package/src/helpers/A_Common.helper.ts +101 -0
  32. package/src/helpers/A_TypeGuards.helper.ts +8 -0
  33. package/src/index.ts +88 -0
  34. package/tests/A-Component.test.ts +1 -1
  35. package/tests/A-Concept.test.ts +58 -10
  36. package/tests/A-Dependency.test.ts +93 -0
  37. package/tests/A-Feature.test.ts +11 -11
  38. package/tests/A-Scope.test.ts +10 -10
  39. package/tests/A-StepManager.test.ts +60 -11
  40. package/tsconfig.json +2 -2
  41. package/tsup.config.ts +32 -0
  42. package/dist/index.js +0 -112
  43. package/dist/index.js.map +0 -1
  44. package/dist/src/constants/env.constants.d.ts +0 -33
  45. package/dist/src/constants/env.constants.js +0 -47
  46. package/dist/src/constants/env.constants.js.map +0 -1
  47. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.d.ts +0 -23
  48. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js +0 -89
  49. package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js.map +0 -1
  50. package/dist/src/global/A-Abstraction/A-Abstraction.class.d.ts +0 -74
  51. package/dist/src/global/A-Abstraction/A-Abstraction.class.js +0 -130
  52. package/dist/src/global/A-Abstraction/A-Abstraction.class.js.map +0 -1
  53. package/dist/src/global/A-Abstraction/A-Abstraction.error.d.ts +0 -7
  54. package/dist/src/global/A-Abstraction/A-Abstraction.error.js +0 -12
  55. package/dist/src/global/A-Abstraction/A-Abstraction.error.js.map +0 -1
  56. package/dist/src/global/A-Abstraction/A-Abstraction.types.d.ts +0 -38
  57. package/dist/src/global/A-Abstraction/A-Abstraction.types.js +0 -3
  58. package/dist/src/global/A-Abstraction/A-Abstraction.types.js.map +0 -1
  59. package/dist/src/global/A-Caller/A_Caller.class.d.ts +0 -33
  60. package/dist/src/global/A-Caller/A_Caller.class.js +0 -44
  61. package/dist/src/global/A-Caller/A_Caller.class.js.map +0 -1
  62. package/dist/src/global/A-Caller/A_Caller.error.d.ts +0 -7
  63. package/dist/src/global/A-Caller/A_Caller.error.js +0 -12
  64. package/dist/src/global/A-Caller/A_Caller.error.js.map +0 -1
  65. package/dist/src/global/A-Caller/A_Caller.types.d.ts +0 -18
  66. package/dist/src/global/A-Caller/A_Caller.types.js +0 -3
  67. package/dist/src/global/A-Caller/A_Caller.types.js.map +0 -1
  68. package/dist/src/global/A-Component/A-Component.class.d.ts +0 -34
  69. package/dist/src/global/A-Component/A-Component.class.js +0 -56
  70. package/dist/src/global/A-Component/A-Component.class.js.map +0 -1
  71. package/dist/src/global/A-Component/A-Component.constants.d.ts +0 -6
  72. package/dist/src/global/A-Component/A-Component.constants.js +0 -11
  73. package/dist/src/global/A-Component/A-Component.constants.js.map +0 -1
  74. package/dist/src/global/A-Component/A-Component.meta.d.ts +0 -34
  75. package/dist/src/global/A-Component/A-Component.meta.js +0 -77
  76. package/dist/src/global/A-Component/A-Component.meta.js.map +0 -1
  77. package/dist/src/global/A-Component/A-Component.types.d.ts +0 -76
  78. package/dist/src/global/A-Component/A-Component.types.js +0 -4
  79. package/dist/src/global/A-Component/A-Component.types.js.map +0 -1
  80. package/dist/src/global/A-Concept/A-Concept.class.d.ts +0 -153
  81. package/dist/src/global/A-Concept/A-Concept.class.js +0 -260
  82. package/dist/src/global/A-Concept/A-Concept.class.js.map +0 -1
  83. package/dist/src/global/A-Concept/A-Concept.constants.d.ts +0 -33
  84. package/dist/src/global/A-Concept/A-Concept.constants.js +0 -39
  85. package/dist/src/global/A-Concept/A-Concept.constants.js.map +0 -1
  86. package/dist/src/global/A-Concept/A-Concept.meta.d.ts +0 -6
  87. package/dist/src/global/A-Concept/A-Concept.meta.js +0 -12
  88. package/dist/src/global/A-Concept/A-Concept.meta.js.map +0 -1
  89. package/dist/src/global/A-Concept/A-Concept.types.d.ts +0 -66
  90. package/dist/src/global/A-Concept/A-Concept.types.js +0 -3
  91. package/dist/src/global/A-Concept/A-Concept.types.js.map +0 -1
  92. package/dist/src/global/A-Container/A-Container.class.d.ts +0 -52
  93. package/dist/src/global/A-Container/A-Container.class.js +0 -78
  94. package/dist/src/global/A-Container/A-Container.class.js.map +0 -1
  95. package/dist/src/global/A-Container/A-Container.constants.d.ts +0 -6
  96. package/dist/src/global/A-Container/A-Container.constants.js +0 -11
  97. package/dist/src/global/A-Container/A-Container.constants.js.map +0 -1
  98. package/dist/src/global/A-Container/A-Container.meta.d.ts +0 -35
  99. package/dist/src/global/A-Container/A-Container.meta.js +0 -83
  100. package/dist/src/global/A-Container/A-Container.meta.js.map +0 -1
  101. package/dist/src/global/A-Container/A-Container.types.d.ts +0 -75
  102. package/dist/src/global/A-Container/A-Container.types.js +0 -4
  103. package/dist/src/global/A-Container/A-Container.types.js.map +0 -1
  104. package/dist/src/global/A-Context/A-Context.class.d.ts +0 -361
  105. package/dist/src/global/A-Context/A-Context.class.js +0 -603
  106. package/dist/src/global/A-Context/A-Context.class.js.map +0 -1
  107. package/dist/src/global/A-Context/A-Context.error.d.ts +0 -20
  108. package/dist/src/global/A-Context/A-Context.error.js +0 -25
  109. package/dist/src/global/A-Context/A-Context.error.js.map +0 -1
  110. package/dist/src/global/A-Context/A-Context.types.d.ts +0 -5
  111. package/dist/src/global/A-Context/A-Context.types.js +0 -3
  112. package/dist/src/global/A-Context/A-Context.types.js.map +0 -1
  113. package/dist/src/global/A-Dependency/A-DependencyReference.class.d.ts +0 -0
  114. package/dist/src/global/A-Dependency/A-DependencyReference.class.js +0 -49
  115. package/dist/src/global/A-Dependency/A-DependencyReference.class.js.map +0 -1
  116. package/dist/src/global/A-Dependency/A-DependencyReference.types.d.ts +0 -0
  117. package/dist/src/global/A-Dependency/A-DependencyReference.types.js +0 -58
  118. package/dist/src/global/A-Dependency/A-DependencyReference.types.js.map +0 -1
  119. package/dist/src/global/A-Entity/A-Entity.class.d.ts +0 -214
  120. package/dist/src/global/A-Entity/A-Entity.class.js +0 -281
  121. package/dist/src/global/A-Entity/A-Entity.class.js.map +0 -1
  122. package/dist/src/global/A-Entity/A-Entity.constants.d.ts +0 -11
  123. package/dist/src/global/A-Entity/A-Entity.constants.js +0 -17
  124. package/dist/src/global/A-Entity/A-Entity.constants.js.map +0 -1
  125. package/dist/src/global/A-Entity/A-Entity.error.d.ts +0 -7
  126. package/dist/src/global/A-Entity/A-Entity.error.js +0 -12
  127. package/dist/src/global/A-Entity/A-Entity.error.js.map +0 -1
  128. package/dist/src/global/A-Entity/A-Entity.meta.d.ts +0 -11
  129. package/dist/src/global/A-Entity/A-Entity.meta.js +0 -18
  130. package/dist/src/global/A-Entity/A-Entity.meta.js.map +0 -1
  131. package/dist/src/global/A-Entity/A-Entity.types.d.ts +0 -56
  132. package/dist/src/global/A-Entity/A-Entity.types.js +0 -5
  133. package/dist/src/global/A-Entity/A-Entity.types.js.map +0 -1
  134. package/dist/src/global/A-Error/A_Error.class.d.ts +0 -229
  135. package/dist/src/global/A-Error/A_Error.class.js +0 -296
  136. package/dist/src/global/A-Error/A_Error.class.js.map +0 -1
  137. package/dist/src/global/A-Error/A_Error.constants.d.ts +0 -5
  138. package/dist/src/global/A-Error/A_Error.constants.js +0 -9
  139. package/dist/src/global/A-Error/A_Error.constants.js.map +0 -1
  140. package/dist/src/global/A-Error/A_Error.types.d.ts +0 -93
  141. package/dist/src/global/A-Error/A_Error.types.js +0 -3
  142. package/dist/src/global/A-Error/A_Error.types.js.map +0 -1
  143. package/dist/src/global/A-Feature/A-Feature-Define.decorator.d.ts +0 -15
  144. package/dist/src/global/A-Feature/A-Feature-Define.decorator.js +0 -76
  145. package/dist/src/global/A-Feature/A-Feature-Define.decorator.js.map +0 -1
  146. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.d.ts +0 -56
  147. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js +0 -119
  148. package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js.map +0 -1
  149. package/dist/src/global/A-Feature/A-Feature.class.d.ts +0 -175
  150. package/dist/src/global/A-Feature/A-Feature.class.js +0 -318
  151. package/dist/src/global/A-Feature/A-Feature.class.js.map +0 -1
  152. package/dist/src/global/A-Feature/A-Feature.error.d.ts +0 -25
  153. package/dist/src/global/A-Feature/A-Feature.error.js +0 -33
  154. package/dist/src/global/A-Feature/A-Feature.error.js.map +0 -1
  155. package/dist/src/global/A-Feature/A-Feature.types.d.ts +0 -310
  156. package/dist/src/global/A-Feature/A-Feature.types.js +0 -26
  157. package/dist/src/global/A-Feature/A-Feature.types.js.map +0 -1
  158. package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +0 -36
  159. package/dist/src/global/A-Fragment/A-Fragment.class.js +0 -46
  160. package/dist/src/global/A-Fragment/A-Fragment.class.js.map +0 -1
  161. package/dist/src/global/A-Fragment/A-Fragment.types.d.ts +0 -21
  162. package/dist/src/global/A-Fragment/A-Fragment.types.js +0 -6
  163. package/dist/src/global/A-Fragment/A-Fragment.types.js.map +0 -1
  164. package/dist/src/global/A-Inject/A-Inject.decorator.d.ts +0 -80
  165. package/dist/src/global/A-Inject/A-Inject.decorator.js +0 -49
  166. package/dist/src/global/A-Inject/A-Inject.decorator.js.map +0 -1
  167. package/dist/src/global/A-Inject/A-Inject.error.d.ts +0 -5
  168. package/dist/src/global/A-Inject/A-Inject.error.js +0 -10
  169. package/dist/src/global/A-Inject/A-Inject.error.js.map +0 -1
  170. package/dist/src/global/A-Inject/A-Inject.types.d.ts +0 -42
  171. package/dist/src/global/A-Inject/A-Inject.types.js +0 -3
  172. package/dist/src/global/A-Inject/A-Inject.types.js.map +0 -1
  173. package/dist/src/global/A-Meta/A-Meta.class.d.ts +0 -97
  174. package/dist/src/global/A-Meta/A-Meta.class.js +0 -164
  175. package/dist/src/global/A-Meta/A-Meta.class.js.map +0 -1
  176. package/dist/src/global/A-Meta/A-Meta.types.d.ts +0 -14
  177. package/dist/src/global/A-Meta/A-Meta.types.js +0 -3
  178. package/dist/src/global/A-Meta/A-Meta.types.js.map +0 -1
  179. package/dist/src/global/A-Scope/A-Scope.class.d.ts +0 -466
  180. package/dist/src/global/A-Scope/A-Scope.class.js +0 -791
  181. package/dist/src/global/A-Scope/A-Scope.class.js.map +0 -1
  182. package/dist/src/global/A-Scope/A-Scope.error.d.ts +0 -8
  183. package/dist/src/global/A-Scope/A-Scope.error.js +0 -13
  184. package/dist/src/global/A-Scope/A-Scope.error.js.map +0 -1
  185. package/dist/src/global/A-Scope/A-Scope.types.d.ts +0 -81
  186. package/dist/src/global/A-Scope/A-Scope.types.js +0 -3
  187. package/dist/src/global/A-Scope/A-Scope.types.js.map +0 -1
  188. package/dist/src/global/A-Stage/A-Stage.class.d.ts +0 -112
  189. package/dist/src/global/A-Stage/A-Stage.class.js +0 -240
  190. package/dist/src/global/A-Stage/A-Stage.class.js.map +0 -1
  191. package/dist/src/global/A-Stage/A-Stage.error.d.ts +0 -4
  192. package/dist/src/global/A-Stage/A-Stage.error.js +0 -11
  193. package/dist/src/global/A-Stage/A-Stage.error.js.map +0 -1
  194. package/dist/src/global/A-Stage/A-Stage.types.d.ts +0 -97
  195. package/dist/src/global/A-Stage/A-Stage.types.js +0 -43
  196. package/dist/src/global/A-Stage/A-Stage.types.js.map +0 -1
  197. package/dist/src/global/A-StepManager/A-StepManager.class.d.ts +0 -20
  198. package/dist/src/global/A-StepManager/A-StepManager.class.js +0 -111
  199. package/dist/src/global/A-StepManager/A-StepManager.class.js.map +0 -1
  200. package/dist/src/global/A-StepManager/A-StepManager.error.d.ts +0 -4
  201. package/dist/src/global/A-StepManager/A-StepManager.error.js +0 -9
  202. package/dist/src/global/A-StepManager/A-StepManager.error.js.map +0 -1
  203. package/dist/src/global/ASEID/ASEID.class.d.ts +0 -130
  204. package/dist/src/global/ASEID/ASEID.class.js +0 -167
  205. package/dist/src/global/ASEID/ASEID.class.js.map +0 -1
  206. package/dist/src/global/ASEID/ASEID.constants.d.ts +0 -0
  207. package/dist/src/global/ASEID/ASEID.constants.js +0 -2
  208. package/dist/src/global/ASEID/ASEID.constants.js.map +0 -1
  209. package/dist/src/global/ASEID/ASEID.error.d.ts +0 -5
  210. package/dist/src/global/ASEID/ASEID.error.js +0 -10
  211. package/dist/src/global/ASEID/ASEID.error.js.map +0 -1
  212. package/dist/src/global/ASEID/ASEID.types.d.ts +0 -65
  213. package/dist/src/global/ASEID/ASEID.types.js +0 -5
  214. package/dist/src/global/ASEID/ASEID.types.js.map +0 -1
  215. package/dist/src/helpers/A_Common.helper.d.ts +0 -28
  216. package/dist/src/helpers/A_Common.helper.js +0 -170
  217. package/dist/src/helpers/A_Common.helper.js.map +0 -1
  218. package/dist/src/helpers/A_Formatter.helper.d.ts +0 -35
  219. package/dist/src/helpers/A_Formatter.helper.js +0 -62
  220. package/dist/src/helpers/A_Formatter.helper.js.map +0 -1
  221. package/dist/src/helpers/A_Identity.helper.d.ts +0 -29
  222. package/dist/src/helpers/A_Identity.helper.js +0 -43
  223. package/dist/src/helpers/A_Identity.helper.js.map +0 -1
  224. package/dist/src/helpers/A_TypeGuards.helper.d.ts +0 -207
  225. package/dist/src/helpers/A_TypeGuards.helper.js +0 -296
  226. package/dist/src/helpers/A_TypeGuards.helper.js.map +0 -1
  227. package/dist/src/types/A_Common.types.d.ts +0 -36
  228. package/dist/src/types/A_Common.types.js +0 -3
  229. package/dist/src/types/A_Common.types.js.map +0 -1
  230. package/index.ts +0 -81
  231. package/src/global/A-Dependency/A-DependencyReference.class.ts +0 -61
  232. package/src/global/A-Dependency/A-DependencyReference.types.ts +0 -61
  233. package/trace-require.js +0 -46
  234. 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.23",
3
+ "version": "0.1.25",
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(
@@ -91,18 +92,22 @@ export function A_Abstraction_Extend(
91
92
  behavior: config.behavior || 'sync',
92
93
  throwOnError: config.throwOnError !== undefined ? config.throwOnError : true,
93
94
 
94
- before: (config.before
95
- ?.map(b =>
96
- b instanceof RegExp
97
- ? b.source
98
- : new RegExp(`^.*${b.replace(/\./g, '\\.')}$`).source)
99
- || []),
100
- after: (config.after
101
- ?.map(a =>
102
- a instanceof RegExp
103
- ? a.source
104
- : new RegExp(`^.*${a.replace(/\./g, '\\.')}$`).source)
105
- || []),
95
+ before: A_TypeGuards.isArray(config.before)
96
+ ? new RegExp(`^${config.before.join('|').replace(/\./g, '\\.')}$`).source
97
+ : config.before instanceof RegExp
98
+ ? config.before.source
99
+ : '',
100
+ after: A_TypeGuards.isArray(config.after)
101
+ ? new RegExp(`^${config.after.join('|').replace(/\./g, '\\.')}$`).source
102
+ : config.after instanceof RegExp
103
+ ? config.after.source
104
+ : '',
105
+
106
+ override: A_TypeGuards.isArray(config.override)
107
+ ? new RegExp(`^${config.override.join('|').replace(/\./g, '\\.')}$`).source
108
+ : config.after instanceof RegExp
109
+ ? config.after.source
110
+ : '',
106
111
  }
107
112
 
108
113
  if (existedIndex !== -1) {
@@ -47,9 +47,10 @@ export class A_ComponentMeta extends A_Meta<A_TYPES__ComponentMeta> {
47
47
  name: extension.name,
48
48
  handler: extension.handler,
49
49
  behavior: extension.behavior,
50
- before: extension.before || [],
51
- after: extension.after || [],
50
+ before: extension.before || '',
51
+ after: extension.after || '',
52
52
  throwOnError: extension.throwOnError || true,
53
+ override:''
53
54
  });
54
55
 
55
56
  });
@@ -64,13 +64,8 @@ export class A_ContainerMeta extends A_Meta<A_TYPES__ContainerMeta> {
64
64
  const args = injections?.get(extension.handler) || [];
65
65
 
66
66
  steps.push({
67
- name: extension.name,
68
- handler: extension.handler,
67
+ ...extension,
69
68
  args,
70
- before: extension.before,
71
- behavior: extension.behavior,
72
- after: extension.after,
73
- throwOnError: extension.throwOnError,
74
69
  });
75
70
 
76
71
  });
@@ -104,9 +99,11 @@ export class A_ContainerMeta extends A_Meta<A_TYPES__ContainerMeta> {
104
99
  name: extension.name,
105
100
  handler: extension.handler,
106
101
  behavior: extension.behavior,
107
- before: extension.before || [],
108
- after: extension.after || [],
102
+ before: extension.before || '',
103
+ after: extension.after || '',
109
104
  throwOnError: extension.throwOnError || true,
105
+ override: ''
106
+
110
107
  });
111
108
 
112
109
  });
@@ -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
@@ -254,7 +254,8 @@ export class A_Entity<
254
254
  ) {
255
255
  const newFeature = new A_Feature({
256
256
  name: feature,
257
- component: this
257
+ component: this,
258
+ scope
258
259
  });
259
260
 
260
261
  return await newFeature.process(scope);
@@ -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))
@@ -87,10 +88,12 @@ export function A_Feature_Define(
87
88
  template: config.template && config.template.length ? config.template.map(
88
89
  item => ({
89
90
  ...item,
90
- before: item.before || [],
91
- after: item.after || [],
91
+ before: item.before || '',
92
+ after: item.after || '',
92
93
  behavior: item.behavior || 'sync',
93
- throwOnError: true
94
+ throwOnError: true,
95
+ override: item.override || ''
96
+
94
97
  })
95
98
  ) : [],
96
99
  });