@webiny/handler-aws 0.0.0-unstable.de38392959 → 0.0.0-unstable.e0bfc55d5a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/createHandler.d.ts +1 -1
- package/createHandler.js.map +1 -1
- package/dynamodb/index.d.ts +3 -3
- package/dynamodb/index.js +3 -1
- package/dynamodb/index.js.map +1 -1
- package/dynamodb/plugins/DynamoDBEventHandler.d.ts +2 -2
- package/dynamodb/plugins/DynamoDBEventHandler.js.map +1 -1
- package/dynamodb/register.js.map +1 -1
- package/eventBridge/index.d.ts +3 -3
- package/eventBridge/index.js +3 -1
- package/eventBridge/index.js.map +1 -1
- package/eventBridge/plugins/EventBridgeEventHandler.d.ts +2 -2
- package/eventBridge/plugins/EventBridgeEventHandler.js.map +1 -1
- package/eventBridge/register.d.ts +1 -1
- package/eventBridge/register.js.map +1 -1
- package/execute.d.ts +1 -1
- package/execute.js +9 -0
- package/execute.js.map +1 -1
- package/gateway/index.d.ts +4 -4
- package/gateway/index.js.map +1 -1
- package/gateway/register.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +12 -0
- package/index.js.map +1 -1
- package/package.json +14 -22
- package/plugins/handlerClient.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js.map +1 -1
- package/raw/index.d.ts +3 -4
- package/raw/index.js +10 -1
- package/raw/index.js.map +1 -1
- package/raw/plugins/RawEventHandler.d.ts +16 -5
- package/raw/plugins/RawEventHandler.js +14 -3
- package/raw/plugins/RawEventHandler.js.map +1 -1
- package/registry.d.ts +9 -3
- package/registry.js +9 -3
- package/registry.js.map +1 -1
- package/s3/index.d.ts +3 -4
- package/s3/index.js +3 -1
- package/s3/index.js.map +1 -1
- package/s3/plugins/S3EventHandler.d.ts +2 -2
- package/s3/plugins/S3EventHandler.js.map +1 -1
- package/s3/register.d.ts +1 -1
- package/s3/register.js.map +1 -1
- package/sns/index.d.ts +3 -4
- package/sns/index.js +3 -1
- package/sns/index.js.map +1 -1
- package/sns/plugins/SNSEventHandler.d.ts +2 -2
- package/sns/plugins/SNSEventHandler.js.map +1 -1
- package/sns/register.js.map +1 -1
- package/sourceHandler.d.ts +1 -1
- package/sourceHandler.js.map +1 -1
- package/sqs/index.d.ts +3 -4
- package/sqs/index.js +7 -2
- package/sqs/index.js.map +1 -1
- package/sqs/plugins/SQSEventHandler.d.ts +2 -2
- package/sqs/plugins/SQSEventHandler.js.map +1 -1
- package/sqs/register.js.map +1 -1
- package/types.d.ts +7 -8
- package/types.js +1 -24
- package/types.js.map +1 -1
- package/utils/composedHandler.d.ts +3 -3
- package/utils/composedHandler.js.map +1 -1
- package/utils/index.d.ts +2 -0
- package/utils/index.js +29 -0
- package/utils/index.js.map +1 -0
- package/utils/timer/CustomTimer.d.ts +5 -0
- package/utils/timer/CustomTimer.js +19 -0
- package/utils/timer/CustomTimer.js.map +1 -0
- package/utils/timer/Timer.d.ts +10 -0
- package/utils/timer/Timer.js +24 -0
- package/utils/timer/Timer.js.map +1 -0
- package/utils/timer/abstractions/ITimer.d.ts +10 -0
- package/utils/timer/abstractions/ITimer.js +7 -0
- package/utils/timer/abstractions/ITimer.js.map +1 -0
- package/utils/timer/factory.d.ts +4 -0
- package/utils/timer/factory.js +20 -0
- package/utils/timer/factory.js.map +1 -0
- package/utils/timer/index.d.ts +4 -0
- package/utils/timer/index.js +51 -0
- package/utils/timer/index.js.map +1 -0
|
@@ -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(
|
|
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 =
|
|
19
|
-
return new RawEventHandler(
|
|
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 { Context as BaseContext, Reply } from \"@webiny/handler/types\";\nimport {
|
|
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,10 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* TODO: refactor this to use a proper DI container
|
|
3
|
+
*/
|
|
4
|
+
import type { HandlerEvent, SourceHandler } from "./types";
|
|
5
|
+
import type { Context as LambdaContext } from "@webiny/aws-sdk/types";
|
|
6
|
+
interface RegisterOptions {
|
|
7
|
+
silent?: boolean;
|
|
8
|
+
}
|
|
3
9
|
declare class HandlerRegistry {
|
|
4
10
|
private readonly handlers;
|
|
5
11
|
private constructor();
|
|
6
12
|
static create(): HandlerRegistry;
|
|
7
|
-
register(handler: SourceHandler<any
|
|
13
|
+
register(handler: SourceHandler<any>, options?: RegisterOptions): void;
|
|
8
14
|
getHandler(event: HandlerEvent, context: LambdaContext): SourceHandler;
|
|
9
15
|
}
|
|
10
16
|
export type { HandlerRegistry };
|
package/registry.js
CHANGED
|
@@ -4,6 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.registry = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* TODO: refactor this to use a proper DI container
|
|
9
|
+
*/
|
|
10
|
+
|
|
7
11
|
class HandlerRegistry {
|
|
8
12
|
handlers = new Map();
|
|
9
13
|
constructor() {
|
|
@@ -14,8 +18,11 @@ class HandlerRegistry {
|
|
|
14
18
|
static create() {
|
|
15
19
|
return new HandlerRegistry();
|
|
16
20
|
}
|
|
17
|
-
register(handler) {
|
|
21
|
+
register(handler, options) {
|
|
18
22
|
if (this.handlers.has(handler.name)) {
|
|
23
|
+
if (options?.silent) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
19
26
|
/**
|
|
20
27
|
* This should only happen during the development phase.
|
|
21
28
|
*/
|
|
@@ -32,7 +39,6 @@ class HandlerRegistry {
|
|
|
32
39
|
throw new Error(`There is no handler for the event: ${JSON.stringify(event)}`);
|
|
33
40
|
}
|
|
34
41
|
}
|
|
35
|
-
const registry = HandlerRegistry.create();
|
|
36
|
-
exports.registry = registry;
|
|
42
|
+
const registry = exports.registry = HandlerRegistry.create();
|
|
37
43
|
|
|
38
44
|
//# sourceMappingURL=registry.js.map
|
package/registry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HandlerRegistry","handlers","Map","constructor","create","register","handler","has","name","Error","set","getHandler","event","context","values","canUse","JSON","stringify","registry","exports"],"sources":["registry.ts"],"sourcesContent":["
|
|
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.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { HandlerFactoryParams } from "../types";
|
|
2
|
-
import { APIGatewayProxyResult, S3Event } from "aws-
|
|
3
|
-
import { Context as LambdaContext } from "aws-lambda/handler";
|
|
1
|
+
import type { HandlerFactoryParams } from "../types";
|
|
2
|
+
import type { APIGatewayProxyResult, Context as LambdaContext, S3Event } from "@webiny/aws-sdk/types";
|
|
4
3
|
export * from "./plugins/S3EventHandler";
|
|
5
4
|
export interface HandlerCallable {
|
|
6
5
|
(event: S3Event, context: LambdaContext): Promise<APIGatewayProxyResult>;
|
|
7
6
|
}
|
|
8
|
-
export
|
|
7
|
+
export type HandlerParams = HandlerFactoryParams;
|
|
9
8
|
export declare const createHandler: (params: HandlerParams) => HandlerCallable;
|
package/s3/index.js
CHANGED
|
@@ -27,7 +27,9 @@ var _reply = _interopRequireDefault(require("fastify/lib/reply"));
|
|
|
27
27
|
var _composedHandler = require("../utils/composedHandler");
|
|
28
28
|
/**
|
|
29
29
|
* We need a class, not an interface exported from types.
|
|
30
|
-
*/
|
|
30
|
+
*/
|
|
31
|
+
// @ts-expect-error
|
|
32
|
+
|
|
31
33
|
const url = "/webiny-s3-event";
|
|
32
34
|
const createHandler = params => {
|
|
33
35
|
return async (event, context) => {
|
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
|
|
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,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,eAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,eAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAdA,IAAAS,QAAA,GAAAf,OAAA;AAMA,IAAAgB,MAAA,GAAAC,sBAAA,CAAAjB,OAAA;AAMA,IAAAkB,gBAAA,GAAAlB,OAAA;AAVA;AACA;AACA;AACA;;AAiBA,MAAMmB,GAAG,GAAG,kBAAkB;AAEvB,MAAMC,aAAa,GAAIC,MAAqB,IAAsB;EACrE,OAAO,OAAOC,KAAK,EAAEC,OAAO,KAAK;IAC7B,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,CAACC,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAACC,OAAO,CAAC,CAAC;IACxF,IAAIJ,OAAO,CAACK,MAAM,KAAK,CAAC,EAAE;MACtB,MAAM,IAAIC,KAAK,CAAC,kEAAkE,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,6 +1,6 @@
|
|
|
1
|
+
import type { Context as LambdaContext, S3Event } from "@webiny/aws-sdk/types";
|
|
1
2
|
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import { Context, Reply, Request } from "@webiny/handler/types";
|
|
3
|
-
import { Context as LambdaContext, S3Event } from "aws-lambda";
|
|
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 {
|
|
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
package/s3/register.js.map
CHANGED
|
@@ -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 {
|
|
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.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Context as LambdaContext } from "aws-lambda/handler";
|
|
1
|
+
import type { APIGatewayProxyResult, SNSEvent, Context as LambdaContext } from "@webiny/aws-sdk/types";
|
|
2
|
+
import type { HandlerFactoryParams } from "../types";
|
|
4
3
|
export * from "./plugins/SNSEventHandler";
|
|
5
4
|
export interface HandlerCallable {
|
|
6
5
|
(event: SNSEvent, context: LambdaContext): Promise<APIGatewayProxyResult>;
|
|
7
6
|
}
|
|
8
|
-
export
|
|
7
|
+
export type HandlerParams = HandlerFactoryParams;
|
|
9
8
|
export declare const createHandler: (params: HandlerParams) => HandlerCallable;
|
package/sns/index.js
CHANGED
|
@@ -27,7 +27,9 @@ var _reply = _interopRequireDefault(require("fastify/lib/reply"));
|
|
|
27
27
|
var _composedHandler = require("../utils/composedHandler");
|
|
28
28
|
/**
|
|
29
29
|
* We need a class, not an interface exported from types.
|
|
30
|
-
*/
|
|
30
|
+
*/
|
|
31
|
+
// @ts-expect-error
|
|
32
|
+
|
|
31
33
|
const url = "/webiny-sns-event";
|
|
32
34
|
const createHandler = params => {
|
|
33
35
|
return async (event, context) => {
|
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 { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport {
|
|
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;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;AAExB,MAAMC,aAAa,GAAIC,MAAqB,IAAsB;EACrE,OAAO,OAAOC,KAAK,EAAEC,OAAO,KAAK;IAC7B,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,CAACC,MAAM,CAAkBC,gCAAe,CAACC,IAAI,CAAC,CAACC,OAAO,CAAC,CAAC;IAC1F,IAAIJ,OAAO,CAACK,MAAM,KAAK,CAAC,EAAE;MACtB,MAAM,IAAIC,KAAK,CAAC,oEAAoE,CAAC;IACzF;IAEA,MAAMC,OAAO,GAAG,IAAAC,sCAAqB,EAInCR,OAAO,CAAC;IAEVP,GAAG,CAACgB,IAAI,CAACrB,GAAG,EAAE,OAAOsB,OAAO,EAAEC,KAAK,KAAK;MACpC,MAAMrB,MAA0E,GAAG;QAC/EoB,OAAO;QACPC,KAAK;QACLnB,OAAO,EAAEC,GAAG,CAACM,MAAM;QACnBR,KAAK;QACLqB,aAAa,EAAEpB;MACnB,CAAC;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,6 +1,6 @@
|
|
|
1
|
+
import type { Context as LambdaContext, SNSEvent } from "@webiny/aws-sdk/types";
|
|
1
2
|
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import { Context, Reply, Request } from "@webiny/handler/types";
|
|
3
|
-
import { Context as LambdaContext, SNSEvent } from "aws-lambda";
|
|
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 {
|
|
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":[]}
|
package/sns/register.js.map
CHANGED
|
@@ -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 { registry } from \"~/registry\";\nimport {
|
|
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":[]}
|
package/sourceHandler.d.ts
CHANGED
|
@@ -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>;
|
package/sourceHandler.js.map
CHANGED
|
@@ -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"}
|
|
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,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Context as LambdaContext } from "aws-lambda/handler";
|
|
1
|
+
import type { APIGatewayProxyResult, Context as LambdaContext, SQSEvent } from "@webiny/aws-sdk/types";
|
|
2
|
+
import type { HandlerFactoryParams } from "../types";
|
|
4
3
|
export * from "./plugins/SQSEventHandler";
|
|
5
4
|
export interface HandlerCallable {
|
|
6
5
|
(event: SQSEvent, context: LambdaContext): Promise<APIGatewayProxyResult>;
|
|
7
6
|
}
|
|
8
|
-
export
|
|
7
|
+
export type HandlerParams = HandlerFactoryParams;
|
|
9
8
|
export declare const createHandler: (params: HandlerParams) => HandlerCallable;
|
package/sqs/index.js
CHANGED
|
@@ -27,7 +27,9 @@ var _reply = _interopRequireDefault(require("fastify/lib/reply"));
|
|
|
27
27
|
var _composedHandler = require("../utils/composedHandler");
|
|
28
28
|
/**
|
|
29
29
|
* We need a class, not an interface exported from types.
|
|
30
|
-
*/
|
|
30
|
+
*/
|
|
31
|
+
// @ts-expect-error
|
|
32
|
+
|
|
31
33
|
const url = "/webiny-sqs-event";
|
|
32
34
|
const createHandler = params => {
|
|
33
35
|
return async (event, context) => {
|
|
@@ -63,7 +65,10 @@ const createHandler = params => {
|
|
|
63
65
|
return result;
|
|
64
66
|
}
|
|
65
67
|
app.__webiny_raw_result = result;
|
|
66
|
-
|
|
68
|
+
if (!reply.sent) {
|
|
69
|
+
reply.send({});
|
|
70
|
+
}
|
|
71
|
+
return reply;
|
|
67
72
|
});
|
|
68
73
|
return (0, _execute.execute)({
|
|
69
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 { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins\";\nimport {
|
|
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;AAExB,MAAMC,aAAa,GAAIC,MAAqB,IAAsB;EACrE,OAAO,OAAOC,KAAK,EAAEC,OAAO,KAAK;IAC7B,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,CAACC,MAAM,CAAkBC,gCAAe,CAACC,IAAI,CAAC,CAACC,OAAO,CAAC,CAAC;IAC1F,IAAIJ,OAAO,CAACK,MAAM,KAAK,CAAC,EAAE;MACtB,MAAM,IAAIC,KAAK,CAAC,oEAAoE,CAAC;IACzF;IAEA,MAAMC,OAAO,GAAG,IAAAC,sCAAqB,EAInCR,OAAO,CAAC;IAEVP,GAAG,CAACgB,IAAI,CAACrB,GAAG,EAAE,OAAOsB,OAAO,EAAEC,KAAK,KAAK;MACpC,MAAMrB,MAA0E,GAAG;QAC/EoB,OAAO;QACPC,KAAK;QACLnB,OAAO,EAAEC,GAAG,CAACM,MAAM;QACnBR,KAAK;QACLqB,aAAa,EAAEpB;MACnB,CAAC;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,IAAI,CAACF,KAAK,CAACK,IAAI,EAAE;QACbL,KAAK,CAACM,IAAI,CAAC,CAAC,CAAC,CAAC;MAClB;MACA,OAAON,KAAK;IAChB,CAAC,CAAC;IACF,OAAO,IAAAO,gBAAO,EAAC;MACXzB,GAAG;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
|
+
import type { Context as LambdaContext, SQSEvent } from "@webiny/aws-sdk/types";
|
|
1
2
|
import { Plugin } from "@webiny/plugins/Plugin";
|
|
2
|
-
import { Context, Reply, Request } from "@webiny/handler/types";
|
|
3
|
-
import { Context as LambdaContext, SQSEvent } from "aws-lambda";
|
|
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 {
|
|
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":[]}
|
package/sqs/register.js.map
CHANGED
|
@@ -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 { registry } from \"~/registry\";\nimport {
|
|
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,11 +1,13 @@
|
|
|
1
|
-
import { APIGatewayEvent, Context as LambdaContext,
|
|
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
|
-
import { CreateHandlerParams as BaseCreateHandlerParams } from "@webiny/handler";
|
|
4
|
-
import { LambdaFastifyOptions as LambdaOptions } from "@fastify/aws-lambda";
|
|
3
|
+
import type { CreateHandlerParams as BaseCreateHandlerParams } from "@webiny/handler";
|
|
4
|
+
import type { LambdaFastifyOptions as LambdaOptions } from "@fastify/aws-lambda";
|
|
5
|
+
import type { GenericRecord } from "@webiny/utils";
|
|
6
|
+
export type { AttributeValue, DynamoDBRecord };
|
|
5
7
|
export { HandlerRegistry } from "./registry";
|
|
6
8
|
export * from "@webiny/handler/types";
|
|
7
|
-
export { APIGatewayEvent, LambdaContext, APIGatewayEventRequestContextWithAuthorizer };
|
|
8
|
-
export
|
|
9
|
+
export type { APIGatewayEvent, LambdaContext, APIGatewayEventRequestContextWithAuthorizer };
|
|
10
|
+
export type HandlerEvent = APIGatewayEvent | SNSEvent | SQSEvent | S3Event | EventBridgeEvent<string, string> | DynamoDBStreamEvent | GenericRecord<string>;
|
|
9
11
|
export interface EventResolver<T = any> {
|
|
10
12
|
(event: HandlerEvent, context: LambdaContext): T;
|
|
11
13
|
}
|
|
@@ -30,9 +32,6 @@ export declare enum Base64EncodeHeader {
|
|
|
30
32
|
binary = "x-webiny-binary"
|
|
31
33
|
}
|
|
32
34
|
declare module "fastify" {
|
|
33
|
-
interface FastifyInstance {
|
|
34
|
-
__webiny_raw_result: any;
|
|
35
|
-
}
|
|
36
35
|
interface FastifyRequest {
|
|
37
36
|
awsLambda: {
|
|
38
37
|
event: APIGatewayEvent;
|
package/types.js
CHANGED
|
@@ -5,23 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
7
|
Base64EncodeHeader: true,
|
|
8
|
-
APIGatewayEvent: true,
|
|
9
|
-
LambdaContext: true,
|
|
10
|
-
APIGatewayEventRequestContextWithAuthorizer: true,
|
|
11
8
|
HandlerRegistry: true
|
|
12
9
|
};
|
|
13
|
-
Object.defineProperty(exports, "APIGatewayEvent", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () {
|
|
16
|
-
return _awsLambda.APIGatewayEvent;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Object.defineProperty(exports, "APIGatewayEventRequestContextWithAuthorizer", {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return _awsLambda.APIGatewayEventRequestContextWithAuthorizer;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
10
|
exports.Base64EncodeHeader = void 0;
|
|
26
11
|
Object.defineProperty(exports, "HandlerRegistry", {
|
|
27
12
|
enumerable: true,
|
|
@@ -29,13 +14,6 @@ Object.defineProperty(exports, "HandlerRegistry", {
|
|
|
29
14
|
return _registry.HandlerRegistry;
|
|
30
15
|
}
|
|
31
16
|
});
|
|
32
|
-
Object.defineProperty(exports, "LambdaContext", {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _awsLambda.Context;
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
var _awsLambda = require("aws-lambda");
|
|
39
17
|
require("fastify");
|
|
40
18
|
var _registry = require("./registry");
|
|
41
19
|
var _types = require("@webiny/handler/types");
|
|
@@ -50,11 +28,10 @@ Object.keys(_types).forEach(function (key) {
|
|
|
50
28
|
}
|
|
51
29
|
});
|
|
52
30
|
});
|
|
53
|
-
let Base64EncodeHeader = /*#__PURE__*/function (Base64EncodeHeader) {
|
|
31
|
+
let Base64EncodeHeader = exports.Base64EncodeHeader = /*#__PURE__*/function (Base64EncodeHeader) {
|
|
54
32
|
Base64EncodeHeader["encoded"] = "x-webiny-base64-encoded";
|
|
55
33
|
Base64EncodeHeader["binary"] = "x-webiny-binary";
|
|
56
34
|
return Base64EncodeHeader;
|
|
57
35
|
}({});
|
|
58
|
-
exports.Base64EncodeHeader = Base64EncodeHeader;
|
|
59
36
|
|
|
60
37
|
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
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,6 +1,6 @@
|
|
|
1
|
-
import { Plugin } from "@webiny/plugins/types";
|
|
2
|
-
|
|
1
|
+
import type { Plugin } from "@webiny/plugins/types";
|
|
2
|
+
type WrappedInput<TInput, TOutput> = TInput & {
|
|
3
3
|
next: () => Promise<TOutput>;
|
|
4
4
|
};
|
|
5
|
-
export declare const createComposedHandler: <P extends Plugin
|
|
5
|
+
export declare const createComposedHandler: <P extends Plugin, TInput, TOutput>(plugins: P[]) => import("@webiny/utils").NextAsyncProcessor<WrappedInput<TInput, TOutput>, TOutput>;
|
|
6
6
|
export {};
|
|
@@ -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"}
|
|
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":[]}
|
package/utils/index.d.ts
ADDED
package/utils/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _composedHandler = require("./composedHandler");
|
|
7
|
+
Object.keys(_composedHandler).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _composedHandler[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _composedHandler[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _timer = require("./timer");
|
|
18
|
+
Object.keys(_timer).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _timer[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _timer[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_composedHandler","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_timer"],"sources":["index.ts"],"sourcesContent":["export * from \"./composedHandler\";\nexport * from \"./timer\";\n"],"mappings":";;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,gBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,gBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,gBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|