@webiny/handler-aws 0.0.0-unstable.9bd236cf5e → 0.0.0-unstable.9f53ea597d

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.
Files changed (98) hide show
  1. package/README.md +10 -14
  2. package/createHandler.d.ts +1 -1
  3. package/createHandler.js +20 -26
  4. package/createHandler.js.map +1 -1
  5. package/dynamodb/index.d.ts +3 -3
  6. package/dynamodb/index.js +39 -76
  7. package/dynamodb/index.js.map +1 -1
  8. package/dynamodb/plugins/DynamoDBEventHandler.d.ts +4 -4
  9. package/dynamodb/plugins/DynamoDBEventHandler.js +11 -18
  10. package/dynamodb/plugins/DynamoDBEventHandler.js.map +1 -1
  11. package/dynamodb/register.js +13 -25
  12. package/dynamodb/register.js.map +1 -1
  13. package/eventBridge/index.d.ts +3 -3
  14. package/eventBridge/index.js +39 -76
  15. package/eventBridge/index.js.map +1 -1
  16. package/eventBridge/plugins/EventBridgeEventHandler.d.ts +4 -4
  17. package/eventBridge/plugins/EventBridgeEventHandler.js +11 -18
  18. package/eventBridge/plugins/EventBridgeEventHandler.js.map +1 -1
  19. package/eventBridge/register.d.ts +1 -1
  20. package/eventBridge/register.js +8 -18
  21. package/eventBridge/register.js.map +1 -1
  22. package/execute.d.ts +1 -1
  23. package/execute.js +53 -68
  24. package/execute.js.map +1 -1
  25. package/gateway/index.d.ts +2 -2
  26. package/gateway/index.js +41 -83
  27. package/gateway/index.js.map +1 -1
  28. package/gateway/register.js +8 -18
  29. package/gateway/register.js.map +1 -1
  30. package/index.d.ts +17 -17
  31. package/index.js +17 -374
  32. package/package.json +22 -19
  33. package/plugins/index.d.ts +1 -1
  34. package/plugins/index.js +3 -10
  35. package/plugins/index.js.map +1 -1
  36. package/raw/index.d.ts +3 -3
  37. package/raw/index.js +42 -86
  38. package/raw/index.js.map +1 -1
  39. package/raw/plugins/RawEventHandler.d.ts +3 -3
  40. package/raw/plugins/RawEventHandler.js +12 -30
  41. package/raw/plugins/RawEventHandler.js.map +1 -1
  42. package/registry.d.ts +2 -2
  43. package/registry.js +17 -38
  44. package/registry.js.map +1 -1
  45. package/s3/index.d.ts +3 -3
  46. package/s3/index.js +39 -76
  47. package/s3/index.js.map +1 -1
  48. package/s3/plugins/S3EventHandler.d.ts +4 -4
  49. package/s3/plugins/S3EventHandler.js +11 -18
  50. package/s3/plugins/S3EventHandler.js.map +1 -1
  51. package/s3/register.d.ts +1 -1
  52. package/s3/register.js +12 -22
  53. package/s3/register.js.map +1 -1
  54. package/sns/index.d.ts +3 -3
  55. package/sns/index.js +39 -76
  56. package/sns/index.js.map +1 -1
  57. package/sns/plugins/SNSEventHandler.d.ts +4 -4
  58. package/sns/plugins/SNSEventHandler.js +11 -18
  59. package/sns/plugins/SNSEventHandler.js.map +1 -1
  60. package/sns/register.js +12 -22
  61. package/sns/register.js.map +1 -1
  62. package/sourceHandler.d.ts +2 -2
  63. package/sourceHandler.js +2 -10
  64. package/sourceHandler.js.map +1 -1
  65. package/sqs/index.d.ts +3 -3
  66. package/sqs/index.js +40 -79
  67. package/sqs/index.js.map +1 -1
  68. package/sqs/plugins/SQSEventHandler.d.ts +4 -4
  69. package/sqs/plugins/SQSEventHandler.js +11 -18
  70. package/sqs/plugins/SQSEventHandler.js.map +1 -1
  71. package/sqs/register.js +13 -25
  72. package/sqs/register.js.map +1 -1
  73. package/types.d.ts +3 -3
  74. package/types.js +7 -34
  75. package/types.js.map +1 -1
  76. package/utils/composedHandler.d.ts +1 -1
  77. package/utils/composedHandler.js +6 -22
  78. package/utils/composedHandler.js.map +1 -1
  79. package/utils/index.d.ts +2 -2
  80. package/utils/index.js +2 -29
  81. package/utils/timer/CustomTimer.js +8 -14
  82. package/utils/timer/CustomTimer.js.map +1 -1
  83. package/utils/timer/Timer.d.ts +1 -1
  84. package/utils/timer/Timer.js +11 -19
  85. package/utils/timer/Timer.js.map +1 -1
  86. package/utils/timer/abstractions/ITimer.js +0 -7
  87. package/utils/timer/factory.d.ts +2 -2
  88. package/utils/timer/factory.js +9 -17
  89. package/utils/timer/factory.js.map +1 -1
  90. package/utils/timer/index.d.ts +4 -4
  91. package/utils/timer/index.js +3 -51
  92. package/index.js.map +0 -1
  93. package/plugins/handlerClient.d.ts +0 -2
  94. package/plugins/handlerClient.js +0 -53
  95. package/plugins/handlerClient.js.map +0 -1
  96. package/utils/index.js.map +0 -1
  97. package/utils/timer/abstractions/ITimer.js.map +0 -1
  98. package/utils/timer/index.js.map +0 -1
package/README.md CHANGED
@@ -1,15 +1,11 @@
1
1
  # @webiny/handler-aws
2
- [![](https://img.shields.io/npm/dw/@webiny/handler-aws.svg)](https://www.npmjs.com/package/@webiny/handler-aws)
3
- [![](https://img.shields.io/npm/v/@webiny/handler-aws.svg)](https://www.npmjs.com/package/@webiny/handler-aws)
4
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
5
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
6
-
7
- ## Install
8
- ```
9
- npm install --save @webiny/handler-aws
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._
@@ -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,29 +1,23 @@
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
- };
1
+ import { AsyncPluginsContainer } from "@webiny/plugins";
2
+ import { registry } from "./registry.js";
3
+ import { lambdaRequestTracker } from "pino-lambda";
4
+ const withRequest = lambdaRequestTracker();
5
+ const createHandler = ({ plugins, ...params })=>{
6
+ const pluginsContainer = new AsyncPluginsContainer(plugins);
7
+ return async (event, context = {})=>{
8
+ withRequest(event, context);
9
+ const plugins = await pluginsContainer.init();
10
+ const handler = registry.getHandler(event, context);
11
+ return handler.handle({
12
+ params: {
13
+ ...params,
14
+ plugins
15
+ },
16
+ event,
17
+ context
18
+ });
19
+ };
26
20
  };
27
- exports.createHandler = createHandler;
21
+ export { createHandler };
28
22
 
29
23
  //# sourceMappingURL=createHandler.js.map
@@ -1 +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":[]}
1
+ {"version":3,"file":"createHandler.js","sources":["../src/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"],"names":["withRequest","lambdaRequestTracker","createHandler","plugins","params","pluginsContainer","AsyncPluginsContainer","event","context","handler","registry"],"mappings":";;;AASA,MAAMA,cAAcC;AAEb,MAAMC,gBAAgC,CAAC,EAAEC,OAAO,EAAE,GAAGC,QAAQ;IAChE,MAAMC,mBAAmB,IAAIC,sBAAsBH;IAEnD,OAAO,OAAOI,OAAOC,UAAU,CAAC,CAAkB;QAC9CR,YAAYO,OAAOC;QAEnB,MAAML,UAAU,MAAME,iBAAiB,IAAI;QAC3C,MAAMI,UAAUC,SAAS,UAAU,CAACH,OAAOC;QAC3C,OAAOC,QAAQ,MAAM,CAAC;YAClB,QAAQ;gBACJ,GAAGL,MAAM;gBACTD;YACJ;YACAI;YACAC;QACJ;IACJ;AACJ"}
@@ -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,79 +1,42 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
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");
28
- /**
29
- * We need a class, not an interface exported from types.
30
- */
31
- // @ts-expect-error
32
-
1
+ import { createHandler } from "@webiny/handler";
2
+ import { registerDefaultPlugins } from "../plugins/index.js";
3
+ import { DynamoDBEventHandler } from "./plugins/DynamoDBEventHandler.js";
4
+ import lib_reply from "fastify/lib/reply.js";
5
+ import { execute } from "../execute.js";
6
+ import { createComposedHandler } from "../utils/composedHandler.js";
7
+ export * from "./plugins/DynamoDBEventHandler.js";
33
8
  const url = "/webiny-dynamodb-event";
34
- const createHandler = params => {
35
- return (payload, context) => {
36
- const app = (0, _handler.createHandler)({
37
- ...params,
38
- options: {
39
- logger: params.debug === true,
40
- ...(params.options || {})
41
- }
42
- });
43
- /**
44
- * We always must add our default plugins to the app.
45
- */
46
- (0, _plugins.registerDefaultPlugins)(app.webiny);
47
- /**
48
- * There must be an event plugin for this handler to work.
49
- */
50
- const plugins = app.webiny.plugins.byType(_DynamoDBEventHandler.DynamoDBEventHandler.type).reverse();
51
- if (plugins.length === 0) {
52
- throw new Error(`To run @webiny/handler-aws/dynamodb, you must have DynamoDBHandler set.`);
53
- }
54
- const handler = (0, _composedHandler.createComposedHandler)(plugins);
55
- app.post(url, async (request, reply) => {
56
- const params = {
57
- request,
58
- context: app.webiny,
59
- event: payload,
60
- lambdaContext: context,
61
- reply
62
- };
63
- const result = await handler(params);
64
- if (result instanceof _reply.default) {
65
- return result;
66
- }
67
- app.__webiny_raw_result = result;
68
- return reply.send({});
69
- });
70
- return (0, _execute.execute)({
71
- app,
72
- url,
73
- payload
74
- });
75
- };
76
- };
77
- exports.createHandler = createHandler;
9
+ const dynamodb_createHandler = (params)=>(payload, context)=>{
10
+ const app = createHandler({
11
+ ...params,
12
+ options: {
13
+ logger: true === params.debug,
14
+ ...params.options || {}
15
+ }
16
+ });
17
+ registerDefaultPlugins(app.webiny);
18
+ const plugins = app.webiny.plugins.byType(DynamoDBEventHandler.type).reverse();
19
+ if (0 === plugins.length) throw new Error("To run @webiny/handler-aws/dynamodb, you must have DynamoDBHandler set.");
20
+ const handler = createComposedHandler(plugins);
21
+ app.post(url, async (request, reply)=>{
22
+ const params = {
23
+ request,
24
+ context: app.webiny,
25
+ event: payload,
26
+ lambdaContext: context,
27
+ reply
28
+ };
29
+ const result = await handler(params);
30
+ if (result instanceof lib_reply) return result;
31
+ app.__webiny_raw_result = result;
32
+ return reply.send({});
33
+ });
34
+ return execute({
35
+ app,
36
+ url: url,
37
+ payload
38
+ });
39
+ };
40
+ export { dynamodb_createHandler as createHandler };
78
41
 
79
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"dynamodb/index.js","sources":["../../src/dynamodb/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"],"names":["url","createHandler","params","payload","context","app","createBaseHandler","registerDefaultPlugins","plugins","DynamoDBEventHandler","Error","handler","createComposedHandler","request","reply","result","Reply","execute"],"mappings":";;;;;;;AAoBA,MAAMA,MAAM;AAQL,MAAMC,yBAAgB,CAACC,SACnB,CAACC,SAASC;QACb,MAAMC,MAAMC,cAAkB;YAC1B,GAAGJ,MAAM;YACT,SAAS;gBACL,QAAQA,AAAiB,SAAjBA,OAAO,KAAK;gBACpB,GAAIA,OAAO,OAAO,IAAI,CAAC,CAAC;YAC5B;QACJ;QAIAK,uBAAuBF,IAAI,MAAM;QAIjC,MAAMG,UAAUH,IAAI,MAAM,CAAC,OAAO,CAC7B,MAAM,CAAuBI,qBAAqB,IAAI,EACtD,OAAO;QACZ,IAAID,AAAmB,MAAnBA,QAAQ,MAAM,EACd,MAAM,IAAIE,MACN;QAIR,MAAMC,UAAUC,sBAIdJ;QAEFH,IAAI,IAAI,CAACL,KAAK,OAAOa,SAASC;YAC1B,MAAMZ,SAGF;gBACAW;gBACA,SAASR,IAAI,MAAM;gBACnB,OAAOF;gBACP,eAAeC;gBACfU;YACJ;YACA,MAAMC,SAAS,MAAMJ,QACjBT;YAGJ,IAAIa,kBAAkBC,WAClB,OAAOD;YAGXV,IAAI,mBAAmB,GAAGU;YAC1B,OAAOD,MAAM,IAAI,CAAC,CAAC;QACvB;QACA,OAAOG,QAAQ;YACXZ;YACAL,KAAAA;YACAG;QACJ;IACJ"}
@@ -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: <Response_1>(cb: DynamoDBEventHandlerCallable<Response_1>) => DynamoDBEventHandler<Response_1>;
20
+ export declare const createEventHandler: <Response>(cb: DynamoDBEventHandlerCallable<Response>) => DynamoDBEventHandler<Response>;
@@ -1,21 +1,14 @@
1
- "use strict";
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 {
9
- static type = "handler.fastify.aws.dynamodb.eventHandler";
10
- constructor(cb) {
11
- super();
12
- this.cb = cb;
13
- }
1
+ import { Plugin } from "@webiny/plugins/Plugin.js";
2
+ class DynamoDBEventHandler extends Plugin {
3
+ static{
4
+ this.type = "handler.fastify.aws.dynamodb.eventHandler";
5
+ }
6
+ constructor(cb){
7
+ super();
8
+ this.cb = cb;
9
+ }
14
10
  }
15
- exports.DynamoDBEventHandler = DynamoDBEventHandler;
16
- const createEventHandler = cb => {
17
- return new DynamoDBEventHandler(cb);
18
- };
19
- exports.createEventHandler = createEventHandler;
11
+ const createEventHandler = (cb)=>new DynamoDBEventHandler(cb);
12
+ export { DynamoDBEventHandler, createEventHandler };
20
13
 
21
14
  //# sourceMappingURL=DynamoDBEventHandler.js.map
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"file":"dynamodb/plugins/DynamoDBEventHandler.js","sources":["../../../src/dynamodb/plugins/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"],"names":["DynamoDBEventHandler","Plugin","cb","createEventHandler"],"mappings":";AAiBO,MAAMA,6BAA6CC;;aAC/B,IAAI,GAAG;;IAI9B,YAAmBC,EAA0C,CAAE;QAC3D,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;AACJ;AAEO,MAAMC,qBAAqB,CAAWD,KAClC,IAAIF,qBAA+BE"}
@@ -1,28 +1,16 @@
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
- }
1
+ import { registry } from "../registry.js";
2
+ import { createSourceHandler } from "../sourceHandler.js";
3
+ import { createHandler } from "./index.js";
4
+ const handler = createSourceHandler({
5
+ name: "handler-aws-dynamodb-stream",
6
+ canUse: (event)=>{
7
+ if (!Array.isArray(event.Records) || 0 === event.Records.length) return false;
8
+ const [record] = event.Records;
9
+ if ("string" != typeof record.eventSource) return false;
10
+ return "aws:dynamodb" === record.eventSource.toLowerCase();
11
+ },
12
+ handle: async ({ params, event, context })=>createHandler(params)(event, context)
25
13
  });
26
- _registry.registry.register(handler);
14
+ registry.register(handler);
27
15
 
28
16
  //# sourceMappingURL=register.js.map
@@ -1 +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":[]}
1
+ {"version":3,"file":"dynamodb/register.js","sources":["../../src/dynamodb/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"],"names":["handler","createSourceHandler","event","Array","record","params","context","createHandler","registry"],"mappings":";;;AAMA,MAAMA,UAAUC,oBAAwD;IACpE,MAAM;IACN,QAAQC,CAAAA;QACJ,IAAI,CAACC,MAAM,OAAO,CAACD,MAAM,OAAO,KAAKA,AAAyB,MAAzBA,MAAM,OAAO,CAAC,MAAM,EACrD,OAAO;QAEX,MAAM,CAACE,OAAO,GAAGF,MAAM,OAAO;QAC9B,IAAI,AAA8B,YAA9B,OAAOE,OAAO,WAAW,EACzB,OAAO;QAEX,OAAOA,AAAqC,mBAArCA,OAAO,WAAW,CAAC,WAAW;IACzC;IACA,QAAQ,OAAO,EAAEC,MAAM,EAAEH,KAAK,EAAEI,OAAO,EAAE,GAC9BC,cAAcF,QAAQH,OAAOI;AAE5C;AAEAE,SAAS,QAAQ,CAACR"}
@@ -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>;
@@ -1,79 +1,42 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
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 _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");
28
- /**
29
- * We need a class, not an interface exported from types.
30
- */
31
- // @ts-expect-error
32
-
1
+ import { createHandler } from "@webiny/handler";
2
+ import { registerDefaultPlugins } from "../plugins/index.js";
3
+ import { EventBridgeEventHandler } from "./plugins/EventBridgeEventHandler.js";
4
+ import { execute } from "../execute.js";
5
+ import lib_reply from "fastify/lib/reply.js";
6
+ import { createComposedHandler } from "../utils/composedHandler.js";
7
+ export * from "./plugins/EventBridgeEventHandler.js";
33
8
  const url = "/webiny-eventBridge-event";
34
- const createHandler = params => {
35
- return (payload, context) => {
36
- const app = (0, _handler.createHandler)({
37
- ...params,
38
- options: {
39
- logger: params.debug === true,
40
- ...(params.options || {})
41
- }
42
- });
43
- /**
44
- * We always must add our default plugins to the app.
45
- */
46
- (0, _plugins.registerDefaultPlugins)(app.webiny);
47
- /**
48
- * There must be an event plugin for this handler to work.
49
- */
50
- const plugins = app.webiny.plugins.byType(_EventBridgeEventHandler.EventBridgeEventHandler.type).reverse();
51
- if (plugins.length === 0) {
52
- throw new Error(`To run @webiny/handler-aws/eventBridge, you must have EventBridgeEventHandler set.`);
53
- }
54
- const handler = (0, _composedHandler.createComposedHandler)(plugins);
55
- app.post(url, async (request, reply) => {
56
- const params = {
57
- request,
58
- reply,
59
- context: app.webiny,
60
- payload,
61
- lambdaContext: context
62
- };
63
- const result = await handler(params);
64
- if (result instanceof _reply.default) {
65
- return result;
66
- }
67
- app.__webiny_raw_result = result;
68
- return reply.send({});
69
- });
70
- return (0, _execute.execute)({
71
- app,
72
- url,
73
- payload
74
- });
75
- };
76
- };
77
- exports.createHandler = createHandler;
9
+ const eventBridge_createHandler = (params)=>(payload, context)=>{
10
+ const app = createHandler({
11
+ ...params,
12
+ options: {
13
+ logger: true === params.debug,
14
+ ...params.options || {}
15
+ }
16
+ });
17
+ registerDefaultPlugins(app.webiny);
18
+ const plugins = app.webiny.plugins.byType(EventBridgeEventHandler.type).reverse();
19
+ if (0 === plugins.length) throw new Error("To run @webiny/handler-aws/eventBridge, you must have EventBridgeEventHandler set.");
20
+ const handler = createComposedHandler(plugins);
21
+ app.post(url, async (request, reply)=>{
22
+ const params = {
23
+ request,
24
+ reply,
25
+ context: app.webiny,
26
+ payload,
27
+ lambdaContext: context
28
+ };
29
+ const result = await handler(params);
30
+ if (result instanceof lib_reply) return result;
31
+ app.__webiny_raw_result = result;
32
+ return reply.send({});
33
+ });
34
+ return execute({
35
+ app,
36
+ url: url,
37
+ payload
38
+ });
39
+ };
40
+ export { eventBridge_createHandler as createHandler };
78
41
 
79
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"eventBridge/index.js","sources":["../../src/eventBridge/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"],"names":["url","createHandler","params","payload","context","app","createBaseHandler","registerDefaultPlugins","plugins","EventBridgeEventHandler","Error","handler","createComposedHandler","request","reply","result","Reply","execute"],"mappings":";;;;;;;AA6BA,MAAMA,MAAM;AAEL,MAAMC,4BAAgB,CAACC,SACnB,CAACC,SAASC;QACb,MAAMC,MAAMC,cAAkB;YAC1B,GAAGJ,MAAM;YACT,SAAS;gBACL,QAAQA,AAAiB,SAAjBA,OAAO,KAAK;gBACpB,GAAIA,OAAO,OAAO,IAAI,CAAC,CAAC;YAC5B;QACJ;QAIAK,uBAAuBF,IAAI,MAAM;QAIjC,MAAMG,UAAUH,IAAI,MAAM,CAAC,OAAO,CAC7B,MAAM,CAA0CI,wBAAwB,IAAI,EAC5E,OAAO;QACZ,IAAID,AAAmB,MAAnBA,QAAQ,MAAM,EACd,MAAM,IAAIE,MACN;QAIR,MAAMC,UAAUC,sBAIdJ;QAEFH,IAAI,IAAI,CAACL,KAAK,OAAOa,SAASC;YAC1B,MAAMZ,SAGF;gBACAW;gBACAC;gBACA,SAAST,IAAI,MAAM;gBACnBF;gBACA,eAAeC;YACnB;YACA,MAAMW,SAAS,MAAMJ,QACjBT;YAOJ,IAAIa,kBAAkBC,WAClB,OAAOD;YAGXV,IAAI,mBAAmB,GAAGU;YAC1B,OAAOD,MAAM,IAAI,CAAC,CAAC;QACvB;QACA,OAAOG,QAAQ;YACXZ;YACAL,KAAAA;YACAG;QACJ;IACJ"}
@@ -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, Response_1 = any>(cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response_1>) => EventBridgeEventHandler<DetailType, Detail, Response_1>;
20
+ export declare const createEventHandler: <DetailType extends string, Detail, Response = any>(cb: EventBridgeEventHandlerCallable<DetailType, Detail, Response>) => EventBridgeEventHandler<DetailType, Detail, Response>;
@@ -1,21 +1,14 @@
1
- "use strict";
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 {
9
- static type = "handler.fastify.aws.eventBridge.eventHandler";
10
- constructor(cb) {
11
- super();
12
- this.cb = cb;
13
- }
1
+ import { Plugin } from "@webiny/plugins/Plugin.js";
2
+ class EventBridgeEventHandler extends Plugin {
3
+ static{
4
+ this.type = "handler.fastify.aws.eventBridge.eventHandler";
5
+ }
6
+ constructor(cb){
7
+ super();
8
+ this.cb = cb;
9
+ }
14
10
  }
15
- exports.EventBridgeEventHandler = EventBridgeEventHandler;
16
- const createEventHandler = cb => {
17
- return new EventBridgeEventHandler(cb);
18
- };
19
- exports.createEventHandler = createEventHandler;
11
+ const createEventHandler = (cb)=>new EventBridgeEventHandler(cb);
12
+ export { EventBridgeEventHandler, createEventHandler };
20
13
 
21
14
  //# sourceMappingURL=EventBridgeEventHandler.js.map
@@ -1 +1 @@
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":[]}
1
+ {"version":3,"file":"eventBridge/plugins/EventBridgeEventHandler.js","sources":["../../../src/eventBridge/plugins/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"],"names":["EventBridgeEventHandler","Plugin","cb","createEventHandler"],"mappings":";AA0BO,MAAMA,gCAIHC;;aACiB,IAAI,GAAG;;IAI9B,YAAmBC,EAAiE,CAAE;QAClF,KAAK;QACL,IAAI,CAAC,EAAE,GAAGA;IACd;AACJ;AAEO,MAAMC,qBAAqB,CAC9BD,KAEO,IAAIF,wBAAsDE"}