@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,643 +0,0 @@
1
- import type { Model, ModelConstructor } from '../orm/model/Model';
2
- import type { BooleanOperator, CompiledQuery, ConnectionContract, CursorPaginateResult, GrammarContract, JoinType, Operator, OrderDirection, PaginateResult, QueryBuilderContract } from '../types';
3
- import { GroupByClause, HavingClause, JoinManager, LimitClause, OrderByClause, SelectClause, WhereClause } from './clauses';
4
- import { Expression } from './Expression';
5
- import type { RelationshipResolver } from './RelationshipResolver';
6
- export declare class QueryBuilderError extends Error {
7
- constructor(message: string);
8
- }
9
- export declare class RecordNotFoundError extends Error {
10
- constructor(message?: string);
11
- }
12
- /**
13
- * Fluent Query Builder for constructing SQL queries.
14
- *
15
- * Provides a chainable interface for building complex SELECT, INSERT, UPDATE,
16
- * and DELETE statements. Supports advanced features like subqueries, joins,
17
- * global scopes, and copy-on-write optimization.
18
- *
19
- * @template T - The structure of the resulting records.
20
- *
21
- * @example
22
- * ```typescript
23
- * const users = await DB.table<User>('users')
24
- * .select('id', 'name')
25
- * .where('status', 'active')
26
- * .orderBy('created_at', 'desc')
27
- * .limit(10)
28
- * .get();
29
- * ```
30
- */
31
- export declare class QueryBuilder<T = Record<string, unknown>> implements QueryBuilderContract<T> {
32
- protected readonly connection: ConnectionContract;
33
- protected readonly grammar: GrammarContract;
34
- /**
35
- * Global relationship resolver to avoid circular dependencies and require() calls.
36
- * Injected by the Model layer.
37
- */
38
- static relationshipResolver?: RelationshipResolver;
39
- /**
40
- * Name of the target database table.
41
- */
42
- protected tableName: string;
43
- /**
44
- * Optional Model class for result hydration.
45
- */
46
- protected modelClass?: ModelConstructor<Model>;
47
- protected selectClause: SelectClause;
48
- protected whereClause: WhereClause;
49
- protected joinManager: JoinManager;
50
- protected groupByClause: GroupByClause;
51
- protected havingClause: HavingClause;
52
- protected orderByClause: OrderByClause;
53
- protected limitClause: LimitClause;
54
- /**
55
- * Read-only flag to bypass hydration for performance.
56
- */
57
- protected isReadOnly: boolean;
58
- /**
59
- * When true, this query will always use the write (primary) connection,
60
- * even if read replicas are configured. Use after a write to avoid
61
- * replication lag issues.
62
- */
63
- protected _forceWrite: boolean;
64
- /**
65
- * Map of relationships to load alongside query results.
66
- */
67
- protected eagerLoads: Map<string, (query: QueryBuilderContract<any>) => void>;
68
- /**
69
- * Result caching configuration.
70
- */
71
- protected _cache?: {
72
- ttl: number;
73
- key?: string;
74
- };
75
- /**
76
- * Internal flag for copy-on-write optimization.
77
- */
78
- protected _isClone: boolean;
79
- /**
80
- * Tracks if clones have been modified.
81
- */
82
- protected _isModified: boolean;
83
- /**
84
- * Tracks reference counts for shared state management.
85
- */
86
- private _cloneCount;
87
- /**
88
- * Registered global query filters.
89
- */
90
- protected globalScopes: Map<string, (query: QueryBuilderContract<any>) => void>;
91
- /**
92
- * Identifiers of scopes to bypass.
93
- */
94
- protected removedScopes: Set<string>;
95
- /**
96
- * Prevents infinite recursion during scope application.
97
- */
98
- protected _isApplyingScopes: boolean;
99
- /**
100
- * Initializes a new query builder.
101
- *
102
- * @param connection - Active database connection.
103
- * @param grammar - SQL compiler instance.
104
- * @param table - Initial table name.
105
- */
106
- constructor(connection: ConnectionContract, grammar: GrammarContract, table: string);
107
- /**
108
- * Implements Copy-on-Write for query cloning.
109
- *
110
- * Shared state (clauses) is lazily copied only when a modification occurs.
111
- * This drastically reduces overhead for operations like .count() or .paginate()
112
- * that require cloning the builder.
113
- *
114
- * @internal
115
- */
116
- protected ensureOwnState(): void;
117
- /**
118
- * Associates a Model with the query for automatic record hydration.
119
- *
120
- * @param model - The Model class constructor.
121
- */
122
- setModel<M extends Model>(model: ModelConstructor<M>): this;
123
- /**
124
- * Retrieves the associated Model class.
125
- */
126
- getModel<M extends Model>(): ModelConstructor<M> | undefined;
127
- /**
128
- * Accesses raw WHERE conditions.
129
- * @internal
130
- */
131
- get wheres(): import('./clauses/WhereClause').WhereCondition[];
132
- /**
133
- * Specifies the columns to be retrieved.
134
- *
135
- * @param columns - List of column names.
136
- */
137
- select(...columns: string[]): this;
138
- /**
139
- * Sets the target database table.
140
- */
141
- from(table: string): this;
142
- /**
143
- * Adds a raw SQL expression to the SELECT clause.
144
- *
145
- * @param sql - Raw SQL template or Expression instance.
146
- * @param bindings - Binding values.
147
- */
148
- selectRaw(sql: string | Expression, bindings?: unknown[]): this;
149
- /**
150
- * Adds the DISTINCT keyword to the selection.
151
- */
152
- distinct(): this;
153
- /**
154
- * Configures query result caching.
155
- *
156
- * @param ttl - Duration in seconds.
157
- * @param key - Explicit cache identifier.
158
- */
159
- cache(ttl: number, key?: string): this;
160
- /**
161
- * Adds a WHERE constraint to the query.
162
- *
163
- * Supports various formats:
164
- * - Key-value object: .where({ id: 1, active: true })
165
- * - Operator form: .where('age', '>', 18)
166
- * - Nested closure: .where(q => q.where('a', 1).orWhere('b', 2))
167
- *
168
- * @param column - Column name, closure, or object.
169
- * @param operatorOrValue - Comparison operator or value.
170
- * @param value - Value (if operator is provided).
171
- */
172
- where(column: string | ((query: QueryBuilderContract<T>) => void) | Record<string, unknown>, operatorOrValue?: Operator | unknown, value?: unknown): this;
173
- /**
174
- * Adds an OR WHERE constraint.
175
- */
176
- orWhere(column: string | ((query: QueryBuilderContract<T>) => void), operatorOrValue?: Operator | unknown, value?: unknown): this;
177
- /**
178
- * Adds a WHERE IN constraint.
179
- *
180
- * @param column - Target column.
181
- * @param values - Values array or subquery.
182
- */
183
- whereIn(column: string, values: unknown[] | QueryBuilderContract<any>): this;
184
- /**
185
- * Adds a WHERE NOT IN constraint.
186
- */
187
- whereNotIn(column: string, values: unknown[] | QueryBuilderContract<any>): this;
188
- /**
189
- * Adds an OR WHERE IN constraint.
190
- */
191
- orWhereIn(column: string, values: unknown[] | QueryBuilderContract<any>): this;
192
- /**
193
- * Adds an OR WHERE NOT IN constraint.
194
- */
195
- orWhereNotIn(column: string, values: unknown[] | QueryBuilderContract<any>): this;
196
- /**
197
- * Adds a WHERE column IS NULL constraint.
198
- */
199
- whereNull(column: string): this;
200
- /**
201
- * Adds a WHERE column IS NOT NULL constraint.
202
- */
203
- whereNotNull(column: string): this;
204
- /**
205
- * Adds an OR WHERE column IS NULL constraint.
206
- */
207
- orWhereNull(column: string): this;
208
- /**
209
- * Adds an OR WHERE column IS NOT NULL constraint.
210
- */
211
- orWhereNotNull(column: string): this;
212
- /**
213
- * Adds a WHERE BETWEEN constraint.
214
- */
215
- whereBetween(column: string, values: [unknown, unknown]): this;
216
- /**
217
- * Adds a WHERE NOT BETWEEN constraint.
218
- */
219
- whereNotBetween(column: string, values: [unknown, unknown]): this;
220
- /**
221
- * Adds a raw SQL WHERE constraint.
222
- */
223
- whereRaw(sql: string | Expression, bindings?: unknown[]): this;
224
- /**
225
- * Adds an OR WHERE raw SQL constraint.
226
- */
227
- orWhereRaw(sql: string | Expression, bindings?: unknown[]): this;
228
- /**
229
- * Compares two columns in a WHERE clause.
230
- */
231
- whereColumn(first: string, operator: Operator, second: string): this;
232
- /**
233
- * Adds a WHERE EXISTS subquery constraint.
234
- *
235
- * @param callback - Logic for the subquery.
236
- */
237
- whereExists(callback: (query: QueryBuilderContract<any>) => void): this;
238
- /**
239
- * Adds a WHERE NOT EXISTS subquery constraint.
240
- */
241
- whereNotExists(callback: (query: QueryBuilderContract<any>) => void): this;
242
- /**
243
- * Adds a constraint for a nested JSON property.
244
- *
245
- * @param column - Path using "->" syntax.
246
- * @param value - Match value.
247
- */
248
- whereJson(column: string, value: unknown): this;
249
- /**
250
- * Adds an OR WHERE constraint for a nested JSON property.
251
- */
252
- orWhereJson(column: string, value: unknown): this;
253
- /**
254
- * Checks if a JSON column contains a specific value.
255
- */
256
- whereJsonContains(column: string, value: unknown): this;
257
- /**
258
- * OR version of {@link whereJsonContains}.
259
- */
260
- orWhereJsonContains(column: string, value: unknown): this;
261
- /**
262
- * Spatial distance filter: matches records within a given radius.
263
- *
264
- * Generates dialect-appropriate SQL:
265
- * - **PostgreSQL**: `ST_DWithin(column::geography, ST_MakePoint(lng, lat)::geography, distance)`
266
- * - **MySQL**: `ST_Distance_Sphere(column, POINT(lng, lat)) <= distance`
267
- *
268
- * Requires a spatial/geometry column and a GIS extension.
269
- *
270
- * @param column - The geometry/geography column name
271
- * @param point - GPS point `{ lat, lng }` in decimal degrees
272
- * @param distanceMeters - Search radius in meters
273
- *
274
- * @example
275
- * ```typescript
276
- * // Find all stores within 5km of a location
277
- * await Store.query().whereDistanceWithin('location', { lat: 25.04, lng: 121.52 }, 5000).get()
278
- * ```
279
- */
280
- whereDistanceWithin(column: string, point: {
281
- lat: number;
282
- lng: number;
283
- }, distanceMeters: number): this;
284
- /**
285
- * Groups constraints in parentheses.
286
- *
287
- * @param callback - Closure for nested builder.
288
- * @param boolean - Connector (and/or).
289
- * @internal
290
- */
291
- protected whereNested(callback: (query: QueryBuilderContract<T>) => void, boolean: BooleanOperator): this;
292
- /**
293
- * Adds an INNER JOIN.
294
- */
295
- join(table: string, first: string, operator: string, second: string): this;
296
- /**
297
- * Adds a LEFT JOIN.
298
- */
299
- leftJoin(table: string, first: string, operator: string, second: string): this;
300
- /**
301
- * Adds a RIGHT JOIN.
302
- */
303
- rightJoin(table: string, first: string, operator: string, second: string): this;
304
- /**
305
- * Adds a CROSS JOIN.
306
- */
307
- crossJoin(table: string): this;
308
- /**
309
- * Internal join registration.
310
- * @internal
311
- */
312
- protected addJoin(type: JoinType, table: string, first: string, operator: string, second: string): this;
313
- /**
314
- * Defines the GROUP BY clause.
315
- */
316
- groupBy(...columns: string[]): this;
317
- /**
318
- * Defines a HAVING constraint.
319
- */
320
- having(column: string, operator: Operator, value: unknown): this;
321
- /**
322
- * Defines a raw HAVING constraint.
323
- */
324
- havingRaw(sql: string | Expression, bindings?: unknown[]): this;
325
- /**
326
- * Defines the ORDER BY clause.
327
- */
328
- orderBy(column: string, direction?: OrderDirection): this;
329
- /**
330
- * Helper for DESC ordering.
331
- */
332
- orderByDesc(column: string): this;
333
- /**
334
- * Adds a raw SQL ORDER BY clause.
335
- */
336
- orderByRaw(sql: string | Expression, bindings?: unknown[]): this;
337
- /**
338
- * Orders results by the latest created_at timestamp.
339
- */
340
- latest(column?: string): this;
341
- /**
342
- * Orders results by the oldest created_at timestamp.
343
- */
344
- oldest(column?: string): this;
345
- /**
346
- * Constrains the number of results.
347
- */
348
- limit(value: number): this;
349
- /**
350
- * Skips the specified number of results.
351
- */
352
- offset(value: number): this;
353
- /**
354
- * Alias for {@link offset}.
355
- */
356
- skip(value: number): this;
357
- /**
358
- * Alias for {@link limit}.
359
- */
360
- take(value: number): this;
361
- /**
362
- * Executes the query using a server-side prepared statement for speed.
363
- */
364
- getPrepared(): Promise<T[]>;
365
- /**
366
- * Fetches raw database rows, bypassing the Model hydration layer.
367
- *
368
- * @returns Array of plain objects.
369
- * @internal
370
- */
371
- getRawResults(): Promise<Record<string, unknown>[]>;
372
- /**
373
- * Executes the query and returns hydrated records.
374
- */
375
- get(): Promise<T[]>;
376
- /**
377
- * Provides an async iterator to stream results one by one.
378
- *
379
- * Essential for processing datasets that exceed memory capacity.
380
- */
381
- stream(): AsyncIterable<T>;
382
- /**
383
- * Returns the first record matching the query.
384
- */
385
- first(): Promise<T | null>;
386
- /**
387
- * Fails if no record matches the query.
388
- * @throws {RecordNotFoundError}
389
- */
390
- firstOrFail(): Promise<T>;
391
- /**
392
- * Shortcut for searching by primary key.
393
- */
394
- find(id: unknown, primaryKey?: string): Promise<T | null>;
395
- /**
396
- * Fails if primary key search yields no result.
397
- */
398
- findOrFail(id: unknown, primaryKey?: string): Promise<T>;
399
- /**
400
- * Retrieves a single column value from the first matching record.
401
- */
402
- value<V = unknown>(column: string): Promise<V | null>;
403
- /**
404
- * Retrieves an array of values for a single column.
405
- */
406
- pluck<V = unknown>(column: string): Promise<V[]>;
407
- /**
408
- * Returns true if any records match the query.
409
- */
410
- exists(): Promise<boolean>;
411
- /**
412
- * Inverse of {@link exists}.
413
- */
414
- doesntExist(): Promise<boolean>;
415
- /**
416
- * Returns the count of matching records.
417
- */
418
- count(column?: string): Promise<number>;
419
- /**
420
- * Returns the maximum value of a column.
421
- */
422
- max<V = number>(column: string): Promise<V | null>;
423
- /**
424
- * Returns the minimum value of a column.
425
- */
426
- min<V = number>(column: string): Promise<V | null>;
427
- /**
428
- * Returns the average value of a column.
429
- */
430
- avg(column: string): Promise<number | null>;
431
- /**
432
- * Returns the sum of a column's values.
433
- */
434
- sum(column: string): Promise<number>;
435
- /**
436
- * Internal generic aggregate execution.
437
- * @internal
438
- */
439
- protected aggregate(func: string, column: string): Promise<number | null>;
440
- /**
441
- * Inserts data into the table.
442
- *
443
- * Automatically handles batching (chunking) to stay within binding limits.
444
- *
445
- * @param data - Single object or array of objects.
446
- * @returns Array of inserted objects (with generated IDs if supported).
447
- */
448
- insert(data: Partial<T> | Partial<T>[]): Promise<T[]>;
449
- /**
450
- * Inserts data and returns the primary key.
451
- *
452
- * @param data - Record data.
453
- * @param primaryKey - Name of the auto-increment column.
454
- * @returns Generated ID.
455
- * @throws {QueryBuilderError} If ID retrieval fails.
456
- */
457
- insertGetId(data: Partial<T>, primaryKey?: string): Promise<number | bigint>;
458
- /**
459
- * Updates records matching the current query state.
460
- *
461
- * @param data - Update values.
462
- * @returns Count of affected rows.
463
- */
464
- update(data: Partial<T>): Promise<number>;
465
- /**
466
- * Specialized method for updating JSON fields.
467
- */
468
- updateJson(column: string, value: unknown): Promise<number>;
469
- /**
470
- * Deletes records matching the query.
471
- *
472
- * Note: This performs a hard delete. For soft deletes, use the Model layer.
473
- */
474
- delete(): Promise<number>;
475
- /**
476
- * Drops all records and resets auto-increment state.
477
- */
478
- truncate(): Promise<void>;
479
- /**
480
- * Defines relationships to load in bulk after the primary query.
481
- */
482
- with(relation: string | string[] | Record<string, (query: QueryBuilderContract<unknown>) => void>): this;
483
- /**
484
- * Filters the query based on relationship existence.
485
- */
486
- whereHas(relation: string, callback?: (query: QueryBuilderContract<unknown>) => void): this;
487
- /**
488
- * Retrieves eager load mapping.
489
- * @internal
490
- */
491
- getEagerLoads(): Map<string, (query: QueryBuilderContract<any>) => void>;
492
- /**
493
- * Includes soft-deleted records (where deleted_at is not null).
494
- */
495
- withTrashed(): this;
496
- /**
497
- * Excludes non-deleted records.
498
- */
499
- onlyTrashed(): this;
500
- /**
501
- * Restores soft-deleted records to active state.
502
- */
503
- restore(): Promise<number>;
504
- /**
505
- * Bypasses soft deletes to permanently remove records.
506
- */
507
- forceDelete(): Promise<number>;
508
- /**
509
- * Atomically increments a numeric column.
510
- */
511
- increment(column: string, amount?: number, extra?: Partial<T>): Promise<number>;
512
- /**
513
- * Atomically decrements a numeric column.
514
- */
515
- decrement(column: string, amount?: number, extra?: Partial<T>): Promise<number>;
516
- /**
517
- * Inserts records or updates them if a uniqueness conflict occurs.
518
- *
519
- * @param data - Records to process.
520
- * @param uniqueBy - Column(s) that identify uniqueness.
521
- * @param update - Column(s) to update on conflict.
522
- * @returns Affected rows.
523
- */
524
- upsert(data: Partial<T> | Partial<T>[], uniqueBy: string | string[], update?: string[]): Promise<number>;
525
- /**
526
- * Alias for {@link paginate}.
527
- */
528
- simplePaginate(perPage?: number, page?: number, primaryKey?: string): Promise<PaginateResult<T>>;
529
- /**
530
- * Forces this query to use the primary (write) connection.
531
- *
532
- * Essential after writes to avoid reading stale data from replicas.
533
- * Example: after saving a model, use `.useWriteConnection()` to read back.
534
- *
535
- * @example
536
- * ```typescript
537
- * await User.create({ name: 'Alice' })
538
- * const alice = await User.query().useWriteConnection().where('name', 'Alice').first()
539
- * ```
540
- */
541
- useWriteConnection(): this;
542
- /**
543
- * Cursor-based pagination for large datasets.
544
- *
545
- * Achieves O(1) performance by using tuple comparison SQL instead of OFFSET.
546
- * Ideal for infinite scroll, API cursors, and feeds with millions of records.
547
- *
548
- * @param limit - Number of records to fetch per page
549
- * @param cursor - Opaque cursor from a previous page's `nextCursor` (undefined for first page)
550
- * @param sortColumn - Column to sort by (defaults to primary key 'id')
551
- * @param direction - Sort direction (defaults to 'asc')
552
- * @returns CursorPaginateResult with data and cursor metadata
553
- *
554
- * @example
555
- * ```typescript
556
- * // First page
557
- * const page1 = await User.query().orderBy('created_at').cursorPaginate(20)
558
- *
559
- * // Next page using cursor from previous result
560
- * const page2 = await User.query().orderBy('created_at').cursorPaginate(20, page1.nextCursor)
561
- * ```
562
- */
563
- cursorPaginate(limit?: number, cursor?: string, sortColumn?: string, direction?: 'asc' | 'desc'): Promise<CursorPaginateResult<T>>;
564
- /**
565
- * Processes the entire dataset in memory-efficient chunks.
566
- *
567
- * @param size - Chunk size.
568
- * @param callback - Logic for each chunk.
569
- */
570
- chunk(size: number, callback: (results: T[]) => Promise<undefined | boolean>): Promise<void>;
571
- /**
572
- * Returns a paginated result set with metadata.
573
- */
574
- paginate(perPage?: number, page?: number, primaryKey?: string): Promise<PaginateResult<T>>;
575
- /**
576
- * Force an ID sort if none exists to prevent skipping records during pagination.
577
- */
578
- ensureDeterministicOrder(primaryKey?: string): this;
579
- /**
580
- * Sets the read-only flag for this query.
581
- */
582
- readonly(value?: boolean): this;
583
- /**
584
- * Checks if read-only is active.
585
- * @internal
586
- */
587
- getIsReadOnly(): boolean;
588
- /**
589
- * Creates a deep copy of the current builder.
590
- *
591
- * Leverages copy-on-write; state is initially shared.
592
- */
593
- clone(): QueryBuilderContract<T>;
594
- /**
595
- * Returns a finalized query structure ready for compilation.
596
- *
597
- * Includes global scope application.
598
- */
599
- getCompiledQuery(): CompiledQuery;
600
- /**
601
- * Internal query structural assembly.
602
- * @internal
603
- */
604
- protected getRawCompiledQuery(): CompiledQuery;
605
- /**
606
- * Executes all registered global scope callbacks.
607
- * @internal
608
- */
609
- protected applyGlobalScopes(): void;
610
- /**
611
- * Returns all bound values for the current state.
612
- */
613
- getBindings(): unknown[];
614
- /**
615
- * Checks for LIMIT or OFFSET definitions.
616
- */
617
- hasLimitOrOffset(): boolean;
618
- /**
619
- * Returns the compiled SQL string.
620
- */
621
- toSql(): string;
622
- /**
623
- * Logs SQL and Bindings to standard output.
624
- */
625
- dump(): this;
626
- /**
627
- * Logs and exits process.
628
- */
629
- dd(): never;
630
- /**
631
- * Registers a permanent filter for this builder instance.
632
- */
633
- applyScope(name: string, callback: (query: QueryBuilderContract<T>) => void): this;
634
- /**
635
- * Bypasses a previously registered scope.
636
- */
637
- withoutGlobalScope(name: string): this;
638
- /**
639
- * Optimizes chunk size to prevent too many bindings for the driver.
640
- * @internal
641
- */
642
- private calculateOptimalChunkSize;
643
- }
@@ -1,23 +0,0 @@
1
- import type { QueryBuilderContract } from '../types';
2
- /**
3
- * Relationship Metadata interface for QueryBuilder
4
- */
5
- export interface RelationshipMeta {
6
- type: string;
7
- related: () => any;
8
- foreignKey?: string;
9
- localKey?: string;
10
- pivotTable?: string;
11
- relatedKey?: string;
12
- pivotColumns?: string[];
13
- morphName?: string;
14
- morphTypeField?: string;
15
- morphIdField?: string;
16
- }
17
- /**
18
- * Relationship Resolver interface to decouple QueryBuilder from Model relationships
19
- */
20
- export interface RelationshipResolver {
21
- getRelationships(model: any): Map<string, RelationshipMeta>;
22
- eagerLoadMany(parents: any[], relations: string[] | Record<string, any> | Map<string, (query: QueryBuilderContract<any>) => void>): Promise<void>;
23
- }