bun-query-builder 0.1.56 → 0.1.58
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 +1 -1
- package/dist/db.d.ts +9 -1
- package/dist/orm.d.ts +21 -2
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -31022,7 +31022,7 @@ function getPrefix() {
|
|
|
31022
31022
|
}
|
|
31023
31023
|
var prefix = getPrefix();
|
|
31024
31024
|
// package.json
|
|
31025
|
-
var version2 = "0.1.
|
|
31025
|
+
var version2 = "0.1.58";
|
|
31026
31026
|
|
|
31027
31027
|
// bin/cli.ts
|
|
31028
31028
|
init_actions();
|
package/dist/db.d.ts
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { Database } from 'bun:sqlite';
|
|
2
2
|
import { SQL } from 'bun';
|
|
3
|
-
import type { PoolConfig } from './types';
|
|
3
|
+
import type { DatabaseConfig, PoolConfig, SupportedDialect } from './types';
|
|
4
4
|
export declare function splitSqlStatements(sql: string): string[];
|
|
5
|
+
/**
|
|
6
|
+
* Creates a database connection string based on the configured dialect and database settings.
|
|
7
|
+
*
|
|
8
|
+
* Exported so the `DB_*` env preference (see below) can be pinned by direct
|
|
9
|
+
* unit tests — the same pattern as `resolvePoolOptions`/`splitSqlStatements`.
|
|
10
|
+
* It is not re-exported from `src/index.ts`, so it stays internal.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createConnectionString(dialect: SupportedDialect, dbConfig: DatabaseConfig): string;
|
|
5
13
|
/**
|
|
6
14
|
* Map the qb-level `pool` config (ms-based, ergonomic) onto the Bun SQL
|
|
7
15
|
* driver's native option names (second resolution). Only the knobs Bun's
|
package/dist/orm.d.ts
CHANGED
|
@@ -255,8 +255,26 @@ declare type SystemFields<TDef extends ModelDefinition> = { [K in TDef extends {
|
|
|
255
255
|
(TDef['traits'] extends { softDeletable: true | object } ? { deleted_at: string | null } : {}) &
|
|
256
256
|
(TDef['traits'] extends { useAuth: true | object } ? { two_factor_secret: string | null; public_key: string | null } : {}) &
|
|
257
257
|
(TDef['traits'] extends { billable: true | object } ? { stripe_id: string | null } : {});
|
|
258
|
+
/**
|
|
259
|
+
* The foreign-key columns a `belongsTo` puts on THIS model's table.
|
|
260
|
+
*
|
|
261
|
+
* `belongsTo: ['Farm', 'Field']` means the migration carries `farm_id` and
|
|
262
|
+
* `field_id`, so they are as real as any declared attribute and code queries
|
|
263
|
+
* them constantly (`Mission.where('field_id', field.id)`). They were missing
|
|
264
|
+
* from both `ModelAttributes` and `ColumnName`, which made every such query a
|
|
265
|
+
* type error against a column that demonstrably exists.
|
|
266
|
+
*
|
|
267
|
+
* The name follows the same snake_case convention the relation resolver uses
|
|
268
|
+
* at runtime: `Farm` -> `farm_id`, `TreatmentMap` -> `treatment_map_id`.
|
|
269
|
+
*/
|
|
270
|
+
declare type BelongsToKeys<TDef extends ModelDefinition> = TDef extends { belongsTo: infer R extends readonly string[] }
|
|
271
|
+
? `${SnakeCase<Uncapitalize<R[number]>>}_id`
|
|
272
|
+
: never;
|
|
273
|
+
declare type BelongsToColumns<TDef extends ModelDefinition> = {
|
|
274
|
+
[K in BelongsToKeys<TDef>]: number
|
|
275
|
+
}
|
|
258
276
|
// Complete model type
|
|
259
|
-
declare type ModelAttributes<TDef extends ModelDefinition> = InferModelAttributes<TDef> & SnakeCaseAttributes<TDef> & SystemFields<TDef>;
|
|
277
|
+
declare type ModelAttributes<TDef extends ModelDefinition> = InferModelAttributes<TDef> & SnakeCaseAttributes<TDef> & SystemFields<TDef> & BelongsToColumns<TDef>;
|
|
260
278
|
// All valid column names
|
|
261
279
|
declare type ColumnName<TDef extends ModelDefinition> = | AttributeKeys<TDef>
|
|
262
280
|
| SnakeCase<AttributeKeys<TDef>>
|
|
@@ -267,7 +285,8 @@ declare type ColumnName<TDef extends ModelDefinition> = | AttributeKeys<TDef>
|
|
|
267
285
|
| (TDef['traits'] extends { useSoftDeletes: true } ? 'deleted_at' : never)
|
|
268
286
|
| (TDef['traits'] extends { softDeletable: true | object } ? 'deleted_at' : never)
|
|
269
287
|
| (TDef['traits'] extends { useAuth: true | object } ? 'two_factor_secret' | 'public_key' : never)
|
|
270
|
-
| (TDef['traits'] extends { billable: true | object } ? 'stripe_id' : never)
|
|
288
|
+
| (TDef['traits'] extends { billable: true | object } ? 'stripe_id' : never)
|
|
289
|
+
| BelongsToKeys<TDef>;
|
|
271
290
|
// Hidden fields
|
|
272
291
|
declare type HiddenKeys<TDef extends ModelDefinition> = {
|
|
273
292
|
[K in AttributeKeys<TDef>]: TDef['attributes'][K] extends { hidden: true } ? K : never
|
package/package.json
CHANGED