@gravito/echo 3.1.1 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (292) hide show
  1. package/README.md +24 -9
  2. package/dist/OrbitEcho.d.ts +76 -60
  3. package/dist/index.d.ts +31 -16
  4. package/dist/index.js +1 -1596
  5. package/dist/index.js.map +3 -28
  6. package/dist/{echo/src/middleware → middleware}/RequestBufferMiddleware.d.ts +3 -3
  7. package/dist/providers/GenericProvider.d.ts +37 -19
  8. package/dist/providers/GitHubProvider.d.ts +21 -13
  9. package/dist/providers/StripeProvider.d.ts +20 -13
  10. package/dist/providers/index.d.ts +14 -4
  11. package/dist/receive/SignatureValidator.d.ts +33 -1
  12. package/dist/receive/WebhookReceiver.d.ts +139 -22
  13. package/dist/receive/index.d.ts +0 -1
  14. package/dist/send/WebhookDispatcher.d.ts +159 -16
  15. package/dist/send/index.d.ts +0 -1
  16. package/dist/types.d.ts +669 -57
  17. package/package.json +5 -2
  18. package/dist/OrbitEcho.d.ts.map +0 -1
  19. package/dist/atlas/src/DB.d.ts +0 -348
  20. package/dist/atlas/src/OrbitAtlas.d.ts +0 -9
  21. package/dist/atlas/src/config/defineConfig.d.ts +0 -14
  22. package/dist/atlas/src/config/index.d.ts +0 -7
  23. package/dist/atlas/src/config/loadConfig.d.ts +0 -41
  24. package/dist/atlas/src/connection/Connection.d.ts +0 -112
  25. package/dist/atlas/src/connection/ConnectionManager.d.ts +0 -180
  26. package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +0 -54
  27. package/dist/atlas/src/drivers/BunSQLDriver.d.ts +0 -32
  28. package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +0 -118
  29. package/dist/atlas/src/drivers/MongoDBDriver.d.ts +0 -36
  30. package/dist/atlas/src/drivers/MySQLDriver.d.ts +0 -79
  31. package/dist/atlas/src/drivers/PostgresDriver.d.ts +0 -96
  32. package/dist/atlas/src/drivers/RedisDriver.d.ts +0 -43
  33. package/dist/atlas/src/drivers/SQLiteDriver.d.ts +0 -45
  34. package/dist/atlas/src/drivers/types.d.ts +0 -260
  35. package/dist/atlas/src/errors/index.d.ts +0 -45
  36. package/dist/atlas/src/grammar/Grammar.d.ts +0 -342
  37. package/dist/atlas/src/grammar/MongoGrammar.d.ts +0 -47
  38. package/dist/atlas/src/grammar/MySQLGrammar.d.ts +0 -54
  39. package/dist/atlas/src/grammar/NullGrammar.d.ts +0 -35
  40. package/dist/atlas/src/grammar/PostgresGrammar.d.ts +0 -62
  41. package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +0 -32
  42. package/dist/atlas/src/index.d.ts +0 -79
  43. package/dist/atlas/src/migration/Migration.d.ts +0 -64
  44. package/dist/atlas/src/migration/MigrationRepository.d.ts +0 -65
  45. package/dist/atlas/src/migration/Migrator.d.ts +0 -110
  46. package/dist/atlas/src/migration/index.d.ts +0 -6
  47. package/dist/atlas/src/observability/AtlasMetrics.d.ts +0 -33
  48. package/dist/atlas/src/observability/AtlasObservability.d.ts +0 -15
  49. package/dist/atlas/src/observability/AtlasTracer.d.ts +0 -12
  50. package/dist/atlas/src/observability/index.d.ts +0 -9
  51. package/dist/atlas/src/orm/Repository.d.ts +0 -247
  52. package/dist/atlas/src/orm/index.d.ts +0 -6
  53. package/dist/atlas/src/orm/model/DirtyTracker.d.ts +0 -121
  54. package/dist/atlas/src/orm/model/Model.d.ts +0 -458
  55. package/dist/atlas/src/orm/model/ModelRegistry.d.ts +0 -20
  56. package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +0 -150
  57. package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +0 -36
  58. package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +0 -92
  59. package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +0 -117
  60. package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +0 -64
  61. package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +0 -15
  62. package/dist/atlas/src/orm/model/concerns/index.d.ts +0 -12
  63. package/dist/atlas/src/orm/model/decorators.d.ts +0 -138
  64. package/dist/atlas/src/orm/model/errors.d.ts +0 -52
  65. package/dist/atlas/src/orm/model/index.d.ts +0 -10
  66. package/dist/atlas/src/orm/model/relationships.d.ts +0 -207
  67. package/dist/atlas/src/orm/model/types.d.ts +0 -12
  68. package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +0 -124
  69. package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +0 -54
  70. package/dist/atlas/src/orm/schema/index.d.ts +0 -6
  71. package/dist/atlas/src/orm/schema/types.d.ts +0 -85
  72. package/dist/atlas/src/pool/AdaptivePoolManager.d.ts +0 -98
  73. package/dist/atlas/src/pool/PoolHealthChecker.d.ts +0 -91
  74. package/dist/atlas/src/pool/PoolStrategy.d.ts +0 -129
  75. package/dist/atlas/src/pool/PoolWarmer.d.ts +0 -92
  76. package/dist/atlas/src/query/Expression.d.ts +0 -60
  77. package/dist/atlas/src/query/NPlusOneDetector.d.ts +0 -10
  78. package/dist/atlas/src/query/QueryBuilder.d.ts +0 -643
  79. package/dist/atlas/src/query/RelationshipResolver.d.ts +0 -23
  80. package/dist/atlas/src/query/clauses/GroupByClause.d.ts +0 -51
  81. package/dist/atlas/src/query/clauses/HavingClause.d.ts +0 -70
  82. package/dist/atlas/src/query/clauses/JoinClause.d.ts +0 -87
  83. package/dist/atlas/src/query/clauses/LimitClause.d.ts +0 -82
  84. package/dist/atlas/src/query/clauses/OrderByClause.d.ts +0 -69
  85. package/dist/atlas/src/query/clauses/SelectClause.d.ts +0 -71
  86. package/dist/atlas/src/query/clauses/WhereClause.d.ts +0 -167
  87. package/dist/atlas/src/query/clauses/index.d.ts +0 -11
  88. package/dist/atlas/src/schema/Blueprint.d.ts +0 -276
  89. package/dist/atlas/src/schema/ColumnDefinition.d.ts +0 -154
  90. package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +0 -37
  91. package/dist/atlas/src/schema/MigrationGenerator.d.ts +0 -45
  92. package/dist/atlas/src/schema/Schema.d.ts +0 -131
  93. package/dist/atlas/src/schema/SchemaDiff.d.ts +0 -73
  94. package/dist/atlas/src/schema/TypeGenerator.d.ts +0 -57
  95. package/dist/atlas/src/schema/TypeWriter.d.ts +0 -42
  96. package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +0 -23
  97. package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +0 -26
  98. package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +0 -28
  99. package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +0 -97
  100. package/dist/atlas/src/schema/grammars/index.d.ts +0 -7
  101. package/dist/atlas/src/schema/index.d.ts +0 -8
  102. package/dist/atlas/src/seed/Factory.d.ts +0 -90
  103. package/dist/atlas/src/seed/Seeder.d.ts +0 -28
  104. package/dist/atlas/src/seed/SeederRunner.d.ts +0 -74
  105. package/dist/atlas/src/seed/index.d.ts +0 -6
  106. package/dist/atlas/src/sharding/ShardingManager.d.ts +0 -59
  107. package/dist/atlas/src/types/index.d.ts +0 -1182
  108. package/dist/atlas/src/utils/CursorEncoding.d.ts +0 -63
  109. package/dist/atlas/src/utils/levenshtein.d.ts +0 -9
  110. package/dist/core/src/Application.d.ts +0 -215
  111. package/dist/core/src/CommandKernel.d.ts +0 -33
  112. package/dist/core/src/ConfigManager.d.ts +0 -65
  113. package/dist/core/src/Container/RequestScopeManager.d.ts +0 -62
  114. package/dist/core/src/Container/RequestScopeMetrics.d.ts +0 -144
  115. package/dist/core/src/Container.d.ts +0 -153
  116. package/dist/core/src/ErrorHandler.d.ts +0 -66
  117. package/dist/core/src/Event.d.ts +0 -5
  118. package/dist/core/src/EventManager.d.ts +0 -123
  119. package/dist/core/src/GlobalErrorHandlers.d.ts +0 -47
  120. package/dist/core/src/GravitoServer.d.ts +0 -28
  121. package/dist/core/src/HookManager.d.ts +0 -591
  122. package/dist/core/src/Listener.d.ts +0 -4
  123. package/dist/core/src/Logger.d.ts +0 -20
  124. package/dist/core/src/PlanetCore.d.ts +0 -378
  125. package/dist/core/src/RequestContext.d.ts +0 -97
  126. package/dist/core/src/Route.d.ts +0 -36
  127. package/dist/core/src/Router.d.ts +0 -284
  128. package/dist/core/src/ServiceProvider.d.ts +0 -178
  129. package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +0 -27
  130. package/dist/core/src/adapters/PhotonAdapter.d.ts +0 -175
  131. package/dist/core/src/adapters/bun/BunContext.d.ts +0 -49
  132. package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +0 -31
  133. package/dist/core/src/adapters/bun/BunRequest.d.ts +0 -31
  134. package/dist/core/src/adapters/bun/RadixNode.d.ts +0 -19
  135. package/dist/core/src/adapters/bun/RadixRouter.d.ts +0 -31
  136. package/dist/core/src/adapters/bun/types.d.ts +0 -20
  137. package/dist/core/src/adapters/photon-types.d.ts +0 -73
  138. package/dist/core/src/adapters/types.d.ts +0 -235
  139. package/dist/core/src/cli/queue-commands.d.ts +0 -6
  140. package/dist/core/src/engine/AOTRouter.d.ts +0 -129
  141. package/dist/core/src/engine/FastContext.d.ts +0 -123
  142. package/dist/core/src/engine/Gravito.d.ts +0 -136
  143. package/dist/core/src/engine/MinimalContext.d.ts +0 -100
  144. package/dist/core/src/engine/analyzer.d.ts +0 -27
  145. package/dist/core/src/engine/constants.d.ts +0 -23
  146. package/dist/core/src/engine/index.d.ts +0 -26
  147. package/dist/core/src/engine/path.d.ts +0 -26
  148. package/dist/core/src/engine/pool.d.ts +0 -83
  149. package/dist/core/src/engine/types.d.ts +0 -146
  150. package/dist/core/src/error-handling/RequestScopeErrorContext.d.ts +0 -126
  151. package/dist/core/src/events/BackpressureManager.d.ts +0 -215
  152. package/dist/core/src/events/CircuitBreaker.d.ts +0 -229
  153. package/dist/core/src/events/DeadLetterQueue.d.ts +0 -219
  154. package/dist/core/src/events/EventBackend.d.ts +0 -12
  155. package/dist/core/src/events/EventOptions.d.ts +0 -204
  156. package/dist/core/src/events/EventPriorityQueue.d.ts +0 -301
  157. package/dist/core/src/events/FlowControlStrategy.d.ts +0 -109
  158. package/dist/core/src/events/IdempotencyCache.d.ts +0 -60
  159. package/dist/core/src/events/MessageQueueBridge.d.ts +0 -184
  160. package/dist/core/src/events/PriorityEscalationManager.d.ts +0 -82
  161. package/dist/core/src/events/RetryScheduler.d.ts +0 -104
  162. package/dist/core/src/events/WorkerPool.d.ts +0 -98
  163. package/dist/core/src/events/WorkerPoolConfig.d.ts +0 -153
  164. package/dist/core/src/events/WorkerPoolMetrics.d.ts +0 -65
  165. package/dist/core/src/events/aggregation/AggregationWindow.d.ts +0 -77
  166. package/dist/core/src/events/aggregation/DeduplicationManager.d.ts +0 -135
  167. package/dist/core/src/events/aggregation/EventAggregationManager.d.ts +0 -108
  168. package/dist/core/src/events/aggregation/EventBatcher.d.ts +0 -99
  169. package/dist/core/src/events/aggregation/types.d.ts +0 -117
  170. package/dist/core/src/events/index.d.ts +0 -25
  171. package/dist/core/src/events/observability/EventMetrics.d.ts +0 -132
  172. package/dist/core/src/events/observability/EventTracer.d.ts +0 -68
  173. package/dist/core/src/events/observability/EventTracing.d.ts +0 -161
  174. package/dist/core/src/events/observability/OTelEventMetrics.d.ts +0 -332
  175. package/dist/core/src/events/observability/ObservableHookManager.d.ts +0 -108
  176. package/dist/core/src/events/observability/StreamWorkerMetrics.d.ts +0 -76
  177. package/dist/core/src/events/observability/index.d.ts +0 -24
  178. package/dist/core/src/events/observability/metrics-types.d.ts +0 -16
  179. package/dist/core/src/events/types.d.ts +0 -134
  180. package/dist/core/src/exceptions/AuthenticationException.d.ts +0 -8
  181. package/dist/core/src/exceptions/AuthorizationException.d.ts +0 -8
  182. package/dist/core/src/exceptions/CircularDependencyException.d.ts +0 -9
  183. package/dist/core/src/exceptions/GravitoException.d.ts +0 -23
  184. package/dist/core/src/exceptions/HttpException.d.ts +0 -9
  185. package/dist/core/src/exceptions/ModelNotFoundException.d.ts +0 -10
  186. package/dist/core/src/exceptions/ValidationException.d.ts +0 -22
  187. package/dist/core/src/exceptions/index.d.ts +0 -7
  188. package/dist/core/src/health/HealthProvider.d.ts +0 -67
  189. package/dist/core/src/helpers/Arr.d.ts +0 -19
  190. package/dist/core/src/helpers/Str.d.ts +0 -23
  191. package/dist/core/src/helpers/data.d.ts +0 -25
  192. package/dist/core/src/helpers/errors.d.ts +0 -34
  193. package/dist/core/src/helpers/response.d.ts +0 -41
  194. package/dist/core/src/helpers.d.ts +0 -338
  195. package/dist/core/src/http/CookieJar.d.ts +0 -51
  196. package/dist/core/src/http/cookie.d.ts +0 -29
  197. package/dist/core/src/http/middleware/BodySizeLimit.d.ts +0 -16
  198. package/dist/core/src/http/middleware/Cors.d.ts +0 -24
  199. package/dist/core/src/http/middleware/Csrf.d.ts +0 -23
  200. package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +0 -28
  201. package/dist/core/src/http/middleware/SecurityHeaders.d.ts +0 -29
  202. package/dist/core/src/http/middleware/ThrottleRequests.d.ts +0 -18
  203. package/dist/core/src/http/types.d.ts +0 -374
  204. package/dist/core/src/index.d.ts +0 -88
  205. package/dist/core/src/instrumentation/index.d.ts +0 -35
  206. package/dist/core/src/instrumentation/opentelemetry.d.ts +0 -178
  207. package/dist/core/src/instrumentation/types.d.ts +0 -182
  208. package/dist/core/src/observability/Metrics.d.ts +0 -244
  209. package/dist/core/src/observability/QueueDashboard.d.ts +0 -136
  210. package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +0 -350
  211. package/dist/core/src/reliability/RetryPolicy.d.ts +0 -217
  212. package/dist/core/src/reliability/index.d.ts +0 -6
  213. package/dist/core/src/router/ControllerDispatcher.d.ts +0 -12
  214. package/dist/core/src/router/RequestValidator.d.ts +0 -20
  215. package/dist/core/src/runtime.d.ts +0 -119
  216. package/dist/core/src/security/Encrypter.d.ts +0 -33
  217. package/dist/core/src/security/Hasher.d.ts +0 -29
  218. package/dist/core/src/testing/HttpTester.d.ts +0 -39
  219. package/dist/core/src/testing/TestResponse.d.ts +0 -78
  220. package/dist/core/src/testing/index.d.ts +0 -2
  221. package/dist/core/src/types/events.d.ts +0 -94
  222. package/dist/echo/src/OrbitEcho.d.ts +0 -115
  223. package/dist/echo/src/index.d.ts +0 -64
  224. package/dist/echo/src/providers/GenericProvider.d.ts +0 -53
  225. package/dist/echo/src/providers/GitHubProvider.d.ts +0 -35
  226. package/dist/echo/src/providers/StripeProvider.d.ts +0 -38
  227. package/dist/echo/src/providers/index.d.ts +0 -14
  228. package/dist/echo/src/receive/SignatureValidator.d.ts +0 -67
  229. package/dist/echo/src/receive/WebhookReceiver.d.ts +0 -185
  230. package/dist/echo/src/receive/index.d.ts +0 -2
  231. package/dist/echo/src/send/WebhookDispatcher.d.ts +0 -198
  232. package/dist/echo/src/send/index.d.ts +0 -1
  233. package/dist/echo/src/types.d.ts +0 -756
  234. package/dist/index.d.ts.map +0 -1
  235. package/dist/monitor/src/MonitorOrbit.d.ts +0 -43
  236. package/dist/monitor/src/config.d.ts +0 -106
  237. package/dist/monitor/src/health/HealthController.d.ts +0 -28
  238. package/dist/monitor/src/health/HealthRegistry.d.ts +0 -80
  239. package/dist/monitor/src/health/index.d.ts +0 -36
  240. package/dist/monitor/src/index.d.ts +0 -13
  241. package/dist/monitor/src/metrics/MetricsController.d.ts +0 -22
  242. package/dist/monitor/src/metrics/MetricsRegistry.d.ts +0 -136
  243. package/dist/monitor/src/metrics/index.d.ts +0 -11
  244. package/dist/monitor/src/tracing/TracingManager.d.ts +0 -97
  245. package/dist/monitor/src/tracing/index.d.ts +0 -10
  246. package/dist/photon/src/index.d.ts +0 -89
  247. package/dist/photon/src/middleware/binary.d.ts +0 -31
  248. package/dist/photon/src/middleware/htmx.d.ts +0 -39
  249. package/dist/photon/src/middleware/ratelimit-redis.d.ts +0 -50
  250. package/dist/photon/src/middleware/ratelimit.d.ts +0 -161
  251. package/dist/photon/src/openapi.d.ts +0 -19
  252. package/dist/providers/GenericProvider.d.ts.map +0 -1
  253. package/dist/providers/GitHubProvider.d.ts.map +0 -1
  254. package/dist/providers/StripeProvider.d.ts.map +0 -1
  255. package/dist/providers/index.d.ts.map +0 -1
  256. package/dist/receive/SignatureValidator.d.ts.map +0 -1
  257. package/dist/receive/WebhookReceiver.d.ts.map +0 -1
  258. package/dist/receive/index.d.ts.map +0 -1
  259. package/dist/send/WebhookDispatcher.d.ts.map +0 -1
  260. package/dist/send/index.d.ts.map +0 -1
  261. package/dist/types.d.ts.map +0 -1
  262. /package/dist/{echo/src/dlq → dlq}/DeadLetterQueue.d.ts +0 -0
  263. /package/dist/{echo/src/dlq → dlq}/MemoryDeadLetterQueue.d.ts +0 -0
  264. /package/dist/{echo/src/dlq → dlq}/index.d.ts +0 -0
  265. /package/dist/{echo/src/middleware → middleware}/index.d.ts +0 -0
  266. /package/dist/{echo/src/observability → observability}/index.d.ts +0 -0
  267. /package/dist/{echo/src/observability → observability}/logging/ConsoleEchoLogger.d.ts +0 -0
  268. /package/dist/{echo/src/observability → observability}/logging/EchoLogger.d.ts +0 -0
  269. /package/dist/{echo/src/observability → observability}/logging/index.d.ts +0 -0
  270. /package/dist/{echo/src/observability → observability}/metrics/MetricsProvider.d.ts +0 -0
  271. /package/dist/{echo/src/observability → observability}/metrics/NoopMetricsProvider.d.ts +0 -0
  272. /package/dist/{echo/src/observability → observability}/metrics/PrometheusMetricsProvider.d.ts +0 -0
  273. /package/dist/{echo/src/observability → observability}/metrics/index.d.ts +0 -0
  274. /package/dist/{echo/src/observability → observability}/tracing/NoopTracer.d.ts +0 -0
  275. /package/dist/{echo/src/observability → observability}/tracing/Tracer.d.ts +0 -0
  276. /package/dist/{echo/src/observability → observability}/tracing/index.d.ts +0 -0
  277. /package/dist/{echo/src/providers → providers}/LinearProvider.d.ts +0 -0
  278. /package/dist/{echo/src/providers → providers}/PaddleProvider.d.ts +0 -0
  279. /package/dist/{echo/src/providers → providers}/ShopifyProvider.d.ts +0 -0
  280. /package/dist/{echo/src/providers → providers}/SlackProvider.d.ts +0 -0
  281. /package/dist/{echo/src/providers → providers}/TwilioProvider.d.ts +0 -0
  282. /package/dist/{echo/src/providers → providers}/base/BaseProvider.d.ts +0 -0
  283. /package/dist/{echo/src/providers → providers}/base/HeaderUtils.d.ts +0 -0
  284. /package/dist/{echo/src/replay → replay}/WebhookReplayService.d.ts +0 -0
  285. /package/dist/{echo/src/replay → replay}/index.d.ts +0 -0
  286. /package/dist/{echo/src/resilience → resilience}/CircuitBreaker.d.ts +0 -0
  287. /package/dist/{echo/src/resilience → resilience}/index.d.ts +0 -0
  288. /package/dist/{echo/src/rotation → rotation}/KeyRotationManager.d.ts +0 -0
  289. /package/dist/{echo/src/rotation → rotation}/index.d.ts +0 -0
  290. /package/dist/{echo/src/storage → storage}/MemoryWebhookStore.d.ts +0 -0
  291. /package/dist/{echo/src/storage → storage}/WebhookStore.d.ts +0 -0
  292. /package/dist/{echo/src/storage → storage}/index.d.ts +0 -0
@@ -1,260 +0,0 @@
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
- }
@@ -1,45 +0,0 @@
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
- }
@@ -1,342 +0,0 @@
1
- /**
2
- * Abstract SQL Grammar providing base logic for SQL generation.
3
- *
4
- * Handles the structural assembly of SELECT, INSERT, UPDATE, and DELETE
5
- * statements. Includes a sophisticated compilation cache to minimize
6
- * string manipulation overhead for repetitive query structures.
7
- */
8
- import { LRUCache } from 'lru-cache';
9
- import type { CompiledQuery, GrammarContract, HavingClause, JoinClause, OrderClause, WhereClause } from '../types';
10
- export declare abstract class Grammar implements GrammarContract {
11
- /**
12
- * Optional prefix for all table names.
13
- */
14
- protected tablePrefix: string;
15
- /**
16
- * Database-specific character for wrapping identifiers (e.g., " or `).
17
- */
18
- protected abstract wrapChar: string;
19
- /**
20
- * Internal cache for compiled SQL templates.
21
- * Keyed by structural hash to allow reuse across different parameter values.
22
- */
23
- private static compilationCache;
24
- /**
25
- * Metrics for cache performance monitoring.
26
- */
27
- private static cacheStats;
28
- /**
29
- * Global toggle for SQL compilation caching.
30
- */
31
- static useCache: boolean;
32
- /**
33
- * Determines if the cache is shared globally or isolated per grammar instance.
34
- */
35
- static cacheScope: 'global' | 'instance';
36
- private _instanceCache?;
37
- private _instanceCacheStats;
38
- /**
39
- * Retrieves performance metrics for the compilation cache.
40
- *
41
- * @returns Stats including hit rate and utilization.
42
- */
43
- static getCacheStats(): {
44
- size: number;
45
- maxSize: number;
46
- hits: number;
47
- misses: number;
48
- sets: number;
49
- hitRate: number;
50
- missRate: number;
51
- totalRequests: number;
52
- utilization: number;
53
- };
54
- /**
55
- * Retrieves metrics for the instance-level cache.
56
- *
57
- * @returns Stats object or null if instance caching is disabled.
58
- */
59
- getInstanceCacheStats(): {
60
- size: number;
61
- maxSize: number;
62
- hits: number;
63
- misses: number;
64
- sets: number;
65
- hitRate: number;
66
- missRate: number;
67
- totalRequests: number;
68
- utilization: number;
69
- } | null;
70
- /**
71
- * Flushes all performance counters.
72
- */
73
- static resetCacheStats(): void;
74
- /**
75
- * Wipes the compilation cache.
76
- */
77
- static clearCache(): void;
78
- /**
79
- * Resizes the global compilation cache.
80
- *
81
- * @param max - Maximum number of templates to store.
82
- */
83
- static setCacheSize(max: number): void;
84
- /**
85
- * Resolves the active cache instance based on scope configuration.
86
- * @internal
87
- */
88
- protected getCompilationCache(): LRUCache<string, string>;
89
- /**
90
- * Returns the database-specific placeholder (e.g., ?, $1, :name).
91
- *
92
- * @param index - The zero-based binding index.
93
- */
94
- abstract getPlaceholder(index: number): string;
95
- /**
96
- * Compiles an INSERT statement that returns the primary key.
97
- */
98
- abstract compileInsertGetId(query: CompiledQuery, values: Record<string, unknown>, primaryKey: string): string;
99
- /**
100
- * Transforms a query structure into a SELECT SQL string.
101
- *
102
- * Leverages caching by generating a structural key that ignores binding values.
103
- *
104
- * @param query - The structural definition of the query.
105
- * @returns The compiled SQL string.
106
- */
107
- compileSelect(query: CompiledQuery): string;
108
- /**
109
- * Generates a unique hash representing the SQL structure.
110
- *
111
- * Ignores specific binding values to allow cache hits for similar queries.
112
- * Uses efficient array joining for performance.
113
- *
114
- * @param query - The query structure.
115
- * @returns A deterministic string key.
116
- */
117
- getStructuralKey(query: CompiledQuery): string;
118
- /**
119
- * Compiles the SELECT list.
120
- * @internal
121
- */
122
- protected compileColumns(query: CompiledQuery): string;
123
- /**
124
- * Compiles the FROM clause.
125
- * @internal
126
- */
127
- protected compileFrom(query: CompiledQuery): string;
128
- /**
129
- * Compiles all WHERE constraints.
130
- *
131
- * @param query - The query definition.
132
- * @param bindingOffset - Initial parameter index.
133
- * @returns Compiled SQL snippet.
134
- * @internal
135
- */
136
- protected compileWheres(query: CompiledQuery, bindingOffset?: number): string;
137
- /**
138
- * @deprecated Use compileWhereWithOffset.
139
- */
140
- protected compileWhere(where: WhereClause, _query: CompiledQuery): string;
141
- /**
142
- * Compiles a single WHERE clause with offset awareness.
143
- * @internal
144
- */
145
- protected compileWhereWithOffset(where: WhereClause, offset: number): {
146
- sql: string;
147
- bindingsUsed: number;
148
- };
149
- /**
150
- * Compiles a standard equality or comparison clause.
151
- * @internal
152
- */
153
- protected compileWhereBasicWithOffset(where: WhereClause, offset: number): string;
154
- /**
155
- * Compiles an IN clause.
156
- * @internal
157
- */
158
- protected compileWhereInWithOffset(where: WhereClause, offset: number): string;
159
- /**
160
- * Wraps nested SQL in parentheses.
161
- * @internal
162
- */
163
- protected compileWhereNested(where: WhereClause): string;
164
- /**
165
- * Compiles IS NULL constraints.
166
- * @internal
167
- */
168
- protected compileWhereNull(where: WhereClause): string;
169
- /**
170
- * Compiles BETWEEN constraints.
171
- * @internal
172
- */
173
- protected compileWhereBetweenWithOffset(where: WhereClause, offset: number): string;
174
- /**
175
- * Compiles column-to-column comparisons.
176
- * @internal
177
- */
178
- protected compileWhereColumn(where: WhereClause): string;
179
- /**
180
- * Compiles all JOIN clauses.
181
- * @internal
182
- */
183
- protected compileJoins(query: CompiledQuery): string;
184
- /**
185
- * Compiles a single JOIN relationship.
186
- * @internal
187
- */
188
- protected compileJoin(join: JoinClause): string;
189
- /**
190
- * Compiles the GROUP BY clause.
191
- * @internal
192
- */
193
- protected compileGroups(query: CompiledQuery): string;
194
- /**
195
- * Compiles all HAVING constraints.
196
- * @internal
197
- */
198
- protected compileHavings(query: CompiledQuery, bindingOffset?: number): string;
199
- /**
200
- * Sums bindings across all WHERE clauses.
201
- * @internal
202
- */
203
- protected countAllWhereBindings(wheres: WhereClause[]): number;
204
- /**
205
- * Counts bindings for a specific WHERE type.
206
- * @internal
207
- */
208
- protected countWhereBindings(where: WhereClause): number;
209
- /**
210
- * Compiles a single HAVING clause.
211
- * @internal
212
- */
213
- protected compileHavingWithOffset(having: HavingClause, offset: number): {
214
- sql: string;
215
- bindingsUsed: number;
216
- };
217
- /**
218
- * @deprecated
219
- */
220
- protected compileHaving(having: HavingClause, _query: CompiledQuery): string;
221
- /**
222
- * Compiles the full ORDER BY clause.
223
- * @internal
224
- */
225
- protected compileOrders(query: CompiledQuery): string;
226
- /**
227
- * Compiles a single sorting rule.
228
- * @internal
229
- */
230
- protected compileOrder(order: OrderClause): string;
231
- /**
232
- * Compiles the LIMIT clause.
233
- * @internal
234
- */
235
- protected compileLimit(query: CompiledQuery): string;
236
- /**
237
- * Compiles the OFFSET clause.
238
- * @internal
239
- */
240
- protected compileOffset(query: CompiledQuery): string;
241
- /**
242
- * Compiles a multi-row INSERT statement.
243
- *
244
- * @param query - The query definition.
245
- * @param values - Records to insert.
246
- * @returns The SQL string.
247
- */
248
- compileInsert(query: CompiledQuery, values: Record<string, unknown>[]): string;
249
- /**
250
- * Compiles an UPDATE statement with WHERE constraints.
251
- *
252
- * @param query - The query definition.
253
- * @param values - Fields and values to update.
254
- * @returns The SQL string.
255
- */
256
- compileUpdate(query: CompiledQuery, values: Record<string, unknown>): string;
257
- /**
258
- * Adjusts placeholders in a pre-compiled snippet.
259
- * @internal
260
- */
261
- protected offsetPlaceholders(sql: string, _offset: number): string;
262
- /**
263
- * Compiles a DELETE statement.
264
- */
265
- compileDelete(query: CompiledQuery): string;
266
- /**
267
- * Compiles a TRUNCATE statement to wipe a table.
268
- */
269
- compileTruncate(query: CompiledQuery): string;
270
- /**
271
- * Compiles an aggregate function selection (COUNT, MAX, etc.).
272
- */
273
- compileAggregate(query: CompiledQuery, aggregate: {
274
- function: string;
275
- column: string;
276
- }): string;
277
- /**
278
- * Compiles an EXISTS check.
279
- */
280
- compileExists(query: CompiledQuery): string;
281
- /**
282
- * Escapes a column name for SQL safety.
283
- *
284
- * Handles table aliases, raw expressions, and wildcards.
285
- *
286
- * @param column - The column identifier.
287
- */
288
- wrapColumn(column: string): string;
289
- /**
290
- * Escapes a table name.
291
- */
292
- wrapTable(table: string): string;
293
- /**
294
- * Internal string escaping.
295
- * @internal
296
- */
297
- protected wrapValue(value: string): string;
298
- /**
299
- * Manually quotes a value for literal injection.
300
- *
301
- * Warning: Prefer bindings over manual quoting for security.
302
- *
303
- * @param value - The value to quote.
304
- */
305
- quoteValue(value: unknown): string;
306
- /**
307
- * Configures a prefix for all table references.
308
- */
309
- setTablePrefix(prefix: string): void;
310
- /**
311
- * Retrieves the current table prefix.
312
- */
313
- getTablePrefix(): string;
314
- /**
315
- * Compiles a query for relationship lateral loading.
316
- * @throws {Error} If unsupported by driver.
317
- */
318
- compileLateralEagerLoad(_table: string, _foreignKey: string, _parentKeys: unknown[], _query: CompiledQuery): {
319
- sql: string;
320
- bindings: unknown[];
321
- };
322
- /**
323
- * Compiles a JSON path selector.
324
- * @throws {Error} If unsupported.
325
- */
326
- compileJsonPath(_column: string, _value: unknown): string;
327
- /**
328
- * Compiles a JSON containment check.
329
- * @throws {Error} If unsupported.
330
- */
331
- compileJsonContains(_column: string, _value: unknown): string;
332
- /**
333
- * Compiles a partial JSON update.
334
- * @throws {Error} If unsupported.
335
- */
336
- compileUpdateJson(_query: CompiledQuery, _column: string, _value: unknown): string;
337
- /**
338
- * Compiles an UPSERT statement.
339
- * @throws {Error} If unsupported.
340
- */
341
- compileUpsert(_query: CompiledQuery, _values: Record<string, unknown>[], _uniqueBy: string[], _update: string[]): string;
342
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * MongoDB Grammar
3
- * @description Translates generic CompiledQuery into a MongoDB Query Protocol (JSON)
4
- */
5
- import type { CompiledQuery } from '../types';
6
- import { Grammar } from './Grammar';
7
- /**
8
- * MongoDB Query Protocol
9
- * Represents the structure passed from Grammar to Driver
10
- */
11
- export interface MongoQueryProtocol {
12
- collection: string;
13
- operation: 'find' | 'insert' | 'update' | 'delete' | 'aggregate' | 'count';
14
- filter?: Record<string, unknown>;
15
- options?: Record<string, unknown>;
16
- document?: Record<string, unknown> | Record<string, unknown>[];
17
- update?: Record<string, unknown>;
18
- pipeline?: Record<string, unknown>[];
19
- }
20
- /**
21
- * Mongo Grammar
22
- * Transforms QueryBuilder state into MongoDB commands
23
- */
24
- export declare class MongoGrammar extends Grammar {
25
- protected wrapChar: string;
26
- getPlaceholder(_index: number): string;
27
- compileInsertGetId(query: CompiledQuery, values: Record<string, unknown>, _primaryKey: string): string;
28
- compileSelect(query: CompiledQuery): string;
29
- compileInsert(query: CompiledQuery, values: Record<string, unknown>[]): string;
30
- compileUpdate(query: CompiledQuery, values: Record<string, unknown>): string;
31
- compileDelete(query: CompiledQuery): string;
32
- compileAggregate(query: CompiledQuery, aggregate: {
33
- function: string;
34
- column: string;
35
- }): string;
36
- compileTruncate(query: CompiledQuery): string;
37
- /**
38
- * Translate generic WhereClause[] to MongoDB Filter
39
- */
40
- private compileMongoWheres;
41
- private normalizeValue;
42
- private compileBasicWhere;
43
- private compileInWhere;
44
- private compileNullWhere;
45
- private normalizeColumn;
46
- compileJsonPath(column: string, value: unknown): string;
47
- }