hysteria-orm 11.0.3 → 11.0.5

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.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { z } from 'zod';
1
2
  import { PassThrough } from 'node:stream';
2
3
  import * as mssql from 'mssql';
3
4
  import { config, Transaction as Transaction$1, IResult } from 'mssql';
@@ -694,7 +695,7 @@ interface SqliteDataSourceInput extends CommonDataSourceInput {
694
695
  * @description The filename of the database file for SQLite
695
696
  * @default ":memory:"
696
697
  */
697
- readonly database?: ":memory:" | (string & {});
698
+ readonly database?: ":memory:" | "file::memory:?cache=shared" | (string & {});
698
699
  }
699
700
  interface NotNullableSqliteDataSourceInput extends SqliteDataSourceInput {
700
701
  readonly type?: "sqlite";
@@ -734,6 +735,26 @@ type ConnectionPolicies = {
734
735
  * and programmatic models created via `defineModel`.
735
736
  */
736
737
  type SqlDataSourceModel = AnyModelConstructor;
738
+ /**
739
+ * @description Migration lock configuration
740
+ */
741
+ type MigrationLockConfig = {
742
+ /**
743
+ * @description Enable/disable migration locking
744
+ * @default true
745
+ */
746
+ enabled?: boolean;
747
+ /**
748
+ * @description Lock timeout in milliseconds for migration advisory lock acquisition
749
+ * @default 30000
750
+ */
751
+ timeout?: number;
752
+ /**
753
+ * @description Custom lock key value - can be string, number, or function returning string|number
754
+ * @default "hysteria_migration_lock"
755
+ */
756
+ customValue?: string | number | (() => string | number);
757
+ };
737
758
  /**
738
759
  * @description Base migration configuration options available for all databases
739
760
  */
@@ -749,12 +770,13 @@ type MigrationConfigBase = {
749
770
  */
750
771
  tsconfig?: string;
751
772
  /**
752
- * @description Acquire advisory lock before running migrations to prevent concurrent execution, can be overridden in the cli command
773
+ * @description Migration lock configuration - can be boolean to enable/disable, or an object for advanced options
753
774
  * @default true
754
775
  */
755
- lock?: boolean;
776
+ lock?: boolean | MigrationLockConfig;
756
777
  /**
757
- * @description Lock timeout in milliseconds for migration advisory lock acquisition, can be overridden in the cli command
778
+ * @deprecated Use lock.timeout instead. Kept for backward compatibility.
779
+ * @description Lock timeout in milliseconds for migration advisory lock acquisition
758
780
  * @default 30000
759
781
  */
760
782
  lockTimeout?: number;
@@ -800,6 +822,13 @@ type SqlDataSourceInputBase<T extends Record<string, SqlDataSourceModel> = {}, C
800
822
  * @default false
801
823
  */
802
824
  readonly logs?: boolean | LoggerConfig;
825
+ /**
826
+ * @description Enable AsyncLocalStorage (CLS) for automatic transaction propagation.
827
+ * When enabled, queries inside `sql.transaction(callback)` automatically use the active
828
+ * transaction without explicit passing.
829
+ * @default true
830
+ */
831
+ readonly clsEnabled?: boolean;
803
832
  /**
804
833
  * @description The connection policies to use for the sql data source that are not configured in the driverOptions
805
834
  */
@@ -1802,6 +1831,93 @@ declare class SchemaBuilder implements PromiseLike<void> {
1802
1831
  * @description Returns true if the builder execution failed
1803
1832
  */
1804
1833
  hasFailed(): boolean;
1834
+ /**
1835
+ * @description Checks if a table exists in the database
1836
+ * @param tableName - The name of the table to check
1837
+ * @returns Promise<boolean> - true if table exists, false otherwise
1838
+ */
1839
+ hasTable(tableName: string): Promise<boolean>;
1840
+ /**
1841
+ * @description Checks if a column exists in a table
1842
+ * @param tableName - The name of the table
1843
+ * @param columnName - The name of the column to check
1844
+ * @returns Promise<boolean> - true if column exists in table, false otherwise
1845
+ */
1846
+ hasColumn(tableName: string, columnName: string): Promise<boolean>;
1847
+ /**
1848
+ * @description Checks if multiple columns exist in a table
1849
+ * @param tableName - The name of the table
1850
+ * @param columnNames - Array of column names to check
1851
+ * @returns Promise<boolean> - true if all columns exist in table, false otherwise
1852
+ */
1853
+ hasColumns(tableName: string, ...columnNames: string[]): Promise<boolean>;
1854
+ /**
1855
+ * @description Checks if an index exists on a table
1856
+ * @param tableName - The name of the table
1857
+ * @param indexName - The name of the index to check
1858
+ * @returns Promise<boolean> - true if index exists on table, false otherwise
1859
+ */
1860
+ hasIndex(tableName: string, indexName: string): Promise<boolean>;
1861
+ /**
1862
+ * @description Checks if a table has a primary key
1863
+ * @param tableName - The name of the table
1864
+ * @returns Promise<boolean> - true if table has primary key, false otherwise
1865
+ */
1866
+ hasPrimaryKey(tableName: string): Promise<boolean>;
1867
+ /**
1868
+ * @description Checks if a unique constraint exists on a table for given columns
1869
+ * @param tableName - The name of the table
1870
+ * @param columns - Array of column names (or single string) that form the unique constraint
1871
+ * @returns Promise<boolean> - true if unique constraint exists, false otherwise
1872
+ */
1873
+ hasUnique(tableName: string, columns: string[] | string): Promise<boolean>;
1874
+ /**
1875
+ * @description Checks if a foreign key constraint exists on a table for given columns
1876
+ * @param tableName - The name of the table
1877
+ * @param columns - Array of column names that form the foreign key
1878
+ * @returns Promise<boolean> - true if foreign key exists, false otherwise
1879
+ */
1880
+ hasForeignKey(tableName: string, columns: string[]): Promise<boolean>;
1881
+ /**
1882
+ * @description Checks if a check constraint exists on a table
1883
+ * @param tableName - The name of the table
1884
+ * @param constraintName - The name of the check constraint to check
1885
+ * @returns Promise<boolean> - true if check constraint exists, false otherwise
1886
+ */
1887
+ hasCheckConstraint(tableName: string, constraintName: string): Promise<boolean>;
1888
+ /**
1889
+ * @description Gets all table names in the database
1890
+ * @returns Promise<string[]> - Array of table names
1891
+ */
1892
+ getTables(): Promise<string[]>;
1893
+ /**
1894
+ * @description Gets all column names for a table
1895
+ * @param tableName - The name of the table
1896
+ * @returns Promise<string[]> - Array of column names
1897
+ */
1898
+ getColumnListing(tableName: string): Promise<string[]>;
1899
+ /**
1900
+ * @description Drops a table if it exists
1901
+ * @param table - The name of the table to drop
1902
+ * @returns this for chaining
1903
+ */
1904
+ dropTableIfExists(table: string): this;
1905
+ /**
1906
+ * @description Drops an index if it exists
1907
+ * @param indexName - The name of the index
1908
+ * @param table - Table name (required for existence check)
1909
+ * @returns Promise<void> - executes immediately, not chainable
1910
+ * @mysql requires table name for existence check
1911
+ */
1912
+ dropIndexIfExists(indexName: string, table: string): Promise<void>;
1913
+ /**
1914
+ * @description Renames a column in a table
1915
+ * @param tableName - The name of the table
1916
+ * @param oldName - The current column name
1917
+ * @param newName - The new column name
1918
+ * @returns this for chaining
1919
+ */
1920
+ renameColumn(tableName: string, oldName: string, newName: string): this;
1805
1921
  }
1806
1922
 
1807
1923
  interface IntrospectedColumn {
@@ -4082,82 +4198,71 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4082
4198
  private orWhereGroup;
4083
4199
  }
4084
4200
 
4085
- type JsonParam = Record<string, unknown> | any[];
4201
+ type DefaultJsonParam = Record<string, any> | any[];
4202
+ type JsonValueForColumn<T extends Model, K extends string> = K extends ModelKey<T> ? NonNullable<T[StripTablePrefix<K> & keyof T]> : DefaultJsonParam;
4086
4203
  declare class JsonQueryBuilder<T extends Model, S extends Record<string, any> = Record<string, any>> extends WhereQueryBuilder<T, S> {
4087
4204
  /**
4088
4205
  * @description Filters records matching exact JSON value.
4089
4206
  */
4090
- whereJson(column: ModelKey<T>, value: JsonParam): this;
4091
- whereJson(column: string, value: JsonParam): this;
4207
+ whereJson<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4092
4208
  /**
4093
4209
  * @description Filters records matching the given JSON value.
4094
4210
  * @mssql Partial JSON matching not supported - only exact matches work
4095
4211
  */
4096
- andWhereJson(column: ModelKey<T>, value: JsonParam): this;
4097
- andWhereJson(column: string, value: JsonParam): this;
4212
+ andWhereJson<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4098
4213
  /**
4099
4214
  * @description Filters records matching the given JSON value.
4100
4215
  * @mssql Partial JSON matching not supported - only exact matches work
4101
4216
  */
4102
- orWhereJson(column: ModelKey<T>, value: JsonParam): this;
4103
- orWhereJson(column: string, value: JsonParam): this;
4217
+ orWhereJson<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4104
4218
  /**
4105
4219
  * @description Filters records where JSON column does NOT contain the given value.
4106
4220
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
4107
4221
  * @mssql not supported - CHARINDEX cannot do partial JSON containment
4108
4222
  */
4109
- whereJsonNotContains(column: ModelKey<T>, value: JsonParam): this;
4110
- whereJsonNotContains(column: string, value: JsonParam): this;
4223
+ whereJsonNotContains<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4111
4224
  /**
4112
4225
  * @description Filters records where JSON column does NOT contain the given value (AND).
4113
4226
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
4114
4227
  * @mssql not supported - CHARINDEX cannot do partial JSON containment
4115
4228
  */
4116
- andWhereJsonNotContains(column: ModelKey<T>, value: JsonParam): this;
4117
- andWhereJsonNotContains(column: string, value: JsonParam): this;
4229
+ andWhereJsonNotContains<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4118
4230
  /**
4119
4231
  * @description Filters records where JSON column does NOT contain the given value (OR).
4120
4232
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
4121
4233
  * @mssql not supported - CHARINDEX cannot do partial JSON containment
4122
4234
  */
4123
- orWhereJsonNotContains(column: ModelKey<T>, value: JsonParam): this;
4124
- orWhereJsonNotContains(column: string, value: JsonParam): this;
4235
+ orWhereJsonNotContains<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4125
4236
  /**
4126
4237
  * @description Filters records where JSON column contains the given value.
4127
4238
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
4128
4239
  * @mssql not supported - CHARINDEX cannot do partial JSON containment
4129
4240
  */
4130
- whereJsonContains(column: ModelKey<T>, value: JsonParam): this;
4131
- whereJsonContains(column: string, value: JsonParam): this;
4241
+ whereJsonContains<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4132
4242
  /**
4133
4243
  * @description Filters records where JSON column contains the given value (AND).
4134
4244
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
4135
4245
  * @mssql not supported - CHARINDEX cannot do partial JSON containment
4136
4246
  */
4137
- andWhereJsonContains(column: ModelKey<T>, value: JsonParam): this;
4138
- andWhereJsonContains(column: string, value: JsonParam): this;
4247
+ andWhereJsonContains<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4139
4248
  /**
4140
4249
  * @description Filters records where JSON column contains the given value (OR).
4141
4250
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
4142
4251
  * @mssql not supported - CHARINDEX cannot do partial JSON containment
4143
4252
  */
4144
- orWhereJsonContains(column: ModelKey<T>, value: JsonParam): this;
4145
- orWhereJsonContains(column: string, value: JsonParam): this;
4253
+ orWhereJsonContains<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4146
4254
  /**
4147
4255
  * @description Filters records where JSON column does NOT match the given value.
4148
4256
  */
4149
- whereNotJson(column: ModelKey<T>, value: JsonParam): this;
4150
- whereNotJson(column: string, value: JsonParam): this;
4257
+ whereNotJson<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4151
4258
  /**
4152
4259
  * @description Filters records where JSON column does NOT match the given value (AND).
4153
4260
  */
4154
- andWhereNotJson(column: ModelKey<T>, value: JsonParam): this;
4155
- andWhereNotJson(column: string, value: JsonParam): this;
4261
+ andWhereNotJson<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4156
4262
  /**
4157
4263
  * @description Filters records where JSON column does NOT match the given value (OR).
4158
4264
  */
4159
- orWhereNotJson(column: ModelKey<T>, value: JsonParam): this;
4160
- orWhereNotJson(column: string, value: JsonParam): this;
4265
+ orWhereNotJson<K extends string>(column: K, value: JsonValueForColumn<T, K>): this;
4161
4266
  /**
4162
4267
  * @description Add a raw JSON filter expression.
4163
4268
  */
@@ -4801,6 +4906,15 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4801
4906
  * @description Options provided in the sql data source initialization
4802
4907
  */
4803
4908
  inputDetails: SqlDataSourceInput<D, T, C>;
4909
+ /**
4910
+ * @description Unique identifier shared across all clones of the same logical data source.
4911
+ * Used to verify ALS transactions belong to this instance.
4912
+ */
4913
+ id: string;
4914
+ /**
4915
+ * @description Whether AsyncLocalStorage (CLS) transaction auto-propagation is enabled.
4916
+ */
4917
+ private readonly clsEnabled;
4804
4918
  /**
4805
4919
  * @description Adapter for `useCache`, uses an in memory strategy by default
4806
4920
  */
@@ -4815,7 +4929,7 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4815
4929
  migrationConfig: {
4816
4930
  path: string;
4817
4931
  tsconfig?: string;
4818
- lock: boolean;
4932
+ lock: boolean | MigrationLockConfig;
4819
4933
  transactional: boolean;
4820
4934
  lockTimeout?: number;
4821
4935
  };
@@ -4838,6 +4952,10 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4838
4952
  * @description Cached AdminJS instance
4839
4953
  */
4840
4954
  private adminJsInstance?;
4955
+ /**
4956
+ * @description Optional zod instance for schema generation
4957
+ */
4958
+ zodEngine: typeof z | null;
4841
4959
  /**
4842
4960
  * @description Callback to handle slave server failures
4843
4961
  */
@@ -4931,6 +5049,11 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4931
5049
  * @returns A slave SqlDataSource instance or null if no slaves are available
4932
5050
  */
4933
5051
  getSlave(): SqlDataSource<D, T, C> | null;
5052
+ /**
5053
+ * @description Returns the SqlDataSource that should execute the next query,
5054
+ * respecting (in order): explicit global transaction, ALS transaction, then self.
5055
+ */
5056
+ getTransactionBoundSqlDataSource(): SqlDataSource | null;
4934
5057
  /**
4935
5058
  * @description Uses the cache adapter to get a value from the cache
4936
5059
  * @param key The key to get the value from
@@ -5033,6 +5156,9 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
5033
5156
  * @param cb if a callback is provided, it will execute the callback and commit or rollback the transaction based on the callback's success or failure
5034
5157
  * @param options.isolationLevel The isolation level to use for the transaction
5035
5158
  * @sqlite ignores the isolation level
5159
+ * @warning SQLite `:memory:` databases use `file::memory:?cache=shared`
5160
+ * to allow transaction connections to share the same in-memory database.
5161
+ * Without shared cache each connection would see an empty fresh database.
5036
5162
  */
5037
5163
  transaction(options?: StartTransactionOptions): Promise<Transaction>;
5038
5164
  transaction<T>(cb: (trx: Transaction) => Promise<T>, options?: StartTransactionOptions): Promise<T>;
@@ -5128,6 +5254,11 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
5128
5254
  * @description Returns the AdminJS configuration options
5129
5255
  */
5130
5256
  getAdminJsOptions(): AdminJsOptions | undefined;
5257
+ /**
5258
+ * @description Loads the zod engine into the data source
5259
+ * @param zod The zod namespace import
5260
+ */
5261
+ loadZodEngine(zod: typeof z): this;
5131
5262
  /**
5132
5263
  * @description Checks if AdminJS is enabled
5133
5264
  */
@@ -5136,6 +5267,71 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
5136
5267
  * @description Introspects table columns metadata
5137
5268
  */
5138
5269
  getTableInfo(table: string): Promise<TableColumnInfo[]>;
5270
+ /**
5271
+ * @description Checks if a table exists in the database
5272
+ * @param tableName - The name of the table to check
5273
+ * @returns Promise<boolean> - true if table exists, false otherwise
5274
+ */
5275
+ hasTable(tableName: string): Promise<boolean>;
5276
+ /**
5277
+ * @description Checks if a column exists in a table
5278
+ * @param tableName - The name of the table
5279
+ * @param columnName - The name of the column to check
5280
+ * @returns Promise<boolean> - true if column exists in table, false otherwise
5281
+ */
5282
+ hasColumn(tableName: string, columnName: string): Promise<boolean>;
5283
+ /**
5284
+ * @description Checks if multiple columns exist in a table
5285
+ * @param tableName - The name of the table
5286
+ * @param columnNames - Array of column names to check
5287
+ * @returns Promise<boolean> - true if all columns exist in table, false otherwise
5288
+ */
5289
+ hasColumns(tableName: string, ...columnNames: string[]): Promise<boolean>;
5290
+ /**
5291
+ * @description Checks if an index exists on a table
5292
+ * @param tableName - The name of the table
5293
+ * @param indexName - The name of the index to check
5294
+ * @returns Promise<boolean> - true if index exists on table, false otherwise
5295
+ */
5296
+ hasIndex(tableName: string, indexName: string): Promise<boolean>;
5297
+ /**
5298
+ * @description Checks if a table has a primary key
5299
+ * @param tableName - The name of the table
5300
+ * @returns Promise<boolean> - true if table has primary key, false otherwise
5301
+ */
5302
+ hasPrimaryKey(tableName: string): Promise<boolean>;
5303
+ /**
5304
+ * @description Checks if a unique constraint exists on a table for given columns
5305
+ * @param tableName - The name of the table
5306
+ * @param columns - Array of column names (or single string) that form the unique constraint
5307
+ * @returns Promise<boolean> - true if unique constraint exists, false otherwise
5308
+ */
5309
+ hasUnique(tableName: string, columns: string[] | string): Promise<boolean>;
5310
+ /**
5311
+ * @description Checks if a foreign key constraint exists on a table for given columns
5312
+ * @param tableName - The name of the table
5313
+ * @param columns - Array of column names that form the foreign key
5314
+ * @returns Promise<boolean> - true if foreign key exists, false otherwise
5315
+ */
5316
+ hasForeignKey(tableName: string, columns: string[]): Promise<boolean>;
5317
+ /**
5318
+ * @description Checks if a check constraint exists on a table
5319
+ * @param tableName - The name of the table
5320
+ * @param constraintName - The name of the check constraint to check
5321
+ * @returns Promise<boolean> - true if check constraint exists, false otherwise
5322
+ */
5323
+ hasCheckConstraint(tableName: string, constraintName: string): Promise<boolean>;
5324
+ /**
5325
+ * @description Gets all table names in the database
5326
+ * @returns Promise<string[]> - Array of table names
5327
+ */
5328
+ getTables(): Promise<string[]>;
5329
+ /**
5330
+ * @description Gets all column names for a table
5331
+ * @param tableName - The name of the table
5332
+ * @returns Promise<string[]> - Array of column names
5333
+ */
5334
+ getColumnListing(tableName: string): Promise<string[]>;
5139
5335
  /**
5140
5336
  * @description Introspects table indexes metadata
5141
5337
  */
@@ -6507,6 +6703,10 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6507
6703
  */
6508
6704
  declare abstract class Model<T extends Model<T> = any> extends Entity {
6509
6705
  private "*";
6706
+ /**
6707
+ * @description The zod instance to use for creating zod schemas, if not set, toZodSchema will throw an error
6708
+ */
6709
+ static zodEngine: typeof z | null;
6510
6710
  /**
6511
6711
  * @description The column used to soft delete a record, default is deletedAt
6512
6712
  */
@@ -7106,6 +7306,14 @@ type DefinedModel<T extends string, C extends Record<string, ColumnDef>, R exten
7106
7306
  beforeDelete?: (queryBuilder: ModelQueryBuilder<{
7107
7307
  readonly __tableName: T;
7108
7308
  } & InferColumns<C> & Model>) => Promise<void> | void;
7309
+ /**
7310
+ * Translates the model definition to a Zod schema.
7311
+ * @throws {HysteriaError} If the zod engine is not loaded. Call `sql.loadZodEngine(z)` first.
7312
+ * @returns A ZodObject representing the model's columns.
7313
+ */
7314
+ toZodSchema(): z.ZodObject<{
7315
+ [K in keyof C]: z.ZodType<InferColumns<C>[K]>;
7316
+ }>;
7109
7317
  } & ModelColumns<T, C>;
7110
7318
  /**
7111
7319
  * Maps a model's column definitions to their fully-qualified `"table.column"`
@@ -7256,6 +7464,14 @@ type HiddenViewStatics = HiddenModelStatics;
7256
7464
  type DefinedView<T extends string, C extends Record<string, ColumnDef>> = Omit<ConcreteModelStatics, HiddenViewStatics> & {
7257
7465
  readonly table: T;
7258
7466
  new (): InferModel<T, C, {}> & Model;
7467
+ /**
7468
+ * Translates the model definition to a Zod schema.
7469
+ * @throws {HysteriaError} If the zod engine is not loaded. Call `sql.loadZodEngine(z)` first.
7470
+ * @returns A ZodObject representing the model's columns.
7471
+ */
7472
+ toZodSchema(): z.ZodObject<{
7473
+ [K in keyof C]: z.ZodType<InferColumns<C>[K]>;
7474
+ }>;
7259
7475
  } & ModelColumns<T, C>;
7260
7476
 
7261
7477
  declare const col: ColNamespace;
@@ -7334,10 +7550,9 @@ declare function createSchema<M extends Record<string, AnyModelConstructor>, R e
7334
7550
  [K in keyof M]?: RelationDefinitions<any, any>;
7335
7551
  }>(models: M, relations?: R): CreateSchemaResult<M, R>;
7336
7552
  /**
7337
- * Creates a fully-typed read-only Model subclass backed by a SQL view.
7338
- *
7339
7553
  * The returned class works with `sql.from(View).many()` and other read operations.
7340
7554
  * Mutation operations (insert, update, delete) are not intended for views.
7555
+ * Does not create a real database view, this is just a shortcut for common query results
7341
7556
  *
7342
7557
  * @example
7343
7558
  * ```typescript
@@ -7987,7 +8202,7 @@ declare abstract class BaseSeeder {
7987
8202
  abstract run(): Promise<void>;
7988
8203
  }
7989
8204
 
7990
- 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}`;
8205
+ 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" | "ZOD_ENGINE_NOT_LOADED" | `SCOPE_NOT_FOUND_${string}`;
7991
8206
 
7992
8207
  declare class HysteriaError extends Error {
7993
8208
  code: HysteriaErrorCode;
@@ -8125,4 +8340,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
8125
8340
  $id?: string;
8126
8341
  }>;
8127
8342
 
8128
- 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 };
8343
+ 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 MigrationLockConfig, 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 };