hysteria-orm 11.0.11 → 11.1.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
@@ -1999,6 +1999,33 @@ declare class InterpreterUtils {
1999
1999
  private readonly autoUpdateColumns;
2000
2000
  constructor(model: typeof Model);
2001
2001
  formatStringColumn(dbType: SqlDataSourceType, column: string): string;
2002
+ /**
2003
+ * @description Returns the raw SQL expression of a computed column, if the given
2004
+ * reference points to one. Strips an optional table prefix before looking up the
2005
+ * model column metadata. Returns `undefined` for non-computed columns.
2006
+ * @internal
2007
+ */
2008
+ resolveComputedExpression(column: string): string | undefined;
2009
+ /**
2010
+ * @description Returns true if the given column name (model property name)
2011
+ * refers to a computed (virtual) column.
2012
+ * @internal
2013
+ */
2014
+ isComputedColumn(column: string): boolean;
2015
+ /**
2016
+ * @description Removes computed (virtual) columns from a list of column names.
2017
+ * Computed columns are never persisted and must not appear in INSERT, UPDATE,
2018
+ * or ON CONFLICT / ON DUPLICATE KEY UPDATE clauses.
2019
+ * @internal
2020
+ */
2021
+ filterComputedColumns(columns: string[]): string[];
2022
+ /**
2023
+ * @description Strips computed (virtual) columns from a data object.
2024
+ * Used before building AST nodes so computed columns never appear in
2025
+ * generated SQL (neither in execution nor in `toSql()` / `unWrap()` previews).
2026
+ * @internal
2027
+ */
2028
+ stripComputedFromData<T extends Record<string, any>>(data: T): T;
2002
2029
  /**
2003
2030
  * @description Formats a column WITHOUT table qualification.
2004
2031
  * ON CONFLICT target lists (Postgres/SQLite) and `excluded.<col>` refs require
@@ -2942,12 +2969,13 @@ type StreamOptions = {
2942
2969
  /** Mysql only */
2943
2970
  objectMode?: boolean;
2944
2971
  };
2972
+ type CursorValue = string | number;
2945
2973
  type Cursor<T extends Model, K extends ModelKey<T>> = {
2946
- key: K;
2947
- value: string | number;
2974
+ key: K | K[];
2975
+ value: CursorValue | CursorValue[];
2948
2976
  };
2949
2977
  type PaginateWithCursorOptions<T extends Model, K extends ModelKey<T>> = {
2950
- discriminator: K;
2978
+ discriminator: K | K[];
2951
2979
  operator?: "<" | ">";
2952
2980
  orderBy?: "asc" | "desc";
2953
2981
  };
@@ -3307,6 +3335,15 @@ type ColumnOptions = {
3307
3335
  * @migration Only affects auto-generated migrations
3308
3336
  */
3309
3337
  zerofill?: boolean;
3338
+ /**
3339
+ * @description Marks the column as a computed (virtual) column. The value is
3340
+ * computed by the database at query time from this raw SQL expression instead
3341
+ * of being stored as a physical column.
3342
+ * @description Computed columns are excluded from migrations and never written
3343
+ * on insert/update. They only appear in results when explicitly selected.
3344
+ * @internal Set via `col.computed()` / `@column.computed()`.
3345
+ */
3346
+ expression?: string;
3310
3347
  } &
3311
3348
  /**
3312
3349
  * @description The data type of the column
@@ -3338,6 +3375,12 @@ type ColumnType = {
3338
3375
  default?: string | number | null | boolean;
3339
3376
  };
3340
3377
  validate?: Validator | Validator[];
3378
+ /**
3379
+ * @description Raw SQL expression for computed (virtual) columns set via
3380
+ * `col.computed()` / `@column.computed()`. The value is computed by the
3381
+ * database at query time and is not a physical column.
3382
+ */
3383
+ expression?: string;
3341
3384
  };
3342
3385
  type IndexType = {
3343
3386
  columns: string[];
@@ -3766,6 +3809,17 @@ declare class SelectQueryBuilder<T extends Model, S extends Record<string, any>
3766
3809
  * @description Clears the SELECT clause
3767
3810
  */
3768
3811
  clearSelect(): this;
3812
+ /**
3813
+ * @description Resolves a column reference to a computed column definition, if any.
3814
+ * @description Strips an optional table prefix, looks the column up in the model's
3815
+ * column metadata, and returns its raw SQL expression plus the database-convention
3816
+ * alias to use in the SELECT clause. Returns `undefined` for non-computed columns.
3817
+ * @internal
3818
+ */
3819
+ protected resolveComputedColumn(column: string): {
3820
+ expression: string;
3821
+ alias: string;
3822
+ } | undefined;
3769
3823
  /**
3770
3824
  * @description Clears the FROM clause
3771
3825
  */
@@ -4463,7 +4517,7 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
4463
4517
  * @description Allows to avoid offset clause that can be inefficient for large datasets
4464
4518
  * @description If using a model query builder, primary key is used as discriminator by default
4465
4519
  * @param options - The options for the paginate with cursor
4466
- * @param options.discriminator - The discriminator to use for the paginate with Cursor pagination
4520
+ * @param options.discriminator - The discriminator (or array of discriminators) to use for the paginate with Cursor pagination. Passing an array enables composite cursor pagination across multiple columns.
4467
4521
  * @param options.operator - The operator to use for the paginate with Cursor pagination
4468
4522
  * @param options.orderBy - The order by to use for the paginate with Cursor pagination
4469
4523
  * @param cursor - The cursor to use for the paginate with Cursor pagination
@@ -6826,6 +6880,24 @@ interface ColumnDef<T = unknown> {
6826
6880
  interface PrimaryColumnDef<T = unknown> extends ColumnDef<T> {
6827
6881
  readonly _isPrimary: true;
6828
6882
  }
6883
+ /**
6884
+ * A column descriptor for a computed (virtual) column defined with
6885
+ * `col.computed()` / `@column.computed()`.
6886
+ *
6887
+ * The value is computed by the database at query time from a raw SQL expression.
6888
+ * Computed columns:
6889
+ * - are excluded from auto-generated migrations (they carry no `type`)
6890
+ * - are never written on insert/update
6891
+ * - only appear in query results when explicitly selected
6892
+ * - resolve to the raw expression when referenced in WHERE/ORDER BY/GROUP BY/HAVING
6893
+ *
6894
+ * `T` carries the TypeScript type the column resolves to when selected.
6895
+ * Inferred instance types treat computed columns as `T | undefined` since they
6896
+ * are absent from results unless explicitly selected.
6897
+ */
6898
+ interface ComputedColumnDef<T = unknown> extends ColumnDef<T> {
6899
+ readonly __computed: true;
6900
+ }
6829
6901
  /**
6830
6902
  * Phantom-typed descriptor for a model relation.
6831
6903
  * `T` carries the TypeScript type the relation resolves to at the instance level.
@@ -6896,6 +6968,13 @@ type ColMediumIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare"
6896
6968
  unsigned?: boolean;
6897
6969
  zerofill?: boolean;
6898
6970
  };
6971
+ type ColComputedOptions = Omit<ColumnOptions, "type" | "primaryKey" | "serialize" | "prepare" | "default" | "autoUpdate"> & {
6972
+ /**
6973
+ * Optional callback applied to the value returned from the database before
6974
+ * it is placed on the model instance.
6975
+ */
6976
+ serialize?: (value: any) => any;
6977
+ };
6899
6978
  type RelationConstraintOptions = {
6900
6979
  /**
6901
6980
  * Useful for auto generated migrations to specify the on delete action, it does not affect the code wise implementation
@@ -7243,6 +7322,47 @@ interface ColNamespace {
7243
7322
  */
7244
7323
  asymmetric<O extends ColAsymmetricOptions = ColAsymmetricOptions>(options: O): ColumnDef<NullableColumn<string, O>>;
7245
7324
  };
7325
+ /**
7326
+ * Computed (virtual) column. The value is computed by the database at query
7327
+ * time from the given raw SQL expression instead of being stored as a
7328
+ * physical column (and instead of being computed in TypeScript). Because the
7329
+ * expression is pushed down into the generated SQL, the computation is done
7330
+ * by the database engine — efficient for filtering, sorting and aggregation
7331
+ * directly on the server.
7332
+ *
7333
+ * @param expression The raw SQL expression evaluated by the database at
7334
+ * query time. It references physical columns as they exist in the database
7335
+ * (no case conversion is applied), so it must be written in the database's
7336
+ * own dialect, e.g. `"concat(first_name, last_name)"` or
7337
+ * `"price * quantity"`.
7338
+ * @param options Optional column options (e.g. `databaseName` for a custom
7339
+ * result alias, or `serialize` to transform the returned value).
7340
+ *
7341
+ * Computed columns:
7342
+ * - are excluded from auto-generated migrations
7343
+ * - are never written on insert/update
7344
+ * - only appear in results when explicitly selected (`.select(User.fullName)`
7345
+ * or `[User.fullName, "alias"]` tuples)
7346
+ * - resolve to the raw expression when referenced in WHERE / ORDER BY /
7347
+ * GROUP BY / HAVING
7348
+ *
7349
+ * ```ts
7350
+ * const User = defineModel("users", {
7351
+ * columns: {
7352
+ * id: col.increment(),
7353
+ * firstName: col.string(),
7354
+ * lastName: col.string(),
7355
+ * fullName: col.computed<string>("concat(first_name, last_name)"),
7356
+ * },
7357
+ * });
7358
+ *
7359
+ * // Selected explicitly - result has fullName: string (computed by the DB)
7360
+ * const user = await sql.from(User).select(User.fullName).one();
7361
+ * // Not selected - fullName is absent from the result
7362
+ * const user = await sql.from(User).one();
7363
+ * ```
7364
+ */
7365
+ computed<T = unknown>(expression: string, options?: ColComputedOptions): ComputedColumnDef<T>;
7246
7366
  }
7247
7367
  type IndexDefinition<K extends string = string> = K[] | {
7248
7368
  columns: K[];
@@ -7282,7 +7402,7 @@ type InferPK<C extends Record<string, ColumnDef>> = [
7282
7402
  ExtractPKType<C>
7283
7403
  ] extends [never] ? string | number : ExtractPKType<C>;
7284
7404
  type InferColumns<C extends Record<string, ColumnDef>> = {
7285
- [K in keyof C]: C[K] extends ColumnDef<infer T> ? T : never;
7405
+ [K in keyof C]: C[K] extends ComputedColumnDef<infer T> ? T | undefined : C[K] extends ColumnDef<infer T> ? T : never;
7286
7406
  };
7287
7407
  type InferRelations<R extends Record<string, RelationDef>> = {
7288
7408
  [K in keyof R]: R[K] extends RelationDef<infer V> ? V : never;
@@ -8499,4 +8619,4 @@ type BetterAuthAdapterConfig = Partial<Pick<AdapterFactoryConfig, "usePlural" |
8499
8619
  */
8500
8620
  declare function betterAuthAdapter(sql: SqlDataSource, config?: BetterAuthAdapterConfig): (options: BetterAuthOptions) => DBAdapter;
8501
8621
 
8502
- export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type AtomicOptions, type BaseModelMethodOptions, BaseSeeder, type BetterAuthAdapterConfig, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, type HysteriaErrorCode, InMemoryAdapter, type InferPK, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type MigrationLockConfig, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type OneOptions, type Operation, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PingResult, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type QueryContext, type QueryContextWithDuration, type QueryObserver, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ValidationContext, ValidationError, type ValidationResult, type Validator, type ViewDefinition, WriteOperation, type WriteReturnType, atomic, betterAuthAdapter, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, required, url };
8622
+ export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type AtomicOptions, type BaseModelMethodOptions, BaseSeeder, type BetterAuthAdapterConfig, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColComputedOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ComputedColumnDef, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, type HysteriaErrorCode, InMemoryAdapter, type InferPK, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type MigrationLockConfig, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type OneOptions, type Operation, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PingResult, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type QueryContext, type QueryContextWithDuration, type QueryObserver, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ValidationContext, ValidationError, type ValidationResult, type Validator, type ViewDefinition, WriteOperation, type WriteReturnType, atomic, betterAuthAdapter, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, required, url };
package/lib/index.d.ts CHANGED
@@ -1999,6 +1999,33 @@ declare class InterpreterUtils {
1999
1999
  private readonly autoUpdateColumns;
2000
2000
  constructor(model: typeof Model);
2001
2001
  formatStringColumn(dbType: SqlDataSourceType, column: string): string;
2002
+ /**
2003
+ * @description Returns the raw SQL expression of a computed column, if the given
2004
+ * reference points to one. Strips an optional table prefix before looking up the
2005
+ * model column metadata. Returns `undefined` for non-computed columns.
2006
+ * @internal
2007
+ */
2008
+ resolveComputedExpression(column: string): string | undefined;
2009
+ /**
2010
+ * @description Returns true if the given column name (model property name)
2011
+ * refers to a computed (virtual) column.
2012
+ * @internal
2013
+ */
2014
+ isComputedColumn(column: string): boolean;
2015
+ /**
2016
+ * @description Removes computed (virtual) columns from a list of column names.
2017
+ * Computed columns are never persisted and must not appear in INSERT, UPDATE,
2018
+ * or ON CONFLICT / ON DUPLICATE KEY UPDATE clauses.
2019
+ * @internal
2020
+ */
2021
+ filterComputedColumns(columns: string[]): string[];
2022
+ /**
2023
+ * @description Strips computed (virtual) columns from a data object.
2024
+ * Used before building AST nodes so computed columns never appear in
2025
+ * generated SQL (neither in execution nor in `toSql()` / `unWrap()` previews).
2026
+ * @internal
2027
+ */
2028
+ stripComputedFromData<T extends Record<string, any>>(data: T): T;
2002
2029
  /**
2003
2030
  * @description Formats a column WITHOUT table qualification.
2004
2031
  * ON CONFLICT target lists (Postgres/SQLite) and `excluded.<col>` refs require
@@ -2942,12 +2969,13 @@ type StreamOptions = {
2942
2969
  /** Mysql only */
2943
2970
  objectMode?: boolean;
2944
2971
  };
2972
+ type CursorValue = string | number;
2945
2973
  type Cursor<T extends Model, K extends ModelKey<T>> = {
2946
- key: K;
2947
- value: string | number;
2974
+ key: K | K[];
2975
+ value: CursorValue | CursorValue[];
2948
2976
  };
2949
2977
  type PaginateWithCursorOptions<T extends Model, K extends ModelKey<T>> = {
2950
- discriminator: K;
2978
+ discriminator: K | K[];
2951
2979
  operator?: "<" | ">";
2952
2980
  orderBy?: "asc" | "desc";
2953
2981
  };
@@ -3307,6 +3335,15 @@ type ColumnOptions = {
3307
3335
  * @migration Only affects auto-generated migrations
3308
3336
  */
3309
3337
  zerofill?: boolean;
3338
+ /**
3339
+ * @description Marks the column as a computed (virtual) column. The value is
3340
+ * computed by the database at query time from this raw SQL expression instead
3341
+ * of being stored as a physical column.
3342
+ * @description Computed columns are excluded from migrations and never written
3343
+ * on insert/update. They only appear in results when explicitly selected.
3344
+ * @internal Set via `col.computed()` / `@column.computed()`.
3345
+ */
3346
+ expression?: string;
3310
3347
  } &
3311
3348
  /**
3312
3349
  * @description The data type of the column
@@ -3338,6 +3375,12 @@ type ColumnType = {
3338
3375
  default?: string | number | null | boolean;
3339
3376
  };
3340
3377
  validate?: Validator | Validator[];
3378
+ /**
3379
+ * @description Raw SQL expression for computed (virtual) columns set via
3380
+ * `col.computed()` / `@column.computed()`. The value is computed by the
3381
+ * database at query time and is not a physical column.
3382
+ */
3383
+ expression?: string;
3341
3384
  };
3342
3385
  type IndexType = {
3343
3386
  columns: string[];
@@ -3766,6 +3809,17 @@ declare class SelectQueryBuilder<T extends Model, S extends Record<string, any>
3766
3809
  * @description Clears the SELECT clause
3767
3810
  */
3768
3811
  clearSelect(): this;
3812
+ /**
3813
+ * @description Resolves a column reference to a computed column definition, if any.
3814
+ * @description Strips an optional table prefix, looks the column up in the model's
3815
+ * column metadata, and returns its raw SQL expression plus the database-convention
3816
+ * alias to use in the SELECT clause. Returns `undefined` for non-computed columns.
3817
+ * @internal
3818
+ */
3819
+ protected resolveComputedColumn(column: string): {
3820
+ expression: string;
3821
+ alias: string;
3822
+ } | undefined;
3769
3823
  /**
3770
3824
  * @description Clears the FROM clause
3771
3825
  */
@@ -4463,7 +4517,7 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
4463
4517
  * @description Allows to avoid offset clause that can be inefficient for large datasets
4464
4518
  * @description If using a model query builder, primary key is used as discriminator by default
4465
4519
  * @param options - The options for the paginate with cursor
4466
- * @param options.discriminator - The discriminator to use for the paginate with Cursor pagination
4520
+ * @param options.discriminator - The discriminator (or array of discriminators) to use for the paginate with Cursor pagination. Passing an array enables composite cursor pagination across multiple columns.
4467
4521
  * @param options.operator - The operator to use for the paginate with Cursor pagination
4468
4522
  * @param options.orderBy - The order by to use for the paginate with Cursor pagination
4469
4523
  * @param cursor - The cursor to use for the paginate with Cursor pagination
@@ -6826,6 +6880,24 @@ interface ColumnDef<T = unknown> {
6826
6880
  interface PrimaryColumnDef<T = unknown> extends ColumnDef<T> {
6827
6881
  readonly _isPrimary: true;
6828
6882
  }
6883
+ /**
6884
+ * A column descriptor for a computed (virtual) column defined with
6885
+ * `col.computed()` / `@column.computed()`.
6886
+ *
6887
+ * The value is computed by the database at query time from a raw SQL expression.
6888
+ * Computed columns:
6889
+ * - are excluded from auto-generated migrations (they carry no `type`)
6890
+ * - are never written on insert/update
6891
+ * - only appear in query results when explicitly selected
6892
+ * - resolve to the raw expression when referenced in WHERE/ORDER BY/GROUP BY/HAVING
6893
+ *
6894
+ * `T` carries the TypeScript type the column resolves to when selected.
6895
+ * Inferred instance types treat computed columns as `T | undefined` since they
6896
+ * are absent from results unless explicitly selected.
6897
+ */
6898
+ interface ComputedColumnDef<T = unknown> extends ColumnDef<T> {
6899
+ readonly __computed: true;
6900
+ }
6829
6901
  /**
6830
6902
  * Phantom-typed descriptor for a model relation.
6831
6903
  * `T` carries the TypeScript type the relation resolves to at the instance level.
@@ -6896,6 +6968,13 @@ type ColMediumIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare"
6896
6968
  unsigned?: boolean;
6897
6969
  zerofill?: boolean;
6898
6970
  };
6971
+ type ColComputedOptions = Omit<ColumnOptions, "type" | "primaryKey" | "serialize" | "prepare" | "default" | "autoUpdate"> & {
6972
+ /**
6973
+ * Optional callback applied to the value returned from the database before
6974
+ * it is placed on the model instance.
6975
+ */
6976
+ serialize?: (value: any) => any;
6977
+ };
6899
6978
  type RelationConstraintOptions = {
6900
6979
  /**
6901
6980
  * Useful for auto generated migrations to specify the on delete action, it does not affect the code wise implementation
@@ -7243,6 +7322,47 @@ interface ColNamespace {
7243
7322
  */
7244
7323
  asymmetric<O extends ColAsymmetricOptions = ColAsymmetricOptions>(options: O): ColumnDef<NullableColumn<string, O>>;
7245
7324
  };
7325
+ /**
7326
+ * Computed (virtual) column. The value is computed by the database at query
7327
+ * time from the given raw SQL expression instead of being stored as a
7328
+ * physical column (and instead of being computed in TypeScript). Because the
7329
+ * expression is pushed down into the generated SQL, the computation is done
7330
+ * by the database engine — efficient for filtering, sorting and aggregation
7331
+ * directly on the server.
7332
+ *
7333
+ * @param expression The raw SQL expression evaluated by the database at
7334
+ * query time. It references physical columns as they exist in the database
7335
+ * (no case conversion is applied), so it must be written in the database's
7336
+ * own dialect, e.g. `"concat(first_name, last_name)"` or
7337
+ * `"price * quantity"`.
7338
+ * @param options Optional column options (e.g. `databaseName` for a custom
7339
+ * result alias, or `serialize` to transform the returned value).
7340
+ *
7341
+ * Computed columns:
7342
+ * - are excluded from auto-generated migrations
7343
+ * - are never written on insert/update
7344
+ * - only appear in results when explicitly selected (`.select(User.fullName)`
7345
+ * or `[User.fullName, "alias"]` tuples)
7346
+ * - resolve to the raw expression when referenced in WHERE / ORDER BY /
7347
+ * GROUP BY / HAVING
7348
+ *
7349
+ * ```ts
7350
+ * const User = defineModel("users", {
7351
+ * columns: {
7352
+ * id: col.increment(),
7353
+ * firstName: col.string(),
7354
+ * lastName: col.string(),
7355
+ * fullName: col.computed<string>("concat(first_name, last_name)"),
7356
+ * },
7357
+ * });
7358
+ *
7359
+ * // Selected explicitly - result has fullName: string (computed by the DB)
7360
+ * const user = await sql.from(User).select(User.fullName).one();
7361
+ * // Not selected - fullName is absent from the result
7362
+ * const user = await sql.from(User).one();
7363
+ * ```
7364
+ */
7365
+ computed<T = unknown>(expression: string, options?: ColComputedOptions): ComputedColumnDef<T>;
7246
7366
  }
7247
7367
  type IndexDefinition<K extends string = string> = K[] | {
7248
7368
  columns: K[];
@@ -7282,7 +7402,7 @@ type InferPK<C extends Record<string, ColumnDef>> = [
7282
7402
  ExtractPKType<C>
7283
7403
  ] extends [never] ? string | number : ExtractPKType<C>;
7284
7404
  type InferColumns<C extends Record<string, ColumnDef>> = {
7285
- [K in keyof C]: C[K] extends ColumnDef<infer T> ? T : never;
7405
+ [K in keyof C]: C[K] extends ComputedColumnDef<infer T> ? T | undefined : C[K] extends ColumnDef<infer T> ? T : never;
7286
7406
  };
7287
7407
  type InferRelations<R extends Record<string, RelationDef>> = {
7288
7408
  [K in keyof R]: R[K] extends RelationDef<infer V> ? V : never;
@@ -8499,4 +8619,4 @@ type BetterAuthAdapterConfig = Partial<Pick<AdapterFactoryConfig, "usePlural" |
8499
8619
  */
8500
8620
  declare function betterAuthAdapter(sql: SqlDataSource, config?: BetterAuthAdapterConfig): (options: BetterAuthOptions) => DBAdapter;
8501
8621
 
8502
- export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type AtomicOptions, type BaseModelMethodOptions, BaseSeeder, type BetterAuthAdapterConfig, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, type HysteriaErrorCode, InMemoryAdapter, type InferPK, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type MigrationLockConfig, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type OneOptions, type Operation, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PingResult, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type QueryContext, type QueryContextWithDuration, type QueryObserver, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ValidationContext, ValidationError, type ValidationResult, type Validator, type ViewDefinition, WriteOperation, type WriteReturnType, atomic, betterAuthAdapter, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, required, url };
8622
+ export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AnyModelConstructor, type AtomicOptions, type BaseModelMethodOptions, BaseSeeder, type BetterAuthAdapterConfig, type BuildSelectType, type BuildSingleSelectType, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColComputedOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ComputedColumnDef, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type ExcludeMethods, type ExtractColumnName, type ExtractSourceColumn, type FetchHooks, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, type HysteriaErrorCode, InMemoryAdapter, type InferPK, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, type ManyOptions, Migration, type MigrationConfig, type MigrationConfigBase, type MigrationLockConfig, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleDBDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type OneOptions, type Operation, type OracleDBDataSourceInput, type OracleDBPoolInstance, type PgPoolClientInstance, type PingResult, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type QueryContext, type QueryContextWithDuration, type QueryObserver, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ValidationContext, ValidationError, type ValidationResult, type Validator, type ViewDefinition, WriteOperation, type WriteReturnType, atomic, betterAuthAdapter, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, required, url };