bun-query-builder 0.2.24 → 0.2.26
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 +25 -1
- package/dist/actions/migrate.d.ts +0 -2
- package/dist/bin/cli.js +217 -102
- package/dist/client.d.ts +3 -0
- package/dist/config.d.ts +31 -2
- package/dist/src/index.js +217 -101
- package/dist/types.d.ts +87 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { config } from './config';
|
|
2
2
|
import { resetConnection } from './db';
|
|
3
3
|
import type { DatabaseSchema } from './schema';
|
|
4
|
+
import type { QueryHooks } from './types';
|
|
4
5
|
import type { SchemaMeta } from './meta';
|
|
5
6
|
/**
|
|
6
7
|
* # `raw`
|
|
@@ -380,6 +381,7 @@ export declare interface QueryBuilder<DB extends DatabaseSchema<any>> {
|
|
|
380
381
|
ids?: (...names: string[]) => any
|
|
381
382
|
advisoryLock?: (key: number | string) => Promise<void>
|
|
382
383
|
tryAdvisoryLock?: (key: number | string) => Promise<boolean>
|
|
384
|
+
advisoryUnlock?: (key: number | string) => Promise<boolean>
|
|
383
385
|
getRelationships?: (table: string) => Record<string, any>
|
|
384
386
|
hasRelationship?: (table: string, relationName: string) => boolean
|
|
385
387
|
getRelationshipType?: (table: string, relationName: string) => string | null
|
|
@@ -390,6 +392,7 @@ declare interface InternalState {
|
|
|
390
392
|
meta?: SchemaMeta
|
|
391
393
|
schema?: any
|
|
392
394
|
txDefaults?: TransactionOptions
|
|
395
|
+
hooks?: QueryHooks
|
|
393
396
|
inTransaction?: boolean
|
|
394
397
|
}
|
|
395
398
|
declare interface TxBackoff { baseMs?: number, maxMs?: number, factor?: number, jitter?: boolean }
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { QueryBuilderConfig, SupportedDialect } from './types';
|
|
1
|
+
import type { QueryBuilderConfig, QueryBuilderOptions, SupportedDialect } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Whether a dialect belongs to the MySQL wire-protocol family (MySQL itself,
|
|
4
4
|
* SingleStore, or Vitess). These share `?` placeholders, backtick identifier
|
|
@@ -62,12 +62,41 @@ export declare function getPlaceholders(count: number, startIndex?: number): str
|
|
|
62
62
|
*
|
|
63
63
|
* So the loaded object is applied with those keys filtered out — an explicit API
|
|
64
64
|
* call is a stronger signal than a file that may not know the embedder exists.
|
|
65
|
+
* The filter is per top-level section; see `configState` for why per-leaf is
|
|
66
|
+
* the wrong granularity.
|
|
65
67
|
*
|
|
66
68
|
* Note the load MUST pass `defaultConfig`: bunfig derives the environment
|
|
67
69
|
* variable names it recognises (`QUERY_BUILDER_*`) from the shape of the
|
|
68
70
|
* defaults, so passing an empty object silently drops env-var support.
|
|
69
71
|
*/
|
|
70
72
|
export declare function getConfig(): Promise<QueryBuilderConfig>;
|
|
71
|
-
export declare function setConfig(userConfig:
|
|
73
|
+
export declare function setConfig(userConfig: QueryBuilderOptions): void;
|
|
74
|
+
/**
|
|
75
|
+
* Identity helper for a typed `query-builder.config.ts`.
|
|
76
|
+
*
|
|
77
|
+
* It exists so that writing a config file requires no decision about which
|
|
78
|
+
* type to annotate with — which is what stacksjs/bun-query-builder#1062 was
|
|
79
|
+
* actually about. The only config type this package exported was
|
|
80
|
+
* `QueryBuilderConfig`, the RESOLVED shape with every field required, and the
|
|
81
|
+
* docs told people to import it, so downstream apps annotated their config
|
|
82
|
+
* file with a type demanding `migrationDir`, `snapshotDir`, `features`,
|
|
83
|
+
* `aliasing` and nine other sections they had no opinion about. Every field
|
|
84
|
+
* added here afterwards was a downstream build break.
|
|
85
|
+
*
|
|
86
|
+
* `defineConfig` takes `QueryBuilderOptions`, so nothing is ever required, and
|
|
87
|
+
* returns its argument unchanged — there is no runtime behavior here, only the
|
|
88
|
+
* type and the editor completion that comes with it.
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* // query-builder.config.ts
|
|
92
|
+
* import { defineConfig } from 'bun-query-builder'
|
|
93
|
+
*
|
|
94
|
+
* export default defineConfig({
|
|
95
|
+
* dialect: 'postgres',
|
|
96
|
+
* database: { database: 'my_app' },
|
|
97
|
+
* })
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function defineConfig(userConfig: QueryBuilderOptions): QueryBuilderOptions;
|
|
72
101
|
export declare const defaultConfig: QueryBuilderConfig;
|
|
73
102
|
export declare const config: QueryBuilderConfig;
|