@groundbrick/db-core 0.0.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/README.md +214 -0
- package/dist/adapters/BaseSqlAdapter.d.ts +14 -0
- package/dist/adapters/BaseSqlAdapter.d.ts.map +1 -0
- package/dist/adapters/BaseSqlAdapter.js +37 -0
- package/dist/adapters/BaseSqlAdapter.js.map +1 -0
- package/dist/adapters/DatabaseAdapter.d.ts +59 -0
- package/dist/adapters/DatabaseAdapter.d.ts.map +1 -0
- package/dist/adapters/DatabaseAdapter.js +120 -0
- package/dist/adapters/DatabaseAdapter.js.map +1 -0
- package/dist/base/BaseTransaction.d.ts +65 -0
- package/dist/base/BaseTransaction.d.ts.map +1 -0
- package/dist/base/BaseTransaction.js +134 -0
- package/dist/base/BaseTransaction.js.map +1 -0
- package/dist/custom-types/MigrationRecord.d.ts +6 -0
- package/dist/custom-types/MigrationRecord.d.ts.map +1 -0
- package/dist/custom-types/MigrationRecord.js +2 -0
- package/dist/custom-types/MigrationRecord.js.map +1 -0
- package/dist/custom-types/QueryParams.d.ts +5 -0
- package/dist/custom-types/QueryParams.d.ts.map +1 -0
- package/dist/custom-types/QueryParams.js +2 -0
- package/dist/custom-types/QueryParams.js.map +1 -0
- package/dist/custom-types/Transaction.d.ts +6 -0
- package/dist/custom-types/Transaction.d.ts.map +1 -0
- package/dist/custom-types/Transaction.js +2 -0
- package/dist/custom-types/Transaction.js.map +1 -0
- package/dist/custom-types/TransactionCallback.d.ts +3 -0
- package/dist/custom-types/TransactionCallback.d.ts.map +1 -0
- package/dist/custom-types/TransactionCallback.js +2 -0
- package/dist/custom-types/TransactionCallback.js.map +1 -0
- package/dist/error-handling/ConnectionError.d.ts +8 -0
- package/dist/error-handling/ConnectionError.d.ts.map +1 -0
- package/dist/error-handling/ConnectionError.js +11 -0
- package/dist/error-handling/ConnectionError.js.map +1 -0
- package/dist/error-handling/DatabaseError.d.ts +18 -0
- package/dist/error-handling/DatabaseError.d.ts.map +1 -0
- package/dist/error-handling/DatabaseError.js +22 -0
- package/dist/error-handling/DatabaseError.js.map +1 -0
- package/dist/error-handling/MigrationError.d.ts +8 -0
- package/dist/error-handling/MigrationError.d.ts.map +1 -0
- package/dist/error-handling/MigrationError.js +11 -0
- package/dist/error-handling/MigrationError.js.map +1 -0
- package/dist/error-handling/QueryError.d.ts +8 -0
- package/dist/error-handling/QueryError.d.ts.map +1 -0
- package/dist/error-handling/QueryError.js +11 -0
- package/dist/error-handling/QueryError.js.map +1 -0
- package/dist/error-handling/TransactionError.d.ts +8 -0
- package/dist/error-handling/TransactionError.d.ts.map +1 -0
- package/dist/error-handling/TransactionError.js +11 -0
- package/dist/error-handling/TransactionError.js.map +1 -0
- package/dist/index.d.ts +138 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +105 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/ConfigValidator.d.ts +10 -0
- package/dist/interfaces/ConfigValidator.d.ts.map +1 -0
- package/dist/interfaces/ConfigValidator.js +2 -0
- package/dist/interfaces/ConfigValidator.js.map +1 -0
- package/dist/interfaces/DatabaseClient.d.ts +18 -0
- package/dist/interfaces/DatabaseClient.d.ts.map +1 -0
- package/dist/interfaces/DatabaseClient.js +2 -0
- package/dist/interfaces/DatabaseClient.js.map +1 -0
- package/dist/interfaces/DatabaseConfig.d.ts +22 -0
- package/dist/interfaces/DatabaseConfig.d.ts.map +1 -0
- package/dist/interfaces/DatabaseConfig.js +2 -0
- package/dist/interfaces/DatabaseConfig.js.map +1 -0
- package/dist/interfaces/DatabaseFactory.d.ts +11 -0
- package/dist/interfaces/DatabaseFactory.d.ts.map +1 -0
- package/dist/interfaces/DatabaseFactory.js +2 -0
- package/dist/interfaces/DatabaseFactory.js.map +1 -0
- package/dist/interfaces/DatabaseTransaction.d.ts +31 -0
- package/dist/interfaces/DatabaseTransaction.d.ts.map +1 -0
- package/dist/interfaces/DatabaseTransaction.js +2 -0
- package/dist/interfaces/DatabaseTransaction.js.map +1 -0
- package/dist/interfaces/HealthCheckResult.d.ts +14 -0
- package/dist/interfaces/HealthCheckResult.d.ts.map +1 -0
- package/dist/interfaces/HealthCheckResult.js +2 -0
- package/dist/interfaces/HealthCheckResult.js.map +1 -0
- package/dist/interfaces/Migration.d.ts +11 -0
- package/dist/interfaces/Migration.d.ts.map +1 -0
- package/dist/interfaces/Migration.js +2 -0
- package/dist/interfaces/Migration.js.map +1 -0
- package/dist/interfaces/MigrationManager.d.ts +31 -0
- package/dist/interfaces/MigrationManager.d.ts.map +1 -0
- package/dist/interfaces/MigrationManager.js +2 -0
- package/dist/interfaces/MigrationManager.js.map +1 -0
- package/dist/interfaces/MigrationStatus.d.ts +10 -0
- package/dist/interfaces/MigrationStatus.d.ts.map +1 -0
- package/dist/interfaces/MigrationStatus.js +2 -0
- package/dist/interfaces/MigrationStatus.js.map +1 -0
- package/dist/interfaces/QueryResult.d.ts +14 -0
- package/dist/interfaces/QueryResult.d.ts.map +1 -0
- package/dist/interfaces/QueryResult.js +2 -0
- package/dist/interfaces/QueryResult.js.map +1 -0
- package/dist/interfaces/SqlAdapter.d.ts +11 -0
- package/dist/interfaces/SqlAdapter.d.ts.map +1 -0
- package/dist/interfaces/SqlAdapter.js +2 -0
- package/dist/interfaces/SqlAdapter.js.map +1 -0
- package/dist/interfaces/index.d.ts +14 -0
- package/dist/interfaces/index.d.ts.map +1 -0
- package/dist/interfaces/index.js +3 -0
- package/dist/interfaces/index.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationRecord.d.ts","sourceRoot":"","sources":["../../src/custom-types/MigrationRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAOnE;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationRecord.js","sourceRoot":"","sources":["../../src/custom-types/MigrationRecord.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryParams.d.ts","sourceRoot":"","sources":["../../src/custom-types/QueryParams.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryParams.js","sourceRoot":"","sources":["../../src/custom-types/QueryParams.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../src/custom-types/Transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAO3E;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Transaction.js","sourceRoot":"","sources":["../../src/custom-types/Transaction.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionCallback.d.ts","sourceRoot":"","sources":["../../src/custom-types/TransactionCallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,mBAAmB,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionCallback.js","sourceRoot":"","sources":["../../src/custom-types/TransactionCallback.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DatabaseError } from "./DatabaseError.js";
|
|
2
|
+
/**
|
|
3
|
+
* Connection error specifically for connection-related issues
|
|
4
|
+
*/
|
|
5
|
+
export declare class ConnectionError extends DatabaseError {
|
|
6
|
+
constructor(message: string, cause?: Error);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ConnectionError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionError.d.ts","sourceRoot":"","sources":["../../src/error-handling/ConnectionError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,qBAAa,eAAgB,SAAQ,aAAa;gBAClC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAI7C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DatabaseError } from "./DatabaseError.js";
|
|
2
|
+
/**
|
|
3
|
+
* Connection error specifically for connection-related issues
|
|
4
|
+
*/
|
|
5
|
+
export class ConnectionError extends DatabaseError {
|
|
6
|
+
constructor(message, cause) {
|
|
7
|
+
super(message, { cause });
|
|
8
|
+
this.name = 'ConnectionError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=ConnectionError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConnectionError.js","sourceRoot":"","sources":["../../src/error-handling/ConnectionError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO,eAAgB,SAAQ,aAAa;IAC9C,YAAY,OAAe,EAAE,KAAa;QACtC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAClC,CAAC;CACJ"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for database operations
|
|
3
|
+
*/
|
|
4
|
+
export declare class DatabaseError extends Error {
|
|
5
|
+
readonly code?: string;
|
|
6
|
+
readonly severity?: string;
|
|
7
|
+
readonly constraint?: string;
|
|
8
|
+
readonly detail?: string;
|
|
9
|
+
readonly cause?: Error;
|
|
10
|
+
constructor(message: string, options?: {
|
|
11
|
+
code?: string;
|
|
12
|
+
severity?: string;
|
|
13
|
+
constraint?: string;
|
|
14
|
+
detail?: string;
|
|
15
|
+
cause?: Error;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=DatabaseError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseError.d.ts","sourceRoot":"","sources":["../../src/error-handling/DatabaseError.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACpC,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC9B,SAAgB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpC,SAAgB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChC,SAAgB,KAAK,CAAC,EAAE,KAAK,CAAC;gBAG1B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,KAAK,CAAC;KACjB;CAaR"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for database operations
|
|
3
|
+
*/
|
|
4
|
+
export class DatabaseError extends Error {
|
|
5
|
+
code;
|
|
6
|
+
severity;
|
|
7
|
+
constraint;
|
|
8
|
+
detail;
|
|
9
|
+
cause;
|
|
10
|
+
constructor(message, options) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'DatabaseError';
|
|
13
|
+
this.code = options?.code;
|
|
14
|
+
this.severity = options?.severity;
|
|
15
|
+
this.constraint = options?.constraint;
|
|
16
|
+
this.detail = options?.detail;
|
|
17
|
+
if (options?.cause) {
|
|
18
|
+
this.cause = options.cause;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=DatabaseError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseError.js","sourceRoot":"","sources":["../../src/error-handling/DatabaseError.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACpB,IAAI,CAAU;IACd,QAAQ,CAAU;IAClB,UAAU,CAAU;IACpB,MAAM,CAAU;IAChB,KAAK,CAAS;IAE9B,YACI,OAAe,EACf,OAMC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,CAAC;QAClC,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAC;QAE9B,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC/B,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DatabaseError } from "./DatabaseError.js";
|
|
2
|
+
/**
|
|
3
|
+
* Migration error for migration-related issues
|
|
4
|
+
*/
|
|
5
|
+
export declare class MigrationError extends DatabaseError {
|
|
6
|
+
constructor(message: string, migrationId?: string, cause?: Error);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=MigrationError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationError.d.ts","sourceRoot":"","sources":["../../src/error-handling/MigrationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,qBAAa,cAAe,SAAQ,aAAa;gBACjC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAInE"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DatabaseError } from "./DatabaseError.js";
|
|
2
|
+
/**
|
|
3
|
+
* Migration error for migration-related issues
|
|
4
|
+
*/
|
|
5
|
+
export class MigrationError extends DatabaseError {
|
|
6
|
+
constructor(message, migrationId, cause) {
|
|
7
|
+
super(message, { cause, code: 'MIGRATION_ERROR', severity: 'ERROR', constraint: migrationId ? `migration_${migrationId}` : undefined });
|
|
8
|
+
this.name = 'MigrationError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=MigrationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationError.js","sourceRoot":"","sources":["../../src/error-handling/MigrationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,aAAa;IAC7C,YAAY,OAAe,EAAE,WAAoB,EAAE,KAAa;QAC5D,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,aAAa,WAAW,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QACxI,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IACjC,CAAC;CACJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DatabaseError } from "./DatabaseError.js";
|
|
2
|
+
/**
|
|
3
|
+
* Query error for SQL execution issues
|
|
4
|
+
*/
|
|
5
|
+
export declare class QueryError extends DatabaseError {
|
|
6
|
+
constructor(message: string, query?: string, params?: any[], originalError?: Error);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=QueryError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryError.d.ts","sourceRoot":"","sources":["../../src/error-handling/QueryError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,qBAAa,UAAW,SAAQ,aAAa;gBAErC,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,GAAG,EAAE,EACd,aAAa,CAAC,EAAE,KAAK;CAK5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DatabaseError } from "./DatabaseError.js";
|
|
2
|
+
/**
|
|
3
|
+
* Query error for SQL execution issues
|
|
4
|
+
*/
|
|
5
|
+
export class QueryError extends DatabaseError {
|
|
6
|
+
constructor(message, query, params, originalError) {
|
|
7
|
+
super(message, { cause: originalError, code: 'QUERY_ERROR', severity: 'ERROR', detail: `Query error occurred${query ? ` for query: ${query}` : ''}` + (params ? ` with params: ${JSON.stringify(params)}` : '') });
|
|
8
|
+
this.name = 'QueryError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=QueryError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QueryError.js","sourceRoot":"","sources":["../../src/error-handling/QueryError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,aAAa;IACzC,YACI,OAAe,EACf,KAAc,EACd,MAAc,EACd,aAAqB;QAErB,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,uBAAuB,KAAK,CAAC,CAAC,CAAC,eAAe,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACnN,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC7B,CAAC;CACJ"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DatabaseError } from "./DatabaseError.js";
|
|
2
|
+
/**
|
|
3
|
+
* Transaction error for transaction-related issues
|
|
4
|
+
*/
|
|
5
|
+
export declare class TransactionError extends DatabaseError {
|
|
6
|
+
constructor(message: string, cause?: Error);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=TransactionError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionError.d.ts","sourceRoot":"","sources":["../../src/error-handling/TransactionError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;gBACnC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;CAI7C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DatabaseError } from "./DatabaseError.js";
|
|
2
|
+
/**
|
|
3
|
+
* Transaction error for transaction-related issues
|
|
4
|
+
*/
|
|
5
|
+
export class TransactionError extends DatabaseError {
|
|
6
|
+
constructor(message, cause) {
|
|
7
|
+
super(message, { cause });
|
|
8
|
+
this.name = 'TransactionError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=TransactionError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionError.js","sourceRoot":"","sources":["../../src/error-handling/TransactionError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAC/C,YAAY,OAAe,EAAE,KAAa;QACtC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACnC,CAAC;CACJ"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { ConnectionError } from './error-handling/ConnectionError.js';
|
|
2
|
+
import { DatabaseError } from './error-handling/DatabaseError.js';
|
|
3
|
+
import { MigrationError } from './error-handling/MigrationError.js';
|
|
4
|
+
import { QueryError } from './error-handling/QueryError.js';
|
|
5
|
+
import { TransactionError } from './error-handling/TransactionError.js';
|
|
6
|
+
import { DatabaseConfig } from './interfaces/DatabaseConfig.js';
|
|
7
|
+
/**
|
|
8
|
+
* Core database client interface that all database implementations must follow.
|
|
9
|
+
* This ensures consistency between PostgreSQL, MySQL, and future database types.
|
|
10
|
+
*/
|
|
11
|
+
export type { DatabaseClient } from './interfaces/DatabaseClient.js';
|
|
12
|
+
/**
|
|
13
|
+
* SQL adapter interface for adapting SQL queries to specific database types.
|
|
14
|
+
* This allows for consistent query handling across different databases.
|
|
15
|
+
*/
|
|
16
|
+
export type { SqlAdapter } from './interfaces/SqlAdapter.js';
|
|
17
|
+
/**
|
|
18
|
+
* Transaction interface - common methods for all database types
|
|
19
|
+
*/
|
|
20
|
+
export type { DatabaseTransaction } from './interfaces/DatabaseTransaction.js';
|
|
21
|
+
/**
|
|
22
|
+
* Alias for DatabaseTransaction (for backward compatibility)
|
|
23
|
+
*/
|
|
24
|
+
export type { DatabaseTransaction as Transaction } from './interfaces/DatabaseTransaction.js';
|
|
25
|
+
/**
|
|
26
|
+
* Database factory interface for creating database instances
|
|
27
|
+
*/
|
|
28
|
+
export type { DatabaseFactory } from './interfaces/DatabaseFactory.js';
|
|
29
|
+
/**
|
|
30
|
+
* Migration manager interface for database schema versioning
|
|
31
|
+
*/
|
|
32
|
+
export type { MigrationManager } from './interfaces/MigrationManager.js';
|
|
33
|
+
/**
|
|
34
|
+
* Configuration validation interface
|
|
35
|
+
*/
|
|
36
|
+
export type { ConfigValidator } from './interfaces/ConfigValidator.js';
|
|
37
|
+
/**
|
|
38
|
+
* Base transaction class that provides common transaction logic
|
|
39
|
+
*/
|
|
40
|
+
export { BaseTransaction } from './base/BaseTransaction.js';
|
|
41
|
+
/**
|
|
42
|
+
* Database adapter for switching between database types
|
|
43
|
+
*/
|
|
44
|
+
export { DatabaseAdapter } from './adapters/DatabaseAdapter.js';
|
|
45
|
+
export { BaseSqlAdapter } from './adapters/BaseSqlAdapter.js';
|
|
46
|
+
export type { AdapterConfig, DatabaseType } from './adapters/DatabaseAdapter.js';
|
|
47
|
+
/**
|
|
48
|
+
* Generic database configuration that can be extended by specific database types
|
|
49
|
+
*/
|
|
50
|
+
export type { DatabaseConfig } from './interfaces/DatabaseConfig.js';
|
|
51
|
+
/**
|
|
52
|
+
* Standard query result structure
|
|
53
|
+
*/
|
|
54
|
+
export type { QueryResult } from './interfaces/QueryResult.js';
|
|
55
|
+
/**
|
|
56
|
+
* Health check result
|
|
57
|
+
*/
|
|
58
|
+
export type { HealthCheckResult } from './interfaces/HealthCheckResult.js';
|
|
59
|
+
/**
|
|
60
|
+
* Migration interface
|
|
61
|
+
*/
|
|
62
|
+
export type { Migration } from './interfaces/Migration.js';
|
|
63
|
+
/**
|
|
64
|
+
* Migration status
|
|
65
|
+
*/
|
|
66
|
+
export type { MigrationStatus } from './interfaces/MigrationStatus.js';
|
|
67
|
+
/**
|
|
68
|
+
* Alias for MigrationStatus (for backward compatibility)
|
|
69
|
+
*/
|
|
70
|
+
export type { MigrationStatus as MigrationRecord } from './interfaces/MigrationStatus.js';
|
|
71
|
+
/**
|
|
72
|
+
* Query parameters type
|
|
73
|
+
*/
|
|
74
|
+
export type { QueryParams } from './custom-types/QueryParams.js';
|
|
75
|
+
/**
|
|
76
|
+
* Transaction callback type
|
|
77
|
+
*/
|
|
78
|
+
export type { TransactionCallback } from './custom-types/TransactionCallback.js';
|
|
79
|
+
/**
|
|
80
|
+
* Base error class for database operations
|
|
81
|
+
*/
|
|
82
|
+
export { DatabaseError } from './error-handling/DatabaseError.js';
|
|
83
|
+
/**
|
|
84
|
+
* Connection error specifically for connection-related issues
|
|
85
|
+
*/
|
|
86
|
+
export { ConnectionError } from './error-handling/ConnectionError.js';
|
|
87
|
+
/**
|
|
88
|
+
* Query error for SQL execution issues
|
|
89
|
+
*/
|
|
90
|
+
export { QueryError } from './error-handling/QueryError.js';
|
|
91
|
+
/**
|
|
92
|
+
* Transaction error for transaction-related issues
|
|
93
|
+
*/
|
|
94
|
+
export { TransactionError } from './error-handling/TransactionError.js';
|
|
95
|
+
/**
|
|
96
|
+
* Migration error for migration-related issues
|
|
97
|
+
*/
|
|
98
|
+
export { MigrationError } from './error-handling/MigrationError.js';
|
|
99
|
+
/**
|
|
100
|
+
* Type guards for error checking
|
|
101
|
+
*/
|
|
102
|
+
export declare const isDatabaseError: (error: any) => error is DatabaseError;
|
|
103
|
+
export declare const isConnectionError: (error: any) => error is ConnectionError;
|
|
104
|
+
export declare const isQueryError: (error: any) => error is QueryError;
|
|
105
|
+
export declare const isTransactionError: (error: any) => error is TransactionError;
|
|
106
|
+
export declare const isMigrationError: (error: any) => error is MigrationError;
|
|
107
|
+
/**
|
|
108
|
+
* Validation helper for database configuration
|
|
109
|
+
*/
|
|
110
|
+
export declare const validateDatabaseConfig: (config: any) => config is DatabaseConfig;
|
|
111
|
+
/**
|
|
112
|
+
* Helper to create a connection key for caching
|
|
113
|
+
*/
|
|
114
|
+
export declare const createConnectionKey: (config: DatabaseConfig) => string;
|
|
115
|
+
/**
|
|
116
|
+
* Helper to sanitize config for logging (removes password)
|
|
117
|
+
*/
|
|
118
|
+
export declare const sanitizeConfigForLogging: (config: DatabaseConfig) => Partial<DatabaseConfig>;
|
|
119
|
+
/**
|
|
120
|
+
* Default pool configuration
|
|
121
|
+
*/
|
|
122
|
+
export declare const DEFAULT_POOL_CONFIG: {
|
|
123
|
+
readonly max: 10;
|
|
124
|
+
readonly min: 2;
|
|
125
|
+
readonly connectionTimeoutMillis: 60000;
|
|
126
|
+
readonly idleTimeoutMillis: 30000;
|
|
127
|
+
readonly acquireTimeout: 60000;
|
|
128
|
+
readonly timeout: 60000;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Migration file pattern
|
|
132
|
+
*/
|
|
133
|
+
export declare const MIGRATION_FILE_PATTERN: RegExp;
|
|
134
|
+
/**
|
|
135
|
+
* Supported database types
|
|
136
|
+
*/
|
|
137
|
+
export type SupportedDatabases = 'postgresql' | 'mysql';
|
|
138
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAMhE;;;GAGG;AACH,YAAY,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE;;;GAGG;AACH,YAAY,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;GAEG;AACH,YAAY,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE/E;;GAEG;AACH,YAAY,EAAE,mBAAmB,IAAI,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAE9F;;GAEG;AACH,YAAY,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAEvE;;GAEG;AACH,YAAY,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AI,OAAO,GAAG,KAAG,KAAK,IAAI,aAErD,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,eAEvD,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,UAElD,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,gBAExD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,cAEtD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,GAAG,KAAG,MAAM,IAAI,cAS9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,cAAc,KAAG,MAE5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,GAAI,QAAQ,cAAc,KAAG,OAAO,CAAC,cAAc,CAGvF,CAAC;AAMF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;CAOtB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAAwB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,OAAO,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Central export file for all shared database interfaces, types, and utilities
|
|
2
|
+
import { ConnectionError } from './error-handling/ConnectionError.js';
|
|
3
|
+
import { DatabaseError } from './error-handling/DatabaseError.js';
|
|
4
|
+
import { MigrationError } from './error-handling/MigrationError.js';
|
|
5
|
+
import { QueryError } from './error-handling/QueryError.js';
|
|
6
|
+
import { TransactionError } from './error-handling/TransactionError.js';
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// BASE CLASSES (exported as classes for inheritance)
|
|
9
|
+
// ============================================================================
|
|
10
|
+
/**
|
|
11
|
+
* Base transaction class that provides common transaction logic
|
|
12
|
+
*/
|
|
13
|
+
export { BaseTransaction } from './base/BaseTransaction.js';
|
|
14
|
+
/**
|
|
15
|
+
* Database adapter for switching between database types
|
|
16
|
+
*/
|
|
17
|
+
export { DatabaseAdapter } from './adapters/DatabaseAdapter.js';
|
|
18
|
+
export { BaseSqlAdapter } from './adapters/BaseSqlAdapter.js';
|
|
19
|
+
// ============================================================================
|
|
20
|
+
// ERROR CLASSES
|
|
21
|
+
// ============================================================================
|
|
22
|
+
/**
|
|
23
|
+
* Base error class for database operations
|
|
24
|
+
*/
|
|
25
|
+
export { DatabaseError } from './error-handling/DatabaseError.js';
|
|
26
|
+
/**
|
|
27
|
+
* Connection error specifically for connection-related issues
|
|
28
|
+
*/
|
|
29
|
+
export { ConnectionError } from './error-handling/ConnectionError.js';
|
|
30
|
+
/**
|
|
31
|
+
* Query error for SQL execution issues
|
|
32
|
+
*/
|
|
33
|
+
export { QueryError } from './error-handling/QueryError.js';
|
|
34
|
+
/**
|
|
35
|
+
* Transaction error for transaction-related issues
|
|
36
|
+
*/
|
|
37
|
+
export { TransactionError } from './error-handling/TransactionError.js';
|
|
38
|
+
/**
|
|
39
|
+
* Migration error for migration-related issues
|
|
40
|
+
*/
|
|
41
|
+
export { MigrationError } from './error-handling/MigrationError.js';
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// UTILITY FUNCTIONS
|
|
44
|
+
// ============================================================================
|
|
45
|
+
/**
|
|
46
|
+
* Type guards for error checking
|
|
47
|
+
*/
|
|
48
|
+
export const isDatabaseError = (error) => {
|
|
49
|
+
return error instanceof DatabaseError;
|
|
50
|
+
};
|
|
51
|
+
export const isConnectionError = (error) => {
|
|
52
|
+
return error instanceof ConnectionError;
|
|
53
|
+
};
|
|
54
|
+
export const isQueryError = (error) => {
|
|
55
|
+
return error instanceof QueryError;
|
|
56
|
+
};
|
|
57
|
+
export const isTransactionError = (error) => {
|
|
58
|
+
return error instanceof TransactionError;
|
|
59
|
+
};
|
|
60
|
+
export const isMigrationError = (error) => {
|
|
61
|
+
return error instanceof MigrationError;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Validation helper for database configuration
|
|
65
|
+
*/
|
|
66
|
+
export const validateDatabaseConfig = (config) => {
|
|
67
|
+
return !!(config &&
|
|
68
|
+
typeof config.host === 'string' &&
|
|
69
|
+
typeof config.port === 'number' &&
|
|
70
|
+
typeof config.database === 'string' &&
|
|
71
|
+
typeof config.user === 'string' &&
|
|
72
|
+
typeof config.password === 'string');
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Helper to create a connection key for caching
|
|
76
|
+
*/
|
|
77
|
+
export const createConnectionKey = (config) => {
|
|
78
|
+
return `${config.host}:${config.port}:${config.database}:${config.user}`;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Helper to sanitize config for logging (removes password)
|
|
82
|
+
*/
|
|
83
|
+
export const sanitizeConfigForLogging = (config) => {
|
|
84
|
+
const { password, ...sanitized } = config;
|
|
85
|
+
return sanitized;
|
|
86
|
+
};
|
|
87
|
+
// ============================================================================
|
|
88
|
+
// CONSTANTS & DEFAULTS
|
|
89
|
+
// ============================================================================
|
|
90
|
+
/**
|
|
91
|
+
* Default pool configuration
|
|
92
|
+
*/
|
|
93
|
+
export const DEFAULT_POOL_CONFIG = {
|
|
94
|
+
max: 10,
|
|
95
|
+
min: 2,
|
|
96
|
+
connectionTimeoutMillis: 60000,
|
|
97
|
+
idleTimeoutMillis: 30000,
|
|
98
|
+
acquireTimeout: 60000,
|
|
99
|
+
timeout: 60000
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Migration file pattern
|
|
103
|
+
*/
|
|
104
|
+
export const MIGRATION_FILE_PATTERN = /^(\d{3})_(.+)\.sql$/;
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,+EAA+E;AAE/E,OAAO,EAAE,eAAe,EAAE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OAAO,EAAE,KAAK;CACR,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DatabaseConfig } from "./DatabaseConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* Configuration validation interface
|
|
4
|
+
*/
|
|
5
|
+
export interface ConfigValidator {
|
|
6
|
+
validate(config: DatabaseConfig): void;
|
|
7
|
+
getRequiredFields(): string[];
|
|
8
|
+
getOptionalFields(): string[];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ConfigValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigValidator.d.ts","sourceRoot":"","sources":["../../src/interfaces/ConfigValidator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IACvC,iBAAiB,IAAI,MAAM,EAAE,CAAC;IAC9B,iBAAiB,IAAI,MAAM,EAAE,CAAC;CACjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfigValidator.js","sourceRoot":"","sources":["../../src/interfaces/ConfigValidator.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HealthCheckResult } from "./HealthCheckResult.js";
|
|
2
|
+
import { QueryResult } from './QueryResult.js';
|
|
3
|
+
import { DatabaseTransaction } from './DatabaseTransaction.js';
|
|
4
|
+
export interface DatabaseClient {
|
|
5
|
+
initialize(): Promise<void>;
|
|
6
|
+
close(): Promise<void>;
|
|
7
|
+
query<T>(sql: string, params?: any[]): Promise<QueryResult<T>>;
|
|
8
|
+
transaction<T>(callback: (tx: DatabaseTransaction) => Promise<T>): Promise<T>;
|
|
9
|
+
getDatabaseType(): 'postgresql' | 'mysql';
|
|
10
|
+
supportsReturning(): boolean;
|
|
11
|
+
healthCheck(): Promise<HealthCheckResult>;
|
|
12
|
+
getConnectionInfo?(): {
|
|
13
|
+
total: number;
|
|
14
|
+
idle: number;
|
|
15
|
+
waiting: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=DatabaseClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseClient.d.ts","sourceRoot":"","sources":["../../src/interfaces/DatabaseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,MAAM,WAAW,cAAc;IAE3B,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IAG/D,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,EAAE,mBAAmB,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;IAG9E,eAAe,IAAI,YAAY,GAAG,OAAO,CAAC;IAC1C,iBAAiB,IAAI,OAAO,CAAC;IAG7B,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE1C,iBAAiB,CAAC,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseClient.js","sourceRoot":"","sources":["../../src/interfaces/DatabaseClient.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic database configuration that can be extended by specific database types
|
|
3
|
+
*/
|
|
4
|
+
export interface DatabaseConfig {
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
database: string;
|
|
8
|
+
user: string;
|
|
9
|
+
password: string;
|
|
10
|
+
ssl?: boolean | object;
|
|
11
|
+
max?: number;
|
|
12
|
+
min?: number;
|
|
13
|
+
idleTimeoutMillis?: number;
|
|
14
|
+
connectionTimeoutMillis?: number;
|
|
15
|
+
acquireTimeoutMillis?: number;
|
|
16
|
+
createTimeoutMillis?: number;
|
|
17
|
+
destroyTimeoutMillis?: number;
|
|
18
|
+
reapIntervalMillis?: number;
|
|
19
|
+
createRetryIntervalMillis?: number;
|
|
20
|
+
[key: string]: any;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=DatabaseConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseConfig.d.ts","sourceRoot":"","sources":["../../src/interfaces/DatabaseConfig.ts"],"names":[],"mappings":"AACA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,yBAAyB,CAAC,EAAE,MAAM,CAAC;IAEnC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseConfig.js","sourceRoot":"","sources":["../../src/interfaces/DatabaseConfig.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Logger } from "@groundbrick/logger";
|
|
2
|
+
import { DatabaseConfig, DatabaseClient } from "./index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Database factory interface for creating database instances
|
|
5
|
+
*/
|
|
6
|
+
export interface DatabaseFactory {
|
|
7
|
+
getInstance(config: DatabaseConfig, logger?: Logger): DatabaseClient;
|
|
8
|
+
closeInstance?(): Promise<void>;
|
|
9
|
+
closeInstance?(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=DatabaseFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseFactory.d.ts","sourceRoot":"","sources":["../../src/interfaces/DatabaseFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG5D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,WAAW,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;IACrE,aAAa,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,aAAa,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DatabaseFactory.js","sourceRoot":"","sources":["../../src/interfaces/DatabaseFactory.ts"],"names":[],"mappings":""}
|