@bernierllc/database-adapter-core 1.0.0

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 (68) hide show
  1. package/README.md +467 -0
  2. package/dist/base/BaseDatabaseAdapter.d.ts +34 -0
  3. package/dist/base/BaseDatabaseAdapter.d.ts.map +1 -0
  4. package/dist/base/BaseDatabaseAdapter.js +52 -0
  5. package/dist/base/BaseMigrationManager.d.ts +41 -0
  6. package/dist/base/BaseMigrationManager.d.ts.map +1 -0
  7. package/dist/base/BaseMigrationManager.js +113 -0
  8. package/dist/base/BaseQueryBuilder.d.ts +68 -0
  9. package/dist/base/BaseQueryBuilder.d.ts.map +1 -0
  10. package/dist/base/BaseQueryBuilder.js +103 -0
  11. package/dist/base/BaseTransaction.d.ts +13 -0
  12. package/dist/base/BaseTransaction.d.ts.map +1 -0
  13. package/dist/base/BaseTransaction.js +17 -0
  14. package/dist/base/index.d.ts +5 -0
  15. package/dist/base/index.d.ts.map +1 -0
  16. package/dist/base/index.js +27 -0
  17. package/dist/errors/ConnectionError.d.ts +17 -0
  18. package/dist/errors/ConnectionError.d.ts.map +1 -0
  19. package/dist/errors/ConnectionError.js +27 -0
  20. package/dist/errors/DatabaseError.d.ts +16 -0
  21. package/dist/errors/DatabaseError.d.ts.map +1 -0
  22. package/dist/errors/DatabaseError.js +27 -0
  23. package/dist/errors/QueryError.d.ts +17 -0
  24. package/dist/errors/QueryError.d.ts.map +1 -0
  25. package/dist/errors/QueryError.js +27 -0
  26. package/dist/errors/index.d.ts +4 -0
  27. package/dist/errors/index.d.ts.map +1 -0
  28. package/dist/errors/index.js +26 -0
  29. package/dist/index.d.ts +11 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +37 -0
  32. package/dist/interfaces/IConnectionPool.d.ts +41 -0
  33. package/dist/interfaces/IConnectionPool.d.ts.map +1 -0
  34. package/dist/interfaces/IConnectionPool.js +9 -0
  35. package/dist/interfaces/IDatabaseAdapter.d.ts +45 -0
  36. package/dist/interfaces/IDatabaseAdapter.d.ts.map +1 -0
  37. package/dist/interfaces/IDatabaseAdapter.js +9 -0
  38. package/dist/interfaces/IDatabaseConfig.d.ts +40 -0
  39. package/dist/interfaces/IDatabaseConfig.d.ts.map +1 -0
  40. package/dist/interfaces/IDatabaseConfig.js +9 -0
  41. package/dist/interfaces/IDatabaseHealth.d.ts +16 -0
  42. package/dist/interfaces/IDatabaseHealth.d.ts.map +1 -0
  43. package/dist/interfaces/IDatabaseHealth.js +9 -0
  44. package/dist/interfaces/IMigration.d.ts +54 -0
  45. package/dist/interfaces/IMigration.d.ts.map +1 -0
  46. package/dist/interfaces/IMigration.js +9 -0
  47. package/dist/interfaces/IQueryBuilder.d.ts +106 -0
  48. package/dist/interfaces/IQueryBuilder.d.ts.map +1 -0
  49. package/dist/interfaces/IQueryBuilder.js +9 -0
  50. package/dist/interfaces/IQueryResult.d.ts +28 -0
  51. package/dist/interfaces/IQueryResult.d.ts.map +1 -0
  52. package/dist/interfaces/IQueryResult.js +9 -0
  53. package/dist/interfaces/IRLSContext.d.ts +15 -0
  54. package/dist/interfaces/IRLSContext.d.ts.map +1 -0
  55. package/dist/interfaces/IRLSContext.js +9 -0
  56. package/dist/interfaces/ITransaction.d.ts +32 -0
  57. package/dist/interfaces/ITransaction.d.ts.map +1 -0
  58. package/dist/interfaces/ITransaction.js +9 -0
  59. package/dist/interfaces/index.d.ts +10 -0
  60. package/dist/interfaces/index.d.ts.map +1 -0
  61. package/dist/interfaces/index.js +32 -0
  62. package/dist/rls/RLSContextManager.d.ts +45 -0
  63. package/dist/rls/RLSContextManager.d.ts.map +1 -0
  64. package/dist/rls/RLSContextManager.js +88 -0
  65. package/dist/rls/index.d.ts +2 -0
  66. package/dist/rls/index.d.ts.map +1 -0
  67. package/dist/rls/index.js +24 -0
  68. package/package.json +55 -0
@@ -0,0 +1,45 @@
1
+ import { ITransaction } from './ITransaction';
2
+ import { IQueryResult } from './IQueryResult';
3
+ import { IDatabaseHealth } from './IDatabaseHealth';
4
+ /**
5
+ * Abstract database adapter interface
6
+ * All concrete database adapters MUST implement this interface
7
+ */
8
+ export interface IDatabaseAdapter {
9
+ /**
10
+ * Connect to database
11
+ * @throws ConnectionError if connection fails
12
+ */
13
+ connect(): Promise<void>;
14
+ /**
15
+ * Disconnect from database
16
+ * @throws Error if disconnection fails
17
+ */
18
+ disconnect(): Promise<void>;
19
+ /**
20
+ * Check if database is connected
21
+ * @returns true if connected
22
+ */
23
+ isConnected(): boolean;
24
+ /**
25
+ * Begin a new transaction
26
+ * @returns Transaction instance
27
+ * @throws Error if not connected or transaction creation fails
28
+ */
29
+ beginTransaction(): Promise<ITransaction>;
30
+ /**
31
+ * Execute a query
32
+ * @template T - Type of rows returned
33
+ * @param sql - SQL query string
34
+ * @param params - Query parameters
35
+ * @returns Query result with rows and metadata
36
+ * @throws QueryError if query fails
37
+ */
38
+ query<T = any>(sql: string, params?: any[]): Promise<IQueryResult<T>>;
39
+ /**
40
+ * Check database health
41
+ * @returns Health status including connection state, latency, and version
42
+ */
43
+ healthCheck(): Promise<IDatabaseHealth>;
44
+ }
45
+ //# sourceMappingURL=IDatabaseAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IDatabaseAdapter.d.ts","sourceRoot":"","sources":["../../src/interfaces/IDatabaseAdapter.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB;;;OAGG;IACH,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5B;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;;;OAIG;IACH,gBAAgB,IAAI,OAAO,CAAC,YAAY,CAAC,CAAC;IAE1C;;;;;;;OAOG;IACH,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtE;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC,eAAe,CAAC,CAAC;CACzC"}
@@ -0,0 +1,9 @@
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 });
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Database connection configuration
3
+ */
4
+ export interface IDatabaseConfig {
5
+ /** Database type */
6
+ type: 'postgresql' | 'mysql' | 'sqlite' | 'mssql';
7
+ /** Host address (not required for SQLite) */
8
+ host?: string;
9
+ /** Port number (not required for SQLite) */
10
+ port?: number;
11
+ /** Database name or file path (for SQLite) */
12
+ database: string;
13
+ /** Username for authentication */
14
+ username?: string;
15
+ /** Password for authentication */
16
+ password?: string;
17
+ /** SSL configuration */
18
+ ssl?: boolean | {
19
+ /** CA certificate */
20
+ ca?: string;
21
+ /** Client certificate */
22
+ cert?: string;
23
+ /** Client key */
24
+ key?: string;
25
+ };
26
+ /** Connection pooling configuration */
27
+ pooling?: {
28
+ /** Minimum number of connections in pool */
29
+ min: number;
30
+ /** Maximum number of connections in pool */
31
+ max: number;
32
+ /** Time in ms before idle connection is closed */
33
+ idleTimeoutMs: number;
34
+ };
35
+ /** Connection timeout in milliseconds */
36
+ connectionTimeoutMs?: number;
37
+ /** Query timeout in milliseconds */
38
+ queryTimeoutMs?: number;
39
+ }
40
+ //# sourceMappingURL=IDatabaseConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IDatabaseConfig.d.ts","sourceRoot":"","sources":["../../src/interfaces/IDatabaseConfig.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oBAAoB;IACpB,IAAI,EAAE,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IAElD,6CAA6C;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,8CAA8C;IAC9C,QAAQ,EAAE,MAAM,CAAC;IAEjB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,kCAAkC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,wBAAwB;IACxB,GAAG,CAAC,EAAE,OAAO,GAAG;QACd,qBAAqB;QACrB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,yBAAyB;QACzB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,iBAAiB;QACjB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IAEF,uCAAuC;IACvC,OAAO,CAAC,EAAE;QACR,4CAA4C;QAC5C,GAAG,EAAE,MAAM,CAAC;QACZ,4CAA4C;QAC5C,GAAG,EAAE,MAAM,CAAC;QACZ,kDAAkD;QAClD,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IAEF,yCAAyC;IACzC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,oCAAoC;IACpC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,9 @@
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 });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Database health status information
3
+ */
4
+ export interface IDatabaseHealth {
5
+ /** Whether database is connected */
6
+ connected: boolean;
7
+ /** Query latency in milliseconds */
8
+ latencyMs: number;
9
+ /** Database version string */
10
+ version: string;
11
+ /** Number of active connections (optional) */
12
+ activeConnections?: number;
13
+ /** Maximum allowed connections (optional) */
14
+ maxConnections?: number;
15
+ }
16
+ //# sourceMappingURL=IDatabaseHealth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IDatabaseHealth.d.ts","sourceRoot":"","sources":["../../src/interfaces/IDatabaseHealth.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oCAAoC;IACpC,SAAS,EAAE,OAAO,CAAC;IAEnB,oCAAoC;IACpC,SAAS,EAAE,MAAM,CAAC;IAElB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAC;IAEhB,8CAA8C;IAC9C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,6CAA6C;IAC7C,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
@@ -0,0 +1,9 @@
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 });
@@ -0,0 +1,54 @@
1
+ import { IDatabaseAdapter } from './IDatabaseAdapter';
2
+ /**
3
+ * Database migration interface
4
+ */
5
+ export interface IMigration {
6
+ /** Unique migration identifier */
7
+ id: string;
8
+ /** Human-readable migration name */
9
+ name: string;
10
+ /**
11
+ * Apply migration (upgrade schema)
12
+ * @param adapter - Database adapter to use
13
+ */
14
+ up(adapter: IDatabaseAdapter): Promise<void>;
15
+ /**
16
+ * Revert migration (downgrade schema)
17
+ * @param adapter - Database adapter to use
18
+ */
19
+ down(adapter: IDatabaseAdapter): Promise<void>;
20
+ }
21
+ /**
22
+ * Migration status information
23
+ */
24
+ export interface IMigrationStatus {
25
+ /** Migration ID */
26
+ id: string;
27
+ /** Migration name */
28
+ name: string;
29
+ /** When migration was applied (null if not applied) */
30
+ appliedAt: Date | null;
31
+ /** Migration status */
32
+ status: 'pending' | 'applied' | 'failed';
33
+ }
34
+ /**
35
+ * Migration manager interface
36
+ */
37
+ export interface IMigrationManager {
38
+ /**
39
+ * Run all pending migrations
40
+ * @throws Error if any migration fails
41
+ */
42
+ up(): Promise<void>;
43
+ /**
44
+ * Rollback last applied migration
45
+ * @throws Error if no migrations to rollback or rollback fails
46
+ */
47
+ down(): Promise<void>;
48
+ /**
49
+ * Get status of all migrations
50
+ * @returns Array of migration statuses
51
+ */
52
+ status(): Promise<IMigrationStatus[]>;
53
+ }
54
+ //# sourceMappingURL=IMigration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IMigration.d.ts","sourceRoot":"","sources":["../../src/interfaces/IMigration.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IAEX,oCAAoC;IACpC,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,EAAE,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE7C;;;OAGG;IACH,IAAI,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mBAAmB;IACnB,EAAE,EAAE,MAAM,CAAC;IAEX,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IAEb,uDAAuD;IACvD,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IAEvB,uBAAuB;IACvB,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;OAGG;IACH,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpB;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEtB;;;OAGG;IACH,MAAM,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC;CACvC"}
@@ -0,0 +1,9 @@
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 });
@@ -0,0 +1,106 @@
1
+ import { IDatabaseAdapter } from './IDatabaseAdapter';
2
+ import { IQueryResult } from './IQueryResult';
3
+ /**
4
+ * Abstract query builder interface
5
+ * Enables type-safe SQL generation without string concatenation
6
+ * @template T - Type of entity being queried
7
+ */
8
+ export interface IQueryBuilder<T = any> {
9
+ /**
10
+ * Select specific columns
11
+ * @param columns - Column names to select
12
+ * @returns Query builder for chaining
13
+ */
14
+ select(...columns: string[]): IQueryBuilder<T>;
15
+ /**
16
+ * Specify table to query from
17
+ * @param table - Table name
18
+ * @returns Query builder for chaining
19
+ */
20
+ from(table: string): IQueryBuilder<T>;
21
+ /**
22
+ * Add WHERE condition
23
+ * @param condition - SQL condition string
24
+ * @param params - Parameters for parameterized query
25
+ * @returns Query builder for chaining
26
+ */
27
+ where(condition: string, params?: any[]): IQueryBuilder<T>;
28
+ /**
29
+ * Add WHERE IN condition
30
+ * @param column - Column name
31
+ * @param values - Array of values for IN clause
32
+ * @returns Query builder for chaining
33
+ */
34
+ whereIn(column: string, values: any[]): IQueryBuilder<T>;
35
+ /**
36
+ * Add ORDER BY clause
37
+ * @param column - Column to order by
38
+ * @param direction - Sort direction (default: ASC)
39
+ * @returns Query builder for chaining
40
+ */
41
+ orderBy(column: string, direction?: 'ASC' | 'DESC'): IQueryBuilder<T>;
42
+ /**
43
+ * Limit number of results
44
+ * @param count - Maximum number of rows
45
+ * @returns Query builder for chaining
46
+ */
47
+ limit(count: number): IQueryBuilder<T>;
48
+ /**
49
+ * Offset results (skip rows)
50
+ * @param count - Number of rows to skip
51
+ * @returns Query builder for chaining
52
+ */
53
+ offset(count: number): IQueryBuilder<T>;
54
+ /**
55
+ * Add INNER JOIN
56
+ * @param table - Table to join
57
+ * @param condition - Join condition
58
+ * @returns Query builder for chaining
59
+ */
60
+ join(table: string, condition: string): IQueryBuilder<T>;
61
+ /**
62
+ * Add LEFT JOIN
63
+ * @param table - Table to join
64
+ * @param condition - Join condition
65
+ * @returns Query builder for chaining
66
+ */
67
+ leftJoin(table: string, condition: string): IQueryBuilder<T>;
68
+ /**
69
+ * Insert single row
70
+ * @param data - Data to insert
71
+ * @returns Query builder for chaining
72
+ */
73
+ insert(data: Partial<T>): IQueryBuilder<T>;
74
+ /**
75
+ * Insert multiple rows
76
+ * @param data - Array of data to insert
77
+ * @returns Query builder for chaining
78
+ */
79
+ insertMany(data: Partial<T>[]): IQueryBuilder<T>;
80
+ /**
81
+ * Update rows
82
+ * @param data - Data to update
83
+ * @returns Query builder for chaining
84
+ */
85
+ update(data: Partial<T>): IQueryBuilder<T>;
86
+ /**
87
+ * Delete rows
88
+ * @returns Query builder for chaining
89
+ */
90
+ delete(): IQueryBuilder<T>;
91
+ /**
92
+ * Build the query
93
+ * @returns SQL string and parameters
94
+ */
95
+ build(): {
96
+ sql: string;
97
+ params: any[];
98
+ };
99
+ /**
100
+ * Execute the query
101
+ * @param adapter - Database adapter to use
102
+ * @returns Query result
103
+ */
104
+ execute(adapter: IDatabaseAdapter): Promise<IQueryResult<T>>;
105
+ }
106
+ //# sourceMappingURL=IQueryBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IQueryBuilder.d.ts","sourceRoot":"","sources":["../../src/interfaces/IQueryBuilder.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,GAAG;IACpC;;;;OAIG;IACH,MAAM,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAE/C;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAEtC;;;;;OAKG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAE3D;;;;;OAKG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAEzD;;;;;OAKG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAEtE;;;;OAIG;IACH,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAEvC;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAExC;;;;;OAKG;IACH,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAEzD;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAE7D;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAE3C;;;;OAIG;IACH,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAEjD;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAE3C;;;OAGG;IACH,MAAM,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;IAE3B;;;OAGG;IACH,KAAK,IAAI;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,EAAE,CAAA;KAAE,CAAC;IAExC;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9D"}
@@ -0,0 +1,9 @@
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 });
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Field metadata information
3
+ */
4
+ export interface IFieldInfo {
5
+ /** Field name */
6
+ name: string;
7
+ /** Database-specific type ID */
8
+ dataTypeID: number;
9
+ /** Human-readable type name (e.g., 'varchar', 'integer') */
10
+ dataTypeName: string;
11
+ /** Whether the field can contain null values */
12
+ nullable: boolean;
13
+ }
14
+ /**
15
+ * Query result with metadata
16
+ * @template T - Type of rows returned
17
+ */
18
+ export interface IQueryResult<T = any> {
19
+ /** Result rows */
20
+ rows: T[];
21
+ /** Number of rows returned */
22
+ rowCount: number;
23
+ /** Field metadata for each column */
24
+ fields: IFieldInfo[];
25
+ /** SQL command executed (e.g., SELECT, INSERT, UPDATE, DELETE) */
26
+ command: string;
27
+ }
28
+ //# sourceMappingURL=IQueryResult.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IQueryResult.d.ts","sourceRoot":"","sources":["../../src/interfaces/IQueryResult.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,YAAY,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,GAAG,GAAG;IACnC,kBAAkB;IAClB,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,qCAAqC;IACrC,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;CACjB"}
@@ -0,0 +1,9 @@
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 });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Row Level Security context
3
+ * Used for multi-tenant security and user-based access control
4
+ */
5
+ export interface IRLSContext {
6
+ /** User ID for RLS filtering */
7
+ userId: string;
8
+ /** User role (e.g., 'admin', 'user', 'guest') */
9
+ userRole: string;
10
+ /** Tenant ID for multi-tenant systems (optional) */
11
+ tenantId?: string;
12
+ /** Additional claims for fine-grained access control (optional) */
13
+ claims?: Record<string, any>;
14
+ }
15
+ //# sourceMappingURL=IRLSContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IRLSContext.d.ts","sourceRoot":"","sources":["../../src/interfaces/IRLSContext.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,gCAAgC;IAChC,MAAM,EAAE,MAAM,CAAC;IAEf,iDAAiD;IACjD,QAAQ,EAAE,MAAM,CAAC;IAEjB,oDAAoD;IACpD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B"}
@@ -0,0 +1,9 @@
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 });
@@ -0,0 +1,32 @@
1
+ import { IQueryResult } from './IQueryResult';
2
+ /**
3
+ * Transaction interface for ACID operations
4
+ */
5
+ export interface ITransaction {
6
+ /** Unique transaction identifier */
7
+ id: string;
8
+ /**
9
+ * Execute query within transaction
10
+ * @template T - Type of rows returned
11
+ * @param sql - SQL query string
12
+ * @param params - Query parameters
13
+ * @returns Query result
14
+ */
15
+ query<T = any>(sql: string, params?: any[]): Promise<IQueryResult<T>>;
16
+ /**
17
+ * Commit transaction changes
18
+ * @throws Error if transaction is not active
19
+ */
20
+ commit(): Promise<void>;
21
+ /**
22
+ * Rollback transaction changes
23
+ * @throws Error if transaction is not active
24
+ */
25
+ rollback(): Promise<void>;
26
+ /**
27
+ * Check if transaction is active
28
+ * @returns true if transaction is active
29
+ */
30
+ isActive(): boolean;
31
+ }
32
+ //# sourceMappingURL=ITransaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ITransaction.d.ts","sourceRoot":"","sources":["../../src/interfaces/ITransaction.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,EAAE,EAAE,MAAM,CAAC;IAEX;;;;;;OAMG;IACH,KAAK,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAEtE;;;OAGG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAExB;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1B;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC;CACrB"}
@@ -0,0 +1,9 @@
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 });
@@ -0,0 +1,10 @@
1
+ export * from './IDatabaseAdapter';
2
+ export * from './ITransaction';
3
+ export * from './IQueryResult';
4
+ export * from './IDatabaseConfig';
5
+ export * from './IDatabaseHealth';
6
+ export * from './IRLSContext';
7
+ export * from './IMigration';
8
+ export * from './IConnectionPool';
9
+ export * from './IQueryBuilder';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAQA,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,32 @@
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("./IDatabaseAdapter"), exports);
25
+ __exportStar(require("./ITransaction"), exports);
26
+ __exportStar(require("./IQueryResult"), exports);
27
+ __exportStar(require("./IDatabaseConfig"), exports);
28
+ __exportStar(require("./IDatabaseHealth"), exports);
29
+ __exportStar(require("./IRLSContext"), exports);
30
+ __exportStar(require("./IMigration"), exports);
31
+ __exportStar(require("./IConnectionPool"), exports);
32
+ __exportStar(require("./IQueryBuilder"), exports);
@@ -0,0 +1,45 @@
1
+ import { IRLSContext } from '../interfaces';
2
+ /**
3
+ * Row Level Security context manager
4
+ * Enables multi-tenant security and user-based access control
5
+ */
6
+ export declare class RLSContextManager {
7
+ private context;
8
+ /**
9
+ * Set RLS context for current operation
10
+ * Context is scoped to this manager instance
11
+ * @param context - RLS context to set
12
+ */
13
+ setContext(context: IRLSContext): void;
14
+ /**
15
+ * Get current RLS context
16
+ * @returns Current context or null if not set
17
+ */
18
+ getContext(): IRLSContext | null;
19
+ /**
20
+ * Clear RLS context
21
+ */
22
+ clearContext(): void;
23
+ /**
24
+ * Execute function with RLS context
25
+ * Restores previous context after execution
26
+ * @template T - Return type of function
27
+ * @param context - RLS context to use
28
+ * @param fn - Function to execute
29
+ * @returns Result of function execution
30
+ */
31
+ withContext<T>(context: IRLSContext, fn: () => Promise<T>): Promise<T>;
32
+ /**
33
+ * Generate PostgreSQL SET statements for RLS
34
+ * These statements set session variables that can be used in RLS policies
35
+ * @returns Array of SQL SET statements
36
+ */
37
+ generateRLSStatements(): string[];
38
+ /**
39
+ * Escape single quotes in values for SQL safety
40
+ * @param value - Value to escape
41
+ * @returns Escaped value
42
+ */
43
+ private escapeValue;
44
+ }
45
+ //# sourceMappingURL=RLSContextManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RLSContextManager.d.ts","sourceRoot":"","sources":["../../src/rls/RLSContextManager.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAA4B;IAE3C;;;;OAIG;IACI,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAI7C;;;OAGG;IACI,UAAU,IAAI,WAAW,GAAG,IAAI;IAIvC;;OAEG;IACI,YAAY,IAAI,IAAI;IAI3B;;;;;;;OAOG;IACU,WAAW,CAAC,CAAC,EACxB,OAAO,EAAE,WAAW,EACpB,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACnB,OAAO,CAAC,CAAC,CAAC;IAUb;;;;OAIG;IACI,qBAAqB,IAAI,MAAM,EAAE;IAyBxC;;;;OAIG;IACH,OAAO,CAAC,WAAW;CAGpB"}
@@ -0,0 +1,88 @@
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.RLSContextManager = void 0;
11
+ /**
12
+ * Row Level Security context manager
13
+ * Enables multi-tenant security and user-based access control
14
+ */
15
+ class RLSContextManager {
16
+ constructor() {
17
+ this.context = null;
18
+ }
19
+ /**
20
+ * Set RLS context for current operation
21
+ * Context is scoped to this manager instance
22
+ * @param context - RLS context to set
23
+ */
24
+ setContext(context) {
25
+ this.context = context;
26
+ }
27
+ /**
28
+ * Get current RLS context
29
+ * @returns Current context or null if not set
30
+ */
31
+ getContext() {
32
+ return this.context;
33
+ }
34
+ /**
35
+ * Clear RLS context
36
+ */
37
+ clearContext() {
38
+ this.context = null;
39
+ }
40
+ /**
41
+ * Execute function with RLS context
42
+ * Restores previous context after execution
43
+ * @template T - Return type of function
44
+ * @param context - RLS context to use
45
+ * @param fn - Function to execute
46
+ * @returns Result of function execution
47
+ */
48
+ async withContext(context, fn) {
49
+ const previous = this.context;
50
+ this.context = context;
51
+ try {
52
+ return await fn();
53
+ }
54
+ finally {
55
+ this.context = previous;
56
+ }
57
+ }
58
+ /**
59
+ * Generate PostgreSQL SET statements for RLS
60
+ * These statements set session variables that can be used in RLS policies
61
+ * @returns Array of SQL SET statements
62
+ */
63
+ generateRLSStatements() {
64
+ if (!this.context) {
65
+ return [];
66
+ }
67
+ const statements = [
68
+ `SET LOCAL "app.user_id" = '${this.escapeValue(this.context.userId)}';`,
69
+ `SET LOCAL "app.user_role" = '${this.escapeValue(this.context.userRole)}';`
70
+ ];
71
+ if (this.context.tenantId) {
72
+ statements.push(`SET LOCAL "app.tenant_id" = '${this.escapeValue(this.context.tenantId)}';`);
73
+ }
74
+ if (this.context.claims) {
75
+ statements.push(`SET LOCAL "app.claims" = '${this.escapeValue(JSON.stringify(this.context.claims))}';`);
76
+ }
77
+ return statements;
78
+ }
79
+ /**
80
+ * Escape single quotes in values for SQL safety
81
+ * @param value - Value to escape
82
+ * @returns Escaped value
83
+ */
84
+ escapeValue(value) {
85
+ return value.replace(/'/g, "''");
86
+ }
87
+ }
88
+ exports.RLSContextManager = RLSContextManager;
@@ -0,0 +1,2 @@
1
+ export * from './RLSContextManager';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rls/index.ts"],"names":[],"mappings":"AAQA,cAAc,qBAAqB,CAAC"}