@webiny/handler-aws 0.0.0-unstable.fcdad0bc61 → 0.0.0-unstable.fdd9228b5d
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/createHandler.d.ts +2 -0
- package/createHandler.js +29 -0
- package/createHandler.js.map +1 -0
- package/dynamodb/index.d.ts +5 -8
- package/dynamodb/index.js +19 -28
- package/dynamodb/index.js.map +1 -1
- package/dynamodb/plugins/DynamoDBEventHandler.d.ts +6 -5
- package/dynamodb/plugins/DynamoDBEventHandler.js +3 -12
- package/dynamodb/plugins/DynamoDBEventHandler.js.map +1 -1
- package/dynamodb/register.d.ts +1 -0
- package/dynamodb/register.js +28 -0
- package/dynamodb/register.js.map +1 -0
- package/eventBridge/index.d.ts +7 -10
- package/eventBridge/index.js +21 -30
- package/eventBridge/index.js.map +1 -1
- package/eventBridge/plugins/EventBridgeEventHandler.d.ts +6 -5
- package/eventBridge/plugins/EventBridgeEventHandler.js +3 -12
- package/eventBridge/plugins/EventBridgeEventHandler.js.map +1 -1
- package/eventBridge/register.d.ts +4 -0
- package/eventBridge/register.js +21 -0
- package/eventBridge/register.js.map +1 -0
- package/execute.d.ts +1 -1
- package/execute.js +16 -14
- package/execute.js.map +1 -1
- package/gateway/index.d.ts +7 -11
- package/gateway/index.js +48 -22
- package/gateway/index.js.map +1 -1
- package/gateway/register.d.ts +1 -0
- package/gateway/register.js +21 -0
- package/gateway/register.js.map +1 -0
- package/index.d.ts +34 -5
- package/index.js +158 -29
- package/index.js.map +1 -1
- package/package.json +14 -20
- package/plugins/handlerClient.js +9 -18
- package/plugins/handlerClient.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +2 -3
- package/plugins/index.js.map +1 -1
- package/raw/index.d.ts +3 -8
- package/raw/index.js +22 -29
- package/raw/index.js.map +1 -1
- package/raw/plugins/RawEventHandler.d.ts +17 -6
- package/raw/plugins/RawEventHandler.js +20 -9
- package/raw/plugins/RawEventHandler.js.map +1 -1
- package/registry.d.ts +17 -0
- package/registry.js +44 -0
- package/registry.js.map +1 -0
- package/s3/index.d.ts +6 -9
- package/s3/index.js +22 -31
- package/s3/index.js.map +1 -1
- package/s3/plugins/S3EventHandler.d.ts +6 -5
- package/s3/plugins/S3EventHandler.js +3 -12
- package/s3/plugins/S3EventHandler.js.map +1 -1
- package/s3/register.d.ts +4 -0
- package/s3/register.js +25 -0
- package/s3/register.js.map +1 -0
- package/sns/index.d.ts +8 -0
- package/sns/index.js +79 -0
- package/sns/index.js.map +1 -0
- package/sns/plugins/SNSEventHandler.d.ts +20 -0
- package/sns/plugins/SNSEventHandler.js +21 -0
- package/sns/plugins/SNSEventHandler.js.map +1 -0
- package/sns/register.d.ts +1 -0
- package/sns/register.js +25 -0
- package/sns/register.js.map +1 -0
- package/sourceHandler.d.ts +2 -0
- package/sourceHandler.js +12 -0
- package/sourceHandler.js.map +1 -0
- package/sqs/index.d.ts +6 -9
- package/sqs/index.js +26 -32
- package/sqs/index.js.map +1 -1
- package/sqs/plugins/SQSEventHandler.d.ts +6 -5
- package/sqs/plugins/SQSEventHandler.js +3 -12
- package/sqs/plugins/SQSEventHandler.js.map +1 -1
- package/sqs/register.d.ts +1 -0
- package/sqs/register.js +28 -0
- package/sqs/register.js.map +1 -0
- package/types.d.ts +27 -4
- package/types.js +14 -9
- package/types.js.map +1 -1
- package/utils/composedHandler.d.ts +6 -0
- package/utils/composedHandler.js +24 -0
- package/utils/composedHandler.js.map +1 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +29 -0
- package/utils/index.js.map +1 -0
- package/utils/timer/CustomTimer.d.ts +5 -0
- package/utils/timer/CustomTimer.js +19 -0
- package/utils/timer/CustomTimer.js.map +1 -0
- package/utils/timer/Timer.d.ts +10 -0
- package/utils/timer/Timer.js +24 -0
- package/utils/timer/Timer.js.map +1 -0
- package/utils/timer/abstractions/ITimer.d.ts +10 -0
- package/utils/timer/abstractions/ITimer.js +7 -0
- package/utils/timer/abstractions/ITimer.js.map +1 -0
- package/utils/timer/factory.d.ts +4 -0
- package/utils/timer/factory.js +20 -0
- package/utils/timer/factory.js.map +1 -0
- package/utils/timer/index.d.ts +4 -0
- package/utils/timer/index.js +51 -0
- package/utils/timer/index.js.map +1 -0
package/createHandler.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createHandler = void 0;
|
|
7
|
+
var _plugins = require("@webiny/plugins");
|
|
8
|
+
var _registry = require("./registry");
|
|
9
|
+
const createHandler = ({
|
|
10
|
+
plugins,
|
|
11
|
+
...params
|
|
12
|
+
}) => {
|
|
13
|
+
const pluginsContainer = new _plugins.AsyncPluginsContainer(plugins);
|
|
14
|
+
return async (event, context) => {
|
|
15
|
+
const plugins = await pluginsContainer.init();
|
|
16
|
+
const handler = _registry.registry.getHandler(event, context);
|
|
17
|
+
return handler.handle({
|
|
18
|
+
params: {
|
|
19
|
+
...params,
|
|
20
|
+
plugins
|
|
21
|
+
},
|
|
22
|
+
event,
|
|
23
|
+
context
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
exports.createHandler = createHandler;
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=createHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","_registry","createHandler","plugins","params","pluginsContainer","AsyncPluginsContainer","event","context","init","handler","registry","getHandler","handle","exports"],"sources":["createHandler.ts"],"sourcesContent":["import { AsyncPluginsContainer } from \"@webiny/plugins\";\nimport type { HandlerFactory } from \"~/types\";\nimport { registry } from \"./registry\";\n\nexport const createHandler: HandlerFactory = ({ plugins, ...params }) => {\n const pluginsContainer = new AsyncPluginsContainer(plugins);\n\n return async (event, context) => {\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,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AAEO,MAAME,aAA6B,GAAGA,CAAC;EAAEC,OAAO;EAAE,GAAGC;AAAO,CAAC,KAAK;EACrE,MAAMC,gBAAgB,GAAG,IAAIC,8BAAqB,CAACH,OAAO,CAAC;EAE3D,OAAO,OAAOI,KAAK,EAAEC,OAAO,KAAK;IAC7B,MAAML,OAAO,GAAG,MAAME,gBAAgB,CAACI,IAAI,CAAC,CAAC;IAC7C,MAAMC,OAAO,GAAGC,kBAAQ,CAACC,UAAU,CAACL,KAAK,EAAEC,OAAO,CAAC;IACnD,OAAOE,OAAO,CAACG,MAAM,CAAC;MAClBT,MAAM,EAAE;QACJ,GAAGA,MAAM;QACTD;MACJ,CAAC;MACDI,KAAK;MACLC;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACM,OAAA,CAAAZ,aAAA,GAAAA,aAAA","ignoreList":[]}
|
package/dynamodb/index.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import type { APIGatewayProxyResult, Context as LambdaContext, DynamoDBStreamEvent } from "@webiny/aws-sdk/types";
|
|
2
|
+
import type { HandlerFactoryParams } from "../types";
|
|
3
|
+
export * from "./plugins/DynamoDBEventHandler";
|
|
4
|
+
export type HandlerParams = HandlerFactoryParams;
|
|
4
5
|
export interface HandlerCallable {
|
|
5
6
|
(event: DynamoDBStreamEvent, context: LambdaContext): Promise<APIGatewayProxyResult>;
|
|
6
7
|
}
|
|
7
|
-
export
|
|
8
|
-
debug?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const createHandler: (params: CreateHandlerParams) => HandlerCallable;
|
|
11
|
-
export * from "./plugins/DynamoDBEventHandler";
|
|
8
|
+
export declare const createHandler: (params: HandlerParams) => HandlerCallable;
|
package/dynamodb/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -9,13 +8,9 @@ var _exportNames = {
|
|
|
9
8
|
createHandler: true
|
|
10
9
|
};
|
|
11
10
|
exports.createHandler = void 0;
|
|
12
|
-
|
|
13
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
14
|
-
|
|
15
11
|
var _handler = require("@webiny/handler");
|
|
16
|
-
|
|
12
|
+
var _plugins = require("../plugins");
|
|
17
13
|
var _DynamoDBEventHandler = require("./plugins/DynamoDBEventHandler");
|
|
18
|
-
|
|
19
14
|
Object.keys(_DynamoDBEventHandler).forEach(function (key) {
|
|
20
15
|
if (key === "default" || key === "__esModule") return;
|
|
21
16
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -27,39 +22,36 @@ Object.keys(_DynamoDBEventHandler).forEach(function (key) {
|
|
|
27
22
|
}
|
|
28
23
|
});
|
|
29
24
|
});
|
|
30
|
-
|
|
31
|
-
var _plugins = require("../plugins");
|
|
32
|
-
|
|
25
|
+
var _reply = _interopRequireDefault(require("fastify/lib/reply"));
|
|
33
26
|
var _execute = require("../execute");
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
var _composedHandler = require("../utils/composedHandler");
|
|
28
|
+
/**
|
|
29
|
+
* We need a class, not an interface exported from types.
|
|
30
|
+
*/
|
|
31
|
+
// @ts-expect-error
|
|
36
32
|
|
|
37
33
|
const url = "/webiny-dynamodb-event";
|
|
38
|
-
|
|
39
34
|
const createHandler = params => {
|
|
40
35
|
return (payload, context) => {
|
|
41
36
|
const app = (0, _handler.createHandler)({
|
|
42
|
-
|
|
43
|
-
options:
|
|
44
|
-
logger: params.debug === true
|
|
45
|
-
|
|
37
|
+
...params,
|
|
38
|
+
options: {
|
|
39
|
+
logger: params.debug === true,
|
|
40
|
+
...(params.options || {})
|
|
41
|
+
}
|
|
46
42
|
});
|
|
47
43
|
/**
|
|
48
44
|
* We always must add our default plugins to the app.
|
|
49
45
|
*/
|
|
50
|
-
|
|
51
46
|
(0, _plugins.registerDefaultPlugins)(app.webiny);
|
|
52
47
|
/**
|
|
53
48
|
* There must be an event plugin for this handler to work.
|
|
54
49
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const handler = plugins.shift();
|
|
58
|
-
|
|
59
|
-
if (!handler) {
|
|
50
|
+
const plugins = app.webiny.plugins.byType(_DynamoDBEventHandler.DynamoDBEventHandler.type).reverse();
|
|
51
|
+
if (plugins.length === 0) {
|
|
60
52
|
throw new Error(`To run @webiny/handler-aws/dynamodb, you must have DynamoDBHandler set.`);
|
|
61
53
|
}
|
|
62
|
-
|
|
54
|
+
const handler = (0, _composedHandler.createComposedHandler)(plugins);
|
|
63
55
|
app.post(url, async (request, reply) => {
|
|
64
56
|
const params = {
|
|
65
57
|
request,
|
|
@@ -68,12 +60,10 @@ const createHandler = params => {
|
|
|
68
60
|
lambdaContext: context,
|
|
69
61
|
reply
|
|
70
62
|
};
|
|
71
|
-
const result = await handler
|
|
72
|
-
|
|
73
|
-
if (result instanceof Reply) {
|
|
63
|
+
const result = await handler(params);
|
|
64
|
+
if (result instanceof _reply.default) {
|
|
74
65
|
return result;
|
|
75
66
|
}
|
|
76
|
-
|
|
77
67
|
app.__webiny_raw_result = result;
|
|
78
68
|
return reply.send({});
|
|
79
69
|
});
|
|
@@ -84,5 +74,6 @@ const createHandler = params => {
|
|
|
84
74
|
});
|
|
85
75
|
};
|
|
86
76
|
};
|
|
77
|
+
exports.createHandler = createHandler;
|
|
87
78
|
|
|
88
|
-
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
package/dynamodb/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_handler","require","_plugins","_DynamoDBEventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_reply","_interopRequireDefault","_execute","_composedHandler","url","createHandler","params","payload","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","DynamoDBEventHandler","type","reverse","length","Error","handler","createComposedHandler","post","request","reply","event","lambdaContext","result","Reply","__webiny_raw_result","send","execute"],"sources":["index.ts"],"sourcesContent":["import type {\n APIGatewayProxyResult,\n Context as LambdaContext,\n DynamoDBStreamEvent\n} from \"@webiny/aws-sdk/types\";\nimport type { HandlerFactoryParams } from \"~/types\";\nimport { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport type { DynamoDBEventHandlerCallableParams } from \"./plugins/DynamoDBEventHandler\";\nimport { DynamoDBEventHandler } from \"./plugins/DynamoDBEventHandler\";\n/**\n * We need a class, not an interface exported from types.\n */\n// @ts-expect-error\nimport Reply from \"fastify/lib/reply\";\nimport { execute } from \"~/execute\";\nimport { createComposedHandler } from \"~/utils/composedHandler\";\n\nexport * from \"./plugins/DynamoDBEventHandler\";\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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,qBAAA,GAAAF,OAAA;AASAG,MAAA,CAAAC,IAAA,CAAAF,qBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,qBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,qBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAJA,IAAAS,MAAA,GAAAC,sBAAA,CAAAhB,OAAA;AACA,IAAAiB,QAAA,GAAAjB,OAAA;AACA,IAAAkB,gBAAA,GAAAlB,OAAA;AANA;AACA;AACA;AACA;;AAOA,MAAMmB,GAAG,GAAG,wBAAwB;AAQ7B,MAAMC,aAAa,GAAIC,MAAqB,IAAsB;EACrE,OAAO,CAACC,OAAO,EAAEC,OAAO,KAAK;IACzB,MAAMC,GAAG,GAAG,IAAAC,sBAAiB,EAAC;MAC1B,GAAGJ,MAAM;MACTK,OAAO,EAAE;QACLC,MAAM,EAAEN,MAAM,CAACO,KAAK,KAAK,IAAI;QAC7B,IAAIP,MAAM,CAACK,OAAO,IAAI,CAAC,CAAC;MAC5B;IACJ,CAAC,CAAC;IACF;AACR;AACA;IACQ,IAAAG,+BAAsB,EAACL,GAAG,CAACM,MAAM,CAAC;IAClC;AACR;AACA;IACQ,MAAMC,OAAO,GAAGP,GAAG,CAACM,MAAM,CAACC,OAAO,CAC7BC,MAAM,CAAuBC,0CAAoB,CAACC,IAAI,CAAC,CACvDC,OAAO,CAAC,CAAC;IACd,IAAIJ,OAAO,CAACK,MAAM,KAAK,CAAC,EAAE;MACtB,MAAM,IAAIC,KAAK,CACX,yEACJ,CAAC;IACL;IAEA,MAAMC,OAAO,GAAG,IAAAC,sCAAqB,EAInCR,OAAO,CAAC;IAEVP,GAAG,CAACgB,IAAI,CAACrB,GAAG,EAAE,OAAOsB,OAAO,EAAEC,KAAK,KAAK;MACpC,MAAMrB,MAGL,GAAG;QACAoB,OAAO;QACPlB,OAAO,EAAEC,GAAG,CAACM,MAAM;QACnBa,KAAK,EAAErB,OAAO;QACdsB,aAAa,EAAErB,OAAO;QACtBmB;MACJ,CAAC;MACD,MAAMG,MAAM,GAAG,MAAMP,OAAO,CACxBjB,MACJ,CAAC;MAED,IAAIwB,MAAM,YAAYC,cAAK,EAAE;QACzB,OAAOD,MAAM;MACjB;MAEArB,GAAG,CAACuB,mBAAmB,GAAGF,MAAM;MAChC,OAAOH,KAAK,CAACM,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAO,IAAAC,gBAAO,EAAC;MACXzB,GAAG;MACHL,GAAG;MACHG;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export interface DynamoDBEventHandlerCallableParams {
|
|
2
|
+
import type { Context, Reply, Request } from "@webiny/handler/types";
|
|
3
|
+
import type { Context as LambdaContext, DynamoDBStreamEvent } from "@webiny/aws-sdk/types";
|
|
4
|
+
export interface DynamoDBEventHandlerCallableParams<Response = Reply> {
|
|
5
5
|
request: Request;
|
|
6
6
|
context: Context;
|
|
7
7
|
event: DynamoDBStreamEvent;
|
|
8
8
|
lambdaContext: LambdaContext;
|
|
9
9
|
reply: Reply;
|
|
10
|
+
next: () => Promise<Response>;
|
|
10
11
|
}
|
|
11
|
-
export interface DynamoDBEventHandlerCallable<Response> {
|
|
12
|
-
(params: DynamoDBEventHandlerCallableParams): Promise<Response
|
|
12
|
+
export interface DynamoDBEventHandlerCallable<Response = Reply> {
|
|
13
|
+
(params: DynamoDBEventHandlerCallableParams<Response>): Promise<Response>;
|
|
13
14
|
}
|
|
14
15
|
export declare class DynamoDBEventHandler<Response = any> extends Plugin {
|
|
15
16
|
static type: string;
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.createEventHandler = exports.DynamoDBEventHandler = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
7
|
var _Plugin = require("@webiny/plugins/Plugin");
|
|
13
|
-
|
|
14
8
|
class DynamoDBEventHandler extends _Plugin.Plugin {
|
|
9
|
+
static type = "handler.fastify.aws.dynamodb.eventHandler";
|
|
15
10
|
constructor(cb) {
|
|
16
11
|
super();
|
|
17
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
18
12
|
this.cb = cb;
|
|
19
13
|
}
|
|
20
|
-
|
|
21
14
|
}
|
|
22
|
-
|
|
23
15
|
exports.DynamoDBEventHandler = DynamoDBEventHandler;
|
|
24
|
-
(0, _defineProperty2.default)(DynamoDBEventHandler, "type", "handler.fastify.aws.dynamodb.eventHandler");
|
|
25
|
-
|
|
26
16
|
const createEventHandler = cb => {
|
|
27
17
|
return new DynamoDBEventHandler(cb);
|
|
28
18
|
};
|
|
19
|
+
exports.createEventHandler = createEventHandler;
|
|
29
20
|
|
|
30
|
-
|
|
21
|
+
//# sourceMappingURL=DynamoDBEventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["DynamoDBEventHandler","Plugin","constructor","cb","createEventHandler"],"sources":["DynamoDBEventHandler.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport {
|
|
1
|
+
{"version":3,"names":["_Plugin","require","DynamoDBEventHandler","Plugin","type","constructor","cb","exports","createEventHandler"],"sources":["DynamoDBEventHandler.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { Context, Reply, Request } from \"@webiny/handler/types\";\nimport type { Context as LambdaContext, DynamoDBStreamEvent } from \"@webiny/aws-sdk/types\";\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,IAAAA,OAAA,GAAAC,OAAA;AAiBO,MAAMC,oBAAoB,SAAyBC,cAAM,CAAC;EAC7D,OAAuBC,IAAI,GAAG,2CAA2C;EAIlEC,WAAWA,CAACC,EAA0C,EAAE;IAC3D,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,oBAAA,GAAAA,oBAAA;AAEM,MAAMM,kBAAkB,GAAcF,EAA0C,IAAK;EACxF,OAAO,IAAIJ,oBAAoB,CAAWI,EAAE,CAAC;AACjD,CAAC;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _registry = require("../registry");
|
|
4
|
+
var _sourceHandler = require("../sourceHandler");
|
|
5
|
+
var _index = require("./index");
|
|
6
|
+
const handler = (0, _sourceHandler.createSourceHandler)({
|
|
7
|
+
name: "handler-aws-dynamodb-stream",
|
|
8
|
+
canUse: event => {
|
|
9
|
+
if (!Array.isArray(event.Records) || event.Records.length === 0) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const [record] = event.Records;
|
|
13
|
+
if (typeof record.eventSource !== "string") {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return record.eventSource.toLowerCase() === "aws:dynamodb";
|
|
17
|
+
},
|
|
18
|
+
handle: async ({
|
|
19
|
+
params,
|
|
20
|
+
event,
|
|
21
|
+
context
|
|
22
|
+
}) => {
|
|
23
|
+
return (0, _index.createHandler)(params)(event, context);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
_registry.registry.register(handler);
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_registry","require","_sourceHandler","_index","handler","createSourceHandler","name","canUse","event","Array","isArray","Records","length","record","eventSource","toLowerCase","handle","params","context","createHandler","registry","register"],"sources":["register.ts"],"sourcesContent":["import { registry } from \"~/registry\";\nimport type { DynamoDBStreamEvent } from \"@webiny/aws-sdk/types\";\nimport { createSourceHandler } from \"~/sourceHandler\";\nimport type { HandlerParams } from \"~/dynamodb/index\";\nimport { createHandler } from \"~/dynamodb/index\";\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,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAEA,MAAMG,OAAO,GAAG,IAAAC,kCAAmB,EAAqC;EACpEC,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,OAAO,IAAAC,oBAAa,EAACF,MAAM,CAAC,CAACT,KAAK,EAAEU,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFE,kBAAQ,CAACC,QAAQ,CAACjB,OAAO,CAAC","ignoreList":[]}
|
package/eventBridge/index.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { APIGatewayProxyResult } from "aws-lambda/trigger/api-gateway-proxy";
|
|
4
|
-
export interface HandlerCallable<DetailType extends string, Detail> {
|
|
5
|
-
(event: EventBridgeEvent<DetailType, Detail>, context: LambdaContext): Promise<APIGatewayProxyResult>;
|
|
6
|
-
}
|
|
7
|
-
export interface CreateHandlerParams extends BaseCreateHandlerParams {
|
|
8
|
-
debug?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare const createHandler: <DetailType extends string, Detail>(params: CreateHandlerParams) => HandlerCallable<DetailType, Detail>;
|
|
1
|
+
import type { HandlerFactoryParams } from "../types";
|
|
2
|
+
import type { APIGatewayProxyResult, Context as LambdaContext, EventBridgeEvent } from "@webiny/aws-sdk/types";
|
|
11
3
|
export * from "./plugins/EventBridgeEventHandler";
|
|
4
|
+
export type HandlerParams = HandlerFactoryParams;
|
|
5
|
+
export interface HandlerCallable {
|
|
6
|
+
(event: EventBridgeEvent<string, string>, context: LambdaContext): Promise<APIGatewayProxyResult>;
|
|
7
|
+
}
|
|
8
|
+
export declare const createHandler: (params: HandlerParams) => HandlerCallable;
|
package/eventBridge/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -9,13 +8,9 @@ var _exportNames = {
|
|
|
9
8
|
createHandler: true
|
|
10
9
|
};
|
|
11
10
|
exports.createHandler = void 0;
|
|
12
|
-
|
|
13
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
14
|
-
|
|
15
11
|
var _handler = require("@webiny/handler");
|
|
16
|
-
|
|
12
|
+
var _plugins = require("../plugins");
|
|
17
13
|
var _EventBridgeEventHandler = require("./plugins/EventBridgeEventHandler");
|
|
18
|
-
|
|
19
14
|
Object.keys(_EventBridgeEventHandler).forEach(function (key) {
|
|
20
15
|
if (key === "default" || key === "__esModule") return;
|
|
21
16
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -27,39 +22,36 @@ Object.keys(_EventBridgeEventHandler).forEach(function (key) {
|
|
|
27
22
|
}
|
|
28
23
|
});
|
|
29
24
|
});
|
|
30
|
-
|
|
31
|
-
var _plugins = require("../plugins");
|
|
32
|
-
|
|
33
25
|
var _execute = require("../execute");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
var _reply = _interopRequireDefault(require("fastify/lib/reply"));
|
|
27
|
+
var _composedHandler = require("../utils/composedHandler");
|
|
28
|
+
/**
|
|
29
|
+
* We need a class, not an interface exported from types.
|
|
30
|
+
*/
|
|
31
|
+
// @ts-expect-error
|
|
32
|
+
|
|
33
|
+
const url = "/webiny-eventBridge-event";
|
|
39
34
|
const createHandler = params => {
|
|
40
35
|
return (payload, context) => {
|
|
41
36
|
const app = (0, _handler.createHandler)({
|
|
42
|
-
|
|
43
|
-
options:
|
|
44
|
-
logger: params.debug === true
|
|
45
|
-
|
|
37
|
+
...params,
|
|
38
|
+
options: {
|
|
39
|
+
logger: params.debug === true,
|
|
40
|
+
...(params.options || {})
|
|
41
|
+
}
|
|
46
42
|
});
|
|
47
43
|
/**
|
|
48
44
|
* We always must add our default plugins to the app.
|
|
49
45
|
*/
|
|
50
|
-
|
|
51
46
|
(0, _plugins.registerDefaultPlugins)(app.webiny);
|
|
52
47
|
/**
|
|
53
48
|
* There must be an event plugin for this handler to work.
|
|
54
49
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const handler = plugins.shift();
|
|
58
|
-
|
|
59
|
-
if (!handler) {
|
|
50
|
+
const plugins = app.webiny.plugins.byType(_EventBridgeEventHandler.EventBridgeEventHandler.type).reverse();
|
|
51
|
+
if (plugins.length === 0) {
|
|
60
52
|
throw new Error(`To run @webiny/handler-aws/eventBridge, you must have EventBridgeEventHandler set.`);
|
|
61
53
|
}
|
|
62
|
-
|
|
54
|
+
const handler = (0, _composedHandler.createComposedHandler)(plugins);
|
|
63
55
|
app.post(url, async (request, reply) => {
|
|
64
56
|
const params = {
|
|
65
57
|
request,
|
|
@@ -68,12 +60,10 @@ const createHandler = params => {
|
|
|
68
60
|
payload,
|
|
69
61
|
lambdaContext: context
|
|
70
62
|
};
|
|
71
|
-
const result = await handler
|
|
72
|
-
|
|
73
|
-
if (result instanceof Reply) {
|
|
63
|
+
const result = await handler(params);
|
|
64
|
+
if (result instanceof _reply.default) {
|
|
74
65
|
return result;
|
|
75
66
|
}
|
|
76
|
-
|
|
77
67
|
app.__webiny_raw_result = result;
|
|
78
68
|
return reply.send({});
|
|
79
69
|
});
|
|
@@ -84,5 +74,6 @@ const createHandler = params => {
|
|
|
84
74
|
});
|
|
85
75
|
};
|
|
86
76
|
};
|
|
77
|
+
exports.createHandler = createHandler;
|
|
87
78
|
|
|
88
|
-
|
|
79
|
+
//# sourceMappingURL=index.js.map
|
package/eventBridge/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_handler","require","_plugins","_EventBridgeEventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_execute","_reply","_interopRequireDefault","_composedHandler","url","createHandler","params","payload","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","EventBridgeEventHandler","type","reverse","length","Error","handler","createComposedHandler","post","request","reply","lambdaContext","result","Reply","__webiny_raw_result","send","execute"],"sources":["index.ts"],"sourcesContent":["import { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport type { EventBridgeEventHandlerCallableParams } from \"~/eventBridge/plugins/EventBridgeEventHandler\";\nimport { EventBridgeEventHandler } from \"~/eventBridge/plugins/EventBridgeEventHandler\";\nimport { execute } from \"~/execute\";\nimport type { HandlerFactoryParams } from \"~/types\";\nimport type {\n APIGatewayProxyResult,\n Context as LambdaContext,\n EventBridgeEvent\n} from \"@webiny/aws-sdk/types\";\n/**\n * We need a class, not an interface exported from types.\n */\n// @ts-expect-error\nimport Reply from \"fastify/lib/reply\";\nimport { createComposedHandler } from \"~/utils/composedHandler\";\n\nexport * from \"./plugins/EventBridgeEventHandler\";\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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,wBAAA,GAAAF,OAAA;AAeAG,MAAA,CAAAC,IAAA,CAAAF,wBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,wBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,wBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAdA,IAAAS,QAAA,GAAAf,OAAA;AAWA,IAAAgB,MAAA,GAAAC,sBAAA,CAAAjB,OAAA;AACA,IAAAkB,gBAAA,GAAAlB,OAAA;AALA;AACA;AACA;AACA;;AAeA,MAAMmB,GAAG,GAAG,2BAA2B;AAEhC,MAAMC,aAAa,GAAIC,MAAqB,IAAsB;EACrE,OAAO,CAACC,OAAO,EAAEC,OAAO,KAAK;IACzB,MAAMC,GAAG,GAAG,IAAAC,sBAAiB,EAAC;MAC1B,GAAGJ,MAAM;MACTK,OAAO,EAAE;QACLC,MAAM,EAAEN,MAAM,CAACO,KAAK,KAAK,IAAI;QAC7B,IAAIP,MAAM,CAACK,OAAO,IAAI,CAAC,CAAC;MAC5B;IACJ,CAAC,CAAC;IACF;AACR;AACA;IACQ,IAAAG,+BAAsB,EAACL,GAAG,CAACM,MAAM,CAAC;IAClC;AACR;AACA;IACQ,MAAMC,OAAO,GAAGP,GAAG,CAACM,MAAM,CAACC,OAAO,CAC7BC,MAAM,CAA0CC,gDAAuB,CAACC,IAAI,CAAC,CAC7EC,OAAO,CAAC,CAAC;IACd,IAAIJ,OAAO,CAACK,MAAM,KAAK,CAAC,EAAE;MACtB,MAAM,IAAIC,KAAK,CACX,oFACJ,CAAC;IACL;IAEA,MAAMC,OAAO,GAAG,IAAAC,sCAAqB,EAInCR,OAAO,CAAC;IAEVP,GAAG,CAACgB,IAAI,CAACrB,GAAG,EAAE,OAAOsB,OAAO,EAAEC,KAAK,KAAK;MACpC,MAAMrB,MAGL,GAAG;QACAoB,OAAO;QACPC,KAAK;QACLnB,OAAO,EAAEC,GAAG,CAACM,MAAM;QACnBR,OAAO;QACPqB,aAAa,EAAEpB;MACnB,CAAC;MACD,MAAMqB,MAAM,GAAG,MAAMN,OAAO,CACxBjB,MAKJ,CAAC;MAED,IAAIuB,MAAM,YAAYC,cAAK,EAAE;QACzB,OAAOD,MAAM;MACjB;MAEApB,GAAG,CAACsB,mBAAmB,GAAGF,MAAM;MAChC,OAAOF,KAAK,CAACK,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAO,IAAAC,gBAAO,EAAC;MACXxB,GAAG;MACHL,GAAG;MACHG;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA","ignoreList":[]}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import type { Context as LambdaContext, EventBridgeEvent } from "@webiny/aws-sdk/types";
|
|
1
2
|
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export interface EventBridgeEventHandlerCallableParams<DetailType extends string, Detail> {
|
|
3
|
+
import type { Context, Reply, Request } from "@webiny/handler/types";
|
|
4
|
+
export interface EventBridgeEventHandlerCallableParams<DetailType extends string, Detail, Response = Reply> {
|
|
5
5
|
request: Request;
|
|
6
6
|
reply: Reply;
|
|
7
7
|
context: Context;
|
|
8
8
|
payload: EventBridgeEvent<DetailType, Detail>;
|
|
9
9
|
lambdaContext: LambdaContext;
|
|
10
|
+
next: () => Promise<Response>;
|
|
10
11
|
}
|
|
11
|
-
export interface EventBridgeEventHandlerCallable<DetailType extends string, Detail, Response> {
|
|
12
|
-
(params: EventBridgeEventHandlerCallableParams<DetailType, Detail>): Promise<Response
|
|
12
|
+
export interface EventBridgeEventHandlerCallable<DetailType extends string, Detail, Response = Reply> {
|
|
13
|
+
(params: EventBridgeEventHandlerCallableParams<DetailType, Detail, Response>): Promise<Response>;
|
|
13
14
|
}
|
|
14
15
|
export declare class EventBridgeEventHandler<DetailType extends string, Detail, Response = any> extends Plugin {
|
|
15
16
|
static type: string;
|
|
@@ -1,30 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.createEventHandler = exports.EventBridgeEventHandler = void 0;
|
|
9
|
-
|
|
10
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
7
|
var _Plugin = require("@webiny/plugins/Plugin");
|
|
13
|
-
|
|
14
8
|
class EventBridgeEventHandler extends _Plugin.Plugin {
|
|
9
|
+
static type = "handler.fastify.aws.eventBridge.eventHandler";
|
|
15
10
|
constructor(cb) {
|
|
16
11
|
super();
|
|
17
|
-
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
18
12
|
this.cb = cb;
|
|
19
13
|
}
|
|
20
|
-
|
|
21
14
|
}
|
|
22
|
-
|
|
23
15
|
exports.EventBridgeEventHandler = EventBridgeEventHandler;
|
|
24
|
-
(0, _defineProperty2.default)(EventBridgeEventHandler, "type", "handler.fastify.aws.sqs.eventHandler");
|
|
25
|
-
|
|
26
16
|
const createEventHandler = cb => {
|
|
27
17
|
return new EventBridgeEventHandler(cb);
|
|
28
18
|
};
|
|
19
|
+
exports.createEventHandler = createEventHandler;
|
|
29
20
|
|
|
30
|
-
|
|
21
|
+
//# sourceMappingURL=EventBridgeEventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EventBridgeEventHandler","Plugin","constructor","cb","createEventHandler"],"sources":["EventBridgeEventHandler.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"names":["_Plugin","require","EventBridgeEventHandler","Plugin","type","constructor","cb","exports","createEventHandler"],"sources":["EventBridgeEventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext, EventBridgeEvent } from \"@webiny/aws-sdk/types\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { Context, Reply, Request } from \"@webiny/handler/types\";\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,IAAAA,OAAA,GAAAC,OAAA;AAyBO,MAAMC,uBAAuB,SAI1BC,cAAM,CAAC;EACb,OAAuBC,IAAI,GAAG,8CAA8C;EAIrEC,WAAWA,CAACC,EAAiE,EAAE;IAClF,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,uBAAA,GAAAA,uBAAA;AAEM,MAAMM,kBAAkB,GAC3BF,EAAiE,IAChE;EACD,OAAO,IAAIJ,uBAAuB,CAA+BI,EAAE,CAAC;AACxE,CAAC;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _registry = require("../registry");
|
|
4
|
+
var _sourceHandler = require("../sourceHandler");
|
|
5
|
+
var _index = require("./index");
|
|
6
|
+
const handler = (0, _sourceHandler.createSourceHandler)({
|
|
7
|
+
name: "handler-aws-event-bridge",
|
|
8
|
+
canUse: event => {
|
|
9
|
+
return !!event.source;
|
|
10
|
+
},
|
|
11
|
+
handle: async ({
|
|
12
|
+
params,
|
|
13
|
+
event,
|
|
14
|
+
context
|
|
15
|
+
}) => {
|
|
16
|
+
return (0, _index.createHandler)(params)(event, context);
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
_registry.registry.register(handler);
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=register.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_registry","require","_sourceHandler","_index","handler","createSourceHandler","name","canUse","event","source","handle","params","context","createHandler","registry","register"],"sources":["register.ts"],"sourcesContent":["import type { EventBridgeEvent } from \"@webiny/aws-sdk/types\";\nimport { registry } from \"~/registry\";\nimport type { HandlerFactoryParams } from \"~/types\";\nimport { createSourceHandler } from \"~/sourceHandler\";\nimport { createHandler } from \"~/eventBridge/index\";\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,IAAAA,SAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAMA,MAAMG,OAAO,GAAG,IAAAC,kCAAmB,EAAkD;EACjFC,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,OAAO,IAAAC,oBAAa,EAACF,MAAM,CAAC,CAACH,KAAK,EAAEI,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFE,kBAAQ,CAACC,QAAQ,CAACX,OAAO,CAAC","ignoreList":[]}
|
package/execute.d.ts
CHANGED