@creator.co/wapi 1.3.19 → 1.4.0-alpha2

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 (57) hide show
  1. package/dist/package.json +2 -1
  2. package/dist/src/BaseEvent/Transaction.d.ts +1 -1
  3. package/dist/src/Database/Database.d.ts +8 -5
  4. package/dist/src/Database/Database.js +5 -3
  5. package/dist/src/Database/Database.js.map +1 -1
  6. package/dist/src/Database/DatabaseManager.d.ts +30 -9
  7. package/dist/src/Database/DatabaseManager.js +24 -8
  8. package/dist/src/Database/DatabaseManager.js.map +1 -1
  9. package/dist/src/Database/DatabaseTransaction.d.ts +66 -31
  10. package/dist/src/Database/DatabaseTransaction.js +51 -30
  11. package/dist/src/Database/DatabaseTransaction.js.map +1 -1
  12. package/dist/src/Database/index.d.ts +2 -1
  13. package/dist/src/Database/index.js.map +1 -1
  14. package/dist/src/Database/integrations/knex/KnexDatabase.d.ts +22 -8
  15. package/dist/src/Database/integrations/knex/KnexDatabase.js +17 -11
  16. package/dist/src/Database/integrations/knex/KnexDatabase.js.map +1 -1
  17. package/dist/src/Database/integrations/knex/KnexTransaction.d.ts +39 -16
  18. package/dist/src/Database/integrations/knex/KnexTransaction.js +83 -17
  19. package/dist/src/Database/integrations/knex/KnexTransaction.js.map +1 -1
  20. package/dist/src/Database/integrations/kysely/KyselyDatabase.d.ts +55 -0
  21. package/dist/src/Database/integrations/kysely/KyselyDatabase.js +127 -0
  22. package/dist/src/Database/integrations/kysely/KyselyDatabase.js.map +1 -0
  23. package/dist/src/Database/integrations/kysely/KyselyTransaction.d.ts +70 -0
  24. package/dist/src/Database/integrations/kysely/KyselyTransaction.js +186 -0
  25. package/dist/src/Database/integrations/kysely/KyselyTransaction.js.map +1 -0
  26. package/dist/src/Database/integrations/pgsql/PostgresDatabase.d.ts +16 -11
  27. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js +18 -16
  28. package/dist/src/Database/integrations/pgsql/PostgresDatabase.js.map +1 -1
  29. package/dist/src/Database/integrations/pgsql/PostgresTransaction.d.ts +42 -16
  30. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js +84 -18
  31. package/dist/src/Database/integrations/pgsql/PostgresTransaction.js.map +1 -1
  32. package/dist/src/Database/types.d.ts +47 -26
  33. package/dist/src/Logger/Logger.d.ts +6 -6
  34. package/dist/src/Logger/Logger.js +12 -15
  35. package/dist/src/Logger/Logger.js.map +1 -1
  36. package/package.json +2 -1
  37. package/src/BaseEvent/Transaction.ts +2 -2
  38. package/src/Database/Database.ts +8 -5
  39. package/src/Database/DatabaseManager.ts +34 -17
  40. package/src/Database/DatabaseTransaction.ts +79 -35
  41. package/src/Database/index.ts +2 -0
  42. package/src/Database/integrations/knex/KnexDatabase.ts +22 -11
  43. package/src/Database/integrations/knex/KnexTransaction.ts +52 -19
  44. package/src/Database/integrations/kysely/KyselyDatabase.ts +87 -0
  45. package/src/Database/integrations/kysely/KyselyTransaction.ts +172 -0
  46. package/src/Database/integrations/pgsql/PostgresDatabase.ts +26 -14
  47. package/src/Database/integrations/pgsql/PostgresTransaction.ts +55 -22
  48. package/src/Database/types.ts +53 -31
  49. package/src/Logger/Logger.ts +12 -15
  50. package/tests/Database/DatabaseManager.test.ts +16 -1
  51. package/tests/Database/integrations/knex/KnexDatabase.test.ts +2 -2
  52. package/tests/Database/integrations/knex/KnexTransaction.test.ts +52 -45
  53. package/tests/Database/integrations/kysely/KyselyDatabase.test.ts +109 -0
  54. package/tests/Database/integrations/kysely/KyselyTransaction.test.ts +118 -0
  55. package/tests/Database/integrations/pg/PostgresDatabase.test.ts +32 -6
  56. package/tests/Database/integrations/pg/PostgresTransaction.test.ts +75 -9
  57. package/tsconfig.json +1 -0
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creator.co/wapi",
3
- "version": "1.3.19",
3
+ "version": "1.4.0-alpha2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -35,6 +35,7 @@
35
35
  "jsonwebtoken": "^9.0.2",
36
36
  "knex": "^3.0.1",
37
37
  "knex-stringcase": "^1.4.6",
38
+ "kysely": "^0.27.2",
38
39
  "node-cache": "^5.1.2",
39
40
  "object-hash": "^3.0.0",
40
41
  "parse-duration": "^1.1.0",
@@ -118,7 +118,7 @@ export default class Transaction<InputType = object, ResponseInnerType = null, M
118
118
  * @param {DbConfig<S>} config - The configuration object for the database.
119
119
  * @returns {Promise<DatabaseTransactionType<S>>} A promise that resolves to the database transaction.
120
120
  */
121
- getDbTransaction<S extends DatabaseType>(config: DbConfig<S>): Promise<DatabaseTransactionType<S>>;
121
+ getDbTransaction<S extends DatabaseType, DBSchema>(config: DbConfig<S>): Promise<DatabaseTransactionType<S, DBSchema>>;
122
122
  private executeDBTransactions;
123
123
  /**
124
124
  * Executes a logger flush operation with error handling and logging.
@@ -1,18 +1,21 @@
1
1
  import { DatabaseTransaction } from './DatabaseTransaction';
2
2
  import { DbConfig } from './types';
3
3
  /**
4
- * Abstract class representing a database.
5
- * @template T - The type of database transaction.
4
+ * Abstract class representing a Database with a generic type extending DatabaseTransaction.
5
+ * @template T - The type of DatabaseTransaction to be used.
6
6
  */
7
7
  export declare abstract class Database<T extends DatabaseTransaction> {
8
8
  readonly config: DbConfig<any>;
9
9
  /**
10
- * Creates a database instance, maintaining a reference to the database configuration.
10
+ * Constructor for a class that takes in a database configuration object.
11
+ * @param {DbConfig<any>} config - The database configuration object.
12
+ * @returns None
11
13
  */
12
14
  protected constructor(config: DbConfig<any>);
13
15
  /**
14
- * Returns a promise resolving to a new instance of the transaction impl.
15
- * @returns A promise that resolves to a transaction instance.
16
+ * Represents an abstract method for a transaction that returns a Promise of type T.
17
+ * This method needs to be implemented by subclasses.
18
+ * @returns A Promise that resolves to a value of type T.
16
19
  */
17
20
  abstract transaction(): Promise<T>;
18
21
  }
@@ -2,12 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Database = void 0;
4
4
  /**
5
- * Abstract class representing a database.
6
- * @template T - The type of database transaction.
5
+ * Abstract class representing a Database with a generic type extending DatabaseTransaction.
6
+ * @template T - The type of DatabaseTransaction to be used.
7
7
  */
8
8
  var Database = /** @class */ (function () {
9
9
  /**
10
- * Creates a database instance, maintaining a reference to the database configuration.
10
+ * Constructor for a class that takes in a database configuration object.
11
+ * @param {DbConfig<any>} config - The database configuration object.
12
+ * @returns None
11
13
  */
12
14
  function Database(config) {
13
15
  this.config = config;
@@ -1 +1 @@
1
- {"version":3,"file":"Database.js","sourceRoot":"","sources":["../../../src/Database/Database.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH;IACE;;OAEG;IACH,kBAAsC,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAOjE,eAAC;AAAD,CAAC,AAXD,IAWC;AAXqB,4BAAQ"}
1
+ {"version":3,"file":"Database.js","sourceRoot":"","sources":["../../../src/Database/Database.ts"],"names":[],"mappings":";;;AAGA;;;GAGG;AACH;IACE;;;;OAIG;IACH,kBAAsC,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAQjE,eAAC;AAAD,CAAC,AAdD,IAcC;AAdqB,4BAAQ"}
@@ -1,32 +1,53 @@
1
1
  import { KnexDatabase } from './integrations/knex/KnexDatabase';
2
+ import { KyselyDatabase } from './integrations/kysely/KyselyDatabase';
2
3
  import { PostgresDatabase } from './integrations/pgsql/PostgresDatabase';
3
4
  import type { DatabaseImplType, DatabaseType, DbConfig } from './types';
4
5
  /**
5
- * An object that maps database names to their corresponding database classes.
6
+ * Object containing different database implementations.
6
7
  * @type {Object}
7
- * @property {KnexDatabase} knex - The Knex database class.
8
- * @property {PostgresDatabase} pg - The Postgres database class.
8
+ * @property {KnexDatabase} knex - Knex database implementation
9
+ * @property {PostgresDatabase} pg - Postgres database implementation
10
+ * @property {KyselyDatabase<any>} kysely - Kysely database implementation
9
11
  */
10
12
  export declare const DATABASES: {
11
13
  knex: typeof KnexDatabase;
12
14
  pg: typeof PostgresDatabase;
15
+ kysely: {
16
+ new (config: DbConfig<"kysely">): KyselyDatabase<any>;
17
+ kyselyPgProvider: typeof import("kysely").PostgresDialect;
18
+ kyselyProvider: typeof import("kysely").Kysely;
19
+ pgProvider: typeof import("pg").Pool;
20
+ };
13
21
  };
14
22
  /**
15
- * A class that manages databases and provides methods for creating and accessing database instances.
23
+ * Manages the creation and storage of database instances.
16
24
  */
17
25
  export declare class DatabaseManager {
18
26
  /**
19
- * The singleton instance of the DatabaseManager class.
27
+ * Singleton instance of the DatabaseManager class.
28
+ * This instance is used to interact with the database.
20
29
  */
21
30
  static readonly INSTANCE: DatabaseManager;
31
+ /**
32
+ * A private property that holds a reference to the DATABASES constant.
33
+ * @type {typeof DATABASES}
34
+ */
22
35
  private databases;
36
+ /**
37
+ * An object that stores instances of DatabaseImplType objects with keys of type string.
38
+ * @type {Object.<string, DatabaseImplType<any, any>>}
39
+ */
23
40
  private instances;
24
41
  /**
25
- * Creates a new instance of a database based on the provided configuration.
42
+ * Creates a database instance based on the provided configuration.
26
43
  * @param {DbConfig<S>} config - The configuration object for the database.
27
- * @returns {DatabaseImplType<S>} - The created database instance.
28
- * @template S - The type of the database.
44
+ * @returns {DatabaseImplType<S, DBSchema>} An instance of the database based on the configuration.
45
+ */
46
+ create<S extends DatabaseType, DBSchema>(config: DbConfig<S>): DatabaseImplType<S, DBSchema>;
47
+ /**
48
+ * Instantiates a database connection based on the provided configuration.
49
+ * @param {DbConfig<'knex'> | DbConfig<'pg'> | DbConfig<'kysely'>} config - The configuration object specifying the type of database.
50
+ * @returns {DatabaseImplType<S, DBSchema>} An instance of the specified database connection.
29
51
  */
30
- create<S extends DatabaseType>(config: DbConfig<S>): DatabaseImplType<S>;
31
52
  private instantiateDb;
32
53
  }
@@ -3,30 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DatabaseManager = exports.DATABASES = void 0;
4
4
  var hash = require("object-hash");
5
5
  var KnexDatabase_1 = require("./integrations/knex/KnexDatabase");
6
+ var KyselyDatabase_1 = require("./integrations/kysely/KyselyDatabase");
6
7
  var PostgresDatabase_1 = require("./integrations/pgsql/PostgresDatabase");
7
8
  /**
8
- * An object that maps database names to their corresponding database classes.
9
+ * Object containing different database implementations.
9
10
  * @type {Object}
10
- * @property {KnexDatabase} knex - The Knex database class.
11
- * @property {PostgresDatabase} pg - The Postgres database class.
11
+ * @property {KnexDatabase} knex - Knex database implementation
12
+ * @property {PostgresDatabase} pg - Postgres database implementation
13
+ * @property {KyselyDatabase<any>} kysely - Kysely database implementation
12
14
  */
13
15
  exports.DATABASES = {
14
16
  knex: KnexDatabase_1.KnexDatabase,
15
17
  pg: PostgresDatabase_1.PostgresDatabase,
18
+ kysely: (KyselyDatabase_1.KyselyDatabase),
16
19
  };
17
20
  /**
18
- * A class that manages databases and provides methods for creating and accessing database instances.
21
+ * Manages the creation and storage of database instances.
19
22
  */
20
23
  var DatabaseManager = /** @class */ (function () {
21
24
  function DatabaseManager() {
25
+ /**
26
+ * A private property that holds a reference to the DATABASES constant.
27
+ * @type {typeof DATABASES}
28
+ */
22
29
  this.databases = exports.DATABASES;
30
+ /**
31
+ * An object that stores instances of DatabaseImplType objects with keys of type string.
32
+ * @type {Object.<string, DatabaseImplType<any, any>>}
33
+ */
23
34
  this.instances = {};
24
35
  }
25
36
  /**
26
- * Creates a new instance of a database based on the provided configuration.
37
+ * Creates a database instance based on the provided configuration.
27
38
  * @param {DbConfig<S>} config - The configuration object for the database.
28
- * @returns {DatabaseImplType<S>} - The created database instance.
29
- * @template S - The type of the database.
39
+ * @returns {DatabaseImplType<S, DBSchema>} An instance of the database based on the configuration.
30
40
  */
31
41
  DatabaseManager.prototype.create = function (config) {
32
42
  var configHash = hash(config);
@@ -37,11 +47,17 @@ var DatabaseManager = /** @class */ (function () {
37
47
  this.instances[configHash] = instance;
38
48
  return instance;
39
49
  };
50
+ /**
51
+ * Instantiates a database connection based on the provided configuration.
52
+ * @param {DbConfig<'knex'> | DbConfig<'pg'> | DbConfig<'kysely'>} config - The configuration object specifying the type of database.
53
+ * @returns {DatabaseImplType<S, DBSchema>} An instance of the specified database connection.
54
+ */
40
55
  DatabaseManager.prototype.instantiateDb = function (config) {
41
56
  return new this.databases[config.type](config);
42
57
  };
43
58
  /**
44
- * The singleton instance of the DatabaseManager class.
59
+ * Singleton instance of the DatabaseManager class.
60
+ * This instance is used to interact with the database.
45
61
  */
46
62
  DatabaseManager.INSTANCE = new DatabaseManager();
47
63
  return DatabaseManager;
@@ -1 +1 @@
1
- {"version":3,"file":"DatabaseManager.js","sourceRoot":"","sources":["../../../src/Database/DatabaseManager.ts"],"names":[],"mappings":";;;AAAA,kCAAmC;AAEnC,iEAA+D;AAC/D,0EAAwE;AAGxE;;;;;GAKG;AACU,QAAA,SAAS,GAAG;IACvB,IAAI,EAAE,2BAAY;IAClB,EAAE,EAAE,mCAAgB;CACrB,CAAA;AAED;;GAEG;AACH;IAAA;QAKU,cAAS,GAAqB,iBAAS,CAAA;QAEvC,cAAS,GAA2C,EAAE,CAAA;IAuBhE,CAAC;IArBC;;;;;OAKG;IACI,gCAAM,GAAb,UAAsC,MAAmB;QACvD,IAAM,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,IAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,MAAa,CAAC,CAAA;QAClD,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAA;QACrC,OAAO,QAAe,CAAA;IACxB,CAAC;IAEO,uCAAa,GAArB,UACE,MAAyC;QAEzC,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAa,CAAC,CAAA;IACvD,CAAC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Database } from './Database';
5
5
  * @class DatabaseTransaction
6
6
  */
7
7
  export declare abstract class DatabaseTransaction extends Function {
8
- private _isOpen;
9
- protected delegate: any;
8
+ /**
9
+ * A boolean flag indicating whether a certain feature is open or closed.
10
+ * @type {boolean}
11
+ */
12
+ protected _isOpen: boolean;
13
+ /**
14
+ * A property representing a writer object.
15
+ * @type {any}
16
+ */
17
+ readonly writer: any;
18
+ /**
19
+ * A property representing a reader object.
20
+ * @type {any}
21
+ */
22
+ readonly reader: any;
23
+ /**
24
+ * A protected property representing a transaction.
25
+ * @type {any}
26
+ */
27
+ protected transaction: any;
28
+ /**
29
+ * A protected property representing a database of type Database<any>.
30
+ * This property is accessible within the class and its subclasses.
31
+ */
10
32
  protected database: Database<any>;
11
33
  /**
12
- * Constructs a new instance of the class.
13
- * @param {any} delegate - The delegate object.
14
- * @param {Database<any>} database - The database object.
15
- * @protected
34
+ * Constructor for a class that interacts with a database using a writer and reader.
35
+ * @param {any} writer - The object responsible for writing to the database.
36
+ * @param {Database<any>} database - The database to interact with.
37
+ * @param {any} [reader] - The object responsible for reading from the database (optional).
38
+ * @returns None
16
39
  */
17
- protected constructor(delegate: any, database: Database<any>);
40
+ protected constructor(writer: any, database: Database<any>, reader?: any);
18
41
  /**
19
- * Wraps an instance of a subclass of DatabaseTransaction with a Proxy object.
20
- * The Proxy object intercepts method calls and delegates to the target instance.
21
- * If the method is on the target instance, it is called directly.
22
- * If the method is not on the target instance and the transaction is open, it is called on the target's delegate implementation.
23
- * If the method is not on the target instance and the transaction is closed, an error is thrown.
24
- * @param {T} subclass - The subclass instance to wrap with a Proxy.
25
- * @returns {T} - The wrapped subclass instance.
26
- * @throws {Error} - If the target instance is closed.
42
+ * Creates a proxy instance for the given subclass of DatabaseTransaction.
43
+ * The proxy handles method binding and transaction execution based on the subclass state.
44
+ * @param {T} subclass - The subclass of DatabaseTransaction to proxy.
45
+ * @returns A proxied instance of the subclass with method binding and transaction execution logic.
27
46
  */
28
- protected static wrapInstance<T extends DatabaseTransaction>(subclass: T): T;
47
+ protected static proxyInstance<T extends DatabaseTransaction>(subclass: T): T;
29
48
  /**
30
- * Returns a boolean value indicating whether the transaction is open or not.
49
+ * Check if the object is open.
31
50
  * @returns {boolean} - true if the object is open, false otherwise.
32
51
  */
33
52
  isOpen: () => boolean;
34
53
  /**
35
- * Commits the transaction.
36
- * @throws {Error} - If the transaction is already closed.
37
- * @returns None
54
+ * Begins a transaction asynchronously.
55
+ * @returns {Promise<void>} A Promise that resolves when the transaction has begun.
56
+ * @throws {Error} If the transaction is already open.
57
+ */
58
+ begin: () => Promise<void>;
59
+ /**
60
+ * Asynchronously commits the transaction.
61
+ * If the transaction is already closed, an error is thrown.
62
+ * @returns Promise<void>
63
+ * @throws Error if the transaction is already closed
38
64
  */
39
65
  commit: () => Promise<void>;
40
66
  /**
41
- * Rollbacks the current transaction.
42
- * @throws {Error} - If the transaction is already closed.
43
- * @returns {Promise<void>} - A promise that resolves once the rollback is complete.
67
+ * Rollback the transaction by reverting any changes made within the transaction.
68
+ * If the transaction is already closed, an error is thrown.
69
+ * @returns Promise<void>
70
+ * @throws Error if the transaction is already closed.
44
71
  */
45
72
  rollback: () => Promise<void>;
46
73
  /**
47
- * Closes the transaction after a successful execution.
48
- * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
74
+ * Closes the success modal, committing or rolling back changes based on the autoCommit setting.
75
+ * If the modal is open and autoCommit is enabled, it will commit the changes.
76
+ * If autoCommit is disabled, it will rollback the changes.
77
+ * @returns {Promise<void>} A promise that resolves once the commit or rollback operation is completed.
49
78
  */
50
79
  closeSuccess: () => Promise<void>;
51
80
  /**
52
- * Closes the transaction after a failed execution.
53
- * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
81
+ * Closes the failure by performing a rollback if the failure is currently open.
82
+ * @returns {Promise<void>} A promise that resolves once the rollback is completed.
54
83
  */
55
84
  closeFailure: () => Promise<void>;
56
85
  /**
57
- * An abstract method that performs the commit operation.
58
- * @returns {Promise<any>} A promise that resolves when the commit operation is completed.
86
+ * Abstract method that should be implemented by subclasses to perform a commit operation.
87
+ * @returns A Promise that resolves when the commit operation is completed.
59
88
  */
60
89
  protected abstract doCommit: () => Promise<any>;
61
90
  /**
62
- * An abstract method that performs a rollback operation.
63
- * @returns A Promise that resolves when the rollback operation is complete.
91
+ * An abstract method that defines the rollback functionality.
92
+ * This method should be implemented by subclasses to perform the actual rollback operation.
93
+ * @returns A Promise that resolves when the rollback operation is completed.
64
94
  */
65
95
  protected abstract doRollback: () => Promise<any>;
96
+ /**
97
+ * Abstract method that defines the beginning of an asynchronous operation.
98
+ * @returns A Promise that resolves when the operation begins.
99
+ */
100
+ protected abstract doBegin: () => Promise<any>;
66
101
  }
@@ -85,25 +85,46 @@ exports.DatabaseTransaction = void 0;
85
85
  var DatabaseTransaction = /** @class */ (function (_super) {
86
86
  __extends(DatabaseTransaction, _super);
87
87
  /**
88
- * Constructs a new instance of the class.
89
- * @param {any} delegate - The delegate object.
90
- * @param {Database<any>} database - The database object.
91
- * @protected
88
+ * Constructor for a class that interacts with a database using a writer and reader.
89
+ * @param {any} writer - The object responsible for writing to the database.
90
+ * @param {Database<any>} database - The database to interact with.
91
+ * @param {any} [reader] - The object responsible for reading from the database (optional).
92
+ * @returns None
92
93
  */
93
- function DatabaseTransaction(delegate, database) {
94
- var _this = _super.call(this, '...args', 'return this.delegate(...args)') || this;
95
- _this._isOpen = true;
94
+ function DatabaseTransaction(writer, database, reader) {
95
+ var _this = _super.call(this, '...args', 'return this.transaction(...args)') || this;
96
96
  /**
97
- * Returns a boolean value indicating whether the transaction is open or not.
97
+ * Check if the object is open.
98
98
  * @returns {boolean} - true if the object is open, false otherwise.
99
99
  */
100
100
  _this.isOpen = function () {
101
101
  return _this._isOpen;
102
102
  };
103
103
  /**
104
- * Commits the transaction.
105
- * @throws {Error} - If the transaction is already closed.
106
- * @returns None
104
+ * Begins a transaction asynchronously.
105
+ * @returns {Promise<void>} A Promise that resolves when the transaction has begun.
106
+ * @throws {Error} If the transaction is already open.
107
+ */
108
+ _this.begin = function () { return __awaiter(_this, void 0, void 0, function () {
109
+ return __generator(this, function (_a) {
110
+ switch (_a.label) {
111
+ case 0:
112
+ if (this._isOpen) {
113
+ throw new Error('Cannot begin, transaction is already opened!');
114
+ }
115
+ return [4 /*yield*/, this.doBegin()];
116
+ case 1:
117
+ _a.sent();
118
+ this._isOpen = true;
119
+ return [2 /*return*/];
120
+ }
121
+ });
122
+ }); };
123
+ /**
124
+ * Asynchronously commits the transaction.
125
+ * If the transaction is already closed, an error is thrown.
126
+ * @returns Promise<void>
127
+ * @throws Error if the transaction is already closed
107
128
  */
108
129
  _this.commit = function () { return __awaiter(_this, void 0, void 0, function () {
109
130
  return __generator(this, function (_a) {
@@ -121,9 +142,10 @@ var DatabaseTransaction = /** @class */ (function (_super) {
121
142
  });
122
143
  }); };
123
144
  /**
124
- * Rollbacks the current transaction.
125
- * @throws {Error} - If the transaction is already closed.
126
- * @returns {Promise<void>} - A promise that resolves once the rollback is complete.
145
+ * Rollback the transaction by reverting any changes made within the transaction.
146
+ * If the transaction is already closed, an error is thrown.
147
+ * @returns Promise<void>
148
+ * @throws Error if the transaction is already closed.
127
149
  */
128
150
  _this.rollback = function () { return __awaiter(_this, void 0, void 0, function () {
129
151
  return __generator(this, function (_a) {
@@ -141,8 +163,10 @@ var DatabaseTransaction = /** @class */ (function (_super) {
141
163
  });
142
164
  }); };
143
165
  /**
144
- * Closes the transaction after a successful execution.
145
- * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
166
+ * Closes the success modal, committing or rolling back changes based on the autoCommit setting.
167
+ * If the modal is open and autoCommit is enabled, it will commit the changes.
168
+ * If autoCommit is disabled, it will rollback the changes.
169
+ * @returns {Promise<void>} A promise that resolves once the commit or rollback operation is completed.
146
170
  */
147
171
  _this.closeSuccess = function () { return __awaiter(_this, void 0, void 0, function () {
148
172
  return __generator(this, function (_a) {
@@ -163,8 +187,8 @@ var DatabaseTransaction = /** @class */ (function (_super) {
163
187
  });
164
188
  }); };
165
189
  /**
166
- * Closes the transaction after a failed execution.
167
- * @returns {Promise<void>} - A promise that resolves once the necessary actions are completed.
190
+ * Closes the failure by performing a rollback if the failure is currently open.
191
+ * @returns {Promise<void>} A promise that resolves once the rollback is completed.
168
192
  */
169
193
  _this.closeFailure = function () { return __awaiter(_this, void 0, void 0, function () {
170
194
  return __generator(this, function (_a) {
@@ -179,21 +203,18 @@ var DatabaseTransaction = /** @class */ (function (_super) {
179
203
  }
180
204
  });
181
205
  }); };
182
- _this.delegate = delegate;
206
+ _this.writer = writer;
183
207
  _this.database = database;
208
+ _this.reader = reader;
184
209
  return _this;
185
210
  }
186
211
  /**
187
- * Wraps an instance of a subclass of DatabaseTransaction with a Proxy object.
188
- * The Proxy object intercepts method calls and delegates to the target instance.
189
- * If the method is on the target instance, it is called directly.
190
- * If the method is not on the target instance and the transaction is open, it is called on the target's delegate implementation.
191
- * If the method is not on the target instance and the transaction is closed, an error is thrown.
192
- * @param {T} subclass - The subclass instance to wrap with a Proxy.
193
- * @returns {T} - The wrapped subclass instance.
194
- * @throws {Error} - If the target instance is closed.
212
+ * Creates a proxy instance for the given subclass of DatabaseTransaction.
213
+ * The proxy handles method binding and transaction execution based on the subclass state.
214
+ * @param {T} subclass - The subclass of DatabaseTransaction to proxy.
215
+ * @returns A proxied instance of the subclass with method binding and transaction execution logic.
195
216
  */
196
- DatabaseTransaction.wrapInstance = function (subclass) {
217
+ DatabaseTransaction.proxyInstance = function (subclass) {
197
218
  var bind = function (target, key) {
198
219
  return typeof target[key] === 'function' ? target[key].bind(target) : target[key];
199
220
  };
@@ -203,13 +224,13 @@ var DatabaseTransaction = /** @class */ (function (_super) {
203
224
  return bind(target, p);
204
225
  }
205
226
  else if (target._isOpen) {
206
- return bind(target.delegate, p);
227
+ return bind(target.transaction, p);
207
228
  }
208
229
  return undefined;
209
230
  },
210
231
  apply: function (target, thisArg, argArray) {
211
232
  if (target._isOpen) {
212
- return target.delegate.apply(target, __spreadArray([], __read(argArray), false));
233
+ return target.transaction.apply(target, __spreadArray([], __read(argArray), false));
213
234
  }
214
235
  throw new Error('Transaction is closed!');
215
236
  },
@@ -1 +1 @@
1
- {"version":3,"file":"DatabaseTransaction.js","sourceRoot":"","sources":["../../../src/Database/DatabaseTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;;GAIG;AACH;IAAkD,uCAAQ;IAKxD;;;;;OAKG;IACH,6BAAsB,QAAa,EAAE,QAAuB;QAC1D,YAAA,MAAK,YAAC,SAAS,EAAE,+BAA+B,CAAC,SAAA;QAX3C,aAAO,GAAY,IAAI,CAAA;QAgD/B;;;WAGG;QACI,YAAM,GAAG;YACd,OAAO,KAAI,CAAC,OAAO,CAAA;QACrB,CAAC,CAAA;QAED;;;;WAIG;QACI,YAAM,GAAG;;;;wBACd,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;4BAClB,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;wBAClE,CAAC;wBACD,qBAAM,IAAI,CAAC,QAAQ,EAAE,EAAA;;wBAArB,SAAqB,CAAA;wBACrB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;;;;aACrB,CAAA;QAED;;;;WAIG;QACI,cAAQ,GAAG;;;;wBAChB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;4BAClB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;wBACpE,CAAC;wBACD,qBAAM,IAAI,CAAC,UAAU,EAAE,EAAA;;wBAAvB,SAAuB,CAAA;wBACvB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;;;;aACrB,CAAA;QAED;;;WAGG;QACI,kBAAY,GAAG;;;;6BAChB,IAAI,CAAC,OAAO,EAAZ,wBAAY;6BACV,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,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AAK,SAAS,EAAE,CAAC;oBAC5B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;gBACxB,CAAC;qBAAM,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;oBAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;gBACpC,CAAC;gBACD,OAAO,SAAS,CAAA;YAClB,CAAC;YACD,KAAK,YAAC,MAAS,EAAE,OAAY,EAAE,QAAe;gBAC5C,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;oBACnB,OAAO,MAAM,CAAC,WAAW,OAAlB,MAAM,2BAAgB,QAAQ,WAAC;gBACxC,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAA;YAC3C,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;IA+FH,0BAAC;AAAD,CAAC,AAlKD,CAAkD,QAAQ,GAkKzD;AAlKqB,kDAAmB"}
@@ -2,6 +2,7 @@ import { Database } from './Database';
2
2
  import { DatabaseManager } from './DatabaseManager';
3
3
  import { DatabaseTransaction } from './DatabaseTransaction';
4
4
  import { KnexTransaction } from './integrations/knex/KnexTransaction';
5
+ import { KyselyTransaction } from './integrations/kysely/KyselyTransaction';
5
6
  import { PostgresTransaction } from './integrations/pgsql/PostgresTransaction';
6
7
  import { DbConfig } from './types';
7
- export { DatabaseTransaction, DbConfig, KnexTransaction, PostgresTransaction, DatabaseManager, Database, };
8
+ export { DatabaseTransaction, DbConfig, KnexTransaction, PostgresTransaction, KyselyTransaction, DatabaseManager, Database, };
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Database/index.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AAanC,yFAbO,mBAAQ,OAaP;AAZV,qDAAmD;AAWjD,gGAXO,iCAAe,OAWP;AAVjB,6DAA2D;AAMzD,oGANO,yCAAmB,OAMP"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Database/index.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AAenC,yFAfO,mBAAQ,OAeP;AAdV,qDAAmD;AAajD,gGAbO,iCAAe,OAaP;AAZjB,6DAA2D;AAOzD,oGAPO,yCAAmB,OAOP"}
@@ -1,23 +1,37 @@
1
+ import knex, { Knex } from 'knex';
1
2
  import { KnexTransaction } from './KnexTransaction';
2
3
  import { Database } from '../../Database';
3
4
  import type { DbConfig } from '../../types';
4
5
  /**
5
- * Represents a Knex database connection.
6
- * @extends Database<KnexTransaction>
6
+ * Represents a KnexDatabase class that extends Database and provides methods for interacting with a Knex database.
7
7
  */
8
8
  export declare class KnexDatabase extends Database<KnexTransaction> {
9
- private static knexProvider;
10
- private client;
11
9
  /**
12
- * Constructs a new instance of the database class using the provided configuration.
13
- * @param {DbConfig<'knex'>} config - The configuration object for the database.
10
+ * A static property that provides a Knex instance based on the given configuration.
11
+ * @param {knex.Knex.Config<any>} config - The configuration object for Knex.
12
+ * @returns {knex.Knex<any, unknown[]>} A Knex instance based on the provided configuration.
13
+ */
14
+ static knexProvider: (config: knex.Knex.Config<any>) => knex.Knex<any, unknown[]>;
15
+ /**
16
+ * Represents a Knex client for interacting with a database.
17
+ * @type {Knex}
18
+ */
19
+ readonly client: Knex;
20
+ /**
21
+ * Constructor for creating a new instance of a database connection using Knex.
22
+ * @param {DbConfig<'knex'>} config - The configuration object for the Knex database.
14
23
  * @returns None
15
24
  */
16
25
  constructor(config: DbConfig<'knex'>);
26
+ /**
27
+ * Constructs a Knex configuration object based on the provided DbConfig.
28
+ * @param {DbConfig<'knex'>} config - The database configuration object.
29
+ * @returns The Knex configuration object with appropriate settings based on the input config.
30
+ */
17
31
  private constructConfig;
18
32
  /**
19
- * Initiates a transaction using the underlying database client.
20
- * @returns {Promise<KnexTransaction>} A promise that resolves to a KnexTransaction object representing the transaction.
33
+ * Override method to start a new transaction using KnexTransactionImpl.
34
+ * @returns {Promise<KnexTransaction>} A promise that resolves to a KnexTransaction object.
21
35
  */
22
36
  transaction(): Promise<KnexTransaction>;
23
37
  }
@@ -57,14 +57,13 @@ var knexStringcase = require("knex-stringcase");
57
57
  var KnexTransaction_1 = require("./KnexTransaction");
58
58
  var Database_1 = require("../../Database");
59
59
  /**
60
- * Represents a Knex database connection.
61
- * @extends Database<KnexTransaction>
60
+ * Represents a KnexDatabase class that extends Database and provides methods for interacting with a Knex database.
62
61
  */
63
62
  var KnexDatabase = /** @class */ (function (_super) {
64
63
  __extends(KnexDatabase, _super);
65
64
  /**
66
- * Constructs a new instance of the database class using the provided configuration.
67
- * @param {DbConfig<'knex'>} config - The configuration object for the database.
65
+ * Constructor for creating a new instance of a database connection using Knex.
66
+ * @param {DbConfig<'knex'>} config - The configuration object for the Knex database.
68
67
  * @returns None
69
68
  */
70
69
  function KnexDatabase(config) {
@@ -72,6 +71,11 @@ var KnexDatabase = /** @class */ (function (_super) {
72
71
  _this.client = KnexDatabase.knexProvider(_this.constructConfig(config));
73
72
  return _this;
74
73
  }
74
+ /**
75
+ * Constructs a Knex configuration object based on the provided DbConfig.
76
+ * @param {DbConfig<'knex'>} config - The database configuration object.
77
+ * @returns The Knex configuration object with appropriate settings based on the input config.
78
+ */
75
79
  KnexDatabase.prototype.constructConfig = function (config) {
76
80
  var knexConfig = {
77
81
  client: config.driver,
@@ -90,22 +94,24 @@ var KnexDatabase = /** @class */ (function (_super) {
90
94
  return config.convertCamelToSnake ? knexStringcase(knexConfig) : knexConfig;
91
95
  };
92
96
  /**
93
- * Initiates a transaction using the underlying database client.
94
- * @returns {Promise<KnexTransaction>} A promise that resolves to a KnexTransaction object representing the transaction.
97
+ * Override method to start a new transaction using KnexTransactionImpl.
98
+ * @returns {Promise<KnexTransaction>} A promise that resolves to a KnexTransaction object.
95
99
  */
96
100
  KnexDatabase.prototype.transaction = function () {
97
101
  return __awaiter(this, void 0, void 0, function () {
98
- var delegate;
99
102
  return __generator(this, function (_a) {
100
103
  switch (_a.label) {
101
- case 0: return [4 /*yield*/, this.client.transaction()];
102
- case 1:
103
- delegate = _a.sent();
104
- return [2 /*return*/, KnexTransaction_1.KnexTransactionImpl.wrapDelegate(delegate, this)];
104
+ case 0: return [4 /*yield*/, KnexTransaction_1.KnexTransactionImpl.newTransaction(this.client, this)];
105
+ case 1: return [2 /*return*/, _a.sent()];
105
106
  }
106
107
  });
107
108
  });
108
109
  };
110
+ /**
111
+ * A static property that provides a Knex instance based on the given configuration.
112
+ * @param {knex.Knex.Config<any>} config - The configuration object for Knex.
113
+ * @returns {knex.Knex<any, unknown[]>} A Knex instance based on the provided configuration.
114
+ */
109
115
  KnexDatabase.knexProvider = knex_1.default;
110
116
  return KnexDatabase;
111
117
  }(Database_1.Database));