@adaas/a-concept 0.0.63 → 0.1.1
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/index.d.ts +24 -32
- package/dist/index.js +35 -52
- package/dist/index.js.map +1 -1
- package/dist/src/constants/env.constants.d.ts +15 -8
- package/dist/src/constants/env.constants.js +17 -10
- package/dist/src/constants/env.constants.js.map +1 -1
- package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.d.ts +23 -0
- package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js +69 -0
- package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js.map +1 -0
- package/dist/src/global/A-Abstraction/A-Abstraction.class.d.ts +47 -20
- package/dist/src/global/A-Abstraction/A-Abstraction.class.js +55 -48
- package/dist/src/global/A-Abstraction/A-Abstraction.class.js.map +1 -1
- package/dist/src/global/A-Abstraction/A-Abstraction.error.d.ts +7 -0
- package/dist/src/global/A-Abstraction/A-Abstraction.error.js +12 -0
- package/dist/src/global/A-Abstraction/A-Abstraction.error.js.map +1 -0
- package/dist/src/global/A-Abstraction/A-Abstraction.types.d.ts +27 -12
- package/dist/src/global/A-Abstraction/A-Abstraction.types.js +0 -8
- package/dist/src/global/A-Abstraction/A-Abstraction.types.js.map +1 -1
- package/dist/src/global/A-Caller/A_Caller.class.d.ts +33 -0
- package/dist/src/global/A-Caller/A_Caller.class.js +44 -0
- package/dist/src/global/A-Caller/A_Caller.class.js.map +1 -0
- package/dist/src/global/A-Caller/A_Caller.error.d.ts +7 -0
- package/dist/src/global/A-Caller/A_Caller.error.js +12 -0
- package/dist/src/global/A-Caller/A_Caller.error.js.map +1 -0
- package/dist/src/global/A-Caller/A_Caller.types.d.ts +18 -0
- package/dist/src/{base/A-Errors/A-Errors.types.js → global/A-Caller/A_Caller.types.js} +1 -1
- package/dist/src/global/A-Caller/A_Caller.types.js.map +1 -0
- package/dist/src/global/A-Component/A-Component.class.d.ts +20 -3
- package/dist/src/global/A-Component/A-Component.class.js +35 -19
- package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.constants.d.ts +6 -0
- package/dist/src/global/A-Component/A-Component.constants.js +11 -0
- package/dist/src/global/A-Component/A-Component.constants.js.map +1 -0
- package/dist/src/global/A-Component/A-Component.meta.d.ts +4 -4
- package/dist/src/global/A-Component/A-Component.meta.js +6 -8
- package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.types.d.ts +40 -22
- package/dist/src/global/A-Component/A-Component.types.js +1 -8
- package/dist/src/global/A-Component/A-Component.types.js.map +1 -1
- package/dist/src/global/A-Concept/A-Concept.class.d.ts +153 -0
- package/dist/src/global/A-Concept/A-Concept.class.js +260 -0
- package/dist/src/global/A-Concept/A-Concept.class.js.map +1 -0
- package/dist/src/global/A-Concept/A-Concept.constants.d.ts +33 -0
- package/dist/src/global/A-Concept/A-Concept.constants.js +39 -0
- package/dist/src/global/A-Concept/A-Concept.constants.js.map +1 -0
- package/dist/src/global/A-Concept/{A_Concept.meta.js → A-Concept.meta.js} +1 -2
- package/dist/src/global/A-Concept/A-Concept.meta.js.map +1 -0
- package/dist/src/global/A-Concept/A-Concept.types.d.ts +83 -0
- package/dist/src/global/{A-Channel/A-Channel.types.js → A-Concept/A-Concept.types.js} +1 -1
- package/dist/src/global/A-Concept/A-Concept.types.js.map +1 -0
- package/dist/src/global/A-Container/A-Container.class.d.ts +31 -35
- package/dist/src/global/A-Container/A-Container.class.js +34 -55
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.constants.d.ts +5 -0
- package/dist/src/global/A-Container/A-Container.constants.js +10 -0
- package/dist/src/global/A-Container/A-Container.constants.js.map +1 -0
- package/dist/src/global/A-Container/A-Container.meta.d.ts +6 -6
- package/dist/src/global/A-Container/A-Container.meta.js +5 -6
- package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.types.d.ts +31 -25
- package/dist/src/global/A-Container/A-Container.types.js +1 -7
- package/dist/src/global/A-Container/A-Container.types.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.class.d.ts +302 -76
- package/dist/src/global/A-Context/A-Context.class.js +436 -244
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.error.d.ts +20 -0
- package/dist/src/global/A-Context/A-Context.error.js +25 -0
- package/dist/src/global/A-Context/A-Context.error.js.map +1 -0
- package/dist/src/global/A-Context/A-Context.types.d.ts +5 -0
- package/dist/src/global/A-Context/A-Context.types.js +1 -0
- package/dist/src/global/A-Entity/A-Entity.class.d.ts +18 -18
- package/dist/src/global/A-Entity/A-Entity.class.js +36 -43
- package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.constants.d.ts +11 -0
- package/dist/src/global/A-Entity/A-Entity.constants.js +17 -0
- package/dist/src/global/A-Entity/A-Entity.constants.js.map +1 -0
- package/dist/src/global/A-Entity/A-Entity.error.d.ts +7 -0
- package/dist/src/global/A-Entity/A-Entity.error.js +12 -0
- package/dist/src/global/A-Entity/A-Entity.error.js.map +1 -0
- package/dist/src/global/A-Entity/A-Entity.meta.d.ts +2 -2
- package/dist/src/global/A-Entity/A-Entity.meta.js +2 -2
- package/dist/src/global/A-Entity/A-Entity.meta.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.types.d.ts +24 -29
- package/dist/src/global/A-Entity/A-Entity.types.js +1 -13
- package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -1
- package/dist/src/global/A-Error/A_Error.class.d.ts +219 -0
- package/dist/src/global/A-Error/A_Error.class.js +267 -0
- package/dist/src/global/A-Error/A_Error.class.js.map +1 -0
- package/dist/src/global/A-Error/A_Error.constants.d.ts +5 -0
- package/dist/src/global/A-Error/A_Error.constants.js +9 -0
- package/dist/src/global/A-Error/A_Error.constants.js.map +1 -0
- package/dist/src/global/A-Error/A_Error.types.d.ts +89 -0
- package/dist/src/{decorators/A-Inject/A-Inject.decorator.types.js → global/A-Error/A_Error.types.js} +1 -1
- package/dist/src/global/A-Error/A_Error.types.js.map +1 -0
- package/dist/src/global/A-Feature/A-Feature-Define.decorator.d.ts +15 -0
- package/dist/src/{decorators → global}/A-Feature/A-Feature-Define.decorator.js +21 -27
- package/dist/src/global/A-Feature/A-Feature-Define.decorator.js.map +1 -0
- package/dist/src/{decorators → global}/A-Feature/A-Feature-Extend.decorator.d.ts +26 -3
- package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js +97 -0
- package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js.map +1 -0
- package/dist/src/global/A-Feature/A-Feature.class.d.ts +120 -30
- package/dist/src/global/A-Feature/A-Feature.class.js +205 -73
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.error.d.ts +25 -0
- package/dist/src/global/A-Feature/A-Feature.error.js +33 -0
- package/dist/src/global/A-Feature/A-Feature.error.js.map +1 -0
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +241 -18
- package/dist/src/global/A-Feature/A-Feature.types.js +16 -22
- package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
- package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +19 -27
- package/dist/src/global/A-Fragment/A-Fragment.class.js +21 -91
- package/dist/src/global/A-Fragment/A-Fragment.class.js.map +1 -1
- package/dist/src/global/A-Fragment/A-Fragment.types.d.ts +19 -1
- package/dist/src/global/A-Fragment/A-Fragment.types.js +3 -0
- package/dist/src/global/A-Fragment/A-Fragment.types.js.map +1 -1
- package/dist/src/global/A-Inject/A-Inject.decorator.d.ts +80 -0
- package/dist/src/global/A-Inject/A-Inject.decorator.js +49 -0
- package/dist/src/global/A-Inject/A-Inject.decorator.js.map +1 -0
- package/dist/src/global/A-Inject/A-Inject.error.d.ts +5 -0
- package/dist/src/global/A-Inject/A-Inject.error.js +10 -0
- package/dist/src/global/A-Inject/A-Inject.error.js.map +1 -0
- package/dist/src/global/A-Inject/A-Inject.types.d.ts +42 -0
- package/dist/src/{decorators/A-Entity/A-Entity.decorator.types.js → global/A-Inject/A-Inject.types.js} +1 -1
- package/dist/src/global/A-Inject/A-Inject.types.js.map +1 -0
- package/dist/src/global/A-Meta/A-Meta.class.d.ts +1 -1
- package/dist/src/global/A-Meta/A-Meta.types.d.ts +14 -0
- package/dist/src/global/A-Meta/A-Meta.types.js +1 -0
- package/dist/src/global/A-Scope/A-Scope.class.d.ts +406 -63
- package/dist/src/global/A-Scope/A-Scope.class.js +533 -287
- package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.error.d.ts +6 -0
- package/dist/src/global/A-Scope/A-Scope.error.js +11 -0
- package/dist/src/global/A-Scope/A-Scope.error.js.map +1 -0
- package/dist/src/global/A-Scope/A-Scope.types.d.ts +50 -13
- package/dist/src/global/A-Stage/A-Stage.class.d.ts +31 -23
- package/dist/src/global/A-Stage/A-Stage.class.js +100 -68
- package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -1
- package/dist/src/global/A-Stage/A-Stage.error.d.ts +2 -1
- package/dist/src/global/A-Stage/A-Stage.error.js +5 -2
- package/dist/src/global/A-Stage/A-Stage.error.js.map +1 -1
- package/dist/src/global/A-Stage/A-Stage.types.d.ts +4 -16
- package/dist/src/global/A-Stage/A-Stage.types.js +0 -16
- package/dist/src/global/A-Stage/A-Stage.types.js.map +1 -1
- package/dist/src/global/ASEID/ASEID.class.d.ts +130 -0
- package/dist/src/global/ASEID/ASEID.class.js +167 -0
- package/dist/src/global/ASEID/ASEID.class.js.map +1 -0
- package/dist/src/global/ASEID/ASEID.constants.js +2 -0
- package/dist/src/global/ASEID/ASEID.constants.js.map +1 -0
- package/dist/src/global/ASEID/ASEID.error.d.ts +5 -0
- package/dist/src/global/ASEID/ASEID.error.js +10 -0
- package/dist/src/global/ASEID/ASEID.error.js.map +1 -0
- package/dist/src/global/ASEID/ASEID.types.d.ts +65 -0
- package/dist/src/global/ASEID/ASEID.types.js +5 -0
- package/dist/src/global/ASEID/ASEID.types.js.map +1 -0
- package/dist/src/helpers/A_Common.helper.d.ts +28 -0
- package/dist/src/helpers/A_Common.helper.js +170 -0
- package/dist/src/helpers/A_Common.helper.js.map +1 -0
- package/dist/src/helpers/A_Formatter.helper.d.ts +35 -0
- package/dist/src/helpers/A_Formatter.helper.js +62 -0
- package/dist/src/helpers/A_Formatter.helper.js.map +1 -0
- package/dist/src/helpers/A_Identity.helper.d.ts +29 -0
- package/dist/src/helpers/A_Identity.helper.js +43 -0
- package/dist/src/helpers/A_Identity.helper.js.map +1 -0
- package/dist/src/helpers/{StepsManager.class.d.ts → A_StepsManager.class.d.ts} +4 -2
- package/dist/src/helpers/{StepsManager.class.js → A_StepsManager.class.js} +10 -5
- package/dist/src/helpers/A_StepsManager.class.js.map +1 -0
- package/dist/src/helpers/A_TypeGuards.helper.d.ts +205 -0
- package/dist/src/helpers/A_TypeGuards.helper.js +288 -0
- package/dist/src/helpers/A_TypeGuards.helper.js.map +1 -0
- package/dist/src/types/A_Common.types.d.ts +36 -0
- package/dist/src/types/A_Common.types.js +3 -0
- package/dist/src/types/A_Common.types.js.map +1 -0
- package/index.ts +27 -51
- package/jest.config.ts +1 -0
- package/package.json +1 -2
- package/src/constants/env.constants.ts +18 -11
- package/src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts +103 -0
- package/src/global/A-Abstraction/A-Abstraction.class.ts +71 -65
- package/src/global/A-Abstraction/A-Abstraction.error.ts +9 -0
- package/src/global/A-Abstraction/A-Abstraction.types.ts +52 -13
- package/src/global/A-Caller/A_Caller.class.ts +61 -0
- package/src/global/A-Caller/A_Caller.error.ts +10 -0
- package/src/global/A-Caller/A_Caller.types.ts +25 -0
- package/src/global/A-Component/A-Component.class.ts +26 -15
- package/src/global/A-Component/A-Component.constants.ts +9 -0
- package/src/global/A-Component/A-Component.meta.ts +6 -16
- package/src/global/A-Component/A-Component.types.ts +53 -28
- package/src/global/A-Concept/A-Concept.class.ts +316 -0
- package/src/global/A-Concept/A-Concept.constants.ts +36 -0
- package/src/global/A-Concept/A-Concept.meta.ts +17 -0
- package/src/global/A-Concept/A-Concept.types.ts +100 -0
- package/src/global/A-Container/A-Container.class.ts +42 -83
- package/src/global/A-Container/A-Container.constants.ts +5 -0
- package/src/global/A-Container/A-Container.meta.ts +7 -11
- package/src/global/A-Container/A-Container.types.ts +38 -34
- package/src/global/A-Context/A-Context.class.ts +648 -412
- package/src/global/A-Context/A-Context.error.ts +44 -0
- package/src/global/A-Context/A-Context.types.ts +14 -0
- package/src/global/A-Entity/A-Entity.class.ts +39 -52
- package/src/global/A-Entity/A-Entity.constants.ts +12 -0
- package/src/global/A-Entity/A-Entity.error.ts +12 -0
- package/src/global/A-Entity/A-Entity.meta.ts +4 -4
- package/src/global/A-Entity/A-Entity.types.ts +31 -36
- package/src/global/A-Error/A_Error.class.ts +408 -0
- package/src/global/A-Error/A_Error.constants.ts +11 -0
- package/src/global/A-Error/A_Error.types.ts +96 -0
- package/src/{decorators → global}/A-Feature/A-Feature-Define.decorator.ts +31 -37
- package/src/global/A-Feature/A-Feature-Extend.decorator.ts +187 -0
- package/src/global/A-Feature/A-Feature.class.ts +279 -122
- package/src/global/A-Feature/A-Feature.error.ts +33 -0
- package/src/global/A-Feature/A-Feature.types.ts +278 -40
- package/src/global/A-Fragment/A-Fragment.class.ts +29 -100
- package/src/global/A-Fragment/A-Fragment.types.ts +25 -3
- package/src/global/A-Inject/A-Inject.decorator.ts +167 -0
- package/src/global/A-Inject/A-Inject.error.ts +8 -0
- package/src/global/A-Inject/A-Inject.types.ts +75 -0
- package/src/global/A-Meta/A-Meta.class.ts +1 -1
- package/src/global/A-Meta/A-Meta.types.ts +21 -0
- package/src/global/A-Scope/A-Scope.class.ts +841 -443
- package/src/global/A-Scope/A-Scope.error.ts +13 -0
- package/src/global/A-Scope/A-Scope.types.ts +65 -26
- package/src/global/A-Stage/A-Stage.class.ts +142 -80
- package/src/global/A-Stage/A-Stage.error.ts +4 -2
- package/src/global/A-Stage/A-Stage.types.ts +4 -25
- package/src/global/ASEID/ASEID.class.ts +275 -0
- package/src/global/ASEID/ASEID.error.ts +12 -0
- package/src/global/ASEID/ASEID.types.ts +79 -0
- package/src/helpers/A_Common.helper.ts +204 -0
- package/src/helpers/A_Formatter.helper.ts +58 -0
- package/src/helpers/A_Identity.helper.ts +53 -0
- package/src/helpers/{StepsManager.class.ts → A_StepsManager.class.ts} +19 -3
- package/src/helpers/A_TypeGuards.helper.ts +318 -0
- package/src/types/A_Common.types.ts +79 -0
- package/tests/A-Common.test.ts +117 -0
- package/tests/A-Component.test.ts +11 -6
- package/tests/A-Concept.test.ts +19 -22
- package/tests/A-Entity.test.ts +24 -24
- package/tests/A-Error.test.ts +129 -0
- package/tests/A-Feature.test.ts +34 -25
- package/tests/A-Scope.test.ts +50 -22
- package/tests/ASEID.test.ts +74 -0
- package/tsconfig.build.json +2 -1
- package/tsconfig.json +3 -2
- package/dist/src/base/A-Config/A-Config.container.d.ts +0 -9
- package/dist/src/base/A-Config/A-Config.container.js +0 -69
- package/dist/src/base/A-Config/A-Config.container.js.map +0 -1
- package/dist/src/base/A-Config/A-Config.context.d.ts +0 -30
- package/dist/src/base/A-Config/A-Config.context.js +0 -60
- package/dist/src/base/A-Config/A-Config.context.js.map +0 -1
- package/dist/src/base/A-Config/A-Config.types.d.ts +0 -20
- package/dist/src/base/A-Config/A-Config.types.js +0 -7
- package/dist/src/base/A-Config/A-Config.types.js.map +0 -1
- package/dist/src/base/A-Config/components/ConfigReader.component.d.ts +0 -29
- package/dist/src/base/A-Config/components/ConfigReader.component.js +0 -84
- package/dist/src/base/A-Config/components/ConfigReader.component.js.map +0 -1
- package/dist/src/base/A-Config/components/ENVConfigReader.component.d.ts +0 -10
- package/dist/src/base/A-Config/components/ENVConfigReader.component.js +0 -37
- package/dist/src/base/A-Config/components/ENVConfigReader.component.js.map +0 -1
- package/dist/src/base/A-Config/components/FileConfigReader.component.d.ts +0 -11
- package/dist/src/base/A-Config/components/FileConfigReader.component.js +0 -48
- package/dist/src/base/A-Config/components/FileConfigReader.component.js.map +0 -1
- package/dist/src/base/A-Errors/A-Error.entity.d.ts +0 -3
- package/dist/src/base/A-Errors/A-Error.entity.js +0 -8
- package/dist/src/base/A-Errors/A-Error.entity.js.map +0 -1
- package/dist/src/base/A-Errors/A-Errors.component.d.ts +0 -19
- package/dist/src/base/A-Errors/A-Errors.component.js +0 -87
- package/dist/src/base/A-Errors/A-Errors.component.js.map +0 -1
- package/dist/src/base/A-Errors/A-Errors.context.d.ts +0 -27
- package/dist/src/base/A-Errors/A-Errors.context.js +0 -50
- package/dist/src/base/A-Errors/A-Errors.context.js.map +0 -1
- package/dist/src/base/A-Errors/A-Errors.types.d.ts +0 -5
- package/dist/src/base/A-Errors/A-Errors.types.js.map +0 -1
- package/dist/src/base/A-Logger/A-Logger.component.d.ts +0 -31
- package/dist/src/base/A-Logger/A-Logger.component.js +0 -155
- package/dist/src/base/A-Logger/A-Logger.component.js.map +0 -1
- package/dist/src/base/A-Logger/A-Logger.types.js +0 -2
- package/dist/src/base/A-Logger/A-Logger.types.js.map +0 -1
- package/dist/src/base/A-Polyfill/A-Polyfill.component.d.ts +0 -5
- package/dist/src/base/A-Polyfill/A-Polyfill.component.js +0 -34
- package/dist/src/base/A-Polyfill/A-Polyfill.component.js.map +0 -1
- package/dist/src/decorators/A-Abstraction/A-Abstraction-Extend.decorator.d.ts +0 -14
- package/dist/src/decorators/A-Abstraction/A-Abstraction-Extend.decorator.js +0 -53
- package/dist/src/decorators/A-Abstraction/A-Abstraction-Extend.decorator.js.map +0 -1
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.d.ts +0 -2
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js +0 -3
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js.map +0 -1
- package/dist/src/decorators/A-Connect/A-Connect.decorator.d.ts +0 -19
- package/dist/src/decorators/A-Connect/A-Connect.decorator.js +0 -31
- package/dist/src/decorators/A-Connect/A-Connect.decorator.js.map +0 -1
- package/dist/src/decorators/A-Connect/A-Connect.decorator.types.d.ts +0 -1
- package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js +0 -3
- package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js.map +0 -1
- package/dist/src/decorators/A-Entity/A-Entity-List.decorator.d.ts +0 -1
- package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js +0 -8
- package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js.map +0 -1
- package/dist/src/decorators/A-Entity/A-Entity.decorator.types.d.ts +0 -14
- package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js.map +0 -1
- package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.d.ts +0 -19
- package/dist/src/decorators/A-Feature/A-Feature-Define.decorator.js.map +0 -1
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js +0 -81
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +0 -1
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +0 -96
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.js +0 -3
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.js.map +0 -1
- package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +0 -30
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js +0 -47
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +0 -1
- package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +0 -48
- package/dist/src/decorators/A-Inject/A-Inject.decorator.types.js.map +0 -1
- package/dist/src/global/A-Channel/A-Channel.class.d.ts +0 -16
- package/dist/src/global/A-Channel/A-Channel.class.js +0 -59
- package/dist/src/global/A-Channel/A-Channel.class.js.map +0 -1
- package/dist/src/global/A-Channel/A-Channel.types.d.ts +0 -68
- package/dist/src/global/A-Channel/A-Channel.types.js.map +0 -1
- package/dist/src/global/A-Command/A-Command.class.d.ts +0 -187
- package/dist/src/global/A-Command/A-Command.class.js +0 -349
- package/dist/src/global/A-Command/A-Command.class.js.map +0 -1
- package/dist/src/global/A-Command/A-Command.constants.d.ts +0 -17
- package/dist/src/global/A-Command/A-Command.constants.js +0 -22
- package/dist/src/global/A-Command/A-Command.constants.js.map +0 -1
- package/dist/src/global/A-Command/A-Command.meta.d.ts +0 -11
- package/dist/src/global/A-Command/A-Command.meta.js +0 -18
- package/dist/src/global/A-Command/A-Command.meta.js.map +0 -1
- package/dist/src/global/A-Command/A-Command.types.d.ts +0 -43
- package/dist/src/global/A-Command/A-Command.types.js +0 -10
- package/dist/src/global/A-Command/A-Command.types.js.map +0 -1
- package/dist/src/global/A-Command/context/A_Command.context.d.ts +0 -64
- package/dist/src/global/A-Command/context/A_Command.context.js +0 -85
- package/dist/src/global/A-Command/context/A_Command.context.js.map +0 -1
- package/dist/src/global/A-Concept/A_Concept.class.d.ts +0 -104
- package/dist/src/global/A-Concept/A_Concept.class.js +0 -217
- package/dist/src/global/A-Concept/A_Concept.class.js.map +0 -1
- package/dist/src/global/A-Concept/A_Concept.meta.js.map +0 -1
- package/dist/src/global/A-Concept/A_Concept.types.d.ts +0 -103
- package/dist/src/global/A-Concept/A_Concept.types.js +0 -28
- package/dist/src/global/A-Concept/A_Concept.types.js.map +0 -1
- package/dist/src/global/A-Feature/A-FeatureCaller.class.d.ts +0 -22
- package/dist/src/global/A-Feature/A-FeatureCaller.class.js +0 -26
- package/dist/src/global/A-Feature/A-FeatureCaller.class.js.map +0 -1
- package/dist/src/helpers/StepsManager.class.js.map +0 -1
- package/dist/src/types/A_Module.types.d.ts +0 -17
- package/dist/src/types/A_Module.types.js +0 -22
- package/dist/src/types/A_Module.types.js.map +0 -1
- package/examples/entity/concept.ts +0 -68
- package/examples/entity/entities/Task.entity.ts +0 -110
- package/examples/entity/entities/User.entity.ts +0 -62
- package/examples/fe-be/channels/Test.channel.ts +0 -27
- package/examples/fe-be/components/BE-Controller.component.ts +0 -20
- package/examples/fe-be/components/FE.component.ts +0 -13
- package/examples/fe-be/containers/ServerApp.container.ts +0 -8
- package/examples/fe-be/containers/WebApp.container.ts +0 -13
- package/examples/multi-container/channels/Direct.channel.ts +0 -39
- package/examples/multi-container/concept.ts +0 -0
- package/examples/multi-container/containers/Command.container.ts +0 -41
- package/examples/multi-container/containers/Schedule.container.ts +0 -52
- package/examples/simple/components/A.component.ts +0 -71
- package/examples/simple/components/B.component.ts +0 -68
- package/examples/simple/concept.ts +0 -87
- package/examples/simple/containers/Main.container.ts +0 -88
- package/examples/simple/containers/Secondary.container.ts +0 -26
- package/examples/simple/context/Fragment_A.context.ts +0 -25
- package/examples/simple/context/Fragment_B.context.ts +0 -19
- package/examples/simple/entities/EntityA.entity.ts +0 -32
- package/examples/simple-http-server/components/http-error-handler.component.ts +0 -47
- package/examples/simple-http-server/components/http-request-handler.component.ts +0 -13
- package/examples/simple-http-server/concept.ts +0 -35
- package/examples/simple-http-server/containers/http-server.container.ts +0 -57
- package/examples/simple-http-server/contexts/http-request.context.ts +0 -59
- package/examples/simple-http-server/contexts/http-server.context.types.ts +0 -0
- package/examples/simple-http-server/controllers/orders.controller.ts +0 -20
- package/examples/simple-http-server/controllers/users.controller.ts +0 -104
- package/examples/simple-http-server/test.ts +0 -290
- package/src/base/A-Config/A-Config.container.ts +0 -68
- package/src/base/A-Config/A-Config.context.ts +0 -114
- package/src/base/A-Config/A-Config.types.ts +0 -28
- package/src/base/A-Config/components/ConfigReader.component.ts +0 -68
- package/src/base/A-Config/components/ENVConfigReader.component.ts +0 -31
- package/src/base/A-Config/components/FileConfigReader.component.ts +0 -41
- package/src/base/A-Errors/A-Error.entity.ts +0 -10
- package/src/base/A-Errors/A-Errors.component.ts +0 -103
- package/src/base/A-Errors/A-Errors.context.ts +0 -90
- package/src/base/A-Errors/A-Errors.types.ts +0 -6
- package/src/base/A-Logger/A-Logger.component.ts +0 -192
- package/src/base/A-Logger/A-Logger.types.ts +0 -0
- package/src/base/A-Polyfill/A-Polyfill.component.ts +0 -18
- package/src/decorators/A-Abstraction/A-Abstraction-Extend.decorator.ts +0 -81
- package/src/decorators/A-Abstraction/A-Abstraction.decorator.types.ts +0 -21
- package/src/decorators/A-Connect/A-Connect.decorator.ts +0 -71
- package/src/decorators/A-Connect/A-Connect.decorator.types.ts +0 -6
- package/src/decorators/A-Entity/A-Entity-List.decorator.ts +0 -12
- package/src/decorators/A-Entity/A-Entity.decorator.types.ts +0 -18
- package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +0 -151
- package/src/decorators/A-Feature/A-Feature.decorator.types.ts +0 -142
- package/src/decorators/A-Inject/A-Inject.decorator.ts +0 -119
- package/src/decorators/A-Inject/A-Inject.decorator.types.ts +0 -85
- package/src/global/A-Channel/A-Channel.class.ts +0 -111
- package/src/global/A-Channel/A-Channel.types.ts +0 -114
- package/src/global/A-Command/A-Command.class.ts +0 -419
- package/src/global/A-Command/A-Command.constants.ts +0 -27
- package/src/global/A-Command/A-Command.meta.ts +0 -22
- package/src/global/A-Command/A-Command.types.ts +0 -73
- package/src/global/A-Command/context/A_Command.context.ts +0 -114
- package/src/global/A-Concept/A_Concept.class.ts +0 -298
- package/src/global/A-Concept/A_Concept.meta.ts +0 -32
- package/src/global/A-Concept/A_Concept.types.ts +0 -143
- package/src/global/A-Feature/A-FeatureCaller.class.ts +0 -38
- package/src/types/A_Module.types.ts +0 -23
- package/tests/A-Command.test.ts +0 -133
- package/tests/A-Config.test.ts +0 -172
- /package/dist/src/global/A-Concept/{A_Concept.meta.d.ts → A-Concept.meta.d.ts} +0 -0
- /package/dist/src/{base/A-Logger/A-Logger.types.d.ts → global/ASEID/ASEID.constants.d.ts} +0 -0
- /package/{examples/fe-be/concept.ts → src/global/ASEID/ASEID.constants.ts} +0 -0
|
@@ -1,177 +1,256 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.A_Scope = void 0;
|
|
4
|
-
const a_utils_1 = require("@adaas/a-utils");
|
|
5
4
|
const A_Fragment_class_1 = require("../A-Fragment/A-Fragment.class");
|
|
6
5
|
const A_Context_class_1 = require("../A-Context/A-Context.class");
|
|
7
|
-
const A_Component_types_1 = require("../A-Component/A-Component.types");
|
|
8
6
|
const A_Component_class_1 = require("../A-Component/A-Component.class");
|
|
9
7
|
const A_Entity_class_1 = require("../A-Entity/A-Entity.class");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
* - Context Fragments
|
|
18
|
-
* - and objects in different parts of your code.
|
|
19
|
-
* Scope determines where a particular piece of data (like a variable or function)
|
|
20
|
-
* can be accessed, modified, or referenced, and it plays a crucial role in avoiding naming collisions and ensuring data integrity.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
8
|
+
const A_TypeGuards_helper_1 = require("../../helpers/A_TypeGuards.helper");
|
|
9
|
+
const A_Error_class_1 = require("../A-Error/A_Error.class");
|
|
10
|
+
const A_Formatter_helper_1 = require("../../helpers/A_Formatter.helper");
|
|
11
|
+
const ASEID_class_1 = require("../ASEID/ASEID.class");
|
|
12
|
+
const A_Common_helper_1 = require("../../helpers/A_Common.helper");
|
|
13
|
+
const A_Scope_error_1 = require("./A-Scope.error");
|
|
14
|
+
const A_Component_constants_1 = require("../A-Component/A-Component.constants");
|
|
24
15
|
class A_Scope {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
get
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
16
|
+
// ===========================================================================
|
|
17
|
+
// --------------------Readonly Allowed Properties----------------------------
|
|
18
|
+
// ===========================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Returns the name of the scope
|
|
21
|
+
*/
|
|
22
|
+
get name() { return this._name; }
|
|
23
|
+
/**
|
|
24
|
+
* Returns a list of Constructors for A-Components that are available in the scope
|
|
25
|
+
*/
|
|
26
|
+
get allowedComponents() { return this._allowedComponents; }
|
|
27
|
+
/**
|
|
28
|
+
* Returns a list of Constructors for A-Entities that are available in the scope
|
|
29
|
+
*/
|
|
30
|
+
get allowedEntities() { return this._allowedEntities; }
|
|
31
|
+
/**
|
|
32
|
+
* Returns a list of Constructors for A-Fragments that are available in the scope
|
|
33
|
+
*/
|
|
34
|
+
get allowedFragments() { return this._allowedFragments; }
|
|
35
|
+
/**
|
|
36
|
+
* Returns a list of Constructors for A-Errors that are available in the scope
|
|
37
|
+
*/
|
|
38
|
+
get allowedErrors() { return this._allowedErrors; }
|
|
39
|
+
// ===========================================================================
|
|
40
|
+
// --------------------Readonly Registered Properties--------------------------
|
|
41
|
+
// ===========================================================================
|
|
42
|
+
/**
|
|
43
|
+
* Returns an Array of entities registered in the scope
|
|
44
|
+
*
|
|
45
|
+
* [!] One entity per aseid
|
|
46
|
+
*/
|
|
47
|
+
get entities() { return Array.from(this._entities.values()); }
|
|
48
|
+
/**
|
|
49
|
+
* Returns an Array of fragments registered in the scope
|
|
50
|
+
*
|
|
51
|
+
* [!] One fragment per scope
|
|
52
|
+
*/
|
|
53
|
+
get fragments() { return Array.from(this._fragments.values()); }
|
|
54
|
+
/**
|
|
55
|
+
* Returns an Array of components registered in the scope
|
|
56
|
+
*
|
|
57
|
+
* [!] One component instance per scope
|
|
58
|
+
*/
|
|
59
|
+
get components() { return Array.from(this._components.values()); }
|
|
60
|
+
/**
|
|
61
|
+
* Returns the parent scope of the current scope
|
|
62
|
+
*
|
|
63
|
+
* @param setValue
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
get parent() {
|
|
72
67
|
return this._parent;
|
|
73
68
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
constructor(param1, param2) {
|
|
70
|
+
// ===========================================================================
|
|
71
|
+
// --------------------ALLowed Constructors--------------------------------
|
|
72
|
+
// ===========================================================================
|
|
73
|
+
/**
|
|
74
|
+
* A set of allowed components, A set of constructors that are allowed in the scope
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
this._allowedComponents = new Set();
|
|
78
|
+
/**
|
|
79
|
+
* A set of allowed errors, A set of constructors that are allowed in the scope
|
|
80
|
+
*/
|
|
81
|
+
this._allowedErrors = new Set();
|
|
82
|
+
/**
|
|
83
|
+
* A set of allowed entities, A set of constructors that are allowed in the scope
|
|
84
|
+
*/
|
|
85
|
+
this._allowedEntities = new Set();
|
|
86
|
+
/**
|
|
87
|
+
* A set of allowed fragments, A set of constructors that are allowed in the scope
|
|
88
|
+
*/
|
|
89
|
+
this._allowedFragments = new Set();
|
|
90
|
+
// ===========================================================================
|
|
91
|
+
// --------------------Internal Storage--------------------------------
|
|
92
|
+
// ===========================================================================
|
|
93
|
+
/**
|
|
94
|
+
* Storage for the components, should be strong as components are unique per scope
|
|
95
|
+
*/
|
|
96
|
+
this._components = new Map();
|
|
97
|
+
/**
|
|
98
|
+
* Storage for the errors, should be strong as errors are unique per code
|
|
99
|
+
*/
|
|
100
|
+
this._errors = new Map();
|
|
101
|
+
/**
|
|
102
|
+
* Storage for the entities, should be strong as entities are unique per aseid
|
|
103
|
+
*/
|
|
104
|
+
this._entities = new Map();
|
|
105
|
+
/**
|
|
106
|
+
* Storage for the fragments, should be weak as fragments are singletons per scope
|
|
107
|
+
*/
|
|
108
|
+
this._fragments = new Map();
|
|
109
|
+
const initializer = this.getInitializer(param1);
|
|
110
|
+
// the returned initializer is already bound to `this` (we used .bind(this)),
|
|
111
|
+
// so calling it will run the appropriate logic on this instance:
|
|
112
|
+
initializer.call(this, param1, param2);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Determines which initializer method to use based on the type of the first parameter.
|
|
116
|
+
*
|
|
117
|
+
* @param param1
|
|
118
|
+
* @returns
|
|
119
|
+
*/
|
|
120
|
+
getInitializer(param1, param2) {
|
|
121
|
+
switch (true) {
|
|
122
|
+
case !param1 && !param2:
|
|
123
|
+
;
|
|
124
|
+
return this.defaultInitialized;
|
|
125
|
+
case !!param1:
|
|
126
|
+
return this.defaultInitialized;
|
|
127
|
+
default:
|
|
128
|
+
throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.ConstructorError, 'Invalid parameters provided to A_Scope constructor');
|
|
81
129
|
}
|
|
82
|
-
return false;
|
|
83
130
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
131
|
+
defaultInitialized(params = {}, config = {}) {
|
|
132
|
+
this._name = params.name || this.constructor.name;
|
|
133
|
+
this.initComponents(params.components);
|
|
134
|
+
this.initErrors(params.errors);
|
|
135
|
+
this.initFragments(params.fragments);
|
|
136
|
+
this.initEntities(params.entities);
|
|
137
|
+
if (config.parent) {
|
|
138
|
+
this._parent = config.parent;
|
|
89
139
|
}
|
|
90
|
-
this._parent = parent;
|
|
91
|
-
return this;
|
|
92
140
|
}
|
|
141
|
+
//==========================================================================
|
|
142
|
+
// --------------------Scope Initialization Methods---------------------------
|
|
143
|
+
//==========================================================================
|
|
93
144
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
145
|
+
* This method is used to initialize the components in the scope
|
|
146
|
+
* To save memory components are initialized only when they are requested
|
|
147
|
+
*
|
|
148
|
+
* This method only registers the component in the scope in case they are not registered yet
|
|
149
|
+
*
|
|
150
|
+
* @param _components
|
|
151
|
+
*/
|
|
152
|
+
initComponents(_components) { _components === null || _components === void 0 ? void 0 : _components.forEach(this.register.bind(this)); }
|
|
153
|
+
/**
|
|
154
|
+
* This method is used to initialize the errors in the scope
|
|
155
|
+
*
|
|
156
|
+
* This method only registers the errors in the scope in case they are not registered yet
|
|
157
|
+
*
|
|
158
|
+
* @param _errors
|
|
159
|
+
*/
|
|
160
|
+
initErrors(_errors) { _errors === null || _errors === void 0 ? void 0 : _errors.forEach(this.register.bind(this)); }
|
|
161
|
+
/**
|
|
162
|
+
* This method is used to initialize the entities in the scope
|
|
163
|
+
*
|
|
164
|
+
* This method only registers the entities in the scope in case they are not registered yet
|
|
165
|
+
*
|
|
166
|
+
* @param _entities
|
|
167
|
+
*/
|
|
168
|
+
initEntities(_entities) { _entities === null || _entities === void 0 ? void 0 : _entities.forEach(ent => this.register(ent)); }
|
|
169
|
+
/**
|
|
170
|
+
* This method is used to initialize the fragments in the scope
|
|
171
|
+
*
|
|
172
|
+
* This method only registers the fragments in the scope in case they are not registered yet
|
|
173
|
+
*
|
|
174
|
+
* @param _fragments
|
|
175
|
+
*/
|
|
176
|
+
initFragments(_fragments) { _fragments === null || _fragments === void 0 ? void 0 : _fragments.forEach(this.register.bind(this)); }
|
|
177
|
+
/**
|
|
178
|
+
* Returns the issuer of the scope, useful for debugging and tracking purposes
|
|
179
|
+
*
|
|
180
|
+
* Issuer can be:
|
|
181
|
+
* - A Container that allocated the scope
|
|
182
|
+
* - A Feature that allocated the scope
|
|
183
|
+
*
|
|
184
|
+
* [!] Note that the issuer is the direct allocator of the scope, so if a Container allocated a Feature that allocated the scope, the issuer will be the Feature
|
|
96
185
|
*
|
|
97
|
-
* @param scope
|
|
98
186
|
* @returns
|
|
99
187
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
let current = this._parent;
|
|
103
|
-
while (current) {
|
|
104
|
-
inheritanceChain.push(current.name);
|
|
105
|
-
if (current === scope) {
|
|
106
|
-
return inheritanceChain;
|
|
107
|
-
}
|
|
108
|
-
current = current._parent;
|
|
109
|
-
}
|
|
110
|
-
return false;
|
|
188
|
+
issuer() {
|
|
189
|
+
return A_Context_class_1.A_Context.issuer(this);
|
|
111
190
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
191
|
+
/**
|
|
192
|
+
* This method is used to inherit from a parent scope
|
|
193
|
+
*
|
|
194
|
+
* [!] This method checks for circular inheritance and throws an error if detected
|
|
195
|
+
*
|
|
196
|
+
* @param parent
|
|
197
|
+
* @returns
|
|
198
|
+
*/
|
|
199
|
+
inherit(parent) {
|
|
200
|
+
if (!parent)
|
|
201
|
+
throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.InitializationError, `Invalid parent scope provided`);
|
|
202
|
+
if (parent === this)
|
|
203
|
+
throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.CircularInheritanceError, `Unable to inherit scope ${this.name} from itself`);
|
|
204
|
+
if (parent === this._parent)
|
|
205
|
+
return this;
|
|
206
|
+
// Prevent circular inheritance
|
|
207
|
+
const circularCheck = this.checkCircularInheritance(parent);
|
|
208
|
+
if (circularCheck)
|
|
209
|
+
throw new A_Scope_error_1.A_ScopeError(A_Scope_error_1.A_ScopeError.CircularInheritanceError, `Circular inheritance detected: ${[...circularCheck, parent.name].join(' -> ')}`);
|
|
210
|
+
this._parent = parent;
|
|
211
|
+
return this;
|
|
120
212
|
}
|
|
121
|
-
has(
|
|
213
|
+
has(ctor) {
|
|
214
|
+
let found = false;
|
|
122
215
|
switch (true) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
if
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
216
|
+
// 1) Check by string name.
|
|
217
|
+
case typeof ctor === 'string': {
|
|
218
|
+
// 1.1 Check if it's a component name
|
|
219
|
+
const possibleComponent = Array.from(this.allowedComponents).find(c => c.name === ctor);
|
|
220
|
+
if (possibleComponent)
|
|
221
|
+
found = true;
|
|
222
|
+
// 1.2 Check if it's a fragment name
|
|
223
|
+
const possibleFragment = Array.from(this.allowedFragments).find(f => f.name === ctor);
|
|
224
|
+
if (possibleFragment)
|
|
225
|
+
found = true;
|
|
226
|
+
// 1.4 Check if it's an entity name or entity static entity property
|
|
227
|
+
const possibleEntity = Array.from(this.allowedEntities).find(e => e.name === ctor);
|
|
228
|
+
if (possibleEntity)
|
|
229
|
+
found = true;
|
|
230
|
+
// 1.5 If not found in current scope, check parent scope
|
|
135
231
|
if (!!this._parent)
|
|
136
|
-
return this._parent.has(
|
|
232
|
+
return this._parent.has(ctor);
|
|
137
233
|
return false;
|
|
138
234
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
return !!found;
|
|
154
|
-
}
|
|
155
|
-
case typeof entity === 'function'
|
|
156
|
-
&& a_utils_1.A_CommonHelper.isInheritedFrom(entity, A_Fragment_class_1.A_Fragment):
|
|
157
|
-
{
|
|
158
|
-
const found = this._fragments.has(entity);
|
|
159
|
-
if (!found && !!this._parent)
|
|
160
|
-
return this._parent.has(entity);
|
|
161
|
-
return found;
|
|
162
|
-
}
|
|
163
|
-
case typeof entity === 'function'
|
|
164
|
-
&& a_utils_1.A_CommonHelper.isInheritedFrom(entity, A_Command_class_1.A_Command):
|
|
165
|
-
{
|
|
166
|
-
const found = this.commands.includes(entity);
|
|
167
|
-
if (!found && !!this._parent)
|
|
168
|
-
return this._parent.has(entity);
|
|
169
|
-
return found;
|
|
170
|
-
}
|
|
171
|
-
default: {
|
|
172
|
-
return false;
|
|
235
|
+
// 2) Check if it's a Component
|
|
236
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isComponentConstructor(ctor): {
|
|
237
|
+
found = this.isAllowedComponent(ctor);
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
// 3) Check if it's an Entity
|
|
241
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isEntityConstructor(ctor): {
|
|
242
|
+
found = this.isAllowedEntity(ctor);
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
// 4) Check if it's a Fragment
|
|
246
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isFragmentConstructor(ctor): {
|
|
247
|
+
found = this.isAllowedFragment(ctor);
|
|
248
|
+
break;
|
|
173
249
|
}
|
|
174
250
|
}
|
|
251
|
+
if (!found && !!this._parent)
|
|
252
|
+
return this._parent.has(ctor);
|
|
253
|
+
return found;
|
|
175
254
|
}
|
|
176
255
|
/**
|
|
177
256
|
* Merges two scopes into a new one
|
|
@@ -185,124 +264,159 @@ class A_Scope {
|
|
|
185
264
|
*/
|
|
186
265
|
merge(anotherScope) {
|
|
187
266
|
const merged = new A_Scope({
|
|
188
|
-
name: `${this.name}
|
|
189
|
-
components:
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
...anotherScope.params.fragments
|
|
196
|
-
])),
|
|
197
|
-
entities: Array.from(new Set([
|
|
198
|
-
...this.params.entities,
|
|
199
|
-
...anotherScope.params.entities
|
|
200
|
-
])),
|
|
267
|
+
name: `${this.name} + ${anotherScope.name}`,
|
|
268
|
+
components: [...this.allowedComponents, ...anotherScope.allowedComponents],
|
|
269
|
+
fragments: [...this.fragments, ...anotherScope.fragments],
|
|
270
|
+
entities: [
|
|
271
|
+
...this.entities, ...anotherScope.entities,
|
|
272
|
+
...this.allowedEntities, ...anotherScope.allowedEntities
|
|
273
|
+
],
|
|
201
274
|
}, {
|
|
202
275
|
parent: this._parent || anotherScope._parent
|
|
203
276
|
});
|
|
204
277
|
return merged;
|
|
205
278
|
}
|
|
206
|
-
/**
|
|
207
|
-
* Allows to retrieve the constructor of the component or entity by its name
|
|
208
|
-
*
|
|
209
|
-
* [!] Notes:
|
|
210
|
-
* - In case of search for A-Entity please ensure that provided string corresponds to the static entity property of the class. [!] By default it's the kebab-case of the class name
|
|
211
|
-
* - In case of search for A_Command please ensure that provided string corresponds to the static code property of the class. [!] By default it's the kebab-case of the class name
|
|
212
|
-
* - In case of search for A_Component please ensure that provided string corresponds to the class name in PascalCase
|
|
213
|
-
*
|
|
214
|
-
* @param name
|
|
215
|
-
* @returns
|
|
216
|
-
*/
|
|
217
279
|
resolveConstructor(name) {
|
|
218
|
-
// Check components
|
|
219
|
-
const component = this.
|
|
280
|
+
// 1) Check components
|
|
281
|
+
const component = Array.from(this.allowedComponents).find(c => c.name === name
|
|
282
|
+
|| c.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name));
|
|
220
283
|
if (component)
|
|
221
284
|
return component;
|
|
222
|
-
// Check entities
|
|
223
|
-
const entity = this.
|
|
224
|
-
|| e.
|
|
225
|
-
|| e.
|
|
285
|
+
// 2) Check entities
|
|
286
|
+
const entity = Array.from(this.allowedEntities).find(e => e.name === name
|
|
287
|
+
|| e.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name)
|
|
288
|
+
|| e.entity === name
|
|
289
|
+
|| e.entity === A_Formatter_helper_1.A_FormatterHelper.toKebabCase(name));
|
|
226
290
|
if (entity)
|
|
227
|
-
return entity
|
|
228
|
-
// Check
|
|
229
|
-
const
|
|
230
|
-
||
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
return command;
|
|
291
|
+
return entity;
|
|
292
|
+
// 3) Check fragments
|
|
293
|
+
const fragment = Array.from(this.allowedFragments).find(f => f.name === name
|
|
294
|
+
|| f.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name));
|
|
295
|
+
if (fragment)
|
|
296
|
+
return fragment;
|
|
234
297
|
// If not found in current scope, check parent scope
|
|
235
298
|
if (!!this._parent) {
|
|
236
299
|
return this._parent.resolveConstructor(name);
|
|
237
300
|
}
|
|
238
301
|
throw new Error(`Component or Entity with name ${name} not found in the scope ${this.name}`);
|
|
239
302
|
}
|
|
240
|
-
|
|
241
|
-
|
|
303
|
+
resolve(
|
|
304
|
+
/**
|
|
305
|
+
* Provide a component, fragment or entity constructor or an array of constructors to resolve its instance(s) from the scope
|
|
306
|
+
*/
|
|
307
|
+
param1, param2) {
|
|
242
308
|
switch (true) {
|
|
243
|
-
case
|
|
244
|
-
return param1.map(c =>
|
|
309
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isArray(param1): {
|
|
310
|
+
return param1.map(c => {
|
|
311
|
+
if (A_TypeGuards_helper_1.A_TypeGuards.isString(c))
|
|
312
|
+
return this.resolveByName(c);
|
|
313
|
+
else
|
|
314
|
+
return this.resolveOnce(c, param2);
|
|
315
|
+
}).filter(Boolean);
|
|
245
316
|
}
|
|
246
|
-
case
|
|
317
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isFunction(param1): {
|
|
247
318
|
return this.resolveOnce(param1, param2);
|
|
248
319
|
}
|
|
249
|
-
case
|
|
320
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isString(param1): {
|
|
250
321
|
return this.resolveByName(param1);
|
|
251
322
|
}
|
|
252
323
|
default: {
|
|
253
|
-
throw new
|
|
324
|
+
throw new A_Error_class_1.A_Error(`Invalid parameter provided to resolve method: ${param1} in scope ${this.name}`);
|
|
254
325
|
}
|
|
255
326
|
}
|
|
256
327
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
328
|
+
// ==================================================================================================
|
|
329
|
+
// --------------------------------------------------------------------------------------------------
|
|
330
|
+
// -------------------------------------INTERNAL RESOLVERS-------------------------------------------
|
|
331
|
+
// --------------------------------------------------------------------------------------------------
|
|
332
|
+
// ==================================================================================================
|
|
333
|
+
/**
|
|
334
|
+
* This method is used internally to resolve a component, fragment or entity by its constructor name
|
|
335
|
+
*
|
|
336
|
+
* [!] Note that this method checks for the component, fragment or entity in the current scope and all parent scopes
|
|
337
|
+
*
|
|
338
|
+
* @param name - name of the component, fragment or entity to resolve (constructor name for components and fragments, static entity property for entities, static code property for commands)
|
|
339
|
+
* @returns
|
|
340
|
+
*/
|
|
341
|
+
resolveByName(
|
|
342
|
+
/**
|
|
343
|
+
* Provide the name of the component, fragment or entity to resolve
|
|
344
|
+
*/
|
|
345
|
+
name) {
|
|
346
|
+
// 1) Check components
|
|
347
|
+
const component = Array.from(this.allowedComponents).find(c => c.name === name
|
|
348
|
+
|| c.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name));
|
|
260
349
|
if (component)
|
|
261
|
-
return this.
|
|
262
|
-
// Check
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
const fragment = this.params.fragments.find(f => f.constructor.name === name);
|
|
268
|
-
if (fragment)
|
|
269
|
-
return this.resolveFragment(fragment.constructor);
|
|
270
|
-
// Check entities
|
|
271
|
-
const entity = this.params.entities.find(e => e.constructor.name === name);
|
|
350
|
+
return this.resolveOnce(component);
|
|
351
|
+
// 2) Check entities
|
|
352
|
+
const entity = Array.from(this.allowedEntities).find(e => e.name === name
|
|
353
|
+
|| e.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name)
|
|
354
|
+
|| e.entity === name
|
|
355
|
+
|| e.entity === A_Formatter_helper_1.A_FormatterHelper.toKebabCase(name));
|
|
272
356
|
if (entity)
|
|
273
|
-
return this.
|
|
357
|
+
return this.resolveOnce(entity);
|
|
358
|
+
// 3) Check fragments
|
|
359
|
+
const fragment = Array.from(this.allowedFragments).find(f => f.name === name
|
|
360
|
+
|| f.name === A_Formatter_helper_1.A_FormatterHelper.toPascalCase(name));
|
|
361
|
+
if (fragment)
|
|
362
|
+
return this.resolveOnce(fragment);
|
|
274
363
|
// If not found in current scope, check parent scope
|
|
275
|
-
if (this._parent) {
|
|
364
|
+
if (!!this._parent) {
|
|
276
365
|
return this._parent.resolveByName(name);
|
|
277
366
|
}
|
|
278
|
-
throw new Error(`Component
|
|
367
|
+
throw new Error(`Component or Entity with name ${name} not found in the scope ${this.name}`);
|
|
279
368
|
}
|
|
369
|
+
/**
|
|
370
|
+
* This method is used internally to resolve a single component, fragment or entity from the scope
|
|
371
|
+
*
|
|
372
|
+
* @param component
|
|
373
|
+
* @param instructions
|
|
374
|
+
* @returns
|
|
375
|
+
*/
|
|
280
376
|
resolveOnce(component, instructions) {
|
|
377
|
+
if (A_TypeGuards_helper_1.A_TypeGuards.isScopeConstructor(component))
|
|
378
|
+
component;
|
|
379
|
+
if (typeof component == 'function' && component.name === 'A_Scope')
|
|
380
|
+
component;
|
|
281
381
|
switch (true) {
|
|
282
|
-
case
|
|
382
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isEntityConstructor(component): {
|
|
283
383
|
return this.resolveEntity(component, instructions);
|
|
284
384
|
}
|
|
285
|
-
case
|
|
385
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isFragmentConstructor(component): {
|
|
286
386
|
return this.resolveFragment(component);
|
|
287
387
|
}
|
|
288
|
-
case
|
|
388
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isScopeConstructor(component): {
|
|
289
389
|
return this.resolveScope(component);
|
|
290
390
|
}
|
|
291
|
-
case
|
|
391
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isComponentConstructor(component): {
|
|
292
392
|
return this.resolveComponent(component);
|
|
293
393
|
}
|
|
294
394
|
default:
|
|
295
395
|
throw new Error(`Injected Component ${component} not found in the scope`);
|
|
296
396
|
}
|
|
297
397
|
}
|
|
398
|
+
/**
|
|
399
|
+
* This method is used internally to resolve a single entity from the scope based on the provided instructions
|
|
400
|
+
*
|
|
401
|
+
* [!] Note that this method can return either a single entity or an array of entities depending on the instructions provided
|
|
402
|
+
*
|
|
403
|
+
* @param entity
|
|
404
|
+
* @param instructions
|
|
405
|
+
* @returns
|
|
406
|
+
*/
|
|
298
407
|
resolveEntity(entity, instructions) {
|
|
299
408
|
var _a;
|
|
300
409
|
const query = (instructions === null || instructions === void 0 ? void 0 : instructions.query) || {};
|
|
301
410
|
const count = ((_a = instructions === null || instructions === void 0 ? void 0 : instructions.pagination) === null || _a === void 0 ? void 0 : _a.count) || 1;
|
|
302
411
|
switch (true) {
|
|
412
|
+
/**
|
|
413
|
+
* 1) In case when no instructions provided, return the first found entity of the provided type
|
|
414
|
+
*
|
|
415
|
+
* [!] Note that it returns ONLY ONE entity
|
|
416
|
+
* [!!] In case when no entity found in the current scope, it tries to resolve it from the parent scope (if exists)
|
|
417
|
+
*/
|
|
303
418
|
case !instructions: {
|
|
304
|
-
const
|
|
305
|
-
const found = entities.find(e => e instanceof entity);
|
|
419
|
+
const found = this.entities.find(e => e instanceof entity);
|
|
306
420
|
switch (true) {
|
|
307
421
|
case !!found:
|
|
308
422
|
return found;
|
|
@@ -312,31 +426,53 @@ class A_Scope {
|
|
|
312
426
|
throw new Error(`Entity ${entity.name} not found in the scope ${this.name}`);
|
|
313
427
|
}
|
|
314
428
|
}
|
|
429
|
+
/**
|
|
430
|
+
* 2) In case when aseid is provided in the query, we can directly get the entity from the map
|
|
431
|
+
*
|
|
432
|
+
* [!] Note that it returns ONLY ONE entity
|
|
433
|
+
*/
|
|
315
434
|
case !!query.aseid
|
|
316
435
|
&& typeof query.aseid === 'string'
|
|
317
436
|
&& this._entities.has(query.aseid):
|
|
318
437
|
{
|
|
319
438
|
return this._entities.get(query.aseid);
|
|
320
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* 3) In case when aseid is provided as ASEID instance, we can directly get the entity from the map
|
|
442
|
+
*
|
|
443
|
+
* [!] Note that it returns ONLY ONE entity
|
|
444
|
+
*/
|
|
321
445
|
case !!query.aseid
|
|
322
446
|
&& typeof query.aseid === 'object'
|
|
323
|
-
&& query.aseid instanceof
|
|
447
|
+
&& query.aseid instanceof ASEID_class_1.ASEID
|
|
324
448
|
&& this._entities.has(query.aseid.toString()):
|
|
325
449
|
{
|
|
326
450
|
return this._entities.get(query.aseid.toString());
|
|
327
451
|
}
|
|
452
|
+
/**
|
|
453
|
+
* 4) In case when id is provided in the query, we have to find the entity by the id
|
|
454
|
+
*
|
|
455
|
+
* [!] Note that it returns ONLY ONE entity
|
|
456
|
+
*/
|
|
328
457
|
case !!query.id: {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
return String(e.id) === String(query.id);
|
|
333
|
-
});
|
|
458
|
+
const found = this.entities
|
|
459
|
+
.filter(e => e instanceof entity)
|
|
460
|
+
.find(e => String(e.id) === String(query.id));
|
|
334
461
|
return found;
|
|
335
462
|
}
|
|
463
|
+
/**
|
|
464
|
+
* 5) In case when there's a query object, we have to filter the entities by the query
|
|
465
|
+
*
|
|
466
|
+
* [!] Note that it can return either a single entity or an array of entities depending on the count instruction
|
|
467
|
+
* [!!] In case when no entity found in the current scope, it tries to resolve it from the parent scope (if exists)
|
|
468
|
+
*/
|
|
336
469
|
default: {
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
470
|
+
const found = this.entities
|
|
471
|
+
.filter(e => e instanceof entity)
|
|
472
|
+
.filter(e => {
|
|
473
|
+
return Object
|
|
474
|
+
.entries(query)
|
|
475
|
+
.every(([key, value]) => {
|
|
340
476
|
if (key in e) {
|
|
341
477
|
return e[key] === value;
|
|
342
478
|
}
|
|
@@ -351,131 +487,143 @@ class A_Scope {
|
|
|
351
487
|
}
|
|
352
488
|
}
|
|
353
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* This method is used internally to resolve a single fragment from the scope
|
|
492
|
+
*
|
|
493
|
+
* @param fragment
|
|
494
|
+
* @returns
|
|
495
|
+
*/
|
|
354
496
|
resolveFragment(fragment) {
|
|
355
|
-
const fragmentInstancePresented = this.
|
|
497
|
+
const fragmentInstancePresented = this._fragments.get(fragment);
|
|
356
498
|
switch (true) {
|
|
357
499
|
case fragmentInstancePresented && this._fragments.has(fragment):
|
|
358
|
-
return
|
|
359
|
-
case fragmentInstancePresented && !this._fragments.has(fragment):
|
|
360
|
-
return this.fragments.find(fr => fr instanceof fragment);
|
|
500
|
+
return fragmentInstancePresented;
|
|
361
501
|
case !fragmentInstancePresented && !!this._parent:
|
|
362
502
|
return this._parent.resolveFragment(fragment);
|
|
363
503
|
default:
|
|
364
504
|
throw new Error(`Fragment ${fragment.name} not found in the scope ${this.name}`);
|
|
365
505
|
}
|
|
366
506
|
}
|
|
507
|
+
/**
|
|
508
|
+
* This method is used internally to resolve a single scope from the current scope
|
|
509
|
+
*
|
|
510
|
+
* @param scope
|
|
511
|
+
* @returns
|
|
512
|
+
*/
|
|
367
513
|
resolveScope(scope) {
|
|
368
514
|
return this;
|
|
369
515
|
}
|
|
516
|
+
/**
|
|
517
|
+
* This method is used internally to resolve a single component from the scope
|
|
518
|
+
*
|
|
519
|
+
* @param component
|
|
520
|
+
* @returns
|
|
521
|
+
*/
|
|
370
522
|
resolveComponent(component) {
|
|
371
523
|
// The idea here that in case when Scope has no exact component we have to resolve it from the _parent
|
|
372
524
|
// BUT: if it's not presented in _parent we have to check for inheritance
|
|
373
525
|
// That means that we should ensure that there's no components that are children of the required component
|
|
374
526
|
switch (true) {
|
|
375
|
-
// In case when the component is available and exists in the scope
|
|
376
|
-
case this.
|
|
527
|
+
// 1) In case when the component is available and exists in the scope
|
|
528
|
+
case this.allowedComponents.has(component) && this._components.has(component): {
|
|
377
529
|
return this._components.get(component);
|
|
378
530
|
}
|
|
379
|
-
// In case the component available but does NOT exist in the scope
|
|
380
|
-
case this.
|
|
531
|
+
// 2) In case the component available but does NOT exist in the scope
|
|
532
|
+
case this.allowedComponents.has(component) && !this._components.has(component): {
|
|
381
533
|
const componentMeta = A_Context_class_1.A_Context.meta(component);
|
|
382
|
-
const argsMeta = componentMeta.get(
|
|
534
|
+
const argsMeta = componentMeta.get(A_Component_constants_1.A_TYPES__ComponentMetaKey.INJECTIONS);
|
|
383
535
|
const resolvedArgs = ((argsMeta === null || argsMeta === void 0 ? void 0 : argsMeta.get('constructor')) || [])
|
|
384
536
|
.map(arg => {
|
|
385
537
|
if ('instructions' in arg) {
|
|
386
538
|
const { target, instructions } = arg;
|
|
387
539
|
return this.resolve(target, instructions);
|
|
388
540
|
}
|
|
541
|
+
// TODO: Fix types mismatch here
|
|
389
542
|
return this.resolve(arg.target);
|
|
390
543
|
});
|
|
391
544
|
const newComponent = new component(...resolvedArgs);
|
|
392
545
|
this.register(newComponent);
|
|
393
546
|
return this._components.get(component);
|
|
394
547
|
}
|
|
395
|
-
// In case when there's a component that is inherited from the required component
|
|
396
|
-
case !this.
|
|
397
|
-
const found = this.
|
|
548
|
+
// 3) In case when there's a component that is inherited from the required component
|
|
549
|
+
case !this.allowedComponents.has(component) && Array.from(this.allowedComponents).some(el => A_Common_helper_1.A_CommonHelper.isInheritedFrom(el, component)): {
|
|
550
|
+
const found = Array.from(this.allowedComponents).find(el => A_Common_helper_1.A_CommonHelper.isInheritedFrom(el, component));
|
|
398
551
|
return this.resolveComponent(found);
|
|
399
552
|
}
|
|
400
|
-
// In case when the component is not available in the scope but the _parent is available
|
|
401
|
-
case
|
|
553
|
+
// 4) In case when the component is not available in the scope but the _parent is available
|
|
554
|
+
case !!this._parent: {
|
|
402
555
|
return this._parent.resolveComponent(component);
|
|
403
556
|
}
|
|
404
557
|
default:
|
|
405
558
|
throw new Error(`Component ${component.name} not found in the scope ${this.name}`);
|
|
406
559
|
}
|
|
407
560
|
}
|
|
408
|
-
/**
|
|
409
|
-
* Should be similar to resolveEntity but for commands
|
|
410
|
-
*
|
|
411
|
-
* @param command
|
|
412
|
-
*/
|
|
413
|
-
resolveCommand(command) {
|
|
414
|
-
const commands = Array.from(this._commands.values());
|
|
415
|
-
const found = commands.find(e => e instanceof command);
|
|
416
|
-
switch (true) {
|
|
417
|
-
case !!found:
|
|
418
|
-
return found;
|
|
419
|
-
case !found && !!this._parent:
|
|
420
|
-
return this._parent.resolveCommand(command);
|
|
421
|
-
default:
|
|
422
|
-
throw new Error(`Command ${command.name} not found in the scope ${this.name}`);
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
561
|
register(param1) {
|
|
426
562
|
switch (true) {
|
|
427
|
-
|
|
563
|
+
// ------------------------------------------
|
|
564
|
+
// ------------ Instances ----------------
|
|
565
|
+
// ------------------------------------------
|
|
566
|
+
// 1) In case when it's a A-Component instance
|
|
567
|
+
case param1 instanceof A_Component_class_1.A_Component: {
|
|
568
|
+
if (!this.allowedComponents.has(param1.constructor))
|
|
569
|
+
this.allowedComponents.add(param1.constructor);
|
|
428
570
|
this._components.set(param1.constructor, param1);
|
|
429
|
-
const allowedComponent = this.components.find(c => c === param1.constructor);
|
|
430
|
-
if (!allowedComponent) {
|
|
431
|
-
this.components.push(param1.constructor);
|
|
432
|
-
}
|
|
433
571
|
A_Context_class_1.A_Context.register(this, param1);
|
|
434
572
|
break;
|
|
435
573
|
}
|
|
574
|
+
// 3) In case when it's a A-Entity instance
|
|
436
575
|
case param1 instanceof A_Entity_class_1.A_Entity && !this._entities.has(param1.aseid.toString()): {
|
|
576
|
+
if (!this.allowedEntities.has(param1.constructor))
|
|
577
|
+
this.allowedEntities.add(param1.constructor);
|
|
437
578
|
this._entities.set(param1.aseid.toString(), param1);
|
|
438
579
|
A_Context_class_1.A_Context.register(this, param1);
|
|
439
580
|
break;
|
|
440
581
|
}
|
|
441
|
-
case
|
|
442
|
-
|
|
443
|
-
if (!
|
|
444
|
-
this.
|
|
445
|
-
}
|
|
582
|
+
// 4) In case when it's a A-Fragment instance
|
|
583
|
+
case param1 instanceof A_Fragment_class_1.A_Fragment: {
|
|
584
|
+
if (!this.allowedFragments.has(param1.constructor))
|
|
585
|
+
this.allowedFragments.add(param1.constructor);
|
|
446
586
|
this._fragments.set(param1.constructor, param1);
|
|
447
587
|
A_Context_class_1.A_Context.register(this, param1);
|
|
448
588
|
break;
|
|
449
589
|
}
|
|
450
|
-
case
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
456
|
-
A_Context_class_1.A_Context.register(this, param1);
|
|
590
|
+
// 5) In case when it's a A-Error instance
|
|
591
|
+
case param1 instanceof A_Error_class_1.A_Error: {
|
|
592
|
+
if (!this.allowedErrors.has(param1.constructor))
|
|
593
|
+
this.allowedErrors.add(param1.constructor);
|
|
594
|
+
// A_Context.register(this, param1);
|
|
457
595
|
break;
|
|
458
596
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
597
|
+
// ------------------------------------------
|
|
598
|
+
// ------------ Constructors ----------------
|
|
599
|
+
// ------------------------------------------
|
|
600
|
+
// 6) In case when it's a A-Component constructor
|
|
601
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isComponentConstructor(param1): {
|
|
602
|
+
if (!this.allowedComponents.has(param1))
|
|
603
|
+
this.allowedComponents.add(param1);
|
|
463
604
|
break;
|
|
464
605
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
if (!
|
|
468
|
-
this.
|
|
469
|
-
}
|
|
606
|
+
// 8) In case when it's a A-Fragment constructor
|
|
607
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isFragmentConstructor(param1): {
|
|
608
|
+
if (!this.allowedFragments.has(param1))
|
|
609
|
+
this.allowedFragments.add(param1);
|
|
470
610
|
break;
|
|
471
611
|
}
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
if (!
|
|
475
|
-
this.
|
|
476
|
-
}
|
|
612
|
+
// 9) In case when it's a A-Entity constructor
|
|
613
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isEntityConstructor(param1): {
|
|
614
|
+
if (!this.allowedEntities.has(param1))
|
|
615
|
+
this.allowedEntities.add(param1);
|
|
477
616
|
break;
|
|
478
617
|
}
|
|
618
|
+
// 10) In case when it's a A-Error constructor
|
|
619
|
+
case A_TypeGuards_helper_1.A_TypeGuards.isErrorConstructor(param1): {
|
|
620
|
+
if (!this.allowedErrors.has(param1))
|
|
621
|
+
this.allowedErrors.add(param1);
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
624
|
+
// ------------------------------------------
|
|
625
|
+
// ------------ Invalid Cases ----------------
|
|
626
|
+
// ------------------------------------------
|
|
479
627
|
default:
|
|
480
628
|
if (param1 instanceof A_Entity_class_1.A_Entity)
|
|
481
629
|
throw new Error(`Entity with ASEID ${param1.aseid.toString()} is already registered in the scope ${this.name}`);
|
|
@@ -485,12 +633,110 @@ class A_Scope {
|
|
|
485
633
|
throw new Error(`Cannot register ${param1} in the scope ${this.name}`);
|
|
486
634
|
}
|
|
487
635
|
}
|
|
636
|
+
/**
|
|
637
|
+
* This method is useful when you want to serialize the scope to JSON
|
|
638
|
+
*
|
|
639
|
+
* [!] Note this is not a deep serialization, only the fragments are serialized
|
|
640
|
+
* [!] Fragments are a storage for information which is relevant to the scope
|
|
641
|
+
*
|
|
642
|
+
* @returns
|
|
643
|
+
*/
|
|
488
644
|
toJSON() {
|
|
489
|
-
return this.fragments
|
|
645
|
+
return this.fragments
|
|
646
|
+
.reduce((acc, fragment) => {
|
|
490
647
|
const serialized = fragment.toJSON();
|
|
491
648
|
return Object.assign(Object.assign({}, acc), { [serialized.name]: serialized });
|
|
492
649
|
}, {});
|
|
493
650
|
}
|
|
651
|
+
//==========================================================================
|
|
652
|
+
// --------------------Scope Type Check Helpers---------------------------
|
|
653
|
+
//==========================================================================
|
|
654
|
+
/**
|
|
655
|
+
* Type guard to check if the constructor is of type A_Component and is allowed in the scope
|
|
656
|
+
*
|
|
657
|
+
* @param ctor
|
|
658
|
+
* @returns
|
|
659
|
+
*/
|
|
660
|
+
isAllowedComponent(ctor) {
|
|
661
|
+
return A_TypeGuards_helper_1.A_TypeGuards.isComponentConstructor(ctor) && this.allowedComponents.has(ctor);
|
|
662
|
+
}
|
|
663
|
+
/**
|
|
664
|
+
* Type guard to check if the constructor is of type A_Entity and is allowed in the scope
|
|
665
|
+
*
|
|
666
|
+
* @param ctor
|
|
667
|
+
* @returns
|
|
668
|
+
*/
|
|
669
|
+
isAllowedEntity(ctor) {
|
|
670
|
+
return A_TypeGuards_helper_1.A_TypeGuards.isEntityConstructor(ctor) && this.allowedEntities.has(ctor);
|
|
671
|
+
}
|
|
672
|
+
/**
|
|
673
|
+
* Type guard to check if the constructor is of type A_Fragment and is allowed in the scope
|
|
674
|
+
*
|
|
675
|
+
* @param ctor
|
|
676
|
+
* @returns
|
|
677
|
+
*/
|
|
678
|
+
isAllowedFragment(ctor) {
|
|
679
|
+
return A_TypeGuards_helper_1.A_TypeGuards.isFragmentConstructor(ctor) && this.allowedFragments.has(ctor);
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* Type guard to check if the constructor is of type A_Error and is allowed in the scope
|
|
683
|
+
*
|
|
684
|
+
* @param ctor
|
|
685
|
+
* @returns
|
|
686
|
+
*/
|
|
687
|
+
isAllowedError(ctor) {
|
|
688
|
+
return A_TypeGuards_helper_1.A_TypeGuards.isErrorConstructor(ctor) && this.allowedErrors.has(ctor);
|
|
689
|
+
}
|
|
690
|
+
// ==========================================================================
|
|
691
|
+
// --------------------DEBUG & Helpers Methods--------------------------------
|
|
692
|
+
// ===========================================================================
|
|
693
|
+
/**
|
|
694
|
+
* This method is used to check if the scope is inherited from another scope
|
|
695
|
+
*
|
|
696
|
+
* @param scope
|
|
697
|
+
* @returns
|
|
698
|
+
*/
|
|
699
|
+
isInheritedFrom(scope) {
|
|
700
|
+
let current = this;
|
|
701
|
+
while (current) {
|
|
702
|
+
if (current === scope) {
|
|
703
|
+
return true;
|
|
704
|
+
}
|
|
705
|
+
current = current._parent;
|
|
706
|
+
}
|
|
707
|
+
return false;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Helper method to check circular inheritance
|
|
711
|
+
* Should return a full sequence of inheritance for logging purposes
|
|
712
|
+
*
|
|
713
|
+
* @param scope
|
|
714
|
+
* @returns
|
|
715
|
+
*/
|
|
716
|
+
checkCircularInheritance(scope) {
|
|
717
|
+
const inheritanceChain = [];
|
|
718
|
+
let current = this._parent;
|
|
719
|
+
while (current) {
|
|
720
|
+
inheritanceChain.push(current.name);
|
|
721
|
+
if (current === scope) {
|
|
722
|
+
return inheritanceChain;
|
|
723
|
+
}
|
|
724
|
+
current = current._parent;
|
|
725
|
+
}
|
|
726
|
+
return false;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Helper method to print the inheritance chain of the scope
|
|
730
|
+
*/
|
|
731
|
+
printInheritanceChain() {
|
|
732
|
+
const chain = [];
|
|
733
|
+
let current = this;
|
|
734
|
+
while (current) {
|
|
735
|
+
chain.push(current.name);
|
|
736
|
+
current = current._parent;
|
|
737
|
+
}
|
|
738
|
+
console.log(chain.join(' -> '));
|
|
739
|
+
}
|
|
494
740
|
}
|
|
495
741
|
exports.A_Scope = A_Scope;
|
|
496
742
|
//# sourceMappingURL=A-Scope.class.js.map
|