@gravito/ripple 3.1.0 → 4.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 +260 -19
- package/dist/atlas/src/DB.d.ts +348 -0
- package/dist/atlas/src/OrbitAtlas.d.ts +9 -0
- package/dist/atlas/src/config/defineConfig.d.ts +14 -0
- package/dist/atlas/src/config/index.d.ts +7 -0
- package/dist/atlas/src/config/loadConfig.d.ts +41 -0
- package/dist/atlas/src/connection/Connection.d.ts +112 -0
- package/dist/atlas/src/connection/ConnectionManager.d.ts +180 -0
- package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +54 -0
- package/dist/atlas/src/drivers/BunSQLDriver.d.ts +32 -0
- package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +118 -0
- package/dist/atlas/src/drivers/MongoDBDriver.d.ts +36 -0
- package/dist/atlas/src/drivers/MySQLDriver.d.ts +79 -0
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +96 -0
- package/dist/atlas/src/drivers/RedisDriver.d.ts +43 -0
- package/dist/atlas/src/drivers/SQLiteDriver.d.ts +45 -0
- package/dist/atlas/src/drivers/types.d.ts +260 -0
- package/dist/atlas/src/errors/index.d.ts +45 -0
- package/dist/atlas/src/grammar/Grammar.d.ts +342 -0
- package/dist/atlas/src/grammar/MongoGrammar.d.ts +47 -0
- package/dist/atlas/src/grammar/MySQLGrammar.d.ts +54 -0
- package/dist/atlas/src/grammar/NullGrammar.d.ts +35 -0
- package/dist/atlas/src/grammar/PostgresGrammar.d.ts +62 -0
- package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +32 -0
- package/dist/atlas/src/index.d.ts +79 -0
- package/dist/atlas/src/migration/Migration.d.ts +64 -0
- package/dist/atlas/src/migration/MigrationRepository.d.ts +65 -0
- package/dist/atlas/src/migration/Migrator.d.ts +110 -0
- package/dist/atlas/src/migration/index.d.ts +6 -0
- package/dist/atlas/src/observability/AtlasMetrics.d.ts +33 -0
- package/dist/atlas/src/observability/AtlasObservability.d.ts +15 -0
- package/dist/atlas/src/observability/AtlasTracer.d.ts +12 -0
- package/dist/atlas/src/observability/index.d.ts +9 -0
- package/dist/atlas/src/orm/Repository.d.ts +247 -0
- package/dist/atlas/src/orm/index.d.ts +6 -0
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +121 -0
- package/dist/atlas/src/orm/model/Model.d.ts +458 -0
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +20 -0
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +150 -0
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +36 -0
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +92 -0
- package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +117 -0
- package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +64 -0
- package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +15 -0
- package/dist/atlas/src/orm/model/concerns/index.d.ts +12 -0
- package/dist/atlas/src/orm/model/decorators.d.ts +138 -0
- package/dist/atlas/src/orm/model/errors.d.ts +52 -0
- package/dist/atlas/src/orm/model/index.d.ts +10 -0
- package/dist/atlas/src/orm/model/relationships.d.ts +207 -0
- package/dist/atlas/src/orm/model/types.d.ts +12 -0
- package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +124 -0
- package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +54 -0
- package/dist/atlas/src/orm/schema/index.d.ts +6 -0
- package/dist/atlas/src/orm/schema/types.d.ts +85 -0
- package/dist/atlas/src/pool/AdaptivePoolManager.d.ts +98 -0
- package/dist/atlas/src/pool/PoolHealthChecker.d.ts +91 -0
- package/dist/atlas/src/pool/PoolStrategy.d.ts +129 -0
- package/dist/atlas/src/pool/PoolWarmer.d.ts +92 -0
- package/dist/atlas/src/query/Expression.d.ts +60 -0
- package/dist/atlas/src/query/NPlusOneDetector.d.ts +10 -0
- package/dist/atlas/src/query/QueryBuilder.d.ts +643 -0
- package/dist/atlas/src/query/RelationshipResolver.d.ts +23 -0
- package/dist/atlas/src/query/clauses/GroupByClause.d.ts +51 -0
- package/dist/atlas/src/query/clauses/HavingClause.d.ts +70 -0
- package/dist/atlas/src/query/clauses/JoinClause.d.ts +87 -0
- package/dist/atlas/src/query/clauses/LimitClause.d.ts +82 -0
- package/dist/atlas/src/query/clauses/OrderByClause.d.ts +69 -0
- package/dist/atlas/src/query/clauses/SelectClause.d.ts +71 -0
- package/dist/atlas/src/query/clauses/WhereClause.d.ts +167 -0
- package/dist/atlas/src/query/clauses/index.d.ts +11 -0
- package/dist/atlas/src/schema/Blueprint.d.ts +276 -0
- package/dist/atlas/src/schema/ColumnDefinition.d.ts +154 -0
- package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +37 -0
- package/dist/atlas/src/schema/MigrationGenerator.d.ts +45 -0
- package/dist/atlas/src/schema/Schema.d.ts +131 -0
- package/dist/atlas/src/schema/SchemaDiff.d.ts +73 -0
- package/dist/atlas/src/schema/TypeGenerator.d.ts +57 -0
- package/dist/atlas/src/schema/TypeWriter.d.ts +42 -0
- package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +23 -0
- package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +26 -0
- package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +28 -0
- package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +97 -0
- package/dist/atlas/src/schema/grammars/index.d.ts +7 -0
- package/dist/atlas/src/schema/index.d.ts +8 -0
- package/dist/atlas/src/seed/Factory.d.ts +90 -0
- package/dist/atlas/src/seed/Seeder.d.ts +28 -0
- package/dist/atlas/src/seed/SeederRunner.d.ts +74 -0
- package/dist/atlas/src/seed/index.d.ts +6 -0
- package/dist/atlas/src/sharding/ShardingManager.d.ts +59 -0
- package/dist/atlas/src/types/index.d.ts +1182 -0
- package/dist/atlas/src/utils/CursorEncoding.d.ts +63 -0
- package/dist/atlas/src/utils/levenshtein.d.ts +9 -0
- package/dist/core/src/CommandKernel.d.ts +33 -0
- package/dist/core/src/ConfigManager.d.ts +39 -0
- package/dist/core/src/Container/RequestScopeManager.d.ts +62 -0
- package/dist/core/src/Container/RequestScopeMetrics.d.ts +144 -0
- package/dist/core/src/Container.d.ts +86 -11
- package/dist/core/src/ErrorHandler.d.ts +3 -0
- package/dist/core/src/HookManager.d.ts +511 -4
- package/dist/core/src/PlanetCore.d.ts +89 -0
- package/dist/core/src/RequestContext.d.ts +97 -0
- package/dist/core/src/Router.d.ts +1 -5
- package/dist/core/src/ServiceProvider.d.ts +22 -0
- package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +1 -0
- package/dist/core/src/adapters/PhotonAdapter.d.ts +5 -0
- package/dist/core/src/adapters/bun/BunContext.d.ts +4 -0
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +1 -0
- package/dist/core/src/adapters/types.d.ts +27 -0
- package/dist/core/src/cli/queue-commands.d.ts +6 -0
- package/dist/core/src/engine/AOTRouter.d.ts +7 -12
- package/dist/core/src/engine/FastContext.d.ts +27 -2
- package/dist/core/src/engine/Gravito.d.ts +0 -1
- package/dist/core/src/engine/MinimalContext.d.ts +25 -2
- package/dist/core/src/engine/types.d.ts +9 -1
- package/dist/core/src/error-handling/RequestScopeErrorContext.d.ts +126 -0
- package/dist/core/src/events/BackpressureManager.d.ts +215 -0
- package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
- package/dist/core/src/events/DeadLetterQueue.d.ts +219 -0
- package/dist/core/src/events/EventBackend.d.ts +12 -0
- package/dist/core/src/events/EventOptions.d.ts +204 -0
- package/dist/core/src/events/EventPriorityQueue.d.ts +301 -0
- package/dist/core/src/events/FlowControlStrategy.d.ts +109 -0
- package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
- package/dist/core/src/events/MessageQueueBridge.d.ts +184 -0
- package/dist/core/src/events/PriorityEscalationManager.d.ts +82 -0
- package/dist/core/src/events/RetryScheduler.d.ts +104 -0
- package/dist/core/src/events/WorkerPool.d.ts +98 -0
- package/dist/core/src/events/WorkerPoolConfig.d.ts +153 -0
- package/dist/core/src/events/WorkerPoolMetrics.d.ts +65 -0
- package/dist/core/src/events/aggregation/AggregationWindow.d.ts +77 -0
- package/dist/core/src/events/aggregation/DeduplicationManager.d.ts +135 -0
- package/dist/core/src/events/aggregation/EventAggregationManager.d.ts +108 -0
- package/dist/core/src/events/aggregation/EventBatcher.d.ts +99 -0
- package/dist/core/src/events/aggregation/types.d.ts +117 -0
- package/dist/core/src/events/index.d.ts +25 -0
- package/dist/core/src/events/observability/EventMetrics.d.ts +132 -0
- package/dist/core/src/events/observability/EventTracer.d.ts +68 -0
- package/dist/core/src/events/observability/EventTracing.d.ts +161 -0
- package/dist/core/src/events/observability/OTelEventMetrics.d.ts +332 -0
- package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
- package/dist/core/src/events/observability/StreamWorkerMetrics.d.ts +76 -0
- package/dist/core/src/events/observability/index.d.ts +24 -0
- package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
- package/dist/core/src/events/types.d.ts +134 -0
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
- package/dist/core/src/exceptions/index.d.ts +1 -0
- package/dist/core/src/health/HealthProvider.d.ts +67 -0
- package/dist/core/src/http/types.d.ts +40 -0
- package/dist/core/src/index.d.ts +25 -4
- package/dist/core/src/instrumentation/index.d.ts +35 -0
- package/dist/core/src/instrumentation/opentelemetry.d.ts +178 -0
- package/dist/core/src/instrumentation/types.d.ts +182 -0
- package/dist/core/src/observability/Metrics.d.ts +244 -0
- package/dist/core/src/observability/QueueDashboard.d.ts +136 -0
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +350 -0
- package/dist/core/src/reliability/RetryPolicy.d.ts +217 -0
- package/dist/core/src/reliability/index.d.ts +6 -0
- package/dist/core/src/router/ControllerDispatcher.d.ts +12 -0
- package/dist/core/src/router/RequestValidator.d.ts +20 -0
- package/dist/index.js +6709 -9888
- package/dist/index.js.map +64 -62
- package/dist/photon/src/index.d.ts +19 -0
- package/dist/photon/src/middleware/ratelimit-redis.d.ts +50 -0
- package/dist/photon/src/middleware/ratelimit.d.ts +161 -0
- package/dist/photon/src/openapi.d.ts +19 -0
- package/dist/proto/ripple.proto +120 -0
- package/dist/ripple/src/RippleServer.d.ts +64 -445
- package/dist/ripple/src/channels/ChannelManager.d.ts +25 -10
- package/dist/ripple/src/drivers/NATSDriver.d.ts +87 -0
- package/dist/ripple/src/drivers/RedisDriver.d.ts +30 -1
- package/dist/ripple/src/drivers/index.d.ts +1 -0
- package/dist/ripple/src/engines/BunEngine.d.ts +98 -0
- package/dist/ripple/src/engines/IRippleEngine.d.ts +205 -0
- package/dist/ripple/src/engines/UWebSocketsEngine.d.ts +97 -0
- package/dist/ripple/src/engines/WsEngine.d.ts +69 -0
- package/dist/ripple/src/engines/index.d.ts +15 -0
- package/dist/ripple/src/index.d.ts +2 -0
- package/dist/ripple/src/middleware/InterceptorManager.d.ts +21 -0
- package/dist/ripple/src/observability/RippleMetrics.d.ts +24 -0
- package/dist/ripple/src/reliability/AckManager.d.ts +48 -0
- package/dist/ripple/src/serializers/ISerializer.d.ts +39 -0
- package/dist/ripple/src/serializers/JsonSerializer.d.ts +19 -0
- package/dist/ripple/src/serializers/ProtobufSerializer.d.ts +41 -0
- package/dist/ripple/src/serializers/index.d.ts +3 -0
- package/dist/ripple/src/tracking/SessionManager.d.ts +104 -0
- package/dist/ripple/src/tracking/index.d.ts +1 -0
- package/dist/ripple/src/types.d.ts +188 -12
- package/dist/ripple/src/utils/MessageSerializer.d.ts +33 -23
- package/dist/ripple/src/utils/TokenBucket.d.ts +25 -0
- package/package.json +25 -8
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PostgreSQL Driver
|
|
3
|
+
* @description Database driver implementation for PostgreSQL using node-pg
|
|
4
|
+
*/
|
|
5
|
+
import type { DriverContract, DriverType, ExecuteResult, PoolHealth, PoolStats, PostgresConfig, QueryResult } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* PostgreSQL Driver
|
|
8
|
+
* Connects and executes queries against PostgreSQL databases
|
|
9
|
+
*/
|
|
10
|
+
export declare class PostgresDriver implements DriverContract {
|
|
11
|
+
private pool;
|
|
12
|
+
private connected;
|
|
13
|
+
private transactionActive;
|
|
14
|
+
private transactionClient;
|
|
15
|
+
private preparedStatements;
|
|
16
|
+
private statementCounter;
|
|
17
|
+
private poolConfig;
|
|
18
|
+
constructor(config: PostgresConfig);
|
|
19
|
+
/**
|
|
20
|
+
* Get driver name
|
|
21
|
+
*/
|
|
22
|
+
getDriverName(): DriverType;
|
|
23
|
+
/**
|
|
24
|
+
* Connect to the database
|
|
25
|
+
*/
|
|
26
|
+
connect(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Disconnect from the database
|
|
29
|
+
*/
|
|
30
|
+
disconnect(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Check if connected
|
|
33
|
+
*/
|
|
34
|
+
isConnected(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Execute a query and return results
|
|
37
|
+
*/
|
|
38
|
+
query<T = Record<string, unknown>>(sql: string, bindings?: unknown[]): Promise<QueryResult<T>>;
|
|
39
|
+
/**
|
|
40
|
+
* Execute a statement (INSERT/UPDATE/DELETE)
|
|
41
|
+
*/
|
|
42
|
+
execute(sql: string, bindings?: unknown[]): Promise<ExecuteResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Prepare a statement for repeated execution
|
|
45
|
+
*/
|
|
46
|
+
prepare(sql: string): Promise<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Execute a prepared statement
|
|
49
|
+
*/
|
|
50
|
+
executePrepared<T>(name: string, bindings?: unknown[]): Promise<QueryResult<T>>;
|
|
51
|
+
/**
|
|
52
|
+
* Clear all prepared statements
|
|
53
|
+
*/
|
|
54
|
+
clearPreparedStatements(): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Begin a transaction
|
|
57
|
+
*/
|
|
58
|
+
beginTransaction(): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Commit the current transaction
|
|
61
|
+
*/
|
|
62
|
+
commit(): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* Rollback the current transaction
|
|
65
|
+
*/
|
|
66
|
+
rollback(): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Check if currently in a transaction
|
|
69
|
+
*/
|
|
70
|
+
inTransaction(): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Get connection pool statistics
|
|
73
|
+
*/
|
|
74
|
+
getPoolStats(): PoolStats | null;
|
|
75
|
+
/**
|
|
76
|
+
* Get connection pool health status
|
|
77
|
+
*/
|
|
78
|
+
getPoolHealth(): PoolHealth;
|
|
79
|
+
/**
|
|
80
|
+
* Adjust the connection pool size
|
|
81
|
+
* Note: pg Pool doesn't support dynamic resizing, so we reconnect with new size
|
|
82
|
+
*/
|
|
83
|
+
adjustPoolSize(targetSize: number): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Get a client for executing queries
|
|
86
|
+
*/
|
|
87
|
+
private getClient;
|
|
88
|
+
/**
|
|
89
|
+
* Normalize PostgreSQL errors
|
|
90
|
+
*/
|
|
91
|
+
private normalizeError;
|
|
92
|
+
/**
|
|
93
|
+
* Dynamically load the pg module
|
|
94
|
+
*/
|
|
95
|
+
private loadPgModule;
|
|
96
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redis Driver
|
|
3
|
+
* @description Driver implementation for Redis using ioredis
|
|
4
|
+
*/
|
|
5
|
+
import type { ConnectionConfig, DriverContract, DriverType, ExecuteResult, QueryResult } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
* Redis Driver
|
|
8
|
+
* Provides a key-value interface via DB.connection('redis')
|
|
9
|
+
*/
|
|
10
|
+
import type { RedisClient } from './types';
|
|
11
|
+
export declare class RedisDriver implements DriverContract {
|
|
12
|
+
private config;
|
|
13
|
+
private client;
|
|
14
|
+
private RedisCtor?;
|
|
15
|
+
constructor(config: ConnectionConfig, deps?: {
|
|
16
|
+
Redis?: new (config: Record<string, unknown>) => RedisClient;
|
|
17
|
+
});
|
|
18
|
+
getDriverName(): DriverType;
|
|
19
|
+
connect(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Dynamically load ioredis module
|
|
22
|
+
*/
|
|
23
|
+
private loadRedisModule;
|
|
24
|
+
disconnect(): Promise<void>;
|
|
25
|
+
isConnected(): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Raw Redis command execution via pseudo-SQL or direct mapping
|
|
28
|
+
*/
|
|
29
|
+
query<T = any>(_sql: string, _bindings?: unknown[]): Promise<QueryResult<T>>;
|
|
30
|
+
execute(_sql: string, _bindings?: unknown[]): Promise<ExecuteResult>;
|
|
31
|
+
get(key: string): Promise<string | null>;
|
|
32
|
+
set(key: string, value: string | number): Promise<'OK'>;
|
|
33
|
+
setex(key: string, seconds: number, value: string | number): Promise<'OK'>;
|
|
34
|
+
del(key: string): Promise<number>;
|
|
35
|
+
/**
|
|
36
|
+
* Get the raw ioredis client for advanced operations
|
|
37
|
+
*/
|
|
38
|
+
getRawClient(): RedisClient | null;
|
|
39
|
+
beginTransaction(): Promise<void>;
|
|
40
|
+
commit(): Promise<void>;
|
|
41
|
+
rollback(): Promise<void>;
|
|
42
|
+
inTransaction(): boolean;
|
|
43
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SQLite Driver
|
|
3
|
+
* @description Database driver implementation for SQLite using better-sqlite3
|
|
4
|
+
*/
|
|
5
|
+
import type { ConnectionConfig, DriverContract, DriverType, ExecuteResult, QueryResult } from '../types';
|
|
6
|
+
/**
|
|
7
|
+
|
|
8
|
+
* SQLite Driver
|
|
9
|
+
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* SQLite driver implementation for Atlas ORM.
|
|
13
|
+
*
|
|
14
|
+
* Automatically detects and uses `bun:sqlite` if running in Bun,
|
|
15
|
+
* otherwise falls back to `better-sqlite3`.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
* @since 3.0.0
|
|
19
|
+
*/
|
|
20
|
+
export declare class SQLiteDriver implements DriverContract {
|
|
21
|
+
private config;
|
|
22
|
+
private client;
|
|
23
|
+
private inTransactionState;
|
|
24
|
+
constructor(config: ConnectionConfig);
|
|
25
|
+
getDriverName(): DriverType;
|
|
26
|
+
connect(): Promise<void>;
|
|
27
|
+
disconnect(): Promise<void>;
|
|
28
|
+
isConnected(): boolean;
|
|
29
|
+
query<T = Record<string, unknown>>(sql: string, bindings?: unknown[]): Promise<QueryResult<T>>;
|
|
30
|
+
execute(sql: string, bindings?: unknown[]): Promise<ExecuteResult>;
|
|
31
|
+
beginTransaction(): Promise<void>;
|
|
32
|
+
commit(): Promise<void>;
|
|
33
|
+
rollback(): Promise<void>;
|
|
34
|
+
inTransaction(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
* Normalize SQLite errors
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
*/
|
|
44
|
+
private normalizeError;
|
|
45
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Driver Type Definitions
|
|
3
|
+
* @description Type definitions for third-party database driver libraries
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* MySQL/MariaDB Pool Connection
|
|
7
|
+
*/
|
|
8
|
+
export interface MySQLPool {
|
|
9
|
+
query(sql: string, values?: unknown[]): Promise<unknown>;
|
|
10
|
+
execute(sql: string, values?: unknown[]): Promise<unknown>;
|
|
11
|
+
getConnection(): Promise<MySQLConnection>;
|
|
12
|
+
end(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* MySQL/MariaDB Connection
|
|
16
|
+
*/
|
|
17
|
+
export interface MySQLConnection {
|
|
18
|
+
query(sql: string, values?: unknown[]): Promise<unknown>;
|
|
19
|
+
execute(sql: string, values?: unknown[]): Promise<unknown>;
|
|
20
|
+
beginTransaction(): Promise<void>;
|
|
21
|
+
commit(): Promise<void>;
|
|
22
|
+
rollback(): Promise<void>;
|
|
23
|
+
release(): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* MySQL/MariaDB Module
|
|
27
|
+
*/
|
|
28
|
+
export interface MySQLModule {
|
|
29
|
+
createPool(config: Record<string, unknown>): MySQLPool;
|
|
30
|
+
createConnection(config: Record<string, unknown>): Promise<MySQLConnection>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* PostgreSQL Pool Client
|
|
34
|
+
*/
|
|
35
|
+
export interface PostgresPoolClient {
|
|
36
|
+
query(sql: string, values?: unknown[]): Promise<{
|
|
37
|
+
rows: unknown[];
|
|
38
|
+
rowCount: number;
|
|
39
|
+
}>;
|
|
40
|
+
release(): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* PostgreSQL Pool
|
|
44
|
+
*/
|
|
45
|
+
export interface PostgresPool {
|
|
46
|
+
connect(): Promise<PostgresPoolClient>;
|
|
47
|
+
query(sql: string, values?: unknown[]): Promise<{
|
|
48
|
+
rows: unknown[];
|
|
49
|
+
rowCount: number;
|
|
50
|
+
}>;
|
|
51
|
+
end(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* SQLite Database Client (Bun)
|
|
55
|
+
*/
|
|
56
|
+
export interface SQLiteClient {
|
|
57
|
+
prepare(sql: string): SQLiteStatement;
|
|
58
|
+
query(sql: string, ...params: unknown[]): unknown[];
|
|
59
|
+
run(sql: string, ...params: unknown[]): {
|
|
60
|
+
changes: number;
|
|
61
|
+
lastInsertRowid: number;
|
|
62
|
+
};
|
|
63
|
+
exec?(sql: string): void;
|
|
64
|
+
pragma?(name: string, value?: unknown): unknown;
|
|
65
|
+
open?: boolean;
|
|
66
|
+
inTransaction?: boolean;
|
|
67
|
+
close(): void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* SQLite Statement
|
|
71
|
+
*/
|
|
72
|
+
export interface SQLiteStatement {
|
|
73
|
+
run(...params: unknown[]): {
|
|
74
|
+
changes: number;
|
|
75
|
+
lastInsertRowid: number;
|
|
76
|
+
};
|
|
77
|
+
all(...params: unknown[]): unknown[];
|
|
78
|
+
get(...params: unknown[]): unknown;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Redis Client
|
|
82
|
+
*/
|
|
83
|
+
export interface RedisClient {
|
|
84
|
+
connect(): Promise<void>;
|
|
85
|
+
get(key: string): Promise<string | null>;
|
|
86
|
+
set(key: string, value: string | number): Promise<'OK'>;
|
|
87
|
+
setex(key: string, seconds: number, value: string | number): Promise<'OK'>;
|
|
88
|
+
del(key: string): Promise<number>;
|
|
89
|
+
keys(pattern: string): Promise<string[]>;
|
|
90
|
+
exists(key: string): Promise<number>;
|
|
91
|
+
expire(key: string, seconds: number): Promise<number>;
|
|
92
|
+
quit(): Promise<void>;
|
|
93
|
+
status?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* MongoDB Client
|
|
97
|
+
*/
|
|
98
|
+
export interface MongoClient {
|
|
99
|
+
connect(): Promise<void>;
|
|
100
|
+
db(name?: string): MongoDatabase;
|
|
101
|
+
close(): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* MongoDB Database
|
|
105
|
+
*/
|
|
106
|
+
export interface MongoDatabase {
|
|
107
|
+
collection(name: string): MongoCollection;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* MongoDB Collection
|
|
111
|
+
*/
|
|
112
|
+
export interface MongoCollection {
|
|
113
|
+
find(filter?: Record<string, unknown>, options?: Record<string, unknown>): MongoCursor;
|
|
114
|
+
findOne(filter?: Record<string, unknown>): Promise<Record<string, unknown> | null>;
|
|
115
|
+
insertOne(doc: Record<string, unknown>): Promise<{
|
|
116
|
+
insertedId: unknown;
|
|
117
|
+
}>;
|
|
118
|
+
insertMany(docs: Record<string, unknown>[]): Promise<{
|
|
119
|
+
insertedIds: unknown[];
|
|
120
|
+
insertedCount: number;
|
|
121
|
+
}>;
|
|
122
|
+
countDocuments(filter?: Record<string, unknown>): Promise<number>;
|
|
123
|
+
updateOne(filter: Record<string, unknown>, update: Record<string, unknown>): Promise<{
|
|
124
|
+
modifiedCount: number;
|
|
125
|
+
}>;
|
|
126
|
+
updateMany(filter: Record<string, unknown>, update: Record<string, unknown>): Promise<{
|
|
127
|
+
modifiedCount: number;
|
|
128
|
+
}>;
|
|
129
|
+
deleteOne(filter: Record<string, unknown>): Promise<{
|
|
130
|
+
deletedCount: number;
|
|
131
|
+
}>;
|
|
132
|
+
deleteMany(filter: Record<string, unknown>): Promise<{
|
|
133
|
+
deletedCount: number;
|
|
134
|
+
}>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* MongoDB Cursor
|
|
138
|
+
*/
|
|
139
|
+
export interface MongoCursor {
|
|
140
|
+
toArray(): Promise<Record<string, unknown>[]>;
|
|
141
|
+
limit(n: number): MongoCursor;
|
|
142
|
+
skip(n: number): MongoCursor;
|
|
143
|
+
sort(sort: Record<string, 1 | -1>): MongoCursor;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Bun SQL Client (Enhanced for Bun 1.3+)
|
|
147
|
+
* @description Comprehensive type definitions for Bun.sql native driver
|
|
148
|
+
*/
|
|
149
|
+
export interface BunSQLClient {
|
|
150
|
+
(strings: TemplateStringsArray, ...values: unknown[]): Promise<BunSQLResult>;
|
|
151
|
+
unsafe?(sql: string, bindings?: unknown[]): Promise<BunSQLResult>;
|
|
152
|
+
query?(sql: string, bindings?: unknown[]): Promise<BunSQLResult>;
|
|
153
|
+
all?(sql: string, bindings?: unknown[]): Promise<unknown[]>;
|
|
154
|
+
run?(sql: string, bindings?: unknown[]): Promise<BunSQLResult>;
|
|
155
|
+
simple?(strings: TemplateStringsArray, ...values: unknown[]): Promise<BunSQLResult>;
|
|
156
|
+
prepare?(sql: string): BunSQLPreparedStatement;
|
|
157
|
+
transaction?<T>(callback: (sql: BunSQLClient) => Promise<T>): Promise<T>;
|
|
158
|
+
begin?(): Promise<BunSQLTransaction>;
|
|
159
|
+
close?(): Promise<void>;
|
|
160
|
+
end?(): Promise<void>;
|
|
161
|
+
readonly connections?: {
|
|
162
|
+
idle: number;
|
|
163
|
+
pending: number;
|
|
164
|
+
active: number;
|
|
165
|
+
total: number;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Bun SQL Query Result
|
|
170
|
+
* @description Result structure returned by Bun.sql queries
|
|
171
|
+
*/
|
|
172
|
+
export interface BunSQLResult {
|
|
173
|
+
/**
|
|
174
|
+
* Result rows (iterable)
|
|
175
|
+
*/
|
|
176
|
+
rows?: unknown[];
|
|
177
|
+
/**
|
|
178
|
+
* Number of rows affected/returned
|
|
179
|
+
*/
|
|
180
|
+
rowCount?: number;
|
|
181
|
+
count?: number;
|
|
182
|
+
/**
|
|
183
|
+
* Last inserted ID (for INSERT operations)
|
|
184
|
+
*/
|
|
185
|
+
lastInsertRowid?: number | bigint;
|
|
186
|
+
/**
|
|
187
|
+
* Number of changed rows (for UPDATE operations)
|
|
188
|
+
*/
|
|
189
|
+
changes?: number;
|
|
190
|
+
/**
|
|
191
|
+
* Iterator support for streaming
|
|
192
|
+
*/
|
|
193
|
+
[Symbol.iterator](): Iterator<unknown>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Bun SQL Prepared Statement
|
|
197
|
+
* @description Prepared statement interface for query optimization
|
|
198
|
+
*/
|
|
199
|
+
export interface BunSQLPreparedStatement {
|
|
200
|
+
/**
|
|
201
|
+
* Execute prepared statement and return result
|
|
202
|
+
*/
|
|
203
|
+
run(...params: unknown[]): Promise<BunSQLResult>;
|
|
204
|
+
/**
|
|
205
|
+
* Execute and return all rows
|
|
206
|
+
*/
|
|
207
|
+
all(...params: unknown[]): Promise<unknown[]>;
|
|
208
|
+
/**
|
|
209
|
+
* Execute and return first row
|
|
210
|
+
*/
|
|
211
|
+
get(...params: unknown[]): Promise<unknown | undefined>;
|
|
212
|
+
/**
|
|
213
|
+
* Finalize and release the prepared statement
|
|
214
|
+
*/
|
|
215
|
+
finalize(): void;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Bun SQL Transaction
|
|
219
|
+
* @description Transaction handle for advanced transaction control
|
|
220
|
+
*/
|
|
221
|
+
export interface BunSQLTransaction {
|
|
222
|
+
/**
|
|
223
|
+
* Commit the transaction
|
|
224
|
+
*/
|
|
225
|
+
commit(): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Rollback the transaction
|
|
228
|
+
*/
|
|
229
|
+
rollback(): Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* Create a savepoint
|
|
232
|
+
*/
|
|
233
|
+
savepoint?(name: string): Promise<void>;
|
|
234
|
+
/**
|
|
235
|
+
* Rollback to a savepoint
|
|
236
|
+
*/
|
|
237
|
+
rollbackTo?(name: string): Promise<void>;
|
|
238
|
+
/**
|
|
239
|
+
* Release a savepoint
|
|
240
|
+
*/
|
|
241
|
+
release?(name: string): Promise<void>;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Bun SQL Pool Configuration
|
|
245
|
+
* @description Configuration options for connection pool
|
|
246
|
+
*/
|
|
247
|
+
export interface BunSQLPoolConfig {
|
|
248
|
+
/**
|
|
249
|
+
* Maximum number of connections in the pool
|
|
250
|
+
*/
|
|
251
|
+
max?: number;
|
|
252
|
+
/**
|
|
253
|
+
* Maximum time (ms) a connection can be idle before being released
|
|
254
|
+
*/
|
|
255
|
+
idleTimeout?: number;
|
|
256
|
+
/**
|
|
257
|
+
* Maximum time (ms) to wait for a connection from the pool
|
|
258
|
+
*/
|
|
259
|
+
connectionTimeout?: number;
|
|
260
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Database Error
|
|
3
|
+
*/
|
|
4
|
+
export declare class DatabaseError extends Error {
|
|
5
|
+
readonly originalError: unknown;
|
|
6
|
+
readonly query?: string;
|
|
7
|
+
readonly bindings?: unknown[];
|
|
8
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Constraint Violation Error (Base)
|
|
12
|
+
*/
|
|
13
|
+
export declare class ConstraintViolationError extends DatabaseError {
|
|
14
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Unique Constraint Violation
|
|
18
|
+
*/
|
|
19
|
+
export declare class UniqueConstraintError extends ConstraintViolationError {
|
|
20
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Foreign Key Constraint Violation
|
|
24
|
+
*/
|
|
25
|
+
export declare class ForeignKeyConstraintError extends ConstraintViolationError {
|
|
26
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Not Null Constraint Violation
|
|
30
|
+
*/
|
|
31
|
+
export declare class NotNullConstraintError extends ConstraintViolationError {
|
|
32
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Table Not Found Error
|
|
36
|
+
*/
|
|
37
|
+
export declare class TableNotFoundError extends DatabaseError {
|
|
38
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Connection Error
|
|
42
|
+
*/
|
|
43
|
+
export declare class ConnectionError extends DatabaseError {
|
|
44
|
+
constructor(message: string, originalError?: unknown);
|
|
45
|
+
}
|