@webiny/handler-aws 0.0.0-unstable.aa00eecd97 → 0.0.0-unstable.ac6ebf63c6
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 +2 -0
- package/createHandler.js +29 -0
- package/createHandler.js.map +1 -0
- package/dynamodb/index.d.ts +5 -8
- package/dynamodb/index.js +27 -40
- package/dynamodb/index.js.map +1 -1
- package/dynamodb/plugins/DynamoDBEventHandler.d.ts +8 -7
- package/dynamodb/plugins/DynamoDBEventHandler.js +6 -15
- package/dynamodb/plugins/DynamoDBEventHandler.js.map +1 -1
- package/dynamodb/register.d.ts +1 -0
- package/dynamodb/register.js +26 -0
- package/dynamodb/register.js.map +1 -0
- package/eventBridge/index.d.ts +7 -10
- package/eventBridge/index.js +28 -41
- package/eventBridge/index.js.map +1 -1
- package/eventBridge/plugins/EventBridgeEventHandler.d.ts +8 -7
- package/eventBridge/plugins/EventBridgeEventHandler.js +6 -15
- package/eventBridge/plugins/EventBridgeEventHandler.js.map +1 -1
- package/eventBridge/register.d.ts +4 -0
- package/eventBridge/register.js +19 -0
- package/eventBridge/register.js.map +1 -0
- package/execute.d.ts +1 -1
- package/execute.js +19 -14
- package/execute.js.map +1 -1
- package/gateway/index.d.ts +7 -11
- package/gateway/index.js +28 -39
- package/gateway/index.js.map +1 -1
- package/gateway/register.d.ts +1 -0
- package/gateway/register.js +19 -0
- package/gateway/register.js.map +1 -0
- package/index.d.ts +35 -7
- package/index.js +47 -257
- package/index.js.map +1 -1
- package/package.json +15 -22
- package/plugins/handlerClient.js +12 -18
- package/plugins/handlerClient.js.map +1 -1
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +5 -10
- package/plugins/index.js.map +1 -1
- package/raw/index.d.ts +5 -10
- package/raw/index.js +33 -41
- package/raw/index.js.map +1 -1
- package/raw/plugins/RawEventHandler.d.ts +17 -6
- package/raw/plugins/RawEventHandler.js +22 -13
- package/raw/plugins/RawEventHandler.js.map +1 -1
- package/registry.d.ts +17 -0
- package/registry.js +38 -0
- package/registry.js.map +1 -0
- package/s3/index.d.ts +6 -9
- package/s3/index.js +30 -43
- package/s3/index.js.map +1 -1
- package/s3/plugins/S3EventHandler.d.ts +8 -7
- package/s3/plugins/S3EventHandler.js +6 -15
- package/s3/plugins/S3EventHandler.js.map +1 -1
- package/s3/register.d.ts +4 -0
- package/s3/register.js +23 -0
- package/s3/register.js.map +1 -0
- package/sns/index.d.ts +8 -0
- package/sns/index.js +57 -0
- package/sns/index.js.map +1 -0
- package/sns/plugins/SNSEventHandler.d.ts +20 -0
- package/sns/plugins/SNSEventHandler.js +13 -0
- package/sns/plugins/SNSEventHandler.js.map +1 -0
- package/sns/register.d.ts +1 -0
- package/sns/register.js +23 -0
- package/sns/register.js.map +1 -0
- package/sourceHandler.d.ts +2 -0
- package/sourceHandler.js +5 -0
- package/sourceHandler.js.map +1 -0
- package/sqs/index.d.ts +6 -9
- package/sqs/index.js +34 -44
- package/sqs/index.js.map +1 -1
- package/sqs/plugins/SQSEventHandler.d.ts +8 -7
- package/sqs/plugins/SQSEventHandler.js +6 -15
- package/sqs/plugins/SQSEventHandler.js.map +1 -1
- package/sqs/register.d.ts +1 -0
- package/sqs/register.js +26 -0
- package/sqs/register.js.map +1 -0
- package/types.d.ts +28 -5
- package/types.js +7 -26
- package/types.js.map +1 -1
- package/utils/composedHandler.d.ts +6 -0
- package/utils/composedHandler.js +17 -0
- package/utils/composedHandler.js.map +1 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +4 -0
- package/utils/index.js.map +1 -0
- package/utils/timer/CustomTimer.d.ts +5 -0
- package/utils/timer/CustomTimer.js +12 -0
- package/utils/timer/CustomTimer.js.map +1 -0
- package/utils/timer/Timer.d.ts +10 -0
- package/utils/timer/Timer.js +17 -0
- package/utils/timer/Timer.js.map +1 -0
- package/utils/timer/abstractions/ITimer.d.ts +10 -0
- package/utils/timer/abstractions/ITimer.js +3 -0
- package/utils/timer/abstractions/ITimer.js.map +1 -0
- package/utils/timer/factory.d.ts +4 -0
- package/utils/timer/factory.js +13 -0
- package/utils/timer/factory.js.map +1 -0
- package/utils/timer/index.d.ts +4 -0
- package/utils/timer/index.js +5 -0
- package/utils/timer/index.js.map +1 -0
package/types.js
CHANGED
|
@@ -1,28 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
Base64EncodeHeader: true
|
|
8
|
-
};
|
|
9
|
-
exports.Base64EncodeHeader = void 0;
|
|
10
|
-
require("fastify");
|
|
11
|
-
var _types = require("@webiny/handler/types");
|
|
12
|
-
Object.keys(_types).forEach(function (key) {
|
|
13
|
-
if (key === "default" || key === "__esModule") return;
|
|
14
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
15
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
16
|
-
Object.defineProperty(exports, key, {
|
|
17
|
-
enumerable: true,
|
|
18
|
-
get: function () {
|
|
19
|
-
return _types[key];
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
let Base64EncodeHeader;
|
|
24
|
-
exports.Base64EncodeHeader = Base64EncodeHeader;
|
|
25
|
-
(function (Base64EncodeHeader) {
|
|
1
|
+
import "fastify";
|
|
2
|
+
export * from "@webiny/handler/types.js";
|
|
3
|
+
export let Base64EncodeHeader = /*#__PURE__*/function (Base64EncodeHeader) {
|
|
26
4
|
Base64EncodeHeader["encoded"] = "x-webiny-base64-encoded";
|
|
27
5
|
Base64EncodeHeader["binary"] = "x-webiny-binary";
|
|
28
|
-
|
|
6
|
+
return Base64EncodeHeader;
|
|
7
|
+
}({});
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Base64EncodeHeader"],"sources":["types.ts"],"sourcesContent":["import {
|
|
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":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Plugin } from "@webiny/plugins/types.js";
|
|
2
|
+
type WrappedInput<TInput, TOutput> = TInput & {
|
|
3
|
+
next: () => Promise<TOutput>;
|
|
4
|
+
};
|
|
5
|
+
export declare const createComposedHandler: <P extends Plugin, TInput, TOutput>(plugins: P[]) => import("@webiny/utils").NextAsyncProcessor<WrappedInput<TInput, TOutput>, TOutput>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { composeAsync } from "@webiny/utils";
|
|
2
|
+
export const createComposedHandler = plugins => {
|
|
3
|
+
return composeAsync(plugins.map(plugin => {
|
|
4
|
+
return next => {
|
|
5
|
+
return async params => {
|
|
6
|
+
return plugin.cb({
|
|
7
|
+
...params,
|
|
8
|
+
next: () => {
|
|
9
|
+
return next(params);
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
}));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=composedHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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
ADDED
package/utils/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./composedHandler.js\";\nexport * from \"./timer/index.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const MAX_RUNNING_MINUTES = 14;
|
|
2
|
+
const MAX_RUNNING_MILLISECONDS = MAX_RUNNING_MINUTES * 60 * 1000;
|
|
3
|
+
export class CustomTimer {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.startTime = Date.now();
|
|
6
|
+
}
|
|
7
|
+
getRemainingMilliseconds() {
|
|
8
|
+
return this.startTime + MAX_RUNNING_MILLISECONDS - Date.now(); // 14 minutes
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=CustomTimer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ITimer } from "./abstractions/ITimer.js";
|
|
2
|
+
export interface ITimerCb {
|
|
3
|
+
(): number;
|
|
4
|
+
}
|
|
5
|
+
export declare class Timer implements ITimer {
|
|
6
|
+
private readonly cb;
|
|
7
|
+
constructor(cb: ITimerCb);
|
|
8
|
+
getRemainingMilliseconds(): number;
|
|
9
|
+
getRemainingSeconds(): number;
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export class Timer {
|
|
2
|
+
constructor(cb) {
|
|
3
|
+
this.cb = cb;
|
|
4
|
+
}
|
|
5
|
+
getRemainingMilliseconds() {
|
|
6
|
+
return this.cb();
|
|
7
|
+
}
|
|
8
|
+
getRemainingSeconds() {
|
|
9
|
+
const result = this.cb();
|
|
10
|
+
if (result > 0) {
|
|
11
|
+
return Math.floor(result / 1000);
|
|
12
|
+
}
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=Timer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Timer","constructor","cb","getRemainingMilliseconds","getRemainingSeconds","result","Math","floor"],"sources":["Timer.ts"],"sourcesContent":["import type { ITimer } from \"./abstractions/ITimer.js\";\n\nexport interface ITimerCb {\n (): number;\n}\n\nexport class Timer implements ITimer {\n private readonly cb: ITimerCb;\n\n public constructor(cb: ITimerCb) {\n this.cb = cb;\n }\n public getRemainingMilliseconds(): number {\n return this.cb();\n }\n\n public getRemainingSeconds(): number {\n const result = this.cb();\n if (result > 0) {\n return Math.floor(result / 1000);\n }\n return 0;\n }\n}\n"],"mappings":"AAMA,OAAO,MAAMA,KAAK,CAAmB;EAG1BC,WAAWA,CAACC,EAAY,EAAE;IAC7B,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EACOC,wBAAwBA,CAAA,EAAW;IACtC,OAAO,IAAI,CAACD,EAAE,CAAC,CAAC;EACpB;EAEOE,mBAAmBA,CAAA,EAAW;IACjC,MAAMC,MAAM,GAAG,IAAI,CAACH,EAAE,CAAC,CAAC;IACxB,IAAIG,MAAM,GAAG,CAAC,EAAE;MACZ,OAAOC,IAAI,CAACC,KAAK,CAACF,MAAM,GAAG,IAAI,CAAC;IACpC;IACA,OAAO,CAAC;EACZ;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["ITimer.ts"],"sourcesContent":["export interface ITimer {\n /**\n * Return value must be in milliseconds.\n */\n getRemainingMilliseconds(): number;\n /**\n * Return value must be in seconds.\n */\n getRemainingSeconds(): number;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ITimer } from "./abstractions/ITimer.js";
|
|
2
|
+
import type { Context as LambdaContext } from "@webiny/aws-sdk/types/index.js";
|
|
3
|
+
export type ITimerFactoryParams = Pick<LambdaContext, "getRemainingTimeInMillis">;
|
|
4
|
+
export declare const timerFactory: (params?: Partial<ITimerFactoryParams>) => ITimer;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CustomTimer } from "./CustomTimer.js";
|
|
2
|
+
import { Timer } from "./Timer.js";
|
|
3
|
+
export const timerFactory = params => {
|
|
4
|
+
const customTimer = new CustomTimer();
|
|
5
|
+
return new Timer(() => {
|
|
6
|
+
if (params?.getRemainingTimeInMillis) {
|
|
7
|
+
return params.getRemainingTimeInMillis();
|
|
8
|
+
}
|
|
9
|
+
return customTimer.getRemainingMilliseconds();
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CustomTimer","Timer","timerFactory","params","customTimer","getRemainingTimeInMillis","getRemainingMilliseconds"],"sources":["factory.ts"],"sourcesContent":["import type { ITimer } from \"./abstractions/ITimer.js\";\nimport { CustomTimer } from \"./CustomTimer.js\";\nimport type { Context as LambdaContext } from \"@webiny/aws-sdk/types/index.js\";\nimport { Timer } from \"./Timer.js\";\n\nexport type ITimerFactoryParams = Pick<LambdaContext, \"getRemainingTimeInMillis\">;\n\nexport const timerFactory = (params?: Partial<ITimerFactoryParams>): ITimer => {\n const customTimer = new CustomTimer();\n\n return new Timer(() => {\n if (params?.getRemainingTimeInMillis) {\n return params.getRemainingTimeInMillis();\n }\n return customTimer.getRemainingMilliseconds();\n });\n};\n"],"mappings":"AACA,SAASA,WAAW;AAEpB,SAASC,KAAK;AAId,OAAO,MAAMC,YAAY,GAAIC,MAAqC,IAAa;EAC3E,MAAMC,WAAW,GAAG,IAAIJ,WAAW,CAAC,CAAC;EAErC,OAAO,IAAIC,KAAK,CAAC,MAAM;IACnB,IAAIE,MAAM,EAAEE,wBAAwB,EAAE;MAClC,OAAOF,MAAM,CAACE,wBAAwB,CAAC,CAAC;IAC5C;IACA,OAAOD,WAAW,CAACE,wBAAwB,CAAC,CAAC;EACjD,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type * from \"./abstractions/ITimer.js\";\nexport * from \"./CustomTimer.js\";\nexport * from \"./factory.js\";\nexport * from \"./Timer.js\";\n"],"mappings":"AACA;AACA;AACA","ignoreList":[]}
|