@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,24 @@
1
+ /**
2
+ * Namespace Constructor Interface
3
+ */
4
+ export type A_TYPES__NamespaceConstructor = {
5
+ name?: string,
6
+ }
7
+
8
+
9
+ /**
10
+ * Namespace Interface
11
+ */
12
+ export interface A_TYPES__INamespace {
13
+ name: string;
14
+ ready: Promise<void>
15
+ }
16
+
17
+
18
+ /**
19
+ * Global Namespace Interface uses for extending the Namespace from other modules or SDKs
20
+ *
21
+ */
22
+ export interface A_TYPES__IGlobalNamespace extends A_TYPES__INamespace {
23
+
24
+ }
@@ -0,0 +1,45 @@
1
+
2
+
3
+ // --------------------------------------------------------------
4
+ // ----- A Concept -> Module Declaration -> Main Config ---------
5
+ // --------------------------------------------------------------
6
+ export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Config = Symbol('a-concept-modules-declaration');
7
+
8
+
9
+
10
+ // -------------------------------------------------------------------------------
11
+ // ----- A Concept -> Module Declaration -> Concept Lifecycle Extension_ ---------
12
+ // -------------------------------------------------------------------------------
13
+ export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootRun = Symbol('a-concept-modules-declaration-lifecycle-root-run');
14
+ export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootLoad = Symbol('a-concept-modules-declaration-lifecycle-root-load');
15
+ export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootBuild = Symbol('a-concept-modules-declaration-lifecycle-root-build');
16
+ export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootPublish = Symbol('a-concept-modules-declaration-lifecycle-root-publish');
17
+ export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootTest = Symbol('a-concept-modules-declaration-lifecycle-root-test');
18
+
19
+
20
+
21
+
22
+ /**
23
+ * Storage to keep the module declarations across all modules
24
+ */
25
+ export const A_CONCEPT_ModulesDeclarationStorage: WeakMap<
26
+ any,
27
+ Map<string | Symbol, any>
28
+ > = new WeakMap();
29
+
30
+
31
+
32
+ /**
33
+ * Storage to keep the lifecycle declarations across all modules
34
+ */
35
+ export const A_CONCEPT_LifecycleDeclarationsStorage: Map<Symbol, any> = new Map();
36
+
37
+
38
+
39
+
40
+
41
+ /**
42
+ * The simplest way to store the decorators
43
+ * If any extra API is needed, it can be added here or replaced with a new class
44
+ */
45
+ export const A_CONCEPT_Storage = new WeakMap();
@@ -0,0 +1,23 @@
1
+ export enum A_TYPES__ModuleState {
2
+ INIT = 'INIT',
3
+ LOADING = 'LOADING',
4
+ READY = 'READY',
5
+ FAILED = 'FAILED'
6
+ }
7
+
8
+ export enum A_TYPES__ModuleTypes {
9
+ /**
10
+ * Custom module type allows additional external control over the module
11
+ */
12
+ CUSTOM = 'CUSTOM',
13
+
14
+ /**
15
+ * Default module type is a module that is used by default and has no additional control.
16
+ */
17
+ DEFAULT = 'DEFAULT'
18
+ }
19
+
20
+
21
+ export type A_TYPES__ModuleConstructor = {
22
+
23
+ }
@@ -0,0 +1,124 @@
1
+ // import { A_CONSTANTS__ERROR_CODES } from '@adaas/a-concept/constants/errors.constants';
2
+ // import { A_ContextClass } from '@adaas/a-concept/global/A-Namespace/A_Namespace.class';
3
+ // import { A_Error } from '@adaas/a-concept/global/A_Error.class';
4
+ // import { config } from 'dotenv';
5
+ // config();
6
+ // jest.retryTimes(0);
7
+
8
+ // describe('Context Tests', () => {
9
+
10
+ // it('Should load default context ', async () => {
11
+ // const testContext = new A_ContextClass({
12
+ // namespace: 'test',
13
+ // });
14
+
15
+ // await testContext.ready;
16
+ // });
17
+
18
+
19
+ // it('Should log data ', async () => {
20
+ // const testContext = new A_ContextClass({
21
+ // namespace: 'test',
22
+ // });
23
+
24
+ // await testContext.ready;
25
+
26
+ // testContext.Logger.log('Test Log');
27
+ // });
28
+
29
+ // it('Should throw Error ', async () => {
30
+
31
+ // const namespace = 'test-namespace';
32
+ // const testContext = new A_ContextClass({
33
+ // namespace,
34
+ // });
35
+
36
+ // await testContext.ready;
37
+
38
+ // try {
39
+ // testContext.Errors.throw(A_CONSTANTS__ERROR_CODES.METHOD_NOT_IMPLEMENTED);
40
+ // } catch (error) {
41
+ // testContext.Logger.error(error);
42
+
43
+ // expect(error).toBeDefined();
44
+ // expect(error).toBeInstanceOf(A_Error);
45
+ // expect((error as A_Error).code).toBe(
46
+ // `${namespace}@error:${A_CONSTANTS__ERROR_CODES.METHOD_NOT_IMPLEMENTED}`
47
+ // );
48
+ // }
49
+ // });
50
+
51
+ // it('Should log original error ', async () => {
52
+
53
+ // const namespace = 'test-error-namespace';
54
+ // const testContext = new A_ContextClass({
55
+ // namespace,
56
+ // });
57
+
58
+ // await testContext.ready;
59
+ // try {
60
+ // try {
61
+ // throw new Error('Test Error');
62
+ // } catch (error) {
63
+ // throw testContext.Errors.wrap(error);
64
+ // }
65
+ // } catch (error) {
66
+ // testContext.Logger.error(error);
67
+
68
+
69
+ // expect(error).toBeDefined();
70
+ // expect(error).toBeInstanceOf(A_Error);
71
+ // }
72
+ // });
73
+
74
+ // it('Should read allowed configuration property ', async () => {
75
+
76
+ // const namespace = 'test-config-read-ok';
77
+ // const testContext = new A_ContextClass({
78
+ // namespace,
79
+ // });
80
+
81
+ // const ignoreErrors = testContext.getConfigurationProperty('CONFIG_IGNORE_ERRORS');
82
+
83
+ // expect(ignoreErrors).toBe(false);
84
+ // });
85
+
86
+ // it('Should fail to read unknown property', async () => {
87
+
88
+ // const namespace = 'test-config-read-fail';
89
+ // const testContext = new A_ContextClass({
90
+ // namespace,
91
+ // });
92
+
93
+ // try {
94
+ // testContext.getConfigurationProperty('TEST_PROPERTY' as any);
95
+ // } catch (error) {
96
+ // testContext.Logger.error(error);
97
+
98
+ // expect(error).toBeDefined();
99
+ // expect(error).toBeInstanceOf(A_Error);
100
+ // expect((error as A_Error).code).toBe(
101
+ // `${namespace}@error:${A_CONSTANTS__ERROR_CODES.CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ}`
102
+ // );
103
+ // }
104
+
105
+ // });
106
+
107
+ // it('Should Log data properly', async () => {
108
+
109
+ // const namespace = 'test-config-read-fail';
110
+ // const testContext = new A_ContextClass({
111
+ // namespace,
112
+ // });
113
+
114
+ // testContext.Logger.log(`
115
+ // Some Suff that should be done`, {
116
+ // test: 'data',
117
+ // test2: {
118
+ // test: 'data'
119
+ // }
120
+ // });
121
+
122
+ // });
123
+
124
+ // });
@@ -0,0 +1,159 @@
1
+ // import { A_CommonHelper } from '@adaas/a-concept/helpers/Common.helper';
2
+ // import { A_TYPES__DeepPartial } from '@adaas/a-concept/types/common.types';
3
+ // import { config } from 'dotenv';
4
+ // config();
5
+ // jest.retryTimes(0);
6
+
7
+ // describe('CommonHelper Tests', () => {
8
+
9
+ // it('Schedule Should execute promise and await it ', async () => {
10
+
11
+ // const start = Date.now();
12
+ // let res = '';
13
+
14
+ // try {
15
+ // const scheduler = A_CommonHelper.schedule(3000, async () => {
16
+ // return 'RESOLVED';
17
+ // });
18
+
19
+
20
+ // res = await scheduler.promise;
21
+
22
+ // } catch (error) {
23
+ // // Handle error if any
24
+ // } finally {
25
+ // const end = Date.now();
26
+ // const duration = end - start;
27
+
28
+ // expect(res).toBe('RESOLVED');
29
+ // // Check if the duration exceeds 3 seconds
30
+ // expect(duration).toBeGreaterThan(3000);
31
+ // }
32
+
33
+ // });
34
+
35
+ // it('Schedule Should be canceled and rejected', async () => {
36
+
37
+ // const start = Date.now();
38
+ // let res = '';
39
+
40
+ // try {
41
+ // const scheduler = A_CommonHelper.schedule(3000, async () => {
42
+ // return 'RESOLVED';
43
+ // });
44
+
45
+
46
+ // scheduler.clear();
47
+ // res = await scheduler.promise;
48
+ // } catch (error) {
49
+ // // Handle error if any
50
+ // } finally {
51
+ // const end = Date.now();
52
+ // const duration = end - start;
53
+
54
+ // expect(res).toBe('');
55
+ // // Check if the duration exceeds 3 seconds
56
+ // expect(duration).toBeLessThan(3000);
57
+ // }
58
+
59
+ // });
60
+
61
+ // it('Deep Clone and Merge ', async () => {
62
+
63
+ // type TestType = {
64
+ // a: string,
65
+ // b: string,
66
+ // c: {
67
+ // d: string
68
+ // },
69
+ // f: (name: string) => string
70
+ // s: Date
71
+ // }
72
+
73
+ // const t: TestType = {
74
+ // a: 'a',
75
+ // b: 'b',
76
+ // c: {
77
+ // d: 'd'
78
+ // },
79
+ // f: (name: string) => { return name },
80
+ // s: new Date()
81
+ // }
82
+
83
+ // const t2: A_TYPES__DeepPartial<TestType> = {
84
+ // a: 'aa',
85
+ // c: {
86
+ // d: 'dd'
87
+ // },
88
+ // f: (name: string) => { return name + '2' }
89
+ // }
90
+
91
+ // const merged = A_CommonHelper.deepCloneAndMerge(t2, t);
92
+
93
+
94
+ // const name = merged.f('names');
95
+
96
+
97
+ // expect(merged.a).toBe('aa');
98
+ // expect(merged.b).toBe('b');
99
+ // expect(merged.c.d).toBe('dd');
100
+ // expect(name).toBe('names2');
101
+ // expect(t).not.toEqual(merged);
102
+ // expect(t2).not.toEqual(merged);
103
+ // });
104
+
105
+ // it('Deep Clone Different Types', async () => {
106
+
107
+ // type TestType = {
108
+ // a: string,
109
+ // b: string,
110
+ // c: {
111
+ // d: string
112
+ // },
113
+ // bool:{
114
+ // a: boolean
115
+ // },
116
+ // f: (name: string) => string
117
+ // s: Date
118
+ // }
119
+
120
+ // const t: TestType = {
121
+ // a: 'a',
122
+ // b: 'b',
123
+ // c: {
124
+ // d: 'd'
125
+ // },
126
+ // bool:{
127
+ // a: true
128
+ // },
129
+ // f: (name: string) => { return name },
130
+ // s: new Date()
131
+ // }
132
+
133
+ // const t2: any = {
134
+ // e: 'foo',
135
+ // b: 'bb',
136
+ // c:{
137
+ // d: 'ddd'
138
+ // },
139
+ // bool:{
140
+ // a: false
141
+ // },
142
+ // some: {
143
+ // d: 'dd'
144
+ // },
145
+ // }
146
+
147
+ // const merged = A_CommonHelper.deepCloneAndMerge(t2, t);
148
+
149
+ // console.log('merged: ', merged)
150
+
151
+ // expect(merged.a).toBe('a');
152
+ // expect(merged.b).toBe('bb');
153
+ // expect(merged.c.d).toBe('ddd');
154
+ // expect(merged.bool.a).toBe(false);
155
+ // expect((merged as any).e).toBe('foo');
156
+ // expect((merged as any).some.d).toBe('dd');
157
+ // expect(merged.f('names')).toBe('names');
158
+ // });
159
+ // });
package/tests/log.ts ADDED
@@ -0,0 +1,54 @@
1
+ // import { A_CONSTANTS__DEFAULT_ERRORS } from "@adaas/a-concept/constants/errors.constants";
2
+ // import { A_Context } from "@adaas/a-concept/global/A-Namespace/A_Namespace.class"
3
+ // import { A_Error } from "@adaas/a-concept/global/A_Error.class";
4
+ // import rl from 'readline';
5
+
6
+
7
+ // (async () => {
8
+
9
+ // await A_Context.ready;
10
+
11
+ // A_Context.configure({
12
+ // verbose: true
13
+ // })
14
+
15
+ // A_Context.Logger.log('Test Log', {
16
+ // test: 'test',
17
+ // test2: 'test2',
18
+ // foo: {
19
+ // bar: 'bar',
20
+ // baz: {
21
+ // qux: 'qux'
22
+ // }
23
+ // }
24
+ // }, 'Maybe its a hige update');
25
+
26
+ // A_Context.Logger.error(new Error('Test Error'), new A_Error(A_CONSTANTS__DEFAULT_ERRORS.CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ));
27
+ // A_Context.Logger.error(new A_Error(A_CONSTANTS__DEFAULT_ERRORS.CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ));
28
+ // A_Context.Logger.log(new A_Error(A_CONSTANTS__DEFAULT_ERRORS.CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ));
29
+
30
+ // const rlInterface = rl.createInterface({
31
+ // input: process.stdin,
32
+ // output: process.stdout
33
+ // });
34
+
35
+ // const answer = await new Promise<string>(resolve => rlInterface
36
+ // .question(
37
+ // A_Context.Logger.compile('pink', 'What is your name?', '(1,2,3,4)').join(' ') + '\n' +
38
+ // A_Context.Logger.compile('pink', 'Answer (1,2,3,4)').join(' '),
39
+ // resolve));
40
+
41
+ // rl.moveCursor(process.stdout, 0, -1); // Move cursor to the beginning of the previous line
42
+ // rl.clearLine(process.stdout, 0); // Clear the current line
43
+
44
+ // const answer2 = await new Promise<string>(resolve => rlInterface
45
+ // .question(
46
+ // A_Context.Logger.compile('pink', 'Answer (1,2,3,4)').join(' '),
47
+ // resolve));
48
+
49
+ // rl.moveCursor(process.stdout, 0, -1); // Move cursor to the beginning of the previous line
50
+ // rl.clearLine(process.stdout, 0); // Clear the current line
51
+ // // console.log('Asnwer: ', answer);
52
+
53
+
54
+ // })()
@@ -0,0 +1,37 @@
1
+ // import { config } from 'dotenv';
2
+ // import { A_Polyfills } from '../src/lib/A_Polyfills'
3
+ // config();
4
+ // jest.retryTimes(0);
5
+
6
+ // describe('Polyfill Tests', () => {
7
+
8
+ // it('It Should return fs', async () => {
9
+
10
+ // const fs = await A_Polyfills.fs();
11
+
12
+
13
+ // console.log('fs: ', fs)
14
+
15
+
16
+ // });
17
+ // it('It Should return crypto', async () => {
18
+
19
+ // const crypto = await A_Polyfills.crypto();
20
+
21
+ // console.log('crypto: ', crypto)
22
+
23
+ // });
24
+
25
+ // it('Crypto should calculate Hash', async () => {
26
+
27
+ // const crypto = await A_Polyfills.crypto();
28
+
29
+ // const hash = await crypto.createFileHash('./index.ts', 'sha-256');
30
+
31
+ // console.log('hash: ', hash)
32
+
33
+
34
+ // });
35
+
36
+
37
+ // });
package/tsconfig.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "compileOnSave": false,
3
+ "compilerOptions": {
4
+ "outDir": "dist",
5
+ "strict": true,
6
+ "noImplicitAny": false,
7
+ "noFallthroughCasesInSwitch": true,
8
+ "downlevelIteration": true,
9
+ "strictFunctionTypes": true,
10
+ "strictNullChecks": true,
11
+ "strictPropertyInitialization": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "resolveJsonModule": true,
14
+ "noErrorTruncation": true,
15
+ "jsx": "react",
16
+ "target": "es2015",
17
+ "module": "commonjs",
18
+ "moduleResolution": "node",
19
+ "allowSyntheticDefaultImports": true,
20
+ "esModuleInterop": true,
21
+ "noUnusedLocals": false,
22
+ "noUnusedParameters": false,
23
+ "removeComments": false,
24
+ "preserveConstEnums": true,
25
+ "sourceMap": true,
26
+ "baseUrl": ".",
27
+ "experimentalDecorators": true,
28
+ "skipLibCheck": true,
29
+ "typeRoots": [
30
+ "node_modules/@types"
31
+ ],
32
+ "paths": {
33
+ "@adaas/a-concept/constants/*": ["src/constants/*"],
34
+ "@adaas/a-concept/global/*": ["src/global/*"],
35
+ "@adaas/a-concept/types/*": ["src/types/*"],
36
+ "@adaas/a-concept/helpers/*": ["src/helpers/*"],
37
+ "@adaas/a-concept/decorators/*": ["src/decorators/*"],
38
+ "@adaas/a-concept/managers/*": ["src/managers/*"],
39
+ "@adaas/a-concept/providers/*": ["src/providers/*"],
40
+ "@adaas/a-concept/modules/*": ["src/modules/*"]
41
+ },
42
+ "lib": [
43
+ "dom",
44
+ "esnext.asynciterable",
45
+ "es2015",
46
+ "es2016",
47
+ "es2017.object"
48
+ ]
49
+ },
50
+ "include": [
51
+ "src/**/*",
52
+ "tests/**/*",
53
+ "examples/**/*",
54
+ "index.ts"
55
+ ],
56
+ "exclude": [
57
+ "node_modules/**/*",
58
+ "dist/**/*",
59
+ "node_modules/@types/mocha/index.d.ts"
60
+ ]
61
+ }
package/tslint.json ADDED
@@ -0,0 +1,98 @@
1
+ {
2
+ "extends": [
3
+ "tslint-react",
4
+ "tslint-config-standard",
5
+ "tslint-microsoft-contrib",
6
+ "tslint-config-prettier"
7
+ ],
8
+ "rules": {
9
+ "array-bracket-spacing": [true, "never"],
10
+ "arrow-return-shorthand": true,
11
+ "no-backbone-get-set-outside-model": false,
12
+ "completed-docs": false,
13
+ "curly": [true, "ignore-same-line"],
14
+ "cyclomatic-complexity": [true, 24],
15
+ "eofline": true,
16
+ "export-name": false,
17
+ "function-name": false,
18
+ "import-name": false,
19
+ "import-spacing": true,
20
+ "interface-name": [true, "never-prefix"],
21
+ "jsx-alignment": false,
22
+ "jsx-boolean-value": false,
23
+ "jsx-curly-spacing": false,
24
+ "jsx-no-multiline-js": false,
25
+ "match-default-export-name": false,
26
+ "max-func-body-length": 200,
27
+ "member-access": [true, "no-public"],
28
+ "member-ordering": {"options": [{"order": "fields-first"}]},
29
+ "missing-jsdoc": false,
30
+ "mocha-no-side-effect-code": false,
31
+ "no-arg": true,
32
+ "no-bitwise": true,
33
+ "no-console": false,
34
+ "no-construct": true,
35
+ "no-default-export": false,
36
+ "no-duplicate-switch-case": true,
37
+ "no-duplicate-variable": true,
38
+ "no-empty-interface": false,
39
+ "no-eval": true,
40
+ "no-function-expression": false,
41
+ "no-http-string": false,
42
+ "no-implicit-dependencies": false,
43
+ "no-multiline-string": false,
44
+ "no-non-null-assertion": true,
45
+ "no-relative-imports": false,
46
+ "no-require-imports": {"severity": "warning"},
47
+ "no-reserved-keywords": false,
48
+ "no-return-await": true,
49
+ "no-single-line-block-comment": false,
50
+ "no-string-throw": true,
51
+ "no-submodule-imports": false,
52
+ "no-suspicious-comment": false,
53
+ "no-unsafe-any": false,
54
+ "no-unused-variable": false,
55
+ "no-var-requires": true,
56
+ "no-void-expression": false,
57
+ "object-curly-spacing": [true, "never"],
58
+ "ordered-imports": false,
59
+ "prefer-for-of": true,
60
+ "prefer-object-spread": true,
61
+ "prefer-type-cast": false,
62
+ "quotemark": [true, "single", "jsx-double", "avoid-escape"],
63
+ "semicolon": [true, "never"],
64
+ "strict-boolean-expressions": false,
65
+ "strict-type-predicates": false,
66
+ "ter-func-call-spacing": [true, "never"],
67
+ "trailing-comma": [true, "always"],
68
+ "type-literal-delimiter": false,
69
+ "typedef": false,
70
+ "typedef-whitespace": [
71
+ true,
72
+ {
73
+ "call-signature": "nospace",
74
+ "index-signature": "nospace",
75
+ "parameter": "nospace",
76
+ "property-declaration": "nospace",
77
+ "variable-declaration": "nospace"
78
+ },
79
+ {
80
+ "call-signature": "onespace",
81
+ "index-signature": "onespace",
82
+ "parameter": "onespace",
83
+ "property-declaration": "onespace",
84
+ "variable-declaration": "onespace"
85
+ }
86
+ ],
87
+ "unified-signatures": true,
88
+ "variable-name": false,
89
+ "whitespace": [
90
+ true,
91
+ "check-branch",
92
+ "check-operator",
93
+ "check-typecast",
94
+ "check-rest-spread",
95
+ "check-type-operator"
96
+ ]
97
+ }
98
+ }