@aetherframework/database 1.0.9
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/LICENSE +21 -0
- package/README.md +846 -0
- package/index.js +31 -0
- package/package.json +56 -0
- package/src/DatabaseManager.js +565 -0
- package/src/core/ConnectionManager.js +351 -0
- package/src/core/DatabaseFactory.js +188 -0
- package/src/core/MongoQueryBuilder.js +576 -0
- package/src/core/PluginManager.js +968 -0
- package/src/core/QueryBuilder.js +4398 -0
- package/src/core/TransactionManager.js +40 -0
- package/src/drivers/clickhouse-driver.js +272 -0
- package/src/drivers/index.js +273 -0
- package/src/drivers/mongodb-driver.js +87 -0
- package/src/drivers/mssql-driver.js +117 -0
- package/src/drivers/mysql-driver.js +169 -0
- package/src/drivers/oracle-driver.js +101 -0
- package/src/drivers/postgres-driver.js +234 -0
- package/src/drivers/redis-driver.js +52 -0
- package/src/drivers/sqlite-driver.js +67 -0
- package/src/middleware/connection-pool.js +455 -0
- package/src/middleware/performance-monitor.js +652 -0
- package/src/middleware/query-cache.js +500 -0
- package/src/middleware/query-logger.js +262 -0
- package/src/plugins/AuditPlugin.js +447 -0
- package/src/plugins/BasePlugin.js +418 -0
- package/src/plugins/BatchOperationPlugin.js +165 -0
- package/src/plugins/CachePlugin.js +407 -0
- package/src/plugins/CtePlugin.js +523 -0
- package/src/plugins/DistributedPlugin.js +543 -0
- package/src/plugins/EncryptionPlugin.js +211 -0
- package/src/plugins/FullTextSearchPlugin.js +164 -0
- package/src/plugins/GeospatialPlugin.js +219 -0
- package/src/plugins/GraphQLPlugin.js +162 -0
- package/src/plugins/HookPlugin.js +211 -0
- package/src/plugins/JsonPlugin.js +366 -0
- package/src/plugins/OptimisticLockPlugin.js +374 -0
- package/src/plugins/PerformancePlugin.js +175 -0
- package/src/plugins/ResiliencePlugin.js +114 -0
- package/src/plugins/ShardingPlugin.js +227 -0
- package/src/plugins/SoftDeletePlugin.js +258 -0
- package/src/plugins/SyncPlugin.js +373 -0
- package/src/plugins/VersioningPlugin.js +314 -0
- package/src/plugins/WindowFunctionPlugin.js +343 -0
- package/src/utils/config-loader.js +632 -0
- package/src/utils/error-handler.js +724 -0
- package/src/utils/migration-runner.js +1066 -0
- package/types.js +129 -0
package/types.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// packages/database/types.js
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {Object} DatabaseConfig
|
|
4
|
+
* @property {string} type - Database type: 'mysql', 'postgres', 'redis', 'mongodb', 'sqlite', 'mssql', 'oracle'
|
|
5
|
+
* @property {string} [host] - Host address
|
|
6
|
+
* @property {number} [port] - Port number
|
|
7
|
+
* @property {string} [user] - Username
|
|
8
|
+
* @property {string} [password] - Password
|
|
9
|
+
* @property {string} [database] - Database name
|
|
10
|
+
* @property {string} [filename] - SQLite file path
|
|
11
|
+
* @property {Object} [options] - Additional options
|
|
12
|
+
* @property {Object} [pool] - Connection pool options
|
|
13
|
+
* @property {number} [pool.min] - Minimum connections
|
|
14
|
+
* @property {number} [pool.max] - Maximum connections
|
|
15
|
+
* @property {number} [pool.idleTimeout] - Idle timeout in ms
|
|
16
|
+
* @property {number} [pool.acquireTimeout] - Acquire timeout in ms
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {Object} QueryResult
|
|
21
|
+
* @property {Array<any>} rows - Result rows
|
|
22
|
+
* @property {number} rowCount - Number of affected rows
|
|
23
|
+
* @property {any} [lastInsertId] - Last insert ID
|
|
24
|
+
* @property {Array<string>} [columns] - Column names
|
|
25
|
+
* @property {string} [commandTag] - Command tag (PostgreSQL)
|
|
26
|
+
* @property {bigint} [cursorId] - Cursor ID (MongoDB)
|
|
27
|
+
* @property {number} [numberReturned] - Number returned (MongoDB)
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {Object} Connection
|
|
32
|
+
* @property {boolean} connected - Connection status
|
|
33
|
+
* @property {function(string, Array): Promise<QueryResult>} query - Execute query
|
|
34
|
+
* @property {function(): Promise<void>} close - Close connection
|
|
35
|
+
* @property {function(): Promise<void>} [beginTransaction] - Begin transaction
|
|
36
|
+
* @property {function(): Promise<void>} [commit] - Commit transaction
|
|
37
|
+
* @property {function(): Promise<void>} [rollback] - Rollback transaction
|
|
38
|
+
* @property {function(function): Promise<any>} [transaction] - Execute transaction
|
|
39
|
+
* @property {function(Array): Promise<Array>} [batch] - Batch operations
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} DriverInterface
|
|
44
|
+
* @property {string} name - Driver name
|
|
45
|
+
* @property {string} version - Driver version
|
|
46
|
+
* @property {function(DatabaseConfig): Promise<Connection>} connect - Connect method
|
|
47
|
+
* @property {function(Connection): Promise<void>} close - Close method
|
|
48
|
+
* @property {function(Connection): Promise<Object>} [healthCheck] - Health check
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @typedef {Object} QueryBuilderOptions
|
|
53
|
+
* @property {string} tableName - Table name
|
|
54
|
+
* @property {Connection} connection - Database connection
|
|
55
|
+
* @property {string} dialect - Database dialect
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @typedef {Object} QueryBuilder
|
|
60
|
+
* @property {function(...string): QueryBuilder} select - Select columns
|
|
61
|
+
* @property {function(): QueryBuilder} distinct - Distinct query
|
|
62
|
+
* @property {function(string, string, any): QueryBuilder} where - Where condition
|
|
63
|
+
* @property {function(string, Array): QueryBuilder} whereIn - Where IN condition
|
|
64
|
+
* @property {function(string, Array): QueryBuilder} whereNotIn - Where NOT IN condition
|
|
65
|
+
* @property {function(string): QueryBuilder} whereNull - Where NULL condition
|
|
66
|
+
* @property {function(string): QueryBuilder} whereNotNull - Where NOT NULL condition
|
|
67
|
+
* @property {function(string, Array): QueryBuilder} whereBetween - Where BETWEEN condition
|
|
68
|
+
* @property {function(string, string): QueryBuilder} whereLike - Where LIKE condition
|
|
69
|
+
* @property {function(string, string, any): QueryBuilder} orWhere - OR Where condition
|
|
70
|
+
* @property {function(string, Array): QueryBuilder} whereRaw - Raw WHERE condition
|
|
71
|
+
* @property {function(string, string): QueryBuilder} orderBy - Order by
|
|
72
|
+
* @property {function(string, Array): QueryBuilder} orderByRaw - Raw ORDER BY
|
|
73
|
+
* @property {function(...string): QueryBuilder} groupBy - Group by
|
|
74
|
+
* @property {function(string, string, any): QueryBuilder} having - Having condition
|
|
75
|
+
* @property {function(number): QueryBuilder} limit - Limit results
|
|
76
|
+
* @property {function(number): QueryBuilder} offset - Offset results
|
|
77
|
+
* @property {function(string, string, string, string, string): QueryBuilder} join - Join table
|
|
78
|
+
* @property {function(string, string, string, string): QueryBuilder} leftJoin - LEFT JOIN
|
|
79
|
+
* @property {function(string, string, string, string): QueryBuilder} rightJoin - RIGHT JOIN
|
|
80
|
+
* @property {function(string): QueryBuilder} crossJoin - CROSS JOIN
|
|
81
|
+
* @property {function(Object|Array): QueryBuilder} insert - Insert data
|
|
82
|
+
* @property {function(Object): QueryBuilder} update - Update data
|
|
83
|
+
* @property {function(): QueryBuilder} delete - Delete data
|
|
84
|
+
* @property {function(...string): QueryBuilder} returning - Returning clause
|
|
85
|
+
* @property {function(string): QueryBuilder} lock - Lock rows
|
|
86
|
+
* @property {function(): Object} toSQL - Generate SQL
|
|
87
|
+
* @property {function(): Promise<QueryResult>} execute - Execute query
|
|
88
|
+
* @property {function(): Promise<Array>} all - Get all rows
|
|
89
|
+
* @property {function(): Promise<any>} first - Get first row
|
|
90
|
+
* @property {function(string): Promise<number>} count - Count rows
|
|
91
|
+
* @property {function(number, number): Promise<Object>} paginate - Paginate results
|
|
92
|
+
* @property {function(Object, string): Promise<any>} insertGetId - Insert and get ID
|
|
93
|
+
* @property {function(Array, number): Promise<Array>} batchInsert - Batch insert
|
|
94
|
+
* @property {function(): QueryBuilder} clone - Clone builder
|
|
95
|
+
* @property {function(): string} toDebugSQL - Debug SQL
|
|
96
|
+
* @property {function(): Promise<any>} explain - Explain query
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* @typedef {Object} DatabaseManager
|
|
101
|
+
* @property {function(DatabaseConfig): Promise<DatabaseManager>} init - Initialize
|
|
102
|
+
* @property {function(string, DatabaseConfig): Promise<Connection>} getConnection - Get connection
|
|
103
|
+
* @property {function(string, Array, string): Promise<QueryResult>} query - Execute query
|
|
104
|
+
* @property {function(string): QueryBuilder} table - Get query builder for table
|
|
105
|
+
* @property {function(function, string): Promise<any>} transaction - Execute transaction
|
|
106
|
+
* @property {function(Object): Promise<Object>} crossDbQuery - Cross-database query
|
|
107
|
+
* @property {function(Array, string): Promise<Array>} batch - Batch operations
|
|
108
|
+
* @property {function(string): Promise<Object>} healthCheck - Health check
|
|
109
|
+
* @property {function(): Promise<Object>} getAllHealthChecks - All health checks
|
|
110
|
+
* @property {function(): Object} getMetrics - Get metrics
|
|
111
|
+
* @property {function(): void} clearCache - Clear query cache
|
|
112
|
+
* @property {function(): Promise<void>} close - Close all connections
|
|
113
|
+
* @property {function(boolean): void} setEnabled - Enable/disable
|
|
114
|
+
* @property {function(): boolean} isDatabaseEnabled - Check if enabled
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @typedef {Object} ConnectionPool
|
|
119
|
+
* @property {function(): Promise<void>} init - Initialize pool
|
|
120
|
+
* @property {function(): Promise<Connection>} getConnection - Get connection
|
|
121
|
+
* @property {function(Connection): void} releaseConnection - Release connection
|
|
122
|
+
* @property {function(string, Array): Promise<QueryResult>} query - Execute query
|
|
123
|
+
* @property {function(): Object} getStats - Get statistics
|
|
124
|
+
* @property {function(): Promise<Object>} healthCheck - Health check
|
|
125
|
+
* @property {function(): Promise<void>} close - Close pool
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
// Export for CommonJS
|
|
129
|
+
module.exports = {};
|