@webiny/handler-aws 6.0.0-alpha.5 → 6.0.0-rc.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 +10 -14
- package/createHandler.d.ts +1 -1
- package/createHandler.js +12 -12
- package/createHandler.js.map +1 -1
- package/dynamodb/index.d.ts +3 -3
- package/dynamodb/index.js +14 -36
- package/dynamodb/index.js.map +1 -1
- package/dynamodb/plugins/DynamoDBEventHandler.d.ts +4 -4
- package/dynamodb/plugins/DynamoDBEventHandler.js +3 -11
- package/dynamodb/plugins/DynamoDBEventHandler.js.map +1 -1
- package/dynamodb/register.js +6 -8
- package/dynamodb/register.js.map +1 -1
- package/eventBridge/index.d.ts +3 -3
- package/eventBridge/index.js +14 -36
- package/eventBridge/index.js.map +1 -1
- package/eventBridge/plugins/EventBridgeEventHandler.d.ts +4 -4
- package/eventBridge/plugins/EventBridgeEventHandler.js +3 -11
- package/eventBridge/plugins/EventBridgeEventHandler.js.map +1 -1
- package/eventBridge/register.d.ts +1 -1
- package/eventBridge/register.js +6 -8
- package/eventBridge/register.js.map +1 -1
- package/execute.d.ts +1 -1
- package/execute.js +3 -10
- package/execute.js.map +1 -1
- package/gateway/index.d.ts +2 -2
- package/gateway/index.js +16 -30
- package/gateway/index.js.map +1 -1
- package/gateway/register.js +6 -8
- package/gateway/register.js.map +1 -1
- package/index.d.ts +17 -17
- package/index.js +45 -371
- package/index.js.map +1 -1
- package/package.json +15 -16
- package/plugins/handlerClient.js +6 -13
- package/plugins/handlerClient.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +3 -10
- package/plugins/index.js.map +1 -1
- package/raw/index.d.ts +3 -3
- package/raw/index.js +14 -33
- package/raw/index.js.map +1 -1
- package/raw/plugins/RawEventHandler.d.ts +3 -3
- package/raw/plugins/RawEventHandler.js +3 -11
- package/raw/plugins/RawEventHandler.js.map +1 -1
- package/registry.d.ts +2 -2
- package/registry.js +1 -7
- package/registry.js.map +1 -1
- package/s3/index.d.ts +3 -3
- package/s3/index.js +14 -36
- package/s3/index.js.map +1 -1
- package/s3/plugins/S3EventHandler.d.ts +4 -4
- package/s3/plugins/S3EventHandler.js +3 -11
- package/s3/plugins/S3EventHandler.js.map +1 -1
- package/s3/register.d.ts +1 -1
- package/s3/register.js +6 -8
- package/s3/register.js.map +1 -1
- package/sns/index.d.ts +3 -3
- package/sns/index.js +14 -36
- package/sns/index.js.map +1 -1
- package/sns/plugins/SNSEventHandler.d.ts +4 -4
- package/sns/plugins/SNSEventHandler.js +3 -11
- package/sns/plugins/SNSEventHandler.js.map +1 -1
- package/sns/register.js +6 -8
- package/sns/register.js.map +1 -1
- package/sourceHandler.d.ts +2 -2
- package/sourceHandler.js +1 -8
- package/sourceHandler.js.map +1 -1
- package/sqs/index.d.ts +3 -3
- package/sqs/index.js +14 -36
- package/sqs/index.js.map +1 -1
- package/sqs/plugins/SQSEventHandler.d.ts +4 -4
- package/sqs/plugins/SQSEventHandler.js +3 -11
- package/sqs/plugins/SQSEventHandler.js.map +1 -1
- package/sqs/register.js +6 -8
- package/sqs/register.js.map +1 -1
- package/types.d.ts +3 -3
- package/types.js +3 -31
- package/types.js.map +1 -1
- package/utils/composedHandler.d.ts +1 -1
- package/utils/composedHandler.js +3 -10
- package/utils/composedHandler.js.map +1 -1
- package/utils/index.d.ts +2 -2
- package/utils/index.js +2 -27
- package/utils/index.js.map +1 -1
- package/utils/timer/CustomTimer.js +1 -8
- package/utils/timer/CustomTimer.js.map +1 -1
- package/utils/timer/Timer.d.ts +1 -1
- package/utils/timer/Timer.js +1 -8
- package/utils/timer/Timer.js.map +1 -1
- package/utils/timer/abstractions/ITimer.js +1 -5
- package/utils/timer/factory.d.ts +2 -2
- package/utils/timer/factory.js +5 -12
- package/utils/timer/factory.js.map +1 -1
- package/utils/timer/index.d.ts +4 -4
- package/utils/timer/index.js +3 -49
- package/utils/timer/index.js.map +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
# @webiny/handler-aws
|
|
2
|
-
|
|
3
|
-
[!
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Or if you prefer yarn:
|
|
13
|
-
```
|
|
14
|
-
yarn add @webiny/handler-aws
|
|
15
|
-
```
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> It’s **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
📘 **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/createHandler.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { HandlerFactory } from "./types";
|
|
1
|
+
import type { HandlerFactory } from "./types.js";
|
|
2
2
|
export declare const createHandler: HandlerFactory;
|
package/createHandler.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { AsyncPluginsContainer } from "@webiny/plugins";
|
|
2
|
+
import { registry } from "./registry.js";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const createHandler = ({
|
|
4
|
+
// TODO: Once we have a better infrastructure for handling such cases, we should refactor this.
|
|
5
|
+
// Ideally, the DI container should already be ready to be used in these `handler` packages.
|
|
6
|
+
// At the moment, that is not the case, so we have to hardcode `pino-lambda` here.
|
|
7
|
+
import { lambdaRequestTracker } from "pino-lambda";
|
|
8
|
+
const withRequest = lambdaRequestTracker();
|
|
9
|
+
export const createHandler = ({
|
|
10
10
|
plugins,
|
|
11
11
|
...params
|
|
12
12
|
}) => {
|
|
13
|
-
const pluginsContainer = new
|
|
14
|
-
return async (event, context) => {
|
|
13
|
+
const pluginsContainer = new AsyncPluginsContainer(plugins);
|
|
14
|
+
return async (event, context = {}) => {
|
|
15
|
+
withRequest(event, context);
|
|
15
16
|
const plugins = await pluginsContainer.init();
|
|
16
|
-
const handler =
|
|
17
|
+
const handler = registry.getHandler(event, context);
|
|
17
18
|
return handler.handle({
|
|
18
19
|
params: {
|
|
19
20
|
...params,
|
|
@@ -24,6 +25,5 @@ const createHandler = ({
|
|
|
24
25
|
});
|
|
25
26
|
};
|
|
26
27
|
};
|
|
27
|
-
exports.createHandler = createHandler;
|
|
28
28
|
|
|
29
29
|
//# sourceMappingURL=createHandler.js.map
|
package/createHandler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["AsyncPluginsContainer","registry","lambdaRequestTracker","withRequest","createHandler","plugins","params","pluginsContainer","event","context","init","handler","getHandler","handle"],"sources":["createHandler.ts"],"sourcesContent":["import { AsyncPluginsContainer } from \"@webiny/plugins\";\nimport type { HandlerFactory, LambdaContext } from \"~/types.js\";\nimport { registry } from \"./registry.js\";\n\n// TODO: Once we have a better infrastructure for handling such cases, we should refactor this.\n// Ideally, the DI container should already be ready to be used in these `handler` packages.\n// At the moment, that is not the case, so we have to hardcode `pino-lambda` here.\nimport { lambdaRequestTracker } from \"pino-lambda\";\n\nconst withRequest = lambdaRequestTracker();\n\nexport const createHandler: HandlerFactory = ({ plugins, ...params }) => {\n const pluginsContainer = new AsyncPluginsContainer(plugins);\n\n return async (event, context = {} as LambdaContext) => {\n withRequest(event, context);\n\n const plugins = await pluginsContainer.init();\n const handler = registry.getHandler(event, context);\n return handler.handle({\n params: {\n ...params,\n plugins\n },\n event,\n context\n });\n };\n};\n"],"mappings":"AAAA,SAASA,qBAAqB,QAAQ,iBAAiB;AAEvD,SAASC,QAAQ;;AAEjB;AACA;AACA;AACA,SAASC,oBAAoB,QAAQ,aAAa;AAElD,MAAMC,WAAW,GAAGD,oBAAoB,CAAC,CAAC;AAE1C,OAAO,MAAME,aAA6B,GAAGA,CAAC;EAAEC,OAAO;EAAE,GAAGC;AAAO,CAAC,KAAK;EACrE,MAAMC,gBAAgB,GAAG,IAAIP,qBAAqB,CAACK,OAAO,CAAC;EAE3D,OAAO,OAAOG,KAAK,EAAEC,OAAO,GAAG,CAAC,CAAkB,KAAK;IACnDN,WAAW,CAACK,KAAK,EAAEC,OAAO,CAAC;IAE3B,MAAMJ,OAAO,GAAG,MAAME,gBAAgB,CAACG,IAAI,CAAC,CAAC;IAC7C,MAAMC,OAAO,GAAGV,QAAQ,CAACW,UAAU,CAACJ,KAAK,EAAEC,OAAO,CAAC;IACnD,OAAOE,OAAO,CAACE,MAAM,CAAC;MAClBP,MAAM,EAAE;QACJ,GAAGA,MAAM;QACTD;MACJ,CAAC;MACDG,KAAK;MACLC;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC","ignoreList":[]}
|
package/dynamodb/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { APIGatewayProxyResult, Context as LambdaContext, DynamoDBStreamEvent } from "@webiny/aws-sdk/types";
|
|
2
|
-
import type { HandlerFactoryParams } from "../types";
|
|
3
|
-
export * from "./plugins/DynamoDBEventHandler";
|
|
1
|
+
import type { APIGatewayProxyResult, Context as LambdaContext, DynamoDBStreamEvent } from "@webiny/aws-sdk/types/index.js";
|
|
2
|
+
import type { HandlerFactoryParams } from "../types.js";
|
|
3
|
+
export * from "./plugins/DynamoDBEventHandler.js";
|
|
4
4
|
export type HandlerParams = HandlerFactoryParams;
|
|
5
5
|
export interface HandlerCallable {
|
|
6
6
|
(event: DynamoDBStreamEvent, context: LambdaContext): Promise<APIGatewayProxyResult>;
|
package/dynamodb/index.js
CHANGED
|
@@ -1,39 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
createHandler: true
|
|
9
|
-
};
|
|
10
|
-
exports.createHandler = void 0;
|
|
11
|
-
var _handler = require("@webiny/handler");
|
|
12
|
-
var _plugins = require("../plugins");
|
|
13
|
-
var _DynamoDBEventHandler = require("./plugins/DynamoDBEventHandler");
|
|
14
|
-
Object.keys(_DynamoDBEventHandler).forEach(function (key) {
|
|
15
|
-
if (key === "default" || key === "__esModule") return;
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
17
|
-
if (key in exports && exports[key] === _DynamoDBEventHandler[key]) return;
|
|
18
|
-
Object.defineProperty(exports, key, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _DynamoDBEventHandler[key];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
var _reply = _interopRequireDefault(require("fastify/lib/reply"));
|
|
26
|
-
var _execute = require("../execute");
|
|
27
|
-
var _composedHandler = require("../utils/composedHandler");
|
|
1
|
+
import { createHandler as createBaseHandler } from "@webiny/handler";
|
|
2
|
+
import { registerDefaultPlugins } from "../plugins/index.js";
|
|
3
|
+
import { DynamoDBEventHandler } from "./plugins/DynamoDBEventHandler.js";
|
|
28
4
|
/**
|
|
29
5
|
* We need a class, not an interface exported from types.
|
|
30
6
|
*/
|
|
31
7
|
// @ts-expect-error
|
|
32
|
-
|
|
8
|
+
import Reply from "fastify/lib/reply.js";
|
|
9
|
+
import { execute } from "../execute.js";
|
|
10
|
+
import { createComposedHandler } from "../utils/composedHandler.js";
|
|
11
|
+
export * from "./plugins/DynamoDBEventHandler.js";
|
|
33
12
|
const url = "/webiny-dynamodb-event";
|
|
34
|
-
const createHandler = params => {
|
|
13
|
+
export const createHandler = params => {
|
|
35
14
|
return (payload, context) => {
|
|
36
|
-
const app = (
|
|
15
|
+
const app = createBaseHandler({
|
|
37
16
|
...params,
|
|
38
17
|
options: {
|
|
39
18
|
logger: params.debug === true,
|
|
@@ -43,15 +22,15 @@ const createHandler = params => {
|
|
|
43
22
|
/**
|
|
44
23
|
* We always must add our default plugins to the app.
|
|
45
24
|
*/
|
|
46
|
-
|
|
25
|
+
registerDefaultPlugins(app.webiny);
|
|
47
26
|
/**
|
|
48
27
|
* There must be an event plugin for this handler to work.
|
|
49
28
|
*/
|
|
50
|
-
const plugins = app.webiny.plugins.byType(
|
|
29
|
+
const plugins = app.webiny.plugins.byType(DynamoDBEventHandler.type).reverse();
|
|
51
30
|
if (plugins.length === 0) {
|
|
52
31
|
throw new Error(`To run @webiny/handler-aws/dynamodb, you must have DynamoDBHandler set.`);
|
|
53
32
|
}
|
|
54
|
-
const handler =
|
|
33
|
+
const handler = createComposedHandler(plugins);
|
|
55
34
|
app.post(url, async (request, reply) => {
|
|
56
35
|
const params = {
|
|
57
36
|
request,
|
|
@@ -61,19 +40,18 @@ const createHandler = params => {
|
|
|
61
40
|
reply
|
|
62
41
|
};
|
|
63
42
|
const result = await handler(params);
|
|
64
|
-
if (result instanceof
|
|
43
|
+
if (result instanceof Reply) {
|
|
65
44
|
return result;
|
|
66
45
|
}
|
|
67
46
|
app.__webiny_raw_result = result;
|
|
68
47
|
return reply.send({});
|
|
69
48
|
});
|
|
70
|
-
return
|
|
49
|
+
return execute({
|
|
71
50
|
app,
|
|
72
51
|
url,
|
|
73
52
|
payload
|
|
74
53
|
});
|
|
75
54
|
};
|
|
76
55
|
};
|
|
77
|
-
exports.createHandler = createHandler;
|
|
78
56
|
|
|
79
57
|
//# sourceMappingURL=index.js.map
|
package/dynamodb/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createHandler","createBaseHandler","registerDefaultPlugins","DynamoDBEventHandler","Reply","execute","createComposedHandler","url","params","payload","context","app","options","logger","debug","webiny","plugins","byType","type","reverse","length","Error","handler","post","request","reply","event","lambdaContext","result","__webiny_raw_result","send"],"sources":["index.ts"],"sourcesContent":["import type {\n APIGatewayProxyResult,\n Context as LambdaContext,\n DynamoDBStreamEvent\n} from \"@webiny/aws-sdk/types/index.js\";\nimport type { HandlerFactoryParams } from \"~/types.js\";\nimport { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins/index.js\";\nimport type { DynamoDBEventHandlerCallableParams } from \"./plugins/DynamoDBEventHandler.js\";\nimport { DynamoDBEventHandler } from \"./plugins/DynamoDBEventHandler.js\";\n/**\n * We need a class, not an interface exported from types.\n */\n// @ts-expect-error\nimport Reply from \"fastify/lib/reply.js\";\nimport { execute } from \"~/execute.js\";\nimport { createComposedHandler } from \"~/utils/composedHandler.js\";\n\nexport * from \"./plugins/DynamoDBEventHandler.js\";\n\nconst url = \"/webiny-dynamodb-event\";\n\nexport type HandlerParams = HandlerFactoryParams;\n\nexport interface HandlerCallable {\n (event: DynamoDBStreamEvent, context: LambdaContext): Promise<APIGatewayProxyResult>;\n}\n\nexport const createHandler = (params: HandlerParams): HandlerCallable => {\n return (payload, context) => {\n const app = createBaseHandler({\n ...params,\n options: {\n logger: params.debug === true,\n ...(params.options || {})\n }\n });\n /**\n * We always must add our default plugins to the app.\n */\n registerDefaultPlugins(app.webiny);\n /**\n * There must be an event plugin for this handler to work.\n */\n const plugins = app.webiny.plugins\n .byType<DynamoDBEventHandler>(DynamoDBEventHandler.type)\n .reverse();\n if (plugins.length === 0) {\n throw new Error(\n `To run @webiny/handler-aws/dynamodb, you must have DynamoDBHandler set.`\n );\n }\n\n const handler = createComposedHandler<\n DynamoDBEventHandler,\n DynamoDBEventHandlerCallableParams<APIGatewayProxyResult>,\n APIGatewayProxyResult\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<\n DynamoDBEventHandlerCallableParams<APIGatewayProxyResult>,\n \"next\"\n > = {\n request,\n context: app.webiny,\n event: payload,\n lambdaContext: context,\n reply\n };\n const result = await handler(\n params as unknown as DynamoDBEventHandlerCallableParams<APIGatewayProxyResult>\n );\n\n if (result instanceof Reply) {\n return result;\n }\n\n app.__webiny_raw_result = result;\n return reply.send({});\n });\n return execute({\n app,\n url,\n payload\n });\n };\n};\n"],"mappings":"AAMA,SAASA,aAAa,IAAIC,iBAAiB,QAAQ,iBAAiB;AACpE,SAASC,sBAAsB;AAE/B,SAASC,oBAAoB;AAC7B;AACA;AACA;AACA;AACA,OAAOC,KAAK,MAAM,sBAAsB;AACxC,SAASC,OAAO;AAChB,SAASC,qBAAqB;AAE9B;AAEA,MAAMC,GAAG,GAAG,wBAAwB;AAQpC,OAAO,MAAMP,aAAa,GAAIQ,MAAqB,IAAsB;EACrE,OAAO,CAACC,OAAO,EAAEC,OAAO,KAAK;IACzB,MAAMC,GAAG,GAAGV,iBAAiB,CAAC;MAC1B,GAAGO,MAAM;MACTI,OAAO,EAAE;QACLC,MAAM,EAAEL,MAAM,CAACM,KAAK,KAAK,IAAI;QAC7B,IAAIN,MAAM,CAACI,OAAO,IAAI,CAAC,CAAC;MAC5B;IACJ,CAAC,CAAC;IACF;AACR;AACA;IACQV,sBAAsB,CAACS,GAAG,CAACI,MAAM,CAAC;IAClC;AACR;AACA;IACQ,MAAMC,OAAO,GAAGL,GAAG,CAACI,MAAM,CAACC,OAAO,CAC7BC,MAAM,CAAuBd,oBAAoB,CAACe,IAAI,CAAC,CACvDC,OAAO,CAAC,CAAC;IACd,IAAIH,OAAO,CAACI,MAAM,KAAK,CAAC,EAAE;MACtB,MAAM,IAAIC,KAAK,CACX,yEACJ,CAAC;IACL;IAEA,MAAMC,OAAO,GAAGhB,qBAAqB,CAInCU,OAAO,CAAC;IAEVL,GAAG,CAACY,IAAI,CAAChB,GAAG,EAAE,OAAOiB,OAAO,EAAEC,KAAK,KAAK;MACpC,MAAMjB,MAGL,GAAG;QACAgB,OAAO;QACPd,OAAO,EAAEC,GAAG,CAACI,MAAM;QACnBW,KAAK,EAAEjB,OAAO;QACdkB,aAAa,EAAEjB,OAAO;QACtBe;MACJ,CAAC;MACD,MAAMG,MAAM,GAAG,MAAMN,OAAO,CACxBd,MACJ,CAAC;MAED,IAAIoB,MAAM,YAAYxB,KAAK,EAAE;QACzB,OAAOwB,MAAM;MACjB;MAEAjB,GAAG,CAACkB,mBAAmB,GAAGD,MAAM;MAChC,OAAOH,KAAK,CAACK,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAOzB,OAAO,CAAC;MACXM,GAAG;MACHJ,GAAG;MACHE;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import type { Context, Reply, Request } from "@webiny/handler/types";
|
|
3
|
-
import type { Context as LambdaContext, DynamoDBStreamEvent } from "@webiny/aws-sdk/types";
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
import type { Context, Reply, Request } from "@webiny/handler/types.js";
|
|
3
|
+
import type { Context as LambdaContext, DynamoDBStreamEvent } from "@webiny/aws-sdk/types/index.js";
|
|
4
4
|
export interface DynamoDBEventHandlerCallableParams<Response = Reply> {
|
|
5
5
|
request: Request;
|
|
6
6
|
context: Context;
|
|
@@ -17,4 +17,4 @@ export declare class DynamoDBEventHandler<Response = any> extends Plugin {
|
|
|
17
17
|
readonly cb: DynamoDBEventHandlerCallable<Response>;
|
|
18
18
|
constructor(cb: DynamoDBEventHandlerCallable<Response>);
|
|
19
19
|
}
|
|
20
|
-
export declare const createEventHandler: <
|
|
20
|
+
export declare const createEventHandler: <Response>(cb: DynamoDBEventHandlerCallable<Response>) => DynamoDBEventHandler<Response>;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createEventHandler = exports.DynamoDBEventHandler = void 0;
|
|
7
|
-
var _Plugin = require("@webiny/plugins/Plugin");
|
|
8
|
-
class DynamoDBEventHandler extends _Plugin.Plugin {
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
export class DynamoDBEventHandler extends Plugin {
|
|
9
3
|
static type = "handler.fastify.aws.dynamodb.eventHandler";
|
|
10
4
|
constructor(cb) {
|
|
11
5
|
super();
|
|
12
6
|
this.cb = cb;
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
const createEventHandler = cb => {
|
|
9
|
+
export const createEventHandler = cb => {
|
|
17
10
|
return new DynamoDBEventHandler(cb);
|
|
18
11
|
};
|
|
19
|
-
exports.createEventHandler = createEventHandler;
|
|
20
12
|
|
|
21
13
|
//# sourceMappingURL=DynamoDBEventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Plugin","DynamoDBEventHandler","type","constructor","cb","createEventHandler"],"sources":["DynamoDBEventHandler.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { Context, Reply, Request } from \"@webiny/handler/types.js\";\nimport type { Context as LambdaContext, DynamoDBStreamEvent } from \"@webiny/aws-sdk/types/index.js\";\n\nexport interface DynamoDBEventHandlerCallableParams<Response = Reply> {\n request: Request;\n context: Context;\n event: DynamoDBStreamEvent;\n lambdaContext: LambdaContext;\n reply: Reply;\n next: () => Promise<Response>;\n}\n\nexport interface DynamoDBEventHandlerCallable<Response = Reply> {\n (params: DynamoDBEventHandlerCallableParams<Response>): Promise<Response>;\n}\n\nexport class DynamoDBEventHandler<Response = any> extends Plugin {\n public static override type = \"handler.fastify.aws.dynamodb.eventHandler\";\n\n public readonly cb: DynamoDBEventHandlerCallable<Response>;\n\n public constructor(cb: DynamoDBEventHandlerCallable<Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEventHandler = <Response>(cb: DynamoDBEventHandlerCallable<Response>) => {\n return new DynamoDBEventHandler<Response>(cb);\n};\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,2BAA2B;AAiBlD,OAAO,MAAMC,oBAAoB,SAAyBD,MAAM,CAAC;EAC7D,OAAuBE,IAAI,GAAG,2CAA2C;EAIlEC,WAAWA,CAACC,EAA0C,EAAE;IAC3D,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAEA,OAAO,MAAMC,kBAAkB,GAAcD,EAA0C,IAAK;EACxF,OAAO,IAAIH,oBAAoB,CAAWG,EAAE,CAAC;AACjD,CAAC","ignoreList":[]}
|
package/dynamodb/register.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _index = require("./index");
|
|
6
|
-
const handler = (0, _sourceHandler.createSourceHandler)({
|
|
1
|
+
import { registry } from "../registry.js";
|
|
2
|
+
import { createSourceHandler } from "../sourceHandler.js";
|
|
3
|
+
import { createHandler } from "./index.js";
|
|
4
|
+
const handler = createSourceHandler({
|
|
7
5
|
name: "handler-aws-dynamodb-stream",
|
|
8
6
|
canUse: event => {
|
|
9
7
|
if (!Array.isArray(event.Records) || event.Records.length === 0) {
|
|
@@ -20,9 +18,9 @@ const handler = (0, _sourceHandler.createSourceHandler)({
|
|
|
20
18
|
event,
|
|
21
19
|
context
|
|
22
20
|
}) => {
|
|
23
|
-
return
|
|
21
|
+
return createHandler(params)(event, context);
|
|
24
22
|
}
|
|
25
23
|
});
|
|
26
|
-
|
|
24
|
+
registry.register(handler);
|
|
27
25
|
|
|
28
26
|
//# sourceMappingURL=register.js.map
|
package/dynamodb/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["registry","createSourceHandler","createHandler","handler","name","canUse","event","Array","isArray","Records","length","record","eventSource","toLowerCase","handle","params","context","register"],"sources":["register.ts"],"sourcesContent":["import { registry } from \"~/registry.js\";\nimport type { DynamoDBStreamEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport { createSourceHandler } from \"~/sourceHandler.js\";\nimport type { HandlerParams } from \"~/dynamodb/index.js\";\nimport { createHandler } from \"~/dynamodb/index.js\";\n\nconst handler = createSourceHandler<DynamoDBStreamEvent, HandlerParams>({\n name: \"handler-aws-dynamodb-stream\",\n canUse: event => {\n if (!Array.isArray(event.Records) || event.Records.length === 0) {\n return false;\n }\n const [record] = event.Records;\n if (typeof record.eventSource !== \"string\") {\n return false;\n }\n return record.eventSource.toLowerCase() === \"aws:dynamodb\";\n },\n handle: async ({ params, event, context }) => {\n return createHandler(params)(event, context);\n }\n});\n\nregistry.register(handler);\n"],"mappings":"AAAA,SAASA,QAAQ;AAEjB,SAASC,mBAAmB;AAE5B,SAASC,aAAa;AAEtB,MAAMC,OAAO,GAAGF,mBAAmB,CAAqC;EACpEG,IAAI,EAAE,6BAA6B;EACnCC,MAAM,EAAEC,KAAK,IAAI;IACb,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAACG,OAAO,CAAC,IAAIH,KAAK,CAACG,OAAO,CAACC,MAAM,KAAK,CAAC,EAAE;MAC7D,OAAO,KAAK;IAChB;IACA,MAAM,CAACC,MAAM,CAAC,GAAGL,KAAK,CAACG,OAAO;IAC9B,IAAI,OAAOE,MAAM,CAACC,WAAW,KAAK,QAAQ,EAAE;MACxC,OAAO,KAAK;IAChB;IACA,OAAOD,MAAM,CAACC,WAAW,CAACC,WAAW,CAAC,CAAC,KAAK,cAAc;EAC9D,CAAC;EACDC,MAAM,EAAE,MAAAA,CAAO;IAAEC,MAAM;IAAET,KAAK;IAAEU;EAAQ,CAAC,KAAK;IAC1C,OAAOd,aAAa,CAACa,MAAM,CAAC,CAACT,KAAK,EAAEU,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFhB,QAAQ,CAACiB,QAAQ,CAACd,OAAO,CAAC","ignoreList":[]}
|
package/eventBridge/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { HandlerFactoryParams } from "../types";
|
|
2
|
-
import type { APIGatewayProxyResult, Context as LambdaContext, EventBridgeEvent } from "@webiny/aws-sdk/types";
|
|
3
|
-
export * from "./plugins/EventBridgeEventHandler";
|
|
1
|
+
import type { HandlerFactoryParams } from "../types.js";
|
|
2
|
+
import type { APIGatewayProxyResult, Context as LambdaContext, EventBridgeEvent } from "@webiny/aws-sdk/types/index.js";
|
|
3
|
+
export * from "./plugins/EventBridgeEventHandler.js";
|
|
4
4
|
export type HandlerParams = HandlerFactoryParams;
|
|
5
5
|
export interface HandlerCallable {
|
|
6
6
|
(event: EventBridgeEvent<string, string>, context: LambdaContext): Promise<APIGatewayProxyResult>;
|
package/eventBridge/index.js
CHANGED
|
@@ -1,39 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
createHandler: true
|
|
9
|
-
};
|
|
10
|
-
exports.createHandler = void 0;
|
|
11
|
-
var _handler = require("@webiny/handler");
|
|
12
|
-
var _plugins = require("../plugins");
|
|
13
|
-
var _EventBridgeEventHandler = require("./plugins/EventBridgeEventHandler");
|
|
14
|
-
Object.keys(_EventBridgeEventHandler).forEach(function (key) {
|
|
15
|
-
if (key === "default" || key === "__esModule") return;
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
17
|
-
if (key in exports && exports[key] === _EventBridgeEventHandler[key]) return;
|
|
18
|
-
Object.defineProperty(exports, key, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _EventBridgeEventHandler[key];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
var _execute = require("../execute");
|
|
26
|
-
var _reply = _interopRequireDefault(require("fastify/lib/reply"));
|
|
27
|
-
var _composedHandler = require("../utils/composedHandler");
|
|
1
|
+
import { createHandler as createBaseHandler } from "@webiny/handler";
|
|
2
|
+
import { registerDefaultPlugins } from "../plugins/index.js";
|
|
3
|
+
import { EventBridgeEventHandler } from "./plugins/EventBridgeEventHandler.js";
|
|
4
|
+
import { execute } from "../execute.js";
|
|
28
5
|
/**
|
|
29
6
|
* We need a class, not an interface exported from types.
|
|
30
7
|
*/
|
|
31
8
|
// @ts-expect-error
|
|
32
|
-
|
|
9
|
+
import Reply from "fastify/lib/reply.js";
|
|
10
|
+
import { createComposedHandler } from "../utils/composedHandler.js";
|
|
11
|
+
export * from "./plugins/EventBridgeEventHandler.js";
|
|
33
12
|
const url = "/webiny-eventBridge-event";
|
|
34
|
-
const createHandler = params => {
|
|
13
|
+
export const createHandler = params => {
|
|
35
14
|
return (payload, context) => {
|
|
36
|
-
const app = (
|
|
15
|
+
const app = createBaseHandler({
|
|
37
16
|
...params,
|
|
38
17
|
options: {
|
|
39
18
|
logger: params.debug === true,
|
|
@@ -43,15 +22,15 @@ const createHandler = params => {
|
|
|
43
22
|
/**
|
|
44
23
|
* We always must add our default plugins to the app.
|
|
45
24
|
*/
|
|
46
|
-
|
|
25
|
+
registerDefaultPlugins(app.webiny);
|
|
47
26
|
/**
|
|
48
27
|
* There must be an event plugin for this handler to work.
|
|
49
28
|
*/
|
|
50
|
-
const plugins = app.webiny.plugins.byType(
|
|
29
|
+
const plugins = app.webiny.plugins.byType(EventBridgeEventHandler.type).reverse();
|
|
51
30
|
if (plugins.length === 0) {
|
|
52
31
|
throw new Error(`To run @webiny/handler-aws/eventBridge, you must have EventBridgeEventHandler set.`);
|
|
53
32
|
}
|
|
54
|
-
const handler =
|
|
33
|
+
const handler = createComposedHandler(plugins);
|
|
55
34
|
app.post(url, async (request, reply) => {
|
|
56
35
|
const params = {
|
|
57
36
|
request,
|
|
@@ -61,19 +40,18 @@ const createHandler = params => {
|
|
|
61
40
|
lambdaContext: context
|
|
62
41
|
};
|
|
63
42
|
const result = await handler(params);
|
|
64
|
-
if (result instanceof
|
|
43
|
+
if (result instanceof Reply) {
|
|
65
44
|
return result;
|
|
66
45
|
}
|
|
67
46
|
app.__webiny_raw_result = result;
|
|
68
47
|
return reply.send({});
|
|
69
48
|
});
|
|
70
|
-
return
|
|
49
|
+
return execute({
|
|
71
50
|
app,
|
|
72
51
|
url,
|
|
73
52
|
payload
|
|
74
53
|
});
|
|
75
54
|
};
|
|
76
55
|
};
|
|
77
|
-
exports.createHandler = createHandler;
|
|
78
56
|
|
|
79
57
|
//# sourceMappingURL=index.js.map
|
package/eventBridge/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createHandler","createBaseHandler","registerDefaultPlugins","EventBridgeEventHandler","execute","Reply","createComposedHandler","url","params","payload","context","app","options","logger","debug","webiny","plugins","byType","type","reverse","length","Error","handler","post","request","reply","lambdaContext","result","__webiny_raw_result","send"],"sources":["index.ts"],"sourcesContent":["import { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins/index.js\";\nimport type { EventBridgeEventHandlerCallableParams } from \"~/eventBridge/plugins/EventBridgeEventHandler.js\";\nimport { EventBridgeEventHandler } from \"~/eventBridge/plugins/EventBridgeEventHandler.js\";\nimport { execute } from \"~/execute.js\";\nimport type { HandlerFactoryParams } from \"~/types.js\";\nimport type {\n APIGatewayProxyResult,\n Context as LambdaContext,\n EventBridgeEvent\n} from \"@webiny/aws-sdk/types/index.js\";\n/**\n * We need a class, not an interface exported from types.\n */\n// @ts-expect-error\nimport Reply from \"fastify/lib/reply.js\";\nimport { createComposedHandler } from \"~/utils/composedHandler.js\";\n\nexport * from \"./plugins/EventBridgeEventHandler.js\";\n\nexport type HandlerParams = HandlerFactoryParams;\n\nexport interface HandlerCallable {\n (\n event: EventBridgeEvent<string, string>,\n context: LambdaContext\n ): Promise<APIGatewayProxyResult>;\n}\n\nconst url = \"/webiny-eventBridge-event\";\n\nexport const createHandler = (params: HandlerParams): HandlerCallable => {\n return (payload, context) => {\n const app = createBaseHandler({\n ...params,\n options: {\n logger: params.debug === true,\n ...(params.options || {})\n }\n });\n /**\n * We always must add our default plugins to the app.\n */\n registerDefaultPlugins(app.webiny);\n /**\n * There must be an event plugin for this handler to work.\n */\n const plugins = app.webiny.plugins\n .byType<EventBridgeEventHandler<string, string>>(EventBridgeEventHandler.type)\n .reverse();\n if (plugins.length === 0) {\n throw new Error(\n `To run @webiny/handler-aws/eventBridge, you must have EventBridgeEventHandler set.`\n );\n }\n\n const handler = createComposedHandler<\n EventBridgeEventHandler<string, string>,\n EventBridgeEventHandlerCallableParams<string, string, APIGatewayProxyResult>,\n APIGatewayProxyResult\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<\n EventBridgeEventHandlerCallableParams<string, string, APIGatewayProxyResult>,\n \"next\"\n > = {\n request,\n reply,\n context: app.webiny,\n payload,\n lambdaContext: context\n };\n const result = await handler(\n params as unknown as EventBridgeEventHandlerCallableParams<\n string,\n string,\n APIGatewayProxyResult\n >\n );\n\n if (result instanceof Reply) {\n return result;\n }\n\n app.__webiny_raw_result = result;\n return reply.send({});\n });\n return execute({\n app,\n url,\n payload\n });\n };\n};\n"],"mappings":"AAAA,SAASA,aAAa,IAAIC,iBAAiB,QAAQ,iBAAiB;AACpE,SAASC,sBAAsB;AAE/B,SAASC,uBAAuB;AAChC,SAASC,OAAO;AAOhB;AACA;AACA;AACA;AACA,OAAOC,KAAK,MAAM,sBAAsB;AACxC,SAASC,qBAAqB;AAE9B;AAWA,MAAMC,GAAG,GAAG,2BAA2B;AAEvC,OAAO,MAAMP,aAAa,GAAIQ,MAAqB,IAAsB;EACrE,OAAO,CAACC,OAAO,EAAEC,OAAO,KAAK;IACzB,MAAMC,GAAG,GAAGV,iBAAiB,CAAC;MAC1B,GAAGO,MAAM;MACTI,OAAO,EAAE;QACLC,MAAM,EAAEL,MAAM,CAACM,KAAK,KAAK,IAAI;QAC7B,IAAIN,MAAM,CAACI,OAAO,IAAI,CAAC,CAAC;MAC5B;IACJ,CAAC,CAAC;IACF;AACR;AACA;IACQV,sBAAsB,CAACS,GAAG,CAACI,MAAM,CAAC;IAClC;AACR;AACA;IACQ,MAAMC,OAAO,GAAGL,GAAG,CAACI,MAAM,CAACC,OAAO,CAC7BC,MAAM,CAA0Cd,uBAAuB,CAACe,IAAI,CAAC,CAC7EC,OAAO,CAAC,CAAC;IACd,IAAIH,OAAO,CAACI,MAAM,KAAK,CAAC,EAAE;MACtB,MAAM,IAAIC,KAAK,CACX,oFACJ,CAAC;IACL;IAEA,MAAMC,OAAO,GAAGhB,qBAAqB,CAInCU,OAAO,CAAC;IAEVL,GAAG,CAACY,IAAI,CAAChB,GAAG,EAAE,OAAOiB,OAAO,EAAEC,KAAK,KAAK;MACpC,MAAMjB,MAGL,GAAG;QACAgB,OAAO;QACPC,KAAK;QACLf,OAAO,EAAEC,GAAG,CAACI,MAAM;QACnBN,OAAO;QACPiB,aAAa,EAAEhB;MACnB,CAAC;MACD,MAAMiB,MAAM,GAAG,MAAML,OAAO,CACxBd,MAKJ,CAAC;MAED,IAAImB,MAAM,YAAYtB,KAAK,EAAE;QACzB,OAAOsB,MAAM;MACjB;MAEAhB,GAAG,CAACiB,mBAAmB,GAAGD,MAAM;MAChC,OAAOF,KAAK,CAACI,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAOzB,OAAO,CAAC;MACXO,GAAG;MACHJ,GAAG;MACHE;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Context as LambdaContext, EventBridgeEvent } from "@webiny/aws-sdk/types";
|
|
2
|
-
import { Plugin } from "@webiny/plugins/Plugin";
|
|
3
|
-
import type { Context, Reply, Request } from "@webiny/handler/types";
|
|
1
|
+
import type { Context as LambdaContext, EventBridgeEvent } from "@webiny/aws-sdk/types/index.js";
|
|
2
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
3
|
+
import type { Context, Reply, Request } from "@webiny/handler/types.js";
|
|
4
4
|
export interface EventBridgeEventHandlerCallableParams<DetailType extends string, Detail, Response = Reply> {
|
|
5
5
|
request: Request;
|
|
6
6
|
reply: Reply;
|
|
@@ -17,4 +17,4 @@ export declare class EventBridgeEventHandler<DetailType extends string, Detail,
|
|
|
17
17
|
readonly cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>;
|
|
18
18
|
constructor(cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>);
|
|
19
19
|
}
|
|
20
|
-
export declare const createEventHandler: <DetailType extends string, Detail,
|
|
20
|
+
export declare const createEventHandler: <DetailType extends string, Detail, Response = any>(cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>) => EventBridgeEventHandler<DetailType, Detail, Response>;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createEventHandler = exports.EventBridgeEventHandler = void 0;
|
|
7
|
-
var _Plugin = require("@webiny/plugins/Plugin");
|
|
8
|
-
class EventBridgeEventHandler extends _Plugin.Plugin {
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
export class EventBridgeEventHandler extends Plugin {
|
|
9
3
|
static type = "handler.fastify.aws.eventBridge.eventHandler";
|
|
10
4
|
constructor(cb) {
|
|
11
5
|
super();
|
|
12
6
|
this.cb = cb;
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
const createEventHandler = cb => {
|
|
9
|
+
export const createEventHandler = cb => {
|
|
17
10
|
return new EventBridgeEventHandler(cb);
|
|
18
11
|
};
|
|
19
|
-
exports.createEventHandler = createEventHandler;
|
|
20
12
|
|
|
21
13
|
//# sourceMappingURL=EventBridgeEventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Plugin","EventBridgeEventHandler","type","constructor","cb","createEventHandler"],"sources":["EventBridgeEventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext, EventBridgeEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { Context, Reply, Request } from \"@webiny/handler/types.js\";\n\nexport interface EventBridgeEventHandlerCallableParams<\n DetailType extends string,\n Detail,\n Response = Reply\n> {\n request: Request;\n reply: Reply;\n context: Context;\n payload: EventBridgeEvent<DetailType, Detail>;\n lambdaContext: LambdaContext;\n next: () => Promise<Response>;\n}\nexport interface EventBridgeEventHandlerCallable<\n DetailType extends string,\n Detail,\n Response = Reply\n> {\n (\n params: EventBridgeEventHandlerCallableParams<DetailType, Detail, Response>\n ): Promise<Response>;\n}\n\nexport class EventBridgeEventHandler<\n DetailType extends string,\n Detail,\n Response = any\n> extends Plugin {\n public static override type = \"handler.fastify.aws.eventBridge.eventHandler\";\n\n public readonly cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>;\n\n public constructor(cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEventHandler = <DetailType extends string, Detail, Response = any>(\n cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>\n) => {\n return new EventBridgeEventHandler<DetailType, Detail, Response>(cb);\n};\n"],"mappings":"AACA,SAASA,MAAM,QAAQ,2BAA2B;AAyBlD,OAAO,MAAMC,uBAAuB,SAI1BD,MAAM,CAAC;EACb,OAAuBE,IAAI,GAAG,8CAA8C;EAIrEC,WAAWA,CAACC,EAAiE,EAAE;IAClF,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAEA,OAAO,MAAMC,kBAAkB,GAC3BD,EAAiE,IAChE;EACD,OAAO,IAAIH,uBAAuB,CAA+BG,EAAE,CAAC;AACxE,CAAC","ignoreList":[]}
|
package/eventBridge/register.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _index = require("./index");
|
|
6
|
-
const handler = (0, _sourceHandler.createSourceHandler)({
|
|
1
|
+
import { registry } from "../registry.js";
|
|
2
|
+
import { createSourceHandler } from "../sourceHandler.js";
|
|
3
|
+
import { createHandler } from "./index.js";
|
|
4
|
+
const handler = createSourceHandler({
|
|
7
5
|
name: "handler-aws-event-bridge",
|
|
8
6
|
canUse: event => {
|
|
9
7
|
return !!event.source;
|
|
@@ -13,9 +11,9 @@ const handler = (0, _sourceHandler.createSourceHandler)({
|
|
|
13
11
|
event,
|
|
14
12
|
context
|
|
15
13
|
}) => {
|
|
16
|
-
return
|
|
14
|
+
return createHandler(params)(event, context);
|
|
17
15
|
}
|
|
18
16
|
});
|
|
19
|
-
|
|
17
|
+
registry.register(handler);
|
|
20
18
|
|
|
21
19
|
//# sourceMappingURL=register.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["registry","createSourceHandler","createHandler","handler","name","canUse","event","source","handle","params","context","register"],"sources":["register.ts"],"sourcesContent":["import type { EventBridgeEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport { registry } from \"~/registry.js\";\nimport type { HandlerFactoryParams } from \"~/types.js\";\nimport { createSourceHandler } from \"~/sourceHandler.js\";\nimport { createHandler } from \"~/eventBridge/index.js\";\n\nexport interface HandlerParams extends HandlerFactoryParams {\n debug?: boolean;\n}\n\nconst handler = createSourceHandler<EventBridgeEvent<string, string>, HandlerParams>({\n name: \"handler-aws-event-bridge\",\n canUse: event => {\n return !!event.source;\n },\n handle: async ({ params, event, context }) => {\n return createHandler(params)(event, context);\n }\n});\n\nregistry.register(handler);\n"],"mappings":"AACA,SAASA,QAAQ;AAEjB,SAASC,mBAAmB;AAC5B,SAASC,aAAa;AAMtB,MAAMC,OAAO,GAAGF,mBAAmB,CAAkD;EACjFG,IAAI,EAAE,0BAA0B;EAChCC,MAAM,EAAEC,KAAK,IAAI;IACb,OAAO,CAAC,CAACA,KAAK,CAACC,MAAM;EACzB,CAAC;EACDC,MAAM,EAAE,MAAAA,CAAO;IAAEC,MAAM;IAAEH,KAAK;IAAEI;EAAQ,CAAC,KAAK;IAC1C,OAAOR,aAAa,CAACO,MAAM,CAAC,CAACH,KAAK,EAAEI,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFV,QAAQ,CAACW,QAAQ,CAACR,OAAO,CAAC","ignoreList":[]}
|
package/execute.d.ts
CHANGED
package/execute.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.execute = void 0;
|
|
7
|
-
var _types = require("./types");
|
|
1
|
+
import { Base64EncodeHeader } from "./types.js";
|
|
8
2
|
const createHandleResponse = (app, resolve) => {
|
|
9
3
|
return (err, result) => {
|
|
10
4
|
if (err) {
|
|
@@ -25,7 +19,7 @@ const createHandleResponse = (app, resolve) => {
|
|
|
25
19
|
};
|
|
26
20
|
return resolve(response);
|
|
27
21
|
}
|
|
28
|
-
const isBase64Encoded = !!result.headers[
|
|
22
|
+
const isBase64Encoded = !!result.headers[Base64EncodeHeader.encoded] || !!result.headers[Base64EncodeHeader.binary];
|
|
29
23
|
const response = {
|
|
30
24
|
statusCode: result.statusCode,
|
|
31
25
|
body: isBase64Encoded ? result.rawPayload.toString("base64") : result.payload,
|
|
@@ -45,7 +39,7 @@ const getPayloadProperty = (payload, prop, defaults = {}) => {
|
|
|
45
39
|
}
|
|
46
40
|
return defaults;
|
|
47
41
|
};
|
|
48
|
-
const execute = params => {
|
|
42
|
+
export const execute = params => {
|
|
49
43
|
const {
|
|
50
44
|
app,
|
|
51
45
|
url,
|
|
@@ -68,6 +62,5 @@ const execute = params => {
|
|
|
68
62
|
}, createHandleResponse(app, resolve));
|
|
69
63
|
});
|
|
70
64
|
};
|
|
71
|
-
exports.execute = execute;
|
|
72
65
|
|
|
73
66
|
//# sourceMappingURL=execute.js.map
|