bun-query-builder 0.1.59 → 0.1.61
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 -191
- package/dist/db.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/inflect.d.ts +29 -0
- package/dist/src/index.js +271 -193
- package/dist/types.d.ts +2 -1
- package/package.json +2 -2
package/dist/db.d.ts
CHANGED
|
@@ -36,6 +36,10 @@ export declare function getOrCreateBunSql(forceNew?: boolean): SQL;
|
|
|
36
36
|
* Call this after changing config via setConfig() to ensure the new config is used.
|
|
37
37
|
*/
|
|
38
38
|
export declare function resetConnection(): void;
|
|
39
|
+
/**
|
|
40
|
+
* Inject a custom SQL instance. Useful for tests or custom connection setups.
|
|
41
|
+
*/
|
|
42
|
+
export declare function setSqlInstance(sql: SQL): void;
|
|
39
43
|
// Wrapper that catches "Connection closed" errors and retries with a fresh connection
|
|
40
44
|
export declare function withFreshConnection<T>(fn: (sql: SQL) => Promise<T>): Promise<T>;
|
|
41
45
|
// Export a lazy proxy - no connection is made until first use
|
package/dist/index.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export * from './dynamodb-single-table';
|
|
|
35
35
|
export * from './dynamodb-tooling-adapter';
|
|
36
36
|
export * from './dynamodb/index';
|
|
37
37
|
export * from './factory';
|
|
38
|
+
export * from './inflect';
|
|
38
39
|
export * from './loader';
|
|
39
40
|
export * from './meta';
|
|
40
41
|
export * from './migrations';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared singularization for relation conventions.
|
|
3
|
+
*
|
|
4
|
+
* Pivot table names and FK columns are derived by singularizing a table name
|
|
5
|
+
* (`posts` -> `post_id`, `[coach, athlete].sort().join('_')`). Four call sites
|
|
6
|
+
* — client.ts, pivot.ts, orm.ts and migrations.ts — each open-coded the same
|
|
7
|
+
* naive trailing-`s` strip, which is wrong for every table `toTableName()`
|
|
8
|
+
* pluralizes with anything other than a bare `s`:
|
|
9
|
+
*
|
|
10
|
+
* categories -> `categorie` (want `category`)
|
|
11
|
+
* addresses -> `addresse` (want `address`)
|
|
12
|
+
* boxes -> `boxe` (want `box`)
|
|
13
|
+
* status -> `statu` (want `status` — it was never plural)
|
|
14
|
+
*
|
|
15
|
+
* Changing the default would rename existing pivot tables and FK columns under
|
|
16
|
+
* live schemas, so `'stripTrailingS'` remains the default and the corrected
|
|
17
|
+
* behavior is opt-in via `relations.singularizeStrategy: 'inflect'`.
|
|
18
|
+
*/
|
|
19
|
+
/** Naive trailing-`s` strip — the historical default. */
|
|
20
|
+
export declare function stripTrailingS(name: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Exact inverse of `toTableName()`'s pluralization rules.
|
|
23
|
+
*
|
|
24
|
+
* Words that aren't plural under those rules (`status`, `bus`, `data`) are
|
|
25
|
+
* returned untouched — the naive strip mangled them.
|
|
26
|
+
*/
|
|
27
|
+
export declare function inflectSingular(name: string): string;
|
|
28
|
+
/** Resolve the singularizer for a configured strategy. */
|
|
29
|
+
export declare function singularizerFor(strategy: 'stripTrailingS' | 'none' | 'inflect' | undefined): (name: string) => string;
|