hysteria-orm 12.2.2 → 12.3.0

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
@@ -921,22 +921,24 @@ declare class UnionNode extends QueryNode {
921
921
  query: QueryNode | QueryNode[] | string;
922
922
  isAll: boolean;
923
923
  type: SetOperationType;
924
+ bindings?: any[];
924
925
  chainsWith: string;
925
926
  canKeywordBeSeenMultipleTimes: boolean;
926
927
  folder: string;
927
928
  file: string;
928
- constructor(query: QueryNode | QueryNode[] | string, isAll?: boolean, type?: SetOperationType);
929
+ constructor(query: QueryNode | QueryNode[] | string, isAll?: boolean, type?: SetOperationType, bindings?: any[]);
929
930
  }
930
931
 
931
932
  declare class WithNode extends QueryNode {
932
933
  alias: string;
933
934
  body: QueryNode | QueryNode[];
934
935
  clause: string;
936
+ columns?: string[];
935
937
  chainsWith: string;
936
938
  canKeywordBeSeenMultipleTimes: boolean;
937
939
  folder: string;
938
940
  file: string;
939
- constructor(clause: string, alias: string, body: QueryNode | QueryNode[]);
941
+ constructor(clause: string, alias: string, body: QueryNode | QueryNode[], columns?: string[]);
940
942
  }
941
943
 
942
944
  declare abstract class DataSource {
@@ -1929,6 +1931,12 @@ declare class InterpreterUtils {
1929
1931
  * @description Formats the from node for write operations removing the "from" keyword
1930
1932
  */
1931
1933
  getFromForWriteOperations(dbType: SqlDataSourceType, fromNode: FromNode): string;
1934
+ /**
1935
+ * @description Renders CTE nodes as a leading `with ...` clause. Used by writes
1936
+ * whose dialect places the CTE inside the statement body (INSERT) rather than
1937
+ * as a sibling node.
1938
+ */
1939
+ renderWithNodes(dbType: SqlDataSourceType, withNodes: WithNode[] | undefined, startIndex: number): ReturnType<typeof AstParser.prototype.parse>;
1932
1940
  }
1933
1941
 
1934
1942
  /**
@@ -1972,6 +1980,48 @@ declare class WriteOperation<T> implements PromiseLike<T> {
1972
1980
  unWrap(): ReturnType<typeof AstParser.prototype.parse>;
1973
1981
  }
1974
1982
 
1983
+ type InsertConflictMode = "update" | "ignore";
1984
+ type InsertConflictConfig = {
1985
+ conflictColumns: string[];
1986
+ mode: InsertConflictMode;
1987
+ columnsToUpdate: string[];
1988
+ };
1989
+ /**
1990
+ * @description A WriteOperation for inserts that can be given a conflict action
1991
+ * (`onConflict(...).merge()` or `.ignore()`) before it is awaited.
1992
+ */
1993
+ declare class InsertWriteOperation<T, K extends string = string> extends WriteOperation<T> {
1994
+ private conflictState;
1995
+ private conflictColumns;
1996
+ private readonly commit;
1997
+ private readonly insertColumns;
1998
+ private readonly caller;
1999
+ constructor(unWrapFn: () => ReturnType<typeof AstParser.prototype.parse>, toSqlFn: () => ReturnType<typeof AstParser.prototype.parse>, toQueryFn: () => string, executor: () => Promise<T>, commit: (config: InsertConflictConfig) => void, insertColumns: readonly string[], caller: string);
2000
+ /**
2001
+ * @description Sets the column(s) that identify a conflict
2002
+ * @description With no arguments the conflict has no explicit target, which is
2003
+ * only valid with `ignore()`
2004
+ * @description Must be followed by `merge()` or `ignore()`
2005
+ */
2006
+ onConflict(): this;
2007
+ onConflict(column: K): this;
2008
+ onConflict(columns: K[]): this;
2009
+ /**
2010
+ * @description Updates the inserted columns when the conflict target already exists
2011
+ * @description Without arguments every inserted column except the conflict target is updated
2012
+ */
2013
+ merge(): this;
2014
+ merge(column: K): this;
2015
+ merge(columns: K[]): this;
2016
+ /**
2017
+ * @description Leaves the existing row untouched when the conflict target already exists
2018
+ * @description Works with or without an explicit conflict target
2019
+ */
2020
+ ignore(): this;
2021
+ private requireConflictTarget;
2022
+ private commitConflict;
2023
+ }
2024
+
1975
2025
  type TransactionIsolationLevel = "READ UNCOMMITTED" | "READ COMMITTED" | "REPEATABLE READ" | "SERIALIZABLE";
1976
2026
  type StartTransactionOptions = {
1977
2027
  isolationLevel?: TransactionIsolationLevel;
@@ -2076,6 +2126,21 @@ type ModelDataProperties = Pick<Model, ExcludeMethods<Model>>;
2076
2126
  * Includes only data columns from the model, excluding foreign keys and relation accessors.
2077
2127
  */
2078
2128
  type ModelWithoutRelations<T extends Model> = Pick<Omit<T, "*">, ExcludeRelations<Omit<T, "*">>> & ModelDataProperties;
2129
+ /**
2130
+ * A JSON mutation helper writes a path rather than a value, so it is accepted only
2131
+ * where the column is JSON: `unknown` from an untyped `col.json()`, or an object
2132
+ * type from a structured `col.jsonb<T>()`.
2133
+ */
2134
+ type JsonMutationFor<V> = [unknown] extends [NonNullable<V>] ? JsonMutationNode : [NonNullable<V>] extends [object] ? JsonMutationNode : never;
2135
+ /**
2136
+ * Values accepted by a model insert or update: the column's own type, or an
2137
+ * expression node such as `sql.rawStatement("LOWER(email)")`. The JSON mutation
2138
+ * helpers (`sql.jsonSet`, `sql.jsonInsert`, `sql.jsonRemove`) are limited to JSON
2139
+ * columns, since they emit a path write rather than a value.
2140
+ */
2141
+ type ModelWriteData<T extends Model> = {
2142
+ [K in keyof ModelWithoutRelations<T>]?: ModelWithoutRelations<T>[K] | RawNode | SqlFuncNode | JsonMutationFor<ModelWithoutRelations<T>[K]>;
2143
+ };
2079
2144
  /**
2080
2145
  * Return type for Model query/mutation methods.
2081
2146
  * Represents data-only properties without any business logic.
@@ -2197,17 +2262,25 @@ declare class ModelManager<T extends Model> {
2197
2262
  * @throws {HysteriaError} if the model has no primary key
2198
2263
  */
2199
2264
  findOneByPrimaryKey(value: string | number, returning?: ModelKey<T>[]): Promise<ModelWithoutRelations<T> | null>;
2265
+ /**
2266
+ * @description Places the CTEs ahead of the insert, except on MySQL/MariaDB which only
2267
+ * accept them inline after the column list (rendered by the insert interpreter).
2268
+ */
2269
+ private withInsertNodes;
2200
2270
  /**
2201
2271
  * @description Creates a new record in the database
2202
2272
  * @returns WriteOperation that executes when awaited
2203
2273
  */
2204
- insert(model: Partial<T>, options?: InsertOptions<T>): WriteOperation<ModelWithoutRelations<T>>;
2274
+ insert(model: ModelWriteData<T>, options?: InsertOptions<T>): InsertWriteOperation<ModelWithoutRelations<T>>;
2205
2275
  /**
2206
2276
  * @description Creates multiple records in the database
2207
2277
  * @returns WriteOperation that executes when awaited
2208
2278
  */
2209
- insertMany(models: Partial<T>[], options?: InsertOptions<T>): WriteOperation<ModelWithoutRelations<T>[]>;
2279
+ insertMany(models: ModelWriteData<T>[], options?: InsertOptions<T>): InsertWriteOperation<ModelWithoutRelations<T>[]>;
2280
+ private insertManyInternal;
2210
2281
  upsertMany(conflictColumns: string[], columnsToUpdate: string[], data: ModelWithoutRelations<T>[], options?: UpsertOptions<T>): WriteOperation<ModelWithoutRelations<T>[]>;
2282
+ private executeInsertConflict;
2283
+ private refetchByConflictColumn;
2211
2284
  /**
2212
2285
  * @description Executes a MERGE statement for MSSQL upsert operations
2213
2286
  */
@@ -2290,16 +2363,28 @@ type TableForeignKeyInfo = {
2290
2363
  onUpdate?: string | null;
2291
2364
  };
2292
2365
 
2366
+ type InsertNodeOptions = {
2367
+ withNodes?: WithNode[];
2368
+ source?: QueryNode[];
2369
+ targetColumns?: string[];
2370
+ ignoreInto?: boolean;
2371
+ disambiguateSource?: boolean;
2372
+ };
2293
2373
  declare class InsertNode extends QueryNode {
2294
2374
  fromNode: FromNode;
2295
2375
  records: Record<string, any>[];
2296
2376
  returning?: string[];
2297
2377
  disableReturning: boolean;
2378
+ withNodes?: WithNode[];
2379
+ source?: QueryNode[];
2380
+ targetColumns?: string[];
2381
+ ignoreInto: boolean;
2382
+ disambiguateSource: boolean;
2298
2383
  chainsWith: string;
2299
2384
  canKeywordBeSeenMultipleTimes: boolean;
2300
2385
  folder: string;
2301
2386
  file: string;
2302
- constructor(fromNode: FromNode, records?: Record<string, any>[], returning?: string[], disableReturning?: boolean, isRawValue?: boolean);
2387
+ constructor(fromNode: FromNode, records?: Record<string, any>[], returning?: string[], disableReturning?: boolean, isRawValue?: boolean, options?: InsertNodeOptions);
2303
2388
  }
2304
2389
 
2305
2390
  declare class OnDuplicateNode extends QueryNode {
@@ -2333,13 +2418,19 @@ declare class ReturningNode extends QueryNode {
2333
2418
 
2334
2419
  type UnionCallBack<T extends Model> = (queryBuilder: QueryBuilder<T>) => QueryBuilder<T>;
2335
2420
 
2421
+ type TruncateOptions = {
2422
+ cascade?: boolean;
2423
+ restartIdentity?: boolean;
2424
+ continueIdentity?: boolean;
2425
+ };
2336
2426
  declare class TruncateNode extends QueryNode {
2337
2427
  fromNode: FromNode | string;
2428
+ options?: TruncateOptions;
2338
2429
  chainsWith: string;
2339
2430
  canKeywordBeSeenMultipleTimes: boolean;
2340
2431
  folder: string;
2341
2432
  file: string;
2342
- constructor(fromNode: FromNode | string, isRawValue?: boolean);
2433
+ constructor(fromNode: FromNode | string, isRawValue?: boolean, options?: TruncateOptions);
2343
2434
  }
2344
2435
 
2345
2436
  declare class UpdateNode extends QueryNode {
@@ -2919,7 +3010,9 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
2919
3010
  protected _interpreterUtils: InterpreterUtils | null;
2920
3011
  protected get interpreterUtils(): InterpreterUtils;
2921
3012
  protected insertNode: InsertNode | null;
3013
+ protected insertNodeSource: QueryNode[] | undefined;
2922
3014
  protected onDuplicateNode: OnDuplicateNode | null;
3015
+ protected insertConflictConfig: InsertConflictConfig | null;
2923
3016
  protected updateNode: UpdateNode | null;
2924
3017
  protected deleteNode: DeleteNode | null;
2925
3018
  protected returningNode: ReturningNode | null;
@@ -3188,12 +3281,12 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3188
3281
  /**
3189
3282
  * @description Adds an INTERSECT to the query (keeps only rows present in both queries).
3190
3283
  */
3191
- intersect(query: string): this;
3284
+ intersect(query: string, bindings?: any[]): this;
3192
3285
  intersect(cb: UnionCallBack<T>): this;
3193
3286
  /**
3194
3287
  * @description Adds an EXCEPT to the query (keeps rows from the first query not present in the second).
3195
3288
  */
3196
- except(query: string): this;
3289
+ except(query: string, bindings?: any[]): this;
3197
3290
  except(cb: UnionCallBack<T>): this;
3198
3291
  private resolveSetOperationNodes;
3199
3292
  /**
@@ -3275,8 +3368,10 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3275
3368
  fromRaw(raw: string, bindings?: any[]): this;
3276
3369
  /**
3277
3370
  * @description Adds a CTE to the query using a callback to build the subquery.
3371
+ * @param columns - Optional explicit column list for the CTE (`with t (a, b) as (...)`)
3278
3372
  */
3279
3373
  with(alias: string, cb: (qb: QueryBuilder<T>) => void | SubQueryable): this;
3374
+ with(alias: string, columns: string[], cb: (qb: QueryBuilder<T>) => void | SubQueryable): this;
3280
3375
  /**
3281
3376
  * @description Adds a recursive CTE to the query using a callback to build the subquery.
3282
3377
  * @mssql not supported
@@ -3299,15 +3394,15 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3299
3394
  * @param returning - The columns to return from the query, only supported by postgres and cockroachdb - default is "*"
3300
3395
  * @returns WriteOperation that executes when awaited
3301
3396
  */
3302
- insert(data: Record<string, WriteQueryParam>, returning: string[]): WriteOperation<T>;
3303
- insert(data: Record<string, WriteQueryParam>): WriteOperation<void>;
3397
+ insert(data: Record<string, WriteQueryParam>, returning: string[]): InsertWriteOperation<T>;
3398
+ insert(data: Record<string, WriteQueryParam>): InsertWriteOperation<void>;
3304
3399
  /**
3305
3400
  * @description Insert multiple records into a table
3306
3401
  * @param returning - The columns to return from the query, only supported by postgres and cockroachdb - default is "*"
3307
3402
  * @returns WriteOperation that executes when awaited
3308
3403
  */
3309
- insertMany(data: Record<string, WriteQueryParam>[], returning: string[]): WriteOperation<T[]>;
3310
- insertMany(data: Record<string, WriteQueryParam>[]): WriteOperation<void>;
3404
+ insertMany(data: Record<string, WriteQueryParam>[], returning: string[]): InsertWriteOperation<T[]>;
3405
+ insertMany(data: Record<string, WriteQueryParam>[]): InsertWriteOperation<void>;
3311
3406
  /**
3312
3407
  * @description Updates or creates a new record using upsert functionality
3313
3408
  * @param data The data to insert or update
@@ -3325,6 +3420,18 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3325
3420
  * @returns WriteOperation that executes when awaited
3326
3421
  */
3327
3422
  upsertMany<O extends Record<string, any>>(conflictColumns: string[], columnsToUpdate: string[], data: O[], options?: UpsertOptionsRawBuilder): WriteOperation<T[]>;
3423
+ private buildRawUpsert;
3424
+ private buildInsertConflictCommit;
3425
+ /**
3426
+ * @description Inserts the rows produced by a SELECT (or a CTE feeding one) into the table.
3427
+ * @param targetColumns - Optional destination column list; positional when omitted
3428
+ * @param source - A builder (or callback) whose SELECT becomes the insert source
3429
+ * @returns InsertWriteOperation, so `onConflict(...).merge()/.ignore()` chains onto it
3430
+ * @warning Rows come from the database, so no validation, hooks or autoCreate columns run
3431
+ */
3432
+ insertFrom(source: QueryBuilder<any> | ((qb: QueryBuilder<any>) => QueryBuilder<any> | void)): InsertWriteOperation<T[]>;
3433
+ insertFrom<C extends string>(targetColumns: C[], source: QueryBuilder<any> | ((qb: QueryBuilder<any>) => QueryBuilder<any> | void)): InsertWriteOperation<T[]>;
3434
+ protected buildInsertFrom(sourceNodes: QueryNode[], targetColumns?: string[]): InsertWriteOperation<T[]>;
3328
3435
  /**
3329
3436
  * @description Executes a MERGE statement for MSSQL upsert operations (raw query builder)
3330
3437
  */
@@ -3347,10 +3454,11 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3347
3454
  protected withReturningNode<N>(nodes: N[]): (N | ReturningNode)[];
3348
3455
  /**
3349
3456
  * @description Deletes all records from a table
3457
+ * @param options - `RESTART IDENTITY` / `CONTINUE IDENTITY` / `CASCADE` (PostgreSQL and CockroachDB only)
3350
3458
  * @warning This operation does not trigger any hook
3351
3459
  * @returns WriteOperation that executes when awaited
3352
3460
  */
3353
- truncate(): WriteOperation<void>;
3461
+ truncate(options?: TruncateOptions): WriteOperation<void>;
3354
3462
  /**
3355
3463
  * @description Deletes records from a table
3356
3464
  * @param returning - Optional array of column names to return from the deleted rows.
@@ -3406,6 +3514,17 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3406
3514
  * @description Removes any with query
3407
3515
  */
3408
3516
  clearWithQuery(): this;
3517
+ /**
3518
+ * @description Rejects clause state that would otherwise be silently dropped on a
3519
+ * write. Thrown at call time so the failure points at the builder call.
3520
+ * @param allowOrderByLimit - MySQL/MariaDB accept ORDER BY / LIMIT on UPDATE and DELETE
3521
+ */
3522
+ protected assertWriteClausesSupported(method: string, allowOrderByLimit?: boolean, allowCte?: boolean): void;
3523
+ /**
3524
+ * @description Single source of truth for a write statement's node list. Preview
3525
+ * (`extractQueryNodes`) and execution both go through it so they cannot diverge.
3526
+ */
3527
+ protected extractWriteNodes(): QueryNode[];
3409
3528
  extractQueryNodes(): QueryNode[];
3410
3529
  protected clearForFunctions(): this;
3411
3530
  /**
@@ -6285,6 +6404,7 @@ type UpsertOptions<T extends Model> = {
6285
6404
  };
6286
6405
  type InsertOptions<T extends Model> = {
6287
6406
  returning?: ReturningKey<T>[];
6407
+ withNodes?: WithNode[];
6288
6408
  };
6289
6409
  type ExcludeRelations<T> = {
6290
6410
  [K in keyof T]: K extends "__tableName" ? never : T[K] extends NullableAndUndefinable<Model> | NullableAndUndefinable<Model[]> | ((...args: any[]) => any) ? never : K;
@@ -6909,17 +7029,26 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6909
7029
  /**
6910
7030
  * @description Inserts a new record into the database.
6911
7031
  */
6912
- insert<const Ret extends readonly (RawModelKey<T> | "*")[] = never[]>(modelData: Partial<ModelWithoutRelations<T>>, options?: {
7032
+ insert<const Ret extends readonly (RawModelKey<T> | "*")[] = never[]>(modelData: ModelWriteData<T>, options?: {
6913
7033
  returning?: Ret;
6914
7034
  trx?: Transaction;
6915
- }): WriteOperation<ReturningResult<T, Ret>>;
7035
+ }): InsertWriteOperation<ReturningResult<T, Ret>, Extract<ModelKey<T>, string>>;
6916
7036
  /**
6917
7037
  * @description Inserts multiple records into the database.
6918
7038
  */
6919
- insertMany<const Ret extends readonly (RawModelKey<T> | "*")[] = never[]>(modelsData: Partial<ModelWithoutRelations<T>>[], options?: {
7039
+ insertMany<const Ret extends readonly (RawModelKey<T> | "*")[] = never[]>(modelsData: ModelWriteData<T>[], options?: {
6920
7040
  returning?: Ret;
6921
7041
  trx?: Transaction;
6922
- }): WriteOperation<ReturningResultMany<T, Ret>>;
7042
+ }): InsertWriteOperation<ReturningResultMany<T, Ret>, Extract<ModelKey<T>, string>>;
7043
+ /**
7044
+ * @description Inserts the rows produced by a SELECT (or a CTE feeding one) into the table.
7045
+ * @param targetColumns - Optional destination model columns; positional when omitted
7046
+ * @param source - A model builder (or callback) whose SELECT becomes the insert source
7047
+ * @returns InsertWriteOperation, so `onConflict(...).merge()/.ignore()` chains onto it
7048
+ * @warning Rows come from the database, so no validation, hooks or autoCreate columns run
7049
+ */
7050
+ insertFrom(source: ModelQueryBuilder<any> | ((qb: ModelQueryBuilder<any>) => ModelQueryBuilder<any> | void)): InsertWriteOperation<T[]>;
7051
+ insertFrom<C extends ModelKey<T>>(targetColumns: C[], source: ModelQueryBuilder<any> | ((qb: ModelQueryBuilder<any>) => ModelQueryBuilder<any> | void)): InsertWriteOperation<T[]>;
6923
7052
  /**
6924
7053
  * @description Upserts a record (insert or update on conflict).
6925
7054
  */
@@ -7017,8 +7146,9 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
7017
7146
  }): Promise<void>;
7018
7147
  /**
7019
7148
  * @description Truncates the table by deleting all records.
7149
+ * @param options - `RESTART IDENTITY` / `CONTINUE IDENTITY` / `CASCADE` (PostgreSQL and CockroachDB only)
7020
7150
  */
7021
- truncate(): WriteOperation<void>;
7151
+ truncate(options?: TruncateOptions): WriteOperation<void>;
7022
7152
  /**
7023
7153
  * @description Updates records matching the current query conditions.
7024
7154
  * @param data - The columns and values to update.
@@ -7026,7 +7156,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
7026
7156
  * @param options.returning - Columns to return from updated rows. Only supported on PostgreSQL, CockroachDB, SQLite, and MSSQL. Not available on MySQL or MariaDB.
7027
7157
  * @returns WriteOperation resolving to the number of affected rows, or the returned columns if `returning` is specified (supported databases only).
7028
7158
  */
7029
- update<const Ret extends ReturningParam<T, D> = never[]>(data: Partial<ModelWithoutRelations<T>>, options?: UpdateOptions & {
7159
+ update<const Ret extends ReturningParam<T, D> = never[]>(data: ModelWriteData<T>, options?: UpdateOptions & {
7030
7160
  returning?: Ret;
7031
7161
  }): WriteOperation<MutationReturningResult<T, Ret>>;
7032
7162
  softDelete(options?: SoftDeleteOptions<T>): WriteOperation<number>;
@@ -9162,7 +9292,7 @@ declare abstract class BaseSeeder {
9162
9292
  abstract run(): Promise<void>;
9163
9293
  }
9164
9294
 
9165
- 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_STRENGTH_NOT_SUPPORTED_IN_${string}` | "QUERY_TIMEOUT" | `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" | "NOT_MATERIALIZED_CTE_NOT_SUPPORTED" | "USING_REQUIRES_JOIN" | "USING_NOT_SUPPORTED_IN_MSSQL" | "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" | "ORDER_BY_REQUIRED" | "ORDER_BY_RAW_NOT_SUPPORTED" | "INVALID_SQL_COMMENT" | "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" | `BETTER_AUTH_MISSING_ID_${string}` | `BETTER_AUTH_INVALID_INCREMENT_${string}` | "ZOD_ENGINE_NOT_LOADED" | "ATOMIC_DATASOURCE_RESOLUTION_FAILED" | "ATOMIC_INVALID_METHOD" | "ATOMIC_CLS_DISABLED" | `SCOPE_NOT_FOUND_${string}`;
9295
+ 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_STRENGTH_NOT_SUPPORTED_IN_${string}` | "QUERY_TIMEOUT" | `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" | "NOT_MATERIALIZED_CTE_NOT_SUPPORTED" | "USING_REQUIRES_JOIN" | "USING_NOT_SUPPORTED_IN_MSSQL" | "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" | "ORDER_BY_REQUIRED" | "ORDER_BY_RAW_NOT_SUPPORTED" | "INVALID_SQL_COMMENT" | "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" | `BETTER_AUTH_MISSING_ID_${string}` | `BETTER_AUTH_INVALID_INCREMENT_${string}` | "ZOD_ENGINE_NOT_LOADED" | "ATOMIC_DATASOURCE_RESOLUTION_FAILED" | "ATOMIC_INVALID_METHOD" | "ATOMIC_CLS_DISABLED" | `SCOPE_NOT_FOUND_${string}` | "ON_CONFLICT_REQUIRES_MERGE_OR_IGNORE" | "MERGE_REQUIRES_ON_CONFLICT" | "ON_CONFLICT_COLUMNS_REQUIRED" | "JOIN_NOT_SUPPORTED_ON_WRITE" | "ORDER_BY_LIMIT_NOT_SUPPORTED_ON_WRITE" | "SELECT_ONLY_CLAUSE_ON_WRITE" | "CTE_NOT_SUPPORTED_ON_INSERT" | "CTE_NOT_SUPPORTED_ON_TRUNCATE" | "CTE_NOT_SUPPORTED_ON_WRITE" | "TRUNCATE_OPTION_NOT_SUPPORTED" | "UPDATE_REQUIRES_COLUMNS";
9166
9296
 
9167
9297
  declare class HysteriaError extends Error {
9168
9298
  code: HysteriaErrorCode;
@@ -9325,4 +9455,4 @@ type BetterAuthAdapterConfig = Partial<Pick<AdapterFactoryConfig, "usePlural" |
9325
9455
  */
9326
9456
  declare function betterAuthAdapter(sql: SqlDataSource, config?: BetterAuthAdapterConfig): (options: BetterAuthOptions) => DBAdapter;
9327
9457
 
9328
- export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AllowedDrivers, type AnyModelConstructor, type AnySqlDataSourceInput, type AtomicOptions, type BaseModelMethodOptions, BaseSeeder, type BeginTransactionOptions, type BetterAuthAdapterConfig, type BuildSelectType, type BuildSingleSelectType, type BuiltinDriverName, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColComputedOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ComputedColumnDef, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type DriverAdapter, type DriverAdapterFactory, type DriverAdapterFactoryContext, type EndTransactionOptions, type ExcludeMethods, type ExecuteOptions, type ExtractColumnName, type ExtractSourceColumn, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, type HysteriaErrorCode, InMemoryAdapter, type InferPK, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsEnvironmentValue, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, Migration, type MigrationConfig, type MigrationConfigBase, type MigrationLockConfig, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelStream, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlComment, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MySqlComment, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type Operation, type PgComment, type PgPoolClientInstance, type PingResult, type PlatformAdapter, type PlatformFs, type PlatformPath, PlatformUnsupportedError, 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 ResolvedJsEnvironment, 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, type SqlComment, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, SqlFuncNode, type SqlFuncRenderer, type SqlHint, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteComment, 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, atomic, betterAuthAdapter, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, loadPlatform, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, registerDriverAdapter, registerSqlFuncRenderer, required, sqlFunc, url };
9458
+ export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AllowedDrivers, type AnyModelConstructor, type AnySqlDataSourceInput, type AtomicOptions, type BaseModelMethodOptions, BaseSeeder, type BeginTransactionOptions, type BetterAuthAdapterConfig, type BuildSelectType, type BuildSingleSelectType, type BuiltinDriverName, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColComputedOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ComputedColumnDef, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type DriverAdapter, type DriverAdapterFactory, type DriverAdapterFactoryContext, type EndTransactionOptions, type ExcludeMethods, type ExecuteOptions, type ExtractColumnName, type ExtractSourceColumn, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, type HysteriaErrorCode, InMemoryAdapter, type InferPK, type InsertConflictConfig, type InsertConflictMode, InsertWriteOperation, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsEnvironmentValue, type JsonMutationFor, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, Migration, type MigrationConfig, type MigrationConfigBase, type MigrationLockConfig, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelStream, type ModelWithoutRelations, type ModelWriteData, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlComment, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MySqlComment, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type Operation, type PgComment, type PgPoolClientInstance, type PingResult, type PlatformAdapter, type PlatformFs, type PlatformPath, PlatformUnsupportedError, 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 ResolvedJsEnvironment, 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, type SqlComment, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, SqlFuncNode, type SqlFuncRenderer, type SqlHint, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteComment, 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, atomic, betterAuthAdapter, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, loadPlatform, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, registerDriverAdapter, registerSqlFuncRenderer, required, sqlFunc, url };