@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,276 @@
1
+ /**
2
+ * Blueprint
3
+ * @description Fluent interface for defining table schema
4
+ */
5
+ import { ColumnDefinition, type ForeignKeyAction } from './ColumnDefinition';
6
+ import type { ForeignKeyDefinition, IndexDefinition } from './ForeignKeyDefinition';
7
+ /**
8
+ * Blueprint
9
+ *
10
+ * The Blueprint class provides a fluent interface for defining table schema.
11
+ * It is used within the `Schema.create` and `Schema.table` callbacks to
12
+ * define columns, indexes, and foreign keys.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * Schema.create('users', (table) => {
17
+ * table.id()
18
+ * table.string('email').unique()
19
+ * table.string('password')
20
+ * table.timestamps()
21
+ * })
22
+ * ```
23
+ */
24
+ export declare class Blueprint {
25
+ /** Table name */
26
+ readonly table: string;
27
+ /** Column definitions */
28
+ private _columns;
29
+ /** Index definitions */
30
+ private _indexes;
31
+ /** Foreign key definitions (standalone) */
32
+ private _foreignKeys;
33
+ /** Columns to drop */
34
+ private _dropColumns;
35
+ /** Indexes to drop */
36
+ private _dropIndexes;
37
+ /** Foreign keys to drop */
38
+ private _dropForeignKeys;
39
+ constructor(table: string);
40
+ /**
41
+ * Create a new auto-incrementing BIGINT primary key column.
42
+ *
43
+ * @param name The name of the column (defaults to 'id').
44
+ * @returns The ColumnDefinition instance for further modification.
45
+ */
46
+ id(name?: string): ColumnDefinition;
47
+ /**
48
+ * Create a new UUID primary key column.
49
+ *
50
+ * @param name The name of the column (defaults to 'id').
51
+ * @returns The ColumnDefinition instance for further modification.
52
+ */
53
+ uuid(name?: string): ColumnDefinition;
54
+ /**
55
+ * Create a new integer column.
56
+ *
57
+ * @param name The name of the column.
58
+ * @returns The ColumnDefinition instance for further modification.
59
+ */
60
+ integer(name: string): ColumnDefinition;
61
+ /**
62
+ * SMALLINT column
63
+ */
64
+ smallInteger(name: string): ColumnDefinition;
65
+ /**
66
+ * BIGINT column
67
+ */
68
+ bigInteger(name: string): ColumnDefinition;
69
+ /**
70
+ * DECIMAL column
71
+ */
72
+ decimal(name: string, precision?: number, scale?: number): ColumnDefinition;
73
+ /**
74
+ * FLOAT column
75
+ */
76
+ float(name: string): ColumnDefinition;
77
+ /**
78
+ * BOOLEAN column
79
+ */
80
+ boolean(name: string): ColumnDefinition;
81
+ /**
82
+ * Create a new string (VARCHAR) column.
83
+ *
84
+ * @param name The name of the column.
85
+ * @param length The maximum length of the string (defaults to 255).
86
+ * @returns The ColumnDefinition instance for further modification.
87
+ */
88
+ string(name: string, length?: number): ColumnDefinition;
89
+ /**
90
+ * TEXT column
91
+ */
92
+ text(name: string): ColumnDefinition;
93
+ /**
94
+ * ENUM column
95
+ */
96
+ enum(name: string, values: string[]): ColumnDefinition;
97
+ /**
98
+ * SET column (MySQL)
99
+ */
100
+ set(name: string, values: string[]): ColumnDefinition;
101
+ /**
102
+ * DATE column
103
+ */
104
+ date(name: string): ColumnDefinition;
105
+ /**
106
+ * TIME column
107
+ */
108
+ time(name: string): ColumnDefinition;
109
+ /**
110
+ * TIME WITH TIME ZONE column
111
+ */
112
+ timeTz(name: string): ColumnDefinition;
113
+ /**
114
+ * DATETIME column
115
+ */
116
+ dateTime(name: string): ColumnDefinition;
117
+ /**
118
+ * DATETIME WITH TIME ZONE column
119
+ */
120
+ dateTimeTz(name: string): ColumnDefinition;
121
+ /**
122
+ * TIMESTAMP column
123
+ */
124
+ timestamp(name: string): ColumnDefinition;
125
+ /**
126
+ * TIMESTAMP WITH TIME ZONE column
127
+ */
128
+ timestampTz(name: string): ColumnDefinition;
129
+ /**
130
+ * Add `created_at` and `updated_at` TIMESTAMP columns to the table.
131
+ */
132
+ timestamps(): void;
133
+ /**
134
+ * created_at and updated_at TIMESTAMP WITH TZ columns
135
+ */
136
+ timestampsTz(): void;
137
+ /**
138
+ * deleted_at TIMESTAMP column for soft deletes
139
+ */
140
+ softDeletes(name?: string): ColumnDefinition;
141
+ /**
142
+ * deleted_at TIMESTAMP WITH TZ column for soft deletes
143
+ */
144
+ softDeletesTz(name?: string): ColumnDefinition;
145
+ /**
146
+ * BINARY/BLOB column
147
+ */
148
+ binary(name: string): ColumnDefinition;
149
+ /**
150
+ * JSON column
151
+ */
152
+ json(name: string): ColumnDefinition;
153
+ /**
154
+ * JSONB column (PostgreSQL)
155
+ */
156
+ jsonb(name: string): ColumnDefinition;
157
+ /**
158
+ * MAC address column
159
+ */
160
+ macAddress(name: string): ColumnDefinition;
161
+ /**
162
+ * IP address column
163
+ */
164
+ ipAddress(name: string): ColumnDefinition;
165
+ /**
166
+ * VECTOR column (PostgreSQL pgvector)
167
+ */
168
+ vector(name: string, dimensions?: number): ColumnDefinition;
169
+ /**
170
+ * remember_token VARCHAR(100) column
171
+ */
172
+ rememberToken(): ColumnDefinition;
173
+ /**
174
+ * Create a new BIGINT UNSIGNED column for a foreign key.
175
+ *
176
+ * @param name The name of the column.
177
+ * @returns The ColumnDefinition instance for further modification.
178
+ *
179
+ * @example
180
+ * ```typescript
181
+ * table.foreignId('user_id').constrained().onDelete('cascade')
182
+ * ```
183
+ */
184
+ foreignId(name: string): ColumnDefinition;
185
+ /**
186
+ * Add a standalone foreign key constraint to the table.
187
+ *
188
+ * @param column The name of the local column.
189
+ * @returns A ForeignKeyBuilder instance to define the reference.
190
+ *
191
+ * @example
192
+ * ```typescript
193
+ * table.foreign('user_id').references('id').on('users')
194
+ * ```
195
+ */
196
+ foreign(column: string): ForeignKeyBuilder;
197
+ /**
198
+ * Add PRIMARY KEY constraint
199
+ */
200
+ primary(columns: string | string[], name?: string): this;
201
+ /**
202
+ * Add a UNIQUE index to the table.
203
+ *
204
+ * @param columns The column(s) to include in the index.
205
+ * @param name The name of the index (optional).
206
+ * @returns The Blueprint instance for chaining.
207
+ */
208
+ unique(columns: string | string[], name?: string): this;
209
+ /**
210
+ * Add a basic index to the table.
211
+ *
212
+ * @param columns The column(s) to include in the index.
213
+ * @param name The name of the index (optional).
214
+ * @returns The Blueprint instance for chaining.
215
+ */
216
+ index(columns: string | string[], name?: string): this;
217
+ /**
218
+ * Add FULLTEXT index
219
+ */
220
+ fullText(columns: string | string[], language?: string, name?: string): this;
221
+ /**
222
+ * Add SPATIAL index (not supported in SQLite)
223
+ */
224
+ spatialIndex(columns: string | string[], name?: string): this;
225
+ /**
226
+ * Drop a column
227
+ */
228
+ dropColumn(column: string | string[]): this;
229
+ /**
230
+ * Drop an index
231
+ */
232
+ dropIndex(name: string | string[]): this;
233
+ /**
234
+ * Drop a foreign key
235
+ */
236
+ dropForeign(columns: string | string[]): this;
237
+ getColumns(): ColumnDefinition[];
238
+ getIndexes(): IndexDefinition[];
239
+ getForeignKeys(): ForeignKeyDefinition[];
240
+ getDropColumns(): string[];
241
+ getDropIndexes(): string[];
242
+ getDropForeignKeys(): string[];
243
+ private addColumn;
244
+ addForeignKey(fk: ForeignKeyDefinition): void;
245
+ }
246
+ /**
247
+ * Foreign Key Builder (for standalone FK definitions)
248
+ */
249
+ declare class ForeignKeyBuilder {
250
+ private readonly blueprint;
251
+ private column;
252
+ private referencedColumn;
253
+ private referencedTable;
254
+ private onDeleteAction;
255
+ private onUpdateAction;
256
+ constructor(blueprint: Blueprint, column: string);
257
+ /**
258
+ * Set the referenced column
259
+ */
260
+ references(column: string): this;
261
+ /**
262
+ * Set the referenced table
263
+ */
264
+ on(table: string): this;
265
+ /**
266
+ * Set ON DELETE action
267
+ */
268
+ onDelete(action: ForeignKeyAction): this;
269
+ /**
270
+ * Set ON UPDATE action
271
+ */
272
+ onUpdate(action: ForeignKeyAction): this;
273
+ private finalize;
274
+ private updateForeignKey;
275
+ }
276
+ export {};
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Column Definition
3
+ * @description Represents a column in a table schema with fluent modifiers
4
+ */
5
+ import type { ForeignKeyDefinition } from './ForeignKeyDefinition';
6
+ /**
7
+ * Column data type
8
+ */
9
+ export type ColumnType = 'bigInteger' | 'binary' | 'boolean' | 'date' | 'dateTime' | 'dateTimeTz' | 'decimal' | 'enum' | 'float' | 'integer' | 'ipAddress' | 'json' | 'jsonb' | 'macAddress' | 'set' | 'smallInteger' | 'string' | 'text' | 'time' | 'timeTz' | 'timestamp' | 'timestampTz' | 'uuid' | 'vector';
10
+ /**
11
+ * Foreign key action
12
+ */
13
+ export type ForeignKeyAction = 'cascade' | 'restrict' | 'no action' | 'set null' | 'set default';
14
+ /**
15
+ * Column Definition
16
+ *
17
+ * The ColumnDefinition class represents a column in a database table.
18
+ * It provides a fluent interface for defining column properties such as
19
+ * nullability, default values, indexes, and foreign key constraints.
20
+ */
21
+ export declare class ColumnDefinition {
22
+ /** Column name */
23
+ readonly name: string;
24
+ /** Column type */
25
+ readonly type: ColumnType;
26
+ /** Type-specific parameters */
27
+ readonly parameters: Record<string, unknown>;
28
+ /** Modifiers */
29
+ private _nullable;
30
+ private _default;
31
+ private _hasDefault;
32
+ private _unique;
33
+ private _index;
34
+ private _primary;
35
+ private _unsigned;
36
+ private _autoIncrement;
37
+ private _comment;
38
+ private _after;
39
+ private _first;
40
+ private _change;
41
+ /** Foreign key reference */
42
+ private _foreignKey;
43
+ constructor(name: string, type: ColumnType, parameters?: Record<string, unknown>);
44
+ /**
45
+ * Allow NULL values to be stored in the column.
46
+ *
47
+ * @param value Whether the column should be nullable (defaults to true).
48
+ * @returns The ColumnDefinition instance for chaining.
49
+ */
50
+ nullable(value?: boolean): this;
51
+ /**
52
+ * Set the default value for the column.
53
+ *
54
+ * @param value The default value.
55
+ * @returns The ColumnDefinition instance for chaining.
56
+ */
57
+ default(value: unknown): this;
58
+ /**
59
+ * Add a UNIQUE constraint to the column.
60
+ *
61
+ * @returns The ColumnDefinition instance for chaining.
62
+ */
63
+ unique(): this;
64
+ /**
65
+ * Add INDEX
66
+ */
67
+ index(): this;
68
+ /**
69
+ * Set the column as a PRIMARY KEY.
70
+ *
71
+ * @returns The ColumnDefinition instance for chaining.
72
+ */
73
+ primary(): this;
74
+ /**
75
+ * Make UNSIGNED (MySQL)
76
+ */
77
+ unsigned(): this;
78
+ /**
79
+ * Set AUTO_INCREMENT
80
+ */
81
+ autoIncrement(): this;
82
+ /**
83
+ * Add column comment
84
+ */
85
+ comment(text: string): this;
86
+ /**
87
+ * Place column after another column (MySQL)
88
+ */
89
+ after(column: string): this;
90
+ /**
91
+ * Place column first (MySQL)
92
+ */
93
+ first(): this;
94
+ /**
95
+ * Mark column for modification
96
+ */
97
+ change(): this;
98
+ /**
99
+ * Define a foreign key constraint for the column.
100
+ *
101
+ * @param table The name of the referenced table (inferred from column name if not provided).
102
+ * @returns The ColumnDefinition instance for chaining.
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * table.foreignId('user_id').constrained('users')
107
+ * ```
108
+ */
109
+ constrained(table?: string): this;
110
+ /**
111
+ * Set the ON DELETE action for the foreign key constraint.
112
+ *
113
+ * @param action The action to perform (e.g., 'cascade', 'set null').
114
+ * @returns The ColumnDefinition instance for chaining.
115
+ */
116
+ onDelete(action: ForeignKeyAction): this;
117
+ /**
118
+ * Set ON UPDATE action
119
+ */
120
+ onUpdate(action: ForeignKeyAction): this;
121
+ /**
122
+ * Set the referenced column (for manual FK definition)
123
+ */
124
+ references(column: string): ForeignKeyBuilder;
125
+ isNullable(): boolean;
126
+ hasDefaultValue(): boolean;
127
+ getDefault(): unknown;
128
+ isUnique(): boolean;
129
+ hasIndex(): boolean;
130
+ isPrimary(): boolean;
131
+ isUnsigned(): boolean;
132
+ isAutoIncrement(): boolean;
133
+ getComment(): string | undefined;
134
+ getAfter(): string | undefined;
135
+ isFirst(): boolean;
136
+ isChange(): boolean;
137
+ getForeignKey(): ForeignKeyDefinition | undefined;
138
+ setForeignKey(fk: ForeignKeyDefinition): void;
139
+ private inferTableName;
140
+ }
141
+ /**
142
+ * Foreign Key Builder
143
+ * For manual foreign key definition: column.references('id').on('users')
144
+ */
145
+ declare class ForeignKeyBuilder {
146
+ private readonly column;
147
+ private referencedColumn;
148
+ constructor(column: ColumnDefinition, referencedColumn: string);
149
+ /**
150
+ * Set the referenced table
151
+ */
152
+ on(table: string): ColumnDefinition;
153
+ }
154
+ export {};
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Foreign Key Definition
3
+ * @description Represents a foreign key constraint
4
+ */
5
+ import type { ForeignKeyAction } from './ColumnDefinition';
6
+ /**
7
+ * Foreign Key Definition
8
+ *
9
+ * Represents a foreign key constraint between two tables.
10
+ */
11
+ export interface ForeignKeyDefinition {
12
+ /** Local column name */
13
+ column: string;
14
+ /** Referenced table name */
15
+ referencedTable: string;
16
+ /** Referenced column name */
17
+ referencedColumn: string;
18
+ /** ON DELETE action */
19
+ onDelete: ForeignKeyAction | undefined;
20
+ /** ON UPDATE action */
21
+ onUpdate: ForeignKeyAction | undefined;
22
+ }
23
+ /**
24
+ * Index Definition
25
+ *
26
+ * Represents a database index (Primary, Unique, Index, Fulltext, or Spatial).
27
+ */
28
+ export interface IndexDefinition {
29
+ /** Index name */
30
+ name: string;
31
+ /** Index type */
32
+ type: 'index' | 'unique' | 'primary' | 'fulltext' | 'spatial';
33
+ /** Columns in the index */
34
+ columns: string[];
35
+ /** Language for fulltext index */
36
+ language?: string | undefined;
37
+ }
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Schema Facade
3
+ * @description Entry point for database schema operations
4
+ */
5
+ import { Blueprint } from './Blueprint';
6
+ /**
7
+ * Schema Facade
8
+ *
9
+ * The Schema class provides a database agnostic way of manipulating tables.
10
+ * It works with all supported databases and provides a unified API for
11
+ * creating, modifying, and dropping tables.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { Schema } from '@gravito/atlas'
16
+ *
17
+ * // Create a new table
18
+ * await Schema.create('users', (table) => {
19
+ * table.id()
20
+ * table.string('email').unique()
21
+ * table.timestamps()
22
+ * })
23
+ *
24
+ * // Modify an existing table
25
+ * await Schema.table('users', (table) => {
26
+ * table.string('phone').nullable()
27
+ * })
28
+ * ```
29
+ */
30
+ export declare class Schema {
31
+ private static grammar;
32
+ private static connectionName;
33
+ /**
34
+ * Set the connection to use for schema operations.
35
+ *
36
+ * @param name The name of the connection defined in your database configuration.
37
+ * @returns The Schema class for chaining.
38
+ */
39
+ static connection(name: string): typeof Schema;
40
+ /**
41
+ * Reset the schema facade state (primarily for testing).
42
+ * @internal
43
+ */
44
+ static reset(): void;
45
+ /**
46
+ * Get the grammar instance for the current connection
47
+ */
48
+ private static getGrammar;
49
+ /**
50
+ * Check if grammar instance matches driver
51
+ */
52
+ private static isGrammarMatch;
53
+ private static getDriverName;
54
+ private static createGrammar;
55
+ /**
56
+ * Create a new table on the schema.
57
+ *
58
+ * @param table The name of the table to create.
59
+ * @param callback A callback that receives a Blueprint instance to define columns.
60
+ *
61
+ * @example
62
+ * ```typescript
63
+ * await Schema.create('posts', (table) => {
64
+ * table.id()
65
+ * table.foreignId('user_id').constrained().onDelete('cascade')
66
+ * table.string('title')
67
+ * table.text('content')
68
+ * table.timestamps()
69
+ * })
70
+ * ```
71
+ */
72
+ static create(table: string, callback: (blueprint: Blueprint) => void): Promise<void>;
73
+ /**
74
+ * Modify an existing table on the schema.
75
+ *
76
+ * @param table The name of the table to modify.
77
+ * @param callback A callback that receives a Blueprint instance to modify columns or indexes.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * await Schema.table('users', (table) => {
82
+ * table.string('avatar_url').nullable()
83
+ * table.index(['email', 'avatar_url'])
84
+ * })
85
+ * ```
86
+ */
87
+ static table(table: string, callback: (blueprint: Blueprint) => void): Promise<void>;
88
+ /**
89
+ * Drop a table from the schema.
90
+ *
91
+ * @param table - The name of the table to drop.
92
+ * @throws Error if the table does not exist.
93
+ */
94
+ static drop(table: string): Promise<void>;
95
+ /**
96
+ * Drop a table from the schema only if it exists.
97
+ *
98
+ * @param table - The name of the table to drop.
99
+ */
100
+ static dropIfExists(table: string): Promise<void>;
101
+ /**
102
+ * Rename an existing table on the schema.
103
+ *
104
+ * @param from - The current name of the table.
105
+ * @param to - The new name for the table.
106
+ */
107
+ static rename(from: string, to: string): Promise<void>;
108
+ /**
109
+ * Determine if the given table exists in the database.
110
+ *
111
+ * @param table - The name of the table to check.
112
+ * @returns Promise resolving to true if the table exists.
113
+ */
114
+ static hasTable(table: string): Promise<boolean>;
115
+ /**
116
+ * Determine if the given table has a specific column.
117
+ *
118
+ * @param table - The name of the table.
119
+ * @param column - The name of the column.
120
+ * @returns Promise resolving to true if the column exists.
121
+ */
122
+ static hasColumn(table: string, column: string): Promise<boolean>;
123
+ /**
124
+ * Get a list of all table names for the current database connection.
125
+ *
126
+ * @returns Promise resolving to an array of table names.
127
+ */
128
+ static getTables(): Promise<string[]>;
129
+ private static executeStatement;
130
+ private static executeQuery;
131
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * MySQL Schema Grammar
3
+ * @description DDL generation for MySQL/MariaDB
4
+ */
5
+ import type { ColumnDefinition } from '../ColumnDefinition';
6
+ import type { IndexDefinition } from '../ForeignKeyDefinition';
7
+ import { SchemaGrammar } from './SchemaGrammar';
8
+ /**
9
+ * MySQL Schema Grammar
10
+ */
11
+ export declare class MySQLSchemaGrammar extends SchemaGrammar {
12
+ protected compileType(column: ColumnDefinition): string;
13
+ protected compileAutoIncrement(): string;
14
+ protected supportsUnsigned(): boolean;
15
+ protected compileFullTextIndex(table: string, index: IndexDefinition): string;
16
+ protected compileSpatialIndex(table: string, index: IndexDefinition): string;
17
+ compileDropIndex(table: string, name: string): string;
18
+ wrapTable(table: string): string;
19
+ wrapColumn(column: string): string;
20
+ compileTableExists(table: string): string;
21
+ compileColumnExists(table: string, column: string): string;
22
+ compileListTables(): string;
23
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * PostgreSQL Schema Grammar
3
+ * @description DDL generation for PostgreSQL
4
+ */
5
+ import type { Blueprint } from '../Blueprint';
6
+ import type { ColumnDefinition } from '../ColumnDefinition';
7
+ import type { IndexDefinition } from '../ForeignKeyDefinition';
8
+ import { SchemaGrammar } from './SchemaGrammar';
9
+ /**
10
+ * PostgreSQL Schema Grammar
11
+ */
12
+ export declare class PostgresSchemaGrammar extends SchemaGrammar {
13
+ protected wrapChar: string;
14
+ protected compileType(column: ColumnDefinition): string;
15
+ protected compileAutoIncrement(): string;
16
+ protected compileColumn(column: ColumnDefinition, blueprint: Blueprint): string;
17
+ protected supportsUnsigned(): boolean;
18
+ protected compileFullTextIndex(table: string, index: IndexDefinition): string;
19
+ protected compileSpatialIndex(table: string, index: IndexDefinition): string;
20
+ compileDropIndex(_table: string, name: string): string;
21
+ wrapTable(table: string): string;
22
+ wrapColumn(column: string): string;
23
+ compileTableExists(table: string): string;
24
+ compileColumnExists(table: string, column: string): string;
25
+ compileListTables(): string;
26
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * SQLite Schema Grammar
3
+ * @description DDL generation for SQLite
4
+ */
5
+ import type { Blueprint } from '../Blueprint';
6
+ import type { ColumnDefinition } from '../ColumnDefinition';
7
+ import type { IndexDefinition } from '../ForeignKeyDefinition';
8
+ import { SchemaGrammar } from './SchemaGrammar';
9
+ /**
10
+ * SQLite Schema Grammar
11
+ * Generates SQL DDL statements specifically for SQLite databases.
12
+ * @internal
13
+ */
14
+ export declare class SQLiteSchemaGrammar extends SchemaGrammar {
15
+ protected wrapChar: string;
16
+ compileCreate(blueprint: Blueprint): string;
17
+ wrapTable(table: string): string;
18
+ wrapColumn(column: string): string;
19
+ compileTableExists(table: string): string;
20
+ compileColumnExists(table: string, column: string): string;
21
+ compileListTables(): string;
22
+ protected compileType(column: ColumnDefinition): string;
23
+ protected compileAutoIncrement(): string;
24
+ protected supportsUnsigned(): boolean;
25
+ protected compileFullTextIndex(_table: string, _index: IndexDefinition): string;
26
+ protected compileSpatialIndex(_table: string, _index: IndexDefinition): string;
27
+ compileDropIndex(_table: string, name: string): string;
28
+ }