@creator.co/wapi 1.2.4 → 1.2.6
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/.github/workflows/npmpublish.yml +1 -1
- package/README.md +216 -5
- package/dist/index.d.ts +15 -0
- package/dist/index.js.map +1 -1
- package/dist/jest.config.js +1 -1
- package/dist/jest.config.js.map +1 -1
- package/dist/package.json +13 -2
- package/dist/src/API/Request.d.ts +45 -82
- package/dist/src/API/Request.js +49 -77
- package/dist/src/API/Request.js.map +1 -1
- package/dist/src/API/Response.d.ts +94 -163
- package/dist/src/API/Response.js +101 -161
- package/dist/src/API/Response.js.map +1 -1
- package/dist/src/API/Utils.d.ts +21 -42
- package/dist/src/API/Utils.js +22 -43
- package/dist/src/API/Utils.js.map +1 -1
- package/dist/src/BaseEvent/EventProcessor.d.ts +32 -55
- package/dist/src/BaseEvent/EventProcessor.js +30 -38
- package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
- package/dist/src/BaseEvent/Process.d.ts +20 -43
- package/dist/src/BaseEvent/Process.js +16 -27
- package/dist/src/BaseEvent/Process.js.map +1 -1
- package/dist/src/BaseEvent/Transaction.d.ts +104 -2
- package/dist/src/BaseEvent/Transaction.js +196 -41
- package/dist/src/BaseEvent/Transaction.js.map +1 -1
- package/dist/src/Config/Configuration.d.ts +48 -66
- package/dist/src/Config/Configuration.js +25 -42
- package/dist/src/Config/Configuration.js.map +1 -1
- package/dist/src/Config/EnvironmentVar.d.ts +30 -57
- package/dist/src/Config/EnvironmentVar.js +28 -41
- package/dist/src/Config/EnvironmentVar.js.map +1 -1
- package/dist/src/Crypto/Crypto.d.ts +17 -35
- package/dist/src/Crypto/Crypto.js +12 -21
- package/dist/src/Crypto/Crypto.js.map +1 -1
- package/dist/src/Crypto/JWT.d.ts +21 -32
- package/dist/src/Crypto/JWT.js +14 -22
- package/dist/src/Crypto/JWT.js.map +1 -1
- package/dist/src/Database/Database.d.ts +18 -0
- package/dist/src/Database/Database.js +18 -0
- package/dist/src/Database/Database.js.map +1 -0
- package/dist/src/Database/DatabaseManager.d.ts +32 -0
- package/dist/src/Database/DatabaseManager.js +50 -0
- package/dist/src/Database/DatabaseManager.js.map +1 -0
- package/dist/src/Database/DatabaseTransaction.d.ts +65 -0
- package/dist/src/Database/DatabaseTransaction.js +183 -0
- package/dist/src/Database/DatabaseTransaction.js.map +1 -0
- package/dist/src/Database/integrations/knex/KnexDatabase.d.ts +22 -0
- package/dist/src/Database/integrations/knex/KnexDatabase.js +108 -0
- package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -0
- package/dist/src/Database/integrations/knex/KnexTransaction.d.ts +37 -0
- package/dist/src/Database/integrations/knex/KnexTransaction.js +60 -0
- package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -0
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +30 -0
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +108 -0
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -0
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.d.ts +37 -0
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +60 -0
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -0
- package/dist/src/Globals.d.ts +26 -94
- package/dist/src/Globals.js +26 -95
- package/dist/src/Globals.js.map +1 -1
- package/dist/src/Logger/Logger.d.ts +82 -105
- package/dist/src/Logger/Logger.js +111 -136
- package/dist/src/Logger/Logger.js.map +1 -1
- package/dist/src/Mailer/Mailer.d.ts +39 -75
- package/dist/src/Mailer/Mailer.js +36 -65
- package/dist/src/Mailer/Mailer.js.map +1 -1
- package/dist/src/Publisher/Publisher.d.ts +17 -25
- package/dist/src/Publisher/Publisher.js +21 -32
- package/dist/src/Publisher/Publisher.js.map +1 -1
- package/dist/src/Server/RouteResolver.d.ts +14 -22
- package/dist/src/Server/RouteResolver.js +21 -34
- package/dist/src/Server/RouteResolver.js.map +1 -1
- package/dist/src/Server/Router.d.ts +72 -51
- package/dist/src/Server/Router.js +8 -17
- package/dist/src/Server/Router.js.map +1 -1
- package/dist/src/Server/lib/ContainerServer.d.ts +15 -31
- package/dist/src/Server/lib/ContainerServer.js +13 -28
- package/dist/src/Server/lib/ContainerServer.js.map +1 -1
- package/dist/src/Server/lib/Server.d.ts +17 -32
- package/dist/src/Server/lib/Server.js +18 -28
- package/dist/src/Server/lib/Server.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandler.d.ts +5 -0
- package/dist/src/Server/lib/container/GenericHandler.js +16 -3
- package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandlerEvent.d.ts +22 -37
- package/dist/src/Server/lib/container/GenericHandlerEvent.js +29 -41
- package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
- package/dist/src/Server/lib/container/HealthHandler.d.ts +6 -0
- package/dist/src/Server/lib/container/HealthHandler.js +6 -0
- package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
- package/dist/src/Server/lib/container/Proxy.d.ts +24 -52
- package/dist/src/Server/lib/container/Proxy.js +52 -52
- package/dist/src/Server/lib/container/Proxy.js.map +1 -1
- package/dist/src/Server/lib/container/Utils.d.ts +6 -10
- package/dist/src/Server/lib/container/Utils.js +6 -10
- package/dist/src/Server/lib/container/Utils.js.map +1 -1
- package/dist/src/Validation/Validator.d.ts +9 -13
- package/dist/src/Validation/Validator.js +8 -12
- package/dist/src/Validation/Validator.js.map +1 -1
- package/index.ts +15 -0
- package/jest.config.ts +1 -1
- package/package.json +13 -2
- package/src/API/Request.ts +66 -84
- package/src/API/Response.ts +144 -203
- package/src/API/Utils.ts +28 -44
- package/src/BaseEvent/EventProcessor.ts +52 -77
- package/src/BaseEvent/Process.ts +27 -52
- package/src/BaseEvent/Transaction.ts +147 -27
- package/src/Config/Configuration.ts +59 -76
- package/src/Config/EnvironmentVar.ts +39 -62
- package/src/Crypto/Crypto.ts +20 -36
- package/src/Crypto/JWT.ts +31 -35
- package/src/Database/Database.ts +19 -0
- package/src/Database/DatabaseManager.ts +51 -0
- package/src/Database/DatabaseTransaction.ts +118 -0
- package/src/Database/integrations/knex/KnexDatabase.ts +47 -0
- package/src/Database/integrations/knex/KnexTransaction.ts +51 -0
- package/src/Database/integrations/pgsql/PostgresDatabase.ts +49 -0
- package/src/Database/integrations/pgsql/PostgresTransaction.ts +54 -0
- package/src/Database/types.d.ts +49 -0
- package/src/Globals.ts +28 -96
- package/src/Logger/Logger.ts +141 -160
- package/src/Mailer/Mailer.ts +43 -76
- package/src/Publisher/Publisher.ts +31 -40
- package/src/Server/RouteResolver.ts +31 -52
- package/src/Server/Router.ts +75 -54
- package/src/Server/lib/ContainerServer.ts +20 -32
- package/src/Server/lib/Server.ts +19 -34
- package/src/Server/lib/container/GenericHandler.ts +17 -3
- package/src/Server/lib/container/GenericHandlerEvent.ts +44 -54
- package/src/Server/lib/container/HealthHandler.ts +6 -0
- package/src/Server/lib/container/Proxy.ts +39 -58
- package/src/Server/lib/container/Utils.ts +7 -10
- package/src/Validation/Validator.ts +11 -13
- package/tests/API/Response.test.ts +55 -56
- package/tests/BaseEvent/EventProcessor.test.ts +49 -50
- package/tests/BaseEvent/Process.test.ts +2 -2
- package/tests/BaseEvent/Transaction.test.ts +102 -44
- package/tests/Config/Config.test.ts +27 -27
- package/tests/Config/EnvironmentVar.test.ts +54 -18
- package/tests/Database/DatabaseManager.test.ts +55 -0
- package/tests/Database/integrations/knex/KnexDatabase.test.ts +53 -0
- package/tests/Database/integrations/knex/KnexTransaction.test.ts +133 -0
- package/tests/Database/integrations/pg/PostgresDatabase.test.ts +50 -0
- package/tests/Database/integrations/pg/PostgresTransaction.test.ts +51 -0
- package/tests/Publisher/Publisher.test.ts +3 -3
- package/tests/Server/lib/ContainerServer.test.ts +21 -22
- package/tests/Server/lib/container/GenericHandler.test.ts +31 -32
- package/tests/Server/lib/container/GenericHandlerEvent.test.ts +2 -2
- package/tests/Server/lib/container/HealthHandler.test.ts +6 -7
- package/tests/Server/lib/container/Proxy.test.ts +37 -35
- package/tsconfig.json +6 -1
|
@@ -2,80 +2,57 @@ import type { Context, SQSBatchResponse, SQSEvent } from 'aws-lambda';
|
|
|
2
2
|
import Transaction, { TransactionConfig } from './Transaction';
|
|
3
3
|
import Response, { ResponseErrorType } from '../API/Response';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
* @
|
|
9
|
-
* @template ResponseInnerType
|
|
5
|
+
* Type definition for an event processor execution function.
|
|
6
|
+
* @param {Transaction<null, ResponseInnerType | ResponseErrorType, SQSBatchResponse>} transaction - The transaction object.
|
|
7
|
+
* @param {string | object} recordContent - The content of the record being processed.
|
|
8
|
+
* @returns {Promise<Response<ResponseInnerType | ResponseErrorType> | SQSBatchResponse>} - A promise that resolves to the response or batch response.
|
|
10
9
|
*/
|
|
11
|
-
export type EventProcessorExecution<ResponseInnerType> = (transaction: Transaction<null, ResponseInnerType | ResponseErrorType, SQSBatchResponse>, recordContent: string | object) => Promise<Response<ResponseInnerType | ResponseErrorType> | SQSBatchResponse>;
|
|
10
|
+
export type EventProcessorExecution<ResponseInnerType> = (transaction: Transaction<null, ResponseInnerType | ResponseErrorType, SQSBatchResponse | null>, recordContent: string | object) => Promise<Response<ResponseInnerType | ResponseErrorType> | SQSBatchResponse | null>;
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @export
|
|
16
|
-
* @class EventProcessor
|
|
17
|
-
* @typedef {EventProcessor}
|
|
18
|
-
* @template ResponseInnerType
|
|
12
|
+
* EventProcessor class that processes events from an SQS queue.
|
|
13
|
+
* @template ResponseInnerType - The type of the inner response object.
|
|
19
14
|
*/
|
|
20
15
|
export default class EventProcessor<ResponseInnerType> {
|
|
21
16
|
/**
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @private
|
|
17
|
+
* A boolean flag indicating whether failures are allowed or not.
|
|
25
18
|
* @readonly
|
|
26
|
-
* @type {boolean}
|
|
27
19
|
*/
|
|
28
|
-
private readonly
|
|
20
|
+
private readonly allowFailure;
|
|
29
21
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @private
|
|
33
|
-
* @readonly
|
|
34
|
-
* @type {TransactionConfig}
|
|
22
|
+
* The configuration object for the API transaction.
|
|
35
23
|
*/
|
|
36
|
-
private readonly
|
|
24
|
+
private readonly config;
|
|
37
25
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @private
|
|
41
|
-
* @readonly
|
|
26
|
+
* The private readonly context property of the class.
|
|
42
27
|
* @type {Context}
|
|
43
28
|
*/
|
|
44
|
-
private readonly
|
|
29
|
+
private readonly context;
|
|
45
30
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @private
|
|
49
|
-
* @readonly
|
|
50
|
-
* @type {SQSEvent}
|
|
31
|
+
* The SQS event object that triggered the Lambda function.
|
|
51
32
|
*/
|
|
52
|
-
private readonly
|
|
33
|
+
private readonly event;
|
|
53
34
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @
|
|
57
|
-
* @param {
|
|
58
|
-
* @param {
|
|
59
|
-
* @
|
|
60
|
-
* @param {?boolean} [allowFailure]
|
|
35
|
+
* Constructs a new instance of the class.
|
|
36
|
+
* @param {SQSEvent} event - The event object representing the incoming SQS message.
|
|
37
|
+
* @param {Context} context - The context object representing the AWS Lambda execution context.
|
|
38
|
+
* @param {TransactionConfig} [config] - Optional configuration object for the transaction.
|
|
39
|
+
* @param {boolean} [allowFailure] - Optional flag indicating whether to allow failure for the transaction.
|
|
40
|
+
* @returns None
|
|
61
41
|
*/
|
|
62
42
|
constructor(event: SQSEvent, context: Context, config?: TransactionConfig, allowFailure?: boolean);
|
|
63
43
|
/**
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* @
|
|
67
|
-
* @
|
|
68
|
-
* @
|
|
69
|
-
* @returns {(Promise<Response<ResponseErrorType> | null | SQSBatchResponse>)}
|
|
44
|
+
* Processes an event using the provided execution object and returns a response.
|
|
45
|
+
* @param {EventProcessorExecution<ResponseInnerType>} execution - The execution object containing the event to process.
|
|
46
|
+
* @param {boolean} [doNotDecodeMessage] - Optional flag indicating whether to decode the message.
|
|
47
|
+
* @returns {Promise<Response<ResponseErrorType> | null | SQSBatchResponse>} - A promise that resolves to the response object, or null if no response is available.
|
|
48
|
+
* @throws {Error} - Throws an error if the response code is not within the range of 200 to 299 and failure is not allowed.
|
|
70
49
|
*/
|
|
71
|
-
processEvent(execution: EventProcessorExecution<ResponseInnerType>, doNotDecodeMessage?: boolean): Promise<Response<ResponseErrorType> | null | SQSBatchResponse>;
|
|
50
|
+
processEvent(execution: EventProcessorExecution<ResponseInnerType>, doNotDecodeMessage?: boolean): Promise<Response<ResponseErrorType | null> | null | SQSBatchResponse>;
|
|
72
51
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* @
|
|
76
|
-
* @
|
|
77
|
-
* @param {boolean} doNotDecodeMessage
|
|
78
|
-
* @returns {(Promise<Response<ResponseErrorType> | null | SQSBatchResponse>)}
|
|
52
|
+
* Processes a raw event by executing the provided execution function and handling any errors or failures.
|
|
53
|
+
* @param {EventProcessorExecution<ResponseInnerType>} execution - The execution function to process the event.
|
|
54
|
+
* @param {boolean} doNotDecodeMessage - Flag indicating whether to decode the message or not.
|
|
55
|
+
* @returns {Promise<Response<ResponseErrorType> | null | SQSBatchResponse>} - A promise that resolves to a response object, null, or a SQS batch response.
|
|
79
56
|
*/
|
|
80
|
-
|
|
57
|
+
private processRawEvent;
|
|
81
58
|
}
|
|
@@ -51,46 +51,40 @@ var Transaction_1 = require("./Transaction");
|
|
|
51
51
|
var Response_1 = require("../API/Response");
|
|
52
52
|
var Globals_1 = require("../Globals");
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @export
|
|
57
|
-
* @class EventProcessor
|
|
58
|
-
* @typedef {EventProcessor}
|
|
59
|
-
* @template ResponseInnerType
|
|
54
|
+
* EventProcessor class that processes events from an SQS queue.
|
|
55
|
+
* @template ResponseInnerType - The type of the inner response object.
|
|
60
56
|
*/
|
|
61
57
|
var EventProcessor = /** @class */ (function () {
|
|
62
58
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* @
|
|
66
|
-
* @param {
|
|
67
|
-
* @param {
|
|
68
|
-
* @
|
|
69
|
-
* @param {?boolean} [allowFailure]
|
|
59
|
+
* Constructs a new instance of the class.
|
|
60
|
+
* @param {SQSEvent} event - The event object representing the incoming SQS message.
|
|
61
|
+
* @param {Context} context - The context object representing the AWS Lambda execution context.
|
|
62
|
+
* @param {TransactionConfig} [config] - Optional configuration object for the transaction.
|
|
63
|
+
* @param {boolean} [allowFailure] - Optional flag indicating whether to allow failure for the transaction.
|
|
64
|
+
* @returns None
|
|
70
65
|
*/
|
|
71
66
|
function EventProcessor(event, context, config, allowFailure) {
|
|
72
|
-
this.
|
|
73
|
-
this.
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
67
|
+
this.event = event;
|
|
68
|
+
this.context = context;
|
|
69
|
+
this.config = config || {};
|
|
70
|
+
this.allowFailure = !!allowFailure;
|
|
76
71
|
}
|
|
77
72
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @
|
|
81
|
-
* @
|
|
82
|
-
* @
|
|
83
|
-
* @returns {(Promise<Response<ResponseErrorType> | null | SQSBatchResponse>)}
|
|
73
|
+
* Processes an event using the provided execution object and returns a response.
|
|
74
|
+
* @param {EventProcessorExecution<ResponseInnerType>} execution - The execution object containing the event to process.
|
|
75
|
+
* @param {boolean} [doNotDecodeMessage] - Optional flag indicating whether to decode the message.
|
|
76
|
+
* @returns {Promise<Response<ResponseErrorType> | null | SQSBatchResponse>} - A promise that resolves to the response object, or null if no response is available.
|
|
77
|
+
* @throws {Error} - Throws an error if the response code is not within the range of 200 to 299 and failure is not allowed.
|
|
84
78
|
*/
|
|
85
79
|
EventProcessor.prototype.processEvent = function (execution, doNotDecodeMessage) {
|
|
86
80
|
return __awaiter(this, void 0, void 0, function () {
|
|
87
81
|
var resp;
|
|
88
82
|
return __generator(this, function (_a) {
|
|
89
83
|
switch (_a.label) {
|
|
90
|
-
case 0: return [4 /*yield*/, this.
|
|
84
|
+
case 0: return [4 /*yield*/, this.processRawEvent(execution, !!doNotDecodeMessage)];
|
|
91
85
|
case 1:
|
|
92
86
|
resp = _a.sent();
|
|
93
|
-
if (!this.
|
|
87
|
+
if (!this.allowFailure &&
|
|
94
88
|
resp &&
|
|
95
89
|
resp instanceof Response_1.default &&
|
|
96
90
|
!(resp.getCode() >= 200 && resp.getCode() < 300))
|
|
@@ -103,26 +97,24 @@ var EventProcessor = /** @class */ (function () {
|
|
|
103
97
|
});
|
|
104
98
|
};
|
|
105
99
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* @
|
|
109
|
-
* @
|
|
110
|
-
* @param {boolean} doNotDecodeMessage
|
|
111
|
-
* @returns {(Promise<Response<ResponseErrorType> | null | SQSBatchResponse>)}
|
|
100
|
+
* Processes a raw event by executing the provided execution function and handling any errors or failures.
|
|
101
|
+
* @param {EventProcessorExecution<ResponseInnerType>} execution - The execution function to process the event.
|
|
102
|
+
* @param {boolean} doNotDecodeMessage - Flag indicating whether to decode the message or not.
|
|
103
|
+
* @returns {Promise<Response<ResponseErrorType> | null | SQSBatchResponse>} - A promise that resolves to a response object, null, or a SQS batch response.
|
|
112
104
|
*/
|
|
113
|
-
EventProcessor.prototype.
|
|
105
|
+
EventProcessor.prototype.processRawEvent = function (execution, doNotDecodeMessage) {
|
|
114
106
|
return __awaiter(this, void 0, void 0, function () {
|
|
115
107
|
var _this = this;
|
|
116
108
|
return __generator(this, function (_a) {
|
|
117
109
|
switch (_a.label) {
|
|
118
110
|
case 0:
|
|
119
|
-
if (!(this.
|
|
120
|
-
return [4 /*yield*/, new Transaction_1.default(this.
|
|
111
|
+
if (!(this.event.Records && this.event.Records.length > 0)) return [3 /*break*/, 2];
|
|
112
|
+
return [4 /*yield*/, new Transaction_1.default(this.event, this.context, __assign(__assign({}, this.config), { syncReturn: true })).execute(function (transaction) { return __awaiter(_this, void 0, void 0, function () {
|
|
121
113
|
var decodedRecords, failureIDs, _a, _b, _c, _i, eventRecordIdx, eventRecord, message, resp;
|
|
122
114
|
return __generator(this, function (_d) {
|
|
123
115
|
switch (_d.label) {
|
|
124
116
|
case 0:
|
|
125
|
-
decodedRecords = this.
|
|
117
|
+
decodedRecords = this.event.Records.map(function (eventRecord) {
|
|
126
118
|
return doNotDecodeMessage ? eventRecord.body : JSON.parse(eventRecord.body);
|
|
127
119
|
});
|
|
128
120
|
failureIDs = [];
|
|
@@ -138,7 +130,7 @@ var EventProcessor = /** @class */ (function () {
|
|
|
138
130
|
if (!(_c in _a)) return [3 /*break*/, 3];
|
|
139
131
|
eventRecordIdx = _c;
|
|
140
132
|
eventRecord = decodedRecords[eventRecordIdx];
|
|
141
|
-
message = this.
|
|
133
|
+
message = this.event.Records[eventRecordIdx];
|
|
142
134
|
return [4 /*yield*/, execution(transaction, eventRecord)
|
|
143
135
|
//check for failure
|
|
144
136
|
];
|
|
@@ -148,7 +140,7 @@ var EventProcessor = /** @class */ (function () {
|
|
|
148
140
|
if (!resp ||
|
|
149
141
|
(resp instanceof Response_1.default && !((resp === null || resp === void 0 ? void 0 : resp.getCode()) >= 200 && (resp === null || resp === void 0 ? void 0 : resp.getCode()) < 300))) {
|
|
150
142
|
//response with failures or fail hard at first
|
|
151
|
-
if (this.
|
|
143
|
+
if (this.allowFailure)
|
|
152
144
|
failureIDs.push(message.messageId);
|
|
153
145
|
else
|
|
154
146
|
return [2 /*return*/, resp];
|
|
@@ -159,7 +151,7 @@ var EventProcessor = /** @class */ (function () {
|
|
|
159
151
|
return [3 /*break*/, 1];
|
|
160
152
|
case 4:
|
|
161
153
|
//not errored and loop ended - succeeded (might have failures)
|
|
162
|
-
if (this.
|
|
154
|
+
if (this.allowFailure)
|
|
163
155
|
return [2 /*return*/, {
|
|
164
156
|
batchItemFailures: failureIDs.map(function (id) { return ({ itemIdentifier: id }); }),
|
|
165
157
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventProcessor.js","sourceRoot":"","sources":["../../../src/BaseEvent/EventProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6CAA8D;AAC9D,4CAA6D;AAC7D,sCAAgC;
|
|
1
|
+
{"version":3,"file":"EventProcessor.js","sourceRoot":"","sources":["../../../src/BaseEvent/EventProcessor.ts"],"names":[],"mappings":"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"}
|
|
@@ -3,72 +3,49 @@ import { TransactionConfig } from './Transaction';
|
|
|
3
3
|
import Logger from '../Logger/Logger';
|
|
4
4
|
import Publisher from '../Publisher/Publisher';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @export
|
|
9
|
-
* @typedef {ProcessConfig}
|
|
6
|
+
* A type that represents a modified version of the TransactionConfig type, excluding the 'throwOnErrors' and 'syncReturn' properties.
|
|
10
7
|
*/
|
|
11
8
|
export type ProcessConfig = Omit<TransactionConfig, 'throwOnErrors' | 'syncReturn'>;
|
|
12
9
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @export
|
|
16
|
-
* @class Process
|
|
17
|
-
* @typedef {Process}
|
|
10
|
+
* Represents a long-running process that executes a given function at a specified interval.
|
|
18
11
|
*/
|
|
19
12
|
export default class Process {
|
|
20
13
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @private
|
|
14
|
+
* Private member variable representing the interval value.
|
|
24
15
|
* @type {number}
|
|
16
|
+
* @private
|
|
25
17
|
*/
|
|
26
|
-
private
|
|
18
|
+
private interval;
|
|
27
19
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @public
|
|
20
|
+
* A logger object used for logging messages, errors, and other information.
|
|
31
21
|
* @readonly
|
|
32
|
-
* @type {Logger}
|
|
33
22
|
*/
|
|
34
23
|
readonly logger: Logger;
|
|
35
24
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* @public
|
|
39
|
-
* @readonly
|
|
40
|
-
* @type {Publisher}
|
|
25
|
+
* The publisher of the content.
|
|
41
26
|
*/
|
|
42
27
|
readonly publisher: Publisher;
|
|
43
28
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @public
|
|
47
|
-
* @type {NodeJS.Timeout}
|
|
29
|
+
* A reference to the NodeJS.Timeout object representing the interval timer.
|
|
48
30
|
*/
|
|
49
|
-
|
|
31
|
+
timeout: NodeJS.Timeout;
|
|
50
32
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @
|
|
54
|
-
* @
|
|
55
|
-
* @param {number} interval
|
|
33
|
+
* Constructs a new instance of the LongRunningProcess class.
|
|
34
|
+
* @param {ProcessConfig} config - The configuration object for the process.
|
|
35
|
+
* @param {number} interval - The interval at which the process should run.
|
|
36
|
+
* @returns None
|
|
56
37
|
*/
|
|
57
38
|
constructor(config: ProcessConfig, interval: number);
|
|
58
39
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* @
|
|
62
|
-
* @param {*} executionFunc
|
|
63
|
-
* @returns {*}
|
|
40
|
+
* Executes the provided execution function at a specified interval.
|
|
41
|
+
* @param {Function} executionFunc - The function to execute.
|
|
42
|
+
* @returns None
|
|
64
43
|
*/
|
|
65
44
|
execute(executionFunc: any): Promise<void>;
|
|
66
45
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @
|
|
70
|
-
* @param {*} executionFunc
|
|
71
|
-
* @returns {unknown}
|
|
46
|
+
* Executes the given execution function asynchronously and handles any exceptions that occur.
|
|
47
|
+
* @param {Function} executionFunc - The function to execute.
|
|
48
|
+
* @returns {boolean} - Returns true if the execution failed, false otherwise.
|
|
72
49
|
*/
|
|
73
|
-
|
|
50
|
+
private iexecute;
|
|
74
51
|
}
|
|
@@ -39,32 +39,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
var Logger_1 = require("../Logger/Logger");
|
|
40
40
|
var Publisher_1 = require("../Publisher/Publisher");
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
* @export
|
|
45
|
-
* @class Process
|
|
46
|
-
* @typedef {Process}
|
|
42
|
+
* Represents a long-running process that executes a given function at a specified interval.
|
|
47
43
|
*/
|
|
48
44
|
var Process = /** @class */ (function () {
|
|
49
45
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* @
|
|
53
|
-
* @
|
|
54
|
-
* @param {number} interval
|
|
46
|
+
* Constructs a new instance of the LongRunningProcess class.
|
|
47
|
+
* @param {ProcessConfig} config - The configuration object for the process.
|
|
48
|
+
* @param {number} interval - The interval at which the process should run.
|
|
49
|
+
* @returns None
|
|
55
50
|
*/
|
|
56
51
|
function Process(config, interval) {
|
|
57
|
-
this.
|
|
52
|
+
this.interval = interval;
|
|
58
53
|
this.logger = new Logger_1.default(config.logger, 'long-running-process');
|
|
59
54
|
this.publisher = new Publisher_1.default(config.publisher);
|
|
60
55
|
}
|
|
61
|
-
//Main interface
|
|
62
56
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* @
|
|
66
|
-
* @param {*} executionFunc
|
|
67
|
-
* @returns {*}
|
|
57
|
+
* Executes the provided execution function at a specified interval.
|
|
58
|
+
* @param {Function} executionFunc - The function to execute.
|
|
59
|
+
* @returns None
|
|
68
60
|
*/
|
|
69
61
|
Process.prototype.execute = function (executionFunc) {
|
|
70
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -74,29 +66,26 @@ var Process = /** @class */ (function () {
|
|
|
74
66
|
//Connect DB
|
|
75
67
|
// if (this.db) await this.db.connect();
|
|
76
68
|
//Program loop
|
|
77
|
-
this.
|
|
69
|
+
this.timeout = setInterval(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
78
70
|
return __generator(this, function (_a) {
|
|
79
71
|
switch (_a.label) {
|
|
80
|
-
case 0: return [4 /*yield*/, this.
|
|
72
|
+
case 0: return [4 /*yield*/, this.iexecute(executionFunc)];
|
|
81
73
|
case 1:
|
|
82
74
|
_a.sent();
|
|
83
75
|
return [2 /*return*/];
|
|
84
76
|
}
|
|
85
77
|
});
|
|
86
|
-
}); }, this.
|
|
78
|
+
}); }, this.interval);
|
|
87
79
|
return [2 /*return*/];
|
|
88
80
|
});
|
|
89
81
|
});
|
|
90
82
|
};
|
|
91
|
-
//Executions
|
|
92
83
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
* @
|
|
96
|
-
* @param {*} executionFunc
|
|
97
|
-
* @returns {unknown}
|
|
84
|
+
* Executes the given execution function asynchronously and handles any exceptions that occur.
|
|
85
|
+
* @param {Function} executionFunc - The function to execute.
|
|
86
|
+
* @returns {boolean} - Returns true if the execution failed, false otherwise.
|
|
98
87
|
*/
|
|
99
|
-
Process.prototype.
|
|
88
|
+
Process.prototype.iexecute = function (executionFunc) {
|
|
100
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
101
90
|
var executionFailed, e_1;
|
|
102
91
|
return __generator(this, function (_a) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Process.js","sourceRoot":"","sources":["../../../src/BaseEvent/Process.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAAqC;AACrC,oDAA8C;
|
|
1
|
+
{"version":3,"file":"Process.js","sourceRoot":"","sources":["../../../src/BaseEvent/Process.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAAqC;AACrC,oDAA8C;AAO9C;;GAEG;AACH;IAqBE;;;;;OAKG;IACH,iBAAY,MAAqB,EAAE,QAAgB;QACjD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,gBAAM,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAA;QAC/D,IAAI,CAAC,SAAS,GAAG,IAAI,mBAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;IAClD,CAAC;IAED;;;;OAIG;IACU,yBAAO,GAApB,UAAqB,aAAa;;;;gBAChC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAA;gBAC/C,YAAY;gBACZ,wCAAwC;gBACxC,cAAc;gBACd,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC;;;oCACzB,qBAAM,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAA;;gCAAlC,SAAkC,CAAA;;;;qBACnC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;;;;KAClB;IAED;;;;OAIG;IACW,0BAAQ,GAAtB,UAAuB,aAAa;;;;;;wBAC9B,eAAe,GAAG,IAAI,CAAC,wBAAwB;wBAAzB,CAAA;;;;wBAGxB,sBAAsB;wBACtB,iDAAiD;wBACjD,SAAS;wBACT,qBAAM,aAAa,CAAC,IAAI,CAAC;4BACzB,WAAW;4BACX,uCAAuC;4BACvC,EAAE;0BAHuB;;wBAHzB,sBAAsB;wBACtB,iDAAiD;wBACjD,SAAS;wBACT,SAAyB,CAAA;wBACzB,WAAW;wBACX,uCAAuC;wBACvC,EAAE;wBACF,eAAe,GAAG,KAAK,CAAA;;;;wBAEvB,kBAAkB;wBAClB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,8DAA8D,CAAC,CAAA;wBACjF,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAC,CAAC,CAAA;;4BAI1B,sBAAO,eAAe,EAAA;;;;KACvB;IACH,cAAC;AAAD,CAAC,AA1ED,IA0EC"}
|
|
@@ -1,29 +1,131 @@
|
|
|
1
1
|
import type { APIGatewayEvent, Context, SQSEvent } from 'aws-lambda';
|
|
2
2
|
import Request from '../API/Request';
|
|
3
3
|
import Response, { ResponseErrorType } from '../API/Response';
|
|
4
|
+
import type { DatabaseTransactionType, DatabaseType, DbConfig } from '../Database/types';
|
|
4
5
|
import Logger, { LoggerConfig } from '../Logger/Logger';
|
|
5
6
|
import Publisher, { PublisherConfig } from '../Publisher/Publisher';
|
|
7
|
+
/**
|
|
8
|
+
* Defines a type for executing a transaction and returning a promise with the response.
|
|
9
|
+
* @param {TransactionType} transaction - The transaction to execute.
|
|
10
|
+
* @returns A promise that resolves to the response of the transaction.
|
|
11
|
+
*/
|
|
6
12
|
export type TransactionExecution<TransactionType, ResponseInnerType, MiscRespType = null> = (transaction: TransactionType) => Promise<Response<ResponseInnerType> | Response<ResponseErrorType> | MiscRespType>;
|
|
13
|
+
/**
|
|
14
|
+
* Represents the configuration options for a transaction.
|
|
15
|
+
* @typedef {Object} TransactionConfig
|
|
16
|
+
* @property {boolean} [throwOnErrors] - Whether to throw an error if there are any errors during the transaction.
|
|
17
|
+
* @property {boolean} [syncReturn] - Whether to return the result of the transaction synchronously.
|
|
18
|
+
* @property {LoggerConfig} [logger] - The configuration options for the logger.
|
|
19
|
+
* @property {PublisherConfig} [publisher] - The configuration options for the publisher.
|
|
20
|
+
*/
|
|
7
21
|
export type TransactionConfig = {
|
|
8
22
|
throwOnErrors?: boolean;
|
|
9
23
|
syncReturn?: boolean;
|
|
10
24
|
logger?: LoggerConfig;
|
|
11
25
|
publisher?: PublisherConfig;
|
|
12
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Represents a transaction object that handles the execution of a request and manages the response.
|
|
29
|
+
* @template InputType - The type of the input data for the transaction.
|
|
30
|
+
* @template ResponseInnerType - The type of the inner response data for the transaction.
|
|
31
|
+
* @template MiscRespType - The type of miscellaneous response data for the transaction.
|
|
32
|
+
*/
|
|
13
33
|
export default class Transaction<InputType = object, ResponseInnerType = null, MiscRespType = null> {
|
|
34
|
+
/**
|
|
35
|
+
* The instance of the DatabaseManager class used for managing the database.
|
|
36
|
+
*/
|
|
37
|
+
private databaseManager;
|
|
38
|
+
/**
|
|
39
|
+
* An array of database transactions.
|
|
40
|
+
* @type {DatabaseTransaction[]}
|
|
41
|
+
*/
|
|
42
|
+
private transactions;
|
|
43
|
+
/**
|
|
44
|
+
* Represents an event object.
|
|
45
|
+
* @private
|
|
46
|
+
* @type {any}
|
|
47
|
+
*/
|
|
14
48
|
private event;
|
|
49
|
+
/**
|
|
50
|
+
* The context object for the current instance.
|
|
51
|
+
*/
|
|
15
52
|
private context;
|
|
53
|
+
/**
|
|
54
|
+
* The response object that can hold different types of responses.
|
|
55
|
+
* @type {Response<ResponseInnerType | ResponseErrorType> | MiscRespType | null}
|
|
56
|
+
*/
|
|
16
57
|
private response;
|
|
58
|
+
/**
|
|
59
|
+
* A private boolean variable indicating whether the return value of a synchronous operation
|
|
60
|
+
* should be synchronized with the calling thread.
|
|
61
|
+
*/
|
|
17
62
|
private syncReturn;
|
|
63
|
+
/**
|
|
64
|
+
* A boolean flag indicating whether retroactive errors are enabled or not.
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
18
67
|
private retrowErrors;
|
|
68
|
+
/**
|
|
69
|
+
* A logger object used for logging messages, errors, and other information.
|
|
70
|
+
* @readonly
|
|
71
|
+
*/
|
|
19
72
|
readonly logger: Logger;
|
|
73
|
+
/**
|
|
74
|
+
* The request object for making a request of type InputType.
|
|
75
|
+
* @readonly
|
|
76
|
+
*/
|
|
20
77
|
readonly request: Request<InputType>;
|
|
78
|
+
/**
|
|
79
|
+
* The publisher of the content.
|
|
80
|
+
*/
|
|
21
81
|
readonly publisher: Publisher;
|
|
22
|
-
|
|
82
|
+
/**
|
|
83
|
+
* A function that acts as a response proxy for a given response object.
|
|
84
|
+
* @param {Response<ResponseInnerType>} response - The response object to proxy.
|
|
85
|
+
* @returns A promise that resolves to void.
|
|
86
|
+
*/
|
|
87
|
+
responseProxy: ((response: Response<ResponseInnerType>) => Promise<void>) | null;
|
|
88
|
+
/**
|
|
89
|
+
* Constructs a new instance of the Transaction class.
|
|
90
|
+
* @param {APIGatewayEvent | SQSEvent} event - The event object passed to the Lambda function.
|
|
91
|
+
* @param {Context} context - The context object passed to the Lambda function.
|
|
92
|
+
* @param {TransactionConfig} [config] - Optional configuration object for the transaction.
|
|
93
|
+
* @returns None
|
|
94
|
+
*/
|
|
23
95
|
constructor(event: APIGatewayEvent | SQSEvent, context: Context, config?: TransactionConfig);
|
|
24
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Executes a transaction using the provided execution function and returns a promise
|
|
98
|
+
* that resolves to the response or miscellaneous response.
|
|
99
|
+
* @param {TransactionExecution<Transaction<InputType, ResponseInnerType, MiscRespType>, ResponseInnerType, MiscRespType>} executionFunc - The execution function to be executed.
|
|
100
|
+
* @returns {Promise<Response<ResponseInnerType | ResponseErrorType> | MiscRespType>} - A promise that resolves to the response or miscellaneous response.
|
|
101
|
+
*/
|
|
102
|
+
execute(executionFunc: TransactionExecution<Transaction<InputType, ResponseInnerType, MiscRespType>, ResponseInnerType, MiscRespType>): Promise<Response<ResponseInnerType | ResponseErrorType> | MiscRespType | null>;
|
|
103
|
+
/**
|
|
104
|
+
* Executes a transaction using the provided execution function and handles the response.
|
|
105
|
+
* @param {TransactionExecution<Transaction<InputType, ResponseInnerType, MiscRespType>, ResponseInnerType, MiscRespType>} executionFunc - The function to execute the transaction.
|
|
106
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the execution failed or not.
|
|
107
|
+
*/
|
|
25
108
|
private iexecute;
|
|
109
|
+
/**
|
|
110
|
+
* Retrieves a database transaction for the specified database configuration.
|
|
111
|
+
* @async
|
|
112
|
+
* @param {DbConfig<S>} config - The configuration object for the database.
|
|
113
|
+
* @returns {Promise<DatabaseTransactionType<S>>} A promise that resolves to the database transaction.
|
|
114
|
+
*/
|
|
115
|
+
getDbTransaction<S extends DatabaseType>(config: DbConfig<S>): Promise<DatabaseTransactionType<S>>;
|
|
26
116
|
private executeDBTransactions;
|
|
117
|
+
/**
|
|
118
|
+
* Executes a logger flush operation with error handling and logging.
|
|
119
|
+
* @param {Function} safeExecution - The function to execute safely.
|
|
120
|
+
* @returns None
|
|
121
|
+
* @throws {Error} - If `retrowErrors` is true and an error occurs during execution.
|
|
122
|
+
*/
|
|
27
123
|
private executeLoggerFlush;
|
|
124
|
+
/**
|
|
125
|
+
* Returns an error response with the specified error message and error code.
|
|
126
|
+
* @param {string} error - The error message.
|
|
127
|
+
* @param {string} code - The error code.
|
|
128
|
+
* @returns {Response<ResponseErrorType>} - The error response.
|
|
129
|
+
*/
|
|
28
130
|
private getErrorResponse;
|
|
29
131
|
}
|