@adaas/a-concept 0.0.2 → 0.0.4
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.
- package/dist/examples/simple/components/A.component.d.ts +7 -0
- package/dist/examples/simple/components/A.component.js +57 -0
- package/dist/examples/simple/components/A.component.js.map +1 -0
- package/dist/examples/simple/components/B.component.d.ts +9 -0
- package/dist/examples/simple/components/B.component.js +77 -0
- package/dist/examples/simple/components/B.component.js.map +1 -0
- package/dist/examples/simple/concept.d.ts +1 -0
- package/dist/examples/simple/concept.js +53 -11
- package/dist/examples/simple/concept.js.map +1 -1
- package/dist/examples/simple/containers/Main.container.d.ts +11 -0
- package/dist/examples/simple/containers/Main.container.js +64 -0
- package/dist/examples/simple/containers/Main.container.js.map +1 -0
- package/dist/examples/simple/context/Fragment_A.context.d.ts +6 -0
- package/dist/examples/simple/context/Fragment_A.context.js +16 -0
- package/dist/examples/simple/context/Fragment_A.context.js.map +1 -0
- package/dist/examples/simple/context/Fragment_B.context.d.ts +6 -0
- package/dist/examples/simple/context/Fragment_B.context.js +16 -0
- package/dist/examples/simple/context/Fragment_B.context.js.map +1 -0
- package/dist/examples/simple-http-server/components/http-error-handler.component.d.ts +9 -0
- package/dist/examples/simple-http-server/components/http-error-handler.component.js +63 -0
- package/dist/examples/simple-http-server/components/http-error-handler.component.js.map +1 -0
- package/dist/examples/simple-http-server/components/http-request-handler.component.d.ts +2 -0
- package/dist/examples/simple-http-server/components/http-request-handler.component.js +7 -0
- package/dist/examples/simple-http-server/components/http-request-handler.component.js.map +1 -0
- package/dist/examples/simple-http-server/concept.js +21 -22
- package/dist/examples/simple-http-server/concept.js.map +1 -1
- package/dist/examples/simple-http-server/containers/http-server.container.d.ts +8 -8
- package/dist/examples/simple-http-server/containers/http-server.container.js +34 -30
- package/dist/examples/simple-http-server/containers/http-server.container.js.map +1 -1
- package/dist/examples/simple-http-server/containers/http-server.controller.js +1 -1
- package/dist/examples/simple-http-server/containers/http-server.router.js +2 -2
- package/dist/examples/simple-http-server/containers/http-server.router.js.map +1 -1
- package/dist/examples/simple-http-server/contexts/http-request.context.d.ts +13 -0
- package/dist/examples/simple-http-server/contexts/http-request.context.js +51 -0
- package/dist/examples/simple-http-server/contexts/http-request.context.js.map +1 -0
- package/dist/examples/simple-http-server/contexts/http-server.context.types.d.ts +0 -4
- package/dist/examples/simple-http-server/contexts/http-server.context.types.js +0 -98
- package/dist/examples/simple-http-server/contexts/http-server.context.types.js.map +1 -1
- package/dist/examples/simple-http-server/contexts/http-server.namespace.d.ts +1 -1
- package/dist/examples/simple-http-server/contexts/http-server.namespace.js +1 -1
- package/dist/examples/simple-http-server/controllers/users.controller.js +2 -2
- package/dist/examples/simple-http-server/test.d.ts +68 -0
- package/dist/examples/simple-http-server/test.js +162 -0
- package/dist/examples/simple-http-server/test.js.map +1 -0
- package/dist/index.d.ts +25 -7
- package/dist/index.js +55 -13
- package/dist/index.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.container.d.ts +8 -0
- package/dist/src/base/A-Config/A-Config.container.js +64 -0
- package/dist/src/base/A-Config/A-Config.container.js.map +1 -0
- package/dist/src/base/A-Config/A-Config.context.d.ts +30 -0
- package/dist/src/base/A-Config/A-Config.context.js +58 -0
- package/dist/src/base/A-Config/A-Config.context.js.map +1 -0
- package/dist/src/base/A-Config/A-Config.types.d.ts +14 -0
- package/dist/src/base/A-Config/A-Config.types.js +3 -0
- package/dist/src/base/A-Config/A-Config.types.js.map +1 -0
- package/dist/src/base/A-Config/components/ConfigReader.component.d.ts +19 -0
- package/dist/src/base/A-Config/components/ConfigReader.component.js +53 -0
- package/dist/src/base/A-Config/components/ConfigReader.component.js.map +1 -0
- package/dist/src/base/A-Config/components/ENVConfigReader.component.d.ts +10 -0
- package/dist/src/base/A-Config/components/ENVConfigReader.component.js +37 -0
- package/dist/src/base/A-Config/components/ENVConfigReader.component.js.map +1 -0
- package/dist/src/base/A-Config/components/FileConfigReader.component.d.ts +11 -0
- package/dist/src/base/A-Config/components/FileConfigReader.component.js +47 -0
- package/dist/src/base/A-Config/components/FileConfigReader.component.js.map +1 -0
- package/dist/src/base/A-Errors/A-Errors.component.d.ts +18 -0
- package/dist/src/base/A-Errors/A-Errors.component.js +85 -0
- package/dist/src/base/A-Errors/A-Errors.component.js.map +1 -0
- package/dist/src/base/A-Errors/A-Errors.context.d.ts +27 -0
- package/dist/src/base/A-Errors/A-Errors.context.js +50 -0
- package/dist/src/base/A-Errors/A-Errors.context.js.map +1 -0
- package/dist/src/base/A-Errors/A-Errors.types.d.ts +5 -0
- package/dist/src/base/A-Errors/A-Errors.types.js +3 -0
- package/dist/src/base/A-Errors/A-Errors.types.js.map +1 -0
- package/dist/src/base/A-Logger/A-Logger.component.d.ts +28 -0
- package/dist/src/base/A-Logger/A-Logger.component.js +142 -0
- package/dist/src/base/A-Logger/A-Logger.component.js.map +1 -0
- package/dist/src/base/A-Logger/A-Logger.types.js +2 -0
- package/dist/src/base/A-Logger/A-Logger.types.js.map +1 -0
- package/dist/src/constants/A_ConceptLifecycle.constants.d.ts +0 -2
- package/dist/src/constants/A_ConceptLifecycle.constants.js +9 -10
- package/dist/src/constants/A_ConceptLifecycle.constants.js.map +1 -1
- package/dist/src/containers/A-Config/A-Config.container.js +1 -1
- package/dist/src/containers/A-Config/A-Config.namespace.d.ts +1 -1
- package/dist/src/containers/A-Config/A-Config.namespace.js +1 -1
- package/dist/src/containers/A-Config/A-Config.types.d.ts +1 -1
- package/dist/src/containers/A-Errors/A-Errors.container.js +1 -1
- package/dist/src/containers/A-Errors/A-Errors.namespace.d.ts +1 -1
- package/dist/src/containers/A-Errors/A-Errors.namespace.js +1 -1
- package/dist/src/containers/A-Errors/A-Errors.types.d.ts +1 -1
- package/dist/src/containers/A-Logger/A-Logger.container.js +1 -1
- package/dist/src/containers/A-Logger/A-Logger.namespace.d.ts +1 -1
- package/dist/src/containers/A-Logger/A-Logger.namespace.js +1 -1
- package/dist/src/containers/A-Logger/components/Logger.component.d.ts +1 -1
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.js.map +1 -1
- package/dist/src/decorators/A-Define/Feature/Feature.decorator.d.ts +16 -0
- package/dist/src/decorators/A-Define/Feature/Feature.decorator.js +36 -0
- package/dist/src/decorators/A-Define/Feature/Feature.decorator.js.map +1 -0
- package/dist/src/decorators/A-Define/Feature/Feature.decorator.types.d.ts +8 -0
- package/dist/src/decorators/A-Define/Feature/Feature.decorator.types.js +3 -0
- package/dist/src/decorators/A-Define/Feature/Feature.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-Define/Lifecycle/Lifecycle.decorator.d.ts +14 -0
- package/dist/src/decorators/A-Define/Lifecycle/Lifecycle.decorator.js +24 -0
- package/dist/src/decorators/A-Define/Lifecycle/Lifecycle.decorator.js.map +1 -0
- package/dist/src/decorators/A-Define/Lifecycle/Lifecycle.decorator.types.d.ts +8 -0
- package/dist/src/decorators/A-Define/Lifecycle/Lifecycle.decorator.types.js +3 -0
- package/dist/src/decorators/A-Define/Lifecycle/Lifecycle.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-Define/index.d.ts +7 -0
- package/dist/src/decorators/A-Define/index.js +10 -0
- package/dist/src/decorators/A-Define/index.js.map +1 -0
- package/dist/src/decorators/A-Extend/A-Extend.decorator.d.ts +18 -0
- package/dist/src/decorators/A-Extend/A-Extend.decorator.js +37 -0
- package/dist/src/decorators/A-Extend/A-Extend.decorator.js.map +1 -0
- package/dist/src/decorators/A-Extend/A-Extend.decorator.types.d.ts +21 -0
- package/dist/src/decorators/A-Extend/A-Extend.decorator.types.js +3 -0
- package/dist/src/decorators/A-Extend/A-Extend.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.d.ts +16 -0
- package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js +37 -0
- package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js.map +1 -0
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.d.ts +16 -0
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js +42 -0
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +1 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +20 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.js +1 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +12 -10
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js +16 -26
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -1
- package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +4 -3
- package/dist/src/decorators/A-Stage/A-Stage.decorator.d.ts +12 -0
- package/dist/src/decorators/A-Stage/A-Stage.decorator.js +35 -0
- package/dist/src/decorators/A-Stage/A-Stage.decorator.js.map +1 -0
- package/dist/src/decorators/A-Stage/A-Stage.decorator.types.d.ts +2 -0
- package/dist/src/decorators/A-Stage/A-Stage.decorator.types.js +3 -0
- package/dist/src/decorators/A-Stage/A-Stage.decorator.types.js.map +1 -0
- package/dist/src/global/A-Channel/A-Channel.class.d.ts +18 -0
- package/dist/src/global/A-Channel/A-Channel.class.js +54 -0
- package/dist/src/global/A-Channel/A-Channel.class.js.map +1 -0
- package/dist/src/global/A-Channel/A-Channel.types.d.ts +35 -0
- package/dist/src/global/A-Channel/A-Channel.types.js +3 -0
- package/dist/src/global/A-Channel/A-Channel.types.js.map +1 -0
- package/dist/src/global/A-Component/A-Component.class.d.ts +1 -11
- package/dist/src/global/A-Component/A-Component.class.js +0 -7
- package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.meta.d.ts +4 -0
- package/dist/src/global/A-Component/A-Component.meta.js +8 -0
- package/dist/src/global/A-Component/A-Component.meta.js.map +1 -0
- package/dist/src/global/A-Component/A-Component.types.d.ts +18 -0
- package/dist/src/global/A-Component/A-Component.types.js +10 -0
- package/dist/src/global/A-Component/A-Component.types.js.map +1 -0
- package/dist/src/global/A-Concept/A_Concept.class.d.ts +41 -17
- package/dist/src/global/A-Concept/A_Concept.class.js +120 -43
- package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
- package/dist/src/global/A-Concept/A_Concept.meta.d.ts +3 -0
- package/dist/src/global/A-Concept/A_Concept.meta.js +9 -0
- package/dist/src/global/A-Concept/A_Concept.meta.js.map +1 -0
- package/dist/src/global/A-Concept/A_Concept.types.d.ts +31 -16
- package/dist/src/global/A-Concept/A_Concept.types.js +25 -0
- package/dist/src/global/A-Concept/A_Concept.types.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.class.d.ts +72 -10
- package/dist/src/global/A-Container/A-Container.class.js +119 -9
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.meta.d.ts +7 -0
- package/dist/src/global/A-Container/A-Container.meta.js +54 -0
- package/dist/src/global/A-Container/A-Container.meta.js.map +1 -0
- package/dist/src/global/A-Container/A-Container.types.d.ts +31 -0
- package/dist/src/global/A-Container/A-Container.types.js +9 -0
- package/dist/src/global/A-Container/A-Container.types.js.map +1 -0
- package/dist/src/global/A-Context/A-Context.class.d.ts +36 -54
- package/dist/src/global/A-Context/A-Context.class.js +127 -61
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.types.d.ts +12 -0
- package/dist/src/global/A-Context/A-Context.types.js +1 -0
- package/dist/src/global/A-Context/A-ContextFragment.class.d.ts +12 -0
- package/dist/src/global/A-Context/A-ContextFragment.class.js +19 -0
- package/dist/src/global/A-Context/A-ContextFragment.class.js.map +1 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.types.d.ts +0 -55
- package/dist/src/global/A-Dependency/A-DependencyReference.types.js +56 -1
- package/dist/src/global/A-Dependency/A-DependencyReference.types.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.class.d.ts +10 -0
- package/dist/src/global/A-Entity/A-Entity.class.js +16 -0
- package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -0
- package/dist/src/global/A-Entity/A-Entity.types.js +2 -0
- package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -0
- package/dist/src/global/A-Feature/A-Feature.class.d.ts +44 -0
- package/dist/src/global/A-Feature/A-Feature.class.js +125 -0
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -0
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +17 -0
- package/dist/src/global/A-Feature/A-Feature.types.js +11 -0
- package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -0
- package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +38 -0
- package/dist/src/global/A-Fragment/A-Fragment.class.js +107 -0
- package/dist/src/global/A-Fragment/A-Fragment.class.js.map +1 -0
- package/dist/src/global/A-Fragment/A-Fragment.types.d.ts +3 -0
- package/dist/src/global/A-Fragment/A-Fragment.types.js +3 -0
- package/dist/src/global/A-Fragment/A-Fragment.types.js.map +1 -0
- package/dist/src/global/A-Meta/A-Meta.class.d.ts +11 -0
- package/dist/src/global/A-Meta/A-Meta.class.js +43 -0
- package/dist/src/global/A-Meta/A-Meta.class.js.map +1 -0
- package/dist/src/global/A-Meta/A-Meta.types.d.ts +0 -0
- package/dist/src/global/A-Meta/A-Meta.types.js +2 -0
- package/dist/src/global/A-Meta/A-Meta.types.js.map +1 -0
- package/dist/src/global/A-Scope/A-Scope.class.d.ts +51 -0
- package/dist/src/global/A-Scope/A-Scope.class.js +133 -0
- package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -0
- package/dist/src/global/A-Scope/A-Scope.types.d.ts +32 -0
- package/dist/src/global/A-Scope/A-Scope.types.js +3 -0
- package/dist/src/global/A-Scope/A-Scope.types.js.map +1 -0
- package/dist/src/storage/A_Component.storage.d.ts +10 -0
- package/dist/src/storage/A_Component.storage.js +17 -0
- package/dist/src/storage/A_Component.storage.js.map +1 -0
- package/dist/src/storage/A_Concept.storage.js +2 -2
- package/dist/src/storage/A_Concept.storage.js.map +1 -1
- package/dist/src/storage/A_Container.storage.d.ts +8 -0
- package/dist/src/storage/A_Container.storage.js +17 -0
- package/dist/src/storage/A_Container.storage.js.map +1 -0
- package/dist/src/storage/A_Inject.storage.d.ts +9 -0
- package/dist/src/storage/A_Inject.storage.js +13 -0
- package/dist/src/storage/A_Inject.storage.js.map +1 -0
- package/examples/simple/components/A.component.ts +35 -0
- package/examples/simple/components/B.component.ts +46 -0
- package/examples/simple/concept.ts +49 -12
- package/examples/simple/containers/Main.container.ts +41 -0
- package/examples/simple/context/Fragment_A.context.ts +25 -0
- package/examples/simple/context/Fragment_B.context.ts +19 -0
- package/examples/simple-http-server/components/http-error-handler.component.ts +44 -0
- package/examples/simple-http-server/components/http-request-handler.component.ts +9 -0
- package/examples/simple-http-server/concept.ts +22 -21
- package/examples/simple-http-server/containers/http-server.container.ts +23 -38
- package/examples/simple-http-server/contexts/http-request.context.ts +59 -0
- package/examples/simple-http-server/contexts/http-server.context.types.ts +0 -108
- package/examples/simple-http-server/test.ts +290 -0
- package/index.ts +55 -8
- package/jest.config.ts +2 -0
- package/package.json +4 -7
- package/src/{containers → base}/A-Config/A-Config.container.ts +21 -20
- package/src/{containers/A-Config/A-Config.namespace.ts → base/A-Config/A-Config.context.ts} +12 -5
- package/src/{containers → base}/A-Config/A-Config.types.ts +10 -4
- package/src/{containers → base}/A-Config/components/ConfigReader.component.ts +7 -3
- package/src/{containers → base}/A-Config/components/ENVConfigReader.component.ts +1 -1
- package/src/{containers → base}/A-Config/components/FileConfigReader.component.ts +1 -1
- package/src/base/A-Errors/A-Errors.component.ts +102 -0
- package/src/{containers/A-Errors/A-Errors.namespace.ts → base/A-Errors/A-Errors.context.ts} +24 -39
- package/src/{containers → base}/A-Errors/A-Errors.types.ts +2 -2
- package/src/base/A-Logger/A-Logger.component.ts +169 -0
- package/src/base/A-Logger/A-Logger.types.ts +0 -0
- package/src/constants/A_ConceptLifecycle.constants.ts +9 -9
- package/src/decorators/A-Feature/A-Feature-Define.decorator.ts +57 -0
- package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +57 -0
- package/src/decorators/A-Feature/A-Feature.decorator.types.ts +56 -0
- package/src/decorators/A-Inject/A-Inject.decorator.ts +65 -53
- package/src/decorators/A-Inject/A-Inject.decorator.types.ts +31 -4
- package/src/decorators/A-Stage/A-Stage.decorator.ts +57 -0
- package/src/decorators/A-Stage/A-Stage.decorator.types.ts +23 -0
- package/src/global/A-Channel/A-Channel.class.ts +48 -0
- package/src/global/A-Channel/A-Channel.types.ts +60 -0
- package/src/global/A-Component/A-Component.class.ts +1 -29
- package/src/global/A-Component/A-Component.meta.ts +9 -0
- package/src/global/A-Component/A-Component.types.ts +40 -0
- package/src/global/A-Concept/A_Concept.class.ts +160 -66
- package/src/global/A-Concept/A_Concept.meta.ts +9 -0
- package/src/global/A-Concept/A_Concept.types.ts +45 -10
- package/src/global/A-Container/A-Container.class.ts +177 -22
- package/src/global/A-Container/A-Container.meta.ts +80 -0
- package/src/global/A-Container/A-Container.types.ts +40 -0
- package/src/global/A-Context/A-Context.class.ts +231 -130
- package/src/global/A-Context/A-Context.types.ts +15 -0
- package/src/global/A-Dependency/A-DependencyReference.types.ts +56 -56
- package/src/global/A-Entity/A-Entity.class.ts +16 -0
- package/src/global/A-Entity/A-Entity.types.ts +0 -0
- package/src/global/A-Feature/A-Feature.class.ts +156 -0
- package/src/global/A-Feature/A-Feature.types.ts +20 -0
- package/src/global/{A-Namespace/A_Namespace.class.ts → A-Fragment/A-Fragment.class.ts} +24 -30
- package/src/global/A-Fragment/A-Fragment.types.ts +6 -0
- package/src/global/A-Meta/A-Meta.class.ts +60 -0
- package/src/global/A-Meta/A-Meta.types.ts +0 -0
- package/src/global/A-Scope/A-Scope.class.ts +208 -0
- package/src/global/A-Scope/A-Scope.types.ts +37 -0
- package/src/storage/A_Component.storage.ts +28 -0
- package/src/storage/A_Concept.storage.ts +5 -1
- package/src/storage/A_Container.storage.ts +21 -0
- package/src/storage/A_Inject.storage.ts +30 -0
- package/tsconfig.json +3 -1
- package/examples/sdk/concept.ts +0 -24
- package/examples/sdk/orders.api.ts +0 -21
- package/examples/sdk/users.api.ts +0 -21
- package/examples/simple-http-server/containers/http-server.controller.ts +0 -24
- package/examples/simple-http-server/containers/http-server.router.ts +0 -23
- package/examples/simple-http-server/contexts/http-server.namespace.ts +0 -36
- package/src/containers/A-Errors/A-Errors.container.ts +0 -14
- package/src/containers/A-Logger/A-Logger.container.ts +0 -22
- package/src/containers/A-Logger/A-Logger.namespace.ts +0 -26
- package/src/containers/A-Logger/components/Logger.component.ts +0 -169
- package/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.ts +0 -46
- package/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.ts +0 -55
- package/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.ts +0 -20
- package/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.ts +0 -62
- package/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.ts +0 -28
- package/src/decorators/A-ConceptLifecycle/index.ts +0 -9
- package/src/decorators/A-Feature/A-Feature.decorator.ts +0 -13
- package/src/decorators/A_Lazy.decorator.ts +0 -31
- package/src/global/A-Namespace/A_Namespace.types.ts +0 -24
- /package/{src/containers/A-Logger/A-Logger.types.ts → dist/src/base/A-Logger/A-Logger.types.d.ts} +0 -0
- /package/{src/decorators/A_ConceptMethods.decorator.ts → dist/src/global/A-Entity/A-Entity.types.d.ts} +0 -0
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ConfigReader } from "./components/ConfigReader.component";
|
|
3
|
+
import { A_Logger } from "../A-Logger/A-Logger.component";
|
|
4
|
+
import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator";
|
|
4
5
|
import { A_Polyfills } from "@adaas/a-utils";
|
|
6
|
+
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
5
7
|
import { FileConfigReader } from "./components/FileConfigReader.component";
|
|
6
8
|
import { ENVConfigReader } from "./components/ENVConfigReader.component";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
+
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
|
|
12
|
-
// @A_Injectable({
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
export class A_ConfigInitializer extends A_Container<A_Config> {
|
|
15
|
+
export class A_ConfigLoader extends A_Container<['load', 'read']> {
|
|
16
16
|
|
|
17
17
|
private reader!: ConfigReader
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
})
|
|
20
|
+
|
|
22
21
|
async identifyReader(
|
|
23
|
-
|
|
22
|
+
@A_Inject(A_Scope) scope: A_Scope,
|
|
23
|
+
@A_Inject(A_Logger) logger: A_Logger
|
|
24
24
|
) {
|
|
25
25
|
|
|
26
26
|
// OR Inject the logger by calling Context Provider
|
|
@@ -30,17 +30,17 @@ export class A_ConfigInitializer extends A_Container<A_Config> {
|
|
|
30
30
|
|
|
31
31
|
switch (true) {
|
|
32
32
|
|
|
33
|
-
case A_Context.environment === 'server' && !!fs.existsSync(`${
|
|
34
|
-
this.reader =
|
|
33
|
+
case A_Context.environment === 'server' && !!fs.existsSync(`${scope.name}.conf.json`):
|
|
34
|
+
this.reader = scope.resolve(FileConfigReader);
|
|
35
35
|
break;
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
case A_Context.environment === 'server': !fs.existsSync(`${
|
|
39
|
-
this.reader =
|
|
38
|
+
case A_Context.environment === 'server': !fs.existsSync(`${scope.name}.conf.json`)
|
|
39
|
+
this.reader = scope.resolve(ENVConfigReader);
|
|
40
40
|
break;
|
|
41
41
|
|
|
42
42
|
case A_Context.environment === 'browser':
|
|
43
|
-
this.reader =
|
|
43
|
+
this.reader = scope.resolve(ENVConfigReader);
|
|
44
44
|
break;
|
|
45
45
|
|
|
46
46
|
default:
|
|
@@ -48,13 +48,14 @@ export class A_ConfigInitializer extends A_Container<A_Config> {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
@A_Load({})
|
|
53
51
|
async readVariables() {
|
|
54
|
-
const config = await this.reader.read(this.namespace.CONFIG_PROPERTIES);
|
|
52
|
+
// const config = await this.reader.read(this.namespace.CONFIG_PROPERTIES);
|
|
55
53
|
|
|
56
|
-
this.namespace.set(config);
|
|
57
|
-
}
|
|
58
54
|
|
|
55
|
+
}
|
|
59
56
|
|
|
60
57
|
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const foo = new A_ConfigLoader({});
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A_CommonHelper, A_TYPES__Required } from "@adaas/a-utils";
|
|
2
2
|
import { A_TYPES__ConfigContainerConstructor } from "./A-Config.types";
|
|
3
|
+
import { A_Fragment } from "@adaas/a-concept/global/A-Fragment/A-Fragment.class";
|
|
3
4
|
|
|
4
5
|
|
|
5
6
|
export class A_Config<
|
|
6
7
|
T extends string = any
|
|
7
|
-
> extends
|
|
8
|
+
> extends A_Fragment {
|
|
9
|
+
|
|
10
|
+
config: A_TYPES__ConfigContainerConstructor<T>;
|
|
8
11
|
|
|
9
12
|
// Custom properties
|
|
10
13
|
private VARIABLES: Map<string, any> = new Map<string, any>();
|
|
14
|
+
|
|
11
15
|
CONFIG_PROPERTIES: T[] = [];
|
|
12
16
|
|
|
13
17
|
protected DEFAULT_ALLOWED_TO_READ_PROPERTIES = [
|
|
@@ -18,13 +22,16 @@ export class A_Config<
|
|
|
18
22
|
|
|
19
23
|
|
|
20
24
|
constructor(
|
|
21
|
-
config: A_TYPES__ConfigContainerConstructor<T>
|
|
25
|
+
config: A_TYPES__Required<Partial<A_TYPES__ConfigContainerConstructor<T>>, ['variables']>
|
|
22
26
|
) {
|
|
23
27
|
super(config);
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
this.config = A_CommonHelper.deepCloneAndMerge<A_TYPES__ConfigContainerConstructor<T>>(config as any, {
|
|
30
|
+
name: this.name,
|
|
31
|
+
defaults: {} as Record<T, any>
|
|
32
|
+
});
|
|
26
33
|
|
|
27
|
-
this.CONFIG_PROPERTIES =
|
|
34
|
+
this.CONFIG_PROPERTIES = this.config.variables ? this.config.variables : [];
|
|
28
35
|
}
|
|
29
36
|
|
|
30
37
|
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A_TYPES__FragmentConstructor } from "@adaas/a-concept/global/A-Fragment/A-Fragment.types";
|
|
2
|
+
import { A_TYPES__Dictionary } from "@adaas/a-utils";
|
|
2
3
|
|
|
3
4
|
export type A_TYPES__ConfigContainerConstructor<T extends string> = {
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
7
|
+
* Allows to define the names of variable to be loaded
|
|
6
8
|
*/
|
|
7
9
|
variables?: Array<T>
|
|
10
|
+
|
|
8
11
|
/**
|
|
9
12
|
* Allows to set the default values for the variables
|
|
10
13
|
*/
|
|
11
|
-
defaults?:
|
|
14
|
+
defaults?: {
|
|
15
|
+
[key in T]?: any
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
// credentials?: {
|
|
13
19
|
// /**
|
|
14
20
|
// * Api Credentials Client ID to authenticate the SDK
|
|
@@ -23,7 +29,7 @@ export type A_TYPES__ConfigContainerConstructor<T extends string> = {
|
|
|
23
29
|
// client_secret: string
|
|
24
30
|
|
|
25
31
|
// }
|
|
26
|
-
} &
|
|
32
|
+
} & A_TYPES__FragmentConstructor;
|
|
27
33
|
|
|
28
34
|
|
|
29
35
|
export type A_TYPES__ConfigContainer_DefaultProperties = 'CONFIG_SDK_VALIDATION'
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
2
|
+
import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator";
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Config Reader
|
|
8
8
|
*/
|
|
9
|
-
export class ConfigReader
|
|
9
|
+
export class ConfigReader {
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
@A_Inject(A_Scope) protected scope: A_Scope
|
|
13
|
+
) { }
|
|
10
14
|
|
|
11
15
|
|
|
12
16
|
/**
|
|
@@ -10,7 +10,7 @@ export class ENVConfigReader extends ConfigReader {
|
|
|
10
10
|
* @param property
|
|
11
11
|
*/
|
|
12
12
|
getConfigurationProperty_ENV_Alias(property: string): string {
|
|
13
|
-
return `${A_CommonHelper.toUpperSnakeCase(this.
|
|
13
|
+
return `${A_CommonHelper.toUpperSnakeCase(this.scope.name)}_${A_CommonHelper.toUpperSnakeCase(property)}`;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
|
|
@@ -26,7 +26,7 @@ export class FileConfigReader extends ConfigReader {
|
|
|
26
26
|
): Promise<Record<T, any>> {
|
|
27
27
|
const fs = await A_Polyfills.fs();
|
|
28
28
|
try {
|
|
29
|
-
const data = fs.readFileSync(`${this.
|
|
29
|
+
const data = fs.readFileSync(`${this.scope.name}.conf.json`, 'utf8');
|
|
30
30
|
|
|
31
31
|
const config: Record<T, any> = JSON.parse(data);
|
|
32
32
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
2
|
+
import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator";
|
|
3
|
+
import { A_Errors } from "./A-Errors.context";
|
|
4
|
+
import { A_CONSTANTS__ERROR_CODES, A_Error, A_ServerError, ASEID } from "@adaas/a-utils";
|
|
5
|
+
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
6
|
+
|
|
7
|
+
export class A_ErrorsManager {
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
@A_Inject(A_Scope) protected scope: A_Scope,
|
|
11
|
+
@A_Inject(A_Errors) protected errors: A_Errors
|
|
12
|
+
) {
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
throw(
|
|
20
|
+
error: Error | unknown | any
|
|
21
|
+
): never
|
|
22
|
+
throw(
|
|
23
|
+
code: A_CONSTANTS__ERROR_CODES | string
|
|
24
|
+
): never
|
|
25
|
+
throw(
|
|
26
|
+
error: A_Error | A_ServerError
|
|
27
|
+
): never
|
|
28
|
+
throw(
|
|
29
|
+
param: A_CONSTANTS__ERROR_CODES | string | A_Error | A_ServerError
|
|
30
|
+
): never {
|
|
31
|
+
switch (true) {
|
|
32
|
+
// In case of error code
|
|
33
|
+
case typeof param === 'string':
|
|
34
|
+
const template = this.errors.get(param);
|
|
35
|
+
const namedCode = `${A_Context.root}@${this.scope.name}:error:${template.code}`
|
|
36
|
+
|
|
37
|
+
if ('serverCode' in template)
|
|
38
|
+
throw new A_ServerError({
|
|
39
|
+
...template,
|
|
40
|
+
code: namedCode
|
|
41
|
+
});
|
|
42
|
+
else
|
|
43
|
+
throw new A_Error({
|
|
44
|
+
...template,
|
|
45
|
+
code: namedCode
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// In case of error object
|
|
49
|
+
case param instanceof A_Error:
|
|
50
|
+
throw param;
|
|
51
|
+
|
|
52
|
+
// Otherwise wrap the error
|
|
53
|
+
default:
|
|
54
|
+
throw this.wrap(param);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* This method wraps an error into the SDK error object.
|
|
61
|
+
*
|
|
62
|
+
* @param error
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
wrap(error: Error | A_Error | unknown | any): A_ServerError | A_Error {
|
|
66
|
+
|
|
67
|
+
switch (true) {
|
|
68
|
+
case error instanceof A_Error:
|
|
69
|
+
let newCode = `${A_Context.root}@${this.scope.name}:error:${error.code}`;
|
|
70
|
+
|
|
71
|
+
if (ASEID.isASEID(error.code)) {
|
|
72
|
+
const aseid = new ASEID(error.code);
|
|
73
|
+
|
|
74
|
+
if (aseid.scope !== this.scope.name)
|
|
75
|
+
newCode = `${A_Context.root}@${this.scope.name}:error:${aseid.id}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if ('serverCode' in error)
|
|
79
|
+
return new A_ServerError({
|
|
80
|
+
originalError: error,
|
|
81
|
+
code: newCode,
|
|
82
|
+
serverCode: error.serverCode,
|
|
83
|
+
name: error.name,
|
|
84
|
+
message: error.message,
|
|
85
|
+
link: error.link,
|
|
86
|
+
description: error.description
|
|
87
|
+
});
|
|
88
|
+
else
|
|
89
|
+
return new A_Error({
|
|
90
|
+
originalError: error,
|
|
91
|
+
code: newCode,
|
|
92
|
+
name: error.name,
|
|
93
|
+
message: error.message,
|
|
94
|
+
link: error.link,
|
|
95
|
+
description: error.description
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
default:
|
|
99
|
+
return new A_Error(error);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -1,23 +1,26 @@
|
|
|
1
|
-
import { A_Namespace } from "@adaas/a-concept/global/A-Namespace/A_Namespace.class";
|
|
2
1
|
import { A_CONSTANTS__ERROR_CODES, A_Error, A_ServerError, A_TYPES__Dictionary, A_TYPES__Error, A_TYPES__ServerError } from "@adaas/a-utils";
|
|
3
2
|
import { A_TYPES__A_ErrorsConstructor } from "./A-Errors.types";
|
|
4
3
|
import { A_CONSTANTS__DEFAULT_ERRORS } from "@adaas/a-utils/dist/src/constants/errors.constants";
|
|
4
|
+
import { A_Fragment } from "@adaas/a-concept/global/A-Fragment/A-Fragment.class";
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
export class A_Errors extends
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export class A_Errors extends A_Fragment {
|
|
10
8
|
|
|
11
9
|
protected registeredErrors: Map<string, A_TYPES__Error | A_TYPES__ServerError> = new Map();
|
|
12
10
|
|
|
13
11
|
constructor(
|
|
14
12
|
params: Partial<A_TYPES__A_ErrorsConstructor>
|
|
15
13
|
) {
|
|
16
|
-
|
|
14
|
+
|
|
15
|
+
super({
|
|
16
|
+
...params,
|
|
17
|
+
name: params.name || 'a-errors'
|
|
18
|
+
});
|
|
17
19
|
|
|
18
20
|
if (params.errors) {
|
|
19
21
|
this.addRegistry(params.errors);
|
|
20
22
|
}
|
|
23
|
+
|
|
21
24
|
this.addRegistry(A_CONSTANTS__DEFAULT_ERRORS);
|
|
22
25
|
}
|
|
23
26
|
|
|
@@ -45,60 +48,42 @@ export class A_Errors extends A_Namespace<Partial<A_TYPES__A_ErrorsConstructor>>
|
|
|
45
48
|
* @param error
|
|
46
49
|
*/
|
|
47
50
|
registerError(error: A_TYPES__Error): A_Errors {
|
|
48
|
-
this.registeredErrors.set(error.code,
|
|
49
|
-
...error,
|
|
50
|
-
code: `${this.name}@error:${error.code}`
|
|
51
|
-
});
|
|
51
|
+
this.registeredErrors.set(error.code, error);
|
|
52
52
|
|
|
53
53
|
return this;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
|
|
56
57
|
/**
|
|
57
58
|
* This method returns an error object by its code.
|
|
58
59
|
*
|
|
59
60
|
* @param code
|
|
60
61
|
* @returns
|
|
61
62
|
*/
|
|
62
|
-
|
|
63
|
+
get(code: A_CONSTANTS__ERROR_CODES | string): A_TYPES__Error | A_TYPES__ServerError {
|
|
63
64
|
let template = this.registeredErrors.get(code);
|
|
64
65
|
|
|
65
66
|
if (!template)
|
|
66
|
-
template = this.registeredErrors.get(A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR)
|
|
67
|
+
template = this.registeredErrors.get(A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR)!;
|
|
67
68
|
|
|
68
|
-
|
|
69
|
-
return new A_ServerError(template as A_TYPES__ServerError);
|
|
70
|
-
} else {
|
|
71
|
-
return new A_Error(template);
|
|
72
|
-
}
|
|
69
|
+
return template;
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
|
|
76
73
|
/**
|
|
74
|
+
* Allows to throw an error by its code.
|
|
75
|
+
* [!] BUT WITHOUT Connection to particular Scope
|
|
76
|
+
*
|
|
77
77
|
* This method throws an error by its code.
|
|
78
78
|
*
|
|
79
79
|
* @param code
|
|
80
80
|
*/
|
|
81
|
-
throw(code: A_CONSTANTS__ERROR_CODES | string): never {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* This method wraps an error into the SDK error object.
|
|
91
|
-
*
|
|
92
|
-
* @param error
|
|
93
|
-
* @returns
|
|
94
|
-
*/
|
|
95
|
-
wrap(error: Error | A_Error | unknown): A_ServerError | A_Error {
|
|
96
|
-
if (error instanceof A_Error) {
|
|
97
|
-
return new A_ServerError(error);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return new A_Error(error);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
81
|
+
// throw(code: A_CONSTANTS__ERROR_CODES | string): never {
|
|
82
|
+
// const template = this.get(code);
|
|
83
|
+
|
|
84
|
+
// if ('serverCode' in template)
|
|
85
|
+
// throw new A_ServerError(template);
|
|
86
|
+
// else
|
|
87
|
+
// throw new A_Error(template)
|
|
88
|
+
// }
|
|
104
89
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A_TYPES__FragmentConstructor } from "@adaas/a-concept/global/A-Fragment/A-Fragment.types"
|
|
2
2
|
import { A_TYPES__Dictionary, A_TYPES__Error } from "@adaas/a-utils"
|
|
3
3
|
|
|
4
4
|
export type A_TYPES__A_ErrorsConstructor = {
|
|
5
5
|
errors: A_TYPES__Dictionary<A_TYPES__Error> | A_TYPES__Error[]
|
|
6
|
-
} &
|
|
6
|
+
} & A_TYPES__FragmentConstructor
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator";
|
|
2
|
+
import { A_Error } from "@adaas/a-utils";
|
|
3
|
+
import { A_Config } from "../A-Config/A-Config.context";
|
|
4
|
+
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export class A_Logger {
|
|
9
|
+
|
|
10
|
+
constructor(
|
|
11
|
+
@A_Inject(A_Scope) protected scope: A_Scope,
|
|
12
|
+
@A_Inject(A_Config) protected config: A_Config
|
|
13
|
+
) {
|
|
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 scopeLength() {
|
|
30
|
+
return this.scope.name.length;
|
|
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.scope.name}] |${this.getTime()}|`,
|
|
41
|
+
(
|
|
42
|
+
args.length > 1
|
|
43
|
+
? '\n' + `${' '.repeat(this.scopeLength + 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.scopeLength + 3)}| `);
|
|
61
|
+
|
|
62
|
+
default:
|
|
63
|
+
return String(
|
|
64
|
+
((i > 0 || args.length > 1) ? '\n' : '')
|
|
65
|
+
+ arg)
|
|
66
|
+
.replace(/\n/g, '\n' + `${' '.repeat(this.scopeLength + 3)}| `)
|
|
67
|
+
}
|
|
68
|
+
})),
|
|
69
|
+
(
|
|
70
|
+
args.length > 1
|
|
71
|
+
? '\n' + `${' '.repeat(this.scopeLength + 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.scope.name}] |${time}| ERROR ${error.code}
|
|
104
|
+
${' '.repeat(this.scopeLength + 3)}| ${error.message}
|
|
105
|
+
${' '.repeat(this.scopeLength + 3)}| ${error.description}
|
|
106
|
+
${' '.repeat(this.scopeLength + 3)}|-------------------------------
|
|
107
|
+
${' '.repeat(this.scopeLength + 3)}| ${error.stack?.split('\n').map((line, index) => index === 0 ? line : `${' '.repeat(this.scopeLength + 3)}| ${line}`).join('\n') || 'No stack trace'}
|
|
108
|
+
${' '.repeat(this.scopeLength + 3)}|-------------------------------
|
|
109
|
+
\x1b[0m`
|
|
110
|
+
+ (error.originalError ? `\x1b[31m${' '.repeat(this.scopeLength + 3)}| Wrapped From ${error.originalError.message}
|
|
111
|
+
${' '.repeat(this.scopeLength + 3)}|-------------------------------
|
|
112
|
+
${' '.repeat(this.scopeLength + 3)}| ${error.originalError.stack?.split('\n').map((line, index) => index === 0 ? line : `${' '.repeat(this.scopeLength + 3)}| ${line}`).join('\n') || 'No stack trace'}
|
|
113
|
+
${' '.repeat(this.scopeLength + 3)}|-------------------------------
|
|
114
|
+
\x1b[0m`: '')
|
|
115
|
+
+ (error.link ? `\x1b[31m${' '.repeat(this.scopeLength + 3)}| Read in docs: ${error.link}
|
|
116
|
+
${' '.repeat(this.scopeLength + 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.scopeLength + 3)}|-------------------------------` +
|
|
127
|
+
'\n' +
|
|
128
|
+
`${' '.repeat(this.scopeLength + 3)}| Error: | ${error.code}
|
|
129
|
+
${' '.repeat(this.scopeLength + 3)}|-------------------------------
|
|
130
|
+
${' '.repeat(this.scopeLength + 3)}|${' '.repeat(10)}| ${error.message}
|
|
131
|
+
${' '.repeat(this.scopeLength + 3)}|${' '.repeat(10)}| ${error.description}
|
|
132
|
+
${' '.repeat(this.scopeLength + 3)}|-------------------------------
|
|
133
|
+
${' '.repeat(this.scopeLength + 3)}| ${error.stack?.split('\n').map((line, index) => index === 0 ? line : `${' '.repeat(this.scopeLength + 3)}| ${line}`).join('\n') || 'No stack trace'}
|
|
134
|
+
${' '.repeat(this.scopeLength + 3)}|-------------------------------`
|
|
135
|
+
+
|
|
136
|
+
(error.originalError ? `${' '.repeat(this.scopeLength + 3)}| Wrapped From ${error.originalError.message}
|
|
137
|
+
${' '.repeat(this.scopeLength + 3)}|-------------------------------
|
|
138
|
+
${' '.repeat(this.scopeLength + 3)}| ${error.originalError.stack?.split('\n').map((line, index) => index === 0 ? line : `${' '.repeat(this.scopeLength + 3)}| ${line}`).join('\n') || 'No stack trace'}
|
|
139
|
+
${' '.repeat(this.scopeLength + 3)}|-------------------------------` : '')
|
|
140
|
+
+
|
|
141
|
+
(error.link ? `${' '.repeat(this.scopeLength + 3)}| Read in docs: ${error.link}
|
|
142
|
+
${' '.repeat(this.scopeLength + 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.scopeLength + 3)}| ${line}`)
|
|
153
|
+
.join('\n')
|
|
154
|
+
|
|
155
|
+
}, null, 2)
|
|
156
|
+
.replace(/\n/g, '\n' + `${' '.repeat(this.scopeLength + 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
|
+
}
|
|
File without changes
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { A_TYPES__ConceptLifecycle_MethodDeclarationConfig } from "../decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types";
|
|
1
|
+
// import { A_TYPES__ConceptLifecycle_MethodDeclarationConfig } from "../decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
export const A_CONSTANTS__DEFAULT_CONCEPT_LIFECYCLE_METHOD_DECLARATION_CONFIG: A_TYPES__ConceptLifecycle_MethodDeclarationConfig = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
5
|
+
// export const A_CONSTANTS__DEFAULT_CONCEPT_LIFECYCLE_METHOD_DECLARATION_CONFIG: A_TYPES__ConceptLifecycle_MethodDeclarationConfig = {
|
|
6
|
+
// name: '',
|
|
7
|
+
// behavior: 'sync',
|
|
8
|
+
// type: 'extension',
|
|
9
|
+
// after: [],
|
|
10
|
+
// before: [],
|
|
11
|
+
// override: []
|
|
12
|
+
// }
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
A_TYPES__A_FeatureDecoratorConfig,
|
|
3
|
+
A_TYPES__A_FeatureDecoratorDescriptor,
|
|
4
|
+
} from "./A-Feature.decorator.types";
|
|
5
|
+
import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
6
|
+
import { A_TYPES__ContainerMetaKey } from "@adaas/a-concept/global/A-Container/A-Container.types";
|
|
7
|
+
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A-Feature decorator
|
|
12
|
+
*
|
|
13
|
+
* This decorator allows to define a custom lifecycle stage for the Container.
|
|
14
|
+
* These stages are executed in a container-specific order and can be extended by components that are injected into the container.
|
|
15
|
+
* This approach allows to create a flexible and extendable architecture for the application.
|
|
16
|
+
*
|
|
17
|
+
* The main difference between the A-Feature and A-Feature decorators is that A-Feature methods can be inherited and overridden by child classes.
|
|
18
|
+
*
|
|
19
|
+
*
|
|
20
|
+
* @param params
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export function A_Feature_Define(
|
|
24
|
+
config: Partial<A_TYPES__A_FeatureDecoratorConfig> = {}
|
|
25
|
+
) {
|
|
26
|
+
return function (
|
|
27
|
+
target: A_Container<any>,
|
|
28
|
+
propertyKey: string,
|
|
29
|
+
descriptor: A_TYPES__A_FeatureDecoratorDescriptor
|
|
30
|
+
) {
|
|
31
|
+
|
|
32
|
+
// Get the existed metadata or create a new one
|
|
33
|
+
const existedMeta = A_Context
|
|
34
|
+
.meta(target)
|
|
35
|
+
.get(A_TYPES__ContainerMetaKey.FEATURES)
|
|
36
|
+
|| new Map();
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// Set the metadata of the method to define a custom Feature with name
|
|
41
|
+
existedMeta.set(propertyKey, {
|
|
42
|
+
handler: propertyKey,
|
|
43
|
+
config: {
|
|
44
|
+
...config,
|
|
45
|
+
name: `${target.constructor.name}.${propertyKey || config.name}`,
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Update the metadata of the container with the new Feature definition
|
|
50
|
+
A_Context
|
|
51
|
+
.meta(target)
|
|
52
|
+
.set(
|
|
53
|
+
A_TYPES__ContainerMetaKey.FEATURES,
|
|
54
|
+
existedMeta
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
}
|