@bernierllc/database-adapter-core 3.0.0 → 3.0.2
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/package.json +2 -2
- package/dist/base/BaseDatabaseAdapter.d.ts +0 -34
- package/dist/base/BaseDatabaseAdapter.d.ts.map +0 -1
- package/dist/base/BaseDatabaseAdapter.js +0 -53
- package/dist/base/BaseMigrationManager.d.ts +0 -41
- package/dist/base/BaseMigrationManager.d.ts.map +0 -1
- package/dist/base/BaseMigrationManager.js +0 -115
- package/dist/base/BaseQueryBuilder.d.ts +0 -68
- package/dist/base/BaseQueryBuilder.d.ts.map +0 -1
- package/dist/base/BaseQueryBuilder.js +0 -103
- package/dist/base/BaseTransaction.d.ts +0 -13
- package/dist/base/BaseTransaction.d.ts.map +0 -1
- package/dist/base/BaseTransaction.js +0 -17
- package/dist/base/index.d.ts +0 -5
- package/dist/base/index.d.ts.map +0 -1
- package/dist/base/index.js +0 -27
- package/dist/errors.d.ts +0 -53
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -58
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -37
- package/dist/interfaces/IConnectionPool.d.ts +0 -41
- package/dist/interfaces/IConnectionPool.d.ts.map +0 -1
- package/dist/interfaces/IConnectionPool.js +0 -9
- package/dist/interfaces/IDatabaseAdapter.d.ts +0 -45
- package/dist/interfaces/IDatabaseAdapter.d.ts.map +0 -1
- package/dist/interfaces/IDatabaseAdapter.js +0 -9
- package/dist/interfaces/IDatabaseConfig.d.ts +0 -40
- package/dist/interfaces/IDatabaseConfig.d.ts.map +0 -1
- package/dist/interfaces/IDatabaseConfig.js +0 -9
- package/dist/interfaces/IDatabaseHealth.d.ts +0 -16
- package/dist/interfaces/IDatabaseHealth.d.ts.map +0 -1
- package/dist/interfaces/IDatabaseHealth.js +0 -9
- package/dist/interfaces/IMigration.d.ts +0 -54
- package/dist/interfaces/IMigration.d.ts.map +0 -1
- package/dist/interfaces/IMigration.js +0 -9
- package/dist/interfaces/IQueryBuilder.d.ts +0 -106
- package/dist/interfaces/IQueryBuilder.d.ts.map +0 -1
- package/dist/interfaces/IQueryBuilder.js +0 -9
- package/dist/interfaces/IQueryResult.d.ts +0 -28
- package/dist/interfaces/IQueryResult.d.ts.map +0 -1
- package/dist/interfaces/IQueryResult.js +0 -9
- package/dist/interfaces/IRLSContext.d.ts +0 -15
- package/dist/interfaces/IRLSContext.d.ts.map +0 -1
- package/dist/interfaces/IRLSContext.js +0 -9
- package/dist/interfaces/ITransaction.d.ts +0 -50
- package/dist/interfaces/ITransaction.d.ts.map +0 -1
- package/dist/interfaces/ITransaction.js +0 -9
- package/dist/interfaces/index.d.ts +0 -10
- package/dist/interfaces/index.d.ts.map +0 -1
- package/dist/interfaces/index.js +0 -32
- package/dist/rls/RLSContextManager.d.ts +0 -45
- package/dist/rls/RLSContextManager.d.ts.map +0 -1
- package/dist/rls/RLSContextManager.js +0 -86
- package/dist/rls/index.d.ts +0 -2
- package/dist/rls/index.d.ts.map +0 -1
- package/dist/rls/index.js +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bernierllc/database-adapter-core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "Abstract Database Interface for MECE Architecture - provides database-agnostic interfaces and base implementations for all database operations",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "UNLICENSED",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@bernierllc/crypto-utils": "1.4.0",
|
|
23
|
-
"@bernierllc/logger": "
|
|
23
|
+
"@bernierllc/logger": "2.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/jest": "^29.5.0",
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { IDatabaseAdapter, IDatabaseConfig, IDatabaseHealth, IQueryResult, ITransaction } from '../interfaces';
|
|
2
|
-
/**
|
|
3
|
-
* Abstract base class for database adapters
|
|
4
|
-
* Provides common functionality for all implementations
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class BaseDatabaseAdapter implements IDatabaseAdapter {
|
|
7
|
-
protected config: IDatabaseConfig;
|
|
8
|
-
protected connected: boolean;
|
|
9
|
-
constructor(config: IDatabaseConfig);
|
|
10
|
-
/**
|
|
11
|
-
* Abstract methods - MUST be implemented by concrete adapters
|
|
12
|
-
*/
|
|
13
|
-
abstract connect(): Promise<void>;
|
|
14
|
-
abstract disconnect(): Promise<void>;
|
|
15
|
-
abstract query<T = any>(sql: string, params?: any[]): Promise<IQueryResult<T>>;
|
|
16
|
-
abstract beginTransaction(): Promise<ITransaction>;
|
|
17
|
-
abstract healthCheck(): Promise<IDatabaseHealth>;
|
|
18
|
-
/**
|
|
19
|
-
* Check if database is connected
|
|
20
|
-
*/
|
|
21
|
-
isConnected(): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Ensure database is connected before operations
|
|
24
|
-
* @throws ConnectionError if not connected
|
|
25
|
-
*/
|
|
26
|
-
protected ensureConnected(): void;
|
|
27
|
-
/**
|
|
28
|
-
* Sanitize error messages to remove sensitive data
|
|
29
|
-
* @param error - Original error
|
|
30
|
-
* @returns Sanitized error
|
|
31
|
-
*/
|
|
32
|
-
protected sanitizeError(error: unknown): Error;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=BaseDatabaseAdapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseDatabaseAdapter.d.ts","sourceRoot":"","sources":["../../src/base/BaseDatabaseAdapter.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,YAAY,EACb,MAAM,eAAe,CAAC;AAGvB;;;GAGG;AACH,8BAAsB,mBAAoB,YAAW,gBAAgB;IACnE,SAAS,CAAC,MAAM,EAAE,eAAe,CAAC;IAClC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAS;gBAEzB,MAAM,EAAE,eAAe;IAInC;;OAEG;IACH,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IACjC,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC9E,QAAQ,CAAC,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC;IAClD,QAAQ,CAAC,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC;IAEhD;;OAEG;IACI,WAAW,IAAI,OAAO;IAI7B;;;OAGG;IACH,SAAS,CAAC,eAAe,IAAI,IAAI;IASjC;;;;OAIG;IACH,SAAS,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK;CAa/C"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2025 Bernier LLC
|
|
4
|
-
|
|
5
|
-
This file is licensed to the client under a limited-use license.
|
|
6
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.BaseDatabaseAdapter = void 0;
|
|
11
|
-
const errors_1 = require("../errors");
|
|
12
|
-
/**
|
|
13
|
-
* Abstract base class for database adapters
|
|
14
|
-
* Provides common functionality for all implementations
|
|
15
|
-
*/
|
|
16
|
-
class BaseDatabaseAdapter {
|
|
17
|
-
config;
|
|
18
|
-
connected = false;
|
|
19
|
-
constructor(config) {
|
|
20
|
-
this.config = config;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Check if database is connected
|
|
24
|
-
*/
|
|
25
|
-
isConnected() {
|
|
26
|
-
return this.connected;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Ensure database is connected before operations
|
|
30
|
-
* @throws ConnectionError if not connected
|
|
31
|
-
*/
|
|
32
|
-
ensureConnected() {
|
|
33
|
-
if (!this.connected) {
|
|
34
|
-
throw new errors_1.ConnectionError('Database not connected. Call connect() first.', { context: { code: 'NOT_CONNECTED' } });
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Sanitize error messages to remove sensitive data
|
|
39
|
-
* @param error - Original error
|
|
40
|
-
* @returns Sanitized error
|
|
41
|
-
*/
|
|
42
|
-
sanitizeError(error) {
|
|
43
|
-
const message = error instanceof Error ? error.message : 'Database error';
|
|
44
|
-
// Remove sensitive data patterns from error messages
|
|
45
|
-
const sanitized = message
|
|
46
|
-
.replace(/password[^\s]*/gi, 'password=***')
|
|
47
|
-
.replace(/secret[^\s]*/gi, 'secret=***')
|
|
48
|
-
.replace(/token[^\s]*/gi, 'token=***')
|
|
49
|
-
.replace(/key[^\s]*/gi, 'key=***');
|
|
50
|
-
return new Error(sanitized);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.BaseDatabaseAdapter = BaseDatabaseAdapter;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { IDatabaseAdapter, IMigration, IMigrationManager, IMigrationStatus } from '../interfaces';
|
|
2
|
-
/**
|
|
3
|
-
* Base migration manager implementation
|
|
4
|
-
* Tracks and executes schema migrations
|
|
5
|
-
*/
|
|
6
|
-
export declare class BaseMigrationManager implements IMigrationManager {
|
|
7
|
-
private adapter;
|
|
8
|
-
private migrations;
|
|
9
|
-
constructor(adapter: IDatabaseAdapter, migrations: IMigration[]);
|
|
10
|
-
/**
|
|
11
|
-
* Run all pending migrations
|
|
12
|
-
* @throws Error if any migration fails
|
|
13
|
-
*/
|
|
14
|
-
up(): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Rollback last applied migration
|
|
17
|
-
* @throws Error if no migrations to rollback or rollback fails
|
|
18
|
-
*/
|
|
19
|
-
down(): Promise<void>;
|
|
20
|
-
/**
|
|
21
|
-
* Get status of all migrations
|
|
22
|
-
*/
|
|
23
|
-
status(): Promise<IMigrationStatus[]>;
|
|
24
|
-
/**
|
|
25
|
-
* Ensure migrations table exists
|
|
26
|
-
*/
|
|
27
|
-
private ensureMigrationsTable;
|
|
28
|
-
/**
|
|
29
|
-
* Get list of applied migration IDs in order
|
|
30
|
-
*/
|
|
31
|
-
private getAppliedMigrations;
|
|
32
|
-
/**
|
|
33
|
-
* Record a migration as applied
|
|
34
|
-
*/
|
|
35
|
-
private recordMigration;
|
|
36
|
-
/**
|
|
37
|
-
* Remove a migration record
|
|
38
|
-
*/
|
|
39
|
-
private removeMigration;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=BaseMigrationManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseMigrationManager.d.ts","sourceRoot":"","sources":["../../src/base/BaseMigrationManager.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,qBAAa,oBAAqB,YAAW,iBAAiB;IAE1D,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;gBADV,OAAO,EAAE,gBAAgB,EACzB,UAAU,EAAE,UAAU,EAAE;IAGlC;;;OAGG;IACU,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBhC;;;OAGG;IACU,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAyBlC;;OAEG;IACU,MAAM,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAYlD;;OAEG;YACW,qBAAqB;IAUnC;;OAEG;YACW,oBAAoB;IAOlC;;OAEG;YACW,eAAe;IAO7B;;OAEG;YACW,eAAe;CAG9B"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2025 Bernier LLC
|
|
4
|
-
|
|
5
|
-
This file is licensed to the client under a limited-use license.
|
|
6
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.BaseMigrationManager = void 0;
|
|
11
|
-
/**
|
|
12
|
-
* Base migration manager implementation
|
|
13
|
-
* Tracks and executes schema migrations
|
|
14
|
-
*/
|
|
15
|
-
class BaseMigrationManager {
|
|
16
|
-
adapter;
|
|
17
|
-
migrations;
|
|
18
|
-
constructor(adapter, migrations) {
|
|
19
|
-
this.adapter = adapter;
|
|
20
|
-
this.migrations = migrations;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Run all pending migrations
|
|
24
|
-
* @throws Error if any migration fails
|
|
25
|
-
*/
|
|
26
|
-
async up() {
|
|
27
|
-
await this.ensureMigrationsTable();
|
|
28
|
-
const applied = await this.getAppliedMigrations();
|
|
29
|
-
const pending = this.migrations.filter(m => !applied.includes(m.id));
|
|
30
|
-
for (const migration of pending) {
|
|
31
|
-
const transaction = await this.adapter.beginTransaction();
|
|
32
|
-
try {
|
|
33
|
-
await migration.up(this.adapter);
|
|
34
|
-
await this.recordMigration(migration.id, migration.name);
|
|
35
|
-
await transaction.commit();
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
await transaction.rollback();
|
|
39
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
40
|
-
throw new Error(`Migration ${migration.name} failed: ${message}`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Rollback last applied migration
|
|
46
|
-
* @throws Error if no migrations to rollback or rollback fails
|
|
47
|
-
*/
|
|
48
|
-
async down() {
|
|
49
|
-
const applied = await this.getAppliedMigrations();
|
|
50
|
-
if (applied.length === 0) {
|
|
51
|
-
throw new Error('No migrations to rollback');
|
|
52
|
-
}
|
|
53
|
-
const lastMigrationId = applied[applied.length - 1];
|
|
54
|
-
const migration = this.migrations.find(m => m.id === lastMigrationId);
|
|
55
|
-
if (!migration) {
|
|
56
|
-
throw new Error(`Migration ${lastMigrationId} not found`);
|
|
57
|
-
}
|
|
58
|
-
const transaction = await this.adapter.beginTransaction();
|
|
59
|
-
try {
|
|
60
|
-
await migration.down(this.adapter);
|
|
61
|
-
await this.removeMigration(migration.id);
|
|
62
|
-
await transaction.commit();
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
await transaction.rollback();
|
|
66
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
67
|
-
throw new Error(`Rollback of ${migration.name} failed: ${message}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Get status of all migrations
|
|
72
|
-
*/
|
|
73
|
-
async status() {
|
|
74
|
-
await this.ensureMigrationsTable();
|
|
75
|
-
const applied = await this.getAppliedMigrations();
|
|
76
|
-
return this.migrations.map(m => ({
|
|
77
|
-
id: m.id,
|
|
78
|
-
name: m.name,
|
|
79
|
-
appliedAt: applied.includes(m.id) ? new Date() : null,
|
|
80
|
-
status: applied.includes(m.id) ? 'applied' : 'pending'
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Ensure migrations table exists
|
|
85
|
-
*/
|
|
86
|
-
async ensureMigrationsTable() {
|
|
87
|
-
await this.adapter.query(`
|
|
88
|
-
CREATE TABLE IF NOT EXISTS migrations (
|
|
89
|
-
id VARCHAR(255) PRIMARY KEY,
|
|
90
|
-
name VARCHAR(255) NOT NULL,
|
|
91
|
-
applied_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
|
92
|
-
)
|
|
93
|
-
`);
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Get list of applied migration IDs in order
|
|
97
|
-
*/
|
|
98
|
-
async getAppliedMigrations() {
|
|
99
|
-
const result = await this.adapter.query('SELECT id FROM migrations ORDER BY applied_at ASC');
|
|
100
|
-
return result.rows.map(r => r.id);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Record a migration as applied
|
|
104
|
-
*/
|
|
105
|
-
async recordMigration(id, name) {
|
|
106
|
-
await this.adapter.query('INSERT INTO migrations (id, name) VALUES ($1, $2)', [id, name]);
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Remove a migration record
|
|
110
|
-
*/
|
|
111
|
-
async removeMigration(id) {
|
|
112
|
-
await this.adapter.query('DELETE FROM migrations WHERE id = $1', [id]);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
exports.BaseMigrationManager = BaseMigrationManager;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { IQueryBuilder, IDatabaseAdapter, IQueryResult } from '../interfaces';
|
|
2
|
-
/**
|
|
3
|
-
* Base query builder implementation
|
|
4
|
-
* Provides common functionality for all SQL dialects
|
|
5
|
-
* @template T - Type of entity being queried
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class BaseQueryBuilder<T = any> implements IQueryBuilder<T> {
|
|
8
|
-
protected _select: string[];
|
|
9
|
-
protected _from: string;
|
|
10
|
-
protected _where: string[];
|
|
11
|
-
protected _params: any[];
|
|
12
|
-
protected _orderBy: string[];
|
|
13
|
-
protected _limit?: number;
|
|
14
|
-
protected _offset?: number;
|
|
15
|
-
protected _joins: string[];
|
|
16
|
-
/**
|
|
17
|
-
* Select specific columns
|
|
18
|
-
*/
|
|
19
|
-
select(...columns: string[]): IQueryBuilder<T>;
|
|
20
|
-
/**
|
|
21
|
-
* Specify table to query from
|
|
22
|
-
*/
|
|
23
|
-
from(table: string): IQueryBuilder<T>;
|
|
24
|
-
/**
|
|
25
|
-
* Add WHERE condition with parameters
|
|
26
|
-
*/
|
|
27
|
-
where(condition: string, params?: readonly unknown[]): IQueryBuilder<T>;
|
|
28
|
-
/**
|
|
29
|
-
* Add WHERE IN condition
|
|
30
|
-
*/
|
|
31
|
-
whereIn(column: string, values: readonly unknown[]): IQueryBuilder<T>;
|
|
32
|
-
/**
|
|
33
|
-
* Add ORDER BY clause
|
|
34
|
-
*/
|
|
35
|
-
orderBy(column: string, direction?: 'ASC' | 'DESC'): IQueryBuilder<T>;
|
|
36
|
-
/**
|
|
37
|
-
* Limit number of results
|
|
38
|
-
*/
|
|
39
|
-
limit(count: number): IQueryBuilder<T>;
|
|
40
|
-
/**
|
|
41
|
-
* Offset results (skip rows)
|
|
42
|
-
*/
|
|
43
|
-
offset(count: number): IQueryBuilder<T>;
|
|
44
|
-
/**
|
|
45
|
-
* Add INNER JOIN
|
|
46
|
-
*/
|
|
47
|
-
join(table: string, condition: string): IQueryBuilder<T>;
|
|
48
|
-
/**
|
|
49
|
-
* Add LEFT JOIN
|
|
50
|
-
*/
|
|
51
|
-
leftJoin(table: string, condition: string): IQueryBuilder<T>;
|
|
52
|
-
/**
|
|
53
|
-
* Execute the query using provided adapter
|
|
54
|
-
*/
|
|
55
|
-
execute(adapter: IDatabaseAdapter): Promise<IQueryResult<T>>;
|
|
56
|
-
/**
|
|
57
|
-
* Abstract methods - MUST be implemented by dialect-specific builders
|
|
58
|
-
*/
|
|
59
|
-
abstract insert(data: Partial<T>): IQueryBuilder<T>;
|
|
60
|
-
abstract insertMany(data: Partial<T>[]): IQueryBuilder<T>;
|
|
61
|
-
abstract update(data: Partial<T>): IQueryBuilder<T>;
|
|
62
|
-
abstract delete(): IQueryBuilder<T>;
|
|
63
|
-
abstract build(): {
|
|
64
|
-
sql: string;
|
|
65
|
-
params: any[];
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=BaseQueryBuilder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseQueryBuilder.d.ts","sourceRoot":"","sources":["../../src/base/BaseQueryBuilder.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE9E;;;;GAIG;AACH,8BAAsB,gBAAgB,CAAC,CAAC,GAAG,GAAG,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IACzE,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,CAAM;IACjC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAM;IAC7B,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM;IAChC,SAAS,CAAC,OAAO,EAAE,GAAG,EAAE,CAAM;IAC9B,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAM;IAClC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,CAAM;IAEhC;;OAEG;IACI,MAAM,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC;IAKrD;;OAEG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC;IAK5C;;OAEG;IACI,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC;IAQ9E;;OAEG;IACI,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,OAAO,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC;IAS5E;;OAEG;IACI,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,KAAK,GAAG,MAAc,GAAG,aAAa,CAAC,CAAC,CAAC;IAKnF;;OAEG;IACI,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC;IAK7C;;OAEG;IACI,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC;IAK9C;;OAEG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC;IAK/D;;OAEG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC;IAKnE;;OAEG;IACU,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAKzE;;OAEG;IACH,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC;IACzD,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,MAAM,IAAI,aAAa,CAAC,CAAC,CAAC;IACnC,QAAQ,CAAC,KAAK,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,EAAE,CAAA;KAAE;CACjD"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2025 Bernier LLC
|
|
4
|
-
|
|
5
|
-
This file is licensed to the client under a limited-use license.
|
|
6
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.BaseQueryBuilder = void 0;
|
|
11
|
-
/**
|
|
12
|
-
* Base query builder implementation
|
|
13
|
-
* Provides common functionality for all SQL dialects
|
|
14
|
-
* @template T - Type of entity being queried
|
|
15
|
-
*/
|
|
16
|
-
class BaseQueryBuilder {
|
|
17
|
-
_select = [];
|
|
18
|
-
_from = '';
|
|
19
|
-
_where = [];
|
|
20
|
-
_params = [];
|
|
21
|
-
_orderBy = [];
|
|
22
|
-
_limit;
|
|
23
|
-
_offset;
|
|
24
|
-
_joins = [];
|
|
25
|
-
/**
|
|
26
|
-
* Select specific columns
|
|
27
|
-
*/
|
|
28
|
-
select(...columns) {
|
|
29
|
-
this._select.push(...columns);
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Specify table to query from
|
|
34
|
-
*/
|
|
35
|
-
from(table) {
|
|
36
|
-
this._from = table;
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Add WHERE condition with parameters
|
|
41
|
-
*/
|
|
42
|
-
where(condition, params) {
|
|
43
|
-
this._where.push(condition);
|
|
44
|
-
if (params) {
|
|
45
|
-
this._params.push(...params);
|
|
46
|
-
}
|
|
47
|
-
return this;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Add WHERE IN condition
|
|
51
|
-
*/
|
|
52
|
-
whereIn(column, values) {
|
|
53
|
-
const placeholders = values
|
|
54
|
-
.map((_, i) => `$${this._params.length + i + 1}`)
|
|
55
|
-
.join(', ');
|
|
56
|
-
this._where.push(`${column} IN (${placeholders})`);
|
|
57
|
-
this._params.push(...values);
|
|
58
|
-
return this;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Add ORDER BY clause
|
|
62
|
-
*/
|
|
63
|
-
orderBy(column, direction = 'ASC') {
|
|
64
|
-
this._orderBy.push(`${column} ${direction}`);
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Limit number of results
|
|
69
|
-
*/
|
|
70
|
-
limit(count) {
|
|
71
|
-
this._limit = count;
|
|
72
|
-
return this;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Offset results (skip rows)
|
|
76
|
-
*/
|
|
77
|
-
offset(count) {
|
|
78
|
-
this._offset = count;
|
|
79
|
-
return this;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Add INNER JOIN
|
|
83
|
-
*/
|
|
84
|
-
join(table, condition) {
|
|
85
|
-
this._joins.push(`JOIN ${table} ON ${condition}`);
|
|
86
|
-
return this;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Add LEFT JOIN
|
|
90
|
-
*/
|
|
91
|
-
leftJoin(table, condition) {
|
|
92
|
-
this._joins.push(`LEFT JOIN ${table} ON ${condition}`);
|
|
93
|
-
return this;
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Execute the query using provided adapter
|
|
97
|
-
*/
|
|
98
|
-
async execute(adapter) {
|
|
99
|
-
const { sql, params } = this.build();
|
|
100
|
-
return adapter.query(sql, params);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
exports.BaseQueryBuilder = BaseQueryBuilder;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ITransaction, IQueryResult } from '../interfaces';
|
|
2
|
-
/**
|
|
3
|
-
* Abstract transaction base class
|
|
4
|
-
* Provides base structure for transaction implementations
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class BaseTransaction implements ITransaction {
|
|
7
|
-
abstract id: string;
|
|
8
|
-
abstract query<T = any>(sql: string, params?: any[]): Promise<IQueryResult<T>>;
|
|
9
|
-
abstract commit(): Promise<void>;
|
|
10
|
-
abstract rollback(): Promise<void>;
|
|
11
|
-
abstract isActive(): boolean;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=BaseTransaction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BaseTransaction.d.ts","sourceRoot":"","sources":["../../src/base/BaseTransaction.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE3D;;;GAGG;AACH,8BAAsB,eAAgB,YAAW,YAAY;IAC3D,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAC9E,QAAQ,CAAC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAChC,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAClC,QAAQ,CAAC,QAAQ,IAAI,OAAO;CAC7B"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2025 Bernier LLC
|
|
4
|
-
|
|
5
|
-
This file is licensed to the client under a limited-use license.
|
|
6
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.BaseTransaction = void 0;
|
|
11
|
-
/**
|
|
12
|
-
* Abstract transaction base class
|
|
13
|
-
* Provides base structure for transaction implementations
|
|
14
|
-
*/
|
|
15
|
-
class BaseTransaction {
|
|
16
|
-
}
|
|
17
|
-
exports.BaseTransaction = BaseTransaction;
|
package/dist/base/index.d.ts
DELETED
package/dist/base/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":"AAQA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC"}
|
package/dist/base/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2025 Bernier LLC
|
|
4
|
-
|
|
5
|
-
This file is licensed to the client under a limited-use license.
|
|
6
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
-
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
-
}
|
|
15
|
-
Object.defineProperty(o, k2, desc);
|
|
16
|
-
}) : (function(o, m, k, k2) {
|
|
17
|
-
if (k2 === undefined) k2 = k;
|
|
18
|
-
o[k2] = m[k];
|
|
19
|
-
}));
|
|
20
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
__exportStar(require("./BaseDatabaseAdapter"), exports);
|
|
25
|
-
__exportStar(require("./BaseTransaction"), exports);
|
|
26
|
-
__exportStar(require("./BaseQueryBuilder"), exports);
|
|
27
|
-
__exportStar(require("./BaseMigrationManager"), exports);
|
package/dist/errors.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Typed error code union for database-adapter-core errors.
|
|
3
|
-
*/
|
|
4
|
-
export type DatabaseAdapterCoreErrorCode = 'DATABASE_ERROR' | 'CONNECTION_ERROR' | 'QUERY_ERROR' | 'INVALID_INPUT' | 'OPERATION_FAILED';
|
|
5
|
-
/**
|
|
6
|
-
* Options bag accepted by all database-adapter-core error classes.
|
|
7
|
-
*
|
|
8
|
-
* - `cause`: chained underlying error (ES2022 Error.cause).
|
|
9
|
-
* - `code`: a typed error code from {@link DatabaseAdapterCoreErrorCode}.
|
|
10
|
-
* - `context`: arbitrary structured context — host/port/query/params/etc.
|
|
11
|
-
*/
|
|
12
|
-
export interface DatabaseAdapterCoreErrorOptions {
|
|
13
|
-
cause?: Error;
|
|
14
|
-
code?: DatabaseAdapterCoreErrorCode;
|
|
15
|
-
context?: Record<string, unknown>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Base database error class.
|
|
19
|
-
* All database-specific errors inherit from this.
|
|
20
|
-
*
|
|
21
|
-
* Uses native ES2022 `Error.cause` for error chaining — read the underlying
|
|
22
|
-
* error via `error.cause` (not `.originalError`, which was removed in 2.0.0).
|
|
23
|
-
*/
|
|
24
|
-
export declare class DatabaseError extends Error {
|
|
25
|
-
readonly code: DatabaseAdapterCoreErrorCode;
|
|
26
|
-
readonly context?: Record<string, unknown>;
|
|
27
|
-
constructor(message: string, options?: DatabaseAdapterCoreErrorOptions);
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Connection-specific database error.
|
|
31
|
-
* Thrown when connection operations fail.
|
|
32
|
-
*
|
|
33
|
-
* Host/port and similar details should be passed via `options.context`.
|
|
34
|
-
*/
|
|
35
|
-
export declare class ConnectionError extends DatabaseError {
|
|
36
|
-
constructor(message: string, options?: Omit<DatabaseAdapterCoreErrorOptions, 'code'>);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Query-specific database error.
|
|
40
|
-
* Thrown when query execution fails.
|
|
41
|
-
*
|
|
42
|
-
* SQL/params and similar details should be passed via `options.context`.
|
|
43
|
-
*/
|
|
44
|
-
export declare class QueryError extends DatabaseError {
|
|
45
|
-
constructor(message: string, options?: Omit<DatabaseAdapterCoreErrorOptions, 'code'>);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Cross-package naming alias for {@link DatabaseError}.
|
|
49
|
-
* Useful when consuming code wants to disambiguate between several
|
|
50
|
-
* package-specific base error classes via a fully qualified name.
|
|
51
|
-
*/
|
|
52
|
-
export { DatabaseError as DatabaseAdapterCoreError };
|
|
53
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,MAAM,4BAA4B,GACpC,gBAAgB,GAChB,kBAAkB,GAClB,aAAa,GACb,eAAe,GACf,kBAAkB,CAAC;AAEvB;;;;;;GAMG;AACH,MAAM,WAAW,+BAA+B;IAC9C,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,4BAA4B,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,SAAgB,IAAI,EAAE,4BAA4B,CAAC;IACnD,SAAgB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEtC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,+BAA+B;CASvE;AAED;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,aAAa;gBAE9C,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CAAC,+BAA+B,EAAE,MAAM,CAAC;CAK1D;AAED;;;;;GAKG;AACH,qBAAa,UAAW,SAAQ,aAAa;gBAEzC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,IAAI,CAAC,+BAA+B,EAAE,MAAM,CAAC;CAK1D;AAED;;;;GAIG;AACH,OAAO,EAAE,aAAa,IAAI,wBAAwB,EAAE,CAAC"}
|
package/dist/errors.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Copyright (c) 2025 Bernier LLC
|
|
4
|
-
|
|
5
|
-
This file is licensed to the client under a limited-use license.
|
|
6
|
-
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
-
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.DatabaseAdapterCoreError = exports.QueryError = exports.ConnectionError = exports.DatabaseError = void 0;
|
|
11
|
-
/**
|
|
12
|
-
* Base database error class.
|
|
13
|
-
* All database-specific errors inherit from this.
|
|
14
|
-
*
|
|
15
|
-
* Uses native ES2022 `Error.cause` for error chaining — read the underlying
|
|
16
|
-
* error via `error.cause` (not `.originalError`, which was removed in 2.0.0).
|
|
17
|
-
*/
|
|
18
|
-
class DatabaseError extends Error {
|
|
19
|
-
code;
|
|
20
|
-
context;
|
|
21
|
-
constructor(message, options) {
|
|
22
|
-
super(message, options?.cause ? { cause: options.cause } : undefined);
|
|
23
|
-
this.name = 'DatabaseError';
|
|
24
|
-
this.code = options?.code ?? 'DATABASE_ERROR';
|
|
25
|
-
if (options?.context !== undefined) {
|
|
26
|
-
this.context = options.context;
|
|
27
|
-
}
|
|
28
|
-
Error.captureStackTrace?.(this, this.constructor);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.DatabaseError = DatabaseError;
|
|
32
|
-
exports.DatabaseAdapterCoreError = DatabaseError;
|
|
33
|
-
/**
|
|
34
|
-
* Connection-specific database error.
|
|
35
|
-
* Thrown when connection operations fail.
|
|
36
|
-
*
|
|
37
|
-
* Host/port and similar details should be passed via `options.context`.
|
|
38
|
-
*/
|
|
39
|
-
class ConnectionError extends DatabaseError {
|
|
40
|
-
constructor(message, options) {
|
|
41
|
-
super(message, { ...options, code: 'CONNECTION_ERROR' });
|
|
42
|
-
this.name = 'ConnectionError';
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.ConnectionError = ConnectionError;
|
|
46
|
-
/**
|
|
47
|
-
* Query-specific database error.
|
|
48
|
-
* Thrown when query execution fails.
|
|
49
|
-
*
|
|
50
|
-
* SQL/params and similar details should be passed via `options.context`.
|
|
51
|
-
*/
|
|
52
|
-
class QueryError extends DatabaseError {
|
|
53
|
-
constructor(message, options) {
|
|
54
|
-
super(message, { ...options, code: 'QUERY_ERROR' });
|
|
55
|
-
this.name = 'QueryError';
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
exports.QueryError = QueryError;
|
package/dist/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @bernierllc/database-adapter-core
|
|
3
|
-
*
|
|
4
|
-
* Abstract Database Interface for MECE Architecture
|
|
5
|
-
* Provides database-agnostic interfaces and base implementations for all database operations
|
|
6
|
-
*/
|
|
7
|
-
export * from './interfaces';
|
|
8
|
-
export * from './base';
|
|
9
|
-
export * from './rls';
|
|
10
|
-
export * from './errors';
|
|
11
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA;;;;;GAKG;AAGH,cAAc,cAAc,CAAC;AAG7B,cAAc,QAAQ,CAAC;AAGvB,cAAc,OAAO,CAAC;AAGtB,cAAc,UAAU,CAAC"}
|