@bitblit/ratchet-epsilon-common 4.0.85-alpha
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/CHANGELOG.md +177 -0
- package/License.txt +13 -0
- package/README.md +242 -0
- package/dist/cjs/background/background-dynamo-log-table-handler.js +38 -0
- package/dist/cjs/background/background-entry.js +2 -0
- package/dist/cjs/background/background-execution-event-type.js +11 -0
- package/dist/cjs/background/background-execution-event.js +2 -0
- package/dist/cjs/background/background-execution-listener.js +2 -0
- package/dist/cjs/background/background-handler.js +269 -0
- package/dist/cjs/background/background-http-adapter-handler.js +127 -0
- package/dist/cjs/background/background-meta-response-internal.js +2 -0
- package/dist/cjs/background/background-process-handling.js +8 -0
- package/dist/cjs/background/background-process-log-table-entry.js +2 -0
- package/dist/cjs/background/background-queue-response-internal.js +2 -0
- package/dist/cjs/background/background-validator.js +88 -0
- package/dist/cjs/background/epsilon-background-process-error.js +93 -0
- package/dist/cjs/background/internal-background-entry.js +2 -0
- package/dist/cjs/background/manager/abstract-background-manager.js +92 -0
- package/dist/cjs/background/manager/aws-sqs-sns-background-manager.js +153 -0
- package/dist/cjs/background/manager/background-manager-like.js +2 -0
- package/dist/cjs/background/manager/single-thread-local-background-manager.js +49 -0
- package/dist/cjs/background/s3-background-transaction-logger.js +54 -0
- package/dist/cjs/build/ratchet-epsilon-common-info.js +18 -0
- package/dist/cjs/built-in/background/echo-processor.js +18 -0
- package/dist/cjs/built-in/background/log-and-enqueue-echo-processor.js +16 -0
- package/dist/cjs/built-in/background/log-message-background-error-processor.js +10 -0
- package/dist/cjs/built-in/background/no-op-processor.js +13 -0
- package/dist/cjs/built-in/background/retry-processor.js +41 -0
- package/dist/cjs/built-in/background/sample-delay-processor.js +16 -0
- package/dist/cjs/built-in/background/sample-input-validated-processor-data.js +2 -0
- package/dist/cjs/built-in/background/sample-input-validated-processor.js +16 -0
- package/dist/cjs/built-in/built-in-trace-id-generators.js +25 -0
- package/dist/cjs/built-in/daemon/daemon-authorizer-function.js +2 -0
- package/dist/cjs/built-in/daemon/daemon-config.js +2 -0
- package/dist/cjs/built-in/daemon/daemon-group-selection-function.js +2 -0
- package/dist/cjs/built-in/daemon/daemon-handler.js +62 -0
- package/dist/cjs/built-in/daemon/daemon-process-state-list.js +2 -0
- package/dist/cjs/built-in/http/apollo-filter.js +63 -0
- package/dist/cjs/built-in/http/built-in-auth-filters.js +115 -0
- package/dist/cjs/built-in/http/built-in-authorizers.js +43 -0
- package/dist/cjs/built-in/http/built-in-filters.js +222 -0
- package/dist/cjs/built-in/http/built-in-handlers.js +73 -0
- package/dist/cjs/built-in/http/log-level-manipulation-filter.js +20 -0
- package/dist/cjs/built-in/http/run-handler-as-filter.js +64 -0
- package/dist/cjs/cli-bootstrap/epsilon-run-background-process-from-command-line-dry-run.js +20 -0
- package/dist/cjs/config/background/background-aws-config.js +2 -0
- package/dist/cjs/config/background/background-config.js +2 -0
- package/dist/cjs/config/background/background-error-processor.js +2 -0
- package/dist/cjs/config/background/background-processor.js +2 -0
- package/dist/cjs/config/background/background-transaction-log.js +2 -0
- package/dist/cjs/config/background/background-transaction-logger.js +2 -0
- package/dist/cjs/config/cron/abstract-cron-entry.js +2 -0
- package/dist/cjs/config/cron/cron-background-entry.js +2 -0
- package/dist/cjs/config/cron/cron-config.js +2 -0
- package/dist/cjs/config/dynamo-db-config.js +2 -0
- package/dist/cjs/config/epsilon-config.js +2 -0
- package/dist/cjs/config/epsilon-lambda-event-handler.js +2 -0
- package/dist/cjs/config/epsilon-logger-config.js +2 -0
- package/dist/cjs/config/generic-aws-event-handler-function.js +2 -0
- package/dist/cjs/config/http/authorizer-function.js +2 -0
- package/dist/cjs/config/http/epsilon-authorization-context.js +2 -0
- package/dist/cjs/config/http/extended-api-gateway-event.js +2 -0
- package/dist/cjs/config/http/filter-chain-context.js +2 -0
- package/dist/cjs/config/http/filter-function.js +2 -0
- package/dist/cjs/config/http/handler-function.js +2 -0
- package/dist/cjs/config/http/http-config.js +2 -0
- package/dist/cjs/config/http/http-processing-config.js +2 -0
- package/dist/cjs/config/http/mapped-http-processing-config.js +2 -0
- package/dist/cjs/config/http/null-returned-object-handling.js +9 -0
- package/dist/cjs/config/inter-api/inter-api-aws-config.js +2 -0
- package/dist/cjs/config/inter-api/inter-api-config.js +2 -0
- package/dist/cjs/config/inter-api/inter-api-process-mapping.js +2 -0
- package/dist/cjs/config/logging-trace-id-generator.js +2 -0
- package/dist/cjs/config/open-api/open-api-document-components.js +2 -0
- package/dist/cjs/config/open-api/open-api-document-path.js +2 -0
- package/dist/cjs/config/open-api/open-api-document.js +2 -0
- package/dist/cjs/config/s3-config.js +2 -0
- package/dist/cjs/config/sns-config.js +2 -0
- package/dist/cjs/epsilon-build-properties.js +28 -0
- package/dist/cjs/epsilon-constants.js +49 -0
- package/dist/cjs/epsilon-global-handler.js +155 -0
- package/dist/cjs/epsilon-instance.js +2 -0
- package/dist/cjs/epsilon-logging-extension-processor.js +19 -0
- package/dist/cjs/http/auth/api-gateway-adapter-authentication-handler.js +75 -0
- package/dist/cjs/http/auth/auth0-web-token-manipulator.js +62 -0
- package/dist/cjs/http/auth/basic-auth-token.js +2 -0
- package/dist/cjs/http/auth/google-web-token-manipulator.js +72 -0
- package/dist/cjs/http/auth/jwt-ratchet-local-web-token-manipulator.js +29 -0
- package/dist/cjs/http/auth/local-web-token-manipulator.js +74 -0
- package/dist/cjs/http/auth/web-token-manipulator.js +2 -0
- package/dist/cjs/http/error/bad-gateway.js +12 -0
- package/dist/cjs/http/error/bad-request-error.js +12 -0
- package/dist/cjs/http/error/conflict-error.js +12 -0
- package/dist/cjs/http/error/epsilon-http-error.js +132 -0
- package/dist/cjs/http/error/forbidden-error.js +12 -0
- package/dist/cjs/http/error/gateway-timeout.js +12 -0
- package/dist/cjs/http/error/method-not-allowed-error.js +12 -0
- package/dist/cjs/http/error/misconfigured-error.js +12 -0
- package/dist/cjs/http/error/not-found-error.js +12 -0
- package/dist/cjs/http/error/not-implemented.js +12 -0
- package/dist/cjs/http/error/request-timeout-error.js +12 -0
- package/dist/cjs/http/error/service-unavailable.js +12 -0
- package/dist/cjs/http/error/too-many-requests-error.js +12 -0
- package/dist/cjs/http/error/unauthorized-error.js +12 -0
- package/dist/cjs/http/event-util.js +180 -0
- package/dist/cjs/http/response-util.js +146 -0
- package/dist/cjs/http/route/epsilon-router.js +2 -0
- package/dist/cjs/http/route/extended-auth-response-context.js +2 -0
- package/dist/cjs/http/route/route-mapping.js +2 -0
- package/dist/cjs/http/route/route-validator-config.js +2 -0
- package/dist/cjs/http/route/router-util.js +238 -0
- package/dist/cjs/http/web-handler.js +122 -0
- package/dist/cjs/http/web-v2-handler.js +25 -0
- package/dist/cjs/index.js +136 -0
- package/dist/cjs/inter-api/inter-api-entry.js +2 -0
- package/dist/cjs/inter-api/inter-api-util.js +62 -0
- package/dist/cjs/inter-api-manager.js +67 -0
- package/dist/cjs/lambda-event-handler/cron-epsilon-lambda-event-handler.js +76 -0
- package/dist/cjs/lambda-event-handler/dynamo-epsilon-lambda-event-handler.js +36 -0
- package/dist/cjs/lambda-event-handler/generic-sns-epsilon-lambda-event-handler.js +32 -0
- package/dist/cjs/lambda-event-handler/inter-api-epsilon-lambda-event-handler.js +26 -0
- package/dist/cjs/lambda-event-handler/s3-epsilon-lambda-event-handler.js +44 -0
- package/dist/cjs/local-container-server.js +79 -0
- package/dist/cjs/local-server-cert.js +71 -0
- package/dist/cjs/local-server.js +145 -0
- package/dist/cjs/open-api-util/open-api-doc-modifications.js +2 -0
- package/dist/cjs/open-api-util/open-api-doc-modifier.js +83 -0
- package/dist/cjs/open-api-util/yaml-combiner.js +32 -0
- package/dist/cjs/run-background-process-from-command-line.js +37 -0
- package/dist/cjs/sample/sample-batch-only-local-server.js +19 -0
- package/dist/cjs/sample/sample-local-server.js +30 -0
- package/dist/cjs/sample/sample-server-components.js +197 -0
- package/dist/cjs/test-error-server.js +48 -0
- package/dist/cjs/util/aws-util.js +69 -0
- package/dist/cjs/util/context-util.js +104 -0
- package/dist/cjs/util/cron-util.js +72 -0
- package/dist/cjs/util/epsilon-config-parser.js +70 -0
- package/dist/es/background/background-dynamo-log-table-handler.js +33 -0
- package/dist/es/background/background-entry.js +1 -0
- package/dist/es/background/background-execution-event-type.js +8 -0
- package/dist/es/background/background-execution-event.js +1 -0
- package/dist/es/background/background-execution-listener.js +1 -0
- package/dist/es/background/background-handler.js +265 -0
- package/dist/es/background/background-http-adapter-handler.js +123 -0
- package/dist/es/background/background-meta-response-internal.js +1 -0
- package/dist/es/background/background-process-handling.js +5 -0
- package/dist/es/background/background-process-log-table-entry.js +1 -0
- package/dist/es/background/background-queue-response-internal.js +1 -0
- package/dist/es/background/background-validator.js +84 -0
- package/dist/es/background/epsilon-background-process-error.js +88 -0
- package/dist/es/background/internal-background-entry.js +1 -0
- package/dist/es/background/manager/abstract-background-manager.js +88 -0
- package/dist/es/background/manager/aws-sqs-sns-background-manager.js +149 -0
- package/dist/es/background/manager/background-manager-like.js +1 -0
- package/dist/es/background/manager/single-thread-local-background-manager.js +45 -0
- package/dist/es/background/s3-background-transaction-logger.js +49 -0
- package/dist/es/build/ratchet-epsilon-common-info.js +14 -0
- package/dist/es/built-in/background/echo-processor.js +14 -0
- package/dist/es/built-in/background/log-and-enqueue-echo-processor.js +12 -0
- package/dist/es/built-in/background/log-message-background-error-processor.js +6 -0
- package/dist/es/built-in/background/no-op-processor.js +9 -0
- package/dist/es/built-in/background/retry-processor.js +36 -0
- package/dist/es/built-in/background/sample-delay-processor.js +12 -0
- package/dist/es/built-in/background/sample-input-validated-processor-data.js +1 -0
- package/dist/es/built-in/background/sample-input-validated-processor.js +12 -0
- package/dist/es/built-in/built-in-trace-id-generators.js +21 -0
- package/dist/es/built-in/daemon/daemon-authorizer-function.js +1 -0
- package/dist/es/built-in/daemon/daemon-config.js +1 -0
- package/dist/es/built-in/daemon/daemon-group-selection-function.js +1 -0
- package/dist/es/built-in/daemon/daemon-handler.js +58 -0
- package/dist/es/built-in/daemon/daemon-process-state-list.js +1 -0
- package/dist/es/built-in/http/apollo-filter.js +58 -0
- package/dist/es/built-in/http/built-in-auth-filters.js +107 -0
- package/dist/es/built-in/http/built-in-authorizers.js +39 -0
- package/dist/es/built-in/http/built-in-filters.js +208 -0
- package/dist/es/built-in/http/built-in-handlers.js +69 -0
- package/dist/es/built-in/http/log-level-manipulation-filter.js +16 -0
- package/dist/es/built-in/http/run-handler-as-filter.js +60 -0
- package/dist/es/cli-bootstrap/epsilon-run-background-process-from-command-line-dry-run.js +17 -0
- package/dist/es/config/background/background-aws-config.js +1 -0
- package/dist/es/config/background/background-config.js +1 -0
- package/dist/es/config/background/background-error-processor.js +1 -0
- package/dist/es/config/background/background-processor.js +1 -0
- package/dist/es/config/background/background-transaction-log.js +1 -0
- package/dist/es/config/background/background-transaction-logger.js +1 -0
- package/dist/es/config/cron/abstract-cron-entry.js +1 -0
- package/dist/es/config/cron/cron-background-entry.js +1 -0
- package/dist/es/config/cron/cron-config.js +1 -0
- package/dist/es/config/dynamo-db-config.js +1 -0
- package/dist/es/config/epsilon-config.js +1 -0
- package/dist/es/config/epsilon-lambda-event-handler.js +1 -0
- package/dist/es/config/epsilon-logger-config.js +1 -0
- package/dist/es/config/generic-aws-event-handler-function.js +1 -0
- package/dist/es/config/http/authorizer-function.js +1 -0
- package/dist/es/config/http/epsilon-authorization-context.js +1 -0
- package/dist/es/config/http/extended-api-gateway-event.js +1 -0
- package/dist/es/config/http/filter-chain-context.js +1 -0
- package/dist/es/config/http/filter-function.js +1 -0
- package/dist/es/config/http/handler-function.js +1 -0
- package/dist/es/config/http/http-config.js +1 -0
- package/dist/es/config/http/http-processing-config.js +1 -0
- package/dist/es/config/http/mapped-http-processing-config.js +1 -0
- package/dist/es/config/http/null-returned-object-handling.js +6 -0
- package/dist/es/config/inter-api/inter-api-aws-config.js +1 -0
- package/dist/es/config/inter-api/inter-api-config.js +1 -0
- package/dist/es/config/inter-api/inter-api-process-mapping.js +1 -0
- package/dist/es/config/logging-trace-id-generator.js +1 -0
- package/dist/es/config/open-api/open-api-document-components.js +1 -0
- package/dist/es/config/open-api/open-api-document-path.js +1 -0
- package/dist/es/config/open-api/open-api-document.js +1 -0
- package/dist/es/config/s3-config.js +1 -0
- package/dist/es/config/sns-config.js +1 -0
- package/dist/es/epsilon-build-properties.js +24 -0
- package/dist/es/epsilon-constants.js +45 -0
- package/dist/es/epsilon-global-handler.js +149 -0
- package/dist/es/epsilon-instance.js +1 -0
- package/dist/es/epsilon-logging-extension-processor.js +15 -0
- package/dist/es/http/auth/api-gateway-adapter-authentication-handler.js +71 -0
- package/dist/es/http/auth/auth0-web-token-manipulator.js +56 -0
- package/dist/es/http/auth/basic-auth-token.js +1 -0
- package/dist/es/http/auth/google-web-token-manipulator.js +67 -0
- package/dist/es/http/auth/jwt-ratchet-local-web-token-manipulator.js +25 -0
- package/dist/es/http/auth/local-web-token-manipulator.js +70 -0
- package/dist/es/http/auth/web-token-manipulator.js +1 -0
- package/dist/es/http/error/bad-gateway.js +8 -0
- package/dist/es/http/error/bad-request-error.js +8 -0
- package/dist/es/http/error/conflict-error.js +8 -0
- package/dist/es/http/error/epsilon-http-error.js +127 -0
- package/dist/es/http/error/forbidden-error.js +8 -0
- package/dist/es/http/error/gateway-timeout.js +8 -0
- package/dist/es/http/error/method-not-allowed-error.js +8 -0
- package/dist/es/http/error/misconfigured-error.js +8 -0
- package/dist/es/http/error/not-found-error.js +8 -0
- package/dist/es/http/error/not-implemented.js +8 -0
- package/dist/es/http/error/request-timeout-error.js +8 -0
- package/dist/es/http/error/service-unavailable.js +8 -0
- package/dist/es/http/error/too-many-requests-error.js +8 -0
- package/dist/es/http/error/unauthorized-error.js +8 -0
- package/dist/es/http/event-util.js +175 -0
- package/dist/es/http/response-util.js +141 -0
- package/dist/es/http/route/epsilon-router.js +1 -0
- package/dist/es/http/route/extended-auth-response-context.js +1 -0
- package/dist/es/http/route/route-mapping.js +1 -0
- package/dist/es/http/route/route-validator-config.js +1 -0
- package/dist/es/http/route/router-util.js +233 -0
- package/dist/es/http/web-handler.js +116 -0
- package/dist/es/http/web-v2-handler.js +21 -0
- package/dist/es/index.js +133 -0
- package/dist/es/inter-api/inter-api-entry.js +1 -0
- package/dist/es/inter-api/inter-api-util.js +58 -0
- package/dist/es/inter-api-manager.js +63 -0
- package/dist/es/lambda-event-handler/cron-epsilon-lambda-event-handler.js +72 -0
- package/dist/es/lambda-event-handler/dynamo-epsilon-lambda-event-handler.js +32 -0
- package/dist/es/lambda-event-handler/generic-sns-epsilon-lambda-event-handler.js +28 -0
- package/dist/es/lambda-event-handler/inter-api-epsilon-lambda-event-handler.js +22 -0
- package/dist/es/lambda-event-handler/s3-epsilon-lambda-event-handler.js +40 -0
- package/dist/es/local-container-server.js +74 -0
- package/dist/es/local-server-cert.js +67 -0
- package/dist/es/local-server.js +140 -0
- package/dist/es/open-api-util/open-api-doc-modifications.js +1 -0
- package/dist/es/open-api-util/open-api-doc-modifier.js +78 -0
- package/dist/es/open-api-util/yaml-combiner.js +27 -0
- package/dist/es/run-background-process-from-command-line.js +32 -0
- package/dist/es/sample/sample-batch-only-local-server.js +17 -0
- package/dist/es/sample/sample-local-server.js +28 -0
- package/dist/es/sample/sample-server-components.js +192 -0
- package/dist/es/test-error-server.js +43 -0
- package/dist/es/util/aws-util.js +65 -0
- package/dist/es/util/context-util.js +95 -0
- package/dist/es/util/cron-util.js +68 -0
- package/dist/es/util/epsilon-config-parser.js +64 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.es.tsbuildinfo +1 -0
- package/dist/tsconfig.types.tsbuildinfo +1 -0
- package/dist/types/background/background-dynamo-log-table-handler.d.ts +11 -0
- package/dist/types/background/background-entry.d.ts +4 -0
- package/dist/types/background/background-execution-event-type.d.ts +7 -0
- package/dist/types/background/background-execution-event.d.ts +8 -0
- package/dist/types/background/background-execution-listener.d.ts +5 -0
- package/dist/types/background/background-handler.d.ts +33 -0
- package/dist/types/background/background-http-adapter-handler.d.ts +26 -0
- package/dist/types/background/background-meta-response-internal.d.ts +5 -0
- package/dist/types/background/background-process-handling.d.ts +4 -0
- package/dist/types/background/background-process-log-table-entry.d.ts +11 -0
- package/dist/types/background/background-queue-response-internal.d.ts +8 -0
- package/dist/types/background/background-validator.d.ts +20 -0
- package/dist/types/background/epsilon-background-process-error.d.ts +30 -0
- package/dist/types/background/internal-background-entry.d.ts +7 -0
- package/dist/types/background/manager/abstract-background-manager.d.ts +26 -0
- package/dist/types/background/manager/aws-sqs-sns-background-manager.d.ts +30 -0
- package/dist/types/background/manager/background-manager-like.d.ts +24 -0
- package/dist/types/background/manager/single-thread-local-background-manager.d.ts +22 -0
- package/dist/types/background/s3-background-transaction-logger.d.ts +17 -0
- package/dist/types/build/ratchet-epsilon-common-info.d.ts +5 -0
- package/dist/types/built-in/background/echo-processor.d.ts +7 -0
- package/dist/types/built-in/background/log-and-enqueue-echo-processor.d.ts +6 -0
- package/dist/types/built-in/background/log-message-background-error-processor.d.ts +5 -0
- package/dist/types/built-in/background/no-op-processor.d.ts +6 -0
- package/dist/types/built-in/background/retry-processor.d.ts +16 -0
- package/dist/types/built-in/background/sample-delay-processor.d.ts +6 -0
- package/dist/types/built-in/background/sample-input-validated-processor-data.d.ts +4 -0
- package/dist/types/built-in/background/sample-input-validated-processor.d.ts +8 -0
- package/dist/types/built-in/built-in-trace-id-generators.d.ts +5 -0
- package/dist/types/built-in/daemon/daemon-authorizer-function.d.ts +5 -0
- package/dist/types/built-in/daemon/daemon-config.d.ts +8 -0
- package/dist/types/built-in/daemon/daemon-group-selection-function.d.ts +4 -0
- package/dist/types/built-in/daemon/daemon-handler.d.ts +22 -0
- package/dist/types/built-in/daemon/daemon-process-state-list.d.ts +8 -0
- package/dist/types/built-in/http/apollo-filter.d.ts +10 -0
- package/dist/types/built-in/http/built-in-auth-filters.d.ts +9 -0
- package/dist/types/built-in/http/built-in-authorizers.d.ts +8 -0
- package/dist/types/built-in/http/built-in-filters.d.ts +25 -0
- package/dist/types/built-in/http/built-in-handlers.d.ts +9 -0
- package/dist/types/built-in/http/log-level-manipulation-filter.d.ts +9 -0
- package/dist/types/built-in/http/run-handler-as-filter.d.ts +12 -0
- package/dist/types/cli-bootstrap/epsilon-run-background-process-from-command-line-dry-run.d.ts +2 -0
- package/dist/types/config/background/background-aws-config.d.ts +7 -0
- package/dist/types/config/background/background-config.d.ts +14 -0
- package/dist/types/config/background/background-error-processor.d.ts +4 -0
- package/dist/types/config/background/background-processor.d.ts +6 -0
- package/dist/types/config/background/background-transaction-log.d.ts +8 -0
- package/dist/types/config/background/background-transaction-logger.d.ts +5 -0
- package/dist/types/config/cron/abstract-cron-entry.d.ts +12 -0
- package/dist/types/config/cron/cron-background-entry.d.ts +15 -0
- package/dist/types/config/cron/cron-config.d.ts +6 -0
- package/dist/types/config/dynamo-db-config.d.ts +5 -0
- package/dist/types/config/epsilon-config.d.ts +20 -0
- package/dist/types/config/epsilon-lambda-event-handler.d.ts +7 -0
- package/dist/types/config/epsilon-logger-config.d.ts +12 -0
- package/dist/types/config/generic-aws-event-handler-function.d.ts +3 -0
- package/dist/types/config/http/authorizer-function.d.ts +6 -0
- package/dist/types/config/http/epsilon-authorization-context.d.ts +5 -0
- package/dist/types/config/http/extended-api-gateway-event.d.ts +7 -0
- package/dist/types/config/http/filter-chain-context.d.ts +14 -0
- package/dist/types/config/http/filter-function.d.ts +4 -0
- package/dist/types/config/http/handler-function.d.ts +5 -0
- package/dist/types/config/http/http-config.d.ts +15 -0
- package/dist/types/config/http/http-processing-config.d.ts +11 -0
- package/dist/types/config/http/mapped-http-processing-config.d.ts +7 -0
- package/dist/types/config/http/null-returned-object-handling.d.ts +5 -0
- package/dist/types/config/inter-api/inter-api-aws-config.d.ts +5 -0
- package/dist/types/config/inter-api/inter-api-config.d.ts +6 -0
- package/dist/types/config/inter-api/inter-api-process-mapping.d.ts +11 -0
- package/dist/types/config/logging-trace-id-generator.d.ts +4 -0
- package/dist/types/config/open-api/open-api-document-components.d.ts +4 -0
- package/dist/types/config/open-api/open-api-document-path.d.ts +2 -0
- package/dist/types/config/open-api/open-api-document.d.ts +6 -0
- package/dist/types/config/s3-config.d.ts +6 -0
- package/dist/types/config/sns-config.d.ts +5 -0
- package/dist/types/epsilon-build-properties.d.ts +9 -0
- package/dist/types/epsilon-constants.d.ts +16 -0
- package/dist/types/epsilon-global-handler.d.ts +23 -0
- package/dist/types/epsilon-instance.d.ts +19 -0
- package/dist/types/epsilon-logging-extension-processor.d.ts +5 -0
- package/dist/types/http/auth/api-gateway-adapter-authentication-handler.d.ts +18 -0
- package/dist/types/http/auth/auth0-web-token-manipulator.d.ts +13 -0
- package/dist/types/http/auth/basic-auth-token.d.ts +7 -0
- package/dist/types/http/auth/google-web-token-manipulator.d.ts +14 -0
- package/dist/types/http/auth/jwt-ratchet-local-web-token-manipulator.d.ts +13 -0
- package/dist/types/http/auth/local-web-token-manipulator.d.ts +20 -0
- package/dist/types/http/auth/web-token-manipulator.d.ts +7 -0
- package/dist/types/http/error/bad-gateway.d.ts +5 -0
- package/dist/types/http/error/bad-request-error.d.ts +5 -0
- package/dist/types/http/error/conflict-error.d.ts +5 -0
- package/dist/types/http/error/epsilon-http-error.d.ts +41 -0
- package/dist/types/http/error/forbidden-error.d.ts +5 -0
- package/dist/types/http/error/gateway-timeout.d.ts +5 -0
- package/dist/types/http/error/method-not-allowed-error.d.ts +5 -0
- package/dist/types/http/error/misconfigured-error.d.ts +5 -0
- package/dist/types/http/error/not-found-error.d.ts +5 -0
- package/dist/types/http/error/not-implemented.d.ts +5 -0
- package/dist/types/http/error/request-timeout-error.d.ts +5 -0
- package/dist/types/http/error/service-unavailable.d.ts +5 -0
- package/dist/types/http/error/too-many-requests-error.d.ts +5 -0
- package/dist/types/http/error/unauthorized-error.d.ts +5 -0
- package/dist/types/http/event-util.d.ts +47 -0
- package/dist/types/http/response-util.d.ts +11 -0
- package/dist/types/http/route/epsilon-router.d.ts +8 -0
- package/dist/types/http/route/extended-auth-response-context.d.ts +6 -0
- package/dist/types/http/route/route-mapping.d.ts +12 -0
- package/dist/types/http/route/route-validator-config.d.ts +5 -0
- package/dist/types/http/route/router-util.d.ts +26 -0
- package/dist/types/http/web-handler.d.ts +26 -0
- package/dist/types/http/web-v2-handler.d.ts +13 -0
- package/dist/types/index.d.ts +136 -0
- package/dist/types/inter-api/inter-api-entry.d.ts +7 -0
- package/dist/types/inter-api/inter-api-util.d.ts +10 -0
- package/dist/types/inter-api-manager.d.ts +17 -0
- package/dist/types/lambda-event-handler/cron-epsilon-lambda-event-handler.d.ts +14 -0
- package/dist/types/lambda-event-handler/dynamo-epsilon-lambda-event-handler.d.ts +11 -0
- package/dist/types/lambda-event-handler/generic-sns-epsilon-lambda-event-handler.d.ts +10 -0
- package/dist/types/lambda-event-handler/inter-api-epsilon-lambda-event-handler.d.ts +10 -0
- package/dist/types/lambda-event-handler/s3-epsilon-lambda-event-handler.d.ts +10 -0
- package/dist/types/local-container-server.d.ts +13 -0
- package/dist/types/local-server-cert.d.ts +5 -0
- package/dist/types/local-server.d.ts +19 -0
- package/dist/types/open-api-util/open-api-doc-modifications.d.ts +8 -0
- package/dist/types/open-api-util/open-api-doc-modifier.d.ts +10 -0
- package/dist/types/open-api-util/yaml-combiner.d.ts +3 -0
- package/dist/types/run-background-process-from-command-line.d.ts +13 -0
- package/dist/types/sample/sample-batch-only-local-server.d.ts +1 -0
- package/dist/types/sample/sample-local-server.d.ts +1 -0
- package/dist/types/sample/sample-server-components.d.ts +12 -0
- package/dist/types/test-error-server.d.ts +13 -0
- package/dist/types/util/aws-util.d.ts +8 -0
- package/dist/types/util/context-util.d.ts +33 -0
- package/dist/types/util/cron-util.d.ts +11 -0
- package/dist/types/util/epsilon-config-parser.d.ts +14 -0
- package/package.json +132 -0
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackgroundHandler = void 0;
|
|
4
|
+
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
5
|
+
const ratchet_aws_1 = require("@bitblit/ratchet-aws");
|
|
6
|
+
const epsilon_constants_1 = require("../epsilon-constants");
|
|
7
|
+
const background_validator_1 = require("./background-validator");
|
|
8
|
+
const background_execution_event_type_1 = require("./background-execution-event-type");
|
|
9
|
+
const context_util_1 = require("../util/context-util");
|
|
10
|
+
const abstract_background_manager_1 = require("./manager/abstract-background-manager");
|
|
11
|
+
class BackgroundHandler {
|
|
12
|
+
constructor(cfg, mgr, modelValidator) {
|
|
13
|
+
this.cfg = cfg;
|
|
14
|
+
this.mgr = mgr;
|
|
15
|
+
this.modelValidator = modelValidator;
|
|
16
|
+
const cfgErrors = background_validator_1.BackgroundValidator.validateConfig(cfg);
|
|
17
|
+
if (cfgErrors.length > 0) {
|
|
18
|
+
ratchet_common_1.ErrorRatchet.throwFormattedErr('Invalid background config : %j', cfgErrors);
|
|
19
|
+
}
|
|
20
|
+
ratchet_common_1.Logger.silly('Starting Background processor, %d processors', cfg.processors.length);
|
|
21
|
+
this.validator = new background_validator_1.BackgroundValidator(cfg, modelValidator);
|
|
22
|
+
this.processors = background_validator_1.BackgroundValidator.validateAndMapProcessors(cfg.processors, modelValidator);
|
|
23
|
+
if ((mgr === null || mgr === void 0 ? void 0 : mgr.immediateProcessQueue) && mgr.immediateProcessQueue()) {
|
|
24
|
+
ratchet_common_1.Logger.info('Attaching to immediate processing queue');
|
|
25
|
+
mgr.immediateProcessQueue().subscribe(async (evt) => {
|
|
26
|
+
ratchet_common_1.Logger.debug('Processing local background entry : %j', evt);
|
|
27
|
+
const rval = await this.processSingleBackgroundEntry(evt);
|
|
28
|
+
ratchet_common_1.Logger.info('Processor returned %s', rval);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
extractLabel(evt, context) {
|
|
33
|
+
let rval = null;
|
|
34
|
+
if (this.isBackgroundStartSnsEvent(evt)) {
|
|
35
|
+
rval = 'BG:START-EVT';
|
|
36
|
+
}
|
|
37
|
+
else if (this.isBackgroundImmediateFireEvent(evt)) {
|
|
38
|
+
const pEvt = this.parseImmediateFireBackgroundEntry(evt);
|
|
39
|
+
rval = 'BG:' + pEvt.type + ':' + pEvt.guid;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
rval = 'BG:UNKNOWN';
|
|
43
|
+
}
|
|
44
|
+
return rval;
|
|
45
|
+
}
|
|
46
|
+
handlesEvent(evt) {
|
|
47
|
+
return ratchet_aws_1.LambdaEventDetector.isValidSnsEvent(evt) && this.isBackgroundSNSEvent(evt);
|
|
48
|
+
}
|
|
49
|
+
isBackgroundSNSEvent(event) {
|
|
50
|
+
return this.isBackgroundStartSnsEvent(event) || this.isBackgroundImmediateFireEvent(event);
|
|
51
|
+
}
|
|
52
|
+
isBackgroundStartSnsEvent(event) {
|
|
53
|
+
let rval = false;
|
|
54
|
+
if (event) {
|
|
55
|
+
if (ratchet_aws_1.LambdaEventDetector.isSingleSnsEvent(event)) {
|
|
56
|
+
const cast = event;
|
|
57
|
+
rval = cast.Records[0].Sns.Message === epsilon_constants_1.EpsilonConstants.BACKGROUND_SNS_START_MARKER;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return rval;
|
|
61
|
+
}
|
|
62
|
+
isBackgroundImmediateFireEvent(event) {
|
|
63
|
+
let rval = false;
|
|
64
|
+
if (!!event) {
|
|
65
|
+
if (ratchet_aws_1.LambdaEventDetector.isSingleSnsEvent(event)) {
|
|
66
|
+
const cast = event;
|
|
67
|
+
const msg = cast.Records[0].Sns.Message;
|
|
68
|
+
if (!!ratchet_common_1.StringRatchet.trimToNull(msg)) {
|
|
69
|
+
const parsed = JSON.parse(msg);
|
|
70
|
+
rval = !!parsed && parsed['type'] === epsilon_constants_1.EpsilonConstants.BACKGROUND_SNS_IMMEDIATE_RUN_FLAG;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return rval;
|
|
75
|
+
}
|
|
76
|
+
parseImmediateFireBackgroundEntry(event) {
|
|
77
|
+
let rval = null;
|
|
78
|
+
try {
|
|
79
|
+
if (!!event) {
|
|
80
|
+
if (ratchet_aws_1.LambdaEventDetector.isSingleSnsEvent(event)) {
|
|
81
|
+
const cast = event;
|
|
82
|
+
const msg = cast.Records[0].Sns.Message;
|
|
83
|
+
if (!!ratchet_common_1.StringRatchet.trimToNull(msg)) {
|
|
84
|
+
const parsed = JSON.parse(msg);
|
|
85
|
+
if (!!parsed && parsed['type'] === epsilon_constants_1.EpsilonConstants.BACKGROUND_SNS_IMMEDIATE_RUN_FLAG) {
|
|
86
|
+
rval = parsed['backgroundEntry'];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
ratchet_common_1.Logger.error('Could not parse %j as an immediate run event : %s', event, err, err);
|
|
94
|
+
}
|
|
95
|
+
return rval;
|
|
96
|
+
}
|
|
97
|
+
async processEvent(event, context) {
|
|
98
|
+
let procd = null;
|
|
99
|
+
if (!this.isBackgroundStartSnsEvent(event)) {
|
|
100
|
+
const backgroundEntry = this.parseImmediateFireBackgroundEntry(event);
|
|
101
|
+
if (!!backgroundEntry) {
|
|
102
|
+
ratchet_common_1.Logger.silly('Processing immediate fire event : %j', backgroundEntry);
|
|
103
|
+
const result = await this.processSingleBackgroundEntry(backgroundEntry);
|
|
104
|
+
procd = 1;
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
ratchet_common_1.Logger.warn('Tried to process non-background start / immediate event : %j returning false', event);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
ratchet_common_1.Logger.info('Reading task from background queue');
|
|
112
|
+
procd = await this.takeAndProcessSingleBackgroundQueueEntry();
|
|
113
|
+
if (procd > 0) {
|
|
114
|
+
ratchet_common_1.Logger.info('Processed %d elements from background queue, refiring', procd);
|
|
115
|
+
const refire = await this.mgr.fireStartProcessingRequest();
|
|
116
|
+
ratchet_common_1.Logger.info('Refire returned %s', refire);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
ratchet_common_1.Logger.info('No items processed - stopping');
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const rval = {
|
|
123
|
+
statusCode: 200,
|
|
124
|
+
body: ratchet_common_1.StringRatchet.safeString(procd),
|
|
125
|
+
isBase64Encoded: false,
|
|
126
|
+
};
|
|
127
|
+
return rval;
|
|
128
|
+
}
|
|
129
|
+
async takeAndProcessSingleBackgroundQueueEntry() {
|
|
130
|
+
let rval = null;
|
|
131
|
+
const entries = await this.mgr.takeEntryFromBackgroundQueue();
|
|
132
|
+
ratchet_common_1.Logger.info('Found %d entries - processing', entries.length);
|
|
133
|
+
for (let i = 0; i < entries.length; i++) {
|
|
134
|
+
const e = entries[i];
|
|
135
|
+
const result = await this.processSingleBackgroundEntry(e);
|
|
136
|
+
rval += result ? 1 : 0;
|
|
137
|
+
}
|
|
138
|
+
ratchet_common_1.Logger.debug('Returning %d', rval);
|
|
139
|
+
return rval;
|
|
140
|
+
}
|
|
141
|
+
async safeWriteToLogger(entry) {
|
|
142
|
+
if (this.cfg.transactionLogger) {
|
|
143
|
+
try {
|
|
144
|
+
await this.cfg.transactionLogger.logTransaction(entry);
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
ratchet_common_1.Logger.error('Failed to write to transaction logger : %j : %s', entry, err, err);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
ratchet_common_1.Logger.silly('Skipping - no logger defined');
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async conditionallyStartTransactionLog(e) {
|
|
155
|
+
if (!ratchet_common_1.StringRatchet.trimToNull(e.guid)) {
|
|
156
|
+
ratchet_common_1.Logger.warn('No guid found - creating');
|
|
157
|
+
e.guid = abstract_background_manager_1.AbstractBackgroundManager.generateBackgroundGuid();
|
|
158
|
+
const log = {
|
|
159
|
+
request: e,
|
|
160
|
+
running: true,
|
|
161
|
+
};
|
|
162
|
+
await this.safeWriteToLogger(log);
|
|
163
|
+
}
|
|
164
|
+
ratchet_common_1.Logger.debug('Starting transaction log');
|
|
165
|
+
}
|
|
166
|
+
async conditionallyCompleteTransactionLog(e, result, error, runtimeMS) {
|
|
167
|
+
ratchet_common_1.Logger.debug('Completing transaction log');
|
|
168
|
+
const log = {
|
|
169
|
+
request: e,
|
|
170
|
+
result: result,
|
|
171
|
+
error: error ? ratchet_common_1.ErrorRatchet.safeStringifyErr(error) : null,
|
|
172
|
+
running: false,
|
|
173
|
+
runtimeMS: runtimeMS,
|
|
174
|
+
};
|
|
175
|
+
await this.safeWriteToLogger(log);
|
|
176
|
+
}
|
|
177
|
+
async conditionallyRunErrorProcessor(e, error) {
|
|
178
|
+
try {
|
|
179
|
+
if (this.cfg.errorProcessor) {
|
|
180
|
+
ratchet_common_1.Logger.info('Running error processor');
|
|
181
|
+
await this.cfg.errorProcessor.handleError(e, error);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
ratchet_common_1.Logger.error('Background : BAD - Failed to run error processor : %s', err, err);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async fireListenerEvent(event) {
|
|
189
|
+
const listeners = this.cfg.executionListeners || [];
|
|
190
|
+
for (const listener of listeners) {
|
|
191
|
+
try {
|
|
192
|
+
await listener.onEvent(event);
|
|
193
|
+
}
|
|
194
|
+
catch (err) {
|
|
195
|
+
ratchet_common_1.Logger.error('Failure triggering handler %s : %s', ratchet_common_1.StringRatchet.trimToNull(listener === null || listener === void 0 ? void 0 : listener.label) || 'No-name', err);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
async processSingleBackgroundEntry(e) {
|
|
200
|
+
context_util_1.ContextUtil.setOverrideTraceFromInternalBackgroundEntry(e);
|
|
201
|
+
ratchet_common_1.Logger.info('Background Process Start: %j', e);
|
|
202
|
+
const sw = new ratchet_common_1.StopWatch();
|
|
203
|
+
await this.conditionallyStartTransactionLog(e);
|
|
204
|
+
let rval = false;
|
|
205
|
+
try {
|
|
206
|
+
await this.fireListenerEvent({
|
|
207
|
+
type: background_execution_event_type_1.BackgroundExecutionEventType.ProcessStarting,
|
|
208
|
+
processorType: e.type,
|
|
209
|
+
data: e.data,
|
|
210
|
+
guid: e.guid,
|
|
211
|
+
});
|
|
212
|
+
const processorInput = this.processors.get(e.type);
|
|
213
|
+
if (!processorInput) {
|
|
214
|
+
ratchet_common_1.ErrorRatchet.throwFormattedErr('Found no processor for background entry : %j (returning false)', e);
|
|
215
|
+
await this.fireListenerEvent({
|
|
216
|
+
type: background_execution_event_type_1.BackgroundExecutionEventType.NoMatchProcessorName,
|
|
217
|
+
processorType: e.type,
|
|
218
|
+
data: e.data,
|
|
219
|
+
guid: e.guid,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
let dataValidationErrors = [];
|
|
223
|
+
if (ratchet_common_1.StringRatchet.trimToNull(processorInput.dataSchemaName)) {
|
|
224
|
+
dataValidationErrors = this.modelValidator.validate(processorInput.dataSchemaName, e.data, false, false);
|
|
225
|
+
}
|
|
226
|
+
if (dataValidationErrors.length > 0) {
|
|
227
|
+
await this.fireListenerEvent({
|
|
228
|
+
type: background_execution_event_type_1.BackgroundExecutionEventType.DataValidationError,
|
|
229
|
+
processorType: e.type,
|
|
230
|
+
data: e.data,
|
|
231
|
+
errors: dataValidationErrors,
|
|
232
|
+
guid: e.guid,
|
|
233
|
+
});
|
|
234
|
+
ratchet_common_1.ErrorRatchet.throwFormattedErr('Not processing, data failed validation; entry was %j : errors : %j', e, dataValidationErrors);
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
let result = await processorInput.handleEvent(e.data, this.mgr);
|
|
238
|
+
result = result || 'SUCCESSFUL COMPLETION : NO RESULT RETURNED';
|
|
239
|
+
await this.conditionallyCompleteTransactionLog(e, result, null, sw.elapsedMS());
|
|
240
|
+
await this.fireListenerEvent({
|
|
241
|
+
type: background_execution_event_type_1.BackgroundExecutionEventType.ExecutionSuccessfullyComplete,
|
|
242
|
+
processorType: e.type,
|
|
243
|
+
data: result,
|
|
244
|
+
guid: e.guid,
|
|
245
|
+
});
|
|
246
|
+
rval = true;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
catch (err) {
|
|
250
|
+
ratchet_common_1.Logger.error('Background Process Error: %j : %s', e, err, err);
|
|
251
|
+
await this.conditionallyRunErrorProcessor(e, err);
|
|
252
|
+
await this.conditionallyCompleteTransactionLog(e, null, err, sw.elapsedMS());
|
|
253
|
+
await this.fireListenerEvent({
|
|
254
|
+
type: background_execution_event_type_1.BackgroundExecutionEventType.ExecutionFailedError,
|
|
255
|
+
processorType: e.type,
|
|
256
|
+
data: e.data,
|
|
257
|
+
errors: [ratchet_common_1.ErrorRatchet.safeStringifyErr(err)],
|
|
258
|
+
guid: e.guid,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
ratchet_common_1.Logger.info('Background Process Stop: %j : %s', e, sw.dump());
|
|
262
|
+
return rval;
|
|
263
|
+
}
|
|
264
|
+
getConfig() {
|
|
265
|
+
const rval = Object.assign({}, this.cfg);
|
|
266
|
+
return rval;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
exports.BackgroundHandler = BackgroundHandler;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackgroundHttpAdapterHandler = void 0;
|
|
4
|
+
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
5
|
+
const ratchet_common_2 = require("@bitblit/ratchet-common");
|
|
6
|
+
const background_process_handling_1 = require("./background-process-handling");
|
|
7
|
+
const ratchet_common_3 = require("@bitblit/ratchet-common");
|
|
8
|
+
const bad_request_error_1 = require("../http/error/bad-request-error");
|
|
9
|
+
const not_found_error_1 = require("../http/error/not-found-error");
|
|
10
|
+
const ratchet_common_4 = require("@bitblit/ratchet-common");
|
|
11
|
+
class BackgroundHttpAdapterHandler {
|
|
12
|
+
constructor(backgroundConfig, modelValidator, backgroundManager, maxWaitInMsForBackgroundJobToStart = 10000) {
|
|
13
|
+
this.backgroundConfig = backgroundConfig;
|
|
14
|
+
this.modelValidator = modelValidator;
|
|
15
|
+
this.backgroundManager = backgroundManager;
|
|
16
|
+
this.maxWaitInMsForBackgroundJobToStart = maxWaitInMsForBackgroundJobToStart;
|
|
17
|
+
}
|
|
18
|
+
get httpMetaEndpoint() {
|
|
19
|
+
return this.backgroundConfig.httpMetaEndpoint;
|
|
20
|
+
}
|
|
21
|
+
get httpSubmissionPath() {
|
|
22
|
+
return this.backgroundConfig.httpSubmissionPath;
|
|
23
|
+
}
|
|
24
|
+
get httpStatusPath() {
|
|
25
|
+
return this.backgroundConfig.httpStatusEndpoint;
|
|
26
|
+
}
|
|
27
|
+
get implyTypeFromPathSuffix() {
|
|
28
|
+
return this.backgroundConfig.implyTypeFromPathSuffix;
|
|
29
|
+
}
|
|
30
|
+
async handleBackgroundStatusRequest(evt, context) {
|
|
31
|
+
ratchet_common_1.Logger.info('handleBackgroundStatusRequest called');
|
|
32
|
+
if (!this.backgroundConfig.transactionLogger) {
|
|
33
|
+
throw new bad_request_error_1.BadRequestError('Process logging not enabled');
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
const guid = ratchet_common_3.StringRatchet.trimToNull(evt.pathParameters['guid']) || ratchet_common_3.StringRatchet.trimToNull(evt.queryStringParameters['guid']);
|
|
37
|
+
if (guid) {
|
|
38
|
+
const sw = new ratchet_common_1.StopWatch();
|
|
39
|
+
let log = null;
|
|
40
|
+
while (!log && sw.elapsedMS() < this.maxWaitInMsForBackgroundJobToStart) {
|
|
41
|
+
log = await this.backgroundConfig.transactionLogger.readTransactionLog(guid);
|
|
42
|
+
if (!log) {
|
|
43
|
+
ratchet_common_1.Logger.debug('No log found yet, waiting 500 ms and retrying (%s of %d waited so far)', sw.dump(), this.maxWaitInMsForBackgroundJobToStart);
|
|
44
|
+
await ratchet_common_4.PromiseRatchet.wait(500);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!log) {
|
|
48
|
+
throw new not_found_error_1.NotFoundError().withFormattedErrorMessage('No background result found for guid %s', guid);
|
|
49
|
+
}
|
|
50
|
+
return log;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
throw new bad_request_error_1.BadRequestError('No guid specified');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async handleBackgroundMetaRequest(evt, context) {
|
|
58
|
+
ratchet_common_1.Logger.info('handleBackgroundMetaRequest called');
|
|
59
|
+
const currentCount = await this.backgroundManager.fetchApproximateNumberOfQueueEntries();
|
|
60
|
+
const valid = this.backgroundConfig.processors.map((b) => b.typeName).filter((a) => !!a);
|
|
61
|
+
valid.sort((a, b) => a.localeCompare(b));
|
|
62
|
+
const rval = {
|
|
63
|
+
currentQueueLength: currentCount,
|
|
64
|
+
validTypes: valid,
|
|
65
|
+
backgroundManagerName: this.backgroundManager.backgroundManagerName,
|
|
66
|
+
};
|
|
67
|
+
return rval;
|
|
68
|
+
}
|
|
69
|
+
async handleBackgroundSubmission(evt, context) {
|
|
70
|
+
ratchet_common_1.Logger.info('handleBackgroundSubmission : %j (mgr:%s)', evt.parsedBody, this.backgroundManager.backgroundManagerName);
|
|
71
|
+
let rval = null;
|
|
72
|
+
const startIdx = evt.path.indexOf(this.httpSubmissionPath) + this.httpSubmissionPath.length;
|
|
73
|
+
let pathSuppliedBackgroundType = this.backgroundConfig.implyTypeFromPathSuffix
|
|
74
|
+
? evt.path.substring(startIdx).split('-').join('').toLowerCase()
|
|
75
|
+
: '';
|
|
76
|
+
if (pathSuppliedBackgroundType.includes('?')) {
|
|
77
|
+
pathSuppliedBackgroundType = pathSuppliedBackgroundType.substring(0, pathSuppliedBackgroundType.indexOf('?'));
|
|
78
|
+
}
|
|
79
|
+
if (pathSuppliedBackgroundType.includes('#')) {
|
|
80
|
+
pathSuppliedBackgroundType = pathSuppliedBackgroundType.substring(0, pathSuppliedBackgroundType.indexOf('#'));
|
|
81
|
+
}
|
|
82
|
+
const entry = evt.parsedBody || {};
|
|
83
|
+
if (ratchet_common_3.StringRatchet.trimToNull(pathSuppliedBackgroundType)) {
|
|
84
|
+
if (ratchet_common_3.StringRatchet.trimToNull(entry === null || entry === void 0 ? void 0 : entry.type) && entry.type.toLocaleLowerCase() !== pathSuppliedBackgroundType.toLocaleLowerCase()) {
|
|
85
|
+
throw new bad_request_error_1.BadRequestError('Background submission has type but does not match path supplied type');
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
entry.type = pathSuppliedBackgroundType;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
if (!ratchet_common_3.StringRatchet.trimToNull(entry === null || entry === void 0 ? void 0 : entry.type)) {
|
|
93
|
+
throw new bad_request_error_1.BadRequestError('Background submission missing type and not configured in pathed mode');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const foundProc = this.backgroundConfig.processors.find((s) => s.typeName.toLowerCase() === entry.type.toLowerCase());
|
|
97
|
+
const immediate = ratchet_common_2.BooleanRatchet.parseBool(evt.queryStringParameters['immediate']);
|
|
98
|
+
const startProcessor = ratchet_common_2.BooleanRatchet.parseBool(evt.queryStringParameters['startProcessor']);
|
|
99
|
+
if (foundProc) {
|
|
100
|
+
if (ratchet_common_3.StringRatchet.trimToNull(foundProc.dataSchemaName)) {
|
|
101
|
+
const errors = this.modelValidator.validate(foundProc.dataSchemaName, entry.data, false, false);
|
|
102
|
+
if (errors.length > 0) {
|
|
103
|
+
throw new bad_request_error_1.BadRequestError().withErrors(errors);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
let result = null;
|
|
107
|
+
if (immediate) {
|
|
108
|
+
result = await this.backgroundManager.fireImmediateProcessRequest(entry);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
result = await this.backgroundManager.addEntryToQueue(entry, startProcessor);
|
|
112
|
+
}
|
|
113
|
+
rval = {
|
|
114
|
+
processHandling: immediate ? background_process_handling_1.BackgroundProcessHandling.Immediate : background_process_handling_1.BackgroundProcessHandling.Queued,
|
|
115
|
+
startProcessorRequested: startProcessor,
|
|
116
|
+
success: true,
|
|
117
|
+
resultId: result,
|
|
118
|
+
error: null,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
throw new bad_request_error_1.BadRequestError().withFormattedErrorMessage('Could not find target background processor : %s', entry.type);
|
|
123
|
+
}
|
|
124
|
+
return rval;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.BackgroundHttpAdapterHandler = BackgroundHttpAdapterHandler;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackgroundProcessHandling = void 0;
|
|
4
|
+
var BackgroundProcessHandling;
|
|
5
|
+
(function (BackgroundProcessHandling) {
|
|
6
|
+
BackgroundProcessHandling["Queued"] = "Queued";
|
|
7
|
+
BackgroundProcessHandling["Immediate"] = "Immediate";
|
|
8
|
+
})(BackgroundProcessHandling = exports.BackgroundProcessHandling || (exports.BackgroundProcessHandling = {}));
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BackgroundValidator = void 0;
|
|
4
|
+
const ratchet_common_1 = require("@bitblit/ratchet-common");
|
|
5
|
+
const ratchet_common_2 = require("@bitblit/ratchet-common");
|
|
6
|
+
const ratchet_common_3 = require("@bitblit/ratchet-common");
|
|
7
|
+
class BackgroundValidator {
|
|
8
|
+
constructor(cfg, modelValidator) {
|
|
9
|
+
this.cfg = cfg;
|
|
10
|
+
this.modelValidator = modelValidator;
|
|
11
|
+
}
|
|
12
|
+
findProcessor(typeName) {
|
|
13
|
+
const rval = this.cfg.processors.find((s) => s.typeName === typeName);
|
|
14
|
+
return rval;
|
|
15
|
+
}
|
|
16
|
+
validType(type) {
|
|
17
|
+
return !!this.findProcessor(type);
|
|
18
|
+
}
|
|
19
|
+
validateEntry(entry) {
|
|
20
|
+
const rval = [];
|
|
21
|
+
if (!entry) {
|
|
22
|
+
rval.push('Entry is null');
|
|
23
|
+
}
|
|
24
|
+
else if (!ratchet_common_3.StringRatchet.trimToNull(entry.type)) {
|
|
25
|
+
rval.push('Entry type is null or empty');
|
|
26
|
+
const proc = this.findProcessor(entry.type);
|
|
27
|
+
if (!proc) {
|
|
28
|
+
rval.push('Entry type is invalid');
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return rval;
|
|
32
|
+
}
|
|
33
|
+
validateEntryAndThrowException(entry) {
|
|
34
|
+
const errors = this.validateEntry(entry);
|
|
35
|
+
if (errors.length > 0) {
|
|
36
|
+
ratchet_common_1.Logger.warn('Invalid entry %j : errors : %j', entry, errors);
|
|
37
|
+
ratchet_common_2.ErrorRatchet.throwFormattedErr('Invalid entry %j : errors : %j', entry, errors);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
static validateAndMapProcessors(processorInput, modelValidator) {
|
|
41
|
+
const rval = new Map();
|
|
42
|
+
processorInput.forEach((p, idx) => {
|
|
43
|
+
if (!p) {
|
|
44
|
+
ratchet_common_2.ErrorRatchet.throwFormattedErr('Null processor provided at index %d', idx);
|
|
45
|
+
}
|
|
46
|
+
if (!ratchet_common_3.StringRatchet.trimToNull(p.typeName)) {
|
|
47
|
+
ratchet_common_2.ErrorRatchet.throwFormattedErr('Processor at index %d defines no name', idx);
|
|
48
|
+
}
|
|
49
|
+
if (rval.has(p.typeName)) {
|
|
50
|
+
ratchet_common_2.ErrorRatchet.throwFormattedErr('More than one processor defined for type %s', p.typeName);
|
|
51
|
+
}
|
|
52
|
+
rval.set(p.typeName, p);
|
|
53
|
+
});
|
|
54
|
+
return rval;
|
|
55
|
+
}
|
|
56
|
+
static validateAwsConfig(cfg) {
|
|
57
|
+
const rval = [];
|
|
58
|
+
if (!cfg) {
|
|
59
|
+
rval.push('Null config');
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
if (!cfg.notificationArn) {
|
|
63
|
+
rval.push('AWS config missing notificationArn');
|
|
64
|
+
}
|
|
65
|
+
if (!cfg.queueUrl) {
|
|
66
|
+
rval.push('AWS config missing queueUrl');
|
|
67
|
+
}
|
|
68
|
+
if ((cfg.sendNotificationOnBackgroundError || cfg.sendNotificationOnBackgroundValidationFailure) &&
|
|
69
|
+
!cfg.backgroundProcessFailureSnsArn) {
|
|
70
|
+
rval.push('At least one send notification flag set to true but no sns arn set');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return rval;
|
|
74
|
+
}
|
|
75
|
+
static validateConfig(cfg) {
|
|
76
|
+
const rval = [];
|
|
77
|
+
if (!cfg) {
|
|
78
|
+
rval.push('Null config');
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
if (!cfg.processors || cfg.processors.length === 0) {
|
|
82
|
+
rval.push('No processes specified');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return rval;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.BackgroundValidator = BackgroundValidator;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EpsilonBackgroundProcessError = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const util_1 = tslib_1.__importDefault(require("util"));
|
|
6
|
+
class EpsilonBackgroundProcessError extends Error {
|
|
7
|
+
constructor(...errors) {
|
|
8
|
+
super(EpsilonBackgroundProcessError.combineErrorStringsWithDefault(errors));
|
|
9
|
+
Object.setPrototypeOf(this, EpsilonBackgroundProcessError.prototype);
|
|
10
|
+
this._errors = errors;
|
|
11
|
+
this[EpsilonBackgroundProcessError.EPSILON_BACKGROUND_PROCESS_ERROR_FLAG_KEY] = true;
|
|
12
|
+
}
|
|
13
|
+
static combineErrorStringsWithDefault(errors, defMessage = 'Internal Server Error') {
|
|
14
|
+
return errors && errors.length > 0 ? errors.join(',') : defMessage;
|
|
15
|
+
}
|
|
16
|
+
setFormattedErrorMessage(format, ...input) {
|
|
17
|
+
const msg = util_1.default.format(format, ...input);
|
|
18
|
+
this.errors = [msg];
|
|
19
|
+
}
|
|
20
|
+
withFormattedErrorMessage(format, ...input) {
|
|
21
|
+
this.setFormattedErrorMessage(format, ...input);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
withErrors(errors) {
|
|
25
|
+
this.errors = errors;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
withDetailErrorCode(detailErrorCode) {
|
|
29
|
+
this._detailErrorCode = detailErrorCode;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
withDetails(details) {
|
|
33
|
+
this._details = details;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
withRequestId(requestId) {
|
|
37
|
+
this._requestId = requestId;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
withWrappedError(err) {
|
|
41
|
+
this._wrappedError = err;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
isWrappedError() {
|
|
45
|
+
return !!this._wrappedError;
|
|
46
|
+
}
|
|
47
|
+
static wrapError(err) {
|
|
48
|
+
let rval = null;
|
|
49
|
+
if (EpsilonBackgroundProcessError.objectIsEpsilonBackgroundProcessError(err)) {
|
|
50
|
+
rval = err;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
rval = new EpsilonBackgroundProcessError(err.message).withWrappedError(err);
|
|
54
|
+
}
|
|
55
|
+
return rval;
|
|
56
|
+
}
|
|
57
|
+
static objectIsEpsilonBackgroundProcessError(obj) {
|
|
58
|
+
return obj && obj['__epsilonHttpErrorFlag'] === true;
|
|
59
|
+
}
|
|
60
|
+
set errors(value) {
|
|
61
|
+
this._errors = value || ['Internal Server Error'];
|
|
62
|
+
this.message = EpsilonBackgroundProcessError.combineErrorStringsWithDefault(this._errors);
|
|
63
|
+
}
|
|
64
|
+
get errors() {
|
|
65
|
+
return this._errors;
|
|
66
|
+
}
|
|
67
|
+
set detailErrorCode(value) {
|
|
68
|
+
this._detailErrorCode = value;
|
|
69
|
+
}
|
|
70
|
+
get detailErrorCode() {
|
|
71
|
+
return this._detailErrorCode;
|
|
72
|
+
}
|
|
73
|
+
set details(value) {
|
|
74
|
+
this._details = value;
|
|
75
|
+
}
|
|
76
|
+
get details() {
|
|
77
|
+
return this._details;
|
|
78
|
+
}
|
|
79
|
+
set requestId(value) {
|
|
80
|
+
this._requestId = value || 'MISSING';
|
|
81
|
+
}
|
|
82
|
+
get requestId() {
|
|
83
|
+
return this._requestId;
|
|
84
|
+
}
|
|
85
|
+
set wrappedError(value) {
|
|
86
|
+
this._wrappedError = value;
|
|
87
|
+
}
|
|
88
|
+
get wrappedError() {
|
|
89
|
+
return this._wrappedError;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.EpsilonBackgroundProcessError = EpsilonBackgroundProcessError;
|
|
93
|
+
EpsilonBackgroundProcessError.EPSILON_BACKGROUND_PROCESS_ERROR_FLAG_KEY = '__epsilonBackgroundProcessErrorFlag';
|