@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,7 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A_TYPES__A_CONCEPT_RootRunParams, A_TYPES__IConceptConstructor } from "./A_Concept.types";
|
|
1
|
+
import { A_TYPES__ConceptStage, A_TYPES__ConceptStageParams, A_TYPES__IConceptConstructor } from "./A_Concept.types";
|
|
3
2
|
import { A_Context } from "../A-Context/A-Context.class";
|
|
4
|
-
import {
|
|
3
|
+
import { A_Container } from "../A-Container/A-Container.class";
|
|
4
|
+
import { A_Logger } from "@adaas/a-concept/base/A-Logger/A-Logger.component";
|
|
5
|
+
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
6
|
+
import { A_TYPES__ContainerMetaKey } from "../A-Container/A-Container.types";
|
|
7
|
+
import { A_Stage } from "@adaas/a-concept/decorators/A-Stage/A-Stage.decorator";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// export type RunParams<T> = T extends A_Container<any, infer Params> ? Params : never;
|
|
5
13
|
|
|
6
14
|
|
|
7
15
|
|
|
@@ -17,56 +25,95 @@ import { A_Errors } from "src/containers/A-Errors/A-Errors.namespace";
|
|
|
17
25
|
*
|
|
18
26
|
*
|
|
19
27
|
*/
|
|
20
|
-
export class A_Concept
|
|
21
|
-
|
|
28
|
+
export class A_Concept<
|
|
29
|
+
_Features extends A_Container<any>[] = any
|
|
30
|
+
> {
|
|
22
31
|
|
|
32
|
+
// ==============================================================================
|
|
33
|
+
// ==================== STATIC LIFECYCLE DECORATORS ===========================
|
|
34
|
+
// ==============================================================================
|
|
23
35
|
/**
|
|
24
|
-
*
|
|
36
|
+
* Load the concept. This step runs before any other steps to ensure that all components are loaded.
|
|
25
37
|
*/
|
|
26
|
-
|
|
38
|
+
static get Load() {
|
|
39
|
+
return A_Stage(A_TYPES__ConceptStage.Load);
|
|
40
|
+
}
|
|
27
41
|
|
|
28
42
|
/**
|
|
29
|
-
*
|
|
43
|
+
* Publish the concept to ADAAS platform. (Or any other place defined in the concept)
|
|
44
|
+
*
|
|
45
|
+
* [!] To extend the logic just create a custom containers and override the default behavior.
|
|
30
46
|
*/
|
|
47
|
+
static get Publish() {
|
|
48
|
+
return A_Stage(A_TYPES__ConceptStage.Publish);
|
|
49
|
+
}
|
|
31
50
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
this.props = props;
|
|
38
|
-
|
|
39
|
-
this.Context = A_Context;
|
|
51
|
+
/**
|
|
52
|
+
* Deploy the concept to the environment.
|
|
53
|
+
*/
|
|
54
|
+
static get Deploy() {
|
|
55
|
+
return A_Stage(A_TYPES__ConceptStage.Deploy);
|
|
40
56
|
}
|
|
41
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Compiles the Concept in case there are some containers that require that.
|
|
60
|
+
*
|
|
61
|
+
* Can be used for static websites or any other concept that requires a build step.
|
|
62
|
+
*
|
|
63
|
+
*/
|
|
64
|
+
static get Build() {
|
|
65
|
+
return A_Stage(A_TYPES__ConceptStage.Build);
|
|
66
|
+
}
|
|
42
67
|
|
|
43
|
-
|
|
44
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Main execution of the concept.
|
|
70
|
+
*/
|
|
71
|
+
static get Run() {
|
|
72
|
+
return A_Stage(A_TYPES__ConceptStage.Run);
|
|
45
73
|
}
|
|
46
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Start the concept. Uses for servers or any other background services.
|
|
77
|
+
*/
|
|
78
|
+
static get Start() {
|
|
79
|
+
return A_Stage(A_TYPES__ConceptStage.Start);
|
|
80
|
+
}
|
|
47
81
|
|
|
48
82
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* @param cl
|
|
52
|
-
* @returns
|
|
83
|
+
* Stop the concept. Uses for servers or any other background services.
|
|
53
84
|
*/
|
|
54
|
-
|
|
55
|
-
return
|
|
56
|
-
? false
|
|
57
|
-
: true
|
|
85
|
+
static get Stop() {
|
|
86
|
+
return A_Stage(A_TYPES__ConceptStage.Stop);
|
|
58
87
|
}
|
|
59
88
|
|
|
60
89
|
|
|
61
90
|
|
|
91
|
+
// ==============================================================================
|
|
92
|
+
// ========================== MAIN Class ======================================
|
|
93
|
+
// ==============================================================================
|
|
62
94
|
|
|
63
|
-
protected
|
|
64
|
-
// await this.Context.init();
|
|
95
|
+
protected containers: A_Container<any>[] = [];
|
|
65
96
|
|
|
66
|
-
|
|
97
|
+
constructor(
|
|
98
|
+
protected props: A_TYPES__IConceptConstructor<_Features>
|
|
99
|
+
) {
|
|
100
|
+
A_Context.allocate(this, {
|
|
101
|
+
name: props.name,
|
|
102
|
+
fragments: props.fragments || [],
|
|
103
|
+
// containers: props.containers
|
|
104
|
+
components: [
|
|
105
|
+
A_Logger,
|
|
106
|
+
]
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
this.containers = props.containers || [];
|
|
67
110
|
}
|
|
68
111
|
|
|
69
112
|
|
|
113
|
+
get namespace() {
|
|
114
|
+
return A_Context.scope(this).name;
|
|
115
|
+
}
|
|
116
|
+
|
|
70
117
|
|
|
71
118
|
// =======================================================================
|
|
72
119
|
// ========================== LIFECYCLE ================================
|
|
@@ -76,35 +123,18 @@ export class A_Concept {
|
|
|
76
123
|
* Run the concept.
|
|
77
124
|
*/
|
|
78
125
|
async run(
|
|
79
|
-
params
|
|
126
|
+
params?: Partial<A_TYPES__ConceptStageParams>
|
|
80
127
|
) {
|
|
81
128
|
|
|
82
|
-
// to prevent modification of the method parameters use the A_Context directly without decorators
|
|
83
|
-
const [
|
|
84
|
-
Errors
|
|
85
|
-
] = this.Context.resolve([A_Errors]);
|
|
86
|
-
|
|
87
|
-
if (this.hasInherited(A_Concept))
|
|
88
|
-
Errors.throw('[root.run] method can not be overridden in the inherited classes');
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// const allRunDeclarations = A_CONCEPT_LifecycleDeclarationsStorage
|
|
92
|
-
// .get(A_CONCEPT_STORAGE__DECORATORS_RUN_DECLARATIONS);
|
|
93
129
|
}
|
|
94
130
|
|
|
95
131
|
|
|
96
132
|
/**
|
|
97
133
|
* Build the concept.
|
|
98
134
|
*/
|
|
99
|
-
async build(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
Errors
|
|
103
|
-
] = this.Context.resolve([A_Errors]);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (this.hasInherited(A_Concept))
|
|
107
|
-
Errors.throw('[root.build] method can not be overridden in the inherited classes');
|
|
135
|
+
async build(
|
|
136
|
+
params?: Partial<A_TYPES__ConceptStageParams>
|
|
137
|
+
) {
|
|
108
138
|
|
|
109
139
|
}
|
|
110
140
|
|
|
@@ -112,32 +142,96 @@ export class A_Concept {
|
|
|
112
142
|
// /**
|
|
113
143
|
// * Deploy the concept.
|
|
114
144
|
// */
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
145
|
+
async deploy(
|
|
146
|
+
params?: Partial<A_TYPES__ConceptStageParams>
|
|
147
|
+
) {
|
|
148
|
+
|
|
149
|
+
}
|
|
119
150
|
|
|
120
151
|
|
|
121
152
|
// /**
|
|
122
153
|
// * Publish the concept.
|
|
123
154
|
// */
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
155
|
+
async publish(
|
|
156
|
+
params?: Partial<A_TYPES__ConceptStageParams>
|
|
157
|
+
) {
|
|
158
|
+
|
|
159
|
+
}
|
|
128
160
|
|
|
129
161
|
|
|
130
162
|
/**
|
|
131
163
|
* Call the specific method of the concept or included modules.
|
|
132
164
|
*/
|
|
133
|
-
async call
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
165
|
+
async call<
|
|
166
|
+
K extends Record<_Features[number]['name'], _Features[number]['exports'][number]>
|
|
167
|
+
>(
|
|
168
|
+
container: K[keyof K],
|
|
169
|
+
params?: A_Fragment[]
|
|
170
|
+
) {
|
|
171
|
+
// for (const feature of this.features) {
|
|
172
|
+
// if (methodName in feature) {
|
|
173
|
+
// (feature as any)[methodName](...args);
|
|
174
|
+
// }
|
|
138
175
|
|
|
139
|
-
//
|
|
140
|
-
// this.Context.Errors.throw('[root.call] method can not be overridden in the inherited classes');
|
|
176
|
+
// }
|
|
141
177
|
}
|
|
142
178
|
|
|
143
|
-
|
|
179
|
+
|
|
180
|
+
private async runStage(
|
|
181
|
+
method: A_TYPES__ConceptStage,
|
|
182
|
+
params: Partial<A_TYPES__ConceptStageParams>
|
|
183
|
+
) {
|
|
184
|
+
|
|
185
|
+
const stages: any[] = [];
|
|
186
|
+
|
|
187
|
+
this.containers.map(container => {
|
|
188
|
+
const meta = A_Context.meta(container);
|
|
189
|
+
|
|
190
|
+
const containerStages = meta.get(A_TYPES__ContainerMetaKey.STAGES)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
if (containerStages) {
|
|
194
|
+
for (const [name, stage] of containerStages) {
|
|
195
|
+
if (stage.name === method) {
|
|
196
|
+
stages.push({
|
|
197
|
+
name,
|
|
198
|
+
container,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const scope = A_Context.allocate(this, {
|
|
207
|
+
components: params.components,
|
|
208
|
+
fragments: params.fragments,
|
|
209
|
+
parent: A_Context.scope(this)
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
for (const stage of stages) {
|
|
213
|
+
await stage.container[stage.name](params);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
private async execute(
|
|
220
|
+
params: Partial<A_TYPES__ConceptStageParams>
|
|
221
|
+
) {
|
|
222
|
+
const fragments = params.fragments || [];
|
|
223
|
+
const component = params.components || [];
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
this.containers.map(container => {
|
|
227
|
+
const meta = A_Context.meta(container);
|
|
228
|
+
|
|
229
|
+
meta.get(A_TYPES__ContainerMetaKey.FEATURES)
|
|
230
|
+
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
|
|
@@ -1,32 +1,60 @@
|
|
|
1
|
-
import { A_Concept } from "./A_Concept.class";
|
|
2
|
-
import { A_Namespace } from "../A-Namespace/A_Namespace.class";
|
|
3
1
|
import { A_Container } from "../A-Container/A-Container.class";
|
|
2
|
+
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
4
3
|
|
|
5
4
|
|
|
6
|
-
export
|
|
5
|
+
export enum A_TYPES__ConceptStage {
|
|
6
|
+
Run = 'run',
|
|
7
|
+
Build = 'build',
|
|
8
|
+
Publish = 'publish',
|
|
9
|
+
Deploy = 'deploy',
|
|
10
|
+
Load = 'load',
|
|
11
|
+
Start = 'start',
|
|
12
|
+
Stop = 'stop',
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// export type A_TYPES__ConceptMeta = {
|
|
17
|
+
// [A_TYPES__ConceptMetaKey.EXTENSIONS]: Map<string, A_TYPES__ConceptMeta_ExtensionItem>,
|
|
18
|
+
// [A_TYPES__ConceptMetaKey.FEATURES]: any[],
|
|
19
|
+
// // [A_TYPES__ConceptMetaKey.INJECTIONS]: Map<
|
|
20
|
+
// // // Where key is method name
|
|
21
|
+
// // Symbol | string,
|
|
22
|
+
// // // And value is Injection instructions
|
|
23
|
+
// // A_TYPES__ConceptMeta_InjectionParams
|
|
24
|
+
// // >
|
|
25
|
+
|
|
26
|
+
// }
|
|
27
|
+
|
|
28
|
+
export enum A_TYPES__ConceptMetaKey {
|
|
29
|
+
LIFECYCLE = 'a-component-extensions',
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export interface A_TYPES__IConceptConstructor<
|
|
34
|
+
T extends Array<A_Container<any>>
|
|
35
|
+
> {
|
|
7
36
|
name: string,
|
|
8
|
-
description?: string,
|
|
9
37
|
|
|
10
38
|
/**
|
|
11
|
-
* A set of
|
|
12
|
-
* These
|
|
39
|
+
* A set of Context Fragments to register globally for the concept.
|
|
40
|
+
* These fragments will be available in the global context.
|
|
13
41
|
*
|
|
14
42
|
*/
|
|
15
|
-
|
|
43
|
+
fragments?: Array<A_Fragment>,
|
|
16
44
|
|
|
17
45
|
|
|
18
46
|
/**
|
|
19
47
|
* A set of Containers that the concept depends on.
|
|
20
48
|
* These containers will create a new Container for the concept.
|
|
21
49
|
*/
|
|
22
|
-
containers?:
|
|
50
|
+
containers?: T,
|
|
23
51
|
|
|
24
52
|
|
|
25
53
|
/**
|
|
26
54
|
* A set of external Concepts that can be used in the current Concept.
|
|
27
55
|
* To provide additional functionality or extend the current Concept.
|
|
28
56
|
*/
|
|
29
|
-
import?: Array<A_Concept>
|
|
57
|
+
// import?: Array<A_Concept>
|
|
30
58
|
}
|
|
31
59
|
|
|
32
60
|
|
|
@@ -38,7 +66,14 @@ export interface A_TYPES__IConceptConstructor {
|
|
|
38
66
|
// =======================================================================
|
|
39
67
|
// =======================================================================
|
|
40
68
|
|
|
41
|
-
export type
|
|
69
|
+
export type A_TYPES__ConceptStageParams = {
|
|
70
|
+
fragments: Array<A_Fragment>,
|
|
71
|
+
components: Array<{ new(...args: any[]): any }>
|
|
72
|
+
}
|
|
42
73
|
|
|
43
74
|
|
|
75
|
+
export type A_TYPES__ConceptCallParams<T extends string> = {
|
|
76
|
+
name: T,
|
|
77
|
+
fragments: Array<A_Fragment>,
|
|
78
|
+
components: Array<{ new(...args: any[]): any }>
|
|
44
79
|
}
|
|
@@ -1,39 +1,194 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A_TYPES__ContainerCallParams, A_TYPES__ContainerConstructor } from "./A-Container.types";
|
|
2
|
+
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
3
|
+
import { A_TYPES__Required } from "@adaas/a-utils";
|
|
4
|
+
import { A_Feature } from "../A-Feature/A-Feature.class";
|
|
5
|
+
import { A_CONTAINER_Storage, A_CONTAINER_STORAGE__Definition__Lifecycle } from "@adaas/a-concept/storage/A_Container.storage";
|
|
6
|
+
import { A_COMPONENT_Storage } from "@adaas/a-concept/storage/A_Component.storage";
|
|
7
|
+
import { A_TYPES__FeatureStep } from "../A-Feature/A-Feature.types";
|
|
8
|
+
import { A_Context } from "../A-Context/A-Context.class";
|
|
9
|
+
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
2
10
|
|
|
3
11
|
|
|
4
12
|
|
|
5
13
|
/**
|
|
6
|
-
* This class should combine Components to achieve the goal withing
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* -
|
|
11
|
-
* -
|
|
14
|
+
* This class should combine Components to achieve the goal withing Concept
|
|
15
|
+
*
|
|
16
|
+
* Container is a direct container that should be "run" to make Concept work.
|
|
17
|
+
* So because of that Container can be:
|
|
18
|
+
* - HTTP Server
|
|
19
|
+
* - BASH Script
|
|
20
|
+
* - Database Connection
|
|
21
|
+
* - Microservice
|
|
12
22
|
* - etc.
|
|
13
23
|
*/
|
|
14
|
-
export class A_Container<
|
|
24
|
+
export class A_Container<
|
|
25
|
+
_FeatureNames extends Array<string>
|
|
26
|
+
> {
|
|
27
|
+
// scope!: A_Scope
|
|
15
28
|
|
|
16
|
-
protected readonly
|
|
29
|
+
protected readonly config!: Partial<A_TYPES__ContainerConstructor<_FeatureNames>>;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Promise that will be resolved when the container is ready to be used.
|
|
33
|
+
*/
|
|
34
|
+
ready!: Promise<void>;
|
|
35
|
+
|
|
36
|
+
get exports(): _FeatureNames {
|
|
37
|
+
return this.config.exports || [] as any;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
get name() {
|
|
41
|
+
return this.config.name || this.constructor.name;
|
|
42
|
+
}
|
|
17
43
|
|
|
18
44
|
|
|
19
45
|
constructor(
|
|
20
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Configuration of the container that will be used to run it.
|
|
48
|
+
*/
|
|
49
|
+
config: Partial<A_TYPES__ContainerConstructor<_FeatureNames>>
|
|
21
50
|
) {
|
|
22
|
-
|
|
23
|
-
|
|
51
|
+
this.config = config;
|
|
52
|
+
|
|
53
|
+
const components = config.components || [];
|
|
54
|
+
const fragments = config.fragments || [];
|
|
55
|
+
|
|
56
|
+
A_Context.allocate(this, {
|
|
57
|
+
components,
|
|
58
|
+
fragments
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Run Async Initialization
|
|
63
|
+
*/
|
|
64
|
+
this.init();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
protected hasInherited(cl: { new(...args: any[]) }): boolean {
|
|
69
|
+
return this.constructor === cl
|
|
70
|
+
? false
|
|
71
|
+
: true
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Initializes the Namespace or can be used to reinitialize the Namespace
|
|
77
|
+
*/
|
|
78
|
+
private async init() {
|
|
79
|
+
if (!this.ready)
|
|
80
|
+
this.ready = new Promise(async (resolve, reject) => {
|
|
81
|
+
try {
|
|
82
|
+
await this.onBeforeInit();
|
|
83
|
+
|
|
84
|
+
await this.onInit();
|
|
85
|
+
|
|
86
|
+
await this.onAfterInit();
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
return resolve();
|
|
90
|
+
} catch (error) {
|
|
91
|
+
return reject(error);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
else
|
|
95
|
+
await this.ready;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* This method allows to call the lifecycle method of the container as well as any other Feature defined for it
|
|
104
|
+
*
|
|
105
|
+
* @param lifecycleMethod
|
|
106
|
+
* @param args
|
|
107
|
+
*/
|
|
108
|
+
call(
|
|
109
|
+
/**
|
|
110
|
+
* A-Feature method name to be called
|
|
111
|
+
*/
|
|
112
|
+
feature: _FeatureNames[number],
|
|
113
|
+
): A_Feature
|
|
114
|
+
call(
|
|
115
|
+
/**
|
|
116
|
+
* A-Feature name to be called
|
|
117
|
+
*/
|
|
118
|
+
params: A_TYPES__Required<Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>, ['name']>,
|
|
119
|
+
): A_Feature
|
|
120
|
+
|
|
121
|
+
call(
|
|
122
|
+
/**
|
|
123
|
+
* A-Feature method name to be called
|
|
124
|
+
*/
|
|
125
|
+
feature: _FeatureNames[number],
|
|
126
|
+
/**
|
|
127
|
+
* Parameters to provide additional data to the feature
|
|
128
|
+
*/
|
|
129
|
+
params: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>,
|
|
130
|
+
): A_Feature
|
|
131
|
+
|
|
132
|
+
call(
|
|
133
|
+
param1: _FeatureNames[number] | A_TYPES__Required<Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>, ['name']>,
|
|
134
|
+
param2?: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>
|
|
135
|
+
): A_Feature {
|
|
136
|
+
|
|
137
|
+
let feature: string;
|
|
138
|
+
let params: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>;
|
|
139
|
+
|
|
140
|
+
if (typeof param1 === 'string') {
|
|
141
|
+
feature = param1;
|
|
142
|
+
params = param2 || {};
|
|
143
|
+
} else {
|
|
144
|
+
feature = param1.name;
|
|
145
|
+
params = param1;
|
|
24
146
|
}
|
|
147
|
+
|
|
148
|
+
const meta = A_Context.meta(this);
|
|
149
|
+
|
|
150
|
+
const steps = meta.feature(this, feature);
|
|
151
|
+
|
|
152
|
+
const newFeature = new A_Feature({
|
|
153
|
+
name: `${this.constructor.name}.${feature}`,
|
|
154
|
+
fragments: param2?.fragments || [],
|
|
155
|
+
components: param2?.components || [],
|
|
156
|
+
steps,
|
|
157
|
+
parent: A_Context.scope(this)
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return newFeature;
|
|
25
161
|
}
|
|
26
162
|
|
|
27
163
|
|
|
28
|
-
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
164
|
+
|
|
165
|
+
// ==============================================================
|
|
166
|
+
// ======================= HOOKS ================================
|
|
167
|
+
// ==============================================================
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Before init hook to be used in inherited classes
|
|
171
|
+
*
|
|
172
|
+
* @returns
|
|
173
|
+
*/
|
|
174
|
+
protected async onBeforeInit() {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Main initialization method for the Container
|
|
180
|
+
*/
|
|
181
|
+
protected async onInit() {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* After init hook to be used in inherited classes
|
|
187
|
+
*
|
|
188
|
+
* @returns
|
|
189
|
+
*/
|
|
190
|
+
protected async onAfterInit() {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
38
193
|
|
|
39
194
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { A_TYPES__ComponentMetaKey } from "../A-Component/A-Component.types";
|
|
2
|
+
import { A_Context } from "../A-Context/A-Context.class";
|
|
3
|
+
import { A_TYPES__FeatureStep } from "../A-Feature/A-Feature.types";
|
|
4
|
+
import { A_Meta } from "../A-Meta/A-Meta.class";
|
|
5
|
+
import { A_Container } from "./A-Container.class";
|
|
6
|
+
import {
|
|
7
|
+
A_TYPES__ContainerMeta,
|
|
8
|
+
A_TYPES__ContainerMetaKey
|
|
9
|
+
} from "./A-Container.types";
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export class A_ContainerMeta extends A_Meta<A_TYPES__ContainerMeta> {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
feature<T extends string>(
|
|
17
|
+
container: A_Container<any>,
|
|
18
|
+
name: T,
|
|
19
|
+
// params:
|
|
20
|
+
) {
|
|
21
|
+
const scope = A_Context.scope(container);
|
|
22
|
+
|
|
23
|
+
// First lets validate that there'are registered method with the same name
|
|
24
|
+
const featureMeta = this.get(A_TYPES__ContainerMetaKey.FEATURES);
|
|
25
|
+
|
|
26
|
+
if (!featureMeta) {
|
|
27
|
+
throw new Error(`Container ${container.constructor.name} has no metadata defined`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const instruction = featureMeta.get(name);
|
|
31
|
+
|
|
32
|
+
if (!instruction)
|
|
33
|
+
throw new Error(`Method ${name} is not defined in ${this.constructor.name}`);
|
|
34
|
+
|
|
35
|
+
// const scope = new A_Scope({
|
|
36
|
+
// name: `${this.constructor.name}.${feature}`,
|
|
37
|
+
// fragments: param2?.fragments || [],
|
|
38
|
+
// components: param2?.components || []
|
|
39
|
+
// }, {
|
|
40
|
+
// parent: this.scope
|
|
41
|
+
// });
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// Now we need to resolve the method from all registered components
|
|
45
|
+
return scope
|
|
46
|
+
.components
|
|
47
|
+
.reduce((
|
|
48
|
+
acc, component
|
|
49
|
+
) => {
|
|
50
|
+
const componentMeta = A_Context.meta(component);
|
|
51
|
+
|
|
52
|
+
const extensions = componentMeta.get(A_TYPES__ComponentMetaKey.EXTENSIONS) || [];
|
|
53
|
+
const injections = componentMeta.get(A_TYPES__ComponentMetaKey.INJECTIONS);
|
|
54
|
+
|
|
55
|
+
const out: A_TYPES__FeatureStep[] = [];
|
|
56
|
+
|
|
57
|
+
extensions.forEach((extension, handler) => {
|
|
58
|
+
if (
|
|
59
|
+
extension.name === name
|
|
60
|
+
&&
|
|
61
|
+
(extension.container === container.constructor.name || extension.container === '*')
|
|
62
|
+
) {
|
|
63
|
+
const args = injections?.get(handler) || [];
|
|
64
|
+
|
|
65
|
+
out.push({
|
|
66
|
+
component,
|
|
67
|
+
handler,
|
|
68
|
+
args
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
return [
|
|
74
|
+
...acc,
|
|
75
|
+
...out
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
}, [] as A_TYPES__FeatureStep[])
|
|
79
|
+
}
|
|
80
|
+
}
|