@gravito/ripple 4.0.1 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/README.md +26 -10
  2. package/dist/{ripple/src/OrbitRipple.d.ts → OrbitRipple.d.ts} +1 -0
  3. package/dist/{ripple/src/RippleServer.d.ts → RippleServer.d.ts} +32 -1
  4. package/dist/core/src/Application.d.ts +41 -0
  5. package/dist/core/src/HookManager.d.ts +33 -189
  6. package/dist/core/src/PlanetCore.d.ts +31 -1
  7. package/dist/core/src/Router.d.ts +32 -46
  8. package/dist/core/src/adapters/bun/BunContext.d.ts +6 -1
  9. package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +35 -0
  10. package/dist/core/src/adapters/bun/BunWebSocketHandler.d.ts +48 -0
  11. package/dist/core/src/adapters/bun/RadixRouter.d.ts +1 -0
  12. package/dist/core/src/adapters/bun/index.d.ts +7 -0
  13. package/dist/core/src/binary/BinaryUtils.d.ts +105 -0
  14. package/dist/core/src/binary/index.d.ts +5 -0
  15. package/dist/core/src/compat/async-local-storage.d.ts +7 -0
  16. package/dist/core/src/compat/crypto.d.ts +6 -0
  17. package/dist/core/src/engine/AOTRouter.d.ts +10 -0
  18. package/dist/core/src/engine/FastContext.d.ts +19 -1
  19. package/dist/core/src/engine/Gravito.d.ts +13 -18
  20. package/dist/core/src/engine/MinimalContext.d.ts +2 -0
  21. package/dist/core/src/engine/analyzer.d.ts +92 -6
  22. package/dist/core/src/engine/types.d.ts +3 -0
  23. package/dist/core/src/events/CircuitBreaker.d.ts +12 -0
  24. package/dist/core/src/events/EventPriorityQueue.d.ts +18 -256
  25. package/dist/core/src/events/index.d.ts +12 -11
  26. package/dist/core/src/events/queue-core.d.ts +77 -0
  27. package/dist/core/src/events/task-executor.d.ts +51 -0
  28. package/dist/core/src/exceptions/AuthException.d.ts +10 -0
  29. package/dist/core/src/exceptions/AuthenticationException.d.ts +2 -2
  30. package/dist/core/src/exceptions/AuthorizationException.d.ts +2 -2
  31. package/dist/core/src/exceptions/CacheException.d.ts +9 -0
  32. package/dist/core/src/exceptions/CircularDependencyException.d.ts +2 -1
  33. package/dist/core/src/exceptions/ConfigurationException.d.ts +9 -0
  34. package/dist/core/src/exceptions/DatabaseException.d.ts +9 -0
  35. package/dist/core/src/exceptions/DomainException.d.ts +9 -0
  36. package/dist/core/src/exceptions/InfrastructureException.d.ts +17 -0
  37. package/dist/core/src/exceptions/QueueException.d.ts +9 -0
  38. package/dist/core/src/exceptions/StorageException.d.ts +9 -0
  39. package/dist/core/src/exceptions/StreamException.d.ts +9 -0
  40. package/dist/core/src/exceptions/SystemException.d.ts +9 -0
  41. package/dist/core/src/exceptions/ValidationException.d.ts +2 -2
  42. package/dist/core/src/exceptions/index.d.ts +10 -0
  43. package/dist/core/src/ffi/NativeAccelerator.d.ts +62 -0
  44. package/dist/core/src/ffi/NativeHasher.d.ts +139 -0
  45. package/dist/core/src/ffi/cbor-fallback.d.ts +96 -0
  46. package/dist/core/src/ffi/hash-fallback.d.ts +33 -0
  47. package/dist/core/src/ffi/index.d.ts +10 -0
  48. package/dist/core/src/ffi/types.d.ts +135 -0
  49. package/dist/core/src/helpers/Str.d.ts +15 -0
  50. package/dist/core/src/hooks/ActionManager.d.ts +132 -0
  51. package/dist/core/src/hooks/AsyncDetector.d.ts +84 -0
  52. package/dist/core/src/hooks/FilterManager.d.ts +71 -0
  53. package/dist/core/src/hooks/MigrationWarner.d.ts +24 -0
  54. package/dist/core/src/hooks/dlq-operations.d.ts +60 -0
  55. package/dist/core/src/hooks/types.d.ts +107 -0
  56. package/dist/core/src/http/CookieJar.d.ts +2 -2
  57. package/dist/core/src/http/types.d.ts +24 -3
  58. package/dist/core/src/index.d.ts +491 -14
  59. package/dist/core/src/observability/contracts.d.ts +137 -0
  60. package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +2 -3
  61. package/dist/core/src/runtime/adapter-bun.d.ts +12 -0
  62. package/dist/core/src/runtime/adapter-deno.d.ts +12 -0
  63. package/dist/core/src/runtime/adapter-node.d.ts +12 -0
  64. package/dist/core/src/runtime/adapter-unknown.d.ts +13 -0
  65. package/dist/core/src/runtime/archive.d.ts +17 -0
  66. package/dist/core/src/runtime/compression.d.ts +21 -0
  67. package/dist/core/src/runtime/deep-equals.d.ts +56 -0
  68. package/dist/core/src/runtime/detection.d.ts +22 -0
  69. package/dist/core/src/runtime/escape.d.ts +34 -0
  70. package/dist/core/src/runtime/index.d.ts +44 -0
  71. package/dist/core/src/runtime/markdown.d.ts +44 -0
  72. package/dist/core/src/runtime/types.d.ts +436 -0
  73. package/dist/core/src/runtime-helpers.d.ts +67 -0
  74. package/dist/core/src/runtime.d.ts +10 -118
  75. package/dist/core/src/testing/HttpTester.d.ts +1 -0
  76. package/dist/core/src/transpiler-utils.d.ts +170 -0
  77. package/dist/{ripple/src/engines → engines}/BunEngine.d.ts +11 -0
  78. package/dist/errors/RippleError.d.ts +66 -0
  79. package/dist/index.js +1 -7502
  80. package/dist/index.js.map +3 -71
  81. package/package.json +6 -2
  82. package/dist/atlas/src/DB.d.ts +0 -348
  83. package/dist/atlas/src/OrbitAtlas.d.ts +0 -9
  84. package/dist/atlas/src/config/defineConfig.d.ts +0 -14
  85. package/dist/atlas/src/config/index.d.ts +0 -7
  86. package/dist/atlas/src/config/loadConfig.d.ts +0 -41
  87. package/dist/atlas/src/connection/Connection.d.ts +0 -112
  88. package/dist/atlas/src/connection/ConnectionManager.d.ts +0 -180
  89. package/dist/atlas/src/connection/ReplicaConnectionPool.d.ts +0 -54
  90. package/dist/atlas/src/drivers/BunSQLDriver.d.ts +0 -32
  91. package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +0 -118
  92. package/dist/atlas/src/drivers/MongoDBDriver.d.ts +0 -36
  93. package/dist/atlas/src/drivers/MySQLDriver.d.ts +0 -79
  94. package/dist/atlas/src/drivers/PostgresDriver.d.ts +0 -96
  95. package/dist/atlas/src/drivers/RedisDriver.d.ts +0 -43
  96. package/dist/atlas/src/drivers/SQLiteDriver.d.ts +0 -45
  97. package/dist/atlas/src/drivers/types.d.ts +0 -260
  98. package/dist/atlas/src/errors/index.d.ts +0 -45
  99. package/dist/atlas/src/grammar/Grammar.d.ts +0 -342
  100. package/dist/atlas/src/grammar/MongoGrammar.d.ts +0 -47
  101. package/dist/atlas/src/grammar/MySQLGrammar.d.ts +0 -54
  102. package/dist/atlas/src/grammar/NullGrammar.d.ts +0 -35
  103. package/dist/atlas/src/grammar/PostgresGrammar.d.ts +0 -62
  104. package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +0 -32
  105. package/dist/atlas/src/index.d.ts +0 -79
  106. package/dist/atlas/src/migration/Migration.d.ts +0 -64
  107. package/dist/atlas/src/migration/MigrationRepository.d.ts +0 -65
  108. package/dist/atlas/src/migration/Migrator.d.ts +0 -110
  109. package/dist/atlas/src/migration/index.d.ts +0 -6
  110. package/dist/atlas/src/observability/AtlasMetrics.d.ts +0 -33
  111. package/dist/atlas/src/observability/AtlasObservability.d.ts +0 -15
  112. package/dist/atlas/src/observability/AtlasTracer.d.ts +0 -12
  113. package/dist/atlas/src/observability/index.d.ts +0 -9
  114. package/dist/atlas/src/orm/Repository.d.ts +0 -247
  115. package/dist/atlas/src/orm/index.d.ts +0 -6
  116. package/dist/atlas/src/orm/model/DirtyTracker.d.ts +0 -121
  117. package/dist/atlas/src/orm/model/Model.d.ts +0 -458
  118. package/dist/atlas/src/orm/model/ModelRegistry.d.ts +0 -20
  119. package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +0 -150
  120. package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +0 -36
  121. package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +0 -92
  122. package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +0 -117
  123. package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +0 -64
  124. package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +0 -15
  125. package/dist/atlas/src/orm/model/concerns/index.d.ts +0 -12
  126. package/dist/atlas/src/orm/model/decorators.d.ts +0 -138
  127. package/dist/atlas/src/orm/model/errors.d.ts +0 -52
  128. package/dist/atlas/src/orm/model/index.d.ts +0 -10
  129. package/dist/atlas/src/orm/model/relationships.d.ts +0 -207
  130. package/dist/atlas/src/orm/model/types.d.ts +0 -12
  131. package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +0 -124
  132. package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +0 -54
  133. package/dist/atlas/src/orm/schema/index.d.ts +0 -6
  134. package/dist/atlas/src/orm/schema/types.d.ts +0 -85
  135. package/dist/atlas/src/pool/AdaptivePoolManager.d.ts +0 -98
  136. package/dist/atlas/src/pool/PoolHealthChecker.d.ts +0 -91
  137. package/dist/atlas/src/pool/PoolStrategy.d.ts +0 -129
  138. package/dist/atlas/src/pool/PoolWarmer.d.ts +0 -92
  139. package/dist/atlas/src/query/Expression.d.ts +0 -60
  140. package/dist/atlas/src/query/NPlusOneDetector.d.ts +0 -10
  141. package/dist/atlas/src/query/QueryBuilder.d.ts +0 -643
  142. package/dist/atlas/src/query/RelationshipResolver.d.ts +0 -23
  143. package/dist/atlas/src/query/clauses/GroupByClause.d.ts +0 -51
  144. package/dist/atlas/src/query/clauses/HavingClause.d.ts +0 -70
  145. package/dist/atlas/src/query/clauses/JoinClause.d.ts +0 -87
  146. package/dist/atlas/src/query/clauses/LimitClause.d.ts +0 -82
  147. package/dist/atlas/src/query/clauses/OrderByClause.d.ts +0 -69
  148. package/dist/atlas/src/query/clauses/SelectClause.d.ts +0 -71
  149. package/dist/atlas/src/query/clauses/WhereClause.d.ts +0 -167
  150. package/dist/atlas/src/query/clauses/index.d.ts +0 -11
  151. package/dist/atlas/src/schema/Blueprint.d.ts +0 -276
  152. package/dist/atlas/src/schema/ColumnDefinition.d.ts +0 -154
  153. package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +0 -37
  154. package/dist/atlas/src/schema/MigrationGenerator.d.ts +0 -45
  155. package/dist/atlas/src/schema/Schema.d.ts +0 -131
  156. package/dist/atlas/src/schema/SchemaDiff.d.ts +0 -73
  157. package/dist/atlas/src/schema/TypeGenerator.d.ts +0 -57
  158. package/dist/atlas/src/schema/TypeWriter.d.ts +0 -42
  159. package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +0 -23
  160. package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +0 -26
  161. package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +0 -28
  162. package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +0 -97
  163. package/dist/atlas/src/schema/grammars/index.d.ts +0 -7
  164. package/dist/atlas/src/schema/index.d.ts +0 -8
  165. package/dist/atlas/src/seed/Factory.d.ts +0 -90
  166. package/dist/atlas/src/seed/Seeder.d.ts +0 -28
  167. package/dist/atlas/src/seed/SeederRunner.d.ts +0 -74
  168. package/dist/atlas/src/seed/index.d.ts +0 -6
  169. package/dist/atlas/src/sharding/ShardingManager.d.ts +0 -59
  170. package/dist/atlas/src/types/index.d.ts +0 -1182
  171. package/dist/atlas/src/utils/CursorEncoding.d.ts +0 -63
  172. package/dist/atlas/src/utils/levenshtein.d.ts +0 -9
  173. package/dist/core/src/adapters/PhotonAdapter.d.ts +0 -175
  174. package/dist/core/src/adapters/photon-types.d.ts +0 -73
  175. package/dist/core/src/http/middleware/BodySizeLimit.d.ts +0 -16
  176. package/dist/core/src/http/middleware/Cors.d.ts +0 -24
  177. package/dist/core/src/http/middleware/Csrf.d.ts +0 -23
  178. package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +0 -28
  179. package/dist/core/src/http/middleware/SecurityHeaders.d.ts +0 -29
  180. package/dist/core/src/http/middleware/ThrottleRequests.d.ts +0 -18
  181. package/dist/core/src/instrumentation/index.d.ts +0 -35
  182. package/dist/core/src/instrumentation/opentelemetry.d.ts +0 -178
  183. package/dist/core/src/instrumentation/types.d.ts +0 -182
  184. package/dist/core/src/observability/Metrics.d.ts +0 -244
  185. package/dist/photon/src/index.d.ts +0 -89
  186. package/dist/photon/src/middleware/binary.d.ts +0 -31
  187. package/dist/photon/src/middleware/htmx.d.ts +0 -39
  188. package/dist/photon/src/middleware/ratelimit-redis.d.ts +0 -50
  189. package/dist/photon/src/middleware/ratelimit.d.ts +0 -161
  190. package/dist/photon/src/openapi.d.ts +0 -19
  191. package/dist/ripple/src/errors/RippleError.d.ts +0 -48
  192. /package/dist/{ripple/src/channels → channels}/Channel.d.ts +0 -0
  193. /package/dist/{ripple/src/channels → channels}/ChannelManager.d.ts +0 -0
  194. /package/dist/{ripple/src/channels → channels}/index.d.ts +0 -0
  195. /package/dist/{ripple/src/drivers → drivers}/LocalDriver.d.ts +0 -0
  196. /package/dist/{ripple/src/drivers → drivers}/NATSDriver.d.ts +0 -0
  197. /package/dist/{ripple/src/drivers → drivers}/RedisDriver.d.ts +0 -0
  198. /package/dist/{ripple/src/drivers → drivers}/index.d.ts +0 -0
  199. /package/dist/{ripple/src/engines → engines}/IRippleEngine.d.ts +0 -0
  200. /package/dist/{ripple/src/engines → engines}/UWebSocketsEngine.d.ts +0 -0
  201. /package/dist/{ripple/src/engines → engines}/WsEngine.d.ts +0 -0
  202. /package/dist/{ripple/src/engines → engines}/index.d.ts +0 -0
  203. /package/dist/{ripple/src/errors → errors}/index.d.ts +0 -0
  204. /package/dist/{ripple/src/events → events}/BroadcastEvent.d.ts +0 -0
  205. /package/dist/{ripple/src/events → events}/BroadcastManager.d.ts +0 -0
  206. /package/dist/{ripple/src/events → events}/Broadcaster.d.ts +0 -0
  207. /package/dist/{ripple/src/events → events}/index.d.ts +0 -0
  208. /package/dist/{ripple/src/health → health}/HealthChecker.d.ts +0 -0
  209. /package/dist/{ripple/src/health → health}/index.d.ts +0 -0
  210. /package/dist/{ripple/src/index.d.ts → index.d.ts} +0 -0
  211. /package/dist/{ripple/src/logging → logging}/Logger.d.ts +0 -0
  212. /package/dist/{ripple/src/logging → logging}/index.d.ts +0 -0
  213. /package/dist/{ripple/src/middleware → middleware}/InterceptorManager.d.ts +0 -0
  214. /package/dist/{ripple/src/observability → observability}/RippleMetrics.d.ts +0 -0
  215. /package/dist/{ripple/src/reliability → reliability}/AckManager.d.ts +0 -0
  216. /package/dist/{ripple/src/serializers → serializers}/ISerializer.d.ts +0 -0
  217. /package/dist/{ripple/src/serializers → serializers}/JsonSerializer.d.ts +0 -0
  218. /package/dist/{ripple/src/serializers → serializers}/ProtobufSerializer.d.ts +0 -0
  219. /package/dist/{ripple/src/serializers → serializers}/index.d.ts +0 -0
  220. /package/dist/{ripple/src/tracking → tracking}/ConnectionTracker.d.ts +0 -0
  221. /package/dist/{ripple/src/tracking → tracking}/SessionManager.d.ts +0 -0
  222. /package/dist/{ripple/src/tracking → tracking}/index.d.ts +0 -0
  223. /package/dist/{ripple/src/types.d.ts → types.d.ts} +0 -0
  224. /package/dist/{ripple/src/utils → utils}/MessageSerializer.d.ts +0 -0
  225. /package/dist/{ripple/src/utils → utils}/TokenBucket.d.ts +0 -0
  226. /package/dist/{ripple/src/utils → utils}/index.d.ts +0 -0
@@ -1,276 +0,0 @@
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 {};
@@ -1,154 +0,0 @@
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 {};
@@ -1,37 +0,0 @@
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
- }
@@ -1,45 +0,0 @@
1
- /**
2
- * @gravito/atlas - Migration Generator
3
- * @description Converts a SchemaDiffResult into SQL ALTER TABLE statements
4
- * for both PostgreSQL and MySQL dialects.
5
- *
6
- * Powers the `migrate:generate` and `db:push` CLI commands.
7
- */
8
- import type { DriverType } from '../types';
9
- import type { SchemaDiffResult } from './SchemaDiff';
10
- export interface MigrationGeneratorOptions {
11
- /** Target database dialect */
12
- dialect: DriverType;
13
- }
14
- /**
15
- * MigrationGenerator
16
- *
17
- * Takes a `SchemaDiffResult` and generates the corresponding SQL statements
18
- * required to bring the database schema in sync with Model definitions.
19
- *
20
- * @example
21
- * ```typescript
22
- * const gen = new MigrationGenerator({ dialect: 'postgres' })
23
- * const sql = gen.generate(diff)
24
- * // Returns: ALTER TABLE users ADD COLUMN bio TEXT NULL; ...
25
- * ```
26
- */
27
- export declare class MigrationGenerator {
28
- private readonly dialect;
29
- constructor(options: MigrationGeneratorOptions);
30
- /**
31
- * Generate SQL statements for the given diff.
32
- *
33
- * @param diff - Schema diff result from SchemaDiff.compare()
34
- * @returns Array of SQL statements to execute
35
- */
36
- generate(diff: SchemaDiffResult): string[];
37
- /**
38
- * Generate a timestamped migration script content string.
39
- *
40
- * @param diff - Schema diff result
41
- * @param migrationName - Optional migration name
42
- */
43
- generateMigrationScript(diff: SchemaDiffResult, migrationName?: string): string;
44
- private quoteIdentifier;
45
- }
@@ -1,131 +0,0 @@
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
- }