bun-query-builder 0.2.43 → 0.2.45
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/dist/bin/cli.js +266 -102
- package/dist/browser.d.ts +11 -5
- package/dist/client.d.ts +30 -30
- package/dist/column-types.d.ts +26 -0
- package/dist/db.d.ts +36 -6
- package/dist/drivers/sqlite.d.ts +11 -6
- package/dist/dynamodb-client.d.ts +57 -18
- package/dist/dynamodb-single-table.d.ts +2 -2
- package/dist/dynamodb-tooling-adapter.d.ts +7 -6
- package/dist/meta.d.ts +1 -1
- package/dist/model.d.ts +4 -0
- package/dist/orm.d.ts +33 -13
- package/dist/schema.d.ts +35 -21
- package/dist/seeder.d.ts +11 -1
- package/dist/sql-fragments.d.ts +1 -1
- package/dist/src/browser.js +2 -2
- package/dist/src/index.js +266 -101
- package/dist/types.d.ts +34 -20
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -134,25 +134,25 @@ export declare interface SqlConfig {
|
|
|
134
134
|
sharedLockSyntax?: 'FOR SHARE' | 'LOCK IN SHARE MODE'
|
|
135
135
|
jsonContainsMode?: 'operator' | 'function'
|
|
136
136
|
}
|
|
137
|
-
/**
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
/** Common fields on every query lifecycle event. */
|
|
138
|
+
export declare interface QueryEvent {
|
|
139
|
+
sql: string
|
|
140
|
+
params?: QueryParam[]
|
|
141
|
+
kind?: QueryKind
|
|
142
|
+
}
|
|
143
143
|
export declare interface QueryHooks {
|
|
144
|
-
onQueryStart?: (event:
|
|
145
|
-
onQueryEnd?: (event:
|
|
146
|
-
onQueryError?: (event:
|
|
147
|
-
startSpan?: (event:
|
|
144
|
+
onQueryStart?: (event: QueryEvent) => void
|
|
145
|
+
onQueryEnd?: (event: QueryEvent & { durationMs: number, rowCount?: number }) => void
|
|
146
|
+
onQueryError?: (event: QueryEvent & { error: unknown, durationMs: number }) => void
|
|
147
|
+
startSpan?: (event: QueryEvent) => { end: (error?: unknown) => void }
|
|
148
148
|
slowQueryThresholdMs?: number
|
|
149
|
-
onSlowQuery?: (event:
|
|
150
|
-
beforeCreate?: (event: { table: string, data:
|
|
151
|
-
afterCreate?: (event: { table: string, data:
|
|
152
|
-
beforeUpdate?: (event: { table: string, data:
|
|
153
|
-
afterUpdate?: (event: { table: string, data:
|
|
154
|
-
beforeDelete?: (event: { table: string, where?:
|
|
155
|
-
afterDelete?: (event: { table: string, where?:
|
|
149
|
+
onSlowQuery?: (event: QueryEvent & { durationMs: number }) => void
|
|
150
|
+
beforeCreate?: (event: { table: string, data: QueryRecord }) => void | Promise<void>
|
|
151
|
+
afterCreate?: (event: { table: string, data: QueryRecord, result: unknown }) => void | Promise<void>
|
|
152
|
+
beforeUpdate?: (event: { table: string, data: QueryRecord, where?: QueryWhere }) => void | Promise<void>
|
|
153
|
+
afterUpdate?: (event: { table: string, data: QueryRecord, where?: QueryWhere, result: unknown }) => void | Promise<void>
|
|
154
|
+
beforeDelete?: (event: { table: string, where?: QueryWhere }) => void | Promise<void>
|
|
155
|
+
afterDelete?: (event: { table: string, where?: QueryWhere, result: unknown }) => void | Promise<void>
|
|
156
156
|
}
|
|
157
157
|
/**
|
|
158
158
|
* # `FeatureToggles`
|
|
@@ -208,7 +208,7 @@ export declare interface BrowserConfig {
|
|
|
208
208
|
onUnauthorized?: () => void
|
|
209
209
|
headers?: Record<string, string>
|
|
210
210
|
timeout?: number
|
|
211
|
-
transformResponse?: <T>(response:
|
|
211
|
+
transformResponse?: <T>(response: unknown) => T
|
|
212
212
|
transformRequest?: <T>(data: T) => any
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
@@ -284,7 +284,7 @@ export declare interface GenerateMigrationResult {
|
|
|
284
284
|
sql: string
|
|
285
285
|
sqlStatements: string[]
|
|
286
286
|
hasChanges: boolean
|
|
287
|
-
plan:
|
|
287
|
+
plan: import('./migrations').MigrationPlan
|
|
288
288
|
operations?: import('./migrations').MigrationOperation[]
|
|
289
289
|
}
|
|
290
290
|
export declare interface UnsafeOptions {
|
|
@@ -309,6 +309,20 @@ export declare interface UnsafeOptions {
|
|
|
309
309
|
* - 'browser': Browser-compatible mode that uses fetch() API calls instead of direct database connections
|
|
310
310
|
*/
|
|
311
311
|
export type SupportedDialect = 'postgres' | 'mysql' | 'singlestore' | 'vitess' | 'sqlite' | 'browser';
|
|
312
|
+
/**
|
|
313
|
+
* # `QueryHooks`
|
|
314
|
+
*
|
|
315
|
+
* Optional lifecycle hooks around query execution. These are invoked for any
|
|
316
|
+
* statement executed through the builder (select/insert/update/delete/raw).
|
|
317
|
+
*/
|
|
318
|
+
/** A bound statement parameter: whatever a driver will accept as a value. */
|
|
319
|
+
export type QueryParam = string | number | bigint | boolean | Date | Uint8Array | null;
|
|
320
|
+
/** The kind of statement a hook is reporting on. */
|
|
321
|
+
export type QueryKind = 'select' | 'insert' | 'update' | 'delete' | 'raw';
|
|
322
|
+
/** The row shape a hook sees. Columns are unknown until the caller narrows. */
|
|
323
|
+
export type QueryRecord = Record<string, unknown>;
|
|
324
|
+
/** A `where` description as the mutation hooks receive it. */
|
|
325
|
+
export type QueryWhere = Record<string, unknown>;
|
|
312
326
|
/**
|
|
313
327
|
* # `DeepPartial`
|
|
314
328
|
*
|
|
@@ -340,7 +354,7 @@ export type SupportedDialect = 'postgres' | 'mysql' | 'singlestore' | 'vitess' |
|
|
|
340
354
|
* signature is not a property. `keyof (() => void)` is `never`, so the
|
|
341
355
|
* hook collapses to an empty object type: no longer callable, and loose
|
|
342
356
|
* enough to accept `42`. It also erases type parameters, which would turn
|
|
343
|
-
* `BrowserConfig.transformResponse` (`<T>(response:
|
|
357
|
+
* `BrowserConfig.transformResponse` (`<T>(response: unknown) => T`) into a
|
|
344
358
|
* shape with no signature at all. A hook or a token getter is a leaf.
|
|
345
359
|
*
|
|
346
360
|
* 2. ARRAYS SECOND, because the merge replaces them rather than merging them.
|
package/package.json
CHANGED