@webiny/handler-aws 6.0.0-beta.0 → 6.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -14
- package/createHandler.d.ts +1 -1
- package/createHandler.js +12 -12
- package/createHandler.js.map +1 -1
- package/dynamodb/index.d.ts +4 -4
- package/dynamodb/index.js +14 -36
- package/dynamodb/index.js.map +1 -1
- package/dynamodb/plugins/DynamoDBEventHandler.d.ts +4 -4
- package/dynamodb/plugins/DynamoDBEventHandler.js +3 -11
- package/dynamodb/plugins/DynamoDBEventHandler.js.map +1 -1
- package/dynamodb/register.js +6 -8
- package/dynamodb/register.js.map +1 -1
- package/eventBridge/index.d.ts +4 -4
- package/eventBridge/index.js +14 -36
- package/eventBridge/index.js.map +1 -1
- package/eventBridge/plugins/EventBridgeEventHandler.d.ts +4 -4
- package/eventBridge/plugins/EventBridgeEventHandler.js +3 -11
- package/eventBridge/plugins/EventBridgeEventHandler.js.map +1 -1
- package/eventBridge/register.d.ts +1 -1
- package/eventBridge/register.js +6 -8
- package/eventBridge/register.js.map +1 -1
- package/execute.d.ts +1 -1
- package/execute.js +12 -10
- package/execute.js.map +1 -1
- package/gateway/index.d.ts +4 -4
- package/gateway/index.js +16 -30
- package/gateway/index.js.map +1 -1
- package/gateway/register.js +6 -8
- package/gateway/register.js.map +1 -1
- package/index.d.ts +17 -17
- package/index.js +45 -371
- package/index.js.map +1 -1
- package/package.json +15 -34
- package/plugins/handlerClient.js +6 -13
- package/plugins/handlerClient.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +3 -10
- package/plugins/index.js.map +1 -1
- package/raw/index.d.ts +5 -6
- package/raw/index.js +23 -33
- package/raw/index.js.map +1 -1
- package/raw/plugins/RawEventHandler.d.ts +16 -5
- package/raw/plugins/RawEventHandler.js +16 -13
- package/raw/plugins/RawEventHandler.js.map +1 -1
- package/registry.d.ts +2 -2
- package/registry.js +1 -7
- package/registry.js.map +1 -1
- package/s3/index.d.ts +4 -5
- package/s3/index.js +14 -36
- package/s3/index.js.map +1 -1
- package/s3/plugins/S3EventHandler.d.ts +4 -4
- package/s3/plugins/S3EventHandler.js +3 -11
- package/s3/plugins/S3EventHandler.js.map +1 -1
- package/s3/register.d.ts +1 -1
- package/s3/register.js +6 -8
- package/s3/register.js.map +1 -1
- package/sns/index.d.ts +4 -5
- package/sns/index.js +14 -36
- package/sns/index.js.map +1 -1
- package/sns/plugins/SNSEventHandler.d.ts +4 -4
- package/sns/plugins/SNSEventHandler.js +3 -11
- package/sns/plugins/SNSEventHandler.js.map +1 -1
- package/sns/register.js +6 -8
- package/sns/register.js.map +1 -1
- package/sourceHandler.d.ts +2 -2
- package/sourceHandler.js +1 -8
- package/sourceHandler.js.map +1 -1
- package/sqs/index.d.ts +4 -5
- package/sqs/index.js +18 -37
- package/sqs/index.js.map +1 -1
- package/sqs/plugins/SQSEventHandler.d.ts +4 -4
- package/sqs/plugins/SQSEventHandler.js +3 -11
- package/sqs/plugins/SQSEventHandler.js.map +1 -1
- package/sqs/register.js +6 -8
- package/sqs/register.js.map +1 -1
- package/types.d.ts +9 -10
- package/types.js +3 -31
- package/types.js.map +1 -1
- package/utils/composedHandler.d.ts +3 -3
- package/utils/composedHandler.js +3 -10
- package/utils/composedHandler.js.map +1 -1
- package/utils/index.d.ts +2 -2
- package/utils/index.js +2 -27
- package/utils/index.js.map +1 -1
- package/utils/timer/CustomTimer.js +1 -8
- package/utils/timer/CustomTimer.js.map +1 -1
- package/utils/timer/Timer.d.ts +1 -1
- package/utils/timer/Timer.js +1 -8
- package/utils/timer/Timer.js.map +1 -1
- package/utils/timer/abstractions/ITimer.js +1 -5
- package/utils/timer/factory.d.ts +3 -3
- package/utils/timer/factory.js +5 -12
- package/utils/timer/factory.js.map +1 -1
- package/utils/timer/index.d.ts +4 -4
- package/utils/timer/index.js +3 -49
- package/utils/timer/index.js.map +1 -1
package/sns/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createHandler","createBaseHandler","registerDefaultPlugins","SNSEventHandler","execute","Reply","createComposedHandler","url","params","event","context","app","options","logger","debug","webiny","plugins","byType","type","reverse","length","Error","handler","post","request","reply","lambdaContext","result","__webiny_raw_result","send","payload"],"sources":["index.ts"],"sourcesContent":["import type {\n APIGatewayProxyResult,\n SNSEvent,\n Context as LambdaContext\n} from \"@webiny/aws-sdk/types/index.js\";\nimport { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins/index.js\";\nimport type { SNSEventHandlerCallableParams } from \"./plugins/SNSEventHandler.js\";\nimport { SNSEventHandler } from \"./plugins/SNSEventHandler.js\";\nimport { execute } from \"~/execute.js\";\nimport type { HandlerFactoryParams } from \"~/types.js\";\n/**\n * We need a class, not an interface exported from types.\n */\n// @ts-expect-error\nimport Reply from \"fastify/lib/reply.js\";\nimport { createComposedHandler } from \"~/utils/composedHandler.js\";\n\nexport * from \"./plugins/SNSEventHandler.js\";\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,SAASA,aAAa,IAAIC,iBAAiB,QAAQ,iBAAiB;AACpE,SAASC,sBAAsB;AAE/B,SAASC,eAAe;AACxB,SAASC,OAAO;AAEhB;AACA;AACA;AACA;AACA,OAAOC,KAAK,MAAM,sBAAsB;AACxC,SAASC,qBAAqB;AAE9B;AAQA,MAAMC,GAAG,GAAG,mBAAmB;AAE/B,OAAO,MAAMP,aAAa,GAAIQ,MAAqB,IAAsB;EACrE,OAAO,OAAOC,KAAK,EAAEC,OAAO,KAAK;IAC7B,MAAMC,GAAG,GAAGV,iBAAiB,CAAC;MAC1B,GAAGO,MAAM;MACTI,OAAO,EAAE;QACLC,MAAM,EAAEL,MAAM,CAACM,KAAK,KAAK,IAAI;QAC7B,IAAIN,MAAM,CAACI,OAAO,IAAI,CAAC,CAAC;MAC5B;IACJ,CAAC,CAAC;IACF;AACR;AACA;IACQV,sBAAsB,CAACS,GAAG,CAACI,MAAM,CAAC;IAClC;AACR;AACA;IACQ,MAAMC,OAAO,GAAGL,GAAG,CAACI,MAAM,CAACC,OAAO,CAACC,MAAM,CAAkBd,eAAe,CAACe,IAAI,CAAC,CAACC,OAAO,CAAC,CAAC;IAC1F,IAAIH,OAAO,CAACI,MAAM,KAAK,CAAC,EAAE;MACtB,MAAM,IAAIC,KAAK,CAAC,oEAAoE,CAAC;IACzF;IAEA,MAAMC,OAAO,GAAGhB,qBAAqB,CAInCU,OAAO,CAAC;IAEVL,GAAG,CAACY,IAAI,CAAChB,GAAG,EAAE,OAAOiB,OAAO,EAAEC,KAAK,KAAK;MACpC,MAAMjB,MAA0E,GAAG;QAC/EgB,OAAO;QACPC,KAAK;QACLf,OAAO,EAAEC,GAAG,CAACI,MAAM;QACnBN,KAAK;QACLiB,aAAa,EAAEhB;MACnB,CAAC;MAED,MAAMiB,MAAM,GAAG,MAAML,OAAO,CACxBd,MACJ,CAAC;MAED,IAAImB,MAAM,YAAYtB,KAAK,EAAE;QACzB,OAAOsB,MAAM;MACjB;MAEAhB,GAAG,CAACiB,mBAAmB,GAAGD,MAAM;MAChC,OAAOF,KAAK,CAACI,IAAI,CAAC,CAAC,CAAC,CAAC;IACzB,CAAC,CAAC;IACF,OAAOzB,OAAO,CAAC;MACXO,GAAG;MACHJ,GAAG;MACHuB,OAAO,EAAErB;IACb,CAAC,CAAC;EACN,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Context as LambdaContext, SNSEvent } from "aws-
|
|
2
|
-
import { Plugin } from "@webiny/plugins/Plugin";
|
|
3
|
-
import { Context, Reply, Request } from "@webiny/handler/types";
|
|
1
|
+
import type { Context as LambdaContext, SNSEvent } from "@webiny/aws-sdk/types/index.js";
|
|
2
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
3
|
+
import type { Context, Reply, Request } from "@webiny/handler/types.js";
|
|
4
4
|
export interface SNSEventHandlerCallableParams<Response = Reply> {
|
|
5
5
|
request: Request;
|
|
6
6
|
reply: Reply;
|
|
@@ -17,4 +17,4 @@ export declare class SNSEventHandler<Response = any> extends Plugin {
|
|
|
17
17
|
readonly cb: SNSEventHandlerCallable<Response>;
|
|
18
18
|
constructor(cb: SNSEventHandlerCallable<Response>);
|
|
19
19
|
}
|
|
20
|
-
export declare const createEventHandler: <
|
|
20
|
+
export declare const createEventHandler: <Response>(cb: SNSEventHandlerCallable<Response>) => SNSEventHandler<Response>;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createEventHandler = exports.SNSEventHandler = void 0;
|
|
7
|
-
var _Plugin = require("@webiny/plugins/Plugin");
|
|
8
|
-
class SNSEventHandler extends _Plugin.Plugin {
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
export class SNSEventHandler extends Plugin {
|
|
9
3
|
static type = "handler.fastify.aws.sns.eventHandler";
|
|
10
4
|
constructor(cb) {
|
|
11
5
|
super();
|
|
12
6
|
this.cb = cb;
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
const createEventHandler = cb => {
|
|
9
|
+
export const createEventHandler = cb => {
|
|
17
10
|
return new SNSEventHandler(cb);
|
|
18
11
|
};
|
|
19
|
-
exports.createEventHandler = createEventHandler;
|
|
20
12
|
|
|
21
13
|
//# sourceMappingURL=SNSEventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Plugin","SNSEventHandler","type","constructor","cb","createEventHandler"],"sources":["SNSEventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext, SNSEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { Context, Reply, Request } from \"@webiny/handler/types.js\";\n\nexport interface 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,SAASA,MAAM,QAAQ,2BAA2B;AAgBlD,OAAO,MAAMC,eAAe,SAAyBD,MAAM,CAAC;EACxD,OAAuBE,IAAI,GAAG,sCAAsC;EAI7DC,WAAWA,CAACC,EAAqC,EAAE;IACtD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAEA,OAAO,MAAMC,kBAAkB,GAAcD,EAAqC,IAAK;EACnF,OAAO,IAAIH,eAAe,CAAWG,EAAE,CAAC;AAC5C,CAAC","ignoreList":[]}
|
package/sns/register.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _sourceHandler = require("../sourceHandler");
|
|
6
|
-
const handler = (0, _sourceHandler.createSourceHandler)({
|
|
1
|
+
import { registry } from "../registry.js";
|
|
2
|
+
import { createHandler } from "./index.js";
|
|
3
|
+
import { createSourceHandler } from "../sourceHandler.js";
|
|
4
|
+
const handler = createSourceHandler({
|
|
7
5
|
name: "handler-aws-sns",
|
|
8
6
|
canUse: event => {
|
|
9
7
|
if (!Array.isArray(event.Records) || event.Records.length === 0) {
|
|
@@ -17,9 +15,9 @@ const handler = (0, _sourceHandler.createSourceHandler)({
|
|
|
17
15
|
event,
|
|
18
16
|
context
|
|
19
17
|
}) => {
|
|
20
|
-
return
|
|
18
|
+
return createHandler(params)(event, context);
|
|
21
19
|
}
|
|
22
20
|
});
|
|
23
|
-
|
|
21
|
+
registry.register(handler);
|
|
24
22
|
|
|
25
23
|
//# sourceMappingURL=register.js.map
|
package/sns/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["registry","createHandler","createSourceHandler","handler","name","canUse","event","Array","isArray","Records","length","record","Sns","handle","params","context","register"],"sources":["register.ts"],"sourcesContent":["import type { SNSEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport { registry } from \"~/registry.js\";\nimport type { HandlerParams } from \"./index.js\";\nimport { createHandler } from \"./index.js\";\nimport { createSourceHandler } from \"~/sourceHandler.js\";\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,SAASA,QAAQ;AAEjB,SAASC,aAAa;AACtB,SAASC,mBAAmB;AAE5B,MAAMC,OAAO,GAAGD,mBAAmB,CAA0B;EACzDE,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,OAAOd,aAAa,CAACa,MAAM,CAAC,CAACR,KAAK,EAAES,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFf,QAAQ,CAACgB,QAAQ,CAACb,OAAO,CAAC","ignoreList":[]}
|
package/sourceHandler.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SourceHandler, HandlerEvent, HandlerFactoryParams } from "./types";
|
|
2
|
-
export declare const createSourceHandler: <TEvent = HandlerEvent, TParams extends HandlerFactoryParams = HandlerFactoryParams>(handler: SourceHandler<TEvent, TParams
|
|
1
|
+
import type { SourceHandler, HandlerEvent, HandlerFactoryParams } from "./types.js";
|
|
2
|
+
export declare const createSourceHandler: <TEvent = HandlerEvent, TParams extends HandlerFactoryParams = HandlerFactoryParams>(handler: SourceHandler<TEvent, TParams>) => SourceHandler<TEvent, TParams, any>;
|
package/sourceHandler.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createSourceHandler = void 0;
|
|
7
|
-
const createSourceHandler = handler => {
|
|
1
|
+
export const createSourceHandler = handler => {
|
|
8
2
|
return handler;
|
|
9
3
|
};
|
|
10
|
-
exports.createSourceHandler = createSourceHandler;
|
|
11
4
|
|
|
12
5
|
//# sourceMappingURL=sourceHandler.js.map
|
package/sourceHandler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createSourceHandler","handler"
|
|
1
|
+
{"version":3,"names":["createSourceHandler","handler"],"sources":["sourceHandler.ts"],"sourcesContent":["import type { SourceHandler, HandlerEvent, HandlerFactoryParams } from \"~/types.js\";\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":"AAEA,OAAO,MAAMA,mBAAmB,GAI5BC,OAAuC,IACtC;EACD,OAAOA,OAAO;AAClB,CAAC","ignoreList":[]}
|
package/sqs/index.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { APIGatewayProxyResult, SQSEvent } from "aws-
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export * from "./plugins/SQSEventHandler";
|
|
1
|
+
import type { APIGatewayProxyResult, Context as LambdaContext, SQSEvent } from "@webiny/aws-sdk/types/index.js";
|
|
2
|
+
import type { HandlerFactoryParams } from "../types.js";
|
|
3
|
+
export * from "./plugins/SQSEventHandler.js";
|
|
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
|
@@ -1,39 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
createHandler: true
|
|
9
|
-
};
|
|
10
|
-
exports.createHandler = void 0;
|
|
11
|
-
var _handler = require("@webiny/handler");
|
|
12
|
-
var _plugins = require("../plugins");
|
|
13
|
-
var _SQSEventHandler = require("./plugins/SQSEventHandler");
|
|
14
|
-
Object.keys(_SQSEventHandler).forEach(function (key) {
|
|
15
|
-
if (key === "default" || key === "__esModule") return;
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
17
|
-
if (key in exports && exports[key] === _SQSEventHandler[key]) return;
|
|
18
|
-
Object.defineProperty(exports, key, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _SQSEventHandler[key];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
var _execute = require("../execute");
|
|
26
|
-
var _reply = _interopRequireDefault(require("fastify/lib/reply"));
|
|
27
|
-
var _composedHandler = require("../utils/composedHandler");
|
|
1
|
+
import { createHandler as createBaseHandler } from "@webiny/handler";
|
|
2
|
+
import { registerDefaultPlugins } from "../plugins/index.js";
|
|
3
|
+
import { SQSEventHandler } from "./plugins/SQSEventHandler.js";
|
|
4
|
+
import { execute } from "../execute.js";
|
|
28
5
|
/**
|
|
29
6
|
* We need a class, not an interface exported from types.
|
|
30
7
|
*/
|
|
31
8
|
// @ts-expect-error
|
|
32
|
-
|
|
9
|
+
import Reply from "fastify/lib/reply.js";
|
|
10
|
+
import { createComposedHandler } from "../utils/composedHandler.js";
|
|
11
|
+
export * from "./plugins/SQSEventHandler.js";
|
|
33
12
|
const url = "/webiny-sqs-event";
|
|
34
|
-
const createHandler = params => {
|
|
13
|
+
export const createHandler = params => {
|
|
35
14
|
return async (event, context) => {
|
|
36
|
-
const app = (
|
|
15
|
+
const app = createBaseHandler({
|
|
37
16
|
...params,
|
|
38
17
|
options: {
|
|
39
18
|
logger: params.debug === true,
|
|
@@ -43,15 +22,15 @@ const createHandler = params => {
|
|
|
43
22
|
/**
|
|
44
23
|
* We always must add our default plugins to the app.
|
|
45
24
|
*/
|
|
46
|
-
|
|
25
|
+
registerDefaultPlugins(app.webiny);
|
|
47
26
|
/**
|
|
48
27
|
* There must be an event plugin for this handler to work.
|
|
49
28
|
*/
|
|
50
|
-
const plugins = app.webiny.plugins.byType(
|
|
29
|
+
const plugins = app.webiny.plugins.byType(SQSEventHandler.type).reverse();
|
|
51
30
|
if (plugins.length === 0) {
|
|
52
31
|
throw new Error(`To run @webiny/handler-aws/sqs, you must have SQSEventHandler set.`);
|
|
53
32
|
}
|
|
54
|
-
const handler =
|
|
33
|
+
const handler = createComposedHandler(plugins);
|
|
55
34
|
app.post(url, async (request, reply) => {
|
|
56
35
|
const params = {
|
|
57
36
|
request,
|
|
@@ -61,19 +40,21 @@ const createHandler = params => {
|
|
|
61
40
|
lambdaContext: context
|
|
62
41
|
};
|
|
63
42
|
const result = await handler(params);
|
|
64
|
-
if (result instanceof
|
|
43
|
+
if (result instanceof Reply) {
|
|
65
44
|
return result;
|
|
66
45
|
}
|
|
67
46
|
app.__webiny_raw_result = result;
|
|
68
|
-
|
|
47
|
+
if (!reply.sent) {
|
|
48
|
+
reply.send({});
|
|
49
|
+
}
|
|
50
|
+
return reply;
|
|
69
51
|
});
|
|
70
|
-
return
|
|
52
|
+
return execute({
|
|
71
53
|
app,
|
|
72
54
|
url,
|
|
73
55
|
payload: event
|
|
74
56
|
});
|
|
75
57
|
};
|
|
76
58
|
};
|
|
77
|
-
exports.createHandler = createHandler;
|
|
78
59
|
|
|
79
60
|
//# sourceMappingURL=index.js.map
|
package/sqs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createHandler","createBaseHandler","registerDefaultPlugins","SQSEventHandler","execute","Reply","createComposedHandler","url","params","event","context","app","options","logger","debug","webiny","plugins","byType","type","reverse","length","Error","handler","post","request","reply","lambdaContext","result","__webiny_raw_result","sent","send","payload"],"sources":["index.ts"],"sourcesContent":["import type {\n APIGatewayProxyResult,\n Context as LambdaContext,\n SQSEvent\n} from \"@webiny/aws-sdk/types/index.js\";\nimport { createHandler as createBaseHandler } from \"@webiny/handler\";\nimport { registerDefaultPlugins } from \"~/plugins/index.js\";\nimport type { SQSEventHandlerCallableParams } from \"~/sqs/plugins/SQSEventHandler.js\";\nimport { SQSEventHandler } from \"~/sqs/plugins/SQSEventHandler.js\";\nimport { execute } from \"~/execute.js\";\nimport type { HandlerFactoryParams } from \"~/types.js\";\n/**\n * We need a class, not an interface exported from types.\n */\n// @ts-expect-error\nimport Reply from \"fastify/lib/reply.js\";\nimport { createComposedHandler } from \"~/utils/composedHandler.js\";\n\nexport * from \"./plugins/SQSEventHandler.js\";\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,SAASA,aAAa,IAAIC,iBAAiB,QAAQ,iBAAiB;AACpE,SAASC,sBAAsB;AAE/B,SAASC,eAAe;AACxB,SAASC,OAAO;AAEhB;AACA;AACA;AACA;AACA,OAAOC,KAAK,MAAM,sBAAsB;AACxC,SAASC,qBAAqB;AAE9B;AAQA,MAAMC,GAAG,GAAG,mBAAmB;AAE/B,OAAO,MAAMP,aAAa,GAAIQ,MAAqB,IAAsB;EACrE,OAAO,OAAOC,KAAK,EAAEC,OAAO,KAAK;IAC7B,MAAMC,GAAG,GAAGV,iBAAiB,CAAC;MAC1B,GAAGO,MAAM;MACTI,OAAO,EAAE;QACLC,MAAM,EAAEL,MAAM,CAACM,KAAK,KAAK,IAAI;QAC7B,IAAIN,MAAM,CAACI,OAAO,IAAI,CAAC,CAAC;MAC5B;IACJ,CAAC,CAAC;IACF;AACR;AACA;IACQV,sBAAsB,CAACS,GAAG,CAACI,MAAM,CAAC;IAClC;AACR;AACA;IACQ,MAAMC,OAAO,GAAGL,GAAG,CAACI,MAAM,CAACC,OAAO,CAACC,MAAM,CAAkBd,eAAe,CAACe,IAAI,CAAC,CAACC,OAAO,CAAC,CAAC;IAC1F,IAAIH,OAAO,CAACI,MAAM,KAAK,CAAC,EAAE;MACtB,MAAM,IAAIC,KAAK,CAAC,oEAAoE,CAAC;IACzF;IAEA,MAAMC,OAAO,GAAGhB,qBAAqB,CAInCU,OAAO,CAAC;IAEVL,GAAG,CAACY,IAAI,CAAChB,GAAG,EAAE,OAAOiB,OAAO,EAAEC,KAAK,KAAK;MACpC,MAAMjB,MAA0E,GAAG;QAC/EgB,OAAO;QACPC,KAAK;QACLf,OAAO,EAAEC,GAAG,CAACI,MAAM;QACnBN,KAAK;QACLiB,aAAa,EAAEhB;MACnB,CAAC;MAED,MAAMiB,MAAM,GAAG,MAAML,OAAO,CACxBd,MACJ,CAAC;MAED,IAAImB,MAAM,YAAYtB,KAAK,EAAE;QACzB,OAAOsB,MAAM;MACjB;MAEAhB,GAAG,CAACiB,mBAAmB,GAAGD,MAAM;MAChC,IAAI,CAACF,KAAK,CAACI,IAAI,EAAE;QACbJ,KAAK,CAACK,IAAI,CAAC,CAAC,CAAC,CAAC;MAClB;MACA,OAAOL,KAAK;IAChB,CAAC,CAAC;IACF,OAAOrB,OAAO,CAAC;MACXO,GAAG;MACHJ,GAAG;MACHwB,OAAO,EAAEtB;IACb,CAAC,CAAC;EACN,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Context as LambdaContext, SQSEvent } from "aws-
|
|
2
|
-
import { Plugin } from "@webiny/plugins/Plugin";
|
|
3
|
-
import { Context, Reply, Request } from "@webiny/handler/types";
|
|
1
|
+
import type { Context as LambdaContext, SQSEvent } from "@webiny/aws-sdk/types/index.js";
|
|
2
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
3
|
+
import type { Context, Reply, Request } from "@webiny/handler/types.js";
|
|
4
4
|
export interface SQSEventHandlerCallableParams<Response = Reply> {
|
|
5
5
|
request: Request;
|
|
6
6
|
reply: Reply;
|
|
@@ -17,4 +17,4 @@ export declare class SQSEventHandler<Response = any> extends Plugin {
|
|
|
17
17
|
readonly cb: SQSEventHandlerCallable<Response>;
|
|
18
18
|
constructor(cb: SQSEventHandlerCallable<Response>);
|
|
19
19
|
}
|
|
20
|
-
export declare const createEventHandler: <
|
|
20
|
+
export declare const createEventHandler: <Response>(cb: SQSEventHandlerCallable<Response>) => SQSEventHandler<Response>;
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createEventHandler = exports.SQSEventHandler = void 0;
|
|
7
|
-
var _Plugin = require("@webiny/plugins/Plugin");
|
|
8
|
-
class SQSEventHandler extends _Plugin.Plugin {
|
|
1
|
+
import { Plugin } from "@webiny/plugins/Plugin.js";
|
|
2
|
+
export class SQSEventHandler extends Plugin {
|
|
9
3
|
static type = "handler.fastify.aws.sqs.eventHandler";
|
|
10
4
|
constructor(cb) {
|
|
11
5
|
super();
|
|
12
6
|
this.cb = cb;
|
|
13
7
|
}
|
|
14
8
|
}
|
|
15
|
-
|
|
16
|
-
const createEventHandler = cb => {
|
|
9
|
+
export const createEventHandler = cb => {
|
|
17
10
|
return new SQSEventHandler(cb);
|
|
18
11
|
};
|
|
19
|
-
exports.createEventHandler = createEventHandler;
|
|
20
12
|
|
|
21
13
|
//# sourceMappingURL=SQSEventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["Plugin","SQSEventHandler","type","constructor","cb","createEventHandler"],"sources":["SQSEventHandler.ts"],"sourcesContent":["import type { Context as LambdaContext, SQSEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport { Plugin } from \"@webiny/plugins/Plugin.js\";\nimport type { Context, Reply, Request } from \"@webiny/handler/types.js\";\n\nexport interface 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,SAASA,MAAM,QAAQ,2BAA2B;AAgBlD,OAAO,MAAMC,eAAe,SAAyBD,MAAM,CAAC;EACxD,OAAuBE,IAAI,GAAG,sCAAsC;EAI7DC,WAAWA,CAACC,EAAqC,EAAE;IACtD,KAAK,CAAC,CAAC;IACP,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;AACJ;AAEA,OAAO,MAAMC,kBAAkB,GAAcD,EAAqC,IAAK;EACnF,OAAO,IAAIH,eAAe,CAAWG,EAAE,CAAC;AAC5C,CAAC","ignoreList":[]}
|
package/sqs/register.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var _sourceHandler = require("../sourceHandler");
|
|
6
|
-
const handler = (0, _sourceHandler.createSourceHandler)({
|
|
1
|
+
import { registry } from "../registry.js";
|
|
2
|
+
import { createHandler } from "./index.js";
|
|
3
|
+
import { createSourceHandler } from "../sourceHandler.js";
|
|
4
|
+
const handler = createSourceHandler({
|
|
7
5
|
name: "handler-aws-sqs",
|
|
8
6
|
canUse: event => {
|
|
9
7
|
if (!Array.isArray(event.Records) || event.Records.length === 0) {
|
|
@@ -20,9 +18,9 @@ const handler = (0, _sourceHandler.createSourceHandler)({
|
|
|
20
18
|
event,
|
|
21
19
|
context
|
|
22
20
|
}) => {
|
|
23
|
-
return
|
|
21
|
+
return createHandler(params)(event, context);
|
|
24
22
|
}
|
|
25
23
|
});
|
|
26
|
-
|
|
24
|
+
registry.register(handler);
|
|
27
25
|
|
|
28
26
|
//# sourceMappingURL=register.js.map
|
package/sqs/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["registry","createHandler","createSourceHandler","handler","name","canUse","event","Array","isArray","Records","length","record","eventSource","toLowerCase","handle","params","context","register"],"sources":["register.ts"],"sourcesContent":["import type { SQSEvent } from \"@webiny/aws-sdk/types/index.js\";\nimport { registry } from \"~/registry.js\";\nimport type { HandlerParams } from \"./index.js\";\nimport { createHandler } from \"./index.js\";\nimport { createSourceHandler } from \"~/sourceHandler.js\";\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,SAASA,QAAQ;AAEjB,SAASC,aAAa;AACtB,SAASC,mBAAmB;AAE5B,MAAMC,OAAO,GAAGD,mBAAmB,CAA0B;EACzDE,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,OAAOf,aAAa,CAACc,MAAM,CAAC,CAACT,KAAK,EAAEU,OAAO,CAAC;EAChD;AACJ,CAAC,CAAC;AAEFhB,QAAQ,CAACiB,QAAQ,CAACd,OAAO,CAAC","ignoreList":[]}
|
package/types.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type { APIGatewayEvent, Context as LambdaContext,
|
|
1
|
+
import type { APIGatewayEvent, APIGatewayEventRequestContextWithAuthorizer, AttributeValue, Context as LambdaContext, DynamoDBRecord, DynamoDBStreamEvent, EventBridgeEvent, S3Event, SNSEvent, SQSEvent } from "@webiny/aws-sdk/types/index.js";
|
|
2
2
|
import "fastify";
|
|
3
|
-
import { CreateHandlerParams as BaseCreateHandlerParams } from "@webiny/handler";
|
|
4
|
-
import { LambdaFastifyOptions as LambdaOptions } from "@fastify/aws-lambda";
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export {
|
|
8
|
-
export
|
|
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 };
|
|
7
|
+
export type { HandlerRegistry } from "./registry.js";
|
|
8
|
+
export * from "@webiny/handler/types.js";
|
|
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
|
@@ -1,34 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
Base64EncodeHeader: true,
|
|
8
|
-
HandlerRegistry: true
|
|
9
|
-
};
|
|
10
|
-
exports.Base64EncodeHeader = void 0;
|
|
11
|
-
Object.defineProperty(exports, "HandlerRegistry", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return _registry.HandlerRegistry;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
require("fastify");
|
|
18
|
-
var _registry = require("./registry");
|
|
19
|
-
var _types = require("@webiny/handler/types");
|
|
20
|
-
Object.keys(_types).forEach(function (key) {
|
|
21
|
-
if (key === "default" || key === "__esModule") return;
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
23
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
24
|
-
Object.defineProperty(exports, key, {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _types[key];
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
let Base64EncodeHeader = exports.Base64EncodeHeader = /*#__PURE__*/function (Base64EncodeHeader) {
|
|
1
|
+
import "fastify";
|
|
2
|
+
export * from "@webiny/handler/types.js";
|
|
3
|
+
export let Base64EncodeHeader = /*#__PURE__*/function (Base64EncodeHeader) {
|
|
32
4
|
Base64EncodeHeader["encoded"] = "x-webiny-base64-encoded";
|
|
33
5
|
Base64EncodeHeader["binary"] = "x-webiny-binary";
|
|
34
6
|
return Base64EncodeHeader;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["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/index.js\";\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 type { HandlerRegistry } from \"~/registry.js\";\n\nexport * from \"@webiny/handler/types.js\";\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":"AAYA,OAAO,SAAS;AAShB,cAAc,0BAA0B;AAyCxC,WAAYA,kBAAkB,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.js";
|
|
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 {};
|
package/utils/composedHandler.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createComposedHandler = void 0;
|
|
7
|
-
var _utils = require("@webiny/utils");
|
|
8
|
-
const createComposedHandler = plugins => {
|
|
9
|
-
return (0, _utils.composeAsync)(plugins.map(plugin => {
|
|
1
|
+
import { composeAsync } from "@webiny/utils";
|
|
2
|
+
export const createComposedHandler = plugins => {
|
|
3
|
+
return composeAsync(plugins.map(plugin => {
|
|
10
4
|
return next => {
|
|
11
5
|
return async params => {
|
|
12
6
|
return plugin.cb({
|
|
@@ -19,6 +13,5 @@ const createComposedHandler = plugins => {
|
|
|
19
13
|
};
|
|
20
14
|
}));
|
|
21
15
|
};
|
|
22
|
-
exports.createComposedHandler = createComposedHandler;
|
|
23
16
|
|
|
24
17
|
//# sourceMappingURL=composedHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["composeAsync","createComposedHandler","plugins","map","plugin","next","params","cb"],"sources":["composedHandler.ts"],"sourcesContent":["import type { Plugin } from \"@webiny/plugins/types.js\";\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,SAASA,YAAY,QAAQ,eAAe;AAM5C,OAAO,MAAMC,qBAAqB,GAAuCC,OAAY,IAAK;EACtF,OAAOF,YAAY,CACfE,OAAO,CAACC,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","ignoreList":[]}
|
package/utils/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./composedHandler";
|
|
2
|
-
export * from "./timer";
|
|
1
|
+
export * from "./composedHandler.js";
|
|
2
|
+
export * from "./timer/index.js";
|
package/utils/index.js
CHANGED
|
@@ -1,29 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
});
|
|
1
|
+
export * from "./composedHandler.js";
|
|
2
|
+
export * from "./timer/index.js";
|
|
28
3
|
|
|
29
4
|
//# sourceMappingURL=index.js.map
|
package/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./composedHandler.js\";\nexport * from \"./timer/index.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.CustomTimer = void 0;
|
|
7
1
|
const MAX_RUNNING_MINUTES = 14;
|
|
8
2
|
const MAX_RUNNING_MILLISECONDS = MAX_RUNNING_MINUTES * 60 * 1000;
|
|
9
|
-
class CustomTimer {
|
|
3
|
+
export class CustomTimer {
|
|
10
4
|
constructor() {
|
|
11
5
|
this.startTime = Date.now();
|
|
12
6
|
}
|
|
@@ -14,6 +8,5 @@ class CustomTimer {
|
|
|
14
8
|
return this.startTime + MAX_RUNNING_MILLISECONDS - Date.now(); // 14 minutes
|
|
15
9
|
}
|
|
16
10
|
}
|
|
17
|
-
exports.CustomTimer = CustomTimer;
|
|
18
11
|
|
|
19
12
|
//# sourceMappingURL=CustomTimer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MAX_RUNNING_MINUTES","MAX_RUNNING_MILLISECONDS","CustomTimer","constructor","startTime","Date","now","getRemainingMilliseconds"
|
|
1
|
+
{"version":3,"names":["MAX_RUNNING_MINUTES","MAX_RUNNING_MILLISECONDS","CustomTimer","constructor","startTime","Date","now","getRemainingMilliseconds"],"sources":["CustomTimer.ts"],"sourcesContent":["const MAX_RUNNING_MINUTES = 14;\nconst MAX_RUNNING_MILLISECONDS = MAX_RUNNING_MINUTES * 60 * 1000;\n\nexport class CustomTimer {\n private readonly startTime: number;\n\n public constructor() {\n this.startTime = Date.now();\n }\n\n public getRemainingMilliseconds(): number {\n return this.startTime + MAX_RUNNING_MILLISECONDS - Date.now(); // 14 minutes\n }\n}\n"],"mappings":"AAAA,MAAMA,mBAAmB,GAAG,EAAE;AAC9B,MAAMC,wBAAwB,GAAGD,mBAAmB,GAAG,EAAE,GAAG,IAAI;AAEhE,OAAO,MAAME,WAAW,CAAC;EAGdC,WAAWA,CAAA,EAAG;IACjB,IAAI,CAACC,SAAS,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC;EAC/B;EAEOC,wBAAwBA,CAAA,EAAW;IACtC,OAAO,IAAI,CAACH,SAAS,GAAGH,wBAAwB,GAAGI,IAAI,CAACC,GAAG,CAAC,CAAC,CAAC,CAAC;EACnE;AACJ","ignoreList":[]}
|
package/utils/timer/Timer.d.ts
CHANGED