@h4ad/serverless-adapter 3.0.0 → 3.1.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/README.md +2 -2
- package/lib/@types/binary-settings.d.ts +41 -0
- package/lib/@types/binary-settings.d.ts.map +1 -0
- package/lib/@types/binary-settings.js +1 -1
- package/lib/@types/binary-settings.js.map +1 -1
- package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts +37 -0
- package/lib/@types/digital-ocean/digital-ocean-http-event.d.ts.map +1 -0
- package/lib/@types/digital-ocean/digital-ocean-http-event.js +1 -1
- package/lib/@types/digital-ocean/digital-ocean-http-event.js.map +1 -1
- package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts +22 -0
- package/lib/@types/digital-ocean/digital-ocean-http-response.d.ts.map +1 -0
- package/lib/@types/digital-ocean/digital-ocean-http-response.js +1 -1
- package/lib/@types/digital-ocean/digital-ocean-http-response.js.map +1 -1
- package/lib/@types/digital-ocean/index.d.ts +2 -0
- package/lib/@types/digital-ocean/index.d.ts.map +1 -0
- package/lib/@types/digital-ocean/index.js +1 -1
- package/lib/@types/digital-ocean/index.js.map +1 -1
- package/lib/@types/headers.d.ts +37 -0
- package/lib/@types/headers.d.ts.map +1 -0
- package/lib/@types/headers.js +1 -1
- package/lib/@types/headers.js.map +1 -1
- package/lib/@types/helpers.d.ts +10 -0
- package/lib/@types/helpers.d.ts.map +1 -0
- package/lib/@types/helpers.js +1 -1
- package/lib/@types/helpers.js.map +1 -1
- package/lib/@types/huawei/huawei-api-gateway-event.d.ts +81 -0
- package/lib/@types/huawei/huawei-api-gateway-event.d.ts.map +1 -0
- package/lib/@types/huawei/huawei-api-gateway-event.js +1 -1
- package/lib/@types/huawei/huawei-api-gateway-event.js.map +1 -1
- package/lib/@types/huawei/huawei-api-gateway-response.d.ts +27 -0
- package/lib/@types/huawei/huawei-api-gateway-response.d.ts.map +1 -0
- package/lib/@types/huawei/huawei-api-gateway-response.js +1 -1
- package/lib/@types/huawei/huawei-api-gateway-response.js.map +1 -1
- package/lib/@types/huawei/huawei-context.d.ts +188 -0
- package/lib/@types/huawei/huawei-context.d.ts.map +1 -0
- package/lib/@types/huawei/huawei-context.js +1 -1
- package/lib/@types/huawei/huawei-context.js.map +1 -1
- package/lib/@types/huawei/index.d.ts +4 -0
- package/lib/@types/huawei/index.d.ts.map +1 -0
- package/lib/@types/huawei/index.js +1 -1
- package/lib/@types/huawei/index.js.map +1 -1
- package/lib/@types/index.d.ts +4 -0
- package/lib/@types/index.d.ts.map +1 -0
- package/lib/@types/index.js +1 -1
- package/lib/@types/index.js.map +1 -1
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts +56 -0
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.d.ts.map +1 -0
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js +1 -1
- package/lib/adapters/apollo-server/apollo-server-mutation.adapter.js.map +1 -1
- package/lib/adapters/apollo-server/index.d.ts +2 -0
- package/lib/adapters/apollo-server/index.d.ts.map +1 -0
- package/lib/adapters/apollo-server/index.js +1 -1
- package/lib/adapters/apollo-server/index.js.map +1 -1
- package/lib/adapters/aws/alb.adapter.d.ts +71 -0
- package/lib/adapters/aws/alb.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/alb.adapter.js +1 -1
- package/lib/adapters/aws/alb.adapter.js.map +1 -1
- package/lib/adapters/aws/api-gateway-v1.adapter.d.ts +76 -0
- package/lib/adapters/aws/api-gateway-v1.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/api-gateway-v1.adapter.js +1 -1
- package/lib/adapters/aws/api-gateway-v1.adapter.js.map +1 -1
- package/lib/adapters/aws/api-gateway-v2.adapter.d.ts +75 -0
- package/lib/adapters/aws/api-gateway-v2.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/api-gateway-v2.adapter.js +1 -1
- package/lib/adapters/aws/api-gateway-v2.adapter.js.map +1 -1
- package/lib/adapters/aws/base/aws-simple-adapter.d.ts +83 -0
- package/lib/adapters/aws/base/aws-simple-adapter.d.ts.map +1 -0
- package/lib/adapters/aws/base/aws-simple-adapter.js +1 -1
- package/lib/adapters/aws/base/aws-simple-adapter.js.map +1 -1
- package/lib/adapters/aws/base/index.d.ts +2 -0
- package/lib/adapters/aws/base/index.d.ts.map +1 -0
- package/lib/adapters/aws/base/index.js +1 -1
- package/lib/adapters/aws/base/index.js.map +1 -1
- package/lib/adapters/aws/dynamodb.adapter.d.ts +56 -0
- package/lib/adapters/aws/dynamodb.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/dynamodb.adapter.js +1 -1
- package/lib/adapters/aws/dynamodb.adapter.js.map +1 -1
- package/lib/adapters/aws/event-bridge.adapter.d.ts +63 -0
- package/lib/adapters/aws/event-bridge.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/event-bridge.adapter.js +1 -1
- package/lib/adapters/aws/event-bridge.adapter.js.map +1 -1
- package/lib/adapters/aws/index.d.ts +12 -0
- package/lib/adapters/aws/index.d.ts.map +1 -0
- package/lib/adapters/aws/index.js +1 -1
- package/lib/adapters/aws/index.js.map +1 -1
- package/lib/adapters/aws/lambda-edge.adapter.d.ts +209 -0
- package/lib/adapters/aws/lambda-edge.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/lambda-edge.adapter.js +1 -1
- package/lib/adapters/aws/lambda-edge.adapter.js.map +1 -1
- package/lib/adapters/aws/request-lambda-edge.adapter.d.ts +131 -0
- package/lib/adapters/aws/request-lambda-edge.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/request-lambda-edge.adapter.js +2 -0
- package/lib/adapters/aws/request-lambda-edge.adapter.js.map +1 -0
- package/lib/adapters/aws/s3.adapter.d.ts +56 -0
- package/lib/adapters/aws/s3.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/s3.adapter.js +1 -1
- package/lib/adapters/aws/s3.adapter.js.map +1 -1
- package/lib/adapters/aws/sns.adapter.d.ts +56 -0
- package/lib/adapters/aws/sns.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/sns.adapter.js +1 -1
- package/lib/adapters/aws/sns.adapter.js.map +1 -1
- package/lib/adapters/aws/sqs.adapter.d.ts +56 -0
- package/lib/adapters/aws/sqs.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/sqs.adapter.js +1 -1
- package/lib/adapters/aws/sqs.adapter.js.map +1 -1
- package/lib/adapters/azure/http-trigger-v4.adapter.d.ts +81 -0
- package/lib/adapters/azure/http-trigger-v4.adapter.d.ts.map +1 -0
- package/lib/adapters/azure/http-trigger-v4.adapter.js +1 -1
- package/lib/adapters/azure/http-trigger-v4.adapter.js.map +1 -1
- package/lib/adapters/azure/index.d.ts +2 -0
- package/lib/adapters/azure/index.d.ts.map +1 -0
- package/lib/adapters/azure/index.js +1 -1
- package/lib/adapters/azure/index.js.map +1 -1
- package/lib/adapters/digital-ocean/http-function.adapter.d.ts +65 -0
- package/lib/adapters/digital-ocean/http-function.adapter.d.ts.map +1 -0
- package/lib/adapters/digital-ocean/http-function.adapter.js +1 -1
- package/lib/adapters/digital-ocean/http-function.adapter.js.map +1 -1
- package/lib/adapters/digital-ocean/index.d.ts +2 -0
- package/lib/adapters/digital-ocean/index.d.ts.map +1 -0
- package/lib/adapters/digital-ocean/index.js +1 -1
- package/lib/adapters/digital-ocean/index.js.map +1 -1
- package/lib/adapters/dummy/dummy.adapter.d.ts +31 -0
- package/lib/adapters/dummy/dummy.adapter.d.ts.map +1 -0
- package/lib/adapters/dummy/dummy.adapter.js +1 -1
- package/lib/adapters/dummy/dummy.adapter.js.map +1 -1
- package/lib/adapters/dummy/index.d.ts +2 -0
- package/lib/adapters/dummy/index.d.ts.map +1 -0
- package/lib/adapters/dummy/index.js +1 -1
- package/lib/adapters/dummy/index.js.map +1 -1
- package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts +66 -0
- package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts.map +1 -0
- package/lib/adapters/huawei/huawei-api-gateway.adapter.js +1 -1
- package/lib/adapters/huawei/huawei-api-gateway.adapter.js.map +1 -1
- package/lib/adapters/huawei/index.d.ts +2 -0
- package/lib/adapters/huawei/index.d.ts.map +1 -0
- package/lib/adapters/huawei/index.js +1 -1
- package/lib/adapters/huawei/index.js.map +1 -1
- package/lib/contracts/adapter.contract.d.ts +152 -0
- package/lib/contracts/adapter.contract.d.ts.map +1 -0
- package/lib/contracts/adapter.contract.js +1 -1
- package/lib/contracts/adapter.contract.js.map +1 -1
- package/lib/contracts/framework.contract.d.ts +19 -0
- package/lib/contracts/framework.contract.d.ts.map +1 -0
- package/lib/contracts/framework.contract.js +1 -1
- package/lib/contracts/framework.contract.js.map +1 -1
- package/lib/contracts/handler.contract.d.ts +25 -0
- package/lib/contracts/handler.contract.d.ts.map +1 -0
- package/lib/contracts/handler.contract.js +1 -1
- package/lib/contracts/handler.contract.js.map +1 -1
- package/lib/contracts/index.d.ts +5 -0
- package/lib/contracts/index.d.ts.map +1 -0
- package/lib/contracts/index.js +1 -1
- package/lib/contracts/index.js.map +1 -1
- package/lib/contracts/resolver.contract.d.ts +83 -0
- package/lib/contracts/resolver.contract.d.ts.map +1 -0
- package/lib/contracts/resolver.contract.js +1 -1
- package/lib/contracts/resolver.contract.js.map +1 -1
- package/lib/core/base-handler.d.ts +32 -0
- package/lib/core/base-handler.d.ts.map +1 -0
- package/lib/core/base-handler.js +1 -1
- package/lib/core/base-handler.js.map +1 -1
- package/lib/core/constants.d.ts +31 -0
- package/lib/core/constants.d.ts.map +1 -0
- package/lib/core/constants.js +1 -1
- package/lib/core/constants.js.map +1 -1
- package/lib/core/current-invoke.d.ts +48 -0
- package/lib/core/current-invoke.d.ts.map +1 -0
- package/lib/core/current-invoke.js +1 -1
- package/lib/core/current-invoke.js.map +1 -1
- package/lib/core/event-body.d.ts +22 -0
- package/lib/core/event-body.d.ts.map +1 -0
- package/lib/core/event-body.js +1 -1
- package/lib/core/event-body.js.map +1 -1
- package/lib/core/headers.d.ts +73 -0
- package/lib/core/headers.d.ts.map +1 -0
- package/lib/core/headers.js +2 -2
- package/lib/core/headers.js.map +1 -1
- package/lib/core/index.d.ts +12 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/index.js +1 -1
- package/lib/core/index.js.map +1 -1
- package/lib/core/is-binary.d.ts +73 -0
- package/lib/core/is-binary.d.ts.map +1 -0
- package/lib/core/is-binary.js +1 -1
- package/lib/core/is-binary.js.map +1 -1
- package/lib/core/logger.d.ts +64 -0
- package/lib/core/logger.d.ts.map +1 -0
- package/lib/core/logger.js +1 -1
- package/lib/core/logger.js.map +1 -1
- package/lib/core/no-op.d.ts +8 -0
- package/lib/core/no-op.d.ts.map +1 -0
- package/lib/core/no-op.js +1 -1
- package/lib/core/no-op.js.map +1 -1
- package/lib/core/optional.d.ts +22 -0
- package/lib/core/optional.d.ts.map +1 -0
- package/lib/core/optional.js +1 -1
- package/lib/core/optional.js.map +1 -1
- package/lib/core/path.d.ts +53 -0
- package/lib/core/path.d.ts.map +1 -0
- package/lib/core/path.js +1 -1
- package/lib/core/path.js.map +1 -1
- package/lib/core/stream.d.ts +21 -0
- package/lib/core/stream.d.ts.map +1 -0
- package/lib/core/stream.js +1 -1
- package/lib/core/stream.js.map +1 -1
- package/lib/frameworks/apollo-server/apollo-server.framework.d.ts +69 -0
- package/lib/frameworks/apollo-server/apollo-server.framework.d.ts.map +1 -0
- package/lib/frameworks/apollo-server/apollo-server.framework.js +1 -1
- package/lib/frameworks/apollo-server/apollo-server.framework.js.map +1 -1
- package/lib/frameworks/apollo-server/index.d.ts +2 -0
- package/lib/frameworks/apollo-server/index.d.ts.map +1 -0
- package/lib/frameworks/apollo-server/index.js +1 -1
- package/lib/frameworks/apollo-server/index.js.map +1 -1
- package/lib/frameworks/body-parser/base-body-parser.framework.d.ts +69 -0
- package/lib/frameworks/body-parser/base-body-parser.framework.d.ts.map +1 -0
- package/lib/frameworks/body-parser/base-body-parser.framework.js +1 -1
- package/lib/frameworks/body-parser/base-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/index.d.ts +6 -0
- package/lib/frameworks/body-parser/index.d.ts.map +1 -0
- package/lib/frameworks/body-parser/index.js +1 -1
- package/lib/frameworks/body-parser/index.js.map +1 -1
- package/lib/frameworks/body-parser/json-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/json-body-parser.framework.d.ts.map +1 -0
- package/lib/frameworks/body-parser/json-body-parser.framework.js +1 -1
- package/lib/frameworks/body-parser/json-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/raw-body-parser.framework.d.ts.map +1 -0
- package/lib/frameworks/body-parser/raw-body-parser.framework.js +1 -1
- package/lib/frameworks/body-parser/raw-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/text-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/text-body-parser.framework.d.ts.map +1 -0
- package/lib/frameworks/body-parser/text-body-parser.framework.js +1 -1
- package/lib/frameworks/body-parser/text-body-parser.framework.js.map +1 -1
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts +26 -0
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.d.ts.map +1 -0
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js +1 -1
- package/lib/frameworks/body-parser/urlencoded-body-parser.framework.js.map +1 -1
- package/lib/frameworks/cors/cors.framework.d.ts +78 -0
- package/lib/frameworks/cors/cors.framework.d.ts.map +1 -0
- package/lib/frameworks/cors/cors.framework.js +2 -2
- package/lib/frameworks/cors/cors.framework.js.map +1 -1
- package/lib/frameworks/cors/index.d.ts +2 -0
- package/lib/frameworks/cors/index.d.ts.map +1 -0
- package/lib/frameworks/cors/index.js +1 -1
- package/lib/frameworks/cors/index.js.map +1 -1
- package/lib/frameworks/deepkit/http-deepkit.framework.d.ts +18 -0
- package/lib/frameworks/deepkit/http-deepkit.framework.d.ts.map +1 -0
- package/lib/frameworks/deepkit/http-deepkit.framework.js +1 -1
- package/lib/frameworks/deepkit/http-deepkit.framework.js.map +1 -1
- package/lib/frameworks/deepkit/index.d.ts +2 -0
- package/lib/frameworks/deepkit/index.d.ts.map +1 -0
- package/lib/frameworks/deepkit/index.js +1 -1
- package/lib/frameworks/deepkit/index.js.map +1 -1
- package/lib/frameworks/express/express.framework.d.ts +17 -0
- package/lib/frameworks/express/express.framework.d.ts.map +1 -0
- package/lib/frameworks/express/express.framework.js +1 -1
- package/lib/frameworks/express/express.framework.js.map +1 -1
- package/lib/frameworks/express/index.d.ts +2 -0
- package/lib/frameworks/express/index.d.ts.map +1 -0
- package/lib/frameworks/express/index.js +1 -1
- package/lib/frameworks/express/index.js.map +1 -1
- package/lib/frameworks/fastify/fastify.framework.d.ts +17 -0
- package/lib/frameworks/fastify/fastify.framework.d.ts.map +1 -0
- package/lib/frameworks/fastify/fastify.framework.js +1 -1
- package/lib/frameworks/fastify/fastify.framework.js.map +1 -1
- package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts +14 -0
- package/lib/frameworks/fastify/helpers/no-op-content-parser.d.ts.map +1 -0
- package/lib/frameworks/fastify/helpers/no-op-content-parser.js +1 -1
- package/lib/frameworks/fastify/helpers/no-op-content-parser.js.map +1 -1
- package/lib/frameworks/fastify/index.d.ts +2 -0
- package/lib/frameworks/fastify/index.d.ts.map +1 -0
- package/lib/frameworks/fastify/index.js +1 -1
- package/lib/frameworks/fastify/index.js.map +1 -1
- package/lib/frameworks/hapi/hapi.framework.d.ts +17 -0
- package/lib/frameworks/hapi/hapi.framework.d.ts.map +1 -0
- package/lib/frameworks/hapi/hapi.framework.js +1 -1
- package/lib/frameworks/hapi/hapi.framework.js.map +1 -1
- package/lib/frameworks/hapi/index.d.ts +2 -0
- package/lib/frameworks/hapi/index.d.ts.map +1 -0
- package/lib/frameworks/hapi/index.js +1 -1
- package/lib/frameworks/hapi/index.js.map +1 -1
- package/lib/frameworks/koa/index.d.ts +2 -0
- package/lib/frameworks/koa/index.d.ts.map +1 -0
- package/lib/frameworks/koa/index.js +1 -1
- package/lib/frameworks/koa/index.js.map +1 -1
- package/lib/frameworks/koa/koa.framework.d.ts +17 -0
- package/lib/frameworks/koa/koa.framework.d.ts.map +1 -0
- package/lib/frameworks/koa/koa.framework.js +1 -1
- package/lib/frameworks/koa/koa.framework.js.map +1 -1
- package/lib/frameworks/lazy/index.d.ts +2 -0
- package/lib/frameworks/lazy/index.d.ts.map +1 -0
- package/lib/frameworks/lazy/index.js +1 -1
- package/lib/frameworks/lazy/index.js.map +1 -1
- package/lib/frameworks/lazy/lazy.framework.d.ts +56 -0
- package/lib/frameworks/lazy/lazy.framework.d.ts.map +1 -0
- package/lib/frameworks/lazy/lazy.framework.js +1 -1
- package/lib/frameworks/lazy/lazy.framework.js.map +1 -1
- package/lib/frameworks/trpc/index.d.ts +2 -0
- package/lib/frameworks/trpc/index.d.ts.map +1 -0
- package/lib/frameworks/trpc/index.js +1 -1
- package/lib/frameworks/trpc/index.js.map +1 -1
- package/lib/frameworks/trpc/trpc.framework.d.ts +153 -0
- package/lib/frameworks/trpc/trpc.framework.d.ts.map +1 -0
- package/lib/frameworks/trpc/trpc.framework.js +1 -1
- package/lib/frameworks/trpc/trpc.framework.js.map +1 -1
- package/lib/handlers/aws/aws-stream.handler.d.ts +89 -0
- package/lib/handlers/aws/aws-stream.handler.d.ts.map +1 -0
- package/lib/handlers/aws/aws-stream.handler.js +1 -1
- package/lib/handlers/aws/aws-stream.handler.js.map +1 -1
- package/lib/handlers/aws/index.d.ts +2 -0
- package/lib/handlers/aws/index.d.ts.map +1 -0
- package/lib/handlers/aws/index.js +1 -1
- package/lib/handlers/aws/index.js.map +1 -1
- package/lib/handlers/azure/azure.handler.d.ts +45 -0
- package/lib/handlers/azure/azure.handler.d.ts.map +1 -0
- package/lib/handlers/azure/azure.handler.js +1 -1
- package/lib/handlers/azure/azure.handler.js.map +1 -1
- package/lib/handlers/azure/index.d.ts +2 -0
- package/lib/handlers/azure/index.d.ts.map +1 -0
- package/lib/handlers/azure/index.js +1 -1
- package/lib/handlers/azure/index.js.map +1 -1
- package/lib/handlers/base/index.d.ts +2 -0
- package/lib/handlers/base/index.d.ts.map +1 -0
- package/lib/handlers/base/index.js +1 -1
- package/lib/handlers/base/index.js.map +1 -1
- package/lib/handlers/base/raw-request.d.ts +31 -0
- package/lib/handlers/base/raw-request.d.ts.map +1 -0
- package/lib/handlers/base/raw-request.js +1 -1
- package/lib/handlers/base/raw-request.js.map +1 -1
- package/lib/handlers/default/default.handler.d.ts +88 -0
- package/lib/handlers/default/default.handler.d.ts.map +1 -0
- package/lib/handlers/default/default.handler.js +1 -1
- package/lib/handlers/default/default.handler.js.map +1 -1
- package/lib/handlers/default/index.d.ts +2 -0
- package/lib/handlers/default/index.d.ts.map +1 -0
- package/lib/handlers/default/index.js +1 -1
- package/lib/handlers/default/index.js.map +1 -1
- package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts +17 -0
- package/lib/handlers/digital-ocean/digital-ocean.handler.d.ts.map +1 -0
- package/lib/handlers/digital-ocean/digital-ocean.handler.js +1 -1
- package/lib/handlers/digital-ocean/digital-ocean.handler.js.map +1 -1
- package/lib/handlers/digital-ocean/index.d.ts +2 -0
- package/lib/handlers/digital-ocean/index.d.ts.map +1 -0
- package/lib/handlers/digital-ocean/index.js +1 -1
- package/lib/handlers/digital-ocean/index.js.map +1 -1
- package/lib/handlers/firebase/http-firebase-v2.handler.d.ts +27 -0
- package/lib/handlers/firebase/http-firebase-v2.handler.d.ts.map +1 -0
- package/lib/handlers/firebase/http-firebase-v2.handler.js +1 -1
- package/lib/handlers/firebase/http-firebase-v2.handler.js.map +1 -1
- package/lib/handlers/firebase/http-firebase.handler.d.ts +19 -0
- package/lib/handlers/firebase/http-firebase.handler.d.ts.map +1 -0
- package/lib/handlers/firebase/http-firebase.handler.js +1 -1
- package/lib/handlers/firebase/http-firebase.handler.js.map +1 -1
- package/lib/handlers/firebase/index.d.ts +3 -0
- package/lib/handlers/firebase/index.d.ts.map +1 -0
- package/lib/handlers/firebase/index.js +1 -1
- package/lib/handlers/firebase/index.js.map +1 -1
- package/lib/handlers/gcp/gcp.handler.d.ts +26 -0
- package/lib/handlers/gcp/gcp.handler.d.ts.map +1 -0
- package/lib/handlers/gcp/gcp.handler.js +1 -1
- package/lib/handlers/gcp/gcp.handler.js.map +1 -1
- package/lib/handlers/gcp/index.d.ts +2 -0
- package/lib/handlers/gcp/index.d.ts.map +1 -0
- package/lib/handlers/gcp/index.js +1 -1
- package/lib/handlers/gcp/index.js.map +1 -1
- package/lib/handlers/huawei/http-huawei.handler.d.ts +59 -0
- package/lib/handlers/huawei/http-huawei.handler.d.ts.map +1 -0
- package/lib/handlers/huawei/http-huawei.handler.js +1 -1
- package/lib/handlers/huawei/http-huawei.handler.js.map +1 -1
- package/lib/handlers/huawei/index.d.ts +2 -0
- package/lib/handlers/huawei/index.d.ts.map +1 -0
- package/lib/handlers/huawei/index.js +1 -1
- package/lib/handlers/huawei/index.js.map +1 -1
- package/lib/index.d.ts +6 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.doc.js +1 -1
- package/lib/index.doc.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/network/index.d.ts +5 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.js +1 -1
- package/lib/network/index.js.map +1 -1
- package/lib/network/request.d.ts +44 -0
- package/lib/network/request.d.ts.map +1 -0
- package/lib/network/request.js +1 -1
- package/lib/network/request.js.map +1 -1
- package/lib/network/response-stream.d.ts +41 -0
- package/lib/network/response-stream.d.ts.map +1 -0
- package/lib/network/response-stream.js +4 -4
- package/lib/network/response-stream.js.map +1 -1
- package/lib/network/response.d.ts +48 -0
- package/lib/network/response.d.ts.map +1 -0
- package/lib/network/response.js +2 -2
- package/lib/network/response.js.map +1 -1
- package/lib/network/utils.d.ts +9 -0
- package/lib/network/utils.d.ts.map +1 -0
- package/lib/network/utils.js +1 -1
- package/lib/network/utils.js.map +1 -1
- package/lib/resolvers/aws-context/aws-context.resolver.d.ts +19 -0
- package/lib/resolvers/aws-context/aws-context.resolver.d.ts.map +1 -0
- package/lib/resolvers/aws-context/aws-context.resolver.js +1 -1
- package/lib/resolvers/aws-context/aws-context.resolver.js.map +1 -1
- package/lib/resolvers/aws-context/index.d.ts +2 -0
- package/lib/resolvers/aws-context/index.d.ts.map +1 -0
- package/lib/resolvers/aws-context/index.js +1 -1
- package/lib/resolvers/aws-context/index.js.map +1 -1
- package/lib/resolvers/callback/callback.resolver.d.ts +23 -0
- package/lib/resolvers/callback/callback.resolver.d.ts.map +1 -0
- package/lib/resolvers/callback/callback.resolver.js +1 -1
- package/lib/resolvers/callback/callback.resolver.js.map +1 -1
- package/lib/resolvers/callback/index.d.ts +2 -0
- package/lib/resolvers/callback/index.d.ts.map +1 -0
- package/lib/resolvers/callback/index.js +1 -1
- package/lib/resolvers/callback/index.js.map +1 -1
- package/lib/resolvers/dummy/dummy.resolver.d.ts +14 -0
- package/lib/resolvers/dummy/dummy.resolver.d.ts.map +1 -0
- package/lib/resolvers/dummy/dummy.resolver.js +1 -1
- package/lib/resolvers/dummy/dummy.resolver.js.map +1 -1
- package/lib/resolvers/dummy/index.d.ts +2 -0
- package/lib/resolvers/dummy/index.d.ts.map +1 -0
- package/lib/resolvers/dummy/index.js +1 -1
- package/lib/resolvers/dummy/index.js.map +1 -1
- package/lib/resolvers/promise/index.d.ts +2 -0
- package/lib/resolvers/promise/index.d.ts.map +1 -0
- package/lib/resolvers/promise/index.js +1 -1
- package/lib/resolvers/promise/index.js.map +1 -1
- package/lib/resolvers/promise/promise.resolver.d.ts +14 -0
- package/lib/resolvers/promise/promise.resolver.d.ts.map +1 -0
- package/lib/resolvers/promise/promise.resolver.js +1 -1
- package/lib/resolvers/promise/promise.resolver.js.map +1 -1
- package/lib/serverless-adapter.d.ts +119 -0
- package/lib/serverless-adapter.d.ts.map +1 -0
- package/lib/serverless-adapter.js +1 -1
- package/lib/serverless-adapter.js.map +1 -1
- package/package.json +2 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),current_invoke_exports={};__export(current_invoke_exports,{getCurrentInvoke:()=>getCurrentInvoke,setCurrentInvoke:()=>setCurrentInvoke});module.exports=__toCommonJS(current_invoke_exports);const currentInvoke={context:null,event:null};function getCurrentInvoke(){return currentInvoke}function setCurrentInvoke({event,context}){currentInvoke.event=event,currentInvoke.context=context}
|
|
2
2
|
//# sourceMappingURL=current-invoke.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"current-invoke.js","sources":["../../src/core/current-invoke.ts"],"sourcesContent":["/**\n * The type that represents the object that handles the references to the event created by the serverless trigger or context created by the serverless environment.\n *\n * @breadcrumb Core / Current Invoke\n * @public\n */\nexport type CurrentInvoke<TEvent, TContext> = {\n /**\n * The event created by the serverless trigger\n *\n * @remarks It's only null when you call {@link getCurrentInvoke} outside this library's pipeline.\n */\n event: TEvent | null;\n\n /**\n * The context created by the serverless environment\n *\n * @remarks It's only null when you call {@link getCurrentInvoke} outside this library's pipeline.\n */\n context: TContext | null;\n};\n\nconst currentInvoke: CurrentInvoke<any, any> = {\n context: null,\n event: null,\n};\n\n/**\n * Get the reference to the event created by the serverless trigger or context created by the serverless environment.\n *\n * @example\n * ```typescript\n * import type { ALBEvent, Context } from 'aws-lambda';\n *\n * // inside the method that handles the aws alb request.\n * const { event, context } = getCurrentInvoke<ALBEvent, Context>();\n * ```\n *\n * @breadcrumb Core / Current Invoke\n * @public\n */\nexport function getCurrentInvoke<TEvent = any, TContext = any>(): CurrentInvoke<\n TEvent,\n TContext\n> {\n return currentInvoke;\n}\n\n/**\n * Method that saves to the event created by the serverless trigger or context created by the serverless environment.\n *\n * @remarks This method MUST NOT be called by you, this method MUST only be used internally in this library.\n *\n * @param event - The event created by the serverless trigger\n * @param context - The context created by the serverless environment\n *\n * @breadcrumb Core / Current Invoke\n * @public\n */\nexport function setCurrentInvoke<TEvent = any, TContext = any>({\n event,\n context,\n}: CurrentInvoke<TEvent, TContext>) {\n currentInvoke.event = event;\n currentInvoke.context = context;\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"current-invoke.js","sources":["../../src/core/current-invoke.ts"],"sourcesContent":["/**\n * The type that represents the object that handles the references to the event created by the serverless trigger or context created by the serverless environment.\n *\n * @breadcrumb Core / Current Invoke\n * @public\n */\nexport type CurrentInvoke<TEvent, TContext> = {\n /**\n * The event created by the serverless trigger\n *\n * @remarks It's only null when you call {@link getCurrentInvoke} outside this library's pipeline.\n */\n event: TEvent | null;\n\n /**\n * The context created by the serverless environment\n *\n * @remarks It's only null when you call {@link getCurrentInvoke} outside this library's pipeline.\n */\n context: TContext | null;\n};\n\nconst currentInvoke: CurrentInvoke<any, any> = {\n context: null,\n event: null,\n};\n\n/**\n * Get the reference to the event created by the serverless trigger or context created by the serverless environment.\n *\n * @example\n * ```typescript\n * import type { ALBEvent, Context } from 'aws-lambda';\n *\n * // inside the method that handles the aws alb request.\n * const { event, context } = getCurrentInvoke<ALBEvent, Context>();\n * ```\n *\n * @breadcrumb Core / Current Invoke\n * @public\n */\nexport function getCurrentInvoke<TEvent = any, TContext = any>(): CurrentInvoke<\n TEvent,\n TContext\n> {\n return currentInvoke;\n}\n\n/**\n * Method that saves to the event created by the serverless trigger or context created by the serverless environment.\n *\n * @remarks This method MUST NOT be called by you, this method MUST only be used internally in this library.\n *\n * @param event - The event created by the serverless trigger\n * @param context - The context created by the serverless environment\n *\n * @breadcrumb Core / Current Invoke\n * @public\n */\nexport function setCurrentInvoke<TEvent = any, TContext = any>({\n event,\n context,\n}: CurrentInvoke<TEvent, TContext>) {\n currentInvoke.event = event;\n currentInvoke.context = context;\n}\n"],"names":[],"mappings":"ooBAAA,uBAAA,CAAA,EAAA,SAAA,uBAAA,CAAA,iBAAA,IAAA,iBAAA,iBAAA,IAAA,gBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,sBAAA,EAsBA,MAAM,cAAyC,CAC7C,QAAS,KACT,MAAO,IACT,EAgBO,SAAS,kBAGd,CACO,OAAA,aACT,CAaO,SAAS,iBAA+C,CAC7D,MACA,OACF,EAAoC,CAClC,cAAc,MAAQ,MACtB,cAAc,QAAU,OAC1B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* Get the event body as buffer from body string with content length
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const body = '{}';
|
|
8
|
+
* const [buffer, contentLength] = getEventBodyAsBuffer(body, false);
|
|
9
|
+
* console.log(buffer);
|
|
10
|
+
* // <Buffer 7b 7d>
|
|
11
|
+
* console.log(contentLength);
|
|
12
|
+
* // 2
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param body - The body string that can be encoded or not
|
|
16
|
+
* @param isBase64Encoded - Tells if body string is encoded in base64
|
|
17
|
+
*
|
|
18
|
+
* @breadcrumb Core
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function getEventBodyAsBuffer(body: string, isBase64Encoded: boolean): [body: Buffer, contentLength: number];
|
|
22
|
+
//# sourceMappingURL=event-body.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-body.d.ts","sourceRoot":"","sources":["../../src/core/event-body.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,OAAO,GACvB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,CAAC,CAOvC"}
|
package/lib/core/event-body.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),event_body_exports={};__export(event_body_exports,{getEventBodyAsBuffer:()=>getEventBodyAsBuffer});module.exports=__toCommonJS(event_body_exports);function getEventBodyAsBuffer(body,isBase64Encoded){const encoding=isBase64Encoded?"base64":"utf8",buffer=Buffer.from(body,encoding),contentLength=Buffer.byteLength(buffer,encoding);return[buffer,contentLength]}
|
|
2
2
|
//# sourceMappingURL=event-body.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-body.js","sources":["../../src/core/event-body.ts"],"sourcesContent":["/**\n * Get the event body as buffer from body string with content length\n *\n * @example\n * ```typescript\n * const body = '{}';\n * const [buffer, contentLength] = getEventBodyAsBuffer(body, false);\n * console.log(buffer);\n * // <Buffer 7b 7d>\n * console.log(contentLength);\n * // 2\n * ```\n *\n * @param body - The body string that can be encoded or not\n * @param isBase64Encoded - Tells if body string is encoded in base64\n *\n * @breadcrumb Core\n * @public\n */\nexport function getEventBodyAsBuffer(\n body: string,\n isBase64Encoded: boolean,\n): [body: Buffer, contentLength: number] {\n const encoding: BufferEncoding = isBase64Encoded ? 'base64' : 'utf8';\n\n const buffer = Buffer.from(body, encoding);\n const contentLength = Buffer.byteLength(buffer, encoding);\n\n return [buffer, contentLength];\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"event-body.js","sources":["../../src/core/event-body.ts"],"sourcesContent":["/**\n * Get the event body as buffer from body string with content length\n *\n * @example\n * ```typescript\n * const body = '{}';\n * const [buffer, contentLength] = getEventBodyAsBuffer(body, false);\n * console.log(buffer);\n * // <Buffer 7b 7d>\n * console.log(contentLength);\n * // 2\n * ```\n *\n * @param body - The body string that can be encoded or not\n * @param isBase64Encoded - Tells if body string is encoded in base64\n *\n * @breadcrumb Core\n * @public\n */\nexport function getEventBodyAsBuffer(\n body: string,\n isBase64Encoded: boolean,\n): [body: Buffer, contentLength: number] {\n const encoding: BufferEncoding = isBase64Encoded ? 'base64' : 'utf8';\n\n const buffer = Buffer.from(body, encoding);\n const contentLength = Buffer.byteLength(buffer, encoding);\n\n return [buffer, contentLength];\n}\n"],"names":[],"mappings":"ooBAAA,mBAAA,CAAA,EAAA,SAAA,mBAAA,CAAA,qBAAA,IAAA,oBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,kBAAA,EAmBO,SAAS,qBACd,KACA,gBACuC,CACjC,MAAA,SAA2B,gBAAkB,SAAW,OAExD,OAAS,OAAO,KAAK,KAAM,QAAQ,EACnC,cAAgB,OAAO,WAAW,OAAQ,QAAQ,EAEjD,MAAA,CAAC,OAAQ,aAAa,CAC/B"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BothValueHeaders } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* Transform a header map and make sure the value is not an array
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const headers = { 'accept-encoding': 'gzip', 'accept-language': ['en-US', 'en;q=0.9'] };
|
|
8
|
+
* const flattenedHeaders = getFlattenedHeadersMap(headers, ',', true);
|
|
9
|
+
* console.log(flattenedHeaders);
|
|
10
|
+
* // { 'accept-encoding': 'gzip', 'accept-language': 'en-US,en;q=0.9' }
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param headersMap - The initial headers
|
|
14
|
+
* @param separator - The separator used when we join the array of header's value
|
|
15
|
+
* @param lowerCaseKey - Should put all keys in lowercase
|
|
16
|
+
*
|
|
17
|
+
* @breadcrumb Core / Headers
|
|
18
|
+
* @public
|
|
19
|
+
*/
|
|
20
|
+
export declare function getFlattenedHeadersMap(headersMap: BothValueHeaders, separator?: string, lowerCaseKey?: boolean): Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* Transforms a header map into a multi-value map header.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* const headers = { 'accept-encoding': 'gzip', 'connection': ['keep-alive'] };
|
|
27
|
+
* const multiValueHeaders = getMultiValueHeadersMap(headers);
|
|
28
|
+
* console.log(multiValueHeaders);
|
|
29
|
+
* // { 'accept-encoding': ['gzip'], 'connection': ['keep-alive'] }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param headersMap - The initial headers
|
|
33
|
+
*
|
|
34
|
+
* @breadcrumb Core / Headers
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare function getMultiValueHeadersMap(headersMap: BothValueHeaders): Record<string, string[]>;
|
|
38
|
+
/**
|
|
39
|
+
* The wrapper that holds the information about single value headers and cookies
|
|
40
|
+
*
|
|
41
|
+
* @breadcrumb Core / Headers
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export type FlattenedHeadersAndCookies = {
|
|
45
|
+
/**
|
|
46
|
+
* Just the single value headers
|
|
47
|
+
*/
|
|
48
|
+
headers: Record<string, string>;
|
|
49
|
+
/**
|
|
50
|
+
* The list of cookies
|
|
51
|
+
*/
|
|
52
|
+
cookies: string[];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Transforms a header map into a single value headers and cookies
|
|
56
|
+
*
|
|
57
|
+
* @param headersMap - The initial headers
|
|
58
|
+
*
|
|
59
|
+
* @breadcrumb Core / Headers
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
export declare function getFlattenedHeadersMapAndCookies(headersMap: BothValueHeaders): FlattenedHeadersAndCookies;
|
|
63
|
+
/**
|
|
64
|
+
* Parse HTTP Raw Headers
|
|
65
|
+
* Attribution to {@link https://github.com/kesla/parse-headers/blob/master/parse-headers.js}
|
|
66
|
+
*
|
|
67
|
+
* @param headers - The raw headers
|
|
68
|
+
*
|
|
69
|
+
* @breadcrumb Core / Headers
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export declare function parseHeaders(headers: string): Record<string, string | string[]>;
|
|
73
|
+
//# sourceMappingURL=headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../../src/core/headers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,gBAAgB,EAC5B,SAAS,GAAE,MAAY,EACvB,YAAY,GAAE,OAAe,GAC5B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,gBAAgB,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAU1B;AAED;;;;;GAKG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC;;OAEG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAC9C,UAAU,EAAE,gBAAgB,GAC3B,0BAA0B,CAuB5B;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,MAAM,GACd,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAkBnC"}
|
package/lib/core/headers.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`);for(let
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),headers_exports={};__export(headers_exports,{getFlattenedHeadersMap:()=>getFlattenedHeadersMap,getFlattenedHeadersMapAndCookies:()=>getFlattenedHeadersMapAndCookies,getMultiValueHeadersMap:()=>getMultiValueHeadersMap,parseHeaders:()=>parseHeaders});module.exports=__toCommonJS(headers_exports);function getFlattenedHeadersMap(headersMap,separator=",",lowerCaseKey=!1){return Object.keys(headersMap).reduce((acc,headerKey)=>{const newKey=lowerCaseKey?headerKey.toLowerCase():headerKey,headerValue=headersMap[headerKey];return Array.isArray(headerValue)?acc[newKey]=headerValue.join(separator):acc[newKey]=(headerValue??"")+"",acc},{})}function getMultiValueHeadersMap(headersMap){return Object.keys(headersMap).reduce((acc,headerKey)=>{const headerValue=headersMap[headerKey];return acc[headerKey.toLowerCase()]=Array.isArray(headerValue)?headerValue.map(String):[String(headerValue)],acc},{})}function getFlattenedHeadersMapAndCookies(headersMap){return Object.keys(headersMap).reduce((acc,headerKey)=>{const headerValue=headersMap[headerKey],lowerHeaderKey=headerKey.toLowerCase();return Array.isArray(headerValue)?lowerHeaderKey!=="set-cookie"?acc.headers[headerKey]=headerValue.join(","):acc.cookies.push(...headerValue):lowerHeaderKey==="set-cookie"&&headerValue!==void 0?acc.cookies.push(headerValue??""):acc.headers[headerKey]=String(headerValue??""),acc},{cookies:[],headers:{}})}function parseHeaders(headers){if(!headers)return{};const result={},headersArr=headers.trim().split(`
|
|
2
|
+
`);for(let i=0;i<headersArr.length;i++){const row=headersArr[i],index=row.indexOf(":"),key=row.slice(0,index).trim().toLowerCase(),value=row.slice(index+1).trim();typeof result[key]>"u"?result[key]=value:Array.isArray(result[key])?result[key].push(value):result[key]=[result[key],value]}return result}
|
|
3
3
|
//# sourceMappingURL=headers.js.map
|
package/lib/core/headers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headers.js","sources":["../../src/core/headers.ts"],"sourcesContent":["//#region Imports\n\nimport { BothValueHeaders } from '../@types';\n\n//#endregion\n\n/**\n * Transform a header map and make sure the value is not an array\n *\n * @example\n * ```typescript\n * const headers = { 'accept-encoding': 'gzip', 'accept-language': ['en-US', 'en;q=0.9'] };\n * const flattenedHeaders = getFlattenedHeadersMap(headers, ',', true);\n * console.log(flattenedHeaders);\n * // { 'accept-encoding': 'gzip', 'accept-language': 'en-US,en;q=0.9' }\n * ```\n *\n * @param headersMap - The initial headers\n * @param separator - The separator used when we join the array of header's value\n * @param lowerCaseKey - Should put all keys in lowercase\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getFlattenedHeadersMap(\n headersMap: BothValueHeaders,\n separator: string = ',',\n lowerCaseKey: boolean = false,\n): Record<string, string> {\n return Object.keys(headersMap).reduce((acc, headerKey) => {\n const newKey = lowerCaseKey ? headerKey.toLowerCase() : headerKey;\n const headerValue = headersMap[headerKey];\n\n if (Array.isArray(headerValue)) acc[newKey] = headerValue.join(separator);\n else acc[newKey] = (headerValue ?? '') + '';\n\n return acc;\n }, {});\n}\n\n/**\n * Transforms a header map into a multi-value map header.\n *\n * @example\n * ```typescript\n * const headers = { 'accept-encoding': 'gzip', 'connection': ['keep-alive'] };\n * const multiValueHeaders = getMultiValueHeadersMap(headers);\n * console.log(multiValueHeaders);\n * // { 'accept-encoding': ['gzip'], 'connection': ['keep-alive'] }\n * ```\n *\n * @param headersMap - The initial headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getMultiValueHeadersMap(\n headersMap: BothValueHeaders,\n): Record<string, string[]> {\n return Object.keys(headersMap).reduce((acc, headerKey) => {\n const headerValue = headersMap[headerKey];\n\n acc[headerKey.toLowerCase()] = Array.isArray(headerValue)\n ? headerValue.map(String)\n : [String(headerValue)];\n\n return acc;\n }, {});\n}\n\n/**\n * The wrapper that holds the information about single value headers and cookies\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport type FlattenedHeadersAndCookies = {\n /**\n * Just the single value headers\n */\n headers: Record<string, string>;\n\n /**\n * The list of cookies\n */\n cookies: string[];\n};\n\n/**\n * Transforms a header map into a single value headers and cookies\n *\n * @param headersMap - The initial headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getFlattenedHeadersMapAndCookies(\n headersMap: BothValueHeaders,\n): FlattenedHeadersAndCookies {\n return Object.keys(headersMap).reduce(\n (acc, headerKey) => {\n const headerValue = headersMap[headerKey];\n const lowerHeaderKey = headerKey.toLowerCase();\n\n if (Array.isArray(headerValue)) {\n if (lowerHeaderKey !== 'set-cookie')\n acc.headers[headerKey] = headerValue.join(',');\n else acc.cookies.push(...headerValue);\n } else {\n if (lowerHeaderKey === 'set-cookie' && headerValue !== undefined)\n acc.cookies.push(headerValue ?? '');\n else acc.headers[headerKey] = String(headerValue ?? '');\n }\n\n return acc;\n },\n {\n cookies: [],\n headers: {},\n } as FlattenedHeadersAndCookies,\n );\n}\n\n/**\n * Parse HTTP Raw Headers\n * Attribution to {@link https://github.com/kesla/parse-headers/blob/master/parse-headers.js}\n *\n * @param headers - The raw headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function parseHeaders(\n headers: string,\n): Record<string, string | string[]> {\n if (!headers) return {};\n\n const result = {};\n const headersArr = headers.trim().split('\\n');\n\n for (let i = 0; i < headersArr.length; i++) {\n const row = headersArr[i];\n const index = row.indexOf(':');\n const key = row.slice(0, index).trim().toLowerCase();\n const value = row.slice(index + 1).trim();\n\n if (typeof result[key] === 'undefined') result[key] = value;\n else if (Array.isArray(result[key])) result[key].push(value);\n else result[key] = [result[key], value];\n }\n\n return result;\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"headers.js","sources":["../../src/core/headers.ts"],"sourcesContent":["//#region Imports\n\nimport { BothValueHeaders } from '../@types';\n\n//#endregion\n\n/**\n * Transform a header map and make sure the value is not an array\n *\n * @example\n * ```typescript\n * const headers = { 'accept-encoding': 'gzip', 'accept-language': ['en-US', 'en;q=0.9'] };\n * const flattenedHeaders = getFlattenedHeadersMap(headers, ',', true);\n * console.log(flattenedHeaders);\n * // { 'accept-encoding': 'gzip', 'accept-language': 'en-US,en;q=0.9' }\n * ```\n *\n * @param headersMap - The initial headers\n * @param separator - The separator used when we join the array of header's value\n * @param lowerCaseKey - Should put all keys in lowercase\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getFlattenedHeadersMap(\n headersMap: BothValueHeaders,\n separator: string = ',',\n lowerCaseKey: boolean = false,\n): Record<string, string> {\n return Object.keys(headersMap).reduce((acc, headerKey) => {\n const newKey = lowerCaseKey ? headerKey.toLowerCase() : headerKey;\n const headerValue = headersMap[headerKey];\n\n if (Array.isArray(headerValue)) acc[newKey] = headerValue.join(separator);\n else acc[newKey] = (headerValue ?? '') + '';\n\n return acc;\n }, {});\n}\n\n/**\n * Transforms a header map into a multi-value map header.\n *\n * @example\n * ```typescript\n * const headers = { 'accept-encoding': 'gzip', 'connection': ['keep-alive'] };\n * const multiValueHeaders = getMultiValueHeadersMap(headers);\n * console.log(multiValueHeaders);\n * // { 'accept-encoding': ['gzip'], 'connection': ['keep-alive'] }\n * ```\n *\n * @param headersMap - The initial headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getMultiValueHeadersMap(\n headersMap: BothValueHeaders,\n): Record<string, string[]> {\n return Object.keys(headersMap).reduce((acc, headerKey) => {\n const headerValue = headersMap[headerKey];\n\n acc[headerKey.toLowerCase()] = Array.isArray(headerValue)\n ? headerValue.map(String)\n : [String(headerValue)];\n\n return acc;\n }, {});\n}\n\n/**\n * The wrapper that holds the information about single value headers and cookies\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport type FlattenedHeadersAndCookies = {\n /**\n * Just the single value headers\n */\n headers: Record<string, string>;\n\n /**\n * The list of cookies\n */\n cookies: string[];\n};\n\n/**\n * Transforms a header map into a single value headers and cookies\n *\n * @param headersMap - The initial headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function getFlattenedHeadersMapAndCookies(\n headersMap: BothValueHeaders,\n): FlattenedHeadersAndCookies {\n return Object.keys(headersMap).reduce(\n (acc, headerKey) => {\n const headerValue = headersMap[headerKey];\n const lowerHeaderKey = headerKey.toLowerCase();\n\n if (Array.isArray(headerValue)) {\n if (lowerHeaderKey !== 'set-cookie')\n acc.headers[headerKey] = headerValue.join(',');\n else acc.cookies.push(...headerValue);\n } else {\n if (lowerHeaderKey === 'set-cookie' && headerValue !== undefined)\n acc.cookies.push(headerValue ?? '');\n else acc.headers[headerKey] = String(headerValue ?? '');\n }\n\n return acc;\n },\n {\n cookies: [],\n headers: {},\n } as FlattenedHeadersAndCookies,\n );\n}\n\n/**\n * Parse HTTP Raw Headers\n * Attribution to {@link https://github.com/kesla/parse-headers/blob/master/parse-headers.js}\n *\n * @param headers - The raw headers\n *\n * @breadcrumb Core / Headers\n * @public\n */\nexport function parseHeaders(\n headers: string,\n): Record<string, string | string[]> {\n if (!headers) return {};\n\n const result = {};\n const headersArr = headers.trim().split('\\n');\n\n for (let i = 0; i < headersArr.length; i++) {\n const row = headersArr[i];\n const index = row.indexOf(':');\n const key = row.slice(0, index).trim().toLowerCase();\n const value = row.slice(index + 1).trim();\n\n if (typeof result[key] === 'undefined') result[key] = value;\n else if (Array.isArray(result[key])) result[key].push(value);\n else result[key] = [result[key], value];\n }\n\n return result;\n}\n"],"names":[],"mappings":"ooBAAA,gBAAA,CAAA,EAAA,SAAA,gBAAA,CAAA,uBAAA,IAAA,uBAAA,iCAAA,IAAA,iCAAA,wBAAA,IAAA,wBAAA,aAAA,IAAA,YAAA,CAAA,EAAA,OAAA,QAAA,aAAA,eAAA,EAwBO,SAAS,uBACd,WACA,UAAoB,IACpB,aAAwB,GACA,CACxB,OAAO,OAAO,KAAK,UAAU,EAAE,OAAO,CAAC,IAAK,YAAc,CACxD,MAAM,OAAS,aAAe,UAAU,YAAA,EAAgB,UAClD,YAAc,WAAW,SAAS,EAEpC,OAAA,MAAM,QAAQ,WAAW,EAAG,IAAI,MAAM,EAAI,YAAY,KAAK,SAAS,EAC/D,IAAA,MAAM,GAAK,aAAe,IAAM,GAElC,GACT,EAAG,CAAE,CAAA,CACP,CAkBO,SAAS,wBACd,WAC0B,CAC1B,OAAO,OAAO,KAAK,UAAU,EAAE,OAAO,CAAC,IAAK,YAAc,CAClD,MAAA,YAAc,WAAW,SAAS,EAExC,WAAI,UAAU,YAAA,CAAa,EAAI,MAAM,QAAQ,WAAW,EACpD,YAAY,IAAI,MAAM,EACtB,CAAC,OAAO,WAAW,CAAC,EAEjB,GACT,EAAG,CAAE,CAAA,CACP,CA4BO,SAAS,iCACd,WAC4B,CACrB,OAAA,OAAO,KAAK,UAAU,EAAE,OAC7B,CAAC,IAAK,YAAc,CACZ,MAAA,YAAc,WAAW,SAAS,EAClC,eAAiB,UAAU,cAE7B,OAAA,MAAM,QAAQ,WAAW,EACvB,iBAAmB,aACrB,IAAI,QAAQ,SAAS,EAAI,YAAY,KAAK,GAAG,EACtC,IAAA,QAAQ,KAAK,GAAG,WAAW,EAEhC,iBAAmB,cAAgB,cAAgB,OACjD,IAAA,QAAQ,KAAK,aAAe,EAAE,EAC/B,IAAI,QAAQ,SAAS,EAAI,OAAO,aAAe,EAAE,EAGjD,GACT,EACA,CACE,QAAS,CAAC,EACV,QAAS,CAAC,CACZ,CAAA,CAEJ,CAWO,SAAS,aACd,QACmC,CACnC,GAAI,CAAC,QAAS,MAAO,GAErB,MAAM,OAAS,CAAA,EACT,WAAa,QAAQ,KAAK,EAAE,MAAM;AAAA,CAAI,EAE5C,QAAS,EAAI,EAAG,EAAI,WAAW,OAAQ,IAAK,CACpC,MAAA,IAAM,WAAW,CAAC,EAClB,MAAQ,IAAI,QAAQ,GAAG,EACvB,IAAM,IAAI,MAAM,EAAG,KAAK,EAAE,OAAO,cACjC,MAAQ,IAAI,MAAM,MAAQ,CAAC,EAAE,OAE/B,OAAO,OAAO,GAAG,EAAM,IAAa,OAAO,GAAG,EAAI,MAC7C,MAAM,QAAQ,OAAO,GAAG,CAAC,EAAU,OAAA,GAAG,EAAE,KAAK,KAAK,EACtD,OAAO,GAAG,EAAI,CAAC,OAAO,GAAG,EAAG,KAAK,EAGjC,OAAA,MACT"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './base-handler';
|
|
2
|
+
export * from './constants';
|
|
3
|
+
export * from './current-invoke';
|
|
4
|
+
export * from './event-body';
|
|
5
|
+
export * from './headers';
|
|
6
|
+
export * from './is-binary';
|
|
7
|
+
export * from './logger';
|
|
8
|
+
export * from './no-op';
|
|
9
|
+
export * from './optional';
|
|
10
|
+
export * from './path';
|
|
11
|
+
export * from './stream';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC"}
|
package/lib/core/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__reExport=(target,mod,secondTarget)=>(__copyProps(target,mod,"default"),secondTarget&&__copyProps(secondTarget,mod,"default")),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),core_exports={};module.exports=__toCommonJS(core_exports);__reExport(core_exports,require("./base-handler"),module.exports);__reExport(core_exports,require("./constants"),module.exports);__reExport(core_exports,require("./current-invoke"),module.exports);__reExport(core_exports,require("./event-body"),module.exports);__reExport(core_exports,require("./headers"),module.exports);__reExport(core_exports,require("./is-binary"),module.exports);__reExport(core_exports,require("./logger"),module.exports);__reExport(core_exports,require("./no-op"),module.exports);__reExport(core_exports,require("./optional"),module.exports);__reExport(core_exports,require("./path"),module.exports);__reExport(core_exports,require("./stream"),module.exports);
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/core/index.ts"],"sourcesContent":["export * from './base-handler';\nexport * from './constants';\nexport * from './current-invoke';\nexport * from './event-body';\nexport * from './headers';\nexport * from './is-binary';\nexport * from './logger';\nexport * from './no-op';\nexport * from './optional';\nexport * from './path';\nexport * from './stream';\n"],"names":[
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/core/index.ts"],"sourcesContent":["export * from './base-handler';\nexport * from './constants';\nexport * from './current-invoke';\nexport * from './event-body';\nexport * from './headers';\nexport * from './is-binary';\nexport * from './logger';\nexport * from './no-op';\nexport * from './optional';\nexport * from './path';\nexport * from './stream';\n"],"names":[],"mappings":"kqBAAA,aAAA,CAAA,EAAA,OAAA,QAAA,aAAA,YAAA,EAAA,WAAA,aAAc,QAAd,gBAAA,EAAA,OAAA,OAAA,EACA,WAAA,aAAc,QADd,aAAA,EAAA,OAAA,OAAA,EAEA,WAAA,aAAc,QAFd,kBAAA,EAAA,OAAA,OAAA,EAGA,WAAA,aAAc,QAHd,cAAA,EAAA,OAAA,OAAA,EAIA,WAAA,aAAc,QAJd,WAAA,EAAA,OAAA,OAAA,EAKA,WAAA,aAAc,QALd,aAAA,EAAA,OAAA,OAAA,EAMA,WAAA,aAAc,QANd,UAAA,EAAA,OAAA,OAAA,EAOA,WAAA,aAAc,QAPd,SAAA,EAAA,OAAA,OAAA,EAQA,WAAA,aAAc,QARd,YAAA,EAAA,OAAA,OAAA,EASA,WAAA,aAAc,QATd,QAAA,EAAA,OAAA,OAAA,EAUA,WAAA,aAAc,QAVd,UAAA,EAAA,OAAA,OAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BinarySettings, BothValueHeaders } from '../@types';
|
|
2
|
+
/**
|
|
3
|
+
* The function that determines by the content encoding whether the response should be treated as binary
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const headers = { 'content-encoding': 'gzip' };
|
|
8
|
+
* const isBinary = isContentEncodingBinary(headers, ['gzip']);
|
|
9
|
+
* console.log(isBinary);
|
|
10
|
+
* // true
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @param headers - The headers of the response
|
|
14
|
+
* @param binaryEncodingTypes - The list of content encodings that will be treated as binary
|
|
15
|
+
*
|
|
16
|
+
* @breadcrumb Core / isBinary
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare function isContentEncodingBinary(headers: BothValueHeaders, binaryEncodingTypes: string[]): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The function that returns the content type of headers
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const headers = { 'content-type': 'application/json' };
|
|
26
|
+
* const contentType = getContentType(headers);
|
|
27
|
+
* console.log(contentType);
|
|
28
|
+
* // application/json
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @param headers - The headers of the response
|
|
32
|
+
*
|
|
33
|
+
* @breadcrumb Core / isBinary
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
export declare function getContentType(headers: BothValueHeaders): string;
|
|
37
|
+
/**
|
|
38
|
+
* The function that determines by the content type whether the response should be treated as binary
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const headers = { 'content-type': 'image/png' };
|
|
43
|
+
* const isBinary = isContentTypeBinary(headers, new Map([['image/png', true]]));
|
|
44
|
+
* console.log(isBinary);
|
|
45
|
+
* // true
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @param headers - The headers of the response
|
|
49
|
+
* @param binaryContentTypes - The list of content types that will be treated as binary
|
|
50
|
+
*
|
|
51
|
+
* @breadcrumb Core / isBinary
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export declare function isContentTypeBinary(headers: BothValueHeaders, binaryContentTypes: string[]): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The function used to determine from the headers and the binary settings if a response should be encoded or not
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const headers = { 'content-type': 'image/png', 'content-encoding': 'gzip' };
|
|
61
|
+
* const isContentBinary = isBinary(headers, { contentEncodings: ['gzip'], contentTypes: ['image/png'] });
|
|
62
|
+
* console.log(isContentBinary);
|
|
63
|
+
* // true
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @param headers - The headers of the response
|
|
67
|
+
* @param binarySettings - The settings for the validation
|
|
68
|
+
*
|
|
69
|
+
* @breadcrumb Core / isBinary
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export declare function isBinary(headers: BothValueHeaders, binarySettings: BinarySettings): boolean;
|
|
73
|
+
//# sourceMappingURL=is-binary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-binary.d.ts","sourceRoot":"","sources":["../../src/core/is-binary.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,gBAAgB,EACzB,mBAAmB,EAAE,MAAM,EAAE,GAC5B,OAAO,CAWT;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAchE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gBAAgB,EACzB,kBAAkB,EAAE,MAAM,EAAE,WAO7B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,gBAAgB,EACzB,cAAc,EAAE,cAAc,GAC7B,OAAO,CAWT"}
|
package/lib/core/is-binary.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),is_binary_exports={};__export(is_binary_exports,{getContentType:()=>getContentType,isBinary:()=>isBinary,isContentEncodingBinary:()=>isContentEncodingBinary,isContentTypeBinary:()=>isContentTypeBinary});module.exports=__toCommonJS(is_binary_exports);function isContentEncodingBinary(headers,binaryEncodingTypes){let contentEncodings=headers["content-encoding"];return contentEncodings?(Array.isArray(contentEncodings)||(contentEncodings=contentEncodings.split(",")),contentEncodings.some(value=>binaryEncodingTypes.includes(value.trim()))):!1}function getContentType(headers){const contentTypeHeaderRaw=headers["content-type"],contentTypeHeader=Array.isArray(contentTypeHeaderRaw)?contentTypeHeaderRaw[0]||"":contentTypeHeaderRaw||"";if(!contentTypeHeaderRaw)return"";const contentTypeStart=contentTypeHeader.indexOf(";");return contentTypeStart===-1?contentTypeHeader:contentTypeHeader.slice(0,contentTypeStart)}function isContentTypeBinary(headers,binaryContentTypes){const contentType=getContentType(headers);return contentType?binaryContentTypes.includes(contentType.trim()):!1}function isBinary(headers,binarySettings){return"isBinary"in binarySettings?binarySettings.isBinary===!1?!1:binarySettings.isBinary(headers):isContentEncodingBinary(headers,binarySettings.contentEncodings)||isContentTypeBinary(headers,binarySettings.contentTypes)}
|
|
2
2
|
//# sourceMappingURL=is-binary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-binary.js","sources":["../../src/core/is-binary.ts"],"sourcesContent":["// ATTRIBUTION: https://github.com/dougmoscrop/serverless-http\n\n//#region Imports\n\nimport { BinarySettings, BothValueHeaders } from '../@types';\n\n//#endregion\n\n/**\n * The function that determines by the content encoding whether the response should be treated as binary\n *\n * @example\n * ```typescript\n * const headers = { 'content-encoding': 'gzip' };\n * const isBinary = isContentEncodingBinary(headers, ['gzip']);\n * console.log(isBinary);\n * // true\n * ```\n *\n * @param headers - The headers of the response\n * @param binaryEncodingTypes - The list of content encodings that will be treated as binary\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function isContentEncodingBinary(\n headers: BothValueHeaders,\n binaryEncodingTypes: string[],\n): boolean {\n let contentEncodings = headers['content-encoding'];\n\n if (!contentEncodings) return false;\n\n if (!Array.isArray(contentEncodings))\n contentEncodings = contentEncodings.split(',');\n\n return contentEncodings.some(value =>\n binaryEncodingTypes.includes(value.trim()),\n );\n}\n\n/**\n * The function that returns the content type of headers\n *\n * @example\n * ```typescript\n * const headers = { 'content-type': 'application/json' };\n * const contentType = getContentType(headers);\n * console.log(contentType);\n * // application/json\n * ```\n *\n * @param headers - The headers of the response\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function getContentType(headers: BothValueHeaders): string {\n const contentTypeHeaderRaw = headers['content-type'];\n const contentTypeHeader = Array.isArray(contentTypeHeaderRaw)\n ? contentTypeHeaderRaw[0] || ''\n : contentTypeHeaderRaw || '';\n\n if (!contentTypeHeaderRaw) return '';\n\n // only compare mime type; ignore encoding part\n const contentTypeStart = contentTypeHeader.indexOf(';');\n\n if (contentTypeStart === -1) return contentTypeHeader;\n\n return contentTypeHeader.slice(0, contentTypeStart);\n}\n\n/**\n * The function that determines by the content type whether the response should be treated as binary\n *\n * @example\n * ```typescript\n * const headers = { 'content-type': 'image/png' };\n * const isBinary = isContentTypeBinary(headers, new Map([['image/png', true]]));\n * console.log(isBinary);\n * // true\n * ```\n *\n * @param headers - The headers of the response\n * @param binaryContentTypes - The list of content types that will be treated as binary\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function isContentTypeBinary(\n headers: BothValueHeaders,\n binaryContentTypes: string[],\n) {\n const contentType = getContentType(headers);\n\n if (!contentType) return false;\n\n return binaryContentTypes.includes(contentType.trim());\n}\n\n/**\n * The function used to determine from the headers and the binary settings if a response should be encoded or not\n *\n * @example\n * ```typescript\n * const headers = { 'content-type': 'image/png', 'content-encoding': 'gzip' };\n * const isContentBinary = isBinary(headers, { contentEncodings: ['gzip'], contentTypes: ['image/png'] });\n * console.log(isContentBinary);\n * // true\n * ```\n *\n * @param headers - The headers of the response\n * @param binarySettings - The settings for the validation\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function isBinary(\n headers: BothValueHeaders,\n binarySettings: BinarySettings,\n): boolean {\n if ('isBinary' in binarySettings) {\n if (binarySettings.isBinary === false) return false;\n\n return binarySettings.isBinary(headers);\n }\n\n return (\n isContentEncodingBinary(headers, binarySettings.contentEncodings) ||\n isContentTypeBinary(headers, binarySettings.contentTypes)\n );\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"is-binary.js","sources":["../../src/core/is-binary.ts"],"sourcesContent":["// ATTRIBUTION: https://github.com/dougmoscrop/serverless-http\n\n//#region Imports\n\nimport { BinarySettings, BothValueHeaders } from '../@types';\n\n//#endregion\n\n/**\n * The function that determines by the content encoding whether the response should be treated as binary\n *\n * @example\n * ```typescript\n * const headers = { 'content-encoding': 'gzip' };\n * const isBinary = isContentEncodingBinary(headers, ['gzip']);\n * console.log(isBinary);\n * // true\n * ```\n *\n * @param headers - The headers of the response\n * @param binaryEncodingTypes - The list of content encodings that will be treated as binary\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function isContentEncodingBinary(\n headers: BothValueHeaders,\n binaryEncodingTypes: string[],\n): boolean {\n let contentEncodings = headers['content-encoding'];\n\n if (!contentEncodings) return false;\n\n if (!Array.isArray(contentEncodings))\n contentEncodings = contentEncodings.split(',');\n\n return contentEncodings.some(value =>\n binaryEncodingTypes.includes(value.trim()),\n );\n}\n\n/**\n * The function that returns the content type of headers\n *\n * @example\n * ```typescript\n * const headers = { 'content-type': 'application/json' };\n * const contentType = getContentType(headers);\n * console.log(contentType);\n * // application/json\n * ```\n *\n * @param headers - The headers of the response\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function getContentType(headers: BothValueHeaders): string {\n const contentTypeHeaderRaw = headers['content-type'];\n const contentTypeHeader = Array.isArray(contentTypeHeaderRaw)\n ? contentTypeHeaderRaw[0] || ''\n : contentTypeHeaderRaw || '';\n\n if (!contentTypeHeaderRaw) return '';\n\n // only compare mime type; ignore encoding part\n const contentTypeStart = contentTypeHeader.indexOf(';');\n\n if (contentTypeStart === -1) return contentTypeHeader;\n\n return contentTypeHeader.slice(0, contentTypeStart);\n}\n\n/**\n * The function that determines by the content type whether the response should be treated as binary\n *\n * @example\n * ```typescript\n * const headers = { 'content-type': 'image/png' };\n * const isBinary = isContentTypeBinary(headers, new Map([['image/png', true]]));\n * console.log(isBinary);\n * // true\n * ```\n *\n * @param headers - The headers of the response\n * @param binaryContentTypes - The list of content types that will be treated as binary\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function isContentTypeBinary(\n headers: BothValueHeaders,\n binaryContentTypes: string[],\n) {\n const contentType = getContentType(headers);\n\n if (!contentType) return false;\n\n return binaryContentTypes.includes(contentType.trim());\n}\n\n/**\n * The function used to determine from the headers and the binary settings if a response should be encoded or not\n *\n * @example\n * ```typescript\n * const headers = { 'content-type': 'image/png', 'content-encoding': 'gzip' };\n * const isContentBinary = isBinary(headers, { contentEncodings: ['gzip'], contentTypes: ['image/png'] });\n * console.log(isContentBinary);\n * // true\n * ```\n *\n * @param headers - The headers of the response\n * @param binarySettings - The settings for the validation\n *\n * @breadcrumb Core / isBinary\n * @public\n */\nexport function isBinary(\n headers: BothValueHeaders,\n binarySettings: BinarySettings,\n): boolean {\n if ('isBinary' in binarySettings) {\n if (binarySettings.isBinary === false) return false;\n\n return binarySettings.isBinary(headers);\n }\n\n return (\n isContentEncodingBinary(headers, binarySettings.contentEncodings) ||\n isContentTypeBinary(headers, binarySettings.contentTypes)\n );\n}\n"],"names":[],"mappings":"ooBAAA,kBAAA,CAAA,EAAA,SAAA,kBAAA,CAAA,eAAA,IAAA,eAAA,SAAA,IAAA,SAAA,wBAAA,IAAA,wBAAA,oBAAA,IAAA,mBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,iBAAA,EAyBO,SAAS,wBACd,QACA,oBACS,CACL,IAAA,iBAAmB,QAAQ,kBAAkB,EAEjD,OAAK,kBAEA,MAAM,QAAQ,gBAAgB,IACd,iBAAA,iBAAiB,MAAM,GAAG,GAExC,iBAAiB,KACtB,OAAA,oBAAoB,SAAS,MAAM,MAAM,CAAA,GANb,EAQhC,CAkBO,SAAS,eAAe,QAAmC,CAC1D,MAAA,qBAAuB,QAAQ,cAAc,EAC7C,kBAAoB,MAAM,QAAQ,oBAAoB,EACxD,qBAAqB,CAAC,GAAK,GAC3B,sBAAwB,GAE5B,GAAI,CAAC,qBAA6B,MAAA,GAG5B,MAAA,iBAAmB,kBAAkB,QAAQ,GAAG,EAEtD,OAAI,mBAAqB,GAAW,kBAE7B,kBAAkB,MAAM,EAAG,gBAAgB,CACpD,CAmBO,SAAS,oBACd,QACA,mBACA,CACM,MAAA,YAAc,eAAe,OAAO,EAE1C,OAAK,YAEE,mBAAmB,SAAS,YAAY,KAAM,CAAA,EAF5B,EAG3B,CAmBO,SAAS,SACd,QACA,eACS,CACT,MAAI,aAAc,eACZ,eAAe,WAAa,GAAc,GAEvC,eAAe,SAAS,OAAO,EAItC,wBAAwB,QAAS,eAAe,gBAAgB,GAChE,oBAAoB,QAAS,eAAe,YAAY,CAE5D"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The type representing the possible log levels to choose from.
|
|
3
|
+
*
|
|
4
|
+
* @breadcrumb Core / Logger
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export type LogLevels = 'debug' | 'verbose' | 'info' | 'warn' | 'error' | 'none';
|
|
8
|
+
/**
|
|
9
|
+
* The options to customize {@link ILogger}
|
|
10
|
+
*
|
|
11
|
+
* @breadcrumb Core / Logger
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export type LoggerOptions = {
|
|
15
|
+
/**
|
|
16
|
+
* Select the log level, {@link LogLevels | see more}.
|
|
17
|
+
*
|
|
18
|
+
* @defaultValue error
|
|
19
|
+
*/
|
|
20
|
+
level: LogLevels;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The log function used in any level.
|
|
24
|
+
*
|
|
25
|
+
* @breadcrumb Core / Logger
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export type LoggerFN = (message: any, ...additional: any[]) => void;
|
|
29
|
+
/**
|
|
30
|
+
* The interface representing the logger, you can provide a custom logger by implementing this interface.
|
|
31
|
+
*
|
|
32
|
+
* @breadcrumb Core / Logger
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export type ILogger = Record<Exclude<LogLevels, 'none'>, LoggerFN>;
|
|
36
|
+
/**
|
|
37
|
+
* The method used to create a simple logger instance to use in this library.
|
|
38
|
+
*
|
|
39
|
+
* @remarks Behind the scenes, this simple logger sends the message to the `console` methods.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* const logger = createDefaultLogger();
|
|
44
|
+
*
|
|
45
|
+
* logger.error('An error happens.');
|
|
46
|
+
* // An error happens.
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @param level - Select the level of the log
|
|
50
|
+
*
|
|
51
|
+
* @breadcrumb Core / Logger
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export declare function createDefaultLogger({ level }?: LoggerOptions): ILogger;
|
|
55
|
+
/**
|
|
56
|
+
* The method used to chck if logger was created by this library, or it was defined by the user.
|
|
57
|
+
*
|
|
58
|
+
* @param logger - The instance of the logger to check
|
|
59
|
+
*
|
|
60
|
+
* @breadcrumb Core / Logger
|
|
61
|
+
* @public
|
|
62
|
+
*/
|
|
63
|
+
export declare function isInternalLogger(logger: ILogger): boolean;
|
|
64
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/core/logger.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GACjB,OAAO,GACP,SAAS,GACT,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,CAAC;AAEX;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;OAIG;IACH,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,UAAU,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;AAmDnE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,KAAK,EAAE,GAAE,aAAkC,GAC5C,OAAO,CAkBT;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAEzD"}
|
package/lib/core/logger.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),logger_exports={};__export(logger_exports,{createDefaultLogger:()=>createDefaultLogger,isInternalLogger:()=>isInternalLogger});module.exports=__toCommonJS(logger_exports);var import_no_op=require("./no-op");const InternalLoggerSymbol=Symbol("InternalLogger"),logLevels={debug:[["debug","debug"],["verbose","debug"],["info","info"],["error","error"],["warn","warn"]],verbose:[["verbose","debug"],["info","info"],["error","error"],["warn","warn"]],info:[["info","info"],["error","error"],["warn","warn"]],warn:[["warn","warn"],["error","error"]],error:[["error","error"]],none:[]},lazyPrint=value=>typeof value=="function"?value():value,print=fn=>(message,...additional)=>console[fn](message,...additional.map(lazyPrint));function createDefaultLogger({level}={level:"error"}){const levels=logLevels[level];if(!levels)throw new Error("Invalid log level");const logger={[InternalLoggerSymbol]:!0,error:import_no_op.NO_OP,debug:import_no_op.NO_OP,info:import_no_op.NO_OP,verbose:import_no_op.NO_OP,warn:import_no_op.NO_OP};for(const[level2,consoleMethod]of levels)logger[level2]=print(consoleMethod);return logger}function isInternalLogger(logger){return!!logger[InternalLoggerSymbol]}
|
|
2
2
|
//# sourceMappingURL=logger.js.map
|
package/lib/core/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sources":["../../src/core/logger.ts"],"sourcesContent":["import { NO_OP } from './no-op';\n\n/**\n * The type representing the possible log levels to choose from.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LogLevels =\n | 'debug'\n | 'verbose'\n | 'info'\n | 'warn'\n | 'error'\n | 'none';\n\n/**\n * The options to customize {@link ILogger}\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LoggerOptions = {\n /**\n * Select the log level, {@link LogLevels | see more}.\n *\n * @defaultValue error\n */\n level: LogLevels;\n};\n\n/**\n * The log function used in any level.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LoggerFN = (message: any, ...additional: any[]) => void;\n\n/**\n * The interface representing the logger, you can provide a custom logger by implementing this interface.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type ILogger = Record<Exclude<LogLevels, 'none'>, LoggerFN>;\n\n/**\n * The symbol used to check against an ILogger instace to verify if that ILogger was created by this library\n *\n * @breadcrumb Core / Logger\n * @public\n */\nconst InternalLoggerSymbol = Symbol('InternalLogger');\n\nconst logLevels: Record<\n LogLevels,\n [level: LogLevels, consoleMethod: keyof Console][]\n> = {\n debug: [\n ['debug', 'debug'],\n ['verbose', 'debug'],\n ['info', 'info'],\n ['error', 'error'],\n ['warn', 'warn'],\n ],\n verbose: [\n ['verbose', 'debug'],\n ['info', 'info'],\n ['error', 'error'],\n ['warn', 'warn'],\n ],\n info: [\n ['info', 'info'],\n ['error', 'error'],\n ['warn', 'warn'],\n ],\n warn: [\n ['warn', 'warn'],\n ['error', 'error'],\n ],\n error: [['error', 'error']],\n none: [],\n};\n\nconst lazyPrint = value => {\n if (typeof value === 'function') return value();\n\n return value;\n};\n\nconst print =\n (fn: string) =>\n (message, ...additional) =>\n console[fn](message, ...additional.map(lazyPrint));\n\n/**\n * The method used to create a simple logger instance to use in this library.\n *\n * @remarks Behind the scenes, this simple logger sends the message to the `console` methods.\n *\n * @example\n * ```typescript\n * const logger = createDefaultLogger();\n *\n * logger.error('An error happens.');\n * // An error happens.\n * ```\n *\n * @param level - Select the level of the log\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport function createDefaultLogger(\n { level }: LoggerOptions = { level: 'error' },\n): ILogger {\n const levels = logLevels[level];\n\n if (!levels) throw new Error('Invalid log level');\n\n const logger = {\n [InternalLoggerSymbol]: true,\n error: NO_OP,\n debug: NO_OP,\n info: NO_OP,\n verbose: NO_OP,\n warn: NO_OP,\n } as ILogger;\n\n for (const [level, consoleMethod] of levels)\n logger[level] = print(consoleMethod);\n\n return logger;\n}\n\n/**\n * The method used to chck if logger was created by this library, or it was defined by the user.\n *\n * @param logger - The instance of the logger to check\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport function isInternalLogger(logger: ILogger): boolean {\n return !!logger[InternalLoggerSymbol];\n}\n"],"names":["
|
|
1
|
+
{"version":3,"file":"logger.js","sources":["../../src/core/logger.ts"],"sourcesContent":["import { NO_OP } from './no-op';\n\n/**\n * The type representing the possible log levels to choose from.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LogLevels =\n | 'debug'\n | 'verbose'\n | 'info'\n | 'warn'\n | 'error'\n | 'none';\n\n/**\n * The options to customize {@link ILogger}\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LoggerOptions = {\n /**\n * Select the log level, {@link LogLevels | see more}.\n *\n * @defaultValue error\n */\n level: LogLevels;\n};\n\n/**\n * The log function used in any level.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type LoggerFN = (message: any, ...additional: any[]) => void;\n\n/**\n * The interface representing the logger, you can provide a custom logger by implementing this interface.\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport type ILogger = Record<Exclude<LogLevels, 'none'>, LoggerFN>;\n\n/**\n * The symbol used to check against an ILogger instace to verify if that ILogger was created by this library\n *\n * @breadcrumb Core / Logger\n * @public\n */\nconst InternalLoggerSymbol = Symbol('InternalLogger');\n\nconst logLevels: Record<\n LogLevels,\n [level: LogLevels, consoleMethod: keyof Console][]\n> = {\n debug: [\n ['debug', 'debug'],\n ['verbose', 'debug'],\n ['info', 'info'],\n ['error', 'error'],\n ['warn', 'warn'],\n ],\n verbose: [\n ['verbose', 'debug'],\n ['info', 'info'],\n ['error', 'error'],\n ['warn', 'warn'],\n ],\n info: [\n ['info', 'info'],\n ['error', 'error'],\n ['warn', 'warn'],\n ],\n warn: [\n ['warn', 'warn'],\n ['error', 'error'],\n ],\n error: [['error', 'error']],\n none: [],\n};\n\nconst lazyPrint = value => {\n if (typeof value === 'function') return value();\n\n return value;\n};\n\nconst print =\n (fn: string) =>\n (message, ...additional) =>\n console[fn](message, ...additional.map(lazyPrint));\n\n/**\n * The method used to create a simple logger instance to use in this library.\n *\n * @remarks Behind the scenes, this simple logger sends the message to the `console` methods.\n *\n * @example\n * ```typescript\n * const logger = createDefaultLogger();\n *\n * logger.error('An error happens.');\n * // An error happens.\n * ```\n *\n * @param level - Select the level of the log\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport function createDefaultLogger(\n { level }: LoggerOptions = { level: 'error' },\n): ILogger {\n const levels = logLevels[level];\n\n if (!levels) throw new Error('Invalid log level');\n\n const logger = {\n [InternalLoggerSymbol]: true,\n error: NO_OP,\n debug: NO_OP,\n info: NO_OP,\n verbose: NO_OP,\n warn: NO_OP,\n } as ILogger;\n\n for (const [level, consoleMethod] of levels)\n logger[level] = print(consoleMethod);\n\n return logger;\n}\n\n/**\n * The method used to chck if logger was created by this library, or it was defined by the user.\n *\n * @param logger - The instance of the logger to check\n *\n * @breadcrumb Core / Logger\n * @public\n */\nexport function isInternalLogger(logger: ILogger): boolean {\n return !!logger[InternalLoggerSymbol];\n}\n"],"names":["level"],"mappings":"ooBAAA,eAAA,CAAA,EAAA,SAAA,eAAA,CAAA,oBAAA,IAAA,oBAAA,iBAAA,IAAA,gBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,cAAA,EAAA,IAAsB,aAAA,QAAA,SAAA,EAqDtB,MAAM,qBAAuB,OAAO,gBAAgB,EAE9C,UAGF,CACF,MAAO,CACL,CAAC,QAAS,OAAO,EACjB,CAAC,UAAW,OAAO,EACnB,CAAC,OAAQ,MAAM,EACf,CAAC,QAAS,OAAO,EACjB,CAAC,OAAQ,MAAM,CACjB,EACA,QAAS,CACP,CAAC,UAAW,OAAO,EACnB,CAAC,OAAQ,MAAM,EACf,CAAC,QAAS,OAAO,EACjB,CAAC,OAAQ,MAAM,CACjB,EACA,KAAM,CACJ,CAAC,OAAQ,MAAM,EACf,CAAC,QAAS,OAAO,EACjB,CAAC,OAAQ,MAAM,CACjB,EACA,KAAM,CACJ,CAAC,OAAQ,MAAM,EACf,CAAC,QAAS,OAAO,CACnB,EACA,MAAO,CAAC,CAAC,QAAS,OAAO,CAAC,EAC1B,KAAM,CAAC,CACT,EAEM,UAAqB,OACrB,OAAO,OAAU,WAAmB,MAAM,EAEvC,MAGH,MACH,IACD,CAAC,WAAY,aACX,QAAQ,EAAE,EAAE,QAAS,GAAG,WAAW,IAAI,SAAS,CAAC,EAoB9C,SAAS,oBACd,CAAE,KAAA,EAAyB,CAAE,MAAO,SAC3B,CACH,MAAA,OAAS,UAAU,KAAK,EAE9B,GAAI,CAAC,OAAc,MAAA,IAAI,MAAM,mBAAmB,EAEhD,MAAM,OAAS,CACb,CAAC,oBAAoB,EAAG,GACxB,MAAO,aAAA,MACP,MAAO,aAAA,MACP,KAAM,aAAA,MACN,QAAS,aAAA,MACT,KAAM,aAAA,KAAA,EAGG,SAAA,CAACA,OAAO,aAAa,IAAK,OAC5BA,OAAAA,MAAK,EAAI,MAAM,aAAa,EAE9B,OAAA,MACT,CAUO,SAAS,iBAAiB,OAA0B,CAClD,MAAA,CAAC,CAAC,OAAO,oBAAoB,CACtC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-op.d.ts","sourceRoot":"","sources":["../../src/core/no-op.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAkB,CAAC"}
|
package/lib/core/no-op.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),no_op_exports={};__export(no_op_exports,{NO_OP:()=>NO_OP});module.exports=__toCommonJS(no_op_exports);const NO_OP=()=>{};
|
|
2
2
|
//# sourceMappingURL=no-op.js.map
|
package/lib/core/no-op.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-op.js","sources":["../../src/core/no-op.ts"],"sourcesContent":["/**\n * No operation function is used when we need to pass a function, but we don't want to specify any behavior.\n *\n * @breadcrumb Core\n * @public\n */\nexport const NO_OP: (...args: any[]) => any = () => void 0;\n"],"names":[
|
|
1
|
+
{"version":3,"file":"no-op.js","sources":["../../src/core/no-op.ts"],"sourcesContent":["/**\n * No operation function is used when we need to pass a function, but we don't want to specify any behavior.\n *\n * @breadcrumb Core\n * @public\n */\nexport const NO_OP: (...args: any[]) => any = () => void 0;\n"],"names":[],"mappings":"ooBAAA,cAAA,CAAA,EAAA,SAAA,cAAA,CAAA,MAAA,IAAA,KAAA,CAAA,EAAA,OAAA,QAAA,aAAA,aAAA,EAMO,MAAM,MAAiC,IAAM"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return the defaultValue whether the value is undefined, otherwise, return the value.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const value1 = getDefaultIfUndefined(undefined, true);
|
|
7
|
+
* const value2 = getDefaultIfUndefined(false, true);
|
|
8
|
+
*
|
|
9
|
+
* console.log(value1);
|
|
10
|
+
* // true
|
|
11
|
+
* console.log(value2);
|
|
12
|
+
* // false
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param value - The value to be checked
|
|
16
|
+
* @param defaultValue - The default value when value is undefined
|
|
17
|
+
*
|
|
18
|
+
* @breadcrumb Core
|
|
19
|
+
* @public
|
|
20
|
+
*/
|
|
21
|
+
export declare function getDefaultIfUndefined<T>(value: T | undefined, defaultValue: T): T;
|
|
22
|
+
//# sourceMappingURL=optional.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optional.d.ts","sourceRoot":"","sources":["../../src/core/optional.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,KAAK,EAAE,CAAC,GAAG,SAAS,EACpB,YAAY,EAAE,CAAC,GACd,CAAC,CAIH"}
|
package/lib/core/optional.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to},__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod),optional_exports={};__export(optional_exports,{getDefaultIfUndefined:()=>getDefaultIfUndefined});module.exports=__toCommonJS(optional_exports);function getDefaultIfUndefined(value,defaultValue){return value===void 0?defaultValue:value}
|
|
2
2
|
//# sourceMappingURL=optional.js.map
|
package/lib/core/optional.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optional.js","sources":["../../src/core/optional.ts"],"sourcesContent":["/**\n * Return the defaultValue whether the value is undefined, otherwise, return the value.\n *\n * @example\n * ```typescript\n * const value1 = getDefaultIfUndefined(undefined, true);\n * const value2 = getDefaultIfUndefined(false, true);\n *\n * console.log(value1);\n * // true\n * console.log(value2);\n * // false\n * ```\n *\n * @param value - The value to be checked\n * @param defaultValue - The default value when value is undefined\n *\n * @breadcrumb Core\n * @public\n */\nexport function getDefaultIfUndefined<T>(\n value: T | undefined,\n defaultValue: T,\n): T {\n if (value === undefined) return defaultValue;\n\n return value;\n}\n"],"names":[
|
|
1
|
+
{"version":3,"file":"optional.js","sources":["../../src/core/optional.ts"],"sourcesContent":["/**\n * Return the defaultValue whether the value is undefined, otherwise, return the value.\n *\n * @example\n * ```typescript\n * const value1 = getDefaultIfUndefined(undefined, true);\n * const value2 = getDefaultIfUndefined(false, true);\n *\n * console.log(value1);\n * // true\n * console.log(value2);\n * // false\n * ```\n *\n * @param value - The value to be checked\n * @param defaultValue - The default value when value is undefined\n *\n * @breadcrumb Core\n * @public\n */\nexport function getDefaultIfUndefined<T>(\n value: T | undefined,\n defaultValue: T,\n): T {\n if (value === undefined) return defaultValue;\n\n return value;\n}\n"],"names":[],"mappings":"ooBAAA,iBAAA,CAAA,EAAA,SAAA,iBAAA,CAAA,sBAAA,IAAA,qBAAA,CAAA,EAAA,OAAA,QAAA,aAAA,gBAAA,EAoBO,SAAS,sBACd,MACA,aACG,CACH,OAAI,QAAU,OAAkB,aAEzB,KACT"}
|