@creator.co/wapi 1.2.4 → 1.2.5
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/dist/jest.config.js +1 -1
- package/dist/jest.config.js.map +1 -1
- package/dist/package.json +8 -2
- package/dist/src/BaseEvent/Transaction.d.ts +10 -0
- package/dist/src/BaseEvent/Transaction.js +147 -37
- package/dist/src/BaseEvent/Transaction.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/Server/lib/container/Proxy.js +3 -2
- package/dist/src/Server/lib/container/Proxy.js.map +1 -1
- package/jest.config.ts +1 -1
- package/package.json +8 -2
- package/src/BaseEvent/Transaction.ts +48 -18
- 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/Server/lib/container/Proxy.ts +2 -1
- package/tests/BaseEvent/Transaction.test.ts +59 -0
- 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/tsconfig.json +5 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.DatabaseTransaction = void 0;
|
|
40
|
+
/**
|
|
41
|
+
* Abstract class representing a database transaction.
|
|
42
|
+
* @class DatabaseTransaction
|
|
43
|
+
*/
|
|
44
|
+
var DatabaseTransaction = /** @class */ (function () {
|
|
45
|
+
/**
|
|
46
|
+
* Constructs a new instance of the class.
|
|
47
|
+
* @param {any} delegate - The delegate object.
|
|
48
|
+
* @param {Database<any>} database - The database object.
|
|
49
|
+
* @protected
|
|
50
|
+
*/
|
|
51
|
+
function DatabaseTransaction(delegate, database) {
|
|
52
|
+
this._isOpen = true;
|
|
53
|
+
this.delegate = delegate;
|
|
54
|
+
this.database = database;
|
|
55
|
+
}
|
|
56
|
+
Object.defineProperty(DatabaseTransaction.prototype, "isOpen", {
|
|
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
|
+
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];
|
|
80
|
+
};
|
|
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 () {
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
if (!this._isOpen) {
|
|
104
|
+
throw new Error('Cannot commit, transaction is already closed!');
|
|
105
|
+
}
|
|
106
|
+
return [4 /*yield*/, this.doCommit()];
|
|
107
|
+
case 1:
|
|
108
|
+
_a.sent();
|
|
109
|
+
this._isOpen = false;
|
|
110
|
+
return [2 /*return*/];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
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
|
+
return __generator(this, function (_a) {
|
|
123
|
+
switch (_a.label) {
|
|
124
|
+
case 0:
|
|
125
|
+
if (!this._isOpen) {
|
|
126
|
+
throw new Error('Cannot rollback, transaction is already closed!');
|
|
127
|
+
}
|
|
128
|
+
return [4 /*yield*/, this.doRollback()];
|
|
129
|
+
case 1:
|
|
130
|
+
_a.sent();
|
|
131
|
+
this._isOpen = false;
|
|
132
|
+
return [2 /*return*/];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
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 () {
|
|
143
|
+
return __generator(this, function (_a) {
|
|
144
|
+
switch (_a.label) {
|
|
145
|
+
case 0:
|
|
146
|
+
if (!this._isOpen) return [3 /*break*/, 4];
|
|
147
|
+
if (!this.database.config.autoCommit) return [3 /*break*/, 2];
|
|
148
|
+
return [4 /*yield*/, this.doCommit()];
|
|
149
|
+
case 1:
|
|
150
|
+
_a.sent();
|
|
151
|
+
return [3 /*break*/, 4];
|
|
152
|
+
case 2: return [4 /*yield*/, this.doRollback()];
|
|
153
|
+
case 3:
|
|
154
|
+
_a.sent();
|
|
155
|
+
_a.label = 4;
|
|
156
|
+
case 4: return [2 /*return*/];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
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 () {
|
|
167
|
+
return __generator(this, function (_a) {
|
|
168
|
+
switch (_a.label) {
|
|
169
|
+
case 0:
|
|
170
|
+
if (!this._isOpen) return [3 /*break*/, 2];
|
|
171
|
+
return [4 /*yield*/, this.doRollback()];
|
|
172
|
+
case 1:
|
|
173
|
+
_a.sent();
|
|
174
|
+
_a.label = 2;
|
|
175
|
+
case 2: return [2 /*return*/];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
return DatabaseTransaction;
|
|
181
|
+
}());
|
|
182
|
+
exports.DatabaseTransaction = DatabaseTransaction;
|
|
183
|
+
//# sourceMappingURL=DatabaseTransaction.js.map
|
|
@@ -0,0 +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,CAAA;IAC1B,CAAC;IAbD,sBAAW,uCAAM;QAJjB;;;WAGG;aACH;YACE,OAAO,IAAI,CAAC,OAAO,CAAA;QACrB,CAAC;;;OAAA;IAaD;;;;;;;;;OASG;IACc,gCAAY,GAA7B,UAA6D,QAAW;QACtE,IAAM,IAAI,GAAG,UAAC,MAAW,EAAE,GAAoB;YAC7C,OAAA,OAAO,MAAM,CAAC,GAAG,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;QAA1E,CAA0E,CAAA;QAE5E,OAAO,IAAI,KAAK,CAAI,QAAQ,EAAE;YAC5B,GAAG,YAAC,MAAS,EAAE,CAAkB;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;SACF,CAAC,CAAA;IACJ,CAAC;IAED;;;;OAIG;IACU,oCAAM,GAAnB;;;;;wBACE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;4BACjB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;yBACjE;wBACD,qBAAM,IAAI,CAAC,QAAQ,EAAE,EAAA;;wBAArB,SAAqB,CAAA;wBACrB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;;;;;KACrB;IAED;;;;OAIG;IACU,sCAAQ,GAArB;;;;;wBACE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;4BACjB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;yBACnE;wBACD,qBAAM,IAAI,CAAC,UAAU,EAAE,EAAA;;wBAAvB,SAAuB,CAAA;wBACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;;;;;KACrB;IAED;;;OAGG;IACU,0CAAY,GAAzB;;;;;6BACM,IAAI,CAAC,OAAO,EAAZ,wBAAY;6BACV,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,EAA/B,wBAA+B;wBACjC,qBAAM,IAAI,CAAC,QAAQ,EAAE,EAAA;;wBAArB,SAAqB,CAAA;;4BAErB,qBAAM,IAAI,CAAC,UAAU,EAAE,EAAA;;wBAAvB,SAAuB,CAAA;;;;;;KAG5B;IAED;;;OAGG;IACU,0CAAY,GAAzB;;;;;6BACM,IAAI,CAAC,OAAO,EAAZ,wBAAY;wBACd,qBAAM,IAAI,CAAC,UAAU,EAAE,EAAA;;wBAAvB,SAAuB,CAAA;;;;;;KAE1B;IAaH,0BAAC;AAAD,CAAC,AA/GD,IA+GC;AA/GqB,kDAAmB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { KnexTransaction } from './KnexTransaction';
|
|
2
|
+
import { Database } from '../../Database';
|
|
3
|
+
import type { DbConfig } from '../../types';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a Knex database connection.
|
|
6
|
+
* @extends Database<KnexTransaction>
|
|
7
|
+
*/
|
|
8
|
+
export declare class KnexDatabase extends Database<KnexTransaction> {
|
|
9
|
+
private static knexProvider;
|
|
10
|
+
private client;
|
|
11
|
+
/**
|
|
12
|
+
* Constructs a new instance of the database class using the provided configuration.
|
|
13
|
+
* @param {DbConfig<'knex'>} config - The configuration object for the database.
|
|
14
|
+
* @returns None
|
|
15
|
+
*/
|
|
16
|
+
constructor(config: DbConfig<'knex'>);
|
|
17
|
+
/**
|
|
18
|
+
* Initiates a transaction using the underlying database client.
|
|
19
|
+
* @returns {Promise<KnexTransaction>} A promise that resolves to a KnexTransaction object representing the transaction.
|
|
20
|
+
*/
|
|
21
|
+
transaction(): Promise<KnexTransaction>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
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 KnexTransaction_1 = require("./KnexTransaction");
|
|
57
|
+
var Database_1 = require("../../Database");
|
|
58
|
+
/**
|
|
59
|
+
* Represents a Knex database connection.
|
|
60
|
+
* @extends Database<KnexTransaction>
|
|
61
|
+
*/
|
|
62
|
+
var KnexDatabase = /** @class */ (function (_super) {
|
|
63
|
+
__extends(KnexDatabase, _super);
|
|
64
|
+
/**
|
|
65
|
+
* Constructs a new instance of the database class using the provided configuration.
|
|
66
|
+
* @param {DbConfig<'knex'>} config - The configuration object for the database.
|
|
67
|
+
* @returns None
|
|
68
|
+
*/
|
|
69
|
+
function KnexDatabase(config) {
|
|
70
|
+
var _this = _super.call(this, config) || this;
|
|
71
|
+
_this.client = KnexDatabase.knexProvider({
|
|
72
|
+
client: config.driver,
|
|
73
|
+
connection: {
|
|
74
|
+
host: config.host,
|
|
75
|
+
port: config.port,
|
|
76
|
+
user: config.username,
|
|
77
|
+
password: config.password,
|
|
78
|
+
database: config.database,
|
|
79
|
+
},
|
|
80
|
+
pool: {
|
|
81
|
+
min: 1,
|
|
82
|
+
max: config.maxConnections,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
return _this;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Initiates a transaction using the underlying database client.
|
|
89
|
+
* @returns {Promise<KnexTransaction>} A promise that resolves to a KnexTransaction object representing the transaction.
|
|
90
|
+
*/
|
|
91
|
+
KnexDatabase.prototype.transaction = function () {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
var delegate;
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
switch (_a.label) {
|
|
96
|
+
case 0: return [4 /*yield*/, this.client.transaction()];
|
|
97
|
+
case 1:
|
|
98
|
+
delegate = _a.sent();
|
|
99
|
+
return [2 /*return*/, KnexTransaction_1.KnexTransactionImpl.wrapDelegate(delegate, this)];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
KnexDatabase.knexProvider = knex_1.default;
|
|
105
|
+
return KnexDatabase;
|
|
106
|
+
}(Database_1.Database));
|
|
107
|
+
exports.KnexDatabase = KnexDatabase;
|
|
108
|
+
//# sourceMappingURL=KnexDatabase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KnexDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexDatabase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAAiC;AAEjC,qDAAwE;AACxE,2CAAyC;AAGzC;;;GAGG;AACH;IAAkC,gCAAyB;IAKzD;;;;OAIG;IACH,sBAAmB,MAAwB;QAA3C,YACE,kBAAM,MAAM,CAAC,SAed;QAdC,KAAI,CAAC,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC;YACtC,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,CAAC,CAAA;;IACJ,CAAC;IAED;;;OAGG;IACmB,kCAAW,GAAjC;;;;;4BACmB,qBAAM,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,EAAA;;wBAA1C,QAAQ,GAAG,SAA+B;wBAChD,sBAAO,qCAAmB,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAA;;;;KACxD;IAlCc,yBAAY,GAAiE,cAAI,CAAA;IAmClG,mBAAC;CAAA,AApCD,CAAkC,mBAAQ,GAoCzC;AApCY,oCAAY"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Knex } from 'knex';
|
|
2
|
+
import { KnexDatabase } from './KnexDatabase';
|
|
3
|
+
import { DatabaseTransaction } from '../../DatabaseTransaction';
|
|
4
|
+
/**
|
|
5
|
+
* A type alias for a Knex transaction object.
|
|
6
|
+
* @typedef {KnexTransactionImpl & Knex.Transaction} KnexTransaction
|
|
7
|
+
*/
|
|
8
|
+
export type KnexTransaction = KnexTransactionImpl & Knex.Transaction;
|
|
9
|
+
/**
|
|
10
|
+
* Implementation of a Knex transaction that extends the DatabaseTransaction class.
|
|
11
|
+
*/
|
|
12
|
+
export declare class KnexTransactionImpl extends DatabaseTransaction {
|
|
13
|
+
/**
|
|
14
|
+
* Constructs a new instance of the private class.
|
|
15
|
+
* @param {Knex.Transaction} delegate - The delegate transaction object.
|
|
16
|
+
* @param {KnexDatabase} database - The database object.
|
|
17
|
+
* @returns None
|
|
18
|
+
*/
|
|
19
|
+
private constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Wraps a delegate transaction object with a custom implementation of the KnexTransaction interface.
|
|
22
|
+
* @param {Knex.Transaction} delegate - The delegate transaction object to wrap.
|
|
23
|
+
* @param {KnexDatabase} database - The KnexDatabase instance associated with the transaction.
|
|
24
|
+
* @returns {KnexTransaction} - The wrapped transaction object.
|
|
25
|
+
*/
|
|
26
|
+
static wrapDelegate(delegate: Knex.Transaction, database: KnexDatabase): KnexTransaction;
|
|
27
|
+
/**
|
|
28
|
+
* Commits the changes made by the delegate object.
|
|
29
|
+
* @returns None
|
|
30
|
+
*/
|
|
31
|
+
protected doCommit(): any;
|
|
32
|
+
/**
|
|
33
|
+
* Performs a rollback operation by calling the rollback method of the delegate object.
|
|
34
|
+
* @returns None
|
|
35
|
+
*/
|
|
36
|
+
protected doRollback(): any;
|
|
37
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.KnexTransactionImpl = void 0;
|
|
19
|
+
var DatabaseTransaction_1 = require("../../DatabaseTransaction");
|
|
20
|
+
/**
|
|
21
|
+
* Implementation of a Knex transaction that extends the DatabaseTransaction class.
|
|
22
|
+
*/
|
|
23
|
+
var KnexTransactionImpl = /** @class */ (function (_super) {
|
|
24
|
+
__extends(KnexTransactionImpl, _super);
|
|
25
|
+
/**
|
|
26
|
+
* Constructs a new instance of the private class.
|
|
27
|
+
* @param {Knex.Transaction} delegate - The delegate transaction object.
|
|
28
|
+
* @param {KnexDatabase} database - The database object.
|
|
29
|
+
* @returns None
|
|
30
|
+
*/
|
|
31
|
+
function KnexTransactionImpl(delegate, database) {
|
|
32
|
+
return _super.call(this, delegate, database) || this;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Wraps a delegate transaction object with a custom implementation of the KnexTransaction interface.
|
|
36
|
+
* @param {Knex.Transaction} delegate - The delegate transaction object to wrap.
|
|
37
|
+
* @param {KnexDatabase} database - The KnexDatabase instance associated with the transaction.
|
|
38
|
+
* @returns {KnexTransaction} - The wrapped transaction object.
|
|
39
|
+
*/
|
|
40
|
+
KnexTransactionImpl.wrapDelegate = function (delegate, database) {
|
|
41
|
+
return DatabaseTransaction_1.DatabaseTransaction.wrapInstance(new KnexTransactionImpl(delegate, database));
|
|
42
|
+
};
|
|
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
|
+
return KnexTransactionImpl;
|
|
58
|
+
}(DatabaseTransaction_1.DatabaseTransaction));
|
|
59
|
+
exports.KnexTransactionImpl = KnexTransactionImpl;
|
|
60
|
+
//# sourceMappingURL=KnexTransaction.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PostgresTransaction } from './PostgresTransaction';
|
|
2
|
+
import { Database } from '../../Database';
|
|
3
|
+
import type { DbConfig } from '../../types';
|
|
4
|
+
/**
|
|
5
|
+
* Represents a Postgres database connection.
|
|
6
|
+
* @extends Database<PostgresTransaction>
|
|
7
|
+
*/
|
|
8
|
+
export declare class PostgresDatabase extends Database<PostgresTransaction> {
|
|
9
|
+
/**
|
|
10
|
+
* A private static property that represents a connection pool for a PostgreSQL database.
|
|
11
|
+
*/
|
|
12
|
+
private static pgProvider;
|
|
13
|
+
/**
|
|
14
|
+
* The client property represents a connection pool to a database.
|
|
15
|
+
* @private
|
|
16
|
+
* @type {Pool}
|
|
17
|
+
*/
|
|
18
|
+
private client;
|
|
19
|
+
/**
|
|
20
|
+
* Constructs a new instance of the class with the given database configuration.
|
|
21
|
+
* @param {DbConfig<'pg'>} config - The configuration object for the PostgreSQL database.
|
|
22
|
+
* @returns None
|
|
23
|
+
*/
|
|
24
|
+
constructor(config: DbConfig<'pg'>);
|
|
25
|
+
/**
|
|
26
|
+
* Initiates a new transaction in the PostgreSQL database.
|
|
27
|
+
* @returns {Promise<PostgresTransaction>} A promise that resolves to a PostgresTransaction object representing the new transaction.
|
|
28
|
+
*/
|
|
29
|
+
transaction(): Promise<PostgresTransaction>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
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.PostgresDatabase = void 0;
|
|
55
|
+
var pg_1 = require("pg");
|
|
56
|
+
var PostgresTransaction_1 = require("./PostgresTransaction");
|
|
57
|
+
var Database_1 = require("../../Database");
|
|
58
|
+
/**
|
|
59
|
+
* Represents a Postgres database connection.
|
|
60
|
+
* @extends Database<PostgresTransaction>
|
|
61
|
+
*/
|
|
62
|
+
var PostgresDatabase = /** @class */ (function (_super) {
|
|
63
|
+
__extends(PostgresDatabase, _super);
|
|
64
|
+
/**
|
|
65
|
+
* Constructs a new instance of the class with the given database configuration.
|
|
66
|
+
* @param {DbConfig<'pg'>} config - The configuration object for the PostgreSQL database.
|
|
67
|
+
* @returns None
|
|
68
|
+
*/
|
|
69
|
+
function PostgresDatabase(config) {
|
|
70
|
+
var _this = _super.call(this, config) || this;
|
|
71
|
+
_this.client = new PostgresDatabase.pgProvider({
|
|
72
|
+
host: config.host,
|
|
73
|
+
port: config.port,
|
|
74
|
+
user: config.username,
|
|
75
|
+
password: config.password,
|
|
76
|
+
database: config.database,
|
|
77
|
+
max: config.maxConnections,
|
|
78
|
+
});
|
|
79
|
+
return _this;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Initiates a new transaction in the PostgreSQL database.
|
|
83
|
+
* @returns {Promise<PostgresTransaction>} A promise that resolves to a PostgresTransaction object representing the new transaction.
|
|
84
|
+
*/
|
|
85
|
+
PostgresDatabase.prototype.transaction = function () {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var delegate;
|
|
88
|
+
return __generator(this, function (_a) {
|
|
89
|
+
switch (_a.label) {
|
|
90
|
+
case 0: return [4 /*yield*/, this.client.connect()];
|
|
91
|
+
case 1:
|
|
92
|
+
delegate = _a.sent();
|
|
93
|
+
return [4 /*yield*/, delegate.query('BEGIN')];
|
|
94
|
+
case 2:
|
|
95
|
+
_a.sent();
|
|
96
|
+
return [2 /*return*/, PostgresTransaction_1.PostgresTransactionImpl.wrapDelegate(delegate, this)];
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* A private static property that represents a connection pool for a PostgreSQL database.
|
|
103
|
+
*/
|
|
104
|
+
PostgresDatabase.pgProvider = pg_1.Pool;
|
|
105
|
+
return PostgresDatabase;
|
|
106
|
+
}(Database_1.Database));
|
|
107
|
+
exports.PostgresDatabase = PostgresDatabase;
|
|
108
|
+
//# sourceMappingURL=PostgresDatabase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostgresDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/pgsql/PostgresDatabase.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAyB;AAEzB,6DAAoF;AACpF,2CAAyC;AAGzC;;;GAGG;AACH;IAAsC,oCAA6B;IAYjE;;;;OAIG;IACH,0BAAmB,MAAsB;QAAzC,YACE,kBAAM,MAAM,CAAC,SASd;QARC,KAAI,CAAC,MAAM,GAAG,IAAI,gBAAgB,CAAC,UAAU,CAAC;YAC5C,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,QAAQ;YACrB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,GAAG,EAAE,MAAM,CAAC,cAAc;SAC3B,CAAC,CAAA;;IACJ,CAAC;IAED;;;OAGG;IACmB,sCAAW,GAAjC;;;;;4BACmB,qBAAM,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,EAAA;;wBAAtC,QAAQ,GAAG,SAA2B;wBAC5C,qBAAM,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,EAAA;;wBAA7B,SAA6B,CAAA;wBAC7B,sBAAO,6CAAuB,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAA;;;;KAC5D;IApCD;;OAEG;IACY,2BAAU,GAAG,SAAI,CAAA;IAkClC,uBAAC;CAAA,AAtCD,CAAsC,mBAAQ,GAsC7C;AAtCY,4CAAgB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PoolClient } from 'pg';
|
|
2
|
+
import { PostgresDatabase } from './PostgresDatabase';
|
|
3
|
+
import { DatabaseTransaction } from '../../DatabaseTransaction';
|
|
4
|
+
/**
|
|
5
|
+
* A type alias representing a Postgres transaction. It extends the `PostgresTransactionImpl`
|
|
6
|
+
* interface and includes the `PoolClient` interface.
|
|
7
|
+
*/
|
|
8
|
+
export type PostgresTransaction = PostgresTransactionImpl & PoolClient;
|
|
9
|
+
/**
|
|
10
|
+
* Represents a transaction in a Postgres database.
|
|
11
|
+
*/
|
|
12
|
+
export declare class PostgresTransactionImpl extends DatabaseTransaction {
|
|
13
|
+
/**
|
|
14
|
+
* Constructs a new instance of the private class.
|
|
15
|
+
* @param {PoolClient} delegate - The delegate object.
|
|
16
|
+
* @param {PostgresDatabase} database - The database object.
|
|
17
|
+
* @returns None
|
|
18
|
+
*/
|
|
19
|
+
private constructor();
|
|
20
|
+
/**
|
|
21
|
+
* Static factory method for creating a new instance, wrapping a delegate PoolClient.
|
|
22
|
+
* @param {PoolClient} delegate - The delegate client to wrap.
|
|
23
|
+
* @param {PostgresDatabase} database - The PostgresDatabase instance associated with the transaction.
|
|
24
|
+
* @returns {PostgresTransaction} - A wrapped PostgresTransaction instance.
|
|
25
|
+
*/
|
|
26
|
+
static wrapDelegate(delegate: PoolClient, database: PostgresDatabase): PostgresTransaction;
|
|
27
|
+
/**
|
|
28
|
+
* Commits the current transaction.
|
|
29
|
+
* @returns A promise that resolves when the commit is successful.
|
|
30
|
+
*/
|
|
31
|
+
protected doCommit(): any;
|
|
32
|
+
/**
|
|
33
|
+
* Performs a rollback operation in the database.
|
|
34
|
+
* @returns A promise that resolves when the rollback operation is completed.
|
|
35
|
+
*/
|
|
36
|
+
protected doRollback(): any;
|
|
37
|
+
}
|