@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,123 @@
1
+ /**
2
+ * Schema Registry
3
+ * @description Central registry for table schemas with JIT sniffing and AOT locking
4
+ */
5
+ import type { ColumnSchema, TableSchema } from './types';
6
+ /**
7
+ * Schema Registry Mode
8
+ */
9
+ export type SchemaMode = 'jit' | 'aot';
10
+ /**
11
+ * Schema Registry Options
12
+ */
13
+ export interface SchemaRegistryOptions {
14
+ /** Mode: jit (dev) or aot (prod) */
15
+ mode?: SchemaMode;
16
+ /** Path to schema lock file */
17
+ lockPath?: string;
18
+ /** Database connection name */
19
+ connection?: string;
20
+ /** Cache TTL in milliseconds (JIT mode) */
21
+ cacheTtl?: number;
22
+ }
23
+ /**
24
+ * Schema Registry
25
+ * Central registry for table schemas
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * // Dev mode: JIT sniffing
30
+ * const registry = SchemaRegistry.getInstance({ mode: 'jit' })
31
+ * const schema = await registry.get('users')
32
+ *
33
+ * // Prod mode: AOT from lock file
34
+ * SchemaRegistry.init({ mode: 'aot', lockPath: '.schema-lock.json' })
35
+ * const schema = await registry.get('users')
36
+ * ```
37
+ */
38
+ export declare class SchemaRegistry {
39
+ private static instance;
40
+ private cache;
41
+ private sniffer;
42
+ private mode;
43
+ private lockPath;
44
+ private cacheTtl;
45
+ private _initialized;
46
+ private constructor();
47
+ /**
48
+ * Check if registry is initialized
49
+ */
50
+ get isInitialized(): boolean;
51
+ /**
52
+ * Initialize the registry (call once at startup)
53
+ */
54
+ static init(options?: SchemaRegistryOptions): SchemaRegistry;
55
+ /**
56
+ * Get the registry instance
57
+ */
58
+ static getInstance(): SchemaRegistry;
59
+ /**
60
+ * Reset the registry (for testing)
61
+ */
62
+ static reset(): void;
63
+ /**
64
+ * Get schema for a table
65
+ */
66
+ get(table: string, connection?: string): Promise<TableSchema>;
67
+ /**
68
+ * Check if table schema exists
69
+ */
70
+ has(table: string): boolean;
71
+ /**
72
+ * Get column schema
73
+ */
74
+ getColumn(table: string, column: string): Promise<ColumnSchema | undefined>;
75
+ /**
76
+ * Check if column exists
77
+ */
78
+ hasColumn(table: string, column: string): Promise<boolean>;
79
+ /**
80
+ * Get all cached tables
81
+ */
82
+ getTables(): string[];
83
+ /**
84
+ * Invalidate cache for a specific table
85
+ * Forces re-sniff on next access
86
+ */
87
+ invalidate(table: string): void;
88
+ /**
89
+ * Invalidate all cached schemas
90
+ */
91
+ invalidateAll(): void;
92
+ /**
93
+ * Force refresh schema for a table
94
+ * Re-sniffs even if cached (JIT mode only)
95
+ */
96
+ refresh(table: string): Promise<TableSchema>;
97
+ /**
98
+ * Wrap a database operation with self-healing
99
+ * Automatically re-sniffs schema on column-related errors and retries
100
+ *
101
+ * @example
102
+ * ```typescript
103
+ * const result = await registry.withSelfHealing('users', async () => {
104
+ * return await connection.table('users').where('new_column', value).get()
105
+ * })
106
+ * ```
107
+ */
108
+ withSelfHealing<T>(table: string, operation: () => Promise<T>): Promise<T>;
109
+ /**
110
+ * Check if an error is schema-related
111
+ */
112
+ private isSchemaError;
113
+ /**
114
+ * Load schemas from lock file (AOT mode)
115
+ */
116
+ loadFromLock(path?: string): void;
117
+ /**
118
+ * Save schemas to lock file
119
+ */
120
+ saveToLock(tables: string[], path?: string): Promise<void>;
121
+ private serializeTableSchema;
122
+ private deserializeTableSchema;
123
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Schema Sniffer
3
+ * @description Introspects database schema at runtime (JIT mode)
4
+ */
5
+ import type { TableSchema } from './types';
6
+ /**
7
+ * Schema Sniffer
8
+ * Retrieves table schema from database at runtime
9
+ */
10
+ export declare class SchemaSniffer {
11
+ private connectionName;
12
+ constructor(connectionName?: string);
13
+ /**
14
+ * Sniff table schema from database
15
+ */
16
+ sniff(table: string): Promise<TableSchema>;
17
+ /**
18
+ * Sniff SQLite table schema
19
+ */
20
+ private sniffSQLite;
21
+ /**
22
+ * Sniff PostgreSQL table schema
23
+ */
24
+ private sniffPostgres;
25
+ /**
26
+ * Sniff MySQL table schema
27
+ */
28
+ private sniffMySQL;
29
+ /**
30
+ * Map PostgreSQL type to ColumnType
31
+ */
32
+ private mapPostgresType;
33
+ /**
34
+ * Map MySQL type to ColumnType
35
+ */
36
+ private mapMySQLType;
37
+ private mapSQLiteType;
38
+ /**
39
+ * Parse default value
40
+ */
41
+ private parseDefault;
42
+ /**
43
+ * Extract length from MySQL type
44
+ */
45
+ private extractMySQLLength;
46
+ /**
47
+ * Extract enum values from MySQL type
48
+ */
49
+ private extractMySQLEnumValues;
50
+ /**
51
+ * Get driver name
52
+ */
53
+ private getDriverName;
54
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Schema Module Index
3
+ */
4
+ export { type SchemaMode, SchemaRegistry, type SchemaRegistryOptions } from './SchemaRegistry';
5
+ export { SchemaSniffer } from './SchemaSniffer';
6
+ export type { ColumnSchema, ColumnType, SchemaLock, SerializedColumnSchema, SerializedTableSchema, TableSchema, } from './types';
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Schema Types
3
+ * @description Type definitions for schema introspection
4
+ */
5
+ /**
6
+ * Column data types
7
+ */
8
+ export type ColumnType = 'string' | 'text' | 'integer' | 'bigint' | 'smallint' | 'decimal' | 'float' | 'boolean' | 'date' | 'time' | 'datetime' | 'timestamp' | 'json' | 'jsonb' | 'uuid' | 'binary' | 'enum' | 'unknown';
9
+ /**
10
+ * Column schema definition
11
+ */
12
+ export interface ColumnSchema {
13
+ /** Column name */
14
+ name: string;
15
+ /** Column type */
16
+ type: ColumnType;
17
+ /** Is nullable */
18
+ nullable: boolean;
19
+ /** Default value */
20
+ default?: unknown;
21
+ /** Is primary key */
22
+ primary: boolean;
23
+ /** Is unique */
24
+ unique: boolean;
25
+ /** Is auto-increment */
26
+ autoIncrement: boolean;
27
+ /** Enum values (if type is enum) */
28
+ enumValues?: string[] | undefined;
29
+ /** Max length (for string types) */
30
+ maxLength?: number | undefined;
31
+ /** Numeric precision */
32
+ precision?: number | undefined;
33
+ /** Numeric scale */
34
+ scale?: number | undefined;
35
+ }
36
+ /**
37
+ * Table schema definition
38
+ */
39
+ export interface TableSchema {
40
+ /** Table name */
41
+ table: string;
42
+ /** Column definitions */
43
+ columns: Map<string, ColumnSchema>;
44
+ /** Primary key column(s) */
45
+ primaryKey: string[];
46
+ /** Timestamp of schema capture */
47
+ capturedAt: number;
48
+ }
49
+ /**
50
+ * Schema lock file format
51
+ */
52
+ export interface SchemaLock {
53
+ /** Version for compatibility */
54
+ version: string;
55
+ /** Driver used to generate */
56
+ driver: string;
57
+ /** Generation timestamp */
58
+ generatedAt: string;
59
+ /** Table schemas */
60
+ tables: Record<string, SerializedTableSchema>;
61
+ }
62
+ /**
63
+ * Serialized table schema (for JSON storage)
64
+ */
65
+ export interface SerializedTableSchema {
66
+ table: string;
67
+ columns: SerializedColumnSchema[];
68
+ primaryKey: string[];
69
+ }
70
+ /**
71
+ * Serialized column schema (for JSON storage)
72
+ */
73
+ export interface SerializedColumnSchema {
74
+ name: string;
75
+ type: ColumnType;
76
+ nullable: boolean;
77
+ default?: unknown;
78
+ primary: boolean;
79
+ unique: boolean;
80
+ autoIncrement: boolean;
81
+ enumValues?: string[] | undefined;
82
+ maxLength?: number | undefined;
83
+ precision?: number | undefined;
84
+ scale?: number | undefined;
85
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Raw SQL Expression
3
+ * @description Represents a raw SQL expression that should not be escaped by the query builder.
4
+ * Use this for complex SQL fragments, function calls, or database-specific syntax.
5
+ */
6
+ export declare class Expression {
7
+ private readonly sql;
8
+ private readonly bindings;
9
+ /**
10
+ * Create a new Expression instance
11
+ *
12
+ * @param sql - The raw SQL string
13
+ * @param bindings - Optional array of bindings for the expression
14
+ */
15
+ constructor(sql: string, bindings?: unknown[]);
16
+ /**
17
+ * Get the raw SQL string
18
+ *
19
+ * @returns The SQL string
20
+ */
21
+ getValue(): string;
22
+ /**
23
+ * Get the bindings associated with this expression
24
+ *
25
+ * @returns Array of bindings
26
+ */
27
+ getBindings(): unknown[];
28
+ /**
29
+ * Convert the expression to its SQL string representation
30
+ *
31
+ * @returns The SQL string
32
+ */
33
+ toString(): string;
34
+ }
35
+ /**
36
+ * Create a raw SQL expression
37
+ *
38
+ * @param sql - The raw SQL string
39
+ * @param bindings - Optional array of bindings
40
+ * @returns A new Expression instance
41
+ * @example
42
+ * ```typescript
43
+ * DB.table('users').select(raw('COUNT(*) as total')).get()
44
+ * ```
45
+ */
46
+ export declare function raw(sql: string, bindings?: unknown[]): Expression;
47
+ /**
48
+ * Tagged template literal for safe raw SQL construction
49
+ *
50
+ * @param strings - Template strings
51
+ * @param values - Values to be used as bindings
52
+ * @returns A new Expression instance with auto-generated placeholders
53
+ * @example
54
+ * ```typescript
55
+ * const userId = 1;
56
+ * const query = sql`SELECT * FROM users WHERE id = ${userId}`;
57
+ * // Result: Expression { sql: "SELECT * FROM users WHERE id = ?", bindings: [1] }
58
+ * ```
59
+ */
60
+ export declare function sql(strings: TemplateStringsArray, ...values: unknown[]): Expression;
@@ -0,0 +1,10 @@
1
+ export declare class NPlusOneDetector {
2
+ private static queryCounts;
3
+ private static timeframe;
4
+ private static threshold;
5
+ private static enabled;
6
+ static track(tableName: string, sql: string, structureKey: string): void;
7
+ static reset(): void;
8
+ static setEnabled(enabled: boolean): void;
9
+ private static warn;
10
+ }