hysteria-orm 10.2.2 → 10.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.cts CHANGED
@@ -1,3 +1,5 @@
1
+ import * as mssql from 'mssql';
2
+ import { config, Transaction as Transaction$1 } from 'mssql';
1
3
  import * as mongodb from 'mongodb';
2
4
  import { Collection as Collection$1 } from 'mongodb';
3
5
  import * as sqlite3 from 'sqlite3';
@@ -32,7 +34,15 @@ declare abstract class Entity {
32
34
  /**
33
35
  * @description Creates a datasource for the selected database type with the provided credentials
34
36
  */
35
- type DataSourceType = "cockroachdb" | "mysql" | "postgres" | "mariadb" | "sqlite" | "mongo";
37
+ type DataSourceType = "cockroachdb" | "mysql" | "postgres" | "mariadb" | "sqlite" | "mssql" | "mongo";
38
+ interface MssqlDataSourceInput extends CommonDataSourceInput {
39
+ readonly type: "mssql";
40
+ readonly host?: string;
41
+ readonly port?: number;
42
+ readonly username?: string;
43
+ readonly password?: string;
44
+ readonly database?: string;
45
+ }
36
46
  interface CommonDataSourceInput {
37
47
  readonly type?: DataSourceType;
38
48
  readonly logs?: boolean;
@@ -85,16 +95,20 @@ interface NotNullableSqliteDataSourceInput extends SqliteDataSourceInput {
85
95
  /**
86
96
  * @description By default the connection details can be provided in the .env file, you can still override each prop with your actual connection details in the input
87
97
  */
88
- type DataSourceInput = MysqlSqlDataSourceInput | SqliteDataSourceInput | PostgresSqlDataSourceInput | MongoDataSourceInput;
98
+ type DataSourceInput = MssqlDataSourceInput | MysqlSqlDataSourceInput | SqliteDataSourceInput | PostgresSqlDataSourceInput | MongoDataSourceInput;
89
99
 
90
100
  type Mysql2Import = typeof mysql2_promise;
91
101
  type PgImport = typeof pg;
92
102
  type Sqlite3Import = typeof sqlite3;
93
103
  type MongoClientImport = typeof mongodb;
104
+ type MssqlImport = typeof mssql;
94
105
  type MysqlCreateConnectionOptions = PoolOptions;
95
106
  type PgClientOptions = ClientConfig;
107
+ type MssqlConnectionOptions = Omit<config, "options"> & {
108
+ options?: Omit<NonNullable<config["options"]>, "abortTransactionOnError" | "enableImplicitTransactions">;
109
+ };
96
110
  type MongoConnectionOptions = NonNullable<ConstructorParameters<MongoClientImport["MongoClient"]>[1]>;
97
- type DriverSpecificOptions<T extends DataSourceType> = T extends "mongo" ? MongoConnectionOptions : T extends "cockroachdb" | "postgres" ? PgClientOptions : T extends "redis" ? RedisOptions : T extends "mysql" | "mariadb" ? MysqlCreateConnectionOptions : never;
111
+ type DriverSpecificOptions<T extends DataSourceType> = T extends "mongo" ? MongoConnectionOptions : T extends "cockroachdb" | "postgres" ? PgClientOptions : T extends "redis" ? RedisOptions : T extends "mysql" | "mariadb" ? MysqlCreateConnectionOptions : T extends "mssql" ? MssqlConnectionOptions : never;
98
112
 
99
113
  type MongoCollectionKey<T> = T extends Collection ? T : never;
100
114
  type BaseModelMethodOptions$1 = {
@@ -436,6 +450,7 @@ declare abstract class DataSource {
436
450
  protected handleMysqlSource(input?: MysqlSqlDataSourceInput): void;
437
451
  protected handleSqliteSource(input?: SqliteDataSourceInput): void;
438
452
  protected handleMongoSource(input?: MongoDataSourceInput): void;
453
+ protected handleMssqlSource(input?: MssqlDataSourceInput): void;
439
454
  }
440
455
 
441
456
  type MongoFindOneOptions<T extends Collection> = {
@@ -1099,7 +1114,7 @@ declare class ConstraintNode extends QueryNode {
1099
1114
  constraintName?: string;
1100
1115
  onDelete?: "cascade" | "restrict" | "set null" | "no action";
1101
1116
  onUpdate?: "cascade" | "restrict" | "set null" | "no action";
1102
- defaultValue?: string;
1117
+ defaultValue?: string | RawNode | undefined;
1103
1118
  checkExpression?: string;
1104
1119
  chainsWith: string;
1105
1120
  canKeywordBeSeenMultipleTimes: boolean;
@@ -1114,7 +1129,7 @@ declare class ConstraintNode extends QueryNode {
1114
1129
  constraintName?: string;
1115
1130
  onDelete?: "cascade" | "restrict" | "set null" | "no action";
1116
1131
  onUpdate?: "cascade" | "restrict" | "set null" | "no action";
1117
- defaultValue?: string;
1132
+ defaultValue?: string | RawNode | undefined;
1118
1133
  checkExpression?: string;
1119
1134
  }, isRawValue?: boolean);
1120
1135
  }
@@ -1217,7 +1232,7 @@ declare class ConstraintBuilder extends BaseBuilder {
1217
1232
  * @description Sets the default value for the column
1218
1233
  * @param value is the default value for the column
1219
1234
  */
1220
- default(value: string | number | boolean | null): this;
1235
+ default(value: string | number | boolean | null | RawNode): this;
1221
1236
  /**
1222
1237
  * @description Sets the column to unique
1223
1238
  * @param options is the options for the unique constraint
@@ -1523,35 +1538,42 @@ declare class AlterTableBuilder extends BaseBuilder {
1523
1538
  /**
1524
1539
  * @description Adds a column to the table
1525
1540
  * @param cb is the callback that will be used to build the column
1541
+ * @mssql Auto-generates default constraint names (DF__table__col__xxxxx) which are hard to drop later
1526
1542
  */
1527
1543
  addColumn(cb: (col: CreateTableBuilder) => ConstraintBuilder): void;
1528
1544
  /**
1529
1545
  * @description Alters a column, can generate multiple sql statements depending on the constraints
1530
1546
  * @throws HysteriaError if sqlite database
1547
+ * @mssql Cannot alter columns with DEFAULT/CHECK constraints or indexes - drop them first
1531
1548
  */
1532
1549
  alterColumn(columnBuilder: (col: CreateTableBuilder) => ConstraintBuilder): void;
1533
1550
  /**
1534
1551
  * @description Drops a column
1552
+ * @mssql Must drop all dependent constraints and indexes before dropping the column
1535
1553
  */
1536
1554
  dropColumn(name: string): void;
1537
1555
  /**
1538
1556
  * @description Renames a column
1557
+ * @mssql Uses sp_rename procedure; does not update references in views/procedures/triggers
1539
1558
  */
1540
1559
  renameColumn(oldName: string, newName: string): void;
1541
1560
  /**
1542
1561
  * @description Drops a default value from a column
1543
1562
  * @sqlite not supported and will throw error
1563
+ * @mssql Requires constraint name; use dropConstraint() with name from sys.default_constraints
1544
1564
  */
1545
1565
  dropDefault(columnName: string): void;
1546
1566
  /**
1547
1567
  * @description Adds a primary key constraint to a column
1548
1568
  * @param columnName is the column name to add the primary key to
1549
1569
  * @sqlite not supported and will throw error
1570
+ * @mssql Column must be NOT NULL before adding primary key
1550
1571
  */
1551
1572
  addPrimaryKey(columnName: string): void;
1552
1573
  /**
1553
1574
  * @description Raw non type safe way builder to add a constraint
1554
1575
  * @sqlite not supported and will throw error
1576
+ * @mssql UNIQUE does not allow multiple NULLs (unlike PostgreSQL)
1555
1577
  */
1556
1578
  addConstraint(...options: ConstructorParameters<typeof ConstraintNode>): void;
1557
1579
  /**
@@ -1597,6 +1619,7 @@ declare class AlterTableBuilder extends BaseBuilder {
1597
1619
  * @postgres not supported, use `dropConstraint` instead with the pk constraint name
1598
1620
  * @sqlite not supported and will throw error
1599
1621
  * @throws HysteriaError if postgres and table is not provided
1622
+ * @mssql Foreign keys referencing this primary key must be dropped first
1600
1623
  */
1601
1624
  dropPrimaryKey(table?: string): void;
1602
1625
  }
@@ -1616,12 +1639,14 @@ declare class Schema {
1616
1639
  runFile(filePath: string): void;
1617
1640
  /**
1618
1641
  * @description Create table constructor
1642
+ * @mssql Does not support ifNotExists option
1619
1643
  */
1620
1644
  createTable(table: string, cb: (table: CreateTableBuilder) => void, options?: {
1621
1645
  ifNotExists?: boolean;
1622
1646
  }): void;
1623
1647
  /**
1624
1648
  * @description Alter table constructor
1649
+ * @mssql Limited support - cannot modify columns with constraints; see AlterTableBuilder methods for details
1625
1650
  */
1626
1651
  alterTable(table: string, cb: (t: AlterTableBuilder) => void): void;
1627
1652
  /**
@@ -1630,6 +1655,7 @@ declare class Schema {
1630
1655
  dropTable(table: string, ifExists?: boolean): void;
1631
1656
  /**
1632
1657
  * @description Rename table in the database
1658
+ * @mssql Uses sp_rename procedure; does not update references in views/procedures/triggers
1633
1659
  */
1634
1660
  renameTable(oldTable: string, newTable: string): void;
1635
1661
  /**
@@ -2582,23 +2608,44 @@ declare abstract class WhereQueryBuilder<T extends Model> extends SelectQueryBui
2582
2608
  orWhereNotNull<S extends string>(column: SelectableColumn<S>): this;
2583
2609
  /**
2584
2610
  * @description Adds a WHERE REGEXP condition to the query.
2611
+ * @mssql doesn't support REGEXP syntax
2612
+ * @sqlite doesn't support REGEXP syntax
2585
2613
  */
2586
2614
  whereRegexp(column: ModelKey<T>, regexp: RegExp): this;
2587
2615
  whereRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
2588
2616
  /**
2589
2617
  * @description Adds an AND WHERE REGEXP condition to the query.
2618
+ * @mssql doesn't support REGEXP syntax
2619
+ * @sqlite doesn't support REGEXP syntax
2590
2620
  */
2591
2621
  andWhereRegexp(column: ModelKey<T>, regexp: RegExp): this;
2592
2622
  andWhereRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
2593
2623
  /**
2594
2624
  * @description Adds an OR WHERE REGEXP condition to the query.
2625
+ * @mssql doesn't support REGEXP syntax
2626
+ * @sqlite doesn't support REGEXP syntax
2595
2627
  */
2596
2628
  orWhereRegexp(column: ModelKey<T>, regexp: RegExp): this;
2597
2629
  orWhereRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
2630
+ /**
2631
+ * @description Adds a WHERE NOT REGEXP condition to the query.
2632
+ * @mssql doesn't support REGEXP syntax
2633
+ * @sqlite doesn't support REGEXP syntax
2634
+ */
2598
2635
  whereNotRegexp(column: ModelKey<T>, regexp: RegExp): this;
2599
2636
  whereNotRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
2637
+ /**
2638
+ * @description Adds an AND WHERE NOT REGEXP condition to the query.
2639
+ * @mssql doesn't support REGEXP syntax
2640
+ * @sqlite doesn't support REGEXP syntax
2641
+ */
2600
2642
  andWhereNotRegexp(column: ModelKey<T>, regexp: RegExp): this;
2601
2643
  andWhereNotRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
2644
+ /**
2645
+ * @description Adds an OR WHERE NOT REGEXP condition to the query.
2646
+ * @mssql doesn't support REGEXP syntax
2647
+ * @sqlite doesn't support REGEXP syntax
2648
+ */
2602
2649
  orWhereNotRegexp(column: ModelKey<T>, regexp: RegExp): this;
2603
2650
  orWhereNotRegexp<S extends string>(column: SelectableColumn<S>, regexp: RegExp): this;
2604
2651
  /**
@@ -2680,47 +2727,55 @@ declare class JsonQueryBuilder<T extends Model> extends WhereQueryBuilder<T> {
2680
2727
  whereJson(column: string, value: JsonParam): this;
2681
2728
  /**
2682
2729
  * @description Filters records matching the given JSON value.
2730
+ * @mssql Partial JSON matching not supported - only exact matches work
2683
2731
  */
2684
2732
  andWhereJson(column: ModelKey<T>, value: JsonParam): this;
2685
2733
  andWhereJson(column: string, value: JsonParam): this;
2686
2734
  /**
2687
2735
  * @description Filters records matching the given JSON value.
2736
+ * @mssql Partial JSON matching not supported - only exact matches work
2688
2737
  */
2689
2738
  orWhereJson(column: ModelKey<T>, value: JsonParam): this;
2690
2739
  orWhereJson(column: string, value: JsonParam): this;
2691
2740
  /**
2692
2741
  * @description Filters records where JSON column does NOT contain the given value.
2693
2742
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
2743
+ * @mssql not supported - CHARINDEX cannot do partial JSON containment
2694
2744
  */
2695
2745
  whereJsonNotContains(column: ModelKey<T>, value: JsonParam): this;
2696
2746
  whereJsonNotContains(column: string, value: JsonParam): this;
2697
2747
  /**
2698
2748
  * @description Filters records where JSON column does NOT contain the given value (AND).
2699
2749
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
2750
+ * @mssql not supported - CHARINDEX cannot do partial JSON containment
2700
2751
  */
2701
2752
  andWhereJsonNotContains(column: ModelKey<T>, value: JsonParam): this;
2702
2753
  andWhereJsonNotContains(column: string, value: JsonParam): this;
2703
2754
  /**
2704
2755
  * @description Filters records where JSON column does NOT contain the given value (OR).
2705
2756
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
2757
+ * @mssql not supported - CHARINDEX cannot do partial JSON containment
2706
2758
  */
2707
2759
  orWhereJsonNotContains(column: ModelKey<T>, value: JsonParam): this;
2708
2760
  orWhereJsonNotContains(column: string, value: JsonParam): this;
2709
2761
  /**
2710
2762
  * @description Filters records where JSON column contains the given value.
2711
2763
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
2764
+ * @mssql not supported - CHARINDEX cannot do partial JSON containment
2712
2765
  */
2713
2766
  whereJsonContains(column: ModelKey<T>, value: JsonParam): this;
2714
2767
  whereJsonContains(column: string, value: JsonParam): this;
2715
2768
  /**
2716
2769
  * @description Filters records where JSON column contains the given value (AND).
2717
2770
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
2771
+ * @mssql not supported - CHARINDEX cannot do partial JSON containment
2718
2772
  */
2719
2773
  andWhereJsonContains(column: ModelKey<T>, value: JsonParam): this;
2720
2774
  andWhereJsonContains(column: string, value: JsonParam): this;
2721
2775
  /**
2722
2776
  * @description Filters records where JSON column contains the given value (OR).
2723
2777
  * @sqlite might not work for all cases, suggest using the whereJsonRaw method instead
2778
+ * @mssql not supported - CHARINDEX cannot do partial JSON containment
2724
2779
  */
2725
2780
  orWhereJsonContains(column: ModelKey<T>, value: JsonParam): this;
2726
2781
  orWhereJsonContains(column: string, value: JsonParam): this;
@@ -2913,6 +2968,7 @@ declare class Transaction {
2913
2968
  private releaseConnection;
2914
2969
  private getIsolationLevelQuery;
2915
2970
  private getSavePointName;
2971
+ private getMssqlTransactionLevel;
2916
2972
  }
2917
2973
 
2918
2974
  type ModelWithoutRelations<T extends Model> = Pick<T, ExcludeRelations<Omit<T, "*">>>;
@@ -3127,6 +3183,8 @@ declare class ModelQueryBuilder<T extends Model, A extends Record<string, any> =
3127
3183
  * @warning Many to many relations have special behavior, since they require a join, a join clause will always be added to the query.
3128
3184
  * @warning Many to many relations uses the model foreign key for mapping in the `$annotations` property, this property will be removed from the model after the relation is filled.
3129
3185
  * @warning Foreign keys should always be selected in the relation query builder, otherwise the relation will not be filled.
3186
+ * @mssql HasMany relations with limit/offset and orderByRaw may fail with "Ambiguous column name" error - use fully qualified column names (e.g., `table.column`) in orderByRaw
3187
+ * @cockroachdb HasMany relations with limit/offset and orderByRaw may fail with "Ambiguous column name" error - use fully qualified column names (e.g., `table.column`) in orderByRaw
3130
3188
  */
3131
3189
  load<RelationKey extends ModelRelation<T>, IA extends Record<string, any> = {}, IR extends Record<string, any> = {}>(relation: RelationKey, cb: (queryBuilder: RelationQueryBuilderType<RelatedInstance<T, RelationKey>>) => RelationQueryBuilderType<RelatedInstance<T, RelationKey>, IA, IR>): ModelQueryBuilder<T, A, R & {
3132
3190
  [K in RelationKey]: Awaited<ReturnType<ModelQueryBuilder<RelatedInstance<T, K>, IA, IR>[RelationRetrieveMethod<T[K]>]>>;
@@ -3292,6 +3350,10 @@ declare class ModelManager<T extends Model> {
3292
3350
  */
3293
3351
  insertMany(models: Partial<T>[], options?: InsertOptions<T>): Promise<AnnotatedModel<T, {}>[]>;
3294
3352
  upsertMany(conflictColumns: string[], columnsToUpdate: string[], data: ModelWithoutRelations<T>[], options?: UpsertOptions<T>): Promise<AnnotatedModel<T, {}>[]>;
3353
+ /**
3354
+ * @description Executes a MERGE statement for MSSQL upsert operations
3355
+ */
3356
+ private executeMssqlMerge;
3295
3357
  /**
3296
3358
  * @description Updates a record, returns the updated record
3297
3359
  * @description Model is retrieved from the database using the primary key regardless of any model hooks
@@ -3384,6 +3446,10 @@ declare class SqlDataSource extends DataSource {
3384
3446
  * @description Maps global keys to specific handlers for cache handling
3385
3447
  */
3386
3448
  cacheKeys: CacheKeys;
3449
+ /**
3450
+ * @description The path to the migrations folder for the sql data source, it's used to configure the migrations path for the sql data source
3451
+ */
3452
+ migrationsPath: string;
3387
3453
  /**
3388
3454
  * @description AdminJS configuration options
3389
3455
  */
@@ -3778,7 +3844,9 @@ type SqlDriverSpecificOptions<T extends DataSourceType> = Omit<DriverSpecificOpt
3778
3844
  type MysqlConnectionInstance = Awaited<ReturnType<Mysql2Import["createPool"]>>;
3779
3845
  type PgPoolClientInstance = InstanceType<PgImport["Pool"]>;
3780
3846
  type SqliteConnectionInstance = InstanceType<Sqlite3Import["Database"]>;
3781
- type SqlPoolType = MysqlConnectionInstance | PgPoolClientInstance | SqliteConnectionInstance;
3847
+ type MssqlPoolInstance = InstanceType<MssqlImport["ConnectionPool"]>;
3848
+ type MssqlConnectionInstance = Awaited<ReturnType<MssqlPoolInstance["connect"]>>;
3849
+ type SqlPoolType = MysqlConnectionInstance | PgPoolClientInstance | SqliteConnectionInstance | MssqlPoolInstance;
3782
3850
  /**
3783
3851
  * @description The connection policies for the sql data source
3784
3852
  * @default By default, the connection policies are not set, so no query will be retried
@@ -3821,6 +3889,11 @@ type SqlDataSourceInput<D extends SqlDataSourceType, T extends Record<string, Sq
3821
3889
  * @warning For usage with types, you must have driver types installed if the driver handles types in a type package like e.g. `@types/pg`
3822
3890
  */
3823
3891
  driverOptions?: SqlDriverSpecificOptions<D>;
3892
+ /**
3893
+ * @description The path to the migrations folder for the sql data source, it's used to configure the migrations path for the sql data source
3894
+ * @default "database/migrations"
3895
+ */
3896
+ migrationsPath?: string;
3824
3897
  /**
3825
3898
  * @description The cache strategy to use for the sql data source, it's used to configure the cache strategy for the sql data source
3826
3899
  */
@@ -3833,7 +3906,7 @@ type SqlDataSourceInput<D extends SqlDataSourceType, T extends Record<string, Sq
3833
3906
  * @description To use AdminJS, install: `npm install adminjs`
3834
3907
  */
3835
3908
  adminJs?: AdminJsOptions;
3836
- } & (MysqlSqlDataSourceInput | PostgresSqlDataSourceInput | SqliteDataSourceInput);
3909
+ } & (MysqlSqlDataSourceInput | MssqlDataSourceInput | PostgresSqlDataSourceInput | SqliteDataSourceInput);
3837
3910
  type UseConnectionInput<D extends SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}> = {
3838
3911
  readonly type: Exclude<DataSourceType, "mongo">;
3839
3912
  readonly logs?: boolean;
@@ -3859,8 +3932,8 @@ type SqlCloneOptions = {
3859
3932
  */
3860
3933
  shouldRecreatePool?: boolean;
3861
3934
  };
3862
- 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;
3863
- 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;
3935
+ type getPoolReturnType<T = SqlDataSourceType> = T extends "mysql" ? MysqlConnectionInstance : T extends "mariadb" ? MysqlConnectionInstance : T extends "postgres" ? PgPoolClientInstance : T extends "cockroachdb" ? PgPoolClientInstance : T extends "sqlite" ? SqliteConnectionInstance : T extends "mssql" ? MssqlPoolInstance : never;
3936
+ 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"]> : T extends "mssql" ? Transaction$1 : never;
3864
3937
  type UseCacheOverloads<C extends CacheKeys> = {
3865
3938
  <K extends keyof C>(key: K, ...args: Parameters<C[K]>): Promise<UseCacheReturnType<C, K>>;
3866
3939
  <K extends keyof C>(key: K, ttl: number, ...args: Parameters<C[K]>): Promise<UseCacheReturnType<C, K>>;
@@ -3895,6 +3968,12 @@ declare class AstParser {
3895
3968
  * Map the database type to a common type if shares the same driver (e.g. mysql and mariadb)
3896
3969
  */
3897
3970
  private mapCommonDbType;
3971
+ /**
3972
+ * @description Generates MSSQL table hints from lock node
3973
+ * MSSQL uses WITH (UPDLOCK), WITH (HOLDLOCK), etc. as table hints
3974
+ * READPAST is the MSSQL equivalent of SKIP LOCKED
3975
+ */
3976
+ private getMssqlTableHints;
3898
3977
  }
3899
3978
 
3900
3979
  declare class DeleteNode extends QueryNode {
@@ -4196,6 +4275,7 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
4196
4275
  with(alias: string, cb: (qb: QueryBuilder<T>) => void): this;
4197
4276
  /**
4198
4277
  * @description Adds a recursive CTE to the query using a callback to build the subquery.
4278
+ * @mssql not supported
4199
4279
  */
4200
4280
  withRecursive(alias: string, cb: (qb: QueryBuilder<T>) => void): this;
4201
4281
  /**
@@ -4232,6 +4312,10 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
4232
4312
  * @param options Upsert options including updateOnConflict and returning columns
4233
4313
  */
4234
4314
  upsertMany<O extends Record<string, any>>(conflictColumns: string[], columnsToUpdate: string[], data: O[], options?: UpsertOptionsRawBuilder): Promise<T[]>;
4315
+ /**
4316
+ * @description Executes a MERGE statement for MSSQL upsert operations (raw query builder)
4317
+ */
4318
+ private executeMssqlMergeRaw;
4235
4319
  /**
4236
4320
  * @description Updates records from a table
4237
4321
  * @returns the number of affected rows
@@ -4318,6 +4402,15 @@ declare class QueryBuilder<T extends Model = any> extends JsonQueryBuilder<T> {
4318
4402
  private softDeleteWithPerformance;
4319
4403
  private deleteWithPerformance;
4320
4404
  private truncateWithPerformance;
4405
+ /**
4406
+ * @description Checks if the current context is an MSSQL transaction
4407
+ * @description MSSQL transactions can only handle one request at a time
4408
+ */
4409
+ protected isMssqlTransaction(): boolean;
4410
+ /**
4411
+ * @description Executes pagination queries, serializing them for MSSQL transactions
4412
+ */
4413
+ protected executePaginateQueries<M, C>(modelsQuery: () => Promise<M>, countQuery: () => Promise<C>): Promise<[M, C]>;
4321
4414
  }
4322
4415
 
4323
4416
  type UnionCallBack<T extends Model> = (queryBuilder: QueryBuilder<T>) => QueryBuilder<T>;
@@ -5770,7 +5863,7 @@ type WithPerformanceResult<R = any> = [string, R];
5770
5863
  */
5771
5864
  declare const withPerformance: <A extends any[], R>(fn: (...args: A) => Promise<R>, returnType?: "millis" | "seconds", fix?: number) => (...args: A) => Promise<WithPerformanceResult<R>>;
5772
5865
 
5773
- 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" | "ADMINJS_NOT_ENABLED" | "ADMINJS_INITIALIZATION_FAILED" | "ADMINJS_NO_MODELS_PROVIDED";
5866
+ type HysteriaErrorCode = `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";
5774
5867
 
5775
5868
  declare class HysteriaError extends Error {
5776
5869
  code: HysteriaErrorCode;
@@ -5795,4 +5888,4 @@ declare const generateOpenApiModelWithMetadata: <T extends new () => Model>(mode
5795
5888
  $id?: string;
5796
5889
  }>;
5797
5890
 
5798
- 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, 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 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, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };
5891
+ 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, 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 MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NumberModelKey, type OneOptions, type PgPoolClientInstance, type PostgresSqlDataSourceInput, QueryBuilder, type RawModelOptions, RawNode, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationQueryBuilderType, type SqlCloneOptions, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDataSourceWithoutTransaction, 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, MongoDataSource as mongo, property, RedisDataSource as redis, SqlDataSource as sql, unique, view, withPerformance };