@herrromich/az-functions 1.0.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/LICENSE +21 -0
- package/README.md +830 -0
- package/coverage/cobertura-coverage.xml +3482 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/context/forked-invocation-context.ts.html +127 -0
- package/coverage/lcov-report/context/index.html +191 -0
- package/coverage/lcov-report/context/index.ts.html +97 -0
- package/coverage/lcov-report/context/platform-context.manager.ts.html +193 -0
- package/coverage/lcov-report/context/platform-context.model.ts.html +262 -0
- package/coverage/lcov-report/context/platform-context.provider.ts.html +196 -0
- package/coverage/lcov-report/context/platform.execution.context.ts.html +217 -0
- package/coverage/lcov-report/context/wrapped-invocation-context.ts.html +163 -0
- package/coverage/lcov-report/event-hub-handler/azure-event-hub-trigger.model.ts.html +187 -0
- package/coverage/lcov-report/event-hub-handler/azure-event-hub-trigger.service.ts.html +760 -0
- package/coverage/lcov-report/event-hub-handler/decorators/decorators.model.ts.html +292 -0
- package/coverage/lcov-report/event-hub-handler/decorators/decorators.ts.html +778 -0
- package/coverage/lcov-report/event-hub-handler/decorators/index.html +146 -0
- package/coverage/lcov-report/event-hub-handler/decorators/index.ts.html +91 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handle-method-args-metadata.service.ts.html +130 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handler-metadata.reader.ts.html +199 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handler-registration.service.ts.html +220 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handler.factory.ts.html +283 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handler.model.ts.html +421 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-handler.provider.ts.html +187 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-trigger-support.factory.ts.html +787 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-trigger-support.service.ts.html +829 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-trigger.model.ts.html +193 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-trigger.service.ts.html +859 -0
- package/coverage/lcov-report/event-hub-handler/event-hub-triggers-registration.service.ts.html +307 -0
- package/coverage/lcov-report/event-hub-handler/index.html +221 -0
- package/coverage/lcov-report/event-hub-handler/index.ts.html +142 -0
- package/coverage/lcov-report/eventhub-handler/decorators/decorators.model.ts.html +277 -0
- package/coverage/lcov-report/eventhub-handler/decorators/decorators.ts.html +679 -0
- package/coverage/lcov-report/eventhub-handler/decorators/index.html +131 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-handler-metadata.reader.ts.html +196 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-handler-registration.service.ts.html +220 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-handler.factory.ts.html +193 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-handler.model.ts.html +406 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-trigger.model.ts.html +187 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-trigger.service.ts.html +760 -0
- package/coverage/lcov-report/eventhub-handler/eventhub-triggers-registration.service.ts.html +304 -0
- package/coverage/lcov-report/eventhub-handler/index.html +206 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/forked-invocation-context.ts.html +127 -0
- package/coverage/lcov-report/function-handler-metadata.reader.ts.html +172 -0
- package/coverage/lcov-report/http-controller/authentication.provider.ts.html +481 -0
- package/coverage/lcov-report/http-controller/authenticator.provider.ts.html +460 -0
- package/coverage/lcov-report/http-controller/azure-http-trigger.service.ts.html +1045 -0
- package/coverage/lcov-report/http-controller/decorators/decorators.model.ts.html +388 -0
- package/coverage/lcov-report/http-controller/decorators/decorators.ts.html +1627 -0
- package/coverage/lcov-report/http-controller/decorators/index.html +146 -0
- package/coverage/lcov-report/http-controller/decorators/index.ts.html +94 -0
- package/coverage/lcov-report/http-controller/http-controller-metadata.reader.ts.html +271 -0
- package/coverage/lcov-report/http-controller/http-controller-metadata.service.ts.html +130 -0
- package/coverage/lcov-report/http-controller/http-controller-platform.model.ts.html +187 -0
- package/coverage/lcov-report/http-controller/http-controller-registration.service.ts.html +241 -0
- package/coverage/lcov-report/http-controller/http-controller.model.ts.html +745 -0
- package/coverage/lcov-report/http-controller/http-handler-support.factory.ts.html +499 -0
- package/coverage/lcov-report/http-controller/http-handler.factory.ts.html +415 -0
- package/coverage/lcov-report/http-controller/http-operation-registration.service.ts.html +328 -0
- package/coverage/lcov-report/http-controller/http-operations-registration.service.ts.html +328 -0
- package/coverage/lcov-report/http-controller/http-request-arg-provider.factory.ts.html +580 -0
- package/coverage/lcov-report/http-controller/http-request-handler.provider.ts.html +388 -0
- package/coverage/lcov-report/http-controller/http-response-processor.factory.ts.html +316 -0
- package/coverage/lcov-report/http-controller/index.html +311 -0
- package/coverage/lcov-report/http-controller/index.ts.html +226 -0
- package/coverage/lcov-report/http-controller/open-api-definition.service.ts.html +568 -0
- package/coverage/lcov-report/http-controller/open-api-metadata.service.ts.html +373 -0
- package/coverage/lcov-report/http-controller/open-api-print.service.ts.html +232 -0
- package/coverage/lcov-report/http-controller/open-api-registration.service.ts.html +220 -0
- package/coverage/lcov-report/http-controller/rest-open-api.regstry.ts.html +262 -0
- package/coverage/lcov-report/http-controller/security/authentication-service.factory.ts.html +280 -0
- package/coverage/lcov-report/http-controller/security/authentication-service.ts.html +115 -0
- package/coverage/lcov-report/http-controller/security/authenticator.provider.ts.html +799 -0
- package/coverage/lcov-report/http-controller/security/bearer-security-authentication.service.ts.html +133 -0
- package/coverage/lcov-report/http-controller/security/index.html +206 -0
- package/coverage/lcov-report/http-controller/security/index.ts.html +94 -0
- package/coverage/lcov-report/http-controller/security/model.ts.html +133 -0
- package/coverage/lcov-report/http-controller/security/operation-authentication.resolver.ts.html +418 -0
- package/coverage/lcov-report/http-controller/security/principal-merge.service.ts.html +163 -0
- package/coverage/lcov-report/http-controller/security/strict-principal-merge.servce.ts.html +154 -0
- package/coverage/lcov-report/http-controller/swagger-handling.service.ts.html +463 -0
- package/coverage/lcov-report/index.html +281 -0
- package/coverage/lcov-report/init.ts.html +97 -0
- package/coverage/lcov-report/ioc-container.utils.ts.html +100 -0
- package/coverage/lcov-report/logger/azure-log-transport.service.ts.html +433 -0
- package/coverage/lcov-report/logger/bindings.ts.html +253 -0
- package/coverage/lcov-report/logger/index.html +221 -0
- package/coverage/lcov-report/logger/index.ts.html +163 -0
- package/coverage/lcov-report/logger/log-level.service.ts.html +127 -0
- package/coverage/lcov-report/logger/log-transport.service.ts.html +571 -0
- package/coverage/lcov-report/logger/logger-factory.provider.ts.html +142 -0
- package/coverage/lcov-report/logger/logger.factory.ts.html +172 -0
- package/coverage/lcov-report/logger/logger.model.ts.html +868 -0
- package/coverage/lcov-report/logger/logger.utils.ts.html +877 -0
- package/coverage/lcov-report/logger/model.ts.html +172 -0
- package/coverage/lcov-report/logger/otel.logger.ts.html +358 -0
- package/coverage/lcov-report/logger/platform.logger.ts.html +229 -0
- package/coverage/lcov-report/logger/trie-search.service.ts.html +616 -0
- package/coverage/lcov-report/platform/azure-platform.ts.html +256 -0
- package/coverage/lcov-report/platform/index.html +176 -0
- package/coverage/lcov-report/platform/index.ts.html +139 -0
- package/coverage/lcov-report/platform/platform-component-metadata.service.ts.html +115 -0
- package/coverage/lcov-report/platform/register-function.factory.ts.html +145 -0
- package/coverage/lcov-report/platform/register-trigger-handler.factory.ts.html +214 -0
- package/coverage/lcov-report/platform/security-context.ts.html +127 -0
- package/coverage/lcov-report/platform/startup.service.ts.html +106 -0
- package/coverage/lcov-report/platform/system-logger-name.provider.ts.html +145 -0
- package/coverage/lcov-report/platform/system.container.ts.html +169 -0
- package/coverage/lcov-report/platform-context.model.ts.html +124 -0
- package/coverage/lcov-report/platform.logger.ts.html +316 -0
- package/coverage/lcov-report/platform.model.ts.html +292 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/security/index.html +146 -0
- package/coverage/lcov-report/security/index.ts.html +91 -0
- package/coverage/lcov-report/security/security-context.ts.html +130 -0
- package/coverage/lcov-report/security/security.model.ts.html +169 -0
- package/coverage/lcov-report/shared/all-settled.util.ts.html +118 -0
- package/coverage/lcov-report/shared/decorators/decorators.model.ts.html +136 -0
- package/coverage/lcov-report/shared/decorators/decorators.ts.html +346 -0
- package/coverage/lcov-report/shared/decorators/index.html +146 -0
- package/coverage/lcov-report/shared/decorators/index.ts.html +91 -0
- package/coverage/lcov-report/shared/function-handler-metadata.reader.ts.html +172 -0
- package/coverage/lcov-report/shared/index.html +176 -0
- package/coverage/lcov-report/shared/index.ts.html +133 -0
- package/coverage/lcov-report/shared/ioc-container.utils.ts.html +115 -0
- package/coverage/lcov-report/shared/platform-context-local-storage.ts.html +133 -0
- package/coverage/lcov-report/shared/platform-context.manager.ts.html +253 -0
- package/coverage/lcov-report/shared/platform.context.provider.ts.html +136 -0
- package/coverage/lcov-report/shared/platform.model.ts.html +298 -0
- package/coverage/lcov-report/shared/security.model.ts.html +142 -0
- package/coverage/lcov-report/shared/trie-search.service.ts.html +337 -0
- package/coverage/lcov-report/shared/trigger-handler-metadata.reader.ts.html +166 -0
- package/coverage/lcov-report/shared/zod-parser-wrapper.service.ts.html +217 -0
- package/coverage/lcov-report/shared/zod-parser-wrapper.ts.html +232 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/context/index.html +191 -0
- package/coverage/lcov-report/src/context/index.ts.html +97 -0
- package/coverage/lcov-report/src/context/platform-context.manager.ts.html +193 -0
- package/coverage/lcov-report/src/context/platform-context.model.ts.html +262 -0
- package/coverage/lcov-report/src/context/platform-context.provider.ts.html +196 -0
- package/coverage/lcov-report/src/context/platform.execution.context.ts.html +217 -0
- package/coverage/lcov-report/src/context/wrapped-invocation-context.ts.html +163 -0
- package/coverage/lcov-report/src/event-hub-handler/azure-event-hub-trigger.model.ts.html +187 -0
- package/coverage/lcov-report/src/event-hub-handler/azure-event-hub-trigger.service.ts.html +769 -0
- package/coverage/lcov-report/src/event-hub-handler/decorators/decorators.model.ts.html +313 -0
- package/coverage/lcov-report/src/event-hub-handler/decorators/decorators.ts.html +778 -0
- package/coverage/lcov-report/src/event-hub-handler/decorators/index.html +146 -0
- package/coverage/lcov-report/src/event-hub-handler/decorators/index.ts.html +91 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handle-method-args-metadata.service.ts.html +130 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handler-metadata.reader.ts.html +199 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handler-registration.service.ts.html +220 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handler.factory.ts.html +283 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handler.model.ts.html +421 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-handler.provider.ts.html +187 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-trigger-support.factory.ts.html +787 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-trigger-support.service.ts.html +832 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-trigger.model.ts.html +193 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-trigger.service.ts.html +859 -0
- package/coverage/lcov-report/src/event-hub-handler/event-hub-triggers-registration.service.ts.html +307 -0
- package/coverage/lcov-report/src/event-hub-handler/index.html +221 -0
- package/coverage/lcov-report/src/event-hub-handler/index.ts.html +142 -0
- package/coverage/lcov-report/src/framework.container.ts.html +157 -0
- package/coverage/lcov-report/src/http-controller/authentication.provider.ts.html +481 -0
- package/coverage/lcov-report/src/http-controller/authenticator.provider.ts.html +460 -0
- package/coverage/lcov-report/src/http-controller/azure-http-trigger.service.ts.html +865 -0
- package/coverage/lcov-report/src/http-controller/decorators/decorators.model.ts.html +553 -0
- package/coverage/lcov-report/src/http-controller/decorators/decorators.ts.html +1633 -0
- package/coverage/lcov-report/src/http-controller/decorators/index.html +146 -0
- package/coverage/lcov-report/src/http-controller/decorators/index.ts.html +94 -0
- package/coverage/lcov-report/src/http-controller/http-controller-metadata.reader.ts.html +271 -0
- package/coverage/lcov-report/src/http-controller/http-controller-metadata.service.ts.html +121 -0
- package/coverage/lcov-report/src/http-controller/http-controller-platform.model.ts.html +187 -0
- package/coverage/lcov-report/src/http-controller/http-controller-registration.service.ts.html +241 -0
- package/coverage/lcov-report/src/http-controller/http-controller.model.ts.html +784 -0
- package/coverage/lcov-report/src/http-controller/http-handler-support.factory.ts.html +481 -0
- package/coverage/lcov-report/src/http-controller/http-handler.factory.ts.html +406 -0
- package/coverage/lcov-report/src/http-controller/http-operation-registration.service.ts.html +328 -0
- package/coverage/lcov-report/src/http-controller/http-operations-registration.service.ts.html +328 -0
- package/coverage/lcov-report/src/http-controller/http-request-arg-provider.factory.ts.html +580 -0
- package/coverage/lcov-report/src/http-controller/http-request-handler.provider.ts.html +388 -0
- package/coverage/lcov-report/src/http-controller/http-response-processor.factory.ts.html +316 -0
- package/coverage/lcov-report/src/http-controller/index.html +311 -0
- package/coverage/lcov-report/src/http-controller/index.ts.html +226 -0
- package/coverage/lcov-report/src/http-controller/open-api-definition.service.ts.html +550 -0
- package/coverage/lcov-report/src/http-controller/open-api-metadata.service.ts.html +373 -0
- package/coverage/lcov-report/src/http-controller/open-api-print.service.ts.html +232 -0
- package/coverage/lcov-report/src/http-controller/open-api-registration.service.ts.html +220 -0
- package/coverage/lcov-report/src/http-controller/rest-open-api.regstry.ts.html +262 -0
- package/coverage/lcov-report/src/http-controller/security/authentication-service.factory.ts.html +280 -0
- package/coverage/lcov-report/src/http-controller/security/authentication-service.ts.html +139 -0
- package/coverage/lcov-report/src/http-controller/security/authenticator.provider.ts.html +799 -0
- package/coverage/lcov-report/src/http-controller/security/bearer-security-authentication.service.ts.html +133 -0
- package/coverage/lcov-report/src/http-controller/security/index.html +206 -0
- package/coverage/lcov-report/src/http-controller/security/index.ts.html +94 -0
- package/coverage/lcov-report/src/http-controller/security/model.ts.html +133 -0
- package/coverage/lcov-report/src/http-controller/security/operation-authentication.resolver.ts.html +418 -0
- package/coverage/lcov-report/src/http-controller/security/principal-merge.service.ts.html +163 -0
- package/coverage/lcov-report/src/http-controller/security/strict-principal-merge.servce.ts.html +154 -0
- package/coverage/lcov-report/src/http-controller/swagger-handling.service.ts.html +463 -0
- package/coverage/lcov-report/src/index.html +161 -0
- package/coverage/lcov-report/src/init.ts.html +97 -0
- package/coverage/lcov-report/src/logger/azure-log-transport.service.ts.html +433 -0
- package/coverage/lcov-report/src/logger/bindings.ts.html +253 -0
- package/coverage/lcov-report/src/logger/index.html +221 -0
- package/coverage/lcov-report/src/logger/index.ts.html +163 -0
- package/coverage/lcov-report/src/logger/log-level.service.ts.html +127 -0
- package/coverage/lcov-report/src/logger/log-transport.service.ts.html +571 -0
- package/coverage/lcov-report/src/logger/logger-factory.provider.ts.html +142 -0
- package/coverage/lcov-report/src/logger/logger.factory.ts.html +172 -0
- package/coverage/lcov-report/src/logger/logger.model.ts.html +868 -0
- package/coverage/lcov-report/src/logger/logger.utils.ts.html +877 -0
- package/coverage/lcov-report/src/logger/otel.logger.ts.html +358 -0
- package/coverage/lcov-report/src/logger/platform.logger.ts.html +229 -0
- package/coverage/lcov-report/src/logger/trie-search.service.ts.html +616 -0
- package/coverage/lcov-report/src/middleware.ts.html +232 -0
- package/coverage/lcov-report/src/platform/azure-platform.ts.html +256 -0
- package/coverage/lcov-report/src/platform/index.html +176 -0
- package/coverage/lcov-report/src/platform/index.ts.html +139 -0
- package/coverage/lcov-report/src/platform/platform-component-metadata.service.ts.html +115 -0
- package/coverage/lcov-report/src/platform/register-function.factory.ts.html +145 -0
- package/coverage/lcov-report/src/platform/register-trigger-handler.factory.ts.html +214 -0
- package/coverage/lcov-report/src/platform/security-context.ts.html +127 -0
- package/coverage/lcov-report/src/platform/startup.service.ts.html +202 -0
- package/coverage/lcov-report/src/platform/system-logger-name.provider.ts.html +145 -0
- package/coverage/lcov-report/src/platform/system.container.ts.html +172 -0
- package/coverage/lcov-report/src/platform.container.ts.html +148 -0
- package/coverage/lcov-report/src/security/index.html +146 -0
- package/coverage/lcov-report/src/security/index.ts.html +91 -0
- package/coverage/lcov-report/src/security/security-context.ts.html +175 -0
- package/coverage/lcov-report/src/security/security.model.ts.html +223 -0
- package/coverage/lcov-report/src/shared/decorators/decorators.model.ts.html +136 -0
- package/coverage/lcov-report/src/shared/decorators/decorators.ts.html +346 -0
- package/coverage/lcov-report/src/shared/decorators/index.html +146 -0
- package/coverage/lcov-report/src/shared/decorators/index.ts.html +91 -0
- package/coverage/lcov-report/src/shared/index.html +176 -0
- package/coverage/lcov-report/src/shared/index.ts.html +133 -0
- package/coverage/lcov-report/src/shared/ioc-container.utils.ts.html +115 -0
- package/coverage/lcov-report/src/shared/platform-context-local-storage.ts.html +133 -0
- package/coverage/lcov-report/src/shared/platform.model.ts.html +298 -0
- package/coverage/lcov-report/src/shared/security.model.ts.html +139 -0
- package/coverage/lcov-report/src/shared/trie-search.service.ts.html +337 -0
- package/coverage/lcov-report/src/shared/trigger-handler-metadata.reader.ts.html +166 -0
- package/coverage/lcov-report/src/shared/zod-parser-wrapper.ts.html +232 -0
- package/coverage/lcov-report/test/index.html +116 -0
- package/coverage/lcov-report/test/utils.ts.html +100 -0
- package/coverage/lcov-report/test-utils/index.html +116 -0
- package/coverage/lcov-report/test-utils/utils.ts.html +100 -0
- package/coverage/lcov-report/trie-search.service.ts.html +469 -0
- package/coverage/lcov-report/trigger-handler-metadata.reader.ts.html +187 -0
- package/coverage/lcov-report/wrapped-invocation-context.ts.html +163 -0
- package/coverage/lcov-report/zod-parser-wrapper.ts.html +232 -0
- package/coverage/lcov.info +3220 -0
- package/dist/assets/swagger-ui/LICENSE +202 -0
- package/dist/assets/swagger-ui/NOTICE +2 -0
- package/dist/assets/swagger-ui/README.md +40 -0
- package/dist/assets/swagger-ui/absolute-path.js +1 -0
- package/dist/assets/swagger-ui/favicon-16x16.png +0 -0
- package/dist/assets/swagger-ui/favicon-32x32.png +0 -0
- package/dist/assets/swagger-ui/index.css +16 -0
- package/dist/assets/swagger-ui/index.html +19 -0
- package/dist/assets/swagger-ui/index.js +1 -0
- package/dist/assets/swagger-ui/log.bundle-sizes.swagger-ui.txt +114 -0
- package/dist/assets/swagger-ui/log.es-bundle-core-sizes.swagger-ui.txt +14 -0
- package/dist/assets/swagger-ui/log.es-bundle-sizes.swagger-ui.txt +114 -0
- package/dist/assets/swagger-ui/oauth2-redirect.html +6 -0
- package/dist/assets/swagger-ui/oauth2-redirect.js +1 -0
- package/dist/assets/swagger-ui/package.json +20 -0
- package/dist/assets/swagger-ui/swagger-initializer.js +1 -0
- package/dist/assets/swagger-ui/swagger-ui-bundle.js +2 -0
- package/dist/assets/swagger-ui/swagger-ui-bundle.js.LICENSE.txt +106 -0
- package/dist/assets/swagger-ui/swagger-ui-bundle.js.map +1 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle-core.js +2 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle-core.js.LICENSE.txt +35 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle-core.js.map +1 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle.js +2 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle.js.LICENSE.txt +106 -0
- package/dist/assets/swagger-ui/swagger-ui-es-bundle.js.map +1 -0
- package/dist/assets/swagger-ui/swagger-ui-standalone-preset.js +2 -0
- package/dist/assets/swagger-ui/swagger-ui-standalone-preset.js.LICENSE.txt +22 -0
- package/dist/assets/swagger-ui/swagger-ui-standalone-preset.js.map +1 -0
- package/dist/assets/swagger-ui/swagger-ui.css +3 -0
- package/dist/assets/swagger-ui/swagger-ui.css.map +1 -0
- package/dist/assets/swagger-ui/swagger-ui.js +1 -0
- package/dist/assets/swagger-ui/swagger-ui.js.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.cjs.LICENSE.txt +24 -0
- package/dist/src/context/index.d.ts +4 -0
- package/dist/src/context/platform-context.manager.d.ts +23 -0
- package/dist/src/context/platform-context.model.d.ts +56 -0
- package/dist/src/context/platform-context.provider.d.ts +23 -0
- package/dist/src/context/platform.execution.context.d.ts +13 -0
- package/dist/src/context/wrapped-invocation-context.d.ts +5 -0
- package/dist/src/event-hub-handler/decorators/decorators.d.ts +161 -0
- package/dist/src/event-hub-handler/decorators/decorators.model.d.ts +62 -0
- package/dist/src/event-hub-handler/decorators/index.d.ts +2 -0
- package/dist/src/event-hub-handler/event-hub-handler-metadata.reader.d.ts +8 -0
- package/dist/src/event-hub-handler/event-hub-handler-registration.service.d.ts +12 -0
- package/dist/src/event-hub-handler/event-hub-handler.factory.d.ts +13 -0
- package/dist/src/event-hub-handler/event-hub-handler.model.d.ts +101 -0
- package/dist/src/event-hub-handler/event-hub-trigger-support.factory.d.ts +10 -0
- package/dist/src/event-hub-handler/event-hub-trigger.model.d.ts +39 -0
- package/dist/src/event-hub-handler/event-hub-triggers-registration.service.d.ts +18 -0
- package/dist/src/event-hub-handler/index.d.ts +4 -0
- package/dist/src/framework.container.d.ts +6 -0
- package/dist/src/http-controller/decorators/decorators.d.ts +410 -0
- package/dist/src/http-controller/decorators/decorators.model.d.ts +123 -0
- package/dist/src/http-controller/decorators/index.d.ts +3 -0
- package/dist/src/http-controller/http-controller-metadata.reader.d.ts +8 -0
- package/dist/src/http-controller/http-controller-registration.service.d.ts +12 -0
- package/dist/src/http-controller/http-controller.model.d.ts +131 -0
- package/dist/src/http-controller/http-handler-support.factory.d.ts +26 -0
- package/dist/src/http-controller/http-handler.factory.d.ts +16 -0
- package/dist/src/http-controller/http-operations-registration.service.d.ts +22 -0
- package/dist/src/http-controller/http-request-arg-provider.factory.d.ts +12 -0
- package/dist/src/http-controller/http-response-processor.factory.d.ts +10 -0
- package/dist/src/http-controller/index.d.ts +11 -0
- package/dist/src/http-controller/open-api-definition.service.d.ts +29 -0
- package/dist/src/http-controller/open-api-metadata.service.d.ts +11 -0
- package/dist/src/http-controller/open-api-print.service.d.ts +8 -0
- package/dist/src/http-controller/open-api-registration.service.d.ts +17 -0
- package/dist/src/http-controller/security/authentication-service.d.ts +15 -0
- package/dist/src/http-controller/security/authenticator.provider.d.ts +31 -0
- package/dist/src/http-controller/security/bearer-security-authentication.service.d.ts +9 -0
- package/dist/src/http-controller/security/bearer-token.service.d.ts +5 -0
- package/dist/src/http-controller/security/index.d.ts +3 -0
- package/dist/src/http-controller/security/operation-authentication.resolver.d.ts +18 -0
- package/dist/src/http-controller/security/principal-merge.service.d.ts +11 -0
- package/dist/src/http-controller/security/strict-principal-merge.servce.d.ts +5 -0
- package/dist/src/http-controller/swagger-handling.service.d.ts +11 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/init.d.ts +1 -0
- package/dist/src/logger/bindings.d.ts +7 -0
- package/dist/src/logger/index.d.ts +6 -0
- package/dist/src/logger/log-level.service.d.ts +7 -0
- package/dist/src/logger/log-transport.service.d.ts +19 -0
- package/dist/src/logger/logger.model.d.ts +241 -0
- package/dist/src/logger/logger.utils.d.ts +17 -0
- package/dist/src/logger/otel.logger.d.ts +9 -0
- package/dist/src/logger/trie-search.service.d.ts +65 -0
- package/dist/src/middleware.d.ts +10 -0
- package/dist/src/platform/azure-platform.d.ts +15 -0
- package/dist/src/platform/index.d.ts +5 -0
- package/dist/src/platform/model.d.ts +18 -0
- package/dist/src/platform/register-trigger-handler.factory.d.ts +5 -0
- package/dist/src/platform/startup.service.d.ts +36 -0
- package/dist/src/platform/system-logger-name.provider.d.ts +1 -0
- package/dist/src/platform.container.d.ts +3 -0
- package/dist/src/security/index.d.ts +2 -0
- package/dist/src/security/security-context.d.ts +22 -0
- package/dist/src/security/security.model.d.ts +37 -0
- package/dist/src/shared/decorators/decorators.d.ts +37 -0
- package/dist/src/shared/decorators/decorators.model.d.ts +13 -0
- package/dist/src/shared/decorators/index.d.ts +2 -0
- package/dist/src/shared/index.d.ts +8 -0
- package/dist/src/shared/ioc-container.utils.d.ts +7 -0
- package/dist/src/shared/platform.model.d.ts +44 -0
- package/dist/src/shared/trigger-handler-metadata.reader.d.ts +6 -0
- package/dist/src/shared/zod-parser-wrapper.d.ts +5 -0
- package/docs/logging.md +805 -0
- package/package.json +87 -0
- package/src/context/index.ts +4 -0
- package/src/context/platform-context.manager.ts +36 -0
- package/src/context/platform-context.model.ts +59 -0
- package/src/context/platform-context.provider.ts +37 -0
- package/src/context/platform.execution.context.ts +44 -0
- package/src/context/wrapped-invocation-context.ts +26 -0
- package/src/event-hub-handler/decorators/decorators.model.ts +76 -0
- package/src/event-hub-handler/decorators/decorators.ts +231 -0
- package/src/event-hub-handler/decorators/index.ts +2 -0
- package/src/event-hub-handler/event-hub-handler-metadata.reader.ts +38 -0
- package/src/event-hub-handler/event-hub-handler-registration.service.ts +45 -0
- package/src/event-hub-handler/event-hub-handler.factory.ts +66 -0
- package/src/event-hub-handler/event-hub-handler.model.ts +112 -0
- package/src/event-hub-handler/event-hub-trigger-support.factory.ts +234 -0
- package/src/event-hub-handler/event-hub-trigger.model.ts +36 -0
- package/src/event-hub-handler/event-hub-triggers-registration.service.ts +74 -0
- package/src/event-hub-handler/index.ts +19 -0
- package/src/framework.container.ts +24 -0
- package/src/http-controller/decorators/decorators.model.ts +156 -0
- package/src/http-controller/decorators/decorators.ts +516 -0
- package/src/http-controller/decorators/index.ts +3 -0
- package/src/http-controller/http-controller-metadata.reader.ts +62 -0
- package/src/http-controller/http-controller-registration.service.ts +52 -0
- package/src/http-controller/http-controller.model.ts +233 -0
- package/src/http-controller/http-handler-support.factory.ts +132 -0
- package/src/http-controller/http-handler.factory.ts +107 -0
- package/src/http-controller/http-operations-registration.service.ts +81 -0
- package/src/http-controller/http-request-arg-provider.factory.ts +165 -0
- package/src/http-controller/http-response-processor.factory.ts +77 -0
- package/src/http-controller/index.ts +47 -0
- package/src/http-controller/open-api-definition.service.ts +155 -0
- package/src/http-controller/open-api-metadata.service.ts +96 -0
- package/src/http-controller/open-api-print.service.ts +49 -0
- package/src/http-controller/open-api-registration.service.ts +45 -0
- package/src/http-controller/security/authentication-service.ts +18 -0
- package/src/http-controller/security/authenticator.provider.ts +238 -0
- package/src/http-controller/security/bearer-security-authentication.service.ts +16 -0
- package/src/http-controller/security/bearer-token.service.ts +6 -0
- package/src/http-controller/security/index.ts +3 -0
- package/src/http-controller/security/operation-authentication.resolver.ts +111 -0
- package/src/http-controller/security/principal-merge.service.ts +26 -0
- package/src/http-controller/security/strict-principal-merge.servce.ts +23 -0
- package/src/http-controller/swagger-handling.service.ts +126 -0
- package/src/index.ts +80 -0
- package/src/init.ts +4 -0
- package/src/logger/bindings.ts +56 -0
- package/src/logger/index.ts +26 -0
- package/src/logger/log-level.service.ts +14 -0
- package/src/logger/log-transport.service.ts +162 -0
- package/src/logger/logger.model.ts +261 -0
- package/src/logger/logger.utils.ts +264 -0
- package/src/logger/otel.logger.ts +91 -0
- package/src/logger/trie-search.service.ts +177 -0
- package/src/middleware.ts +49 -0
- package/src/platform/azure-platform.ts +57 -0
- package/src/platform/index.ts +18 -0
- package/src/platform/model.ts +19 -0
- package/src/platform/register-trigger-handler.factory.ts +43 -0
- package/src/platform/startup.service.ts +39 -0
- package/src/platform/system-logger-name.provider.ts +20 -0
- package/src/platform.container.ts +21 -0
- package/src/security/index.ts +2 -0
- package/src/security/security-context.ts +30 -0
- package/src/security/security.model.ts +46 -0
- package/src/shared/decorators/decorators.model.ts +17 -0
- package/src/shared/decorators/decorators.ts +87 -0
- package/src/shared/decorators/index.ts +2 -0
- package/src/shared/index.ts +16 -0
- package/src/shared/ioc-container.utils.ts +10 -0
- package/src/shared/platform.model.ts +71 -0
- package/src/shared/trigger-handler-metadata.reader.ts +27 -0
- package/src/shared/zod-parser-wrapper.ts +49 -0
- package/src/test-utilities/index.ts +1 -0
- package/src/test-utilities/utils.ts +5 -0
- package/tsconfig.test.json +8 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { injectable } from 'inversify';
|
|
2
|
+
import {
|
|
3
|
+
FUNCTION_HANDLER_METADATA,
|
|
4
|
+
TriggerHandlerClass,
|
|
5
|
+
TriggerHandlerMetadataError,
|
|
6
|
+
TriggerHandlerMetadataReader,
|
|
7
|
+
} from 'shared';
|
|
8
|
+
import { ControllerOperationMetadata, HTTP_CONTROLLER_TYPE, HttpControllerMetadata } from './decorators';
|
|
9
|
+
|
|
10
|
+
@injectable()
|
|
11
|
+
export class HttpControllerMetadataReader {
|
|
12
|
+
constructor(private readonly metadataReader: TriggerHandlerMetadataReader) {}
|
|
13
|
+
|
|
14
|
+
getHandlerClassMetadata(triggerHandlerClass: TriggerHandlerClass): HttpControllerMetadata {
|
|
15
|
+
const handlerClassMetadata = this.metadataReader.getHandlerClassMetadata(triggerHandlerClass);
|
|
16
|
+
if (handlerClassMetadata.type !== HTTP_CONTROLLER_TYPE) {
|
|
17
|
+
throw new TriggerHandlerMetadataError(
|
|
18
|
+
`Invalid type for handler class ${triggerHandlerClass.name}. Expected '${HTTP_CONTROLLER_TYPE}', but got '${handlerClassMetadata.type}'.`,
|
|
19
|
+
{
|
|
20
|
+
cause: {
|
|
21
|
+
triggerHandlerClass: triggerHandlerClass.name,
|
|
22
|
+
expectedType: HTTP_CONTROLLER_TYPE,
|
|
23
|
+
actualType: handlerClassMetadata.type,
|
|
24
|
+
reason: 'invalid type',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return handlerClassMetadata as HttpControllerMetadata;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getOperationMetadata(handlerClass: TriggerHandlerClass, operation: string): ControllerOperationMetadata {
|
|
33
|
+
const argsMetadata = Reflect.getOwnMetadata(FUNCTION_HANDLER_METADATA, handlerClass.prototype, operation);
|
|
34
|
+
if (argsMetadata === undefined) {
|
|
35
|
+
throw new TriggerHandlerMetadataError(
|
|
36
|
+
`No metadata found for operation ${operation} in handler class ${handlerClass.name}.`,
|
|
37
|
+
{
|
|
38
|
+
cause: {
|
|
39
|
+
handlerClass: handlerClass.name,
|
|
40
|
+
operation,
|
|
41
|
+
reason: 'no metadata',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (argsMetadata.type !== HTTP_CONTROLLER_TYPE) {
|
|
47
|
+
throw new TriggerHandlerMetadataError(
|
|
48
|
+
`Invalid type for operation ${operation} in handler class ${handlerClass.name}. Expected '${HTTP_CONTROLLER_TYPE}', but got '${argsMetadata.type}'.`,
|
|
49
|
+
{
|
|
50
|
+
cause: {
|
|
51
|
+
handlerClass: handlerClass.name,
|
|
52
|
+
operation,
|
|
53
|
+
expectedType: HTTP_CONTROLLER_TYPE,
|
|
54
|
+
actualType: argsMetadata.type,
|
|
55
|
+
reason: 'invalid type',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
return argsMetadata as ControllerOperationMetadata;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { app, HttpMethod } from '@azure/functions';
|
|
2
|
+
import { Container, inject, injectable } from 'inversify';
|
|
3
|
+
import { PLATFORM_CONTAINER, TriggerHandlerClass, TriggerHandlerRegistrationService } from 'shared';
|
|
4
|
+
import { OperationMethod } from './decorators';
|
|
5
|
+
import { HttpHandlerFactory } from './http-handler.factory';
|
|
6
|
+
import { HttpOperationRegistration, HttpOperationsRegistrationService } from './http-operations-registration.service';
|
|
7
|
+
|
|
8
|
+
const httpMethodMap: Record<OperationMethod, HttpMethod> = {
|
|
9
|
+
get: 'GET',
|
|
10
|
+
head: 'HEAD',
|
|
11
|
+
delete: 'DELETE',
|
|
12
|
+
post: 'POST',
|
|
13
|
+
put: 'PUT',
|
|
14
|
+
patch: 'PATCH',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
@injectable()
|
|
18
|
+
export class HttpControllerRegistrationService implements TriggerHandlerRegistrationService {
|
|
19
|
+
constructor(
|
|
20
|
+
@inject(PLATFORM_CONTAINER) private readonly platformContainer: Container,
|
|
21
|
+
private readonly operationsRegistrationService: HttpOperationsRegistrationService,
|
|
22
|
+
private readonly handlerFactory: HttpHandlerFactory,
|
|
23
|
+
) {}
|
|
24
|
+
|
|
25
|
+
register(controllerClass: TriggerHandlerClass) {
|
|
26
|
+
this.platformContainer.bind(controllerClass).toSelf();
|
|
27
|
+
const controller = this.platformContainer.get(controllerClass);
|
|
28
|
+
this.operationsRegistrationService.registerOperations(controllerClass, registrationData => {
|
|
29
|
+
this.registerTrigger(controller, registrationData);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private registerTrigger(controller: object, registrationData: HttpOperationRegistration) {
|
|
34
|
+
const { operationId, controllerMethod, operationMetadata } = registrationData;
|
|
35
|
+
|
|
36
|
+
const controllerPrototype = controller.constructor.prototype;
|
|
37
|
+
const route = registrationData.application.context + '/' + registrationData.route;
|
|
38
|
+
const method = async (...args: unknown[]): Promise<unknown> => {
|
|
39
|
+
return await controllerPrototype[controllerMethod].call(controller, ...args);
|
|
40
|
+
};
|
|
41
|
+
const handler = this.handlerFactory.createHandler(registrationData, method);
|
|
42
|
+
const { method: httpMethod, authLevel, extraInputs, extraOutputs } = operationMetadata;
|
|
43
|
+
app.http(operationId, {
|
|
44
|
+
route,
|
|
45
|
+
methods: [httpMethodMap[httpMethod]],
|
|
46
|
+
handler,
|
|
47
|
+
authLevel,
|
|
48
|
+
extraInputs,
|
|
49
|
+
extraOutputs,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { Cookie, HttpResponseInit } from '@azure/functions';
|
|
2
|
+
import { getReasonPhrase, StatusCodes } from 'http-status-codes';
|
|
3
|
+
import * as _ from 'lodash';
|
|
4
|
+
import * as path from 'node:path';
|
|
5
|
+
import type { OpenAPIObject } from 'openapi3-ts/oas30';
|
|
6
|
+
import { AzFunctionsRuntimeError } from 'shared';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
|
|
9
|
+
export type OpenAPIObjectConfig = Omit<OpenAPIObject, 'paths' | 'webhooks'>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Represents a REST application with a name, context, and OpenAPI configuration.
|
|
13
|
+
*
|
|
14
|
+
* @property name The name of the REST application.
|
|
15
|
+
* @property context The context path for the REST application.
|
|
16
|
+
* @property openApiConfig The OpenAPI configuration for the REST application.
|
|
17
|
+
*/
|
|
18
|
+
export interface RestApplication {
|
|
19
|
+
name: string;
|
|
20
|
+
context: string;
|
|
21
|
+
openApiConfig: OpenAPIObjectConfig;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents the options for an HTTP trigger error, including the response and additional details.
|
|
26
|
+
*
|
|
27
|
+
* @property response The HTTP response initialization options, including the status.
|
|
28
|
+
* @property details Additional details about the error.
|
|
29
|
+
*/
|
|
30
|
+
export interface HttpTriggerErrorOptions<Status extends number = number> extends ErrorOptions {
|
|
31
|
+
response?: HttpResponseInit & { status?: Status };
|
|
32
|
+
details?: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export abstract class BaseHttpTriggerError<Status extends number = number> extends AzFunctionsRuntimeError {
|
|
36
|
+
private readonly _response: HttpResponseInit;
|
|
37
|
+
protected abstract getStatus(): Status;
|
|
38
|
+
get status(): number {
|
|
39
|
+
return this.getStatus();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
constructor(message?: string, options?: HttpTriggerErrorOptions<Status>) {
|
|
43
|
+
super(message, { cause: options?.cause, details: options?.details });
|
|
44
|
+
this.name = this.constructor.name;
|
|
45
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
46
|
+
const response = options?.response;
|
|
47
|
+
const status = response?.status ?? this.getStatus();
|
|
48
|
+
this.message = message ?? getReasonPhrase(status);
|
|
49
|
+
this._response = {
|
|
50
|
+
...response,
|
|
51
|
+
status,
|
|
52
|
+
...(response?.body === undefined && response?.jsonBody === undefined ? { body: this.message } : {}),
|
|
53
|
+
};
|
|
54
|
+
this._details = {
|
|
55
|
+
httpStatus: this.getStatus(),
|
|
56
|
+
reasonPhrase: getReasonPhrase(this.getStatus()),
|
|
57
|
+
...options?.details,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get response(): HttpResponseInit {
|
|
62
|
+
return this._response;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Represents a common HTTP trigger error with a default status of 500 (Internal Server Error).
|
|
68
|
+
*
|
|
69
|
+
* It can optionally include a response object with a specific status and body, and additional details about the error.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* throw new CommonHttpTriggerError('Resource was not found', {
|
|
74
|
+
* response: {
|
|
75
|
+
* status: 404,
|
|
76
|
+
* jsonBody: {
|
|
77
|
+
* error: 'Resource not found'
|
|
78
|
+
* }
|
|
79
|
+
* }
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export class CommonHttpTriggerError extends BaseHttpTriggerError {
|
|
84
|
+
override getStatus(): number {
|
|
85
|
+
return this.response?.status ?? StatusCodes.INTERNAL_SERVER_ERROR;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Represents a Bad Request (400) HTTP trigger error.
|
|
91
|
+
*/
|
|
92
|
+
export class BadRequestError extends BaseHttpTriggerError<StatusCodes.BAD_REQUEST> {
|
|
93
|
+
override getStatus(): StatusCodes.BAD_REQUEST {
|
|
94
|
+
return StatusCodes.BAD_REQUEST;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Represents an Unauthorized (401) HTTP trigger error.
|
|
100
|
+
*/
|
|
101
|
+
export class UnauthorizedError extends BaseHttpTriggerError<StatusCodes.UNAUTHORIZED> {
|
|
102
|
+
override getStatus(): StatusCodes.UNAUTHORIZED {
|
|
103
|
+
return StatusCodes.UNAUTHORIZED;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Represents a Forbidden (403) HTTP trigger error.
|
|
109
|
+
*/
|
|
110
|
+
export class ForbiddenError extends BaseHttpTriggerError<StatusCodes.FORBIDDEN> {
|
|
111
|
+
override getStatus(): StatusCodes.FORBIDDEN {
|
|
112
|
+
return StatusCodes.FORBIDDEN;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Represents a Not Found (404) HTTP trigger error.
|
|
118
|
+
*/
|
|
119
|
+
export class NotFoundError extends BaseHttpTriggerError<StatusCodes.NOT_FOUND> {
|
|
120
|
+
override getStatus(): StatusCodes.NOT_FOUND {
|
|
121
|
+
return StatusCodes.NOT_FOUND;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Represents an Internal Server Error (500) HTTP trigger error.
|
|
127
|
+
*/
|
|
128
|
+
export class InternalServerError extends BaseHttpTriggerError<StatusCodes.INTERNAL_SERVER_ERROR> {
|
|
129
|
+
override getStatus(): StatusCodes.INTERNAL_SERVER_ERROR {
|
|
130
|
+
return StatusCodes.INTERNAL_SERVER_ERROR;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Default Zod schema for validating string values.
|
|
136
|
+
*/
|
|
137
|
+
export const StringSchema = z.string();
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Default Zod schema for validating optional string values.
|
|
141
|
+
*/
|
|
142
|
+
export const OptionalStringSchema = StringSchema.optional();
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Default Zod schema for validating number values.
|
|
146
|
+
*/
|
|
147
|
+
export const NumberSchema = z.number();
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Abstract builder class for constructing HTTP direct responses.
|
|
151
|
+
*
|
|
152
|
+
* @template T The type of the JSON body to be included in the response.
|
|
153
|
+
*/
|
|
154
|
+
export abstract class HttpDirectResponseBuilder<T = unknown> {
|
|
155
|
+
abstract status(status: number): HttpDirectResponseBuilder<T>;
|
|
156
|
+
abstract header(name: string, value: string): HttpDirectResponseBuilder<T>;
|
|
157
|
+
abstract addCookie(value: Cookie): HttpDirectResponseBuilder<T>;
|
|
158
|
+
abstract jsonBody(body: T): HttpDirectResponseBuilder<T>;
|
|
159
|
+
abstract build(): HttpResponseInit;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Creates a new instance of the HTTP direct response builder.
|
|
163
|
+
*
|
|
164
|
+
* @template T The type of the JSON body to be included in the response.
|
|
165
|
+
* @returns A new instance of HttpDirectResponseBuilder.
|
|
166
|
+
*/
|
|
167
|
+
static builder<T>(): HttpDirectResponseBuilder<T> {
|
|
168
|
+
return new HttpDirectResponseBuilderImpl<T>();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export class HttpDirectResponseBuilderImpl<T = unknown> extends HttpDirectResponseBuilder<T> {
|
|
173
|
+
private _status: number = StatusCodes.OK;
|
|
174
|
+
private _headers?: Record<string, string>;
|
|
175
|
+
private _cookies?: Cookie[];
|
|
176
|
+
private _jsonBody?: T;
|
|
177
|
+
|
|
178
|
+
status(status: number): HttpDirectResponseBuilder<T> {
|
|
179
|
+
this._status = status;
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
header(name: string, value: string): HttpDirectResponseBuilder<T> {
|
|
184
|
+
if (!this._headers) {
|
|
185
|
+
this._headers = {};
|
|
186
|
+
}
|
|
187
|
+
this._headers[name] = value;
|
|
188
|
+
return this;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
addCookie(value: Cookie): HttpDirectResponseBuilder<T> {
|
|
192
|
+
if (!this._cookies) {
|
|
193
|
+
this._cookies = [];
|
|
194
|
+
}
|
|
195
|
+
this._cookies.push(value);
|
|
196
|
+
return this;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
jsonBody(body: T): HttpDirectResponseBuilder<T> {
|
|
200
|
+
this._jsonBody = body;
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
build(): HttpResponseInit {
|
|
205
|
+
return {
|
|
206
|
+
status: this._status,
|
|
207
|
+
headers: _.cloneDeep(this._headers),
|
|
208
|
+
cookies: _.cloneDeep(this._cookies),
|
|
209
|
+
jsonBody: _.cloneDeep(this._jsonBody),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// eslint-disable-next-line sonarjs/slow-regex
|
|
215
|
+
const CLEANUP_REGEX = /^\/+|\/+$/g;
|
|
216
|
+
export function joinPosix(...segments: string[]): string {
|
|
217
|
+
return path.posix.join(...segments.map(s => s.replace(CLEANUP_REGEX, '')));
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const HttpResponseInitSchema = z
|
|
221
|
+
.object({
|
|
222
|
+
status: z.number().optional(),
|
|
223
|
+
headers: z.record(z.string(), z.string()).optional(),
|
|
224
|
+
cookies: z.array(z.any()).optional(),
|
|
225
|
+
body: z.any().optional(),
|
|
226
|
+
jsonBody: z.any().optional(),
|
|
227
|
+
enableContentNegotiation: z.boolean().optional(),
|
|
228
|
+
})
|
|
229
|
+
.refine(obj => Object.values(obj).some(v => v !== undefined), { message: 'At least one property must be provided' });
|
|
230
|
+
|
|
231
|
+
export function isHttpResponseInit(obj: unknown): obj is HttpResponseInit {
|
|
232
|
+
return HttpResponseInitSchema.safeParse(obj).success;
|
|
233
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { HttpRequest, InvocationContext } from '@azure/functions';
|
|
2
|
+
import { HttpResponseInit } from '@azure/functions/types/http';
|
|
3
|
+
import { injectable } from 'inversify';
|
|
4
|
+
import * as _ from 'lodash';
|
|
5
|
+
import { AuthContext } from 'security';
|
|
6
|
+
import { AzFunctionsSystemError } from 'shared';
|
|
7
|
+
import { Promisable } from 'type-fest';
|
|
8
|
+
import { ControllerOperationArgMetadata, DirectResponseObject } from './decorators';
|
|
9
|
+
import { InternalServerError, isHttpResponseInit, OptionalStringSchema } from './http-controller.model';
|
|
10
|
+
import { HttpRequestArgProviderFactory } from './http-request-arg-provider.factory';
|
|
11
|
+
import { HttpResponseProcessorFactory, ResponsePartialProcessor } from './http-response-processor.factory';
|
|
12
|
+
|
|
13
|
+
export class HttpTriggerDefinitionError extends AzFunctionsSystemError {}
|
|
14
|
+
|
|
15
|
+
export interface HttpRequestProcessorInput {
|
|
16
|
+
request: HttpRequest;
|
|
17
|
+
invocationContext: InvocationContext;
|
|
18
|
+
authContext: AuthContext;
|
|
19
|
+
}
|
|
20
|
+
export type HttpRequestArgsProvider = (input: HttpRequestProcessorInput) => Promise<unknown[]>;
|
|
21
|
+
export type HttpRequestArgProvider = (input: HttpRequestProcessorInput) => Promisable<unknown>;
|
|
22
|
+
|
|
23
|
+
export type HttpResponseProcessor = (response: unknown) => Promise<HttpResponseInit>;
|
|
24
|
+
|
|
25
|
+
@injectable()
|
|
26
|
+
export class HttpHandlerSupportFactory {
|
|
27
|
+
constructor(
|
|
28
|
+
private readonly httpRequestArgProviderFactory: HttpRequestArgProviderFactory,
|
|
29
|
+
private readonly httpResponseProcessorFactory: HttpResponseProcessorFactory,
|
|
30
|
+
) {}
|
|
31
|
+
|
|
32
|
+
createRequestArgsProvider(operationArgs: ControllerOperationArgMetadata[]): HttpRequestArgsProvider {
|
|
33
|
+
this.validateArgs(operationArgs);
|
|
34
|
+
const argProviders: HttpRequestArgProvider[] = [];
|
|
35
|
+
for (const arg of operationArgs) {
|
|
36
|
+
switch (arg.type) {
|
|
37
|
+
case 'path': {
|
|
38
|
+
argProviders.push(this.httpRequestArgProviderFactory.createPathParamArgProvider(arg));
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
case 'header': {
|
|
42
|
+
const headerItemName = arg.name;
|
|
43
|
+
const headerSchema = arg.schema ?? OptionalStringSchema;
|
|
44
|
+
argProviders.push(this.httpRequestArgProviderFactory.createHeaderProvider(headerItemName, headerSchema));
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
case 'query': {
|
|
48
|
+
argProviders.push(this.httpRequestArgProviderFactory.createQueryItemArgProvider(arg));
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
case 'request':
|
|
52
|
+
argProviders.push(({ request }) => request);
|
|
53
|
+
break;
|
|
54
|
+
case 'invocationContext':
|
|
55
|
+
argProviders.push(({ invocationContext }) => invocationContext);
|
|
56
|
+
break;
|
|
57
|
+
case 'authContext':
|
|
58
|
+
argProviders.push(({ authContext }) => authContext);
|
|
59
|
+
break;
|
|
60
|
+
case 'body':
|
|
61
|
+
argProviders.push(this.httpRequestArgProviderFactory.createBodyArgProvider(arg.schema));
|
|
62
|
+
break;
|
|
63
|
+
case 'undefined':
|
|
64
|
+
argProviders.push(() => undefined);
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return this.httpRequestArgProviderFactory.createArgsProvider(argProviders);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private validateArgs(operationArgs: ControllerOperationArgMetadata[]) {
|
|
72
|
+
let bodyParamCount = 0;
|
|
73
|
+
let requestParamCount = 0;
|
|
74
|
+
for (const arg of operationArgs) {
|
|
75
|
+
if (arg.type === 'body') {
|
|
76
|
+
bodyParamCount++;
|
|
77
|
+
}
|
|
78
|
+
if (arg.type === 'request') {
|
|
79
|
+
requestParamCount++;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (bodyParamCount > 1) {
|
|
83
|
+
throw new HttpTriggerDefinitionError('Multiple body parameters are not allowed in a single operation.');
|
|
84
|
+
}
|
|
85
|
+
if (requestParamCount > 1) {
|
|
86
|
+
throw new HttpTriggerDefinitionError('Multiple request parameters are not allowed in a single operation.');
|
|
87
|
+
}
|
|
88
|
+
if (bodyParamCount > 0 && requestParamCount > 0) {
|
|
89
|
+
throw new HttpTriggerDefinitionError('Cannot have both body and request parameters in a single operation.');
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
createResponseProcessor(directResponse?: DirectResponseObject): HttpResponseProcessor {
|
|
94
|
+
const partialProcessors: ResponsePartialProcessor[] = [
|
|
95
|
+
this.httpResponseProcessorFactory.provideJsonBodyProcessor(directResponse),
|
|
96
|
+
this.httpResponseProcessorFactory.provideStatusProcessor(directResponse),
|
|
97
|
+
this.httpResponseProcessorFactory.provideHeaderProcessor(directResponse),
|
|
98
|
+
].filter((processor): processor is ResponsePartialProcessor => processor !== undefined);
|
|
99
|
+
|
|
100
|
+
return async (value: unknown): Promise<HttpResponseInit> => {
|
|
101
|
+
let input: HttpResponseInit;
|
|
102
|
+
if (isHttpResponseInit(value)) {
|
|
103
|
+
if (directResponse === undefined) {
|
|
104
|
+
return value;
|
|
105
|
+
} else {
|
|
106
|
+
input = value;
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
if (directResponse === undefined) {
|
|
110
|
+
throw new InternalServerError(
|
|
111
|
+
'Controller method should return HttpResponseInit when directResponse is not defined',
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
input = {
|
|
115
|
+
jsonBody: value,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
const processionResults = await Promise.allSettled(partialProcessors.map(processor => processor(input)));
|
|
119
|
+
|
|
120
|
+
const [fulfilled, rejected] = _.partition(processionResults, result => result.status === 'fulfilled');
|
|
121
|
+
if (rejected.length > 0) {
|
|
122
|
+
const errors = rejected.map(reason => reason.reason);
|
|
123
|
+
throw new InternalServerError('Failed processing response', {
|
|
124
|
+
details: { errors },
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return fulfilled.reduce((acc, result) => {
|
|
128
|
+
return { ...acc, ...result.value };
|
|
129
|
+
}, input);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { HttpRequest, InvocationContext } from '@azure/functions';
|
|
2
|
+
import { HttpResponseInit } from '@azure/functions/types/http';
|
|
3
|
+
import { PLATFORM_CONTEXT_MANAGER, PLATFORM_CONTEXT_PROVIDER } from 'context';
|
|
4
|
+
import { getReasonPhrase, StatusCodes } from 'http-status-codes';
|
|
5
|
+
import { Container, inject, injectable } from 'inversify';
|
|
6
|
+
import { adjustContextLoggerMetadata, LOGGER_FACTORY, LoggerFactory } from 'logger';
|
|
7
|
+
import { AUTHENTICATION_CONTEXT_KEY } from 'security';
|
|
8
|
+
import { PLATFORM_CONTAINER } from 'shared';
|
|
9
|
+
import { BaseHttpTriggerError } from './http-controller.model';
|
|
10
|
+
import { HttpHandlerSupportFactory } from './http-handler-support.factory';
|
|
11
|
+
import { HttpOperationRegistration } from './http-operations-registration.service';
|
|
12
|
+
import { AuthenticatorProvider } from './security/authenticator.provider';
|
|
13
|
+
|
|
14
|
+
export type RequestHandler = (request: HttpRequest, context: InvocationContext) => Promise<HttpResponseInit>;
|
|
15
|
+
|
|
16
|
+
@injectable()
|
|
17
|
+
export class HttpHandlerFactory {
|
|
18
|
+
private readonly logger;
|
|
19
|
+
|
|
20
|
+
constructor(
|
|
21
|
+
@inject(LOGGER_FACTORY) loggerFactory: LoggerFactory,
|
|
22
|
+
@inject(PLATFORM_CONTAINER) private readonly platformContainer: Container,
|
|
23
|
+
private readonly supportService: HttpHandlerSupportFactory,
|
|
24
|
+
private readonly authenticationProvider: AuthenticatorProvider,
|
|
25
|
+
) {
|
|
26
|
+
this.logger = loggerFactory();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
createHandler(
|
|
30
|
+
operationRegistration: HttpOperationRegistration,
|
|
31
|
+
method: (...args: unknown[]) => Promise<unknown>,
|
|
32
|
+
): RequestHandler {
|
|
33
|
+
const { operationId, operationMetadata } = operationRegistration;
|
|
34
|
+
const argsProvider = this.supportService.createRequestArgsProvider(operationMetadata.args);
|
|
35
|
+
const responseProvider = this.supportService.createResponseProcessor(operationMetadata.directResponse);
|
|
36
|
+
const contextManager = this.platformContainer.get(PLATFORM_CONTEXT_MANAGER);
|
|
37
|
+
const contextProvider = this.platformContainer.get(PLATFORM_CONTEXT_PROVIDER);
|
|
38
|
+
const authenticator = this.authenticationProvider.provideAuthenticator(operationRegistration);
|
|
39
|
+
return async (request: HttpRequest, invocationContext: InvocationContext): Promise<HttpResponseInit> => {
|
|
40
|
+
return await contextManager.runWith(
|
|
41
|
+
contextProvider.providePlatformContext(invocationContext),
|
|
42
|
+
async (): Promise<HttpResponseInit> => {
|
|
43
|
+
adjustContextLoggerMetadata(contextManager, {
|
|
44
|
+
error: {
|
|
45
|
+
operationRegistration,
|
|
46
|
+
},
|
|
47
|
+
warn: {
|
|
48
|
+
operationId,
|
|
49
|
+
},
|
|
50
|
+
silly: {
|
|
51
|
+
operationRegistration,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
this.logger.http(`Processing HTTP request for operation ${operationId} started`, {
|
|
55
|
+
request,
|
|
56
|
+
});
|
|
57
|
+
this.logger.silly(`Processing HTTP request for operation ${operationId} started`, {
|
|
58
|
+
request,
|
|
59
|
+
});
|
|
60
|
+
let response: HttpResponseInit;
|
|
61
|
+
try {
|
|
62
|
+
const authContext = await authenticator(request);
|
|
63
|
+
contextManager.active()?.setValue(AUTHENTICATION_CONTEXT_KEY, authContext);
|
|
64
|
+
const args = await argsProvider({ request, invocationContext, authContext });
|
|
65
|
+
this.logger.debug(`Calling controller method for operation ${operationId} with arguments`, {
|
|
66
|
+
args,
|
|
67
|
+
});
|
|
68
|
+
const result = await method(...args);
|
|
69
|
+
this.logger.debug(`Controller method for operation ${operationId} called`);
|
|
70
|
+
response = await responseProvider(result);
|
|
71
|
+
this.logger.http(`HTTP request processed for operation ${operationId}`, {
|
|
72
|
+
response,
|
|
73
|
+
});
|
|
74
|
+
this.logger.silly(`HTTP request for operation ${operationId} processed`, {
|
|
75
|
+
response,
|
|
76
|
+
});
|
|
77
|
+
} catch (e) {
|
|
78
|
+
if (e instanceof BaseHttpTriggerError) {
|
|
79
|
+
this.logger.warn(e.message, {
|
|
80
|
+
operationId,
|
|
81
|
+
...e.details,
|
|
82
|
+
});
|
|
83
|
+
response = e.response;
|
|
84
|
+
} else {
|
|
85
|
+
this.logger.error(`Failed to process HTTP request for operation ${operationId}`, {
|
|
86
|
+
httpStatus: StatusCodes.INTERNAL_SERVER_ERROR,
|
|
87
|
+
reasonPhrase: getReasonPhrase(StatusCodes.INTERNAL_SERVER_ERROR),
|
|
88
|
+
error: e,
|
|
89
|
+
});
|
|
90
|
+
response = {
|
|
91
|
+
status: StatusCodes.INTERNAL_SERVER_ERROR,
|
|
92
|
+
body: 'Internal server error.',
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
this.logger.http(`Failed to process HTTP request for operation ${operationId}`, {
|
|
96
|
+
response,
|
|
97
|
+
});
|
|
98
|
+
this.logger.silly(`Failed to process HTTP request for operation ${operationId}`, {
|
|
99
|
+
response,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return response;
|
|
103
|
+
},
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { inject, injectable } from 'inversify';
|
|
2
|
+
import { LOGGER_FACTORY, LoggerFactory } from 'logger';
|
|
3
|
+
import { TriggerHandlerClass, TriggerHandlerMetadataError } from 'shared';
|
|
4
|
+
import { ControllerOperationMetadata, HttpControllerMetadata, HttpControllerMetadataReader } from './decorators';
|
|
5
|
+
import { joinPosix, RestApplication } from './http-controller.model';
|
|
6
|
+
import { OpenApiDefinitionService } from './open-api-definition.service';
|
|
7
|
+
|
|
8
|
+
export interface HttpOperationRegistration {
|
|
9
|
+
operationId: string;
|
|
10
|
+
controllerMethod: string;
|
|
11
|
+
controllerMetadata: HttpControllerMetadata;
|
|
12
|
+
operationMetadata: ControllerOperationMetadata;
|
|
13
|
+
application: RestApplication;
|
|
14
|
+
route: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type RegisterCallback = (operationRegistration: HttpOperationRegistration) => void;
|
|
18
|
+
|
|
19
|
+
@injectable()
|
|
20
|
+
export class HttpOperationsRegistrationService {
|
|
21
|
+
private readonly logger;
|
|
22
|
+
|
|
23
|
+
constructor(
|
|
24
|
+
@inject(LOGGER_FACTORY) loggerFactory: LoggerFactory,
|
|
25
|
+
private readonly metadataReader: HttpControllerMetadataReader,
|
|
26
|
+
private readonly openApiDefinitionService: OpenApiDefinitionService,
|
|
27
|
+
) {
|
|
28
|
+
this.logger = loggerFactory();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
registerOperations(controllerClass: TriggerHandlerClass, registerCallback: RegisterCallback): void {
|
|
32
|
+
const controllerMetadata = this.metadataReader.getHandlerClassMetadata(controllerClass);
|
|
33
|
+
const prototype = controllerClass.prototype;
|
|
34
|
+
const application = this.openApiDefinitionService.getApplication(controllerMetadata.application);
|
|
35
|
+
this.logger.debug('Registering operations for controller started', {
|
|
36
|
+
class: controllerClass.name,
|
|
37
|
+
metadata: controllerMetadata,
|
|
38
|
+
});
|
|
39
|
+
let operationsCount = 0;
|
|
40
|
+
for (const controllerMethod of Object.getOwnPropertyNames(prototype)) {
|
|
41
|
+
const operationMetadata = this.getOperationMetadata(controllerClass, controllerMethod);
|
|
42
|
+
if (operationMetadata === undefined) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const route = joinPosix(controllerMetadata.path, operationMetadata.path ?? '.');
|
|
46
|
+
const operationId = operationMetadata.operationId ?? controllerMethod;
|
|
47
|
+
const operationRegistration: HttpOperationRegistration = {
|
|
48
|
+
operationId,
|
|
49
|
+
controllerMethod,
|
|
50
|
+
controllerMetadata: controllerMetadata,
|
|
51
|
+
operationMetadata,
|
|
52
|
+
application,
|
|
53
|
+
route,
|
|
54
|
+
};
|
|
55
|
+
registerCallback(operationRegistration);
|
|
56
|
+
operationsCount++;
|
|
57
|
+
this.logger.debug(
|
|
58
|
+
`Operation ${operationId} for ${route} in controller class ${controllerClass.name} registered`,
|
|
59
|
+
{
|
|
60
|
+
operationRegistration,
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
this.logger.verbose(`${operationsCount} operation(s) for controller ${controllerClass.name} registered`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private getOperationMetadata(
|
|
68
|
+
controllerClass: TriggerHandlerClass,
|
|
69
|
+
controllerMethod: string,
|
|
70
|
+
): ControllerOperationMetadata | undefined {
|
|
71
|
+
try {
|
|
72
|
+
return this.metadataReader.getOperationMetadata(controllerClass, controllerMethod);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
// if Azure Function class is not HTTP Controller
|
|
75
|
+
if (error instanceof TriggerHandlerMetadataError) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|