hysteria-orm 11.0.1 → 11.0.2

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/lib/index.d.cts CHANGED
@@ -1,3 +1,4 @@
1
+ import { PassThrough } from 'node:stream';
1
2
  import * as mssql from 'mssql';
2
3
  import { config, Transaction as Transaction$1, IResult } from 'mssql';
3
4
  import * as mysql2_promise from 'mysql2/promise';
@@ -12,9 +13,8 @@ import { Collection as Collection$1 } from 'mongodb';
12
13
  import * as sqlite3 from 'sqlite3';
13
14
  import { RunResult } from 'sqlite3';
14
15
  import { RedisOptions, Redis } from 'ioredis';
15
- import { PassThrough } from 'node:stream';
16
16
 
17
- type CaseConvention = "camel" | "snake" | "preserve" | RegExp | ((column: string) => string);
17
+ type CaseConvention = "camel" | "snake" | "pascal" | "preserve" | RegExp | ((column: string) => string);
18
18
 
19
19
  type CommonConstraintOptions = {
20
20
  constraintName?: string;
@@ -162,13 +162,6 @@ type DateTimeOptions = {
162
162
  */
163
163
  type DatabaseTableOptions = MysqlTableOptions | PostgresTableOptions | SqliteTableOptions | MssqlTableOptions | OracledbTableOptions | MysqlAdvancedTableOptions;
164
164
 
165
- /**
166
- * Simplifies complex return types like SelectedModel to make it more readable and strips out whatever is passed as the second type parameter (e.g. SELECT_BRAND) to avoid showing it in the IDE autocomplete.
167
- */
168
- type Simplify<T, Strip> = T extends infer U ? {
169
- [K in keyof U as K extends Strip ? never : K]: U[K];
170
- } : never;
171
-
172
165
  declare abstract class QueryNode {
173
166
  /**
174
167
  * Sql keyword to use for the query e.g. "select"
@@ -939,6 +932,17 @@ type SlaveAlgorithm = "roundRobin" | "random";
939
932
  type RawQueryOptions = {
940
933
  replicationMode?: ReplicationType;
941
934
  };
935
+ /**
936
+ * @description Result of a health check ping operation
937
+ */
938
+ type PingResult = {
939
+ /** Whether the ping was successful */
940
+ ok: boolean;
941
+ /** Latency in milliseconds */
942
+ latencyMs: number;
943
+ /** Database dialect/type */
944
+ dialect: SqlDataSourceType;
945
+ };
942
946
 
943
947
  type OpenApiModelType = {
944
948
  type: "object";
@@ -1800,6 +1804,44 @@ declare class SchemaBuilder implements PromiseLike<void> {
1800
1804
  hasFailed(): boolean;
1801
1805
  }
1802
1806
 
1807
+ interface IntrospectedColumn {
1808
+ name: string;
1809
+ type: string;
1810
+ nullable: boolean;
1811
+ default?: string | null;
1812
+ length?: number;
1813
+ isPrimaryKey?: boolean;
1814
+ isForeignKey?: boolean;
1815
+ references?: {
1816
+ table: string;
1817
+ column: string;
1818
+ };
1819
+ }
1820
+ interface IntrospectedForeignKey {
1821
+ column: string;
1822
+ references: {
1823
+ table: string;
1824
+ column: string;
1825
+ };
1826
+ onDelete?: string;
1827
+ onUpdate?: string;
1828
+ }
1829
+ interface IntrospectedTable {
1830
+ name: string;
1831
+ columns: IntrospectedColumn[];
1832
+ primaryKeys?: string[];
1833
+ foreignKeys?: IntrospectedForeignKey[];
1834
+ indices?: {
1835
+ name: string;
1836
+ columns: string[];
1837
+ unique?: boolean;
1838
+ }[];
1839
+ }
1840
+ interface IntrospectedSchema {
1841
+ dialect: string;
1842
+ tables: IntrospectedTable[];
1843
+ }
1844
+
1803
1845
  type AstParserType = {
1804
1846
  sql: string;
1805
1847
  bindings: any[];
@@ -1974,81 +2016,6 @@ declare class ModelManager<T extends Model> {
1974
2016
  private applyFieldCondition;
1975
2017
  }
1976
2018
 
1977
- type JsonPathInput = string | (string | number)[];
1978
- /**
1979
- * Recursively generates all valid dot-separated JSON path strings from an
1980
- * object type `T`.
1981
- *
1982
- * Handles nested objects, arrays (via numeric indices), and stops recursion at
1983
- * a configurable depth (default 5) to prevent infinite expansion with deeply
1984
- * nested or self-referential types.
1985
- *
1986
- * @typeParam T - The root object type to extract paths from.
1987
- *
1988
- * @example
1989
- * ```ts
1990
- * type Data = { user: { name: string; roles: string[] }; count: number };
1991
- * type P = JsonPaths<Data>;
1992
- * // "user" | "user.name" | "user.roles" | "user.roles.${number}" | "count"
1993
- * ```
1994
- */
1995
- type JsonPaths<T, Depth extends number[] = []> = Depth["length"] extends 5 ? never : T extends readonly (infer E)[] ? `${number}` | (NonNullable<E> extends object ? `${number}.${JsonPaths<NonNullable<E>, [...Depth, 1]>}` : never) : T extends object ? {
1996
- [K in keyof T & string]: K | (NonNullable<T[K]> extends object ? `${K}.${JsonPaths<NonNullable<T[K]>, [...Depth, 1]>}` : never);
1997
- }[keyof T & string] : never;
1998
- /**
1999
- * Resolves the TypeScript type of a model column given its `ModelKey` string.
2000
- * Strips any table prefix (e.g. `"users.metadata"` → `"metadata"`) before
2001
- * indexing into the model.
2002
- *
2003
- * @typeParam T - The Model instance type.
2004
- * @typeParam K - The column key (plain or table-prefixed).
2005
- */
2006
- type ResolveColumnType<T extends Model, K extends string> = T[StripTablePrefix<K> & keyof T];
2007
- /**
2008
- * Type-safe JSON path input that provides IDE autocompletion for known JSON
2009
- * column structures while still accepting arbitrary strings as a fallback.
2010
- *
2011
- * - When `ColumnType` is a known object/array type: suggests all valid
2012
- * dot-separated paths via {@link JsonPaths}, plus `(string & {})` as a
2013
- * catch-all and `(string | number)[]` for the array form.
2014
- * - When `ColumnType` is `unknown`, a primitive, or `never`: falls back to the
2015
- * original untyped {@link JsonPathInput}.
2016
- *
2017
- * Uses the `SpecificLiteral | (string & {})` pattern so TypeScript's
2018
- * autocomplete shows the known paths first without blocking custom strings.
2019
- *
2020
- * @typeParam ColumnType - The TypeScript type of the JSON column value.
2021
- *
2022
- * @example
2023
- * ```ts
2024
- * type Settings = { theme: string; notifications: { email: boolean } };
2025
- * type P = TypedJsonPathInput<Settings | null>;
2026
- * // "theme" | "notifications" | "notifications.email" | (string & {}) | (string | number)[]
2027
- * ```
2028
- */
2029
- /**
2030
- * Resolves the TypeScript type at a given dot-separated JSON path within a
2031
- * root type. Handles `$` prefix, dot notation, and array numeric indices.
2032
- *
2033
- * Falls back to `unknown` when the path does not match the type structure.
2034
- *
2035
- * @typeParam T - The root JSON object type to traverse.
2036
- * @typeParam Path - A dot-separated string path.
2037
- *
2038
- * @example
2039
- * ```ts
2040
- * type Data = { user: { name: string; roles: string[] } };
2041
- * type A = ResolveJsonPathType<Data, "user.name">; // string
2042
- * type B = ResolveJsonPathType<Data, "user.roles">; // string[]
2043
- * type C = ResolveJsonPathType<Data, "user">; // { name: string; roles: string[] }
2044
- * type D = ResolveJsonPathType<Data, "$">; // Data
2045
- * ```
2046
- */
2047
- type ResolveJsonPathType<T, Path extends string> = Path extends `$.${infer Rest}` ? ResolveJsonPathType<T, Rest> : Path extends "$" | "" ? T : Path extends `${infer Head}.${infer Rest}` ? Head extends keyof NonNullable<T> ? ResolveJsonPathType<NonNullable<T>[Head], Rest> : NonNullable<T> extends readonly (infer E)[] ? Head extends `${number}` ? ResolveJsonPathType<E, Rest> : unknown : unknown : Path extends keyof NonNullable<T> ? NonNullable<T>[Path] : NonNullable<T> extends readonly (infer E)[] ? Path extends `${number}` ? E : unknown : unknown;
2048
- type TypedJsonPathInput<ColumnType> = [NonNullable<ColumnType>] extends [
2049
- never
2050
- ] ? JsonPathInput : unknown extends NonNullable<ColumnType> ? JsonPathInput : NonNullable<ColumnType> extends object ? JsonPaths<NonNullable<ColumnType>> | (string & {}) | (string | number)[] : JsonPathInput;
2051
-
2052
2019
  declare class DeleteNode extends QueryNode {
2053
2020
  fromNode: FromNode;
2054
2021
  returning?: string[];
@@ -2587,6 +2554,19 @@ declare class MongoDataSource extends DataSource {
2587
2554
  }): CollectionManager<T>;
2588
2555
  from(collectionName: string): MongoQueryBuilder<Collection>;
2589
2556
  getModelManager<T extends Collection>(model: typeof Collection, mongoDataSource: MongoDataSource, session?: InstanceType<MongoClientImport["ClientSession"]>): CollectionManager<T>;
2557
+ /**
2558
+ * @description Executes a lightweight health check ping
2559
+ * @returns Promise resolving to PingResult with ok status, latency in ms, and dialect 'mongo'
2560
+ */
2561
+ ping(): Promise<{
2562
+ ok: boolean;
2563
+ latencyMs: number;
2564
+ dialect: "mongo";
2565
+ }>;
2566
+ /**
2567
+ * @description Returns true if the MongoDB connection is healthy, false on error (never throws)
2568
+ */
2569
+ isHealthy(): Promise<boolean>;
2590
2570
  }
2591
2571
 
2592
2572
  type MongoCollectionKey<T> = T extends Collection ? T : never;
@@ -2651,129 +2631,369 @@ declare class WhereGroupNode extends QueryNode {
2651
2631
  constructor(nodes: (WhereNode | WhereGroupNode | WhereSubqueryNode)[], chainsWith?: "and" | "or");
2652
2632
  }
2653
2633
 
2654
- declare class DistinctNode extends QueryNode {
2655
- chainsWith: string;
2656
- canKeywordBeSeenMultipleTimes: boolean;
2657
- folder: string;
2658
- file: string;
2659
- constructor();
2660
- }
2661
-
2662
- declare class DistinctOnNode extends QueryNode {
2663
- columns: string[];
2664
- chainsWith: string;
2665
- canKeywordBeSeenMultipleTimes: boolean;
2666
- folder: string;
2667
- file: string;
2668
- constructor(columns: string[]);
2669
- }
2670
-
2671
- declare class SelectNode extends QueryNode {
2672
- column: string | QueryNode | QueryNode[];
2673
- alias?: string;
2674
- sqlFunction?: string;
2675
- chainsWith: string;
2676
- canKeywordBeSeenMultipleTimes: boolean;
2677
- folder: string;
2678
- file: string;
2679
- constructor(column: string | QueryNode | QueryNode[], alias?: string, sqlFunction?: string, isRaw?: boolean);
2680
- }
2681
-
2682
- declare class JoinNode extends QueryNode {
2683
- table: string;
2684
- left: string;
2685
- right: string;
2686
- on?: {
2687
- left?: string;
2688
- right?: string;
2689
- operator: string;
2690
- };
2691
- chainsWith: string;
2692
- canKeywordBeSeenMultipleTimes: boolean;
2693
- folder: string;
2694
- file: string;
2695
- type: "inner" | "left" | "right" | "full" | "cross" | "natural";
2696
- additionalConditions?: (WhereNode | WhereGroupNode | WhereSubqueryNode)[];
2697
- constructor(table: string, left: string, right: string, type: "inner" | "left" | "right" | "full" | "cross" | "natural" | undefined, on: {
2698
- left?: string;
2699
- right?: string;
2700
- operator: string;
2701
- }, isRawValue?: boolean, additionalConditions?: (WhereNode | WhereGroupNode | WhereSubqueryNode)[]);
2702
- }
2703
-
2704
- declare class GroupByNode extends QueryNode {
2705
- column: string;
2706
- chainsWith: string;
2707
- canKeywordBeSeenMultipleTimes: boolean;
2708
- folder: string;
2709
- file: string;
2710
- constructor(column: string, isRawValue?: boolean);
2711
- }
2712
-
2713
- declare class LimitNode extends QueryNode {
2714
- limit: number;
2715
- chainsWith: string;
2716
- canKeywordBeSeenMultipleTimes: boolean;
2717
- folder: string;
2718
- file: string;
2719
- constructor(limit: number);
2720
- }
2721
-
2722
- declare class OffsetNode extends QueryNode {
2723
- offset: number;
2724
- chainsWith: string;
2725
- canKeywordBeSeenMultipleTimes: boolean;
2726
- folder: string;
2727
- file: string;
2728
- constructor(offset: number);
2729
- }
2730
-
2731
- declare class OrderByNode extends QueryNode {
2732
- column: string;
2733
- direction: "asc" | "desc";
2734
- chainsWith: string;
2735
- canKeywordBeSeenMultipleTimes: boolean;
2736
- folder: string;
2737
- file: string;
2738
- constructor(column: string, direction?: "asc" | "desc", isRawValue?: boolean);
2739
- }
2740
-
2741
- type DateFormat = "ISO" | "TIMESTAMP" | "DATE_ONLY" | "TIME_ONLY";
2742
- type Timezone = "UTC" | "LOCAL";
2634
+ /**
2635
+ * Simplifies complex return types like SelectedModel to make it more readable and strips out whatever is passed as the second type parameter (e.g. SELECT_BRAND) to avoid showing it in the IDE autocomplete.
2636
+ */
2637
+ type Simplify<T, Strip> = T extends infer U ? {
2638
+ [K in keyof U as K extends Strip ? never : K]: U[K];
2639
+ } : never;
2743
2640
 
2641
+ type PluckReturnType<T extends Model, K extends RawModelKey<T>> = T[StripTablePrefix<K & string> & keyof T] extends infer U ? U[] : never;
2744
2642
  /**
2745
- * @description Options for the relation
2746
- * @property {string} softDeleteColumn - The column name for the soft delete column, if set, the relation will only return rows that have not been soft deleted
2747
- * @property {string} softDeleteType - The type of the soft delete column
2643
+ * Common SQL functions with intellisense support.
2644
+ * Provides autocomplete for standard SQL aggregate and scalar functions,
2645
+ * while still allowing any custom function name via string fallback.
2646
+ *
2647
+ * @example
2648
+ * selectFunc("count", "*", "total") // Intellisense suggests "count"
2649
+ * selectFunc("custom_fn", "col", "res") // Custom functions still work
2748
2650
  */
2749
- declare enum RelationEnum {
2750
- hasOne = "hasOne",// One to One without foreign key
2751
- belongsTo = "belongsTo",// One to One with foreign key
2752
- hasMany = "hasMany",
2753
- manyToMany = "manyToMany"
2754
- }
2651
+ type SqlFunction = "count" | "sum" | "avg" | "min" | "max" | "upper" | "lower" | "length" | "trim" | "abs" | "round" | "coalesce" | "ceil" | "floor" | "sqrt" | (string & {});
2755
2652
  /**
2756
- * Main Relation Class
2653
+ * Maps SQL function names to their return types.
2654
+ * Used by selectFunc to auto-infer the result type.
2655
+ *
2656
+ * - Numeric functions (count, sum, avg, etc.) → number
2657
+ * - String functions (upper, lower, trim) → string
2658
+ * - Unknown functions → any
2757
2659
  */
2758
- declare abstract class Relation {
2759
- abstract type: RelationEnum;
2760
- model: typeof Model;
2761
- columnName: string;
2762
- foreignKey?: string;
2763
- relatedModel: string;
2764
- protected constructor(model: typeof Model, columnName: string);
2765
- }
2766
-
2767
- type BaseColumnDataType = Exclude<keyof CreateTableBuilder, "enum" | "rawColumn" | "custom">;
2660
+ type SqlFunctionReturnType<F extends string> = F extends "count" | "sum" | "avg" | "min" | "max" | "length" | "abs" | "round" | "ceil" | "floor" | "sqrt" ? number : F extends "upper" | "lower" | "trim" ? string : any;
2768
2661
  /**
2769
- * Column data type - supports built-in types with intellisense and custom string types.
2770
- * Built-in types get autocomplete, custom types pass through as-is for extensions like pgvector.
2662
+ * A tuple type for selecting a column with an alias.
2663
+ * @example ["id", "userId"] selects "id" column as "userId"
2664
+ */
2665
+ type SelectTuple<C extends string = string, A extends string = string> = readonly [column: C, alias: A];
2666
+ /**
2667
+ * Input type for select() method in raw query builder.
2668
+ * Accepts either a column string or a [column, alias] tuple.
2669
+ *
2771
2670
  * @example
2772
- * col<string>({ type: "varchar", length: 255 }) // built-in
2773
- * col<string>({ type: "vector", length: 1536 }) // custom (pgvector)
2671
+ * .select("id", "name") // Simple columns
2672
+ * .select(["id", "userId"], ["name", "n"]) // Columns with aliases
2673
+ * .select("id", ["name", "userName"]) // Mixed
2774
2674
  */
2775
- type ColumnDataType = BaseColumnDataType | (string & {}) | readonly string[];
2776
- type ColumnDataTypeOptionWithLength = {
2675
+ type Selectable = string | SelectTuple;
2676
+ /**
2677
+ * Unique symbol used internally to mark that a raw select() has been called.
2678
+ */
2679
+ declare const RAW_SELECT_BRAND: unique symbol;
2680
+ /**
2681
+ * Marker type to indicate that a raw select() has been called.
2682
+ * @internal
2683
+ */
2684
+ type RawSelectBrand = {
2685
+ [RAW_SELECT_BRAND]?: never;
2686
+ };
2687
+ /**
2688
+ * Utility type to convert a union to an intersection.
2689
+ * @internal
2690
+ */
2691
+ type UnionToIntersection$1<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
2692
+ /**
2693
+ * Extracts the final property name from a column selection for raw queries.
2694
+ * Supports both string columns and [column, alias] tuples.
2695
+ *
2696
+ * | Input | Output |
2697
+ * |------------------------------|---------------|
2698
+ * | `"name"` | `"name"` |
2699
+ * | `"users.name"` | `"name"` |
2700
+ * | `["name", "userName"]` | `"userName"` |
2701
+ * | `["users.id", "id"]` | `"id"` |
2702
+ * | `"*"` | `never` |
2703
+ * | `"users.*"` | `never` |
2704
+ */
2705
+ type ExtractRawColumnName<S> = S extends readonly [
2706
+ string,
2707
+ infer Alias extends string
2708
+ ] ? Alias : S extends string ? S extends "*" ? never : S extends `${string}.*` ? never : S extends `${string}.${infer Column}` ? Column extends "*" ? never : Column : S : never;
2709
+ /**
2710
+ * Builds the type for a single selected column in a raw query.
2711
+ * All column types are `any` since we don't have model type information.
2712
+ * Supports both string columns and [column, alias] tuples.
2713
+ *
2714
+ * | Selection | Result Type |
2715
+ * |------------------------|---------------------------------------|
2716
+ * | `"*"` | `Record<string, any>` |
2717
+ * | `"table.*"` | `Record<string, any>` |
2718
+ * | `"column"` | `{ column: any }` |
2719
+ * | `["col", "alias"]` | `{ alias: any }` |
2720
+ *
2721
+ * @internal
2722
+ */
2723
+ type BuildRawSingleSelectType<S> = S extends readonly [
2724
+ string,
2725
+ infer Alias extends string
2726
+ ] ? {
2727
+ [K in Alias]: any;
2728
+ } : S extends string ? S extends "*" ? Record<string, any> : S extends `${string}.*` ? Record<string, any> : ExtractRawColumnName<S> extends never ? {} : {
2729
+ [K in ExtractRawColumnName<S> & string]: any;
2730
+ } : {};
2731
+ /**
2732
+ * Checks if a column selection includes wildcards or is empty.
2733
+ * @internal
2734
+ */
2735
+ type HasRawStarOrEmpty<Columns extends readonly Selectable[]> = Columns["length"] extends 0 ? true : "*" extends Columns[number] ? true : false;
2736
+ /**
2737
+ * Builds the combined TypeScript type for multiple selected columns in a raw query.
2738
+ * Supports both string columns and [column, alias] tuples.
2739
+ *
2740
+ * ## Rules
2741
+ *
2742
+ * 1. **Empty selection or `*`**: Returns `Record<string, any>`
2743
+ * 2. **Specific columns**: Returns intersection of all selected column types (all `any`)
2744
+ * 3. **With `table.*`**: Adds `Record<string, any>` to allow unknown properties
2745
+ *
2746
+ * @example
2747
+ * // .select("name", ["age", "userAge"])
2748
+ * BuildRawSelectType<["name", ["age", "userAge"]]>
2749
+ * // Result: { name: any; userAge: any } & RawSelectBrand
2750
+ *
2751
+ * @example
2752
+ * // .select("*")
2753
+ * BuildRawSelectType<["*"]>
2754
+ * // Result: Record<string, any>
2755
+ */
2756
+ type BuildRawSelectType<Columns extends readonly Selectable[]> = HasRawStarOrEmpty<Columns> extends true ? Record<string, any> : UnionToIntersection$1<{
2757
+ [K in keyof Columns]: BuildRawSingleSelectType<Columns[K]>;
2758
+ }[number]> extends infer Result ? Result extends Record<string, any> ? keyof Result extends never ? Record<string, any> : Result & RawSelectBrand : Record<string, any> : Record<string, any>;
2759
+ /**
2760
+ * Composes a new selection with the existing selection state for raw queries.
2761
+ *
2762
+ * - If S is the default Record<string, any> (no previous select), returns just the new selection
2763
+ * - If S is a typed selection from a prior select/selectRaw, composes with new selection
2764
+ *
2765
+ * Detection uses `string extends keyof S`: true for untyped `Record<string, any>`, false for any
2766
+ * specific typed record (e.g. `{ userName: any }`). This avoids relying on the RAW_SELECT_BRAND
2767
+ * symbol, which gets stripped by Simplify in intermediate types.
2768
+ *
2769
+ * @typeParam S - Current selection state
2770
+ * @typeParam Added - New fields being added by the select
2771
+ *
2772
+ * @example
2773
+ * // First selectRaw - creates new selection
2774
+ * ComposeRawSelect<Record<string, any>, { count: number }>
2775
+ * // Result: { count: number }
2776
+ *
2777
+ * @example
2778
+ * // Chained after select - composes with previous
2779
+ * ComposeRawSelect<{ userName: any }, { nameLength: number }>
2780
+ * // Result: { userName: any; nameLength: number }
2781
+ */
2782
+ type ComposeRawSelect<S extends Record<string, any>, Added extends Record<string, any>> = Simplify<(string extends keyof S ? RawSelectBrand : S) & Added, typeof RAW_SELECT_BRAND>;
2783
+ /**
2784
+ * Composes a BuildRawSelectType result with the existing selection state.
2785
+ *
2786
+ * Similar to ComposeRawSelect but designed for use with BuildRawSelectType.
2787
+ *
2788
+ * @typeParam S - Current selection state
2789
+ * @typeParam Columns - The columns being selected
2790
+ */
2791
+ type ComposeBuildRawSelect<S extends Record<string, any>, Columns extends readonly Selectable[]> = Simplify<(string extends keyof S ? {} : S) & BuildRawSelectType<Columns>, typeof RAW_SELECT_BRAND>;
2792
+ type WhereOnlyQueryBuilder<T extends Model> = Pick<WhereQueryBuilder<T>, "where" | "andWhere" | "orWhere" | "whereNot" | "andWhereNot" | "orWhereNot" | "whereIn" | "andWhereIn" | "orWhereIn" | "whereNotIn" | "andWhereNotIn" | "orWhereNotIn" | "whereBetween" | "andWhereBetween" | "orWhereBetween" | "whereNotBetween" | "andWhereNotBetween" | "orWhereNotBetween" | "whereNull" | "andWhereNull" | "orWhereNull" | "whereNotNull" | "andWhereNotNull" | "orWhereNotNull" | "whereLike" | "andWhereLike" | "orWhereLike" | "whereILike" | "andWhereILike" | "orWhereILike" | "whereNotLike" | "andWhereNotLike" | "orWhereNotLike" | "whereNotILike" | "andWhereNotILike" | "orWhereNotILike" | "whereRegexp" | "andWhereRegexp" | "orWhereRegexp" | "whereNotRegexp" | "andWhereNotRegexp" | "orWhereNotRegexp" | "whereRaw" | "andWhereRaw" | "orWhereRaw" | "whereExists" | "orWhereExists" | "andWhereExists" | "whereNotExists" | "orWhereNotExists" | "andWhereNotExists" | "whereColumn" | "andWhereColumn" | "orWhereColumn"> & Pick<JsonQueryBuilder<T>, "whereJson" | "andWhereJson" | "orWhereJson" | "whereJsonContains" | "andWhereJsonContains" | "orWhereJsonContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonRaw" | "andWhereJsonRaw" | "orWhereJsonRaw" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains">;
2793
+ type RelationRetrieveMethod<P> = NonNullable<P> extends any[] ? "many" : "one";
2794
+ /**
2795
+ * Validates a column string for raw query builder select().
2796
+ * Use [column, alias] tuple format for aliases instead of "column as alias".
2797
+ * Use selectFunction() for SQL functions instead of embedding them in select().
2798
+ */
2799
+ type SelectableColumn$1<T extends string = string> = T extends `${string}.${string}.${string}` ? never : T extends `${string} ${string}` ? never : T extends `.${string}` | `${string}.` ? never : T extends `${string}-${string}` ? never : T extends `${string}.${string}` ? T : T;
2800
+ /**
2801
+ * @description A column that can be used in a join statement e.g. `users.id`
2802
+ */
2803
+ type JoinableColumn = `${string}.${string}`;
2804
+ /**
2805
+ * @description Options for streaming queries
2806
+ * @sqlite Ignores the options below
2807
+ */
2808
+ type StreamOptions = {
2809
+ highWaterMark?: number;
2810
+ /** Postgres only */
2811
+ rowMode?: "array";
2812
+ /** Postgres only */
2813
+ batchSize?: number;
2814
+ /** Postgres only */
2815
+ types?: any;
2816
+ /** Mysql only */
2817
+ objectMode?: boolean;
2818
+ };
2819
+ type Cursor<T extends Model, K extends ModelKey<T>> = {
2820
+ key: K;
2821
+ value: string | number;
2822
+ };
2823
+ type PaginateWithCursorOptions<T extends Model, K extends ModelKey<T>> = {
2824
+ discriminator: K;
2825
+ operator?: "<" | ">";
2826
+ orderBy?: "asc" | "desc";
2827
+ };
2828
+ type UpsertOptionsRawBuilder = {
2829
+ updateOnConflict?: boolean;
2830
+ returning?: readonly string[];
2831
+ };
2832
+ type WriteQueryParam = string | number | boolean | Date | RawNode | object | null | undefined;
2833
+ /**
2834
+ * Simple paginated data type for raw query builders (without Model constraint)
2835
+ */
2836
+ type RawPaginatedData<S extends Record<string, any>> = {
2837
+ paginationMetadata: {
2838
+ perPage: number;
2839
+ currentPage: number;
2840
+ firstPage: number;
2841
+ isEmpty: boolean;
2842
+ total: number;
2843
+ lastPage: number;
2844
+ hasMorePages: boolean;
2845
+ hasPages: boolean;
2846
+ };
2847
+ data: S[];
2848
+ };
2849
+ /**
2850
+ * Simple cursor paginated data type for raw query builders (without Model constraint)
2851
+ */
2852
+ type RawCursorPaginatedData<S extends Record<string, any>> = {
2853
+ paginationMetadata: {
2854
+ perPage: number;
2855
+ firstPage: number;
2856
+ isEmpty: boolean;
2857
+ total: number;
2858
+ };
2859
+ data: S[];
2860
+ };
2861
+
2862
+ declare class DistinctNode extends QueryNode {
2863
+ chainsWith: string;
2864
+ canKeywordBeSeenMultipleTimes: boolean;
2865
+ folder: string;
2866
+ file: string;
2867
+ constructor();
2868
+ }
2869
+
2870
+ declare class DistinctOnNode extends QueryNode {
2871
+ columns: string[];
2872
+ chainsWith: string;
2873
+ canKeywordBeSeenMultipleTimes: boolean;
2874
+ folder: string;
2875
+ file: string;
2876
+ constructor(columns: string[]);
2877
+ }
2878
+
2879
+ declare class SelectNode extends QueryNode {
2880
+ column: string | QueryNode | QueryNode[];
2881
+ alias?: string;
2882
+ sqlFunction?: string;
2883
+ chainsWith: string;
2884
+ canKeywordBeSeenMultipleTimes: boolean;
2885
+ folder: string;
2886
+ file: string;
2887
+ constructor(column: string | QueryNode | QueryNode[], alias?: string, sqlFunction?: string, isRaw?: boolean);
2888
+ }
2889
+
2890
+ declare class JoinNode extends QueryNode {
2891
+ table: string;
2892
+ left: string;
2893
+ right: string;
2894
+ on?: {
2895
+ left?: string;
2896
+ right?: string;
2897
+ operator: string;
2898
+ };
2899
+ chainsWith: string;
2900
+ canKeywordBeSeenMultipleTimes: boolean;
2901
+ folder: string;
2902
+ file: string;
2903
+ type: "inner" | "left" | "right" | "full" | "cross" | "natural";
2904
+ additionalConditions?: (WhereNode | WhereGroupNode | WhereSubqueryNode)[];
2905
+ constructor(table: string, left: string, right: string, type: "inner" | "left" | "right" | "full" | "cross" | "natural" | undefined, on: {
2906
+ left?: string;
2907
+ right?: string;
2908
+ operator: string;
2909
+ }, isRawValue?: boolean, additionalConditions?: (WhereNode | WhereGroupNode | WhereSubqueryNode)[]);
2910
+ }
2911
+
2912
+ declare class GroupByNode extends QueryNode {
2913
+ column: string;
2914
+ chainsWith: string;
2915
+ canKeywordBeSeenMultipleTimes: boolean;
2916
+ folder: string;
2917
+ file: string;
2918
+ constructor(column: string, isRawValue?: boolean);
2919
+ }
2920
+
2921
+ declare class LimitNode extends QueryNode {
2922
+ limit: number;
2923
+ chainsWith: string;
2924
+ canKeywordBeSeenMultipleTimes: boolean;
2925
+ folder: string;
2926
+ file: string;
2927
+ constructor(limit: number);
2928
+ }
2929
+
2930
+ declare class OffsetNode extends QueryNode {
2931
+ offset: number;
2932
+ chainsWith: string;
2933
+ canKeywordBeSeenMultipleTimes: boolean;
2934
+ folder: string;
2935
+ file: string;
2936
+ constructor(offset: number);
2937
+ }
2938
+
2939
+ declare class OrderByNode extends QueryNode {
2940
+ column: string;
2941
+ direction: "asc" | "desc";
2942
+ chainsWith: string;
2943
+ canKeywordBeSeenMultipleTimes: boolean;
2944
+ folder: string;
2945
+ file: string;
2946
+ constructor(column: string, direction?: "asc" | "desc", isRawValue?: boolean);
2947
+ }
2948
+
2949
+ type DateFormat = "ISO" | "TIMESTAMP" | "DATE_ONLY" | "TIME_ONLY";
2950
+ type Timezone = "UTC" | "LOCAL";
2951
+
2952
+ /**
2953
+ * @description Options for the relation
2954
+ * @property {string} softDeleteColumn - The column name for the soft delete column, if set, the relation will only return rows that have not been soft deleted
2955
+ * @property {string} softDeleteType - The type of the soft delete column
2956
+ */
2957
+ declare enum RelationEnum {
2958
+ hasOne = "hasOne",// One to One without foreign key
2959
+ belongsTo = "belongsTo",// One to One with foreign key
2960
+ hasMany = "hasMany",
2961
+ manyToMany = "manyToMany"
2962
+ }
2963
+ /**
2964
+ * Main Relation Class
2965
+ */
2966
+ declare abstract class Relation {
2967
+ abstract type: RelationEnum;
2968
+ model: typeof Model;
2969
+ columnName: string;
2970
+ foreignKey?: string;
2971
+ relatedModel: string;
2972
+ protected constructor(model: typeof Model, columnName: string);
2973
+ }
2974
+
2975
+ type ValidationResult = {
2976
+ valid: boolean;
2977
+ message?: string;
2978
+ };
2979
+ type ValidationContext = {
2980
+ model: any;
2981
+ column: string;
2982
+ operation: "insert" | "update";
2983
+ data: any;
2984
+ };
2985
+ type Validator = (value: any, context: ValidationContext) => ValidationResult | Promise<ValidationResult>;
2986
+
2987
+ type BaseColumnDataType = Exclude<keyof CreateTableBuilder, "enum" | "rawColumn" | "custom">;
2988
+ /**
2989
+ * Column data type - supports built-in types with intellisense and custom string types.
2990
+ * Built-in types get autocomplete, custom types pass through as-is for extensions like pgvector.
2991
+ * @example
2992
+ * col<string>({ type: "varchar", length: 255 }) // built-in
2993
+ * col<string>({ type: "vector", length: 1536 }) // custom (pgvector)
2994
+ */
2995
+ type ColumnDataType = BaseColumnDataType | (string & {}) | readonly string[];
2996
+ type ColumnDataTypeOptionWithLength = {
2777
2997
  type?: "char" | "varchar" | "string" | "uuid" | "ulid" | "varbinary" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "increment" | "bigIncrement";
2778
2998
  length?: number;
2779
2999
  };
@@ -2947,6 +3167,10 @@ type ColumnOptions = {
2947
3167
  * @migration Only affects auto-generated migrations (CREATE TABLE / ALTER TABLE). Does NOT set a default value during insert operations — use `prepare` for that.
2948
3168
  */
2949
3169
  default?: string | number | null | boolean;
3170
+ /**
3171
+ * @description Per-column validators applied on insert/update
3172
+ */
3173
+ validate?: Validator | Validator[];
2950
3174
  } &
2951
3175
  /**
2952
3176
  * @description The data type of the column
@@ -2976,6 +3200,7 @@ type ColumnType = {
2976
3200
  nullable?: boolean;
2977
3201
  default?: string | number | null | boolean;
2978
3202
  };
3203
+ validate?: Validator | Validator[];
2979
3204
  };
2980
3205
  type IndexType = {
2981
3206
  columns: string[];
@@ -3022,7 +3247,7 @@ declare abstract class FooterQueryBuilder<T extends Model, S extends Record<stri
3022
3247
  * @description Adds a group by query
3023
3248
  */
3024
3249
  groupBy(...columns: ModelKey<T>[]): this;
3025
- groupBy<S extends string>(...columns: SelectableColumn<S>[]): this;
3250
+ groupBy<S extends string>(...columns: SelectableColumn$1<S>[]): this;
3026
3251
  /**
3027
3252
  * @description Adds a raw group by query, GROUP BY clause is not necessary and will be added automatically
3028
3253
  */
@@ -3031,7 +3256,7 @@ declare abstract class FooterQueryBuilder<T extends Model, S extends Record<stri
3031
3256
  * @description Adds an order by query
3032
3257
  */
3033
3258
  orderBy(column: ModelKey<T>, order: OrderByChoices): this;
3034
- orderBy<S extends string>(column: SelectableColumn<S>, order: OrderByChoices): this;
3259
+ orderBy<S extends string>(column: SelectableColumn$1<S>, order: OrderByChoices): this;
3035
3260
  /**
3036
3261
  * @description Adds a raw order by query, ORDER BY clause is not necessary and will be added automatically
3037
3262
  */
@@ -3058,180 +3283,180 @@ declare class JoinOnQueryBuilder {
3058
3283
  /**
3059
3284
  * @description Adds a WHERE condition to the query.
3060
3285
  */
3061
- where(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3286
+ where(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3062
3287
  where(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
3063
- where(column: SelectableColumn<string>, value: BaseValues$2): this;
3288
+ where(column: SelectableColumn$1<string>, value: BaseValues$2): this;
3064
3289
  /**
3065
3290
  * @description Adds an AND WHERE condition to the query.
3066
3291
  */
3067
- andWhere(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3068
- andWhere(column: SelectableColumn<string>, value: BaseValues$2): this;
3292
+ andWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3293
+ andWhere(column: SelectableColumn$1<string>, value: BaseValues$2): this;
3069
3294
  andWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
3070
3295
  /**
3071
3296
  * @description Adds an OR WHERE condition to the query.
3072
3297
  */
3073
- orWhere(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3074
- orWhere(column: SelectableColumn<string>, value: BaseValues$2): this;
3298
+ orWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3299
+ orWhere(column: SelectableColumn$1<string>, value: BaseValues$2): this;
3075
3300
  orWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
3076
3301
  /**
3077
3302
  * @description Adds a negated WHERE condition to the query.
3078
3303
  */
3079
- whereNot(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3080
- whereNot(column: SelectableColumn<string>, value: BaseValues$2): this;
3304
+ whereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3305
+ whereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
3081
3306
  /**
3082
3307
  * @description Adds a negated AND WHERE condition to the query.
3083
3308
  */
3084
- andWhereNot(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3085
- andWhereNot(column: SelectableColumn<string>, value: BaseValues$2): this;
3309
+ andWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3310
+ andWhereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
3086
3311
  /**
3087
3312
  * @description Adds a negated OR WHERE condition to the query.
3088
3313
  */
3089
- orWhereNot(column: SelectableColumn<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3090
- orWhereNot(column: SelectableColumn<string>, value: BaseValues$2): this;
3314
+ orWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
3315
+ orWhereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
3091
3316
  /**
3092
3317
  * @description Adds a WHERE BETWEEN condition to the query.
3093
3318
  */
3094
- whereBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
3319
+ whereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
3095
3320
  /**
3096
3321
  * @description Adds an AND WHERE BETWEEN condition to the query.
3097
3322
  */
3098
- andWhereBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
3323
+ andWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
3099
3324
  /**
3100
3325
  * @description Adds an OR WHERE BETWEEN condition to the query.
3101
3326
  */
3102
- orWhereBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
3327
+ orWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
3103
3328
  /**
3104
3329
  * @description Adds a WHERE NOT BETWEEN condition to the query.
3105
3330
  */
3106
- whereNotBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
3331
+ whereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
3107
3332
  /**
3108
3333
  * @description Adds an AND WHERE NOT BETWEEN condition to the query.
3109
3334
  */
3110
- andWhereNotBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
3335
+ andWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
3111
3336
  /**
3112
3337
  * @description Adds an OR WHERE NOT BETWEEN condition to the query.
3113
3338
  */
3114
- orWhereNotBetween(column: SelectableColumn<string>, min: BaseValues$2, max: BaseValues$2): this;
3339
+ orWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
3115
3340
  /**
3116
3341
  * @description Adds a WHERE LIKE condition to the query.
3117
3342
  */
3118
- whereLike(column: SelectableColumn<string>, value: string): this;
3343
+ whereLike(column: SelectableColumn$1<string>, value: string): this;
3119
3344
  /**
3120
3345
  * @description Adds an AND WHERE LIKE condition to the query.
3121
3346
  */
3122
- andWhereLike(column: SelectableColumn<string>, value: string): this;
3347
+ andWhereLike(column: SelectableColumn$1<string>, value: string): this;
3123
3348
  /**
3124
3349
  * @description Adds an OR WHERE LIKE condition to the query.
3125
3350
  */
3126
- orWhereLike(column: SelectableColumn<string>, value: string): this;
3351
+ orWhereLike(column: SelectableColumn$1<string>, value: string): this;
3127
3352
  /**
3128
3353
  * @description Adds a WHERE ILIKE condition to the query.
3129
3354
  */
3130
- whereILike(column: SelectableColumn<string>, value: string): this;
3355
+ whereILike(column: SelectableColumn$1<string>, value: string): this;
3131
3356
  /**
3132
3357
  * @description Adds an AND WHERE ILIKE condition to the query.
3133
3358
  */
3134
- andWhereILike(column: SelectableColumn<string>, value: string): this;
3359
+ andWhereILike(column: SelectableColumn$1<string>, value: string): this;
3135
3360
  /**
3136
3361
  * @description Adds an OR WHERE ILIKE condition to the query.
3137
3362
  */
3138
- orWhereILike(column: SelectableColumn<string>, value: string): this;
3363
+ orWhereILike(column: SelectableColumn$1<string>, value: string): this;
3139
3364
  /**
3140
3365
  * @description Adds a WHERE NOT LIKE condition to the query.
3141
3366
  */
3142
- whereNotLike(column: SelectableColumn<string>, value: string): this;
3367
+ whereNotLike(column: SelectableColumn$1<string>, value: string): this;
3143
3368
  /**
3144
3369
  * @description Adds an AND WHERE NOT LIKE condition to the query.
3145
3370
  */
3146
- andWhereNotLike(column: SelectableColumn<string>, value: string): this;
3371
+ andWhereNotLike(column: SelectableColumn$1<string>, value: string): this;
3147
3372
  /**
3148
3373
  * @description Adds an OR WHERE NOT LIKE condition to the query.
3149
3374
  */
3150
- orWhereNotLike(column: SelectableColumn<string>, value: string): this;
3375
+ orWhereNotLike(column: SelectableColumn$1<string>, value: string): this;
3151
3376
  /**
3152
3377
  * @description Adds a WHERE NOT ILIKE condition to the query.
3153
3378
  */
3154
- whereNotILike(column: SelectableColumn<string>, value: string): this;
3379
+ whereNotILike(column: SelectableColumn$1<string>, value: string): this;
3155
3380
  /**
3156
3381
  * @description Adds an AND WHERE NOT ILIKE condition to the query.
3157
3382
  */
3158
- andWhereNotILike(column: SelectableColumn<string>, value: string): this;
3383
+ andWhereNotILike(column: SelectableColumn$1<string>, value: string): this;
3159
3384
  /**
3160
3385
  * @description Adds an OR WHERE NOT ILIKE condition to the query.
3161
3386
  */
3162
- orWhereNotILike(column: SelectableColumn<string>, value: string): this;
3387
+ orWhereNotILike(column: SelectableColumn$1<string>, value: string): this;
3163
3388
  /**
3164
3389
  * @description Adds a WHERE IN condition to the query.
3165
3390
  */
3166
- whereIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
3391
+ whereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
3167
3392
  /**
3168
3393
  * @description Adds an AND WHERE IN condition to the query.
3169
3394
  */
3170
- andWhereIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
3395
+ andWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
3171
3396
  /**
3172
3397
  * @description Adds an OR WHERE IN condition to the query.
3173
3398
  */
3174
- orWhereIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
3399
+ orWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
3175
3400
  /**
3176
3401
  * @description Adds a WHERE NOT IN condition to the query.
3177
3402
  */
3178
- whereNotIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
3403
+ whereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
3179
3404
  /**
3180
3405
  * @description Adds an AND WHERE NOT IN condition to the query.
3181
3406
  */
3182
- andWhereNotIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
3407
+ andWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
3183
3408
  /**
3184
3409
  * @description Adds an OR WHERE NOT IN condition to the query.
3185
3410
  */
3186
- orWhereNotIn(column: SelectableColumn<string>, values: BaseValues$2[]): this;
3411
+ orWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
3187
3412
  /**
3188
3413
  * @description Adds a WHERE NULL condition to the query.
3189
3414
  */
3190
- whereNull(column: SelectableColumn<string>): this;
3415
+ whereNull(column: SelectableColumn$1<string>): this;
3191
3416
  /**
3192
3417
  * @description Adds an AND WHERE NULL condition to the query.
3193
3418
  */
3194
- andWhereNull(column: SelectableColumn<string>): this;
3419
+ andWhereNull(column: SelectableColumn$1<string>): this;
3195
3420
  /**
3196
3421
  * @description Adds an OR WHERE NULL condition to the query.
3197
3422
  */
3198
- orWhereNull(column: SelectableColumn<string>): this;
3423
+ orWhereNull(column: SelectableColumn$1<string>): this;
3199
3424
  /**
3200
3425
  * @description Adds a WHERE NOT NULL condition to the query.
3201
3426
  */
3202
- whereNotNull(column: SelectableColumn<string>): this;
3427
+ whereNotNull(column: SelectableColumn$1<string>): this;
3203
3428
  /**
3204
3429
  * @description Adds an AND WHERE NOT NULL condition to the query.
3205
3430
  */
3206
- andWhereNotNull(column: SelectableColumn<string>): this;
3431
+ andWhereNotNull(column: SelectableColumn$1<string>): this;
3207
3432
  /**
3208
3433
  * @description Adds an OR WHERE NOT NULL condition to the query.
3209
3434
  */
3210
- orWhereNotNull(column: SelectableColumn<string>): this;
3435
+ orWhereNotNull(column: SelectableColumn$1<string>): this;
3211
3436
  /**
3212
3437
  * @description Adds a WHERE REGEXP condition to the query.
3213
3438
  */
3214
- whereRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
3439
+ whereRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
3215
3440
  /**
3216
3441
  * @description Adds an AND WHERE REGEXP condition to the query.
3217
3442
  */
3218
- andWhereRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
3443
+ andWhereRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
3219
3444
  /**
3220
3445
  * @description Adds an OR WHERE REGEXP condition to the query.
3221
3446
  */
3222
- orWhereRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
3447
+ orWhereRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
3223
3448
  /**
3224
3449
  * @description Adds a WHERE NOT REGEXP condition to the query.
3225
3450
  */
3226
- whereNotRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
3451
+ whereNotRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
3227
3452
  /**
3228
3453
  * @description Adds an AND WHERE NOT REGEXP condition to the query.
3229
3454
  */
3230
- andWhereNotRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
3455
+ andWhereNotRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
3231
3456
  /**
3232
3457
  * @description Adds an OR WHERE NOT REGEXP condition to the query.
3233
3458
  */
3234
- orWhereNotRegexp(column: SelectableColumn<string>, regexp: RegExp): this;
3459
+ orWhereNotRegexp(column: SelectableColumn$1<string>, regexp: RegExp): this;
3235
3460
  /**
3236
3461
  * @description Adds a WHERE group condition with AND.
3237
3462
  */
@@ -3382,7 +3607,7 @@ declare class SelectQueryBuilder<T extends Model, S extends Record<string, any>
3382
3607
  * .select(["id", "userId"], ["name", "userName"]) // Columns with aliases
3383
3608
  * .select("id", ["name", "userName"]) // Mixed
3384
3609
  */
3385
- select<C extends string>(...columns: (SelectableColumn<C> | Selectable)[]): this;
3610
+ select<C extends string>(...columns: (SelectableColumn$1<C> | Selectable)[]): this;
3386
3611
  select(...columns: (ModelKey<T> | "*" | Selectable)[]): this;
3387
3612
  /**
3388
3613
  * @description Adds a raw SELECT statement to the query
@@ -3429,7 +3654,7 @@ declare class SelectQueryBuilder<T extends Model, S extends Record<string, any>
3429
3654
  * @postgresql Only usable with PostgreSQL
3430
3655
  */
3431
3656
  distinctOn(...columns: ModelKey<T>[]): this;
3432
- distinctOn<C extends string>(...columns: SelectableColumn<C>[]): this;
3657
+ distinctOn<C extends string>(...columns: SelectableColumn$1<C>[]): this;
3433
3658
  /**
3434
3659
  * @description Selects a JSON value at the specified path and returns it as JSON.
3435
3660
  * @description Path format is standardized across all databases — the ORM converts to DB-specific syntax.
@@ -3610,62 +3835,62 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
3610
3835
  * @description Adds a WHERE LIKE condition to the query.
3611
3836
  */
3612
3837
  whereLike(column: ModelKey<T>, value: string): this;
3613
- whereLike<S extends string>(column: SelectableColumn<S>, value: string): this;
3838
+ whereLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3614
3839
  /**
3615
3840
  * @description Adds an AND WHERE LIKE condition to the query.
3616
3841
  */
3617
3842
  andWhereLike(column: ModelKey<T>, value: string): this;
3618
- andWhereLike<S extends string>(column: SelectableColumn<S>, value: string): this;
3843
+ andWhereLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3619
3844
  /**
3620
3845
  * @description Adds an OR WHERE LIKE condition to the query.
3621
3846
  */
3622
3847
  orWhereLike(column: ModelKey<T>, value: string): this;
3623
- orWhereLike<S extends string>(column: SelectableColumn<S>, value: string): this;
3848
+ orWhereLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3624
3849
  /**
3625
3850
  * @description Adds a WHERE ILIKE condition to the query.
3626
3851
  */
3627
3852
  whereILike(column: ModelKey<T>, value: string): this;
3628
- whereILike<S extends string>(column: SelectableColumn<S>, value: string): this;
3853
+ whereILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3629
3854
  /**
3630
3855
  * @description Adds an AND WHERE ILIKE condition to the query.
3631
3856
  */
3632
3857
  andWhereILike(column: ModelKey<T>, value: string): this;
3633
- andWhereILike<S extends string>(column: SelectableColumn<S>, value: string): this;
3858
+ andWhereILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3634
3859
  /**
3635
3860
  * @description Adds an OR WHERE ILIKE condition to the query.
3636
3861
  */
3637
3862
  orWhereILike(column: ModelKey<T>, value: string): this;
3638
- orWhereILike<S extends string>(column: SelectableColumn<S>, value: string): this;
3863
+ orWhereILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3639
3864
  /**
3640
3865
  * @description Adds a WHERE NOT LIKE condition to the query.
3641
3866
  */
3642
3867
  whereNotLike(column: ModelKey<T>, value: string): this;
3643
- whereNotLike<S extends string>(column: SelectableColumn<S>, value: string): this;
3868
+ whereNotLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3644
3869
  /**
3645
3870
  * @description Adds an AND WHERE NOT LIKE condition to the query.
3646
3871
  */
3647
3872
  andWhereNotLike(column: ModelKey<T>, value: string): this;
3648
- andWhereNotLike<S extends string>(column: SelectableColumn<S>, value: string): this;
3873
+ andWhereNotLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3649
3874
  /**
3650
3875
  * @description Adds an OR WHERE NOT LIKE condition to the query.
3651
3876
  */
3652
3877
  orWhereNotLike(column: ModelKey<T>, value: string): this;
3653
- orWhereNotLike<S extends string>(column: SelectableColumn<S>, value: string): this;
3878
+ orWhereNotLike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3654
3879
  /**
3655
3880
  * @description Adds a WHERE NOT ILIKE condition to the query.
3656
3881
  */
3657
3882
  whereNotILike(column: ModelKey<T>, value: string): this;
3658
- whereNotILike<S extends string>(column: SelectableColumn<S>, value: string): this;
3883
+ whereNotILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3659
3884
  /**
3660
3885
  * @description Adds an AND WHERE NOT ILIKE condition to the query.
3661
3886
  */
3662
3887
  andWhereNotILike(column: ModelKey<T>, value: string): this;
3663
- andWhereNotILike<S extends string>(column: SelectableColumn<S>, value: string): this;
3888
+ andWhereNotILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3664
3889
  /**
3665
3890
  * @description Adds an OR WHERE NOT ILIKE condition to the query.
3666
3891
  */
3667
3892
  orWhereNotILike(column: ModelKey<T>, value: string): this;
3668
- orWhereNotILike<S extends string>(column: SelectableColumn<S>, value: string): this;
3893
+ orWhereNotILike<S extends string>(column: SelectableColumn$1<S>, value: string): this;
3669
3894
  /**
3670
3895
  * @description Adds a WHERE IN condition to the query.
3671
3896
  * @warning If the array is empty, it will add an impossible condition.
@@ -3712,74 +3937,74 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
3712
3937
  * @description Adds a WHERE NULL condition to the query.
3713
3938
  */
3714
3939
  whereNull(column: ModelKey<T>): this;
3715
- whereNull<S extends string>(column: SelectableColumn<S>): this;
3940
+ whereNull<S extends string>(column: SelectableColumn$1<S>): this;
3716
3941
  /**
3717
3942
  * @description Adds an AND WHERE NULL condition to the query.
3718
3943
  */
3719
3944
  andWhereNull(column: ModelKey<T>): this;
3720
- andWhereNull<S extends string>(column: SelectableColumn<S>): this;
3945
+ andWhereNull<S extends string>(column: SelectableColumn$1<S>): this;
3721
3946
  /**
3722
3947
  * @description Adds an OR WHERE NULL condition to the query.
3723
3948
  */
3724
3949
  orWhereNull(column: ModelKey<T>): this;
3725
- orWhereNull<S extends string>(column: SelectableColumn<S>): this;
3950
+ orWhereNull<S extends string>(column: SelectableColumn$1<S>): this;
3726
3951
  /**
3727
3952
  * @description Adds a WHERE NOT NULL condition to the query.
3728
3953
  */
3729
3954
  whereNotNull(column: ModelKey<T>): this;
3730
- whereNotNull<S extends string>(column: SelectableColumn<S>): this;
3955
+ whereNotNull<S extends string>(column: SelectableColumn$1<S>): this;
3731
3956
  /**
3732
3957
  * @description Adds an AND WHERE NOT NULL condition to the query.
3733
3958
  */
3734
3959
  andWhereNotNull(column: ModelKey<T>): this;
3735
- andWhereNotNull<S extends string>(column: SelectableColumn<S>): this;
3960
+ andWhereNotNull<S extends string>(column: SelectableColumn$1<S>): this;
3736
3961
  /**
3737
3962
  * @description Adds an OR WHERE NOT NULL condition to the query.
3738
3963
  */
3739
3964
  orWhereNotNull(column: ModelKey<T>): this;
3740
- orWhereNotNull<S extends string>(column: SelectableColumn<S>): this;
3965
+ orWhereNotNull<S extends string>(column: SelectableColumn$1<S>): this;
3741
3966
  /**
3742
3967
  * @description Adds a WHERE REGEXP condition to the query.
3743
3968
  * @mssql doesn't support REGEXP syntax
3744
3969
  * @sqlite doesn't support REGEXP syntax
3745
3970
  */
3746
3971
  whereRegexp(column: ModelKey<T>, regexp: RegExp): this;
3747
- whereRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
3972
+ whereRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
3748
3973
  /**
3749
3974
  * @description Adds an AND WHERE REGEXP condition to the query.
3750
3975
  * @mssql doesn't support REGEXP syntax
3751
3976
  * @sqlite doesn't support REGEXP syntax
3752
3977
  */
3753
3978
  andWhereRegexp(column: ModelKey<T>, regexp: RegExp): this;
3754
- andWhereRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
3979
+ andWhereRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
3755
3980
  /**
3756
3981
  * @description Adds an OR WHERE REGEXP condition to the query.
3757
3982
  * @mssql doesn't support REGEXP syntax
3758
3983
  * @sqlite doesn't support REGEXP syntax
3759
3984
  */
3760
3985
  orWhereRegexp(column: ModelKey<T>, regexp: RegExp): this;
3761
- orWhereRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
3986
+ orWhereRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
3762
3987
  /**
3763
3988
  * @description Adds a WHERE NOT REGEXP condition to the query.
3764
3989
  * @mssql doesn't support REGEXP syntax
3765
3990
  * @sqlite doesn't support REGEXP syntax
3766
3991
  */
3767
3992
  whereNotRegexp(column: ModelKey<T>, regexp: RegExp): this;
3768
- whereNotRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
3993
+ whereNotRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
3769
3994
  /**
3770
3995
  * @description Adds an AND WHERE NOT REGEXP condition to the query.
3771
3996
  * @mssql doesn't support REGEXP syntax
3772
3997
  * @sqlite doesn't support REGEXP syntax
3773
3998
  */
3774
3999
  andWhereNotRegexp(column: ModelKey<T>, regexp: RegExp): this;
3775
- andWhereNotRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
4000
+ andWhereNotRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
3776
4001
  /**
3777
4002
  * @description Adds an OR WHERE NOT REGEXP condition to the query.
3778
4003
  * @mssql doesn't support REGEXP syntax
3779
4004
  * @sqlite doesn't support REGEXP syntax
3780
4005
  */
3781
4006
  orWhereNotRegexp(column: ModelKey<T>, regexp: RegExp): this;
3782
- orWhereNotRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
4007
+ orWhereNotRegexp<S extends string>(column: SelectableColumn$1<S>, regexp: RegExp): this;
3783
4008
  /**
3784
4009
  * @description Adds a AND WHERE EXISTS condition to the query. By default uses the same table, you can use the `from` method to change the table.
3785
4010
  */
@@ -3950,8 +4175,7 @@ declare class JsonQueryBuilder<T extends Model, S extends Record<string, any> =
3950
4175
  /**
3951
4176
  * @description Minimal interface satisfied by both QueryBuilder and ModelQueryBuilder.
3952
4177
  * Used as the return type for subquery callbacks so that both QB and MQB can be
3953
- * returned without TypeScript complaining about structural incompatibilities in
3954
- * the `performance` property.
4178
+ * returned without TypeScript complaining about structural incompatibilities.
3955
4179
  */
3956
4180
  interface SubQueryable {
3957
4181
  extractQueryNodes(): QueryNode[];
@@ -3971,63 +4195,6 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3971
4195
  protected deleteNode: DeleteNode | null;
3972
4196
  protected truncateNode: TruncateNode | null;
3973
4197
  protected replicationMode: ReplicationType | null;
3974
- /**
3975
- * @description Performance methods that return the time that took to execute the query with the result
3976
- */
3977
- performance: {
3978
- many: (returnType?: "millis" | "seconds") => Promise<{
3979
- data: S[];
3980
- time: number;
3981
- }>;
3982
- one: (returnType?: "millis" | "seconds") => Promise<{
3983
- data: S | null;
3984
- time: number;
3985
- }>;
3986
- oneOrFail: (returnType?: "millis" | "seconds") => Promise<{
3987
- data: S;
3988
- time: number;
3989
- }>;
3990
- paginate: (page: number, perPage: number, returnType?: "millis" | "seconds") => Promise<{
3991
- data: RawPaginatedData<S>;
3992
- time: number;
3993
- }>;
3994
- paginateWithCursor: (page: number, options: PaginateWithCursorOptions<T, ModelKey<T>>, cursor?: Cursor<T, ModelKey<T>>, returnType?: "millis" | "seconds") => Promise<{
3995
- data: [RawCursorPaginatedData<S>, Cursor<T, ModelKey<T>>];
3996
- time: number;
3997
- }>;
3998
- exists: (returnType?: "millis" | "seconds") => Promise<{
3999
- data: boolean;
4000
- time: number;
4001
- }>;
4002
- truncate: (returnType?: "millis" | "seconds") => Promise<{
4003
- data: void;
4004
- time: number;
4005
- }>;
4006
- delete: (returnType?: "millis" | "seconds") => Promise<{
4007
- data: any;
4008
- time: number;
4009
- }>;
4010
- insert: (data: Record<string, any>, returnType?: "millis" | "seconds") => Promise<{
4011
- data: void;
4012
- time: number;
4013
- }>;
4014
- insertMany: (data: Record<string, any>[], returnType?: "millis" | "seconds") => Promise<{
4015
- data: void;
4016
- time: number;
4017
- }>;
4018
- update: (data: Record<string, any>, returnType?: "millis" | "seconds") => Promise<{
4019
- data: any;
4020
- time: number;
4021
- }>;
4022
- softDelete: (options?: Omit<SoftDeleteOptions<T>, "ignoreBeforeDeleteHook">, returnType?: "millis" | "seconds") => Promise<{
4023
- data: number;
4024
- time: number;
4025
- }>;
4026
- pluck: (key: RawModelKey<T>, returnType?: "millis" | "seconds") => Promise<{
4027
- data: PluckReturnType<T, RawModelKey<T>>;
4028
- time: number;
4029
- }>;
4030
- };
4031
4198
  constructor(model: typeof Model, sqlDataSource: SqlDataSource);
4032
4199
  /**
4033
4200
  * @description Sets the replication mode for the query builder
@@ -4377,36 +4544,6 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
4377
4544
  clearWithQuery(): this;
4378
4545
  extractQueryNodes(): QueryNode[];
4379
4546
  protected clearForFunctions(): this;
4380
- /**
4381
- * @description Makes a many query and returns the time that took to execute that query
4382
- */
4383
- private manyWithPerformance;
4384
- /**
4385
- * @description Makes a one query and returns the time that took to execute that query
4386
- */
4387
- private oneWithPerformance;
4388
- /**
4389
- * @alias oneOrFailWithPerformance
4390
- */
4391
- private firstOrFailWithPerformance;
4392
- private paginateWithPerformance;
4393
- private paginateWithCursorWithPerformance;
4394
- /**
4395
- * @description Makes a one or fail query and returns the time that took to execute that query
4396
- */
4397
- private oneOrFailWithPerformance;
4398
- /**
4399
- * @description Executes the query and returns true if the query returns at least one result, false otherwise.
4400
- * @description Returns the time that took to execute the query
4401
- */
4402
- private existsWithPerformance;
4403
- private pluckWithPerformance;
4404
- private updateWithPerformance;
4405
- private insertWithPerformance;
4406
- private insertManyWithPerformance;
4407
- private softDeleteWithPerformance;
4408
- private deleteWithPerformance;
4409
- private truncateWithPerformance;
4410
4547
  /**
4411
4548
  * @description Checks if the current context is an MSSQL transaction
4412
4549
  * @description MSSQL transactions can only handle one request at a time
@@ -4560,6 +4697,41 @@ declare class Transaction {
4560
4697
  private getMssqlTransactionLevel;
4561
4698
  }
4562
4699
 
4700
+ type Operation = "SELECT" | "INSERT" | "UPDATE" | "DELETE" | "OTHER";
4701
+ interface QueryContext {
4702
+ sql: string;
4703
+ params: any[];
4704
+ model?: any;
4705
+ operation?: string;
4706
+ timestamp: number;
4707
+ }
4708
+ /**
4709
+ * Query context extended with execution metadata.
4710
+ * @property duration - Query execution time in milliseconds (ms)
4711
+ */
4712
+ type QueryContextWithDuration = QueryContext & {
4713
+ duration: number;
4714
+ result?: any;
4715
+ };
4716
+ interface QueryObserver {
4717
+ onBeforeQuery?(ctx: QueryContext): Promise<void> | void;
4718
+ onAfterQuery?(ctx: QueryContextWithDuration): Promise<void> | void;
4719
+ onQueryError?(ctx: QueryContext & {
4720
+ error: Error;
4721
+ }): Promise<void> | void;
4722
+ }
4723
+ declare class ObserverChain {
4724
+ private observers;
4725
+ constructor(observers?: QueryObserver[]);
4726
+ add(observer: QueryObserver): void;
4727
+ notifyBefore(ctx: QueryContext): Promise<void>;
4728
+ notifyAfter(ctx: QueryContextWithDuration, result?: any): Promise<void>;
4729
+ notifyError(ctx: QueryContext & {
4730
+ error: Error;
4731
+ }): Promise<void>;
4732
+ }
4733
+ declare const deriveOperationFromQuery: (sql: string) => string;
4734
+
4563
4735
  declare const SQL_DATA_SOURCE_SYMBOL: unique symbol;
4564
4736
  /**
4565
4737
  * @description The SqlDataSource class is the main class for interacting with the database, it's used to create connections, execute queries, and manage transactions
@@ -4653,6 +4825,10 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4653
4825
  path: string;
4654
4826
  tsconfig?: string;
4655
4827
  };
4828
+ /**
4829
+ * Optional observer chain for query middleware. See src/sql/observers for details.
4830
+ */
4831
+ observerChain?: ObserverChain;
4656
4832
  /**
4657
4833
  * @description AdminJS configuration options
4658
4834
  */
@@ -4671,6 +4847,20 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4671
4847
  * @description Returns the configured slave failure callback
4672
4848
  */
4673
4849
  getOnSlaveServerFailure(): ((error: Error, context: SlaveContext) => void | Promise<void>) | undefined;
4850
+ /**
4851
+ * @description Add a single observer to the query middleware chain.
4852
+ * Can be called multiple times to add multiple observers.
4853
+ * @param observer A QueryObserver with onBeforeQuery, onAfterQuery, and/or onQueryError handlers
4854
+ * @example
4855
+ * ```ts
4856
+ * sql.addObserver({
4857
+ * onBeforeQuery: (ctx) => console.log("Before:", ctx.sql),
4858
+ * onAfterQuery: (ctx) => console.log("After:", ctx.sql),
4859
+ * onQueryError: (ctx) => console.log("Error:", ctx.sql)
4860
+ * });
4861
+ * ```
4862
+ */
4863
+ addObserver(observer: QueryObserver): this;
4674
4864
  /**
4675
4865
  * @description Creates a new SqlDataSource instance. Call `.connect()` to establish the connection.
4676
4866
  * @param input Configuration options for the database connection. If not provided, uses env variables.
@@ -4871,6 +5061,11 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4871
5061
  * @description Returns the connection details
4872
5062
  */
4873
5063
  getConnectionDetails(): SqlDataSourceInput<D, T, C>;
5064
+ /**
5065
+ * @description Introspects database schema and returns a basic introspection structure.
5066
+ * This is a scaffold for dialect-aware introspection to be expanded.
5067
+ */
5068
+ introspectSchema(): Promise<IntrospectedSchema[]>;
4874
5069
  /**
4875
5070
  * @description Syncs the schema of the database with the models metadata
4876
5071
  * @warning This will drop and recreate all the indexes and constraints, use with caution
@@ -4964,6 +5159,15 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4964
5159
  * @returns true if lock was acquired, false otherwise
4965
5160
  */
4966
5161
  acquireLock(lockKey?: string, timeoutMs?: number): Promise<boolean>;
5162
+ /**
5163
+ * @description Executes a lightweight health check query
5164
+ * @returns Promise resolving to PingResult with ok status, latency in ms, and dialect
5165
+ */
5166
+ ping(): Promise<PingResult>;
5167
+ /**
5168
+ * @description Returns true if the database connection is healthy, false on error (never throws)
5169
+ */
5170
+ isHealthy(): Promise<boolean>;
4967
5171
  /**
4968
5172
  * @description Releases an advisory lock
4969
5173
  * @param lockKey - The lock identifier (defaults to 'hysteria_lock')
@@ -5162,7 +5366,7 @@ type RelatedInstance<M extends Model, K extends ModelRelation<M>> = NonNullable<
5162
5366
  *
5163
5367
  * @internal
5164
5368
  */
5165
- type UnionToIntersection$1<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
5369
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
5166
5370
  /**
5167
5371
  * Represents valid string column selection formats with intellisense support.
5168
5372
  * Use [column, alias] tuple format for aliases instead of "column as alias".
@@ -5184,7 +5388,7 @@ type UnionToIntersection$1<U> = (U extends any ? (k: U) => void : never) extends
5184
5388
  * "*" // All columns
5185
5389
  * );
5186
5390
  */
5187
- type SelectableColumn$1<T extends Model> = ModelKey<T> | `${string}.${string | "*"}` | "*";
5391
+ type SelectableColumn<T extends Model> = ModelKey<T> | `${string}.${string | "*"}` | "*";
5188
5392
  /**
5189
5393
  * A tuple type for selecting a column with an alias in ModelQueryBuilder.
5190
5394
  * @example ["id", "userId"] selects "id" column as "userId"
@@ -5199,7 +5403,7 @@ type ModelSelectTuple<T extends Model, C extends ModelKey<T> | `${string}.${stri
5199
5403
  * .select(["id", "userId"], ["name", "userName"]) // Columns with aliases
5200
5404
  * .select("id", ["name", "userName"]) // Mixed
5201
5405
  */
5202
- type ModelSelectableInput<T extends Model> = SelectableColumn$1<T> | ModelSelectTuple<T>;
5406
+ type ModelSelectableInput<T extends Model> = SelectableColumn<T> | ModelSelectTuple<T>;
5203
5407
  /**
5204
5408
  * Extracts the final property name from a column selection.
5205
5409
  * Supports both string columns and [column, alias] tuples.
@@ -5317,7 +5521,7 @@ type SelectBrand = {
5317
5521
  * BuildSelectType<User, ["*"]>
5318
5522
  * // Result: ModelWithoutRelations<User> (all columns)
5319
5523
  */
5320
- type BuildSelectType<T extends Model, Columns extends readonly (string | readonly [string, string])[]> = HasStarOrEmpty<Columns> extends true ? ModelWithoutRelations<T> : UnionToIntersection$1<{
5524
+ type BuildSelectType<T extends Model, Columns extends readonly (string | readonly [string, string])[]> = HasStarOrEmpty<Columns> extends true ? ModelWithoutRelations<T> : UnionToIntersection<{
5321
5525
  [K in keyof Columns]: BuildSingleSelectType<T, Columns[K]>;
5322
5526
  }[number]> extends infer Result ? Result extends Record<string, any> ? keyof Result extends never ? ModelWithoutRelations<T> : Result & ModelDataProperties & SelectBrand : ModelWithoutRelations<T> : ModelWithoutRelations<T>;
5323
5527
  /**
@@ -5544,254 +5748,108 @@ type FindOneType<T extends Model, S extends ModelKey<T>[] = any[], R extends Mod
5544
5748
  relations?: R;
5545
5749
  orderBy?: OrderByType<T>;
5546
5750
  groupBy?: ModelKey<T>[];
5547
- where?: WhereType<T>;
5548
- ignoreHooks?: FetchHooks;
5549
- };
5550
- type FindType<T extends Model, S extends ModelKey<T>[] = any[], R extends ModelRelation<T>[] = never[]> = Omit<FindOneType<T, S, R>, "throwErrorOnNull"> & {
5551
- limit?: number;
5552
- };
5553
- type FindReturnType<T extends Model, S extends ModelKey<T>[] = any[], R extends ModelRelation<T>[] = never[]> = S extends readonly any[] ? S[number] extends never ? ModelWithoutRelations<T> & {
5554
- [K in R[number] & keyof T]: T[K];
5555
- } : {
5556
- [K in StripTablePrefix<S[number] & string> & keyof T]: T[K];
5557
- } & {
5558
- [K in R[number] & keyof T]: T[K];
5559
- } : ModelWithoutRelations<T> & {
5560
- [K in R[number] & keyof T]: T[K];
5561
- };
5562
- /**
5563
- * Return type for write operations (insert/upsert) based on the returning columns.
5564
- * - `undefined` or `[]` -> `void` (no data fetched)
5565
- * - `["*"]` -> `ModelQueryResult<T>` (full model)
5566
- * - `["col1", "col2"]` -> `{ col1: ...; col2: ... } & ModelDataProperties`
5567
- *
5568
- * @typeParam T - The Model type
5569
- * @typeParam R - The returning columns array (literal tuple for type inference)
5570
- */
5571
- type WriteReturnType<T extends Model, R extends ReturningColumns<T>> = R extends undefined ? void : R extends readonly [] ? void : R extends readonly ReturningKey<T>[] ? "*" extends R[number] ? ModelQueryResult<T> : {
5572
- [K in R[number] & string & keyof T]: T[K];
5573
- } & ModelDataProperties : never;
5574
-
5575
- type PluckReturnType<T extends Model, K extends RawModelKey<T>> = T[StripTablePrefix<K & string> & keyof T] extends infer U ? U[] : never;
5576
- /**
5577
- * Common SQL functions with intellisense support.
5578
- * Provides autocomplete for standard SQL aggregate and scalar functions,
5579
- * while still allowing any custom function name via string fallback.
5580
- *
5581
- * @example
5582
- * selectFunc("count", "*", "total") // Intellisense suggests "count"
5583
- * selectFunc("custom_fn", "col", "res") // Custom functions still work
5584
- */
5585
- type SqlFunction = "count" | "sum" | "avg" | "min" | "max" | "upper" | "lower" | "length" | "trim" | "abs" | "round" | "coalesce" | "ceil" | "floor" | "sqrt" | (string & {});
5586
- /**
5587
- * Maps SQL function names to their return types.
5588
- * Used by selectFunc to auto-infer the result type.
5589
- *
5590
- * - Numeric functions (count, sum, avg, etc.) → number
5591
- * - String functions (upper, lower, trim) → string
5592
- * - Unknown functions → any
5593
- */
5594
- type SqlFunctionReturnType<F extends string> = F extends "count" | "sum" | "avg" | "min" | "max" | "length" | "abs" | "round" | "ceil" | "floor" | "sqrt" ? number : F extends "upper" | "lower" | "trim" ? string : any;
5595
- /**
5596
- * A tuple type for selecting a column with an alias.
5597
- * @example ["id", "userId"] selects "id" column as "userId"
5598
- */
5599
- type SelectTuple<C extends string = string, A extends string = string> = readonly [column: C, alias: A];
5600
- /**
5601
- * Input type for select() method in raw query builder.
5602
- * Accepts either a column string or a [column, alias] tuple.
5603
- *
5604
- * @example
5605
- * .select("id", "name") // Simple columns
5606
- * .select(["id", "userId"], ["name", "n"]) // Columns with aliases
5607
- * .select("id", ["name", "userName"]) // Mixed
5608
- */
5609
- type Selectable = string | SelectTuple;
5610
- /**
5611
- * Unique symbol used internally to mark that a raw select() has been called.
5612
- */
5613
- declare const RAW_SELECT_BRAND: unique symbol;
5614
- /**
5615
- * Marker type to indicate that a raw select() has been called.
5616
- * @internal
5617
- */
5618
- type RawSelectBrand = {
5619
- [RAW_SELECT_BRAND]?: never;
5751
+ where?: WhereType<T>;
5752
+ ignoreHooks?: FetchHooks;
5753
+ };
5754
+ type FindType<T extends Model, S extends ModelKey<T>[] = any[], R extends ModelRelation<T>[] = never[]> = Omit<FindOneType<T, S, R>, "throwErrorOnNull"> & {
5755
+ limit?: number;
5756
+ };
5757
+ type FindReturnType<T extends Model, S extends ModelKey<T>[] = any[], R extends ModelRelation<T>[] = never[]> = S extends readonly any[] ? S[number] extends never ? ModelWithoutRelations<T> & {
5758
+ [K in R[number] & keyof T]: T[K];
5759
+ } : {
5760
+ [K in StripTablePrefix<S[number] & string> & keyof T]: T[K];
5761
+ } & {
5762
+ [K in R[number] & keyof T]: T[K];
5763
+ } : ModelWithoutRelations<T> & {
5764
+ [K in R[number] & keyof T]: T[K];
5620
5765
  };
5621
5766
  /**
5622
- * Utility type to convert a union to an intersection.
5623
- * @internal
5624
- */
5625
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
5626
- /**
5627
- * Extracts the final property name from a column selection for raw queries.
5628
- * Supports both string columns and [column, alias] tuples.
5767
+ * Return type for write operations (insert/upsert) based on the returning columns.
5768
+ * - `undefined` or `[]` -> `void` (no data fetched)
5769
+ * - `["*"]` -> `ModelQueryResult<T>` (full model)
5770
+ * - `["col1", "col2"]` -> `{ col1: ...; col2: ... } & ModelDataProperties`
5629
5771
  *
5630
- * | Input | Output |
5631
- * |------------------------------|---------------|
5632
- * | `"name"` | `"name"` |
5633
- * | `"users.name"` | `"name"` |
5634
- * | `["name", "userName"]` | `"userName"` |
5635
- * | `["users.id", "id"]` | `"id"` |
5636
- * | `"*"` | `never` |
5637
- * | `"users.*"` | `never` |
5772
+ * @typeParam T - The Model type
5773
+ * @typeParam R - The returning columns array (literal tuple for type inference)
5638
5774
  */
5639
- type ExtractRawColumnName<S> = S extends readonly [
5640
- string,
5641
- infer Alias extends string
5642
- ] ? Alias : S extends string ? S extends "*" ? never : S extends `${string}.*` ? never : S extends `${string}.${infer Column}` ? Column extends "*" ? never : Column : S : never;
5775
+ type WriteReturnType<T extends Model, R extends ReturningColumns<T>> = R extends undefined ? void : R extends readonly [] ? void : R extends readonly ReturningKey<T>[] ? "*" extends R[number] ? ModelQueryResult<T> : {
5776
+ [K in R[number] & string & keyof T]: T[K];
5777
+ } & ModelDataProperties : never;
5778
+
5779
+ type JsonPathInput = string | (string | number)[];
5643
5780
  /**
5644
- * Builds the type for a single selected column in a raw query.
5645
- * All column types are `any` since we don't have model type information.
5646
- * Supports both string columns and [column, alias] tuples.
5781
+ * Recursively generates all valid dot-separated JSON path strings from an
5782
+ * object type `T`.
5647
5783
  *
5648
- * | Selection | Result Type |
5649
- * |------------------------|---------------------------------------|
5650
- * | `"*"` | `Record<string, any>` |
5651
- * | `"table.*"` | `Record<string, any>` |
5652
- * | `"column"` | `{ column: any }` |
5653
- * | `["col", "alias"]` | `{ alias: any }` |
5784
+ * Handles nested objects, arrays (via numeric indices), and stops recursion at
5785
+ * a configurable depth (default 5) to prevent infinite expansion with deeply
5786
+ * nested or self-referential types.
5654
5787
  *
5655
- * @internal
5788
+ * @typeParam T - The root object type to extract paths from.
5789
+ *
5790
+ * @example
5791
+ * ```ts
5792
+ * type Data = { user: { name: string; roles: string[] }; count: number };
5793
+ * type P = JsonPaths<Data>;
5794
+ * // "user" | "user.name" | "user.roles" | "user.roles.${number}" | "count"
5795
+ * ```
5656
5796
  */
5657
- type BuildRawSingleSelectType<S> = S extends readonly [
5658
- string,
5659
- infer Alias extends string
5660
- ] ? {
5661
- [K in Alias]: any;
5662
- } : S extends string ? S extends "*" ? Record<string, any> : S extends `${string}.*` ? Record<string, any> : ExtractRawColumnName<S> extends never ? {} : {
5663
- [K in ExtractRawColumnName<S> & string]: any;
5664
- } : {};
5797
+ type JsonPaths<T, Depth extends number[] = []> = Depth["length"] extends 5 ? never : T extends readonly (infer E)[] ? `${number}` | (NonNullable<E> extends object ? `${number}.${JsonPaths<NonNullable<E>, [...Depth, 1]>}` : never) : T extends object ? {
5798
+ [K in keyof T & string]: K | (NonNullable<T[K]> extends object ? `${K}.${JsonPaths<NonNullable<T[K]>, [...Depth, 1]>}` : never);
5799
+ }[keyof T & string] : never;
5665
5800
  /**
5666
- * Checks if a column selection includes wildcards or is empty.
5667
- * @internal
5801
+ * Resolves the TypeScript type of a model column given its `ModelKey` string.
5802
+ * Strips any table prefix (e.g. `"users.metadata"` → `"metadata"`) before
5803
+ * indexing into the model.
5804
+ *
5805
+ * @typeParam T - The Model instance type.
5806
+ * @typeParam K - The column key (plain or table-prefixed).
5668
5807
  */
5669
- type HasRawStarOrEmpty<Columns extends readonly Selectable[]> = Columns["length"] extends 0 ? true : "*" extends Columns[number] ? true : false;
5808
+ type ResolveColumnType<T extends Model, K extends string> = T[StripTablePrefix<K> & keyof T];
5670
5809
  /**
5671
- * Builds the combined TypeScript type for multiple selected columns in a raw query.
5672
- * Supports both string columns and [column, alias] tuples.
5810
+ * Type-safe JSON path input that provides IDE autocompletion for known JSON
5811
+ * column structures while still accepting arbitrary strings as a fallback.
5673
5812
  *
5674
- * ## Rules
5813
+ * - When `ColumnType` is a known object/array type: suggests all valid
5814
+ * dot-separated paths via {@link JsonPaths}, plus `(string & {})` as a
5815
+ * catch-all and `(string | number)[]` for the array form.
5816
+ * - When `ColumnType` is `unknown`, a primitive, or `never`: falls back to the
5817
+ * original untyped {@link JsonPathInput}.
5675
5818
  *
5676
- * 1. **Empty selection or `*`**: Returns `Record<string, any>`
5677
- * 2. **Specific columns**: Returns intersection of all selected column types (all `any`)
5678
- * 3. **With `table.*`**: Adds `Record<string, any>` to allow unknown properties
5819
+ * Uses the `SpecificLiteral | (string & {})` pattern so TypeScript's
5820
+ * autocomplete shows the known paths first without blocking custom strings.
5679
5821
  *
5680
- * @example
5681
- * // .select("name", ["age", "userAge"])
5682
- * BuildRawSelectType<["name", ["age", "userAge"]]>
5683
- * // Result: { name: any; userAge: any } & RawSelectBrand
5822
+ * @typeParam ColumnType - The TypeScript type of the JSON column value.
5684
5823
  *
5685
5824
  * @example
5686
- * // .select("*")
5687
- * BuildRawSelectType<["*"]>
5688
- * // Result: Record<string, any>
5825
+ * ```ts
5826
+ * type Settings = { theme: string; notifications: { email: boolean } };
5827
+ * type P = TypedJsonPathInput<Settings | null>;
5828
+ * // "theme" | "notifications" | "notifications.email" | (string & {}) | (string | number)[]
5829
+ * ```
5689
5830
  */
5690
- type BuildRawSelectType<Columns extends readonly Selectable[]> = HasRawStarOrEmpty<Columns> extends true ? Record<string, any> : UnionToIntersection<{
5691
- [K in keyof Columns]: BuildRawSingleSelectType<Columns[K]>;
5692
- }[number]> extends infer Result ? Result extends Record<string, any> ? keyof Result extends never ? Record<string, any> : Result & RawSelectBrand : Record<string, any> : Record<string, any>;
5693
5831
  /**
5694
- * Composes a new selection with the existing selection state for raw queries.
5695
- *
5696
- * - If S is the default Record<string, any> (no previous select), returns just the new selection
5697
- * - If S is a typed selection from a prior select/selectRaw, composes with new selection
5698
- *
5699
- * Detection uses `string extends keyof S`: true for untyped `Record<string, any>`, false for any
5700
- * specific typed record (e.g. `{ userName: any }`). This avoids relying on the RAW_SELECT_BRAND
5701
- * symbol, which gets stripped by Simplify in intermediate types.
5832
+ * Resolves the TypeScript type at a given dot-separated JSON path within a
5833
+ * root type. Handles `$` prefix, dot notation, and array numeric indices.
5702
5834
  *
5703
- * @typeParam S - Current selection state
5704
- * @typeParam Added - New fields being added by the select
5835
+ * Falls back to `unknown` when the path does not match the type structure.
5705
5836
  *
5706
- * @example
5707
- * // First selectRaw - creates new selection
5708
- * ComposeRawSelect<Record<string, any>, { count: number }>
5709
- * // Result: { count: number }
5837
+ * @typeParam T - The root JSON object type to traverse.
5838
+ * @typeParam Path - A dot-separated string path.
5710
5839
  *
5711
5840
  * @example
5712
- * // Chained after select - composes with previous
5713
- * ComposeRawSelect<{ userName: any }, { nameLength: number }>
5714
- * // Result: { userName: any; nameLength: number }
5715
- */
5716
- type ComposeRawSelect<S extends Record<string, any>, Added extends Record<string, any>> = Simplify<(string extends keyof S ? RawSelectBrand : S) & Added, typeof RAW_SELECT_BRAND>;
5717
- /**
5718
- * Composes a BuildRawSelectType result with the existing selection state.
5719
- *
5720
- * Similar to ComposeRawSelect but designed for use with BuildRawSelectType.
5721
- *
5722
- * @typeParam S - Current selection state
5723
- * @typeParam Columns - The columns being selected
5724
- */
5725
- type ComposeBuildRawSelect<S extends Record<string, any>, Columns extends readonly Selectable[]> = Simplify<(string extends keyof S ? {} : S) & BuildRawSelectType<Columns>, typeof RAW_SELECT_BRAND>;
5726
- type WhereOnlyQueryBuilder<T extends Model> = Pick<WhereQueryBuilder<T>, "where" | "andWhere" | "orWhere" | "whereNot" | "andWhereNot" | "orWhereNot" | "whereIn" | "andWhereIn" | "orWhereIn" | "whereNotIn" | "andWhereNotIn" | "orWhereNotIn" | "whereBetween" | "andWhereBetween" | "orWhereBetween" | "whereNotBetween" | "andWhereNotBetween" | "orWhereNotBetween" | "whereNull" | "andWhereNull" | "orWhereNull" | "whereNotNull" | "andWhereNotNull" | "orWhereNotNull" | "whereLike" | "andWhereLike" | "orWhereLike" | "whereILike" | "andWhereILike" | "orWhereILike" | "whereNotLike" | "andWhereNotLike" | "orWhereNotLike" | "whereNotILike" | "andWhereNotILike" | "orWhereNotILike" | "whereRegexp" | "andWhereRegexp" | "orWhereRegexp" | "whereNotRegexp" | "andWhereNotRegexp" | "orWhereNotRegexp" | "whereRaw" | "andWhereRaw" | "orWhereRaw" | "whereExists" | "orWhereExists" | "andWhereExists" | "whereNotExists" | "orWhereNotExists" | "andWhereNotExists" | "whereColumn" | "andWhereColumn" | "orWhereColumn"> & Pick<JsonQueryBuilder<T>, "whereJson" | "andWhereJson" | "orWhereJson" | "whereJsonContains" | "andWhereJsonContains" | "orWhereJsonContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains" | "whereJsonRaw" | "andWhereJsonRaw" | "orWhereJsonRaw" | "whereJsonNotContains" | "andWhereJsonNotContains" | "orWhereJsonNotContains">;
5727
- type RelationRetrieveMethod<P> = NonNullable<P> extends any[] ? "many" : "one";
5728
- /**
5729
- * Validates a column string for raw query builder select().
5730
- * Use [column, alias] tuple format for aliases instead of "column as alias".
5731
- * Use selectFunction() for SQL functions instead of embedding them in select().
5732
- */
5733
- type SelectableColumn<T extends string = string> = T extends `${string}.${string}.${string}` ? never : T extends `${string} ${string}` ? never : T extends `.${string}` | `${string}.` ? never : T extends `${string}-${string}` ? never : T extends `${string}.${string}` ? T : T;
5734
- /**
5735
- * @description A column that can be used in a join statement e.g. `users.id`
5736
- */
5737
- type JoinableColumn = `${string}.${string}`;
5738
- /**
5739
- * @description Options for streaming queries
5740
- * @sqlite Ignores the options below
5741
- */
5742
- type StreamOptions = {
5743
- highWaterMark?: number;
5744
- /** Postgres only */
5745
- rowMode?: "array";
5746
- /** Postgres only */
5747
- batchSize?: number;
5748
- /** Postgres only */
5749
- types?: any;
5750
- /** Mysql only */
5751
- objectMode?: boolean;
5752
- };
5753
- type Cursor<T extends Model, K extends ModelKey<T>> = {
5754
- key: K;
5755
- value: string | number;
5756
- };
5757
- type PaginateWithCursorOptions<T extends Model, K extends ModelKey<T>> = {
5758
- discriminator: K;
5759
- operator?: "<" | ">";
5760
- orderBy?: "asc" | "desc";
5761
- };
5762
- type UpsertOptionsRawBuilder = {
5763
- updateOnConflict?: boolean;
5764
- returning?: readonly string[];
5765
- };
5766
- type WriteQueryParam = string | number | boolean | Date | RawNode | object | null | undefined;
5767
- /**
5768
- * Simple paginated data type for raw query builders (without Model constraint)
5769
- */
5770
- type RawPaginatedData<S extends Record<string, any>> = {
5771
- paginationMetadata: {
5772
- perPage: number;
5773
- currentPage: number;
5774
- firstPage: number;
5775
- isEmpty: boolean;
5776
- total: number;
5777
- lastPage: number;
5778
- hasMorePages: boolean;
5779
- hasPages: boolean;
5780
- };
5781
- data: S[];
5782
- };
5783
- /**
5784
- * Simple cursor paginated data type for raw query builders (without Model constraint)
5841
+ * ```ts
5842
+ * type Data = { user: { name: string; roles: string[] } };
5843
+ * type A = ResolveJsonPathType<Data, "user.name">; // string
5844
+ * type B = ResolveJsonPathType<Data, "user.roles">; // string[]
5845
+ * type C = ResolveJsonPathType<Data, "user">; // { name: string; roles: string[] }
5846
+ * type D = ResolveJsonPathType<Data, "$">; // Data
5847
+ * ```
5785
5848
  */
5786
- type RawCursorPaginatedData<S extends Record<string, any>> = {
5787
- paginationMetadata: {
5788
- perPage: number;
5789
- firstPage: number;
5790
- isEmpty: boolean;
5791
- total: number;
5792
- };
5793
- data: S[];
5794
- };
5849
+ type ResolveJsonPathType<T, Path extends string> = Path extends `$.${infer Rest}` ? ResolveJsonPathType<T, Rest> : Path extends "$" | "" ? T : Path extends `${infer Head}.${infer Rest}` ? Head extends keyof NonNullable<T> ? ResolveJsonPathType<NonNullable<T>[Head], Rest> : NonNullable<T> extends readonly (infer E)[] ? Head extends `${number}` ? ResolveJsonPathType<E, Rest> : unknown : unknown : Path extends keyof NonNullable<T> ? NonNullable<T>[Path] : NonNullable<T> extends readonly (infer E)[] ? Path extends `${number}` ? E : unknown : unknown;
5850
+ type TypedJsonPathInput<ColumnType> = [NonNullable<ColumnType>] extends [
5851
+ never
5852
+ ] ? JsonPathInput : unknown extends NonNullable<ColumnType> ? JsonPathInput : NonNullable<ColumnType> extends object ? JsonPaths<NonNullable<ColumnType>> | (string & {}) | (string | number)[] : JsonPathInput;
5795
5853
 
5796
5854
  declare class SqlModelManagerUtils<T extends Model> {
5797
5855
  protected dbType: SqlDataSourceType;
@@ -5847,62 +5905,6 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
5847
5905
  protected offsetValue?: number;
5848
5906
  /** Options for relation loading strategy */
5849
5907
  protected loadOptions: LoadOptions;
5850
- performance: {
5851
- many: (options?: ManyOptions, returnType?: "millis" | "seconds") => Promise<{
5852
- data: SelectedModel<T, S, R>[];
5853
- time: number;
5854
- }>;
5855
- one: (options?: OneOptions, returnType?: "millis" | "seconds") => Promise<{
5856
- data: SelectedModel<T, S, R> | null;
5857
- time: number;
5858
- }>;
5859
- oneOrFail: (options?: OneOptions, returnType?: "millis" | "seconds") => Promise<{
5860
- data: SelectedModel<T, S, R>;
5861
- time: number;
5862
- }>;
5863
- paginate: (page: number, perPage: number, options?: {
5864
- ignoreHooks?: boolean;
5865
- }, returnType?: "millis" | "seconds") => Promise<{
5866
- data: PaginatedData<T, S, R>;
5867
- time: number;
5868
- }>;
5869
- exists: (returnType?: "millis" | "seconds") => Promise<{
5870
- data: boolean;
5871
- time: number;
5872
- }>;
5873
- paginateWithCursor: (page: number, options: PaginateWithCursorOptions<T, ModelKey<T>>, cursor?: Cursor<T, ModelKey<T>>, returnType?: "millis" | "seconds") => Promise<{
5874
- data: [CursorPaginatedData<T, S, R>, Cursor<T, ModelKey<T>>];
5875
- time: number;
5876
- }>;
5877
- truncate: (returnType?: "millis" | "seconds") => Promise<{
5878
- data: void;
5879
- time: number;
5880
- }>;
5881
- delete: (returnType?: "millis" | "seconds") => Promise<{
5882
- data: number;
5883
- time: number;
5884
- }>;
5885
- update: (data: Partial<ModelWithoutRelations<T>>, options?: UpdateOptions, returnType?: "millis" | "seconds") => Promise<{
5886
- data: MutationReturningResult<T, ReturningParam<T, D>>;
5887
- time: number;
5888
- }>;
5889
- softDelete: (options?: Omit<SoftDeleteOptions<T>, "ignoreBeforeDeleteHook">, returnType?: "millis" | "seconds") => Promise<{
5890
- data: number;
5891
- time: number;
5892
- }>;
5893
- pluck: (key: RawModelKey<T>, returnType?: "millis" | "seconds") => Promise<{
5894
- data: PluckReturnType<T, RawModelKey<T>>;
5895
- time: number;
5896
- }>;
5897
- insert: (data: Partial<ModelWithoutRelations<T>>, returnType?: "millis" | "seconds") => Promise<{
5898
- data: "*" extends "*" | RawModelKey<T> ? Simplify<ModelQueryResult<T>, never> : Simplify<{ [K in ("*" | RawModelKey<T>) & string & keyof T]: T[K]; }, never>;
5899
- time: number;
5900
- }>;
5901
- insertMany: (data: Partial<ModelWithoutRelations<T>>[], returnType?: "millis" | "seconds") => Promise<{
5902
- data: "*" extends "*" | RawModelKey<T> ? Simplify<ModelQueryResult<T>, never>[] : Simplify<{ [K in ("*" | RawModelKey<T>) & string & keyof T]: T[K]; }, never>[];
5903
- time: number;
5904
- }>;
5905
- };
5906
5908
  constructor(model: typeof Model, sqlDataSource: SqlDataSource);
5907
5909
  /**
5908
5910
  * @description Returns true if the query builder is a relation query builder, this changes the behavior of the query builder like limit, offset, etc.
@@ -6496,19 +6498,6 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6496
6498
  protected getFilterValuesFromModelsForRelation(relation: Relation, models: T[]): any[];
6497
6499
  protected applyHavingRelatedFilter(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, operator?: BinaryOperatorType$2, value?: BaseValues$2): void;
6498
6500
  protected addAdditionalColumnsToModel(row: any): Record<string, any>;
6499
- private manyWithPerformance;
6500
- private oneWithPerformance;
6501
- private oneOrFailWithPerformance;
6502
- private paginateWithPerformance;
6503
- private paginateWithCursorWithPerformance;
6504
- private existsWithPerformance;
6505
- private pluckWithPerformance;
6506
- private softDeleteWithPerformance;
6507
- private updateWithPerformance;
6508
- private deleteWithPerformance;
6509
- private truncateWithPerformance;
6510
- private insertWithPerformance;
6511
- private insertManyWithPerformance;
6512
6501
  }
6513
6502
 
6514
6503
  /**
@@ -6561,6 +6550,10 @@ declare abstract class Model<T extends Model<T> = any> extends Entity {
6561
6550
  static getIndexes(): IndexType[];
6562
6551
  static getUniques(): UniqueType[];
6563
6552
  static getChecks(): CheckType[];
6553
+ static validate(data: any): Promise<{
6554
+ valid: boolean;
6555
+ errors?: Record<string, string[]>;
6556
+ }>;
6564
6557
  }
6565
6558
 
6566
6559
  /**
@@ -6590,6 +6583,8 @@ interface RelationDef<T = any> {
6590
6583
  }
6591
6584
  type ColOptions = Omit<ColumnOptions, "primaryKey" | "serialize" | "prepare" | "default"> & {
6592
6585
  length?: number;
6586
+ /** Per-column validators (optional) */
6587
+ validate?: Validator | Validator[];
6593
6588
  };
6594
6589
  type ColPrimaryOptions = Omit<ColumnOptions, "primaryKey" | "serialize" | "prepare" | "default">;
6595
6590
  type ColStringOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default"> & {
@@ -6680,7 +6675,6 @@ type TypedPrepare<T> = {
6680
6675
  };
6681
6676
  type TypedDefault<T> = {
6682
6677
  /**
6683
- * Narrows the `default` property to the column's base type.
6684
6678
  * @migration Migration-only metadata. Sets the DEFAULT clause in CREATE TABLE / ALTER TABLE.
6685
6679
  * Does **not** enforce a value during `insert()` — pass the value explicitly or use `prepare`.
6686
6680
  */
@@ -7794,6 +7788,13 @@ declare class RedisDataSource {
7794
7788
  protected static getValue<T = RedisFetchable>(value: string | null): T | null;
7795
7789
  }
7796
7790
 
7791
+ declare class ObserverChainWrapper {
7792
+ private chain;
7793
+ constructor(observers?: QueryObserver[]);
7794
+ get chainInstance(): ObserverChain;
7795
+ add(observer: QueryObserver): void;
7796
+ }
7797
+
7797
7798
  declare class Schema {
7798
7799
  queryStatements: string[];
7799
7800
  sqlType: SqlDataSourceType;
@@ -7985,16 +7986,7 @@ declare abstract class BaseSeeder {
7985
7986
  abstract run(): Promise<void>;
7986
7987
  }
7987
7988
 
7988
- type WithPerformanceResult<R = any> = [string, R];
7989
- /**
7990
- * @description executes the async function with a timer to check how long it took
7991
- * @param `returnType` of the performance in milliseconds or seconds
7992
- * @param `fix` Number of digits in the decimal part of the performance result
7993
- * @returns An array with the millis or seconds that the function took as first element, and the result of the async function as second element
7994
- */
7995
- declare const withPerformance: <A extends any[], R>(fn: (...args: A) => Promise<R>, returnType?: "millis" | "seconds", fix?: number) => (...args: A) => Promise<WithPerformanceResult<R>>;
7996
-
7997
- type HysteriaErrorCode = "CONNECTION_ALREADY_ESTABLISHED" | `UNSUPPORTED_ISOLATION_LEVEL_${string}` | "ROW_NOT_FOUND" | `UNSUPPORTED_DATABASE_TYPE_${string}` | `RELATION_TYPE_NOT_SUPPORTED_${string}` | `NOT_SUPPORTED_IN_${string}` | `RELATION_NOT_FOUND_IN_MODEL_${string}` | `UNKNOWN_RELATION_TYPE_${string}` | `DISTINCT_ON_NOT_SUPPORTED_IN_${string}` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_HAS_ONE_RELATION_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_BELONGS_TO_RELATION_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_HAS_MANY_RELATION_${string}` | `MANY_TO_MANY_RELATION_NOT_FOUND_FOR_RELATED_MODEL_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_MANY_TO_MANY_RELATION_${string}` | `RELATED_MODEL_DOES_NOT_HAVE_A_PRIMARY_KEY_${string}` | `FOR_SHARE_NOT_SUPPORTED_IN_${string}` | `SKIP_LOCKED_NOT_SUPPORTED_IN_${string}` | `LOCK_FOR_UPDATE_NOT_SUPPORTED_${string}` | `KEY_${string}_HAS_NO_HANDLER_IN_CACHE_KEYS_CONFIG` | `CACHE_ADAPTER_NOT_CONFIGURED` | `SQLITE_NOT_SUPPORTED` | `COCKROACHDB_NOT_SUPPORTED` | `RELATION_NOT_FOUND` | `POSTGRES_TABLE_REQUIRED` | `MODEL_HAS_NO_PRIMARY_KEY_VALUE` | `RELATION_NOT_MANY_TO_MANY` | "MATERIALIZED_CTE_NOT_SUPPORTED" | "DUPLICATE_MODEL_KEYS_WHILE_INSTANTIATING_MODELS" | "INVALID_ONE_PARAMETER_WHERE_CONDITION" | "INVALID_PAGINATION_PARAMETERS" | "MISSING_ALIAS_FOR_SUBQUERY" | "MODEL_HAS_NO_PRIMARY_KEY" | "PRIMARY_KEY_NOT_FOUND" | "SQLITE_ONLY_SUPPORTS_SERIALIZABLE_ISOLATION_LEVEL" | "MUST_CALL_BUILD_CTE_AT_LEAST_ONCE" | "REGEXP_NOT_SUPPORTED_IN_SQLITE" | "MANY_TO_MANY_RELATION_MUST_HAVE_A_THROUGH_MODEL" | "INSERT_FAILED" | "MULTIPLE_PRIMARY_KEYS_NOT_ALLOWED" | "FILE_NOT_A_SQL_OR_TXT_FILE" | "CONNECTION_NOT_ESTABLISHED" | "TRANSACTION_NOT_ACTIVE" | "DEVELOPMENT_ERROR" | "MIGRATION_MODULE_NOT_FOUND" | "DRIVER_NOT_FOUND" | "FILE_NOT_FOUND_OR_NOT_ACCESSIBLE" | "ENV_NOT_SET" | "REQUIRED_VALUE_NOT_SET" | "SET_FAILED" | "GET_FAILED" | "REFERENCES_OPTION_REQUIRED" | "DELETE_FAILED" | "INVALID_DEFAULT_VALUE" | "DISCONNECT_FAILED" | "FLUSH_FAILED" | "LEFT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "RIGHT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "MODEL_HAS_NO_PRIMARY_KEY" | "GLOBAL_TRANSACTION_ALREADY_STARTED" | "GLOBAL_TRANSACTION_NOT_STARTED" | "MYSQL_REQUIRES_TABLE_NAME_FOR_INDEX_DROP" | "INVALID_DATE_OBJECT" | "INVALID_DATE_STRING" | "FAILED_TO_PARSE_DATE" | "MIGRATION_MODULE_REQUIRES_TS_NODE" | "FAILED_TO_ENCRYPT_SYMMETRICALLY" | "FAILED_TO_DECRYPT_SYMMETRICALLY" | "FAILED_TO_ENCRYPT_ASYMMETRICALLY" | "FAILED_TO_DECRYPT_ASYMMETRICALLY" | "UNSUPPORTED_RELATION_TYPE" | "LPUSH_FAILED" | "RPUSH_FAILED" | "LPOP_FAILED" | "RPOP_FAILED" | "LRANGE_FAILED" | "LLEN_FAILED" | "HSET_FAILED" | "HMSET_FAILED" | "HGET_FAILED" | "HGETALL_FAILED" | "HMGET_FAILED" | "HDEL_FAILED" | "HEXISTS_FAILED" | "HKEYS_FAILED" | "HLEN_FAILED" | "SADD_FAILED" | "SMEMBERS_FAILED" | "SREM_FAILED" | "SISMEMBER_FAILED" | "SCARD_FAILED" | "SINTER_FAILED" | "SUNION_FAILED" | "SDIFF_FAILED" | "ZADD_FAILED" | "ZRANGE_FAILED" | "ZREVRANGE_FAILED" | "ZREM_FAILED" | "ZSCORE_FAILED" | "ZCARD_FAILED" | "SUBSCRIBE_FAILED" | "UNSUBSCRIBE_FAILED" | "PUBLISH_FAILED" | "PSUBSCRIBE_FAILED" | "PUNSUBSCRIBE_FAILED" | "EXISTS_FAILED" | "EXPIRE_FAILED" | "EXPIREAT_FAILED" | "PEXPIRE_FAILED" | "TTL_FAILED" | "PTTL_FAILED" | "PERSIST_FAILED" | "KEYS_FAILED" | "RENAME_FAILED" | "TYPE_FAILED" | "SCAN_FAILED" | "ADMINJS_NOT_ENABLED" | "ADMINJS_INITIALIZATION_FAILED" | "ADMINJS_NO_MODELS_PROVIDED";
7989
+ type HysteriaErrorCode = "VALIDATION_ERROR" | "CONNECTION_ALREADY_ESTABLISHED" | `UNSUPPORTED_ISOLATION_LEVEL_${string}` | "ROW_NOT_FOUND" | `UNSUPPORTED_DATABASE_TYPE_${string}` | `RELATION_TYPE_NOT_SUPPORTED_${string}` | `NOT_SUPPORTED_IN_${string}` | `RELATION_NOT_FOUND_IN_MODEL_${string}` | `UNKNOWN_RELATION_TYPE_${string}` | `DISTINCT_ON_NOT_SUPPORTED_IN_${string}` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA` | `CONFLICT_COLUMNS_NOT_PRESENT_IN_DATA_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_HAS_ONE_RELATION_${string}` | `FOREIGN_KEY_VALUES_MISSING_FOR_BELONGS_TO_RELATION_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_HAS_MANY_RELATION_${string}` | `MANY_TO_MANY_RELATION_NOT_FOUND_FOR_RELATED_MODEL_${string}` | `PRIMARY_KEY_VALUES_MISSING_FOR_MANY_TO_MANY_RELATION_${string}` | `RELATED_MODEL_DOES_NOT_HAVE_A_PRIMARY_KEY_${string}` | `FOR_SHARE_NOT_SUPPORTED_IN_${string}` | `SKIP_LOCKED_NOT_SUPPORTED_IN_${string}` | `LOCK_FOR_UPDATE_NOT_SUPPORTED_${string}` | `KEY_${string}_HAS_NO_HANDLER_IN_CACHE_KEYS_CONFIG` | `CACHE_ADAPTER_NOT_CONFIGURED` | `SQLITE_NOT_SUPPORTED` | `COCKROACHDB_NOT_SUPPORTED` | `RELATION_NOT_FOUND` | `POSTGRES_TABLE_REQUIRED` | `MODEL_HAS_NO_PRIMARY_KEY_VALUE` | `RELATION_NOT_MANY_TO_MANY` | "MATERIALIZED_CTE_NOT_SUPPORTED" | "DUPLICATE_MODEL_KEYS_WHILE_INSTANTIATING_MODELS" | "INVALID_ONE_PARAMETER_WHERE_CONDITION" | "INVALID_PAGINATION_PARAMETERS" | "MISSING_ALIAS_FOR_SUBQUERY" | "MODEL_HAS_NO_PRIMARY_KEY" | "PRIMARY_KEY_NOT_FOUND" | "SQLITE_ONLY_SUPPORTS_SERIALIZABLE_ISOLATION_LEVEL" | "MUST_CALL_BUILD_CTE_AT_LEAST_ONCE" | "REGEXP_NOT_SUPPORTED_IN_SQLITE" | "MANY_TO_MANY_RELATION_MUST_HAVE_A_THROUGH_MODEL" | "INSERT_FAILED" | "MULTIPLE_PRIMARY_KEYS_NOT_ALLOWED" | "FILE_NOT_A_SQL_OR_TXT_FILE" | "CONNECTION_NOT_ESTABLISHED" | "TRANSACTION_NOT_ACTIVE" | "DEVELOPMENT_ERROR" | "MIGRATION_MODULE_NOT_FOUND" | "DRIVER_NOT_FOUND" | "FILE_NOT_FOUND_OR_NOT_ACCESSIBLE" | "ENV_NOT_SET" | "REQUIRED_VALUE_NOT_SET" | "SET_FAILED" | "GET_FAILED" | "REFERENCES_OPTION_REQUIRED" | "DELETE_FAILED" | "INVALID_DEFAULT_VALUE" | "DISCONNECT_FAILED" | "FLUSH_FAILED" | "LEFT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "RIGHT_COLUMN_NOT_PROVIDED_FOR_JOIN" | "MODEL_HAS_NO_PRIMARY_KEY" | "GLOBAL_TRANSACTION_ALREADY_STARTED" | "GLOBAL_TRANSACTION_NOT_STARTED" | "MYSQL_REQUIRES_TABLE_NAME_FOR_INDEX_DROP" | "INVALID_DATE_OBJECT" | "INVALID_DATE_STRING" | "FAILED_TO_PARSE_DATE" | "MIGRATION_MODULE_REQUIRES_TS_NODE" | "FAILED_TO_ENCRYPT_SYMMETRICALLY" | "FAILED_TO_DECRYPT_SYMMETRICALLY" | "FAILED_TO_ENCRYPT_ASYMMETRICALLY" | "FAILED_TO_DECRYPT_ASYMMETRICALLY" | "UNSUPPORTED_RELATION_TYPE" | "LPUSH_FAILED" | "RPUSH_FAILED" | "LPOP_FAILED" | "RPOP_FAILED" | "LRANGE_FAILED" | "LLEN_FAILED" | "HSET_FAILED" | "HMSET_FAILED" | "HGET_FAILED" | "HGETALL_FAILED" | "HMGET_FAILED" | "HDEL_FAILED" | "HEXISTS_FAILED" | "HKEYS_FAILED" | "HLEN_FAILED" | "SADD_FAILED" | "SMEMBERS_FAILED" | "SREM_FAILED" | "SISMEMBER_FAILED" | "SCARD_FAILED" | "SINTER_FAILED" | "SUNION_FAILED" | "SDIFF_FAILED" | "ZADD_FAILED" | "ZRANGE_FAILED" | "ZREVRANGE_FAILED" | "ZREM_FAILED" | "ZSCORE_FAILED" | "ZCARD_FAILED" | "SUBSCRIBE_FAILED" | "UNSUBSCRIBE_FAILED" | "PUBLISH_FAILED" | "PSUBSCRIBE_FAILED" | "PUNSUBSCRIBE_FAILED" | "EXISTS_FAILED" | "EXPIRE_FAILED" | "EXPIREAT_FAILED" | "PEXPIRE_FAILED" | "TTL_FAILED" | "PTTL_FAILED" | "PERSIST_FAILED" | "KEYS_FAILED" | "RENAME_FAILED" | "TYPE_FAILED" | "SCAN_FAILED" | "ADMINJS_NOT_ENABLED" | "ADMINJS_INITIALIZATION_FAILED" | "ADMINJS_NO_MODELS_PROVIDED" | `SCOPE_NOT_FOUND_${string}`;
7998
7990
 
7999
7991
  declare class HysteriaError extends Error {
8000
7992
  code: HysteriaErrorCode;
@@ -8002,6 +7994,56 @@ declare class HysteriaError extends Error {
8002
7994
  error?: Error;
8003
7995
  constructor(caller: string, code: HysteriaErrorCode, error?: Error);
8004
7996
  }
7997
+ declare class ValidationError extends HysteriaError {
7998
+ errors: Record<string, string[]>;
7999
+ constructor(errors: Record<string, string[]>);
8000
+ }
8001
+
8002
+ /**
8003
+ * @description Field is required and will throw if not provided
8004
+ * @throws HysteriaError with code VALIDATION_ERROR
8005
+ */
8006
+ declare const required: Validator;
8007
+ /**
8008
+ * @description Field must have a minimum length, null is allowed
8009
+ * @throws HysteriaError with code VALIDATION_ERROR
8010
+ */
8011
+ declare const minLength: (min: number) => Validator;
8012
+ /**
8013
+ * @description Field must have a maximum length, null is allowed
8014
+ * @throws HysteriaError with code VALIDATION_ERROR
8015
+ */
8016
+ declare const maxLength: (max: number) => Validator;
8017
+ /**
8018
+ * @description Field must have a minimum value, null is allowed
8019
+ * @throws HysteriaError with code VALIDATION_ERROR
8020
+ */
8021
+ declare const min: (minValue: number) => Validator;
8022
+ /**
8023
+ * @description Field must have a maximum value, null is allowed
8024
+ * @throws HysteriaError with code VALIDATION_ERROR
8025
+ */
8026
+ declare const max: (maxValue: number) => Validator;
8027
+ /**
8028
+ * @description Field must match a regex, null is allowed
8029
+ * @throws HysteriaError with code VALIDATION_ERROR
8030
+ */
8031
+ declare const pattern: (regex: RegExp) => Validator;
8032
+ /**
8033
+ * @description Field must be a valid email, null is allowed
8034
+ * @throws HysteriaError with code VALIDATION_ERROR
8035
+ */
8036
+ declare const email: Validator;
8037
+ /**
8038
+ * @description Field must be a valid url, null is allowed
8039
+ * @throws HysteriaError with code VALIDATION_ERROR
8040
+ */
8041
+ declare const url: Validator;
8042
+ /**
8043
+ * @description Field must be a valid enum value, null is allowed
8044
+ * @throws HysteriaError with code VALIDATION_ERROR
8045
+ */
8046
+ declare const enumValidator: (allowed: readonly string[]) => Validator;
8005
8047
 
8006
8048
  interface PropertyDef<T = unknown> {
8007
8049
  _phantom: T;
@@ -8082,4 +8124,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
8082
8124
  $id?: string;
8083
8125
  }>;
8084
8126
 
8085
- export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type BaseModelMethodOptions, BaseSeeder, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type InferPK, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn$1 as SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ViewDefinition, WriteOperation, type WriteReturnType, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, prop, RedisDataSource as redis, withPerformance };
8127
+ export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type BaseModelMethodOptions, BaseSeeder, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type InferPK, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type OneOptions, type Operation, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PingResult, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type QueryContext, type QueryContextWithDuration, type QueryObserver, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ValidationContext, ValidationError, type ValidationResult, type Validator, type ViewDefinition, WriteOperation, type WriteReturnType, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, required, url };