hysteria-orm 10.4.6 → 10.4.7

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
@@ -2986,8 +2986,8 @@ declare class SelectQueryBuilder<T extends Model> extends JoinQueryBuilder<T> {
2986
2986
  * @warning For annotations, use the `annotate` method instead, aliases and methods are not supported in the select method and will give error `column "${columnName} as ${alias}" does not exist`
2987
2987
  * @example
2988
2988
  * ```ts
2989
- * const user = await User.query().select("name", "age").first(); // SELECT name, age FROM users
2990
- * const user = await User.query().select("name", "users.age").first(); // SELECT name, users.age FROM users
2989
+ * const user = await User.query().select("name", "age").one(); // SELECT name, age FROM users
2990
+ * const user = await User.query().select("name", "users.age").one(); // SELECT name, users.age FROM users
2991
2991
  * ```
2992
2992
  */
2993
2993
  select<S extends string>(...columns: SelectableColumn<S>[]): this;
@@ -3018,9 +3018,9 @@ declare class SelectQueryBuilder<T extends Model> extends JoinQueryBuilder<T> {
3018
3018
  * @description If using a model, the result will be available in the $annotations property of the model, else it will be available in the result of the query
3019
3019
  * @example
3020
3020
  * ```ts
3021
- * const user = await User.query().annotate("max", "id", "maxId").first(); // max(id) as maxId
3022
- * const user = await User.query().annotate("id", "superId").first(); // id as superId
3023
- * const user = await User.query().annotate("id", "superId").first(); // id as superId
3021
+ * const user = await User.query().annotate("max", "id", "maxId").one(); // max(id) as maxId
3022
+ * const user = await User.query().annotate("id", "superId").one(); // id as superId
3023
+ * const user = await User.query().annotate("id", "superId").one(); // id as superId
3024
3024
  * ```
3025
3025
  */
3026
3026
  annotate<A extends string>(column: string, alias: A): this;
@@ -3059,15 +3059,15 @@ declare class SelectQueryBuilder<T extends Model> extends JoinQueryBuilder<T> {
3059
3059
  * @example
3060
3060
  * ```ts
3061
3061
  * // All databases accept the same path format:
3062
- * const user = await User.query().selectJson("data", "$.user.name", "userName").first();
3062
+ * const user = await User.query().selectJson("data", "$.user.name", "userName").one();
3063
3063
  * console.log(user?.$annotations?.userName); // Typed!
3064
3064
  *
3065
- * await User.query().selectJson("data", "user.name", "userName").first(); // $ is optional
3066
- * await User.query().selectJson("data", ["user", "name"], "userName").first();
3065
+ * await User.query().selectJson("data", "user.name", "userName").one(); // $ is optional
3066
+ * await User.query().selectJson("data", ["user", "name"], "userName").one();
3067
3067
  *
3068
3068
  * // Array indices:
3069
- * await User.query().selectJson("data", "items.0.name", "firstItemName").first();
3070
- * await User.query().selectJson("data", ["items", 0, "name"], "firstItemName").first();
3069
+ * await User.query().selectJson("data", "items.0.name", "firstItemName").one();
3070
+ * await User.query().selectJson("data", ["items", 0, "name"], "firstItemName").one();
3071
3071
  * ```
3072
3072
  */
3073
3073
  selectJson<A extends string>(column: ModelKey<T>, path: JsonPathInput, alias: A): this;
@@ -3082,10 +3082,10 @@ declare class SelectQueryBuilder<T extends Model> extends JoinQueryBuilder<T> {
3082
3082
  * @example
3083
3083
  * ```ts
3084
3084
  * // All databases accept the same path format:
3085
- * const user = await User.query().selectJsonText("data", "$.user.name", "userName").first();
3085
+ * const user = await User.query().selectJsonText("data", "$.user.name", "userName").one();
3086
3086
  * console.log(user?.$annotations?.userName); // Typed!
3087
3087
  *
3088
- * await User.query().selectJsonText("data", ["user", "name"], "userName").first();
3088
+ * await User.query().selectJsonText("data", ["user", "name"], "userName").one();
3089
3089
  * ```
3090
3090
  */
3091
3091
  selectJsonText<A extends string>(column: ModelKey<T>, path: JsonPathInput, alias: A): this;
@@ -3100,11 +3100,11 @@ declare class SelectQueryBuilder<T extends Model> extends JoinQueryBuilder<T> {
3100
3100
  * @example
3101
3101
  * ```ts
3102
3102
  * // All databases accept the same path format:
3103
- * const user = await User.query().selectJsonArrayLength("data", "$.items", "itemCount").first();
3103
+ * const user = await User.query().selectJsonArrayLength("data", "$.items", "itemCount").one();
3104
3104
  * console.log(user?.$annotations?.itemCount); // Typed!
3105
3105
  *
3106
- * await User.query().selectJsonArrayLength("data", "items", "itemCount").first();
3107
- * await User.query().selectJsonArrayLength("data", "$", "totalCount").first(); // root array
3106
+ * await User.query().selectJsonArrayLength("data", "items", "itemCount").one();
3107
+ * await User.query().selectJsonArrayLength("data", "$", "totalCount").one(); // root array
3108
3108
  * ```
3109
3109
  */
3110
3110
  selectJsonArrayLength<A extends string>(column: ModelKey<T>, path: JsonPathInput, alias: A): this;
@@ -3121,11 +3121,11 @@ declare class SelectQueryBuilder<T extends Model> extends JoinQueryBuilder<T> {
3121
3121
  * @example
3122
3122
  * ```ts
3123
3123
  * // All databases accept the same path format:
3124
- * const user = await User.query().selectJsonKeys("data", "$.user", "userKeys").first();
3124
+ * const user = await User.query().selectJsonKeys("data", "$.user", "userKeys").one();
3125
3125
  * console.log(user?.$annotations?.userKeys); // Typed!
3126
3126
  *
3127
- * await User.query().selectJsonKeys("data", "user", "userKeys").first();
3128
- * await User.query().selectJsonKeys("data", "$", "rootKeys").first(); // root object
3127
+ * await User.query().selectJsonKeys("data", "user", "userKeys").one();
3128
+ * await User.query().selectJsonKeys("data", "$", "rootKeys").one(); // root object
3129
3129
  * ```
3130
3130
  */
3131
3131
  selectJsonKeys<A extends string>(column: ModelKey<T>, path: JsonPathInput, alias: A): this;
@@ -3137,7 +3137,7 @@ declare class SelectQueryBuilder<T extends Model> extends JoinQueryBuilder<T> {
3137
3137
  * @description Result will be available in model.$annotations[alias]
3138
3138
  * @example
3139
3139
  * ```ts
3140
- * const user = await User.query().selectJsonRaw("data->>'email'", "userEmail").first();
3140
+ * const user = await User.query().selectJsonRaw("data->>'email'", "userEmail").one();
3141
3141
  * console.log(user?.$annotations?.userEmail); // Typed!
3142
3142
  * ```
3143
3143
  */
@@ -3685,14 +3685,6 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
3685
3685
  data: AnnotatedModel<T, A, R>;
3686
3686
  time: number;
3687
3687
  }>;
3688
- first: (options?: OneOptions, returnType?: "millis" | "seconds") => Promise<{
3689
- data: AnnotatedModel<T, A, R> | null;
3690
- time: number;
3691
- }>;
3692
- firstOrFail: (options?: OneOptions, returnType?: "millis" | "seconds") => Promise<{
3693
- data: AnnotatedModel<T, A, R>;
3694
- time: number;
3695
- }>;
3696
3688
  paginate: (page: number, perPage: number, options?: {
3697
3689
  ignoreHooks?: boolean;
3698
3690
  }, returnType?: "millis" | "seconds") => Promise<{
@@ -3739,7 +3731,6 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
3739
3731
  */
3740
3732
  static from(model: typeof Model, options?: BaseModelMethodOptions): ModelQueryBuilder<InstanceType<typeof model>>;
3741
3733
  one(options?: OneOptions): Promise<AnnotatedModel<T, A, R> | null>;
3742
- first(options?: OneOptions): Promise<AnnotatedModel<T, A, R> | null>;
3743
3734
  oneOrFail(options?: {
3744
3735
  ignoreHooks?: OneOptions["ignoreHooks"] & {
3745
3736
  customError?: Error;
@@ -3790,10 +3781,10 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
3790
3781
  * @description If the alias matches a model field name, it overrides that field. Otherwise, it's available in $annotations
3791
3782
  * @example
3792
3783
  * ```ts
3793
- * const user = await User.query().annotate("max", "id", "maxId").first(); // max(id) as maxId
3794
- * const user = await User.query().annotate("id", "superId").first(); // id as superId
3784
+ * const user = await User.query().annotate("max", "id", "maxId").one(); // max(id) as maxId
3785
+ * const user = await User.query().annotate("id", "superId").one(); // id as superId
3795
3786
  * // If alias matches model field, it overrides it:
3796
- * const user = await User.query().annotate("COUNT(*)", "email").first(); // user.email is now a number
3787
+ * const user = await User.query().annotate("COUNT(*)", "email").one(); // user.email is now a number
3797
3788
  * ```
3798
3789
  */
3799
3790
  annotate<K extends string, V = any>(column: string, alias: K): AnnotationResult<T, A, R, K, V>;
@@ -3812,29 +3803,29 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
3812
3803
  * // All these path formats are supported:
3813
3804
  *
3814
3805
  * // 1. With $ prefix (standard JSON path)
3815
- * await User.query().selectJson("data", "$.user.name", "userName").first();
3806
+ * await User.query().selectJson("data", "$.user.name", "userName").one();
3816
3807
  *
3817
3808
  * // 2. Without $ prefix ($ is optional)
3818
- * await User.query().selectJson("data", "user.name", "userName").first();
3809
+ * await User.query().selectJson("data", "user.name", "userName").one();
3819
3810
  *
3820
3811
  * // 3. Array format
3821
- * await User.query().selectJson("data", ["user", "name"], "userName").first();
3812
+ * await User.query().selectJson("data", ["user", "name"], "userName").one();
3822
3813
  *
3823
3814
  * // 4. Array indices with dot notation
3824
- * await User.query().selectJson("data", "items.0.name", "firstItemName").first();
3815
+ * await User.query().selectJson("data", "items.0.name", "firstItemName").one();
3825
3816
  *
3826
3817
  * // 5. Array indices with array format
3827
- * await User.query().selectJson("data", ["items", 0, "name"], "firstItemName").first();
3818
+ * await User.query().selectJson("data", ["items", 0, "name"], "firstItemName").one();
3828
3819
  *
3829
3820
  * // 6. Root object
3830
- * await User.query().selectJson("data", "$", "allData").first();
3821
+ * await User.query().selectJson("data", "$", "allData").one();
3831
3822
  *
3832
3823
  * // Access the result - in $annotations if not a model field
3833
- * const user = await User.query().selectJson("data", "user.name", "userName").first();
3824
+ * const user = await User.query().selectJson("data", "user.name", "userName").one();
3834
3825
  * console.log(user?.$annotations?.userName); // Typed as any
3835
3826
  *
3836
3827
  * // If alias matches model field, it overrides it
3837
- * const user2 = await User.query().selectJson("data", "$.name", "email").first();
3828
+ * const user2 = await User.query().selectJson("data", "$.name", "email").one();
3838
3829
  * console.log(user2?.email); // Overrides model's email field
3839
3830
  * ```
3840
3831
  */
@@ -3852,23 +3843,23 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
3852
3843
  * // All these path formats are supported:
3853
3844
  *
3854
3845
  * // 1. With $ prefix
3855
- * await User.query().selectJsonText("data", "$.user.email", "userEmail").first();
3846
+ * await User.query().selectJsonText("data", "$.user.email", "userEmail").one();
3856
3847
  *
3857
3848
  * // 2. Without $ prefix
3858
- * await User.query().selectJsonText("data", "user.email", "userEmail").first();
3849
+ * await User.query().selectJsonText("data", "user.email", "userEmail").one();
3859
3850
  *
3860
3851
  * // 3. Array format
3861
- * await User.query().selectJsonText("data", ["user", "email"], "userEmail").first();
3852
+ * await User.query().selectJsonText("data", ["user", "email"], "userEmail").one();
3862
3853
  *
3863
3854
  * // 4. Array indices
3864
- * await User.query().selectJsonText("data", "tags.0", "firstTag").first();
3865
- * await User.query().selectJsonText("data", ["tags", 0], "firstTag").first();
3855
+ * await User.query().selectJsonText("data", "tags.0", "firstTag").one();
3856
+ * await User.query().selectJsonText("data", ["tags", 0], "firstTag").one();
3866
3857
  *
3867
3858
  * // 5. Deep nesting
3868
- * await User.query().selectJsonText("data", "user.profile.bio", "biography").first();
3859
+ * await User.query().selectJsonText("data", "user.profile.bio", "biography").one();
3869
3860
  *
3870
3861
  * // Access the result - in $annotations if not a model field
3871
- * const user = await User.query().selectJsonText("data", "user.email", "userEmail").first();
3862
+ * const user = await User.query().selectJsonText("data", "user.email", "userEmail").one();
3872
3863
  * console.log(user?.$annotations?.userEmail); // Typed as string
3873
3864
  * ```
3874
3865
  */
@@ -3887,27 +3878,27 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
3887
3878
  * // All these path formats are supported:
3888
3879
  *
3889
3880
  * // 1. With $ prefix
3890
- * await User.query().selectJsonArrayLength("data", "$.items", "itemCount").first();
3881
+ * await User.query().selectJsonArrayLength("data", "$.items", "itemCount").one();
3891
3882
  *
3892
3883
  * // 2. Without $ prefix
3893
- * await User.query().selectJsonArrayLength("data", "items", "itemCount").first();
3884
+ * await User.query().selectJsonArrayLength("data", "items", "itemCount").one();
3894
3885
  *
3895
3886
  * // 3. Array format
3896
- * await User.query().selectJsonArrayLength("data", ["items"], "itemCount").first();
3887
+ * await User.query().selectJsonArrayLength("data", ["items"], "itemCount").one();
3897
3888
  *
3898
3889
  * // 4. Root array (use "$" or "")
3899
- * await User.query().selectJsonArrayLength("data", "$", "totalCount").first();
3900
- * await User.query().selectJsonArrayLength("data", "", "totalCount").first();
3890
+ * await User.query().selectJsonArrayLength("data", "$", "totalCount").one();
3891
+ * await User.query().selectJsonArrayLength("data", "", "totalCount").one();
3901
3892
  *
3902
3893
  * // 5. Nested arrays
3903
- * await User.query().selectJsonArrayLength("data", "user.roles", "roleCount").first();
3904
- * await User.query().selectJsonArrayLength("data", ["user", "roles"], "roleCount").first();
3894
+ * await User.query().selectJsonArrayLength("data", "user.roles", "roleCount").one();
3895
+ * await User.query().selectJsonArrayLength("data", ["user", "roles"], "roleCount").one();
3905
3896
  *
3906
3897
  * // 6. Deeply nested arrays
3907
- * await User.query().selectJsonArrayLength("data", "level1.level2.items", "deepCount").first();
3898
+ * await User.query().selectJsonArrayLength("data", "level1.level2.items", "deepCount").one();
3908
3899
  *
3909
3900
  * // Access the result - in $annotations if not a model field
3910
- * const user = await User.query().selectJsonArrayLength("data", "items", "count").first();
3901
+ * const user = await User.query().selectJsonArrayLength("data", "items", "count").one();
3911
3902
  * console.log(user?.$annotations?.count); // Typed as number
3912
3903
  * ```
3913
3904
  */
@@ -3928,27 +3919,27 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
3928
3919
  * // All these path formats are supported:
3929
3920
  *
3930
3921
  * // 1. With $ prefix
3931
- * await User.query().selectJsonKeys("data", "$.settings", "settingKeys").first();
3922
+ * await User.query().selectJsonKeys("data", "$.settings", "settingKeys").one();
3932
3923
  *
3933
3924
  * // 2. Without $ prefix
3934
- * await User.query().selectJsonKeys("data", "settings", "settingKeys").first();
3925
+ * await User.query().selectJsonKeys("data", "settings", "settingKeys").one();
3935
3926
  *
3936
3927
  * // 3. Array format
3937
- * await User.query().selectJsonKeys("data", ["settings"], "settingKeys").first();
3928
+ * await User.query().selectJsonKeys("data", ["settings"], "settingKeys").one();
3938
3929
  *
3939
3930
  * // 4. Root object (use "$" or "")
3940
- * await User.query().selectJsonKeys("data", "$", "rootKeys").first();
3941
- * await User.query().selectJsonKeys("data", "", "rootKeys").first();
3931
+ * await User.query().selectJsonKeys("data", "$", "rootKeys").one();
3932
+ * await User.query().selectJsonKeys("data", "", "rootKeys").one();
3942
3933
  *
3943
3934
  * // 5. Nested objects
3944
- * await User.query().selectJsonKeys("data", "user.profile", "profileKeys").first();
3945
- * await User.query().selectJsonKeys("data", ["user", "profile"], "profileKeys").first();
3935
+ * await User.query().selectJsonKeys("data", "user.profile", "profileKeys").one();
3936
+ * await User.query().selectJsonKeys("data", ["user", "profile"], "profileKeys").one();
3946
3937
  *
3947
3938
  * // 6. Deeply nested objects
3948
- * await User.query().selectJsonKeys("data", "settings.display.theme", "themeKeys").first();
3939
+ * await User.query().selectJsonKeys("data", "settings.display.theme", "themeKeys").one();
3949
3940
  *
3950
3941
  * // Access the result - in $annotations if not a model field
3951
- * const user = await User.query().selectJsonKeys("data", "settings", "keys").first();
3942
+ * const user = await User.query().selectJsonKeys("data", "settings", "keys").one();
3952
3943
  * console.log(user?.$annotations?.keys); // Typed as any[] - ["theme", "fontSize", "autoSave"]
3953
3944
  * ```
3954
3945
  */
@@ -3964,28 +3955,28 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
3964
3955
  * @example
3965
3956
  * ```ts
3966
3957
  * // PostgreSQL - Extract as text with ->> operator
3967
- * await User.query().selectJsonRaw("data->>'email'", "userEmail").first();
3958
+ * await User.query().selectJsonRaw("data->>'email'", "userEmail").one();
3968
3959
  *
3969
3960
  * // PostgreSQL - Extract nested JSON with -> operator
3970
- * await User.query().selectJsonRaw("data->'user'->'profile'->>'name'", "profileName").first();
3961
+ * await User.query().selectJsonRaw("data->'user'->'profile'->>'name'", "profileName").one();
3971
3962
  *
3972
3963
  * // PostgreSQL - Array element access
3973
- * await User.query().selectJsonRaw("data->'items'->0->>'name'", "firstName").first();
3964
+ * await User.query().selectJsonRaw("data->'items'->0->>'name'", "firstName").one();
3974
3965
  *
3975
3966
  * // MySQL - Extract value with JSON_EXTRACT and ->>
3976
- * await User.query().selectJsonRaw("data->>'$.email'", "userEmail").first();
3967
+ * await User.query().selectJsonRaw("data->>'$.email'", "userEmail").one();
3977
3968
  *
3978
3969
  * // MySQL - Array length with JSON_LENGTH
3979
- * await User.query().selectJsonRaw("JSON_LENGTH(data, '$.items')", "itemCount").first();
3970
+ * await User.query().selectJsonRaw("JSON_LENGTH(data, '$.items')", "itemCount").one();
3980
3971
  *
3981
3972
  * // MSSQL - Extract value with JSON_VALUE
3982
- * await User.query().selectJsonRaw("JSON_VALUE(data, '$.email')", "userEmail").first();
3973
+ * await User.query().selectJsonRaw("JSON_VALUE(data, '$.email')", "userEmail").one();
3983
3974
  *
3984
3975
  * // SQLite - Extract value with json_extract
3985
- * await User.query().selectJsonRaw("json_extract(data, '$.email')", "userEmail").first();
3976
+ * await User.query().selectJsonRaw("json_extract(data, '$.email')", "userEmail").one();
3986
3977
  *
3987
3978
  * // Access the result - in $annotations if not a model field
3988
- * const user = await User.query().selectJsonRaw("data->>'email'", "userEmail").first();
3979
+ * const user = await User.query().selectJsonRaw("data->>'email'", "userEmail").one();
3989
3980
  * console.log(user?.$annotations?.userEmail); // Typed as any
3990
3981
  * ```
3991
3982
  */
@@ -4066,7 +4057,6 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
4066
4057
  private oneWithPerformance;
4067
4058
  private oneOrFailWithPerformance;
4068
4059
  private firstOrFailWithPerformance;
4069
- private firstWithPerformance;
4070
4060
  private paginateWithPerformance;
4071
4061
  private paginateWithCursorWithPerformance;
4072
4062
  private existsWithPerformance;
@@ -4263,7 +4253,7 @@ type TransactionExecutionOptions = {
4263
4253
  };
4264
4254
 
4265
4255
  /**
4266
- * @description Transaction class, not meant to be used directly, use sql.startTransaction() instead
4256
+ * @description Transaction class, not meant to be used directly, use sql.transaction() instead
4267
4257
  */
4268
4258
  declare class Transaction {
4269
4259
  /**
@@ -4274,7 +4264,7 @@ declare class Transaction {
4274
4264
  * import { User } from "./models/user";
4275
4265
  *
4276
4266
  * // Raw queries
4277
- * const trx = await sql.startTransaction();
4267
+ * const trx = await sql.transaction();
4278
4268
  * await trx.rawQuery("SELECT * FROM users");
4279
4269
  *
4280
4270
  * // Model manager
@@ -4287,7 +4277,7 @@ declare class Transaction {
4287
4277
  * await trx.commit();
4288
4278
  * ```
4289
4279
  */
4290
- sql: Omit<SqlDataSource, "transaction" | "startGlobalTransaction" | "startTransaction">;
4280
+ sql: Omit<SqlDataSource, "transaction" | "startGlobalTransaction">;
4291
4281
  /**
4292
4282
  * @description Whether the transaction is active
4293
4283
  */
@@ -4308,9 +4298,9 @@ declare class Transaction {
4308
4298
  nestedTransaction(): Promise<Transaction>;
4309
4299
  nestedTransaction(cb: (trx: Transaction) => Promise<void>): Promise<void>;
4310
4300
  /**
4311
- * @description Starts a transaction, automatically handled from the sql data source instance in the `startTransaction` method
4301
+ * @description Starts a transaction, automatically handled from the sql data source instance in the `transaction` method
4312
4302
  */
4313
- startTransaction(): Promise<void>;
4303
+ transaction(): Promise<void>;
4314
4304
  /**
4315
4305
  * @description Commit the transaction releasing the connection
4316
4306
  * @throws {HysteriaError} if the transaction is not active and options.throwErrorOnInactiveTransaction is true
@@ -4463,10 +4453,6 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4463
4453
  /**
4464
4454
  * @description Closes the primary connection (singleton instance)
4465
4455
  */
4466
- static closeConnection(): Promise<void>;
4467
- /**
4468
- * @alias closeConnection
4469
- */
4470
4456
  static disconnect(): Promise<void>;
4471
4457
  /**
4472
4458
  * @description Starts a global transaction on the primary database connection
@@ -4610,11 +4596,6 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4610
4596
  * @param options.isolationLevel The isolation level to use for the transaction
4611
4597
  * @sqlite ignores the isolation level
4612
4598
  */
4613
- startTransaction(options?: StartTransactionOptions): Promise<Transaction>;
4614
- startTransaction(cb: (trx: Transaction) => Promise<void>, options?: StartTransactionOptions): Promise<void>;
4615
- /**
4616
- * @alias startTransaction
4617
- */
4618
4599
  transaction(options?: StartTransactionOptions): Promise<Transaction>;
4619
4600
  transaction(cb: (trx: Transaction) => Promise<void>, options?: StartTransactionOptions): Promise<void>;
4620
4601
  /**
@@ -4638,15 +4619,11 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4638
4619
  * @description If there is an active global transaction, it will be rolled back
4639
4620
  * @description Also disconnects all slave connections if any are configured
4640
4621
  */
4641
- closeConnection(): Promise<void>;
4622
+ disconnect(): Promise<void>;
4642
4623
  /**
4643
4624
  * @description Returns the connection details
4644
4625
  */
4645
4626
  getConnectionDetails(): SqlDataSourceInput<D, T, C>;
4646
- /**
4647
- * @alias closeConnection
4648
- */
4649
- disconnect(): Promise<void>;
4650
4627
  /**
4651
4628
  * @description Syncs the schema of the database with the models metadata
4652
4629
  * @warning This will drop and recreate all the indexes and constraints, use with caution
@@ -4655,6 +4632,11 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4655
4632
  syncSchema(options?: {
4656
4633
  transactional: boolean;
4657
4634
  }): Promise<void>;
4635
+ /**
4636
+ * @description Extracts rows from raw query result based on database type
4637
+ * MySQL/MariaDB returns [rows, fields], Postgres returns {rows: []}, others return rows directly
4638
+ */
4639
+ private extractRowsFromRawResult;
4658
4640
  /**
4659
4641
  * @description Executes a raw query on the database and returns the raw driver result
4660
4642
  */
@@ -4774,7 +4756,7 @@ type BaseModelMethodOptions = {
4774
4756
  * port: 5432,
4775
4757
  * });
4776
4758
  *
4777
- * const user = await User.query({ connection: customConnection }).first();
4759
+ * const user = await User.query({ connection: customConnection }).one();
4778
4760
  * ```
4779
4761
  */
4780
4762
  connection?: SqlDataSource;
@@ -4847,14 +4829,6 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
4847
4829
  data: any;
4848
4830
  time: number;
4849
4831
  }>;
4850
- first: (returnType?: "millis" | "seconds") => Promise<{
4851
- data: AnnotatedModel<T, any, any> | null;
4852
- time: number;
4853
- }>;
4854
- firstOrFail: (returnType?: "millis" | "seconds") => Promise<{
4855
- data: any;
4856
- time: number;
4857
- }>;
4858
4832
  paginate: (page: number, perPage: number, returnType?: "millis" | "seconds") => Promise<{
4859
4833
  data: PaginatedData<T>;
4860
4834
  time: number;
@@ -4922,10 +4896,6 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
4922
4896
  * @description Executes the query and retrieves a single result.
4923
4897
  */
4924
4898
  one(): Promise<AnnotatedModel<T, any, any> | null>;
4925
- /**
4926
- * @alias one
4927
- */
4928
- first(): Promise<AnnotatedModel<T, any, any> | null>;
4929
4899
  /**
4930
4900
  * @description Executes the query and retrieves the first result. Fail if no result is found.
4931
4901
  */
@@ -5172,10 +5142,6 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
5172
5142
  * @description Makes a one query and returns the time that took to execute that query
5173
5143
  */
5174
5144
  private oneWithPerformance;
5175
- /**
5176
- * @alias oneWithPerformance
5177
- */
5178
- private firstWithPerformance;
5179
5145
  /**
5180
5146
  * @alias oneOrFailWithPerformance
5181
5147
  */
@@ -5346,7 +5312,7 @@ declare abstract class Model extends Entity {
5346
5312
  static dryQuery<T extends Model>(this: new () => T | typeof Model, options?: Omit<BaseModelMethodOptions, "ignoreHooks">): DryModelQueryBuilderWithoutReadOperations<T>;
5347
5313
  /**
5348
5314
  * @description Finds the first record in the database
5349
- * @deprecated Used only for debugging purposes, use findOne or query instead
5315
+ * @deprecated Used only for debugging purposes, use `.findOne` or `.query` instead
5350
5316
  */
5351
5317
  static first<T extends Model>(this: new () => T | typeof Model, options?: BaseModelMethodOptions): Promise<AnnotatedModel<T, {}> | null>;
5352
5318
  /**
@@ -5539,6 +5505,76 @@ declare abstract class Model extends Entity {
5539
5505
  * @javascript
5540
5506
  */
5541
5507
  static column(columnName: string, ...args: Parameters<typeof column>): void;
5508
+ /**
5509
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5510
+ * @javascript
5511
+ */
5512
+ static dateColumn(columnName: string, ...args: Parameters<(typeof column)["date"]>): void;
5513
+ /**
5514
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5515
+ * @javascript
5516
+ */
5517
+ static datetimeColumn(columnName: string, ...args: Parameters<(typeof column)["datetime"]>): void;
5518
+ /**
5519
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5520
+ * @javascript
5521
+ */
5522
+ static timestampColumn(columnName: string, ...args: Parameters<(typeof column)["timestamp"]>): void;
5523
+ /**
5524
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5525
+ * @javascript
5526
+ */
5527
+ static timeColumn(columnName: string, ...args: Parameters<(typeof column)["time"]>): void;
5528
+ /**
5529
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5530
+ * @javascript
5531
+ */
5532
+ static booleanColumn(columnName: string, ...args: Parameters<(typeof column)["boolean"]>): void;
5533
+ /**
5534
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5535
+ * @javascript
5536
+ */
5537
+ static jsonColumn(columnName: string, ...args: Parameters<(typeof column)["json"]>): void;
5538
+ /**
5539
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5540
+ * @javascript
5541
+ */
5542
+ static uuidColumn(columnName: string, ...args: Parameters<(typeof column)["uuid"]>): void;
5543
+ /**
5544
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5545
+ * @javascript
5546
+ */
5547
+ static ulidColumn(columnName: string, ...args: Parameters<(typeof column)["ulid"]>): void;
5548
+ /**
5549
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5550
+ * @javascript
5551
+ */
5552
+ static integerColumn(columnName: string, ...args: Parameters<(typeof column)["integer"]>): void;
5553
+ /**
5554
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5555
+ * @javascript
5556
+ */
5557
+ static floatColumn(columnName: string, ...args: Parameters<(typeof column)["float"]>): void;
5558
+ /**
5559
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5560
+ * @javascript
5561
+ */
5562
+ static incrementColumn(columnName: string, ...args: Parameters<(typeof column)["increment"]>): void;
5563
+ /**
5564
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5565
+ * @javascript
5566
+ */
5567
+ static bigIncrementColumn(columnName: string, ...args: Parameters<(typeof column)["bigIncrement"]>): void;
5568
+ /**
5569
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5570
+ * @javascript
5571
+ */
5572
+ static encryptionSymmetricColumn(columnName: string, ...args: Parameters<(typeof column)["encryption"]["symmetric"]>): void;
5573
+ /**
5574
+ * @description Defines a column in the model, useful in javascript in order to not have to rely on decorators since are not supported without a transpiler like babel
5575
+ * @javascript
5576
+ */
5577
+ static encryptionAsymmetricColumn(columnName: string, ...args: Parameters<(typeof column)["encryption"]["asymmetric"]>): void;
5542
5578
  /**
5543
5579
  * @description Defines an hasOne relation
5544
5580
  * @javascript
@@ -5861,39 +5897,155 @@ declare class ModelFactory<M extends Model> {
5861
5897
  }
5862
5898
  declare const createModelFactory: <M extends Model>(typeofModel: typeof Model, modelData: Partial<ModelWithoutRelations<M>>) => ModelFactory<M>;
5863
5899
 
5900
+ type Constructor<T = Model> = new (...args: any[]) => T;
5901
+ type AbstractConstructor<T = Model> = abstract new (...args: any[]) => T;
5902
+ type AnyConstructor<T = Model> = Constructor<T> | AbstractConstructor<T>;
5903
+
5904
+ interface BigIntFields {
5905
+ id: number;
5906
+ }
5864
5907
  /**
5865
- * @description Mixin to add createdAt, updatedAt and deletedAt columns to a model
5908
+ * Mixin to add a bigint primary key column with auto-increment.
5909
+ * Uses bigint database type but TypeScript number type.
5910
+ *
5911
+ * @example
5912
+ * ```ts
5913
+ * class User extends bigIntMixin() {
5914
+ * declare name: string;
5915
+ * }
5916
+ *
5917
+ * // Composable with other mixins
5918
+ * class Post extends timestampMixin(bigIntMixin()) {}
5919
+ * ```
5866
5920
  */
5867
- declare class TimestampedModel extends Model {
5868
- createdAt: Date;
5869
- updatedAt: Date;
5870
- deletedAt: Date | null;
5871
- }
5921
+ declare function bigIntMixin(): typeof Model & Constructor<BigIntFields>;
5922
+ declare function bigIntMixin<TBase extends AnyConstructor>(Base: TBase): TBase & Constructor<BigIntFields>;
5923
+ declare const BigIntMixin: typeof bigIntMixin;
5872
5924
 
5925
+ interface IncrementFields {
5926
+ id: number;
5927
+ }
5873
5928
  /**
5874
- * @description Mixin to add a uuid column to a model
5929
+ * Mixin to add an auto-incrementing integer primary key column.
5930
+ *
5931
+ * @example
5932
+ * ```ts
5933
+ * class User extends incrementMixin() {
5934
+ * declare name: string;
5935
+ * }
5936
+ *
5937
+ * // Composable with other mixins
5938
+ * class Post extends timestampMixin(incrementMixin()) {}
5939
+ * ```
5875
5940
  */
5876
- declare class UuidModel extends Model {
5941
+ declare function incrementMixin(): typeof Model & Constructor<IncrementFields>;
5942
+ declare function incrementMixin<TBase extends AnyConstructor>(Base: TBase): TBase & Constructor<IncrementFields>;
5943
+ declare const IncrementMixin: typeof incrementMixin;
5944
+
5945
+ interface UlidFields {
5877
5946
  id: string;
5878
5947
  }
5879
-
5880
5948
  /**
5881
- * @description Mixin to add an autogenerated id column to a model
5949
+ * Mixin to add a ULID primary key column.
5950
+ * ULID = Universally Unique Lexicographically Sortable Identifier.
5951
+ * Automatically generates ULID if not provided.
5952
+ *
5953
+ * @example
5954
+ * ```ts
5955
+ * class User extends ulidMixin() {
5956
+ * declare name: string;
5957
+ * }
5958
+ *
5959
+ * // Composable with other mixins
5960
+ * class Post extends timestampMixin(ulidMixin()) {}
5961
+ * ```
5882
5962
  */
5883
- declare class AutogeneratedModel extends Model {
5884
- id: BigInt;
5885
- }
5963
+ declare function ulidMixin(): typeof Model & Constructor<UlidFields>;
5964
+ declare function ulidMixin<TBase extends AnyConstructor>(Base: TBase): TBase & Constructor<UlidFields>;
5965
+ declare const UlidMixin: typeof ulidMixin;
5886
5966
 
5967
+ interface UuidFields {
5968
+ id: string;
5969
+ }
5887
5970
  /**
5888
- * @description Mixin to add a user model with id, email, createdAt, updatedAt and deletedAt columns
5971
+ * Mixin to add a UUID primary key column.
5972
+ * Automatically generates UUID if not provided.
5973
+ *
5974
+ * @example
5975
+ * ```ts
5976
+ * class User extends uuidMixin() {
5977
+ * declare name: string;
5978
+ * }
5979
+ *
5980
+ * // Composable with other mixins
5981
+ * class Post extends timestampMixin(uuidMixin()) {}
5982
+ * ```
5889
5983
  */
5890
- declare class UserMixin extends Model {
5891
- id: BigInt;
5892
- email: string;
5984
+ declare function uuidMixin(): typeof Model & Constructor<UuidFields>;
5985
+ declare function uuidMixin<TBase extends AnyConstructor>(Base: TBase): TBase & Constructor<UuidFields>;
5986
+ declare const UuidMixin: typeof uuidMixin;
5987
+
5988
+ interface TimestampFields {
5893
5989
  createdAt: Date;
5894
5990
  updatedAt: Date;
5895
5991
  deletedAt: Date | null;
5896
5992
  }
5993
+ /**
5994
+ * Mixin to add timestamp columns for tracking record creation and updates.
5995
+ * Adds createdAt, updatedAt, and deletedAt columns.
5996
+ * - createdAt: Auto-set on record creation
5997
+ * - updatedAt: Auto-set on creation and updates
5998
+ * - deletedAt: Nullable, for soft deletes
5999
+ *
6000
+ * @example
6001
+ * ```ts
6002
+ * class User extends timestampMixin() {
6003
+ * declare name: string;
6004
+ * }
6005
+ *
6006
+ * // Composable with other mixins
6007
+ * class Post extends timestampMixin(uuidMixin()) {}
6008
+ * ```
6009
+ */
6010
+ declare function timestampMixin(): typeof Model & Constructor<TimestampFields>;
6011
+ declare function timestampMixin<TBase extends AnyConstructor>(Base: TBase): TBase & Constructor<TimestampFields>;
6012
+ declare const TimestampMixin: typeof timestampMixin;
6013
+
6014
+ /**
6015
+ * Column definitions map for the mixin factory.
6016
+ * Keys are property names, values are ColumnOptions.
6017
+ */
6018
+ type MixinColumns<TFields> = {
6019
+ [K in keyof TFields]: ColumnOptions;
6020
+ };
6021
+ /**
6022
+ * Creates a custom mixin function with the specified columns.
6023
+ *
6024
+ * @example
6025
+ * ```ts
6026
+ * interface AuditFields {
6027
+ * createdBy: string | null;
6028
+ * updatedBy: string | null;
6029
+ * }
6030
+ *
6031
+ * const auditMixin = createMixin<AuditFields>({
6032
+ * createdBy: { nullable: true },
6033
+ * updatedBy: { nullable: true },
6034
+ * });
6035
+ *
6036
+ * class User extends auditMixin(timestampMixin(uuidMixin())) {
6037
+ * static table = 'users';
6038
+ * }
6039
+ * ```
6040
+ */
6041
+ declare const createMixin: <TFields>(columns: MixinColumns<TFields>) => {
6042
+ (): typeof Model & Constructor<TFields>;
6043
+ <TBase extends AnyConstructor>(base: TBase): TBase & Constructor<TFields>;
6044
+ };
6045
+ declare const MixinFactory: <TFields>(columns: MixinColumns<TFields>) => {
6046
+ (): typeof Model & Constructor<TFields>;
6047
+ <TBase extends AnyConstructor>(base: TBase): TBase & Constructor<TFields>;
6048
+ };
5897
6049
 
5898
6050
  declare class InMemoryAdapter implements CacheAdapter {
5899
6051
  get<T = void>(key: string): Promise<T>;
@@ -6758,4 +6910,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
6758
6910
  $id?: string;
6759
6911
  }>;
6760
6912
 
6761
- export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnnotatedModel, type AsymmetricEncryptionOptions, AutogeneratedModel, type BaseModelMethodOptions, type BaseModelRelationType, BaseSeeder, 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, type MigrationConfig, type MigrationConfigBase, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type ReplicationType, type SeederConfig, 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 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, property, RedisDataSource as redis, unique, view, withPerformance };
6913
+ export { type AbstractConstructor, type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnnotatedModel, type AnyConstructor, type AsymmetricEncryptionOptions, type BaseModelMethodOptions, type BaseModelRelationType, BaseSeeder, type BigIntFields, BigIntMixin, 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 Constructor, type DataSourceInput, type DataSourceType, type DateColumnOptions, DryModelQueryBuilder, DryQueryBuilder, type FetchHooks, type GetConnectionReturnType, HysteriaError, InMemoryAdapter, type IncrementFields, IncrementMixin, type IndexType, type LazyRelationType, type ManyOptions, type ManyToManyOptions, type ManyToManyStringOptions, Migration, type MigrationConfig, type MigrationConfigBase, type MixinColumns, MixinFactory, Model, type ModelInstanceType, ModelQueryBuilder, type ModelWithoutRelations, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type ReplicationType, type SeederConfig, 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 SymmetricEncryptionOptions, type TableFormat, type ThroughModel, type TimestampFields, TimestampMixin, Transaction, type TransactionExecutionOptions, type UlidFields, UlidMixin, type UniqueType, type UseCacheReturnType, type UseConnectionInput, type UuidFields, UuidMixin, belongsTo, bigIntMixin, column, createMixin, createModelFactory, defineMigrator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, getCollectionProperties, getIndexes, getModelColumns, type getPoolReturnType, getPrimaryKey, getRelations, getRelationsMetadata, getUniques, hasMany, hasOne, incrementMixin, index, HysteriaLogger as logger, manyToMany, property, RedisDataSource as redis, timestampMixin, ulidMixin, unique, uuidMixin, view, withPerformance };