@rsdk/core 0.14.0
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/.eslintignore +4 -0
- package/.eslintrc.js +4 -0
- package/.prettierignore +1 -0
- package/.prettierrc.json +1 -0
- package/dist/app/platform.app.d.ts +28 -0
- package/dist/app/platform.app.js +49 -0
- package/dist/app/platform.app.js.map +1 -0
- package/dist/app-metadata/app-metadata.const.d.ts +3 -0
- package/dist/app-metadata/app-metadata.const.js +7 -0
- package/dist/app-metadata/app-metadata.const.js.map +1 -0
- package/dist/app-metadata/app-metadata.module.d.ts +5 -0
- package/dist/app-metadata/app-metadata.module.js +41 -0
- package/dist/app-metadata/app-metadata.module.js.map +1 -0
- package/dist/app-metadata/app-name.const.d.ts +1 -0
- package/dist/app-metadata/app-name.const.js +5 -0
- package/dist/app-metadata/app-name.const.js.map +1 -0
- package/dist/app-metadata/app-name.validator.d.ts +2 -0
- package/dist/app-metadata/app-name.validator.js +14 -0
- package/dist/app-metadata/app-name.validator.js.map +1 -0
- package/dist/app-metadata/decorators/app-name.decorator.d.ts +1 -0
- package/dist/app-metadata/decorators/app-name.decorator.js +8 -0
- package/dist/app-metadata/decorators/app-name.decorator.js.map +1 -0
- package/dist/app-metadata/decorators/index.d.ts +1 -0
- package/dist/app-metadata/decorators/index.js +18 -0
- package/dist/app-metadata/decorators/index.js.map +1 -0
- package/dist/app-metadata/exceptions/app-name-validation.exception.d.ts +4 -0
- package/dist/app-metadata/exceptions/app-name-validation.exception.js +38 -0
- package/dist/app-metadata/exceptions/app-name-validation.exception.js.map +1 -0
- package/dist/app-metadata/exceptions/index.d.ts +1 -0
- package/dist/app-metadata/exceptions/index.js +18 -0
- package/dist/app-metadata/exceptions/index.js.map +1 -0
- package/dist/app-metadata/index.d.ts +2 -0
- package/dist/app-metadata/index.js +19 -0
- package/dist/app-metadata/index.js.map +1 -0
- package/dist/config/additional-source/additional-source.initializer.d.ts +38 -0
- package/dist/config/additional-source/additional-source.initializer.js +130 -0
- package/dist/config/additional-source/additional-source.initializer.js.map +1 -0
- package/dist/config/additional-source/additional-source.module.d.ts +24 -0
- package/dist/config/additional-source/additional-source.module.js +32 -0
- package/dist/config/additional-source/additional-source.module.js.map +1 -0
- package/dist/config/config-reload.indicator.d.ts +8 -0
- package/dist/config/config-reload.indicator.js +42 -0
- package/dist/config/config-reload.indicator.js.map +1 -0
- package/dist/config/config.abstract.d.ts +19 -0
- package/dist/config/config.abstract.js +57 -0
- package/dist/config/config.abstract.js.map +1 -0
- package/dist/config/config.module.d.ts +121 -0
- package/dist/config/config.module.js +271 -0
- package/dist/config/config.module.js.map +1 -0
- package/dist/config/exceptions/config-not-bootstrapped.exception.d.ts +4 -0
- package/dist/config/exceptions/config-not-bootstrapped.exception.js +30 -0
- package/dist/config/exceptions/config-not-bootstrapped.exception.js.map +1 -0
- package/dist/config/exceptions/config-property-metadata-not-found.d.ts +4 -0
- package/dist/config/exceptions/config-property-metadata-not-found.js +13 -0
- package/dist/config/exceptions/config-property-metadata-not-found.js.map +1 -0
- package/dist/config/exceptions/index.d.ts +3 -0
- package/dist/config/exceptions/index.js +22 -0
- package/dist/config/exceptions/index.js.map +1 -0
- package/dist/config/exceptions/property.exception.d.ts +5 -0
- package/dist/config/exceptions/property.exception.js +18 -0
- package/dist/config/exceptions/property.exception.js.map +1 -0
- package/dist/config/index.d.ts +10 -0
- package/dist/config/index.js +29 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/metadata/config-metadata.registry.d.ts +17 -0
- package/dist/config/metadata/config-metadata.registry.js +46 -0
- package/dist/config/metadata/config-metadata.registry.js.map +1 -0
- package/dist/config/metadata/decorators/config-section.decorator.d.ts +10 -0
- package/dist/config/metadata/decorators/config-section.decorator.js +19 -0
- package/dist/config/metadata/decorators/config-section.decorator.js.map +1 -0
- package/dist/config/metadata/decorators/declare-property.decorator.d.ts +17 -0
- package/dist/config/metadata/decorators/declare-property.decorator.js +37 -0
- package/dist/config/metadata/decorators/declare-property.decorator.js.map +1 -0
- package/dist/config/metadata/decorators/index.d.ts +4 -0
- package/dist/config/metadata/decorators/index.js +21 -0
- package/dist/config/metadata/decorators/index.js.map +1 -0
- package/dist/config/metadata/decorators/inject-property.decorator.d.ts +19 -0
- package/dist/config/metadata/decorators/inject-property.decorator.js +26 -0
- package/dist/config/metadata/decorators/inject-property.decorator.js.map +1 -0
- package/dist/config/metadata/decorators/property.decorator.d.ts +12 -0
- package/dist/config/metadata/decorators/property.decorator.js +27 -0
- package/dist/config/metadata/decorators/property.decorator.js.map +1 -0
- package/dist/config/metadata/exceptions/duplicate-property.exception.d.ts +4 -0
- package/dist/config/metadata/exceptions/duplicate-property.exception.js +27 -0
- package/dist/config/metadata/exceptions/duplicate-property.exception.js.map +1 -0
- package/dist/config/metadata/exceptions/duplicate-section.exception.d.ts +6 -0
- package/dist/config/metadata/exceptions/duplicate-section.exception.js +27 -0
- package/dist/config/metadata/exceptions/duplicate-section.exception.js.map +1 -0
- package/dist/config/metadata/exceptions/duplicate-source.exception.d.ts +6 -0
- package/dist/config/metadata/exceptions/duplicate-source.exception.js +27 -0
- package/dist/config/metadata/exceptions/duplicate-source.exception.js.map +1 -0
- package/dist/config/metadata/exceptions/index.d.ts +3 -0
- package/dist/config/metadata/exceptions/index.js +20 -0
- package/dist/config/metadata/exceptions/index.js.map +1 -0
- package/dist/config/metadata/index.d.ts +2 -0
- package/dist/config/metadata/index.js +19 -0
- package/dist/config/metadata/index.js.map +1 -0
- package/dist/config/parsers/array.parser.d.ts +11 -0
- package/dist/config/parsers/array.parser.js +33 -0
- package/dist/config/parsers/array.parser.js.map +1 -0
- package/dist/config/parsers/boolean/bool.parser.d.ts +6 -0
- package/dist/config/parsers/boolean/bool.parser.js +20 -0
- package/dist/config/parsers/boolean/bool.parser.js.map +1 -0
- package/dist/config/parsers/boolean/index.d.ts +1 -0
- package/dist/config/parsers/boolean/index.js +18 -0
- package/dist/config/parsers/boolean/index.js.map +1 -0
- package/dist/config/parsers/enum/enum.parser.d.ts +9 -0
- package/dist/config/parsers/enum/enum.parser.js +24 -0
- package/dist/config/parsers/enum/enum.parser.js.map +1 -0
- package/dist/config/parsers/enum/index.d.ts +1 -0
- package/dist/config/parsers/enum/index.js +18 -0
- package/dist/config/parsers/enum/index.js.map +1 -0
- package/dist/config/parsers/index.d.ts +10 -0
- package/dist/config/parsers/index.js +27 -0
- package/dist/config/parsers/index.js.map +1 -0
- package/dist/config/parsers/int/index.d.ts +1 -0
- package/dist/config/parsers/int/index.js +18 -0
- package/dist/config/parsers/int/index.js.map +1 -0
- package/dist/config/parsers/int/int.parser.d.ts +6 -0
- package/dist/config/parsers/int/int.parser.js +20 -0
- package/dist/config/parsers/int/int.parser.js.map +1 -0
- package/dist/config/parsers/number/index.d.ts +1 -0
- package/dist/config/parsers/number/index.js +18 -0
- package/dist/config/parsers/number/index.js.map +1 -0
- package/dist/config/parsers/number/number.parser.d.ts +6 -0
- package/dist/config/parsers/number/number.parser.js +23 -0
- package/dist/config/parsers/number/number.parser.js.map +1 -0
- package/dist/config/parsers/path/fspath.parser.d.ts +8 -0
- package/dist/config/parsers/path/fspath.parser.js +56 -0
- package/dist/config/parsers/path/fspath.parser.js.map +1 -0
- package/dist/config/parsers/path/index.d.ts +1 -0
- package/dist/config/parsers/path/index.js +18 -0
- package/dist/config/parsers/path/index.js.map +1 -0
- package/dist/config/parsers/size/index.d.ts +1 -0
- package/dist/config/parsers/size/index.js +18 -0
- package/dist/config/parsers/size/index.js.map +1 -0
- package/dist/config/parsers/size/size.parser.d.ts +7 -0
- package/dist/config/parsers/size/size.parser.js +21 -0
- package/dist/config/parsers/size/size.parser.js.map +1 -0
- package/dist/config/parsers/string/index.d.ts +1 -0
- package/dist/config/parsers/string/index.js +18 -0
- package/dist/config/parsers/string/index.js.map +1 -0
- package/dist/config/parsers/string/string.parser.d.ts +6 -0
- package/dist/config/parsers/string/string.parser.js +18 -0
- package/dist/config/parsers/string/string.parser.js.map +1 -0
- package/dist/config/parsers/timespan/index.d.ts +1 -0
- package/dist/config/parsers/timespan/index.js +18 -0
- package/dist/config/parsers/timespan/index.js.map +1 -0
- package/dist/config/parsers/timespan/timespan.parser.d.ts +7 -0
- package/dist/config/parsers/timespan/timespan.parser.js +21 -0
- package/dist/config/parsers/timespan/timespan.parser.js.map +1 -0
- package/dist/config/parsers/url/index.d.ts +1 -0
- package/dist/config/parsers/url/index.js +18 -0
- package/dist/config/parsers/url/index.js.map +1 -0
- package/dist/config/parsers/url/url.parser.d.ts +6 -0
- package/dist/config/parsers/url/url.parser.js +18 -0
- package/dist/config/parsers/url/url.parser.js.map +1 -0
- package/dist/config/reload/config-reload.events.d.ts +22 -0
- package/dist/config/reload/config-reload.events.js +19 -0
- package/dist/config/reload/config-reload.events.js.map +1 -0
- package/dist/config/reload/index.d.ts +1 -0
- package/dist/config/reload/index.js +18 -0
- package/dist/config/reload/index.js.map +1 -0
- package/dist/config/sources/base/config-source.abstract.d.ts +23 -0
- package/dist/config/sources/base/config-source.abstract.js +73 -0
- package/dist/config/sources/base/config-source.abstract.js.map +1 -0
- package/dist/config/sources/base/index.d.ts +2 -0
- package/dist/config/sources/base/index.js +19 -0
- package/dist/config/sources/base/index.js.map +1 -0
- package/dist/config/sources/base/reloadable-config-source.abstract.d.ts +12 -0
- package/dist/config/sources/base/reloadable-config-source.abstract.js +30 -0
- package/dist/config/sources/base/reloadable-config-source.abstract.js.map +1 -0
- package/dist/config/sources/config-source.decorator.d.ts +12 -0
- package/dist/config/sources/config-source.decorator.js +22 -0
- package/dist/config/sources/config-source.decorator.js.map +1 -0
- package/dist/config/sources/exceptions/config-source-di.exception.d.ts +6 -0
- package/dist/config/sources/exceptions/config-source-di.exception.js +34 -0
- package/dist/config/sources/exceptions/config-source-di.exception.js.map +1 -0
- package/dist/config/sources/exceptions/config-source.exception.d.ts +4 -0
- package/dist/config/sources/exceptions/config-source.exception.js +11 -0
- package/dist/config/sources/exceptions/config-source.exception.js.map +1 -0
- package/dist/config/sources/exceptions/index.d.ts +2 -0
- package/dist/config/sources/exceptions/index.js +19 -0
- package/dist/config/sources/exceptions/index.js.map +1 -0
- package/dist/config/sources/implementations/json-file.source.d.ts +9 -0
- package/dist/config/sources/implementations/json-file.source.js +46 -0
- package/dist/config/sources/implementations/json-file.source.js.map +1 -0
- package/dist/config/sources/implementations/relodable-json-file.source.d.ts +8 -0
- package/dist/config/sources/implementations/relodable-json-file.source.js +55 -0
- package/dist/config/sources/implementations/relodable-json-file.source.js.map +1 -0
- package/dist/config/sources/index.d.ts +3 -0
- package/dist/config/sources/index.js +20 -0
- package/dist/config/sources/index.js.map +1 -0
- package/dist/config/types.d.ts +65 -0
- package/dist/config/types.js +3 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config/vars.class.d.ts +19 -0
- package/dist/config/vars.class.js +79 -0
- package/dist/config/vars.class.js.map +1 -0
- package/dist/exceptions/base/bootstrap-exception.abstract.d.ts +15 -0
- package/dist/exceptions/base/bootstrap-exception.abstract.js +22 -0
- package/dist/exceptions/base/bootstrap-exception.abstract.js.map +1 -0
- package/dist/exceptions/base/index.d.ts +3 -0
- package/dist/exceptions/base/index.js +20 -0
- package/dist/exceptions/base/index.js.map +1 -0
- package/dist/exceptions/base/pipeline-exception.abstract.d.ts +21 -0
- package/dist/exceptions/base/pipeline-exception.abstract.js +29 -0
- package/dist/exceptions/base/pipeline-exception.abstract.js.map +1 -0
- package/dist/exceptions/base/platform-exception.absract.d.ts +48 -0
- package/dist/exceptions/base/platform-exception.absract.js +49 -0
- package/dist/exceptions/base/platform-exception.absract.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/double-init.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/double-init.exception.js +35 -0
- package/dist/exceptions/implementations/bootstrap/double-init.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/duplicate-protocol.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/duplicate-protocol.exception.js +34 -0
- package/dist/exceptions/implementations/bootstrap/duplicate-protocol.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/index.d.ts +8 -0
- package/dist/exceptions/implementations/bootstrap/index.js +25 -0
- package/dist/exceptions/implementations/bootstrap/index.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/no-http.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/no-http.exception.js +36 -0
- package/dist/exceptions/implementations/bootstrap/no-http.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/no-init.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/no-init.exception.js +35 -0
- package/dist/exceptions/implementations/bootstrap/no-init.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/no-matching-transport.exception.d.ts +5 -0
- package/dist/exceptions/implementations/bootstrap/no-matching-transport.exception.js +37 -0
- package/dist/exceptions/implementations/bootstrap/no-matching-transport.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/sequence.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/sequence.exception.js +31 -0
- package/dist/exceptions/implementations/bootstrap/sequence.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/symbol-key-decoration.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/symbol-key-decoration.exception.js +30 -0
- package/dist/exceptions/implementations/bootstrap/symbol-key-decoration.exception.js.map +1 -0
- package/dist/exceptions/implementations/bootstrap/unknown-bootstrap.exception.d.ts +4 -0
- package/dist/exceptions/implementations/bootstrap/unknown-bootstrap.exception.js +27 -0
- package/dist/exceptions/implementations/bootstrap/unknown-bootstrap.exception.js.map +1 -0
- package/dist/exceptions/implementations/index.d.ts +2 -0
- package/dist/exceptions/implementations/index.js +19 -0
- package/dist/exceptions/implementations/index.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/authentication.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/authentication.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/authentication.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/conflict.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/conflict.exception.js +36 -0
- package/dist/exceptions/implementations/pipeline/conflict.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/duplicate-entity.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/duplicate-entity.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/duplicate-entity.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/index.d.ts +9 -0
- package/dist/exceptions/implementations/pipeline/index.js +26 -0
- package/dist/exceptions/implementations/pipeline/index.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/input.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/input.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/input.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/internal.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/internal.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/internal.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/not-allowed.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/not-allowed.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/not-allowed.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/not-found.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/not-found.exception.js +35 -0
- package/dist/exceptions/implementations/pipeline/not-found.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/timeout.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/timeout.exception.js +34 -0
- package/dist/exceptions/implementations/pipeline/timeout.exception.js.map +1 -0
- package/dist/exceptions/implementations/pipeline/validation.exception.d.ts +4 -0
- package/dist/exceptions/implementations/pipeline/validation.exception.js +13 -0
- package/dist/exceptions/implementations/pipeline/validation.exception.js.map +1 -0
- package/dist/exceptions/index.d.ts +5 -0
- package/dist/exceptions/index.js +24 -0
- package/dist/exceptions/index.js.map +1 -0
- package/dist/exceptions/metadata/decorators/exception.decorator.d.ts +2 -0
- package/dist/exceptions/metadata/decorators/exception.decorator.js +13 -0
- package/dist/exceptions/metadata/decorators/exception.decorator.js.map +1 -0
- package/dist/exceptions/metadata/decorators/index.d.ts +2 -0
- package/dist/exceptions/metadata/decorators/index.js +19 -0
- package/dist/exceptions/metadata/decorators/index.js.map +1 -0
- package/dist/exceptions/metadata/decorators/throws.decorator.d.ts +3 -0
- package/dist/exceptions/metadata/decorators/throws.decorator.js +20 -0
- package/dist/exceptions/metadata/decorators/throws.decorator.js.map +1 -0
- package/dist/exceptions/metadata/exceptions.registry.d.ts +23 -0
- package/dist/exceptions/metadata/exceptions.registry.js +30 -0
- package/dist/exceptions/metadata/exceptions.registry.js.map +1 -0
- package/dist/exceptions/metadata/index.d.ts +2 -0
- package/dist/exceptions/metadata/index.js +19 -0
- package/dist/exceptions/metadata/index.js.map +1 -0
- package/dist/exceptions/types.d.ts +18 -0
- package/dist/exceptions/types.js +23 -0
- package/dist/exceptions/types.js.map +1 -0
- package/dist/exceptions/validation/exception.d.ts +4 -0
- package/dist/exceptions/validation/exception.js +13 -0
- package/dist/exceptions/validation/exception.js.map +1 -0
- package/dist/exceptions.handling/constants.d.ts +3 -0
- package/dist/exceptions.handling/constants.js +7 -0
- package/dist/exceptions.handling/constants.js.map +1 -0
- package/dist/exceptions.handling/global-exceptions.config.d.ts +4 -0
- package/dist/exceptions.handling/global-exceptions.config.js +32 -0
- package/dist/exceptions.handling/global-exceptions.config.js.map +1 -0
- package/dist/exceptions.handling/global-exceptions.filter.d.ts +17 -0
- package/dist/exceptions.handling/global-exceptions.filter.js +83 -0
- package/dist/exceptions.handling/global-exceptions.filter.js.map +1 -0
- package/dist/exceptions.handling/global-exceptions.module.d.ts +26 -0
- package/dist/exceptions.handling/global-exceptions.module.js +47 -0
- package/dist/exceptions.handling/global-exceptions.module.js.map +1 -0
- package/dist/exceptions.handling/index.d.ts +2 -0
- package/dist/exceptions.handling/index.js +19 -0
- package/dist/exceptions.handling/index.js.map +1 -0
- package/dist/exceptions.handling/types.d.ts +81 -0
- package/dist/exceptions.handling/types.js +3 -0
- package/dist/exceptions.handling/types.js.map +1 -0
- package/dist/health/exceptions/health-check.exception.d.ts +5 -0
- package/dist/health/exceptions/health-check.exception.js +24 -0
- package/dist/health/exceptions/health-check.exception.js.map +1 -0
- package/dist/health/exceptions/index.d.ts +1 -0
- package/dist/health/exceptions/index.js +18 -0
- package/dist/health/exceptions/index.js.map +1 -0
- package/dist/health/health.const.d.ts +2 -0
- package/dist/health/health.const.js +6 -0
- package/dist/health/health.const.js.map +1 -0
- package/dist/health/health.module.d.ts +5 -0
- package/dist/health/health.module.js +33 -0
- package/dist/health/health.module.js.map +1 -0
- package/dist/health/health.service.d.ts +14 -0
- package/dist/health/health.service.js +118 -0
- package/dist/health/health.service.js.map +1 -0
- package/dist/health/helpers/check-result.class.d.ts +37 -0
- package/dist/health/helpers/check-result.class.js +49 -0
- package/dist/health/helpers/check-result.class.js.map +1 -0
- package/dist/health/helpers/index.d.ts +1 -0
- package/dist/health/helpers/index.js +18 -0
- package/dist/health/helpers/index.js.map +1 -0
- package/dist/health/index.d.ts +6 -0
- package/dist/health/index.js +23 -0
- package/dist/health/index.js.map +1 -0
- package/dist/health/indicators.abstract/fs-access.indicator.d.ts +27 -0
- package/dist/health/indicators.abstract/fs-access.indicator.js +36 -0
- package/dist/health/indicators.abstract/fs-access.indicator.js.map +1 -0
- package/dist/health/indicators.abstract/index.d.ts +2 -0
- package/dist/health/indicators.abstract/index.js +19 -0
- package/dist/health/indicators.abstract/index.js.map +1 -0
- package/dist/health/indicators.abstract/ping.indicator.d.ts +21 -0
- package/dist/health/indicators.abstract/ping.indicator.js +28 -0
- package/dist/health/indicators.abstract/ping.indicator.js.map +1 -0
- package/dist/health/metadata/index.d.ts +2 -0
- package/dist/health/metadata/index.js +19 -0
- package/dist/health/metadata/index.js.map +1 -0
- package/dist/health/metadata/indicator.decorator.d.ts +5 -0
- package/dist/health/metadata/indicator.decorator.js +16 -0
- package/dist/health/metadata/indicator.decorator.js.map +1 -0
- package/dist/health/metadata/indicators.registry.d.ts +12 -0
- package/dist/health/metadata/indicators.registry.js +26 -0
- package/dist/health/metadata/indicators.registry.js.map +1 -0
- package/dist/health/types.d.ts +45 -0
- package/dist/health/types.js +3 -0
- package/dist/health/types.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/adapters/index.d.ts +1 -0
- package/dist/logging/adapters/index.js +18 -0
- package/dist/logging/adapters/index.js.map +1 -0
- package/dist/logging/adapters/nest-logger.adapter.d.ts +11 -0
- package/dist/logging/adapters/nest-logger.adapter.js +27 -0
- package/dist/logging/adapters/nest-logger.adapter.js.map +1 -0
- package/dist/logging/decorators/index.d.ts +1 -0
- package/dist/logging/decorators/index.js +18 -0
- package/dist/logging/decorators/index.js.map +1 -0
- package/dist/logging/decorators/inject-logger.decorator.d.ts +2 -0
- package/dist/logging/decorators/inject-logger.decorator.js +13 -0
- package/dist/logging/decorators/inject-logger.decorator.js.map +1 -0
- package/dist/logging/helpers.d.ts +2 -0
- package/dist/logging/helpers.js +7 -0
- package/dist/logging/helpers.js.map +1 -0
- package/dist/logging/index.d.ts +4 -0
- package/dist/logging/index.js +21 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logging.config.d.ts +6 -0
- package/dist/logging/logging.config.js +38 -0
- package/dist/logging/logging.config.js.map +1 -0
- package/dist/logging/logging.module.d.ts +10 -0
- package/dist/logging/logging.module.js +54 -0
- package/dist/logging/logging.module.js.map +1 -0
- package/dist/logging/types.d.ts +2 -0
- package/dist/logging/types.js +3 -0
- package/dist/logging/types.js.map +1 -0
- package/dist/manifest/manifest.d.ts +7 -0
- package/dist/manifest/manifest.js +23 -0
- package/dist/manifest/manifest.js.map +1 -0
- package/dist/metrics/index.d.ts +4 -0
- package/dist/metrics/index.js +27 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/metadata/decorators/index.d.ts +1 -0
- package/dist/metrics/metadata/decorators/index.js +18 -0
- package/dist/metrics/metadata/decorators/index.js.map +1 -0
- package/dist/metrics/metadata/decorators/metric.decorator.d.ts +13 -0
- package/dist/metrics/metadata/decorators/metric.decorator.js +11 -0
- package/dist/metrics/metadata/decorators/metric.decorator.js.map +1 -0
- package/dist/metrics/metadata/index.d.ts +2 -0
- package/dist/metrics/metadata/index.js +19 -0
- package/dist/metrics/metadata/index.js.map +1 -0
- package/dist/metrics/metadata/metrics.registry.d.ts +8 -0
- package/dist/metrics/metadata/metrics.registry.js +26 -0
- package/dist/metrics/metadata/metrics.registry.js.map +1 -0
- package/dist/metrics/metrics.config.d.ts +5 -0
- package/dist/metrics/metrics.config.js +36 -0
- package/dist/metrics/metrics.config.js.map +1 -0
- package/dist/metrics/metrics.module.d.ts +35 -0
- package/dist/metrics/metrics.module.js +98 -0
- package/dist/metrics/metrics.module.js.map +1 -0
- package/dist/metrics/types.d.ts +21 -0
- package/dist/metrics/types.js +12 -0
- package/dist/metrics/types.js.map +1 -0
- package/dist/noop.http-adapter.d.ts +32 -0
- package/dist/noop.http-adapter.js +100 -0
- package/dist/noop.http-adapter.js.map +1 -0
- package/dist/platform.context.d.ts +55 -0
- package/dist/platform.context.js +162 -0
- package/dist/platform.context.js.map +1 -0
- package/dist/platform.module.d.ts +8 -0
- package/dist/platform.module.js +61 -0
- package/dist/platform.module.js.map +1 -0
- package/dist/plugin/plugin.module.d.ts +5 -0
- package/dist/plugin/plugin.module.js +22 -0
- package/dist/plugin/plugin.module.js.map +1 -0
- package/dist/tracing/auto-instrumentations.config.d.ts +1 -0
- package/dist/tracing/auto-instrumentations.config.js +35 -0
- package/dist/tracing/auto-instrumentations.config.js.map +1 -0
- package/dist/tracing/constants.d.ts +5 -0
- package/dist/tracing/constants.js +10 -0
- package/dist/tracing/constants.js.map +1 -0
- package/dist/tracing/decorators/index.d.ts +2 -0
- package/dist/tracing/decorators/index.js +19 -0
- package/dist/tracing/decorators/index.js.map +1 -0
- package/dist/tracing/decorators/no-span.decorator.d.ts +5 -0
- package/dist/tracing/decorators/no-span.decorator.js +12 -0
- package/dist/tracing/decorators/no-span.decorator.js.map +1 -0
- package/dist/tracing/decorators/span.decorator.d.ts +6 -0
- package/dist/tracing/decorators/span.decorator.js +18 -0
- package/dist/tracing/decorators/span.decorator.js.map +1 -0
- package/dist/tracing/index.d.ts +1 -0
- package/dist/tracing/index.js +18 -0
- package/dist/tracing/index.js.map +1 -0
- package/dist/tracing/services/index.d.ts +3 -0
- package/dist/tracing/services/index.js +20 -0
- package/dist/tracing/services/index.js.map +1 -0
- package/dist/tracing/services/instrumentation.service.d.ts +10 -0
- package/dist/tracing/services/instrumentation.service.js +138 -0
- package/dist/tracing/services/instrumentation.service.js.map +1 -0
- package/dist/tracing/services/metadata.scanner.d.ts +11 -0
- package/dist/tracing/services/metadata.scanner.js +50 -0
- package/dist/tracing/services/metadata.scanner.js.map +1 -0
- package/dist/tracing/services/trace.injector.d.ts +12 -0
- package/dist/tracing/services/trace.injector.js +119 -0
- package/dist/tracing/services/trace.injector.js.map +1 -0
- package/dist/tracing/tracing.config.d.ts +5 -0
- package/dist/tracing/tracing.config.js +36 -0
- package/dist/tracing/tracing.config.js.map +1 -0
- package/dist/tracing/tracing.module.d.ts +22 -0
- package/dist/tracing/tracing.module.js +118 -0
- package/dist/tracing/tracing.module.js.map +1 -0
- package/dist/transport/transport.module.d.ts +8 -0
- package/dist/transport/transport.module.js +55 -0
- package/dist/transport/transport.module.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +21 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/metadata.d.ts +38 -0
- package/dist/types/metadata.js +30 -0
- package/dist/types/metadata.js.map +1 -0
- package/dist/types/options.d.ts +68 -0
- package/dist/types/options.js +3 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/plugins.d.ts +51 -0
- package/dist/types/plugins.js +6 -0
- package/dist/types/plugins.js.map +1 -0
- package/dist/types/transports.d.ts +85 -0
- package/dist/types/transports.js +11 -0
- package/dist/types/transports.js.map +1 -0
- package/package.json +53 -0
- package/src/app/platform.app.ts +52 -0
- package/src/app-metadata/app-metadata.const.ts +3 -0
- package/src/app-metadata/app-metadata.module.ts +34 -0
- package/src/app-metadata/app-name.const.ts +1 -0
- package/src/app-metadata/app-name.validator.ts +11 -0
- package/src/app-metadata/decorators/app-name.decorator.ts +5 -0
- package/src/app-metadata/decorators/index.ts +1 -0
- package/src/app-metadata/exceptions/app-name-validation.exception.ts +23 -0
- package/src/app-metadata/exceptions/index.ts +1 -0
- package/src/app-metadata/index.ts +2 -0
- package/src/config/additional-source/additional-source.initializer.ts +165 -0
- package/src/config/additional-source/additional-source.module.ts +48 -0
- package/src/config/config-reload.indicator.ts +36 -0
- package/src/config/config.abstract.ts +70 -0
- package/src/config/config.module.ts +330 -0
- package/src/config/exceptions/config-not-bootstrapped.exception.ts +15 -0
- package/src/config/exceptions/config-property-metadata-not-found.ts +9 -0
- package/src/config/exceptions/index.ts +3 -0
- package/src/config/exceptions/property.exception.ts +15 -0
- package/src/config/index.ts +10 -0
- package/src/config/metadata/config-metadata.registry.ts +76 -0
- package/src/config/metadata/decorators/config-section.decorator.ts +30 -0
- package/src/config/metadata/decorators/declare-property.decorator.ts +37 -0
- package/src/config/metadata/decorators/index.ts +4 -0
- package/src/config/metadata/decorators/inject-property.decorator.ts +29 -0
- package/src/config/metadata/decorators/property.decorator.ts +42 -0
- package/src/config/metadata/exceptions/duplicate-property.exception.ts +12 -0
- package/src/config/metadata/exceptions/duplicate-section.exception.ts +13 -0
- package/src/config/metadata/exceptions/duplicate-source.exception.ts +13 -0
- package/src/config/metadata/exceptions/index.ts +3 -0
- package/src/config/metadata/index.ts +2 -0
- package/src/config/parsers/array.parser.ts +40 -0
- package/src/config/parsers/boolean/bool.parser.ts +20 -0
- package/src/config/parsers/boolean/bool.spec.ts +4 -0
- package/src/config/parsers/boolean/index.ts +1 -0
- package/src/config/parsers/enum/enum.parser.ts +23 -0
- package/src/config/parsers/enum/enum.spec.ts +5 -0
- package/src/config/parsers/enum/index.ts +1 -0
- package/src/config/parsers/index.ts +10 -0
- package/src/config/parsers/int/index.ts +1 -0
- package/src/config/parsers/int/int.parser.ts +20 -0
- package/src/config/parsers/int/int.spec.ts +5 -0
- package/src/config/parsers/number/index.ts +1 -0
- package/src/config/parsers/number/number.parser.ts +23 -0
- package/src/config/parsers/number/number.spec.ts +5 -0
- package/src/config/parsers/path/fspath.parser.ts +65 -0
- package/src/config/parsers/path/index.ts +1 -0
- package/src/config/parsers/size/index.ts +1 -0
- package/src/config/parsers/size/size.parser.ts +22 -0
- package/src/config/parsers/size/size.spec.ts +4 -0
- package/src/config/parsers/string/index.ts +1 -0
- package/src/config/parsers/string/string.parser.ts +19 -0
- package/src/config/parsers/timespan/index.ts +1 -0
- package/src/config/parsers/timespan/timespan.parser.ts +27 -0
- package/src/config/parsers/timespan/timespan.spec.ts +4 -0
- package/src/config/parsers/url/index.ts +1 -0
- package/src/config/parsers/url/url.parser.ts +19 -0
- package/src/config/reload/config-reload.events.ts +43 -0
- package/src/config/reload/index.ts +1 -0
- package/src/config/sources/base/config-source.abstract.ts +90 -0
- package/src/config/sources/base/index.ts +2 -0
- package/src/config/sources/base/reloadable-config-source.abstract.ts +39 -0
- package/src/config/sources/config-source.decorator.ts +37 -0
- package/src/config/sources/exceptions/config-source-di.exception.ts +20 -0
- package/src/config/sources/exceptions/config-source.exception.ts +7 -0
- package/src/config/sources/exceptions/index.ts +2 -0
- package/src/config/sources/implementations/json-file.source.ts +29 -0
- package/src/config/sources/implementations/relodable-json-file.source.ts +39 -0
- package/src/config/sources/index.ts +3 -0
- package/src/config/types.ts +87 -0
- package/src/config/vars.class.ts +103 -0
- package/src/exceptions/base/bootstrap-exception.abstract.ts +20 -0
- package/src/exceptions/base/index.ts +3 -0
- package/src/exceptions/base/pipeline-exception.abstract.ts +29 -0
- package/src/exceptions/base/platform-exception.absract.ts +72 -0
- package/src/exceptions/implementations/bootstrap/double-init.exception.ts +21 -0
- package/src/exceptions/implementations/bootstrap/duplicate-protocol.exception.ts +19 -0
- package/src/exceptions/implementations/bootstrap/index.ts +8 -0
- package/src/exceptions/implementations/bootstrap/no-http.exception.ts +21 -0
- package/src/exceptions/implementations/bootstrap/no-init.exception.ts +21 -0
- package/src/exceptions/implementations/bootstrap/no-matching-transport.exception.ts +24 -0
- package/src/exceptions/implementations/bootstrap/sequence.exception.ts +16 -0
- package/src/exceptions/implementations/bootstrap/symbol-key-decoration.exception.ts +15 -0
- package/src/exceptions/implementations/bootstrap/unknown-bootstrap.exception.ts +11 -0
- package/src/exceptions/implementations/index.ts +2 -0
- package/src/exceptions/implementations/pipeline/authentication.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/conflict.exception.ts +21 -0
- package/src/exceptions/implementations/pipeline/duplicate-entity.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/index.ts +9 -0
- package/src/exceptions/implementations/pipeline/input.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/internal.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/not-allowed.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/not-found.exception.ts +20 -0
- package/src/exceptions/implementations/pipeline/timeout.exception.ts +19 -0
- package/src/exceptions/implementations/pipeline/validation.exception.ts +9 -0
- package/src/exceptions/index.ts +5 -0
- package/src/exceptions/metadata/decorators/exception.decorator.ts +10 -0
- package/src/exceptions/metadata/decorators/index.ts +2 -0
- package/src/exceptions/metadata/decorators/throws.decorator.ts +25 -0
- package/src/exceptions/metadata/exceptions.registry.ts +50 -0
- package/src/exceptions/metadata/index.ts +2 -0
- package/src/exceptions/types.ts +18 -0
- package/src/exceptions/validation/exception.ts +9 -0
- package/src/exceptions.handling/constants.ts +3 -0
- package/src/exceptions.handling/global-exceptions.config.ts +15 -0
- package/src/exceptions.handling/global-exceptions.filter.ts +81 -0
- package/src/exceptions.handling/global-exceptions.module.ts +67 -0
- package/src/exceptions.handling/index.ts +2 -0
- package/src/exceptions.handling/types.ts +88 -0
- package/src/health/exceptions/health-check.exception.ts +9 -0
- package/src/health/exceptions/index.ts +1 -0
- package/src/health/health.const.ts +2 -0
- package/src/health/health.module.ts +23 -0
- package/src/health/health.service.ts +125 -0
- package/src/health/helpers/check-result.class.ts +52 -0
- package/src/health/helpers/index.ts +1 -0
- package/src/health/index.ts +6 -0
- package/src/health/indicators.abstract/fs-access.indicator.ts +47 -0
- package/src/health/indicators.abstract/index.ts +2 -0
- package/src/health/indicators.abstract/ping.indicator.ts +36 -0
- package/src/health/metadata/index.ts +2 -0
- package/src/health/metadata/indicator.decorator.ts +25 -0
- package/src/health/metadata/indicators.registry.ts +38 -0
- package/src/health/types.ts +50 -0
- package/src/index.ts +32 -0
- package/src/logging/adapters/index.ts +1 -0
- package/src/logging/adapters/nest-logger.adapter.ts +32 -0
- package/src/logging/decorators/index.ts +1 -0
- package/src/logging/decorators/inject-logger.decorator.ts +15 -0
- package/src/logging/helpers.ts +5 -0
- package/src/logging/index.ts +4 -0
- package/src/logging/logging.config.ts +26 -0
- package/src/logging/logging.module.ts +48 -0
- package/src/logging/types.ts +3 -0
- package/src/manifest/manifest.ts +23 -0
- package/src/metrics/index.ts +4 -0
- package/src/metrics/metadata/decorators/index.ts +1 -0
- package/src/metrics/metadata/decorators/metric.decorator.ts +45 -0
- package/src/metrics/metadata/index.ts +2 -0
- package/src/metrics/metadata/metrics.registry.ts +35 -0
- package/src/metrics/metrics.config.ts +16 -0
- package/src/metrics/metrics.module.ts +100 -0
- package/src/metrics/types.ts +39 -0
- package/src/noop.http-adapter.ts +126 -0
- package/src/platform.context.ts +214 -0
- package/src/platform.module.ts +65 -0
- package/src/plugin/plugin.module.ts +24 -0
- package/src/tracing/auto-instrumentations.config.ts +35 -0
- package/src/tracing/constants.ts +6 -0
- package/src/tracing/decorators/index.ts +2 -0
- package/src/tracing/decorators/no-span.decorator.ts +10 -0
- package/src/tracing/decorators/span.decorator.ts +20 -0
- package/src/tracing/index.ts +1 -0
- package/src/tracing/services/index.ts +3 -0
- package/src/tracing/services/instrumentation.service.ts +145 -0
- package/src/tracing/services/metadata.scanner.ts +40 -0
- package/src/tracing/services/trace.injector.ts +147 -0
- package/src/tracing/tracing.config.ts +22 -0
- package/src/tracing/tracing.module.ts +120 -0
- package/src/transport/transport.module.ts +64 -0
- package/src/types/index.ts +4 -0
- package/src/types/metadata.ts +88 -0
- package/src/types/options.ts +83 -0
- package/src/types/plugins.ts +68 -0
- package/src/types/transports.ts +110 -0
- package/tsconfig.json +10 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { SELF_DECLARED_DEPS_METADATA } from '@nestjs/common/constants';
|
|
2
|
+
import type { Constructor } from '@rsdk/common';
|
|
3
|
+
|
|
4
|
+
import { APP_NAME } from '../../app-metadata/app-metadata.const';
|
|
5
|
+
import { NoInitException } from '../../exceptions';
|
|
6
|
+
import { ConfigPropertyMetadataNotFound } from '../exceptions';
|
|
7
|
+
import { isPropertyToken } from '../metadata';
|
|
8
|
+
import type { ConfigSource } from '../sources';
|
|
9
|
+
import { ConfigSourceDIException, isReloadable } from '../sources';
|
|
10
|
+
import type { RawValues } from '../types';
|
|
11
|
+
|
|
12
|
+
import type { AdditionalSourceOptions } from './additional-source.module';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Содержит логику инициализации дополнительных источников конфигурации
|
|
16
|
+
*/
|
|
17
|
+
export class AdditionalSourceInitializer {
|
|
18
|
+
/**
|
|
19
|
+
* Промис, состояние которого отражает состояние инициализации дополнительных источников конфигурации
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
private initializePromise: Promise<void> | undefined;
|
|
23
|
+
|
|
24
|
+
constructor(private options: AdditionalSourceOptions) {}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Инициализирует дополнительные источники конфигурации
|
|
28
|
+
* ATTENTION: Можно вызывать сколько угодно раз, однако результат будет идентичным в буквальном смысле,
|
|
29
|
+
*
|
|
30
|
+
* AdditionalSourceModuleInitializer.initialize() === AdditionalSourceModuleInitializer.initialize() // true
|
|
31
|
+
*
|
|
32
|
+
* Это сделано намеренно из-за того как nestjs работает с разрешением зависимостей, а именно `Promise.all`.
|
|
33
|
+
* Соответственно провайдеров конфигурации может быть много и всем им необходимо инициализировать
|
|
34
|
+
* источники, проверка на `isInitialized` очевидно создаёт неразрешимые проблемы из-за асинхронности.
|
|
35
|
+
*/
|
|
36
|
+
async initialize(): Promise<void> {
|
|
37
|
+
if (this.initializePromise) {
|
|
38
|
+
return this.initializePromise;
|
|
39
|
+
}
|
|
40
|
+
this.initializePromise = this.initializeAdditionalSources(this.options);
|
|
41
|
+
return this.initializePromise;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Initializing additional configuration sources.
|
|
46
|
+
* Loading values and merging them into the storage.
|
|
47
|
+
* NOTE: standalone properties from env can be used to
|
|
48
|
+
* configure additional sources
|
|
49
|
+
*/
|
|
50
|
+
private async initializeAdditionalSources(
|
|
51
|
+
options: AdditionalSourceOptions,
|
|
52
|
+
): Promise<void> {
|
|
53
|
+
if (!options.sources || options.sources.length === 0) {
|
|
54
|
+
options.logger.info('No additional sources configured');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const { sources, events, logger, vars } = options;
|
|
58
|
+
|
|
59
|
+
logger.info('Initializing additional configuration sources');
|
|
60
|
+
|
|
61
|
+
for (const ctor of sources) {
|
|
62
|
+
// We should restore the order to initialize for our ctor init later
|
|
63
|
+
const args = this.getConfigSourceArguments(options, ctor);
|
|
64
|
+
|
|
65
|
+
const source = new ctor(...args);
|
|
66
|
+
|
|
67
|
+
logger.info('Loading configuration from source', {
|
|
68
|
+
source: source.name,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const loaded = await source.load();
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Loading and merging data into storage
|
|
75
|
+
*/
|
|
76
|
+
const { updatedKeys } = vars.merge(loaded);
|
|
77
|
+
|
|
78
|
+
if (updatedKeys.length > 0) {
|
|
79
|
+
logger.warn(`${updatedKeys.length} values overwritten`, {
|
|
80
|
+
keys: updatedKeys,
|
|
81
|
+
source: source.name,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* In case the source is reloadable we subscribe to it's
|
|
87
|
+
* 'reload' event
|
|
88
|
+
*/
|
|
89
|
+
if (isReloadable(source)) {
|
|
90
|
+
logger.info('Setting up configuration reload', {
|
|
91
|
+
source: source.name,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
source.init();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
events.on('reload', (source: ConfigSource, newValues: RawValues) => {
|
|
99
|
+
const { createdKeys, updatedKeys } = vars.merge(newValues);
|
|
100
|
+
if (createdKeys.length > 0 || updatedKeys.length > 0) {
|
|
101
|
+
events.emit('merge', source, {
|
|
102
|
+
createdKeys,
|
|
103
|
+
updatedKeys,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
logger.info('Additional sources initialized successfully');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Returns the arguments for creating the `ConfigSource` instance
|
|
113
|
+
* @param options
|
|
114
|
+
* @param ctor
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
private getConfigSourceArguments(
|
|
118
|
+
options: AdditionalSourceOptions,
|
|
119
|
+
ctor: Constructor<ConfigSource>,
|
|
120
|
+
): unknown[] {
|
|
121
|
+
// Injectable config properties!
|
|
122
|
+
const metadata = Reflect.getMetadata(SELF_DECLARED_DEPS_METADATA, ctor) as {
|
|
123
|
+
index: number;
|
|
124
|
+
param: unknown;
|
|
125
|
+
}[];
|
|
126
|
+
|
|
127
|
+
// No metadata - no args
|
|
128
|
+
if (!metadata) {
|
|
129
|
+
return [];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const sortedMetadata = [...metadata].sort((a, b) => a.index - b.index);
|
|
133
|
+
|
|
134
|
+
const { prefix, propertyMetadata, vars } = options;
|
|
135
|
+
const injectables = new Map<unknown, unknown>().set(APP_NAME, prefix);
|
|
136
|
+
|
|
137
|
+
const args = sortedMetadata.map((x) => {
|
|
138
|
+
if (injectables.has(x.param)) {
|
|
139
|
+
return injectables.get(x.param);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
if (!isPropertyToken(x.param)) {
|
|
143
|
+
throw new ConfigSourceDIException(ctor, x.param);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const propMeta = propertyMetadata.get(x.param);
|
|
147
|
+
if (!propMeta) {
|
|
148
|
+
throw new ConfigPropertyMetadataNotFound(x.param);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const property = vars.extract(propMeta);
|
|
152
|
+
if (!property) {
|
|
153
|
+
throw new NoInitException(
|
|
154
|
+
'Config property',
|
|
155
|
+
x.param as string,
|
|
156
|
+
'You probably should add @DeclareProperty decorator to source class.',
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return property;
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
return args;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import type { Constructor } from '@rsdk/common';
|
|
3
|
+
import type { ILogger } from '@rsdk/logging';
|
|
4
|
+
|
|
5
|
+
import { ConfigReloadIndicator } from '../config-reload.indicator';
|
|
6
|
+
import type { PropertyToken } from '../metadata';
|
|
7
|
+
import type { ReloadEvents } from '../reload';
|
|
8
|
+
import type { ConfigSource } from '../sources';
|
|
9
|
+
import type { PropertyMetadata } from '../types';
|
|
10
|
+
import type { Vars } from '../vars.class';
|
|
11
|
+
|
|
12
|
+
import { AdditionalSourceInitializer } from './additional-source.initializer';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Модуль реализующий работу с `AdditionalSource` указанными в конфиге.
|
|
16
|
+
* Инициализирует все `source` в хуке `onModuleInit`
|
|
17
|
+
*/
|
|
18
|
+
export class AdditionalSourceModule {
|
|
19
|
+
static forRoot(options: AdditionalSourceOptions): DynamicModule {
|
|
20
|
+
return {
|
|
21
|
+
imports: [
|
|
22
|
+
{
|
|
23
|
+
global: true,
|
|
24
|
+
module: AdditionalSourceModule,
|
|
25
|
+
providers: [
|
|
26
|
+
{
|
|
27
|
+
provide: AdditionalSourceInitializer,
|
|
28
|
+
useValue: new AdditionalSourceInitializer(options),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
exports: [AdditionalSourceInitializer],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
providers: [ConfigReloadIndicator],
|
|
35
|
+
module: AdditionalSourceModule,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface AdditionalSourceOptions {
|
|
41
|
+
sources: Constructor<ConfigSource>[] | undefined;
|
|
42
|
+
logger: ILogger;
|
|
43
|
+
properties: Map<PropertyToken, unknown>;
|
|
44
|
+
propertyMetadata: Map<string, PropertyMetadata>;
|
|
45
|
+
vars: Vars;
|
|
46
|
+
events: ReloadEvents;
|
|
47
|
+
prefix: string;
|
|
48
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
|
|
3
|
+
import type { CheckDetails, HealthIndicator } from '../health';
|
|
4
|
+
import { CheckResult } from '../health/helpers';
|
|
5
|
+
|
|
6
|
+
import type { Config } from './config.abstract';
|
|
7
|
+
import { ReloadEvents } from './reload';
|
|
8
|
+
import type { ConfigSource } from './sources';
|
|
9
|
+
|
|
10
|
+
@Injectable()
|
|
11
|
+
export class ConfigReloadIndicator implements HealthIndicator {
|
|
12
|
+
private events = ReloadEvents.getInstance();
|
|
13
|
+
private errors = new Map<ConfigSource | Config, Error>();
|
|
14
|
+
|
|
15
|
+
constructor() {
|
|
16
|
+
this.events
|
|
17
|
+
.on('reload_failure', (source, err) => this.errors.set(source, err))
|
|
18
|
+
.on('update_failure', (config, err) => this.errors.set(config, err))
|
|
19
|
+
.on('reload', (source) => this.errors.delete(source))
|
|
20
|
+
.on('update', (config) => this.errors.delete(config));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async check(): Promise<CheckResult> {
|
|
24
|
+
if (this.errors.size === 0) {
|
|
25
|
+
return CheckResult.up({});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const details: CheckDetails = {};
|
|
29
|
+
|
|
30
|
+
for (const [key, err] of this.errors.entries()) {
|
|
31
|
+
details[key.constructor.name] = { error: err };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return CheckResult.down(details);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { intersection, isEqual } from 'lodash';
|
|
2
|
+
|
|
3
|
+
import 'reflect-metadata';
|
|
4
|
+
|
|
5
|
+
import { CONFIG_METADATA_KEY } from './metadata';
|
|
6
|
+
import { ReloadEvents } from './reload';
|
|
7
|
+
import type { PropertyMetadata, SectionMetadata } from './types';
|
|
8
|
+
import type { Vars } from './vars.class';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* It is unconventional to use raw values from process.env or somewhere
|
|
12
|
+
* else because it will not be autodocumented. Instead developer is strongly
|
|
13
|
+
* encouraged to extends this abstract class and annotate all fields with
|
|
14
|
+
* @Property() decorator providing nesessary metadata.
|
|
15
|
+
*/
|
|
16
|
+
export class Config {
|
|
17
|
+
/**
|
|
18
|
+
* Keys are prefixed and sources are added.
|
|
19
|
+
*/
|
|
20
|
+
private readonly propertiesMetadata: Record<string, PropertyMetadata>;
|
|
21
|
+
private readonly events: ReloadEvents = ReloadEvents.getInstance();
|
|
22
|
+
|
|
23
|
+
// TODO: why not to pass this.vars and event emitter?
|
|
24
|
+
constructor() {
|
|
25
|
+
const metadata = Reflect.getMetadata(
|
|
26
|
+
CONFIG_METADATA_KEY,
|
|
27
|
+
this.constructor,
|
|
28
|
+
) as SectionMetadata;
|
|
29
|
+
|
|
30
|
+
this.propertiesMetadata = metadata.properties;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
onUpdate(fn: (keys: string[]) => void): void {
|
|
34
|
+
this.events.on('update', (_: Config, updatedKeys: string[]) => {
|
|
35
|
+
const prefixedKeys = Object.keys(this.propertiesMetadata).map(
|
|
36
|
+
(x) => `${this.constructor.name}/${x}`,
|
|
37
|
+
);
|
|
38
|
+
if (intersection(prefixedKeys, updatedKeys).length > 0) {
|
|
39
|
+
fn(updatedKeys);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
read(vars: Vars): string[] {
|
|
45
|
+
const updated: string[] = [];
|
|
46
|
+
|
|
47
|
+
for (const [prop, metadata] of Object.entries(this.propertiesMetadata)) {
|
|
48
|
+
const value = (this as any)[prop];
|
|
49
|
+
const newValue = vars.extract(metadata);
|
|
50
|
+
|
|
51
|
+
// FIXME: Doesn't work with object types.
|
|
52
|
+
if (!isEqual(newValue, value)) {
|
|
53
|
+
(this as any)[prop] = newValue;
|
|
54
|
+
updated.push(`${this.constructor.name}/${prop}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return updated;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
tryUpdate(vars: Vars): void {
|
|
62
|
+
try {
|
|
63
|
+
const updated = this.read(vars);
|
|
64
|
+
|
|
65
|
+
this.events.emit('update', this, updated);
|
|
66
|
+
} catch (err: any) {
|
|
67
|
+
this.events.emit('update_failure', this, err);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import type { DynamicModule, FactoryProvider, Provider } from '@nestjs/common';
|
|
2
|
+
import { Module } from '@nestjs/common';
|
|
3
|
+
import type { Constructor } from '@rsdk/common';
|
|
4
|
+
import { dotenv } from '@rsdk/common';
|
|
5
|
+
import { LoggerFactory } from '@rsdk/logging';
|
|
6
|
+
|
|
7
|
+
import { SequenceException } from '../exceptions';
|
|
8
|
+
import type { PlatformOptions } from '../types';
|
|
9
|
+
|
|
10
|
+
import { AdditionalSourceInitializer } from './additional-source/additional-source.initializer';
|
|
11
|
+
import { AdditionalSourceModule } from './additional-source/additional-source.module';
|
|
12
|
+
import type { Config } from './config.abstract';
|
|
13
|
+
import {
|
|
14
|
+
ConfigNotBootstrappedException,
|
|
15
|
+
ConfigPropertyMetadataNotFound,
|
|
16
|
+
} from './exceptions';
|
|
17
|
+
import type { PropertyToken } from './metadata';
|
|
18
|
+
import { ConfigMetadataRegistry, getPropertyToken } from './metadata';
|
|
19
|
+
import { ReloadEvents } from './reload';
|
|
20
|
+
import type { ConfigSource } from './sources';
|
|
21
|
+
import type { ConfigValue, PropertyMetadata } from './types';
|
|
22
|
+
import { Vars } from './vars.class';
|
|
23
|
+
|
|
24
|
+
export interface ConfigModuleOptions {
|
|
25
|
+
/**
|
|
26
|
+
* By convention every configuration key should have unique prefix
|
|
27
|
+
* for current service. It is inferred from application name
|
|
28
|
+
*/
|
|
29
|
+
appName: string;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Additional asynchronous configuration sources. For example a source
|
|
33
|
+
* that loads configuration from Consul or other remote system.
|
|
34
|
+
*/
|
|
35
|
+
sources?: Constructor<ConfigSource>[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Configuration is loaded in predictable order. You should take
|
|
40
|
+
* into account chat all repeating keys will be overwritten on each step:
|
|
41
|
+
*
|
|
42
|
+
* 1. .env file if there is any
|
|
43
|
+
* 2. process environment
|
|
44
|
+
* 3. динамические source'ы (если сделать последовательно - то в порядке указания)
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
@Module({})
|
|
48
|
+
export class PlatformConfigModule {
|
|
49
|
+
private static isBootstrapped = false;
|
|
50
|
+
private static events = ReloadEvents.getInstance();
|
|
51
|
+
private static vars: Vars;
|
|
52
|
+
private static prefix: string;
|
|
53
|
+
/**
|
|
54
|
+
* Проинициализированные секции конфигов
|
|
55
|
+
* @private
|
|
56
|
+
*/
|
|
57
|
+
private static initializedConfigs = new Map<Constructor<Config>, Config>();
|
|
58
|
+
/**
|
|
59
|
+
* undefined является валидным значением по умолчанию (`defaultValue`)
|
|
60
|
+
* @private
|
|
61
|
+
*/
|
|
62
|
+
private static properties = new Map<PropertyToken, ConfigValue | undefined>();
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* We don't use class as context here because it is undefined if
|
|
66
|
+
* tsc target is ES2022
|
|
67
|
+
*/
|
|
68
|
+
private static logger = LoggerFactory.create('PlatformConfigModule');
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Метадата о необходимых приложению значениях конфигурации
|
|
72
|
+
* Зачем храним?
|
|
73
|
+
* Потому что пайплайн такой:
|
|
74
|
+
* 1. Собираем данные о том какие поля нам нужны
|
|
75
|
+
* 2. Приложение запрашивает поле из конфигурации
|
|
76
|
+
* 3. Ищем метаданные
|
|
77
|
+
* 4. По метаданным вытягиваем значение
|
|
78
|
+
* 5. Отдаём значение
|
|
79
|
+
*
|
|
80
|
+
* Это важно так как позволяет прозрачным образом контролировать этот процесс и инициализировать поля в тот момент когда они потребуются
|
|
81
|
+
* А не в тот момент когда их объявили
|
|
82
|
+
* Основной кейс, где это применяется - тесты
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
private static propertyMetadata = new Map<string, PropertyMetadata>();
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* This method should be invoked BEFORE bootstrapping nest application.
|
|
89
|
+
*
|
|
90
|
+
* It takes 2 main actions:
|
|
91
|
+
* - load environment variables
|
|
92
|
+
*
|
|
93
|
+
* - instantiates all configuration initializedConfig (classes marked with
|
|
94
|
+
* @ConfigSection() decorator) and adds them into internal storage
|
|
95
|
+
*
|
|
96
|
+
* If any of these actions fails - application should exit.
|
|
97
|
+
*
|
|
98
|
+
* NOTE: This method should be invoked before any other interaction
|
|
99
|
+
* with ConfigurationModule
|
|
100
|
+
*
|
|
101
|
+
* ATTENTION: not load values from additional source
|
|
102
|
+
*/
|
|
103
|
+
static bootstrap(options?: ConfigModuleOptions): void {
|
|
104
|
+
if (this.isBootstrapped) {
|
|
105
|
+
throw new SequenceException("Can't bootstrap ConfigurationModule twice");
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
this.prefix = options?.appName ?? '';
|
|
109
|
+
|
|
110
|
+
if (this.prefix) {
|
|
111
|
+
this.logger.info('Setting configuration keys prefix', {
|
|
112
|
+
prefix: this.prefix,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this.vars = new Vars(this.prefix);
|
|
117
|
+
|
|
118
|
+
this.readEnvironment();
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Reading and validating standalone properties from env.
|
|
122
|
+
*
|
|
123
|
+
* NOTE: Splitting extraction if standalone properties into 2 phases
|
|
124
|
+
* is necessary, some configuration sources can need something
|
|
125
|
+
* from env to be instatiated.
|
|
126
|
+
*/
|
|
127
|
+
const { properties } = ConfigMetadataRegistry.getMetadata();
|
|
128
|
+
|
|
129
|
+
this.extractStandaloneProperties(properties, 'expectedInEnv');
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* NOTE: That properties from .env already loaded.
|
|
133
|
+
* Now loading ones from other sources
|
|
134
|
+
*/
|
|
135
|
+
this.extractStandaloneProperties(properties, 'others');
|
|
136
|
+
|
|
137
|
+
this.isBootstrapped = true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Use this method to imports specific configuration property
|
|
142
|
+
* into given module
|
|
143
|
+
*
|
|
144
|
+
* @param alias It's not so easy to use plain property key because
|
|
145
|
+
* of prefix and source key issues. That's why we use aliases. Specify
|
|
146
|
+
* the same string that was used to define property in
|
|
147
|
+
* @Property() or @ExtraEnv() decorator.
|
|
148
|
+
*
|
|
149
|
+
* @returns DynamicModule
|
|
150
|
+
*/
|
|
151
|
+
static forProperty(alias: string): DynamicModule {
|
|
152
|
+
const token = getPropertyToken(alias);
|
|
153
|
+
const provider = this.getPropertyProvider(token);
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
module: PlatformConfigModule,
|
|
157
|
+
providers: [provider],
|
|
158
|
+
exports: [provider],
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Use this method to import specified configuration section
|
|
164
|
+
* into given module
|
|
165
|
+
* @param ctor Pass constructor of configuration section class
|
|
166
|
+
* @returns DynamicModule
|
|
167
|
+
*/
|
|
168
|
+
static forFeature(ctor: Constructor<Config>): DynamicModule {
|
|
169
|
+
/**
|
|
170
|
+
* Factory providers are used because at the point of time when
|
|
171
|
+
* forFeature() is executed Config instances don't yet exist
|
|
172
|
+
*/
|
|
173
|
+
const provider: FactoryProvider = {
|
|
174
|
+
inject: [{ optional: true, token: AdditionalSourceInitializer }],
|
|
175
|
+
provide: ctor,
|
|
176
|
+
useFactory: async (
|
|
177
|
+
additionalSourceModuleInitializer?: AdditionalSourceInitializer,
|
|
178
|
+
) => {
|
|
179
|
+
/**
|
|
180
|
+
* Да, каждый раз вызываем метод `initialize` более подробно почему так - смотри в `JSDoc` метода
|
|
181
|
+
*/
|
|
182
|
+
await additionalSourceModuleInitializer?.initialize();
|
|
183
|
+
return this.resolve(ctor);
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
module: PlatformConfigModule,
|
|
189
|
+
providers: [provider],
|
|
190
|
+
|
|
191
|
+
exports: [provider],
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
static forRoot(options: PlatformOptions): DynamicModule {
|
|
196
|
+
const providers: Provider[] = [];
|
|
197
|
+
const imports: (Promise<DynamicModule> | DynamicModule)[] = [];
|
|
198
|
+
|
|
199
|
+
if (options.config?.sources) {
|
|
200
|
+
imports.push(
|
|
201
|
+
// TODO: Эти опции в идеале добавить в сам контейнер и использовать их везде
|
|
202
|
+
AdditionalSourceModule.forRoot({
|
|
203
|
+
sources: options.config?.sources,
|
|
204
|
+
logger: this.logger,
|
|
205
|
+
properties: this.properties,
|
|
206
|
+
vars: this.vars,
|
|
207
|
+
events: this.events,
|
|
208
|
+
prefix: this.prefix,
|
|
209
|
+
propertyMetadata: this.propertyMetadata,
|
|
210
|
+
}),
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return {
|
|
215
|
+
imports,
|
|
216
|
+
module: PlatformConfigModule,
|
|
217
|
+
providers,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Extracting specific instance of configuration section by
|
|
223
|
+
* its class reference. Throws error if called before .bootstrap()
|
|
224
|
+
*
|
|
225
|
+
* ATTENTION: Конфиг будет разрешен с доступными на данный момент переменными,
|
|
226
|
+
* то есть если дополнительные источники конфигурации ещё не были проинициализированы,
|
|
227
|
+
* они не будут учтены в разрешении конфигурации.
|
|
228
|
+
*
|
|
229
|
+
* @param ctor Pass constructor of configuration section class
|
|
230
|
+
* @returns T
|
|
231
|
+
*/
|
|
232
|
+
static resolve<T extends Config>(ctor: Constructor<T>): T {
|
|
233
|
+
/**
|
|
234
|
+
* Автор уверен, что здесь не стоит делать bootstrap так как это разные зоны ответственности
|
|
235
|
+
*/
|
|
236
|
+
if (!this.isBootstrapped) {
|
|
237
|
+
throw new ConfigNotBootstrappedException();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const instance = this.initializedConfigs.get(ctor);
|
|
241
|
+
if (!instance) {
|
|
242
|
+
const instantiateSection = this.instantiateSection(ctor);
|
|
243
|
+
|
|
244
|
+
this.initializedConfigs.set(ctor, instantiateSection);
|
|
245
|
+
return instantiateSection;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// We know exactly it is T
|
|
249
|
+
return instance as T;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
private static getPropertyProvider(
|
|
253
|
+
token: `STANDALONE_CONFIG_PROPERTY_${string}`,
|
|
254
|
+
): FactoryProvider<ConfigValue | undefined> {
|
|
255
|
+
return {
|
|
256
|
+
inject: [{ optional: true, token: AdditionalSourceInitializer }],
|
|
257
|
+
provide: token,
|
|
258
|
+
useFactory: async (
|
|
259
|
+
additionalSourceModuleInitializer?: AdditionalSourceInitializer,
|
|
260
|
+
): Promise<ConfigValue | undefined> => {
|
|
261
|
+
await additionalSourceModuleInitializer?.initialize();
|
|
262
|
+
if (this.properties.has(token)) {
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
264
|
+
return this.properties.get(token)!;
|
|
265
|
+
}
|
|
266
|
+
const propMeta = this.propertyMetadata.get(token);
|
|
267
|
+
if (!propMeta) {
|
|
268
|
+
throw new ConfigPropertyMetadataNotFound(token);
|
|
269
|
+
}
|
|
270
|
+
const value = this.vars.extract(propMeta);
|
|
271
|
+
|
|
272
|
+
this.properties.set(token, value);
|
|
273
|
+
return value;
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
private static readEnvironment(): void {
|
|
279
|
+
this.logger.info('Loading variables from .env file if exists');
|
|
280
|
+
dotenv.config();
|
|
281
|
+
|
|
282
|
+
this.logger.info('Initializing raw parameters storage');
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Copying parameters from process.env, skipping entries
|
|
286
|
+
* for which value is undefined (not sure it's possible,
|
|
287
|
+
* but @types/node says it is).
|
|
288
|
+
*/
|
|
289
|
+
|
|
290
|
+
for (const [key, value] of Object.entries(process.env)) {
|
|
291
|
+
if (value !== undefined) {
|
|
292
|
+
this.vars.set(key, value);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
private static extractStandaloneProperties(
|
|
298
|
+
properties: Map<string, PropertyMetadata>,
|
|
299
|
+
subset: 'expectedInEnv' | 'others',
|
|
300
|
+
): void {
|
|
301
|
+
for (const [alias, metadata] of properties.entries()) {
|
|
302
|
+
if (subset === 'expectedInEnv' && !metadata.expectedInEnv) {
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
this.propertyMetadata.set(getPropertyToken(alias), metadata);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Инициализирует инстанс секции конфига
|
|
312
|
+
* ATTENTION: не проверяет есть ли ещё проинициализированные, будьте внимательны во избежание неожиданного поведение
|
|
313
|
+
* @param ctor
|
|
314
|
+
* @private
|
|
315
|
+
*/
|
|
316
|
+
private static instantiateSection<T extends Config>(ctor: Constructor<T>): T {
|
|
317
|
+
const instance = new ctor();
|
|
318
|
+
|
|
319
|
+
this.logger.debug('Initializing configuration section instance', {
|
|
320
|
+
ctor: ctor.name,
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
this.events.on('merge', () => {
|
|
324
|
+
instance.tryUpdate(this.vars);
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
instance.read(this.vars);
|
|
328
|
+
return instance;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { text } from '@rsdk/common';
|
|
2
|
+
|
|
3
|
+
import { BootstrapException, Exception } from '../../exceptions';
|
|
4
|
+
|
|
5
|
+
@Exception({
|
|
6
|
+
description: text`
|
|
7
|
+
Occures when something is calling PlatformConfigModule functionality
|
|
8
|
+
when it is not yet bootstrapped.
|
|
9
|
+
`,
|
|
10
|
+
})
|
|
11
|
+
export class ConfigNotBootstrappedException extends BootstrapException {
|
|
12
|
+
constructor() {
|
|
13
|
+
super('Configuration module is not bootstrapped!');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { InternalException } from '../../exceptions';
|
|
2
|
+
|
|
3
|
+
export class ConfigPropertyMetadataNotFound extends InternalException {
|
|
4
|
+
constructor(configPropertyToken: string) {
|
|
5
|
+
super(`Metadata for config property ${configPropertyToken} not found`, {
|
|
6
|
+
details: configPropertyToken,
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PlatformException } from '../../exceptions';
|
|
2
|
+
|
|
3
|
+
export class PropertyException extends PlatformException {
|
|
4
|
+
constructor(property: string, msg: string) {
|
|
5
|
+
super('CONFIG:PROPERTY', msg, {
|
|
6
|
+
details: {
|
|
7
|
+
property,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static fromError(err: any, key: string): PropertyException {
|
|
13
|
+
return new PropertyException(key, err.message || 'UNKNOWN ERROR');
|
|
14
|
+
}
|
|
15
|
+
}
|