@gl-life/gl-life-database 1.0.0 → 1.1.1
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/API.md +450 -1
- package/README.md +173 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +21 -3
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cache/index.d.ts +0 -4
- package/dist/cache/index.d.ts.map +0 -1
- package/dist/cache/invalidation.d.ts +0 -156
- package/dist/cache/invalidation.d.ts.map +0 -1
- package/dist/cache/kv-cache.d.ts +0 -79
- package/dist/cache/kv-cache.d.ts.map +0 -1
- package/dist/cache/memory-cache.d.ts +0 -68
- package/dist/cache/memory-cache.d.ts.map +0 -1
- package/dist/cloudforge/d1-adapter.d.ts +0 -67
- package/dist/cloudforge/d1-adapter.d.ts.map +0 -1
- package/dist/cloudforge/do-storage.d.ts +0 -51
- package/dist/cloudforge/do-storage.d.ts.map +0 -1
- package/dist/cloudforge/index.d.ts +0 -4
- package/dist/cloudforge/index.d.ts.map +0 -1
- package/dist/cloudforge/r2-backup.d.ts +0 -38
- package/dist/cloudforge/r2-backup.d.ts.map +0 -1
- package/dist/connection/index.d.ts +0 -2
- package/dist/connection/index.d.ts.map +0 -1
- package/dist/connection/manager.d.ts +0 -54
- package/dist/connection/manager.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/migration/index.d.ts +0 -4
- package/dist/migration/index.d.ts.map +0 -1
- package/dist/migration/loader.d.ts +0 -88
- package/dist/migration/loader.d.ts.map +0 -1
- package/dist/migration/runner.d.ts +0 -91
- package/dist/migration/runner.d.ts.map +0 -1
- package/dist/migration/seeder.d.ts +0 -95
- package/dist/migration/seeder.d.ts.map +0 -1
- package/dist/query/builder.d.ts +0 -47
- package/dist/query/builder.d.ts.map +0 -1
- package/dist/query/index.d.ts +0 -3
- package/dist/query/index.d.ts.map +0 -1
- package/dist/query/raw.d.ts +0 -92
- package/dist/query/raw.d.ts.map +0 -1
- package/dist/tenant/context.d.ts +0 -52
- package/dist/tenant/context.d.ts.map +0 -1
- package/dist/tenant/index.d.ts +0 -4
- package/dist/tenant/index.d.ts.map +0 -1
- package/dist/tenant/query-wrapper.d.ts +0 -96
- package/dist/tenant/query-wrapper.d.ts.map +0 -1
- package/dist/tenant/schema-manager.d.ts +0 -185
- package/dist/tenant/schema-manager.d.ts.map +0 -1
- package/dist/transaction/index.d.ts +0 -2
- package/dist/transaction/index.d.ts.map +0 -1
- package/dist/transaction/transaction.d.ts +0 -51
- package/dist/transaction/transaction.d.ts.map +0 -1
- package/dist/types/cache.d.ts +0 -214
- package/dist/types/cache.d.ts.map +0 -1
- package/dist/types/cloudforge.d.ts +0 -753
- package/dist/types/cloudforge.d.ts.map +0 -1
- package/dist/types/connection.d.ts +0 -91
- package/dist/types/connection.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -10
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/migration.d.ts +0 -225
- package/dist/types/migration.d.ts.map +0 -1
- package/dist/types/plugin.d.ts +0 -432
- package/dist/types/plugin.d.ts.map +0 -1
- package/dist/types/query-builder.d.ts +0 -217
- package/dist/types/query-builder.d.ts.map +0 -1
- package/dist/types/seed.d.ts +0 -187
- package/dist/types/seed.d.ts.map +0 -1
- package/dist/types/tenant.d.ts +0 -140
- package/dist/types/tenant.d.ts.map +0 -1
- package/dist/types/transaction.d.ts +0 -144
- package/dist/types/transaction.d.ts.map +0 -1
package/dist/types/plugin.d.ts
DELETED
|
@@ -1,432 +0,0 @@
|
|
|
1
|
-
import { Result, Option, Logger } from '@gl-life/gl-life-core';
|
|
2
|
-
import type { QueryBuilder } from './query-builder.js';
|
|
3
|
-
import type { Transaction } from './transaction.js';
|
|
4
|
-
import type { TenantContext } from './tenant.js';
|
|
5
|
-
import type { Migration } from './migration.js';
|
|
6
|
-
/**
|
|
7
|
-
* Plugin lifecycle phases
|
|
8
|
-
*/
|
|
9
|
-
export type PluginLifecyclePhase = 'REGISTERED' | 'INITIALIZING' | 'INITIALIZED' | 'ACTIVE' | 'DESTROYING' | 'DESTROYED';
|
|
10
|
-
/**
|
|
11
|
-
* Plugin type categories
|
|
12
|
-
*/
|
|
13
|
-
export type PluginType = 'DATABASE' | 'CACHE' | 'MIGRATION' | 'TENANT' | 'LOGGING' | 'CUSTOM';
|
|
14
|
-
/**
|
|
15
|
-
* Plugin priority levels
|
|
16
|
-
*/
|
|
17
|
-
export type PluginPriority = 'CRITICAL' | 'HIGH' | 'NORMAL' | 'LOW';
|
|
18
|
-
/**
|
|
19
|
-
* Plugin error types
|
|
20
|
-
*/
|
|
21
|
-
export type PluginError = {
|
|
22
|
-
type: 'INIT_FAILED';
|
|
23
|
-
message: string;
|
|
24
|
-
pluginName: string;
|
|
25
|
-
cause?: unknown;
|
|
26
|
-
} | {
|
|
27
|
-
type: 'DESTROY_FAILED';
|
|
28
|
-
message: string;
|
|
29
|
-
pluginName: string;
|
|
30
|
-
cause?: unknown;
|
|
31
|
-
} | {
|
|
32
|
-
type: 'HOOK_FAILED';
|
|
33
|
-
message: string;
|
|
34
|
-
pluginName: string;
|
|
35
|
-
hook: string;
|
|
36
|
-
cause?: unknown;
|
|
37
|
-
} | {
|
|
38
|
-
type: 'ALREADY_REGISTERED';
|
|
39
|
-
message: string;
|
|
40
|
-
pluginName: string;
|
|
41
|
-
} | {
|
|
42
|
-
type: 'NOT_FOUND';
|
|
43
|
-
message: string;
|
|
44
|
-
pluginName: string;
|
|
45
|
-
} | {
|
|
46
|
-
type: 'DEPENDENCY_MISSING';
|
|
47
|
-
message: string;
|
|
48
|
-
pluginName: string;
|
|
49
|
-
dependency: string;
|
|
50
|
-
} | {
|
|
51
|
-
type: 'VERSION_CONFLICT';
|
|
52
|
-
message: string;
|
|
53
|
-
pluginName: string;
|
|
54
|
-
expected: string;
|
|
55
|
-
actual: string;
|
|
56
|
-
} | {
|
|
57
|
-
type: 'UNKNOWN';
|
|
58
|
-
message: string;
|
|
59
|
-
cause?: unknown;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Plugin metadata
|
|
63
|
-
*/
|
|
64
|
-
export interface PluginMetadata {
|
|
65
|
-
/** Plugin name */
|
|
66
|
-
name: string;
|
|
67
|
-
/** Plugin version */
|
|
68
|
-
version: string;
|
|
69
|
-
/** Plugin type */
|
|
70
|
-
type: PluginType;
|
|
71
|
-
/** Plugin description */
|
|
72
|
-
description?: string;
|
|
73
|
-
/** Plugin author */
|
|
74
|
-
author?: string;
|
|
75
|
-
/** Plugin priority */
|
|
76
|
-
priority?: PluginPriority;
|
|
77
|
-
/** Required dependencies */
|
|
78
|
-
dependencies?: string[];
|
|
79
|
-
/** Compatible database versions */
|
|
80
|
-
compatibleVersions?: string[];
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Query execution context passed to hooks
|
|
84
|
-
*/
|
|
85
|
-
export interface QueryContext {
|
|
86
|
-
/** SQL query */
|
|
87
|
-
sql: string;
|
|
88
|
-
/** Query parameters */
|
|
89
|
-
params?: unknown[];
|
|
90
|
-
/** Query builder instance (if applicable) */
|
|
91
|
-
queryBuilder?: QueryBuilder<unknown>;
|
|
92
|
-
/** Transaction instance (if in transaction) */
|
|
93
|
-
transaction?: Transaction;
|
|
94
|
-
/** Tenant context (if multi-tenant) */
|
|
95
|
-
tenantContext?: TenantContext;
|
|
96
|
-
/** Query start timestamp */
|
|
97
|
-
startTime: Date;
|
|
98
|
-
/** Custom metadata */
|
|
99
|
-
metadata?: Record<string, unknown>;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Query result context passed to after hooks
|
|
103
|
-
*/
|
|
104
|
-
export interface QueryResultContext<T = unknown> extends QueryContext {
|
|
105
|
-
/** Query result */
|
|
106
|
-
result: T;
|
|
107
|
-
/** Query end timestamp */
|
|
108
|
-
endTime: Date;
|
|
109
|
-
/** Execution duration in milliseconds */
|
|
110
|
-
duration: number;
|
|
111
|
-
/** Whether query used cache */
|
|
112
|
-
fromCache?: boolean;
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Base plugin interface
|
|
116
|
-
*
|
|
117
|
-
* All plugins must implement this interface to integrate with the database system.
|
|
118
|
-
*/
|
|
119
|
-
export interface Plugin {
|
|
120
|
-
/**
|
|
121
|
-
* Plugin metadata
|
|
122
|
-
*/
|
|
123
|
-
readonly metadata: PluginMetadata;
|
|
124
|
-
/**
|
|
125
|
-
* Current plugin lifecycle phase
|
|
126
|
-
*/
|
|
127
|
-
readonly phase: PluginLifecyclePhase;
|
|
128
|
-
/**
|
|
129
|
-
* Plugin logger instance
|
|
130
|
-
*/
|
|
131
|
-
readonly logger: Logger;
|
|
132
|
-
/**
|
|
133
|
-
* Initialize the plugin
|
|
134
|
-
*
|
|
135
|
-
* Called once when the plugin is registered.
|
|
136
|
-
*
|
|
137
|
-
* @param config - Plugin configuration
|
|
138
|
-
* @returns Result with void on success or PluginError on failure
|
|
139
|
-
*/
|
|
140
|
-
init(config?: Record<string, unknown>): Promise<Result<void, PluginError>>;
|
|
141
|
-
/**
|
|
142
|
-
* Destroy the plugin
|
|
143
|
-
*
|
|
144
|
-
* Called when the plugin is being unregistered or system shutdown.
|
|
145
|
-
*
|
|
146
|
-
* @returns Result with void on success or PluginError on failure
|
|
147
|
-
*/
|
|
148
|
-
destroy(): Promise<Result<void, PluginError>>;
|
|
149
|
-
/**
|
|
150
|
-
* Hook called before query execution
|
|
151
|
-
*
|
|
152
|
-
* @param context - Query context
|
|
153
|
-
* @returns Result with modified context or original context
|
|
154
|
-
*/
|
|
155
|
-
beforeQuery?(context: QueryContext): Promise<Result<QueryContext, PluginError>>;
|
|
156
|
-
/**
|
|
157
|
-
* Hook called after query execution
|
|
158
|
-
*
|
|
159
|
-
* @param context - Query result context
|
|
160
|
-
* @returns Result with modified context or original context
|
|
161
|
-
*/
|
|
162
|
-
afterQuery?<T = unknown>(context: QueryResultContext<T>): Promise<Result<QueryResultContext<T>, PluginError>>;
|
|
163
|
-
/**
|
|
164
|
-
* Hook called when query execution fails
|
|
165
|
-
*
|
|
166
|
-
* @param context - Query context
|
|
167
|
-
* @param error - Query error
|
|
168
|
-
* @returns Result with void or PluginError
|
|
169
|
-
*/
|
|
170
|
-
onQueryError?(context: QueryContext, error: unknown): Promise<Result<void, PluginError>>;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Database plugin interface
|
|
174
|
-
*
|
|
175
|
-
* Specialized plugin for database connection and execution enhancements.
|
|
176
|
-
*/
|
|
177
|
-
export interface DatabasePlugin extends Plugin {
|
|
178
|
-
metadata: PluginMetadata & {
|
|
179
|
-
type: 'DATABASE';
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* Hook called before database connection
|
|
183
|
-
*
|
|
184
|
-
* @param config - Connection configuration
|
|
185
|
-
* @returns Result with modified config or original config
|
|
186
|
-
*/
|
|
187
|
-
beforeConnect?(config: Record<string, unknown>): Promise<Result<Record<string, unknown>, PluginError>>;
|
|
188
|
-
/**
|
|
189
|
-
* Hook called after database connection
|
|
190
|
-
*
|
|
191
|
-
* @returns Result with void or PluginError
|
|
192
|
-
*/
|
|
193
|
-
afterConnect?(): Promise<Result<void, PluginError>>;
|
|
194
|
-
/**
|
|
195
|
-
* Hook called before database disconnection
|
|
196
|
-
*
|
|
197
|
-
* @returns Result with void or PluginError
|
|
198
|
-
*/
|
|
199
|
-
beforeDisconnect?(): Promise<Result<void, PluginError>>;
|
|
200
|
-
/**
|
|
201
|
-
* Hook called after database disconnection
|
|
202
|
-
*
|
|
203
|
-
* @returns Result with void or PluginError
|
|
204
|
-
*/
|
|
205
|
-
afterDisconnect?(): Promise<Result<void, PluginError>>;
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Cache plugin interface
|
|
209
|
-
*
|
|
210
|
-
* Specialized plugin for cache operations and strategies.
|
|
211
|
-
*/
|
|
212
|
-
export interface CachePlugin extends Plugin {
|
|
213
|
-
metadata: PluginMetadata & {
|
|
214
|
-
type: 'CACHE';
|
|
215
|
-
};
|
|
216
|
-
/**
|
|
217
|
-
* Hook called before cache get operation
|
|
218
|
-
*
|
|
219
|
-
* @param key - Cache key
|
|
220
|
-
* @returns Result with modified key or original key
|
|
221
|
-
*/
|
|
222
|
-
beforeCacheGet?(key: string): Promise<Result<string, PluginError>>;
|
|
223
|
-
/**
|
|
224
|
-
* Hook called after cache get operation
|
|
225
|
-
*
|
|
226
|
-
* @param key - Cache key
|
|
227
|
-
* @param value - Cached value (or None if miss)
|
|
228
|
-
* @returns Result with void or PluginError
|
|
229
|
-
*/
|
|
230
|
-
afterCacheGet?<T = unknown>(key: string, value: Option<T>): Promise<Result<void, PluginError>>;
|
|
231
|
-
/**
|
|
232
|
-
* Hook called before cache set operation
|
|
233
|
-
*
|
|
234
|
-
* @param key - Cache key
|
|
235
|
-
* @param value - Value to cache
|
|
236
|
-
* @param ttl - TTL in seconds
|
|
237
|
-
* @returns Result with modified cache parameters
|
|
238
|
-
*/
|
|
239
|
-
beforeCacheSet?<T = unknown>(key: string, value: T, ttl?: number): Promise<Result<{
|
|
240
|
-
key: string;
|
|
241
|
-
value: T;
|
|
242
|
-
ttl?: number;
|
|
243
|
-
}, PluginError>>;
|
|
244
|
-
/**
|
|
245
|
-
* Hook called after cache set operation
|
|
246
|
-
*
|
|
247
|
-
* @param key - Cache key
|
|
248
|
-
* @returns Result with void or PluginError
|
|
249
|
-
*/
|
|
250
|
-
afterCacheSet?(key: string): Promise<Result<void, PluginError>>;
|
|
251
|
-
/**
|
|
252
|
-
* Hook called before cache invalidation
|
|
253
|
-
*
|
|
254
|
-
* @param pattern - Invalidation pattern
|
|
255
|
-
* @returns Result with modified pattern or original pattern
|
|
256
|
-
*/
|
|
257
|
-
beforeCacheInvalidate?(pattern: string): Promise<Result<string, PluginError>>;
|
|
258
|
-
/**
|
|
259
|
-
* Hook called after cache invalidation
|
|
260
|
-
*
|
|
261
|
-
* @param pattern - Invalidation pattern
|
|
262
|
-
* @param count - Number of invalidated entries
|
|
263
|
-
* @returns Result with void or PluginError
|
|
264
|
-
*/
|
|
265
|
-
afterCacheInvalidate?(pattern: string, count: number): Promise<Result<void, PluginError>>;
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Migration plugin interface
|
|
269
|
-
*
|
|
270
|
-
* Specialized plugin for migration operations and validation.
|
|
271
|
-
*/
|
|
272
|
-
export interface MigrationPlugin extends Plugin {
|
|
273
|
-
metadata: PluginMetadata & {
|
|
274
|
-
type: 'MIGRATION';
|
|
275
|
-
};
|
|
276
|
-
/**
|
|
277
|
-
* Hook called before migration execution
|
|
278
|
-
*
|
|
279
|
-
* @param migration - Migration to execute
|
|
280
|
-
* @returns Result with modified migration or original migration
|
|
281
|
-
*/
|
|
282
|
-
beforeMigrate?(migration: Migration): Promise<Result<Migration, PluginError>>;
|
|
283
|
-
/**
|
|
284
|
-
* Hook called after migration execution
|
|
285
|
-
*
|
|
286
|
-
* @param migration - Executed migration
|
|
287
|
-
* @param success - Whether migration succeeded
|
|
288
|
-
* @returns Result with void or PluginError
|
|
289
|
-
*/
|
|
290
|
-
afterMigrate?(migration: Migration, success: boolean): Promise<Result<void, PluginError>>;
|
|
291
|
-
/**
|
|
292
|
-
* Hook called before migration rollback
|
|
293
|
-
*
|
|
294
|
-
* @param migration - Migration to rollback
|
|
295
|
-
* @returns Result with modified migration or original migration
|
|
296
|
-
*/
|
|
297
|
-
beforeRollback?(migration: Migration): Promise<Result<Migration, PluginError>>;
|
|
298
|
-
/**
|
|
299
|
-
* Hook called after migration rollback
|
|
300
|
-
*
|
|
301
|
-
* @param migration - Rolled back migration
|
|
302
|
-
* @param success - Whether rollback succeeded
|
|
303
|
-
* @returns Result with void or PluginError
|
|
304
|
-
*/
|
|
305
|
-
afterRollback?(migration: Migration, success: boolean): Promise<Result<void, PluginError>>;
|
|
306
|
-
/**
|
|
307
|
-
* Validate a migration before execution
|
|
308
|
-
*
|
|
309
|
-
* @param migration - Migration to validate
|
|
310
|
-
* @returns Result with true if valid, false otherwise
|
|
311
|
-
*/
|
|
312
|
-
validateMigration?(migration: Migration): Promise<Result<boolean, PluginError>>;
|
|
313
|
-
}
|
|
314
|
-
/**
|
|
315
|
-
* Tenant plugin interface
|
|
316
|
-
*
|
|
317
|
-
* Specialized plugin for multi-tenancy operations.
|
|
318
|
-
*/
|
|
319
|
-
export interface TenantPlugin extends Plugin {
|
|
320
|
-
metadata: PluginMetadata & {
|
|
321
|
-
type: 'TENANT';
|
|
322
|
-
};
|
|
323
|
-
/**
|
|
324
|
-
* Hook called before tenant is set
|
|
325
|
-
*
|
|
326
|
-
* @param tenantId - Tenant identifier
|
|
327
|
-
* @returns Result with modified tenant ID or original tenant ID
|
|
328
|
-
*/
|
|
329
|
-
beforeSetTenant?(tenantId: string): Promise<Result<string, PluginError>>;
|
|
330
|
-
/**
|
|
331
|
-
* Hook called after tenant is set
|
|
332
|
-
*
|
|
333
|
-
* @param tenantId - Tenant identifier
|
|
334
|
-
* @returns Result with void or PluginError
|
|
335
|
-
*/
|
|
336
|
-
afterSetTenant?(tenantId: string): Promise<Result<void, PluginError>>;
|
|
337
|
-
/**
|
|
338
|
-
* Hook called before tenant is cleared
|
|
339
|
-
*
|
|
340
|
-
* @returns Result with void or PluginError
|
|
341
|
-
*/
|
|
342
|
-
beforeClearTenant?(): Promise<Result<void, PluginError>>;
|
|
343
|
-
/**
|
|
344
|
-
* Hook called after tenant is cleared
|
|
345
|
-
*
|
|
346
|
-
* @returns Result with void or PluginError
|
|
347
|
-
*/
|
|
348
|
-
afterClearTenant?(): Promise<Result<void, PluginError>>;
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Plugin registry interface
|
|
352
|
-
*
|
|
353
|
-
* Manages plugin registration, initialization, and lifecycle.
|
|
354
|
-
*/
|
|
355
|
-
export interface PluginRegistry {
|
|
356
|
-
/**
|
|
357
|
-
* Register a plugin
|
|
358
|
-
*
|
|
359
|
-
* @param plugin - Plugin instance to register
|
|
360
|
-
* @returns Result with void on success or PluginError on failure
|
|
361
|
-
*/
|
|
362
|
-
register(plugin: Plugin): Promise<Result<void, PluginError>>;
|
|
363
|
-
/**
|
|
364
|
-
* Unregister a plugin
|
|
365
|
-
*
|
|
366
|
-
* @param name - Plugin name
|
|
367
|
-
* @returns Result with void on success or PluginError on failure
|
|
368
|
-
*/
|
|
369
|
-
unregister(name: string): Promise<Result<void, PluginError>>;
|
|
370
|
-
/**
|
|
371
|
-
* Get a registered plugin
|
|
372
|
-
*
|
|
373
|
-
* @param name - Plugin name
|
|
374
|
-
* @returns Option with plugin instance or None
|
|
375
|
-
*/
|
|
376
|
-
get(name: string): Option<Plugin>;
|
|
377
|
-
/**
|
|
378
|
-
* Get all registered plugins
|
|
379
|
-
*
|
|
380
|
-
* @returns Array of registered plugins
|
|
381
|
-
*/
|
|
382
|
-
getAll(): Plugin[];
|
|
383
|
-
/**
|
|
384
|
-
* Get plugins by type
|
|
385
|
-
*
|
|
386
|
-
* @param type - Plugin type
|
|
387
|
-
* @returns Array of plugins matching the type
|
|
388
|
-
*/
|
|
389
|
-
getByType(type: PluginType): Plugin[];
|
|
390
|
-
/**
|
|
391
|
-
* Check if a plugin is registered
|
|
392
|
-
*
|
|
393
|
-
* @param name - Plugin name
|
|
394
|
-
* @returns True if plugin is registered
|
|
395
|
-
*/
|
|
396
|
-
has(name: string): boolean;
|
|
397
|
-
/**
|
|
398
|
-
* Initialize all registered plugins
|
|
399
|
-
*
|
|
400
|
-
* @returns Result with void on success or PluginError on failure
|
|
401
|
-
*/
|
|
402
|
-
initializeAll(): Promise<Result<void, PluginError>>;
|
|
403
|
-
/**
|
|
404
|
-
* Destroy all registered plugins
|
|
405
|
-
*
|
|
406
|
-
* @returns Result with void on success or PluginError on failure
|
|
407
|
-
*/
|
|
408
|
-
destroyAll(): Promise<Result<void, PluginError>>;
|
|
409
|
-
/**
|
|
410
|
-
* Execute beforeQuery hooks for all plugins
|
|
411
|
-
*
|
|
412
|
-
* @param context - Query context
|
|
413
|
-
* @returns Result with modified context or PluginError
|
|
414
|
-
*/
|
|
415
|
-
executeBeforeQuery(context: QueryContext): Promise<Result<QueryContext, PluginError>>;
|
|
416
|
-
/**
|
|
417
|
-
* Execute afterQuery hooks for all plugins
|
|
418
|
-
*
|
|
419
|
-
* @param context - Query result context
|
|
420
|
-
* @returns Result with modified context or PluginError
|
|
421
|
-
*/
|
|
422
|
-
executeAfterQuery<T = unknown>(context: QueryResultContext<T>): Promise<Result<QueryResultContext<T>, PluginError>>;
|
|
423
|
-
/**
|
|
424
|
-
* Execute onQueryError hooks for all plugins
|
|
425
|
-
*
|
|
426
|
-
* @param context - Query context
|
|
427
|
-
* @param error - Query error
|
|
428
|
-
* @returns Result with void or PluginError
|
|
429
|
-
*/
|
|
430
|
-
executeOnQueryError(context: QueryContext, error: unknown): Promise<Result<void, PluginError>>;
|
|
431
|
-
}
|
|
432
|
-
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/types/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,YAAY,GACZ,cAAc,GACd,aAAa,GACb,QAAQ,GACR,YAAY,GACZ,WAAW,CAAC;AAEhB;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,G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iB,CAAC,CAAC,GAAG,OAAO,EAC3B,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC7B,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;IAEvD;;;;;;OAMG;IACH,mBAAmB,CAAC,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;CAChG"}
|
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { Result } from '@gl-life/gl-life-core';
|
|
2
|
-
/**
|
|
3
|
-
* Query builder error types
|
|
4
|
-
*/
|
|
5
|
-
export type QueryBuilderError = {
|
|
6
|
-
type: 'INVALID_QUERY';
|
|
7
|
-
message: string;
|
|
8
|
-
} | {
|
|
9
|
-
type: 'EXECUTION_FAILED';
|
|
10
|
-
message: string;
|
|
11
|
-
cause?: unknown;
|
|
12
|
-
} | {
|
|
13
|
-
type: 'VALIDATION_FAILED';
|
|
14
|
-
message: string;
|
|
15
|
-
errors: string[];
|
|
16
|
-
} | {
|
|
17
|
-
type: 'UNKNOWN';
|
|
18
|
-
message: string;
|
|
19
|
-
cause?: unknown;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Where clause condition operators
|
|
23
|
-
*/
|
|
24
|
-
export type WhereOperator = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'LIKE' | 'NOT LIKE' | 'IN' | 'NOT IN' | 'IS NULL' | 'IS NOT NULL' | 'BETWEEN';
|
|
25
|
-
/**
|
|
26
|
-
* Join types
|
|
27
|
-
*/
|
|
28
|
-
export type JoinType = 'INNER' | 'LEFT' | 'RIGHT' | 'FULL' | 'CROSS';
|
|
29
|
-
/**
|
|
30
|
-
* Order direction
|
|
31
|
-
*/
|
|
32
|
-
export type OrderDirection = 'ASC' | 'DESC';
|
|
33
|
-
/**
|
|
34
|
-
* Where clause condition
|
|
35
|
-
*/
|
|
36
|
-
export interface WhereCondition {
|
|
37
|
-
field: string;
|
|
38
|
-
operator: WhereOperator;
|
|
39
|
-
value?: unknown;
|
|
40
|
-
values?: unknown[];
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Join clause configuration
|
|
44
|
-
*/
|
|
45
|
-
export interface JoinClause {
|
|
46
|
-
type: JoinType;
|
|
47
|
-
table: string;
|
|
48
|
-
leftField: string;
|
|
49
|
-
rightField: string;
|
|
50
|
-
alias?: string;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Order by clause
|
|
54
|
-
*/
|
|
55
|
-
export interface OrderByClause {
|
|
56
|
-
field: string;
|
|
57
|
-
direction: OrderDirection;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Type-safe query builder interface
|
|
61
|
-
*
|
|
62
|
-
* Provides a fluent API for constructing SQL queries with type safety.
|
|
63
|
-
* Supports select, insert, update, delete operations with chaining.
|
|
64
|
-
*/
|
|
65
|
-
export interface QueryBuilder<T = unknown> {
|
|
66
|
-
/**
|
|
67
|
-
* Specify the table to query
|
|
68
|
-
*
|
|
69
|
-
* @param table - Table name
|
|
70
|
-
* @returns QueryBuilder instance for chaining
|
|
71
|
-
*/
|
|
72
|
-
table(table: string): QueryBuilder<T>;
|
|
73
|
-
/**
|
|
74
|
-
* Select specific columns
|
|
75
|
-
*
|
|
76
|
-
* @param columns - Column names to select
|
|
77
|
-
* @returns QueryBuilder instance for chaining
|
|
78
|
-
*/
|
|
79
|
-
select(...columns: string[]): QueryBuilder<T>;
|
|
80
|
-
/**
|
|
81
|
-
* Add WHERE clause condition
|
|
82
|
-
*
|
|
83
|
-
* @param field - Field name
|
|
84
|
-
* @param operator - Comparison operator
|
|
85
|
-
* @param value - Value to compare
|
|
86
|
-
* @returns QueryBuilder instance for chaining
|
|
87
|
-
*/
|
|
88
|
-
where(field: string, operator: WhereOperator, value?: unknown): QueryBuilder<T>;
|
|
89
|
-
/**
|
|
90
|
-
* Add OR WHERE clause condition
|
|
91
|
-
*
|
|
92
|
-
* @param field - Field name
|
|
93
|
-
* @param operator - Comparison operator
|
|
94
|
-
* @param value - Value to compare
|
|
95
|
-
* @returns QueryBuilder instance for chaining
|
|
96
|
-
*/
|
|
97
|
-
orWhere(field: string, operator: WhereOperator, value?: unknown): QueryBuilder<T>;
|
|
98
|
-
/**
|
|
99
|
-
* Add WHERE IN clause
|
|
100
|
-
*
|
|
101
|
-
* @param field - Field name
|
|
102
|
-
* @param values - Array of values
|
|
103
|
-
* @returns QueryBuilder instance for chaining
|
|
104
|
-
*/
|
|
105
|
-
whereIn(field: string, values: unknown[]): QueryBuilder<T>;
|
|
106
|
-
/**
|
|
107
|
-
* Add JOIN clause
|
|
108
|
-
*
|
|
109
|
-
* @param table - Table to join
|
|
110
|
-
* @param leftField - Left join field
|
|
111
|
-
* @param rightField - Right join field
|
|
112
|
-
* @param type - Join type (default: INNER)
|
|
113
|
-
* @returns QueryBuilder instance for chaining
|
|
114
|
-
*/
|
|
115
|
-
join(table: string, leftField: string, rightField: string, type?: JoinType): QueryBuilder<T>;
|
|
116
|
-
/**
|
|
117
|
-
* Add ORDER BY clause
|
|
118
|
-
*
|
|
119
|
-
* @param field - Field to order by
|
|
120
|
-
* @param direction - Order direction (default: ASC)
|
|
121
|
-
* @returns QueryBuilder instance for chaining
|
|
122
|
-
*/
|
|
123
|
-
orderBy(field: string, direction?: OrderDirection): QueryBuilder<T>;
|
|
124
|
-
/**
|
|
125
|
-
* Add GROUP BY clause
|
|
126
|
-
*
|
|
127
|
-
* @param fields - Fields to group by
|
|
128
|
-
* @returns QueryBuilder instance for chaining
|
|
129
|
-
*/
|
|
130
|
-
groupBy(...fields: string[]): QueryBuilder<T>;
|
|
131
|
-
/**
|
|
132
|
-
* Add HAVING clause
|
|
133
|
-
*
|
|
134
|
-
* @param condition - Having condition
|
|
135
|
-
* @returns QueryBuilder instance for chaining
|
|
136
|
-
*/
|
|
137
|
-
having(condition: string): QueryBuilder<T>;
|
|
138
|
-
/**
|
|
139
|
-
* Limit number of results
|
|
140
|
-
*
|
|
141
|
-
* @param limit - Maximum number of results
|
|
142
|
-
* @returns QueryBuilder instance for chaining
|
|
143
|
-
*/
|
|
144
|
-
limit(limit: number): QueryBuilder<T>;
|
|
145
|
-
/**
|
|
146
|
-
* Offset results
|
|
147
|
-
*
|
|
148
|
-
* @param offset - Number of results to skip
|
|
149
|
-
* @returns QueryBuilder instance for chaining
|
|
150
|
-
*/
|
|
151
|
-
offset(offset: number): QueryBuilder<T>;
|
|
152
|
-
/**
|
|
153
|
-
* Insert data
|
|
154
|
-
*
|
|
155
|
-
* @param data - Data to insert
|
|
156
|
-
* @returns Result with inserted record or QueryBuilderError
|
|
157
|
-
*/
|
|
158
|
-
insert(data: Partial<T>): Promise<Result<T, QueryBuilderError>>;
|
|
159
|
-
/**
|
|
160
|
-
* Insert multiple records
|
|
161
|
-
*
|
|
162
|
-
* @param data - Array of records to insert
|
|
163
|
-
* @returns Result with inserted records or QueryBuilderError
|
|
164
|
-
*/
|
|
165
|
-
insertMany(data: Partial<T>[]): Promise<Result<T[], QueryBuilderError>>;
|
|
166
|
-
/**
|
|
167
|
-
* Update data
|
|
168
|
-
*
|
|
169
|
-
* @param data - Data to update
|
|
170
|
-
* @returns Result with number of affected rows or QueryBuilderError
|
|
171
|
-
*/
|
|
172
|
-
update(data: Partial<T>): Promise<Result<number, QueryBuilderError>>;
|
|
173
|
-
/**
|
|
174
|
-
* Delete records
|
|
175
|
-
*
|
|
176
|
-
* @returns Result with number of deleted rows or QueryBuilderError
|
|
177
|
-
*/
|
|
178
|
-
delete(): Promise<Result<number, QueryBuilderError>>;
|
|
179
|
-
/**
|
|
180
|
-
* Execute query and get first result
|
|
181
|
-
*
|
|
182
|
-
* @returns Result with first record or null, or QueryBuilderError
|
|
183
|
-
*/
|
|
184
|
-
first(): Promise<Result<T | null, QueryBuilderError>>;
|
|
185
|
-
/**
|
|
186
|
-
* Execute query and get all results
|
|
187
|
-
*
|
|
188
|
-
* @returns Result with array of records or QueryBuilderError
|
|
189
|
-
*/
|
|
190
|
-
get(): Promise<Result<T[], QueryBuilderError>>;
|
|
191
|
-
/**
|
|
192
|
-
* Count records
|
|
193
|
-
*
|
|
194
|
-
* @param field - Field to count (default: *)
|
|
195
|
-
* @returns Result with count or QueryBuilderError
|
|
196
|
-
*/
|
|
197
|
-
count(field?: string): Promise<Result<number, QueryBuilderError>>;
|
|
198
|
-
/**
|
|
199
|
-
* Get the generated SQL query
|
|
200
|
-
*
|
|
201
|
-
* @returns SQL query string
|
|
202
|
-
*/
|
|
203
|
-
toSQL(): string;
|
|
204
|
-
/**
|
|
205
|
-
* Get the query parameters
|
|
206
|
-
*
|
|
207
|
-
* @returns Array of query parameters
|
|
208
|
-
*/
|
|
209
|
-
getBindings(): unknown[];
|
|
210
|
-
/**
|
|
211
|
-
* Clone the query builder
|
|
212
|
-
*
|
|
213
|
-
* @returns New QueryBuilder instance with same configuration
|
|
214
|
-
*/
|
|
215
|
-
clone(): QueryBuilder<T>;
|
|
216
|
-
}
|
|
217
|
-
//# sourceMappingURL=query-builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"query-builder.d.ts","sourceRoot":"","sources":["../../src/types/query-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,SAAS,CAAC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