@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.
- package/README.md +211 -0
- package/dist/atlas/src/DB.d.ts +301 -0
- package/dist/atlas/src/OrbitAtlas.d.ts +9 -0
- package/dist/atlas/src/config/defineConfig.d.ts +14 -0
- package/dist/atlas/src/config/index.d.ts +7 -0
- package/dist/atlas/src/config/loadConfig.d.ts +48 -0
- package/dist/atlas/src/connection/Connection.d.ts +108 -0
- package/dist/atlas/src/connection/ConnectionManager.d.ts +111 -0
- package/dist/atlas/src/drivers/BunSQLDriver.d.ts +32 -0
- package/dist/atlas/src/drivers/BunSQLPreparedStatement.d.ts +118 -0
- package/dist/atlas/src/drivers/MongoDBDriver.d.ts +36 -0
- package/dist/atlas/src/drivers/MySQLDriver.d.ts +66 -0
- package/dist/atlas/src/drivers/PostgresDriver.d.ts +83 -0
- package/dist/atlas/src/drivers/RedisDriver.d.ts +43 -0
- package/dist/atlas/src/drivers/SQLiteDriver.d.ts +45 -0
- package/dist/atlas/src/drivers/types.d.ts +260 -0
- package/dist/atlas/src/errors/index.d.ts +45 -0
- package/dist/atlas/src/grammar/Grammar.d.ts +342 -0
- package/dist/atlas/src/grammar/MongoGrammar.d.ts +47 -0
- package/dist/atlas/src/grammar/MySQLGrammar.d.ts +54 -0
- package/dist/atlas/src/grammar/NullGrammar.d.ts +35 -0
- package/dist/atlas/src/grammar/PostgresGrammar.d.ts +62 -0
- package/dist/atlas/src/grammar/SQLiteGrammar.d.ts +32 -0
- package/dist/atlas/src/index.d.ts +67 -0
- package/dist/atlas/src/migration/Migration.d.ts +64 -0
- package/dist/atlas/src/migration/MigrationRepository.d.ts +65 -0
- package/dist/atlas/src/migration/Migrator.d.ts +110 -0
- package/dist/atlas/src/migration/index.d.ts +6 -0
- package/dist/atlas/src/observability/AtlasMetrics.d.ts +11 -0
- package/dist/atlas/src/observability/AtlasObservability.d.ts +15 -0
- package/dist/atlas/src/observability/AtlasTracer.d.ts +12 -0
- package/dist/atlas/src/observability/index.d.ts +9 -0
- package/dist/atlas/src/orm/index.d.ts +5 -0
- package/dist/atlas/src/orm/model/DirtyTracker.d.ts +121 -0
- package/dist/atlas/src/orm/model/Model.d.ts +449 -0
- package/dist/atlas/src/orm/model/ModelRegistry.d.ts +20 -0
- package/dist/atlas/src/orm/model/concerns/HasAttributes.d.ts +136 -0
- package/dist/atlas/src/orm/model/concerns/HasEvents.d.ts +36 -0
- package/dist/atlas/src/orm/model/concerns/HasPersistence.d.ts +87 -0
- package/dist/atlas/src/orm/model/concerns/HasRelationships.d.ts +117 -0
- package/dist/atlas/src/orm/model/concerns/HasSerialization.d.ts +64 -0
- package/dist/atlas/src/orm/model/concerns/applyMixins.d.ts +15 -0
- package/dist/atlas/src/orm/model/concerns/index.d.ts +12 -0
- package/dist/atlas/src/orm/model/decorators.d.ts +109 -0
- package/dist/atlas/src/orm/model/errors.d.ts +52 -0
- package/dist/atlas/src/orm/model/index.d.ts +10 -0
- package/dist/atlas/src/orm/model/relationships.d.ts +207 -0
- package/dist/atlas/src/orm/model/types.d.ts +12 -0
- package/dist/atlas/src/orm/schema/SchemaRegistry.d.ts +123 -0
- package/dist/atlas/src/orm/schema/SchemaSniffer.d.ts +54 -0
- package/dist/atlas/src/orm/schema/index.d.ts +6 -0
- package/dist/atlas/src/orm/schema/types.d.ts +85 -0
- package/dist/atlas/src/query/Expression.d.ts +60 -0
- package/dist/atlas/src/query/NPlusOneDetector.d.ts +10 -0
- package/dist/atlas/src/query/QueryBuilder.d.ts +573 -0
- package/dist/atlas/src/query/clauses/GroupByClause.d.ts +51 -0
- package/dist/atlas/src/query/clauses/HavingClause.d.ts +70 -0
- package/dist/atlas/src/query/clauses/JoinClause.d.ts +87 -0
- package/dist/atlas/src/query/clauses/LimitClause.d.ts +82 -0
- package/dist/atlas/src/query/clauses/OrderByClause.d.ts +69 -0
- package/dist/atlas/src/query/clauses/SelectClause.d.ts +71 -0
- package/dist/atlas/src/query/clauses/WhereClause.d.ts +167 -0
- package/dist/atlas/src/query/clauses/index.d.ts +11 -0
- package/dist/atlas/src/schema/Blueprint.d.ts +276 -0
- package/dist/atlas/src/schema/ColumnDefinition.d.ts +154 -0
- package/dist/atlas/src/schema/ForeignKeyDefinition.d.ts +37 -0
- package/dist/atlas/src/schema/Schema.d.ts +131 -0
- package/dist/atlas/src/schema/grammars/MySQLSchemaGrammar.d.ts +23 -0
- package/dist/atlas/src/schema/grammars/PostgresSchemaGrammar.d.ts +26 -0
- package/dist/atlas/src/schema/grammars/SQLiteSchemaGrammar.d.ts +28 -0
- package/dist/atlas/src/schema/grammars/SchemaGrammar.d.ts +97 -0
- package/dist/atlas/src/schema/grammars/index.d.ts +7 -0
- package/dist/atlas/src/schema/index.d.ts +8 -0
- package/dist/atlas/src/seed/Factory.d.ts +90 -0
- package/dist/atlas/src/seed/Seeder.d.ts +28 -0
- package/dist/atlas/src/seed/SeederRunner.d.ts +74 -0
- package/dist/atlas/src/seed/index.d.ts +6 -0
- package/dist/atlas/src/types/index.d.ts +1100 -0
- package/dist/atlas/src/utils/levenshtein.d.ts +9 -0
- package/dist/core/src/Application.d.ts +215 -0
- package/dist/core/src/CommandKernel.d.ts +33 -0
- package/dist/core/src/ConfigManager.d.ts +26 -0
- package/dist/core/src/Container.d.ts +108 -0
- package/dist/core/src/ErrorHandler.d.ts +63 -0
- package/dist/core/src/Event.d.ts +5 -0
- package/dist/core/src/EventManager.d.ts +123 -0
- package/dist/core/src/GlobalErrorHandlers.d.ts +47 -0
- package/dist/core/src/GravitoServer.d.ts +28 -0
- package/dist/core/src/HookManager.d.ts +496 -0
- package/dist/core/src/Listener.d.ts +4 -0
- package/dist/core/src/Logger.d.ts +20 -0
- package/dist/core/src/PlanetCore.d.ts +289 -0
- package/dist/core/src/Route.d.ts +36 -0
- package/dist/core/src/Router.d.ts +284 -0
- package/dist/core/src/ServiceProvider.d.ts +156 -0
- package/dist/core/src/adapters/GravitoEngineAdapter.d.ts +27 -0
- package/dist/core/src/adapters/PhotonAdapter.d.ts +171 -0
- package/dist/core/src/adapters/bun/BunContext.d.ts +45 -0
- package/dist/core/src/adapters/bun/BunNativeAdapter.d.ts +31 -0
- package/dist/core/src/adapters/bun/BunRequest.d.ts +31 -0
- package/dist/core/src/adapters/bun/RadixNode.d.ts +19 -0
- package/dist/core/src/adapters/bun/RadixRouter.d.ts +31 -0
- package/dist/core/src/adapters/bun/types.d.ts +20 -0
- package/dist/core/src/adapters/photon-types.d.ts +73 -0
- package/dist/core/src/adapters/types.d.ts +235 -0
- package/dist/core/src/engine/AOTRouter.d.ts +124 -0
- package/dist/core/src/engine/FastContext.d.ts +100 -0
- package/dist/core/src/engine/Gravito.d.ts +137 -0
- package/dist/core/src/engine/MinimalContext.d.ts +79 -0
- package/dist/core/src/engine/analyzer.d.ts +27 -0
- package/dist/core/src/engine/constants.d.ts +23 -0
- package/dist/core/src/engine/index.d.ts +26 -0
- package/dist/core/src/engine/path.d.ts +26 -0
- package/dist/core/src/engine/pool.d.ts +83 -0
- package/dist/core/src/engine/types.d.ts +143 -0
- package/dist/core/src/events/CircuitBreaker.d.ts +229 -0
- package/dist/core/src/events/DeadLetterQueue.d.ts +145 -0
- package/dist/core/src/events/EventBackend.d.ts +11 -0
- package/dist/core/src/events/EventOptions.d.ts +109 -0
- package/dist/core/src/events/EventPriorityQueue.d.ts +202 -0
- package/dist/core/src/events/IdempotencyCache.d.ts +60 -0
- package/dist/core/src/events/index.d.ts +14 -0
- package/dist/core/src/events/observability/EventMetrics.d.ts +132 -0
- package/dist/core/src/events/observability/EventTracer.d.ts +68 -0
- package/dist/core/src/events/observability/EventTracing.d.ts +161 -0
- package/dist/core/src/events/observability/OTelEventMetrics.d.ts +240 -0
- package/dist/core/src/events/observability/ObservableHookManager.d.ts +108 -0
- package/dist/core/src/events/observability/index.d.ts +20 -0
- package/dist/core/src/events/observability/metrics-types.d.ts +16 -0
- package/dist/core/src/events/types.d.ts +75 -0
- package/dist/core/src/exceptions/AuthenticationException.d.ts +8 -0
- package/dist/core/src/exceptions/AuthorizationException.d.ts +8 -0
- package/dist/core/src/exceptions/CircularDependencyException.d.ts +9 -0
- package/dist/core/src/exceptions/GravitoException.d.ts +23 -0
- package/dist/core/src/exceptions/HttpException.d.ts +9 -0
- package/dist/core/src/exceptions/ModelNotFoundException.d.ts +10 -0
- package/dist/core/src/exceptions/ValidationException.d.ts +22 -0
- package/dist/core/src/exceptions/index.d.ts +7 -0
- package/dist/core/src/helpers/Arr.d.ts +19 -0
- package/dist/core/src/helpers/Str.d.ts +23 -0
- package/dist/core/src/helpers/data.d.ts +25 -0
- package/dist/core/src/helpers/errors.d.ts +34 -0
- package/dist/core/src/helpers/response.d.ts +41 -0
- package/dist/core/src/helpers.d.ts +338 -0
- package/dist/core/src/http/CookieJar.d.ts +51 -0
- package/dist/core/src/http/cookie.d.ts +29 -0
- package/dist/core/src/http/middleware/BodySizeLimit.d.ts +16 -0
- package/dist/core/src/http/middleware/Cors.d.ts +24 -0
- package/dist/core/src/http/middleware/Csrf.d.ts +23 -0
- package/dist/core/src/http/middleware/HeaderTokenGate.d.ts +28 -0
- package/dist/core/src/http/middleware/SecurityHeaders.d.ts +29 -0
- package/dist/core/src/http/middleware/ThrottleRequests.d.ts +18 -0
- package/dist/core/src/http/types.d.ts +355 -0
- package/dist/core/src/index.d.ts +76 -0
- package/dist/core/src/instrumentation/index.d.ts +35 -0
- package/dist/core/src/instrumentation/opentelemetry.d.ts +178 -0
- package/dist/core/src/instrumentation/types.d.ts +182 -0
- package/dist/core/src/reliability/DeadLetterQueueManager.d.ts +316 -0
- package/dist/core/src/reliability/RetryPolicy.d.ts +217 -0
- package/dist/core/src/reliability/index.d.ts +6 -0
- package/dist/core/src/router/ControllerDispatcher.d.ts +12 -0
- package/dist/core/src/router/RequestValidator.d.ts +20 -0
- package/dist/core/src/runtime.d.ts +119 -0
- package/dist/core/src/security/Encrypter.d.ts +33 -0
- package/dist/core/src/security/Hasher.d.ts +29 -0
- package/dist/core/src/testing/HttpTester.d.ts +39 -0
- package/dist/core/src/testing/TestResponse.d.ts +78 -0
- package/dist/core/src/testing/index.d.ts +2 -0
- package/dist/core/src/types/events.d.ts +94 -0
- package/dist/echo/src/OrbitEcho.d.ts +115 -0
- package/dist/echo/src/dlq/DeadLetterQueue.d.ts +94 -0
- package/dist/echo/src/dlq/MemoryDeadLetterQueue.d.ts +36 -0
- package/dist/echo/src/dlq/index.d.ts +2 -0
- package/dist/echo/src/index.d.ts +64 -0
- package/dist/echo/src/middleware/RequestBufferMiddleware.d.ts +62 -0
- package/dist/echo/src/middleware/index.d.ts +8 -0
- package/dist/echo/src/observability/index.d.ts +3 -0
- package/dist/echo/src/observability/logging/ConsoleEchoLogger.d.ts +37 -0
- package/dist/echo/src/observability/logging/EchoLogger.d.ts +38 -0
- package/dist/echo/src/observability/logging/index.d.ts +2 -0
- package/dist/echo/src/observability/metrics/MetricsProvider.d.ts +69 -0
- package/dist/echo/src/observability/metrics/NoopMetricsProvider.d.ts +17 -0
- package/dist/echo/src/observability/metrics/PrometheusMetricsProvider.d.ts +39 -0
- package/dist/echo/src/observability/metrics/index.d.ts +3 -0
- package/dist/echo/src/observability/tracing/NoopTracer.d.ts +33 -0
- package/dist/echo/src/observability/tracing/Tracer.d.ts +75 -0
- package/dist/echo/src/observability/tracing/index.d.ts +2 -0
- package/dist/echo/src/providers/GenericProvider.d.ts +53 -0
- package/dist/echo/src/providers/GitHubProvider.d.ts +35 -0
- package/dist/echo/src/providers/LinearProvider.d.ts +27 -0
- package/dist/echo/src/providers/PaddleProvider.d.ts +31 -0
- package/dist/echo/src/providers/ShopifyProvider.d.ts +27 -0
- package/dist/echo/src/providers/SlackProvider.d.ts +27 -0
- package/dist/echo/src/providers/StripeProvider.d.ts +38 -0
- package/dist/echo/src/providers/TwilioProvider.d.ts +31 -0
- package/dist/echo/src/providers/base/BaseProvider.d.ts +87 -0
- package/dist/echo/src/providers/base/HeaderUtils.d.ts +34 -0
- package/dist/echo/src/providers/index.d.ts +14 -0
- package/dist/echo/src/receive/SignatureValidator.d.ts +67 -0
- package/dist/echo/src/receive/WebhookReceiver.d.ts +185 -0
- package/dist/echo/src/receive/index.d.ts +2 -0
- package/dist/echo/src/replay/WebhookReplayService.d.ts +35 -0
- package/dist/echo/src/replay/index.d.ts +1 -0
- package/dist/echo/src/resilience/CircuitBreaker.d.ts +117 -0
- package/dist/echo/src/resilience/index.d.ts +10 -0
- package/dist/echo/src/rotation/KeyRotationManager.d.ts +127 -0
- package/dist/echo/src/rotation/index.d.ts +10 -0
- package/dist/echo/src/send/WebhookDispatcher.d.ts +198 -0
- package/dist/echo/src/send/index.d.ts +1 -0
- package/dist/echo/src/storage/MemoryWebhookStore.d.ts +14 -0
- package/dist/echo/src/storage/WebhookStore.d.ts +236 -0
- package/dist/echo/src/storage/index.d.ts +2 -0
- package/dist/echo/src/types.d.ts +756 -0
- package/dist/index.js +1332 -190
- package/dist/index.js.map +28 -10
- package/dist/photon/src/index.d.ts +84 -0
- package/dist/photon/src/middleware/binary.d.ts +31 -0
- package/dist/photon/src/middleware/htmx.d.ts +39 -0
- package/dist/photon/src/middleware/ratelimit.d.ts +157 -0
- package/dist/photon/src/openapi.d.ts +19 -0
- 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
|
+
}
|