@adaas/a-concept 0.0.3 → 0.0.5
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 +71 -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 +27 -19
- package/dist/index.js +58 -26
- 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 +16 -0
- package/dist/src/base/A-Config/A-Config.types.js +7 -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 +37 -54
- package/dist/src/global/A-Context/A-Context.class.js +129 -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.class.d.ts +0 -17
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js +47 -65
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js.map +1 -1
- 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 +57 -0
- package/dist/src/global/A-Entity/A-Entity.class.js +102 -0
- package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -0
- package/dist/src/global/A-Entity/A-Entity.types.d.ts +13 -0
- package/dist/src/global/A-Entity/A-Entity.types.js +4 -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 +16 -0
- package/dist/src/global/A-Meta/A-Meta.class.js +69 -0
- package/dist/src/global/A-Meta/A-Meta.class.js.map +1 -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 +135 -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 +47 -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 +53 -22
- package/jest.config.ts +1 -3
- 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 +15 -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 +64 -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 +172 -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 +233 -130
- package/src/global/A-Context/A-Context.types.ts +15 -0
- package/src/global/A-Dependency/A-DependencyReference.class.ts +61 -61
- package/src/global/A-Dependency/A-DependencyReference.types.ts +56 -56
- package/src/global/A-Entity/A-Entity.class.ts +141 -0
- package/src/global/A-Entity/A-Entity.types.ts +17 -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 +96 -0
- package/src/global/A-Meta/A-Meta.types.ts +0 -0
- package/src/global/A-Scope/A-Scope.class.ts +211 -0
- package/src/global/A-Scope/A-Scope.types.ts +37 -0
- package/tsconfig.json +1 -3
- 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/storage/A_Concept.storage.ts +0 -45
- /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-Meta/A-Meta.types.d.ts} +0 -0
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { A_Namespace } from "@adaas/a-concept/global/A-Namespace/A_Namespace.class"
|
|
1
|
+
// import { A_Namespace } from "@adaas/a-concept/global/A-Namespace/A_Namespace.class"
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
export type A_TYPES__A_DependencyReferenceConstructor = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
4
|
+
// export type A_TYPES__A_DependencyReferenceConstructor = {
|
|
5
|
+
// /**
|
|
6
|
+
// * The name of the dependency
|
|
7
|
+
// */
|
|
8
|
+
// name: string
|
|
9
|
+
// /**
|
|
10
|
+
// * The version of the module
|
|
11
|
+
// * By default it is 1.0.0
|
|
12
|
+
// */
|
|
13
|
+
// version: string
|
|
14
|
+
// /**
|
|
15
|
+
// * The dependencies of the module
|
|
16
|
+
// * Could be:
|
|
17
|
+
// * - other Modules
|
|
18
|
+
// * - other Contexts
|
|
19
|
+
// *
|
|
20
|
+
// */
|
|
21
|
+
// dependencies: Array<typeof A_Namespace>
|
|
22
|
+
// /**
|
|
23
|
+
// * The source of the dependency
|
|
24
|
+
// * Could be:
|
|
25
|
+
// * - a string representing the path to the module
|
|
26
|
+
// * - a module class (in case when config should be provided via the module constructor)
|
|
27
|
+
// * - a module class constructor
|
|
28
|
+
// * - a context class (in case when config should be provided via the context constructor)
|
|
29
|
+
// * - a context class constructor
|
|
30
|
+
// *
|
|
31
|
+
// */
|
|
32
|
+
// // source: A_Module | A_Context | typeof A_Module | typeof A_Context | string
|
|
33
|
+
// source: A_Namespace
|
|
34
|
+
// }
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
export type A_TYPES__A_DependencyReferenceConstructorConfig = {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
// export type A_TYPES__A_DependencyReferenceConstructorConfig = {
|
|
38
|
+
// /**
|
|
39
|
+
// * Sync - blocks A-Express Application initialization until module is ready
|
|
40
|
+
// * Async - allows to initialize module after A-Express Application initialization
|
|
41
|
+
// */
|
|
42
|
+
// behavior: 'async' | 'sync',
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
44
|
+
// /**
|
|
45
|
+
// * Allows to define a scheme of retries
|
|
46
|
+
// */
|
|
47
|
+
// retries: {
|
|
48
|
+
// /**
|
|
49
|
+
// * The number of retries
|
|
50
|
+
// * Default is 3
|
|
51
|
+
// */
|
|
52
|
+
// n: number,
|
|
53
|
+
// /**
|
|
54
|
+
// * The timeout between retries
|
|
55
|
+
// * Multiplied by the number of retries
|
|
56
|
+
// * So after each retry the timeout is increased e.g. 1000ms * 1, 1000ms * 2, 1000ms * 3
|
|
57
|
+
// * Default is 1000
|
|
58
|
+
// */
|
|
59
|
+
// timeout: number
|
|
60
|
+
// }
|
|
61
|
+
// }
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { A_Error, ASEID } from "@adaas/a-utils";
|
|
2
|
+
|
|
3
|
+
import { A_CONSTANTS__DEFAULT_ERRORS } from "@adaas/a-utils/dist/src/constants/errors.constants";
|
|
4
|
+
import { A_TYPES__Entity_JSON, A_TYPES__IEntity } from "./A-Entity.types";
|
|
5
|
+
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A_Entity is another abstraction that describes all major participants in the system business logic.
|
|
9
|
+
* Each Entity should have a clear definition and a clear set of responsibilities.
|
|
10
|
+
* However, entity may hide some of its responsibilities behind the interface to prevent overload.
|
|
11
|
+
*
|
|
12
|
+
* Each entity should be connected to the ContextFragment (Scope) and should be able to communicate with other entities.
|
|
13
|
+
*/
|
|
14
|
+
export class A_Entity<
|
|
15
|
+
_ConstructorType = any,
|
|
16
|
+
_SerializedType extends A_TYPES__Entity_JSON = A_TYPES__Entity_JSON,
|
|
17
|
+
>
|
|
18
|
+
extends A_Fragment
|
|
19
|
+
implements A_TYPES__IEntity {
|
|
20
|
+
|
|
21
|
+
aseid!: ASEID;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
aseid: string
|
|
26
|
+
)
|
|
27
|
+
constructor(
|
|
28
|
+
aseid: ASEID
|
|
29
|
+
)
|
|
30
|
+
constructor(
|
|
31
|
+
serialized: _SerializedType
|
|
32
|
+
)
|
|
33
|
+
constructor(
|
|
34
|
+
newEntity: _ConstructorType
|
|
35
|
+
)
|
|
36
|
+
constructor(props: string | ASEID | _SerializedType | _ConstructorType) {
|
|
37
|
+
super();
|
|
38
|
+
|
|
39
|
+
switch (true) {
|
|
40
|
+
case (typeof props === 'string' && ASEID.isASEID(props)):
|
|
41
|
+
this.aseid = new ASEID(props);
|
|
42
|
+
break;
|
|
43
|
+
case (props instanceof ASEID):
|
|
44
|
+
this.aseid = props;
|
|
45
|
+
break;
|
|
46
|
+
case (typeof props === 'object' && (props as any).aseid):
|
|
47
|
+
this.fromSerialized(props as _SerializedType);
|
|
48
|
+
break;
|
|
49
|
+
|
|
50
|
+
case (typeof props === 'object'):
|
|
51
|
+
this.fromNewEntity(props as _ConstructorType);
|
|
52
|
+
break
|
|
53
|
+
|
|
54
|
+
default:
|
|
55
|
+
throw new A_Error(A_CONSTANTS__DEFAULT_ERRORS.INCORRECT_A_ENTITY_CONSTRUCTOR);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ====================================================================
|
|
61
|
+
// ================== DUPLICATED ASEID Getters ========================
|
|
62
|
+
// ====================================================================
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Extracts the ID from the ASEID
|
|
66
|
+
* ID is the unique identifier of the entity
|
|
67
|
+
*/
|
|
68
|
+
get id(): string | number {
|
|
69
|
+
return this.aseid.id;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Extracts the namespace from the ASEID
|
|
74
|
+
* namespace is an application specific identifier from where the entity is coming from
|
|
75
|
+
*/
|
|
76
|
+
get namespace(): string {
|
|
77
|
+
return this.aseid.namespace
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Extracts the scope from the ASEID
|
|
82
|
+
* scope is the scope of the entity from Application Namespace
|
|
83
|
+
*/
|
|
84
|
+
get scope(): string {
|
|
85
|
+
return this.aseid.scope;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Extracts the entity from the ASEID
|
|
90
|
+
* entity is the name of the entity from Application Namespace
|
|
91
|
+
*/
|
|
92
|
+
get entity(): string {
|
|
93
|
+
return this.aseid.entity;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Extracts the version from the ASEID
|
|
98
|
+
* version is the version of the entity
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
get version(): string | undefined {
|
|
102
|
+
return this.aseid.version;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Extracts the shard from the ASEID
|
|
107
|
+
* shard is the shard of the entity
|
|
108
|
+
*/
|
|
109
|
+
get shard(): string | undefined {
|
|
110
|
+
return this.aseid.shard;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
protected fromNewEntity(newEntity: _ConstructorType): void {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
protected fromSerialized(serialized: _SerializedType): void {
|
|
119
|
+
this.aseid = new ASEID((serialized).aseid);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Converts the entity to a JSON object
|
|
126
|
+
*
|
|
127
|
+
*
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
toJSON(): _SerializedType {
|
|
131
|
+
return {
|
|
132
|
+
aseid: this.aseid.toString()
|
|
133
|
+
} as _SerializedType;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
toString(): string {
|
|
139
|
+
return this.aseid.toString();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ASEID } from "@adaas/a-utils";
|
|
2
|
+
|
|
3
|
+
export interface A_TYPES__IEntity {
|
|
4
|
+
/**
|
|
5
|
+
* The ASEID of the entity
|
|
6
|
+
*/
|
|
7
|
+
aseid: ASEID
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export type A_TYPES__Entity_JSON = {
|
|
12
|
+
/**
|
|
13
|
+
* The ASEID of the entity
|
|
14
|
+
*/
|
|
15
|
+
aseid: string
|
|
16
|
+
};
|
|
17
|
+
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { A_Feature_Define } from "@adaas/a-concept/decorators/A-Feature/A-Feature-Define.decorator";
|
|
2
|
+
import { A_Feature_Extend } from "@adaas/a-concept/decorators/A-Feature/A-Feature-Extend.decorator";
|
|
3
|
+
import { A_TYPES__FeatureConstructor, A_TYPES__FeatureState, A_TYPES__FeatureStep } from "./A-Feature.types";
|
|
4
|
+
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
5
|
+
import { A_Error, A_TYPES__Required } from "@adaas/a-utils";
|
|
6
|
+
import { A_Context } from "../A-Context/A-Context.class";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A_Feature is representing a feature that can be executed across multiple components
|
|
12
|
+
* This class stores the steps of the feature and executes them in order of appearance
|
|
13
|
+
*
|
|
14
|
+
* Using A_Feature.Define and A_Feature.Extend decorators to define and extend the feature methods
|
|
15
|
+
* across the different, distributed components
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export class A_Feature {
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Define a new A-Feature
|
|
23
|
+
*/
|
|
24
|
+
static get Define() {
|
|
25
|
+
return A_Feature_Define;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Extend an existing A-Feature
|
|
31
|
+
*/
|
|
32
|
+
static get Extend() {
|
|
33
|
+
return A_Feature_Extend;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
// protected scope: A_Scope
|
|
40
|
+
protected steps: A_TYPES__FeatureStep[] = []
|
|
41
|
+
|
|
42
|
+
state: A_TYPES__FeatureState = A_TYPES__FeatureState.INITIALIZED;
|
|
43
|
+
|
|
44
|
+
result?: any
|
|
45
|
+
error?: A_Error
|
|
46
|
+
|
|
47
|
+
constructor(
|
|
48
|
+
params: A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps']>
|
|
49
|
+
) {
|
|
50
|
+
// this.scope = params.scope;
|
|
51
|
+
this.steps = params.steps;
|
|
52
|
+
|
|
53
|
+
A_Context.allocate(this, params);
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* This method marks the feature as completed and returns the result
|
|
60
|
+
* Uses to interrupt or end the feature processing
|
|
61
|
+
*
|
|
62
|
+
* @param result
|
|
63
|
+
* @returns
|
|
64
|
+
*/
|
|
65
|
+
async completed<T extends any>(
|
|
66
|
+
...result: T[]
|
|
67
|
+
): Promise<T> {
|
|
68
|
+
|
|
69
|
+
this.result = result;
|
|
70
|
+
this.state = A_TYPES__FeatureState.COMPLETED;
|
|
71
|
+
|
|
72
|
+
return this.result;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* This method marks the feature as failed and throws an error
|
|
78
|
+
* Uses to interrupt or end the feature processing
|
|
79
|
+
*
|
|
80
|
+
* @param error
|
|
81
|
+
*/
|
|
82
|
+
async failed(
|
|
83
|
+
error: Error | A_Error | unknown
|
|
84
|
+
) {
|
|
85
|
+
this.error = error as A_Error;
|
|
86
|
+
this.state = A_TYPES__FeatureState.FAILED;
|
|
87
|
+
|
|
88
|
+
await this.errorHandler(error);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
async process() {
|
|
94
|
+
try {
|
|
95
|
+
this.state = A_TYPES__FeatureState.PROCESSING;
|
|
96
|
+
|
|
97
|
+
for (const { component, handler, args } of this.steps) {
|
|
98
|
+
|
|
99
|
+
if (
|
|
100
|
+
(this.state as any) === A_TYPES__FeatureState.FAILED
|
|
101
|
+
||
|
|
102
|
+
(this.state as any) === A_TYPES__FeatureState.COMPLETED
|
|
103
|
+
) {
|
|
104
|
+
throw new Error('FEATURE_PROCESSING_INTERRUPTED');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const instance = A_Context.scope(this).resolve(component);
|
|
108
|
+
|
|
109
|
+
if (instance[handler]) {
|
|
110
|
+
const callArgs = A_Context.scope(this).resolve(args);
|
|
111
|
+
await instance[handler](...callArgs);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
await this.completed();
|
|
116
|
+
|
|
117
|
+
} catch (error) {
|
|
118
|
+
console.log('Feature processing error:', error);
|
|
119
|
+
|
|
120
|
+
await this.failed(error);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
protected async errorHandler(error: Error | A_Error | unknown) {
|
|
126
|
+
switch (true) {
|
|
127
|
+
case error instanceof A_Error:
|
|
128
|
+
throw error;
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
case error instanceof Error
|
|
132
|
+
&& error.message === 'FEATURE_PROCESSING_INTERRUPTED'
|
|
133
|
+
&& this.state === A_TYPES__FeatureState.FAILED:
|
|
134
|
+
throw new A_Error({
|
|
135
|
+
message: 'FEATURE_PROCESSING_INTERRUPTED',
|
|
136
|
+
code: 'FEATURE_PROCESSING_INTERRUPTED',
|
|
137
|
+
data: {
|
|
138
|
+
feature: this
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
case error instanceof Error
|
|
144
|
+
&& error.message === 'FEATURE_PROCESSING_INTERRUPTED'
|
|
145
|
+
&& this.state === A_TYPES__FeatureState.COMPLETED:
|
|
146
|
+
|
|
147
|
+
// Do nothing
|
|
148
|
+
break;
|
|
149
|
+
|
|
150
|
+
default:
|
|
151
|
+
throw error;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { A_TYPES__ScopeConfig, A_TYPES__ScopeConstructor } from "../A-Scope/A-Scope.types"
|
|
2
|
+
|
|
3
|
+
export type A_TYPES__FeatureConstructor = {
|
|
4
|
+
steps: A_TYPES__FeatureStep[]
|
|
5
|
+
} & A_TYPES__ScopeConstructor & A_TYPES__ScopeConfig
|
|
6
|
+
|
|
7
|
+
export enum A_TYPES__FeatureState {
|
|
8
|
+
INITIALIZED = "INITIALIZED",
|
|
9
|
+
PROCESSING = "PROCESSING",
|
|
10
|
+
|
|
11
|
+
COMPLETED = "COMPLETED",
|
|
12
|
+
FAILED = "FAILED",
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export type A_TYPES__FeatureStep = {
|
|
17
|
+
component: { new(...args: any[]): any },
|
|
18
|
+
handler: string,
|
|
19
|
+
args: any[]
|
|
20
|
+
}
|
|
@@ -1,48 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
A_TYPES__NamespaceConstructor,
|
|
4
|
-
A_TYPES__INamespace,
|
|
5
|
-
} from './A_Namespace.types';
|
|
6
|
-
import { A_Context } from '../A-Context/A-Context.class';
|
|
1
|
+
import { A_Context } from "../A-Context/A-Context.class";
|
|
2
|
+
import { A_TYPES__FragmentConstructor } from "./A-Fragment.types";
|
|
7
3
|
|
|
8
4
|
|
|
9
5
|
/**
|
|
10
|
-
*
|
|
6
|
+
* A-Fragment = Context Fragments is a set of arguments that can be used to define a Context for the pipeline.
|
|
7
|
+
* In other words it is a dynamic context that will be created on pipeline start and destroyed on pipeline end.
|
|
8
|
+
* During the execution of the pipeline, the Context Fragments can be used to pass the data between the pipeline steps.
|
|
11
9
|
*
|
|
12
|
-
*
|
|
13
|
-
* It is used to share some data, configuration, dependencies, etc. between different parts of the application.
|
|
10
|
+
* Or to store the data that is required for the pipeline execution
|
|
14
11
|
*
|
|
15
|
-
* Namespace allow to :
|
|
16
|
-
* - share some data between different parts of the application,
|
|
17
|
-
* - share some configuration between different parts of the application,
|
|
18
|
-
* - share some dependencies between different parts of the application,
|
|
19
|
-
* - extend the capabilities of the application by adding new features or modifying existing ones into base classes
|
|
20
|
-
*
|
|
21
12
|
*/
|
|
22
|
-
export class
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
export class A_Fragment {
|
|
14
|
+
|
|
15
|
+
name: string;
|
|
25
16
|
|
|
26
|
-
/**
|
|
27
|
-
* Namespace namespace
|
|
28
|
-
*/
|
|
29
|
-
name!: string;
|
|
30
17
|
|
|
31
18
|
/**
|
|
32
|
-
*
|
|
19
|
+
* Indicates that Context Fragment is ready to use
|
|
33
20
|
*/
|
|
34
21
|
ready!: Promise<void>;
|
|
35
22
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
|
|
24
|
+
constructor(params: Partial<A_TYPES__FragmentConstructor> = {}) {
|
|
25
|
+
|
|
26
|
+
this.name = params.name || this.constructor.name;
|
|
27
|
+
|
|
39
28
|
/**
|
|
40
29
|
* Register the Namespace in the global Namespace provider
|
|
41
30
|
*/
|
|
42
31
|
this.name = A_Context
|
|
43
32
|
.register(
|
|
44
33
|
this,
|
|
45
|
-
|
|
34
|
+
this.name
|
|
46
35
|
);
|
|
47
36
|
|
|
48
37
|
/**
|
|
@@ -53,6 +42,7 @@ export class A_Namespace<
|
|
|
53
42
|
|
|
54
43
|
|
|
55
44
|
|
|
45
|
+
|
|
56
46
|
private hasInherited(cl: { new(...args: any[]) }): boolean {
|
|
57
47
|
return this.constructor === cl
|
|
58
48
|
? false
|
|
@@ -62,7 +52,7 @@ export class A_Namespace<
|
|
|
62
52
|
/**
|
|
63
53
|
* Initializes the Namespace or can be used to reinitialize the Namespace
|
|
64
54
|
*/
|
|
65
|
-
|
|
55
|
+
private async init() {
|
|
66
56
|
if (!this.ready)
|
|
67
57
|
this.ready = new Promise(async (resolve, reject) => {
|
|
68
58
|
try {
|
|
@@ -83,6 +73,10 @@ export class A_Namespace<
|
|
|
83
73
|
|
|
84
74
|
|
|
85
75
|
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
86
80
|
// ==============================================================
|
|
87
81
|
// ======================= HOOKS ================================
|
|
88
82
|
// ==============================================================
|
|
@@ -100,9 +94,8 @@ export class A_Namespace<
|
|
|
100
94
|
* Main initialization method for the SDK
|
|
101
95
|
*/
|
|
102
96
|
protected async onInit() {
|
|
103
|
-
|
|
104
97
|
// global logger configuration
|
|
105
|
-
if (A_Context.environment === 'server' && !this.hasInherited(
|
|
98
|
+
if (A_Context.environment === 'server' && !this.hasInherited(A_Fragment)) {
|
|
106
99
|
// eslint-disable-next-line no-use-before-define
|
|
107
100
|
// process.on('uncaughtException', (error) => {
|
|
108
101
|
// // log only in case of A_AUTH_Error
|
|
@@ -125,4 +118,5 @@ export class A_Namespace<
|
|
|
125
118
|
protected async onAfterInit() {
|
|
126
119
|
return;
|
|
127
120
|
}
|
|
121
|
+
|
|
128
122
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { A_TYPES__Dictionary } from "@adaas/a-utils";
|
|
2
|
+
import { A_Component } from "../A-Component/A-Component.class";
|
|
3
|
+
import { A_Container } from "../A-Container/A-Container.class";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A Meta is an entity that stores all the metadata for the specific entity like container, component, feature, etc.
|
|
9
|
+
*
|
|
10
|
+
* [!] Meta can be different depending on the type of input data
|
|
11
|
+
*/
|
|
12
|
+
export class A_Meta<
|
|
13
|
+
_StorageItems extends Record<string, any>
|
|
14
|
+
// _StorageItems extends Record<string, Map<string | Symbol, any> | Array<any> | A_TYPES__Dictionary<any>>
|
|
15
|
+
> {
|
|
16
|
+
|
|
17
|
+
protected meta: Map<keyof _StorageItems, _StorageItems[keyof _StorageItems]> = new Map();
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
from(
|
|
21
|
+
meta: A_Meta<_StorageItems>
|
|
22
|
+
): A_Meta<_StorageItems> {
|
|
23
|
+
this.meta = new Map(meta.meta);
|
|
24
|
+
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// ===================================================================================================
|
|
30
|
+
// ================================ META OPERATIONS ==================================================
|
|
31
|
+
// ===================================================================================================
|
|
32
|
+
|
|
33
|
+
// Method to set values in the map
|
|
34
|
+
set<K extends keyof _StorageItems>(key: K, value: _StorageItems[K]) {
|
|
35
|
+
|
|
36
|
+
const inheritedValue = this.meta.get(key)
|
|
37
|
+
|| Array.isArray(value)
|
|
38
|
+
? []
|
|
39
|
+
: (value as any) instanceof Map
|
|
40
|
+
? new Map()
|
|
41
|
+
: {};
|
|
42
|
+
const targetValue = this.meta.get(key)
|
|
43
|
+
|| Array.isArray(value)
|
|
44
|
+
? [
|
|
45
|
+
...inheritedValue as any
|
|
46
|
+
] : (value as any) instanceof Map
|
|
47
|
+
? new Map(inheritedValue as any)
|
|
48
|
+
: { ...inheritedValue };
|
|
49
|
+
|
|
50
|
+
this.meta.set(key, value);
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Method to get values from the map
|
|
55
|
+
get<K extends keyof _StorageItems>(key: K): _StorageItems[K] | undefined {
|
|
56
|
+
return this.meta.get(key) as _StorageItems[K];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// Delete a key-value pair by key
|
|
61
|
+
delete(key: keyof _StorageItems): boolean {
|
|
62
|
+
return this.meta.delete(key);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Search for keys by regex
|
|
66
|
+
findByRegex(regex: RegExp): Array<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> {
|
|
67
|
+
const results: Array<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> = [];
|
|
68
|
+
for (const [key, value] of this.meta.entries()) {
|
|
69
|
+
if (regex.test(String(key))) {
|
|
70
|
+
results.push([key, value]);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return results;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Check if a key exists
|
|
77
|
+
has(key: keyof _StorageItems): boolean {
|
|
78
|
+
return this.meta.has(key);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Get all entries in the map
|
|
82
|
+
entries(): IterableIterator<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> {
|
|
83
|
+
return this.meta.entries();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
// Clear all entries
|
|
88
|
+
clear(): void {
|
|
89
|
+
this.meta.clear();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
|
|
File without changes
|