@creator.co/wapi 1.3.2 → 1.3.4

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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.3.2-alpha",
3
+ "version": "1.3.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1 +1 @@
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;AAgCnE;;;;;GAKG;AACH;IA8DE;;;;;;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,M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a;;;;;;;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,AAvPD,IAuPC"}
@@ -1,17 +1,13 @@
1
1
  import { Database } from './Database';
2
2
  /**
3
3
  * Abstract class representing a database transaction.
4
+ * Warning: These need to be arrow functions!
4
5
  * @class DatabaseTransaction
5
6
  */
6
- export declare abstract class DatabaseTransaction {
7
+ export declare abstract class DatabaseTransaction extends Function {
7
8
  private _isOpen;
8
9
  protected delegate: any;
9
10
  protected database: Database<any>;
10
- /**
11
- * Returns a boolean value indicating whether the transaction is open or not.
12
- * @returns {boolean} - true if the object is open, false otherwise.
13
- */
14
- get isOpen(): boolean;
15
11
  /**
16
12
  * Constructs a new instance of the class.
17
13
  * @param {any} delegate - The delegate object.
@@ -30,36 +26,41 @@ export declare abstract class DatabaseTransaction {
30
26
  * @throws {Error} - If the target instance is closed.
31
27
  */
32
28
  protected static wrapInstance<T extends DatabaseTransaction>(subclass: T): T;
29
+ /**
30
+ * Returns a boolean value indicating whether the transaction is open or not.
31
+ * @returns {boolean} - true if the object is open, false otherwise.
32
+ */
33
+ isOpen: () => boolean;
33
34
  /**
34
35
  * Commits the transaction.
35
36
  * @throws {Error} - If the transaction is already closed.
36
37
  * @returns None
37
38
  */
38
- commit(): Promise<void>;
39
+ commit: () => Promise<void>;
39
40
  /**
40
41
  * Rollbacks the current transaction.
41
42
  * @throws {Error} - If the transaction is already closed.
42
43
  * @returns {Promise<void>} - A promise that resolves once the rollback is complete.
43
44
  */
44
- rollback(): Promise<void>;
45
+ rollback: () => Promise<void>;
45
46
  /**
46
47
  * Closes the transaction after a successful execution.
47
48
  * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
48
49
  */
49
- closeSuccess(): Promise<void>;
50
+ closeSuccess: () => Promise<void>;
50
51
  /**
51
52
  * Closes the transaction after a failed execution.
52
53
  * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
53
54
  */
54
- closeFailure(): Promise<void>;
55
+ closeFailure: () => Promise<void>;
55
56
  /**
56
57
  * An abstract method that performs the commit operation.
57
58
  * @returns {Promise<any>} A promise that resolves when the commit operation is completed.
58
59
  */
59
- protected abstract doCommit(): Promise<any>;
60
+ protected abstract doCommit: () => Promise<any>;
60
61
  /**
61
62
  * An abstract method that performs a rollback operation.
62
63
  * @returns A Promise that resolves when the rollback operation is complete.
63
64
  */
64
- protected abstract doRollback(): Promise<any>;
65
+ protected abstract doRollback: () => Promise<any>;
65
66
  }
@@ -1,4 +1,19 @@
1
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
+ })();
2
17
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
18
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
19
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,13 +50,40 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
50
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
51
  }
37
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
+ };
38
78
  Object.defineProperty(exports, "__esModule", { value: true });
39
79
  exports.DatabaseTransaction = void 0;
40
80
  /**
41
81
  * Abstract class representing a database transaction.
82
+ * Warning: These need to be arrow functions!
42
83
  * @class DatabaseTransaction
43
84
  */
44
- var DatabaseTransaction = /** @class */ (function () {
85
+ var DatabaseTransaction = /** @class */ (function (_super) {
86
+ __extends(DatabaseTransaction, _super);
45
87
  /**
46
88
  * Constructs a new instance of the class.
47
89
  * @param {any} delegate - The delegate object.
@@ -49,54 +91,21 @@ var DatabaseTransaction = /** @class */ (function () {
49
91
  * @protected
50
92
  */
51
93
  function DatabaseTransaction(delegate, database) {
52
- this._isOpen = true;
53
- this.delegate = delegate;
54
- this.database = database;
55
- }
56
- Object.defineProperty(DatabaseTransaction.prototype, "isOpen", {
94
+ var _this = _super.call(this, '...args', 'return this.delegate(...args)') || this;
95
+ _this._isOpen = true;
57
96
  /**
58
97
  * Returns a boolean value indicating whether the transaction is open or not.
59
98
  * @returns {boolean} - true if the object is open, false otherwise.
60
99
  */
61
- get: function () {
62
- return this._isOpen;
63
- },
64
- enumerable: false,
65
- configurable: true
66
- });
67
- /**
68
- * Wraps an instance of a subclass of DatabaseTransaction with a Proxy object.
69
- * The Proxy object intercepts method calls and delegates to the target instance.
70
- * If the method is on the target instance, it is called directly.
71
- * If the method is not on the target instance and the transaction is open, it is called on the target's delegate implementation.
72
- * If the method is not on the target instance and the transaction is closed, an error is thrown.
73
- * @param {T} subclass - The subclass instance to wrap with a Proxy.
74
- * @returns {T} - The wrapped subclass instance.
75
- * @throws {Error} - If the target instance is closed.
76
- */
77
- DatabaseTransaction.wrapInstance = function (subclass) {
78
- var bind = function (target, key) {
79
- return typeof target[key] === 'function' ? target[key].bind(target) : target[key];
100
+ _this.isOpen = function () {
101
+ return _this._isOpen;
80
102
  };
81
- return new Proxy(subclass, {
82
- get: function (target, p) {
83
- if (target[p] !== undefined) {
84
- return bind(target, p);
85
- }
86
- else if (target._isOpen) {
87
- return bind(target.delegate, p);
88
- }
89
- return undefined;
90
- },
91
- });
92
- };
93
- /**
94
- * Commits the transaction.
95
- * @throws {Error} - If the transaction is already closed.
96
- * @returns None
97
- */
98
- DatabaseTransaction.prototype.commit = function () {
99
- return __awaiter(this, void 0, void 0, function () {
103
+ /**
104
+ * Commits the transaction.
105
+ * @throws {Error} - If the transaction is already closed.
106
+ * @returns None
107
+ */
108
+ _this.commit = function () { return __awaiter(_this, void 0, void 0, function () {
100
109
  return __generator(this, function (_a) {
101
110
  switch (_a.label) {
102
111
  case 0:
@@ -110,15 +119,13 @@ var DatabaseTransaction = /** @class */ (function () {
110
119
  return [2 /*return*/];
111
120
  }
112
121
  });
113
- });
114
- };
115
- /**
116
- * Rollbacks the current transaction.
117
- * @throws {Error} - If the transaction is already closed.
118
- * @returns {Promise<void>} - A promise that resolves once the rollback is complete.
119
- */
120
- DatabaseTransaction.prototype.rollback = function () {
121
- return __awaiter(this, void 0, void 0, function () {
122
+ }); };
123
+ /**
124
+ * Rollbacks the current transaction.
125
+ * @throws {Error} - If the transaction is already closed.
126
+ * @returns {Promise<void>} - A promise that resolves once the rollback is complete.
127
+ */
128
+ _this.rollback = function () { return __awaiter(_this, void 0, void 0, function () {
122
129
  return __generator(this, function (_a) {
123
130
  switch (_a.label) {
124
131
  case 0:
@@ -132,14 +139,12 @@ var DatabaseTransaction = /** @class */ (function () {
132
139
  return [2 /*return*/];
133
140
  }
134
141
  });
135
- });
136
- };
137
- /**
138
- * Closes the transaction after a successful execution.
139
- * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
140
- */
141
- DatabaseTransaction.prototype.closeSuccess = function () {
142
- return __awaiter(this, void 0, void 0, function () {
142
+ }); };
143
+ /**
144
+ * Closes the transaction after a successful execution.
145
+ * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
146
+ */
147
+ _this.closeSuccess = function () { return __awaiter(_this, void 0, void 0, function () {
143
148
  return __generator(this, function (_a) {
144
149
  switch (_a.label) {
145
150
  case 0:
@@ -156,14 +161,12 @@ var DatabaseTransaction = /** @class */ (function () {
156
161
  case 4: return [2 /*return*/];
157
162
  }
158
163
  });
159
- });
160
- };
161
- /**
162
- * Closes the transaction after a failed execution.
163
- * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
164
- */
165
- DatabaseTransaction.prototype.closeFailure = function () {
166
- return __awaiter(this, void 0, void 0, function () {
164
+ }); };
165
+ /**
166
+ * Closes the transaction after a failed execution.
167
+ * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
168
+ */
169
+ _this.closeFailure = function () { return __awaiter(_this, void 0, void 0, function () {
167
170
  return __generator(this, function (_a) {
168
171
  switch (_a.label) {
169
172
  case 0:
@@ -175,9 +178,44 @@ var DatabaseTransaction = /** @class */ (function () {
175
178
  case 2: return [2 /*return*/];
176
179
  }
177
180
  });
181
+ }); };
182
+ _this.delegate = delegate;
183
+ _this.database = database;
184
+ return _this;
185
+ }
186
+ /**
187
+ * Wraps an instance of a subclass of DatabaseTransaction with a Proxy object.
188
+ * The Proxy object intercepts method calls and delegates to the target instance.
189
+ * If the method is on the target instance, it is called directly.
190
+ * If the method is not on the target instance and the transaction is open, it is called on the target's delegate implementation.
191
+ * If the method is not on the target instance and the transaction is closed, an error is thrown.
192
+ * @param {T} subclass - The subclass instance to wrap with a Proxy.
193
+ * @returns {T} - The wrapped subclass instance.
194
+ * @throws {Error} - If the target instance is closed.
195
+ */
196
+ DatabaseTransaction.wrapInstance = function (subclass) {
197
+ var bind = function (target, key) {
198
+ return typeof target[key] === 'function' ? target[key].bind(target) : target[key];
199
+ };
200
+ return new Proxy(subclass, {
201
+ get: function (target, p) {
202
+ if (target[p] !== undefined) {
203
+ return bind(target, p);
204
+ }
205
+ else if (target._isOpen) {
206
+ return bind(target.delegate, p);
207
+ }
208
+ return undefined;
209
+ },
210
+ apply: function (target, thisArg, argArray) {
211
+ if (target._isOpen) {
212
+ return target.delegate.apply(target, __spreadArray([], __read(argArray), false));
213
+ }
214
+ throw new Error('Transaction is closed!');
215
+ },
178
216
  });
179
217
  };
180
218
  return DatabaseTransaction;
181
- }());
219
+ }(Function));
182
220
  exports.DatabaseTransaction = DatabaseTransaction;
183
221
  //# sourceMappingURL=DatabaseTransaction.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatabaseTransaction.js","sourceRoot":"","sources":["../../../src/Database/DatabaseTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;GAGG;AACH;IAaE;;;;;OAKG;IACH,6BAAsB,QAAa,EAAE,QAAuB;QAlBpD,YAAO,GAAY,IAAI,CAAA;QAmB7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAA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AAkB;gBAC/B,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;oBAC3B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;iBACvB;qBAAM,IAAI,MAAM,CAAC,OAAO,EAAE;oBACzB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;iBAChC;gBACD,OAAO,SAAS,CAAA;YAClB,CAAC;YACD,KAAK,YAAC,MAAS,EAAE,OAAY,EAAE,QAAe;gBAC5C,IAAI,MAAM,CAAC,OAAO,EAAE;oBAClB,OAAO,MAAM,CAAC,QAAQ,OAAf,MAAM,2BAAa,QAAQ,WAAC;iBACpC;gBACD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;YAC3C,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;IAuEH,0BAAC;AAAD,CAAC,AAtHD,CAAkD,QAAQ,GAsHzD;AAtHqB,kDAAmB"}
@@ -28,10 +28,10 @@ export declare class KnexTransactionImpl extends DatabaseTransaction {
28
28
  * Commits the changes made by the delegate object.
29
29
  * @returns None
30
30
  */
31
- protected doCommit(): any;
31
+ protected doCommit: () => any;
32
32
  /**
33
33
  * Performs a rollback operation by calling the rollback method of the delegate object.
34
34
  * @returns None
35
35
  */
36
- protected doRollback(): any;
36
+ protected doRollback: () => any;
37
37
  }
@@ -29,7 +29,22 @@ var KnexTransactionImpl = /** @class */ (function (_super) {
29
29
  * @returns None
30
30
  */
31
31
  function KnexTransactionImpl(delegate, database) {
32
- return _super.call(this, delegate, database) || this;
32
+ var _this = _super.call(this, delegate, database) || this;
33
+ /**
34
+ * Commits the changes made by the delegate object.
35
+ * @returns None
36
+ */
37
+ _this.doCommit = function () {
38
+ return _this.delegate.commit();
39
+ };
40
+ /**
41
+ * Performs a rollback operation by calling the rollback method of the delegate object.
42
+ * @returns None
43
+ */
44
+ _this.doRollback = function () {
45
+ return _this.delegate.rollback();
46
+ };
47
+ return _this;
33
48
  }
34
49
  /**
35
50
  * Wraps a delegate transaction object with a custom implementation of the KnexTransaction interface.
@@ -40,20 +55,6 @@ var KnexTransactionImpl = /** @class */ (function (_super) {
40
55
  KnexTransactionImpl.wrapDelegate = function (delegate, database) {
41
56
  return DatabaseTransaction_1.DatabaseTransaction.wrapInstance(new KnexTransactionImpl(delegate, database));
42
57
  };
43
- /**
44
- * Commits the changes made by the delegate object.
45
- * @returns None
46
- */
47
- KnexTransactionImpl.prototype.doCommit = function () {
48
- return this.delegate.commit();
49
- };
50
- /**
51
- * Performs a rollback operation by calling the rollback method of the delegate object.
52
- * @returns None
53
- */
54
- KnexTransactionImpl.prototype.doRollback = function () {
55
- return this.delegate.rollback();
56
- };
57
58
  return KnexTransactionImpl;
58
59
  }(DatabaseTransaction_1.DatabaseTransaction));
59
60
  exports.KnexTransactionImpl = KnexTransactionImpl;
@@ -1 +1 @@
1
- {"version":3,"file":"KnexTransaction.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAGA,iEAA+D;AAQ/D;;GAEG;AACH;IAAyC,uCAAmB;IAC1D;;;;;OAKG;IACH,6BAAoB,QAA0B,EAAE,QAAsB;eACpE,kBAAM,QAAQ,EAAE,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACW,gCAAY,GAA1B,UAA2B,QAA0B,EAAE,QAAsB;QAC3E,OAAO,yCAAmB,CAAC,YAAY,CAAC,IAAI,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAQ,CAAA;IAC7F,CAAC;IAED;;;OAGG;IACO,sCAAQ,GAAlB;QACE,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAA;IAC/B,CAAC;IAED;;;OAGG;IACO,wCAAU,GAApB;QACE,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAA;IACjC,CAAC;IACH,0BAAC;AAAD,CAAC,AApCD,CAAyC,yCAAmB,GAoC3D;AApCY,kDAAmB"}
1
+ {"version":3,"file":"KnexTransaction.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAGA,iEAA+D;AAQ/D;;GAEG;AACH;IAAyC,uCAAmB;IAC1D;;;;;OAKG;IACH,6BAAoB,QAA0B,EAAE,QAAsB;QAAtE,YACE,kBAAM,QAAQ,EAAE,QAAQ,CAAC,SAC1B;QAYD;;;WAGG;QACO,cAAQ,GAAG;YACnB,OAAO,KAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAA;QAC/B,CAAC,CAAA;QAED;;;WAGG;QACO,gBAAU,GAAG;YACrB,OAAO,KAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAA;QACjC,CAAC,CAAA;;IA1BD,CAAC;IAED;;;;;OAKG;IACW,gCAAY,GAA1B,UAA2B,QAA0B,EAAE,QAAsB;QAC3E,OAAO,yCAAmB,CAAC,YAAY,CAAC,IAAI,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAQ,CAAA;IAC7F,CAAC;IAiBH,0BAAC;AAAD,CAAC,AApCD,CAAyC,yCAAmB,GAoC3D;AApCY,kDAAmB"}
@@ -28,10 +28,10 @@ export declare class PostgresTransactionImpl extends DatabaseTransaction {
28
28
  * Commits the current transaction.
29
29
  * @returns A promise that resolves when the commit is successful.
30
30
  */
31
- protected doCommit(): any;
31
+ protected doCommit: () => any;
32
32
  /**
33
33
  * Performs a rollback operation in the database.
34
34
  * @returns A promise that resolves when the rollback operation is completed.
35
35
  */
36
- protected doRollback(): any;
36
+ protected doRollback: () => any;
37
37
  }
@@ -29,7 +29,22 @@ var PostgresTransactionImpl = /** @class */ (function (_super) {
29
29
  * @returns None
30
30
  */
31
31
  function PostgresTransactionImpl(delegate, database) {
32
- return _super.call(this, delegate, database) || this;
32
+ var _this = _super.call(this, delegate, database) || this;
33
+ /**
34
+ * Commits the current transaction.
35
+ * @returns A promise that resolves when the commit is successful.
36
+ */
37
+ _this.doCommit = function () {
38
+ return _this.delegate.query('COMMIT');
39
+ };
40
+ /**
41
+ * Performs a rollback operation in the database.
42
+ * @returns A promise that resolves when the rollback operation is completed.
43
+ */
44
+ _this.doRollback = function () {
45
+ return _this.delegate.query('ROLLBACK');
46
+ };
47
+ return _this;
33
48
  }
34
49
  /**
35
50
  * Static factory method for creating a new instance, wrapping a delegate PoolClient.
@@ -40,20 +55,6 @@ var PostgresTransactionImpl = /** @class */ (function (_super) {
40
55
  PostgresTransactionImpl.wrapDelegate = function (delegate, database) {
41
56
  return DatabaseTransaction_1.DatabaseTransaction.wrapInstance(new PostgresTransactionImpl(delegate, database));
42
57
  };
43
- /**
44
- * Commits the current transaction.
45
- * @returns A promise that resolves when the commit is successful.
46
- */
47
- PostgresTransactionImpl.prototype.doCommit = function () {
48
- return this.delegate.query('COMMIT');
49
- };
50
- /**
51
- * Performs a rollback operation in the database.
52
- * @returns A promise that resolves when the rollback operation is completed.
53
- */
54
- PostgresTransactionImpl.prototype.doRollback = function () {
55
- return this.delegate.query('ROLLBACK');
56
- };
57
58
  return PostgresTransactionImpl;
58
59
  }(DatabaseTransaction_1.DatabaseTransaction));
59
60
  exports.PostgresTransactionImpl = PostgresTransactionImpl;
@@ -1 +1 @@
1
- {"version":3,"file":"PostgresTransaction.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/pgsql/PostgresTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAGA,iEAA+D;AAQ/D;;GAEG;AACH;IAA6C,2CAAmB;IAC9D;;;;;OAKG;IACH,iCAAoB,QAAoB,EAAE,QAA0B;eAClE,kBAAM,QAAQ,EAAE,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;;OAKG;IACW,oCAAY,GAA1B,UACE,QAAoB,EACpB,QAA0B;QAE1B,OAAO,yCAAmB,CAAC,YAAY,CAAC,IAAI,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAQ,CAAA;IACjG,CAAC;IAED;;;OAGG;IACO,0CAAQ,GAAlB;QACE,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IACtC,CAAC;IAED;;;OAGG;IACO,4CAAU,GAApB;QACE,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IACxC,CAAC;IACH,8BAAC;AAAD,CAAC,AAvCD,CAA6C,yCAAmB,GAuC/D;AAvCY,0DAAuB"}
1
+ {"version":3,"file":"PostgresTransaction.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/pgsql/PostgresTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAGA,iEAA+D;AAQ/D;;GAEG;AACH;IAA6C,2CAAmB;IAC9D;;;;;OAKG;IACH,iCAAoB,QAAoB,EAAE,QAA0B;QAApE,YACE,kBAAM,QAAQ,EAAE,QAAQ,CAAC,SAC1B;QAeD;;;WAGG;QACO,cAAQ,GAAG;YACnB,OAAO,KAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;QACtC,CAAC,CAAA;QAED;;;WAGG;QACO,gBAAU,GAAG;YACrB,OAAO,KAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;QACxC,CAAC,CAAA;;IA7BD,CAAC;IAED;;;;;OAKG;IACW,oCAAY,GAA1B,UACE,QAAoB,EACpB,QAA0B;QAE1B,OAAO,yCAAmB,CAAC,YAAY,CAAC,IAAI,uBAAuB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAQ,CAAA;IACjG,CAAC;IAiBH,8BAAC;AAAD,CAAC,AAvCD,CAA6C,yCAAmB,GAuC/D;AAvCY,0DAAuB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.3.2",
3
+ "version": "1.3.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -50,7 +50,7 @@ export default class Request<InputType, PathParamsType, QueryParamsType> {
50
50
  * @param {keyof QueryParamsType} paramName - The name of the query parameter to retrieve.
51
51
  * @returns {string | null} The value of the query parameter, or null if it does not exist.
52
52
  */
53
- public getQueryParam(paramName: keyof QueryParamsType): QueryParamsType[paramParam] {
53
+ public getQueryParam(paramName: keyof QueryParamsType): string | null {
54
54
  return Utils.caseInsensitiveObjectForKey(
55
55
  this.requestEvent.queryStringParameters,
56
56
  String(paramName)
@@ -118,8 +118,8 @@ export default class Transaction<
118
118
  const transactionId = context.awsRequestId
119
119
  ? context.awsRequestId
120
120
  : (<APIGatewayEvent>event).requestContext
121
- ? (<APIGatewayEvent>event).requestContext.requestId
122
- : 'unknown'
121
+ ? (<APIGatewayEvent>event).requestContext.requestId
122
+ : 'unknown'
123
123
  // transaction ctx
124
124
  this.event = event
125
125
  this.context = context
@@ -2,21 +2,14 @@ import { Database } from './Database'
2
2
 
3
3
  /**
4
4
  * Abstract class representing a database transaction.
5
+ * Warning: These need to be arrow functions!
5
6
  * @class DatabaseTransaction
6
7
  */
7
- export abstract class DatabaseTransaction {
8
+ export abstract class DatabaseTransaction extends Function {
8
9
  private _isOpen: boolean = true
9
10
  protected delegate: any
10
11
  protected database: Database<any>
11
12
 
12
- /**
13
- * Returns a boolean value indicating whether the transaction is open or not.
14
- * @returns {boolean} - true if the object is open, false otherwise.
15
- */
16
- public get isOpen(): boolean {
17
- return this._isOpen
18
- }
19
-
20
13
  /**
21
14
  * Constructs a new instance of the class.
22
15
  * @param {any} delegate - The delegate object.
@@ -24,6 +17,7 @@ export abstract class DatabaseTransaction {
24
17
  * @protected
25
18
  */
26
19
  protected constructor(delegate: any, database: Database<any>) {
20
+ super('...args', 'return this.delegate(...args)')
27
21
  this.delegate = delegate
28
22
  this.database = database
29
23
  }
@@ -51,15 +45,29 @@ export abstract class DatabaseTransaction {
51
45
  }
52
46
  return undefined
53
47
  },
48
+ apply(target: T, thisArg: any, argArray: any[]): any {
49
+ if (target._isOpen) {
50
+ return target.delegate(...argArray)
51
+ }
52
+ throw new Error('Transaction is closed!')
53
+ },
54
54
  })
55
55
  }
56
56
 
57
+ /**
58
+ * Returns a boolean value indicating whether the transaction is open or not.
59
+ * @returns {boolean} - true if the object is open, false otherwise.
60
+ */
61
+ public isOpen = (): boolean => {
62
+ return this._isOpen
63
+ }
64
+
57
65
  /**
58
66
  * Commits the transaction.
59
67
  * @throws {Error} - If the transaction is already closed.
60
68
  * @returns None
61
69
  */
62
- public async commit(): Promise<void> {
70
+ public commit = async (): Promise<void> => {
63
71
  if (!this._isOpen) {
64
72
  throw new Error('Cannot commit, transaction is already closed!')
65
73
  }
@@ -72,7 +80,7 @@ export abstract class DatabaseTransaction {
72
80
  * @throws {Error} - If the transaction is already closed.
73
81
  * @returns {Promise<void>} - A promise that resolves once the rollback is complete.
74
82
  */
75
- public async rollback(): Promise<void> {
83
+ public rollback = async (): Promise<void> => {
76
84
  if (!this._isOpen) {
77
85
  throw new Error('Cannot rollback, transaction is already closed!')
78
86
  }
@@ -84,7 +92,7 @@ export abstract class DatabaseTransaction {
84
92
  * Closes the transaction after a successful execution.
85
93
  * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
86
94
  */
87
- public async closeSuccess() {
95
+ public closeSuccess = async () => {
88
96
  if (this._isOpen) {
89
97
  if (this.database.config.autoCommit) {
90
98
  await this.doCommit()
@@ -98,7 +106,7 @@ export abstract class DatabaseTransaction {
98
106
  * Closes the transaction after a failed execution.
99
107
  * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
100
108
  */
101
- public async closeFailure() {
109
+ public closeFailure = async () => {
102
110
  if (this._isOpen) {
103
111
  await this.doRollback()
104
112
  }
@@ -108,11 +116,11 @@ export abstract class DatabaseTransaction {
108
116
  * An abstract method that performs the commit operation.
109
117
  * @returns {Promise<any>} A promise that resolves when the commit operation is completed.
110
118
  */
111
- protected abstract doCommit(): Promise<any>
119
+ protected abstract doCommit: () => Promise<any>
112
120
 
113
121
  /**
114
122
  * An abstract method that performs a rollback operation.
115
123
  * @returns A Promise that resolves when the rollback operation is complete.
116
124
  */
117
- protected abstract doRollback(): Promise<any>
125
+ protected abstract doRollback: () => Promise<any>
118
126
  }
@@ -37,7 +37,7 @@ export class KnexTransactionImpl extends DatabaseTransaction {
37
37
  * Commits the changes made by the delegate object.
38
38
  * @returns None
39
39
  */
40
- protected doCommit() {
40
+ protected doCommit = () => {
41
41
  return this.delegate.commit()
42
42
  }
43
43
 
@@ -45,7 +45,7 @@ export class KnexTransactionImpl extends DatabaseTransaction {
45
45
  * Performs a rollback operation by calling the rollback method of the delegate object.
46
46
  * @returns None
47
47
  */
48
- protected doRollback() {
48
+ protected doRollback = () => {
49
49
  return this.delegate.rollback()
50
50
  }
51
51
  }
@@ -40,7 +40,7 @@ export class PostgresTransactionImpl extends DatabaseTransaction {
40
40
  * Commits the current transaction.
41
41
  * @returns A promise that resolves when the commit is successful.
42
42
  */
43
- protected doCommit() {
43
+ protected doCommit = () => {
44
44
  return this.delegate.query('COMMIT')
45
45
  }
46
46
 
@@ -48,7 +48,7 @@ export class PostgresTransactionImpl extends DatabaseTransaction {
48
48
  * Performs a rollback operation in the database.
49
49
  * @returns A promise that resolves when the rollback operation is completed.
50
50
  */
51
- protected doRollback() {
51
+ protected doRollback = () => {
52
52
  return this.delegate.query('ROLLBACK')
53
53
  }
54
54
  }
@@ -1,6 +1,6 @@
1
1
  import { expect } from 'chai'
2
2
 
3
- import { DatabaseManager } from '../../src/Database/DatabaseManager'
3
+ import { DatabaseManager } from '../../src/Database'
4
4
  import type { DatabaseType, DbConfig } from '../../src/Database/types'
5
5
 
6
6
  type FakeDatabase = { host: string; type: 'knex' | 'pg' }
@@ -1,8 +1,7 @@
1
1
  import { Knex } from 'knex'
2
2
 
3
+ import type { DbConfig } from '../../../../src/Database'
3
4
  import { KnexDatabase } from '../../../../src/Database/integrations/knex/KnexDatabase'
4
- import { KnexTransactionImpl } from '../../../../src/Database/integrations/knex/KnexTransaction'
5
- import type { DbConfig } from '../../../../src/Database/types'
6
5
 
7
6
  const config: DbConfig<'knex'> = {
8
7
  type: 'knex',
@@ -47,7 +46,7 @@ describe('KnexDatabase', () => {
47
46
 
48
47
  const trans = await underTest.transaction()
49
48
 
50
- expect(trans).toBeInstanceOf(KnexTransactionImpl)
49
+ expect(trans).toBeInstanceOf(Function)
51
50
  expect(trans['delegate']).toBe(mockTrans)
52
51
  })
53
52
 
@@ -70,7 +69,7 @@ describe('KnexDatabase', () => {
70
69
 
71
70
  const trans = await underTest.transaction()
72
71
 
73
- expect(trans).toBeInstanceOf(KnexTransactionImpl)
72
+ expect(trans).toBeInstanceOf(Function)
74
73
  expect(trans['delegate']).toBe(mockTrans)
75
74
  })
76
75
  })
@@ -12,13 +12,12 @@ const testResources = (config: Partial<DbConfig<'knex'>>) => {
12
12
  } as DbConfig<'knex'>,
13
13
  } as KnexDatabase
14
14
 
15
- const delegate = jest.fn().mockImplementation(() => {
16
- return {
17
- commit: jest.fn(),
18
- rollback: jest.fn(),
19
- select: jest.fn(),
20
- }
21
- })() as any as Knex.Transaction
15
+ const mock = jest.fn() as any
16
+ mock.commit = jest.fn()
17
+ mock.rollback = jest.fn()
18
+ mock.select = jest.fn()
19
+
20
+ const delegate = mock as Knex.Transaction
22
21
 
23
22
  return {
24
23
  delegate,
@@ -30,7 +29,7 @@ describe('KnexTransaction', () => {
30
29
  test('Can only commit once', async () => {
31
30
  const { delegate, underTest } = testResources({})
32
31
  await underTest.commit()
33
- expect(underTest.isOpen).toBe(false)
32
+ expect(underTest.isOpen()).toBe(false)
34
33
  expect(delegate.commit).toBeCalled()
35
34
 
36
35
  await expect(underTest.commit).rejects.toThrowError(
@@ -41,7 +40,7 @@ describe('KnexTransaction', () => {
41
40
  test("Can't commit after rollback", async () => {
42
41
  const { delegate, underTest } = testResources({})
43
42
  await underTest.rollback()
44
- expect(underTest.isOpen).toBe(false)
43
+ expect(underTest.isOpen()).toBe(false)
45
44
  expect(delegate.rollback).toBeCalled()
46
45
 
47
46
  await expect(underTest.commit).rejects.toThrowError(
@@ -61,7 +60,7 @@ describe('KnexTransaction', () => {
61
60
 
62
61
  await underTest.commit()
63
62
  expect(delegate.commit).toBeCalled()
64
- expect(underTest.isOpen).toBe(false)
63
+ expect(underTest.isOpen()).toBe(false)
65
64
 
66
65
  expect(underTest.select).toBeUndefined()
67
66
  })
@@ -131,3 +130,12 @@ describe('KnexTransaction - closeFailure', () => {
131
130
  expect(delegate.commit).toBeCalledTimes(1)
132
131
  })
133
132
  })
133
+
134
+ describe('KnexTransaction - call direct', () => {
135
+ test('Calls delegate', async () => {
136
+ const { delegate, underTest } = testResources({ autoCommit: false })
137
+
138
+ underTest('test')
139
+ expect(delegate).toBeCalledWith('test')
140
+ })
141
+ })
@@ -1,8 +1,7 @@
1
1
  import { PoolClient } from 'pg'
2
2
 
3
+ import type { DbConfig } from '../../../../src/Database'
3
4
  import { PostgresDatabase } from '../../../../src/Database/integrations/pgsql/PostgresDatabase'
4
- import { PostgresTransactionImpl } from '../../../../src/Database/integrations/pgsql/PostgresTransaction'
5
- import type { DbConfig } from '../../../../src/Database/types'
6
5
 
7
6
  const config: DbConfig<'pg'> = {
8
7
  type: 'pg',
@@ -44,7 +43,7 @@ describe('PostgresDatabase', () => {
44
43
  const trans = await underTest.transaction()
45
44
 
46
45
  expect(mockTrans.query).toBeCalledWith('BEGIN')
47
- expect(trans).toBeInstanceOf(PostgresTransactionImpl)
46
+ expect(trans).toBeInstanceOf(Function)
48
47
  expect(trans['delegate']).toBe(mockTrans)
49
48
  })
50
49
  })
@@ -1,8 +1,8 @@
1
1
  import { PoolClient } from 'pg'
2
2
 
3
+ import type { DbConfig } from '../../../../src/Database'
3
4
  import { PostgresDatabase } from '../../../../src/Database/integrations/pgsql/PostgresDatabase'
4
5
  import { PostgresTransactionImpl } from '../../../../src/Database/integrations/pgsql/PostgresTransaction'
5
- import type { DbConfig } from '../../../../src/Database/types'
6
6
 
7
7
  const testResources = (config: Partial<DbConfig<'pg'>>) => {
8
8
  const database = {
@@ -30,7 +30,7 @@ describe('PostgresTransaction', () => {
30
30
  test('Can only commit once', async () => {
31
31
  const { delegate, underTest } = testResources({})
32
32
  await underTest.commit()
33
- expect(underTest.isOpen).toBe(false)
33
+ expect(underTest.isOpen()).toBe(false)
34
34
  expect(delegate.query).toBeCalledWith('COMMIT')
35
35
 
36
36
  await expect(underTest.commit).rejects.toThrowError(
@@ -41,7 +41,7 @@ describe('PostgresTransaction', () => {
41
41
  test('Can only rollback once', async () => {
42
42
  const { delegate, underTest } = testResources({})
43
43
  await underTest.rollback()
44
- expect(underTest.isOpen).toBe(false)
44
+ expect(underTest.isOpen()).toBe(false)
45
45
  expect(delegate.query).toBeCalledWith('ROLLBACK')
46
46
 
47
47
  await expect(underTest.rollback).rejects.toThrowError(