@creator.co/wapi 1.6.1 → 2.0.0-alpha.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.
Files changed (84) hide show
  1. package/.github/workflows/npmpublish.yml +1 -1
  2. package/.github/workflows/prs.yml +1 -1
  3. package/dist/index.js +45 -31
  4. package/dist/index.js.map +1 -1
  5. package/dist/jest.config.js +2 -4
  6. package/dist/jest.config.js.map +1 -1
  7. package/dist/package.json +12 -12
  8. package/dist/src/API/Request.js +53 -59
  9. package/dist/src/API/Request.js.map +1 -1
  10. package/dist/src/API/Response.js +81 -156
  11. package/dist/src/API/Response.js.map +1 -1
  12. package/dist/src/BaseEvent/EventProcessor.js +54 -132
  13. package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
  14. package/dist/src/BaseEvent/Process.js +40 -98
  15. package/dist/src/BaseEvent/Process.js.map +1 -1
  16. package/dist/src/BaseEvent/Transaction.js +122 -310
  17. package/dist/src/BaseEvent/Transaction.js.map +1 -1
  18. package/dist/src/Cache/Redis.js +55 -119
  19. package/dist/src/Cache/Redis.js.map +1 -1
  20. package/dist/src/Cache/types.js +1 -2
  21. package/dist/src/Config/Configuration.js +46 -86
  22. package/dist/src/Config/Configuration.js.map +1 -1
  23. package/dist/src/Config/EnvironmentVar.js +57 -119
  24. package/dist/src/Config/EnvironmentVar.js.map +1 -1
  25. package/dist/src/Crypto/Crypto.js +35 -82
  26. package/dist/src/Crypto/Crypto.js.map +1 -1
  27. package/dist/src/Crypto/JWT.js +12 -27
  28. package/dist/src/Crypto/JWT.js.map +1 -1
  29. package/dist/src/Database/Database.js +3 -8
  30. package/dist/src/Database/Database.js.map +1 -1
  31. package/dist/src/Database/DatabaseManager.js +23 -28
  32. package/dist/src/Database/DatabaseManager.js.map +1 -1
  33. package/dist/src/Database/DatabaseTransaction.js +50 -166
  34. package/dist/src/Database/DatabaseTransaction.js.map +1 -1
  35. package/dist/src/Database/index.js +11 -15
  36. package/dist/src/Database/index.js.map +1 -1
  37. package/dist/src/Database/integrations/knex/KnexDatabase.js +22 -76
  38. package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -1
  39. package/dist/src/Database/integrations/knex/KnexTransaction.js +19 -85
  40. package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -1
  41. package/dist/src/Database/integrations/kysely/KyselyDatabase.js +37 -88
  42. package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +1 -1
  43. package/dist/src/Database/integrations/kysely/KyselyTransaction.js +46 -114
  44. package/dist/src/Database/integrations/kysely/KyselyTransaction.js.map +1 -1
  45. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +20 -71
  46. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -1
  47. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +19 -85
  48. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -1
  49. package/dist/src/Database/types.js +1 -2
  50. package/dist/src/Globals.js +93 -98
  51. package/dist/src/Globals.js.map +1 -1
  52. package/dist/src/Logger/Logger.js +88 -222
  53. package/dist/src/Logger/Logger.js.map +1 -1
  54. package/dist/src/Mailer/Mailer.js +83 -204
  55. package/dist/src/Mailer/Mailer.js.map +1 -1
  56. package/dist/src/Publisher/Publisher.js +43 -107
  57. package/dist/src/Publisher/Publisher.js.map +1 -1
  58. package/dist/src/Server/RouteResolver.js +22 -49
  59. package/dist/src/Server/RouteResolver.js.map +1 -1
  60. package/dist/src/Server/Router.js +12 -16
  61. package/dist/src/Server/Router.js.map +1 -1
  62. package/dist/src/Server/lib/ContainerServer.js +21 -83
  63. package/dist/src/Server/lib/ContainerServer.js.map +1 -1
  64. package/dist/src/Server/lib/Server.js +50 -99
  65. package/dist/src/Server/lib/Server.js.map +1 -1
  66. package/dist/src/Server/lib/container/GenericHandler.js +32 -107
  67. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
  68. package/dist/src/Server/lib/container/GenericHandlerEvent.js +37 -81
  69. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
  70. package/dist/src/Server/lib/container/HealthHandler.js +3 -35
  71. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
  72. package/dist/src/Server/lib/container/Proxy.js +64 -127
  73. package/dist/src/Server/lib/container/Proxy.js.map +1 -1
  74. package/dist/src/Server/lib/container/Utils.js +12 -55
  75. package/dist/src/Server/lib/container/Utils.js.map +1 -1
  76. package/dist/src/Util/AsyncSingleton.js +40 -164
  77. package/dist/src/Util/AsyncSingleton.js.map +1 -1
  78. package/dist/src/Util/Utils.js +18 -24
  79. package/dist/src/Util/Utils.js.map +1 -1
  80. package/dist/src/Validation/Validator.js +10 -16
  81. package/dist/src/Validation/Validator.js.map +1 -1
  82. package/package.json +12 -12
  83. package/tests/Logger/Logger.test.ts +5 -3
  84. package/tsconfig.json +3 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DatabaseManager.js","sourceRoot":"","sources":["../../../src/Database/DatabaseManager.ts"],"names":[],"mappings":";;;AAAA,kCAAmC;AAEnC,iEAA+D;AAC/D,uEAAqE;AACrE,0EAAwE;AAGxE;;;;;;GAMG;AACU,QAAA,SAAS,GAAG;IACvB,IAAI,EAAE,2BAAY;IAClB,EAAE,EAAE,mCAAgB;IACpB,MAAM,EAAE,+BAAc;CACvB,CAAA;AAED;;GAEG;AACH;IAAA;QAME;;;WAGG;QACK,cAAS,GAAqB,iBAAS,CAAA;QAC/C;;;WAGG;QACK,cAAS,GAAgD,EAAE,CAAA;IA6BrE,CAAC;IA3BC;;;;OAIG;IACI,gCAAM,GAAb,UACE,MAAmB;QAEnB,IAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAA;QAC/B,IAAI,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,UAAU,CAAQ,CAAA;QAC1C,CAAC;QACD,IAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAc,MAAa,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AAC,CAAA;QAC/D,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAA;QACrC,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED;;;;OAIG;IACK,aAAa,CACnB,MAA8D;QAE9D,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAa,CAAQ,CAAA;IAC9D,CAAC;;AA1CD;;;GAGG;AACoB,wBAAQ,GAAG,IAAI,eAAe,EAAE,AAAxB,CAAwB"}
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -23,67 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
24
8
  });
25
9
  };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- var __read = (this && this.__read) || function (o, n) {
54
- var m = typeof Symbol === "function" && o[Symbol.iterator];
55
- if (!m) return o;
56
- var i = m.call(o), r, ar = [], e;
57
- try {
58
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
59
- }
60
- catch (error) { e = { error: error }; }
61
- finally {
62
- try {
63
- if (r && !r.done && (m = i["return"])) m.call(i);
64
- }
65
- finally { if (e) throw e.error; }
66
- }
67
- return ar;
68
- };
69
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
70
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
71
- if (ar || !(i in from)) {
72
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
73
- ar[i] = from[i];
74
- }
75
- }
76
- return to.concat(ar || Array.prototype.slice.call(from));
77
- };
78
- Object.defineProperty(exports, "__esModule", { value: true });
79
- exports.DatabaseTransaction = void 0;
80
10
  /**
81
11
  * Abstract class representing a database transaction.
82
12
  * Warning: These need to be arrow functions!
83
13
  * @class DatabaseTransaction
84
14
  */
85
- var DatabaseTransaction = /** @class */ (function (_super) {
86
- __extends(DatabaseTransaction, _super);
15
+ export class DatabaseTransaction extends Function {
87
16
  /**
88
17
  * Constructor for a class that interacts with a database using a writer and reader.
89
18
  * @param {any} writer - The object responsible for writing to the database.
@@ -91,122 +20,81 @@ var DatabaseTransaction = /** @class */ (function (_super) {
91
20
  * @param {any} [reader] - The object responsible for reading from the database (optional).
92
21
  * @returns None
93
22
  */
94
- function DatabaseTransaction(writer, database, reader) {
95
- var _this = _super.call(this, '...args', 'return this.transaction(...args)') || this;
23
+ constructor(writer, database, reader) {
24
+ super('...args', 'return this.transaction(...args)');
96
25
  /**
97
26
  * Check if the object is open.
98
27
  * @returns {boolean} - true if the object is open, false otherwise.
99
28
  */
100
- _this.isOpen = function () {
101
- return _this._isOpen;
29
+ this.isOpen = () => {
30
+ return this._isOpen;
102
31
  };
103
32
  /**
104
33
  * Begins a transaction asynchronously.
105
34
  * @returns {Promise<void>} A Promise that resolves when the transaction has begun.
106
35
  * @throws {Error} If the transaction is already open.
107
36
  */
108
- _this.begin = function () { return __awaiter(_this, void 0, void 0, function () {
109
- return __generator(this, function (_a) {
110
- switch (_a.label) {
111
- case 0:
112
- if (this._isOpen) {
113
- throw new Error('Cannot begin, transaction is already opened!');
114
- }
115
- return [4 /*yield*/, this.doBegin()];
116
- case 1:
117
- _a.sent();
118
- this._isOpen = true;
119
- return [2 /*return*/];
120
- }
121
- });
122
- }); };
37
+ this.begin = () => __awaiter(this, void 0, void 0, function* () {
38
+ if (this._isOpen) {
39
+ throw new Error('Cannot begin, transaction is already opened!');
40
+ }
41
+ yield this.doBegin();
42
+ this._isOpen = true;
43
+ });
123
44
  /**
124
45
  * Asynchronously commits the transaction.
125
46
  * If the transaction is already closed, an error is thrown.
126
47
  * @returns Promise<void>
127
48
  * @throws Error if the transaction is already closed
128
49
  */
129
- _this.commit = function () { return __awaiter(_this, void 0, void 0, function () {
130
- return __generator(this, function (_a) {
131
- switch (_a.label) {
132
- case 0:
133
- if (!this._isOpen) {
134
- throw new Error('Cannot commit, transaction is already closed!');
135
- }
136
- return [4 /*yield*/, this.doCommit()];
137
- case 1:
138
- _a.sent();
139
- this._isOpen = false;
140
- return [2 /*return*/];
141
- }
142
- });
143
- }); };
50
+ this.commit = () => __awaiter(this, void 0, void 0, function* () {
51
+ if (!this._isOpen) {
52
+ throw new Error('Cannot commit, transaction is already closed!');
53
+ }
54
+ yield this.doCommit();
55
+ this._isOpen = false;
56
+ });
144
57
  /**
145
58
  * Rollback the transaction by reverting any changes made within the transaction.
146
59
  * If the transaction is already closed, an error is thrown.
147
60
  * @returns Promise<void>
148
61
  * @throws Error if the transaction is already closed.
149
62
  */
150
- _this.rollback = function () { return __awaiter(_this, void 0, void 0, function () {
151
- return __generator(this, function (_a) {
152
- switch (_a.label) {
153
- case 0:
154
- if (!this._isOpen) {
155
- throw new Error('Cannot rollback, transaction is already closed!');
156
- }
157
- return [4 /*yield*/, this.doRollback()];
158
- case 1:
159
- _a.sent();
160
- this._isOpen = false;
161
- return [2 /*return*/];
162
- }
163
- });
164
- }); };
63
+ this.rollback = () => __awaiter(this, void 0, void 0, function* () {
64
+ if (!this._isOpen) {
65
+ throw new Error('Cannot rollback, transaction is already closed!');
66
+ }
67
+ yield this.doRollback();
68
+ this._isOpen = false;
69
+ });
165
70
  /**
166
71
  * Closes the success modal, committing or rolling back changes based on the autoCommit setting.
167
72
  * If the modal is open and autoCommit is enabled, it will commit the changes.
168
73
  * If autoCommit is disabled, it will rollback the changes.
169
74
  * @returns {Promise<void>} A promise that resolves once the commit or rollback operation is completed.
170
75
  */
171
- _this.closeSuccess = function () { return __awaiter(_this, void 0, void 0, function () {
172
- return __generator(this, function (_a) {
173
- switch (_a.label) {
174
- case 0:
175
- if (!this._isOpen) return [3 /*break*/, 4];
176
- if (!this.database.config.autoCommit) return [3 /*break*/, 2];
177
- return [4 /*yield*/, this.doCommit()];
178
- case 1:
179
- _a.sent();
180
- return [3 /*break*/, 4];
181
- case 2: return [4 /*yield*/, this.doRollback()];
182
- case 3:
183
- _a.sent();
184
- _a.label = 4;
185
- case 4: return [2 /*return*/];
76
+ this.closeSuccess = () => __awaiter(this, void 0, void 0, function* () {
77
+ if (this._isOpen) {
78
+ if (this.database.config.autoCommit) {
79
+ yield this.doCommit();
80
+ }
81
+ else {
82
+ yield this.doRollback();
186
83
  }
187
- });
188
- }); };
84
+ }
85
+ });
189
86
  /**
190
87
  * Closes the failure by performing a rollback if the failure is currently open.
191
88
  * @returns {Promise<void>} A promise that resolves once the rollback is completed.
192
89
  */
193
- _this.closeFailure = function () { return __awaiter(_this, void 0, void 0, function () {
194
- return __generator(this, function (_a) {
195
- switch (_a.label) {
196
- case 0:
197
- if (!this._isOpen) return [3 /*break*/, 2];
198
- return [4 /*yield*/, this.doRollback()];
199
- case 1:
200
- _a.sent();
201
- _a.label = 2;
202
- case 2: return [2 /*return*/];
203
- }
204
- });
205
- }); };
206
- _this.writer = writer;
207
- _this.database = database;
208
- _this.reader = reader;
209
- return _this;
90
+ this.closeFailure = () => __awaiter(this, void 0, void 0, function* () {
91
+ if (this._isOpen) {
92
+ yield this.doRollback();
93
+ }
94
+ });
95
+ this.writer = writer;
96
+ this.database = database;
97
+ this.reader = reader;
210
98
  }
211
99
  /**
212
100
  * Creates a proxy instance for the given subclass of DatabaseTransaction.
@@ -214,12 +102,10 @@ var DatabaseTransaction = /** @class */ (function (_super) {
214
102
  * @param {T} subclass - The subclass of DatabaseTransaction to proxy.
215
103
  * @returns A proxied instance of the subclass with method binding and transaction execution logic.
216
104
  */
217
- DatabaseTransaction.proxyInstance = function (subclass) {
218
- var bind = function (target, key) {
219
- return typeof target[key] === 'function' ? target[key].bind(target) : target[key];
220
- };
105
+ static proxyInstance(subclass) {
106
+ const bind = (target, key) => typeof target[key] === 'function' ? target[key].bind(target) : target[key];
221
107
  return new Proxy(subclass, {
222
- get: function (target, p) {
108
+ get(target, p) {
223
109
  if (target[p] !== undefined) {
224
110
  return bind(target, p);
225
111
  }
@@ -228,15 +114,13 @@ var DatabaseTransaction = /** @class */ (function (_super) {
228
114
  }
229
115
  return undefined;
230
116
  },
231
- apply: function (target, thisArg, argArray) {
117
+ apply(target, thisArg, argArray) {
232
118
  if (target._isOpen) {
233
- return target.transaction.apply(target, __spreadArray([], __read(argArray), false));
119
+ return target.transaction(...argArray);
234
120
  }
235
121
  throw new Error('Transaction is closed!');
236
122
  },
237
123
  });
238
- };
239
- return DatabaseTransaction;
240
- }(Function));
241
- exports.DatabaseTransaction = DatabaseTransaction;
124
+ }
125
+ }
242
126
  //# sourceMappingURL=DatabaseTransaction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatabaseTransaction.js","sourceRoot":"","sources":["../../../src/Database/DatabaseTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;GAIG;AACH;IAAkD,uCAAQ;IA2BxD;;;;;;OAMG;IACH,6BAAsB,MAAW,EAAE,QAAuB,EAAE,MAAY;QACtE,YAAA,MAAK,YAAC,SAAS,EAAE,kCAAkC,CAAC,SAAA;QAkCtD;;;WAGG;QACI,YAAM,GAAG;YACd,OAAO,KAAI,CAAC,OAAO,CAAA;QACrB,CAAC,CAAA;QAED;;;;WAIG;QACI,WAAK,GAAG;;;;wBACb,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;4BACjB,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;wBACjE,CAAC;wBACD,qBAAM,IAAI,CAAC,OAAO,EAAE,EAAA;;wBAApB,S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FF"}
@@ -1,16 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KyselyDatabase = exports.PostgresDatabase = exports.KnexDatabase = exports.DatabaseManager = exports.Database = exports.DatabaseTransaction = void 0;
4
- var Database_1 = require("./Database");
5
- Object.defineProperty(exports, "Database", { enumerable: true, get: function () { return Database_1.Database; } });
6
- var DatabaseManager_1 = require("./DatabaseManager");
7
- Object.defineProperty(exports, "DatabaseManager", { enumerable: true, get: function () { return DatabaseManager_1.DatabaseManager; } });
8
- var DatabaseTransaction_1 = require("./DatabaseTransaction");
9
- Object.defineProperty(exports, "DatabaseTransaction", { enumerable: true, get: function () { return DatabaseTransaction_1.DatabaseTransaction; } });
10
- var KnexDatabase_1 = require("./integrations/knex/KnexDatabase");
11
- Object.defineProperty(exports, "KnexDatabase", { enumerable: true, get: function () { return KnexDatabase_1.KnexDatabase; } });
12
- var KyselyDatabase_1 = require("./integrations/kysely/KyselyDatabase");
13
- Object.defineProperty(exports, "KyselyDatabase", { enumerable: true, get: function () { return KyselyDatabase_1.KyselyDatabase; } });
14
- var PostgresDatabase_1 = require("./integrations/pgsql/PostgresDatabase");
15
- Object.defineProperty(exports, "PostgresDatabase", { enumerable: true, get: function () { return PostgresDatabase_1.PostgresDatabase; } });
1
+ import { Database } from './Database';
2
+ import { DatabaseManager } from './DatabaseManager';
3
+ import { DatabaseTransaction } from './DatabaseTransaction';
4
+ import { KnexDatabase } from './integrations/knex/KnexDatabase';
5
+ import { KyselyDatabase } from './integrations/kysely/KyselyDatabase';
6
+ import { PostgresDatabase } from './integrations/pgsql/PostgresDatabase';
7
+ export {
8
+ // Abstracts
9
+ DatabaseTransaction, Database,
10
+ // 'Entrypoints'
11
+ DatabaseManager, KnexDatabase, PostgresDatabase, KyselyDatabase, };
16
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Database/index.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AAcnC,yFAdO,mBAAQ,OAcP;AAbV,qDAAmD;AAejD,gGAfO,iCAAe,OAeP;AAdjB,6DAA2D;AAWzD,oGAXO,yCAAmB,OAWP;AAVrB,iEAA+D;AAiB7D,6FAjBO,2BAAY,OAiBP;AAfd,uEAAqE;AAqBnE,+FArBO,+BAAc,OAqBP;AAnBhB,0EAAwE;AAgBtE,iGAhBO,mCAAgB,OAgBP"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Database/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;AAIxE,OAAO;AACL,YAAY;AACZ,mBAAmB,EACnB,QAAQ;AACR,gBAAgB;AAChB,eAAe,EAIf,YAAY,EAGZ,gBAAgB,EAGhB,cAAc,GACf,CAAA"}
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -23,61 +7,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
24
8
  });
25
9
  };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.KnexDatabase = void 0;
55
- var knex_1 = require("knex");
56
- var knexStringcase = require("knex-stringcase");
57
- var KnexTransaction_1 = require("./KnexTransaction");
58
- var Database_1 = require("../../Database");
10
+ import knex from 'knex';
11
+ import * as knexStringcase from 'knex-stringcase';
12
+ import { KnexTransactionImpl } from './KnexTransaction';
13
+ import { Database } from '../../Database';
59
14
  /**
60
15
  * Represents a KnexDatabase class that extends Database and provides methods for interacting with a Knex database.
61
16
  */
62
- var KnexDatabase = /** @class */ (function (_super) {
63
- __extends(KnexDatabase, _super);
17
+ export class KnexDatabase extends Database {
64
18
  /**
65
19
  * Constructor for creating a new instance of a database connection using Knex.
66
20
  * @param {DbConfig<'knex'>} config - The configuration object for the Knex database.
67
21
  * @returns None
68
22
  */
69
- function KnexDatabase(config) {
70
- var _this = _super.call(this, config) || this;
71
- _this.client = KnexDatabase.knexProvider(_this.constructConfig(config));
72
- return _this;
23
+ constructor(config) {
24
+ super(config);
25
+ this.client = KnexDatabase.knexProvider(this.constructConfig(config));
73
26
  }
74
27
  /**
75
28
  * Constructs a Knex configuration object based on the provided DbConfig.
76
29
  * @param {DbConfig<'knex'>} config - The database configuration object.
77
30
  * @returns The Knex configuration object with appropriate settings based on the input config.
78
31
  */
79
- KnexDatabase.prototype.constructConfig = function (config) {
80
- var knexConfig = {
32
+ constructConfig(config) {
33
+ const knexConfig = {
81
34
  client: config.driver,
82
35
  connection: {
83
36
  host: config.host,
@@ -92,28 +45,21 @@ var KnexDatabase = /** @class */ (function (_super) {
92
45
  },
93
46
  };
94
47
  return config.convertCamelToSnake ? knexStringcase(knexConfig) : knexConfig;
95
- };
48
+ }
96
49
  /**
97
50
  * Override method to start a new transaction using KnexTransactionImpl.
98
51
  * @returns {Promise<KnexTransaction>} A promise that resolves to a KnexTransaction object.
99
52
  */
100
- KnexDatabase.prototype.transaction = function () {
101
- return __awaiter(this, void 0, void 0, function () {
102
- return __generator(this, function (_a) {
103
- switch (_a.label) {
104
- case 0: return [4 /*yield*/, KnexTransaction_1.KnexTransactionImpl.newTransaction(this.client, this)];
105
- case 1: return [2 /*return*/, _a.sent()];
106
- }
107
- });
53
+ transaction() {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ return yield KnexTransactionImpl.newTransaction(this.client, this);
108
56
  });
109
- };
110
- /**
111
- * A static property that provides a Knex instance based on the given configuration.
112
- * @param {knex.Knex.Config<any>} config - The configuration object for Knex.
113
- * @returns {knex.Knex<any, unknown[]>} A Knex instance based on the provided configuration.
114
- */
115
- KnexDatabase.knexProvider = knex_1.default;
116
- return KnexDatabase;
117
- }(Database_1.Database));
118
- exports.KnexDatabase = KnexDatabase;
57
+ }
58
+ }
59
+ /**
60
+ * A static property that provides a Knex instance based on the given configuration.
61
+ * @param {knex.Knex.Config<any>} config - The configuration object for Knex.
62
+ * @returns {knex.Knex<any, unknown[]>} A Knex instance based on the provided configuration.
63
+ */
64
+ KnexDatabase.knexProvider = knex;
119
65
  //# sourceMappingURL=KnexDatabase.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"KnexDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexDatabase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAiC;AACjC,gDAAiD;AAEjD,qDAAwE;AACxE,2CAAyC;AAGzC;;GAEG;AACH;IAAkC,gCAAyB;IAazD;;;;OAIG;IACH,sBAAmB,MAAwB;QACzC,YAAA,MAAK,YAAC,MAAM,CAAC,SAAA;QAEb,KAAI,CAAC,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,KAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;;IACvE,CAAC;IAED;;;;OAIG;IACK,sCAAe,GAAvB,UAAwB,MAAwB;QAC9C,IAAM,UAAU,GAAG;YACjB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,U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OAIG;IACK,eAAe,CAAC,MAAwB;QAC9C,MAAM,UAAU,GAAG;YACjB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,UAAU,EAAE;gBACV,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,IAAI,EAAE,MAAM,CAAC,QAAQ;gBACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;gBACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;aAC1B;YACD,IAAI,EAAE;gBACJ,GAAG,EAAE,CAAC;gBACN,GAAG,EAAE,MAAM,CAAC,cAAc;aAC3B;SACF,CAAA;QAED,OAAO,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAA;IAC7E,CAAC;IAED;;;OAGG;IACmB,WAAW;;YAC/B,OAAO,MAAM,mBAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACpE,CAAC;KAAA;;AArDD;;;;GAIG;AACY,yBAAY,GAAiE,IAAI,CAAA"}
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -23,82 +7,42 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
24
8
  });
25
9
  };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
33
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.KnexTransactionImpl = void 0;
55
- var DatabaseTransaction_1 = require("../../DatabaseTransaction");
10
+ import { DatabaseTransaction } from '../../DatabaseTransaction';
56
11
  /**
57
12
  * Represents a Knex database transaction implementation that extends DatabaseTransaction.
58
13
  * @class
59
14
  */
60
- var KnexTransactionImpl = /** @class */ (function (_super) {
61
- __extends(KnexTransactionImpl, _super);
15
+ export class KnexTransactionImpl extends DatabaseTransaction {
62
16
  /**
63
17
  * Constructs a new instance of the class with the provided Knex writer and database.
64
18
  * @param {Knex} writer - The Knex instance used for writing to the database.
65
19
  * @param {KnexDatabase} database - The KnexDatabase instance used for database operations.
66
20
  * @returns None
67
21
  */
68
- function KnexTransactionImpl(writer, database) {
69
- var _this = _super.call(this, writer, database) || this;
22
+ constructor(writer, database) {
23
+ super(writer, database);
70
24
  /**
71
25
  * Initiates a transaction using the writer and assigns it to the 'transaction' property.
72
26
  * @returns {Promise<Transaction>} A promise that resolves to the transaction object.
73
27
  */
74
- _this.doBegin = function () { return __awaiter(_this, void 0, void 0, function () {
75
- var _a;
76
- return __generator(this, function (_b) {
77
- switch (_b.label) {
78
- case 0:
79
- _a = this;
80
- return [4 /*yield*/, this.writer.transaction()];
81
- case 1:
82
- _a.transaction = _b.sent();
83
- return [2 /*return*/, this.transaction];
84
- }
85
- });
86
- }); };
28
+ this.doBegin = () => __awaiter(this, void 0, void 0, function* () {
29
+ this.transaction = yield this.writer.transaction();
30
+ return this.transaction;
31
+ });
87
32
  /**
88
33
  * Commits the current transaction.
89
34
  * @returns None
90
35
  */
91
- _this.doCommit = function () {
92
- return _this.transaction.commit();
36
+ this.doCommit = () => {
37
+ return this.transaction.commit();
93
38
  };
94
39
  /**
95
40
  * Rollback the current transaction.
96
41
  * @returns The result of the rollback operation.
97
42
  */
98
- _this.doRollback = function () {
99
- return _this.transaction.rollback();
43
+ this.doRollback = () => {
44
+ return this.transaction.rollback();
100
45
  };
101
- return _this;
102
46
  }
103
47
  /**
104
48
  * Creates a new database transaction using the provided Knex instance and database configuration.
@@ -106,22 +50,12 @@ var KnexTransactionImpl = /** @class */ (function (_super) {
106
50
  * @param {KnexDatabase} database - The database configuration for the transaction.
107
51
  * @returns {Promise<KnexTransaction>} A promise that resolves to a new database transaction.
108
52
  */
109
- KnexTransactionImpl.newTransaction = function (write, database) {
110
- return __awaiter(this, void 0, void 0, function () {
111
- var tx;
112
- return __generator(this, function (_a) {
113
- switch (_a.label) {
114
- case 0:
115
- tx = new KnexTransactionImpl(write, database);
116
- return [4 /*yield*/, tx.begin()];
117
- case 1:
118
- _a.sent();
119
- return [2 /*return*/, DatabaseTransaction_1.DatabaseTransaction.proxyInstance(tx)];
120
- }
121
- });
53
+ static newTransaction(write, database) {
54
+ return __awaiter(this, void 0, void 0, function* () {
55
+ const tx = new KnexTransactionImpl(write, database);
56
+ yield tx.begin();
57
+ return DatabaseTransaction.proxyInstance(tx);
122
58
  });
123
- };
124
- return KnexTransactionImpl;
125
- }(DatabaseTransaction_1.DatabaseTransaction));
126
- exports.KnexTransactionImpl = KnexTransactionImpl;
59
+ }
60
+ }
127
61
  //# sourceMappingURL=KnexTransaction.js.map