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.
@@ -16,6 +16,10 @@ declare interface InferableAttribute<T = unknown> {
16
16
  guarded?: boolean
17
17
  nullable?: boolean
18
18
  default?: InferType<T>
19
+ validation?: {
20
+ rule: ValidationType
21
+ message?: Record<string, string>
22
+ }
19
23
  factory?: (faker: Faker) => InferType<T>
20
24
  }
21
25
  /** Minimal model definition shape for type inference */
@@ -60,7 +64,11 @@ declare type PrimitiveTypeMap = {
60
64
  declare type InferType<T> = T extends keyof PrimitiveTypeMap ? PrimitiveTypeMap[T] :
61
65
  T extends readonly (infer U)[] ? U :
62
66
  T extends (infer U)[] ? U :
63
- unknown;
67
+ T extends { getShape: () => infer TShape extends Readonly<Record<string, unknown>> }
68
+ ? { -readonly [TKey in keyof TShape]: InferType<TShape[TKey]> }
69
+ : T extends { test: (value: infer U) => unknown } ? U :
70
+ T extends { validate: (value: infer U) => unknown } ? U :
71
+ unknown;
64
72
  /**
65
73
  * Resolves TModel to the underlying definition type.
66
74
  * Handles both raw definitions and wrapped models (from defineModel / createModel / createBrowserModel)
@@ -112,7 +120,9 @@ declare type SnakeCase<S extends string> = S extends `${infer C}${infer Rest}`
112
120
  // ============================================================================
113
121
  declare type InferSingleAttributeType<TAttr> = TAttr extends { type: infer T } ? InferType<T> :
114
122
  TAttr extends { factory: (faker: Faker) => infer R } ? R :
115
- unknown;
123
+ TAttr extends { validation: { rule: infer R } } ? InferType<R> :
124
+ TAttr extends { default: infer D } ? D :
125
+ unknown;
116
126
  /**
117
127
  * Infer the full attributes type from a model definition or wrapped model.
118
128
  * Includes user-defined attributes plus system fields (id, uuid, timestamps, soft deletes).
@@ -281,7 +291,7 @@ export type InferRelationNames<TModel> = ResolveDefinition<TModel> extends infer
281
291
  export type InferNumericColumns<TModel> = ResolveDefinition<TModel> extends infer TDef extends InferableModelDefinition
282
292
  ? {
283
293
  [K in DefinitionAttributeKeys<TDef>]:
284
- TDef['attributes'][K] extends { type: 'number' } ? K : never
294
+ InferSingleAttributeType<TDef['attributes'][K]> extends number ? K : never
285
295
  }[DefinitionAttributeKeys<TDef>]
286
296
  : never;
287
297
  /**
package/dist/types.d.ts CHANGED
@@ -370,7 +370,12 @@ export type SupportedDialect = 'postgres' | 'mysql' | 'singlestore' | 'vitess' |
370
370
  * `QueryBuilderConfig`. If one is ever added, give it a clause here too: a
371
371
  * mapped type shreds its methods exactly like a function's.
372
372
  */
373
- export type DeepPartial<T> = T extends (...args: any[]) => any // eslint-disable-line pickier/no-unused-vars -- `args` names a parameter in a function TYPE, not a binding
373
+ // `args` names a parameter in a function TYPE, not a binding, so there is
374
+ // nothing that could reference it. The trailing `eslint-disable-line` form this
375
+ // used to carry stopped being honoured in pickier 0.1.56; only the
376
+ // next-line form is.
377
+ // eslint-disable-next-line pickier/no-unused-vars
378
+ export type DeepPartial<T> = T extends (...args: any[]) => any
374
379
  ? T
375
380
  : T extends readonly (infer E)[]
376
381
  ? readonly E[]
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bun-query-builder",
3
3
  "type": "module",
4
- "version": "0.2.26",
4
+ "version": "0.2.28",
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",
@@ -77,13 +77,13 @@
77
77
  "typecheck": "bun --bun tsc"
78
78
  },
79
79
  "dependencies": {
80
- "@stacksjs/clapp": "^0.2.0",
80
+ "@stacksjs/clapp": "^0.2.12",
81
81
  "@stacksjs/ts-faker": "^0.1.8",
82
- "@stacksjs/ts-validation": "^0.5.0",
82
+ "@stacksjs/ts-validation": "^0.5.2",
83
83
  "dynamodb-tooling": "^0.3.5"
84
84
  },
85
85
  "devDependencies": {
86
- "bunfig": "^0.15.6"
86
+ "bunfig": "^0.15.17"
87
87
  },
88
88
  "git-hooks": {
89
89
  "pre-commit": {