metal-orm 1.0.63 → 1.0.65

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/dist/index.d.cts CHANGED
@@ -343,19 +343,19 @@ interface TableOptions {
343
343
  charset?: string;
344
344
  collation?: string;
345
345
  }
346
- interface TableHooks {
347
- beforeInsert?(ctx: unknown, entity: unknown): Promise<void> | void;
348
- afterInsert?(ctx: unknown, entity: unknown): Promise<void> | void;
349
- beforeUpdate?(ctx: unknown, entity: unknown): Promise<void> | void;
350
- afterUpdate?(ctx: unknown, entity: unknown): Promise<void> | void;
351
- beforeDelete?(ctx: unknown, entity: unknown): Promise<void> | void;
352
- afterDelete?(ctx: unknown, entity: unknown): Promise<void> | void;
346
+ interface TableHooks<TEntity = unknown, TContext = unknown> {
347
+ beforeInsert?(ctx: TContext, entity: TEntity): Promise<void> | void;
348
+ afterInsert?(ctx: TContext, entity: TEntity): Promise<void> | void;
349
+ beforeUpdate?(ctx: TContext, entity: TEntity): Promise<void> | void;
350
+ afterUpdate?(ctx: TContext, entity: TEntity): Promise<void> | void;
351
+ beforeDelete?(ctx: TContext, entity: TEntity): Promise<void> | void;
352
+ afterDelete?(ctx: TContext, entity: TEntity): Promise<void> | void;
353
353
  }
354
354
  /**
355
355
  * Definition of a database table with its columns and relationships
356
356
  * @typeParam T - Type of the columns record
357
357
  */
358
- interface TableDef<T extends Record<string, ColumnDef> = Record<string, ColumnDef>> {
358
+ interface TableDef<T extends Record<string, ColumnDef> = Record<string, ColumnDef>, TEntity = unknown, TContext = unknown> {
359
359
  /** Name of the table */
360
360
  name: string;
361
361
  /** Optional schema/catalog name */
@@ -365,7 +365,7 @@ interface TableDef<T extends Record<string, ColumnDef> = Record<string, ColumnDe
365
365
  /** Record of relationship definitions keyed by relation name */
366
366
  relations: Record<string, RelationDef>;
367
367
  /** Optional lifecycle hooks */
368
- hooks?: TableHooks;
368
+ hooks?: TableHooks<TEntity, TContext>;
369
369
  /** Composite primary key definition (falls back to column.primary flags) */
370
370
  primaryKey?: string[];
371
371
  /** Secondary indexes */
@@ -396,7 +396,7 @@ interface TableDef<T extends Record<string, ColumnDef> = Record<string, ColumnDe
396
396
  * });
397
397
  * ```
398
398
  */
399
- declare const defineTable: <T extends Record<string, ColumnDef>>(name: string, columns: T, relations?: Record<string, RelationDef>, hooks?: TableHooks, options?: TableOptions) => TableDef<T>;
399
+ declare const defineTable: <T extends Record<string, ColumnDef>, TEntity = unknown, TContext = unknown>(name: string, columns: T, relations?: Record<string, RelationDef>, hooks?: TableHooks<TEntity, TContext>, options?: TableOptions) => TableDef<T, TEntity, TContext>;
400
400
  /**
401
401
  * Assigns relations to a table definition while preserving literal typing.
402
402
  */
@@ -458,8 +458,8 @@ type ColumnToTs<T extends ColumnDef> = [
458
458
  type InferRow<TTable extends TableDef> = {
459
459
  [K in keyof TTable['columns']]: ColumnToTs<TTable['columns'][K]>;
460
460
  };
461
- type RelationResult$1<T extends RelationDef> = T extends HasManyRelation<infer TTarget> ? InferRow<TTarget>[] : T extends HasOneRelation<infer TTarget> ? InferRow<TTarget> | null : T extends BelongsToRelation<infer TTarget> ? InferRow<TTarget> | null : T extends BelongsToManyRelation<infer TTarget, TableDef> ? (InferRow<TTarget> & {
462
- _pivot?: Record<string, unknown>;
461
+ type RelationResult$1<T extends RelationDef> = T extends HasManyRelation<infer TTarget> ? InferRow<TTarget>[] : T extends HasOneRelation<infer TTarget> ? InferRow<TTarget> | null : T extends BelongsToRelation<infer TTarget> ? InferRow<TTarget> | null : T extends BelongsToManyRelation<infer TTarget, infer TPivot> ? (InferRow<TTarget> & {
462
+ _pivot?: InferRow<TPivot>;
463
463
  })[] : never;
464
464
  /**
465
465
  * Maps relation names to the expected row results
@@ -467,10 +467,10 @@ type RelationResult$1<T extends RelationDef> = T extends HasManyRelation<infer T
467
467
  type RelationMap<TTable extends TableDef> = {
468
468
  [K in keyof TTable['relations']]: RelationResult$1<TTable['relations'][K]>;
469
469
  };
470
- type RelationWrapper$1<TRel extends RelationDef> = TRel extends HasManyRelation<infer TTarget> ? HasManyCollection<EntityInstance<TTarget>> & ReadonlyArray<EntityInstance<TTarget>> : TRel extends HasOneRelation<infer TTarget> ? HasOneReference<EntityInstance<TTarget>> : TRel extends BelongsToManyRelation<infer TTarget> ? ManyToManyCollection<EntityInstance<TTarget> & {
471
- _pivot?: Record<string, unknown>;
470
+ type RelationWrapper$1<TRel extends RelationDef> = TRel extends HasManyRelation<infer TTarget> ? HasManyCollection<EntityInstance<TTarget>> & ReadonlyArray<EntityInstance<TTarget>> : TRel extends HasOneRelation<infer TTarget> ? HasOneReference<EntityInstance<TTarget>> : TRel extends BelongsToManyRelation<infer TTarget, infer TPivot> ? ManyToManyCollection<EntityInstance<TTarget> & {
471
+ _pivot?: InferRow<TPivot>;
472
472
  }> & ReadonlyArray<EntityInstance<TTarget> & {
473
- _pivot?: Record<string, unknown>;
473
+ _pivot?: InferRow<TPivot>;
474
474
  }> : TRel extends BelongsToRelation<infer TTarget> ? BelongsToReference<EntityInstance<TTarget>> : never;
475
475
  interface HasManyCollection<TChild> {
476
476
  length: number;
@@ -883,6 +883,11 @@ type ExpressionNode = BinaryExpressionNode | LogicalExpressionNode | NullExpress
883
883
 
884
884
  type LiteralValue = LiteralNode['value'];
885
885
  type ValueOperandInput = OperandNode | LiteralValue;
886
+ type TypedLike<T> = {
887
+ tsType?: T;
888
+ } | {
889
+ __tsType: T;
890
+ };
886
891
  /**
887
892
  * Converts a primitive or existing operand into an operand node
888
893
  * @param value - Value or operand to normalize
@@ -914,272 +919,481 @@ declare const aliasRef: (name: string) => AliasRefNode;
914
919
  */
915
920
  declare const correlateBy: (table: string, column: string) => ColumnNode;
916
921
  /**
917
- * Creates an equality expression (left = right)
918
- * @param left - Left operand
919
- * @param right - Right operand
920
- * @returns Binary expression node with equality operator
922
+ * Creates an equality expression (`left = right`).
923
+ *
924
+ * Supports type safety when used with `ColumnDef` objects containing strict type information.
925
+ *
926
+ * @param left - The left operand (column or value).
927
+ * @param right - The right operand (column or value).
928
+ * @returns A `BinaryExpressionNode` representing the equality check.
929
+ *
930
+ * @example
931
+ * // Basic usage
932
+ * eq(users.id, 1);
933
+ *
934
+ * // With strict typing (typescript will error if types mismatch)
935
+ * eq(users.firstName, 'Ada');
921
936
  */
922
- declare const eq: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number | boolean) => BinaryExpressionNode;
937
+ declare function eq<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
938
+ declare function eq(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number | boolean): BinaryExpressionNode;
923
939
  /**
924
- * Creates a not equal expression (left != right)
940
+ * Creates a not equal expression (`left != right`).
941
+ *
942
+ * @param left - The left operand (column or value).
943
+ * @param right - The right operand (column or value).
944
+ * @returns A `BinaryExpressionNode` representing the inequality check.
945
+ *
946
+ * @example
947
+ * neq(users.status, 'inactive');
925
948
  */
926
- declare const neq: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number | boolean) => BinaryExpressionNode;
949
+ declare function neq<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
950
+ declare function neq(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number | boolean): BinaryExpressionNode;
927
951
  /**
928
- * Creates a greater-than expression (left > right)
929
- * @param left - Left operand
930
- * @param right - Right operand
931
- * @returns Binary expression node with greater-than operator
952
+ * Creates a greater-than expression (`left > right`).
953
+ *
954
+ * @param left - The left operand.
955
+ * @param right - The right operand.
956
+ * @returns A `BinaryExpressionNode`.
957
+ *
958
+ * @example
959
+ * gt(users.age, 18);
932
960
  */
933
- declare const gt: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BinaryExpressionNode;
961
+ declare function gt<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
962
+ declare function gt(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number): BinaryExpressionNode;
934
963
  /**
935
- * Creates a greater than or equal expression (left >= right)
964
+ * Creates a greater-than-or-equal expression (`left >= right`).
965
+ *
966
+ * @param left - The left operand.
967
+ * @param right - The right operand.
968
+ * @returns A `BinaryExpressionNode`.
969
+ *
970
+ * @example
971
+ * gte(users.score, 100);
936
972
  */
937
- declare const gte: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BinaryExpressionNode;
973
+ declare function gte<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
974
+ declare function gte(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number): BinaryExpressionNode;
938
975
  /**
939
- * Creates a less-than expression (left < right)
940
- * @param left - Left operand
941
- * @param right - Right operand
942
- * @returns Binary expression node with less-than operator
976
+ * Creates a less-than expression (`left < right`).
977
+ *
978
+ * @param left - The left operand.
979
+ * @param right - The right operand.
980
+ * @returns A `BinaryExpressionNode`.
981
+ *
982
+ * @example
983
+ * lt(inventory.stock, 5);
943
984
  */
944
- declare const lt: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BinaryExpressionNode;
985
+ declare function lt<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
986
+ declare function lt(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number): BinaryExpressionNode;
945
987
  /**
946
- * Creates a less than or equal expression (left <= right)
988
+ * Creates a less-than-or-equal expression (`left <= right`).
989
+ *
990
+ * @param left - The left operand.
991
+ * @param right - The right operand.
992
+ * @returns A `BinaryExpressionNode`.
993
+ *
994
+ * @example
995
+ * lte(products.price, 50.00);
947
996
  */
948
- declare const lte: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BinaryExpressionNode;
997
+ declare function lte<T>(left: TypedLike<T>, right: T | TypedLike<T>): BinaryExpressionNode;
998
+ declare function lte(left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number): BinaryExpressionNode;
949
999
  /**
950
- * Creates a LIKE pattern matching expression
951
- * @param left - Left operand
952
- * @param pattern - Pattern to match
953
- * @param escape - Optional escape character
954
- * @returns Binary expression node with LIKE operator
1000
+ * Creates a `LIKE` pattern matching expression.
1001
+ *
1002
+ * @param left - The column or expression to check.
1003
+ * @param pattern - The pattern string (e.g., 'A%').
1004
+ * @param escape - Optional escape character.
1005
+ * @returns A `BinaryExpressionNode`.
1006
+ *
1007
+ * @example
1008
+ * like(users.email, '%@gmail.com');
955
1009
  */
956
1010
  declare const like: (left: OperandNode | ColumnRef, pattern: string, escape?: string) => BinaryExpressionNode;
957
1011
  /**
958
- * Creates a NOT LIKE pattern matching expression
959
- * @param left - Left operand
960
- * @param pattern - Pattern to match
961
- * @param escape - Optional escape character
962
- * @returns Binary expression node with NOT LIKE operator
1012
+ * Creates a `NOT LIKE` pattern matching expression.
1013
+ *
1014
+ * @param left - The column or expression to check.
1015
+ * @param pattern - The pattern string.
1016
+ * @param escape - Optional escape character.
1017
+ * @returns A `BinaryExpressionNode`.
1018
+ *
1019
+ * @example
1020
+ * notLike(users.email, 'test%');
963
1021
  */
964
1022
  declare const notLike: (left: OperandNode | ColumnRef, pattern: string, escape?: string) => BinaryExpressionNode;
965
1023
  /**
966
- * Creates a logical AND expression
967
- * @param operands - Expressions to combine with AND
968
- * @returns Logical expression node with AND operator
1024
+ * Creates a logical AND expression to combine multiple conditions.
1025
+ *
1026
+ * @param operands - One or more conditions to combine.
1027
+ * @returns A `LogicalExpressionNode`.
1028
+ *
1029
+ * @example
1030
+ * and(
1031
+ * eq(users.isActive, true),
1032
+ * gt(users.age, 18)
1033
+ * );
969
1034
  */
970
1035
  declare const and: (...operands: ExpressionNode[]) => LogicalExpressionNode;
971
1036
  /**
972
- * Creates a logical OR expression
973
- * @param operands - Expressions to combine with OR
974
- * @returns Logical expression node with OR operator
1037
+ * Creates a logical OR expression to combine multiple conditions.
1038
+ *
1039
+ * @param operands - One or more conditions to combine.
1040
+ * @returns A `LogicalExpressionNode`.
1041
+ *
1042
+ * @example
1043
+ * or(
1044
+ * eq(users.role, 'admin'),
1045
+ * eq(users.role, 'moderator')
1046
+ * );
975
1047
  */
976
1048
  declare const or: (...operands: ExpressionNode[]) => LogicalExpressionNode;
977
1049
  /**
978
- * Creates an IS NULL expression
979
- * @param left - Operand to check for null
980
- * @returns Null expression node with IS NULL operator
1050
+ * Creates an IS NULL check (`left IS NULL`).
1051
+ *
1052
+ * @param left - The operand to check.
1053
+ * @returns A `NullExpressionNode`.
1054
+ *
1055
+ * @example
1056
+ * isNull(users.deletedAt);
981
1057
  */
982
1058
  declare const isNull: (left: OperandNode | ColumnRef) => NullExpressionNode;
983
1059
  /**
984
- * Creates an IS NOT NULL expression
985
- * @param left - Operand to check for non-null
986
- * @returns Null expression node with IS NOT NULL operator
1060
+ * Creates an IS NOT NULL check (`left IS NOT NULL`).
1061
+ *
1062
+ * @param left - The operand to check.
1063
+ * @returns A `NullExpressionNode`.
1064
+ *
1065
+ * @example
1066
+ * isNotNull(users.email);
987
1067
  */
988
1068
  declare const isNotNull: (left: OperandNode | ColumnRef) => NullExpressionNode;
989
1069
  /**
990
- * Creates an IN expression (value IN list)
991
- * @param left - Operand to check
992
- * @param values - Values to check against
993
- * @returns IN expression node
1070
+ * Creates an IN list check (`left IN (v1, v2, ...)`).
1071
+ *
1072
+ * @param left - The operand to check.
1073
+ * @param values - An array of values to check against.
1074
+ * @returns An `InExpressionNode`.
1075
+ *
1076
+ * @example
1077
+ * inList(users.status, ['active', 'pending']);
994
1078
  */
995
1079
  declare const inList: (left: OperandNode | ColumnRef, values: (string | number | LiteralNode)[]) => InExpressionNode;
996
1080
  /**
997
- * Creates a NOT IN expression (value NOT IN list)
998
- * @param left - Operand to check
999
- * @param values - Values to check against
1000
- * @returns NOT IN expression node
1081
+ * Creates a NOT IN list check (`left NOT IN (v1, v2, ...)`).
1082
+ *
1083
+ * @param left - The operand to check.
1084
+ * @param values - An array of values to check against.
1085
+ * @returns An `InExpressionNode`.
1086
+ *
1087
+ * @example
1088
+ * notInList(users.id, [1, 2, 3]);
1001
1089
  */
1002
1090
  declare const notInList: (left: OperandNode | ColumnRef, values: (string | number | LiteralNode)[]) => InExpressionNode;
1091
+ /**
1092
+ * Creates an IN subquery check (`left IN (SELECT ...)`).
1093
+ *
1094
+ * @param left - The operand to check.
1095
+ * @param subquery - The subquery to run.
1096
+ * @returns An `InExpressionNode`.
1097
+ *
1098
+ * @example
1099
+ * inSubquery(
1100
+ * posts.authorId,
1101
+ * selectFromEntity(User).select({ id: users.id }).where(eq(users.isActive, true))
1102
+ * );
1103
+ */
1003
1104
  declare const inSubquery: (left: OperandNode | ColumnRef, subquery: SelectQueryInput) => InExpressionNode;
1105
+ /**
1106
+ * Creates a NOT IN subquery check (`left NOT IN (SELECT ...)`).
1107
+ *
1108
+ * @param left - The operand to check.
1109
+ * @param subquery - The subquery to run.
1110
+ * @returns An `InExpressionNode`.
1111
+ *
1112
+ * @example
1113
+ * notInSubquery(
1114
+ * users.id,
1115
+ * selectFromEntity(Blacklist).select({ userId: blacklist.userId })
1116
+ * );
1117
+ */
1004
1118
  declare const notInSubquery: (left: OperandNode | ColumnRef, subquery: SelectQueryInput) => InExpressionNode;
1005
1119
  /**
1006
- * Creates a BETWEEN expression (value BETWEEN lower AND upper)
1007
- * @param left - Operand to check
1008
- * @param lower - Lower bound
1009
- * @param upper - Upper bound
1010
- * @returns BETWEEN expression node
1120
+ * Creates a BETWEEN check (`left BETWEEN lower AND upper`).
1121
+ *
1122
+ * @param left - The operand to check.
1123
+ * @param lower - The lower bound (inclusive).
1124
+ * @param upper - The upper bound (inclusive).
1125
+ * @returns A `BetweenExpressionNode`.
1126
+ *
1127
+ * @example
1128
+ * between(products.price, 10, 100);
1011
1129
  */
1012
1130
  declare const between: (left: OperandNode | ColumnRef, lower: OperandNode | ColumnRef | string | number, upper: OperandNode | ColumnRef | string | number) => BetweenExpressionNode;
1013
1131
  /**
1014
- * Creates a NOT BETWEEN expression (value NOT BETWEEN lower AND upper)
1015
- * @param left - Operand to check
1016
- * @param lower - Lower bound
1017
- * @param upper - Upper bound
1018
- * @returns NOT BETWEEN expression node
1132
+ * Creates a NOT BETWEEN check (`left NOT BETWEEN lower AND upper`).
1133
+ *
1134
+ * @param left - The operand to check.
1135
+ * @param lower - The lower bound (inclusive).
1136
+ * @param upper - The upper bound (inclusive).
1137
+ * @returns A `BetweenExpressionNode`.
1138
+ *
1139
+ * @example
1140
+ * notBetween(users.age, 20, 30);
1019
1141
  */
1020
1142
  declare const notBetween: (left: OperandNode | ColumnRef, lower: OperandNode | ColumnRef | string | number, upper: OperandNode | ColumnRef | string | number) => BetweenExpressionNode;
1143
+ /**
1144
+ * Creates an addition expression (`left + right`).
1145
+ *
1146
+ * @param left - The left operand.
1147
+ * @param right - The right operand.
1148
+ * @returns An `ArithmeticExpressionNode`.
1149
+ */
1021
1150
  declare const add: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => ArithmeticExpressionNode;
1151
+ /**
1152
+ * Creates a subtraction expression (`left - right`).
1153
+ *
1154
+ * @param left - The left operand.
1155
+ * @param right - The right operand.
1156
+ * @returns An `ArithmeticExpressionNode`.
1157
+ */
1022
1158
  declare const sub: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => ArithmeticExpressionNode;
1159
+ /**
1160
+ * Creates a multiplication expression (`left * right`).
1161
+ *
1162
+ * @param left - The left operand.
1163
+ * @param right - The right operand.
1164
+ * @returns An `ArithmeticExpressionNode`.
1165
+ */
1023
1166
  declare const mul: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => ArithmeticExpressionNode;
1167
+ /**
1168
+ * Creates a division expression (`left / right`).
1169
+ *
1170
+ * @param left - The left operand.
1171
+ * @param right - The right operand.
1172
+ * @returns An `ArithmeticExpressionNode`.
1173
+ */
1024
1174
  declare const div: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => ArithmeticExpressionNode;
1025
1175
  /**
1026
- * Creates a bitwise AND expression (left & right)
1176
+ * Creates a bitwise AND expression (`left & right`).
1177
+ *
1178
+ * @param left - The left operand.
1179
+ * @param right - The right operand.
1180
+ * @returns A `BitwiseExpressionNode`.
1027
1181
  */
1028
1182
  declare const bitAnd: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
1029
1183
  /**
1030
- * Creates a bitwise OR expression (left | right)
1184
+ * Creates a bitwise OR expression (`left | right`).
1185
+ *
1186
+ * @param left - The left operand.
1187
+ * @param right - The right operand.
1188
+ * @returns A `BitwiseExpressionNode`.
1031
1189
  */
1032
1190
  declare const bitOr: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
1033
1191
  /**
1034
- * Creates a bitwise XOR expression (left ^ right)
1192
+ * Creates a bitwise XOR expression (`left ^ right`).
1193
+ *
1194
+ * @param left - The left operand.
1195
+ * @param right - The right operand.
1196
+ * @returns A `BitwiseExpressionNode`.
1035
1197
  */
1036
1198
  declare const bitXor: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
1037
1199
  /**
1038
- * Creates a bitwise shift left expression (left << right)
1200
+ * Creates a bitwise left-shift expression (`left << right`).
1201
+ *
1202
+ * @param left - The left operand.
1203
+ * @param right - The right operand (number of bits).
1204
+ * @returns A `BitwiseExpressionNode`.
1039
1205
  */
1040
1206
  declare const shiftLeft: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
1041
1207
  /**
1042
- * Creates a bitwise shift right expression (left >> right)
1208
+ * Creates a bitwise right-shift expression (`left >> right`).
1209
+ *
1210
+ * @param left - The left operand.
1211
+ * @param right - The right operand (number of bits).
1212
+ * @returns A `BitwiseExpressionNode`.
1043
1213
  */
1044
1214
  declare const shiftRight: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
1045
1215
  /**
1046
- * Creates a JSON path expression
1047
- * @param col - Source column
1048
- * @param path - JSON path expression
1049
- * @returns JSON path node
1216
+ * Creates a JSON path extraction expression.
1217
+ *
1218
+ * @param col - The source column (should be a JSON/JSONB column).
1219
+ * @param path - The JSON path expression (e.g., '$.address.city').
1220
+ * @returns A `JsonPathNode`.
1221
+ *
1222
+ * @example
1223
+ * jsonPath(users.profile, '$.settings.theme');
1050
1224
  */
1051
1225
  declare const jsonPath: (col: ColumnRef | ColumnNode, path: string) => JsonPathNode;
1052
1226
  /**
1053
- * Creates a CASE expression
1054
- * @param conditions - Array of WHEN-THEN conditions
1055
- * @param elseValue - Optional ELSE value
1056
- * @returns CASE expression node
1227
+ * Creates a CASE expression (`CASE WHEN ... THEN ... ELSE ... END`).
1228
+ *
1229
+ * @param conditions - An array of `{ when, then }` objects.
1230
+ * @param elseValue - Optional value for the `ELSE` clause.
1231
+ * @returns A `CaseExpressionNode`.
1232
+ *
1233
+ * @example
1234
+ * caseWhen([
1235
+ * { when: gt(users.age, 65), then: 'Senior' },
1236
+ * { when: gt(users.age, 18), then: 'Adult' }
1237
+ * ], 'Minor');
1057
1238
  */
1058
1239
  declare const caseWhen: (conditions: {
1059
1240
  when: ExpressionNode;
1060
1241
  then: OperandNode | ColumnRef | string | number | boolean | null;
1061
1242
  }[], elseValue?: OperandNode | ColumnRef | string | number | boolean | null) => CaseExpressionNode;
1062
1243
  /**
1063
- * Builds a CAST expression node for casting values to SQL types.
1244
+ * Creates a CAST expression (`CAST(expression AS type)`).
1245
+ *
1246
+ * @param expression - The expression to cast.
1247
+ * @param castType - The target SQL type (e.g., 'VARCHAR', 'INTEGER').
1248
+ * @returns A `CastExpressionNode`.
1249
+ *
1250
+ * @example
1251
+ * cast(users.age, 'VARCHAR');
1064
1252
  */
1065
1253
  declare const cast: (expression: OperandNode | ColumnRef | string | number | boolean | null, castType: string) => CastExpressionNode;
1066
1254
  /**
1067
- * Creates an EXISTS expression
1068
- * @param subquery - Subquery to check for existence
1069
- * @returns EXISTS expression node
1255
+ * Creates an EXISTS check (`EXISTS (SELECT ...)`).
1256
+ *
1257
+ * @param subquery - The subquery to check.
1258
+ * @returns An `ExistsExpressionNode`.
1259
+ *
1260
+ * @example
1261
+ * exists(
1262
+ * selectFromEntity(Order).where(eq(orders.userId, users.id))
1263
+ * );
1070
1264
  */
1071
1265
  declare const exists: (subquery: SelectQueryNode) => ExistsExpressionNode;
1072
1266
  /**
1073
- * Creates a NOT EXISTS expression
1074
- * @param subquery - Subquery to check for non-existence
1075
- * @returns NOT EXISTS expression node
1267
+ * Creates a NOT EXISTS check (`NOT EXISTS (SELECT ...)`).
1268
+ *
1269
+ * @param subquery - The subquery to check.
1270
+ * @returns An `ExistsExpressionNode`.
1271
+ *
1272
+ * @example
1273
+ * notExists(
1274
+ * selectFromEntity(Subscription).where(eq(subscriptions.userId, users.id))
1275
+ * );
1076
1276
  */
1077
1277
  declare const notExists: (subquery: SelectQueryNode) => ExistsExpressionNode;
1078
1278
  /**
1079
- * Creates a COLLATE expression (expression COLLATE collationName)
1080
- * @param expression - Expression to be collated
1081
- * @param collation - Collation name
1082
- * @returns COLLATE expression node
1279
+ * Creates a COLLATE expression (`expression COLLATE collation`).
1280
+ *
1281
+ * @param expression - The expression string.
1282
+ * @param collation - The collation name (e.g., 'nocase').
1283
+ * @returns A `CollateExpressionNode`.
1284
+ *
1285
+ * @example
1286
+ * collate(users.email, 'nocase');
1083
1287
  */
1084
1288
  declare const collate: (expression: OperandNode | ColumnRef | string | number | boolean | null, collation: string) => CollateExpressionNode;
1085
1289
 
1086
1290
  /**
1087
- * Creates a ROW_NUMBER window function
1088
- * @returns Window function node for ROW_NUMBER
1291
+ * Creates a ROW_NUMBER window function.
1292
+ *
1293
+ * @returns A `TypedExpression<number>` representing the `ROW_NUMBER` window function.
1089
1294
  */
1090
- declare const rowNumber: () => WindowFunctionNode;
1295
+ declare const rowNumber: () => TypedExpression<number>;
1091
1296
  /**
1092
- * Creates a RANK window function
1093
- * @returns Window function node for RANK
1297
+ * Creates a RANK window function.
1298
+ *
1299
+ * @returns A `TypedExpression<number>` representing the `RANK` window function.
1094
1300
  */
1095
- declare const rank: () => WindowFunctionNode;
1301
+ declare const rank: () => TypedExpression<number>;
1096
1302
  /**
1097
- * Creates a DENSE_RANK window function
1098
- * @returns Window function node for DENSE_RANK
1303
+ * Creates a DENSE_RANK window function.
1304
+ *
1305
+ * @returns A `TypedExpression<number>` representing the `DENSE_RANK` window function.
1099
1306
  */
1100
- declare const denseRank: () => WindowFunctionNode;
1307
+ declare const denseRank: () => TypedExpression<number>;
1101
1308
  /**
1102
- * Creates an NTILE window function
1103
- * @param n - Number of buckets
1104
- * @returns Window function node for NTILE
1309
+ * Creates an NTILE window function.
1310
+ *
1311
+ * @param n - Number of buckets.
1312
+ * @returns A `TypedExpression<number>` representing the `NTILE` window function.
1105
1313
  */
1106
- declare const ntile: (n: number) => WindowFunctionNode;
1314
+ declare const ntile: (n: number) => TypedExpression<number>;
1107
1315
  /**
1108
- * Creates a LAG window function
1109
- * @param col - Column to lag
1110
- * @param offset - Offset (defaults to 1)
1111
- * @param defaultValue - Default value if no row exists
1112
- * @returns Window function node for LAG
1316
+ * Creates a LAG window function.
1317
+ *
1318
+ * @param col - Column or expression to lag.
1319
+ * @param offset - Optional offset (defaults to 1).
1320
+ * @param defaultValue - Optional default value.
1321
+ * @returns A `TypedExpression<T>` representing the `LAG` window function.
1113
1322
  */
1114
- declare const lag: (col: ColumnRef | ColumnNode, offset?: number, defaultValue?: LiteralNode["value"]) => WindowFunctionNode;
1323
+ declare const lag: <T = unknown>(col: ColumnRef | ColumnNode, offset?: number, defaultValue?: LiteralNode["value"]) => TypedExpression<T>;
1115
1324
  /**
1116
- * Creates a LEAD window function
1117
- * @param col - Column to lead
1118
- * @param offset - Offset (defaults to 1)
1119
- * @param defaultValue - Default value if no row exists
1120
- * @returns Window function node for LEAD
1325
+ * Creates a LEAD window function.
1326
+ *
1327
+ * @param col - Column or expression to lead.
1328
+ * @param offset - Optional offset (defaults to 1).
1329
+ * @param defaultValue - Optional default value.
1330
+ * @returns A `TypedExpression<T>` representing the `LEAD` window function.
1121
1331
  */
1122
- declare const lead: (col: ColumnRef | ColumnNode, offset?: number, defaultValue?: LiteralNode["value"]) => WindowFunctionNode;
1332
+ declare const lead: <T = unknown>(col: ColumnRef | ColumnNode, offset?: number, defaultValue?: LiteralNode["value"]) => TypedExpression<T>;
1123
1333
  /**
1124
- * Creates a FIRST_VALUE window function
1125
- * @param col - Column to get first value from
1126
- * @returns Window function node for FIRST_VALUE
1334
+ * Creates a FIRST_VALUE window function.
1335
+ *
1336
+ * @param col - Column or expression to get first value from.
1337
+ * @returns A `TypedExpression<T>` representing the `FIRST_VALUE` window function.
1127
1338
  */
1128
- declare const firstValue: (col: ColumnRef | ColumnNode) => WindowFunctionNode;
1339
+ declare const firstValue: <T = unknown>(col: ColumnRef | ColumnNode) => TypedExpression<T>;
1129
1340
  /**
1130
- * Creates a LAST_VALUE window function
1131
- * @param col - Column to get last value from
1132
- * @returns Window function node for LAST_VALUE
1341
+ * Creates a LAST_VALUE window function.
1342
+ *
1343
+ * @param col - Column or expression to get last value from.
1344
+ * @returns A `TypedExpression<T>` representing the `LAST_VALUE` window function.
1133
1345
  */
1134
- declare const lastValue: (col: ColumnRef | ColumnNode) => WindowFunctionNode;
1346
+ declare const lastValue: <T = unknown>(col: ColumnRef | ColumnNode) => TypedExpression<T>;
1135
1347
  /**
1136
- * Creates a custom window function
1137
- * @param name - Window function name
1138
- * @param args - Function arguments
1139
- * @param partitionBy - Optional PARTITION BY columns
1140
- * @param orderBy - Optional ORDER BY clauses
1141
- * @returns Window function node
1348
+ * Creates a custom window function.
1349
+ *
1350
+ * @param name - Window function name.
1351
+ * @param args - Function arguments.
1352
+ * @param partitionBy - Optional PARTITION BY columns.
1353
+ * @param orderBy - Optional ORDER BY clauses.
1354
+ * @returns A `TypedExpression<T>` representing the window function.
1142
1355
  */
1143
- declare const windowFunction: (name: string, args?: (ColumnRef | ColumnNode | LiteralNode | JsonPathNode)[], partitionBy?: (ColumnRef | ColumnNode)[], orderBy?: {
1356
+ declare const windowFunction: <T = unknown>(name: string, args?: (ColumnRef | ColumnNode | LiteralNode | JsonPathNode)[], partitionBy?: (ColumnRef | ColumnNode)[], orderBy?: {
1144
1357
  column: ColumnRef | ColumnNode;
1145
1358
  direction: OrderDirection;
1146
- }[]) => WindowFunctionNode;
1359
+ }[]) => TypedExpression<T>;
1147
1360
 
1148
1361
  /**
1149
1362
  * Creates a COUNT function expression
1150
1363
  * @param col - Column to count
1151
1364
  * @returns Function node with COUNT
1152
1365
  */
1153
- declare const count: (col: ColumnRef | ColumnNode) => FunctionNode;
1366
+ declare const count: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1154
1367
  /**
1155
1368
  * Creates a SUM function expression
1156
1369
  * @param col - Column to sum
1157
1370
  * @returns Function node with SUM
1158
1371
  */
1159
- declare const sum: (col: ColumnRef | ColumnNode) => FunctionNode;
1372
+ declare const sum: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1160
1373
  /**
1161
1374
  * Creates an AVG function expression
1162
1375
  * @param col - Column to average
1163
1376
  * @returns Function node with AVG
1164
1377
  */
1165
- declare const avg: (col: ColumnRef | ColumnNode) => FunctionNode;
1378
+ declare const avg: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1166
1379
  /**
1167
1380
  * Creates a MIN function expression
1168
1381
  * @param col - Column to take the minimum of
1169
1382
  * @returns Function node with MIN
1170
1383
  */
1171
- declare const min: (col: ColumnRef | ColumnNode) => FunctionNode;
1384
+ declare const min: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1172
1385
  /**
1173
1386
  * Creates a MAX function expression
1174
1387
  * @param col - Column to take the maximum of
1175
1388
  * @returns Function node with MAX
1176
1389
  */
1177
- declare const max: (col: ColumnRef | ColumnNode) => FunctionNode;
1390
+ declare const max: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1178
1391
  /**
1179
1392
  * Creates a COUNT(*) function expression.
1180
- * @returns Function node with COUNT(*)
1393
+ *
1394
+ * @returns A `TypedExpression<number>` representing the `COUNT(*)` SQL function.
1181
1395
  */
1182
- declare const countAll: () => FunctionNode;
1396
+ declare const countAll: () => TypedExpression<number>;
1183
1397
  type GroupConcatOrderByInput = {
1184
1398
  column: ColumnRef | ColumnNode;
1185
1399
  direction?: OrderDirection;
@@ -1190,20 +1404,27 @@ type GroupConcatOptions = {
1190
1404
  };
1191
1405
  /**
1192
1406
  * Aggregates grouped strings into a single value.
1407
+ *
1408
+ * @param col - Column or expression to aggregate.
1409
+ * @param options - Optional separator and ordering.
1410
+ * @returns A `TypedExpression<string>` representing the `GROUP_CONCAT` SQL function.
1411
+ *
1412
+ * @example
1413
+ * groupConcat(users.name, { separator: ', ', orderBy: [{ column: users.name }] });
1193
1414
  */
1194
- declare const groupConcat: (col: ColumnRef | ColumnNode, options?: GroupConcatOptions) => FunctionNode;
1415
+ declare const groupConcat: (col: ColumnRef | ColumnNode, options?: GroupConcatOptions) => TypedExpression<string>;
1195
1416
  /**
1196
1417
  * Creates a STDDEV function expression
1197
1418
  * @param col - Column to calculate standard deviation for
1198
1419
  * @returns Function node with STDDEV
1199
1420
  */
1200
- declare const stddev: (col: ColumnRef | ColumnNode) => FunctionNode;
1421
+ declare const stddev: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1201
1422
  /**
1202
1423
  * Creates a VARIANCE function expression
1203
1424
  * @param col - Column to calculate variance for
1204
1425
  * @returns Function node with VARIANCE
1205
1426
  */
1206
- declare const variance: (col: ColumnRef | ColumnNode) => FunctionNode;
1427
+ declare const variance: (col: ColumnRef | ColumnNode) => TypedExpression<number>;
1207
1428
 
1208
1429
  /**
1209
1430
  * Visitor for expression nodes
@@ -2590,7 +2811,7 @@ interface TrackedEntity {
2590
2811
  /** The table definition this entity belongs to */
2591
2812
  table: TableDef;
2592
2813
  /** The actual entity instance */
2593
- entity: unknown;
2814
+ entity: object;
2594
2815
  /** Primary key value of the entity */
2595
2816
  pk: string | number | null;
2596
2817
  /** Current status of the entity */
@@ -2778,7 +2999,7 @@ declare class IdentityMap {
2778
2999
  * @param pk The primary key value.
2779
3000
  * @returns The entity instance if found, undefined otherwise.
2780
3001
  */
2781
- getEntity(table: TableDef, pk: string | number): unknown | undefined;
3002
+ getEntity(table: TableDef, pk: string | number): object | undefined;
2782
3003
  /**
2783
3004
  * Registers a tracked entity in the identity map.
2784
3005
  * @param tracked The tracked entity metadata and instance.
@@ -2827,7 +3048,7 @@ declare class UnitOfWork {
2827
3048
  * @param pk - The primary key value
2828
3049
  * @returns The entity or undefined if not found
2829
3050
  */
2830
- getEntity(table: TableDef, pk: string | number): unknown | undefined;
3051
+ getEntity(table: TableDef, pk: string | number): object | undefined;
2831
3052
  /**
2832
3053
  * Gets all tracked entities for a specific table.
2833
3054
  * @param table - The table definition
@@ -2839,38 +3060,38 @@ declare class UnitOfWork {
2839
3060
  * @param entity - The entity to find
2840
3061
  * @returns The tracked entity or undefined if not found
2841
3062
  */
2842
- findTracked(entity: unknown): TrackedEntity | undefined;
3063
+ findTracked(entity: object): TrackedEntity | undefined;
2843
3064
  /**
2844
3065
  * Sets an entity in the identity map.
2845
3066
  * @param table - The table definition
2846
3067
  * @param pk - The primary key value
2847
3068
  * @param entity - The entity instance
2848
3069
  */
2849
- setEntity(table: TableDef, pk: string | number, entity: unknown): void;
3070
+ setEntity(table: TableDef, pk: string | number, entity: object): void;
2850
3071
  /**
2851
3072
  * Tracks a new entity.
2852
3073
  * @param table - The table definition
2853
3074
  * @param entity - The entity instance
2854
3075
  * @param pk - Optional primary key value
2855
3076
  */
2856
- trackNew(table: TableDef, entity: unknown, pk?: string | number): void;
3077
+ trackNew(table: TableDef, entity: object, pk?: string | number): void;
2857
3078
  /**
2858
3079
  * Tracks a managed entity.
2859
3080
  * @param table - The table definition
2860
3081
  * @param pk - The primary key value
2861
3082
  * @param entity - The entity instance
2862
3083
  */
2863
- trackManaged(table: TableDef, pk: string | number, entity: unknown): void;
3084
+ trackManaged(table: TableDef, pk: string | number, entity: object): void;
2864
3085
  /**
2865
3086
  * Marks an entity as dirty (modified).
2866
3087
  * @param entity - The entity to mark as dirty
2867
3088
  */
2868
- markDirty(entity: unknown): void;
3089
+ markDirty(entity: object): void;
2869
3090
  /**
2870
3091
  * Marks an entity as removed.
2871
3092
  * @param entity - The entity to mark as removed
2872
3093
  */
2873
- markRemoved(entity: unknown): void;
3094
+ markRemoved(entity: object): void;
2874
3095
  /**
2875
3096
  * Flushes pending changes to the database.
2876
3097
  */
@@ -3153,6 +3374,7 @@ interface ExecutionContext {
3153
3374
  interceptors: InterceptorPipeline;
3154
3375
  }
3155
3376
 
3377
+ type PrimaryKey$1 = string | number;
3156
3378
  /**
3157
3379
  * Interface for entity context providing entity tracking and management.
3158
3380
  */
@@ -3167,38 +3389,38 @@ interface EntityContext {
3167
3389
  * @param pk - The primary key value
3168
3390
  * @returns The entity or undefined
3169
3391
  */
3170
- getEntity(table: TableDef, pk: unknown): unknown;
3392
+ getEntity(table: TableDef, pk: PrimaryKey$1): object | undefined;
3171
3393
  /**
3172
3394
  * Sets an entity in the context.
3173
3395
  * @param table - The table definition
3174
3396
  * @param pk - The primary key value
3175
3397
  * @param entity - The entity to set
3176
3398
  */
3177
- setEntity(table: TableDef, pk: unknown, entity: unknown): void;
3399
+ setEntity(table: TableDef, pk: PrimaryKey$1, entity: object): void;
3178
3400
  /**
3179
3401
  * Tracks a new entity.
3180
3402
  * @param table - The table definition
3181
3403
  * @param entity - The new entity
3182
3404
  * @param pk - Optional primary key
3183
3405
  */
3184
- trackNew(table: TableDef, entity: unknown, pk?: unknown): void;
3406
+ trackNew(table: TableDef, entity: object, pk?: PrimaryKey$1): void;
3185
3407
  /**
3186
3408
  * Tracks a managed entity.
3187
3409
  * @param table - The table definition
3188
3410
  * @param pk - The primary key
3189
3411
  * @param entity - The managed entity
3190
3412
  */
3191
- trackManaged(table: TableDef, pk: unknown, entity: unknown): void;
3413
+ trackManaged(table: TableDef, pk: PrimaryKey$1, entity: object): void;
3192
3414
  /**
3193
3415
  * Marks an entity as dirty.
3194
3416
  * @param entity - The entity to mark
3195
3417
  */
3196
- markDirty(entity: unknown): void;
3418
+ markDirty(entity: object): void;
3197
3419
  /**
3198
3420
  * Marks an entity as removed.
3199
3421
  * @param entity - The entity to mark
3200
3422
  */
3201
- markRemoved(entity: unknown): void;
3423
+ markRemoved(entity: object): void;
3202
3424
  /**
3203
3425
  * Gets all tracked entities for a table.
3204
3426
  * @param table - The table definition
@@ -3356,38 +3578,38 @@ declare class OrmSession<E extends DomainEvent = OrmDomainEvent> implements Enti
3356
3578
  * @param pk - The primary key value
3357
3579
  * @returns The entity or undefined if not found
3358
3580
  */
3359
- getEntity(table: TableDef, pk: unknown): unknown | undefined;
3581
+ getEntity(table: TableDef, pk: PrimaryKey$1): object | undefined;
3360
3582
  /**
3361
3583
  * Sets an entity in the identity map.
3362
3584
  * @param table - The table definition
3363
3585
  * @param pk - The primary key value
3364
3586
  * @param entity - The entity instance
3365
3587
  */
3366
- setEntity(table: TableDef, pk: unknown, entity: unknown): void;
3588
+ setEntity(table: TableDef, pk: PrimaryKey$1, entity: object): void;
3367
3589
  /**
3368
3590
  * Tracks a new entity.
3369
3591
  * @param table - The table definition
3370
3592
  * @param entity - The entity instance
3371
3593
  * @param pk - Optional primary key value
3372
3594
  */
3373
- trackNew(table: TableDef, entity: unknown, pk?: unknown): void;
3595
+ trackNew(table: TableDef, entity: object, pk?: PrimaryKey$1): void;
3374
3596
  /**
3375
3597
  * Tracks a managed entity.
3376
3598
  * @param table - The table definition
3377
3599
  * @param pk - The primary key value
3378
3600
  * @param entity - The entity instance
3379
3601
  */
3380
- trackManaged(table: TableDef, pk: unknown, entity: unknown): void;
3602
+ trackManaged(table: TableDef, pk: PrimaryKey$1, entity: object): void;
3381
3603
  /**
3382
3604
  * Marks an entity as dirty (modified).
3383
3605
  * @param entity - The entity to mark as dirty
3384
3606
  */
3385
- markDirty(entity: unknown): void;
3607
+ markDirty(entity: object): void;
3386
3608
  /**
3387
3609
  * Marks an entity as removed.
3388
3610
  * @param entity - The entity to mark as removed
3389
3611
  */
3390
- markRemoved(entity: unknown): void;
3612
+ markRemoved(entity: object): void;
3391
3613
  /**
3392
3614
  * Registers a relation change.
3393
3615
  * @param root - The root entity
@@ -4008,7 +4230,7 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
4008
4230
  * .where(eq(userTable.columns.active, false));
4009
4231
  * qb.union(activeUsers).union(inactiveUsers);
4010
4232
  */
4011
- union<TSub extends TableDef>(query: SelectQueryBuilder<unknown, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
4233
+ union<TSub extends TableDef>(query: SelectQueryBuilder<T, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
4012
4234
  /**
4013
4235
  * Combines this query with another using UNION ALL
4014
4236
  * @param query - Query to union with
@@ -4018,7 +4240,7 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
4018
4240
  * const q2 = new SelectQueryBuilder(userTable).where(lt(userTable.columns.score, 20));
4019
4241
  * qb.unionAll(q1).unionAll(q2);
4020
4242
  */
4021
- unionAll<TSub extends TableDef>(query: SelectQueryBuilder<unknown, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
4243
+ unionAll<TSub extends TableDef>(query: SelectQueryBuilder<T, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
4022
4244
  /**
4023
4245
  * Combines this query with another using INTERSECT
4024
4246
  * @param query - Query to intersect with
@@ -4030,7 +4252,7 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
4030
4252
  * .where(eq(userTable.columns.premium, true));
4031
4253
  * qb.intersect(activeUsers).intersect(premiumUsers);
4032
4254
  */
4033
- intersect<TSub extends TableDef>(query: SelectQueryBuilder<unknown, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
4255
+ intersect<TSub extends TableDef>(query: SelectQueryBuilder<T, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
4034
4256
  /**
4035
4257
  * Combines this query with another using EXCEPT
4036
4258
  * @param query - Query to subtract
@@ -4041,7 +4263,7 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
4041
4263
  * .where(eq(userTable.columns.active, false));
4042
4264
  * qb.except(allUsers).except(inactiveUsers); // Only active users
4043
4265
  */
4044
- except<TSub extends TableDef>(query: SelectQueryBuilder<unknown, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
4266
+ except<TSub extends TableDef>(query: SelectQueryBuilder<T, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
4045
4267
  /**
4046
4268
  * Adds a WHERE EXISTS condition to the query
4047
4269
  * @param subquery - Subquery to check for existence
@@ -4148,6 +4370,7 @@ type Ctor<T> = {
4148
4370
  */
4149
4371
  declare function esel<TEntity extends object, K extends keyof TEntity & string>(entity: Ctor<TEntity>, ...props: K[]): Record<K, ColumnDef>;
4150
4372
 
4373
+ type InsertRows = Record<string, ValueOperandInput>[];
4151
4374
  /**
4152
4375
  * Maintains immutable state for building INSERT queries
4153
4376
  */
@@ -4171,7 +4394,7 @@ declare class InsertQueryState {
4171
4394
  * @throws Error if mixing VALUES with SELECT source
4172
4395
  * @throws Error if invalid values are provided
4173
4396
  */
4174
- withValues(rows: Record<string, unknown>[]): InsertQueryState;
4397
+ withValues(rows: InsertRows): InsertQueryState;
4175
4398
  /**
4176
4399
  * Sets the columns for the INSERT query
4177
4400
  * @param columns - Column nodes to insert into
@@ -4214,7 +4437,7 @@ declare class InsertQueryBuilder<T> {
4214
4437
  * @param rowOrRows - Single row object or array of row objects to insert
4215
4438
  * @returns A new InsertQueryBuilder with the VALUES clause added
4216
4439
  */
4217
- values(rowOrRows: Record<string, unknown> | Record<string, unknown>[]): InsertQueryBuilder<T>;
4440
+ values(rowOrRows: Record<string, ValueOperandInput> | Record<string, ValueOperandInput>[]): InsertQueryBuilder<T>;
4218
4441
  /**
4219
4442
  * Specifies the columns for the INSERT query
4220
4443
  * @param columns - Column definitions or nodes to insert into
@@ -5012,598 +5235,766 @@ declare const getSchemaIntrospector: (dialect: DialectName) => SchemaIntrospecto
5012
5235
  type OperandInput$5 = OperandNode | ColumnDef | string | number | boolean | null;
5013
5236
  /**
5014
5237
  * Converts a string to lowercase.
5015
- * @param value - The string value.
5016
- * @returns A FunctionNode representing the LOWER SQL function.
5238
+ *
5239
+ * @param value - The string value or column.
5240
+ * @returns A `TypedExpression<string>` representing the `LOWER` SQL function.
5241
+ *
5242
+ * @example
5243
+ * lower(users.email);
5017
5244
  */
5018
- declare const lower: (value: OperandInput$5) => FunctionNode;
5245
+ declare const lower: (value: OperandInput$5) => TypedExpression<string>;
5019
5246
  /**
5020
5247
  * Converts a string to uppercase.
5021
- * @param value - The string value.
5022
- * @returns A FunctionNode representing the UPPER SQL function.
5248
+ *
5249
+ * @param value - The string value or column.
5250
+ * @returns A `TypedExpression<string>` representing the `UPPER` SQL function.
5251
+ *
5252
+ * @example
5253
+ * upper(users.firstName);
5023
5254
  */
5024
- declare const upper: (value: OperandInput$5) => FunctionNode;
5255
+ declare const upper: (value: OperandInput$5) => TypedExpression<string>;
5025
5256
  /**
5026
5257
  * Returns the ASCII code of the first character of a string.
5027
- * @param value - The string value.
5028
- * @returns A FunctionNode representing the ASCII SQL function.
5258
+ *
5259
+ * @param value - The string value or column.
5260
+ * @returns A `TypedExpression<number>` representing the `ASCII` SQL function.
5261
+ *
5262
+ * @example
5263
+ * ascii(users.initial);
5029
5264
  */
5030
- declare const ascii: (value: OperandInput$5) => FunctionNode;
5265
+ declare const ascii: (value: OperandInput$5) => TypedExpression<number>;
5031
5266
  /**
5032
5267
  * Returns a string from one or more ASCII codes.
5033
- * @param codes - The ASCII codes.
5034
- * @returns A FunctionNode representing the CHAR SQL function.
5268
+ *
5269
+ * @param codes - One or more ASCII codes.
5270
+ * @returns A `TypedExpression<string>` representing the `CHAR` SQL function.
5271
+ *
5272
+ * @example
5273
+ * char(65, 66, 67); // 'ABC'
5035
5274
  */
5036
- declare const char: (...codes: OperandInput$5[]) => FunctionNode;
5275
+ declare const char: (...codes: OperandInput$5[]) => TypedExpression<string>;
5037
5276
  /**
5038
5277
  * Returns the number of characters in a string.
5039
- * @param value - The string value.
5040
- * @returns A FunctionNode representing the CHAR_LENGTH SQL function.
5278
+ *
5279
+ * @param value - The string value or column.
5280
+ * @returns A `TypedExpression<number>` representing the `CHAR_LENGTH` SQL function.
5281
+ *
5282
+ * @example
5283
+ * charLength(users.bio);
5041
5284
  */
5042
- declare const charLength: (value: OperandInput$5) => FunctionNode;
5285
+ declare const charLength: (value: OperandInput$5) => TypedExpression<number>;
5043
5286
  /**
5044
5287
  * Returns the length of a string in bytes or characters.
5045
- * @param value - The string value.
5046
- * @returns A FunctionNode representing the LENGTH SQL function.
5288
+ *
5289
+ * @param value - The string value or column.
5290
+ * @returns A `TypedExpression<number>` representing the `LENGTH` SQL function.
5291
+ *
5292
+ * @example
5293
+ * length(users.password);
5047
5294
  */
5048
- declare const length: (value: OperandInput$5) => FunctionNode;
5295
+ declare const length: (value: OperandInput$5) => TypedExpression<number>;
5049
5296
  /**
5050
5297
  * Removes leading and trailing whitespace or specified characters from a string.
5051
- * @param value - The string value.
5052
- * @param chars - The characters to trim (optional).
5053
- * @returns A FunctionNode representing the TRIM SQL function.
5298
+ *
5299
+ * @param value - The string value or column.
5300
+ * @param chars - Optional characters to trim.
5301
+ * @returns A `TypedExpression<string>` representing the `TRIM` SQL function.
5302
+ *
5303
+ * @example
5304
+ * trim(users.name);
5305
+ * trim(users.path, '/');
5054
5306
  */
5055
- declare const trim: (value: OperandInput$5, chars?: OperandInput$5) => FunctionNode;
5307
+ declare const trim: (value: OperandInput$5, chars?: OperandInput$5) => TypedExpression<string>;
5056
5308
  /**
5057
5309
  * Removes leading whitespace from a string.
5058
- * @param value - The string value.
5059
- * @returns A FunctionNode representing the LTRIM SQL function.
5310
+ *
5311
+ * @param value - The string value or column.
5312
+ * @returns A `TypedExpression<string>` representing the `LTRIM` SQL function.
5060
5313
  */
5061
- declare const ltrim: (value: OperandInput$5) => FunctionNode;
5314
+ declare const ltrim: (value: OperandInput$5) => TypedExpression<string>;
5062
5315
  /**
5063
5316
  * Removes trailing whitespace from a string.
5064
- * @param value - The string value.
5065
- * @returns A FunctionNode representing the RTRIM SQL function.
5317
+ *
5318
+ * @param value - The string value or column.
5319
+ * @returns A `TypedExpression<string>` representing the `RTRIM` SQL function.
5066
5320
  */
5067
- declare const rtrim: (value: OperandInput$5) => FunctionNode;
5321
+ declare const rtrim: (value: OperandInput$5) => TypedExpression<string>;
5068
5322
  /**
5069
5323
  * Concatenates two or more strings.
5070
- * @param args - The strings to concatenate.
5071
- * @returns A FunctionNode representing the CONCAT SQL function.
5324
+ *
5325
+ * @param args - The strings or columns to concatenate.
5326
+ * @returns A `TypedExpression<string>` representing the `CONCAT` SQL function.
5327
+ *
5328
+ * @example
5329
+ * concat(users.firstName, ' ', users.lastName);
5072
5330
  */
5073
- declare const concat: (...args: OperandInput$5[]) => FunctionNode;
5331
+ declare const concat: (...args: OperandInput$5[]) => TypedExpression<string>;
5074
5332
  /**
5075
5333
  * Concatenates strings with a separator.
5334
+ *
5076
5335
  * @param separator - The separator string.
5077
- * @param args - The strings to concatenate.
5078
- * @returns A FunctionNode representing the CONCAT_WS SQL function.
5336
+ * @param args - The strings or columns to concatenate.
5337
+ * @returns A `TypedExpression<string>` representing the `CONCAT_WS` SQL function.
5338
+ *
5339
+ * @example
5340
+ * concatWs(', ', users.lastName, users.firstName);
5079
5341
  */
5080
- declare const concatWs: (separator: OperandInput$5, ...args: OperandInput$5[]) => FunctionNode;
5342
+ declare const concatWs: (separator: OperandInput$5, ...args: OperandInput$5[]) => TypedExpression<string>;
5081
5343
  /**
5082
5344
  * Extracts a substring from a string.
5083
- * @param value - The string value.
5084
- * @param start - The starting position.
5085
- * @param length - The length of the substring (optional).
5086
- * @returns A FunctionNode representing the SUBSTR SQL function.
5345
+ *
5346
+ * @param value - The input string or column.
5347
+ * @param start - The starting position (1-indexed).
5348
+ * @param length - Optional length of the substring.
5349
+ * @returns A `TypedExpression<string>` representing the `SUBSTR` SQL function.
5350
+ *
5351
+ * @example
5352
+ * substr(users.token, 1, 8);
5087
5353
  */
5088
- declare const substr: (value: OperandInput$5, start: OperandInput$5, length?: OperandInput$5) => FunctionNode;
5354
+ declare const substr: (value: OperandInput$5, start: OperandInput$5, length?: OperandInput$5) => TypedExpression<string>;
5089
5355
  /**
5090
5356
  * Returns the leftmost characters of a string.
5091
- * @param value - The string value.
5092
- * @param len - The number of characters to return.
5093
- * @returns A FunctionNode representing the LEFT SQL function.
5357
+ *
5358
+ * @param value - The string value or column.
5359
+ * @param len - Number of characters to return.
5360
+ * @returns A `TypedExpression<string>` representing the `LEFT` SQL function.
5094
5361
  */
5095
- declare const left: (value: OperandInput$5, len: OperandInput$5) => FunctionNode;
5362
+ declare const left: (value: OperandInput$5, len: OperandInput$5) => TypedExpression<string>;
5096
5363
  /**
5097
5364
  * Returns the rightmost characters of a string.
5098
- * @param value - The string value.
5099
- * @param len - The number of characters to return.
5100
- * @returns A FunctionNode representing the RIGHT SQL function.
5365
+ *
5366
+ * @param value - The string value or column.
5367
+ * @param len - Number of characters to return.
5368
+ * @returns A `TypedExpression<string>` representing the `RIGHT` SQL function.
5101
5369
  */
5102
- declare const right: (value: OperandInput$5, len: OperandInput$5) => FunctionNode;
5370
+ declare const right: (value: OperandInput$5, len: OperandInput$5) => TypedExpression<string>;
5103
5371
  /**
5104
5372
  * Returns the position of a substring in a string.
5373
+ *
5105
5374
  * @param substring - The substring to search for.
5106
- * @param value - The string to search in.
5107
- * @returns A FunctionNode representing the POSITION SQL function.
5375
+ * @param value - The string or column to search within.
5376
+ * @returns A `TypedExpression<number>` representing the `POSITION` SQL function.
5108
5377
  */
5109
- declare const position: (substring: OperandInput$5, value: OperandInput$5) => FunctionNode;
5378
+ declare const position: (substring: OperandInput$5, value: OperandInput$5) => TypedExpression<number>;
5110
5379
  /**
5111
5380
  * Returns the position of a substring in a string.
5112
- * @param value - The string to search in.
5381
+ *
5382
+ * @param value - The string or column to search within.
5113
5383
  * @param substring - The substring to search for.
5114
- * @returns A FunctionNode representing the INSTR SQL function.
5384
+ * @returns A `TypedExpression<number>` representing the `INSTR` SQL function.
5115
5385
  */
5116
- declare const instr: (value: OperandInput$5, substring: OperandInput$5) => FunctionNode;
5386
+ declare const instr: (value: OperandInput$5, substring: OperandInput$5) => TypedExpression<number>;
5117
5387
  /**
5118
5388
  * Returns the position of a substring in a string, optionally starting from a position.
5119
- * @param substring - The substring to search for.
5120
- * @param value - The string to search in.
5121
- * @param start - The starting position (optional).
5122
- * @returns A FunctionNode representing the LOCATE SQL function.
5389
+ *
5390
+ * @param substring - Substring to find.
5391
+ * @param value - String/column to search.
5392
+ * @param start - Optional starting position.
5393
+ * @returns A `TypedExpression<number>` representing the `LOCATE` SQL function.
5123
5394
  */
5124
- declare const locate: (substring: OperandInput$5, value: OperandInput$5, start?: OperandInput$5) => FunctionNode;
5395
+ declare const locate: (substring: OperandInput$5, value: OperandInput$5, start?: OperandInput$5) => TypedExpression<number>;
5125
5396
  /**
5126
5397
  * Replaces occurrences of a substring in a string.
5127
- * @param value - The string to search in.
5128
- * @param search - The substring to replace.
5129
- * @param replacement - The replacement string.
5130
- * @returns A FunctionNode representing the REPLACE SQL function.
5398
+ *
5399
+ * @param value - The original string or column.
5400
+ * @param search - Substring to search for.
5401
+ * @param replacement - Replacement string.
5402
+ * @returns A `TypedExpression<string>` representing the `REPLACE` SQL function.
5403
+ *
5404
+ * @example
5405
+ * replace(users.email, 'old.com', 'new.com');
5131
5406
  */
5132
- declare const replace: (value: OperandInput$5, search: OperandInput$5, replacement: OperandInput$5) => FunctionNode;
5407
+ declare const replace: (value: OperandInput$5, search: OperandInput$5, replacement: OperandInput$5) => TypedExpression<string>;
5133
5408
  /**
5134
5409
  * Repeats a string a specified number of times.
5410
+ *
5135
5411
  * @param value - The string to repeat.
5136
- * @param count - The number of times to repeat.
5137
- * @returns A FunctionNode representing the REPEAT SQL function.
5412
+ * @param count - How many times to repeat.
5413
+ * @returns A `TypedExpression<string>` representing the `REPEAT` SQL function.
5138
5414
  */
5139
- declare const repeat: (value: OperandInput$5, count: OperandInput$5) => FunctionNode;
5415
+ declare const repeat: (value: OperandInput$5, count: OperandInput$5) => TypedExpression<string>;
5140
5416
  /**
5141
5417
  * Left-pads a string to a certain length with another string.
5142
- * @param value - The string to pad.
5143
- * @param len - The length to pad to.
5144
- * @param pad - The padding string.
5145
- * @returns A FunctionNode representing the LPAD SQL function.
5418
+ *
5419
+ * @param value - The string/column to pad.
5420
+ * @param len - Target length.
5421
+ * @param pad - Padding string.
5422
+ * @returns A `TypedExpression<string>` representing the `LPAD` SQL function.
5146
5423
  */
5147
- declare const lpad: (value: OperandInput$5, len: OperandInput$5, pad: OperandInput$5) => FunctionNode;
5424
+ declare const lpad: (value: OperandInput$5, len: OperandInput$5, pad: OperandInput$5) => TypedExpression<string>;
5148
5425
  /**
5149
5426
  * Right-pads a string to a certain length with another string.
5150
- * @param value - The string to pad.
5151
- * @param len - The length to pad to.
5152
- * @param pad - The padding string.
5153
- * @returns A FunctionNode representing the RPAD SQL function.
5427
+ *
5428
+ * @param value - The string/column to pad.
5429
+ * @param len - Target length.
5430
+ * @param pad - Padding string.
5431
+ * @returns A `TypedExpression<string>` representing the `RPAD` SQL function.
5154
5432
  */
5155
- declare const rpad: (value: OperandInput$5, len: OperandInput$5, pad: OperandInput$5) => FunctionNode;
5433
+ declare const rpad: (value: OperandInput$5, len: OperandInput$5, pad: OperandInput$5) => TypedExpression<string>;
5156
5434
  /**
5157
5435
  * Returns a string consisting of a specified number of spaces.
5158
- * @param count - The number of spaces.
5159
- * @returns A FunctionNode representing the SPACE SQL function.
5436
+ *
5437
+ * @param count - Number of spaces.
5438
+ * @returns A `TypedExpression<string>` representing the `SPACE` SQL function.
5160
5439
  */
5161
- declare const space: (count: OperandInput$5) => FunctionNode;
5440
+ declare const space: (count: OperandInput$5) => TypedExpression<string>;
5162
5441
  /**
5163
5442
  * Reverses a string.
5164
- * @param value - The string value.
5165
- * @returns A FunctionNode representing the REVERSE SQL function.
5443
+ *
5444
+ * @param value - The string value or column.
5445
+ * @returns A `TypedExpression<string>` representing the `REVERSE` SQL function.
5166
5446
  */
5167
- declare const reverse: (value: OperandInput$5) => FunctionNode;
5447
+ declare const reverse: (value: OperandInput$5) => TypedExpression<string>;
5168
5448
  /**
5169
5449
  * Capitalizes the first letter of each word in a string.
5170
- * @param value - The string value.
5171
- * @returns A FunctionNode representing the INITCAP SQL function.
5450
+ *
5451
+ * @param value - The string value or column.
5452
+ * @returns A `TypedExpression<string>` representing the `INITCAP` SQL function.
5172
5453
  */
5173
- declare const initcap: (value: OperandInput$5) => FunctionNode;
5454
+ declare const initcap: (value: OperandInput$5) => TypedExpression<string>;
5174
5455
  /**
5175
5456
  * Returns the MD5 hash of a string.
5176
- * @param value - The string value.
5177
- * @returns A FunctionNode representing the MD5 SQL function.
5457
+ *
5458
+ * @param value - The string value or column.
5459
+ * @returns A `TypedExpression<string>` representing the `MD5` SQL function.
5178
5460
  */
5179
- declare const md5: (value: OperandInput$5) => FunctionNode;
5461
+ declare const md5: (value: OperandInput$5) => TypedExpression<string>;
5180
5462
  /**
5181
5463
  * Returns the SHA-1 hash of a string.
5182
- * @param value - The string value.
5183
- * @returns A FunctionNode representing the SHA1 SQL function.
5464
+ *
5465
+ * @param value - The string value or column.
5466
+ * @returns A `TypedExpression<string>` representing the `SHA1` SQL function.
5184
5467
  */
5185
- declare const sha1: (value: OperandInput$5) => FunctionNode;
5468
+ declare const sha1: (value: OperandInput$5) => TypedExpression<string>;
5186
5469
  /**
5187
5470
  * Returns the SHA-2 hash of a string with a specified bit length.
5188
- * @param value - The string value.
5189
- * @param bits - The bit length (e.g., 224, 256, 384, 512).
5190
- * @returns A FunctionNode representing the SHA2 SQL function.
5471
+ *
5472
+ * @param value - The input.
5473
+ * @param bits - Bit length (e.g., 256, 512).
5474
+ * @returns A `TypedExpression<string>` representing the `SHA2` SQL function.
5191
5475
  */
5192
- declare const sha2: (value: OperandInput$5, bits: OperandInput$5) => FunctionNode;
5476
+ declare const sha2: (value: OperandInput$5, bits: OperandInput$5) => TypedExpression<string>;
5193
5477
  /**
5194
5478
  * Returns the length of a string in bits.
5195
- * @param value - The string value.
5196
- * @returns A FunctionNode representing the BIT_LENGTH SQL function.
5479
+ *
5480
+ * @param value - String value or column.
5481
+ * @returns A `TypedExpression<number>` representing the `BIT_LENGTH` SQL function.
5197
5482
  */
5198
- declare const bitLength: (value: OperandInput$5) => FunctionNode;
5483
+ declare const bitLength: (value: OperandInput$5) => TypedExpression<number>;
5199
5484
  /**
5200
5485
  * Returns the length of a string in bytes.
5201
- * @param value - The string value.
5202
- * @returns A FunctionNode representing the OCTET_LENGTH SQL function.
5486
+ *
5487
+ * @param value - String value or column.
5488
+ * @returns A `TypedExpression<number>` representing the `OCTET_LENGTH` SQL function.
5203
5489
  */
5204
- declare const octetLength: (value: OperandInput$5) => FunctionNode;
5490
+ declare const octetLength: (value: OperandInput$5) => TypedExpression<number>;
5205
5491
  /**
5206
5492
  * Returns a string from an ASCII code.
5207
- * @param code - The ASCII code.
5208
- * @returns A FunctionNode representing the CHR/CHAR SQL function.
5493
+ *
5494
+ * @param code - ASCII code.
5495
+ * @returns A `TypedExpression<string>` representing the `CHR` SQL function.
5209
5496
  */
5210
- declare const chr: (code: OperandInput$5) => FunctionNode;
5497
+ declare const chr: (code: OperandInput$5) => TypedExpression<string>;
5211
5498
 
5212
5499
  type OperandInput$4 = OperandNode | ColumnDef | string | number | boolean | null;
5213
5500
  /**
5214
5501
  * Returns the absolute value of a number.
5215
- * @param value - The numeric value.
5216
- * @returns A FunctionNode representing the ABS SQL function.
5502
+ *
5503
+ * @param value - The numeric value or column.
5504
+ * @returns A `TypedExpression<number>` representing the `ABS` SQL function.
5505
+ *
5506
+ * @example
5507
+ * abs(transactions.amount);
5217
5508
  */
5218
- declare const abs: (value: OperandInput$4) => FunctionNode;
5509
+ declare const abs: (value: OperandInput$4) => TypedExpression<number>;
5219
5510
  /**
5220
5511
  * Returns the arccosine (inverse cosine) of a number.
5221
- * @param value - The numeric value.
5222
- * @returns A FunctionNode representing the ACOS SQL function.
5512
+ *
5513
+ * @param value - The numeric value or column.
5514
+ * @returns A `TypedExpression<number>` representing the `ACOS` SQL function.
5223
5515
  */
5224
- declare const acos: (value: OperandInput$4) => FunctionNode;
5516
+ declare const acos: (value: OperandInput$4) => TypedExpression<number>;
5225
5517
  /**
5226
5518
  * Returns the arcsine (inverse sine) of a number.
5227
- * @param value - The numeric value.
5228
- * @returns A FunctionNode representing the ASIN SQL function.
5519
+ *
5520
+ * @param value - The numeric value or column.
5521
+ * @returns A `TypedExpression<number>` representing the `ASIN` SQL function.
5229
5522
  */
5230
- declare const asin: (value: OperandInput$4) => FunctionNode;
5523
+ declare const asin: (value: OperandInput$4) => TypedExpression<number>;
5231
5524
  /**
5232
5525
  * Returns the arctangent (inverse tangent) of a number.
5233
- * @param value - The numeric value.
5234
- * @returns A FunctionNode representing the ATAN SQL function.
5526
+ *
5527
+ * @param value - The numeric value or column.
5528
+ * @returns A `TypedExpression<number>` representing the `ATAN` SQL function.
5235
5529
  */
5236
- declare const atan: (value: OperandInput$4) => FunctionNode;
5530
+ declare const atan: (value: OperandInput$4) => TypedExpression<number>;
5237
5531
  /**
5238
5532
  * Returns the arctangent of the two arguments.
5533
+ *
5239
5534
  * @param y - The y-coordinate.
5240
5535
  * @param x - The x-coordinate.
5241
- * @returns A FunctionNode representing the ATAN2 SQL function.
5536
+ * @returns A `TypedExpression<number>` representing the `ATAN2` SQL function.
5242
5537
  */
5243
- declare const atan2: (y: OperandInput$4, x: OperandInput$4) => FunctionNode;
5538
+ declare const atan2: (y: OperandInput$4, x: OperandInput$4) => TypedExpression<number>;
5244
5539
  /**
5245
5540
  * Returns the smallest integer greater than or equal to a number.
5246
- * @param value - The numeric value.
5247
- * @returns A FunctionNode representing the CEIL SQL function.
5541
+ *
5542
+ * @param value - The numeric value or column.
5543
+ * @returns A `TypedExpression<number>` representing the `CEIL` SQL function.
5248
5544
  */
5249
- declare const ceil: (value: OperandInput$4) => FunctionNode;
5545
+ declare const ceil: (value: OperandInput$4) => TypedExpression<number>;
5250
5546
  /**
5251
5547
  * Alias for ceil. Returns the smallest integer greater than or equal to a number.
5252
- * @param value - The numeric value.
5253
- * @returns A FunctionNode representing the CEILING SQL function.
5548
+ *
5549
+ * @param value - The numeric value or column.
5550
+ * @returns A `TypedExpression<number>` representing the `CEILING` SQL function.
5254
5551
  */
5255
- declare const ceiling: (value: OperandInput$4) => FunctionNode;
5552
+ declare const ceiling: (value: OperandInput$4) => TypedExpression<number>;
5256
5553
  /**
5257
5554
  * Returns the cosine of a number (in radians).
5555
+ *
5258
5556
  * @param value - The numeric value in radians.
5259
- * @returns A FunctionNode representing the COS SQL function.
5557
+ * @returns A `TypedExpression<number>` representing the `COS` SQL function.
5260
5558
  */
5261
- declare const cos: (value: OperandInput$4) => FunctionNode;
5559
+ declare const cos: (value: OperandInput$4) => TypedExpression<number>;
5262
5560
  /**
5263
5561
  * Returns the cotangent of a number.
5562
+ *
5264
5563
  * @param value - The numeric value.
5265
- * @returns A FunctionNode representing the COT SQL function.
5564
+ * @returns A `TypedExpression<number>` representing the `COT` SQL function.
5266
5565
  */
5267
- declare const cot: (value: OperandInput$4) => FunctionNode;
5566
+ declare const cot: (value: OperandInput$4) => TypedExpression<number>;
5268
5567
  /**
5269
5568
  * Converts radians to degrees.
5569
+ *
5270
5570
  * @param value - The angle in radians.
5271
- * @returns A FunctionNode representing the DEGREES SQL function.
5571
+ * @returns A `TypedExpression<number>` representing the `DEGREES` SQL function.
5272
5572
  */
5273
- declare const degrees: (value: OperandInput$4) => FunctionNode;
5573
+ declare const degrees: (value: OperandInput$4) => TypedExpression<number>;
5274
5574
  /**
5275
5575
  * Returns e raised to the power of the argument.
5576
+ *
5276
5577
  * @param value - The exponent.
5277
- * @returns A FunctionNode representing the EXP SQL function.
5578
+ * @returns A `TypedExpression<number>` representing the `EXP` SQL function.
5278
5579
  */
5279
- declare const exp: (value: OperandInput$4) => FunctionNode;
5580
+ declare const exp: (value: OperandInput$4) => TypedExpression<number>;
5280
5581
  /**
5281
5582
  * Returns the largest integer less than or equal to a number.
5583
+ *
5282
5584
  * @param value - The numeric value.
5283
- * @returns A FunctionNode representing the FLOOR SQL function.
5585
+ * @returns A `TypedExpression<number>` representing the `FLOOR` SQL function.
5284
5586
  */
5285
- declare const floor: (value: OperandInput$4) => FunctionNode;
5587
+ declare const floor: (value: OperandInput$4) => TypedExpression<number>;
5286
5588
  /**
5287
5589
  * Returns the natural logarithm (base e) of a number.
5590
+ *
5288
5591
  * @param value - The numeric value.
5289
- * @returns A FunctionNode representing the LN SQL function.
5592
+ * @returns A `TypedExpression<number>` representing the `LN` SQL function.
5290
5593
  */
5291
- declare const ln: (value: OperandInput$4) => FunctionNode;
5594
+ declare const ln: (value: OperandInput$4) => TypedExpression<number>;
5292
5595
  /**
5293
5596
  * Returns the base-10 logarithm of a number.
5597
+ *
5294
5598
  * @param value - The numeric value.
5295
- * @returns A FunctionNode representing the LOG SQL function.
5599
+ * @returns A `TypedExpression<number>` representing the `LOG` SQL function.
5296
5600
  */
5297
- declare const log: (value: OperandInput$4) => FunctionNode;
5601
+ declare const log: (value: OperandInput$4) => TypedExpression<number>;
5298
5602
  /**
5299
5603
  * Returns the base-10 logarithm of a number.
5604
+ *
5300
5605
  * @param value - The numeric value.
5301
- * @returns A FunctionNode representing the LOG10 SQL function.
5606
+ * @returns A `TypedExpression<number>` representing the `LOG10` SQL function.
5302
5607
  */
5303
- declare const log10: (value: OperandInput$4) => FunctionNode;
5608
+ declare const log10: (value: OperandInput$4) => TypedExpression<number>;
5304
5609
  /**
5305
5610
  * Returns the logarithm of a number for a specific base.
5611
+ *
5306
5612
  * @param base - The base of the logarithm.
5307
5613
  * @param value - The numeric value.
5308
- * @returns A FunctionNode representing the LOG_BASE SQL function.
5614
+ * @returns A `TypedExpression<number>` representing the `LOG_BASE` SQL function.
5309
5615
  */
5310
- declare const logBase: (base: OperandInput$4, value: OperandInput$4) => FunctionNode;
5616
+ declare const logBase: (base: OperandInput$4, value: OperandInput$4) => TypedExpression<number>;
5311
5617
  /**
5312
5618
  * Returns the remainder of dividing x by y.
5619
+ *
5313
5620
  * @param x - The dividend.
5314
5621
  * @param y - The divisor.
5315
- * @returns A FunctionNode representing the MOD SQL function.
5622
+ * @returns A `TypedExpression<number>` representing the `MOD` SQL function.
5316
5623
  */
5317
- declare const mod: (x: OperandInput$4, y: OperandInput$4) => FunctionNode;
5624
+ declare const mod: (x: OperandInput$4, y: OperandInput$4) => TypedExpression<number>;
5318
5625
  /**
5319
5626
  * Returns the value of PI (approximately 3.14159...).
5320
- * @returns A FunctionNode representing the PI SQL function.
5627
+ *
5628
+ * @returns A `TypedExpression<number>` representing the `PI` SQL function.
5321
5629
  */
5322
- declare const pi: () => FunctionNode;
5630
+ declare const pi: () => TypedExpression<number>;
5323
5631
  /**
5324
5632
  * Returns x raised to the power of y.
5633
+ *
5325
5634
  * @param x - The base.
5326
5635
  * @param y - The exponent.
5327
- * @returns A FunctionNode representing the POWER SQL function.
5636
+ * @returns A `TypedExpression<number>` representing the `POWER` SQL function.
5328
5637
  */
5329
- declare const power: (x: OperandInput$4, y: OperandInput$4) => FunctionNode;
5638
+ declare const power: (x: OperandInput$4, y: OperandInput$4) => TypedExpression<number>;
5330
5639
  /**
5331
5640
  * Alias for power. Returns x raised to the power of y.
5641
+ *
5332
5642
  * @param x - The base.
5333
5643
  * @param y - The exponent.
5334
- * @returns A FunctionNode representing the POW SQL function.
5644
+ * @returns A `TypedExpression<number>` representing the `POW` SQL function.
5335
5645
  */
5336
- declare const pow: (x: OperandInput$4, y: OperandInput$4) => FunctionNode;
5646
+ declare const pow: (x: OperandInput$4, y: OperandInput$4) => TypedExpression<number>;
5337
5647
  /**
5338
5648
  * Converts degrees to radians.
5649
+ *
5339
5650
  * @param value - The angle in degrees.
5340
- * @returns A FunctionNode representing the RADIANS SQL function.
5651
+ * @returns A `TypedExpression<number>` representing the `RADIANS` SQL function.
5341
5652
  */
5342
- declare const radians: (value: OperandInput$4) => FunctionNode;
5653
+ declare const radians: (value: OperandInput$4) => TypedExpression<number>;
5343
5654
  /**
5344
5655
  * Returns a random number between 0 and 1.
5345
- * @returns A FunctionNode representing the RANDOM SQL function.
5656
+ *
5657
+ * @returns A `TypedExpression<number>` representing the `RANDOM` SQL function.
5346
5658
  */
5347
- declare const random: () => FunctionNode;
5659
+ declare const random: () => TypedExpression<number>;
5348
5660
  /**
5349
5661
  * Alias for random. Returns a random number between 0 and 1.
5350
- * @returns A FunctionNode representing the RAND SQL function.
5662
+ *
5663
+ * @returns A `TypedExpression<number>` representing the `RAND` SQL function.
5351
5664
  */
5352
- declare const rand: () => FunctionNode;
5665
+ declare const rand: () => TypedExpression<number>;
5353
5666
  /**
5354
5667
  * Rounds a number to a specified number of decimal places.
5668
+ *
5355
5669
  * @param value - The numeric value to round.
5356
- * @param decimals - The number of decimal places (optional).
5357
- * @returns A FunctionNode representing the ROUND SQL function.
5670
+ * @param decimals - Optional number of decimal places.
5671
+ * @returns A `TypedExpression<number>` representing the `ROUND` SQL function.
5358
5672
  */
5359
- declare const round: (value: OperandInput$4, decimals?: OperandInput$4) => FunctionNode;
5673
+ declare const round: (value: OperandInput$4, decimals?: OperandInput$4) => TypedExpression<number>;
5360
5674
  /**
5361
5675
  * Returns the sign of a number (-1 for negative, 0 for zero, 1 for positive).
5676
+ *
5362
5677
  * @param value - The numeric value.
5363
- * @returns A FunctionNode representing the SIGN SQL function.
5678
+ * @returns A `TypedExpression<number>` representing the `SIGN` SQL function.
5364
5679
  */
5365
- declare const sign: (value: OperandInput$4) => FunctionNode;
5680
+ declare const sign: (value: OperandInput$4) => TypedExpression<number>;
5366
5681
  /**
5367
5682
  * Returns the sine of a number (in radians).
5683
+ *
5368
5684
  * @param value - The numeric value in radians.
5369
- * @returns A FunctionNode representing the SIN SQL function.
5685
+ * @returns A `TypedExpression<number>` representing the `SIN` SQL function.
5370
5686
  */
5371
- declare const sin: (value: OperandInput$4) => FunctionNode;
5687
+ declare const sin: (value: OperandInput$4) => TypedExpression<number>;
5372
5688
  /**
5373
5689
  * Returns the square root of a number.
5374
- * @param value - The numeric value.
5375
- * @returns A FunctionNode representing the SQRT SQL function.
5690
+ *
5691
+ * @param value - The numeric value or column.
5692
+ * @returns A `TypedExpression<number>` representing the `SQRT` SQL function.
5376
5693
  */
5377
- declare const sqrt: (value: OperandInput$4) => FunctionNode;
5694
+ declare const sqrt: (value: OperandInput$4) => TypedExpression<number>;
5378
5695
  /**
5379
5696
  * Returns the tangent of a number (in radians).
5697
+ *
5380
5698
  * @param value - The numeric value in radians.
5381
- * @returns A FunctionNode representing the TAN SQL function.
5699
+ * @returns A `TypedExpression<number>` representing the `TAN` SQL function.
5382
5700
  */
5383
- declare const tan: (value: OperandInput$4) => FunctionNode;
5701
+ declare const tan: (value: OperandInput$4) => TypedExpression<number>;
5384
5702
  /**
5385
5703
  * Truncates a number to a specified number of decimal places without rounding.
5704
+ *
5386
5705
  * @param value - The numeric value to truncate.
5387
- * @param decimals - The number of decimal places (optional).
5388
- * @returns A FunctionNode representing the TRUNC SQL function.
5706
+ * @param decimals - Optional number of decimal places.
5707
+ * @returns A `TypedExpression<number>` representing the `TRUNC` SQL function.
5389
5708
  */
5390
- declare const trunc: (value: OperandInput$4, decimals?: OperandInput$4) => FunctionNode;
5709
+ declare const trunc: (value: OperandInput$4, decimals?: OperandInput$4) => TypedExpression<number>;
5391
5710
  /**
5392
5711
  * Alias for trunc. Truncates a number to a specified number of decimal places without rounding.
5712
+ *
5393
5713
  * @param value - The numeric value to truncate.
5394
5714
  * @param decimals - The number of decimal places.
5395
- * @returns A FunctionNode representing the TRUNCATE SQL function.
5715
+ * @returns A `TypedExpression<number>` representing the `TRUNCATE` SQL function.
5396
5716
  */
5397
- declare const truncate: (value: OperandInput$4, decimals: OperandInput$4) => FunctionNode;
5717
+ declare const truncate: (value: OperandInput$4, decimals: OperandInput$4) => TypedExpression<number>;
5398
5718
  /**
5399
5719
  * Returns the base-2 logarithm of a number.
5400
- * @param value - The numeric value.
5401
- * @returns A FunctionNode representing the LOG2 SQL function.
5720
+ *
5721
+ * @param value - The numeric value or column.
5722
+ * @returns A `TypedExpression<number>` representing the `LOG2` SQL function.
5402
5723
  */
5403
- declare const log2: (value: OperandInput$4) => FunctionNode;
5724
+ declare const log2: (value: OperandInput$4) => TypedExpression<number>;
5404
5725
  /**
5405
5726
  * Returns the cube root of a number.
5406
- * @param value - The numeric value.
5407
- * @returns A FunctionNode representing the CBRT SQL function.
5727
+ *
5728
+ * @param value - The numeric value or column.
5729
+ * @returns A `TypedExpression<number>` representing the `CBRT` SQL function.
5408
5730
  */
5409
- declare const cbrt: (value: OperandInput$4) => FunctionNode;
5731
+ declare const cbrt: (value: OperandInput$4) => TypedExpression<number>;
5410
5732
 
5411
5733
  type OperandInput$3 = OperandNode | ColumnDef | string | number | boolean | null;
5412
5734
  /**
5413
5735
  * Returns the current local date and time.
5414
- * @returns A FunctionNode representing the NOW() SQL function.
5736
+ *
5737
+ * @returns A `TypedExpression<Date>` representing the `NOW()` SQL function.
5415
5738
  */
5416
- declare const now: () => FunctionNode;
5739
+ declare const now: () => TypedExpression<Date>;
5417
5740
  /**
5418
- * Returns the current date without time.
5419
- * @returns A FunctionNode representing the CURRENT_DATE SQL function.
5741
+ * Returns the current date (without time).
5742
+ *
5743
+ * @returns A `TypedExpression<Date>` representing the `CURRENT_DATE` SQL function.
5420
5744
  */
5421
- declare const currentDate: () => FunctionNode;
5745
+ declare const currentDate: () => TypedExpression<Date>;
5422
5746
  /**
5423
- * Returns the current time without date.
5424
- * @returns A FunctionNode representing the CURRENT_TIME SQL function.
5747
+ * Returns the current time (without date).
5748
+ *
5749
+ * @returns A `TypedExpression<Date>` representing the `CURRENT_TIME` SQL function.
5425
5750
  */
5426
- declare const currentTime: () => FunctionNode;
5751
+ declare const currentTime: () => TypedExpression<Date>;
5427
5752
  /**
5428
5753
  * Returns the current UTC date and time.
5429
- * @returns A FunctionNode representing the UTC_NOW() SQL function.
5754
+ *
5755
+ * @returns A `TypedExpression<Date>` representing the `UTC_NOW()` SQL function.
5430
5756
  */
5431
- declare const utcNow: () => FunctionNode;
5757
+ declare const utcNow: () => TypedExpression<Date>;
5432
5758
  /**
5433
5759
  * Returns the current local time.
5434
- * @returns A FunctionNode representing the LOCALTIME SQL function.
5760
+ *
5761
+ * @returns A `TypedExpression<Date>` representing the `LOCALTIME` SQL function.
5435
5762
  */
5436
- declare const localTime: () => FunctionNode;
5763
+ declare const localTime: () => TypedExpression<Date>;
5437
5764
  /**
5438
5765
  * Returns the current local timestamp.
5439
- * @returns A FunctionNode representing the LOCALTIMESTAMP SQL function.
5766
+ *
5767
+ * @returns A `TypedExpression<Date>` representing the `LOCALTIMESTAMP` SQL function.
5440
5768
  */
5441
- declare const localTimestamp: () => FunctionNode;
5769
+ declare const localTimestamp: () => TypedExpression<Date>;
5442
5770
  /**
5443
5771
  * Extracts a specified part from a date or datetime value.
5444
- * @param part - The date part to extract (e.g., 'YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE', 'SECOND').
5445
- * @param date - The date or datetime value to extract from.
5446
- * @returns A FunctionNode representing the EXTRACT SQL function.
5772
+ *
5773
+ * @param part - The date part to extract (e.g., 'YEAR', 'MONTH', 'DAY').
5774
+ * @param date - The date/datetime value or column.
5775
+ * @returns A `TypedExpression<number>` representing the `EXTRACT` SQL function.
5447
5776
  */
5448
- declare const extract: (part: OperandInput$3, date: OperandInput$3) => FunctionNode;
5777
+ declare const extract: (part: OperandInput$3, date: OperandInput$3) => TypedExpression<number>;
5449
5778
  /**
5450
5779
  * Extracts the year from a date or datetime value.
5451
- * @param date - The date or datetime value.
5452
- * @returns A FunctionNode representing the YEAR SQL function.
5780
+ *
5781
+ * @param date - The date value.
5782
+ * @returns A `TypedExpression<number>` representing the `YEAR` SQL function.
5453
5783
  */
5454
- declare const year: (date: OperandInput$3) => FunctionNode;
5784
+ declare const year: (date: OperandInput$3) => TypedExpression<number>;
5455
5785
  /**
5456
5786
  * Extracts the month from a date or datetime value.
5457
- * @param date - The date or datetime value.
5458
- * @returns A FunctionNode representing the MONTH SQL function.
5787
+ *
5788
+ * @param date - The date value.
5789
+ * @returns A `TypedExpression<number>` representing the `MONTH` SQL function.
5459
5790
  */
5460
- declare const month: (date: OperandInput$3) => FunctionNode;
5791
+ declare const month: (date: OperandInput$3) => TypedExpression<number>;
5461
5792
  /**
5462
5793
  * Extracts the day of the month from a date or datetime value.
5463
- * @param date - The date or datetime value.
5464
- * @returns A FunctionNode representing the DAY SQL function.
5794
+ *
5795
+ * @param date - The date value.
5796
+ * @returns A `TypedExpression<number>` representing the `DAY` SQL function.
5465
5797
  */
5466
- declare const day: (date: OperandInput$3) => FunctionNode;
5798
+ declare const day: (date: OperandInput$3) => TypedExpression<number>;
5467
5799
  /**
5468
5800
  * Adds a specified time interval to a date or datetime value.
5469
- * @param date - The date or datetime value to add to.
5470
- * @param interval - The number of units to add.
5471
- * @param unit - The unit type (e.g., 'DAY', 'MONTH', 'YEAR', 'HOUR', 'MINUTE', 'SECOND').
5472
- * @returns A FunctionNode representing the DATE_ADD SQL function.
5801
+ *
5802
+ * @param date - The base date.
5803
+ * @param interval - The numeric interval to add.
5804
+ * @param unit - The unit (e.g., 'DAY', 'MONTH').
5805
+ * @returns A `TypedExpression<Date>` representing the `DATE_ADD` SQL function.
5473
5806
  */
5474
- declare const dateAdd: (date: OperandInput$3, interval: OperandInput$3, unit: OperandInput$3) => FunctionNode;
5807
+ declare const dateAdd: (date: OperandInput$3, interval: OperandInput$3, unit: OperandInput$3) => TypedExpression<Date>;
5475
5808
  /**
5476
5809
  * Subtracts a specified time interval from a date or datetime value.
5477
- * @param date - The date or datetime value to subtract from.
5478
- * @param interval - The number of units to subtract.
5479
- * @param unit - The unit type (e.g., 'DAY', 'MONTH', 'YEAR', 'HOUR', 'MINUTE', 'SECOND').
5480
- * @returns A FunctionNode representing the DATE_SUB SQL function.
5810
+ *
5811
+ * @param date - The base date.
5812
+ * @param interval - The numeric interval to subtract.
5813
+ * @param unit - The unit (e.g., 'DAY', 'MONTH').
5814
+ * @returns A `TypedExpression<Date>` representing the `DATE_SUB` SQL function.
5481
5815
  */
5482
- declare const dateSub: (date: OperandInput$3, interval: OperandInput$3, unit: OperandInput$3) => FunctionNode;
5816
+ declare const dateSub: (date: OperandInput$3, interval: OperandInput$3, unit: OperandInput$3) => TypedExpression<Date>;
5483
5817
  /**
5484
5818
  * Returns the difference between two dates in days.
5485
- * @param date1 - The end date.
5486
- * @param date2 - The start date.
5487
- * @returns A FunctionNode representing the DATE_DIFF SQL function.
5819
+ *
5820
+ * @param date1 - End date.
5821
+ * @param date2 - Start date.
5822
+ * @returns A `TypedExpression<number>` representing the `DATE_DIFF` SQL function.
5488
5823
  */
5489
- declare const dateDiff: (date1: OperandInput$3, date2: OperandInput$3) => FunctionNode;
5824
+ declare const dateDiff: (date1: OperandInput$3, date2: OperandInput$3) => TypedExpression<number>;
5490
5825
  /**
5491
5826
  * Converts a date or datetime value to a formatted string.
5492
- * @param date - The date or datetime value to format.
5493
- * @param format - The format string (dialect-specific).
5494
- * @returns A FunctionNode representing the DATE_FORMAT SQL function.
5827
+ *
5828
+ * @param date - The date value.
5829
+ * @param format - Dialect-specific format string.
5830
+ * @returns A `TypedExpression<string>` representing the `DATE_FORMAT` SQL function.
5495
5831
  */
5496
- declare const dateFormat: (date: OperandInput$3, format: OperandInput$3) => FunctionNode;
5832
+ declare const dateFormat: (date: OperandInput$3, format: OperandInput$3) => TypedExpression<string>;
5497
5833
  /**
5498
- * Returns the current Unix timestamp (seconds since 1970-01-01 00:00:00 UTC).
5499
- * @returns A FunctionNode representing the UNIX_TIMESTAMP SQL function.
5834
+ * Returns the current Unix timestamp (seconds since epoch).
5835
+ *
5836
+ * @returns A `TypedExpression<number>` representing the `UNIX_TIMESTAMP` SQL function.
5500
5837
  */
5501
- declare const unixTimestamp: () => FunctionNode;
5838
+ declare const unixTimestamp: () => TypedExpression<number>;
5502
5839
  /**
5503
- * Converts a Unix timestamp (seconds since 1970-01-01 00:00:00 UTC) to a date.
5504
- * @param timestamp - Unix timestamp in seconds.
5505
- * @returns A FunctionNode representing the FROM_UNIXTIME SQL function.
5840
+ * Converts a Unix timestamp to a Date.
5841
+ *
5842
+ * @param timestamp - Seconds since epoch.
5843
+ * @returns A `TypedExpression<Date>` representing the `FROM_UNIXTIME` SQL function.
5506
5844
  */
5507
- declare const fromUnixTime: (timestamp: OperandInput$3) => FunctionNode;
5845
+ declare const fromUnixTime: (timestamp: OperandInput$3) => TypedExpression<Date>;
5508
5846
  /**
5509
5847
  * Returns the last day of the month for a given date.
5848
+ *
5510
5849
  * @param date - The date value.
5511
- * @returns A FunctionNode representing the END_OF_MONTH SQL function.
5850
+ * @returns A `TypedExpression<Date>` representing the `END_OF_MONTH` SQL function.
5512
5851
  */
5513
- declare const endOfMonth: (date: OperandInput$3) => FunctionNode;
5852
+ declare const endOfMonth: (date: OperandInput$3) => TypedExpression<Date>;
5514
5853
  /**
5515
5854
  * Returns the index of the weekday for a given date (1 = Sunday, 2 = Monday, etc.).
5855
+ *
5516
5856
  * @param date - The date value.
5517
- * @returns A FunctionNode representing the DAY_OF_WEEK SQL function.
5857
+ * @returns A `TypedExpression<number>` representing the `DAY_OF_WEEK` SQL function.
5518
5858
  */
5519
- declare const dayOfWeek: (date: OperandInput$3) => FunctionNode;
5859
+ declare const dayOfWeek: (date: OperandInput$3) => TypedExpression<number>;
5520
5860
  /**
5521
5861
  * Returns the week number of the year for a given date.
5862
+ *
5522
5863
  * @param date - The date value.
5523
- * @returns A FunctionNode representing the WEEK_OF_YEAR SQL function.
5864
+ * @returns A `TypedExpression<number>` representing the `WEEK_OF_YEAR` SQL function.
5524
5865
  */
5525
- declare const weekOfYear: (date: OperandInput$3) => FunctionNode;
5866
+ declare const weekOfYear: (date: OperandInput$3) => TypedExpression<number>;
5526
5867
  /**
5527
- * Truncates a date or datetime value to a specified precision (e.g., first day of the month/year).
5528
- * @param part - The truncation precision (e.g., 'YEAR', 'MONTH', 'DAY').
5529
- * @param date - The date or datetime value to truncate.
5530
- * @returns A FunctionNode representing the DATE_TRUNC SQL function.
5868
+ * Truncates a date or datetime value to a specified precision.
5869
+ *
5870
+ * @param part - The precision (e.g., 'YEAR', 'MONTH').
5871
+ * @param date - The date to truncate.
5872
+ * @returns A `TypedExpression<Date>` representing the `DATE_TRUNC` SQL function.
5531
5873
  */
5532
- declare const dateTrunc: (part: OperandInput$3, date: OperandInput$3) => FunctionNode;
5874
+ declare const dateTrunc: (part: OperandInput$3, date: OperandInput$3) => TypedExpression<Date>;
5533
5875
  /**
5534
- * Returns the difference between two timestamps as an interval.
5535
- * @param timestamp - The end timestamp.
5536
- * @param baseTimestamp - The start timestamp (optional, defaults to current time).
5537
- * @returns A FunctionNode representing the AGE SQL function.
5876
+ * Returns the difference between two timestamps as an interval string.
5877
+ *
5878
+ * @param timestamp - End timestamp.
5879
+ * @param baseTimestamp - Optional start timestamp.
5880
+ * @returns A `TypedExpression<string>` representing the `AGE` SQL function.
5538
5881
  */
5539
- declare const age: (timestamp: OperandInput$3, baseTimestamp?: OperandInput$3) => FunctionNode;
5882
+ declare const age: (timestamp: OperandInput$3, baseTimestamp?: OperandInput$3) => TypedExpression<string>;
5540
5883
  /**
5541
5884
  * Extracts the hour from a date or datetime value.
5542
- * @param date - The date or datetime value.
5543
- * @returns A FunctionNode representing the HOUR SQL function.
5885
+ *
5886
+ * @param date - The date value.
5887
+ * @returns A `TypedExpression<number>` representing the `HOUR` SQL function.
5544
5888
  */
5545
- declare const hour: (date: OperandInput$3) => FunctionNode;
5889
+ declare const hour: (date: OperandInput$3) => TypedExpression<number>;
5546
5890
  /**
5547
5891
  * Extracts the minute from a date or datetime value.
5548
- * @param date - The date or datetime value.
5549
- * @returns A FunctionNode representing the MINUTE SQL function.
5892
+ *
5893
+ * @param date - The date value.
5894
+ * @returns A `TypedExpression<number>` representing the `MINUTE` SQL function.
5550
5895
  */
5551
- declare const minute: (date: OperandInput$3) => FunctionNode;
5896
+ declare const minute: (date: OperandInput$3) => TypedExpression<number>;
5552
5897
  /**
5553
5898
  * Extracts the second from a date or datetime value.
5554
- * @param date - The date or datetime value.
5555
- * @returns A FunctionNode representing the SECOND SQL function.
5899
+ *
5900
+ * @param date - The date value.
5901
+ * @returns A `TypedExpression<number>` representing the `SECOND` SQL function.
5556
5902
  */
5557
- declare const second: (date: OperandInput$3) => FunctionNode;
5903
+ declare const second: (date: OperandInput$3) => TypedExpression<number>;
5558
5904
  /**
5559
5905
  * Extracts the quarter from a date or datetime value (1-4).
5560
- * @param date - The date or datetime value.
5561
- * @returns A FunctionNode representing the QUARTER SQL function.
5906
+ *
5907
+ * @param date - The date value.
5908
+ * @returns A `TypedExpression<number>` representing the `QUARTER` SQL function.
5562
5909
  */
5563
- declare const quarter: (date: OperandInput$3) => FunctionNode;
5910
+ declare const quarter: (date: OperandInput$3) => TypedExpression<number>;
5564
5911
 
5565
5912
  type OperandInput$2 = OperandNode | ColumnDef | string | number | boolean | null;
5566
5913
  /**
5567
5914
  * Returns the first non-null value in a list.
5568
- * @param args - The list of values to check.
5569
- * @returns A FunctionNode representing the COALESCE SQL function.
5915
+ *
5916
+ * @param args - The list of values or columns to check.
5917
+ * @returns A `TypedExpression<T>` representing the `COALESCE` SQL function.
5918
+ *
5919
+ * @example
5920
+ * coalesce(users.nickname, users.firstName, 'Guest');
5570
5921
  */
5571
- declare const coalesce: (...args: OperandInput$2[]) => FunctionNode;
5922
+ declare const coalesce: <T = unknown>(...args: OperandInput$2[]) => TypedExpression<T>;
5572
5923
  /**
5573
5924
  * Returns null if the two arguments are equal, otherwise returns the first argument.
5925
+ *
5574
5926
  * @param val1 - The first value.
5575
- * @param val2 - The second value.
5576
- * @returns A FunctionNode representing the NULLIF SQL function.
5927
+ * @param val2 - The second value to compare against.
5928
+ * @returns A `TypedExpression<T>` representing the `NULLIF` SQL function.
5577
5929
  */
5578
- declare const nullif: (val1: OperandInput$2, val2: OperandInput$2) => FunctionNode;
5930
+ declare const nullif: <T = unknown>(val1: OperandInput$2, val2: OperandInput$2) => TypedExpression<T>;
5579
5931
  /**
5580
5932
  * Returns the largest value in a list.
5581
- * @param args - The list of values to compare.
5582
- * @returns A FunctionNode representing the GREATEST SQL function.
5933
+ *
5934
+ * @param args - The list of values or columns to compare.
5935
+ * @returns A `TypedExpression<T>` representing the `GREATEST` SQL function.
5583
5936
  */
5584
- declare const greatest: (...args: OperandInput$2[]) => FunctionNode;
5937
+ declare const greatest: <T = unknown>(...args: OperandInput$2[]) => TypedExpression<T>;
5585
5938
  /**
5586
5939
  * Returns the smallest value in a list.
5587
- * @param args - The list of values to compare.
5588
- * @returns A FunctionNode representing the LEAST SQL function.
5940
+ *
5941
+ * @param args - The list of values or columns to compare.
5942
+ * @returns A `TypedExpression<T>` representing the `LEAST` SQL function.
5589
5943
  */
5590
- declare const least: (...args: OperandInput$2[]) => FunctionNode;
5944
+ declare const least: <T = unknown>(...args: OperandInput$2[]) => TypedExpression<T>;
5591
5945
  /**
5592
5946
  * Returns the first argument if it is not null, otherwise returns the second argument.
5947
+ *
5593
5948
  * @param val - The value to check.
5594
5949
  * @param defaultValue - The default value to return if val is null.
5595
- * @returns A FunctionNode representing the COALESCE SQL function.
5950
+ * @returns A `TypedExpression<T>` representing the `COALESCE` SQL function.
5596
5951
  */
5597
- declare const ifNull: (val: OperandInput$2, defaultValue: OperandInput$2) => FunctionNode;
5952
+ declare const ifNull: <T = unknown>(val: OperandInput$2, defaultValue: OperandInput$2) => TypedExpression<T>;
5598
5953
 
5599
5954
  type OperandInput$1 = OperandNode | ColumnDef | string | number | boolean | null;
5600
- declare const jsonLength: (target: OperandInput$1, path?: OperandInput$1) => FunctionNode;
5601
- declare const jsonSet: (target: OperandInput$1, path: OperandInput$1, value: OperandInput$1) => FunctionNode;
5602
- declare const jsonArrayAgg: (value: OperandInput$1) => FunctionNode;
5603
- declare const jsonContains: (target: OperandInput$1, candidate: OperandInput$1, path?: OperandInput$1) => FunctionNode;
5955
+ /**
5956
+ * Returns the number of elements in a JSON array or object.
5957
+ *
5958
+ * @param target - JSON column or value.
5959
+ * @param path - Optional JSON path.
5960
+ * @returns A `TypedExpression<number>` representing the `JSON_LENGTH` SQL function.
5961
+ */
5962
+ declare const jsonLength: (target: OperandInput$1, path?: OperandInput$1) => TypedExpression<number>;
5963
+ /**
5964
+ * Inserts or updates a value in a JSON document.
5965
+ *
5966
+ * @param target - JSON column or value.
5967
+ * @param path - JSON path to set.
5968
+ * @param value - Value to set.
5969
+ * @returns A `TypedExpression<T>` representing the `JSON_SET` SQL function.
5970
+ */
5971
+ declare const jsonSet: <T = unknown>(target: OperandInput$1, path: OperandInput$1, value: OperandInput$1) => TypedExpression<T>;
5972
+ /**
5973
+ * Aggregates values into a JSON array.
5974
+ *
5975
+ * @param value - Column or expression to aggregate.
5976
+ * @returns A `TypedExpression<unknown[]>` representing the `JSON_ARRAYAGG` SQL function.
5977
+ */
5978
+ declare const jsonArrayAgg: (value: OperandInput$1) => TypedExpression<unknown[]>;
5979
+ /**
5980
+ * Checks if a JSON document contains a specific piece of data.
5981
+ *
5982
+ * @param target - JSON column or value.
5983
+ * @param candidate - Data to look for.
5984
+ * @param path - Optional JSON path to search within.
5985
+ * @returns A `TypedExpression<boolean>` representing the `JSON_CONTAINS` SQL function.
5986
+ */
5987
+ declare const jsonContains: (target: OperandInput$1, candidate: OperandInput$1, path?: OperandInput$1) => TypedExpression<boolean>;
5604
5988
 
5605
5989
  type OperandInput = OperandNode | ColumnDef | string | number | boolean | null;
5606
- declare const arrayAppend: (array: OperandInput, value: OperandInput) => FunctionNode;
5990
+ /**
5991
+ * Appends a value to the end of an array.
5992
+ *
5993
+ * @param array - Array column or value.
5994
+ * @param value - Value to append.
5995
+ * @returns A `TypedExpression<unknown[]>` representing the `ARRAY_APPEND` SQL function.
5996
+ */
5997
+ declare const arrayAppend: (array: OperandInput, value: OperandInput) => TypedExpression<unknown[]>;
5607
5998
 
5608
5999
  /**
5609
6000
  * Browser-compatible implementation of AsyncLocalStorage.
@@ -6557,4 +6948,4 @@ type PooledExecutorFactoryOptions<TConn> = {
6557
6948
  */
6558
6949
  declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
6559
6950
 
6560
- export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, type IntrospectOptions, type JsonPathNode, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
6951
+ export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, type IntrospectOptions, type JsonPathNode, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };