bun-query-builder 0.2.26 → 0.2.28
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/actions/explain.d.ts +1 -1
- package/dist/actions/file.d.ts +1 -1
- package/dist/actions/inspect.d.ts +1 -1
- package/dist/actions/introspect.d.ts +4 -1
- package/dist/actions/ping.d.ts +1 -1
- package/dist/actions/sql.d.ts +5 -1
- package/dist/actions/unsafe.d.ts +1 -1
- package/dist/actions/wait-ready.d.ts +1 -1
- package/dist/bin/cli.js +331 -262
- package/dist/browser.d.ts +14 -8
- package/dist/client.d.ts +144 -101
- package/dist/config.d.ts +71 -0
- package/dist/db.d.ts +5 -0
- package/dist/model.d.ts +1 -1
- package/dist/orm.d.ts +25 -12
- package/dist/schema.d.ts +1 -1
- package/dist/src/index.js +178 -144
- package/dist/type-inference.d.ts +13 -3
- package/dist/types.d.ts +6 -1
- package/package.json +4 -4
package/dist/db.d.ts
CHANGED
|
@@ -60,6 +60,11 @@ export declare function resetConnection(): void;
|
|
|
60
60
|
export declare function setSqlInstance(sql: SQL): void;
|
|
61
61
|
// Wrapper that catches "Connection closed" errors and retries with a fresh connection
|
|
62
62
|
export declare function withFreshConnection<T>(fn: (sql: SQL) => Promise<T>): Promise<T>;
|
|
63
|
+
/**
|
|
64
|
+
* Lazy SQL connection proxy - connection is only created when first accessed.
|
|
65
|
+
* This allows setConfig() to be called before any database connection is made.
|
|
66
|
+
*/
|
|
67
|
+
declare function createLazyBunSql(): SQL;
|
|
63
68
|
// Export a lazy proxy - no connection is made until first use
|
|
64
69
|
export declare const bunSql: SQL;
|
|
65
70
|
/**
|
package/dist/model.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ export declare function registerModel<TModel>(name: string, model: TModel): TMod
|
|
|
79
79
|
* @param definition - The model definition
|
|
80
80
|
* @returns An isomorphic model with query methods
|
|
81
81
|
*/
|
|
82
|
-
export declare function defineModel<const TDef extends BrowserModelDefinition>(definition: TDef):
|
|
82
|
+
export declare function defineModel<const TDef extends BrowserModelDefinition>(definition: TDef): unknown;
|
|
83
83
|
/**
|
|
84
84
|
* Register models on the global window.StacksBrowser object.
|
|
85
85
|
* Call this in your app's entry point to make models available for STX auto-imports.
|
package/dist/orm.d.ts
CHANGED
|
@@ -228,8 +228,11 @@ declare type PrimitiveTypeMap = {
|
|
|
228
228
|
declare type InferType<T> = T extends keyof PrimitiveTypeMap ? PrimitiveTypeMap[T] :
|
|
229
229
|
T extends readonly (infer U)[] ? U :
|
|
230
230
|
T extends (infer U)[] ? U :
|
|
231
|
-
T extends {
|
|
232
|
-
|
|
231
|
+
T extends { getShape: () => infer TShape extends Readonly<Record<string, unknown>> }
|
|
232
|
+
? { -readonly [TKey in keyof TShape]: InferType<TShape[TKey]> }
|
|
233
|
+
: T extends { test: (value: infer U) => unknown } ? U :
|
|
234
|
+
T extends { validate: (value: infer U) => unknown } ? U :
|
|
235
|
+
unknown;
|
|
233
236
|
// Extract attribute keys from definition
|
|
234
237
|
declare type AttributeKeys<TDef extends ModelDefinition> = keyof TDef['attributes'] & string;
|
|
235
238
|
// Infer single attribute type
|
|
@@ -358,9 +361,9 @@ declare type FillableAttributes<TDef extends ModelDefinition> = Partial<Pick<
|
|
|
358
361
|
ModelAttributes<TDef>,
|
|
359
362
|
FillableKeys<TDef> | SnakeCase<FillableKeys<TDef>> | BelongsToKeys<TDef>
|
|
360
363
|
>>;
|
|
361
|
-
// Numeric attribute columns
|
|
364
|
+
// Numeric attribute columns - constrains aggregate methods (sum, avg, etc.)
|
|
362
365
|
declare type NumericColumns<TDef extends ModelDefinition> = {
|
|
363
|
-
[K in AttributeKeys<TDef>]: TDef['attributes'][K] extends
|
|
366
|
+
[K in AttributeKeys<TDef>]: InferAttributeType<TDef['attributes'][K]> extends number ? K : never
|
|
364
367
|
}[AttributeKeys<TDef>];
|
|
365
368
|
/**
|
|
366
369
|
* Relation names of one relation declaration. Array form lowercases the
|
|
@@ -369,25 +372,35 @@ declare type NumericColumns<TDef extends ModelDefinition> = {
|
|
|
369
372
|
* and would otherwise leak its own keys ('length', indices, ...) into the
|
|
370
373
|
* relation-name union.
|
|
371
374
|
*/
|
|
372
|
-
declare type RelationKeyOf<V> = V extends
|
|
373
|
-
?
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
:
|
|
375
|
+
declare type RelationKeyOf<V> = V extends string
|
|
376
|
+
? Lowercase<V>
|
|
377
|
+
: V extends readonly (infer E)[]
|
|
378
|
+
? E extends string ? Lowercase<E>
|
|
379
|
+
: E extends { model: infer M extends string } ? Lowercase<M>
|
|
380
|
+
: never
|
|
381
|
+
: V extends Readonly<Record<infer K, unknown>>
|
|
382
|
+
? K & string
|
|
383
|
+
: never;
|
|
379
384
|
declare type InferBelongsToNames<TDef> = TDef extends { belongsTo: infer V } ? RelationKeyOf<V> : never;
|
|
380
385
|
declare type InferHasManyNames<TDef> = TDef extends { hasMany: infer V } ? RelationKeyOf<V> : never;
|
|
381
386
|
declare type InferHasOneNames<TDef> = TDef extends { hasOne: infer V } ? RelationKeyOf<V> : never;
|
|
382
387
|
declare type InferBelongsToManyNames<TDef> = TDef extends { belongsToMany: infer V } ? RelationKeyOf<V> : never;
|
|
383
388
|
declare type InferHasOneThroughNames<TDef> = TDef extends { hasOneThrough: infer V } ? RelationKeyOf<V> : never;
|
|
384
389
|
declare type InferHasManyThroughNames<TDef> = TDef extends { hasManyThrough: infer V } ? RelationKeyOf<V> : never;
|
|
390
|
+
declare type InferMorphOneNames<TDef> = TDef extends { morphOne: infer V } ? RelationKeyOf<V> : never;
|
|
391
|
+
declare type InferMorphManyNames<TDef> = TDef extends { morphMany: infer V } ? RelationKeyOf<V> : never;
|
|
392
|
+
declare type InferMorphToManyNames<TDef> = TDef extends { morphToMany: infer V } ? RelationKeyOf<V> : never;
|
|
393
|
+
declare type InferMorphedByManyNames<TDef> = TDef extends { morphedByMany: infer V } ? RelationKeyOf<V> : never;
|
|
385
394
|
export type InferRelationNames<TDef> = | InferBelongsToNames<TDef>
|
|
386
395
|
| InferHasManyNames<TDef>
|
|
387
396
|
| InferHasOneNames<TDef>
|
|
388
397
|
| InferBelongsToManyNames<TDef>
|
|
389
398
|
| InferHasOneThroughNames<TDef>
|
|
390
|
-
| InferHasManyThroughNames<TDef
|
|
399
|
+
| InferHasManyThroughNames<TDef>
|
|
400
|
+
| InferMorphOneNames<TDef>
|
|
401
|
+
| InferMorphManyNames<TDef>
|
|
402
|
+
| InferMorphToManyNames<TDef>
|
|
403
|
+
| InferMorphedByManyNames<TDef>;
|
|
391
404
|
/**
|
|
392
405
|
* Cardinality-aware value of a loaded relation as returned by
|
|
393
406
|
* `ModelInstance.getRelation()`. Relations declared as to-many (hasMany,
|
package/dist/schema.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export declare interface Attribute {
|
|
|
62
62
|
fillable?: boolean
|
|
63
63
|
guarded?: boolean
|
|
64
64
|
foreignKey?: boolean | ForeignKeyConfig
|
|
65
|
-
factory?: (faker: Faker) =>
|
|
65
|
+
factory?: (faker: Faker) => unknown
|
|
66
66
|
validation: {
|
|
67
67
|
rule: ValidationType
|
|
68
68
|
message?: ValidatorMessage
|