@creator.co/wapi 1.6.1 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/.github/workflows/npmpublish.yml +1 -1
  2. package/.github/workflows/prs.yml +1 -1
  3. package/dist/index.js +45 -31
  4. package/dist/index.js.map +1 -1
  5. package/dist/jest.config.js +2 -4
  6. package/dist/jest.config.js.map +1 -1
  7. package/dist/package.json +12 -12
  8. package/dist/src/API/Request.js +53 -59
  9. package/dist/src/API/Request.js.map +1 -1
  10. package/dist/src/API/Response.js +81 -156
  11. package/dist/src/API/Response.js.map +1 -1
  12. package/dist/src/BaseEvent/EventProcessor.js +54 -132
  13. package/dist/src/BaseEvent/EventProcessor.js.map +1 -1
  14. package/dist/src/BaseEvent/Process.js +40 -98
  15. package/dist/src/BaseEvent/Process.js.map +1 -1
  16. package/dist/src/BaseEvent/Transaction.js +122 -310
  17. package/dist/src/BaseEvent/Transaction.js.map +1 -1
  18. package/dist/src/Cache/Redis.js +55 -119
  19. package/dist/src/Cache/Redis.js.map +1 -1
  20. package/dist/src/Cache/types.js +1 -2
  21. package/dist/src/Config/Configuration.js +46 -86
  22. package/dist/src/Config/Configuration.js.map +1 -1
  23. package/dist/src/Config/EnvironmentVar.js +57 -119
  24. package/dist/src/Config/EnvironmentVar.js.map +1 -1
  25. package/dist/src/Crypto/Crypto.js +35 -82
  26. package/dist/src/Crypto/Crypto.js.map +1 -1
  27. package/dist/src/Crypto/JWT.js +12 -27
  28. package/dist/src/Crypto/JWT.js.map +1 -1
  29. package/dist/src/Database/Database.js +3 -8
  30. package/dist/src/Database/Database.js.map +1 -1
  31. package/dist/src/Database/DatabaseManager.js +23 -28
  32. package/dist/src/Database/DatabaseManager.js.map +1 -1
  33. package/dist/src/Database/DatabaseTransaction.js +50 -166
  34. package/dist/src/Database/DatabaseTransaction.js.map +1 -1
  35. package/dist/src/Database/index.js +11 -15
  36. package/dist/src/Database/index.js.map +1 -1
  37. package/dist/src/Database/integrations/knex/KnexDatabase.js +22 -76
  38. package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -1
  39. package/dist/src/Database/integrations/knex/KnexTransaction.js +19 -85
  40. package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -1
  41. package/dist/src/Database/integrations/kysely/KyselyDatabase.js +37 -88
  42. package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +1 -1
  43. package/dist/src/Database/integrations/kysely/KyselyTransaction.js +46 -114
  44. package/dist/src/Database/integrations/kysely/KyselyTransaction.js.map +1 -1
  45. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +20 -71
  46. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -1
  47. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +19 -85
  48. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -1
  49. package/dist/src/Database/types.js +1 -2
  50. package/dist/src/Globals.js +93 -98
  51. package/dist/src/Globals.js.map +1 -1
  52. package/dist/src/Logger/Logger.js +88 -222
  53. package/dist/src/Logger/Logger.js.map +1 -1
  54. package/dist/src/Mailer/Mailer.js +83 -204
  55. package/dist/src/Mailer/Mailer.js.map +1 -1
  56. package/dist/src/Publisher/Publisher.js +43 -107
  57. package/dist/src/Publisher/Publisher.js.map +1 -1
  58. package/dist/src/Server/RouteResolver.js +22 -49
  59. package/dist/src/Server/RouteResolver.js.map +1 -1
  60. package/dist/src/Server/Router.js +12 -16
  61. package/dist/src/Server/Router.js.map +1 -1
  62. package/dist/src/Server/lib/ContainerServer.js +21 -83
  63. package/dist/src/Server/lib/ContainerServer.js.map +1 -1
  64. package/dist/src/Server/lib/Server.js +50 -99
  65. package/dist/src/Server/lib/Server.js.map +1 -1
  66. package/dist/src/Server/lib/container/GenericHandler.js +32 -107
  67. package/dist/src/Server/lib/container/GenericHandler.js.map +1 -1
  68. package/dist/src/Server/lib/container/GenericHandlerEvent.js +37 -81
  69. package/dist/src/Server/lib/container/GenericHandlerEvent.js.map +1 -1
  70. package/dist/src/Server/lib/container/HealthHandler.js +3 -35
  71. package/dist/src/Server/lib/container/HealthHandler.js.map +1 -1
  72. package/dist/src/Server/lib/container/Proxy.js +64 -127
  73. package/dist/src/Server/lib/container/Proxy.js.map +1 -1
  74. package/dist/src/Server/lib/container/Utils.js +12 -55
  75. package/dist/src/Server/lib/container/Utils.js.map +1 -1
  76. package/dist/src/Util/AsyncSingleton.js +40 -164
  77. package/dist/src/Util/AsyncSingleton.js.map +1 -1
  78. package/dist/src/Util/Utils.js +18 -24
  79. package/dist/src/Util/Utils.js.map +1 -1
  80. package/dist/src/Validation/Validator.js +10 -16
  81. package/dist/src/Validation/Validator.js.map +1 -1
  82. package/package.json +12 -12
  83. package/tests/Logger/Logger.test.ts +5 -3
  84. package/tsconfig.json +3 -1
@@ -1 +1 @@
1
- {"version":3,"file":"KnexTransaction.js","sourceRoot":"","sources":["../../../../../src/Database/integrations/knex/KnexTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,iEAA+D;AAQ/D;;;GAGG;AACH;IAAyC,uCAAmB;IAkB1D;;;;;OAKG;IACH,6BAAoB,MAAY,EAAE,QAAsB;QACtD,YAAA,MAAK,YAAC,MAAM,EAAE,QAAQ,CAAC,SAAA;QAkBzB;;;WAGG;QACO,aAAO,GAAG;;;;;wBAClB,KAAA,IAAI,CAAA;wBAAe,qBAAM,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,EAAA;;wBAAlD,GAAK,WAAW,GAAG,SAA+B,CAAA;wBAClD,sBAAO,IAAI,CAAC,WAAW,EAAA;;;aACxB,CAAA;QAED;;;WAGG;QACO,cAAQ,GAAG;YACnB,OAAO,KAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAA;QAClC,CAAC,CAAA;QAED;;;WAGG;QACO,gBAAU,GAAG;YACrB,OAAO,KAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAA;QACpC,CAAC,CAAA;;IAxCD,CAAC;IAED;;;;;OAKG;IACiB,kCAAc,GAAlC,UACE,KAAW,EACX,QAAsB;;;;;;wBAEhB,EAAE,GAAG,IAAI,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;wBACnD,qBAAM,EAAE,CAAC,KAAK,EAAE,EAAA;;wBAAhB,SAAgB,CAAA;wBAChB,sBAAO,yCAAmB,CAAC,aAAa,CAAC,EAAE,CAAQ,EAAA;;;;KACpD;IA0BH,0BAAC;AAAD,CAAC,AAnED,CAAyC,yCAAmB,GAmE3D;AAnEY,kDAAmB"}
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
- 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.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
- var KyselyDatabase = /** @class */ (function (_super) {
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
- function KyselyDatabase(config) {
71
- var _this = _super.call(this, config) || this;
72
- _this.pgClient = _this.dialectFactory(config);
73
- _this.client = _this.providerFactory(_this.pgClient);
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
- _this.pgReadClient = _this.dialectFactory(config.readReplica);
76
- _this.readClient = _this.providerFactory(_this.pgReadClient);
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
- KyselyDatabase.prototype.transaction = function () {
85
- return __awaiter(this, void 0, void 0, function () {
86
- return __generator(this, function (_a) {
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
- KyselyDatabase.prototype.dialectFactory = function (config) {
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
- KyselyDatabase.prototype.providerFactory = function (dialect) {
64
+ providerFactory(dialect) {
114
65
  return new KyselyDatabase.kyselyProvider({
115
- dialect: dialect,
116
- plugins: [new kysely_1.CamelCasePlugin()],
66
+ dialect,
67
+ plugins: [new CamelCasePlugin()],
117
68
  });
118
- };
119
- /**
120
- * Represents a PostgreSQL provider for querying data using the PostgresDialect.
121
- * @type {PostgresDialect}
122
- */
123
- KyselyDatabase.kyselyPgProvider = kysely_1.PostgresDialect;
124
- /**
125
- * A public static property that provides access to the Kysely class.
126
- * This property can be accessed without creating an instance of the class.
127
- */
128
- KyselyDatabase.kyselyProvider = kysely_1.Kysely;
129
- /**
130
- * A static property that represents a connection pool for PostgreSQL database connections.
131
- * @type {Pool}
132
- */
133
- KyselyDatabase.pgProvider = pg_1.Pool;
134
- return KyselyDatabase;
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAiE;AACjE,yBAAyB;AAEzB,yDAA8E;AAC9E,2CAAyC;AAGzC;;;GAGG;AACH;IAAsD,kCAAqC;IAmCzF;;;;OAIG;IACH,wBAAmB,MAA0B;QAC3C,YAAA,MAAK,YAAC,MAAM,CAAC,SAAA;QACb,KAAI,CAAC,Q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AAU,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
- 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.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
- var KyselyTransactionImpl = /** @class */ (function (_super) {
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
- function KyselyTransactionImpl(delegate, database, reader) {
69
- var _this = _super.call(this, delegate, database, reader) || this;
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
- _this.doBegin = function () { return __awaiter(_this, void 0, void 0, function () {
75
- var _this = this;
76
- return __generator(this, function (_a) {
77
- this.txWrapper = new Deferred();
78
- return [2 /*return*/, new Promise(function (resolve) {
79
- _this.writer
80
- .transaction()
81
- .execute(function (trx) { return __awaiter(_this, void 0, void 0, function () {
82
- return __generator(this, function (_a) {
83
- this.transaction = trx;
84
- resolve(trx); // resolve with tx
85
- return [2 /*return*/, this.txWrapper.promise]; // wait for wrapper to be solved
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
- _this.doCommit = function () {
99
- _this.txWrapper.resolve(null);
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
- _this.doRollback = function () {
107
- _this.txWrapper.reject(new Error('Rollback'));
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
- KyselyTransactionImpl.newTransaction = function (connection, database, reader) {
120
- return __awaiter(this, void 0, void 0, function () {
121
- var tx;
122
- return __generator(this, function (_a) {
123
- switch (_a.label) {
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
- return KyselyTransactionImpl;
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
- var Deferred = /** @class */ (function () {
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
- function Deferred() {
147
- var _this = this;
148
- this._promise = new Promise(function (resolve, reject) {
149
- _this._reject = reject;
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
- Object.defineProperty(Deferred.prototype, "promise", {
154
- /**
155
- * Getter method to retrieve the Promise object.
156
- * @returns {Promise<T>} A Promise object of type T.
157
- */
158
- get: function () {
159
- return this._promise;
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
- Deferred.prototype.resolve = function (value) {
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
- Deferred.prototype.reject = function (reason) {
112
+ reject(reason) {
180
113
  if (this._reject) {
181
114
  this._reject(reason);
182
115
  }
183
- };
184
- return Deferred;
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,iEAA+D;AAQ/D;;GAEG;AACH;IAAqD,yCAAmB;IAyBtE;;;;;;OAMG;IACH,+BACE,QAA0B,E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AuCH,4BAAC;AAAD,CAAC,AA9FD,CAAqD,yCAAmB,GA8FvE;AA9FY,sDAAqB;AAgGlC;;;GAGG;AACH;IAgBE;;;OAGG;IACH;QAAA,iBAKC;QAJC,IAAI,CAAC,QAAQ,GAAG,IAAI,OAAO,CAAI,UAAC,OAAO,EAAE,MAAM;YAC7C,KAAI,CAAC,OAAO,GAAG,MAAM,CAAA;YACrB,KAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACzB,CAAC,CAAC,CAAA;IACJ,CAAC;IAMD,sBAAW,6BAAO;QAJlB;;;WAGG;aACH;YACE,OAAO,IAAI,CAAC,QAAQ,CAAA;QACtB,CAAC;;;OAAA;IAED;;;;OAIG;IACI,0BAAO,GAAd,UAAe,KAAyB;QACtC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,yBAAM,GAAb,UAAc,MAAY;QACxB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACtB,CAAC;IACH,CAAC;IACH,eAAC;AAAD,CAAC,AAxDD,IAwDC"}
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,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E;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
- 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");
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
- var PostgresDatabase = /** @class */ (function (_super) {
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
- function PostgresDatabase(config) {
70
- var _this = _super.call(this, config) || this;
71
- _this.client = _this.providerFactory(config);
23
+ constructor(config) {
24
+ super(config);
25
+ this.client = this.providerFactory(config);
72
26
  if (config.readReplica)
73
- _this.readClient = _this.providerFactory(config.readReplica);
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
- PostgresDatabase.prototype.transaction = function () {
81
- return __awaiter(this, void 0, void 0, function () {
82
- return __generator(this, function (_a) {
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
- PostgresDatabase.prototype.providerFactory = function (config) {
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
- * A public static property that represents a connection pool for a PostgreSQL database.
99
- * This property is used to manage and provide connections to the PostgreSQL database.
100
- */
101
- PostgresDatabase.pgProvider = pg_1.Pool;
102
- return PostgresDatabase;
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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yBAAyB;AAEzB,6DAAoF;AACpF,2CAAyC;AAGzC;;;GAGG;AACH;IAAsC,oCAA6B;IAgBjE;;;;OAIG;IACH,0BAAmB,MAAsB;QACvC,YAAA,MAAK,YAAC,MAAM,CAAC,SAAA;QACb,KAAI,CAAC,MAAM,GAAG,KAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAA;QAC1C,IAAI,MAAM,CAAC,WAAW;YAAE,KAAI,CAAC,UAAU,GAAG,KAAI,CAAC,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;;IACpF,CAAC;IAED;;;OAGG;IACmB,sCAAW,GAAjC;;;gBACE,sBAAO,6CAAuB,CAAC,cAAc,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,EAAA;;;KAClF;IACO,0CAAe,GAAvB,UAAwB,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;IA1CD;;;OAGG;IACY,2BAAU,GAAG,SAAI,CAAA;IAuClC,uBAAC;CAAA,AA5CD,CAAsC,mBAAQ,G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