@gravito/ripple 4.0.1 → 5.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 (226) hide show
  1. package/README.md +26 -10
  2. package/dist/{ripple/src/OrbitRipple.d.ts → OrbitRipple.d.ts} +1 -0
  3. package/dist/{ripple/src/RippleServer.d.ts → RippleServer.d.ts} +32 -1
  4. package/dist/core/src/Application.d.ts +41 -0
  5. package/dist/core/src/HookManager.d.ts +33 -189
  6. package/dist/core/src/PlanetCore.d.ts +31 -1
  7. package/dist/core/src/Router.d.ts +32 -46
  8. package/dist/core/src/adapters/bun/BunContext.d.ts +6 -1
  9. package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +35 -0
  10. package/dist/core/src/adapters/bun/BunWebSocketHandler.d.ts +48 -0
  11. package/dist/core/src/adapters/bun/RadixRouter.d.ts +1 -0
  12. package/dist/core/src/adapters/bun/index.d.ts +7 -0
  13. package/dist/core/src/binary/BinaryUtils.d.ts +105 -0
  14. package/dist/core/src/binary/index.d.ts +5 -0
  15. package/dist/core/src/compat/async-local-storage.d.ts +7 -0
  16. package/dist/core/src/compat/crypto.d.ts +6 -0
  17. package/dist/core/src/engine/AOTRouter.d.ts +10 -0
  18. package/dist/core/src/engine/FastContext.d.ts +19 -1
  19. package/dist/core/src/engine/Gravito.d.ts +13 -18
  20. package/dist/core/src/engine/MinimalContext.d.ts +2 -0
  21. package/dist/core/src/engine/analyzer.d.ts +92 -6
  22. package/dist/core/src/engine/types.d.ts +3 -0
  23. package/dist/core/src/events/CircuitBreaker.d.ts +12 -0
  24. package/dist/core/src/events/EventPriorityQueue.d.ts +18 -256
  25. package/dist/core/src/events/index.d.ts +12 -11
  26. package/dist/core/src/events/queue-core.d.ts +77 -0
  27. package/dist/core/src/events/task-executor.d.ts +51 -0
  28. package/dist/core/src/exceptions/AuthException.d.ts +10 -0
  29. package/dist/core/src/exceptions/AuthenticationException.d.ts +2 -2
  30. package/dist/core/src/exceptions/AuthorizationException.d.ts +2 -2
  31. package/dist/core/src/exceptions/CacheException.d.ts +9 -0
  32. package/dist/core/src/exceptions/CircularDependencyException.d.ts +2 -1
  33. package/dist/core/src/exceptions/ConfigurationException.d.ts +9 -0
  34. package/dist/core/src/exceptions/DatabaseException.d.ts +9 -0
  35. package/dist/core/src/exceptions/DomainException.d.ts +9 -0
  36. package/dist/core/src/exceptions/InfrastructureException.d.ts +17 -0
  37. package/dist/core/src/exceptions/QueueException.d.ts +9 -0
  38. package/dist/core/src/exceptions/StorageException.d.ts +9 -0
  39. package/dist/core/src/exceptions/StreamException.d.ts +9 -0
  40. package/dist/core/src/exceptions/SystemException.d.ts +9 -0
  41. package/dist/core/src/exceptions/ValidationException.d.ts +2 -2
  42. package/dist/core/src/exceptions/index.d.ts +10 -0
  43. package/dist/core/src/ffi/NativeAccelerator.d.ts +62 -0
  44. package/dist/core/src/ffi/NativeHasher.d.ts +139 -0
  45. package/dist/core/src/ffi/cbor-fallback.d.ts +96 -0
  46. package/dist/core/src/ffi/hash-fallback.d.ts +33 -0
  47. package/dist/core/src/ffi/index.d.ts +10 -0
  48. package/dist/core/src/ffi/types.d.ts +135 -0
  49. package/dist/core/src/helpers/Str.d.ts +15 -0
  50. package/dist/core/src/hooks/ActionManager.d.ts +132 -0
  51. package/dist/core/src/hooks/AsyncDetector.d.ts +84 -0
  52. package/dist/core/src/hooks/FilterManager.d.ts +71 -0
  53. package/dist/core/src/hooks/MigrationWarner.d.ts +24 -0
  54. package/dist/core/src/hooks/dlq-operations.d.ts +60 -0
  55. package/dist/core/src/hooks/types.d.ts +107 -0
  56. package/dist/core/src/http/CookieJar.d.ts +2 -2
  57. package/dist/core/src/http/types.d.ts +24 -3
  58. package/dist/core/src/index.d.ts +491 -14
  59. package/dist/core/src/observability/contracts.d.ts +137 -0
  60. package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +2 -3
  61. package/dist/core/src/runtime/adapter-bun.d.ts +12 -0
  62. package/dist/core/src/runtime/adapter-deno.d.ts +12 -0
  63. package/dist/core/src/runtime/adapter-node.d.ts +12 -0
  64. package/dist/core/src/runtime/adapter-unknown.d.ts +13 -0
  65. package/dist/core/src/runtime/archive.d.ts +17 -0
  66. package/dist/core/src/runtime/compression.d.ts +21 -0
  67. package/dist/core/src/runtime/deep-equals.d.ts +56 -0
  68. package/dist/core/src/runtime/detection.d.ts +22 -0
  69. package/dist/core/src/runtime/escape.d.ts +34 -0
  70. package/dist/core/src/runtime/index.d.ts +44 -0
  71. package/dist/core/src/runtime/markdown.d.ts +44 -0
  72. package/dist/core/src/runtime/types.d.ts +436 -0
  73. package/dist/core/src/runtime-helpers.d.ts +67 -0
  74. package/dist/core/src/runtime.d.ts +10 -118
  75. package/dist/core/src/testing/HttpTester.d.ts +1 -0
  76. package/dist/core/src/transpiler-utils.d.ts +170 -0
  77. package/dist/{ripple/src/engines → engines}/BunEngine.d.ts +11 -0
  78. package/dist/errors/RippleError.d.ts +66 -0
  79. package/dist/index.js +1 -7502
  80. package/dist/index.js.map +3 -71
  81. package/package.json +6 -2
  82. package/dist/atlas/src/DB.d.ts +0 -348
  83. package/dist/atlas/src/OrbitAtlas.d.ts +0 -9
  84. package/dist/atlas/src/config/defineConfig.d.ts +0 -14
  85. package/dist/atlas/src/config/index.d.ts +0 -7
  86. package/dist/atlas/src/config/loadConfig.d.ts +0 -41
  87. package/dist/atlas/src/connection/Connection.d.ts +0 -112
  88. package/dist/atlas/src/connection/ConnectionManager.d.ts +0 -180
  89. package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +0 -54
  90. package/dist/atlas/src/drivers/BunSQLDriver.d.ts +0 -32
  91. package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +0 -118
  92. package/dist/atlas/src/drivers/MongoDBDriver.d.ts +0 -36
  93. package/dist/atlas/src/drivers/MySQLDriver.d.ts +0 -79
  94. package/dist/atlas/src/drivers/PostgresDriver.d.ts +0 -96
  95. package/dist/atlas/src/drivers/RedisDriver.d.ts +0 -43
  96. package/dist/atlas/src/drivers/SQLiteDriver.d.ts +0 -45
  97. package/dist/atlas/src/drivers/types.d.ts +0 -260
  98. package/dist/atlas/src/errors/index.d.ts +0 -45
  99. package/dist/atlas/src/grammar/Grammar.d.ts +0 -342
  100. package/dist/atlas/src/grammar/MongoGrammar.d.ts +0 -47
  101. package/dist/atlas/src/grammar/MySQLGrammar.d.ts +0 -54
  102. package/dist/atlas/src/grammar/NullGrammar.d.ts +0 -35
  103. package/dist/atlas/src/grammar/PostgresGrammar.d.ts +0 -62
  104. package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +0 -32
  105. package/dist/atlas/src/index.d.ts +0 -79
  106. package/dist/atlas/src/migration/Migration.d.ts +0 -64
  107. package/dist/atlas/src/migration/MigrationRepository.d.ts +0 -65
  108. package/dist/atlas/src/migration/Migrator.d.ts +0 -110
  109. package/dist/atlas/src/migration/index.d.ts +0 -6
  110. package/dist/atlas/src/observability/AtlasMetrics.d.ts +0 -33
  111. package/dist/atlas/src/observability/AtlasObservability.d.ts +0 -15
  112. package/dist/atlas/src/observability/AtlasTracer.d.ts +0 -12
  113. package/dist/atlas/src/observability/index.d.ts +0 -9
  114. package/dist/atlas/src/orm/Repository.d.ts +0 -247
  115. package/dist/atlas/src/orm/index.d.ts +0 -6
  116. package/dist/atlas/src/orm/model/DirtyTracker.d.ts +0 -121
  117. package/dist/atlas/src/orm/model/Model.d.ts +0 -458
  118. package/dist/atlas/src/orm/model/ModelRegistry.d.ts +0 -20
  119. package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +0 -150
  120. package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +0 -36
  121. package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +0 -92
  122. package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +0 -117
  123. package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +0 -64
  124. package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +0 -15
  125. package/dist/atlas/src/orm/model/concerns/index.d.ts +0 -12
  126. package/dist/atlas/src/orm/model/decorators.d.ts +0 -138
  127. package/dist/atlas/src/orm/model/errors.d.ts +0 -52
  128. package/dist/atlas/src/orm/model/index.d.ts +0 -10
  129. package/dist/atlas/src/orm/model/relationships.d.ts +0 -207
  130. package/dist/atlas/src/orm/model/types.d.ts +0 -12
  131. package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +0 -124
  132. package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +0 -54
  133. package/dist/atlas/src/orm/schema/index.d.ts +0 -6
  134. package/dist/atlas/src/orm/schema/types.d.ts +0 -85
  135. package/dist/atlas/src/pool/AdaptivePoolManager.d.ts +0 -98
  136. package/dist/atlas/src/pool/PoolHealthChecker.d.ts +0 -91
  137. package/dist/atlas/src/pool/PoolStrategy.d.ts +0 -129
  138. package/dist/atlas/src/pool/PoolWarmer.d.ts +0 -92
  139. package/dist/atlas/src/query/Expression.d.ts +0 -60
  140. package/dist/atlas/src/query/NPlusOneDetector.d.ts +0 -10
  141. package/dist/atlas/src/query/QueryBuilder.d.ts +0 -643
  142. package/dist/atlas/src/query/RelationshipResolver.d.ts +0 -23
  143. package/dist/atlas/src/query/clauses/GroupByClause.d.ts +0 -51
  144. package/dist/atlas/src/query/clauses/HavingClause.d.ts +0 -70
  145. package/dist/atlas/src/query/clauses/JoinClause.d.ts +0 -87
  146. package/dist/atlas/src/query/clauses/LimitClause.d.ts +0 -82
  147. package/dist/atlas/src/query/clauses/OrderByClause.d.ts +0 -69
  148. package/dist/atlas/src/query/clauses/SelectClause.d.ts +0 -71
  149. package/dist/atlas/src/query/clauses/WhereClause.d.ts +0 -167
  150. package/dist/atlas/src/query/clauses/index.d.ts +0 -11
  151. package/dist/atlas/src/schema/Blueprint.d.ts +0 -276
  152. package/dist/atlas/src/schema/ColumnDefinition.d.ts +0 -154
  153. package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +0 -37
  154. package/dist/atlas/src/schema/MigrationGenerator.d.ts +0 -45
  155. package/dist/atlas/src/schema/Schema.d.ts +0 -131
  156. package/dist/atlas/src/schema/SchemaDiff.d.ts +0 -73
  157. package/dist/atlas/src/schema/TypeGenerator.d.ts +0 -57
  158. package/dist/atlas/src/schema/TypeWriter.d.ts +0 -42
  159. package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +0 -23
  160. package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +0 -26
  161. package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +0 -28
  162. package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +0 -97
  163. package/dist/atlas/src/schema/grammars/index.d.ts +0 -7
  164. package/dist/atlas/src/schema/index.d.ts +0 -8
  165. package/dist/atlas/src/seed/Factory.d.ts +0 -90
  166. package/dist/atlas/src/seed/Seeder.d.ts +0 -28
  167. package/dist/atlas/src/seed/SeederRunner.d.ts +0 -74
  168. package/dist/atlas/src/seed/index.d.ts +0 -6
  169. package/dist/atlas/src/sharding/ShardingManager.d.ts +0 -59
  170. package/dist/atlas/src/types/index.d.ts +0 -1182
  171. package/dist/atlas/src/utils/CursorEncoding.d.ts +0 -63
  172. package/dist/atlas/src/utils/levenshtein.d.ts +0 -9
  173. package/dist/core/src/adapters/PhotonAdapter.d.ts +0 -175
  174. package/dist/core/src/adapters/photon-types.d.ts +0 -73
  175. package/dist/core/src/http/middleware/BodySizeLimit.d.ts +0 -16
  176. package/dist/core/src/http/middleware/Cors.d.ts +0 -24
  177. package/dist/core/src/http/middleware/Csrf.d.ts +0 -23
  178. package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +0 -28
  179. package/dist/core/src/http/middleware/SecurityHeaders.d.ts +0 -29
  180. package/dist/core/src/http/middleware/ThrottleRequests.d.ts +0 -18
  181. package/dist/core/src/instrumentation/index.d.ts +0 -35
  182. package/dist/core/src/instrumentation/opentelemetry.d.ts +0 -178
  183. package/dist/core/src/instrumentation/types.d.ts +0 -182
  184. package/dist/core/src/observability/Metrics.d.ts +0 -244
  185. package/dist/photon/src/index.d.ts +0 -89
  186. package/dist/photon/src/middleware/binary.d.ts +0 -31
  187. package/dist/photon/src/middleware/htmx.d.ts +0 -39
  188. package/dist/photon/src/middleware/ratelimit-redis.d.ts +0 -50
  189. package/dist/photon/src/middleware/ratelimit.d.ts +0 -161
  190. package/dist/photon/src/openapi.d.ts +0 -19
  191. package/dist/ripple/src/errors/RippleError.d.ts +0 -48
  192. /package/dist/{ripple/src/channels → channels}/Channel.d.ts +0 -0
  193. /package/dist/{ripple/src/channels → channels}/ChannelManager.d.ts +0 -0
  194. /package/dist/{ripple/src/channels → channels}/index.d.ts +0 -0
  195. /package/dist/{ripple/src/drivers → drivers}/LocalDriver.d.ts +0 -0
  196. /package/dist/{ripple/src/drivers → drivers}/NATSDriver.d.ts +0 -0
  197. /package/dist/{ripple/src/drivers → drivers}/RedisDriver.d.ts +0 -0
  198. /package/dist/{ripple/src/drivers → drivers}/index.d.ts +0 -0
  199. /package/dist/{ripple/src/engines → engines}/IRippleEngine.d.ts +0 -0
  200. /package/dist/{ripple/src/engines → engines}/UWebSocketsEngine.d.ts +0 -0
  201. /package/dist/{ripple/src/engines → engines}/WsEngine.d.ts +0 -0
  202. /package/dist/{ripple/src/engines → engines}/index.d.ts +0 -0
  203. /package/dist/{ripple/src/errors → errors}/index.d.ts +0 -0
  204. /package/dist/{ripple/src/events → events}/BroadcastEvent.d.ts +0 -0
  205. /package/dist/{ripple/src/events → events}/BroadcastManager.d.ts +0 -0
  206. /package/dist/{ripple/src/events → events}/Broadcaster.d.ts +0 -0
  207. /package/dist/{ripple/src/events → events}/index.d.ts +0 -0
  208. /package/dist/{ripple/src/health → health}/HealthChecker.d.ts +0 -0
  209. /package/dist/{ripple/src/health → health}/index.d.ts +0 -0
  210. /package/dist/{ripple/src/index.d.ts → index.d.ts} +0 -0
  211. /package/dist/{ripple/src/logging → logging}/Logger.d.ts +0 -0
  212. /package/dist/{ripple/src/logging → logging}/index.d.ts +0 -0
  213. /package/dist/{ripple/src/middleware → middleware}/InterceptorManager.d.ts +0 -0
  214. /package/dist/{ripple/src/observability → observability}/RippleMetrics.d.ts +0 -0
  215. /package/dist/{ripple/src/reliability → reliability}/AckManager.d.ts +0 -0
  216. /package/dist/{ripple/src/serializers → serializers}/ISerializer.d.ts +0 -0
  217. /package/dist/{ripple/src/serializers → serializers}/JsonSerializer.d.ts +0 -0
  218. /package/dist/{ripple/src/serializers → serializers}/ProtobufSerializer.d.ts +0 -0
  219. /package/dist/{ripple/src/serializers → serializers}/index.d.ts +0 -0
  220. /package/dist/{ripple/src/tracking → tracking}/ConnectionTracker.d.ts +0 -0
  221. /package/dist/{ripple/src/tracking → tracking}/SessionManager.d.ts +0 -0
  222. /package/dist/{ripple/src/tracking → tracking}/index.d.ts +0 -0
  223. /package/dist/{ripple/src/types.d.ts → types.d.ts} +0 -0
  224. /package/dist/{ripple/src/utils → utils}/MessageSerializer.d.ts +0 -0
  225. /package/dist/{ripple/src/utils → utils}/TokenBucket.d.ts +0 -0
  226. /package/dist/{ripple/src/utils → utils}/index.d.ts +0 -0
@@ -1,180 +0,0 @@
1
- /**
2
- * Connection Manager
3
- * @description Manages multiple database connections
4
- */
5
- import { type AdaptivePoolConfig, AdaptivePoolManager } from '../pool/AdaptivePoolManager';
6
- import { type PoolHealthCheckConfig } from '../pool/PoolHealthChecker';
7
- import { type PoolWarmerConfig } from '../pool/PoolWarmer';
8
- import type { AtlasConnectionEntry, ConnectionContract, PoolHealth } from '../types';
9
- /**
10
- * Connection Manager
11
- *
12
- * Responsible for managing the lifecycle of database connections.
13
- * It handles connection pooling (via drivers), lazy initialization,
14
- * and automatic cleanup of idle connections.
15
- *
16
- * Connections are stored in a Map and retrieved by name. If a connection
17
- * hasn't been initialized, the manager creates it using the provided configuration.
18
- */
19
- export declare class ConnectionManager {
20
- private readonly configs;
21
- private connections;
22
- private defaultConnectionName;
23
- private lastUsed;
24
- private cleanupInterval?;
25
- private healthChecker?;
26
- private warmer?;
27
- private adaptiveManager?;
28
- /** Replica pools keyed by connection name */
29
- private replicaPools;
30
- private readonly MAX_IDLE_TIME;
31
- private readonly CLEANUP_INTERVAL;
32
- constructor(configs?: Record<string, AtlasConnectionEntry>);
33
- /**
34
- * Get a connection instance by name.
35
- * If the connection is not already initialized, it will be created.
36
- *
37
- * @param name - Optional connection name (defaults to 'default').
38
- * @returns The connection instance.
39
- * @throws Error if the connection is not configured.
40
- */
41
- connection(name?: string): ConnectionContract;
42
- /**
43
- * Get the read replica connection for a named connection.
44
- * Returns the round-robin selected read replica, or the write connection
45
- * if no replicas are configured.
46
- *
47
- * @param name - Connection name (defaults to default)
48
- */
49
- readConnection(name?: string): ConnectionContract;
50
- /**
51
- * Get the write (primary) connection for a named connection.
52
- *
53
- * @param name - Connection name (defaults to default)
54
- */
55
- writeConnection(name?: string): ConnectionContract;
56
- /**
57
- * Check whether a given connection has read replicas.
58
- */
59
- hasReplicas(name?: string): boolean;
60
- /**
61
- * Build and register a Connection instance, wrapping it in a Proxy.
62
- * @internal
63
- */
64
- private _buildAndRegisterConnection;
65
- /**
66
- * Build a proxy-wrapped Connection from config without registering.
67
- * @internal
68
- */
69
- private _buildConnection;
70
- /**
71
- * Add a connection configuration.
72
- *
73
- * @param name - Unique name for the connection.
74
- * @param config - Connection configuration settings (standard or read/write replica).
75
- */
76
- addConnection(name: string, config: AtlasConnectionEntry): void;
77
- /**
78
- * Set the default connection name.
79
- *
80
- * @param name - The name of the default connection.
81
- */
82
- setDefaultConnection(name: string): void;
83
- /**
84
- * Get the default connection name.
85
- *
86
- * @returns The default connection name.
87
- */
88
- getDefaultConnection(): string;
89
- /**
90
- * Check if a connection configuration exists.
91
- *
92
- * @param name - The connection name to check.
93
- * @returns True if the connection is configured.
94
- */
95
- hasConnection(name: string): boolean;
96
- /**
97
- * Get all configured connection names.
98
- *
99
- * @returns Array of connection names.
100
- */
101
- getConnectionNames(): string[];
102
- /**
103
- * Get the configuration for a specific connection.
104
- *
105
- * @param name - The connection name.
106
- * @returns The connection configuration or undefined if not found.
107
- */
108
- getConfig(name: string): AtlasConnectionEntry | undefined;
109
- /**
110
- * Disconnect all active connections.
111
- *
112
- * @returns A promise that resolves when all connections are closed.
113
- */
114
- disconnectAll(): Promise<void>;
115
- /**
116
- * Disconnect a specific connection by name.
117
- *
118
- * @param name - Optional connection name (defaults to default).
119
- * @returns A promise that resolves when the connection is closed.
120
- */
121
- disconnect(name?: string): Promise<void>;
122
- /**
123
- * Purge a connection from the manager's cache.
124
- * This will NOT disconnect the connection if it's already active.
125
- *
126
- * @param name - Optional connection name.
127
- */
128
- purge(name?: string): void;
129
- /**
130
- * Reconnect to a connection.
131
- * This will disconnect the existing connection and create a new one.
132
- *
133
- * @param name - Optional connection name.
134
- * @returns The new connection instance.
135
- */
136
- reconnect(name?: string): Promise<ConnectionContract>;
137
- private cleanupIdleConnections;
138
- private startCleanup;
139
- stopCleanup(): void;
140
- /**
141
- * Enable connection pool health checking
142
- */
143
- enableHealthCheck(config?: Partial<PoolHealthCheckConfig>): void;
144
- /**
145
- * Disable connection pool health checking
146
- */
147
- disableHealthCheck(): void;
148
- /**
149
- * Get connection pool health status
150
- */
151
- getHealthStatus(connectionName?: string): PoolHealth | Map<string, PoolHealth>;
152
- /**
153
- * Enable connection pool warming
154
- */
155
- enableWarmup(config?: Partial<PoolWarmerConfig>): void;
156
- /**
157
- * Warm up all connection pools
158
- */
159
- warmup(): Promise<any>;
160
- /**
161
- * Enable adaptive connection pool management
162
- * Automatically adjusts pool sizes based on load patterns
163
- */
164
- enableAdaptive(config?: Partial<AdaptivePoolConfig>): void;
165
- /**
166
- * Disable adaptive connection pool management
167
- */
168
- disableAdaptive(): void;
169
- /**
170
- * Get adaptive pool manager instance (if enabled)
171
- */
172
- getAdaptiveManager(): AdaptivePoolManager | undefined;
173
- /**
174
- * Shutdown the connection manager.
175
- * Stops the idle cleanup interval, health checking, adaptive management, and disconnects all connections.
176
- *
177
- * @returns A promise that resolves when shutdown is complete.
178
- */
179
- shutdown(): Promise<void>;
180
- }
@@ -1,54 +0,0 @@
1
- /**
2
- * @gravito/atlas - Replica Connection Pool
3
- * @description Manages read/write replica connections with Round-robin load balancing.
4
- *
5
- * Wraps a write (primary) connection and a pool of read (replica) connections.
6
- * Transparently routes SELECT queries to read replicas and mutations to the primary.
7
- */
8
- import type { ConnectionContract } from '../types';
9
- /**
10
- * ReplicaConnectionPool
11
- *
12
- * Holds one authoritative write connection and N read replica connections.
13
- * Applies Round-robin selection across replicas to balance read load.
14
- *
15
- * Usage:
16
- * ```typescript
17
- * const pool = new ReplicaConnectionPool(writeConn, [replica1, replica2])
18
- * const readConn = pool.getReadConnection() // Round-robin
19
- * const writeConn = pool.getWriteConnection() // Always primary
20
- * ```
21
- */
22
- export declare class ReplicaConnectionPool {
23
- private readonly writeConnection;
24
- private readonly readConnections;
25
- private roundRobinIndex;
26
- constructor(writeConnection: ConnectionContract, readConnections?: ConnectionContract[]);
27
- /**
28
- * Get the primary write connection (always the same node).
29
- */
30
- getWriteConnection(): ConnectionContract;
31
- /**
32
- * Get a read replica connection using Round-robin selection.
33
- *
34
- * Falls back to the write connection if no replicas are configured.
35
- */
36
- getReadConnection(): ConnectionContract;
37
- /**
38
- * Whether this pool has any read replicas configured.
39
- */
40
- hasReplicas(): boolean;
41
- /**
42
- * Total number of replica connections in the pool.
43
- */
44
- replicaCount(): number;
45
- /**
46
- * Disconnect all connections (write + all replicas).
47
- */
48
- disconnectAll(): Promise<void>;
49
- /**
50
- * Reset round-robin index (useful for testing).
51
- * @internal
52
- */
53
- _resetIndex(): void;
54
- }
@@ -1,32 +0,0 @@
1
- /**
2
- * Bun Native SQL Driver
3
- */
4
- import type { ConnectionConfig, DriverContract, DriverType, ExecuteResult, PoolStats, QueryResult } from '../types';
5
- export declare class BunSQLDriver implements DriverContract {
6
- private readonly config;
7
- private client;
8
- private sqliteClient;
9
- private connected;
10
- private transactionActive;
11
- private preparedManager?;
12
- constructor(config: ConnectionConfig);
13
- getDriverName(): DriverType;
14
- connect(): Promise<void>;
15
- disconnect(): Promise<void>;
16
- isConnected(): boolean;
17
- query<T = Record<string, unknown>>(sql: string, bindings?: unknown[]): Promise<QueryResult<T>>;
18
- execute(sql: string, bindings?: unknown[]): Promise<ExecuteResult>;
19
- private normalizeBindings;
20
- beginTransaction(): Promise<void>;
21
- commit(): Promise<void>;
22
- rollback(): Promise<void>;
23
- inTransaction(): boolean;
24
- private ensureConnection;
25
- private getConnectionUrl;
26
- prepare(sql: string): Promise<string>;
27
- executePrepared<T = Record<string, unknown>>(name: string, bindings?: unknown[]): Promise<QueryResult<T>>;
28
- clearPreparedStatements(): Promise<void>;
29
- stream<T = Record<string, unknown>>(sql: string, bindings?: unknown[]): AsyncIterable<T>;
30
- getPoolStats(): PoolStats | null;
31
- private normalizeError;
32
- }
@@ -1,118 +0,0 @@
1
- /**
2
- * Bun SQL Prepared Statement Manager
3
- * @description Manages prepared statement caching, lifecycle, and optimization
4
- */
5
- import type { BunSQLClient } from './types';
6
- /**
7
- * Configuration options for prepared statement manager
8
- */
9
- export interface PreparedStatementManagerConfig {
10
- /**
11
- * Maximum number of prepared statements to cache
12
- * @default 100
13
- */
14
- maxStatements?: number;
15
- /**
16
- * Idle timeout in milliseconds before a statement is removed
17
- * @default 60000 (1 minute)
18
- */
19
- idleTimeout?: number;
20
- }
21
- /**
22
- * Prepared Statement Manager for BunSQL
23
- *
24
- * Manages statement caching and lifecycle to optimize query performance.
25
- * Features:
26
- * - LRU (Least Recently Used) cache eviction
27
- * - Idle timeout cleanup
28
- * - Usage statistics tracking
29
- *
30
- * @example
31
- * ```typescript
32
- * const manager = new BunSQLPreparedStatementManager(client)
33
- *
34
- * // Prepare a statement
35
- * const stmtId = await manager.prepare('SELECT * FROM users WHERE id = ?')
36
- *
37
- * // Execute multiple times
38
- * const users1 = await manager.execute(stmtId, [1])
39
- * const users2 = await manager.execute(stmtId, [2])
40
- *
41
- * // Clean up
42
- * await manager.clear()
43
- * ```
44
- */
45
- export declare class BunSQLPreparedStatementManager {
46
- private readonly client;
47
- private statements;
48
- private sqlToName;
49
- private readonly config;
50
- private cleanupTimer?;
51
- constructor(client: BunSQLClient, config?: PreparedStatementManagerConfig);
52
- /**
53
- * Prepare a SQL statement for repeated execution
54
- *
55
- * @param sql - SQL query to prepare
56
- * @returns Prepared statement identifier
57
- */
58
- prepare(sql: string): Promise<string>;
59
- /**
60
- * Execute a prepared statement
61
- *
62
- * @param name - Prepared statement identifier
63
- * @param bindings - Query parameters
64
- * @returns Query result rows
65
- */
66
- execute<T = Record<string, unknown>>(name: string, bindings?: unknown[]): Promise<T[]>;
67
- /**
68
- * Clear all prepared statements
69
- */
70
- clear(): Promise<void>;
71
- /**
72
- * Clean up idle statements
73
- */
74
- cleanup(): Promise<void>;
75
- /**
76
- * Get statement usage statistics
77
- *
78
- * @param name - Prepared statement identifier
79
- * @returns Usage statistics or null if not found
80
- */
81
- getStats(name: string): {
82
- useCount: number;
83
- lastUsed: number;
84
- } | null;
85
- /**
86
- * Get the number of cached statements
87
- */
88
- getSize(): number;
89
- /**
90
- * Destroy the manager and clean up resources
91
- */
92
- destroy(): Promise<void>;
93
- /**
94
- * Evict the least recently used statement
95
- * @private
96
- */
97
- private evictLeastRecentlyUsed;
98
- /**
99
- * Generate a unique statement name
100
- * @private
101
- */
102
- private generateStatementName;
103
- /**
104
- * Simple hash function for SQL strings
105
- * @private
106
- */
107
- private simpleHash;
108
- /**
109
- * Start periodic cleanup timer
110
- * @private
111
- */
112
- private startCleanupTimer;
113
- /**
114
- * Stop cleanup timer
115
- * @private
116
- */
117
- private stopCleanupTimer;
118
- }
@@ -1,36 +0,0 @@
1
- import type { ConnectionConfig, DriverContract, DriverType, ExecuteResult, QueryResult } from '../types';
2
- /**
3
- * MongoDB Driver
4
- * Provides a document interface via DB.connection('mongodb')
5
- */
6
- import type { MongoClient } from './types';
7
- export declare class MongoDBDriver implements DriverContract {
8
- private config;
9
- private client;
10
- private db;
11
- private MongoClientCtor?;
12
- constructor(config: ConnectionConfig, deps?: {
13
- MongoClient?: new (url: string, options?: Record<string, unknown>) => MongoClient;
14
- });
15
- getDriverName(): DriverType;
16
- connect(): Promise<void>;
17
- /**
18
- * Dynamically load mongodb module
19
- */
20
- private loadMongoModule;
21
- disconnect(): Promise<void>;
22
- isConnected(): boolean;
23
- /**
24
- * Execute a query (Protocol: JSON String)
25
- */
26
- query<T = Record<string, unknown>>(protocolJson: string, _bindings?: unknown[]): Promise<QueryResult<T>>;
27
- /**
28
- * Execute a write operation (Protocol: JSON String)
29
- */
30
- execute(protocolJson: string, _bindings?: unknown[]): Promise<ExecuteResult>;
31
- beginTransaction(): Promise<void>;
32
- commit(): Promise<void>;
33
- rollback(): Promise<void>;
34
- inTransaction(): boolean;
35
- private mapDocument;
36
- }
@@ -1,79 +0,0 @@
1
- /**
2
- * MySQL/MariaDB Driver
3
- * @description Database driver for MySQL and MariaDB using mysql2 package
4
- */
5
- import type { ConnectionConfig, DriverContract, DriverType, ExecuteResult, PoolHealth, PoolStats, QueryResult } from '../types';
6
- export declare class MySQLDriver implements DriverContract {
7
- private pool;
8
- private transactionConnection;
9
- private connected;
10
- private mysql;
11
- private poolConfig;
12
- private readonly driverType;
13
- constructor(config: ConnectionConfig, driverType?: 'mysql' | 'mariadb');
14
- /**
15
- * Get the driver name
16
- */
17
- getDriverName(): DriverType;
18
- /**
19
- * Connect to MySQL/MariaDB
20
- */
21
- connect(): Promise<void>;
22
- /**
23
- * Dynamically load mysql2 module
24
- */
25
- private loadMySQLModule;
26
- /**
27
- * Disconnect from MySQL
28
- */
29
- disconnect(): Promise<void>;
30
- /**
31
- * Check if connected
32
- */
33
- isConnected(): boolean;
34
- /**
35
- * Execute a query
36
- */
37
- query<T = Record<string, unknown>>(sql: string, bindings?: unknown[]): Promise<QueryResult<T>>;
38
- /**
39
- * Execute a statement (INSERT/UPDATE/DELETE)
40
- */
41
- execute(sql: string, bindings?: unknown[]): Promise<ExecuteResult>;
42
- /**
43
- * Begin a transaction
44
- */
45
- beginTransaction(): Promise<void>;
46
- /**
47
- * Commit the current transaction
48
- */
49
- commit(): Promise<void>;
50
- /**
51
- * Rollback the current transaction
52
- */
53
- rollback(): Promise<void>;
54
- /**
55
- * Check if in transaction
56
- */
57
- inTransaction(): boolean;
58
- /**
59
- * Get connection pool statistics
60
- */
61
- getPoolStats(): PoolStats | null;
62
- /**
63
- * Get connection pool health status
64
- */
65
- getPoolHealth(): PoolHealth;
66
- /**
67
- * Adjust the connection pool size
68
- * Note: mysql2 Pool doesn't support dynamic resizing, so we reconnect with new size
69
- */
70
- adjustPoolSize(targetSize: number): Promise<void>;
71
- /**
72
- * Get a connection from the pool
73
- */
74
- private getConnection;
75
- /**
76
- * Normalize MySQL/MariaDB errors
77
- */
78
- private normalizeError;
79
- }
@@ -1,96 +0,0 @@
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
- }
@@ -1,43 +0,0 @@
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
- }
@@ -1,45 +0,0 @@
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
- }