@adaas/a-concept 0.0.2

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 (231) hide show
  1. package/.nvmrc +1 -0
  2. package/LICENSE +22 -0
  3. package/README.md +19 -0
  4. package/dist/examples/sdk/concept.d.ts +0 -0
  5. package/dist/examples/sdk/concept.js +21 -0
  6. package/dist/examples/sdk/concept.js.map +1 -0
  7. package/dist/examples/sdk/orders.api.d.ts +0 -0
  8. package/dist/examples/sdk/orders.api.js +16 -0
  9. package/dist/examples/sdk/orders.api.js.map +1 -0
  10. package/dist/examples/sdk/users.api.d.ts +0 -0
  11. package/dist/examples/sdk/users.api.js +16 -0
  12. package/dist/examples/sdk/users.api.js.map +1 -0
  13. package/dist/examples/simple/concept.d.ts +0 -0
  14. package/dist/examples/simple/concept.js +13 -0
  15. package/dist/examples/simple/concept.js.map +1 -0
  16. package/dist/examples/simple-http-server/concept.d.ts +1 -0
  17. package/dist/examples/simple-http-server/concept.js +36 -0
  18. package/dist/examples/simple-http-server/concept.js.map +1 -0
  19. package/dist/examples/simple-http-server/containers/http-server.container.d.ts +12 -0
  20. package/dist/examples/simple-http-server/containers/http-server.container.js +69 -0
  21. package/dist/examples/simple-http-server/containers/http-server.container.js.map +1 -0
  22. package/dist/examples/simple-http-server/containers/http-server.controller.d.ts +7 -0
  23. package/dist/examples/simple-http-server/containers/http-server.controller.js +37 -0
  24. package/dist/examples/simple-http-server/containers/http-server.controller.js.map +1 -0
  25. package/dist/examples/simple-http-server/containers/http-server.router.d.ts +6 -0
  26. package/dist/examples/simple-http-server/containers/http-server.router.js +39 -0
  27. package/dist/examples/simple-http-server/containers/http-server.router.js.map +1 -0
  28. package/dist/examples/simple-http-server/contexts/http-server.context.types.d.ts +4 -0
  29. package/dist/examples/simple-http-server/contexts/http-server.context.types.js +100 -0
  30. package/dist/examples/simple-http-server/contexts/http-server.context.types.js.map +1 -0
  31. package/dist/examples/simple-http-server/contexts/http-server.namespace.d.ts +10 -0
  32. package/dist/examples/simple-http-server/contexts/http-server.namespace.js +26 -0
  33. package/dist/examples/simple-http-server/contexts/http-server.namespace.js.map +1 -0
  34. package/dist/examples/simple-http-server/controllers/orders.controller.d.ts +5 -0
  35. package/dist/examples/simple-http-server/controllers/orders.controller.js +32 -0
  36. package/dist/examples/simple-http-server/controllers/orders.controller.js.map +1 -0
  37. package/dist/examples/simple-http-server/controllers/users.controller.d.ts +0 -0
  38. package/dist/examples/simple-http-server/controllers/users.controller.js +87 -0
  39. package/dist/examples/simple-http-server/controllers/users.controller.js.map +1 -0
  40. package/dist/examples/simple-http-server/modules/simple-http-server.context.d.ts +5 -0
  41. package/dist/examples/simple-http-server/modules/simple-http-server.context.js +25 -0
  42. package/dist/examples/simple-http-server/modules/simple-http-server.context.js.map +1 -0
  43. package/dist/examples/simple-http-server/modules/simple-http-server.module.d.ts +16 -0
  44. package/dist/examples/simple-http-server/modules/simple-http-server.module.js +8 -0
  45. package/dist/examples/simple-http-server/modules/simple-http-server.module.js.map +1 -0
  46. package/dist/examples/simple-http-server/modules/simple-http-server.types.d.ts +2 -0
  47. package/dist/examples/simple-http-server/modules/simple-http-server.types.js +3 -0
  48. package/dist/examples/simple-http-server/modules/simple-http-server.types.js.map +1 -0
  49. package/dist/index.d.ts +12 -0
  50. package/dist/index.js +38 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/src/constants/A_ConceptLifecycle.constants.d.ts +2 -0
  53. package/dist/src/constants/A_ConceptLifecycle.constants.js +12 -0
  54. package/dist/src/constants/A_ConceptLifecycle.constants.js.map +1 -0
  55. package/dist/src/containers/A-Config/A-Config.container.d.ts +7 -0
  56. package/dist/src/containers/A-Config/A-Config.container.js +65 -0
  57. package/dist/src/containers/A-Config/A-Config.container.js.map +1 -0
  58. package/dist/src/containers/A-Config/A-Config.namespace.d.ts +28 -0
  59. package/dist/src/containers/A-Config/A-Config.namespace.js +54 -0
  60. package/dist/src/containers/A-Config/A-Config.namespace.js.map +1 -0
  61. package/dist/src/containers/A-Config/A-Config.types.d.ts +12 -0
  62. package/dist/src/containers/A-Config/A-Config.types.js +3 -0
  63. package/dist/src/containers/A-Config/A-Config.types.js.map +1 -0
  64. package/dist/src/containers/A-Config/components/ConfigReader.component.d.ts +18 -0
  65. package/dist/src/containers/A-Config/components/ConfigReader.component.js +37 -0
  66. package/dist/src/containers/A-Config/components/ConfigReader.component.js.map +1 -0
  67. package/dist/src/containers/A-Config/components/ENVConfigReader.component.d.ts +10 -0
  68. package/dist/src/containers/A-Config/components/ENVConfigReader.component.js +37 -0
  69. package/dist/src/containers/A-Config/components/ENVConfigReader.component.js.map +1 -0
  70. package/dist/src/containers/A-Config/components/FileConfigReader.component.d.ts +11 -0
  71. package/dist/src/containers/A-Config/components/FileConfigReader.component.js +47 -0
  72. package/dist/src/containers/A-Config/components/FileConfigReader.component.js.map +1 -0
  73. package/dist/src/containers/A-Errors/A-Errors.container.d.ts +5 -0
  74. package/dist/src/containers/A-Errors/A-Errors.container.js +32 -0
  75. package/dist/src/containers/A-Errors/A-Errors.container.js.map +1 -0
  76. package/dist/src/containers/A-Errors/A-Errors.namespace.d.ts +40 -0
  77. package/dist/src/containers/A-Errors/A-Errors.namespace.js +76 -0
  78. package/dist/src/containers/A-Errors/A-Errors.namespace.js.map +1 -0
  79. package/dist/src/containers/A-Errors/A-Errors.types.d.ts +5 -0
  80. package/dist/src/containers/A-Errors/A-Errors.types.js +3 -0
  81. package/dist/src/containers/A-Errors/A-Errors.types.js.map +1 -0
  82. package/dist/src/containers/A-Logger/A-Logger.container.d.ts +6 -0
  83. package/dist/src/containers/A-Logger/A-Logger.container.js +41 -0
  84. package/dist/src/containers/A-Logger/A-Logger.container.js.map +1 -0
  85. package/dist/src/containers/A-Logger/A-Logger.namespace.d.ts +17 -0
  86. package/dist/src/containers/A-Logger/A-Logger.namespace.js +22 -0
  87. package/dist/src/containers/A-Logger/A-Logger.namespace.js.map +1 -0
  88. package/dist/src/containers/A-Logger/A-Logger.types.d.ts +0 -0
  89. package/dist/src/containers/A-Logger/A-Logger.types.js +2 -0
  90. package/dist/src/containers/A-Logger/A-Logger.types.js.map +1 -0
  91. package/dist/src/containers/A-Logger/components/Logger.component.d.ts +29 -0
  92. package/dist/src/containers/A-Logger/components/Logger.component.js +128 -0
  93. package/dist/src/containers/A-Logger/components/Logger.component.js.map +1 -0
  94. package/dist/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.d.ts +34 -0
  95. package/dist/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.js +3 -0
  96. package/dist/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.js.map +1 -0
  97. package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.d.ts +11 -0
  98. package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.js +36 -0
  99. package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.js.map +1 -0
  100. package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.d.ts +7 -0
  101. package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.js +3 -0
  102. package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.js.map +1 -0
  103. package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.d.ts +17 -0
  104. package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.js +42 -0
  105. package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.js.map +1 -0
  106. package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.d.ts +8 -0
  107. package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.js +3 -0
  108. package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.js.map +1 -0
  109. package/dist/src/decorators/A-ConceptLifecycle/index.d.ts +7 -0
  110. package/dist/src/decorators/A-ConceptLifecycle/index.js +11 -0
  111. package/dist/src/decorators/A-ConceptLifecycle/index.js.map +1 -0
  112. package/dist/src/decorators/A-Feature/A-Feature.decorator.d.ts +0 -0
  113. package/dist/src/decorators/A-Feature/A-Feature.decorator.js +11 -0
  114. package/dist/src/decorators/A-Feature/A-Feature.decorator.js.map +1 -0
  115. package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +0 -0
  116. package/dist/src/decorators/A-Feature/A-Feature.decorator.types.js +2 -0
  117. package/dist/src/decorators/A-Feature/A-Feature.decorator.types.js.map +1 -0
  118. package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +22 -0
  119. package/dist/src/decorators/A-Inject/A-Inject.decorator.js +32 -0
  120. package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -0
  121. package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +4 -0
  122. package/dist/src/decorators/A-Inject/A-Inject.decorator.types.js +3 -0
  123. package/dist/src/decorators/A-Inject/A-Inject.decorator.types.js.map +1 -0
  124. package/dist/src/decorators/A_ConceptMethods.decorator.d.ts +0 -0
  125. package/dist/src/decorators/A_ConceptMethods.decorator.js +2 -0
  126. package/dist/src/decorators/A_ConceptMethods.decorator.js.map +1 -0
  127. package/dist/src/decorators/A_Lazy.decorator.d.ts +5 -0
  128. package/dist/src/decorators/A_Lazy.decorator.js +20 -0
  129. package/dist/src/decorators/A_Lazy.decorator.js.map +1 -0
  130. package/dist/src/global/A-Component/A-Component.class.d.ts +16 -0
  131. package/dist/src/global/A-Component/A-Component.class.js +18 -0
  132. package/dist/src/global/A-Component/A-Component.class.js.map +1 -0
  133. package/dist/src/global/A-Concept/A_Concept.class.d.ts +46 -0
  134. package/dist/src/global/A-Concept/A_Concept.class.js +106 -0
  135. package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -0
  136. package/dist/src/global/A-Concept/A_Concept.types.d.ts +26 -0
  137. package/dist/src/global/A-Concept/A_Concept.types.js +3 -0
  138. package/dist/src/global/A-Concept/A_Concept.types.js.map +1 -0
  139. package/dist/src/global/A-Container/A-Container.class.d.ts +14 -0
  140. package/dist/src/global/A-Container/A-Container.class.js +21 -0
  141. package/dist/src/global/A-Container/A-Container.class.js.map +1 -0
  142. package/dist/src/global/A-Context/A-Context.class.d.ts +88 -0
  143. package/dist/src/global/A-Context/A-Context.class.js +118 -0
  144. package/dist/src/global/A-Context/A-Context.class.js.map +1 -0
  145. package/dist/src/global/A-Context/A-Context.types.d.ts +0 -0
  146. package/dist/src/global/A-Context/A-Context.types.js +2 -0
  147. package/dist/src/global/A-Context/A-Context.types.js.map +1 -0
  148. package/dist/src/global/A-Dependency/A-DependencyReference.class.d.ts +17 -0
  149. package/dist/src/global/A-Dependency/A-DependencyReference.class.js +67 -0
  150. package/dist/src/global/A-Dependency/A-DependencyReference.class.js.map +1 -0
  151. package/dist/src/global/A-Dependency/A-DependencyReference.types.d.ts +55 -0
  152. package/dist/src/global/A-Dependency/A-DependencyReference.types.js +3 -0
  153. package/dist/src/global/A-Dependency/A-DependencyReference.types.js.map +1 -0
  154. package/dist/src/global/A-Namespace/A_Namespace.class.d.ts +47 -0
  155. package/dist/src/global/A-Namespace/A_Namespace.class.js +112 -0
  156. package/dist/src/global/A-Namespace/A_Namespace.class.js.map +1 -0
  157. package/dist/src/global/A-Namespace/A_Namespace.types.d.ts +19 -0
  158. package/dist/src/global/A-Namespace/A_Namespace.types.js +3 -0
  159. package/dist/src/global/A-Namespace/A_Namespace.types.js.map +1 -0
  160. package/dist/src/managers/A_DependencyManager.class.d.ts +24 -0
  161. package/dist/src/managers/A_DependencyManager.class.js +129 -0
  162. package/dist/src/managers/A_DependencyManager.class.js.map +1 -0
  163. package/dist/src/storage/A_Concept.storage.d.ts +19 -0
  164. package/dist/src/storage/A_Concept.storage.js +29 -0
  165. package/dist/src/storage/A_Concept.storage.js.map +1 -0
  166. package/dist/src/types/A_DependencyManager.types.d.ts +15 -0
  167. package/dist/src/types/A_DependencyManager.types.js +3 -0
  168. package/dist/src/types/A_DependencyManager.types.js.map +1 -0
  169. package/dist/src/types/A_Module.types.d.ts +17 -0
  170. package/dist/src/types/A_Module.types.js +22 -0
  171. package/dist/src/types/A_Module.types.js.map +1 -0
  172. package/docs/logo.png +0 -0
  173. package/examples/sdk/concept.ts +24 -0
  174. package/examples/sdk/orders.api.ts +21 -0
  175. package/examples/sdk/users.api.ts +21 -0
  176. package/examples/simple/concept.ts +16 -0
  177. package/examples/simple-http-server/concept.ts +30 -0
  178. package/examples/simple-http-server/containers/http-server.container.ts +69 -0
  179. package/examples/simple-http-server/containers/http-server.controller.ts +24 -0
  180. package/examples/simple-http-server/containers/http-server.router.ts +23 -0
  181. package/examples/simple-http-server/contexts/http-server.context.types.ts +108 -0
  182. package/examples/simple-http-server/contexts/http-server.namespace.ts +36 -0
  183. package/examples/simple-http-server/controllers/orders.controller.ts +20 -0
  184. package/examples/simple-http-server/controllers/users.controller.ts +104 -0
  185. package/index.ts +14 -0
  186. package/jest.config.ts +22 -0
  187. package/package.json +73 -0
  188. package/src/constants/A_ConceptLifecycle.constants.ts +12 -0
  189. package/src/containers/A-Config/A-Config.container.ts +60 -0
  190. package/src/containers/A-Config/A-Config.namespace.ts +98 -0
  191. package/src/containers/A-Config/A-Config.types.ts +31 -0
  192. package/src/containers/A-Config/components/ConfigReader.component.ts +30 -0
  193. package/src/containers/A-Config/components/ENVConfigReader.component.ts +31 -0
  194. package/src/containers/A-Config/components/FileConfigReader.component.ts +42 -0
  195. package/src/containers/A-Errors/A-Errors.container.ts +14 -0
  196. package/src/containers/A-Errors/A-Errors.namespace.ts +104 -0
  197. package/src/containers/A-Errors/A-Errors.types.ts +6 -0
  198. package/src/containers/A-Logger/A-Logger.container.ts +22 -0
  199. package/src/containers/A-Logger/A-Logger.namespace.ts +26 -0
  200. package/src/containers/A-Logger/A-Logger.types.ts +0 -0
  201. package/src/containers/A-Logger/components/Logger.component.ts +169 -0
  202. package/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.ts +46 -0
  203. package/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.ts +55 -0
  204. package/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.ts +20 -0
  205. package/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.ts +62 -0
  206. package/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.ts +28 -0
  207. package/src/decorators/A-ConceptLifecycle/index.ts +9 -0
  208. package/src/decorators/A-Feature/A-Feature.decorator.ts +13 -0
  209. package/src/decorators/A-Feature/A-Feature.decorator.types.ts +0 -0
  210. package/src/decorators/A-Inject/A-Inject.decorator.ts +75 -0
  211. package/src/decorators/A-Inject/A-Inject.decorator.types.ts +10 -0
  212. package/src/decorators/A_ConceptMethods.decorator.ts +0 -0
  213. package/src/decorators/A_Lazy.decorator.ts +31 -0
  214. package/src/global/A-Component/A-Component.class.ts +33 -0
  215. package/src/global/A-Concept/A_Concept.class.ts +143 -0
  216. package/src/global/A-Concept/A_Concept.types.ts +44 -0
  217. package/src/global/A-Container/A-Container.class.ts +39 -0
  218. package/src/global/A-Context/A-Context.class.ts +230 -0
  219. package/src/global/A-Context/A-Context.types.ts +0 -0
  220. package/src/global/A-Dependency/A-DependencyReference.class.ts +61 -0
  221. package/src/global/A-Dependency/A-DependencyReference.types.ts +61 -0
  222. package/src/global/A-Namespace/A_Namespace.class.ts +128 -0
  223. package/src/global/A-Namespace/A_Namespace.types.ts +24 -0
  224. package/src/storage/A_Concept.storage.ts +45 -0
  225. package/src/types/A_Module.types.ts +23 -0
  226. package/tests/context.test.ts +124 -0
  227. package/tests/default.test.ts +159 -0
  228. package/tests/log.ts +54 -0
  229. package/tests/polyfill.test.ts +37 -0
  230. package/tsconfig.json +61 -0
  231. package/tslint.json +98 -0
@@ -0,0 +1,169 @@
1
+ import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
2
+ import { A_Namespace } from "@adaas/a-concept/global/A-Namespace/A_Namespace.class";
3
+ import { A_Error } from "@adaas/a-utils";
4
+ import { A_Config } from "src/containers/A-Config/A-Config.namespace";
5
+
6
+
7
+ export class Logger extends A_Component {
8
+
9
+ constructor(
10
+ protected namespace: A_Namespace,
11
+ protected config: A_Config
12
+ ) {
13
+ super(namespace);
14
+ }
15
+
16
+ readonly colors = {
17
+ green: '32',
18
+ blue: '34',
19
+ red: '31',
20
+ yellow: '33',
21
+ gray: '90',
22
+ magenta: '35',
23
+ cyan: '36',
24
+ white: '37',
25
+ pink: '95',
26
+ } as const
27
+
28
+
29
+ get namespaceLength() {
30
+ return this.namespaceLength;
31
+ }
32
+
33
+
34
+ compile(
35
+ color: keyof typeof this.colors,
36
+ ...args: any[]
37
+ ): Array<string> {
38
+
39
+ return [
40
+ `\x1b[${this.colors[color]}m[${this.namespace}] |${this.getTime()}|`,
41
+ (
42
+ args.length > 1
43
+ ? '\n' + `${' '.repeat(this.namespaceLength + 3)}|-------------------------------`
44
+ : ''
45
+
46
+ ),
47
+ ...(args
48
+ .map((arg, i) => {
49
+
50
+
51
+ switch (true) {
52
+ case arg instanceof A_Error:
53
+ return this.compile_A_Error(arg);
54
+
55
+ case arg instanceof Error:
56
+ return this.compile_Error(arg);
57
+
58
+ case typeof arg === 'object':
59
+ return JSON.stringify(arg, null, 2)
60
+ .replace(/\n/g, '\n' + `${' '.repeat(this.namespaceLength + 3)}| `);
61
+
62
+ default:
63
+ return String(
64
+ ((i > 0 || args.length > 1) ? '\n' : '')
65
+ + arg)
66
+ .replace(/\n/g, '\n' + `${' '.repeat(this.namespaceLength + 3)}| `)
67
+ }
68
+ })),
69
+ (
70
+ args.length > 1
71
+ ? '\n' + `${' '.repeat(this.namespaceLength + 3)}|-------------------------------\x1b[0m`
72
+ : '\x1b[0m'
73
+ )
74
+ ]
75
+ }
76
+
77
+
78
+ log(...args) {
79
+ if (!this.config.get('CONFIG_VERBOSE'))
80
+ return;
81
+
82
+ console.log(...this.compile('blue', ...args));
83
+ }
84
+
85
+ warning(...args) {
86
+ if (!this.config.get('CONFIG_VERBOSE'))
87
+ return;
88
+
89
+ console.log(...this.compile('yellow', ...args));
90
+ }
91
+
92
+ error(...args) {
93
+ if (this.config.get('CONFIG_IGNORE_ERRORS'))
94
+ return;
95
+
96
+ return console.log(...this.compile('red', ...args));
97
+ }
98
+
99
+
100
+ protected log_A_Error(error: A_Error) {
101
+ const time = this.getTime();
102
+
103
+ console.log(`\x1b[31m[${this.namespace}] |${time}| ERROR ${error.code}
104
+ ${' '.repeat(this.namespaceLength + 3)}| ${error.message}
105
+ ${' '.repeat(this.namespaceLength + 3)}| ${error.description}
106
+ ${' '.repeat(this.namespaceLength + 3)}|-------------------------------
107
+ ${' '.repeat(this.namespaceLength + 3)}| ${error.stack?.split('\n').map((line, index) => index === 0 ? line : `${' '.repeat(this.namespaceLength + 3)}| ${line}`).join('\n') || 'No stack trace'}
108
+ ${' '.repeat(this.namespaceLength + 3)}|-------------------------------
109
+ \x1b[0m`
110
+ + (error.originalError ? `\x1b[31m${' '.repeat(this.namespaceLength + 3)}| Wrapped From ${error.originalError.message}
111
+ ${' '.repeat(this.namespaceLength + 3)}|-------------------------------
112
+ ${' '.repeat(this.namespaceLength + 3)}| ${error.originalError.stack?.split('\n').map((line, index) => index === 0 ? line : `${' '.repeat(this.namespaceLength + 3)}| ${line}`).join('\n') || 'No stack trace'}
113
+ ${' '.repeat(this.namespaceLength + 3)}|-------------------------------
114
+ \x1b[0m`: '')
115
+ + (error.link ? `\x1b[31m${' '.repeat(this.namespaceLength + 3)}| Read in docs: ${error.link}
116
+ ${' '.repeat(this.namespaceLength + 3)}|-------------------------------
117
+ \x1b[0m`: ''));
118
+
119
+ }
120
+
121
+ protected compile_A_Error(error: A_Error): string {
122
+ const time = this.getTime();
123
+
124
+ return '\n' +
125
+
126
+ `${' '.repeat(this.namespaceLength + 3)}|-------------------------------` +
127
+ '\n' +
128
+ `${' '.repeat(this.namespaceLength + 3)}| Error: | ${error.code}
129
+ ${' '.repeat(this.namespaceLength + 3)}|-------------------------------
130
+ ${' '.repeat(this.namespaceLength + 3)}|${' '.repeat(10)}| ${error.message}
131
+ ${' '.repeat(this.namespaceLength + 3)}|${' '.repeat(10)}| ${error.description}
132
+ ${' '.repeat(this.namespaceLength + 3)}|-------------------------------
133
+ ${' '.repeat(this.namespaceLength + 3)}| ${error.stack?.split('\n').map((line, index) => index === 0 ? line : `${' '.repeat(this.namespaceLength + 3)}| ${line}`).join('\n') || 'No stack trace'}
134
+ ${' '.repeat(this.namespaceLength + 3)}|-------------------------------`
135
+ +
136
+ (error.originalError ? `${' '.repeat(this.namespaceLength + 3)}| Wrapped From ${error.originalError.message}
137
+ ${' '.repeat(this.namespaceLength + 3)}|-------------------------------
138
+ ${' '.repeat(this.namespaceLength + 3)}| ${error.originalError.stack?.split('\n').map((line, index) => index === 0 ? line : `${' '.repeat(this.namespaceLength + 3)}| ${line}`).join('\n') || 'No stack trace'}
139
+ ${' '.repeat(this.namespaceLength + 3)}|-------------------------------` : '')
140
+ +
141
+ (error.link ? `${' '.repeat(this.namespaceLength + 3)}| Read in docs: ${error.link}
142
+ ${' '.repeat(this.namespaceLength + 3)}|-------------------------------` : '');
143
+
144
+ }
145
+
146
+
147
+ protected compile_Error(error: Error): string {
148
+ return JSON.stringify({
149
+ name: error.name,
150
+ message: error.message,
151
+ stack: error.stack?.split('\n')
152
+ .map((line, index) => index === 0 ? line : `${' '.repeat(this.namespaceLength + 3)}| ${line}`)
153
+ .join('\n')
154
+
155
+ }, null, 2)
156
+ .replace(/\n/g, '\n' + `${' '.repeat(this.namespaceLength + 3)}| `)
157
+ .replace(/\\n/g, '\n')
158
+ }
159
+
160
+
161
+
162
+ protected getTime() {
163
+ const now = new Date();
164
+ const minutes = String(now.getMinutes()).padStart(2, '0');
165
+ const seconds = String(now.getSeconds()).padStart(2, '0');
166
+ const milliseconds = String(now.getMilliseconds()).padStart(4, '0');
167
+ return `${minutes}:${seconds}:${milliseconds}`;
168
+ }
169
+ }
@@ -0,0 +1,46 @@
1
+
2
+
3
+ export type A_TYPES__ConceptLifecycle_MethodDeclarationConfig = {
4
+ /**
5
+ * The name of the method. If not provided, the name of the function will be used.
6
+ * The name is connected to the class name.
7
+ * e.g. 'YourClass.yourMethod'
8
+ */
9
+ name: string,
10
+
11
+ /**
12
+ * Allows to override the method with a new implementation.
13
+ * The methods listed will not be called.
14
+ * e.g. ['YourClass.yourMethod']
15
+ */
16
+ override: Array<string> | string | Function,
17
+
18
+ /**
19
+ * Defines a flexible dependency management mechanism to enable pipeline-like behavior.
20
+ * The target method will be called before the methods listed.
21
+ * e.g. ['YourClass.yourMethod']
22
+ */
23
+ before: Array<string> | string | Function,
24
+
25
+ /**
26
+ * Defines a flexible dependency management mechanism to enable pipeline-like behavior.
27
+ * The target method will be called after the methods listed.
28
+ * e.g. ['YourClass.yourMethod']
29
+ */
30
+ after: Array<string> | string | Function,
31
+
32
+
33
+ /**
34
+ * Allows to define a behavior of the method
35
+ * Sync - blocks other Concept Lifecycle methods until the method is ready
36
+ * Async - allows to initialize method after Concept Lifecycle initialization
37
+ */
38
+ behavior: 'sync' | 'async',
39
+ type: 'extension' | 'pipe'
40
+ }
41
+
42
+
43
+
44
+
45
+ export type A_TYPES__ConceptLifecycle_MethodDeclarationStorage = {
46
+ }
@@ -0,0 +1,55 @@
1
+ import { A_TYPES__A_LoadDecoratorConfig, A_TYPES__A_LoadDecoratorDescriptor, A_TYPES__A_LoadDecoratorStorageInstruction } from "./A-Load.decorator.types";
2
+ import { A_CONCEPT_ModulesDeclarationStorage, A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootLoad } from "src/storage/A_Concept.storage";
3
+ import { A_CommonHelper } from "@adaas/a-utils";
4
+ import { A_CONSTANTS__DEFAULT_CONCEPT_LIFECYCLE_METHOD_DECLARATION_CONFIG } from "@adaas/a-concept/constants/A_ConceptLifecycle.constants";
5
+ import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
6
+
7
+
8
+
9
+
10
+ /**
11
+ * A-Load decorator
12
+ *
13
+ * This Decorator allows to an extended flow of Concept loading.
14
+ *
15
+ * @param params
16
+ * @returns
17
+ */
18
+ export function A_Load(
19
+ config: Partial<A_TYPES__A_LoadDecoratorConfig> = {}
20
+ ) {
21
+
22
+ return function (
23
+ target: A_Container,
24
+ propertyKey: string,
25
+ descriptor: A_TYPES__A_LoadDecoratorDescriptor
26
+ ) {
27
+ const targetProperty: Symbol = A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootLoad;
28
+
29
+
30
+
31
+ const existedMeta = A_CONCEPT_ModulesDeclarationStorage.get(target.constructor) || new Map();
32
+ const inheritMeta = A_CONCEPT_ModulesDeclarationStorage.get(Object.getPrototypeOf(target.constructor)) || new Map();
33
+
34
+ const inheritedInstructions = inheritMeta.get(targetProperty) || [];
35
+ const instructions: Array<A_TYPES__A_LoadDecoratorStorageInstruction> = existedMeta.get(targetProperty) || [...inheritedInstructions];
36
+
37
+ /**
38
+ * That's is needed to remove the previous definition of the method from parent classes
39
+ * and override it with the new one
40
+ */
41
+ const targetInstructions = instructions
42
+ .filter(
43
+ (instr: A_TYPES__A_LoadDecoratorStorageInstruction) => instr.handler !== propertyKey
44
+ );
45
+
46
+ targetInstructions.push({
47
+ handler: propertyKey,
48
+ config: A_CommonHelper.deepCloneAndMerge(config, A_CONSTANTS__DEFAULT_CONCEPT_LIFECYCLE_METHOD_DECLARATION_CONFIG)
49
+ });
50
+
51
+ existedMeta.set(targetProperty, targetInstructions);
52
+
53
+ A_CONCEPT_ModulesDeclarationStorage.set(target.constructor, existedMeta);
54
+ };
55
+ }
@@ -0,0 +1,20 @@
1
+ import { A_TYPES__ConceptLifecycle_MethodDeclarationConfig } from "../A-ConceptLifecycle.decorator.types"
2
+
3
+ export type A_TYPES__A_LoadDecoratorDescriptor =
4
+ TypedPropertyDescriptor<(
5
+ ...args: any[]
6
+ ) => void>
7
+ |
8
+ TypedPropertyDescriptor<(
9
+ ...args: any[]
10
+ ) => Promise<void>>
11
+
12
+
13
+ export type A_TYPES__A_LoadDecoratorConfig = {
14
+ } & A_TYPES__ConceptLifecycle_MethodDeclarationConfig
15
+
16
+
17
+ export type A_TYPES__A_LoadDecoratorStorageInstruction = {
18
+ handler: string,
19
+ config: A_TYPES__A_LoadDecoratorConfig
20
+ }
@@ -0,0 +1,62 @@
1
+ import { A_TYPES__A_RunDecoratorConfig, A_TYPES__A_RunDecoratorDescriptor, A_TYPES__A_RunDecoratorStorageInstruction } from "./A-Run.decorator.types";
2
+ import { A_CONCEPT_ModulesDeclarationStorage, A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootRun } from "src/storage/A_Concept.storage";
3
+ import { A_CommonHelper } from "@adaas/a-utils";
4
+ import { A_CONSTANTS__DEFAULT_CONCEPT_LIFECYCLE_METHOD_DECLARATION_CONFIG } from "@adaas/a-concept/constants/A_ConceptLifecycle.constants";
5
+ import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
6
+
7
+
8
+
9
+
10
+
11
+ /**
12
+ * A-Run decorator
13
+ *
14
+ * This decorator is used to define a method that will be executed during the lifecycle of the module.
15
+ * Depending on the definition and configurations
16
+ * it will be executed during the run command
17
+ * modifying and adjusting the whole [root.run] pipeline.
18
+ *
19
+ * This decorator can be used in case of the need to define a custom logic that will be executed during the run command.
20
+ *
21
+ *
22
+ * @param params
23
+ * @returns
24
+ */
25
+ export function A_Run(
26
+ config: Partial<A_TYPES__A_RunDecoratorConfig> = {}
27
+ ) {
28
+
29
+ return function (
30
+ target: A_Container,
31
+ propertyKey: string,
32
+ descriptor: A_TYPES__A_RunDecoratorDescriptor
33
+ ) {
34
+ const targetProperty: Symbol = A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootRun;
35
+
36
+
37
+
38
+ const existedMeta = A_CONCEPT_ModulesDeclarationStorage.get(target.constructor) || new Map();
39
+ const inheritMeta = A_CONCEPT_ModulesDeclarationStorage.get(Object.getPrototypeOf(target.constructor)) || new Map();
40
+
41
+ const inheritedInstructions = inheritMeta.get(targetProperty) || [];
42
+ const instructions: Array<A_TYPES__A_RunDecoratorStorageInstruction> = existedMeta.get(targetProperty) || [...inheritedInstructions];
43
+
44
+ /**
45
+ * That's is needed to remove the previous definition of the method from parent classes
46
+ * and override it with the new one
47
+ */
48
+ const targetInstructions = instructions
49
+ .filter(
50
+ (instr: A_TYPES__A_RunDecoratorStorageInstruction) => instr.handler !== propertyKey
51
+ );
52
+
53
+ targetInstructions.push({
54
+ handler: propertyKey,
55
+ config: A_CommonHelper.deepCloneAndMerge(config, A_CONSTANTS__DEFAULT_CONCEPT_LIFECYCLE_METHOD_DECLARATION_CONFIG)
56
+ });
57
+
58
+ existedMeta.set(targetProperty, targetInstructions);
59
+
60
+ A_CONCEPT_ModulesDeclarationStorage.set(target.constructor, existedMeta);
61
+ };
62
+ }
@@ -0,0 +1,28 @@
1
+ import { A_TYPES__A_CONCEPT_RootRunParams } from "@adaas/a-concept/global/A-Concept/A_Concept.types"
2
+ import { A_TYPES__ConceptLifecycle_MethodDeclarationConfig } from "../A-ConceptLifecycle.decorator.types"
3
+
4
+ export type A_TYPES__A_RunDecoratorDescriptor =
5
+ TypedPropertyDescriptor<(
6
+ params: A_TYPES__A_CONCEPT_RootRunParams
7
+ ) => any>
8
+ |
9
+ TypedPropertyDescriptor<(
10
+ ) => any>
11
+ |
12
+ TypedPropertyDescriptor<(
13
+ params: A_TYPES__A_CONCEPT_RootRunParams
14
+ ) => Promise<any>>
15
+ |
16
+ TypedPropertyDescriptor<(
17
+ ) => Promise<any>>
18
+
19
+
20
+ export type A_TYPES__A_RunDecoratorConfig = {
21
+
22
+ } & A_TYPES__ConceptLifecycle_MethodDeclarationConfig
23
+
24
+
25
+ export type A_TYPES__A_RunDecoratorStorageInstruction = {
26
+ handler: string,
27
+ config: A_TYPES__A_RunDecoratorConfig
28
+ }
@@ -0,0 +1,9 @@
1
+ import { A_Load } from "./A-Load/A-Load.decorator";
2
+ import { A_Run } from "./A-Run/A-Run.decorator";
3
+
4
+
5
+ export const A_Lifecycle = {
6
+ Load: A_Load,
7
+ Run: A_Run,
8
+ Build: A_Run
9
+ }
@@ -0,0 +1,13 @@
1
+
2
+
3
+
4
+
5
+ // export function A_Feature(
6
+ // params: any = {
7
+ // name: '',
8
+ // description: '',
9
+ // version: '',
10
+ // }
11
+ // ) {
12
+ // return A_Pipeline('root.run');
13
+ // }
@@ -0,0 +1,75 @@
1
+ import { A_Namespace } from "@adaas/a-concept/global/A-Namespace/A_Namespace.class";
2
+ import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
3
+ import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
4
+
5
+ /**
6
+ * A-Inject decorator
7
+ *
8
+ * This Decorator allows to inject dependencies into the module like
9
+ * - Namespaces
10
+ * - Other Concepts
11
+ * - or maybe Components
12
+ *
13
+ * @param params
14
+ * @returns
15
+ */
16
+ export function A_Inject<
17
+ T extends { new(...args: any[]): A_Component }
18
+ >(
19
+ component: T
20
+ )
21
+ export function A_Inject<
22
+ T extends { new(...args: any[]): A_Namespace }
23
+ >(
24
+ namespace: T
25
+ )
26
+ export function A_Inject<
27
+ E extends { new(...args: any[]): A_Namespace },
28
+ T extends Array<E>
29
+ >(
30
+ namespaces: T
31
+ )
32
+ export function A_Inject<
33
+ E extends { new(...args: any[]): A_Namespace },
34
+ K extends { new(...args: any[]): A_Component },
35
+ T extends Array<E>
36
+ >(
37
+ param1: T | E | K
38
+ ) {
39
+ switch (true) {
40
+ case param1 instanceof A_Component:
41
+ return function (
42
+ target: T,
43
+ propertyKey: string | symbol,
44
+ parameterIndex: number
45
+ ) {
46
+ // It should be just register the parameter in method that will be resolved in the method
47
+ }
48
+ case param1 instanceof A_Namespace:
49
+ return function (
50
+ target: T,
51
+ propertyKey: string | symbol,
52
+ parameterIndex: number
53
+ ) {
54
+ // It should be just register the parameter in method that will be resolved in the method
55
+ }
56
+ }
57
+
58
+ // const namespaces: Array<typeof A_Namespace> = [
59
+ // ...(Array.isArray(param1) ? param1 : [param1])
60
+ // ];
61
+
62
+ // const resolvedNamespaces: Array<A_Namespace> = []
63
+
64
+ // for (const namespace of namespaces) {
65
+ // resolvedNamespaces.push(A_Context.resolve(namespace));
66
+ // }
67
+
68
+ // return function (
69
+ // target: T | E,
70
+ // propertyKey: string | symbol,
71
+ // parameterIndex: number
72
+ // ) {
73
+ // // It should be just register the parameter in method that will be resolved in the method
74
+ // }
75
+ }
@@ -0,0 +1,10 @@
1
+ export type A_TYPES__A_InjectDecoratorDescriptor = TypedPropertyDescriptor<(
2
+ ...args: any[]
3
+ ) => Promise<void>>
4
+
5
+
6
+
7
+ export type A_TYPES__A_InjectDecoratorStorageInstruction = {
8
+ handler: string,
9
+ // config: A_TYPES__A_InjectDecoratorConfig
10
+ }
File without changes
@@ -0,0 +1,31 @@
1
+ function RegisterLazyMethod(
2
+ target: any,
3
+ propertyKey: string,
4
+ descriptor: PropertyDescriptor
5
+ ) {
6
+ const originalMethod = descriptor.value;
7
+
8
+ descriptor.value = function (...args: any[]) {
9
+ console.log(`Intercepted call to method: ${propertyKey}`);
10
+ console.log(`Arguments: `, args);
11
+
12
+ // You can modify args or do something else here
13
+ const result = originalMethod.apply(this, args);
14
+
15
+ // You can also modify the return value
16
+ console.log(`Result: `, result);
17
+ return result;
18
+ };
19
+
20
+ return descriptor;
21
+ }
22
+
23
+
24
+
25
+ export function A_Lazy(
26
+ params: {
27
+ source: string;
28
+ }
29
+ ) {
30
+ return RegisterLazyMethod;
31
+ }
@@ -0,0 +1,33 @@
1
+ import { A_Namespace } from "../A-Namespace/A_Namespace.class";
2
+
3
+
4
+
5
+ /**
6
+ * This element only contains the specific code
7
+ *
8
+ */
9
+ export class A_Component<T extends A_Namespace = A_Namespace> {
10
+
11
+ constructor(
12
+ /**
13
+ * Primary context that impacts the component behavior
14
+ */
15
+ protected namespace: A_Namespace
16
+ ) {
17
+
18
+ }
19
+
20
+
21
+
22
+
23
+ // constructor(
24
+ // private auth: A_AUTH_Context,
25
+ // private arc: A_ARC_Context,
26
+ // private products: A_PRODUCTS_Context,
27
+ // private express: A_EXPRESS_Context,
28
+ // ) {
29
+
30
+ // }
31
+
32
+
33
+ }