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/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
- * # `QueryHooks`
139
- *
140
- * Optional lifecycle hooks around query execution. These are invoked for any
141
- * statement executed through the builder (select/insert/update/delete/raw).
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: { sql: string, params?: any[], kind?: 'select' | 'insert' | 'update' | 'delete' | 'raw' }) => void
145
- onQueryEnd?: (event: { sql: string, params?: any[], durationMs: number, rowCount?: number, kind?: 'select' | 'insert' | 'update' | 'delete' | 'raw' }) => void
146
- onQueryError?: (event: { sql: string, params?: any[], error: any, durationMs: number, kind?: 'select' | 'insert' | 'update' | 'delete' | 'raw' }) => void
147
- startSpan?: (event: { sql: string, params?: any[], kind?: 'select' | 'insert' | 'update' | 'delete' | 'raw' }) => { end: (error?: any) => void }
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: { sql: string, params?: any[], durationMs: number, kind?: 'select' | 'insert' | 'update' | 'delete' | 'raw' }) => void
150
- beforeCreate?: (event: { table: string, data: any }) => void | Promise<void>
151
- afterCreate?: (event: { table: string, data: any, result: any }) => void | Promise<void>
152
- beforeUpdate?: (event: { table: string, data: any, where?: any }) => void | Promise<void>
153
- afterUpdate?: (event: { table: string, data: any, where?: any, result: any }) => void | Promise<void>
154
- beforeDelete?: (event: { table: string, where?: any }) => void | Promise<void>
155
- afterDelete?: (event: { table: string, where?: any, result: any }) => void | Promise<void>
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: any) => T
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: any
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: any) => T`) into a
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-query-builder",
3
3
  "type": "module",
4
- "version": "0.2.43",
4
+ "version": "0.2.45",
5
5
  "description": "A simple yet performant query builder for TypeScript. Built with Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",