@gravito/echo 3.0.0 → 3.1.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 (221) hide show
  1. package/README.md +211 -0
  2. package/dist/atlas/src/DB.d.ts +301 -0
  3. package/dist/atlas/src/OrbitAtlas.d.ts +9 -0
  4. package/dist/atlas/src/config/defineConfig.d.ts +14 -0
  5. package/dist/atlas/src/config/index.d.ts +7 -0
  6. package/dist/atlas/src/config/loadConfig.d.ts +48 -0
  7. package/dist/atlas/src/connection/Connection.d.ts +108 -0
  8. package/dist/atlas/src/connection/ConnectionManager.d.ts +111 -0
  9. package/dist/atlas/src/drivers/BunSQLDriver.d.ts +32 -0
  10. package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +118 -0
  11. package/dist/atlas/src/drivers/MongoDBDriver.d.ts +36 -0
  12. package/dist/atlas/src/drivers/MySQLDriver.d.ts +66 -0
  13. package/dist/atlas/src/drivers/PostgresDriver.d.ts +83 -0
  14. package/dist/atlas/src/drivers/RedisDriver.d.ts +43 -0
  15. package/dist/atlas/src/drivers/SQLiteDriver.d.ts +45 -0
  16. package/dist/atlas/src/drivers/types.d.ts +260 -0
  17. package/dist/atlas/src/errors/index.d.ts +45 -0
  18. package/dist/atlas/src/grammar/Grammar.d.ts +342 -0
  19. package/dist/atlas/src/grammar/MongoGrammar.d.ts +47 -0
  20. package/dist/atlas/src/grammar/MySQLGrammar.d.ts +54 -0
  21. package/dist/atlas/src/grammar/NullGrammar.d.ts +35 -0
  22. package/dist/atlas/src/grammar/PostgresGrammar.d.ts +62 -0
  23. package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +32 -0
  24. package/dist/atlas/src/index.d.ts +67 -0
  25. package/dist/atlas/src/migration/Migration.d.ts +64 -0
  26. package/dist/atlas/src/migration/MigrationRepository.d.ts +65 -0
  27. package/dist/atlas/src/migration/Migrator.d.ts +110 -0
  28. package/dist/atlas/src/migration/index.d.ts +6 -0
  29. package/dist/atlas/src/observability/AtlasMetrics.d.ts +11 -0
  30. package/dist/atlas/src/observability/AtlasObservability.d.ts +15 -0
  31. package/dist/atlas/src/observability/AtlasTracer.d.ts +12 -0
  32. package/dist/atlas/src/observability/index.d.ts +9 -0
  33. package/dist/atlas/src/orm/index.d.ts +5 -0
  34. package/dist/atlas/src/orm/model/DirtyTracker.d.ts +121 -0
  35. package/dist/atlas/src/orm/model/Model.d.ts +449 -0
  36. package/dist/atlas/src/orm/model/ModelRegistry.d.ts +20 -0
  37. package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +136 -0
  38. package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +36 -0
  39. package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +87 -0
  40. package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +117 -0
  41. package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +64 -0
  42. package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +15 -0
  43. package/dist/atlas/src/orm/model/concerns/index.d.ts +12 -0
  44. package/dist/atlas/src/orm/model/decorators.d.ts +109 -0
  45. package/dist/atlas/src/orm/model/errors.d.ts +52 -0
  46. package/dist/atlas/src/orm/model/index.d.ts +10 -0
  47. package/dist/atlas/src/orm/model/relationships.d.ts +207 -0
  48. package/dist/atlas/src/orm/model/types.d.ts +12 -0
  49. package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +123 -0
  50. package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +54 -0
  51. package/dist/atlas/src/orm/schema/index.d.ts +6 -0
  52. package/dist/atlas/src/orm/schema/types.d.ts +85 -0
  53. package/dist/atlas/src/query/Expression.d.ts +60 -0
  54. package/dist/atlas/src/query/NPlusOneDetector.d.ts +10 -0
  55. package/dist/atlas/src/query/QueryBuilder.d.ts +573 -0
  56. package/dist/atlas/src/query/clauses/GroupByClause.d.ts +51 -0
  57. package/dist/atlas/src/query/clauses/HavingClause.d.ts +70 -0
  58. package/dist/atlas/src/query/clauses/JoinClause.d.ts +87 -0
  59. package/dist/atlas/src/query/clauses/LimitClause.d.ts +82 -0
  60. package/dist/atlas/src/query/clauses/OrderByClause.d.ts +69 -0
  61. package/dist/atlas/src/query/clauses/SelectClause.d.ts +71 -0
  62. package/dist/atlas/src/query/clauses/WhereClause.d.ts +167 -0
  63. package/dist/atlas/src/query/clauses/index.d.ts +11 -0
  64. package/dist/atlas/src/schema/Blueprint.d.ts +276 -0
  65. package/dist/atlas/src/schema/ColumnDefinition.d.ts +154 -0
  66. package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +37 -0
  67. package/dist/atlas/src/schema/Schema.d.ts +131 -0
  68. package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +23 -0
  69. package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +26 -0
  70. package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +28 -0
  71. package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +97 -0
  72. package/dist/atlas/src/schema/grammars/index.d.ts +7 -0
  73. package/dist/atlas/src/schema/index.d.ts +8 -0
  74. package/dist/atlas/src/seed/Factory.d.ts +90 -0
  75. package/dist/atlas/src/seed/Seeder.d.ts +28 -0
  76. package/dist/atlas/src/seed/SeederRunner.d.ts +74 -0
  77. package/dist/atlas/src/seed/index.d.ts +6 -0
  78. package/dist/atlas/src/types/index.d.ts +1100 -0
  79. package/dist/atlas/src/utils/levenshtein.d.ts +9 -0
  80. package/dist/core/src/Application.d.ts +215 -0
  81. package/dist/core/src/CommandKernel.d.ts +33 -0
  82. package/dist/core/src/ConfigManager.d.ts +26 -0
  83. package/dist/core/src/Container.d.ts +108 -0
  84. package/dist/core/src/ErrorHandler.d.ts +63 -0
  85. package/dist/core/src/Event.d.ts +5 -0
  86. package/dist/core/src/EventManager.d.ts +123 -0
  87. package/dist/core/src/GlobalErrorHandlers.d.ts +47 -0
  88. package/dist/core/src/GravitoServer.d.ts +28 -0
  89. package/dist/core/src/HookManager.d.ts +496 -0
  90. package/dist/core/src/Listener.d.ts +4 -0
  91. package/dist/core/src/Logger.d.ts +20 -0
  92. package/dist/core/src/PlanetCore.d.ts +289 -0
  93. package/dist/core/src/Route.d.ts +36 -0
  94. package/dist/core/src/Router.d.ts +284 -0
  95. package/dist/core/src/ServiceProvider.d.ts +156 -0
  96. package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +27 -0
  97. package/dist/core/src/adapters/PhotonAdapter.d.ts +171 -0
  98. package/dist/core/src/adapters/bun/BunContext.d.ts +45 -0
  99. package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +31 -0
  100. package/dist/core/src/adapters/bun/BunRequest.d.ts +31 -0
  101. package/dist/core/src/adapters/bun/RadixNode.d.ts +19 -0
  102. package/dist/core/src/adapters/bun/RadixRouter.d.ts +31 -0
  103. package/dist/core/src/adapters/bun/types.d.ts +20 -0
  104. package/dist/core/src/adapters/photon-types.d.ts +73 -0
  105. package/dist/core/src/adapters/types.d.ts +235 -0
  106. package/dist/core/src/engine/AOTRouter.d.ts +124 -0
  107. package/dist/core/src/engine/FastContext.d.ts +100 -0
  108. package/dist/core/src/engine/Gravito.d.ts +137 -0
  109. package/dist/core/src/engine/MinimalContext.d.ts +79 -0
  110. package/dist/core/src/engine/analyzer.d.ts +27 -0
  111. package/dist/core/src/engine/constants.d.ts +23 -0
  112. package/dist/core/src/engine/index.d.ts +26 -0
  113. package/dist/core/src/engine/path.d.ts +26 -0
  114. package/dist/core/src/engine/pool.d.ts +83 -0
  115. package/dist/core/src/engine/types.d.ts +143 -0
  116. package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
  117. package/dist/core/src/events/DeadLetterQueue.d.ts +145 -0
  118. package/dist/core/src/events/EventBackend.d.ts +11 -0
  119. package/dist/core/src/events/EventOptions.d.ts +109 -0
  120. package/dist/core/src/events/EventPriorityQueue.d.ts +202 -0
  121. package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
  122. package/dist/core/src/events/index.d.ts +14 -0
  123. package/dist/core/src/events/observability/EventMetrics.d.ts +132 -0
  124. package/dist/core/src/events/observability/EventTracer.d.ts +68 -0
  125. package/dist/core/src/events/observability/EventTracing.d.ts +161 -0
  126. package/dist/core/src/events/observability/OTelEventMetrics.d.ts +240 -0
  127. package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
  128. package/dist/core/src/events/observability/index.d.ts +20 -0
  129. package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
  130. package/dist/core/src/events/types.d.ts +75 -0
  131. package/dist/core/src/exceptions/AuthenticationException.d.ts +8 -0
  132. package/dist/core/src/exceptions/AuthorizationException.d.ts +8 -0
  133. package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
  134. package/dist/core/src/exceptions/GravitoException.d.ts +23 -0
  135. package/dist/core/src/exceptions/HttpException.d.ts +9 -0
  136. package/dist/core/src/exceptions/ModelNotFoundException.d.ts +10 -0
  137. package/dist/core/src/exceptions/ValidationException.d.ts +22 -0
  138. package/dist/core/src/exceptions/index.d.ts +7 -0
  139. package/dist/core/src/helpers/Arr.d.ts +19 -0
  140. package/dist/core/src/helpers/Str.d.ts +23 -0
  141. package/dist/core/src/helpers/data.d.ts +25 -0
  142. package/dist/core/src/helpers/errors.d.ts +34 -0
  143. package/dist/core/src/helpers/response.d.ts +41 -0
  144. package/dist/core/src/helpers.d.ts +338 -0
  145. package/dist/core/src/http/CookieJar.d.ts +51 -0
  146. package/dist/core/src/http/cookie.d.ts +29 -0
  147. package/dist/core/src/http/middleware/BodySizeLimit.d.ts +16 -0
  148. package/dist/core/src/http/middleware/Cors.d.ts +24 -0
  149. package/dist/core/src/http/middleware/Csrf.d.ts +23 -0
  150. package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +28 -0
  151. package/dist/core/src/http/middleware/SecurityHeaders.d.ts +29 -0
  152. package/dist/core/src/http/middleware/ThrottleRequests.d.ts +18 -0
  153. package/dist/core/src/http/types.d.ts +355 -0
  154. package/dist/core/src/index.d.ts +76 -0
  155. package/dist/core/src/instrumentation/index.d.ts +35 -0
  156. package/dist/core/src/instrumentation/opentelemetry.d.ts +178 -0
  157. package/dist/core/src/instrumentation/types.d.ts +182 -0
  158. package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +316 -0
  159. package/dist/core/src/reliability/RetryPolicy.d.ts +217 -0
  160. package/dist/core/src/reliability/index.d.ts +6 -0
  161. package/dist/core/src/router/ControllerDispatcher.d.ts +12 -0
  162. package/dist/core/src/router/RequestValidator.d.ts +20 -0
  163. package/dist/core/src/runtime.d.ts +119 -0
  164. package/dist/core/src/security/Encrypter.d.ts +33 -0
  165. package/dist/core/src/security/Hasher.d.ts +29 -0
  166. package/dist/core/src/testing/HttpTester.d.ts +39 -0
  167. package/dist/core/src/testing/TestResponse.d.ts +78 -0
  168. package/dist/core/src/testing/index.d.ts +2 -0
  169. package/dist/core/src/types/events.d.ts +94 -0
  170. package/dist/echo/src/OrbitEcho.d.ts +115 -0
  171. package/dist/echo/src/dlq/DeadLetterQueue.d.ts +94 -0
  172. package/dist/echo/src/dlq/MemoryDeadLetterQueue.d.ts +36 -0
  173. package/dist/echo/src/dlq/index.d.ts +2 -0
  174. package/dist/echo/src/index.d.ts +64 -0
  175. package/dist/echo/src/middleware/RequestBufferMiddleware.d.ts +62 -0
  176. package/dist/echo/src/middleware/index.d.ts +8 -0
  177. package/dist/echo/src/observability/index.d.ts +3 -0
  178. package/dist/echo/src/observability/logging/ConsoleEchoLogger.d.ts +37 -0
  179. package/dist/echo/src/observability/logging/EchoLogger.d.ts +38 -0
  180. package/dist/echo/src/observability/logging/index.d.ts +2 -0
  181. package/dist/echo/src/observability/metrics/MetricsProvider.d.ts +69 -0
  182. package/dist/echo/src/observability/metrics/NoopMetricsProvider.d.ts +17 -0
  183. package/dist/echo/src/observability/metrics/PrometheusMetricsProvider.d.ts +39 -0
  184. package/dist/echo/src/observability/metrics/index.d.ts +3 -0
  185. package/dist/echo/src/observability/tracing/NoopTracer.d.ts +33 -0
  186. package/dist/echo/src/observability/tracing/Tracer.d.ts +75 -0
  187. package/dist/echo/src/observability/tracing/index.d.ts +2 -0
  188. package/dist/echo/src/providers/GenericProvider.d.ts +53 -0
  189. package/dist/echo/src/providers/GitHubProvider.d.ts +35 -0
  190. package/dist/echo/src/providers/LinearProvider.d.ts +27 -0
  191. package/dist/echo/src/providers/PaddleProvider.d.ts +31 -0
  192. package/dist/echo/src/providers/ShopifyProvider.d.ts +27 -0
  193. package/dist/echo/src/providers/SlackProvider.d.ts +27 -0
  194. package/dist/echo/src/providers/StripeProvider.d.ts +38 -0
  195. package/dist/echo/src/providers/TwilioProvider.d.ts +31 -0
  196. package/dist/echo/src/providers/base/BaseProvider.d.ts +87 -0
  197. package/dist/echo/src/providers/base/HeaderUtils.d.ts +34 -0
  198. package/dist/echo/src/providers/index.d.ts +14 -0
  199. package/dist/echo/src/receive/SignatureValidator.d.ts +67 -0
  200. package/dist/echo/src/receive/WebhookReceiver.d.ts +185 -0
  201. package/dist/echo/src/receive/index.d.ts +2 -0
  202. package/dist/echo/src/replay/WebhookReplayService.d.ts +35 -0
  203. package/dist/echo/src/replay/index.d.ts +1 -0
  204. package/dist/echo/src/resilience/CircuitBreaker.d.ts +117 -0
  205. package/dist/echo/src/resilience/index.d.ts +10 -0
  206. package/dist/echo/src/rotation/KeyRotationManager.d.ts +127 -0
  207. package/dist/echo/src/rotation/index.d.ts +10 -0
  208. package/dist/echo/src/send/WebhookDispatcher.d.ts +198 -0
  209. package/dist/echo/src/send/index.d.ts +1 -0
  210. package/dist/echo/src/storage/MemoryWebhookStore.d.ts +14 -0
  211. package/dist/echo/src/storage/WebhookStore.d.ts +236 -0
  212. package/dist/echo/src/storage/index.d.ts +2 -0
  213. package/dist/echo/src/types.d.ts +756 -0
  214. package/dist/index.js +1332 -190
  215. package/dist/index.js.map +28 -10
  216. package/dist/photon/src/index.d.ts +84 -0
  217. package/dist/photon/src/middleware/binary.d.ts +31 -0
  218. package/dist/photon/src/middleware/htmx.d.ts +39 -0
  219. package/dist/photon/src/middleware/ratelimit.d.ts +157 -0
  220. package/dist/photon/src/openapi.d.ts +19 -0
  221. package/package.json +7 -5
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Join Clause
3
+ *
4
+ * Handles JOIN operations
5
+ */
6
+ import type { JoinClause, JoinType } from '../../types';
7
+ /**
8
+ * Join Manager
9
+ * @description Handles the construction of JOIN clauses for SQL queries
10
+ */
11
+ export declare class JoinManager {
12
+ /** Internal storage for join conditions */
13
+ private joins;
14
+ /**
15
+ * Add a JOIN condition to the query
16
+ *
17
+ * @param type - Join type (INNER, LEFT, RIGHT, FULL, CROSS)
18
+ * @param table - Table to join
19
+ * @param first - First column for the ON condition
20
+ * @param operator - Join operator (=, !=, >, <, etc.)
21
+ * @param second - Second column for the ON condition
22
+ * @example
23
+ * ```typescript
24
+ * manager.add('inner', 'posts', 'users.id', '=', 'posts.user_id')
25
+ * ```
26
+ */
27
+ add(type: JoinType, table: string, first: string, operator: string, second: string): void;
28
+ /**
29
+ * Add a LEFT JOIN condition
30
+ *
31
+ * @param table - Table to join
32
+ * @param first - First column for the ON condition
33
+ * @param operator - Join operator
34
+ * @param second - Second column for the ON condition
35
+ * @example
36
+ * ```typescript
37
+ * manager.left('posts', 'users.id', '=', 'posts.user_id')
38
+ * ```
39
+ */
40
+ left(table: string, first: string, operator: string, second: string): void;
41
+ /**
42
+ * Add a RIGHT JOIN condition
43
+ *
44
+ * @param table - Table to join
45
+ * @param first - First column for the ON condition
46
+ * @param operator - Join operator
47
+ * @param second - Second column for the ON condition
48
+ */
49
+ right(table: string, first: string, operator: string, second: string): void;
50
+ /**
51
+ * Add a CROSS JOIN condition
52
+ *
53
+ * @param table - Table to join
54
+ * @param first - First column for the ON condition
55
+ * @param operator - Join operator
56
+ * @param second - Second column for the ON condition
57
+ */
58
+ cross(table: string, first: string, operator: string, second: string): void;
59
+ /**
60
+ * Get all joins
61
+ *
62
+ * @returns Array of joins
63
+ */
64
+ getJoins(): JoinClause[];
65
+ /**
66
+ * Compile the JOIN clause to SQL
67
+ *
68
+ * @returns JOIN clause SQL string
69
+ */
70
+ toSQL(): string;
71
+ /**
72
+ * Reset the clause state
73
+ */
74
+ reset(): void;
75
+ /**
76
+ * Check if the clause has any joins
77
+ *
78
+ * @returns True if joins exist
79
+ */
80
+ hasJoins(): boolean;
81
+ /**
82
+ * Clone the clause
83
+ *
84
+ * @returns A deep copy of the clause
85
+ */
86
+ clone(): JoinManager;
87
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Limit Clause
3
+ * @description Handles the construction of LIMIT and OFFSET clauses for SQL queries
4
+ */
5
+ export declare class LimitClause {
6
+ /** The maximum number of records to return */
7
+ private limitValue?;
8
+ /** The number of records to skip before starting to return results */
9
+ private offsetValue?;
10
+ /**
11
+ * Set the LIMIT value
12
+ *
13
+ * @param value - Maximum number of records
14
+ * @example
15
+ * ```typescript
16
+ * clause.setLimit(10)
17
+ * ```
18
+ */
19
+ setLimit(value: number): void;
20
+ /**
21
+ * Set the OFFSET value
22
+ *
23
+ * @param value - Number of records to skip
24
+ * @example
25
+ * ```typescript
26
+ * clause.setOffset(20)
27
+ * ```
28
+ */
29
+ setOffset(value: number): void;
30
+ /**
31
+ * Get the current LIMIT value
32
+ *
33
+ * @returns The limit value or undefined if not set
34
+ */
35
+ getLimit(): number | undefined;
36
+ /**
37
+ * Get the current OFFSET value
38
+ *
39
+ * @returns The offset value or undefined if not set
40
+ */
41
+ getOffset(): number | undefined;
42
+ /**
43
+ * Compile the LIMIT/OFFSET clause to SQL
44
+ *
45
+ * @returns SQL string for the clause
46
+ */
47
+ toSQL(): string;
48
+ /**
49
+ * Reset the clause state
50
+ */
51
+ reset(): void;
52
+ /**
53
+ * Check if the clause has a LIMIT value set
54
+ *
55
+ * @returns True if limit is set
56
+ */
57
+ hasLimit(): boolean;
58
+ /**
59
+ * Check if the clause has an OFFSET value set
60
+ *
61
+ * @returns True if offset is set
62
+ */
63
+ hasOffset(): boolean;
64
+ /**
65
+ * Set the number of records to take (alias for limit)
66
+ *
67
+ * @param value - Number of records
68
+ */
69
+ take(value: number): void;
70
+ /**
71
+ * Set the number of records to skip (alias for offset)
72
+ *
73
+ * @param value - Number of records
74
+ */
75
+ skip(value: number): void;
76
+ /**
77
+ * Clone the clause
78
+ *
79
+ * @returns A deep copy of the clause
80
+ */
81
+ clone(): LimitClause;
82
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Order By Clause
3
+ *
4
+ * Handles ORDER BY operations
5
+ */
6
+ import type { OrderClause as OrderClauseType, OrderDirection } from '../../types';
7
+ import { Expression } from '../Expression';
8
+ /**
9
+ * Order By Clause
10
+ * @description Handles the construction of ORDER BY clauses for SQL queries
11
+ */
12
+ export declare class OrderByClause {
13
+ /** Internal storage for order by clauses */
14
+ private orders;
15
+ /** Bindings for raw order clauses */
16
+ private bindings;
17
+ /**
18
+ * Add an ORDER BY clause to the query
19
+ *
20
+ * @param column - Column name
21
+ * @param direction - Sort direction ('asc' or 'desc')
22
+ * @example
23
+ * ```typescript
24
+ * clause.orderBy('created_at', 'desc')
25
+ * ```
26
+ */
27
+ orderBy(column: string, direction?: OrderDirection): void;
28
+ /**
29
+ * Add a raw ORDER BY clause to the query
30
+ *
31
+ * @param sql - Raw SQL string or Expression instance
32
+ * @param bindings - Optional array of bindings
33
+ */
34
+ orderByRaw(sql: string | Expression, bindings?: unknown[]): void;
35
+ /**
36
+ * Get all order clauses
37
+ *
38
+ * @returns Array of order clauses
39
+ */
40
+ getOrders(): OrderClauseType[];
41
+ /**
42
+ * Get the bindings associated with this clause
43
+ *
44
+ * @returns Array of bindings
45
+ */
46
+ getBindings(): unknown[];
47
+ /**
48
+ * Compile the ORDER BY clause to SQL
49
+ *
50
+ * @returns ORDER BY clause SQL string
51
+ */
52
+ toSQL(): string;
53
+ /**
54
+ * Reset the clause state
55
+ */
56
+ reset(): void;
57
+ /**
58
+ * Check if the clause has any order conditions
59
+ *
60
+ * @returns True if order conditions exist
61
+ */
62
+ hasOrders(): boolean;
63
+ /**
64
+ * Clone the clause
65
+ *
66
+ * @returns A deep copy of the clause
67
+ */
68
+ clone(): OrderByClause;
69
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Select Clause
3
+ * @description Handles the construction of SELECT and DISTINCT clauses for SQL queries
4
+ */
5
+ export declare class SelectClause {
6
+ /** Array of columns to select, defaults to all columns ('*') */
7
+ private columns;
8
+ /** Whether to apply the DISTINCT keyword to the query */
9
+ private distinct;
10
+ /** Bindings for raw expressions */
11
+ private bindings;
12
+ /**
13
+ * Set the columns to be selected
14
+ *
15
+ * @param columns - List of column names
16
+ * @example
17
+ * ```typescript
18
+ * clause.setColumns('id', 'name', 'email')
19
+ * ```
20
+ */
21
+ setColumns(...columns: string[]): void;
22
+ /**
23
+ * Add a raw SQL expression to the SELECT clause
24
+ *
25
+ * @param expression - Raw SQL string
26
+ * @param bindings - Bindings for the expression
27
+ * @example
28
+ * ```typescript
29
+ * clause.addRaw('COUNT(*) as total')
30
+ * ```
31
+ */
32
+ addRaw(expression: string, bindings?: unknown[]): void;
33
+ /**
34
+ * Enable the DISTINCT keyword for the query
35
+ */
36
+ setDistinct(): void;
37
+ /**
38
+ * Get the list of selected columns
39
+ *
40
+ * @returns Array of column names or expressions
41
+ */
42
+ getColumns(): string[];
43
+ /**
44
+ * Check if the DISTINCT keyword is enabled
45
+ *
46
+ * @returns True if distinct is set
47
+ */
48
+ isDistinct(): boolean;
49
+ /**
50
+ * Compile the SELECT clause to SQL
51
+ *
52
+ * @returns SQL string for the clause
53
+ */
54
+ toSQL(): string;
55
+ /**
56
+ * Reset the clause state to its default values
57
+ */
58
+ reset(): void;
59
+ /**
60
+ * Get the bindings associated with this clause
61
+ *
62
+ * @returns Array of bindings
63
+ */
64
+ getBindings(): unknown[];
65
+ /**
66
+ * Clone the clause
67
+ *
68
+ * @returns A deep copy of the clause
69
+ */
70
+ clone(): SelectClause;
71
+ }
@@ -0,0 +1,167 @@
1
+ import type { Operator } from '../../types';
2
+ /**
3
+ * Where Condition Interface
4
+ * @description Represents a single WHERE condition or a group of nested conditions
5
+ */
6
+ export interface WhereCondition {
7
+ /** Type of the condition */
8
+ type: 'basic' | 'nested' | 'in' | 'null' | 'between' | 'raw' | 'exists' | 'column';
9
+ /** Column name for the condition */
10
+ column?: string;
11
+ /** Comparison operator (e.g., '=', '!=', 'LIKE') */
12
+ operator?: Operator;
13
+ /** Value to compare against (for basic conditions) */
14
+ value?: unknown;
15
+ /** Logical connector to the previous condition ('and' or 'or') */
16
+ boolean: 'and' | 'or';
17
+ /** Array of nested conditions (for 'nested' type) */
18
+ conditions?: WhereCondition[];
19
+ /** Array of values (for 'in' type) */
20
+ values?: unknown[];
21
+ /** Whether to negate the condition (e.g., NOT IN, IS NOT NULL) */
22
+ not?: boolean;
23
+ /** Raw SQL for raw clauses */
24
+ sql?: string;
25
+ /** Bindings for raw clauses */
26
+ bindings?: unknown[];
27
+ }
28
+ /**
29
+ * Where Clause
30
+ * @description Handles the construction of WHERE clauses with support for complex nested conditions
31
+ */
32
+ export declare class WhereClause {
33
+ /** Internal storage for WHERE conditions */
34
+ private wheres;
35
+ /**
36
+ * Add a basic WHERE condition
37
+ *
38
+ * @param column - Column name
39
+ * @param operator - Comparison operator
40
+ * @param value - Value to compare
41
+ * @param boolean - Logical connector ('and' or 'or')
42
+ * @example
43
+ * ```typescript
44
+ * clause.add('status', '=', 'active')
45
+ * ```
46
+ */
47
+ add(column: string, operator: Operator, value: unknown, boolean?: 'and' | 'or'): void;
48
+ /**
49
+ * Add a group of nested WHERE conditions
50
+ *
51
+ * @param conditions - Array of nested conditions
52
+ * @param boolean - Logical connector for the group
53
+ * @example
54
+ * ```typescript
55
+ * clause.addNested([
56
+ * { type: 'basic', column: 'age', operator: '>', value: 18 },
57
+ * { type: 'basic', column: 'status', operator: '=', value: 'active', boolean: 'or' }
58
+ * ])
59
+ * ```
60
+ */
61
+ addNested(conditions: WhereCondition[], boolean?: 'and' | 'or'): void;
62
+ /**
63
+ * Add a WHERE IN condition
64
+ *
65
+ * @param column - Column name
66
+ * @param values - Array of values to check against
67
+ * @param boolean - Logical connector
68
+ * @param not - Whether to use NOT IN
69
+ * @example
70
+ * ```typescript
71
+ * clause.addIn('id', [1, 2, 3])
72
+ * ```
73
+ */
74
+ addIn(column: string, values: unknown[], boolean?: 'and' | 'or', not?: boolean): void;
75
+ /**
76
+ * Add a WHERE NULL condition
77
+ *
78
+ * @param column - Column name
79
+ * @param boolean - Logical connector
80
+ * @param not - Whether to use IS NOT NULL
81
+ * @example
82
+ * ```typescript
83
+ * clause.addNull('deleted_at')
84
+ * ```
85
+ */
86
+ addNull(column: string, boolean?: 'and' | 'or', not?: boolean): void;
87
+ /**
88
+ * Add a WHERE NOT NULL condition
89
+ *
90
+ * @param column - Column name
91
+ * @param boolean - Logical connector
92
+ */
93
+ addNotNull(column: string, boolean?: 'and' | 'or'): void;
94
+ /**
95
+ * Add a WHERE BETWEEN condition
96
+ *
97
+ * @param column - Column name
98
+ * @param values - [min, max] values
99
+ * @param boolean - Logical connector
100
+ * @param not - Negate condition
101
+ */
102
+ addBetween(column: string, values: [unknown, unknown], boolean?: 'and' | 'or', not?: boolean): void;
103
+ /**
104
+ * Add a raw WHERE condition
105
+ *
106
+ * @param sql - SQL string
107
+ * @param bindings - Bindings array
108
+ * @param boolean - Logical connector
109
+ */
110
+ addRaw(sql: string, bindings: unknown[], boolean?: 'and' | 'or'): void;
111
+ /**
112
+ * Add a column comparison condition
113
+ *
114
+ * @param first - First column
115
+ * @param operator - Operator
116
+ * @param second - Second column
117
+ * @param boolean - Logical connector
118
+ */
119
+ addColumn(first: string, operator: Operator, second: string, boolean?: 'and' | 'or'): void;
120
+ /**
121
+ * Get all registered WHERE conditions
122
+ *
123
+ * @returns Array of conditions
124
+ */
125
+ getWheres(): WhereCondition[];
126
+ /**
127
+ * Helper to perform deep copy of conditions
128
+ */
129
+ private deepCopyConditions;
130
+ /**
131
+ * Extract all values from the conditions for use as query bindings
132
+ *
133
+ * @returns Array of binding values
134
+ */
135
+ getValues(): unknown[];
136
+ private getNestedValues;
137
+ /**
138
+ * Compile the WHERE clause to SQL
139
+ *
140
+ * @returns SQL string for the clause
141
+ */
142
+ toSQL(): string;
143
+ /**
144
+ * Recursively compile nested conditions to SQL
145
+ *
146
+ * @param conditions - Array of nested conditions
147
+ * @returns Compiled SQL string for the nested group
148
+ * @internal
149
+ */
150
+ private compileNested;
151
+ /**
152
+ * Reset the clause state
153
+ */
154
+ reset(): void;
155
+ /**
156
+ * Check if the clause has any conditions registered
157
+ *
158
+ * @returns True if conditions exist
159
+ */
160
+ hasConditions(): boolean;
161
+ /**
162
+ * Clone the clause
163
+ *
164
+ * @returns A deep copy of the clause
165
+ */
166
+ clone(): WhereClause;
167
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Query Clauses Index
3
+ * @description Re-exports all query clause modules for easier access
4
+ */
5
+ export { GroupByClause } from './GroupByClause';
6
+ export { HavingClause } from './HavingClause';
7
+ export { JoinManager } from './JoinClause';
8
+ export { LimitClause } from './LimitClause';
9
+ export { OrderByClause } from './OrderByClause';
10
+ export { SelectClause } from './SelectClause';
11
+ export { WhereClause, type WhereCondition } from './WhereClause';