@webiny/handler-aws 6.0.0-alpha.0 → 6.0.0-alpha.2

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 (48) hide show
  1. package/createHandler.d.ts +1 -1
  2. package/createHandler.js.map +1 -1
  3. package/dynamodb/index.js.map +1 -1
  4. package/dynamodb/plugins/DynamoDBEventHandler.d.ts +1 -1
  5. package/dynamodb/plugins/DynamoDBEventHandler.js.map +1 -1
  6. package/dynamodb/register.js.map +1 -1
  7. package/eventBridge/index.js.map +1 -1
  8. package/eventBridge/plugins/EventBridgeEventHandler.d.ts +1 -1
  9. package/eventBridge/plugins/EventBridgeEventHandler.js.map +1 -1
  10. package/eventBridge/register.d.ts +1 -1
  11. package/eventBridge/register.js.map +1 -1
  12. package/gateway/index.d.ts +1 -1
  13. package/gateway/index.js.map +1 -1
  14. package/gateway/register.js.map +1 -1
  15. package/package.json +9 -9
  16. package/plugins/index.d.ts +1 -1
  17. package/plugins/index.js.map +1 -1
  18. package/raw/index.d.ts +1 -1
  19. package/raw/index.js +10 -1
  20. package/raw/index.js.map +1 -1
  21. package/raw/plugins/RawEventHandler.d.ts +15 -4
  22. package/raw/plugins/RawEventHandler.js +14 -3
  23. package/raw/plugins/RawEventHandler.js.map +1 -1
  24. package/registry.d.ts +2 -2
  25. package/registry.js.map +1 -1
  26. package/s3/index.js.map +1 -1
  27. package/s3/plugins/S3EventHandler.d.ts +1 -1
  28. package/s3/plugins/S3EventHandler.js.map +1 -1
  29. package/s3/register.d.ts +1 -1
  30. package/s3/register.js.map +1 -1
  31. package/sns/index.js.map +1 -1
  32. package/sns/plugins/SNSEventHandler.d.ts +1 -1
  33. package/sns/plugins/SNSEventHandler.js.map +1 -1
  34. package/sns/register.js.map +1 -1
  35. package/sourceHandler.d.ts +1 -1
  36. package/sourceHandler.js.map +1 -1
  37. package/sqs/index.d.ts +2 -2
  38. package/sqs/index.js +4 -1
  39. package/sqs/index.js.map +1 -1
  40. package/sqs/plugins/SQSEventHandler.d.ts +1 -1
  41. package/sqs/plugins/SQSEventHandler.js.map +1 -1
  42. package/sqs/register.js.map +1 -1
  43. package/types.d.ts +3 -5
  44. package/types.js.map +1 -1
  45. package/utils/composedHandler.d.ts +1 -1
  46. package/utils/composedHandler.js.map +1 -1
  47. package/utils/timer/Timer.d.ts +1 -1
  48. package/utils/timer/Timer.js.map +1 -1
@@ -1,2 +1,2 @@
1
- import { HandlerFactory } from "./types";
1
+ import type { HandlerFactory } from "./types";
2
2
  export declare const createHandler: HandlerFactory;
@@ -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 { 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,"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 +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 {\n DynamoDBEventHandler,\n DynamoDBEventHandlerCallableParams\n} 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;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAYAG,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,"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,5 +1,5 @@
1
1
  import { Plugin } from "@webiny/plugins/Plugin";
2
- import { Context, Reply, Request } from "@webiny/handler/types";
2
+ import type { Context, Reply, Request } from "@webiny/handler/types";
3
3
  import type { Context as LambdaContext, DynamoDBStreamEvent } from "@webiny/aws-sdk/types";
4
4
  export interface DynamoDBEventHandlerCallableParams<Response = Reply> {
5
5
  request: Request;
@@ -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 { 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,"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 +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 { createHandler, HandlerParams } 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;AACA,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,"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 +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 {\n EventBridgeEventHandler,\n EventBridgeEventHandlerCallableParams\n} 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;AACA,IAAAE,wBAAA,GAAAF,OAAA;AAkBAG,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,MAA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AS,aAAA,GAAAA,aAAA","ignoreList":[]}
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,O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-1,6 +1,6 @@
1
1
  import type { Context as LambdaContext, EventBridgeEvent } from "@webiny/aws-sdk/types";
2
2
  import { Plugin } from "@webiny/plugins/Plugin";
3
- import { Context, Reply, Request } from "@webiny/handler/types";
3
+ import type { Context, Reply, Request } from "@webiny/handler/types";
4
4
  export interface EventBridgeEventHandlerCallableParams<DetailType extends string, Detail, Response = Reply> {
5
5
  request: Request;
6
6
  reply: Reply;
@@ -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 { 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,"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,4 +1,4 @@
1
- import { HandlerFactoryParams } from "../types";
1
+ import type { HandlerFactoryParams } from "../types";
2
2
  export interface HandlerParams extends HandlerFactoryParams {
3
3
  debug?: boolean;
4
4
  }
@@ -1 +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 { 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":[]}
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":[]}
@@ -1,5 +1,5 @@
1
1
  import type { APIGatewayEvent, Context as LambdaContext } from "@webiny/aws-sdk/types";
2
- import { LambdaResponse } from "@fastify/aws-lambda";
2
+ import type { LambdaResponse } from "@fastify/aws-lambda";
3
3
  import { createRoute, RoutePlugin } from "@webiny/handler";
4
4
  import type { HandlerFactoryParams } from "../types";
5
5
  export { RoutePlugin, createRoute };
@@ -1 +1 @@
1
- {"version":3,"names":["_awsLambda","_interopRequireDefault","require","_handler","_plugins","_types","getHeader","headers","header","key","toLowerCase","undefined","defaultContentType","defaultCharset","attachRequiredProperties","event","contentType","join","body","startsWith","createHandler","params","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","RoutePlugin","type","length","Error","appLambda","awsLambdaFastify","decorateRequest","serializeLambdaArguments","decorationPropertyName","enforceBase64","response","Base64EncodeHeader","encoded","binary","lambdaOptions","exports"],"sources":["index.ts"],"sourcesContent":["import type {\n APIGatewayEvent,\n APIGatewayProxyEventHeaders,\n Context as LambdaContext\n} from \"@webiny/aws-sdk/types\";\nimport awsLambdaFastify, { LambdaResponse } from \"@fastify/aws-lambda\";\nimport { createHandler as createBaseHandler, createRoute, RoutePlugin } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport type { HandlerFactoryParams } from \"~/types\";\nimport { Base64EncodeHeader } from \"~/types\";\n\nexport { RoutePlugin, createRoute };\n\nexport type HandlerParams = HandlerFactoryParams;\n\nexport interface HandlerCallable {\n (event: APIGatewayEvent, ctx: LambdaContext): Promise<LambdaResponse>;\n}\n\nconst getHeader = (headers: APIGatewayProxyEventHeaders, header: string): string | undefined => {\n for (const key in headers) {\n if (key.toLowerCase() !== header) {\n continue;\n }\n return headers[key];\n }\n return undefined;\n};\n\nconst defaultContentType = \"application/json\";\nconst defaultCharset = \"utf-8\";\n/**\n * We need to attach default headers to the request, so it does not break if there is none sent.\n */\nconst attachRequiredProperties = (event: APIGatewayEvent): void => {\n /**\n * A possibility that headers are not defined?\n * Maybe during testing?\n */\n if (!event.headers) {\n event.headers = {};\n }\n const contentType = getHeader(event.headers, \"content-type\");\n /**\n * We check the existing content type and add the default one if it does not exist.\n *\n * Also, if the content-type is the application/json, and the body is not sent, we add it.\n */\n if (!contentType) {\n event.headers[\"content-type\"] = [defaultContentType, `charset=${defaultCharset}`].join(\";\");\n event.body = \"{}\";\n } else if (!event.body && contentType.startsWith(defaultContentType)) {\n event.body = \"{}\";\n }\n};\n\nexport const createHandler = (params: HandlerParams): HandlerCallable => {\n return async (event, 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 if (app.webiny.plugins.byType<RoutePlugin>(RoutePlugin.type).length === 0) {\n throw new Error(\n `To run @webiny/handler-aws/gateway, you must have at least one RoutePlugin set.`\n );\n }\n attachRequiredProperties(event);\n\n const appLambda = awsLambdaFastify(app, {\n decorateRequest: true,\n serializeLambdaArguments: true,\n decorationPropertyName: \"awsLambda\",\n enforceBase64: response => {\n return (\n !!response.headers[Base64EncodeHeader.encoded] ||\n !!response.headers[Base64EncodeHeader.binary]\n );\n },\n ...(params.lambdaOptions || {})\n });\n return appLambda(event, context);\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,MAAA,GAAAH,OAAA;AAUA,MAAMI,SAAS,GAAGA,CAACC,OAAoC,EAAEC,MAAc,KAAyB;EAC5F,KAAK,MAAMC,GAAG,IAAIF,OAAO,EAAE;IACvB,IAAIE,GAAG,CAACC,WAAW,CAAC,CAAC,KAAKF,MAAM,EAAE;MAC9B;IACJ;IACA,OAAOD,OAAO,CAACE,GAAG,CAAC;EACvB;EACA,OAAOE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;IACArB,wBAAwB,CAACC,KAAK,CAAC;IAE/B,MAAMqB,SAAS,GAAG,IAAAC,kBAAgB,EAACd,GAAG,EAAE;MACpCe,eAAe,EAAE,IAAI;MACrBC,wBAAwB,EAAE,IAAI;MAC9BC,sBAAsB,EAAE,WAAW;MACnCC,aAAa,EAAEC,QAAQ,IAAI;QACvB,OACI,CAAC,CAACA,QAAQ,CAACnC,OAAO,CAACoC,yBAAkB,CAACC,OAAO,CAAC,IAC9C,CAAC,CAACF,QAAQ,CAACnC,OAAO,CAACoC,yBAAkB,CAACE,MAAM,CAAC;MAErD,CAAC;MACD,IAAIxB,MAAM,CAACyB,aAAa,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC;IACF,OAAOV,SAAS,CAACrB,KAAK,EAAEO,OAAO,CAAC;EACpC,CAAC;AACL,CAAC;AAACyB,OAAA,CAAA3B,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_awsLambda","_interopRequireDefault","require","_handler","_plugins","_types","getHeader","headers","header","key","toLowerCase","undefined","defaultContentType","defaultCharset","attachRequiredProperties","event","contentType","join","body","startsWith","createHandler","params","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","RoutePlugin","type","length","Error","appLambda","awsLambdaFastify","decorateRequest","serializeLambdaArguments","decorationPropertyName","enforceBase64","response","Base64EncodeHeader","encoded","binary","lambdaOptions","exports"],"sources":["index.ts"],"sourcesContent":["import type {\n APIGatewayEvent,\n APIGatewayProxyEventHeaders,\n Context as LambdaContext\n} from \"@webiny/aws-sdk/types\";\nimport type { LambdaResponse } from \"@fastify/aws-lambda\";\nimport awsLambdaFastify from \"@fastify/aws-lambda\";\nimport { createHandler as createBaseHandler, createRoute, RoutePlugin } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport type { HandlerFactoryParams } from \"~/types\";\nimport { Base64EncodeHeader } from \"~/types\";\n\nexport { RoutePlugin, createRoute };\n\nexport type HandlerParams = HandlerFactoryParams;\n\nexport interface HandlerCallable {\n (event: APIGatewayEvent, ctx: LambdaContext): Promise<LambdaResponse>;\n}\n\nconst getHeader = (headers: APIGatewayProxyEventHeaders, header: string): string | undefined => {\n for (const key in headers) {\n if (key.toLowerCase() !== header) {\n continue;\n }\n return headers[key];\n }\n return undefined;\n};\n\nconst defaultContentType = \"application/json\";\nconst defaultCharset = \"utf-8\";\n/**\n * We need to attach default headers to the request, so it does not break if there is none sent.\n */\nconst attachRequiredProperties = (event: APIGatewayEvent): void => {\n /**\n * A possibility that headers are not defined?\n * Maybe during testing?\n */\n if (!event.headers) {\n event.headers = {};\n }\n const contentType = getHeader(event.headers, \"content-type\");\n /**\n * We check the existing content type and add the default one if it does not exist.\n *\n * Also, if the content-type is the application/json, and the body is not sent, we add it.\n */\n if (!contentType) {\n event.headers[\"content-type\"] = [defaultContentType, `charset=${defaultCharset}`].join(\";\");\n event.body = \"{}\";\n } else if (!event.body && contentType.startsWith(defaultContentType)) {\n event.body = \"{}\";\n }\n};\n\nexport const createHandler = (params: HandlerParams): HandlerCallable => {\n return async (event, 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 if (app.webiny.plugins.byType<RoutePlugin>(RoutePlugin.type).length === 0) {\n throw new Error(\n `To run @webiny/handler-aws/gateway, you must have at least one RoutePlugin set.`\n );\n }\n attachRequiredProperties(event);\n\n const appLambda = awsLambdaFastify(app, {\n decorateRequest: true,\n serializeLambdaArguments: true,\n decorationPropertyName: \"awsLambda\",\n enforceBase64: response => {\n return (\n !!response.headers[Base64EncodeHeader.encoded] ||\n !!response.headers[Base64EncodeHeader.binary]\n );\n },\n ...(params.lambdaOptions || {})\n });\n return appLambda(event, context);\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QA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K,IAAI;QAC7B,IAAIN,MAAM,CAACI,OAAO,IAAI,CAAC,CAAC;MAC5B;IACJ,CAAC,CAAC;IACF;AACR;AACA;IACQ,IAAAG,+BAAsB,EAACL,GAAG,CAACM,MAAM,CAAC;IAElC,IAAIN,GAAG,CAACM,MAAM,CAACC,OAAO,CAACC,MAAM,CAAcC,oBAAW,CAACC,IAAI,CAAC,CAACC,MAAM,KAAK,CAAC,EAAE;MACvE,MAAM,IAAIC,KAAK,CACX,iFACJ,CAAC;IACL;IACArB,wBAAwB,CAACC,KAAK,CAAC;IAE/B,MAAMqB,SAAS,GAAG,IAAAC,kBAAgB,EAACd,GAAG,EAAE;MACpCe,eAAe,EAAE,IAAI;MACrBC,wBAAwB,EAAE,IAAI;MAC9BC,sBAAsB,EAAE,WAAW;MACnCC,aAAa,EAAEC,QAAQ,IAAI;QACvB,OACI,CAAC,CAACA,QAAQ,CAACnC,OAAO,CAACoC,yBAAkB,CAACC,OAAO,CAAC,IAC9C,CAAC,CAACF,QAAQ,CAACnC,OAAO,CAACoC,yBAAkB,CAACE,MAAM,CAAC;MAErD,CAAC;MACD,IAAIxB,MAAM,CAACyB,aAAa,IAAI,CAAC,CAAC;IAClC,CAAC,CAAC;IACF,OAAOV,SAAS,CAACrB,KAAK,EAAEO,OAAO,CAAC;EACpC,CAAC;AACL,CAAC;AAACyB,OAAA,CAAA3B,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_registry","require","_sourceHandler","_index","handler","createSourceHandler","name","canUse","event","httpMethod","handle","params","context","createHandler","registry","register"],"sources":["register.ts"],"sourcesContent":["import type { APIGatewayEvent } from \"@webiny/aws-sdk/types\";\nimport { registry } from \"~/registry\";\nimport { createSourceHandler } from \"~/sourceHandler\";\nimport { createHandler, HandlerParams } from \"./index\";\n\nconst handler = createSourceHandler<APIGatewayEvent, HandlerParams>({\n name: \"handler-aws-api-gateway\",\n canUse: event => {\n return !!event.httpMethod;\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;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,MAAMG,OAAO,GAAG,IAAAC,kCAAmB,EAAiC;EAChEC,IAAI,EAAE,yBAAyB;EAC/BC,MAAM,EAAEC,KAAK,IAAI;IACb,OAAO,CAAC,CAACA,KAAK,CAACC,UAAU;EAC7B,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":[]}
1
+ {"version":3,"names":["_registry","require","_sourceHandler","_index","handler","createSourceHandler","name","canUse","event","httpMethod","handle","params","context","createHandler","registry","register"],"sources":["register.ts"],"sourcesContent":["import type { APIGatewayEvent } from \"@webiny/aws-sdk/types\";\nimport { registry } from \"~/registry\";\nimport { createSourceHandler } from \"~/sourceHandler\";\nimport type { HandlerParams } from \"./index\";\nimport { createHandler } from \"./index\";\n\nconst handler = createSourceHandler<APIGatewayEvent, HandlerParams>({\n name: \"handler-aws-api-gateway\",\n canUse: event => {\n return !!event.httpMethod;\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;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAEA,MAAMG,OAAO,GAAG,IAAAC,kCAAmB,EAAiC;EAChEC,IAAI,EAAE,yBAAyB;EAC/BC,MAAM,EAAEC,KAAK,IAAI;IACb,OAAO,CAAC,CAACA,KAAK,CAACC,UAAU;EAC7B,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/handler-aws",
3
- "version": "6.0.0-alpha.0",
3
+ "version": "6.0.0-alpha.2",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,15 +13,15 @@
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
15
  "@fastify/aws-lambda": "4.1.0",
16
- "@webiny/aws-sdk": "6.0.0-alpha.0",
17
- "@webiny/handler": "6.0.0-alpha.0",
18
- "@webiny/handler-client": "6.0.0-alpha.0",
19
- "@webiny/plugins": "6.0.0-alpha.0",
20
- "@webiny/utils": "6.0.0-alpha.0",
21
- "fastify": "4.29.0"
16
+ "@webiny/aws-sdk": "6.0.0-alpha.2",
17
+ "@webiny/handler": "6.0.0-alpha.2",
18
+ "@webiny/handler-client": "6.0.0-alpha.2",
19
+ "@webiny/plugins": "6.0.0-alpha.2",
20
+ "@webiny/utils": "6.0.0-alpha.2",
21
+ "fastify": "4.29.1"
22
22
  },
23
23
  "devDependencies": {
24
- "@webiny/project-utils": "6.0.0-alpha.0",
24
+ "@webiny/project-utils": "6.0.0-alpha.2",
25
25
  "rimraf": "6.0.1",
26
26
  "typescript": "5.3.3"
27
27
  },
@@ -33,5 +33,5 @@
33
33
  "build": "node ../cli/bin.js run build",
34
34
  "watch": "node ../cli/bin.js run watch"
35
35
  },
36
- "gitHead": "a5b28fed7a242d8f56712197a8ea83aa6d2ed101"
36
+ "gitHead": "7c9e8fbfd62a57ece5f880dbad6c864636b0355e"
37
37
  }
@@ -1,2 +1,2 @@
1
- import { Context } from "@webiny/handler/types";
1
+ import type { Context } from "@webiny/handler/types";
2
2
  export declare const registerDefaultPlugins: (context: Context) => void;
@@ -1 +1 @@
1
- {"version":3,"names":["_handlerClient","require","registerDefaultPlugins","context","plugins","register","createHandlerClientPlugin","exports"],"sources":["index.ts"],"sourcesContent":["import { createHandlerClientPlugin } from \"./handlerClient\";\nimport { Context } from \"@webiny/handler/types\";\n\nexport const registerDefaultPlugins = (context: Context): void => {\n context.plugins.register([createHandlerClientPlugin()]);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAGO,MAAMC,sBAAsB,GAAIC,OAAgB,IAAW;EAC9DA,OAAO,CAACC,OAAO,CAACC,QAAQ,CAAC,CAAC,IAAAC,wCAAyB,EAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAACC,OAAA,CAAAL,sBAAA,GAAAA,sBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_handlerClient","require","registerDefaultPlugins","context","plugins","register","createHandlerClientPlugin","exports"],"sources":["index.ts"],"sourcesContent":["import { createHandlerClientPlugin } from \"./handlerClient\";\nimport type { Context } from \"@webiny/handler/types\";\n\nexport const registerDefaultPlugins = (context: Context): void => {\n context.plugins.register([createHandlerClientPlugin()]);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAGO,MAAMC,sBAAsB,GAAIC,OAAgB,IAAW;EAC9DA,OAAO,CAACC,OAAO,CAACC,QAAQ,CAAC,CAAC,IAAAC,wCAAyB,EAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAACC,OAAA,CAAAL,sBAAA,GAAAA,sBAAA","ignoreList":[]}
package/raw/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * We should try to have some kind of standardized event type implementation at some point.
6
6
  */
7
7
  import type { APIGatewayProxyResult, Context as LambdaContext } from "@webiny/aws-sdk/types";
8
- import { CreateHandlerParams as BaseCreateHandlerParams } from "@webiny/handler";
8
+ import type { CreateHandlerParams as BaseCreateHandlerParams } from "@webiny/handler";
9
9
  export interface HandlerCallable<Payload, Response = APIGatewayProxyResult> {
10
10
  (payload: Payload, context: LambdaContext): Promise<Response>;
11
11
  }
package/raw/index.js CHANGED
@@ -48,7 +48,16 @@ const createHandler = params => {
48
48
  /**
49
49
  * There must be an event plugin for this handler to work.
50
50
  */
51
- const plugins = app.webiny.plugins.byType(_RawEventHandler.RawEventHandler.type).reverse();
51
+ const plugins = app.webiny.plugins.byType(_RawEventHandler.RawEventHandler.type).filter(plugin => {
52
+ /**
53
+ * Just in case check that the plugin contains canHandle method.
54
+ * If it does not, we assume it can handle any payload.
55
+ */
56
+ if (typeof plugin.canHandle !== "function") {
57
+ return true;
58
+ }
59
+ return plugin.canHandle(payload);
60
+ }).reverse();
52
61
  if (plugins.length === 0) {
53
62
  throw new Error(`To run @webiny/handler-aws/raw, you must have RawEventHandler set.`);
54
63
  }
package/raw/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_handler","require","_RawEventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_plugins","_execute","_composedHandler","Reply","url","createHandler","params","payload","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","RawEventHandler","type","reverse","length","Error","handler","createComposedHandler","post","request","reply","lambdaContext","result","__webiny_raw_result","send","execute"],"sources":["index.ts"],"sourcesContent":["/**\n * This is the handler implementation for @webiny/handler/plugins/EventPlugin.\n * This is mostly meant for some custom lambda calls as we are sometimes invoking lambdas directly.\n *\n * We should try to have some kind of standardized event type implementation at some point.\n */\nimport type { APIGatewayProxyResult, Context as LambdaContext } from \"@webiny/aws-sdk/types\";\nimport {\n createHandler as createBaseHandler,\n CreateHandlerParams as BaseCreateHandlerParams\n} from \"@webiny/handler\";\nimport { RawEventHandler } from \"~/raw/plugins/RawEventHandler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport { execute } from \"~/execute\";\nimport { createComposedHandler } from \"~/utils/composedHandler\";\nimport { Context, Request } from \"@webiny/handler/types\";\n\nconst Reply = require(\"fastify/lib/reply\");\n\nconst url = \"/webiny-raw-event\";\n\nexport interface HandlerCallable<Payload, Response = APIGatewayProxyResult> {\n (payload: Payload, context: LambdaContext): Promise<Response>;\n}\n\nexport type CreateHandlerParams = BaseCreateHandlerParams;\n\ninterface HandlerParams<Payload = any> {\n request: Request;\n context: Context;\n payload: Payload;\n lambdaContext: LambdaContext;\n reply: Record<string, any>;\n next: () => Promise<Payload>;\n}\n\nexport const createHandler = <Payload = any, Response = APIGatewayProxyResult>(\n params: CreateHandlerParams\n): HandlerCallable<Payload, Response> => {\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<RawEventHandler<Payload, any, Response>>(RawEventHandler.type)\n .reverse();\n if (plugins.length === 0) {\n throw new Error(`To run @webiny/handler-aws/raw, you must have RawEventHandler set.`);\n }\n\n const handler = createComposedHandler<\n RawEventHandler<Payload, any, Response>,\n HandlerParams,\n Response\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<HandlerParams, \"next\"> = {\n request,\n reply,\n context: app.webiny,\n payload,\n lambdaContext: context\n };\n const result = await handler(params as unknown as HandlerParams);\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\nexport * from \"./plugins/RawEventHandler\";\n"],"mappings":";;;;;;;;;AAOA,IAAAA,QAAA,GAAAC,OAAA;AAIA,IAAAC,gBAAA,GAAAD,OAAA;AAiFAE,MAAA,CAAAC,IAAA,CAAAF,gBAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MA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AG,EAAE,OAAOsB,OAAO,EAAEC,KAAK,KAAK;MACpC,MAAMrB,MAAmC,GAAG;QACxCoB,OAAO;QACPC,KAAK;QACLnB,OAAO,EAAEC,GAAG,CAACM,MAAM;QACnBR,OAAO;QACPqB,aAAa,EAAEpB;MACnB,CAAC;MACD,MAAMqB,MAAM,GAAG,MAAMN,OAAO,CAACjB,MAAkC,CAAC;MAEhE,IAAIuB,MAAM,YAAY1B,KAAK,EAAE;QACzB,OAAO0B,MAAM;MACjB;MAEApB,GAAG,CAACqB,mBAAmB,GAAGD,MAAM;MAChC,OAAOF,KAAK,CAACI,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAO,IAAAC,gBAAO,EAAC;MACXvB,GAAG;MACHL,GAAG;MACHG;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_handler","require","_RawEventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_plugins","_execute","_composedHandler","Reply","url","createHandler","params","payload","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","RawEventHandler","type","filter","plugin","canHandle","reverse","length","Error","handler","createComposedHandler","post","request","reply","lambdaContext","result","__webiny_raw_result","send","execute"],"sources":["index.ts"],"sourcesContent":["/**\n * This is the handler implementation for @webiny/handler/plugins/EventPlugin.\n * This is mostly meant for some custom lambda calls as we are sometimes invoking lambdas directly.\n *\n * We should try to have some kind of standardized event type implementation at some point.\n */\nimport type { APIGatewayProxyResult, Context as LambdaContext } from \"@webiny/aws-sdk/types\";\nimport type { CreateHandlerParams as BaseCreateHandlerParams } from \"@webiny/handler\";\nimport { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { RawEventHandler } from \"~/raw/plugins/RawEventHandler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport { execute } from \"~/execute\";\nimport { createComposedHandler } from \"~/utils/composedHandler\";\nimport type { Context, Request } from \"@webiny/handler/types\";\n\nconst Reply = require(\"fastify/lib/reply\");\n\nconst url = \"/webiny-raw-event\";\n\nexport interface HandlerCallable<Payload, Response = APIGatewayProxyResult> {\n (payload: Payload, context: LambdaContext): Promise<Response>;\n}\n\nexport type CreateHandlerParams = BaseCreateHandlerParams;\n\ninterface HandlerParams<Payload = any> {\n request: Request;\n context: Context;\n payload: Payload;\n lambdaContext: LambdaContext;\n reply: Record<string, any>;\n next: () => Promise<Payload>;\n}\n\nexport const createHandler = <Payload = any, Response = APIGatewayProxyResult>(\n params: CreateHandlerParams\n): HandlerCallable<Payload, Response> => {\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<RawEventHandler<Payload, any, Response>>(RawEventHandler.type)\n .filter(plugin => {\n /**\n * Just in case check that the plugin contains canHandle method.\n * If it does not, we assume it can handle any payload.\n */\n if (typeof plugin.canHandle !== \"function\") {\n return true;\n }\n return plugin.canHandle(payload);\n })\n .reverse();\n if (plugins.length === 0) {\n throw new Error(`To run @webiny/handler-aws/raw, you must have RawEventHandler set.`);\n }\n\n const handler = createComposedHandler<\n RawEventHandler<Payload, any, Response>,\n HandlerParams,\n Response\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<HandlerParams, \"next\"> = {\n request,\n reply,\n context: app.webiny,\n payload,\n lambdaContext: context\n };\n const result = await handler(params as unknown as HandlerParams);\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\nexport * from \"./plugins/RawEventHandler\";\n"],"mappings":";;;;;;;;;AAQA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,gB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S,KAAK,UAAU,EAAE;QACxC,OAAO,IAAI;MACf;MACA,OAAOD,MAAM,CAACC,SAAS,CAACf,OAAO,CAAC;IACpC,CAAC,CAAC,CACDgB,OAAO,CAAC,CAAC;IACd,IAAIP,OAAO,CAACQ,MAAM,KAAK,CAAC,EAAE;MACtB,MAAM,IAAIC,KAAK,CAAC,oEAAoE,CAAC;IACzF;IAEA,MAAMC,OAAO,GAAG,IAAAC,sCAAqB,EAInCX,OAAO,CAAC;IAEVP,GAAG,CAACmB,IAAI,CAACxB,GAAG,EAAE,OAAOyB,OAAO,EAAEC,KAAK,KAAK;MACpC,MAAMxB,MAAmC,GAAG;QACxCuB,OAAO;QACPC,KAAK;QACLtB,OAAO,EAAEC,GAAG,CAACM,MAAM;QACnBR,OAAO;QACPwB,aAAa,EAAEvB;MACnB,CAAC;MACD,MAAMwB,MAAM,GAAG,MAAMN,OAAO,CAACpB,MAAkC,CAAC;MAEhE,IAAI0B,MAAM,YAAY7B,KAAK,EAAE;QACzB,OAAO6B,MAAM;MACjB;MAEAvB,GAAG,CAACwB,mBAAmB,GAAGD,MAAM;MAChC,OAAOF,KAAK,CAACI,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAO,IAAAC,gBAAO,EAAC;MACX1B,GAAG;MACHL,GAAG;MACHG;IACJ,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1,13 +1,24 @@
1
1
  import type { Context as LambdaContext } from "@webiny/aws-sdk/types";
2
- import { Context as BaseContext, Reply } from "@webiny/handler/types";
3
- import { EventPlugin, EventPluginCallableParams } from "@webiny/handler";
2
+ import type { Context as BaseContext, Reply } from "@webiny/handler/types";
3
+ import type { EventPluginCallableParams } from "@webiny/handler";
4
+ import { EventPlugin } from "@webiny/handler";
4
5
  export interface RawEventHandlerCallableParams<Event, Context extends BaseContext> extends EventPluginCallableParams<Event, Context> {
5
6
  lambdaContext: LambdaContext;
6
7
  }
7
8
  export interface RawEventHandlerCallable<Event, Context extends BaseContext, Response> {
8
9
  (params: RawEventHandlerCallableParams<Event, Context>): Promise<Response | Reply>;
9
10
  }
11
+ export interface RawEventHandlerParamsConfig<Event = any, Context extends BaseContext = BaseContext, Response = any> {
12
+ canHandle(event: Event): boolean;
13
+ handle: RawEventHandlerCallable<Event, Context, Response>;
14
+ }
15
+ export type RawEventHandlerParams<Event = any, Context extends BaseContext = BaseContext, Response = any> = RawEventHandlerCallable<Event, Context, Response> | RawEventHandlerParamsConfig<Event, Context, Response>;
10
16
  export declare class RawEventHandler<Event = any, Context extends BaseContext = BaseContext, Response = any> extends EventPlugin<Event, Context, Response> {
11
- constructor(cb: RawEventHandlerCallable<Event, Context, Response>);
17
+ private readonly params;
18
+ constructor(params: RawEventHandlerParams<Event, Context, Response>);
19
+ /**
20
+ *
21
+ */
22
+ canHandle(event: Event): boolean;
12
23
  }
13
- export declare const createEventHandler: <Event_1 = any, Context extends BaseContext = BaseContext, Response_1 = any>(cb: RawEventHandlerCallable<Event_1, Context, Response_1>) => RawEventHandler<Event_1, Context, Response_1>;
24
+ export declare const createEventHandler: <Event_1 = any, Context extends BaseContext = BaseContext, Response_1 = any>(params: RawEventHandlerParams<Event_1, Context, Response_1>) => RawEventHandler<Event_1, Context, Response_1>;
@@ -6,17 +6,28 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.createEventHandler = exports.RawEventHandler = void 0;
7
7
  var _handler = require("@webiny/handler");
8
8
  class RawEventHandler extends _handler.EventPlugin {
9
- constructor(cb) {
9
+ constructor(params) {
10
+ const cb = typeof params === "function" ? params : params.handle;
10
11
  /**
11
12
  * Callable is correct, TS is just having problems with the override.
12
13
  */
13
14
  // @ts-expect-error
14
15
  super(cb);
16
+ this.params = params;
17
+ }
18
+ /**
19
+ *
20
+ */
21
+ canHandle(event) {
22
+ if (typeof this.params === "function" || !this.params?.canHandle) {
23
+ return true;
24
+ }
25
+ return this.params.canHandle(event);
15
26
  }
16
27
  }
17
28
  exports.RawEventHandler = RawEventHandler;
18
- const createEventHandler = cb => {
19
- return new RawEventHandler(cb);
29
+ const createEventHandler = params => {
30
+ return new RawEventHandler(params);
20
31
  };
21
32
  exports.createEventHandler = createEventHandler;
22
33
 
@@ -1 +1 @@
1
- {"version":3,"names":["_handler","require","RawEventHandler","EventPlugin","constructor","cb","exports","createEventHandler"],"sources":["RawEventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext } from \"@webiny/aws-sdk/types\";\nimport { Context as BaseContext, Reply } from \"@webiny/handler/types\";\nimport { EventPlugin, EventPluginCallableParams } from \"@webiny/handler\";\n\nexport interface RawEventHandlerCallableParams<Event, Context extends BaseContext>\n extends EventPluginCallableParams<Event, Context> {\n lambdaContext: LambdaContext;\n}\nexport interface RawEventHandlerCallable<Event, Context extends BaseContext, Response> {\n (params: RawEventHandlerCallableParams<Event, Context>): Promise<Response | Reply>;\n}\n\nexport class RawEventHandler<\n Event = any,\n Context extends BaseContext = BaseContext,\n Response = any\n> extends EventPlugin<Event, Context, Response> {\n public constructor(cb: RawEventHandlerCallable<Event, Context, Response>) {\n /**\n * Callable is correct, TS is just having problems with the override.\n */\n // @ts-expect-error\n super(cb);\n }\n}\n\nexport const createEventHandler = <\n Event = any,\n Context extends BaseContext = BaseContext,\n Response = any\n>(\n cb: RawEventHandlerCallable<Event, Context, Response>\n) => {\n return new RawEventHandler<Event, Context, Response>(cb);\n};\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAUO,MAAMC,eAAe,SAIlBC,oBAAW,CAA2B;EACrCC,WAAWA,CAACC,EAAqD,EAAE;IACtE;AACR;AACA;IACQ;IACA,KAAK,CAACA,EAAE,CAAC;EACb;AACJ;AAACC,OAAA,CAAAJ,eAAA,GAAAA,eAAA;AAEM,MAAMK,kBAAkB,GAK3BF,EAAqD,IACpD;EACD,OAAO,IAAIH,eAAe,CAA2BG,EAAE,CAAC;AAC5D,CAAC;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_handler","require","RawEventHandler","EventPlugin","constructor","params","cb","handle","canHandle","event","exports","createEventHandler"],"sources":["RawEventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext } from \"@webiny/aws-sdk/types\";\nimport type { Context as BaseContext, Reply } from \"@webiny/handler/types\";\nimport type { EventPluginCallableParams } from \"@webiny/handler\";\nimport { EventPlugin } from \"@webiny/handler\";\n\nexport interface RawEventHandlerCallableParams<Event, Context extends BaseContext>\n extends EventPluginCallableParams<Event, Context> {\n lambdaContext: LambdaContext;\n}\nexport interface RawEventHandlerCallable<Event, Context extends BaseContext, Response> {\n (params: RawEventHandlerCallableParams<Event, Context>): Promise<Response | Reply>;\n}\n\nexport interface RawEventHandlerParamsConfig<\n Event = any,\n Context extends BaseContext = BaseContext,\n Response = any\n> {\n canHandle(event: Event): boolean;\n handle: RawEventHandlerCallable<Event, Context, Response>;\n}\n\nexport type RawEventHandlerParams<\n Event = any,\n Context extends BaseContext = BaseContext,\n Response = any\n> =\n | RawEventHandlerCallable<Event, Context, Response>\n | RawEventHandlerParamsConfig<Event, Context, Response>;\n\nexport class RawEventHandler<\n Event = any,\n Context extends BaseContext = BaseContext,\n Response = any\n> extends EventPlugin<Event, Context, Response> {\n private readonly params: RawEventHandlerParams<Event, Context, Response>;\n\n public constructor(params: RawEventHandlerParams<Event, Context, Response>) {\n const cb = typeof params === \"function\" ? params : params.handle;\n /**\n * Callable is correct, TS is just having problems with the override.\n */\n // @ts-expect-error\n super(cb);\n this.params = params;\n }\n /**\n *\n */\n public canHandle(event: Event): boolean {\n if (typeof this.params === \"function\" || !this.params?.canHandle) {\n return true;\n }\n return this.params.canHandle(event);\n }\n}\n\nexport const createEventHandler = <\n Event = any,\n Context extends BaseContext = BaseContext,\n Response = any\n>(\n params: RawEventHandlerParams<Event, Context, Response>\n) => {\n return new RawEventHandler<Event, Context, Response>(params);\n};\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AA2BO,MAAMC,eAAe,SAIlBC,oBAAW,CAA2B;EAGrCC,WAAWA,CAACC,MAAuD,EAAE;IACxE,MAAMC,EAAE,GAAG,OAAOD,MAAM,KAAK,UAAU,GAAGA,MAAM,GAAGA,MAAM,CAACE,MAAM;IAChE;AACR;AACA;IACQ;IACA,KAAK,CAACD,EAAE,CAAC;IACT,IAAI,CAACD,MAAM,GAAGA,MAAM;EACxB;EACA;AACJ;AACA;EACWG,SAASA,CAACC,KAAY,EAAW;IACpC,IAAI,OAAO,IAAI,CAACJ,MAAM,KAAK,UAAU,IAAI,CAAC,IAAI,CAACA,MAAM,EAAEG,SAAS,EAAE;MAC9D,OAAO,IAAI;IACf;IACA,OAAO,IAAI,CAACH,MAAM,CAACG,SAAS,CAACC,KAAK,CAAC;EACvC;AACJ;AAACC,OAAA,CAAAR,eAAA,GAAAA,eAAA;AAEM,MAAMS,kBAAkB,GAK3BN,MAAuD,IACtD;EACD,OAAO,IAAIH,eAAe,CAA2BG,MAAM,CAAC;AAChE,CAAC;AAACK,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
package/registry.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * TODO: refactor this to use a proper DI container
3
3
  */
4
- import { HandlerEvent, SourceHandler } from "./types";
5
- import { Context as LambdaContext } from "@webiny/aws-sdk/types";
4
+ import type { HandlerEvent, SourceHandler } from "./types";
5
+ import type { Context as LambdaContext } from "@webiny/aws-sdk/types";
6
6
  interface RegisterOptions {
7
7
  silent?: boolean;
8
8
  }
package/registry.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["HandlerRegistry","handlers","Map","constructor","create","register","handler","options","has","name","silent","Error","set","getHandler","event","context","values","canUse","JSON","stringify","registry","exports"],"sources":["registry.ts"],"sourcesContent":["/**\n * TODO: refactor this to use a proper DI container\n */\nimport { HandlerEvent, SourceHandler } from \"~/types\";\nimport { Context as LambdaContext } from \"@webiny/aws-sdk/types\";\n\ninterface RegisterOptions {\n silent?: boolean;\n}\n\nclass HandlerRegistry {\n private readonly handlers = new Map<string, SourceHandler>();\n\n private constructor() {\n /**\n * We don't want this class to be constructed outside the static create() method\n */\n }\n\n public static create() {\n return new HandlerRegistry();\n }\n\n public register(handler: SourceHandler<any>, options?: RegisterOptions) {\n if (this.handlers.has(handler.name)) {\n if (options?.silent) {\n return;\n }\n /**\n * This should only happen during the development phase.\n */\n throw new Error(`Handler \"${handler.name}\" is already registered.`);\n }\n this.handlers.set(handler.name, handler);\n }\n\n public getHandler(event: HandlerEvent, context: LambdaContext): SourceHandler {\n for (const handler of this.handlers.values()) {\n if (handler.canUse(event, context)) {\n return handler;\n }\n }\n throw new Error(`There is no handler for the event: ${JSON.stringify(event)}`);\n }\n}\n\nexport type { HandlerRegistry };\n\nexport const registry = HandlerRegistry.create();\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAQA,MAAMA,eAAe,CAAC;EACDC,QAAQ,GAAG,IAAIC,GAAG,CAAwB,CAAC;EAEpDC,WAAWA,CAAA,EAAG;IAClB;AACR;AACA;EAFQ;EAKJ,OAAcC,MAAMA,CAAA,EAAG;IACnB,OAAO,IAAIJ,eAAe,CAAC,CAAC;EAChC;EAEOK,QAAQA,CAACC,OAA2B,EAAEC,OAAyB,EAAE;IACpE,IAAI,IAAI,CAACN,QAAQ,CAACO,GAAG,CAACF,OAAO,CAACG,IAAI,CAAC,EAAE;MACjC,IAAIF,OAAO,EAAEG,MAAM,EAAE;QACjB;MACJ;MACA;AACZ;AACA;MACY,MAAM,IAAIC,KAAK,CAAC,YAAYL,OAAO,CAACG,IAAI,0BAA0B,CAAC;IACvE;IACA,IAAI,CAACR,QAAQ,CAACW,GAAG,CAACN,OAAO,CAACG,IAAI,EAAEH,OAAO,CAAC;EAC5C;EAEOO,UAAUA,CAACC,KAAmB,EAAEC,OAAsB,EAAiB;IAC1E,KAAK,MAAMT,OAAO,IAAI,IAAI,CAACL,QAAQ,CAACe,MAAM,CAAC,CAAC,EAAE;MAC1C,IAAIV,OAAO,CAACW,MAAM,CAACH,KAAK,EAAEC,OAAO,CAAC,EAAE;QAChC,OAAOT,OAAO;MAClB;IACJ;IACA,MAAM,IAAIK,KAAK,CAAC,sCAAsCO,IAAI,CAACC,SAAS,CAACL,KAAK,CAAC,EAAE,CAAC;EAClF;AACJ;AAIO,MAAMM,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAGpB,eAAe,CAACI,MAAM,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["HandlerRegistry","handlers","Map","constructor","create","register","handler","options","has","name","silent","Error","set","getHandler","event","context","values","canUse","JSON","stringify","registry","exports"],"sources":["registry.ts"],"sourcesContent":["/**\n * TODO: refactor this to use a proper DI container\n */\nimport type { HandlerEvent, SourceHandler } from \"~/types\";\nimport type { Context as LambdaContext } from \"@webiny/aws-sdk/types\";\n\ninterface RegisterOptions {\n silent?: boolean;\n}\n\nclass HandlerRegistry {\n private readonly handlers = new Map<string, SourceHandler>();\n\n private constructor() {\n /**\n * We don't want this class to be constructed outside the static create() method\n */\n }\n\n public static create() {\n return new HandlerRegistry();\n }\n\n public register(handler: SourceHandler<any>, options?: RegisterOptions) {\n if (this.handlers.has(handler.name)) {\n if (options?.silent) {\n return;\n }\n /**\n * This should only happen during the development phase.\n */\n throw new Error(`Handler \"${handler.name}\" is already registered.`);\n }\n this.handlers.set(handler.name, handler);\n }\n\n public getHandler(event: HandlerEvent, context: LambdaContext): SourceHandler {\n for (const handler of this.handlers.values()) {\n if (handler.canUse(event, context)) {\n return handler;\n }\n }\n throw new Error(`There is no handler for the event: ${JSON.stringify(event)}`);\n }\n}\n\nexport type { HandlerRegistry };\n\nexport const registry = HandlerRegistry.create();\n"],"mappings":";;;;;;AAAA;AACA;AACA;;AAQA,MAAMA,eAAe,CAAC;EACDC,QAAQ,GAAG,IAAIC,GAAG,CAAwB,CAAC;EAEpDC,WAAWA,CAAA,EAAG;IAClB;AACR;AACA;EAFQ;EAKJ,OAAcC,MAAMA,CAAA,EAAG;IACnB,OAAO,IAAIJ,eAAe,CAAC,CAAC;EAChC;EAEOK,QAAQA,CAACC,OAA2B,EAAEC,OAAyB,EAAE;IACpE,IAAI,IAAI,CAACN,QAAQ,CAACO,GAAG,CAACF,OAAO,CAACG,IAAI,CAAC,EAAE;MACjC,IAAIF,OAAO,EAAEG,MAAM,EAAE;QACjB;MACJ;MACA;AACZ;AACA;MACY,MAAM,IAAIC,KAAK,CAAC,YAAYL,OAAO,CAACG,IAAI,0BAA0B,CAAC;IACvE;IACA,IAAI,CAACR,QAAQ,CAACW,GAAG,CAACN,OAAO,CAACG,IAAI,EAAEH,OAAO,CAAC;EAC5C;EAEOO,UAAUA,CAACC,KAAmB,EAAEC,OAAsB,EAAiB;IAC1E,KAAK,MAAMT,OAAO,IAAI,IAAI,CAACL,QAAQ,CAACe,MAAM,CAAC,CAAC,EAAE;MAC1C,IAAIV,OAAO,CAACW,MAAM,CAACH,KAAK,EAAEC,OAAO,CAAC,EAAE;QAChC,OAAOT,OAAO;MAClB;IACJ;IACA,MAAM,IAAIK,KAAK,CAAC,sCAAsCO,IAAI,CAACC,SAAS,CAACL,KAAK,CAAC,EAAE,CAAC;EAClF;AACJ;AAIO,MAAMM,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAGpB,eAAe,CAACI,MAAM,CAAC,CAAC","ignoreList":[]}
package/s3/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_handler","require","_plugins","_S3EventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_execute","_reply","_interopRequireDefault","_composedHandler","url","createHandler","params","event","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","S3EventHandler","type","reverse","length","Error","handler","createComposedHandler","post","request","reply","lambdaContext","result","Reply","__webiny_raw_result","send","execute","payload"],"sources":["index.ts"],"sourcesContent":["import { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport { S3EventHandler, S3EventHandlerCallableParams } from \"~/s3/plugins/S3EventHandler\";\nimport { execute } from \"~/execute\";\nimport type { HandlerFactoryParams } from \"~/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 type {\n APIGatewayProxyResult,\n Context as LambdaContext,\n S3Event\n} from \"@webiny/aws-sdk/types\";\nimport { createComposedHandler } from \"~/utils/composedHandler\";\n\nexport * from \"./plugins/S3EventHandler\";\n\nexport interface HandlerCallable {\n (event: S3Event, context: LambdaContext): Promise<APIGatewayProxyResult>;\n}\n\nexport type HandlerParams = HandlerFactoryParams;\n\nconst url = \"/webiny-s3-event\";\n\nexport const createHandler = (params: HandlerParams): HandlerCallable => {\n return async (event, 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.byType<S3EventHandler>(S3EventHandler.type).reverse();\n if (plugins.length === 0) {\n throw new Error(`To run @webiny/handler-aws/s3, you must have S3EventHandler set.`);\n }\n\n const handler = createComposedHandler<\n S3EventHandler,\n S3EventHandlerCallableParams<APIGatewayProxyResult>,\n APIGatewayProxyResult\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<S3EventHandlerCallableParams<APIGatewayProxyResult>, \"next\"> = {\n request,\n reply,\n context: app.webiny,\n event,\n lambdaContext: context\n };\n const result = await handler(\n params as unknown as S3EventHandlerCallableParams<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: event\n });\n };\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA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AkE,CAAC;IACvF;IAEA,MAAMC,OAAO,GAAG,IAAAC,sCAAqB,EAInCR,OAAO,CAAC;IAEVP,GAAG,CAACgB,IAAI,CAACrB,GAAG,EAAE,OAAOsB,OAAO,EAAEC,KAAK,KAAK;MACpC,MAAMrB,MAAyE,GAAG;QAC9EoB,OAAO;QACPC,KAAK;QACLnB,OAAO,EAAEC,GAAG,CAACM,MAAM;QACnBR,KAAK;QACLqB,aAAa,EAAEpB;MACnB,CAAC;MACD,MAAMqB,MAAM,GAAG,MAAMN,OAAO,CACxBjB,MACJ,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;MACH8B,OAAO,EAAE3B;IACb,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_handler","require","_plugins","_S3EventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_execute","_reply","_interopRequireDefault","_composedHandler","url","createHandler","params","event","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","S3EventHandler","type","reverse","length","Error","handler","createComposedHandler","post","request","reply","lambdaContext","result","Reply","__webiny_raw_result","send","execute","payload"],"sources":["index.ts"],"sourcesContent":["import { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport type { S3EventHandlerCallableParams } from \"~/s3/plugins/S3EventHandler\";\nimport { S3EventHandler } from \"~/s3/plugins/S3EventHandler\";\nimport { execute } from \"~/execute\";\nimport type { HandlerFactoryParams } from \"~/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 type {\n APIGatewayProxyResult,\n Context as LambdaContext,\n S3Event\n} from \"@webiny/aws-sdk/types\";\nimport { createComposedHandler } from \"~/utils/composedHandler\";\n\nexport * from \"./plugins/S3EventHandler\";\n\nexport interface HandlerCallable {\n (event: S3Event, context: LambdaContext): Promise<APIGatewayProxyResult>;\n}\n\nexport type HandlerParams = HandlerFactoryParams;\n\nconst url = \"/webiny-s3-event\";\n\nexport const createHandler = (params: HandlerParams): HandlerCallable => {\n return async (event, 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.byType<S3EventHandler>(S3EventHandler.type).reverse();\n if (plugins.length === 0) {\n throw new Error(`To run @webiny/handler-aws/s3, you must have S3EventHandler set.`);\n }\n\n const handler = createComposedHandler<\n S3EventHandler,\n S3EventHandlerCallableParams<APIGatewayProxyResult>,\n APIGatewayProxyResult\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<S3EventHandlerCallableParams<APIGatewayProxyResult>, \"next\"> = {\n request,\n reply,\n context: app.webiny,\n event,\n lambdaContext: context\n };\n const result = await handler(\n params as unknown as S3EventHandlerCallableParams<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: event\n });\n };\n};\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AAeAG,MAAA,CAAAC,IAAA,CAAAF,eAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CA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AG;QAC9EoB,OAAO;QACPC,KAAK;QACLnB,OAAO,EAAEC,GAAG,CAACM,MAAM;QACnBR,KAAK;QACLqB,aAAa,EAAEpB;MACnB,CAAC;MACD,MAAMqB,MAAM,GAAG,MAAMN,OAAO,CACxBjB,MACJ,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;MACH8B,OAAO,EAAE3B;IACb,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import type { Context as LambdaContext, S3Event } from "@webiny/aws-sdk/types";
2
2
  import { Plugin } from "@webiny/plugins/Plugin";
3
- import { Context, Reply, Request } from "@webiny/handler/types";
3
+ import type { Context, Reply, Request } from "@webiny/handler/types";
4
4
  export interface S3EventHandlerCallableParams<Response = Reply> {
5
5
  request: Request;
6
6
  context: Context;
@@ -1 +1 @@
1
- {"version":3,"names":["_Plugin","require","S3EventHandler","Plugin","type","constructor","cb","exports","createEventHandler"],"sources":["S3EventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext, S3Event } from \"@webiny/aws-sdk/types\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport { Context, Reply, Request } from \"@webiny/handler/types\";\n\nexport interface S3EventHandlerCallableParams<Response = Reply> {\n request: Request;\n context: Context;\n event: S3Event;\n lambdaContext: LambdaContext;\n reply: Reply;\n next: () => Promise<Response>;\n}\n\nexport interface S3EventHandlerCallable<Response = Reply> {\n (params: S3EventHandlerCallableParams<Response>): Promise<Response>;\n}\n\nexport class S3EventHandler<Response = any> extends Plugin {\n public static override type = \"handler.fastify.aws.s3.eventHandler\";\n\n public readonly cb: S3EventHandlerCallable<Response>;\n\n public constructor(cb: S3EventHandlerCallable<Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEventHandler = <Response>(cb: S3EventHandlerCallable<Response>) => {\n return new S3EventHandler<Response>(cb);\n};\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAgBO,MAAMC,cAAc,SAAyBC,cAAM,CAAC;EACvD,OAAuBC,IAAI,GAAG,qCAAqC;EAI5DC,WAAWA,CAACC,EAAoC,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,cAAA,GAAAA,cAAA;AAEM,MAAMM,kBAAkB,GAAcF,EAAoC,IAAK;EAClF,OAAO,IAAIJ,cAAc,CAAWI,EAAE,CAAC;AAC3C,CAAC;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_Plugin","require","S3EventHandler","Plugin","type","constructor","cb","exports","createEventHandler"],"sources":["S3EventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext, S3Event } from \"@webiny/aws-sdk/types\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { Context, Reply, Request } from \"@webiny/handler/types\";\n\nexport interface S3EventHandlerCallableParams<Response = Reply> {\n request: Request;\n context: Context;\n event: S3Event;\n lambdaContext: LambdaContext;\n reply: Reply;\n next: () => Promise<Response>;\n}\n\nexport interface S3EventHandlerCallable<Response = Reply> {\n (params: S3EventHandlerCallableParams<Response>): Promise<Response>;\n}\n\nexport class S3EventHandler<Response = any> extends Plugin {\n public static override type = \"handler.fastify.aws.s3.eventHandler\";\n\n public readonly cb: S3EventHandlerCallable<Response>;\n\n public constructor(cb: S3EventHandlerCallable<Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEventHandler = <Response>(cb: S3EventHandlerCallable<Response>) => {\n return new S3EventHandler<Response>(cb);\n};\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAgBO,MAAMC,cAAc,SAAyBC,cAAM,CAAC;EACvD,OAAuBC,IAAI,GAAG,qCAAqC;EAI5DC,WAAWA,CAACC,EAAoC,EAAE;IACrD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,cAAA,GAAAA,cAAA;AAEM,MAAMM,kBAAkB,GAAcF,EAAoC,IAAK;EAClF,OAAO,IAAIJ,cAAc,CAAWI,EAAE,CAAC;AAC3C,CAAC;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
package/s3/register.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { HandlerFactoryParams } from "../types";
1
+ import type { HandlerFactoryParams } from "../types";
2
2
  export interface HandlerParams extends HandlerFactoryParams {
3
3
  debug?: boolean;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_registry","require","_sourceHandler","_index","handler","createSourceHandler","name","canUse","event","Array","isArray","Records","length","record","s3","handle","params","context","createHandler","registry","register"],"sources":["register.ts"],"sourcesContent":["import type { S3Event } from \"@webiny/aws-sdk/types\";\nimport { registry } from \"~/registry\";\nimport { HandlerFactoryParams } from \"~/types\";\nimport { createSourceHandler } from \"~/sourceHandler\";\nimport { createHandler } from \"./index\";\n\nexport interface HandlerParams extends HandlerFactoryParams {\n debug?: boolean;\n}\n\nconst handler = createSourceHandler<S3Event, HandlerParams>({\n name: \"handler-aws-s3\",\n canUse: event => {\n if (!Array.isArray(event.Records) || event.Records.length === 0) {\n return false;\n }\n const [record] = event.Records;\n return !!record.s3;\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,EAAyB;EACxDC,IAAI,EAAE,gBAAgB;EACtBC,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,OAAO,CAAC,CAACE,MAAM,CAACC,EAAE;EACtB,CAAC;EACDC,MAAM,EAAE,MAAAA,CAAO;IAAEC,MAAM;IAAER,KAAK;IAAES;EAAQ,CAAC,KAAK;IAC1C,OAAO,IAAAC,oBAAa,EAACF,MAAM,CAAC,CAACR,KAAK,EAAES,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFE,kBAAQ,CAACC,QAAQ,CAAChB,OAAO,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_registry","require","_sourceHandler","_index","handler","createSourceHandler","name","canUse","event","Array","isArray","Records","length","record","s3","handle","params","context","createHandler","registry","register"],"sources":["register.ts"],"sourcesContent":["import type { S3Event } from \"@webiny/aws-sdk/types\";\nimport { registry } from \"~/registry\";\nimport type { HandlerFactoryParams } from \"~/types\";\nimport { createSourceHandler } from \"~/sourceHandler\";\nimport { createHandler } from \"./index\";\n\nexport interface HandlerParams extends HandlerFactoryParams {\n debug?: boolean;\n}\n\nconst handler = createSourceHandler<S3Event, HandlerParams>({\n name: \"handler-aws-s3\",\n canUse: event => {\n if (!Array.isArray(event.Records) || event.Records.length === 0) {\n return false;\n }\n const [record] = event.Records;\n return !!record.s3;\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,EAAyB;EACxDC,IAAI,EAAE,gBAAgB;EACtBC,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,OAAO,CAAC,CAACE,MAAM,CAACC,EAAE;EACtB,CAAC;EACDC,MAAM,EAAE,MAAAA,CAAO;IAAEC,MAAM;IAAER,KAAK;IAAES;EAAQ,CAAC,KAAK;IAC1C,OAAO,IAAAC,oBAAa,EAACF,MAAM,CAAC,CAACR,KAAK,EAAES,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFE,kBAAQ,CAACC,QAAQ,CAAChB,OAAO,CAAC","ignoreList":[]}
package/sns/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_handler","require","_plugins","_SNSEventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_execute","_reply","_interopRequireDefault","_composedHandler","url","createHandler","params","event","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","SNSEventHandler","type","reverse","length","Error","handler","createComposedHandler","post","request","reply","lambdaContext","result","Reply","__webiny_raw_result","send","execute","payload"],"sources":["index.ts"],"sourcesContent":["import type {\n APIGatewayProxyResult,\n SNSEvent,\n Context as LambdaContext\n} from \"@webiny/aws-sdk/types\";\nimport { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport { SNSEventHandler, SNSEventHandlerCallableParams } from \"./plugins/SNSEventHandler\";\nimport { execute } from \"~/execute\";\nimport type { HandlerFactoryParams } from \"~/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/SNSEventHandler\";\n\nexport interface HandlerCallable {\n (event: SNSEvent, context: LambdaContext): Promise<APIGatewayProxyResult>;\n}\n\nexport type HandlerParams = HandlerFactoryParams;\n\nconst url = \"/webiny-sns-event\";\n\nexport const createHandler = (params: HandlerParams): HandlerCallable => {\n return async (event, 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.byType<SNSEventHandler>(SNSEventHandler.type).reverse();\n if (plugins.length === 0) {\n throw new Error(`To run @webiny/handler-aws/sns, you must have SNSEventHandler set.`);\n }\n\n const handler = createComposedHandler<\n SNSEventHandler,\n SNSEventHandlerCallableParams<APIGatewayProxyResult>,\n APIGatewayProxyResult\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<SNSEventHandlerCallableParams<APIGatewayProxyResult>, \"next\"> = {\n request,\n reply,\n context: app.webiny,\n event,\n lambdaContext: context\n };\n\n const result = await handler(\n params as unknown as SNSEventHandlerCallableParams<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: event\n });\n };\n};\n"],"mappings":";;;;;;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAUAG,MAAA,CAAAC,IAAA,CAAAF,gBAAA,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,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AC;MAED,MAAMqB,MAAM,GAAG,MAAMN,OAAO,CACxBjB,MACJ,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;MACH8B,OAAO,EAAE3B;IACb,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_handler","require","_plugins","_SNSEventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_execute","_reply","_interopRequireDefault","_composedHandler","url","createHandler","params","event","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","SNSEventHandler","type","reverse","length","Error","handler","createComposedHandler","post","request","reply","lambdaContext","result","Reply","__webiny_raw_result","send","execute","payload"],"sources":["index.ts"],"sourcesContent":["import type {\n APIGatewayProxyResult,\n SNSEvent,\n Context as LambdaContext\n} from \"@webiny/aws-sdk/types\";\nimport { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport type { SNSEventHandlerCallableParams } from \"./plugins/SNSEventHandler\";\nimport { SNSEventHandler } from \"./plugins/SNSEventHandler\";\nimport { execute } from \"~/execute\";\nimport type { HandlerFactoryParams } from \"~/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/SNSEventHandler\";\n\nexport interface HandlerCallable {\n (event: SNSEvent, context: LambdaContext): Promise<APIGatewayProxyResult>;\n}\n\nexport type HandlerParams = HandlerFactoryParams;\n\nconst url = \"/webiny-sns-event\";\n\nexport const createHandler = (params: HandlerParams): HandlerCallable => {\n return async (event, 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.byType<SNSEventHandler>(SNSEventHandler.type).reverse();\n if (plugins.length === 0) {\n throw new Error(`To run @webiny/handler-aws/sns, you must have SNSEventHandler set.`);\n }\n\n const handler = createComposedHandler<\n SNSEventHandler,\n SNSEventHandlerCallableParams<APIGatewayProxyResult>,\n APIGatewayProxyResult\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<SNSEventHandlerCallableParams<APIGatewayProxyResult>, \"next\"> = {\n request,\n reply,\n context: app.webiny,\n event,\n lambdaContext: context\n };\n\n const result = await handler(\n params as unknown as SNSEventHandlerCallableParams<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: event\n });\n };\n};\n"],"mappings":";;;;;;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAUAG,MAAA,CAAAC,IAAA,CAAAF,gBAAA,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,gBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,gBAAA,CAAAI,GAAA;IAAA;EAA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M;MAChC,OAAOF,KAAK,CAACK,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAO,IAAAC,gBAAO,EAAC;MACXxB,GAAG;MACHL,GAAG;MACH8B,OAAO,EAAE3B;IACb,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import type { Context as LambdaContext, SNSEvent } from "@webiny/aws-sdk/types";
2
2
  import { Plugin } from "@webiny/plugins/Plugin";
3
- import { Context, Reply, Request } from "@webiny/handler/types";
3
+ import type { Context, Reply, Request } from "@webiny/handler/types";
4
4
  export interface SNSEventHandlerCallableParams<Response = Reply> {
5
5
  request: Request;
6
6
  reply: Reply;
@@ -1 +1 @@
1
- {"version":3,"names":["_Plugin","require","SNSEventHandler","Plugin","type","constructor","cb","exports","createEventHandler"],"sources":["SNSEventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext, SNSEvent } from \"@webiny/aws-sdk/types\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport { Context, Reply, Request } from \"@webiny/handler/types\";\n\nexport interface SNSEventHandlerCallableParams<Response = Reply> {\n request: Request;\n reply: Reply;\n context: Context;\n event: SNSEvent;\n lambdaContext: LambdaContext;\n next: () => Promise<Response>;\n}\n\nexport interface SNSEventHandlerCallable<Response = Reply> {\n (params: SNSEventHandlerCallableParams<Response>): Promise<Response>;\n}\n\nexport class SNSEventHandler<Response = any> extends Plugin {\n public static override type = \"handler.fastify.aws.sns.eventHandler\";\n\n public readonly cb: SNSEventHandlerCallable<Response>;\n\n public constructor(cb: SNSEventHandlerCallable<Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEventHandler = <Response>(cb: SNSEventHandlerCallable<Response>) => {\n return new SNSEventHandler<Response>(cb);\n};\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAgBO,MAAMC,eAAe,SAAyBC,cAAM,CAAC;EACxD,OAAuBC,IAAI,GAAG,sCAAsC;EAI7DC,WAAWA,CAACC,EAAqC,EAAE;IACtD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,eAAA,GAAAA,eAAA;AAEM,MAAMM,kBAAkB,GAAcF,EAAqC,IAAK;EACnF,OAAO,IAAIJ,eAAe,CAAWI,EAAE,CAAC;AAC5C,CAAC;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_Plugin","require","SNSEventHandler","Plugin","type","constructor","cb","exports","createEventHandler"],"sources":["SNSEventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext, SNSEvent } from \"@webiny/aws-sdk/types\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { Context, Reply, Request } from \"@webiny/handler/types\";\n\nexport interface SNSEventHandlerCallableParams<Response = Reply> {\n request: Request;\n reply: Reply;\n context: Context;\n event: SNSEvent;\n lambdaContext: LambdaContext;\n next: () => Promise<Response>;\n}\n\nexport interface SNSEventHandlerCallable<Response = Reply> {\n (params: SNSEventHandlerCallableParams<Response>): Promise<Response>;\n}\n\nexport class SNSEventHandler<Response = any> extends Plugin {\n public static override type = \"handler.fastify.aws.sns.eventHandler\";\n\n public readonly cb: SNSEventHandlerCallable<Response>;\n\n public constructor(cb: SNSEventHandlerCallable<Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEventHandler = <Response>(cb: SNSEventHandlerCallable<Response>) => {\n return new SNSEventHandler<Response>(cb);\n};\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAgBO,MAAMC,eAAe,SAAyBC,cAAM,CAAC;EACxD,OAAuBC,IAAI,GAAG,sCAAsC;EAI7DC,WAAWA,CAACC,EAAqC,EAAE;IACtD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,eAAA,GAAAA,eAAA;AAEM,MAAMM,kBAAkB,GAAcF,EAAqC,IAAK;EACnF,OAAO,IAAIJ,eAAe,CAAWI,EAAE,CAAC;AAC5C,CAAC;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_registry","require","_index","_sourceHandler","handler","createSourceHandler","name","canUse","event","Array","isArray","Records","length","record","Sns","handle","params","context","createHandler","registry","register"],"sources":["register.ts"],"sourcesContent":["import type { SNSEvent } from \"@webiny/aws-sdk/types\";\nimport { registry } from \"~/registry\";\nimport { createHandler, HandlerParams } from \"./index\";\nimport { createSourceHandler } from \"~/sourceHandler\";\n\nconst handler = createSourceHandler<SNSEvent, HandlerParams>({\n name: \"handler-aws-sns\",\n canUse: event => {\n if (!Array.isArray(event.Records) || event.Records.length === 0) {\n return false;\n }\n const [record] = event.Records;\n return !!record.Sns;\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;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEA,MAAMG,OAAO,GAAG,IAAAC,kCAAmB,EAA0B;EACzDC,IAAI,EAAE,iBAAiB;EACvBC,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,OAAO,CAAC,CAACE,MAAM,CAACC,GAAG;EACvB,CAAC;EACDC,MAAM,EAAE,MAAAA,CAAO;IAAEC,MAAM;IAAER,KAAK;IAAES;EAAQ,CAAC,KAAK;IAC1C,OAAO,IAAAC,oBAAa,EAACF,MAAM,CAAC,CAACR,KAAK,EAAES,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFE,kBAAQ,CAACC,QAAQ,CAAChB,OAAO,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_registry","require","_index","_sourceHandler","handler","createSourceHandler","name","canUse","event","Array","isArray","Records","length","record","Sns","handle","params","context","createHandler","registry","register"],"sources":["register.ts"],"sourcesContent":["import type { SNSEvent } from \"@webiny/aws-sdk/types\";\nimport { registry } from \"~/registry\";\nimport type { HandlerParams } from \"./index\";\nimport { createHandler } from \"./index\";\nimport { createSourceHandler } from \"~/sourceHandler\";\n\nconst handler = createSourceHandler<SNSEvent, HandlerParams>({\n name: \"handler-aws-sns\",\n canUse: event => {\n if (!Array.isArray(event.Records) || event.Records.length === 0) {\n return false;\n }\n const [record] = event.Records;\n return !!record.Sns;\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,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEA,MAAMG,OAAO,GAAG,IAAAC,kCAAmB,EAA0B;EACzDC,IAAI,EAAE,iBAAiB;EACvBC,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,OAAO,CAAC,CAACE,MAAM,CAACC,GAAG;EACvB,CAAC;EACDC,MAAM,EAAE,MAAAA,CAAO;IAAEC,MAAM;IAAER,KAAK;IAAES;EAAQ,CAAC,KAAK;IAC1C,OAAO,IAAAC,oBAAa,EAACF,MAAM,CAAC,CAACR,KAAK,EAAES,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFE,kBAAQ,CAACC,QAAQ,CAAChB,OAAO,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { SourceHandler, HandlerEvent, HandlerFactoryParams } from "./types";
1
+ import type { SourceHandler, HandlerEvent, HandlerFactoryParams } from "./types";
2
2
  export declare const createSourceHandler: <TEvent = HandlerEvent, TParams extends HandlerFactoryParams = HandlerFactoryParams>(handler: SourceHandler<TEvent, TParams, any>) => SourceHandler<TEvent, TParams, any>;
@@ -1 +1 @@
1
- {"version":3,"names":["createSourceHandler","handler","exports"],"sources":["sourceHandler.ts"],"sourcesContent":["import { SourceHandler, HandlerEvent, HandlerFactoryParams } from \"~/types\";\n\nexport const createSourceHandler = <\n TEvent = HandlerEvent,\n TParams extends HandlerFactoryParams = HandlerFactoryParams\n>(\n handler: SourceHandler<TEvent, TParams>\n) => {\n return handler;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,mBAAmB,GAI5BC,OAAuC,IACtC;EACD,OAAOA,OAAO;AAClB,CAAC;AAACC,OAAA,CAAAF,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["createSourceHandler","handler","exports"],"sources":["sourceHandler.ts"],"sourcesContent":["import type { SourceHandler, HandlerEvent, HandlerFactoryParams } from \"~/types\";\n\nexport const createSourceHandler = <\n TEvent = HandlerEvent,\n TParams extends HandlerFactoryParams = HandlerFactoryParams\n>(\n handler: SourceHandler<TEvent, TParams>\n) => {\n return handler;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,mBAAmB,GAI5BC,OAAuC,IACtC;EACD,OAAOA,OAAO;AAClB,CAAC;AAACC,OAAA,CAAAF,mBAAA,GAAAA,mBAAA","ignoreList":[]}
package/sqs/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { APIGatewayProxyResult, SQSEvent, Context as LambdaContext } from "@webiny/aws-sdk/types";
2
- import { HandlerFactoryParams } from "../types";
1
+ import type { APIGatewayProxyResult, Context as LambdaContext, SQSEvent } from "@webiny/aws-sdk/types";
2
+ import type { HandlerFactoryParams } from "../types";
3
3
  export * from "./plugins/SQSEventHandler";
4
4
  export interface HandlerCallable {
5
5
  (event: SQSEvent, context: LambdaContext): Promise<APIGatewayProxyResult>;
package/sqs/index.js CHANGED
@@ -65,7 +65,10 @@ const createHandler = params => {
65
65
  return result;
66
66
  }
67
67
  app.__webiny_raw_result = result;
68
- return reply.send({});
68
+ if (!reply.sent) {
69
+ reply.send({});
70
+ }
71
+ return reply;
69
72
  });
70
73
  return (0, _execute.execute)({
71
74
  app,
package/sqs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_handler","require","_plugins","_SQSEventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_execute","_reply","_interopRequireDefault","_composedHandler","url","createHandler","params","event","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","SQSEventHandler","type","reverse","length","Error","handler","createComposedHandler","post","request","reply","lambdaContext","result","Reply","__webiny_raw_result","send","execute","payload"],"sources":["index.ts"],"sourcesContent":["import type {\n APIGatewayProxyResult,\n SQSEvent,\n Context as LambdaContext\n} from \"@webiny/aws-sdk/types\";\nimport { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport { SQSEventHandler, SQSEventHandlerCallableParams } from \"~/sqs/plugins/SQSEventHandler\";\nimport { execute } from \"~/execute\";\nimport { HandlerFactoryParams } from \"~/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/SQSEventHandler\";\n\nexport interface HandlerCallable {\n (event: SQSEvent, context: LambdaContext): Promise<APIGatewayProxyResult>;\n}\n\nexport type HandlerParams = HandlerFactoryParams;\n\nconst url = \"/webiny-sqs-event\";\n\nexport const createHandler = (params: HandlerParams): HandlerCallable => {\n return async (event, 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.byType<SQSEventHandler>(SQSEventHandler.type).reverse();\n if (plugins.length === 0) {\n throw new Error(`To run @webiny/handler-aws/sqs, you must have SQSEventHandler set.`);\n }\n\n const handler = createComposedHandler<\n SQSEventHandler,\n SQSEventHandlerCallableParams<APIGatewayProxyResult>,\n APIGatewayProxyResult\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<SQSEventHandlerCallableParams<APIGatewayProxyResult>, \"next\"> = {\n request,\n reply,\n context: app.webiny,\n event,\n lambdaContext: context\n };\n\n const result = await handler(\n params as unknown as SQSEventHandlerCallableParams<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: event\n });\n };\n};\n"],"mappings":";;;;;;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAUAG,MAAA,CAAAC,IAAA,CAAAF,gBAAA,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,gBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,gBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AATA,IAAAS,QAAA,GAAAf,OAAA;AAMA,IAAAgB,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AC;IACzB,CAAC,CAAC;IACF,OAAO,IAAAC,gBAAO,EAAC;MACXxB,GAAG;MACHL,GAAG;MACH8B,OAAO,EAAE3B;IACb,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_handler","require","_plugins","_SQSEventHandler","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_execute","_reply","_interopRequireDefault","_composedHandler","url","createHandler","params","event","context","app","createBaseHandler","options","logger","debug","registerDefaultPlugins","webiny","plugins","byType","SQSEventHandler","type","reverse","length","Error","handler","createComposedHandler","post","request","reply","lambdaContext","result","Reply","__webiny_raw_result","sent","send","execute","payload"],"sources":["index.ts"],"sourcesContent":["import type {\n APIGatewayProxyResult,\n Context as LambdaContext,\n SQSEvent\n} from \"@webiny/aws-sdk/types\";\nimport { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport type { SQSEventHandlerCallableParams } from \"~/sqs/plugins/SQSEventHandler\";\nimport { SQSEventHandler } from \"~/sqs/plugins/SQSEventHandler\";\nimport { execute } from \"~/execute\";\nimport type { HandlerFactoryParams } from \"~/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/SQSEventHandler\";\n\nexport interface HandlerCallable {\n (event: SQSEvent, context: LambdaContext): Promise<APIGatewayProxyResult>;\n}\n\nexport type HandlerParams = HandlerFactoryParams;\n\nconst url = \"/webiny-sqs-event\";\n\nexport const createHandler = (params: HandlerParams): HandlerCallable => {\n return async (event, 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.byType<SQSEventHandler>(SQSEventHandler.type).reverse();\n if (plugins.length === 0) {\n throw new Error(`To run @webiny/handler-aws/sqs, you must have SQSEventHandler set.`);\n }\n\n const handler = createComposedHandler<\n SQSEventHandler,\n SQSEventHandlerCallableParams<APIGatewayProxyResult>,\n APIGatewayProxyResult\n >(plugins);\n\n app.post(url, async (request, reply) => {\n const params: Omit<SQSEventHandlerCallableParams<APIGatewayProxyResult>, \"next\"> = {\n request,\n reply,\n context: app.webiny,\n event,\n lambdaContext: context\n };\n\n const result = await handler(\n params as unknown as SQSEventHandlerCallableParams<APIGatewayProxyResult>\n );\n\n if (result instanceof Reply) {\n return result;\n }\n\n app.__webiny_raw_result = result;\n if (!reply.sent) {\n reply.send({});\n }\n return reply;\n });\n return execute({\n app,\n url,\n payload: event\n });\n };\n};\n"],"mappings":";;;;;;;;;;AAKA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAUAG,MAAA,CAAAC,IAAA,CAAAF,gBAAA,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,gBAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,gBAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AATA,IAAAS,QAAA,GAAAf,OAAA;AAMA,IAAAgB,MAAA,GAAAC,sBAAA,CAAAjB,OAAA;AACA,IAAAkB,gBAAA,GAAAlB,OAAA;AALA;AACA;AACA;AACA;;AAYA,MAAMmB,GAAG,GAAG,mBAAmB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MACHL,GAAG;MACH+B,OAAO,EAAE5B;IACb,CAAC,CAAC;EACN,CAAC;AACL,CAAC;AAACX,OAAA,CAAAS,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import type { Context as LambdaContext, SQSEvent } from "@webiny/aws-sdk/types";
2
2
  import { Plugin } from "@webiny/plugins/Plugin";
3
- import { Context, Reply, Request } from "@webiny/handler/types";
3
+ import type { Context, Reply, Request } from "@webiny/handler/types";
4
4
  export interface SQSEventHandlerCallableParams<Response = Reply> {
5
5
  request: Request;
6
6
  reply: Reply;
@@ -1 +1 @@
1
- {"version":3,"names":["_Plugin","require","SQSEventHandler","Plugin","type","constructor","cb","exports","createEventHandler"],"sources":["SQSEventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext, SQSEvent } from \"@webiny/aws-sdk/types\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport { Context, Reply, Request } from \"@webiny/handler/types\";\n\nexport interface SQSEventHandlerCallableParams<Response = Reply> {\n request: Request;\n reply: Reply;\n context: Context;\n event: SQSEvent;\n lambdaContext: LambdaContext;\n next: () => Promise<Response>;\n}\n\nexport interface SQSEventHandlerCallable<Response = Reply> {\n (params: SQSEventHandlerCallableParams<Response>): Promise<Response>;\n}\n\nexport class SQSEventHandler<Response = any> extends Plugin {\n public static override type = \"handler.fastify.aws.sqs.eventHandler\";\n\n public readonly cb: SQSEventHandlerCallable<Response>;\n\n public constructor(cb: SQSEventHandlerCallable<Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEventHandler = <Response>(cb: SQSEventHandlerCallable<Response>) => {\n return new SQSEventHandler<Response>(cb);\n};\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAgBO,MAAMC,eAAe,SAAyBC,cAAM,CAAC;EACxD,OAAuBC,IAAI,GAAG,sCAAsC;EAI7DC,WAAWA,CAACC,EAAqC,EAAE;IACtD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,eAAA,GAAAA,eAAA;AAEM,MAAMM,kBAAkB,GAAcF,EAAqC,IAAK;EACnF,OAAO,IAAIJ,eAAe,CAAWI,EAAE,CAAC;AAC5C,CAAC;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_Plugin","require","SQSEventHandler","Plugin","type","constructor","cb","exports","createEventHandler"],"sources":["SQSEventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext, SQSEvent } from \"@webiny/aws-sdk/types\";\nimport { Plugin } from \"@webiny/plugins/Plugin\";\nimport type { Context, Reply, Request } from \"@webiny/handler/types\";\n\nexport interface SQSEventHandlerCallableParams<Response = Reply> {\n request: Request;\n reply: Reply;\n context: Context;\n event: SQSEvent;\n lambdaContext: LambdaContext;\n next: () => Promise<Response>;\n}\n\nexport interface SQSEventHandlerCallable<Response = Reply> {\n (params: SQSEventHandlerCallableParams<Response>): Promise<Response>;\n}\n\nexport class SQSEventHandler<Response = any> extends Plugin {\n public static override type = \"handler.fastify.aws.sqs.eventHandler\";\n\n public readonly cb: SQSEventHandlerCallable<Response>;\n\n public constructor(cb: SQSEventHandlerCallable<Response>) {\n super();\n this.cb = cb;\n }\n}\n\nexport const createEventHandler = <Response>(cb: SQSEventHandlerCallable<Response>) => {\n return new SQSEventHandler<Response>(cb);\n};\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AAgBO,MAAMC,eAAe,SAAyBC,cAAM,CAAC;EACxD,OAAuBC,IAAI,GAAG,sCAAsC;EAI7DC,WAAWA,CAACC,EAAqC,EAAE;IACtD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAACC,OAAA,CAAAL,eAAA,GAAAA,eAAA;AAEM,MAAMM,kBAAkB,GAAcF,EAAqC,IAAK;EACnF,OAAO,IAAIJ,eAAe,CAAWI,EAAE,CAAC;AAC5C,CAAC;AAACC,OAAA,CAAAC,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["_registry","require","_index","_sourceHandler","handler","createSourceHandler","name","canUse","event","Array","isArray","Records","length","record","eventSource","toLowerCase","handle","params","context","createHandler","registry","register"],"sources":["register.ts"],"sourcesContent":["import type { SQSEvent } from \"@webiny/aws-sdk/types\";\nimport { registry } from \"~/registry\";\nimport { createHandler, HandlerParams } from \"./index\";\nimport { createSourceHandler } from \"~/sourceHandler\";\n\nconst handler = createSourceHandler<SQSEvent, HandlerParams>({\n name: \"handler-aws-sqs\",\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:sqs\";\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;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEA,MAAMG,OAAO,GAAG,IAAAC,kCAAmB,EAA0B;EACzDC,IAAI,EAAE,iBAAiB;EACvBC,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,SAAS;EACzD,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,"names":["_registry","require","_index","_sourceHandler","handler","createSourceHandler","name","canUse","event","Array","isArray","Records","length","record","eventSource","toLowerCase","handle","params","context","createHandler","registry","register"],"sources":["register.ts"],"sourcesContent":["import type { SQSEvent } from \"@webiny/aws-sdk/types\";\nimport { registry } from \"~/registry\";\nimport type { HandlerParams } from \"./index\";\nimport { createHandler } from \"./index\";\nimport { createSourceHandler } from \"~/sourceHandler\";\n\nconst handler = createSourceHandler<SQSEvent, HandlerParams>({\n name: \"handler-aws-sqs\",\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:sqs\";\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,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAEA,MAAMG,OAAO,GAAG,IAAAC,kCAAmB,EAA0B;EACzDC,IAAI,EAAE,iBAAiB;EACvBC,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,SAAS;EACzD,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/types.d.ts CHANGED
@@ -1,12 +1,13 @@
1
- import type { AttributeValue, DynamoDBRecord, APIGatewayEvent, APIGatewayEventRequestContextWithAuthorizer, Context as LambdaContext, DynamoDBStreamEvent, EventBridgeEvent, S3Event, SNSEvent, SQSEvent } from "@webiny/aws-sdk/types";
1
+ import type { APIGatewayEvent, APIGatewayEventRequestContextWithAuthorizer, AttributeValue, Context as LambdaContext, DynamoDBRecord, DynamoDBStreamEvent, EventBridgeEvent, S3Event, SNSEvent, SQSEvent } from "@webiny/aws-sdk/types";
2
2
  import "fastify";
3
3
  import type { CreateHandlerParams as BaseCreateHandlerParams } from "@webiny/handler";
4
4
  import type { LambdaFastifyOptions as LambdaOptions } from "@fastify/aws-lambda";
5
+ import type { GenericRecord } from "@webiny/utils";
5
6
  export type { AttributeValue, DynamoDBRecord };
6
7
  export { HandlerRegistry } from "./registry";
7
8
  export * from "@webiny/handler/types";
8
9
  export type { APIGatewayEvent, LambdaContext, APIGatewayEventRequestContextWithAuthorizer };
9
- export type HandlerEvent = APIGatewayEvent | SNSEvent | SQSEvent | S3Event | EventBridgeEvent<string, string> | DynamoDBStreamEvent;
10
+ export type HandlerEvent = APIGatewayEvent | SNSEvent | SQSEvent | S3Event | EventBridgeEvent<string, string> | DynamoDBStreamEvent | GenericRecord<string>;
10
11
  export interface EventResolver<T = any> {
11
12
  (event: HandlerEvent, context: LambdaContext): T;
12
13
  }
@@ -31,9 +32,6 @@ export declare enum Base64EncodeHeader {
31
32
  binary = "x-webiny-binary"
32
33
  }
33
34
  declare module "fastify" {
34
- interface FastifyInstance {
35
- __webiny_raw_result: any;
36
- }
37
35
  interface FastifyRequest {
38
36
  awsLambda: {
39
37
  event: APIGatewayEvent;
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["require","_registry","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","Base64EncodeHeader"],"sources":["types.ts"],"sourcesContent":["import type {\n AttributeValue,\n DynamoDBRecord,\n APIGatewayEvent,\n APIGatewayEventRequestContextWithAuthorizer,\n Context as LambdaContext,\n DynamoDBStreamEvent,\n EventBridgeEvent,\n S3Event,\n SNSEvent,\n SQSEvent\n} from \"@webiny/aws-sdk/types\";\nimport \"fastify\";\nimport type { CreateHandlerParams as BaseCreateHandlerParams } from \"@webiny/handler\";\nimport type { LambdaFastifyOptions as LambdaOptions } from \"@fastify/aws-lambda\";\n\nexport type { AttributeValue, DynamoDBRecord };\n\nexport { HandlerRegistry } from \"~/registry\";\n\nexport * from \"@webiny/handler/types\";\n\nexport type { APIGatewayEvent, LambdaContext, APIGatewayEventRequestContextWithAuthorizer };\n\nexport type HandlerEvent =\n | APIGatewayEvent\n | SNSEvent\n | SQSEvent\n | S3Event\n | EventBridgeEvent<string, string>\n | DynamoDBStreamEvent;\n\nexport interface EventResolver<T = any> {\n (event: HandlerEvent, context: LambdaContext): T;\n}\n\nexport interface HandlerFactoryParams extends BaseCreateHandlerParams {\n lambdaOptions?: LambdaOptions;\n}\n\nexport interface HandlerFactory<T extends HandlerFactoryParams = HandlerFactoryParams, R = any> {\n (params: T): EventResolver<R>;\n}\n\nexport interface HandlerParams<E, P extends HandlerFactoryParams> {\n params: P;\n event: E;\n context: LambdaContext;\n}\n\nexport interface SourceHandler<\n E = HandlerEvent,\n P extends HandlerFactoryParams = HandlerFactoryParams,\n T = any\n> {\n name: string;\n canUse: (event: Partial<E>, context: LambdaContext) => boolean;\n handle: (params: HandlerParams<E, P>) => Promise<T>;\n}\n\nexport enum Base64EncodeHeader {\n encoded = \"x-webiny-base64-encoded\",\n binary = \"x-webiny-binary\"\n}\n\ndeclare module \"fastify\" {\n interface FastifyInstance {\n __webiny_raw_result: any;\n }\n interface FastifyRequest {\n awsLambda: {\n event: APIGatewayEvent;\n context: LambdaContext;\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAYAA,OAAA;AAMA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,MAAA,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,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAAsC,IAwC1BS,kBAAkB,GAAAJ,OAAA,CAAAI,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA","ignoreList":[]}
1
+ {"version":3,"names":["require","_registry","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","Base64EncodeHeader"],"sources":["types.ts"],"sourcesContent":["import type {\n APIGatewayEvent,\n APIGatewayEventRequestContextWithAuthorizer,\n AttributeValue,\n Context as LambdaContext,\n DynamoDBRecord,\n DynamoDBStreamEvent,\n EventBridgeEvent,\n S3Event,\n SNSEvent,\n SQSEvent\n} from \"@webiny/aws-sdk/types\";\nimport \"fastify\";\nimport type { CreateHandlerParams as BaseCreateHandlerParams } from \"@webiny/handler\";\nimport type { LambdaFastifyOptions as LambdaOptions } from \"@fastify/aws-lambda\";\nimport type { GenericRecord } from \"@webiny/utils\";\n\nexport type { AttributeValue, DynamoDBRecord };\n\nexport { HandlerRegistry } from \"~/registry\";\n\nexport * from \"@webiny/handler/types\";\n\nexport type { APIGatewayEvent, LambdaContext, APIGatewayEventRequestContextWithAuthorizer };\n\nexport type HandlerEvent =\n | APIGatewayEvent\n | SNSEvent\n | SQSEvent\n | S3Event\n | EventBridgeEvent<string, string>\n | DynamoDBStreamEvent\n | GenericRecord<string>;\n\nexport interface EventResolver<T = any> {\n (event: HandlerEvent, context: LambdaContext): T;\n}\n\nexport interface HandlerFactoryParams extends BaseCreateHandlerParams {\n lambdaOptions?: LambdaOptions;\n}\n\nexport interface HandlerFactory<T extends HandlerFactoryParams = HandlerFactoryParams, R = any> {\n (params: T): EventResolver<R>;\n}\n\nexport interface HandlerParams<E, P extends HandlerFactoryParams> {\n params: P;\n event: E;\n context: LambdaContext;\n}\n\nexport interface SourceHandler<\n E = HandlerEvent,\n P extends HandlerFactoryParams = HandlerFactoryParams,\n T = any\n> {\n name: string;\n canUse: (event: Partial<E>, context: LambdaContext) => boolean;\n handle: (params: HandlerParams<E, P>) => Promise<T>;\n}\n\nexport enum Base64EncodeHeader {\n encoded = \"x-webiny-base64-encoded\",\n binary = \"x-webiny-binary\"\n}\n\ndeclare module \"fastify\" {\n interface FastifyRequest {\n awsLambda: {\n event: APIGatewayEvent;\n context: LambdaContext;\n };\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAYAA,OAAA;AAOA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,MAAA,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,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAAsC,IAyC1BS,kBAAkB,GAAAJ,OAAA,CAAAI,kBAAA,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { Plugin } from "@webiny/plugins/types";
1
+ import type { Plugin } from "@webiny/plugins/types";
2
2
  type WrappedInput<TInput, TOutput> = TInput & {
3
3
  next: () => Promise<TOutput>;
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_utils","require","createComposedHandler","plugins","composeAsync","map","plugin","next","params","cb","exports"],"sources":["composedHandler.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport { composeAsync } from \"@webiny/utils\";\n\ntype WrappedInput<TInput, TOutput> = TInput & {\n next: () => Promise<TOutput>;\n};\n\nexport const createComposedHandler = <P extends Plugin, TInput, TOutput>(plugins: P[]) => {\n return composeAsync<WrappedInput<TInput, TOutput>, TOutput>(\n plugins.map(plugin => {\n return next => {\n return async params => {\n return plugin.cb({\n ...params,\n next: () => {\n return next(params);\n }\n });\n };\n };\n })\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAMO,MAAMC,qBAAqB,GAAuCC,OAAY,IAAK;EACtF,OAAO,IAAAC,mBAAY,EACfD,OAAO,CAACE,GAAG,CAACC,MAAM,IAAI;IAClB,OAAOC,IAAI,IAAI;MACX,OAAO,MAAMC,MAAM,IAAI;QACnB,OAAOF,MAAM,CAACG,EAAE,CAAC;UACb,GAAGD,MAAM;UACTD,IAAI,EAAEA,CAAA,KAAM;YACR,OAAOA,IAAI,CAACC,MAAM,CAAC;UACvB;QACJ,CAAC,CAAC;MACN,CAAC;IACL,CAAC;EACL,CAAC,CACL,CAAC;AACL,CAAC;AAACE,OAAA,CAAAR,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_utils","require","createComposedHandler","plugins","composeAsync","map","plugin","next","params","cb","exports"],"sources":["composedHandler.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types\";\nimport { composeAsync } from \"@webiny/utils\";\n\ntype WrappedInput<TInput, TOutput> = TInput & {\n next: () => Promise<TOutput>;\n};\n\nexport const createComposedHandler = <P extends Plugin, TInput, TOutput>(plugins: P[]) => {\n return composeAsync<WrappedInput<TInput, TOutput>, TOutput>(\n plugins.map(plugin => {\n return next => {\n return async params => {\n return plugin.cb({\n ...params,\n next: () => {\n return next(params);\n }\n });\n };\n };\n })\n );\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAMO,MAAMC,qBAAqB,GAAuCC,OAAY,IAAK;EACtF,OAAO,IAAAC,mBAAY,EACfD,OAAO,CAACE,GAAG,CAACC,MAAM,IAAI;IAClB,OAAOC,IAAI,IAAI;MACX,OAAO,MAAMC,MAAM,IAAI;QACnB,OAAOF,MAAM,CAACG,EAAE,CAAC;UACb,GAAGD,MAAM;UACTD,IAAI,EAAEA,CAAA,KAAM;YACR,OAAOA,IAAI,CAACC,MAAM,CAAC;UACvB;QACJ,CAAC,CAAC;MACN,CAAC;IACL,CAAC;EACL,CAAC,CACL,CAAC;AACL,CAAC;AAACE,OAAA,CAAAR,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ITimer } from "./abstractions/ITimer";
1
+ import type { ITimer } from "./abstractions/ITimer";
2
2
  export interface ITimerCb {
3
3
  (): number;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"names":["Timer","constructor","cb","getRemainingMilliseconds","getRemainingSeconds","result","Math","floor","exports"],"sources":["Timer.ts"],"sourcesContent":["import { ITimer } from \"./abstractions/ITimer\";\n\nexport interface ITimerCb {\n (): number;\n}\n\nexport class Timer implements ITimer {\n private readonly cb: ITimerCb;\n\n public constructor(cb: ITimerCb) {\n this.cb = cb;\n }\n public getRemainingMilliseconds(): number {\n return this.cb();\n }\n\n public getRemainingSeconds(): number {\n const result = this.cb();\n if (result > 0) {\n return Math.floor(result / 1000);\n }\n return 0;\n }\n}\n"],"mappings":";;;;;;AAMO,MAAMA,KAAK,CAAmB;EAG1BC,WAAWA,CAACC,EAAY,EAAE;IAC7B,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EACOC,wBAAwBA,CAAA,EAAW;IACtC,OAAO,IAAI,CAACD,EAAE,CAAC,CAAC;EACpB;EAEOE,mBAAmBA,CAAA,EAAW;IACjC,MAAMC,MAAM,GAAG,IAAI,CAACH,EAAE,CAAC,CAAC;IACxB,IAAIG,MAAM,GAAG,CAAC,EAAE;MACZ,OAAOC,IAAI,CAACC,KAAK,CAACF,MAAM,GAAG,IAAI,CAAC;IACpC;IACA,OAAO,CAAC;EACZ;AACJ;AAACG,OAAA,CAAAR,KAAA,GAAAA,KAAA","ignoreList":[]}
1
+ {"version":3,"names":["Timer","constructor","cb","getRemainingMilliseconds","getRemainingSeconds","result","Math","floor","exports"],"sources":["Timer.ts"],"sourcesContent":["import type { ITimer } from \"./abstractions/ITimer\";\n\nexport interface ITimerCb {\n (): number;\n}\n\nexport class Timer implements ITimer {\n private readonly cb: ITimerCb;\n\n public constructor(cb: ITimerCb) {\n this.cb = cb;\n }\n public getRemainingMilliseconds(): number {\n return this.cb();\n }\n\n public getRemainingSeconds(): number {\n const result = this.cb();\n if (result > 0) {\n return Math.floor(result / 1000);\n }\n return 0;\n }\n}\n"],"mappings":";;;;;;AAMO,MAAMA,KAAK,CAAmB;EAG1BC,WAAWA,CAACC,EAAY,EAAE;IAC7B,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EACOC,wBAAwBA,CAAA,EAAW;IACtC,OAAO,IAAI,CAACD,EAAE,CAAC,CAAC;EACpB;EAEOE,mBAAmBA,CAAA,EAAW;IACjC,MAAMC,MAAM,GAAG,IAAI,CAACH,EAAE,CAAC,CAAC;IACxB,IAAIG,MAAM,GAAG,CAAC,EAAE;MACZ,OAAOC,IAAI,CAACC,KAAK,CAACF,MAAM,GAAG,IAAI,CAAC;IACpC;IACA,OAAO,CAAC;EACZ;AACJ;AAACG,OAAA,CAAAR,KAAA,GAAAA,KAAA","ignoreList":[]}