@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.
- package/.github/workflows/npmpublish.yml +1 -1
- package/.github/workflows/prs.yml +1 -1
- package/dist/index.js +45 -31
- package/dist/index.js.map +1 -1
- package/dist/jest.config.js +2 -4
- package/dist/jest.config.js.map +1 -1
- package/dist/package.json +12 -12
- package/dist/src/API/Request.js +53 -59
- package/dist/src/API/Request.js.map +1 -1
- package/dist/src/API/Response.js +81 -156
- package/dist/src/API/Response.js.map +1 -1
- package/dist/src/BaseEvent/EventProcessor.js +54 -132
- package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
- package/dist/src/BaseEvent/Process.js +40 -98
- package/dist/src/BaseEvent/Process.js.map +1 -1
- package/dist/src/BaseEvent/Transaction.js +122 -310
- package/dist/src/BaseEvent/Transaction.js.map +1 -1
- package/dist/src/Cache/Redis.js +55 -119
- package/dist/src/Cache/Redis.js.map +1 -1
- package/dist/src/Cache/types.js +1 -2
- package/dist/src/Config/Configuration.js +46 -86
- package/dist/src/Config/Configuration.js.map +1 -1
- package/dist/src/Config/EnvironmentVar.js +57 -119
- package/dist/src/Config/EnvironmentVar.js.map +1 -1
- package/dist/src/Crypto/Crypto.js +35 -82
- package/dist/src/Crypto/Crypto.js.map +1 -1
- package/dist/src/Crypto/JWT.js +12 -27
- package/dist/src/Crypto/JWT.js.map +1 -1
- package/dist/src/Database/Database.js +3 -8
- package/dist/src/Database/Database.js.map +1 -1
- package/dist/src/Database/DatabaseManager.js +23 -28
- package/dist/src/Database/DatabaseManager.js.map +1 -1
- package/dist/src/Database/DatabaseTransaction.js +50 -166
- package/dist/src/Database/DatabaseTransaction.js.map +1 -1
- package/dist/src/Database/index.js +11 -15
- package/dist/src/Database/index.js.map +1 -1
- package/dist/src/Database/integrations/knex/KnexDatabase.js +22 -76
- package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -1
- package/dist/src/Database/integrations/knex/KnexTransaction.js +19 -85
- package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -1
- package/dist/src/Database/integrations/kysely/KyselyDatabase.js +37 -88
- package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +1 -1
- package/dist/src/Database/integrations/kysely/KyselyTransaction.js +46 -114
- package/dist/src/Database/integrations/kysely/KyselyTransaction.js.map +1 -1
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +20 -71
- package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -1
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +19 -85
- package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -1
- package/dist/src/Database/types.js +1 -2
- package/dist/src/Globals.js +93 -98
- package/dist/src/Globals.js.map +1 -1
- package/dist/src/Logger/Logger.js +88 -222
- package/dist/src/Logger/Logger.js.map +1 -1
- package/dist/src/Mailer/Mailer.js +83 -204
- package/dist/src/Mailer/Mailer.js.map +1 -1
- package/dist/src/Publisher/Publisher.js +43 -107
- package/dist/src/Publisher/Publisher.js.map +1 -1
- package/dist/src/Server/RouteResolver.js +22 -49
- package/dist/src/Server/RouteResolver.js.map +1 -1
- package/dist/src/Server/Router.js +12 -16
- package/dist/src/Server/Router.js.map +1 -1
- package/dist/src/Server/lib/ContainerServer.js +21 -83
- package/dist/src/Server/lib/ContainerServer.js.map +1 -1
- package/dist/src/Server/lib/Server.js +50 -99
- package/dist/src/Server/lib/Server.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandler.js +32 -107
- package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
- package/dist/src/Server/lib/container/GenericHandlerEvent.js +37 -81
- package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
- package/dist/src/Server/lib/container/HealthHandler.js +3 -35
- package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
- package/dist/src/Server/lib/container/Proxy.js +64 -127
- package/dist/src/Server/lib/container/Proxy.js.map +1 -1
- package/dist/src/Server/lib/container/Utils.js +12 -55
- package/dist/src/Server/lib/container/Utils.js.map +1 -1
- package/dist/src/Util/AsyncSingleton.js +40 -164
- package/dist/src/Util/AsyncSingleton.js.map +1 -1
- package/dist/src/Util/Utils.js +18 -24
- package/dist/src/Util/Utils.js.map +1 -1
- package/dist/src/Validation/Validator.js +10 -16
- package/dist/src/Validation/Validator.js.map +1 -1
- package/package.json +12 -12
- package/tests/Logger/Logger.test.ts +5 -3
- package/tsconfig.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseManager.js","sourceRoot":"","sources":["../../../src/Database/DatabaseManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DatabaseManager.js","sourceRoot":"","sources":["../../../src/Database/DatabaseManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;AAGxE;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,IAAI,EAAE,YAAY;IAClB,EAAE,EAAE,gBAAgB;IACpB,MAAM,EAAE,cAAc;CACvB,CAAA;AAED;;GAEG;AACH,MAAM,OAAO,eAAe;IAA5B;QAME;;;WAGG;QACK,cAAS,GAAqB,SAAS,CAAA;QAC/C;;;WAGG;QACK,cAAS,GAAgD,EAAE,CAAA;IA6BrE,CAAC;IA3BC;;;;OAIG;IACI,MAAM,CACX,MAAmB;QAEnB,MAAM,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,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAc,MAAa,CAAC,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
|
-
|
|
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
|
-
|
|
95
|
-
|
|
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
|
-
|
|
101
|
-
return
|
|
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
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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
|
-
|
|
218
|
-
|
|
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
|
|
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
|
|
117
|
+
apply(target, thisArg, argArray) {
|
|
232
118
|
if (target._isOpen) {
|
|
233
|
-
return target.transaction
|
|
119
|
+
return target.transaction(...argArray);
|
|
234
120
|
}
|
|
235
121
|
throw new Error('Transaction is closed!');
|
|
236
122
|
},
|
|
237
123
|
});
|
|
238
|
-
}
|
|
239
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"DatabaseTransaction.js","sourceRoot":"","sources":["../../../src/Database/DatabaseTransaction.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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":"
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
|
|
80
|
-
|
|
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
|
-
|
|
101
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
return
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"KnexDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexDatabase.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,IAAc,MAAM,MAAM,CAAA;AACjC,OAAO,KAAK,cAAc,MAAM,iBAAiB,CAAA;AAEjD,OAAO,EAAmB,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACxE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAGzC;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,QAAyB;IAazD;;;;OAIG;IACH,YAAmB,MAAwB;QACzC,KAAK,CAAC,MAAM,CAAC,CAAA;QAEb,IAAI,CAAC,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAA;IACvE,CAAC;IAED;;;;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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
69
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
|
|
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
|
-
|
|
92
|
-
return
|
|
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
|
-
|
|
99
|
-
return
|
|
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
|
-
|
|
110
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
125
|
-
}(DatabaseTransaction_1.DatabaseTransaction));
|
|
126
|
-
exports.KnexTransactionImpl = KnexTransactionImpl;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
127
61
|
//# sourceMappingURL=KnexTransaction.js.map
|