hysteria-orm 10.1.8 → 10.2.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
@@ -712,6 +712,16 @@ type ForeignKeyOptions = CommonConstraintOptions & {
712
712
  };
713
713
  type CreateTableContext = "alter_table" | "create_table";
714
714
 
715
+ interface CacheAdapter {
716
+ get<T = void>(key: string): Promise<T>;
717
+ set<T = any>(key: string, data: T, ttl?: number): Promise<void>;
718
+ invalidate(key: string): Promise<void>;
719
+ disconnect?(): Promise<void>;
720
+ }
721
+
722
+ type CacheKeys = Record<string, (...args: any[]) => Promise<any>>;
723
+ type UseCacheReturnType<C extends CacheKeys, K extends keyof C> = K extends never ? never : Awaited<ReturnType<C[K]>>;
724
+
715
725
  type OpenApiModelType = {
716
726
  type: "object";
717
727
  properties: Record<string, OpenApiModelPropertyType>;
@@ -1227,11 +1237,11 @@ declare class AlterTableBuilder extends BaseBuilder {
1227
1237
  */
1228
1238
  dropDefault(columnName: string): void;
1229
1239
  /**
1230
- * @description Adds a primary key to a column
1240
+ * @description Adds a primary key constraint to a column
1241
+ * @param columnName is the column name to add the primary key to
1231
1242
  * @sqlite not supported and will throw error
1232
- * @private Used internally by alterColumn
1233
1243
  */
1234
- private addPrimaryKey;
1244
+ addPrimaryKey(columnName: string): void;
1235
1245
  /**
1236
1246
  * @description Raw non type safe way builder to add a constraint
1237
1247
  * @sqlite not supported and will throw error
@@ -1239,23 +1249,21 @@ declare class AlterTableBuilder extends BaseBuilder {
1239
1249
  addConstraint(...options: ConstructorParameters<typeof ConstraintNode>): void;
1240
1250
  /**
1241
1251
  * @description Adds a foreign key constraint to a column
1252
+ * @param columnName is the column name in the current table
1253
+ * @param foreignTable is the referenced table name
1254
+ * @param foreignColumn is the referenced column name
1255
+ * @param options optional foreign key options (constraintName, onDelete, onUpdate)
1242
1256
  * @sqlite not supported and will throw error
1243
- * @private Used internally by alterColumn
1244
1257
  */
1245
- private addForeignKey;
1258
+ foreignKey(columnName: string, foreignTable: string, foreignColumn: string, options?: ForeignKeyOptions): void;
1246
1259
  /**
1247
1260
  * @description Adds a unique constraint to a column
1248
1261
  * @description By default generates a constraint name using standard pattern: uq_${table}_${column}
1262
+ * @param columnName is the column name in the current table
1263
+ * @param options optional constraint options (constraintName)
1249
1264
  * @sqlite not supported and will throw error
1250
- * @private Used internally by alterColumn
1251
- */
1252
- private unique;
1253
- /**
1254
- * @description Sets a default value for a column
1255
- * @sqlite not supported and will throw error
1256
- * @private Used internally by alterColumn
1257
1265
  */
1258
- private setDefault;
1266
+ unique(columnName: string, options?: CommonConstraintOptions): void;
1259
1267
  /**
1260
1268
  * @description Drops a foreign key by column name and referenced column, generates constraint name using standard pattern: fk_${table}_${leftColumn}_${rightColumn}
1261
1269
  * @description If a custom constraint name was used to generate the foreign key, use `dropConstraint` instead
@@ -1808,6 +1816,10 @@ type ManyToManyOptions<T extends typeof Model, TM extends ThroughModel<T>> = {
1808
1816
  */
1809
1817
  rightForeignKey?: TM extends ThroughModelString ? string : ModelKey<InstanceType<ExtractModelFromTM<TM>>>;
1810
1818
  };
1819
+ type ManyToManyStringOptions = {
1820
+ leftForeignKey?: string;
1821
+ rightForeignKey?: string;
1822
+ };
1811
1823
  type IndexType = {
1812
1824
  columns: string[];
1813
1825
  name: string;
@@ -3057,6 +3069,14 @@ declare class SqlDataSource extends DataSource {
3057
3069
  * @description Options provided in the sql data source initialization
3058
3070
  */
3059
3071
  inputDetails: SqlDataSourceInput<SqlDataSourceType>;
3072
+ /**
3073
+ * @description Adapter for `useCache`, uses an in memory strategy by default
3074
+ */
3075
+ cacheAdapter: CacheAdapter;
3076
+ /**
3077
+ * @description Maps global keys to specific handlers for cache handling
3078
+ */
3079
+ cacheKeys: CacheKeys;
3060
3080
  /**
3061
3081
  * @description Establishes the default singleton connection used by default by all the Models, if not configuration is passed, env variables will be used instead
3062
3082
  * @description You can continue to use the global sql class exported by hysteria after the connection without having to rely on the return of this function
@@ -3073,8 +3093,8 @@ declare class SqlDataSource extends DataSource {
3073
3093
  * User.query(); // Will use the default connection
3074
3094
  * ```
3075
3095
  */
3076
- static connect<U extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}>(input: SqlDataSourceInput<U, T>, cb?: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void> | void): Promise<AugmentedSqlDataSource<T>>;
3077
- static connect<T extends Record<string, SqlDataSourceModel> = {}>(cb?: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void> | void): Promise<SqlDataSource>;
3096
+ static connect<U extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}>(input: SqlDataSourceInput<U, T, C>, cb?: (sqlDataSource: AugmentedSqlDataSource<T, C>) => Promise<void> | void): Promise<AugmentedSqlDataSource<T, C>>;
3097
+ static connect<T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}>(cb?: (sqlDataSource: AugmentedSqlDataSource<T, C>) => Promise<void> | void): Promise<AugmentedSqlDataSource<T, C>>;
3078
3098
  /**
3079
3099
  * @description Get's another database connection and return it, this won't be marked as the default connection used by the Models, for that use the static method `connect`
3080
3100
  * @description By default not used by the Models, you have to pass it as a parameter to the Models to use it
@@ -3088,8 +3108,8 @@ declare class SqlDataSource extends DataSource {
3088
3108
  * const user = await User.query({ connection: anotherSql }).many();
3089
3109
  * ```
3090
3110
  */
3091
- static connectToSecondarySource<U extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}>(input: SqlDataSourceInput<U, T>, cb?: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void> | void): Promise<AugmentedSqlDataSource<T>>;
3092
- static connectToSecondarySource<T extends Record<string, SqlDataSourceModel> = {}>(cb?: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void> | void): Promise<SqlDataSource>;
3111
+ static connectToSecondarySource<U extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}>(input: SqlDataSourceInput<U, T, C>, cb?: (sqlDataSource: AugmentedSqlDataSource<T, C>) => Promise<void> | void): Promise<AugmentedSqlDataSource<T, C>>;
3112
+ static connectToSecondarySource<T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}>(cb?: (sqlDataSource: AugmentedSqlDataSource<T, C>) => Promise<void> | void): Promise<AugmentedSqlDataSource<T, C>>;
3093
3113
  /**
3094
3114
  * @description Creates a new connection and executes a callback with the new instance, the connection is automatically closed after the callback is executed, so it's lifespan is only inside the callback
3095
3115
  * @description By default not used by the Models, you have to pass it as a parameter to the Models to use it
@@ -3103,7 +3123,7 @@ declare class SqlDataSource extends DataSource {
3103
3123
  * });
3104
3124
  * ```
3105
3125
  */
3106
- static useConnection<U extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}>(connectionDetails: UseConnectionInput<U, T>, cb: (sqlDataSource: AugmentedSqlDataSource<T>) => Promise<void>): Promise<void>;
3126
+ static useConnection<U extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}>(connectionDetails: UseConnectionInput<U, T, C>, cb: (sqlDataSource: AugmentedSqlDataSource<T, C>) => Promise<void>): Promise<void>;
3107
3127
  /**
3108
3128
  * @description Returns the instance of the SqlDataSource
3109
3129
  * @throws {HysteriaError} If the connection is not established
@@ -3194,6 +3214,25 @@ declare class SqlDataSource extends DataSource {
3194
3214
  */
3195
3215
  static rawStatement(value: string): RawNode;
3196
3216
  private constructor();
3217
+ /**
3218
+ * @description Uses the cache adapter to get a value from the cache
3219
+ * @param key The key to get the value from
3220
+ * @param args The arguments to pass to the key handler
3221
+ */
3222
+ useCache<M extends Record<string, typeof Model>, C extends CacheKeys, K extends keyof C>(this: AugmentedSqlDataSource<M, C>, key: K, ...args: Parameters<C[K]>): Promise<UseCacheReturnType<C, K>>;
3223
+ /**
3224
+ * @description Uses the cache adapter to get a value from the cache
3225
+ * @param key The key to get the value from
3226
+ * @param ttl The time to live for the value in milliseconds
3227
+ * @param args The arguments to pass to the key handler
3228
+ */
3229
+ useCache<M extends Record<string, typeof Model>, C extends CacheKeys, K extends keyof C>(this: AugmentedSqlDataSource<M, C>, key: K, ttl: number, ...args: Parameters<C[K]>): Promise<UseCacheReturnType<C, K>>;
3230
+ /**
3231
+ * @description Invalidates a value from the cache
3232
+ * @param key The key to invalidate the value from
3233
+ * @param args The arguments to pass to the key handler
3234
+ */
3235
+ invalidCache<M extends Record<string, typeof Model>, C extends CacheKeys, K extends keyof C>(this: AugmentedSqlDataSource<M, C>, key: K, ...args: Parameters<C[K]>): Promise<void>;
3197
3236
  /**
3198
3237
  * @description Returns true if the connection is established
3199
3238
  */
@@ -3383,7 +3422,7 @@ type SqlDataSourceModel = typeof Model;
3383
3422
  * @description The input type for the SqlDataSource constructor
3384
3423
  * @description The connectionPolicies object is used to configure the connection policies for the sql data source
3385
3424
  */
3386
- type SqlDataSourceInput<D extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}> = {
3425
+ type SqlDataSourceInput<D extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}> = {
3387
3426
  readonly type?: Exclude<DataSourceType, "mongo">;
3388
3427
  /**
3389
3428
  * @description Whether to log the sql queries and other debug information
@@ -3406,14 +3445,22 @@ type SqlDataSourceInput<D extends SqlDataSourceType, T extends Record<string, Sq
3406
3445
  * @description The driver specific options to use for the sql data source, it's used to configure the driver specific options for the sql data source
3407
3446
  */
3408
3447
  driverOptions?: SqlDriverSpecificOptions<D>;
3448
+ cacheStrategy?: {
3449
+ cacheAdapter?: CacheAdapter;
3450
+ keys: C;
3451
+ };
3409
3452
  } & (MysqlSqlDataSourceInput | PostgresSqlDataSourceInput | SqliteDataSourceInput);
3410
- type UseConnectionInput<D extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}> = {
3453
+ type UseConnectionInput<D extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}> = {
3411
3454
  readonly type: Exclude<DataSourceType, "mongo">;
3412
3455
  readonly logs?: boolean;
3413
3456
  readonly models?: T;
3414
3457
  readonly driverOptions?: SqlDriverSpecificOptions<D>;
3415
3458
  connectionPolicies?: ConnectionPolicies;
3416
3459
  queryFormatOptions?: FormatOptionsWithLanguage;
3460
+ cacheStrategy?: {
3461
+ cacheAdapter: CacheAdapter;
3462
+ keys: C;
3463
+ };
3417
3464
  } & (NotNullableMysqlSqlDataSourceInput | NotNullablePostgresSqlDataSourceInput | NotNullableSqliteDataSourceInput);
3418
3465
  type SqlDataSourceType = Exclude<DataSourceType, "mongo">;
3419
3466
  type SqlCloneOptions = {
@@ -3425,7 +3472,17 @@ type SqlCloneOptions = {
3425
3472
  };
3426
3473
  type getPoolReturnType<T = SqlDataSourceType> = T extends "mysql" ? MysqlConnectionInstance : T extends "mariadb" ? MysqlConnectionInstance : T extends "postgres" ? PgPoolClientInstance : T extends "cockroachdb" ? PgPoolClientInstance : T extends "sqlite" ? SqliteConnectionInstance : never;
3427
3474
  type GetConnectionReturnType<T = SqlDataSourceType> = T extends "mysql" ? PoolConnection : T extends "mariadb" ? PoolConnection : T extends "postgres" ? PoolClient : T extends "cockroachdb" ? PoolClient : T extends "sqlite" ? InstanceType<Sqlite3Import["Database"]> : never;
3428
- type AugmentedSqlDataSource<T extends Record<string, SqlDataSourceModel> = {}> = SqlDataSource & {
3475
+ type UseCacheOverloads<C extends CacheKeys> = {
3476
+ <K extends keyof C>(key: K, ...args: Parameters<C[K]>): Promise<UseCacheReturnType<C, K>>;
3477
+ <K extends keyof C>(key: K, ttl: number, ...args: Parameters<C[K]>): Promise<UseCacheReturnType<C, K>>;
3478
+ };
3479
+ type UseCacheType<C extends CacheKeys> = keyof C extends never ? SqlDataSource["useCache"] : UseCacheOverloads<C>;
3480
+ type InvalidCacheType<C extends CacheKeys> = keyof C extends never ? SqlDataSource["invalidCache"] : <K extends keyof C>(key: K) => Promise<void>;
3481
+ type AugmentedSqlDataSource<T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}> = Omit<SqlDataSource, "useCache" | "invalidCache" | "clone"> & {
3482
+ useCache: UseCacheType<C>;
3483
+ invalidCache: InvalidCacheType<C>;
3484
+ clone(options?: SqlCloneOptions): Promise<AugmentedSqlDataSource<T, C>>;
3485
+ } & {
3429
3486
  [key in keyof T]: T[key];
3430
3487
  };
3431
3488
  type SqlDataSourceWithoutTransaction<T extends Record<string, SqlDataSourceModel> = {}> = Pick<SqlDataSource, "sqlPool" | "sqlConnection" | "inputDetails" | "isConnected" | "getDbType" | "clone" | "getModelManager" | "getPool" | "getConnection" | "closeConnection" | "getConnectionDetails" | "disconnect" | "syncSchema" | "rawQuery" | "rawStatement" | "getTableSchema" | "getModelOpenApiSchema" | "getTableInfo" | "getIndexInfo" | "getForeignKeyInfo" | "getPrimaryKeyInfo" | "registeredModels" | "type" | "host" | "port" | "username" | "password" | "database" | "logs" | "query"> & {
@@ -3889,7 +3946,7 @@ type AnnotatedModel<T extends Model, A extends object = {}, R extends object = {
3889
3946
  $annotations: A;
3890
3947
  } & R;
3891
3948
  type CommonSqlMethodReturnType<T extends SqlMethod> = T extends "count" | "sum" | "avg" | "min" | "max" ? number : T extends "upper" | "lower" | "trim" ? string : T extends "length" ? number : T extends "cast" | "convert" ? any : T extends "abs" | "round" | "floor" | "ceil" ? number : any;
3892
- type RelatedInstance<M extends Model, K extends ModelRelation<M>> = M[K] extends (infer R)[] ? R extends Model ? R : never : M[K] extends Model ? M[K] : never;
3949
+ type RelatedInstance<M extends Model, K extends ModelRelation<M>> = NonNullable<M[K]> extends (infer R)[] ? R extends Model ? R : never : NonNullable<M[K]> extends Model ? NonNullable<M[K]> : never;
3893
3950
 
3894
3951
  type NullableAndUndefinable<T> = T | (T | null) | (T | undefined) | (T | null | undefined);
3895
3952
  type UpsertOptions<T extends Model> = {
@@ -4225,6 +4282,10 @@ declare abstract class Model extends Entity {
4225
4282
  * @description Gives the correct model manager with the correct connection based on the options provided
4226
4283
  */
4227
4284
  private static dispatchModelManager;
4285
+ /**
4286
+ * @description Merges the provided data with the model instance
4287
+ */
4288
+ mergeProps<T extends Model = this>(this: T, data: Partial<ModelWithoutRelations<T>>): void;
4228
4289
  /**
4229
4290
  * @description inserts or updates the model to the database, must have a primary key in order to work
4230
4291
  * @throws {HysteriaError} If the model has no primary key
@@ -4386,18 +4447,21 @@ declare function getModelColumns(target: typeof Model): ColumnType[];
4386
4447
  * ```
4387
4448
  */
4388
4449
  declare function belongsTo<M extends typeof Model = any, R extends typeof Model = any>(model: () => R, foreignKey?: ModelKey<InstanceType<M>>, options?: BaseModelRelationType): PropertyDecorator;
4450
+ declare function belongsTo<R extends typeof Model = any>(model: () => R, foreignKey?: string, options?: BaseModelRelationType): PropertyDecorator;
4389
4451
  /**
4390
4452
  * @description Establishes a has one relation with the given model
4391
4453
  * @default foreignKey by default will be the singular of the model name plus "_id"
4392
4454
  * @example User will have foreignKey "user_id" on the Post model
4393
4455
  */
4394
4456
  declare function hasOne<T extends typeof Model>(model: () => T, foreignKey?: ModelKey<InstanceType<T>>): PropertyDecorator;
4457
+ declare function hasOne<T extends typeof Model>(model: () => T, foreignKey?: string): PropertyDecorator;
4395
4458
  /**
4396
4459
  * @description Establishes a has many relation with the given model
4397
4460
  * @default foreignKey by default will be the singular of the model name plus "_id"
4398
4461
  * @example User will have foreignKey "user_id" on the Post model
4399
4462
  */
4400
4463
  declare function hasMany<T extends typeof Model>(model: () => T, foreignKey?: ModelKey<InstanceType<T>>): PropertyDecorator;
4464
+ declare function hasMany<T extends typeof Model>(model: () => T, foreignKey?: string): PropertyDecorator;
4401
4465
  /**
4402
4466
  * @description Establishes a many to many relation with the given model
4403
4467
  * @default foreignKey by default will be the singular of the model that establishes the relation name plus "_id"
@@ -4409,6 +4473,7 @@ declare function hasMany<T extends typeof Model>(model: () => T, foreignKey?: Mo
4409
4473
  * @example User will have foreignKey "user_id" on the Join table by default
4410
4474
  */
4411
4475
  declare function manyToMany<R extends typeof Model, T extends typeof Model, TM extends ThroughModel<T>>(model: () => R, throughModel: TM, throughModelKeys?: ManyToManyOptions<T, TM>, options?: BaseModelRelationType): PropertyDecorator;
4476
+ declare function manyToMany<R extends typeof Model>(model: () => R, throughModel: string | (() => typeof Model), throughModelKeys?: ManyToManyStringOptions, options?: BaseModelRelationType): PropertyDecorator;
4412
4477
  declare function getRelationsMetadata(target: typeof Model): LazyRelationType[];
4413
4478
  /**
4414
4479
  * @description Returns the relations of the model
@@ -4477,6 +4542,25 @@ declare class UserMixin extends Model {
4477
4542
  deletedAt: Date | null;
4478
4543
  }
4479
4544
 
4545
+ declare class InMemoryAdapter implements CacheAdapter {
4546
+ get<T = void>(key: string): Promise<T>;
4547
+ set<T = any>(key: string, data: T, ttl?: number): Promise<void>;
4548
+ invalidate(key: string): Promise<void>;
4549
+ }
4550
+
4551
+ declare class RedisCacheAdapter implements CacheAdapter {
4552
+ redisInstance: Redis;
4553
+ private ioRedisOptions;
4554
+ constructor(ioRedisOptions: RedisOptions);
4555
+ private getClient;
4556
+ get<T = void>(key: string): Promise<T>;
4557
+ set<T = any>(key: string, data: T, ttl?: number): Promise<void>;
4558
+ invalidate(key: string): Promise<void>;
4559
+ private serializeData;
4560
+ private deserializeData;
4561
+ disconnect(): Promise<void>;
4562
+ }
4563
+
4480
4564
  /**
4481
4565
  * @description The RedisStorable type is a type that can be stored in redis
4482
4566
  */
@@ -5226,7 +5310,7 @@ declare abstract class Migration {
5226
5310
  /**
5227
5311
  * @description This method is called after the migration has been run
5228
5312
  */
5229
- afterMigration?(sqlDataSource: SqlDataSource): Promise<void>;
5313
+ afterMigration?(sqlDataSource: SqlDataSource | AugmentedSqlDataSource): Promise<void>;
5230
5314
  }
5231
5315
 
5232
5316
  /**
@@ -5279,7 +5363,7 @@ type WithPerformanceResult<R = any> = [string, R];
5279
5363
  */
5280
5364
  declare const withPerformance: <A extends any[], R>(fn: (...args: A) => Promise<R>, returnType?: "millis" | "seconds", fix?: number) => (...args: A) => Promise<WithPerformanceResult<R>>;
5281
5365
 
5282
- type HysteriaErrorCode = "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}` | `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";
5366
+ type HysteriaErrorCode = "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";
5283
5367
 
5284
5368
  declare class HysteriaError extends Error {
5285
5369
  code: HysteriaErrorCode;
@@ -5304,4 +5388,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
5304
5388
  $id?: string;
5305
5389
  }>;
5306
5390
 
5307
- export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseConnectionInput, UserMixin, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };
5391
+ export { type AnnotatedModel, type AsymmetricEncryptionOptions, type AugmentedSqlDataSource, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, type CacheAdapter, type CacheKeys, ClientMigrator, Collection, type ColumnDataTypeOption, type ColumnDataTypeOptionSimple, type ColumnDataTypeOptionWithBinary, type ColumnDataTypeOptionWithDatePrecision, type ColumnDataTypeOptionWithEnum, type ColumnDataTypeOptionWithLength, type ColumnDataTypeOptionWithPrecision, type ColumnDataTypeOptionWithScaleAndPrecision, type ColumnDataTypeOptionWithText, type ColumnOptions, type ColumnType, type CommonDataSourceInput, type CommonSqlMethodReturnType, type ConnectionPolicies, type DataSourceInput, type DataSourceType, type DateColumnOptions, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, type SqlDriverSpecificOptions, type SqlPoolType, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type SymmetricEncryptionOptions, type TableFormat, type ThroughModel, TimestampedModel, Transaction, type TransactionExecutionOptions, type UniqueType, type UseCacheReturnType, type UseConnectionInput, UserMixin, UuidModel, belongsTo, column, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, index, HysteriaLogger as logger, manyToMany, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };