@creator.co/wapi 1.6.0 → 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/src/Logger/Logger.ts +2 -2
- package/tests/Logger/Logger.test.ts +6 -4
- package/tsconfig.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnexTransaction.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexTransaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KnexTransaction.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexTransaction.ts"],"names":[],"mappings":";;;;;;;;;AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAQ/D;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,mBAAmB;IAkB1D;;;;;OAKG;IACH,YAAoB,MAAY,EAAE,QAAsB;QACtD,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QAkBzB;;;WAGG;QACO,YAAO,GAAG,GAAS,EAAE;YAC7B,IAAI,CAAC,WAAW,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAA;YAClD,OAAO,IAAI,CAAC,WAAW,CAAA;QACzB,CAAC,CAAA,CAAA;QAED;;;WAGG;QACO,aAAQ,GAAG,GAAG,EAAE;YACxB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAA;QAClC,CAAC,CAAA;QAED;;;WAGG;QACO,eAAU,GAAG,GAAG,EAAE;YAC1B,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAA;QACpC,CAAC,CAAA;IAxCD,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAO,cAAc,CAChC,KAAW,EACX,QAAsB;;YAEtB,MAAM,EAAE,GAAG,IAAI,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;YACnD,MAAM,EAAE,CAAC,KAAK,EAAE,CAAA;YAChB,OAAO,mBAAmB,CAAC,aAAa,CAAC,EAAE,CAAQ,CAAA;QACrD,CAAC;KAAA;CA0BF"}
|
|
@@ -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,77 +7,44 @@ 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.KyselyDatabase = void 0;
|
|
55
|
-
var kysely_1 = require("kysely");
|
|
56
|
-
var pg_1 = require("pg");
|
|
57
|
-
var KyselyTransaction_1 = require("./KyselyTransaction");
|
|
58
|
-
var Database_1 = require("../../Database");
|
|
10
|
+
import { CamelCasePlugin, Kysely, PostgresDialect } from 'kysely';
|
|
11
|
+
import { Pool } from 'pg';
|
|
12
|
+
import { KyselyTransactionImpl } from './KyselyTransaction';
|
|
13
|
+
import { Database } from '../../Database';
|
|
59
14
|
/**
|
|
60
15
|
* Represents a database connection using the Kysely library with support for transactions.
|
|
61
16
|
* @template DBSchema - The schema type for the database.
|
|
62
17
|
*/
|
|
63
|
-
|
|
64
|
-
__extends(KyselyDatabase, _super);
|
|
18
|
+
export class KyselyDatabase extends Database {
|
|
65
19
|
/**
|
|
66
20
|
* Constructor for creating a database connection using the provided configuration.
|
|
67
21
|
* @param {DbConfig<'kysely'>} config - The configuration object for the database connection.
|
|
68
22
|
* @returns None
|
|
69
23
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
24
|
+
constructor(config) {
|
|
25
|
+
super(config);
|
|
26
|
+
this.pgClient = this.dialectFactory(config);
|
|
27
|
+
this.client = this.providerFactory(this.pgClient);
|
|
74
28
|
if (config.readReplica) {
|
|
75
|
-
|
|
76
|
-
|
|
29
|
+
this.pgReadClient = this.dialectFactory(config.readReplica);
|
|
30
|
+
this.readClient = this.providerFactory(this.pgReadClient);
|
|
77
31
|
}
|
|
78
|
-
return _this;
|
|
79
32
|
}
|
|
80
33
|
/**
|
|
81
34
|
* Override method that starts a new transaction using the provided client and read client.
|
|
82
35
|
* @returns A Promise that resolves to a KyselyTransaction object for the specified database schema.
|
|
83
36
|
*/
|
|
84
|
-
|
|
85
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
return
|
|
87
|
-
return [2 /*return*/, KyselyTransaction_1.KyselyTransactionImpl.newTransaction(this.client, this, this.readClient)];
|
|
88
|
-
});
|
|
37
|
+
transaction() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
return KyselyTransactionImpl.newTransaction(this.client, this, this.readClient);
|
|
89
40
|
});
|
|
90
|
-
}
|
|
41
|
+
}
|
|
91
42
|
/**
|
|
92
43
|
* Creates a database dialect based on the provided configuration.
|
|
93
44
|
* @param {DbBaseConfig} config - The configuration object for the database connection.
|
|
94
45
|
* @returns A database dialect instance based on the provided configuration.
|
|
95
46
|
*/
|
|
96
|
-
|
|
47
|
+
dialectFactory(config) {
|
|
97
48
|
return new KyselyDatabase.kyselyPgProvider({
|
|
98
49
|
pool: new KyselyDatabase.pgProvider({
|
|
99
50
|
host: config.host,
|
|
@@ -104,34 +55,32 @@ var KyselyDatabase = /** @class */ (function (_super) {
|
|
|
104
55
|
max: config.maxConnections,
|
|
105
56
|
}),
|
|
106
57
|
});
|
|
107
|
-
}
|
|
58
|
+
}
|
|
108
59
|
/**
|
|
109
60
|
* Creates a provider for interacting with a database using the specified Postgres dialect.
|
|
110
61
|
* @param {PostgresDialect} dialect - The Postgres dialect to use for the database connection.
|
|
111
62
|
* @returns A database provider for interacting with the database.
|
|
112
63
|
*/
|
|
113
|
-
|
|
64
|
+
providerFactory(dialect) {
|
|
114
65
|
return new KyselyDatabase.kyselyProvider({
|
|
115
|
-
dialect
|
|
116
|
-
plugins: [new
|
|
66
|
+
dialect,
|
|
67
|
+
plugins: [new CamelCasePlugin()],
|
|
117
68
|
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}(Database_1.Database));
|
|
136
|
-
exports.KyselyDatabase = KyselyDatabase;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Represents a PostgreSQL provider for querying data using the PostgresDialect.
|
|
73
|
+
* @type {PostgresDialect}
|
|
74
|
+
*/
|
|
75
|
+
KyselyDatabase.kyselyPgProvider = PostgresDialect;
|
|
76
|
+
/**
|
|
77
|
+
* A public static property that provides access to the Kysely class.
|
|
78
|
+
* This property can be accessed without creating an instance of the class.
|
|
79
|
+
*/
|
|
80
|
+
KyselyDatabase.kyselyProvider = Kysely;
|
|
81
|
+
/**
|
|
82
|
+
* A static property that represents a connection pool for PostgreSQL database connections.
|
|
83
|
+
* @type {Pool}
|
|
84
|
+
*/
|
|
85
|
+
KyselyDatabase.pgProvider = Pool;
|
|
137
86
|
//# sourceMappingURL=KyselyDatabase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KyselyDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/kysely/KyselyDatabase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KyselyDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/kysely/KyselyDatabase.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAEzB,OAAO,EAAqB,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAGzC;;;GAGG;AACH,MAAM,OAAO,cAAiC,SAAQ,QAAqC;IAmCzF;;;;OAIG;IACH,YAAmB,MAA0B;QAC3C,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAA;QAC3C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACjD,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;YACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;YAC3D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAC3D,CAAC;IACH,CAAC;IAED;;;OAGG;IACmB,WAAW;;YAC/B,OAAO,qBAAqB,CAAC,cAAc,CAAW,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;QAC3F,CAAC;KAAA;IACD;;;;OAIG;IACK,cAAc,CAAC,MAAoB;QACzC,OAAO,IAAI,cAAc,CAAC,gBAAgB,CAAC;YACzC,IAAI,EAAE,IAAI,cAAc,CAAC,UAAU,CAAC;gBAClC,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;gBACzB,GAAG,EAAE,MAAM,CAAC,cAAc;aAC3B,CAAC;SACH,CAAC,CAAA;IACJ,CAAC;IACD;;;;OAIG;IACK,eAAe,CAAC,OAAwB;QAC9C,OAAO,IAAI,cAAc,CAAC,cAAc,CAAW;YACjD,OAAO;YACP,OAAO,EAAE,CAAC,IAAI,eAAe,EAAE,CAAC;SACjC,CAAC,CAAA;IACJ,CAAC;;AAnFD;;;GAGG;AACY,+BAAgB,GAAG,eAAe,CAAA;AACjD;;;GAGG;AACY,6BAAc,GAAG,MAAM,CAAA;AACtC;;;GAGG;AACY,yBAAU,GAAG,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,41 +7,11 @@ 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.KyselyTransactionImpl = void 0;
|
|
55
|
-
var DatabaseTransaction_1 = require("../../DatabaseTransaction");
|
|
10
|
+
import { DatabaseTransaction } from '../../DatabaseTransaction';
|
|
56
11
|
/**
|
|
57
12
|
* Represents a transaction in a Postgres database.
|
|
58
13
|
*/
|
|
59
|
-
|
|
60
|
-
__extends(KyselyTransactionImpl, _super);
|
|
14
|
+
export class KyselyTransactionImpl extends DatabaseTransaction {
|
|
61
15
|
/**
|
|
62
16
|
* Constructs a new instance of the class.
|
|
63
17
|
* @param {Kysely<DBSchema>} delegate - The delegate object for the database query.
|
|
@@ -65,49 +19,43 @@ var KyselyTransactionImpl = /** @class */ (function (_super) {
|
|
|
65
19
|
* @param {Kysely<DBSchema>} [reader] - An optional reader object for the query.
|
|
66
20
|
* @returns None
|
|
67
21
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
22
|
+
constructor(delegate, database, reader) {
|
|
23
|
+
super(delegate, database, reader);
|
|
70
24
|
/**
|
|
71
25
|
* Asynchronously begins a transaction using a writer and resolves the transaction once it is executed.
|
|
72
26
|
* @returns A Promise that resolves with the transaction object once the transaction is executed.
|
|
73
27
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}); })
|
|
88
|
-
.catch(function () {
|
|
89
|
-
// Don't do anything here. Just swallow the exception.
|
|
90
|
-
});
|
|
91
|
-
})];
|
|
28
|
+
this.doBegin = () => __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
this.txWrapper = new Deferred();
|
|
30
|
+
return new Promise(resolve => {
|
|
31
|
+
this.writer
|
|
32
|
+
.transaction()
|
|
33
|
+
.execute((trx) => __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
this.transaction = trx;
|
|
35
|
+
resolve(trx); // resolve with tx
|
|
36
|
+
return this.txWrapper.promise; // wait for wrapper to be solved
|
|
37
|
+
}))
|
|
38
|
+
.catch(() => {
|
|
39
|
+
// Don't do anything here. Just swallow the exception.
|
|
40
|
+
});
|
|
92
41
|
});
|
|
93
|
-
});
|
|
42
|
+
});
|
|
94
43
|
/**
|
|
95
44
|
* Executes the commit operation by resolving the transaction wrapper and returning a resolved Promise.
|
|
96
45
|
* @returns A Promise that resolves to null.
|
|
97
46
|
*/
|
|
98
|
-
|
|
99
|
-
|
|
47
|
+
this.doCommit = () => {
|
|
48
|
+
this.txWrapper.resolve(null);
|
|
100
49
|
return Promise.resolve();
|
|
101
50
|
};
|
|
102
51
|
/**
|
|
103
52
|
* Performs a rollback operation by rejecting the transaction wrapper with an error.
|
|
104
53
|
* @returns A resolved Promise after the rollback operation is completed.
|
|
105
54
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
55
|
+
this.doRollback = () => {
|
|
56
|
+
this.txWrapper.reject(new Error('Rollback'));
|
|
108
57
|
return Promise.resolve();
|
|
109
58
|
};
|
|
110
|
-
return _this;
|
|
111
59
|
}
|
|
112
60
|
/**
|
|
113
61
|
* Creates a new database transaction for the given database schema.
|
|
@@ -116,71 +64,55 @@ var KyselyTransactionImpl = /** @class */ (function (_super) {
|
|
|
116
64
|
* @param {Kysely<DBSchema>} [reader] - An optional reader object for the transaction.
|
|
117
65
|
* @returns {Promise<KyselyTransaction<DBSchema>>} A promise that resolves to the created transaction.
|
|
118
66
|
*/
|
|
119
|
-
|
|
120
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
case 0:
|
|
125
|
-
tx = new KyselyTransactionImpl(connection, database, reader);
|
|
126
|
-
return [4 /*yield*/, tx.begin()];
|
|
127
|
-
case 1:
|
|
128
|
-
_a.sent();
|
|
129
|
-
return [2 /*return*/, DatabaseTransaction_1.DatabaseTransaction.proxyInstance(tx)];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
67
|
+
static newTransaction(connection, database, reader) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const tx = new KyselyTransactionImpl(connection, database, reader);
|
|
70
|
+
yield tx.begin();
|
|
71
|
+
return DatabaseTransaction.proxyInstance(tx);
|
|
132
72
|
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
}(DatabaseTransaction_1.DatabaseTransaction));
|
|
136
|
-
exports.KyselyTransactionImpl = KyselyTransactionImpl;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
137
75
|
/**
|
|
138
76
|
* Represents a deferred promise that can be resolved or rejected at a later time.
|
|
139
77
|
* @template T - The type of the value that the promise will resolve to.
|
|
140
78
|
*/
|
|
141
|
-
|
|
79
|
+
class Deferred {
|
|
142
80
|
/**
|
|
143
81
|
* Constructor for creating a new Promise instance with resolve and reject functions.
|
|
144
82
|
* @constructor
|
|
145
83
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
_this._resolve = resolve;
|
|
84
|
+
constructor() {
|
|
85
|
+
this._promise = new Promise((resolve, reject) => {
|
|
86
|
+
this._reject = reject;
|
|
87
|
+
this._resolve = resolve;
|
|
151
88
|
});
|
|
152
89
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
},
|
|
161
|
-
enumerable: false,
|
|
162
|
-
configurable: true
|
|
163
|
-
});
|
|
90
|
+
/**
|
|
91
|
+
* Getter method to retrieve the Promise object.
|
|
92
|
+
* @returns {Promise<T>} A Promise object of type T.
|
|
93
|
+
*/
|
|
94
|
+
get promise() {
|
|
95
|
+
return this._promise;
|
|
96
|
+
}
|
|
164
97
|
/**
|
|
165
98
|
* Resolves the Promise with the given value.
|
|
166
99
|
* @param {T | PromiseLike<T>} value - The value to resolve the Promise with.
|
|
167
100
|
* @returns void
|
|
168
101
|
*/
|
|
169
|
-
|
|
102
|
+
resolve(value) {
|
|
170
103
|
if (this._resolve) {
|
|
171
104
|
this._resolve(value);
|
|
172
105
|
}
|
|
173
|
-
}
|
|
106
|
+
}
|
|
174
107
|
/**
|
|
175
108
|
* Rejects the Promise with the given reason, if the reject function is available.
|
|
176
109
|
* @param {any} reason - The reason for rejecting the Promise.
|
|
177
110
|
* @returns void
|
|
178
111
|
*/
|
|
179
|
-
|
|
112
|
+
reject(reason) {
|
|
180
113
|
if (this._reject) {
|
|
181
114
|
this._reject(reason);
|
|
182
115
|
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
}());
|
|
116
|
+
}
|
|
117
|
+
}
|
|
186
118
|
//# sourceMappingURL=KyselyTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KyselyTransaction.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/kysely/KyselyTransaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KyselyTransaction.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/kysely/KyselyTransaction.ts"],"names":[],"mappings":";;;;;;;;;AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAQ/D;;GAEG;AACH,MAAM,OAAO,qBAAgC,SAAQ,mBAAmB;IAyBtE;;;;;;OAMG;IACH,YACE,QAA0B,EAC1B,QAAkC,EAClC,MAAyB;QAEzB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;QAoBnC;;;WAGG;QACO,YAAO,GAAG,GAAS,EAAE;YAC7B,IAAI,CAAC,SAAS,GAAG,IAAI,QAAQ,EAAO,CAAA;YACpC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;gBAC3B,IAAI,CAAC,MAAM;qBACR,WAAW,EAAE;qBACb,OAAO,CAAC,CAAM,GAAG,EAAC,EAAE;oBACnB,IAAI,CAAC,WAAW,GAAG,GAAG,CAAA;oBACtB,OAAO,CAAC,GAAG,CAAC,CAAA,CAAC,kBAAkB;oBAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAA,CAAC,gCAAgC;gBAChE,CAAC,CAAA,CAAC;qBACD,KAAK,CAAC,GAAG,EAAE;oBACV,sDAAsD;gBACxD,CAAC,CAAC,CAAA;YACN,CAAC,CAAC,CAAA;QACJ,CAAC,CAAA,CAAA;QAED;;;WAGG;QACO,aAAQ,GAAG,GAAG,EAAE;YACxB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;YAC5B,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;QAC1B,CAAC,CAAA;QAED;;;WAGG;QACO,eAAU,GAAG,GAAG,EAAE;YAC1B,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAA;YAC5C,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;QAC1B,CAAC,CAAA;IAvDD,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAO,cAAc,CAChC,UAA4B,EAC5B,QAAkC,EAClC,MAAyB;;YAEzB,MAAM,EAAE,GAAG,IAAI,qBAAqB,CAAW,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;YAC5E,MAAM,EAAE,CAAC,KAAK,EAAE,CAAA;YAChB,OAAO,mBAAmB,CAAC,aAAa,CAAC,EAAE,CAAQ,CAAA;QACrD,CAAC;KAAA;CAuCF;AAED;;;GAGG;AACH,MAAM,QAAQ;IAgBZ;;;OAGG;IACH;QACE,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACjD,IAAI,CAAC,OAAO,GAAG,MAAM,CAAA;YACrB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACzB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;;OAGG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAED;;;;OAIG;IACI,OAAO,CAAC,KAAyB;QACtC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAY;QACxB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -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,68 +7,35 @@ 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
|
-
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");
|
|
10
|
+
import { Pool } from 'pg';
|
|
11
|
+
import { PostgresTransactionImpl } from './PostgresTransaction';
|
|
12
|
+
import { Database } from '../../Database';
|
|
58
13
|
/**
|
|
59
14
|
* Represents a Postgres database connection that extends the Database class.
|
|
60
15
|
* @extends Database<PostgresTransaction>
|
|
61
16
|
*/
|
|
62
|
-
|
|
63
|
-
__extends(PostgresDatabase, _super);
|
|
17
|
+
export class PostgresDatabase extends Database {
|
|
64
18
|
/**
|
|
65
19
|
* Constructor for creating a new instance of a database connection using Postgres.
|
|
66
20
|
* @param {DbConfig<'pg'>} config - The configuration object for the Postgres database.
|
|
67
21
|
* @returns None
|
|
68
22
|
*/
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
23
|
+
constructor(config) {
|
|
24
|
+
super(config);
|
|
25
|
+
this.client = this.providerFactory(config);
|
|
72
26
|
if (config.readReplica)
|
|
73
|
-
|
|
74
|
-
return _this;
|
|
27
|
+
this.readClient = this.providerFactory(config.readReplica);
|
|
75
28
|
}
|
|
76
29
|
/**
|
|
77
30
|
* Creates a new Postgres transaction using the provided client and read client.
|
|
78
31
|
* @returns {Promise<PostgresTransaction>} A promise that resolves to a new PostgresTransaction object.
|
|
79
32
|
*/
|
|
80
|
-
|
|
81
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
82
|
-
return
|
|
83
|
-
return [2 /*return*/, PostgresTransaction_1.PostgresTransactionImpl.newTransaction(this.client, this, this.readClient)];
|
|
84
|
-
});
|
|
33
|
+
transaction() {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
return PostgresTransactionImpl.newTransaction(this.client, this, this.readClient);
|
|
85
36
|
});
|
|
86
|
-
}
|
|
87
|
-
|
|
37
|
+
}
|
|
38
|
+
providerFactory(config) {
|
|
88
39
|
return new PostgresDatabase.pgProvider({
|
|
89
40
|
host: config.host,
|
|
90
41
|
port: config.port,
|
|
@@ -93,13 +44,11 @@ var PostgresDatabase = /** @class */ (function (_super) {
|
|
|
93
44
|
database: config.database,
|
|
94
45
|
max: config.maxConnections,
|
|
95
46
|
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}(Database_1.Database));
|
|
104
|
-
exports.PostgresDatabase = PostgresDatabase;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A public static property that represents a connection pool for a PostgreSQL database.
|
|
51
|
+
* This property is used to manage and provide connections to the PostgreSQL database.
|
|
52
|
+
*/
|
|
53
|
+
PostgresDatabase.pgProvider = Pool;
|
|
105
54
|
//# sourceMappingURL=PostgresDatabase.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgresDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/pgsql/PostgresDatabase.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PostgresDatabase.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/pgsql/PostgresDatabase.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAA;AAEzB,OAAO,EAAuB,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAGzC;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,QAA6B;IAgBjE;;;;OAIG;IACH,YAAmB,MAAsB;QACvC,KAAK,CAAC,MAAM,CAAC,CAAA;QACb,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;QAC1C,IAAI,MAAM,CAAC,WAAW;YAAE,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;IACpF,CAAC;IAED;;;OAGG;IACmB,WAAW;;YAC/B,OAAO,uBAAuB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,CAAA;QACnF,CAAC;KAAA;IACO,eAAe,CAAC,MAAoB;QAC1C,OAAO,IAAI,gBAAgB,CAAC,UAAU,CAAC;YACrC,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;;AA1CD;;;GAGG;AACY,2BAAU,GAAG,IAAI,CAAA"}
|