@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
|
@@ -1,59 +1,66 @@
|
|
|
1
|
-
import { HuaweiApiGatewayEvent, HuaweiContext } from '../../@types/huawei';
|
|
2
|
-
import { HuaweiApiGatewayResponse } from '../../@types/huawei/huawei-api-gateway-response';
|
|
1
|
+
import { HuaweiApiGatewayEvent, HuaweiApiGatewayResponse, HuaweiContext } from '../../@types/huawei';
|
|
3
2
|
import { AdapterContract, AdapterRequest, GetResponseAdapterProps, OnErrorProps } from '../../contracts';
|
|
4
3
|
/**
|
|
5
4
|
* The options to customize the {@link HuaweiApiGatewayAdapter}
|
|
5
|
+
*
|
|
6
|
+
* @breadcrumb Adapters / Huawei / HuaweiApiGatewayAdapter
|
|
7
|
+
* @public
|
|
6
8
|
*/
|
|
7
9
|
export interface HuaweiApiGatewayOptions {
|
|
8
10
|
/**
|
|
9
11
|
* Strip base path for custom domains
|
|
10
12
|
*
|
|
11
|
-
* @
|
|
13
|
+
* @defaultValue ''
|
|
12
14
|
*/
|
|
13
15
|
stripBasePath?: string;
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* The adapter to handle requests from Huawei Api Gateway
|
|
17
19
|
*
|
|
18
|
-
* @example
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
19
22
|
* const stripBasePath = '/any/custom/base/path'; // default ''
|
|
20
23
|
* const adapter = new ApiGatewayAdapter({ stripBasePath });
|
|
21
24
|
* ```
|
|
22
25
|
*
|
|
23
|
-
*
|
|
26
|
+
* @breadcrumb Adapters / Huawei / HuaweiApiGatewayAdapter
|
|
27
|
+
* @public
|
|
28
|
+
*
|
|
29
|
+
* {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0102.html#functiongraph_02_0102__li5178638110137 | Event Reference}
|
|
24
30
|
*/
|
|
25
31
|
export declare class HuaweiApiGatewayAdapter implements AdapterContract<HuaweiApiGatewayEvent, HuaweiContext, HuaweiApiGatewayResponse> {
|
|
26
32
|
protected readonly options?: HuaweiApiGatewayOptions | undefined;
|
|
27
33
|
/**
|
|
28
34
|
* Default constructor
|
|
29
35
|
*
|
|
30
|
-
* @param options The options to customize the {@link HuaweiApiGatewayAdapter}
|
|
36
|
+
* @param options - The options to customize the {@link HuaweiApiGatewayAdapter}
|
|
31
37
|
*/
|
|
32
38
|
constructor(options?: HuaweiApiGatewayOptions | undefined);
|
|
33
39
|
/**
|
|
34
|
-
* @inheritDoc
|
|
40
|
+
* {@inheritDoc}
|
|
35
41
|
*/
|
|
36
42
|
getAdapterName(): string;
|
|
37
43
|
/**
|
|
38
|
-
* @inheritDoc
|
|
44
|
+
* {@inheritDoc}
|
|
39
45
|
*/
|
|
40
46
|
canHandle(event: unknown): event is HuaweiApiGatewayEvent;
|
|
41
47
|
/**
|
|
42
|
-
* @inheritDoc
|
|
48
|
+
* {@inheritDoc}
|
|
43
49
|
*/
|
|
44
50
|
getRequest(event: HuaweiApiGatewayEvent): AdapterRequest;
|
|
45
51
|
/**
|
|
46
|
-
* @inheritDoc
|
|
52
|
+
* {@inheritDoc}
|
|
47
53
|
*/
|
|
48
54
|
getResponse({ headers: responseHeaders, body, isBase64Encoded, statusCode, }: GetResponseAdapterProps<HuaweiApiGatewayEvent>): HuaweiApiGatewayResponse;
|
|
49
55
|
/**
|
|
50
|
-
* @inheritDoc
|
|
56
|
+
* {@inheritDoc}
|
|
51
57
|
*/
|
|
52
58
|
onErrorWhileForwarding({ error, delegatedResolver, respondWithErrors, event, log, }: OnErrorProps<HuaweiApiGatewayEvent, HuaweiApiGatewayResponse>): void;
|
|
53
59
|
/**
|
|
54
60
|
* Get path from event with query strings
|
|
55
61
|
*
|
|
56
|
-
* @param event The event sent by serverless
|
|
62
|
+
* @param event - The event sent by serverless
|
|
57
63
|
*/
|
|
58
64
|
protected getPathFromEvent(event: HuaweiApiGatewayEvent): string;
|
|
59
65
|
}
|
|
66
|
+
//# sourceMappingURL=huawei-api-gateway.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"huawei-api-gateway.adapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/huawei/huawei-api-gateway.adapter.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,YAAY,EACb,MAAM,iBAAiB,CAAC;AAWzB;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB;IACtC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,uBACX,YACE,eAAe,CACb,qBAAqB,EACrB,aAAa,EACb,wBAAwB,CACzB;IASS,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC;IALvC;;;;OAIG;gBAC4B,OAAO,CAAC,qCAAyB;IAMhE;;OAEG;IACI,cAAc,IAAI,MAAM;IAI/B;;OAEG;IACI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB;IAehE;;OAEG;IACI,UAAU,CAAC,KAAK,EAAE,qBAAqB,GAAG,cAAc;IA6B/D;;OAEG;IACI,WAAW,CAAC,EACjB,OAAO,EAAE,eAAe,EACxB,IAAI,EACJ,eAAe,EACf,UAAU,GACX,EAAE,uBAAuB,CAAC,qBAAqB,CAAC,GAAG,wBAAwB;IAW5E;;OAEG;IACI,sBAAsB,CAAC,EAC5B,KAAK,EACL,iBAAiB,EACjB,iBAAiB,EACjB,KAAK,EACL,GAAG,GACJ,EAAE,YAAY,CAAC,qBAAqB,EAAE,wBAAwB,CAAC,GAAG,IAAI;IAkBvE;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,MAAM;CAcjE"}
|
|
@@ -6,19 +6,23 @@ const core_1 = require("../../core");
|
|
|
6
6
|
/**
|
|
7
7
|
* The adapter to handle requests from Huawei Api Gateway
|
|
8
8
|
*
|
|
9
|
-
* @example
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
10
11
|
* const stripBasePath = '/any/custom/base/path'; // default ''
|
|
11
12
|
* const adapter = new ApiGatewayAdapter({ stripBasePath });
|
|
12
13
|
* ```
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
+
* @breadcrumb Adapters / Huawei / HuaweiApiGatewayAdapter
|
|
16
|
+
* @public
|
|
17
|
+
*
|
|
18
|
+
* {@link https://support.huaweicloud.com/intl/en-us/devg-functiongraph/functiongraph_02_0102.html#functiongraph_02_0102__li5178638110137 | Event Reference}
|
|
15
19
|
*/
|
|
16
20
|
class HuaweiApiGatewayAdapter {
|
|
17
21
|
//#region Constructor
|
|
18
22
|
/**
|
|
19
23
|
* Default constructor
|
|
20
24
|
*
|
|
21
|
-
* @param options The options to customize the {@link HuaweiApiGatewayAdapter}
|
|
25
|
+
* @param options - The options to customize the {@link HuaweiApiGatewayAdapter}
|
|
22
26
|
*/
|
|
23
27
|
constructor(options) {
|
|
24
28
|
this.options = options;
|
|
@@ -26,13 +30,13 @@ class HuaweiApiGatewayAdapter {
|
|
|
26
30
|
//#endregion
|
|
27
31
|
//#region Public Methods
|
|
28
32
|
/**
|
|
29
|
-
* @inheritDoc
|
|
33
|
+
* {@inheritDoc}
|
|
30
34
|
*/
|
|
31
35
|
getAdapterName() {
|
|
32
36
|
return HuaweiApiGatewayAdapter.name;
|
|
33
37
|
}
|
|
34
38
|
/**
|
|
35
|
-
* @inheritDoc
|
|
39
|
+
* {@inheritDoc}
|
|
36
40
|
*/
|
|
37
41
|
canHandle(event) {
|
|
38
42
|
const apiGatewayEvent = event;
|
|
@@ -46,7 +50,7 @@ class HuaweiApiGatewayAdapter {
|
|
|
46
50
|
!('multiValueQueryStringParameters' in apiGatewayEvent));
|
|
47
51
|
}
|
|
48
52
|
/**
|
|
49
|
-
* @inheritDoc
|
|
53
|
+
* {@inheritDoc}
|
|
50
54
|
*/
|
|
51
55
|
getRequest(event) {
|
|
52
56
|
const method = event.httpMethod;
|
|
@@ -68,7 +72,7 @@ class HuaweiApiGatewayAdapter {
|
|
|
68
72
|
};
|
|
69
73
|
}
|
|
70
74
|
/**
|
|
71
|
-
* @inheritDoc
|
|
75
|
+
* {@inheritDoc}
|
|
72
76
|
*/
|
|
73
77
|
getResponse({ headers: responseHeaders, body, isBase64Encoded, statusCode, }) {
|
|
74
78
|
const headers = (0, core_1.getMultiValueHeadersMap)(responseHeaders);
|
|
@@ -80,7 +84,7 @@ class HuaweiApiGatewayAdapter {
|
|
|
80
84
|
};
|
|
81
85
|
}
|
|
82
86
|
/**
|
|
83
|
-
* @inheritDoc
|
|
87
|
+
* {@inheritDoc}
|
|
84
88
|
*/
|
|
85
89
|
onErrorWhileForwarding({ error, delegatedResolver, respondWithErrors, event, log, }) {
|
|
86
90
|
const body = respondWithErrors ? error.stack : '';
|
|
@@ -99,7 +103,7 @@ class HuaweiApiGatewayAdapter {
|
|
|
99
103
|
/**
|
|
100
104
|
* Get path from event with query strings
|
|
101
105
|
*
|
|
102
|
-
* @param event The event sent by serverless
|
|
106
|
+
* @param event - The event sent by serverless
|
|
103
107
|
*/
|
|
104
108
|
getPathFromEvent(event) {
|
|
105
109
|
var _a;
|
|
@@ -111,3 +115,4 @@ class HuaweiApiGatewayAdapter {
|
|
|
111
115
|
}
|
|
112
116
|
}
|
|
113
117
|
exports.HuaweiApiGatewayAdapter = HuaweiApiGatewayAdapter;
|
|
118
|
+
//# sourceMappingURL=huawei-api-gateway.adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"huawei-api-gateway.adapter.js","sourceRoot":"","sources":["../../../src/adapters/huawei/huawei-api-gateway.adapter.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/huawei/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
|
|
@@ -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];
|
|
@@ -11,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./huawei-api-gateway.adapter"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/huawei/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+DAA6C"}
|
|
@@ -3,25 +3,11 @@ import { BothValueHeaders, SingleValueHeaders } from '../@types';
|
|
|
3
3
|
import { ILogger } from '../core';
|
|
4
4
|
import { ServerlessResponse } from '../network';
|
|
5
5
|
import { DelegatedResolver } from './resolver.contract';
|
|
6
|
-
/**
|
|
7
|
-
* The props of the method that verify if this handler should handle the event.
|
|
8
|
-
*/
|
|
9
|
-
export interface CanHandleProps<TEvent, TContext> {
|
|
10
|
-
/**
|
|
11
|
-
* The event sent by the serverless
|
|
12
|
-
*/
|
|
13
|
-
event: TEvent | unknown;
|
|
14
|
-
/**
|
|
15
|
-
* The context sent by the serverless
|
|
16
|
-
*/
|
|
17
|
-
context: TContext | unknown;
|
|
18
|
-
/**
|
|
19
|
-
* The instance of the logger.
|
|
20
|
-
*/
|
|
21
|
-
log: ILogger;
|
|
22
|
-
}
|
|
23
6
|
/**
|
|
24
7
|
* The request interface used to bridge any event source to the framework.
|
|
8
|
+
*
|
|
9
|
+
* @breadcrumb Contracts / AdapterContract
|
|
10
|
+
* @public
|
|
25
11
|
*/
|
|
26
12
|
export interface AdapterRequest {
|
|
27
13
|
/**
|
|
@@ -39,22 +25,29 @@ export interface AdapterRequest {
|
|
|
39
25
|
/**
|
|
40
26
|
* The body as buffer to use to create the request to the framework
|
|
41
27
|
*/
|
|
42
|
-
body
|
|
28
|
+
body?: Buffer;
|
|
43
29
|
/**
|
|
44
30
|
* The remote address (client ip) to use to create the request to the framework
|
|
45
31
|
*/
|
|
46
32
|
remoteAddress?: string;
|
|
47
33
|
/**
|
|
48
|
-
* The address of the event source (used in Lambda
|
|
34
|
+
* The address of the event source (used in Lambda\@edge)
|
|
35
|
+
*
|
|
36
|
+
* @deprecated It is no longer used in the library and will be removed in the next major release.
|
|
49
37
|
*/
|
|
50
38
|
host?: string;
|
|
51
39
|
/**
|
|
52
|
-
* The address of the event source (used in Lambda
|
|
40
|
+
* The address of the event source (used in Lambda\@edge)
|
|
41
|
+
*
|
|
42
|
+
* @deprecated It is no longer used in the library and will be removed in the next major release.
|
|
53
43
|
*/
|
|
54
44
|
hostname?: string;
|
|
55
45
|
}
|
|
56
46
|
/**
|
|
57
47
|
* The props of the method that get the response from the framework and transform it into a format that the event source can handle
|
|
48
|
+
*
|
|
49
|
+
* @breadcrumb Contracts / AdapterContract
|
|
50
|
+
* @public
|
|
58
51
|
*/
|
|
59
52
|
export interface GetResponseAdapterProps<TEvent> {
|
|
60
53
|
/**
|
|
@@ -62,9 +55,9 @@ export interface GetResponseAdapterProps<TEvent> {
|
|
|
62
55
|
*/
|
|
63
56
|
event: TEvent;
|
|
64
57
|
/**
|
|
65
|
-
* The framework {@link ServerlessResponse response}.
|
|
58
|
+
* The framework {@link ServerlessResponse | response}.
|
|
66
59
|
*
|
|
67
|
-
* @
|
|
60
|
+
* @remarks It can be optional, as this method can be used when an error occurs during the handling of the request by the framework.
|
|
68
61
|
*/
|
|
69
62
|
response?: ServerlessResponse;
|
|
70
63
|
/**
|
|
@@ -90,6 +83,9 @@ export interface GetResponseAdapterProps<TEvent> {
|
|
|
90
83
|
}
|
|
91
84
|
/**
|
|
92
85
|
* The props of the method that handle the response when an error occurs while forwarding the request to the framework
|
|
86
|
+
*
|
|
87
|
+
* @breadcrumb Contracts / AdapterContract
|
|
88
|
+
* @public
|
|
93
89
|
*/
|
|
94
90
|
export interface OnErrorProps<TEvent, TResponse> {
|
|
95
91
|
/**
|
|
@@ -115,6 +111,9 @@ export interface OnErrorProps<TEvent, TResponse> {
|
|
|
115
111
|
}
|
|
116
112
|
/**
|
|
117
113
|
* The interface that represents a contract between the adapter and the actual implementation of the adapter.
|
|
114
|
+
*
|
|
115
|
+
* @breadcrumb Contracts / AdapterContract
|
|
116
|
+
* @public
|
|
118
117
|
*/
|
|
119
118
|
export interface AdapterContract<TEvent, TContext, TResponse> {
|
|
120
119
|
/**
|
|
@@ -124,29 +123,30 @@ export interface AdapterContract<TEvent, TContext, TResponse> {
|
|
|
124
123
|
/**
|
|
125
124
|
* Decide if this adapter can handle a request based in the event payload
|
|
126
125
|
*
|
|
127
|
-
* @param event The event sent by serverless
|
|
128
|
-
* @param context The context sent by the serverless
|
|
129
|
-
* @param log The instance of logger
|
|
126
|
+
* @param event - The event sent by serverless
|
|
127
|
+
* @param context - The context sent by the serverless
|
|
128
|
+
* @param log - The instance of logger
|
|
130
129
|
*/
|
|
131
130
|
canHandle(event: unknown, context: TContext, log: ILogger): boolean;
|
|
132
131
|
/**
|
|
133
132
|
* Maps the serverless payload to an actual request that a framework can handle
|
|
134
133
|
*
|
|
135
|
-
* @param event The event sent by serverless
|
|
136
|
-
* @param context The context sent by the serverless
|
|
137
|
-
* @param log The instance of logger
|
|
134
|
+
* @param event - The event sent by serverless
|
|
135
|
+
* @param context - The context sent by the serverless
|
|
136
|
+
* @param log - The instance of logger
|
|
138
137
|
*/
|
|
139
138
|
getRequest(event: TEvent, context: TContext, log: ILogger): AdapterRequest;
|
|
140
139
|
/**
|
|
141
140
|
* Maps the response of the framework to a payload that serverless can handle
|
|
142
141
|
*
|
|
143
|
-
* @param props The props sent by serverless
|
|
142
|
+
* @param props - The props sent by serverless
|
|
144
143
|
*/
|
|
145
144
|
getResponse(props: GetResponseAdapterProps<TEvent>): TResponse;
|
|
146
145
|
/**
|
|
147
146
|
* When an error occurs while forwarding the request to the framework
|
|
148
147
|
*
|
|
149
|
-
* @
|
|
148
|
+
* @remarks You must call resolver.fail or resolver.succeed when implementing this method.
|
|
150
149
|
*/
|
|
151
150
|
onErrorWhileForwarding(props: OnErrorProps<TEvent, TResponse>): void;
|
|
152
151
|
}
|
|
152
|
+
//# sourceMappingURL=adapter.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.contract.d.ts","sourceRoot":"","sources":["../../src/contracts/adapter.contract.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,kBAAkB,CAAC;IAE5B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,WAAW,uBAAuB,CAAC,MAAM;IAC7C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;IAE9B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,gBAAgB,CAAC;IAE1B;;OAEG;IACH,eAAe,EAAE,OAAO,CAAC;IAEzB;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY,CAAC,MAAM,EAAE,SAAS;IAC7C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;IAEb;;OAEG;IACH,iBAAiB,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAEhD;;OAEG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS;IAC1D;;OAEG;IACH,cAAc,IAAI,MAAM,CAAC;IAEzB;;;;;;OAMG;IACH,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC;IAEpE;;;;;;OAMG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,OAAO,GAAG,cAAc,CAAC;IAE3E;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,uBAAuB,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAE/D;;;;OAIG;IACH,sBAAsB,CAAC,KAAK,EAAE,YAAY,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;CACtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.contract.js","sourceRoot":"","sources":["../../src/contracts/adapter.contract.ts"],"names":[],"mappings":";AAAA,iBAAiB"}
|
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
/**
|
|
4
4
|
* The interface that represents a contract between the framework and the framework implementation
|
|
5
|
+
*
|
|
6
|
+
* @breadcrumb Contracts
|
|
7
|
+
* @public
|
|
5
8
|
*/
|
|
6
9
|
export interface FrameworkContract<TApp> {
|
|
7
10
|
/**
|
|
8
11
|
* Send the request and response objects to the framework
|
|
9
12
|
*
|
|
10
|
-
* @param app
|
|
11
|
-
* @param request
|
|
12
|
-
* @param response
|
|
13
|
+
* @param app - The instance of your app (Express, Fastify, Koa, etc...)
|
|
14
|
+
* @param request - The request object that will be forward to your app
|
|
15
|
+
* @param response - The response object that will be forward to your app to output the response
|
|
13
16
|
*/
|
|
14
17
|
sendRequest(app: TApp, request: IncomingMessage, response: ServerResponse): void;
|
|
15
18
|
}
|
|
19
|
+
//# sourceMappingURL=framework.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework.contract.d.ts","sourceRoot":"","sources":["../../src/contracts/framework.contract.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAIvD;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB,CAAC,IAAI;IACrC;;;;;;OAMG;IACH,WAAW,CACT,GAAG,EAAE,IAAI,EACT,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,cAAc,GACvB,IAAI,CAAC;CACT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"framework.contract.js","sourceRoot":"","sources":["../../src/contracts/framework.contract.ts"],"names":[],"mappings":";AAAA,iBAAiB"}
|
|
@@ -5,10 +5,16 @@ import { FrameworkContract } from './framework.contract';
|
|
|
5
5
|
import { ResolverContract } from './resolver.contract';
|
|
6
6
|
/**
|
|
7
7
|
* The function used to handle serverless requests
|
|
8
|
+
*
|
|
9
|
+
* @breadcrumb Contracts / HandlerContract
|
|
10
|
+
* @public
|
|
8
11
|
*/
|
|
9
12
|
export declare type ServerlessHandler<TReturn> = (...args: any[]) => TReturn;
|
|
10
13
|
/**
|
|
11
14
|
* The interface that represents the contract between the handler and the real implementation
|
|
15
|
+
*
|
|
16
|
+
* @breadcrumb Contracts / HandlerContract
|
|
17
|
+
* @public
|
|
12
18
|
*/
|
|
13
19
|
export interface HandlerContract<TApp, TEvent, TContext, TCallback, TResponse, TReturn> {
|
|
14
20
|
/**
|
|
@@ -16,3 +22,4 @@ export interface HandlerContract<TApp, TEvent, TContext, TCallback, TResponse, T
|
|
|
16
22
|
*/
|
|
17
23
|
getHandler(app: TApp, framework: FrameworkContract<TApp>, adapters: AdapterContract<TEvent, TContext, TResponse>[], resolverFactory: ResolverContract<TEvent, TContext, TCallback, TResponse, TReturn>, binarySettings: BinarySettings, respondWithErrors: boolean, log: ILogger): ServerlessHandler<TReturn>;
|
|
18
24
|
}
|
|
25
|
+
//# sourceMappingURL=handler.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.contract.d.ts","sourceRoot":"","sources":["../../src/contracts/handler.contract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAIvD;;;;;GAKG;AACH,oBAAY,iBAAiB,CAAC,OAAO,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC;AAErE;;;;;GAKG;AACH,MAAM,WAAW,eAAe,CAC9B,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO;IAEP;;OAEG;IACH,UAAU,CACR,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAClC,QAAQ,EAAE,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,EACxD,eAAe,EAAE,gBAAgB,CAC/B,MAAM,EACN,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,CACR,EACD,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,OAAO,EAC1B,GAAG,EAAE,OAAO,GACX,iBAAiB,CAAC,OAAO,CAAC,CAAC;CAC/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler.contract.js","sourceRoot":"","sources":["../../src/contracts/handler.contract.ts"],"names":[],"mappings":";AAAA,iBAAiB"}
|
package/lib/contracts/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC"}
|
package/lib/contracts/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];
|
|
@@ -14,3 +18,4 @@ __exportStar(require("./adapter.contract"), exports);
|
|
|
14
18
|
__exportStar(require("./framework.contract"), exports);
|
|
15
19
|
__exportStar(require("./handler.contract"), exports);
|
|
16
20
|
__exportStar(require("./resolver.contract"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,uDAAqC;AACrC,qDAAmC;AACnC,sDAAoC"}
|
|
@@ -2,34 +2,43 @@ import { ILogger } from '../core';
|
|
|
2
2
|
import { AdapterContract } from './adapter.contract';
|
|
3
3
|
/**
|
|
4
4
|
* The type that represents a resolver used to send the response, error or success, to the client
|
|
5
|
+
*
|
|
6
|
+
* @breadcrumb Contracts / ResolverContract
|
|
7
|
+
* @public
|
|
5
8
|
*/
|
|
6
9
|
export declare type Resolver<TResponse, TReturn> = {
|
|
7
10
|
/**
|
|
8
11
|
* The method that will perform the task of forwarding the request to the framework and waiting for the promise to be resolved with the response
|
|
9
12
|
*
|
|
10
|
-
* @param task The task to be executed
|
|
13
|
+
* @param task - The task to be executed
|
|
11
14
|
*/
|
|
12
15
|
run(task: () => Promise<TResponse>): TReturn;
|
|
13
16
|
};
|
|
14
17
|
/**
|
|
15
18
|
* The type that represents a delegate resolver that is passed to the adapter to handle what to do when an error occurs during forwarding.
|
|
19
|
+
*
|
|
20
|
+
* @breadcrumb Contracts / ResolverContract
|
|
21
|
+
* @public
|
|
16
22
|
*/
|
|
17
23
|
export declare type DelegatedResolver<TResponse> = {
|
|
18
24
|
/**
|
|
19
25
|
* Send the success response to the client
|
|
20
26
|
*
|
|
21
|
-
* @param success The serverless response
|
|
27
|
+
* @param success - The serverless response
|
|
22
28
|
*/
|
|
23
29
|
succeed: (response: TResponse) => void;
|
|
24
30
|
/**
|
|
25
31
|
* Send the error response to the client
|
|
26
32
|
*
|
|
27
|
-
* @param error The error object
|
|
33
|
+
* @param error - The error object
|
|
28
34
|
*/
|
|
29
35
|
fail: (error: Error) => void;
|
|
30
36
|
};
|
|
31
37
|
/**
|
|
32
38
|
* The createResolver contract props
|
|
39
|
+
*
|
|
40
|
+
* @breadcrumb Contracts / ResolverContract
|
|
41
|
+
* @public
|
|
33
42
|
*/
|
|
34
43
|
export declare type ResolverProps<TEvent, TContext, TCallback, TResponse> = {
|
|
35
44
|
/**
|
|
@@ -59,12 +68,16 @@ export declare type ResolverProps<TEvent, TContext, TCallback, TResponse> = {
|
|
|
59
68
|
};
|
|
60
69
|
/**
|
|
61
70
|
* The interface that represents the contract used to send the response to the client
|
|
71
|
+
*
|
|
72
|
+
* @breadcrumb Contracts / ResolverContract
|
|
73
|
+
* @public
|
|
62
74
|
*/
|
|
63
75
|
export interface ResolverContract<TEvent, TContext, TCallback, TResponse, TReturn> {
|
|
64
76
|
/**
|
|
65
77
|
* Create the resolver based on the context, callback or promise
|
|
66
78
|
*
|
|
67
|
-
* @param props The props used to create the resolver
|
|
79
|
+
* @param props - The props used to create the resolver
|
|
68
80
|
*/
|
|
69
81
|
createResolver(props: ResolverProps<TEvent, TContext, TCallback, TResponse>): Resolver<TResponse, TReturn>;
|
|
70
82
|
}
|
|
83
|
+
//# sourceMappingURL=resolver.contract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.contract.d.ts","sourceRoot":"","sources":["../../src/contracts/resolver.contract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAIrD;;;;;GAKG;AACH,oBAAY,QAAQ,CAAC,SAAS,EAAE,OAAO,IAAI;IACzC;;;;OAIG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC;CAC9C,CAAC;AAEF;;;;;GAKG;AACH,oBAAY,iBAAiB,CAAC,SAAS,IAAI;IACzC;;;;OAIG;IACH,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI,CAAC;IAEvC;;;;OAIG;IACH,IAAI,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,oBAAY,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,IAAI;IAClE;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,iBAAiB,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,GAAG,EAAE,OAAO,CAAC;IAEb;;OAEG;IACH,OAAO,EAAE,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAEtD;;OAEG;IACH,OAAO,CAAC,EAAE,QAAQ,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAC/B,MAAM,EACN,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO;IAEP;;;;OAIG;IACH,cAAc,CACZ,KAAK,EAAE,aAAa,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,GAC3D,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.contract.js","sourceRoot":"","sources":["../../src/contracts/resolver.contract.ts"],"names":[],"mappings":";AAAA,iBAAiB"}
|
|
@@ -4,6 +4,9 @@ import { ServerlessRequest, ServerlessResponse } from '../network';
|
|
|
4
4
|
import { ILogger } from './index';
|
|
5
5
|
/**
|
|
6
6
|
* The abstract class that represents the base class for a handler
|
|
7
|
+
*
|
|
8
|
+
* @breadcrumb Core
|
|
9
|
+
* @public
|
|
7
10
|
*/
|
|
8
11
|
export declare abstract class BaseHandler<TApp, TEvent, TContext, TCallback, TResponse, TReturn> implements HandlerContract<TApp, TEvent, TContext, TCallback, TResponse, TReturn> {
|
|
9
12
|
/**
|
|
@@ -13,16 +16,17 @@ export declare abstract class BaseHandler<TApp, TEvent, TContext, TCallback, TRe
|
|
|
13
16
|
/**
|
|
14
17
|
* Get the adapter to handle a specific event and context
|
|
15
18
|
*
|
|
16
|
-
* @param event The event sent by serverless
|
|
17
|
-
* @param context The context sent by serverless
|
|
18
|
-
* @param adapters The list of adapters
|
|
19
|
-
* @param log The instance of logger
|
|
19
|
+
* @param event - The event sent by serverless
|
|
20
|
+
* @param context - The context sent by serverless
|
|
21
|
+
* @param adapters - The list of adapters
|
|
22
|
+
* @param log - The instance of logger
|
|
20
23
|
*/
|
|
21
24
|
protected getAdapterByEventAndContext(event: TEvent, context: TContext, adapters: AdapterContract<TEvent, TContext, TResponse>[], log: ILogger): AdapterContract<TEvent, TContext, TResponse>;
|
|
22
25
|
/**
|
|
23
26
|
* Get serverless request and response frmo the adapter request
|
|
24
27
|
*
|
|
25
|
-
* @param requestValues The request values from adapter
|
|
28
|
+
* @param requestValues - The request values from adapter
|
|
26
29
|
*/
|
|
27
30
|
protected getServerlessRequestResponseFromAdapterRequest(requestValues: AdapterRequest): [request: ServerlessRequest, response: ServerlessResponse];
|
|
28
31
|
}
|
|
32
|
+
//# sourceMappingURL=base-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-handler.d.ts","sourceRoot":"","sources":["../../src/core/base-handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAIlC;;;;;GAKG;AACH,8BAAsB,WAAW,CAC/B,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,CACP,YACE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC;IAIxE;;OAEG;aACa,UAAU,CACxB,GAAG,EAAE,IAAI,EACT,SAAS,EAAE,iBAAiB,CAAC,IAAI,CAAC,EAClC,QAAQ,EAAE,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,EACxD,eAAe,EAAE,gBAAgB,CAC/B,MAAM,EACN,QAAQ,EACR,SAAS,EACT,SAAS,EACT,OAAO,CACR,EACD,cAAc,EAAE,cAAc,EAC9B,iBAAiB,EAAE,OAAO,EAC1B,GAAG,EAAE,OAAO,GACX,iBAAiB,CAAC,OAAO,CAAC;IAM7B;;;;;;;OAOG;IACH,SAAS,CAAC,2BAA2B,CACnC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,EACxD,GAAG,EAAE,OAAO,GACX,eAAe,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC;IAsB/C;;;;OAIG;IACH,SAAS,CAAC,8CAA8C,CACtD,aAAa,EAAE,cAAc,GAC5B,CAAC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,CAAC;CAiB9D"}
|
package/lib/core/base-handler.js
CHANGED
|
@@ -6,6 +6,9 @@ const network_1 = require("../network");
|
|
|
6
6
|
//#endregion
|
|
7
7
|
/**
|
|
8
8
|
* The abstract class that represents the base class for a handler
|
|
9
|
+
*
|
|
10
|
+
* @breadcrumb Core
|
|
11
|
+
* @public
|
|
9
12
|
*/
|
|
10
13
|
class BaseHandler {
|
|
11
14
|
//#endregion
|
|
@@ -13,10 +16,10 @@ class BaseHandler {
|
|
|
13
16
|
/**
|
|
14
17
|
* Get the adapter to handle a specific event and context
|
|
15
18
|
*
|
|
16
|
-
* @param event The event sent by serverless
|
|
17
|
-
* @param context The context sent by serverless
|
|
18
|
-
* @param adapters The list of adapters
|
|
19
|
-
* @param log The instance of logger
|
|
19
|
+
* @param event - The event sent by serverless
|
|
20
|
+
* @param context - The context sent by serverless
|
|
21
|
+
* @param adapters - The list of adapters
|
|
22
|
+
* @param log - The instance of logger
|
|
20
23
|
*/
|
|
21
24
|
getAdapterByEventAndContext(event, context, adapters, log) {
|
|
22
25
|
const resolvedAdapters = adapters.filter(adapter => adapter.canHandle(event, context, log));
|
|
@@ -33,7 +36,7 @@ class BaseHandler {
|
|
|
33
36
|
/**
|
|
34
37
|
* Get serverless request and response frmo the adapter request
|
|
35
38
|
*
|
|
36
|
-
* @param requestValues The request values from adapter
|
|
39
|
+
* @param requestValues - The request values from adapter
|
|
37
40
|
*/
|
|
38
41
|
getServerlessRequestResponseFromAdapterRequest(requestValues) {
|
|
39
42
|
const request = new network_1.ServerlessRequest({
|
|
@@ -50,3 +53,4 @@ class BaseHandler {
|
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
exports.BaseHandler = BaseHandler;
|
|
56
|
+
//# sourceMappingURL=base-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-handler.js","sourceRoot":"","sources":["../../src/core/base-handler.ts"],"names":[],"mappings":";AAAA,iBAAiB;;;AAWjB,wCAAmE;AAGnE,YAAY;AAEZ;;;;;GAKG;AACH,MAAsB,WAAW;IA+B/B,YAAY;IAEZ,2BAA2B;IAE3B;;;;;;;OAOG;IACO,2BAA2B,CACnC,KAAa,EACb,OAAiB,EACjB,QAAwD,EACxD,GAAY;QAEZ,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CACjD,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,CAAC,CACvC,CAAC;QAEF,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EAAE;YACjC,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;SACH;QAED,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;YAC/B,MAAM,IAAI,KAAK,CACb,yFAAyF,QAAQ;iBAC9F,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,cAAc,EAAE,CAAC;iBACxC,IAAI,CAAC,IAAI,CAAC,GAAG,CACjB,CAAC;SACH;QAED,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACO,8CAA8C,CACtD,aAA6B;QAE7B,MAAM,OAAO,GAAG,IAAI,2BAAiB,CAAC;YACpC,MAAM,EAAE,aAAa,CAAC,MAAM;YAC5B,OAAO,EAAE,aAAa,CAAC,OAAO;YAC9B,IAAI,EAAE,aAAa,CAAC,IAAI;YACxB,aAAa,EAAE,aAAa,CAAC,aAAa;YAC1C,GAAG,EAAE,aAAa,CAAC,IAAI;SACxB,CAAC,CAAC;QAEH,MAAM,QAAQ,GAAG,IAAI,4BAAkB,CAAC;YACtC,MAAM,EAAE,aAAa,CAAC,MAAM;SAC7B,CAAC,CAAC;QAEH,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7B,CAAC;CAGF;AA9FD,kCA8FC"}
|