@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,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Driver Type Definitions
|
|
3
|
+
* @description Type definitions for third-party database driver libraries
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* MySQL/MariaDB Pool Connection
|
|
7
|
+
*/
|
|
8
|
+
export interface MySQLPool {
|
|
9
|
+
query(sql: string, values?: unknown[]): Promise<unknown>;
|
|
10
|
+
execute(sql: string, values?: unknown[]): Promise<unknown>;
|
|
11
|
+
getConnection(): Promise<MySQLConnection>;
|
|
12
|
+
end(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* MySQL/MariaDB Connection
|
|
16
|
+
*/
|
|
17
|
+
export interface MySQLConnection {
|
|
18
|
+
query(sql: string, values?: unknown[]): Promise<unknown>;
|
|
19
|
+
execute(sql: string, values?: unknown[]): Promise<unknown>;
|
|
20
|
+
beginTransaction(): Promise<void>;
|
|
21
|
+
commit(): Promise<void>;
|
|
22
|
+
rollback(): Promise<void>;
|
|
23
|
+
release(): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* MySQL/MariaDB Module
|
|
27
|
+
*/
|
|
28
|
+
export interface MySQLModule {
|
|
29
|
+
createPool(config: Record<string, unknown>): MySQLPool;
|
|
30
|
+
createConnection(config: Record<string, unknown>): Promise<MySQLConnection>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* PostgreSQL Pool Client
|
|
34
|
+
*/
|
|
35
|
+
export interface PostgresPoolClient {
|
|
36
|
+
query(sql: string, values?: unknown[]): Promise<{
|
|
37
|
+
rows: unknown[];
|
|
38
|
+
rowCount: number;
|
|
39
|
+
}>;
|
|
40
|
+
release(): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* PostgreSQL Pool
|
|
44
|
+
*/
|
|
45
|
+
export interface PostgresPool {
|
|
46
|
+
connect(): Promise<PostgresPoolClient>;
|
|
47
|
+
query(sql: string, values?: unknown[]): Promise<{
|
|
48
|
+
rows: unknown[];
|
|
49
|
+
rowCount: number;
|
|
50
|
+
}>;
|
|
51
|
+
end(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* SQLite Database Client (Bun)
|
|
55
|
+
*/
|
|
56
|
+
export interface SQLiteClient {
|
|
57
|
+
prepare(sql: string): SQLiteStatement;
|
|
58
|
+
query(sql: string, ...params: unknown[]): unknown[];
|
|
59
|
+
run(sql: string, ...params: unknown[]): {
|
|
60
|
+
changes: number;
|
|
61
|
+
lastInsertRowid: number;
|
|
62
|
+
};
|
|
63
|
+
exec?(sql: string): void;
|
|
64
|
+
pragma?(name: string, value?: unknown): unknown;
|
|
65
|
+
open?: boolean;
|
|
66
|
+
inTransaction?: boolean;
|
|
67
|
+
close(): void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* SQLite Statement
|
|
71
|
+
*/
|
|
72
|
+
export interface SQLiteStatement {
|
|
73
|
+
run(...params: unknown[]): {
|
|
74
|
+
changes: number;
|
|
75
|
+
lastInsertRowid: number;
|
|
76
|
+
};
|
|
77
|
+
all(...params: unknown[]): unknown[];
|
|
78
|
+
get(...params: unknown[]): unknown;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Redis Client
|
|
82
|
+
*/
|
|
83
|
+
export interface RedisClient {
|
|
84
|
+
connect(): Promise<void>;
|
|
85
|
+
get(key: string): Promise<string | null>;
|
|
86
|
+
set(key: string, value: string | number): Promise<'OK'>;
|
|
87
|
+
setex(key: string, seconds: number, value: string | number): Promise<'OK'>;
|
|
88
|
+
del(key: string): Promise<number>;
|
|
89
|
+
keys(pattern: string): Promise<string[]>;
|
|
90
|
+
exists(key: string): Promise<number>;
|
|
91
|
+
expire(key: string, seconds: number): Promise<number>;
|
|
92
|
+
quit(): Promise<void>;
|
|
93
|
+
status?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* MongoDB Client
|
|
97
|
+
*/
|
|
98
|
+
export interface MongoClient {
|
|
99
|
+
connect(): Promise<void>;
|
|
100
|
+
db(name?: string): MongoDatabase;
|
|
101
|
+
close(): Promise<void>;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* MongoDB Database
|
|
105
|
+
*/
|
|
106
|
+
export interface MongoDatabase {
|
|
107
|
+
collection(name: string): MongoCollection;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* MongoDB Collection
|
|
111
|
+
*/
|
|
112
|
+
export interface MongoCollection {
|
|
113
|
+
find(filter?: Record<string, unknown>, options?: Record<string, unknown>): MongoCursor;
|
|
114
|
+
findOne(filter?: Record<string, unknown>): Promise<Record<string, unknown> | null>;
|
|
115
|
+
insertOne(doc: Record<string, unknown>): Promise<{
|
|
116
|
+
insertedId: unknown;
|
|
117
|
+
}>;
|
|
118
|
+
insertMany(docs: Record<string, unknown>[]): Promise<{
|
|
119
|
+
insertedIds: unknown[];
|
|
120
|
+
insertedCount: number;
|
|
121
|
+
}>;
|
|
122
|
+
countDocuments(filter?: Record<string, unknown>): Promise<number>;
|
|
123
|
+
updateOne(filter: Record<string, unknown>, update: Record<string, unknown>): Promise<{
|
|
124
|
+
modifiedCount: number;
|
|
125
|
+
}>;
|
|
126
|
+
updateMany(filter: Record<string, unknown>, update: Record<string, unknown>): Promise<{
|
|
127
|
+
modifiedCount: number;
|
|
128
|
+
}>;
|
|
129
|
+
deleteOne(filter: Record<string, unknown>): Promise<{
|
|
130
|
+
deletedCount: number;
|
|
131
|
+
}>;
|
|
132
|
+
deleteMany(filter: Record<string, unknown>): Promise<{
|
|
133
|
+
deletedCount: number;
|
|
134
|
+
}>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* MongoDB Cursor
|
|
138
|
+
*/
|
|
139
|
+
export interface MongoCursor {
|
|
140
|
+
toArray(): Promise<Record<string, unknown>[]>;
|
|
141
|
+
limit(n: number): MongoCursor;
|
|
142
|
+
skip(n: number): MongoCursor;
|
|
143
|
+
sort(sort: Record<string, 1 | -1>): MongoCursor;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Bun SQL Client (Enhanced for Bun 1.3+)
|
|
147
|
+
* @description Comprehensive type definitions for Bun.sql native driver
|
|
148
|
+
*/
|
|
149
|
+
export interface BunSQLClient {
|
|
150
|
+
(strings: TemplateStringsArray, ...values: unknown[]): Promise<BunSQLResult>;
|
|
151
|
+
unsafe?(sql: string, bindings?: unknown[]): Promise<BunSQLResult>;
|
|
152
|
+
query?(sql: string, bindings?: unknown[]): Promise<BunSQLResult>;
|
|
153
|
+
all?(sql: string, bindings?: unknown[]): Promise<unknown[]>;
|
|
154
|
+
run?(sql: string, bindings?: unknown[]): Promise<BunSQLResult>;
|
|
155
|
+
simple?(strings: TemplateStringsArray, ...values: unknown[]): Promise<BunSQLResult>;
|
|
156
|
+
prepare?(sql: string): BunSQLPreparedStatement;
|
|
157
|
+
transaction?<T>(callback: (sql: BunSQLClient) => Promise<T>): Promise<T>;
|
|
158
|
+
begin?(): Promise<BunSQLTransaction>;
|
|
159
|
+
close?(): Promise<void>;
|
|
160
|
+
end?(): Promise<void>;
|
|
161
|
+
readonly connections?: {
|
|
162
|
+
idle: number;
|
|
163
|
+
pending: number;
|
|
164
|
+
active: number;
|
|
165
|
+
total: number;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Bun SQL Query Result
|
|
170
|
+
* @description Result structure returned by Bun.sql queries
|
|
171
|
+
*/
|
|
172
|
+
export interface BunSQLResult {
|
|
173
|
+
/**
|
|
174
|
+
* Result rows (iterable)
|
|
175
|
+
*/
|
|
176
|
+
rows?: unknown[];
|
|
177
|
+
/**
|
|
178
|
+
* Number of rows affected/returned
|
|
179
|
+
*/
|
|
180
|
+
rowCount?: number;
|
|
181
|
+
count?: number;
|
|
182
|
+
/**
|
|
183
|
+
* Last inserted ID (for INSERT operations)
|
|
184
|
+
*/
|
|
185
|
+
lastInsertRowid?: number | bigint;
|
|
186
|
+
/**
|
|
187
|
+
* Number of changed rows (for UPDATE operations)
|
|
188
|
+
*/
|
|
189
|
+
changes?: number;
|
|
190
|
+
/**
|
|
191
|
+
* Iterator support for streaming
|
|
192
|
+
*/
|
|
193
|
+
[Symbol.iterator](): Iterator<unknown>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Bun SQL Prepared Statement
|
|
197
|
+
* @description Prepared statement interface for query optimization
|
|
198
|
+
*/
|
|
199
|
+
export interface BunSQLPreparedStatement {
|
|
200
|
+
/**
|
|
201
|
+
* Execute prepared statement and return result
|
|
202
|
+
*/
|
|
203
|
+
run(...params: unknown[]): Promise<BunSQLResult>;
|
|
204
|
+
/**
|
|
205
|
+
* Execute and return all rows
|
|
206
|
+
*/
|
|
207
|
+
all(...params: unknown[]): Promise<unknown[]>;
|
|
208
|
+
/**
|
|
209
|
+
* Execute and return first row
|
|
210
|
+
*/
|
|
211
|
+
get(...params: unknown[]): Promise<unknown | undefined>;
|
|
212
|
+
/**
|
|
213
|
+
* Finalize and release the prepared statement
|
|
214
|
+
*/
|
|
215
|
+
finalize(): void;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Bun SQL Transaction
|
|
219
|
+
* @description Transaction handle for advanced transaction control
|
|
220
|
+
*/
|
|
221
|
+
export interface BunSQLTransaction {
|
|
222
|
+
/**
|
|
223
|
+
* Commit the transaction
|
|
224
|
+
*/
|
|
225
|
+
commit(): Promise<void>;
|
|
226
|
+
/**
|
|
227
|
+
* Rollback the transaction
|
|
228
|
+
*/
|
|
229
|
+
rollback(): Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* Create a savepoint
|
|
232
|
+
*/
|
|
233
|
+
savepoint?(name: string): Promise<void>;
|
|
234
|
+
/**
|
|
235
|
+
* Rollback to a savepoint
|
|
236
|
+
*/
|
|
237
|
+
rollbackTo?(name: string): Promise<void>;
|
|
238
|
+
/**
|
|
239
|
+
* Release a savepoint
|
|
240
|
+
*/
|
|
241
|
+
release?(name: string): Promise<void>;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Bun SQL Pool Configuration
|
|
245
|
+
* @description Configuration options for connection pool
|
|
246
|
+
*/
|
|
247
|
+
export interface BunSQLPoolConfig {
|
|
248
|
+
/**
|
|
249
|
+
* Maximum number of connections in the pool
|
|
250
|
+
*/
|
|
251
|
+
max?: number;
|
|
252
|
+
/**
|
|
253
|
+
* Maximum time (ms) a connection can be idle before being released
|
|
254
|
+
*/
|
|
255
|
+
idleTimeout?: number;
|
|
256
|
+
/**
|
|
257
|
+
* Maximum time (ms) to wait for a connection from the pool
|
|
258
|
+
*/
|
|
259
|
+
connectionTimeout?: number;
|
|
260
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base Database Error
|
|
3
|
+
*/
|
|
4
|
+
export declare class DatabaseError extends Error {
|
|
5
|
+
readonly originalError: unknown;
|
|
6
|
+
readonly query?: string;
|
|
7
|
+
readonly bindings?: unknown[];
|
|
8
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Constraint Violation Error (Base)
|
|
12
|
+
*/
|
|
13
|
+
export declare class ConstraintViolationError extends DatabaseError {
|
|
14
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Unique Constraint Violation
|
|
18
|
+
*/
|
|
19
|
+
export declare class UniqueConstraintError extends ConstraintViolationError {
|
|
20
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Foreign Key Constraint Violation
|
|
24
|
+
*/
|
|
25
|
+
export declare class ForeignKeyConstraintError extends ConstraintViolationError {
|
|
26
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Not Null Constraint Violation
|
|
30
|
+
*/
|
|
31
|
+
export declare class NotNullConstraintError extends ConstraintViolationError {
|
|
32
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Table Not Found Error
|
|
36
|
+
*/
|
|
37
|
+
export declare class TableNotFoundError extends DatabaseError {
|
|
38
|
+
constructor(message: string, originalError?: unknown, query?: string, bindings?: unknown[]);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Connection Error
|
|
42
|
+
*/
|
|
43
|
+
export declare class ConnectionError extends DatabaseError {
|
|
44
|
+
constructor(message: string, originalError?: unknown);
|
|
45
|
+
}
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Abstract SQL Grammar providing base logic for SQL generation.
|
|
3
|
+
*
|
|
4
|
+
* Handles the structural assembly of SELECT, INSERT, UPDATE, and DELETE
|
|
5
|
+
* statements. Includes a sophisticated compilation cache to minimize
|
|
6
|
+
* string manipulation overhead for repetitive query structures.
|
|
7
|
+
*/
|
|
8
|
+
import { LRUCache } from 'lru-cache';
|
|
9
|
+
import type { CompiledQuery, GrammarContract, HavingClause, JoinClause, OrderClause, WhereClause } from '../types';
|
|
10
|
+
export declare abstract class Grammar implements GrammarContract {
|
|
11
|
+
/**
|
|
12
|
+
* Optional prefix for all table names.
|
|
13
|
+
*/
|
|
14
|
+
protected tablePrefix: string;
|
|
15
|
+
/**
|
|
16
|
+
* Database-specific character for wrapping identifiers (e.g., " or `).
|
|
17
|
+
*/
|
|
18
|
+
protected abstract wrapChar: string;
|
|
19
|
+
/**
|
|
20
|
+
* Internal cache for compiled SQL templates.
|
|
21
|
+
* Keyed by structural hash to allow reuse across different parameter values.
|
|
22
|
+
*/
|
|
23
|
+
private static compilationCache;
|
|
24
|
+
/**
|
|
25
|
+
* Metrics for cache performance monitoring.
|
|
26
|
+
*/
|
|
27
|
+
private static cacheStats;
|
|
28
|
+
/**
|
|
29
|
+
* Global toggle for SQL compilation caching.
|
|
30
|
+
*/
|
|
31
|
+
static useCache: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Determines if the cache is shared globally or isolated per grammar instance.
|
|
34
|
+
*/
|
|
35
|
+
static cacheScope: 'global' | 'instance';
|
|
36
|
+
private _instanceCache?;
|
|
37
|
+
private _instanceCacheStats;
|
|
38
|
+
/**
|
|
39
|
+
* Retrieves performance metrics for the compilation cache.
|
|
40
|
+
*
|
|
41
|
+
* @returns Stats including hit rate and utilization.
|
|
42
|
+
*/
|
|
43
|
+
static getCacheStats(): {
|
|
44
|
+
size: number;
|
|
45
|
+
maxSize: number;
|
|
46
|
+
hits: number;
|
|
47
|
+
misses: number;
|
|
48
|
+
sets: number;
|
|
49
|
+
hitRate: number;
|
|
50
|
+
missRate: number;
|
|
51
|
+
totalRequests: number;
|
|
52
|
+
utilization: number;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Retrieves metrics for the instance-level cache.
|
|
56
|
+
*
|
|
57
|
+
* @returns Stats object or null if instance caching is disabled.
|
|
58
|
+
*/
|
|
59
|
+
getInstanceCacheStats(): {
|
|
60
|
+
size: number;
|
|
61
|
+
maxSize: number;
|
|
62
|
+
hits: number;
|
|
63
|
+
misses: number;
|
|
64
|
+
sets: number;
|
|
65
|
+
hitRate: number;
|
|
66
|
+
missRate: number;
|
|
67
|
+
totalRequests: number;
|
|
68
|
+
utilization: number;
|
|
69
|
+
} | null;
|
|
70
|
+
/**
|
|
71
|
+
* Flushes all performance counters.
|
|
72
|
+
*/
|
|
73
|
+
static resetCacheStats(): void;
|
|
74
|
+
/**
|
|
75
|
+
* Wipes the compilation cache.
|
|
76
|
+
*/
|
|
77
|
+
static clearCache(): void;
|
|
78
|
+
/**
|
|
79
|
+
* Resizes the global compilation cache.
|
|
80
|
+
*
|
|
81
|
+
* @param max - Maximum number of templates to store.
|
|
82
|
+
*/
|
|
83
|
+
static setCacheSize(max: number): void;
|
|
84
|
+
/**
|
|
85
|
+
* Resolves the active cache instance based on scope configuration.
|
|
86
|
+
* @internal
|
|
87
|
+
*/
|
|
88
|
+
protected getCompilationCache(): LRUCache<string, string>;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the database-specific placeholder (e.g., ?, $1, :name).
|
|
91
|
+
*
|
|
92
|
+
* @param index - The zero-based binding index.
|
|
93
|
+
*/
|
|
94
|
+
abstract getPlaceholder(index: number): string;
|
|
95
|
+
/**
|
|
96
|
+
* Compiles an INSERT statement that returns the primary key.
|
|
97
|
+
*/
|
|
98
|
+
abstract compileInsertGetId(query: CompiledQuery, values: Record<string, unknown>, primaryKey: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Transforms a query structure into a SELECT SQL string.
|
|
101
|
+
*
|
|
102
|
+
* Leverages caching by generating a structural key that ignores binding values.
|
|
103
|
+
*
|
|
104
|
+
* @param query - The structural definition of the query.
|
|
105
|
+
* @returns The compiled SQL string.
|
|
106
|
+
*/
|
|
107
|
+
compileSelect(query: CompiledQuery): string;
|
|
108
|
+
/**
|
|
109
|
+
* Generates a unique hash representing the SQL structure.
|
|
110
|
+
*
|
|
111
|
+
* Ignores specific binding values to allow cache hits for similar queries.
|
|
112
|
+
* Uses efficient array joining for performance.
|
|
113
|
+
*
|
|
114
|
+
* @param query - The query structure.
|
|
115
|
+
* @returns A deterministic string key.
|
|
116
|
+
*/
|
|
117
|
+
getStructuralKey(query: CompiledQuery): string;
|
|
118
|
+
/**
|
|
119
|
+
* Compiles the SELECT list.
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
protected compileColumns(query: CompiledQuery): string;
|
|
123
|
+
/**
|
|
124
|
+
* Compiles the FROM clause.
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
protected compileFrom(query: CompiledQuery): string;
|
|
128
|
+
/**
|
|
129
|
+
* Compiles all WHERE constraints.
|
|
130
|
+
*
|
|
131
|
+
* @param query - The query definition.
|
|
132
|
+
* @param bindingOffset - Initial parameter index.
|
|
133
|
+
* @returns Compiled SQL snippet.
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
protected compileWheres(query: CompiledQuery, bindingOffset?: number): string;
|
|
137
|
+
/**
|
|
138
|
+
* @deprecated Use compileWhereWithOffset.
|
|
139
|
+
*/
|
|
140
|
+
protected compileWhere(where: WhereClause, _query: CompiledQuery): string;
|
|
141
|
+
/**
|
|
142
|
+
* Compiles a single WHERE clause with offset awareness.
|
|
143
|
+
* @internal
|
|
144
|
+
*/
|
|
145
|
+
protected compileWhereWithOffset(where: WhereClause, offset: number): {
|
|
146
|
+
sql: string;
|
|
147
|
+
bindingsUsed: number;
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Compiles a standard equality or comparison clause.
|
|
151
|
+
* @internal
|
|
152
|
+
*/
|
|
153
|
+
protected compileWhereBasicWithOffset(where: WhereClause, offset: number): string;
|
|
154
|
+
/**
|
|
155
|
+
* Compiles an IN clause.
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
158
|
+
protected compileWhereInWithOffset(where: WhereClause, offset: number): string;
|
|
159
|
+
/**
|
|
160
|
+
* Wraps nested SQL in parentheses.
|
|
161
|
+
* @internal
|
|
162
|
+
*/
|
|
163
|
+
protected compileWhereNested(where: WhereClause): string;
|
|
164
|
+
/**
|
|
165
|
+
* Compiles IS NULL constraints.
|
|
166
|
+
* @internal
|
|
167
|
+
*/
|
|
168
|
+
protected compileWhereNull(where: WhereClause): string;
|
|
169
|
+
/**
|
|
170
|
+
* Compiles BETWEEN constraints.
|
|
171
|
+
* @internal
|
|
172
|
+
*/
|
|
173
|
+
protected compileWhereBetweenWithOffset(where: WhereClause, offset: number): string;
|
|
174
|
+
/**
|
|
175
|
+
* Compiles column-to-column comparisons.
|
|
176
|
+
* @internal
|
|
177
|
+
*/
|
|
178
|
+
protected compileWhereColumn(where: WhereClause): string;
|
|
179
|
+
/**
|
|
180
|
+
* Compiles all JOIN clauses.
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
protected compileJoins(query: CompiledQuery): string;
|
|
184
|
+
/**
|
|
185
|
+
* Compiles a single JOIN relationship.
|
|
186
|
+
* @internal
|
|
187
|
+
*/
|
|
188
|
+
protected compileJoin(join: JoinClause): string;
|
|
189
|
+
/**
|
|
190
|
+
* Compiles the GROUP BY clause.
|
|
191
|
+
* @internal
|
|
192
|
+
*/
|
|
193
|
+
protected compileGroups(query: CompiledQuery): string;
|
|
194
|
+
/**
|
|
195
|
+
* Compiles all HAVING constraints.
|
|
196
|
+
* @internal
|
|
197
|
+
*/
|
|
198
|
+
protected compileHavings(query: CompiledQuery, bindingOffset?: number): string;
|
|
199
|
+
/**
|
|
200
|
+
* Sums bindings across all WHERE clauses.
|
|
201
|
+
* @internal
|
|
202
|
+
*/
|
|
203
|
+
protected countAllWhereBindings(wheres: WhereClause[]): number;
|
|
204
|
+
/**
|
|
205
|
+
* Counts bindings for a specific WHERE type.
|
|
206
|
+
* @internal
|
|
207
|
+
*/
|
|
208
|
+
protected countWhereBindings(where: WhereClause): number;
|
|
209
|
+
/**
|
|
210
|
+
* Compiles a single HAVING clause.
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
protected compileHavingWithOffset(having: HavingClause, offset: number): {
|
|
214
|
+
sql: string;
|
|
215
|
+
bindingsUsed: number;
|
|
216
|
+
};
|
|
217
|
+
/**
|
|
218
|
+
* @deprecated
|
|
219
|
+
*/
|
|
220
|
+
protected compileHaving(having: HavingClause, _query: CompiledQuery): string;
|
|
221
|
+
/**
|
|
222
|
+
* Compiles the full ORDER BY clause.
|
|
223
|
+
* @internal
|
|
224
|
+
*/
|
|
225
|
+
protected compileOrders(query: CompiledQuery): string;
|
|
226
|
+
/**
|
|
227
|
+
* Compiles a single sorting rule.
|
|
228
|
+
* @internal
|
|
229
|
+
*/
|
|
230
|
+
protected compileOrder(order: OrderClause): string;
|
|
231
|
+
/**
|
|
232
|
+
* Compiles the LIMIT clause.
|
|
233
|
+
* @internal
|
|
234
|
+
*/
|
|
235
|
+
protected compileLimit(query: CompiledQuery): string;
|
|
236
|
+
/**
|
|
237
|
+
* Compiles the OFFSET clause.
|
|
238
|
+
* @internal
|
|
239
|
+
*/
|
|
240
|
+
protected compileOffset(query: CompiledQuery): string;
|
|
241
|
+
/**
|
|
242
|
+
* Compiles a multi-row INSERT statement.
|
|
243
|
+
*
|
|
244
|
+
* @param query - The query definition.
|
|
245
|
+
* @param values - Records to insert.
|
|
246
|
+
* @returns The SQL string.
|
|
247
|
+
*/
|
|
248
|
+
compileInsert(query: CompiledQuery, values: Record<string, unknown>[]): string;
|
|
249
|
+
/**
|
|
250
|
+
* Compiles an UPDATE statement with WHERE constraints.
|
|
251
|
+
*
|
|
252
|
+
* @param query - The query definition.
|
|
253
|
+
* @param values - Fields and values to update.
|
|
254
|
+
* @returns The SQL string.
|
|
255
|
+
*/
|
|
256
|
+
compileUpdate(query: CompiledQuery, values: Record<string, unknown>): string;
|
|
257
|
+
/**
|
|
258
|
+
* Adjusts placeholders in a pre-compiled snippet.
|
|
259
|
+
* @internal
|
|
260
|
+
*/
|
|
261
|
+
protected offsetPlaceholders(sql: string, _offset: number): string;
|
|
262
|
+
/**
|
|
263
|
+
* Compiles a DELETE statement.
|
|
264
|
+
*/
|
|
265
|
+
compileDelete(query: CompiledQuery): string;
|
|
266
|
+
/**
|
|
267
|
+
* Compiles a TRUNCATE statement to wipe a table.
|
|
268
|
+
*/
|
|
269
|
+
compileTruncate(query: CompiledQuery): string;
|
|
270
|
+
/**
|
|
271
|
+
* Compiles an aggregate function selection (COUNT, MAX, etc.).
|
|
272
|
+
*/
|
|
273
|
+
compileAggregate(query: CompiledQuery, aggregate: {
|
|
274
|
+
function: string;
|
|
275
|
+
column: string;
|
|
276
|
+
}): string;
|
|
277
|
+
/**
|
|
278
|
+
* Compiles an EXISTS check.
|
|
279
|
+
*/
|
|
280
|
+
compileExists(query: CompiledQuery): string;
|
|
281
|
+
/**
|
|
282
|
+
* Escapes a column name for SQL safety.
|
|
283
|
+
*
|
|
284
|
+
* Handles table aliases, raw expressions, and wildcards.
|
|
285
|
+
*
|
|
286
|
+
* @param column - The column identifier.
|
|
287
|
+
*/
|
|
288
|
+
wrapColumn(column: string): string;
|
|
289
|
+
/**
|
|
290
|
+
* Escapes a table name.
|
|
291
|
+
*/
|
|
292
|
+
wrapTable(table: string): string;
|
|
293
|
+
/**
|
|
294
|
+
* Internal string escaping.
|
|
295
|
+
* @internal
|
|
296
|
+
*/
|
|
297
|
+
protected wrapValue(value: string): string;
|
|
298
|
+
/**
|
|
299
|
+
* Manually quotes a value for literal injection.
|
|
300
|
+
*
|
|
301
|
+
* Warning: Prefer bindings over manual quoting for security.
|
|
302
|
+
*
|
|
303
|
+
* @param value - The value to quote.
|
|
304
|
+
*/
|
|
305
|
+
quoteValue(value: unknown): string;
|
|
306
|
+
/**
|
|
307
|
+
* Configures a prefix for all table references.
|
|
308
|
+
*/
|
|
309
|
+
setTablePrefix(prefix: string): void;
|
|
310
|
+
/**
|
|
311
|
+
* Retrieves the current table prefix.
|
|
312
|
+
*/
|
|
313
|
+
getTablePrefix(): string;
|
|
314
|
+
/**
|
|
315
|
+
* Compiles a query for relationship lateral loading.
|
|
316
|
+
* @throws {Error} If unsupported by driver.
|
|
317
|
+
*/
|
|
318
|
+
compileLateralEagerLoad(_table: string, _foreignKey: string, _parentKeys: unknown[], _query: CompiledQuery): {
|
|
319
|
+
sql: string;
|
|
320
|
+
bindings: unknown[];
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Compiles a JSON path selector.
|
|
324
|
+
* @throws {Error} If unsupported.
|
|
325
|
+
*/
|
|
326
|
+
compileJsonPath(_column: string, _value: unknown): string;
|
|
327
|
+
/**
|
|
328
|
+
* Compiles a JSON containment check.
|
|
329
|
+
* @throws {Error} If unsupported.
|
|
330
|
+
*/
|
|
331
|
+
compileJsonContains(_column: string, _value: unknown): string;
|
|
332
|
+
/**
|
|
333
|
+
* Compiles a partial JSON update.
|
|
334
|
+
* @throws {Error} If unsupported.
|
|
335
|
+
*/
|
|
336
|
+
compileUpdateJson(_query: CompiledQuery, _column: string, _value: unknown): string;
|
|
337
|
+
/**
|
|
338
|
+
* Compiles an UPSERT statement.
|
|
339
|
+
* @throws {Error} If unsupported.
|
|
340
|
+
*/
|
|
341
|
+
compileUpsert(_query: CompiledQuery, _values: Record<string, unknown>[], _uniqueBy: string[], _update: string[]): string;
|
|
342
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MongoDB Grammar
|
|
3
|
+
* @description Translates generic CompiledQuery into a MongoDB Query Protocol (JSON)
|
|
4
|
+
*/
|
|
5
|
+
import type { CompiledQuery } from '../types';
|
|
6
|
+
import { Grammar } from './Grammar';
|
|
7
|
+
/**
|
|
8
|
+
* MongoDB Query Protocol
|
|
9
|
+
* Represents the structure passed from Grammar to Driver
|
|
10
|
+
*/
|
|
11
|
+
export interface MongoQueryProtocol {
|
|
12
|
+
collection: string;
|
|
13
|
+
operation: 'find' | 'insert' | 'update' | 'delete' | 'aggregate' | 'count';
|
|
14
|
+
filter?: Record<string, unknown>;
|
|
15
|
+
options?: Record<string, unknown>;
|
|
16
|
+
document?: Record<string, unknown> | Record<string, unknown>[];
|
|
17
|
+
update?: Record<string, unknown>;
|
|
18
|
+
pipeline?: Record<string, unknown>[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Mongo Grammar
|
|
22
|
+
* Transforms QueryBuilder state into MongoDB commands
|
|
23
|
+
*/
|
|
24
|
+
export declare class MongoGrammar extends Grammar {
|
|
25
|
+
protected wrapChar: string;
|
|
26
|
+
getPlaceholder(_index: number): string;
|
|
27
|
+
compileInsertGetId(query: CompiledQuery, values: Record<string, unknown>, _primaryKey: string): string;
|
|
28
|
+
compileSelect(query: CompiledQuery): string;
|
|
29
|
+
compileInsert(query: CompiledQuery, values: Record<string, unknown>[]): string;
|
|
30
|
+
compileUpdate(query: CompiledQuery, values: Record<string, unknown>): string;
|
|
31
|
+
compileDelete(query: CompiledQuery): string;
|
|
32
|
+
compileAggregate(query: CompiledQuery, aggregate: {
|
|
33
|
+
function: string;
|
|
34
|
+
column: string;
|
|
35
|
+
}): string;
|
|
36
|
+
compileTruncate(query: CompiledQuery): string;
|
|
37
|
+
/**
|
|
38
|
+
* Translate generic WhereClause[] to MongoDB Filter
|
|
39
|
+
*/
|
|
40
|
+
private compileMongoWheres;
|
|
41
|
+
private normalizeValue;
|
|
42
|
+
private compileBasicWhere;
|
|
43
|
+
private compileInWhere;
|
|
44
|
+
private compileNullWhere;
|
|
45
|
+
private normalizeColumn;
|
|
46
|
+
compileJsonPath(column: string, value: unknown): string;
|
|
47
|
+
}
|