@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
|
@@ -35,15 +35,73 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
+
if (!m) return o;
|
|
41
|
+
var i = m.call(o), r, ar = [], e;
|
|
42
|
+
try {
|
|
43
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
+
}
|
|
45
|
+
catch (error) { e = { error: error }; }
|
|
46
|
+
finally {
|
|
47
|
+
try {
|
|
48
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
+
}
|
|
50
|
+
finally { if (e) throw e.error; }
|
|
51
|
+
}
|
|
52
|
+
return ar;
|
|
53
|
+
};
|
|
54
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
+
if (ar || !(i in from)) {
|
|
57
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
+
ar[i] = from[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
+
};
|
|
63
|
+
var __values = (this && this.__values) || function(o) {
|
|
64
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
65
|
+
if (m) return m.call(o);
|
|
66
|
+
if (o && typeof o.length === "number") return {
|
|
67
|
+
next: function () {
|
|
68
|
+
if (o && i >= o.length) o = void 0;
|
|
69
|
+
return { value: o && o[i++], done: !o };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
73
|
+
};
|
|
38
74
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
75
|
var Request_1 = require("../API/Request");
|
|
40
76
|
var Response_1 = require("../API/Response");
|
|
77
|
+
var DatabaseManager_1 = require("../Database/DatabaseManager");
|
|
41
78
|
var Globals_1 = require("../Globals");
|
|
42
79
|
var Logger_1 = require("../Logger/Logger");
|
|
43
80
|
var Publisher_1 = require("../Publisher/Publisher");
|
|
81
|
+
/**
|
|
82
|
+
* Represents a transaction object that handles the execution of a request and manages the response.
|
|
83
|
+
* @template InputType - The type of the input data for the transaction.
|
|
84
|
+
* @template ResponseInnerType - The type of the inner response data for the transaction.
|
|
85
|
+
* @template MiscRespType - The type of miscellaneous response data for the transaction.
|
|
86
|
+
*/
|
|
44
87
|
var Transaction = /** @class */ (function () {
|
|
45
|
-
|
|
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
|
+
*/
|
|
46
95
|
function Transaction(event, context, config) {
|
|
96
|
+
/**
|
|
97
|
+
* The instance of the DatabaseManager class used for managing the database.
|
|
98
|
+
*/
|
|
99
|
+
this.databaseManager = DatabaseManager_1.DatabaseManager.INSTANCE;
|
|
100
|
+
/**
|
|
101
|
+
* An array of database transactions.
|
|
102
|
+
* @type {DatabaseTransaction[]}
|
|
103
|
+
*/
|
|
104
|
+
this.transactions = [];
|
|
47
105
|
var transactionId = context.awsRequestId
|
|
48
106
|
? context.awsRequestId
|
|
49
107
|
: event.requestContext
|
|
@@ -63,7 +121,12 @@ var Transaction = /** @class */ (function () {
|
|
|
63
121
|
this.request = new Request_1.default(this.event, this.context, this.logger);
|
|
64
122
|
this.publisher = new Publisher_1.default(config === null || config === void 0 ? void 0 : config.publisher);
|
|
65
123
|
}
|
|
66
|
-
|
|
124
|
+
/**
|
|
125
|
+
* Executes a transaction using the provided execution function and returns a promise
|
|
126
|
+
* that resolves to the response or miscellaneous response.
|
|
127
|
+
* @param {TransactionExecution<Transaction<InputType, ResponseInnerType, MiscRespType>, ResponseInnerType, MiscRespType>} executionFunc - The execution function to be executed.
|
|
128
|
+
* @returns {Promise<Response<ResponseInnerType | ResponseErrorType> | MiscRespType>} - A promise that resolves to the response or miscellaneous response.
|
|
129
|
+
*/
|
|
67
130
|
Transaction.prototype.execute = function (executionFunc) {
|
|
68
131
|
return __awaiter(this, void 0, void 0, function () {
|
|
69
132
|
var _this = this;
|
|
@@ -102,7 +165,11 @@ var Transaction = /** @class */ (function () {
|
|
|
102
165
|
});
|
|
103
166
|
});
|
|
104
167
|
};
|
|
105
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Executes a transaction using the provided execution function and handles the response.
|
|
170
|
+
* @param {TransactionExecution<Transaction<InputType, ResponseInnerType, MiscRespType>, ResponseInnerType, MiscRespType>} executionFunc - The function to execute the transaction.
|
|
171
|
+
* @returns {Promise<boolean>} - A promise that resolves to a boolean indicating whether the execution failed or not.
|
|
172
|
+
*/
|
|
106
173
|
Transaction.prototype.iexecute = function (executionFunc) {
|
|
107
174
|
return __awaiter(this, void 0, void 0, function () {
|
|
108
175
|
var executionFailed, _a, e_1;
|
|
@@ -161,55 +228,138 @@ var Transaction = /** @class */ (function () {
|
|
|
161
228
|
});
|
|
162
229
|
});
|
|
163
230
|
};
|
|
164
|
-
|
|
231
|
+
/**
|
|
232
|
+
* Retrieves a database transaction for the specified database configuration.
|
|
233
|
+
* @async
|
|
234
|
+
* @param {DbConfig<S>} config - The configuration object for the database.
|
|
235
|
+
* @returns {Promise<DatabaseTransactionType<S>>} A promise that resolves to the database transaction.
|
|
236
|
+
*/
|
|
237
|
+
Transaction.prototype.getDbTransaction = function (config) {
|
|
165
238
|
return __awaiter(this, void 0, void 0, function () {
|
|
166
|
-
var
|
|
239
|
+
var db, dbTrans;
|
|
167
240
|
return __generator(this, function (_a) {
|
|
168
241
|
switch (_a.label) {
|
|
169
242
|
case 0:
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
// if (this.db) await this.db.connect();
|
|
173
|
-
// //start transaction
|
|
174
|
-
// if (this.db) await this.db.beginTransaction();
|
|
175
|
-
// //
|
|
176
|
-
// let executionFailed =
|
|
177
|
-
return [4 /*yield*/, safeExecution()
|
|
178
|
-
// //Commit if not failed, rollback if failed
|
|
179
|
-
// if (!executionFailed) {
|
|
180
|
-
// if (this.db) await this.db.commit();
|
|
181
|
-
// } else {
|
|
182
|
-
// this.logger.log("Rolling back DB transactions. Main code failed!");
|
|
183
|
-
// if (this.db) await this.db.rollback();
|
|
184
|
-
// }
|
|
185
|
-
// //Cleanup DB after execution
|
|
186
|
-
// if (this.db) await this.db.cleanup();
|
|
187
|
-
];
|
|
243
|
+
db = this.databaseManager.create(config);
|
|
244
|
+
return [4 /*yield*/, db.transaction()];
|
|
188
245
|
case 1:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
246
|
+
dbTrans = _a.sent();
|
|
247
|
+
this.transactions.push(dbTrans);
|
|
248
|
+
return [2 /*return*/, dbTrans];
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
/*
|
|
254
|
+
* Executes a series of database transactions in a safe manner.
|
|
255
|
+
* @param {Function} safeExecution - The function that contains the database transactions to be executed.
|
|
256
|
+
* @returns None
|
|
257
|
+
* @throws {Error} - If an exception occurs during the execution of the transactions and `retrowErrors` is true.
|
|
258
|
+
*/
|
|
259
|
+
Transaction.prototype.executeDBTransactions = function (safeExecution) {
|
|
260
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
261
|
+
var execFailed, _a, _b, transaction, e_2, e_3_1, e_4, _c, _d, transaction, e_5, e_6_1;
|
|
262
|
+
var e_3, _e, e_6, _f;
|
|
263
|
+
return __generator(this, function (_g) {
|
|
264
|
+
switch (_g.label) {
|
|
265
|
+
case 0:
|
|
266
|
+
_g.trys.push([0, 12, , 23]);
|
|
267
|
+
return [4 /*yield*/, safeExecution()];
|
|
268
|
+
case 1:
|
|
269
|
+
execFailed = _g.sent();
|
|
270
|
+
_g.label = 2;
|
|
197
271
|
case 2:
|
|
198
|
-
|
|
272
|
+
_g.trys.push([2, 9, 10, 11]);
|
|
273
|
+
_a = __values(__spreadArray([], __read(this.transactions), false).reverse()), _b = _a.next();
|
|
274
|
+
_g.label = 3;
|
|
275
|
+
case 3:
|
|
276
|
+
if (!!_b.done) return [3 /*break*/, 8];
|
|
277
|
+
transaction = _b.value;
|
|
278
|
+
_g.label = 4;
|
|
279
|
+
case 4:
|
|
280
|
+
_g.trys.push([4, 6, , 7]);
|
|
281
|
+
return [4 /*yield*/, transaction[execFailed ? 'closeFailure' : 'closeSuccess']()];
|
|
282
|
+
case 5:
|
|
283
|
+
_g.sent();
|
|
284
|
+
return [3 /*break*/, 7];
|
|
285
|
+
case 6:
|
|
286
|
+
e_2 = _g.sent();
|
|
287
|
+
// TODO: should we keep committing transactions even if one fails?
|
|
288
|
+
this.logger.error('Exception when closing DB transactions after success.');
|
|
289
|
+
this.logger.exception(e_2);
|
|
290
|
+
return [3 /*break*/, 7];
|
|
291
|
+
case 7:
|
|
292
|
+
_b = _a.next();
|
|
293
|
+
return [3 /*break*/, 3];
|
|
294
|
+
case 8: return [3 /*break*/, 11];
|
|
295
|
+
case 9:
|
|
296
|
+
e_3_1 = _g.sent();
|
|
297
|
+
e_3 = { error: e_3_1 };
|
|
298
|
+
return [3 /*break*/, 11];
|
|
299
|
+
case 10:
|
|
300
|
+
try {
|
|
301
|
+
if (_b && !_b.done && (_e = _a.return)) _e.call(_a);
|
|
302
|
+
}
|
|
303
|
+
finally { if (e_3) throw e_3.error; }
|
|
304
|
+
return [7 /*endfinally*/];
|
|
305
|
+
case 11: return [3 /*break*/, 23];
|
|
306
|
+
case 12:
|
|
307
|
+
e_4 = _g.sent();
|
|
308
|
+
_g.label = 13;
|
|
309
|
+
case 13:
|
|
310
|
+
_g.trys.push([13, 20, 21, 22]);
|
|
311
|
+
_c = __values(__spreadArray([], __read(this.transactions), false).reverse()), _d = _c.next();
|
|
312
|
+
_g.label = 14;
|
|
313
|
+
case 14:
|
|
314
|
+
if (!!_d.done) return [3 /*break*/, 19];
|
|
315
|
+
transaction = _d.value;
|
|
316
|
+
_g.label = 15;
|
|
317
|
+
case 15:
|
|
318
|
+
_g.trys.push([15, 17, , 18]);
|
|
319
|
+
return [4 /*yield*/, transaction.closeFailure()];
|
|
320
|
+
case 16:
|
|
321
|
+
_g.sent();
|
|
322
|
+
return [3 /*break*/, 18];
|
|
323
|
+
case 17:
|
|
324
|
+
e_5 = _g.sent();
|
|
325
|
+
this.logger.error('Exception when closing DB transactions after failure.');
|
|
326
|
+
this.logger.exception(e_5);
|
|
327
|
+
return [3 /*break*/, 18];
|
|
328
|
+
case 18:
|
|
329
|
+
_d = _c.next();
|
|
330
|
+
return [3 /*break*/, 14];
|
|
331
|
+
case 19: return [3 /*break*/, 22];
|
|
332
|
+
case 20:
|
|
333
|
+
e_6_1 = _g.sent();
|
|
334
|
+
e_6 = { error: e_6_1 };
|
|
335
|
+
return [3 /*break*/, 22];
|
|
336
|
+
case 21:
|
|
337
|
+
try {
|
|
338
|
+
if (_d && !_d.done && (_f = _c.return)) _f.call(_c);
|
|
339
|
+
}
|
|
340
|
+
finally { if (e_6) throw e_6.error; }
|
|
341
|
+
return [7 /*endfinally*/];
|
|
342
|
+
case 22:
|
|
199
343
|
this.logger.error('Exception when executing DB transactions.');
|
|
200
|
-
this.logger.log(
|
|
344
|
+
this.logger.log(e_4.stack);
|
|
201
345
|
//retrow?
|
|
202
346
|
if (this.retrowErrors)
|
|
203
|
-
throw
|
|
204
|
-
return [3 /*break*/,
|
|
205
|
-
case
|
|
347
|
+
throw e_4;
|
|
348
|
+
return [3 /*break*/, 23];
|
|
349
|
+
case 23: return [2 /*return*/];
|
|
206
350
|
}
|
|
207
351
|
});
|
|
208
352
|
});
|
|
209
353
|
};
|
|
354
|
+
/**
|
|
355
|
+
* Executes a logger flush operation with error handling and logging.
|
|
356
|
+
* @param {Function} safeExecution - The function to execute safely.
|
|
357
|
+
* @returns None
|
|
358
|
+
* @throws {Error} - If `retrowErrors` is true and an error occurs during execution.
|
|
359
|
+
*/
|
|
210
360
|
Transaction.prototype.executeLoggerFlush = function (safeExecution) {
|
|
211
361
|
return __awaiter(this, void 0, void 0, function () {
|
|
212
|
-
var
|
|
362
|
+
var e_7;
|
|
213
363
|
return __generator(this, function (_a) {
|
|
214
364
|
switch (_a.label) {
|
|
215
365
|
case 0:
|
|
@@ -219,12 +369,12 @@ var Transaction = /** @class */ (function () {
|
|
|
219
369
|
_a.sent();
|
|
220
370
|
return [3 /*break*/, 4];
|
|
221
371
|
case 2:
|
|
222
|
-
|
|
372
|
+
e_7 = _a.sent();
|
|
223
373
|
this.logger.error('Exception when flushing logs.');
|
|
224
|
-
this.logger.exception(
|
|
374
|
+
this.logger.exception(e_7);
|
|
225
375
|
//retrow?
|
|
226
376
|
if (this.retrowErrors)
|
|
227
|
-
throw
|
|
377
|
+
throw e_7;
|
|
228
378
|
return [3 /*break*/, 4];
|
|
229
379
|
case 3:
|
|
230
380
|
this.logger.debug('Transaction ended');
|
|
@@ -234,7 +384,12 @@ var Transaction = /** @class */ (function () {
|
|
|
234
384
|
});
|
|
235
385
|
});
|
|
236
386
|
};
|
|
237
|
-
|
|
387
|
+
/**
|
|
388
|
+
* Returns an error response with the specified error message and error code.
|
|
389
|
+
* @param {string} error - The error message.
|
|
390
|
+
* @param {string} code - The error code.
|
|
391
|
+
* @returns {Response<ResponseErrorType>} - The error response.
|
|
392
|
+
*/
|
|
238
393
|
Transaction.prototype.getErrorResponse = function (error, code) {
|
|
239
394
|
return Response_1.default.BadRequestResponseWithRollback(error, code);
|
|
240
395
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../src/BaseEvent/Transaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../../src/BaseEvent/Transaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,0CAAoC;AACpC,4CAA6D;AAC7D,+DAA6D;AAG7D,sCAAgC;AAChC,2CAAuD;AACvD,oDAAmE;AA0BnE;;;;;GAKG;AACH;IA4DE;;;;;;OAMG;IACH,qBAAY,KAAiC,EAAE,OAAgB,EAAE,MAA0B;QA9D3F;;WAEG;QACK,oBAAe,GAAoB,iCAAe,CAAC,QAAQ,CAAA;QACnE;;;WAGG;QACK,iBAAY,GAA0B,EAAE,CAAA;QAuD9C,IAAM,aAAa,GAAG,OAAO,CAAC,YAAY;YACxC,CAAC,CAAC,OAAO,CAAC,YAAY;YACtB,CAAC,CAAmB,KAAM,CAAC,cAAc;gBACzC,CAAC,CAAmB,KAAM,CAAC,cAAc,CAAC,SAAS;gBACnD,CAAC,CAAC,SAAS,CAAA;QACb,kBAAkB;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,kJAAkJ;QAClJ,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA;QACzB,oBAAoB;QACpB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,UAAU,CAAA,CAAA;QACtC,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,aAAa,CAAA,CAAA,CAAC,4B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AC,CAAA;wBAC1E,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAC,CAAC,CAAA;;;;;;;;;;;;;;;;;wBAG5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAA;wBAC9D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAC,CAAC,KAAK,CAAC,CAAA;wBACxB,SAAS;wBACT,IAAI,IAAI,CAAC,YAAY;4BAAE,MAAM,GAAC,CAAA;;;;;;KAEjC;IAED;;;;;OAKG;IACW,wCAAkB,GAAhC,UAAiC,aAAa;;;;;;;wBAE1C,qBAAM,aAAa,EAAE,EAAA;;wBAArB,SAAqB,CAAA;;;;wBAErB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAA;wBAClD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAC,CAAC,CAAA;wBACxB,SAAS;wBACT,IAAI,IAAI,CAAC,YAAY;4BAAE,MAAM,GAAC,CAAA;;;wBAE9B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAA;;;;;;KAEzC;IAED;;;;;OAKG;IACK,sCAAgB,GAAxB,UAAyB,KAAa,EAAE,IAAY;QAClD,OAAO,kBAAQ,CAAC,8BAA8B,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IAC7D,CAAC;IACH,kBAAC;AAAD,CAAC,AAjPD,IAiPC"}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* @
|
|
5
|
-
* @
|
|
2
|
+
* Represents the schema for the configuration object.
|
|
3
|
+
* @typedef {Object} ConfigurationSchema
|
|
4
|
+
* @property {Object} [name] - The name of the configuration property.
|
|
5
|
+
* @property {boolean} [name.isLocal] - Indicates if the property is for local use.
|
|
6
|
+
* @property {boolean} [name.isRemote] - Indicates if the property is for remote use.
|
|
7
|
+
* @property {boolean} [name.required] - Indicates if the property is required.
|
|
8
|
+
* @property {string} [name.cachingPolicy] - The caching policy for the property.
|
|
6
9
|
*/
|
|
7
10
|
export type ConfigurationSchema = {
|
|
8
11
|
[name: string]: {
|
|
@@ -13,10 +16,9 @@ export type ConfigurationSchema = {
|
|
|
13
16
|
};
|
|
14
17
|
};
|
|
15
18
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
19
|
-
* @template Type
|
|
19
|
+
* Extracts the properties from a given type that have the `isRemote` property set to `true`.
|
|
20
|
+
* @param {Type} - The type to extract properties from.
|
|
21
|
+
* @returns An object type with the extracted properties.
|
|
20
22
|
*/
|
|
21
23
|
type ExtractRemote<Type> = {
|
|
22
24
|
[Property in keyof Type]-?: Type[Property] extends {
|
|
@@ -24,10 +26,9 @@ type ExtractRemote<Type> = {
|
|
|
24
26
|
} ? Property : null;
|
|
25
27
|
};
|
|
26
28
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
30
|
-
* @template Type
|
|
29
|
+
* Extracts the properties from a given type that have the `isLocal` property set to `true`.
|
|
30
|
+
* @typeparam Type - The type to extract properties from.
|
|
31
|
+
* @returns An object type with the extracted properties as keys and their corresponding types.
|
|
31
32
|
*/
|
|
32
33
|
type ExtractLocal<Type> = {
|
|
33
34
|
[Property in keyof Type]-?: Type[Property] extends {
|
|
@@ -35,96 +36,77 @@ type ExtractLocal<Type> = {
|
|
|
35
36
|
} ? Property : null;
|
|
36
37
|
};
|
|
37
38
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
42
|
-
* @template U
|
|
39
|
+
* Creates a new type by omitting keys from type T whose values are of type U.
|
|
40
|
+
* @param {T} - The original type
|
|
41
|
+
* @param {U} - The type to omit from T
|
|
42
|
+
* @returns A new type with the omitted keys
|
|
43
43
|
*/
|
|
44
44
|
type OmitKeysByValueType<T, U> = {
|
|
45
45
|
[P in keyof T]: T[P] extends U ? never : P;
|
|
46
46
|
}[keyof T];
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @
|
|
51
|
-
* @
|
|
52
|
-
* @
|
|
48
|
+
* Omit properties from an object type by their value type.
|
|
49
|
+
* @template T - The object type to omit properties from.
|
|
50
|
+
* @template V - The value type of properties to omit.
|
|
51
|
+
* @typedef OmitByValueType
|
|
52
|
+
* @property {T} T - The object type to omit properties from.
|
|
53
|
+
* @property {V} V - The value type of properties to omit.
|
|
54
|
+
* @returns {OmitKeysByValueType<T, V>} - The resulting object type after omitting properties.
|
|
53
55
|
*/
|
|
54
56
|
type OmitByValueType<T, V> = T extends infer _ ? {
|
|
55
57
|
[key in OmitKeysByValueType<T, V>]: T[key];
|
|
56
58
|
} : never;
|
|
57
59
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @export
|
|
61
|
-
* @class Configuration
|
|
62
|
-
* @typedef {Configuration}
|
|
63
|
-
* @template {ConfigurationSchema} T
|
|
60
|
+
* Represents a configuration object with a specified schema and remote prefix.
|
|
61
|
+
* @template T - The type of the configuration schema.
|
|
64
62
|
*/
|
|
65
63
|
export default class Configuration<T extends ConfigurationSchema> {
|
|
66
64
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* @private
|
|
70
|
-
* @readonly
|
|
65
|
+
* The schema for the private readonly property.
|
|
71
66
|
* @type {T}
|
|
72
67
|
*/
|
|
73
68
|
private readonly schema;
|
|
74
69
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* @private
|
|
78
|
-
* @readonly
|
|
70
|
+
* The prefix used for remote resources.
|
|
79
71
|
* @type {string}
|
|
80
72
|
*/
|
|
81
73
|
private readonly remotePrefix;
|
|
82
74
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* @
|
|
86
|
-
* @
|
|
87
|
-
* @param {string} remotePrefix
|
|
75
|
+
* Constructs a new instance of the class.
|
|
76
|
+
* @param {T} schema - The schema object.
|
|
77
|
+
* @param {string} remotePrefix - The remote prefix string.
|
|
78
|
+
* @returns None
|
|
88
79
|
*/
|
|
89
80
|
constructor(schema: T, remotePrefix: string);
|
|
90
81
|
/**
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
* @
|
|
94
|
-
* @param {keyof OmitByValueType<ExtractLocal<T>, null>} propName
|
|
95
|
-
* @returns {*}
|
|
82
|
+
* Retrieves the value of a property from the environment variables or cache.
|
|
83
|
+
* @param {keyof OmitByValueType<ExtractLocal<T>, null>} propName - The name of the property to retrieve.
|
|
84
|
+
* @returns The value of the property.
|
|
96
85
|
*/
|
|
97
86
|
get(propName: keyof OmitByValueType<ExtractLocal<T>, null>): any;
|
|
98
87
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* @
|
|
102
|
-
* @async
|
|
103
|
-
* @param {keyof OmitByValueType<ExtractRemote<T>, null>} propName
|
|
104
|
-
* @returns {Promise<any>}
|
|
88
|
+
* Asynchronously retrieves the value of a property from the remote environment.
|
|
89
|
+
* @param {keyof OmitByValueType<ExtractRemote<T>, null>} propName - The name of the property to retrieve.
|
|
90
|
+
* @returns {Promise<any>} - A promise that resolves to the value of the property.
|
|
105
91
|
*/
|
|
106
92
|
asyncGet(propName: keyof OmitByValueType<ExtractRemote<T>, null>): Promise<any>;
|
|
107
93
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* @
|
|
111
|
-
* @param {string} valueKey
|
|
112
|
-
* @returns {*}
|
|
94
|
+
* Retrieves the cached value associated with the given key from the cache store.
|
|
95
|
+
* @param {string} valueKey - The key of the value to retrieve from the cache.
|
|
96
|
+
* @returns The cached value associated with the given key, or undefined if the key does not exist in the cache.
|
|
113
97
|
*/
|
|
114
98
|
private getCachedValue;
|
|
115
99
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
* @
|
|
119
|
-
* @param {string}
|
|
120
|
-
* @
|
|
121
|
-
* @param {string} [policy="1d"]
|
|
100
|
+
* Caches a value with the specified key and expiration policy.
|
|
101
|
+
* @param {string} valueKey - The key to associate with the cached value.
|
|
102
|
+
* @param {any} value - The value to be cached.
|
|
103
|
+
* @param {string} [policy='1d'] - The expiration policy for the cached value. Defaults to '1d' (1 day).
|
|
104
|
+
* @returns None
|
|
122
105
|
*/
|
|
123
106
|
private cacheValue;
|
|
124
107
|
/**
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* @private
|
|
108
|
+
* Resets the cache by creating a new instance of the MemCache class and assigning it to the cacheStore variable.
|
|
109
|
+
* @returns None
|
|
128
110
|
*/
|
|
129
111
|
private resetCache;
|
|
130
112
|
}
|
|
@@ -42,37 +42,29 @@ var EnvironmentVar_1 = require("./EnvironmentVar");
|
|
|
42
42
|
// Hold cached values at nodeVM level
|
|
43
43
|
// eslint-disable-next-line no-var
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* @type {*}
|
|
45
|
+
* Creates a new instance of a memory cache store.
|
|
46
|
+
* @returns {MemCache} A new instance of a memory cache store.
|
|
48
47
|
*/
|
|
49
48
|
var cacheStore = new MemCache();
|
|
50
49
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* @export
|
|
54
|
-
* @class Configuration
|
|
55
|
-
* @typedef {Configuration}
|
|
56
|
-
* @template {ConfigurationSchema} T
|
|
50
|
+
* Represents a configuration object with a specified schema and remote prefix.
|
|
51
|
+
* @template T - The type of the configuration schema.
|
|
57
52
|
*/
|
|
58
53
|
var Configuration = /** @class */ (function () {
|
|
59
54
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* @
|
|
63
|
-
* @
|
|
64
|
-
* @param {string} remotePrefix
|
|
55
|
+
* Constructs a new instance of the class.
|
|
56
|
+
* @param {T} schema - The schema object.
|
|
57
|
+
* @param {string} remotePrefix - The remote prefix string.
|
|
58
|
+
* @returns None
|
|
65
59
|
*/
|
|
66
60
|
function Configuration(schema, remotePrefix) {
|
|
67
61
|
this.schema = schema;
|
|
68
62
|
this.remotePrefix = remotePrefix;
|
|
69
63
|
}
|
|
70
64
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
74
|
-
* @param {keyof OmitByValueType<ExtractLocal<T>, null>} propName
|
|
75
|
-
* @returns {*}
|
|
65
|
+
* Retrieves the value of a property from the environment variables or cache.
|
|
66
|
+
* @param {keyof OmitByValueType<ExtractLocal<T>, null>} propName - The name of the property to retrieve.
|
|
67
|
+
* @returns The value of the property.
|
|
76
68
|
*/
|
|
77
69
|
Configuration.prototype.get = function (propName) {
|
|
78
70
|
var propString = propName;
|
|
@@ -85,12 +77,9 @@ var Configuration = /** @class */ (function () {
|
|
|
85
77
|
return v;
|
|
86
78
|
};
|
|
87
79
|
/**
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* @
|
|
91
|
-
* @async
|
|
92
|
-
* @param {keyof OmitByValueType<ExtractRemote<T>, null>} propName
|
|
93
|
-
* @returns {Promise<any>}
|
|
80
|
+
* Asynchronously retrieves the value of a property from the remote environment.
|
|
81
|
+
* @param {keyof OmitByValueType<ExtractRemote<T>, null>} propName - The name of the property to retrieve.
|
|
82
|
+
* @returns {Promise<any>} - A promise that resolves to the value of the property.
|
|
94
83
|
*/
|
|
95
84
|
Configuration.prototype.asyncGet = function (propName) {
|
|
96
85
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -115,34 +104,28 @@ var Configuration = /** @class */ (function () {
|
|
|
115
104
|
});
|
|
116
105
|
});
|
|
117
106
|
};
|
|
118
|
-
// caching layer
|
|
119
107
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* @
|
|
123
|
-
* @param {string} valueKey
|
|
124
|
-
* @returns {*}
|
|
108
|
+
* Retrieves the cached value associated with the given key from the cache store.
|
|
109
|
+
* @param {string} valueKey - The key of the value to retrieve from the cache.
|
|
110
|
+
* @returns The cached value associated with the given key, or undefined if the key does not exist in the cache.
|
|
125
111
|
*/
|
|
126
112
|
Configuration.prototype.getCachedValue = function (valueKey) {
|
|
127
113
|
return cacheStore.get(valueKey);
|
|
128
114
|
};
|
|
129
115
|
/**
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* @
|
|
133
|
-
* @param {string}
|
|
134
|
-
* @
|
|
135
|
-
* @param {string} [policy="1d"]
|
|
116
|
+
* Caches a value with the specified key and expiration policy.
|
|
117
|
+
* @param {string} valueKey - The key to associate with the cached value.
|
|
118
|
+
* @param {any} value - The value to be cached.
|
|
119
|
+
* @param {string} [policy='1d'] - The expiration policy for the cached value. Defaults to '1d' (1 day).
|
|
120
|
+
* @returns None
|
|
136
121
|
*/
|
|
137
122
|
Configuration.prototype.cacheValue = function (valueKey, value, policy) {
|
|
138
123
|
if (policy === void 0) { policy = '1d'; }
|
|
139
|
-
cacheStore.set(valueKey, value, DurationParser(policy, 's'));
|
|
124
|
+
cacheStore.set(valueKey, value, DurationParser(policy, 's') || '');
|
|
140
125
|
};
|
|
141
|
-
// unit-test support
|
|
142
126
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
* @private
|
|
127
|
+
* Resets the cache by creating a new instance of the MemCache class and assigning it to the cacheStore variable.
|
|
128
|
+
* @returns None
|
|
146
129
|
*/
|
|
147
130
|
Configuration.prototype.resetCache = function () {
|
|
148
131
|
cacheStore = new MemCache();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../src/Config/Configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAsC;AACtC,+CAAgD;AAEhD,mDAAkE;AAElE,qCAAqC;AACrC,kCAAkC;AAClC
|
|
1
|
+
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../src/Config/Configuration.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,q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