@h4ad/serverless-adapter 2.3.1 → 2.5.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 +22 -243
- package/lib/@types/binary-settings.d.ts +24 -6
- package/lib/@types/binary-settings.d.ts.map +1 -0
- package/lib/@types/binary-settings.js +1 -0
- package/lib/@types/binary-settings.js.map +1 -0
- package/lib/@types/headers.d.ts +16 -3
- package/lib/@types/headers.d.ts.map +1 -0
- package/lib/@types/headers.js +1 -0
- package/lib/@types/headers.js.map +1 -0
- package/lib/@types/helpers.d.ts +4 -0
- package/lib/@types/helpers.d.ts.map +1 -0
- package/lib/@types/helpers.js +1 -0
- package/lib/@types/helpers.js.map +1 -0
- package/lib/@types/huawei/huawei-api-gateway-event.d.ts +62 -0
- package/lib/@types/huawei/huawei-api-gateway-event.d.ts.map +1 -0
- package/lib/@types/huawei/huawei-api-gateway-event.js +2 -0
- package/lib/@types/huawei/huawei-api-gateway-event.js.map +1 -0
- package/lib/@types/huawei/huawei-api-gateway-response.d.ts +20 -0
- package/lib/@types/huawei/huawei-api-gateway-response.d.ts.map +1 -0
- package/lib/@types/huawei/huawei-api-gateway-response.js +2 -0
- package/lib/@types/huawei/huawei-api-gateway-response.js.map +1 -0
- package/lib/@types/huawei/huawei-context.d.ts +157 -0
- package/lib/@types/huawei/huawei-context.d.ts.map +1 -0
- package/lib/@types/huawei/huawei-context.js +1 -0
- package/lib/@types/huawei/huawei-context.js.map +1 -0
- package/lib/@types/huawei/index.d.ts +1 -0
- package/lib/@types/huawei/index.d.ts.map +1 -0
- package/lib/@types/huawei/index.js +6 -1
- package/lib/@types/huawei/index.js.map +1 -0
- package/lib/@types/index.d.ts +2 -1
- package/lib/@types/index.d.ts.map +1 -0
- package/lib/@types/index.js +7 -2
- package/lib/@types/index.js.map +1 -0
- package/lib/adapters/aws/alb.adapter.d.ts +18 -10
- package/lib/adapters/aws/alb.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/alb.adapter.js +14 -9
- package/lib/adapters/aws/alb.adapter.js.map +1 -0
- package/lib/adapters/aws/api-gateway-v1.adapter.d.ts +20 -12
- package/lib/adapters/aws/api-gateway-v1.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/api-gateway-v1.adapter.js +19 -14
- package/lib/adapters/aws/api-gateway-v1.adapter.js.map +1 -0
- package/lib/adapters/aws/api-gateway-v2.adapter.d.ts +19 -11
- package/lib/adapters/aws/api-gateway-v2.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/api-gateway-v2.adapter.js +15 -10
- package/lib/adapters/aws/api-gateway-v2.adapter.js.map +1 -0
- package/lib/adapters/aws/dynamodb.adapter.d.ts +18 -10
- package/lib/adapters/aws/dynamodb.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/dynamodb.adapter.js +13 -8
- package/lib/adapters/aws/dynamodb.adapter.js.map +1 -0
- package/lib/adapters/aws/event-bridge.adapter.d.ts +21 -10
- package/lib/adapters/aws/event-bridge.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/event-bridge.adapter.js +13 -8
- package/lib/adapters/aws/event-bridge.adapter.js.map +1 -0
- package/lib/adapters/aws/index.d.ts +1 -0
- package/lib/adapters/aws/index.d.ts.map +1 -0
- package/lib/adapters/aws/index.js +6 -1
- package/lib/adapters/aws/index.js.map +1 -0
- package/lib/adapters/aws/lambda-edge.adapter.d.ts +76 -46
- package/lib/adapters/aws/lambda-edge.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/lambda-edge.adapter.js +40 -24
- package/lib/adapters/aws/lambda-edge.adapter.js.map +1 -0
- package/lib/adapters/aws/sns.adapter.d.ts +18 -10
- package/lib/adapters/aws/sns.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/sns.adapter.js +13 -8
- package/lib/adapters/aws/sns.adapter.js.map +1 -0
- package/lib/adapters/aws/sqs.adapter.d.ts +18 -10
- package/lib/adapters/aws/sqs.adapter.d.ts.map +1 -0
- package/lib/adapters/aws/sqs.adapter.js +13 -8
- package/lib/adapters/aws/sqs.adapter.js.map +1 -0
- 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 +191 -0
- package/lib/adapters/azure/http-trigger-v4.adapter.js.map +1 -0
- 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 +18 -0
- package/lib/adapters/azure/index.js.map +1 -0
- package/lib/adapters/dummy/dummy.adapter.d.ts +9 -5
- package/lib/adapters/dummy/dummy.adapter.d.ts.map +1 -0
- package/lib/adapters/dummy/dummy.adapter.js +9 -5
- package/lib/adapters/dummy/dummy.adapter.js.map +1 -0
- package/lib/adapters/dummy/index.d.ts +1 -0
- package/lib/adapters/dummy/index.d.ts.map +1 -0
- package/lib/adapters/dummy/index.js +6 -1
- package/lib/adapters/dummy/index.js.map +1 -0
- package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts +19 -12
- package/lib/adapters/huawei/huawei-api-gateway.adapter.d.ts.map +1 -0
- package/lib/adapters/huawei/huawei-api-gateway.adapter.js +14 -9
- package/lib/adapters/huawei/huawei-api-gateway.adapter.js.map +1 -0
- package/lib/adapters/huawei/index.d.ts +1 -0
- package/lib/adapters/huawei/index.d.ts.map +1 -0
- package/lib/adapters/huawei/index.js +6 -1
- package/lib/adapters/huawei/index.js.map +1 -0
- package/lib/contracts/adapter.contract.d.ts +30 -30
- package/lib/contracts/adapter.contract.d.ts.map +1 -0
- package/lib/contracts/adapter.contract.js +2 -0
- package/lib/contracts/adapter.contract.js.map +1 -0
- package/lib/contracts/framework.contract.d.ts +7 -3
- package/lib/contracts/framework.contract.d.ts.map +1 -0
- package/lib/contracts/framework.contract.js +1 -0
- package/lib/contracts/framework.contract.js.map +1 -0
- package/lib/contracts/handler.contract.d.ts +7 -0
- package/lib/contracts/handler.contract.d.ts.map +1 -0
- package/lib/contracts/handler.contract.js +1 -0
- package/lib/contracts/handler.contract.js.map +1 -0
- package/lib/contracts/index.d.ts +1 -0
- package/lib/contracts/index.d.ts.map +1 -0
- package/lib/contracts/index.js +6 -1
- package/lib/contracts/index.js.map +1 -0
- package/lib/contracts/resolver.contract.d.ts +17 -4
- package/lib/contracts/resolver.contract.d.ts.map +1 -0
- package/lib/contracts/resolver.contract.js +1 -0
- package/lib/contracts/resolver.contract.js.map +1 -0
- package/lib/core/base-handler.d.ts +9 -5
- package/lib/core/base-handler.d.ts.map +1 -0
- package/lib/core/base-handler.js +9 -5
- package/lib/core/base-handler.js.map +1 -0
- package/lib/core/constants.d.ts +27 -0
- package/lib/core/constants.d.ts.map +1 -0
- package/lib/core/constants.js +21 -0
- package/lib/core/constants.js.map +1 -0
- package/lib/core/current-invoke.d.ts +17 -6
- package/lib/core/current-invoke.d.ts.map +1 -0
- package/lib/core/current-invoke.js +12 -4
- package/lib/core/current-invoke.js.map +1 -0
- package/lib/core/event-body.d.ts +9 -3
- package/lib/core/event-body.d.ts.map +1 -0
- package/lib/core/event-body.js +9 -3
- package/lib/core/event-body.js.map +1 -0
- package/lib/core/headers.d.ts +17 -6
- package/lib/core/headers.d.ts.map +1 -0
- package/lib/core/headers.js +17 -6
- package/lib/core/headers.js.map +1 -0
- package/lib/core/index.d.ts +1 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/index.js +6 -1
- package/lib/core/index.js.map +1 -0
- package/lib/core/is-binary.d.ts +29 -11
- package/lib/core/is-binary.d.ts.map +1 -0
- package/lib/core/is-binary.js +29 -11
- package/lib/core/is-binary.js.map +1 -0
- package/lib/core/logger.d.ts +31 -5
- package/lib/core/logger.d.ts.map +1 -0
- package/lib/core/logger.js +29 -4
- package/lib/core/logger.js.map +1 -0
- package/lib/core/no-op.d.ts +4 -0
- package/lib/core/no-op.d.ts.map +1 -0
- package/lib/core/no-op.js +4 -0
- package/lib/core/no-op.js.map +1 -0
- package/lib/core/optional.d.ts +8 -3
- package/lib/core/optional.d.ts.map +1 -0
- package/lib/core/optional.js +8 -3
- package/lib/core/optional.js.map +1 -0
- package/lib/core/path.d.ts +14 -5
- package/lib/core/path.d.ts.map +1 -0
- package/lib/core/path.js +14 -5
- package/lib/core/path.js.map +1 -0
- package/lib/core/stream.d.ts +5 -1
- package/lib/core/stream.d.ts.map +1 -0
- package/lib/core/stream.js +6 -2
- package/lib/core/stream.js.map +1 -0
- package/lib/frameworks/express/express.framework.d.ts +5 -1
- package/lib/frameworks/express/express.framework.d.ts.map +1 -0
- package/lib/frameworks/express/express.framework.js +5 -1
- package/lib/frameworks/express/express.framework.js.map +1 -0
- package/lib/frameworks/express/index.d.ts +1 -0
- package/lib/frameworks/express/index.d.ts.map +1 -0
- package/lib/frameworks/express/index.js +6 -1
- package/lib/frameworks/express/index.js.map +1 -0
- package/lib/frameworks/fastify/fastify.framework.d.ts +5 -1
- package/lib/frameworks/fastify/fastify.framework.d.ts.map +1 -0
- package/lib/frameworks/fastify/fastify.framework.js +5 -1
- package/lib/frameworks/fastify/fastify.framework.js.map +1 -0
- package/lib/frameworks/fastify/index.d.ts +1 -0
- package/lib/frameworks/fastify/index.d.ts.map +1 -0
- package/lib/frameworks/fastify/index.js +6 -1
- package/lib/frameworks/fastify/index.js.map +1 -0
- package/lib/frameworks/hapi/hapi.framework.d.ts +5 -1
- package/lib/frameworks/hapi/hapi.framework.d.ts.map +1 -0
- package/lib/frameworks/hapi/hapi.framework.js +5 -1
- package/lib/frameworks/hapi/hapi.framework.js.map +1 -0
- package/lib/frameworks/hapi/index.d.ts +1 -0
- package/lib/frameworks/hapi/index.d.ts.map +1 -0
- package/lib/frameworks/hapi/index.js +6 -1
- package/lib/frameworks/hapi/index.js.map +1 -0
- package/lib/frameworks/koa/index.d.ts +1 -0
- package/lib/frameworks/koa/index.d.ts.map +1 -0
- package/lib/frameworks/koa/index.js +6 -1
- package/lib/frameworks/koa/index.js.map +1 -0
- package/lib/frameworks/koa/koa.framework.d.ts +5 -1
- package/lib/frameworks/koa/koa.framework.d.ts.map +1 -0
- package/lib/frameworks/koa/koa.framework.js +5 -1
- package/lib/frameworks/koa/koa.framework.js.map +1 -0
- package/lib/frameworks/lazy/index.d.ts +1 -0
- package/lib/frameworks/lazy/index.d.ts.map +1 -0
- package/lib/frameworks/lazy/index.js +6 -1
- package/lib/frameworks/lazy/index.js.map +1 -0
- package/lib/frameworks/lazy/lazy.framework.d.ts +7 -2
- package/lib/frameworks/lazy/lazy.framework.d.ts.map +1 -0
- package/lib/frameworks/lazy/lazy.framework.js +7 -2
- package/lib/frameworks/lazy/lazy.framework.js.map +1 -0
- 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 +18 -0
- package/lib/frameworks/trpc/index.js.map +1 -0
- package/lib/frameworks/trpc/trpc.framework.d.ts +152 -0
- package/lib/frameworks/trpc/trpc.framework.d.ts.map +1 -0
- package/lib/frameworks/trpc/trpc.framework.js +137 -0
- package/lib/frameworks/trpc/trpc.framework.js.map +1 -0
- 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 +63 -0
- package/lib/handlers/azure/azure.handler.js.map +1 -0
- 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 +18 -0
- package/lib/handlers/azure/index.js.map +1 -0
- package/lib/handlers/default/default.handler.d.ts +36 -32
- package/lib/handlers/default/default.handler.d.ts.map +1 -0
- package/lib/handlers/default/default.handler.js +48 -52
- package/lib/handlers/default/default.handler.js.map +1 -0
- package/lib/handlers/default/index.d.ts +1 -0
- package/lib/handlers/default/index.d.ts.map +1 -0
- package/lib/handlers/default/index.js +6 -1
- package/lib/handlers/default/index.js.map +1 -0
- package/lib/handlers/huawei/http-huawei.handler.d.ts +14 -4
- package/lib/handlers/huawei/http-huawei.handler.d.ts.map +1 -0
- package/lib/handlers/huawei/http-huawei.handler.js +15 -4
- package/lib/handlers/huawei/http-huawei.handler.js.map +1 -0
- package/lib/handlers/huawei/index.d.ts +1 -0
- package/lib/handlers/huawei/index.d.ts.map +1 -0
- package/lib/handlers/huawei/index.js +6 -1
- package/lib/handlers/huawei/index.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -1
- package/lib/index.js.map +1 -0
- package/lib/network/index.d.ts +1 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.js +6 -1
- package/lib/network/index.js.map +1 -0
- package/lib/network/request.d.ts +28 -0
- package/lib/network/request.d.ts.map +1 -0
- package/lib/network/request.js +7 -0
- package/lib/network/request.js.map +1 -0
- package/lib/network/response.d.ts +18 -1
- package/lib/network/response.d.ts.map +1 -0
- package/lib/network/response.js +9 -1
- package/lib/network/response.js.map +1 -0
- package/lib/resolvers/aws-context/aws-context.resolver.d.ts +7 -9
- package/lib/resolvers/aws-context/aws-context.resolver.d.ts.map +1 -0
- package/lib/resolvers/aws-context/aws-context.resolver.js +7 -9
- package/lib/resolvers/aws-context/aws-context.resolver.js.map +1 -0
- package/lib/resolvers/aws-context/index.d.ts +1 -0
- package/lib/resolvers/aws-context/index.d.ts.map +1 -0
- package/lib/resolvers/aws-context/index.js +6 -1
- package/lib/resolvers/aws-context/index.js.map +1 -0
- package/lib/resolvers/callback/callback.resolver.d.ts +9 -2
- package/lib/resolvers/callback/callback.resolver.d.ts.map +1 -0
- package/lib/resolvers/callback/callback.resolver.js +6 -2
- package/lib/resolvers/callback/callback.resolver.js.map +1 -0
- package/lib/resolvers/callback/index.d.ts +1 -0
- package/lib/resolvers/callback/index.d.ts.map +1 -0
- package/lib/resolvers/callback/index.js +6 -1
- package/lib/resolvers/callback/index.js.map +1 -0
- package/lib/resolvers/dummy/dummy.resolver.d.ts +5 -1
- package/lib/resolvers/dummy/dummy.resolver.d.ts.map +1 -0
- package/lib/resolvers/dummy/dummy.resolver.js +5 -1
- package/lib/resolvers/dummy/dummy.resolver.js.map +1 -0
- package/lib/resolvers/dummy/index.d.ts +1 -0
- package/lib/resolvers/dummy/index.d.ts.map +1 -0
- package/lib/resolvers/dummy/index.js +6 -1
- package/lib/resolvers/dummy/index.js.map +1 -0
- package/lib/resolvers/promise/index.d.ts +1 -0
- package/lib/resolvers/promise/index.d.ts.map +1 -0
- package/lib/resolvers/promise/index.js +6 -1
- package/lib/resolvers/promise/index.js.map +1 -0
- package/lib/resolvers/promise/promise.resolver.d.ts +5 -1
- package/lib/resolvers/promise/promise.resolver.d.ts.map +1 -0
- package/lib/resolvers/promise/promise.resolver.js +5 -1
- package/lib/resolvers/promise/promise.resolver.js.map +1 -0
- package/lib/serverless-adapter.d.ts +17 -12
- package/lib/serverless-adapter.d.ts.map +1 -0
- package/lib/serverless-adapter.js +17 -12
- package/lib/serverless-adapter.js.map +1 -0
- package/package.json +32 -4
- package/lib/@types/proxy-params.d.ts +0 -8
- package/lib/@types/proxy-params.js +0 -2
package/lib/core/constants.d.ts
CHANGED
|
@@ -1,4 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default encodings that are treated as binary, they are compared with the `Content-Encoding` header.
|
|
3
|
+
*
|
|
4
|
+
* @breadcrumb Core / Constants
|
|
5
|
+
* @defaultValue ['gzip', 'deflate', 'br']
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
1
8
|
export declare const DEFAULT_BINARY_ENCODINGS: string[];
|
|
9
|
+
/**
|
|
10
|
+
* Default content types that are treated as binary, they are compared with the `Content-Type` header.
|
|
11
|
+
*
|
|
12
|
+
* @breadcrumb Core / Constants
|
|
13
|
+
* @defaultValue [new RegExp('^image/.*$'), new RegExp('^video/.*$'), 'application/pdf']
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
2
16
|
export declare const DEFAULT_BINARY_CONTENT_TYPES: (string | RegExp)[];
|
|
17
|
+
/**
|
|
18
|
+
* Type alias for empty response and can be used on some adapters when the adapter does not need to return a response.
|
|
19
|
+
*
|
|
20
|
+
* @breadcrumb Core / Constants
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
3
23
|
export declare type IEmptyResponse = {};
|
|
24
|
+
/**
|
|
25
|
+
* Constant for empty response and can be used on some adapters when the adapter does not need to return a response.
|
|
26
|
+
*
|
|
27
|
+
* @breadcrumb Core / Constants
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
4
30
|
export declare const EmptyResponse: IEmptyResponse;
|
|
31
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,EAA8B,CAAC;AAE5E;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAI3D,CAAC;AAEF;;;;;GAKG;AAEH,oBAAY,cAAc,GAAG,EAAE,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,cAAmB,CAAC"}
|
package/lib/core/constants.js
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmptyResponse = exports.DEFAULT_BINARY_CONTENT_TYPES = exports.DEFAULT_BINARY_ENCODINGS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Default encodings that are treated as binary, they are compared with the `Content-Encoding` header.
|
|
6
|
+
*
|
|
7
|
+
* @breadcrumb Core / Constants
|
|
8
|
+
* @defaultValue ['gzip', 'deflate', 'br']
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
4
11
|
exports.DEFAULT_BINARY_ENCODINGS = ['gzip', 'deflate', 'br'];
|
|
12
|
+
/**
|
|
13
|
+
* Default content types that are treated as binary, they are compared with the `Content-Type` header.
|
|
14
|
+
*
|
|
15
|
+
* @breadcrumb Core / Constants
|
|
16
|
+
* @defaultValue [new RegExp('^image/.*$'), new RegExp('^video/.*$'), 'application/pdf']
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
5
19
|
exports.DEFAULT_BINARY_CONTENT_TYPES = [
|
|
6
20
|
new RegExp('^image/.*$'),
|
|
7
21
|
new RegExp('^video/.*$'),
|
|
8
22
|
'application/pdf',
|
|
9
23
|
];
|
|
24
|
+
/**
|
|
25
|
+
* Constant for empty response and can be used on some adapters when the adapter does not need to return a response.
|
|
26
|
+
*
|
|
27
|
+
* @breadcrumb Core / Constants
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
10
30
|
exports.EmptyResponse = {};
|
|
31
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACU,QAAA,wBAAwB,GAAa,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AAE5E;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAwB;IAC/D,IAAI,MAAM,CAAC,YAAY,CAAC;IACxB,IAAI,MAAM,CAAC,YAAY,CAAC;IACxB,iBAAiB;CAClB,CAAC;AAWF;;;;;GAKG;AACU,QAAA,aAAa,GAAmB,EAAE,CAAC"}
|
|
@@ -1,37 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 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.
|
|
3
|
+
*
|
|
4
|
+
* @breadcrumb Core / Current Invoke
|
|
5
|
+
* @public
|
|
3
6
|
*/
|
|
4
7
|
export declare type CurrentInvoke<TEvent, TContext> = {
|
|
5
8
|
/**
|
|
6
9
|
* The event created by the serverless trigger
|
|
7
10
|
*
|
|
8
|
-
* @
|
|
11
|
+
* @remarks It's only null when you call {@link getCurrentInvoke} outside this library's pipeline.
|
|
9
12
|
*/
|
|
10
13
|
event: TEvent | null;
|
|
11
14
|
/**
|
|
12
15
|
* The context created by the serverless environment
|
|
13
16
|
*
|
|
14
|
-
* @
|
|
17
|
+
* @remarks It's only null when you call {@link getCurrentInvoke} outside this library's pipeline.
|
|
15
18
|
*/
|
|
16
19
|
context: TContext | null;
|
|
17
20
|
};
|
|
18
21
|
/**
|
|
19
22
|
* Get the reference to the event created by the serverless trigger or context created by the serverless environment.
|
|
20
23
|
*
|
|
21
|
-
* @example
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
22
26
|
* import type { ALBEvent, Context } from 'aws-lambda';
|
|
23
27
|
*
|
|
24
28
|
* // inside the method that handles the aws alb request.
|
|
25
29
|
* const { event, context } = getCurrentInvoke<ALBEvent, Context>();
|
|
26
30
|
* ```
|
|
31
|
+
*
|
|
32
|
+
* @breadcrumb Core / Current Invoke
|
|
33
|
+
* @public
|
|
27
34
|
*/
|
|
28
35
|
export declare function getCurrentInvoke<TEvent = any, TContext = any>(): CurrentInvoke<TEvent, TContext>;
|
|
29
36
|
/**
|
|
30
37
|
* Method that saves to the event created by the serverless trigger or context created by the serverless environment.
|
|
31
38
|
*
|
|
32
|
-
* @
|
|
39
|
+
* @remarks This method MUST NOT be called by you, this method MUST only be used internally in this library.
|
|
40
|
+
*
|
|
41
|
+
* @param event - The event created by the serverless trigger
|
|
42
|
+
* @param context - The context created by the serverless environment
|
|
33
43
|
*
|
|
34
|
-
* @
|
|
35
|
-
* @
|
|
44
|
+
* @breadcrumb Core / Current Invoke
|
|
45
|
+
* @public
|
|
36
46
|
*/
|
|
37
47
|
export declare function setCurrentInvoke<TEvent = any, TContext = any>({ event, context, }: CurrentInvoke<TEvent, TContext>): void;
|
|
48
|
+
//# sourceMappingURL=current-invoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-invoke.d.ts","sourceRoot":"","sources":["../../src/core/current-invoke.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,oBAAY,aAAa,CAAC,MAAM,EAAE,QAAQ,IAAI;IAC5C;;;;OAIG;IACH,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAErB;;;;OAIG;IACH,OAAO,EAAE,QAAQ,GAAG,IAAI,CAAC;CAC1B,CAAC;AAOF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAG,GAAG,EAAE,QAAQ,GAAG,GAAG,KAAK,aAAa,CAC7E,MAAM,EACN,QAAQ,CACT,CAEA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,GAAG,GAAG,EAAE,QAAQ,GAAG,GAAG,EAAE,EAC7D,KAAK,EACL,OAAO,GACR,EAAE,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,QAGjC"}
|
|
@@ -8,12 +8,16 @@ const currentInvoke = {
|
|
|
8
8
|
/**
|
|
9
9
|
* Get the reference to the event created by the serverless trigger or context created by the serverless environment.
|
|
10
10
|
*
|
|
11
|
-
* @example
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
12
13
|
* import type { ALBEvent, Context } from 'aws-lambda';
|
|
13
14
|
*
|
|
14
15
|
* // inside the method that handles the aws alb request.
|
|
15
16
|
* const { event, context } = getCurrentInvoke<ALBEvent, Context>();
|
|
16
17
|
* ```
|
|
18
|
+
*
|
|
19
|
+
* @breadcrumb Core / Current Invoke
|
|
20
|
+
* @public
|
|
17
21
|
*/
|
|
18
22
|
function getCurrentInvoke() {
|
|
19
23
|
return currentInvoke;
|
|
@@ -22,13 +26,17 @@ exports.getCurrentInvoke = getCurrentInvoke;
|
|
|
22
26
|
/**
|
|
23
27
|
* Method that saves to the event created by the serverless trigger or context created by the serverless environment.
|
|
24
28
|
*
|
|
25
|
-
* @
|
|
29
|
+
* @remarks This method MUST NOT be called by you, this method MUST only be used internally in this library.
|
|
30
|
+
*
|
|
31
|
+
* @param event - The event created by the serverless trigger
|
|
32
|
+
* @param context - The context created by the serverless environment
|
|
26
33
|
*
|
|
27
|
-
* @
|
|
28
|
-
* @
|
|
34
|
+
* @breadcrumb Core / Current Invoke
|
|
35
|
+
* @public
|
|
29
36
|
*/
|
|
30
37
|
function setCurrentInvoke({ event, context, }) {
|
|
31
38
|
currentInvoke.event = event;
|
|
32
39
|
currentInvoke.context = context;
|
|
33
40
|
}
|
|
34
41
|
exports.setCurrentInvoke = setCurrentInvoke;
|
|
42
|
+
//# sourceMappingURL=current-invoke.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"current-invoke.js","sourceRoot":"","sources":["../../src/core/current-invoke.ts"],"names":[],"mappings":";;;AAsBA,MAAM,aAAa,GAA4B;IAC7C,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;CACZ,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,SAAgB,gBAAgB;IAI9B,OAAO,aAAa,CAAC;AACvB,CAAC;AALD,4CAKC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAA+B,EAC7D,KAAK,EACL,OAAO,GACyB;IAChC,aAAa,CAAC,KAAK,GAAG,KAAK,CAAC;IAC5B,aAAa,CAAC,OAAO,GAAG,OAAO,CAAC;AAClC,CAAC;AAND,4CAMC"}
|
package/lib/core/event-body.d.ts
CHANGED
|
@@ -2,15 +2,21 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Get the event body as buffer from body string with content length
|
|
4
4
|
*
|
|
5
|
-
* @example
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
6
7
|
* const body = '{}';
|
|
7
8
|
* const [buffer, contentLength] = getEventBodyAsBuffer(body, false);
|
|
8
9
|
* console.log(buffer);
|
|
9
10
|
* // <Buffer 7b 7d>
|
|
10
11
|
* console.log(contentLength);
|
|
11
12
|
* // 2
|
|
13
|
+
* ```
|
|
12
14
|
*
|
|
13
|
-
* @param body The body string that can be encoded or not
|
|
14
|
-
* @param isBase64Encoded Tells if body string is encoded in base64
|
|
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
|
|
15
20
|
*/
|
|
16
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
|
@@ -4,16 +4,21 @@ exports.getEventBodyAsBuffer = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Get the event body as buffer from body string with content length
|
|
6
6
|
*
|
|
7
|
-
* @example
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
8
9
|
* const body = '{}';
|
|
9
10
|
* const [buffer, contentLength] = getEventBodyAsBuffer(body, false);
|
|
10
11
|
* console.log(buffer);
|
|
11
12
|
* // <Buffer 7b 7d>
|
|
12
13
|
* console.log(contentLength);
|
|
13
14
|
* // 2
|
|
15
|
+
* ```
|
|
14
16
|
*
|
|
15
|
-
* @param body The body string that can be encoded or not
|
|
16
|
-
* @param isBase64Encoded Tells if body string is encoded in base64
|
|
17
|
+
* @param body - The body string that can be encoded or not
|
|
18
|
+
* @param isBase64Encoded - Tells if body string is encoded in base64
|
|
19
|
+
*
|
|
20
|
+
* @breadcrumb Core
|
|
21
|
+
* @public
|
|
17
22
|
*/
|
|
18
23
|
function getEventBodyAsBuffer(body, isBase64Encoded) {
|
|
19
24
|
const encoding = isBase64Encoded ? 'base64' : 'utf8';
|
|
@@ -22,3 +27,4 @@ function getEventBodyAsBuffer(body, isBase64Encoded) {
|
|
|
22
27
|
return [buffer, contentLength];
|
|
23
28
|
}
|
|
24
29
|
exports.getEventBodyAsBuffer = getEventBodyAsBuffer;
|
|
30
|
+
//# sourceMappingURL=event-body.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-body.js","sourceRoot":"","sources":["../../src/core/event-body.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,oBAAoB,CAClC,IAAY,EACZ,eAAwB;IAExB,MAAM,QAAQ,GAAmB,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IAErE,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC3C,MAAM,aAAa,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAE1D,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AACjC,CAAC;AAVD,oDAUC"}
|
package/lib/core/headers.d.ts
CHANGED
|
@@ -2,26 +2,37 @@ import { BothValueHeaders } from '../@types';
|
|
|
2
2
|
/**
|
|
3
3
|
* Transform a header map and make sure the value is not an array
|
|
4
4
|
*
|
|
5
|
-
* @example
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
6
7
|
* const headers = { 'accept-encoding': 'gzip', 'accept-language': ['en-US', 'en;q=0.9'] };
|
|
7
8
|
* const flattenedHeaders = getFlattenedHeadersMap(headers, ',', true);
|
|
8
9
|
* console.log(flattenedHeaders);
|
|
9
10
|
* // { 'accept-encoding': 'gzip', 'accept-language': 'en-US,en;q=0.9' }
|
|
10
11
|
* ```
|
|
11
|
-
*
|
|
12
|
-
* @param
|
|
13
|
-
* @param
|
|
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
|
|
14
19
|
*/
|
|
15
20
|
export declare function getFlattenedHeadersMap(headersMap: BothValueHeaders, separator?: string, lowerCaseKey?: boolean): Record<string, string>;
|
|
16
21
|
/**
|
|
17
22
|
* Transforms a header map into a multi-value map header.
|
|
18
23
|
*
|
|
19
|
-
* @example
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
20
26
|
* const headers = { 'accept-encoding': 'gzip', 'connection': ['keep-alive'] };
|
|
21
27
|
* const multiValueHeaders = getMultiValueHeadersMap(headers);
|
|
22
28
|
* console.log(multiValueHeaders);
|
|
23
29
|
* // { 'accept-encoding': ['gzip'], 'connection': ['keep-alive'] }
|
|
24
30
|
* ```
|
|
25
|
-
*
|
|
31
|
+
*
|
|
32
|
+
* @param headersMap - The initial headers
|
|
33
|
+
*
|
|
34
|
+
* @breadcrumb Core / Headers
|
|
35
|
+
* @public
|
|
26
36
|
*/
|
|
27
37
|
export declare function getMultiValueHeadersMap(headersMap: BothValueHeaders): Record<string, string[]>;
|
|
38
|
+
//# 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,CAaxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,gBAAgB,GAC3B,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAW1B"}
|
package/lib/core/headers.js
CHANGED
|
@@ -6,15 +6,20 @@ exports.getMultiValueHeadersMap = exports.getFlattenedHeadersMap = void 0;
|
|
|
6
6
|
/**
|
|
7
7
|
* Transform a header map and make sure the value is not an array
|
|
8
8
|
*
|
|
9
|
-
* @example
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
10
11
|
* const headers = { 'accept-encoding': 'gzip', 'accept-language': ['en-US', 'en;q=0.9'] };
|
|
11
12
|
* const flattenedHeaders = getFlattenedHeadersMap(headers, ',', true);
|
|
12
13
|
* console.log(flattenedHeaders);
|
|
13
14
|
* // { 'accept-encoding': 'gzip', 'accept-language': 'en-US,en;q=0.9' }
|
|
14
15
|
* ```
|
|
15
|
-
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
16
|
+
*
|
|
17
|
+
* @param headersMap - The initial headers
|
|
18
|
+
* @param separator - The separator used when we join the array of header's value
|
|
19
|
+
* @param lowerCaseKey - Should put all keys in lowercase
|
|
20
|
+
*
|
|
21
|
+
* @breadcrumb Core / Headers
|
|
22
|
+
* @public
|
|
18
23
|
*/
|
|
19
24
|
function getFlattenedHeadersMap(headersMap, separator = ',', lowerCaseKey = false) {
|
|
20
25
|
const commaDelimitedHeaders = {};
|
|
@@ -32,13 +37,18 @@ exports.getFlattenedHeadersMap = getFlattenedHeadersMap;
|
|
|
32
37
|
/**
|
|
33
38
|
* Transforms a header map into a multi-value map header.
|
|
34
39
|
*
|
|
35
|
-
* @example
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
36
42
|
* const headers = { 'accept-encoding': 'gzip', 'connection': ['keep-alive'] };
|
|
37
43
|
* const multiValueHeaders = getMultiValueHeadersMap(headers);
|
|
38
44
|
* console.log(multiValueHeaders);
|
|
39
45
|
* // { 'accept-encoding': ['gzip'], 'connection': ['keep-alive'] }
|
|
40
46
|
* ```
|
|
41
|
-
*
|
|
47
|
+
*
|
|
48
|
+
* @param headersMap - The initial headers
|
|
49
|
+
*
|
|
50
|
+
* @breadcrumb Core / Headers
|
|
51
|
+
* @public
|
|
42
52
|
*/
|
|
43
53
|
function getMultiValueHeadersMap(headersMap) {
|
|
44
54
|
const multiValueHeaders = {};
|
|
@@ -51,3 +61,4 @@ function getMultiValueHeadersMap(headersMap) {
|
|
|
51
61
|
return multiValueHeaders;
|
|
52
62
|
}
|
|
53
63
|
exports.getMultiValueHeadersMap = getMultiValueHeadersMap;
|
|
64
|
+
//# sourceMappingURL=headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../../src/core/headers.ts"],"names":[],"mappings":";AAAA,iBAAiB;;;AAIjB,YAAY;AAEZ;;;;;;;;;;;;;;;;;GAiBG;AACH,SAAgB,sBAAsB,CACpC,UAA4B,EAC5B,YAAoB,GAAG,EACvB,eAAwB,KAAK;IAE7B,MAAM,qBAAqB,GAA2B,EAAE,CAAC;IACzD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAErD,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,iBAAiB,EAAE;QACxD,MAAM,MAAM,GAAG,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;QAElE,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;YAC5B,qBAAqB,CAAC,MAAM,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;;YACzD,qBAAqB,CAAC,MAAM,CAAC,GAAG,WAAW,IAAI,EAAE,CAAC;KACxD;IAED,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAjBD,wDAiBC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,uBAAuB,CACrC,UAA4B;IAE5B,MAAM,iBAAiB,GAA6B,EAAE,CAAC;IACvD,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAErD,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,iBAAiB,EAAE;QACxD,iBAAiB,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;YACrE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC;YACzB,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;KAC3B;IAED,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAbD,0DAaC"}
|
package/lib/core/index.d.ts
CHANGED
|
@@ -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,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -21,3 +25,4 @@ __exportStar(require("./no-op"), exports);
|
|
|
21
25
|
__exportStar(require("./optional"), exports);
|
|
22
26
|
__exportStar(require("./path"), exports);
|
|
23
27
|
__exportStar(require("./stream"), exports);
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,8CAA4B;AAC5B,mDAAiC;AACjC,+CAA6B;AAC7B,4CAA0B;AAC1B,8CAA4B;AAC5B,2CAAyB;AACzB,0CAAwB;AACxB,6CAA2B;AAC3B,yCAAuB;AACvB,2CAAyB"}
|
package/lib/core/is-binary.d.ts
CHANGED
|
@@ -2,54 +2,72 @@ import { BinarySettings, BothValueHeaders } from '../@types';
|
|
|
2
2
|
/**
|
|
3
3
|
* The function that determines by the content encoding whether the response should be treated as binary
|
|
4
4
|
*
|
|
5
|
-
* @example
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
6
7
|
* const headers = { 'Content-Encoding': 'gzip' };
|
|
7
8
|
* const isBinary = isContentEncodingBinary(headers, ['gzip']);
|
|
8
9
|
* console.log(isBinary);
|
|
9
10
|
* // true
|
|
10
11
|
* ```
|
|
11
12
|
*
|
|
12
|
-
* @param headers The headers of the response
|
|
13
|
-
* @param binaryEncodingTypes The list of content encodings that will be treated as binary
|
|
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
|
|
14
18
|
*/
|
|
15
19
|
export declare function isContentEncodingBinary(headers: BothValueHeaders, binaryEncodingTypes: string[]): boolean;
|
|
16
20
|
/**
|
|
17
21
|
* The function that returns the content type of headers
|
|
18
22
|
*
|
|
19
|
-
* @example
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
20
25
|
* const headers = { 'Content-Type': 'application/json' };
|
|
21
26
|
* const contentType = getContentType(headers);
|
|
22
27
|
* console.log(contentType);
|
|
23
28
|
* // application/json
|
|
24
29
|
* ```
|
|
25
30
|
*
|
|
26
|
-
* @param headers The headers of the response
|
|
31
|
+
* @param headers - The headers of the response
|
|
32
|
+
*
|
|
33
|
+
* @breadcrumb Core / isBinary
|
|
34
|
+
* @public
|
|
27
35
|
*/
|
|
28
36
|
export declare function getContentType(headers: BothValueHeaders): string;
|
|
29
37
|
/**
|
|
30
38
|
* The function that determines by the content type whether the response should be treated as binary
|
|
31
39
|
*
|
|
32
|
-
* @example
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
33
42
|
* const headers = { 'Content-Type': 'image/png' };
|
|
34
43
|
* const isBinary = isContentTypeBinary(headers, [new RegExp('^image/.*$')]);
|
|
35
44
|
* console.log(isBinary);
|
|
36
45
|
* // true
|
|
37
46
|
* ```
|
|
38
47
|
*
|
|
39
|
-
* @param headers The headers of the response
|
|
40
|
-
* @param binaryContentTypes The list of content types that will be treated as binary
|
|
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
|
|
41
53
|
*/
|
|
42
54
|
export declare function isContentTypeBinary(headers: BothValueHeaders, binaryContentTypes: (string | RegExp)[]): boolean;
|
|
43
55
|
/**
|
|
44
56
|
* The function used to determine from the headers and the binary settings if a response should be encoded or not
|
|
45
57
|
*
|
|
46
|
-
* @example
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
47
60
|
* const headers = { 'Content-Type': 'image/png', 'Content-Encoding': 'gzip' };
|
|
48
61
|
* const isContentBinary = isBinary(headers, { contentEncodings: ['gzip'], contentTypes: [new RegExp('^image/.*$')] });
|
|
49
62
|
* console.log(isContentBinary);
|
|
50
63
|
* // true
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* @param headers - The headers of the response
|
|
67
|
+
* @param binarySettings - The settings for the validation
|
|
51
68
|
*
|
|
52
|
-
* @
|
|
53
|
-
* @
|
|
69
|
+
* @breadcrumb Core / isBinary
|
|
70
|
+
* @public
|
|
54
71
|
*/
|
|
55
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;AAK7D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,gBAAgB,EACzB,mBAAmB,EAAE,MAAM,EAAE,GAC5B,OAAO,CAUT;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAMhE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gBAAgB,EACzB,kBAAkB,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,WAexC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,gBAAgB,EACzB,cAAc,EAAE,cAAc,GAC7B,OAAO,CAWT"}
|
package/lib/core/is-binary.js
CHANGED
|
@@ -7,15 +7,19 @@ const headers_1 = require("./headers");
|
|
|
7
7
|
/**
|
|
8
8
|
* The function that determines by the content encoding whether the response should be treated as binary
|
|
9
9
|
*
|
|
10
|
-
* @example
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
11
12
|
* const headers = { 'Content-Encoding': 'gzip' };
|
|
12
13
|
* const isBinary = isContentEncodingBinary(headers, ['gzip']);
|
|
13
14
|
* console.log(isBinary);
|
|
14
15
|
* // true
|
|
15
16
|
* ```
|
|
16
17
|
*
|
|
17
|
-
* @param headers The headers of the response
|
|
18
|
-
* @param binaryEncodingTypes The list of content encodings that will be treated as binary
|
|
18
|
+
* @param headers - The headers of the response
|
|
19
|
+
* @param binaryEncodingTypes - The list of content encodings that will be treated as binary
|
|
20
|
+
*
|
|
21
|
+
* @breadcrumb Core / isBinary
|
|
22
|
+
* @public
|
|
19
23
|
*/
|
|
20
24
|
function isContentEncodingBinary(headers, binaryEncodingTypes) {
|
|
21
25
|
const multiValueHeaders = (0, headers_1.getMultiValueHeadersMap)(headers);
|
|
@@ -28,14 +32,18 @@ exports.isContentEncodingBinary = isContentEncodingBinary;
|
|
|
28
32
|
/**
|
|
29
33
|
* The function that returns the content type of headers
|
|
30
34
|
*
|
|
31
|
-
* @example
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
32
37
|
* const headers = { 'Content-Type': 'application/json' };
|
|
33
38
|
* const contentType = getContentType(headers);
|
|
34
39
|
* console.log(contentType);
|
|
35
40
|
* // application/json
|
|
36
41
|
* ```
|
|
37
42
|
*
|
|
38
|
-
* @param headers The headers of the response
|
|
43
|
+
* @param headers - The headers of the response
|
|
44
|
+
*
|
|
45
|
+
* @breadcrumb Core / isBinary
|
|
46
|
+
* @public
|
|
39
47
|
*/
|
|
40
48
|
function getContentType(headers) {
|
|
41
49
|
const flattenedHeaders = (0, headers_1.getFlattenedHeadersMap)(headers, ';', true);
|
|
@@ -47,15 +55,19 @@ exports.getContentType = getContentType;
|
|
|
47
55
|
/**
|
|
48
56
|
* The function that determines by the content type whether the response should be treated as binary
|
|
49
57
|
*
|
|
50
|
-
* @example
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
51
60
|
* const headers = { 'Content-Type': 'image/png' };
|
|
52
61
|
* const isBinary = isContentTypeBinary(headers, [new RegExp('^image/.*$')]);
|
|
53
62
|
* console.log(isBinary);
|
|
54
63
|
* // true
|
|
55
64
|
* ```
|
|
56
65
|
*
|
|
57
|
-
* @param headers The headers of the response
|
|
58
|
-
* @param binaryContentTypes The list of content types that will be treated as binary
|
|
66
|
+
* @param headers - The headers of the response
|
|
67
|
+
* @param binaryContentTypes - The list of content types that will be treated as binary
|
|
68
|
+
*
|
|
69
|
+
* @breadcrumb Core / isBinary
|
|
70
|
+
* @public
|
|
59
71
|
*/
|
|
60
72
|
function isContentTypeBinary(headers, binaryContentTypes) {
|
|
61
73
|
const binaryContentTypesRegexes = binaryContentTypes.map(binaryContentType => binaryContentType instanceof RegExp
|
|
@@ -70,14 +82,19 @@ exports.isContentTypeBinary = isContentTypeBinary;
|
|
|
70
82
|
/**
|
|
71
83
|
* The function used to determine from the headers and the binary settings if a response should be encoded or not
|
|
72
84
|
*
|
|
73
|
-
* @example
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
74
87
|
* const headers = { 'Content-Type': 'image/png', 'Content-Encoding': 'gzip' };
|
|
75
88
|
* const isContentBinary = isBinary(headers, { contentEncodings: ['gzip'], contentTypes: [new RegExp('^image/.*$')] });
|
|
76
89
|
* console.log(isContentBinary);
|
|
77
90
|
* // true
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* @param headers - The headers of the response
|
|
94
|
+
* @param binarySettings - The settings for the validation
|
|
78
95
|
*
|
|
79
|
-
* @
|
|
80
|
-
* @
|
|
96
|
+
* @breadcrumb Core / isBinary
|
|
97
|
+
* @public
|
|
81
98
|
*/
|
|
82
99
|
function isBinary(headers, binarySettings) {
|
|
83
100
|
if ('isBinary' in binarySettings) {
|
|
@@ -89,3 +106,4 @@ function isBinary(headers, binarySettings) {
|
|
|
89
106
|
isContentTypeBinary(headers, binarySettings.contentTypes));
|
|
90
107
|
}
|
|
91
108
|
exports.isBinary = isBinary;
|
|
109
|
+
//# sourceMappingURL=is-binary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-binary.js","sourceRoot":"","sources":["../../src/core/is-binary.ts"],"names":[],"mappings":";AAAA,8DAA8D;;;AAK9D,uCAA4E;AAE5E,YAAY;AAEZ;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,uBAAuB,CACrC,OAAyB,EACzB,mBAA6B;IAE7B,MAAM,iBAAiB,GAAG,IAAA,iCAAuB,EAAC,OAAO,CAAC,CAAC;IAE3D,MAAM,gBAAgB,GAAG,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;IAE/D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC;QAAE,OAAO,KAAK,CAAC;IAEnD,OAAO,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CACnC,mBAAmB,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAC3E,CAAC;AACJ,CAAC;AAbD,0DAaC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,cAAc,CAAC,OAAyB;IACtD,MAAM,gBAAgB,GAAG,IAAA,gCAAsB,EAAC,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;IACpE,MAAM,iBAAiB,GAAG,gBAAgB,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IAEjE,+CAA+C;IAC/C,OAAO,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AACzC,CAAC;AAND,wCAMC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,mBAAmB,CACjC,OAAyB,EACzB,kBAAuC;IAEvC,MAAM,yBAAyB,GAAG,kBAAkB,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAC3E,iBAAiB,YAAY,MAAM;QACjC,CAAC,CAAC,iBAAiB;QACnB,CAAC,CAAC,IAAI,MAAM,CAAC,GAAG,iBAAiB,EAAE,CAAC,CACvC,CAAC;IAEF,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC;IAE5C,IAAI,CAAC,WAAW;QAAE,OAAO,KAAK,CAAC;IAE/B,OAAO,yBAAyB,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CACxD,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,CACpC,CAAC;AACJ,CAAC;AAjBD,kDAiBC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,QAAQ,CACtB,OAAyB,EACzB,cAA8B;IAE9B,IAAI,UAAU,IAAI,cAAc,EAAE;QAChC,IAAI,cAAc,CAAC,QAAQ,KAAK,KAAK;YAAE,OAAO,KAAK,CAAC;QAEpD,OAAO,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;KACzC;IAED,OAAO,CACL,uBAAuB,CAAC,OAAO,EAAE,cAAc,CAAC,gBAAgB,CAAC;QACjE,mBAAmB,CAAC,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,CAC1D,CAAC;AACJ,CAAC;AAdD,4BAcC"}
|
package/lib/core/logger.d.ts
CHANGED
|
@@ -1,38 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The type representing the possible log levels to choose from.
|
|
3
|
+
*
|
|
4
|
+
* @breadcrumb Core / Logger
|
|
5
|
+
* @public
|
|
3
6
|
*/
|
|
4
7
|
export declare type LogLevels = 'debug' | 'verbose' | 'info' | 'warn' | 'error' | 'none';
|
|
5
8
|
/**
|
|
6
9
|
* The options to customize {@link ILogger}
|
|
10
|
+
*
|
|
11
|
+
* @breadcrumb Core / Logger
|
|
12
|
+
* @public
|
|
7
13
|
*/
|
|
8
14
|
export declare type LoggerOptions = {
|
|
9
15
|
/**
|
|
10
|
-
* Select the log level, {@link LogLevels see more}.
|
|
16
|
+
* Select the log level, {@link LogLevels | see more}.
|
|
11
17
|
*
|
|
12
|
-
* @
|
|
18
|
+
* @defaultValue error
|
|
13
19
|
*/
|
|
14
20
|
level: LogLevels;
|
|
15
21
|
};
|
|
16
22
|
/**
|
|
17
23
|
* The log function used in any level.
|
|
24
|
+
*
|
|
25
|
+
* @breadcrumb Core / Logger
|
|
26
|
+
* @public
|
|
18
27
|
*/
|
|
19
28
|
export declare type LoggerFN = (message: any, ...additional: any[]) => void;
|
|
20
29
|
/**
|
|
21
30
|
* The interface representing the logger, you can provide a custom logger by implementing this interface.
|
|
31
|
+
*
|
|
32
|
+
* @breadcrumb Core / Logger
|
|
33
|
+
* @public
|
|
22
34
|
*/
|
|
23
35
|
export declare type ILogger = Record<Exclude<LogLevels, 'none'>, LoggerFN>;
|
|
24
36
|
/**
|
|
25
37
|
* The method used to create a simple logger instance to use in this library.
|
|
26
38
|
*
|
|
27
|
-
* @
|
|
39
|
+
* @remarks Behind the scenes, this simple logger sends the message to the `console` methods.
|
|
28
40
|
*
|
|
29
|
-
* @example
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
30
43
|
* const logger = createDefaultLogger();
|
|
31
44
|
*
|
|
32
45
|
* logger.error('An error happens.');
|
|
33
46
|
* // An error happens.
|
|
34
47
|
* ```
|
|
35
48
|
*
|
|
36
|
-
* @param level Select the level of the log
|
|
49
|
+
* @param level - Select the level of the log
|
|
50
|
+
*
|
|
51
|
+
* @breadcrumb Core / Logger
|
|
52
|
+
* @public
|
|
37
53
|
*/
|
|
38
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":"AAAA;;;;;GAKG;AACH,oBAAY,SAAS,GACjB,OAAO,GACP,SAAS,GACT,MAAM,GACN,MAAM,GACN,OAAO,GACP,MAAM,CAAC;AAEX;;;;;GAKG;AACH,oBAAY,aAAa,GAAG;IAC1B;;;;OAIG;IACH,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF;;;;;GAKG;AACH,oBAAY,QAAQ,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,GAAG,UAAU,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;AAEpE;;;;;GAKG;AACH,oBAAY,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,CAAC;AAUnE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CACjC,EAAE,KAAK,EAAE,GAAE,aAAkC,GAC5C,OAAO,CAkCT;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAEzD"}
|