metal-orm 1.0.45 → 1.0.47

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.
Files changed (63) hide show
  1. package/dist/index.cjs +1092 -323
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +99 -9
  4. package/dist/index.d.ts +99 -9
  5. package/dist/index.js +1087 -323
  6. package/dist/index.js.map +1 -1
  7. package/package.json +1 -1
  8. package/scripts/generate-entities.mjs +36 -9
  9. package/src/codegen/typescript.ts +22 -10
  10. package/src/core/ast/adapters.ts +2 -1
  11. package/src/core/ast/expression-builders.ts +13 -0
  12. package/src/core/ast/expression-nodes.ts +25 -5
  13. package/src/core/ast/expression-visitor.ts +5 -0
  14. package/src/core/ast/query.ts +9 -1
  15. package/src/core/ddl/dialects/base-schema-dialect.ts +2 -1
  16. package/src/core/ddl/dialects/mssql-schema-dialect.ts +10 -23
  17. package/src/core/ddl/dialects/mysql-schema-dialect.ts +10 -24
  18. package/src/core/ddl/dialects/postgres-schema-dialect.ts +10 -23
  19. package/src/core/ddl/dialects/render-reference.test.ts +2 -1
  20. package/src/core/ddl/dialects/sqlite-schema-dialect.ts +9 -23
  21. package/src/core/ddl/introspect/catalogs/index.ts +4 -1
  22. package/src/core/ddl/introspect/catalogs/mssql.ts +126 -0
  23. package/src/core/ddl/introspect/catalogs/mysql.ts +89 -0
  24. package/src/core/ddl/introspect/catalogs/postgres.ts +2 -1
  25. package/src/core/ddl/introspect/catalogs/sqlite.ts +47 -0
  26. package/src/core/ddl/introspect/functions/mssql.ts +84 -0
  27. package/src/core/ddl/introspect/mssql.ts +471 -194
  28. package/src/core/ddl/introspect/mysql.ts +336 -125
  29. package/src/core/ddl/introspect/postgres.ts +45 -5
  30. package/src/core/ddl/introspect/run-select.ts +3 -8
  31. package/src/core/ddl/introspect/sqlite.ts +113 -59
  32. package/src/core/ddl/schema-dialect.ts +2 -1
  33. package/src/core/ddl/schema-diff.ts +2 -1
  34. package/src/core/ddl/schema-generator.ts +2 -1
  35. package/src/core/ddl/schema-types.ts +3 -1
  36. package/src/core/ddl/sql-writing.ts +2 -1
  37. package/src/core/dialect/abstract.ts +12 -1
  38. package/src/core/dialect/mssql/index.ts +4 -10
  39. package/src/core/functions/datetime.ts +2 -1
  40. package/src/core/functions/numeric.ts +2 -1
  41. package/src/core/functions/text.ts +2 -1
  42. package/src/decorators/{column.ts → column-decorator.ts} +4 -1
  43. package/src/decorators/index.ts +1 -1
  44. package/src/index.ts +2 -1
  45. package/src/orm/entity-metadata.ts +2 -1
  46. package/src/orm/lazy-batch.ts +2 -1
  47. package/src/orm/orm-session.ts +2 -1
  48. package/src/query-builder/column-selector.ts +2 -1
  49. package/src/query-builder/delete.ts +2 -1
  50. package/src/query-builder/insert.ts +2 -1
  51. package/src/query-builder/query-ast-service.ts +4 -3
  52. package/src/query-builder/relation-projection-helper.ts +2 -1
  53. package/src/query-builder/relation-service.ts +2 -1
  54. package/src/query-builder/select/predicate-facet.ts +2 -1
  55. package/src/query-builder/select/projection-facet.ts +2 -1
  56. package/src/query-builder/select-helpers.ts +2 -1
  57. package/src/query-builder/select-query-state.ts +2 -0
  58. package/src/query-builder/select.ts +2 -1
  59. package/src/query-builder/update.ts +2 -1
  60. package/src/schema/{column.ts → column-types.ts} +317 -290
  61. package/src/schema/table-guards.ts +1 -1
  62. package/src/schema/table.ts +1 -1
  63. package/src/schema/types.ts +10 -8
package/dist/index.d.cts CHANGED
@@ -1,7 +1,24 @@
1
1
  /**
2
- * Supported column data types for database schema definitions
2
+ * Canonical, dialect-agnostic column data types.
3
+ * Keep this intentionally small; dialect-specific names should be expressed via `dialectTypes`.
3
4
  */
4
- type ColumnType = 'INT' | 'INTEGER' | 'BIGINT' | 'VARCHAR' | 'TEXT' | 'JSON' | 'ENUM' | 'DECIMAL' | 'FLOAT' | 'DOUBLE' | 'UUID' | 'BINARY' | 'VARBINARY' | 'BLOB' | 'BYTEA' | 'DATE' | 'DATETIME' | 'TIMESTAMP' | 'TIMESTAMPTZ' | 'BOOLEAN' | 'int' | 'integer' | 'bigint' | 'varchar' | 'text' | 'json' | 'enum' | 'decimal' | 'float' | 'double' | 'uuid' | 'binary' | 'varbinary' | 'blob' | 'bytea' | 'date' | 'datetime' | 'timestamp' | 'timestamptz' | 'boolean';
5
+ declare const STANDARD_COLUMN_TYPES: readonly ["INT", "INTEGER", "BIGINT", "VARCHAR", "TEXT", "JSON", "ENUM", "DECIMAL", "FLOAT", "DOUBLE", "UUID", "BINARY", "VARBINARY", "BLOB", "DATE", "DATETIME", "TIMESTAMP", "TIMESTAMPTZ", "BOOLEAN"];
6
+ /** Known logical types the ORM understands. */
7
+ type StandardColumnType = (typeof STANDARD_COLUMN_TYPES)[number];
8
+ /**
9
+ * Column type value.
10
+ * We allow arbitrary strings so new/dialect-specific types don't require touching this module.
11
+ */
12
+ type ColumnType = StandardColumnType | (string & {});
13
+ /**
14
+ * Normalizes a column type to its canonical lowercase form when it's one of the known logical types.
15
+ * Unknown/custom types are returned untouched to avoid clobbering dialect-specific casing.
16
+ */
17
+ declare const normalizeColumnType: (type: ColumnType) => ColumnType;
18
+ /**
19
+ * Renders a raw SQL type name with optional parameters.
20
+ */
21
+ declare const renderTypeWithArgs: (sqlType: string, args?: unknown[]) => string;
5
22
  type ReferentialAction = 'NO ACTION' | 'RESTRICT' | 'CASCADE' | 'SET NULL' | 'SET DEFAULT';
6
23
  interface RawDefaultValue {
7
24
  raw: string;
@@ -29,6 +46,8 @@ interface ColumnDef<T extends ColumnType = ColumnType, TRuntime = unknown> {
29
46
  name: string;
30
47
  /** Data type of the column */
31
48
  type: T;
49
+ /** Optional explicit SQL type per dialect (e.g., { postgres: 'bytea' }) */
50
+ dialectTypes?: Partial<Record<string, string>>;
32
51
  /** Optional override for the inferred TypeScript type */
33
52
  tsType?: TRuntime;
34
53
  /** Whether this column is a primary key */
@@ -132,6 +151,15 @@ declare const col: {
132
151
  * @param values - Enum values
133
152
  */
134
153
  enum: (values: string[]) => ColumnDef<"ENUM">;
154
+ /**
155
+ * Creates a column definition with a custom SQL type.
156
+ * Useful for dialect-specific types without polluting the standard set.
157
+ */
158
+ custom: (type: string, opts?: {
159
+ dialect?: string;
160
+ args?: unknown[];
161
+ tsType?: unknown;
162
+ }) => ColumnDef;
135
163
  /**
136
164
  * Marks a column definition as a primary key
137
165
  * @param def - Column definition to modify
@@ -407,12 +435,13 @@ declare function getColumn<T extends TableDef>(table: T, key: string): ColumnDef
407
435
  * Resolves a relation definition to its target table type.
408
436
  */
409
437
  type RelationTargetTable<TRel extends RelationDef> = TRel extends HasManyRelation<infer TTarget> ? TTarget : TRel extends HasOneRelation<infer TTarget> ? TTarget : TRel extends BelongsToRelation<infer TTarget> ? TTarget : TRel extends BelongsToManyRelation<infer TTarget> ? TTarget : never;
438
+ type NormalizedColumnType<T extends ColumnDef> = Lowercase<T['type'] & string>;
410
439
  /**
411
440
  * Maps a ColumnDef to its TypeScript type representation
412
441
  */
413
442
  type ColumnToTs<T extends ColumnDef> = [
414
443
  unknown
415
- ] extends [T['tsType']] ? T['type'] extends 'INT' | 'INTEGER' | 'int' | 'integer' ? number : T['type'] extends 'BIGINT' | 'bigint' ? number | bigint : T['type'] extends 'DECIMAL' | 'decimal' | 'FLOAT' | 'float' | 'DOUBLE' | 'double' ? number : T['type'] extends 'BOOLEAN' | 'boolean' ? boolean : T['type'] extends 'JSON' | 'json' ? unknown : T['type'] extends 'BLOB' | 'blob' | 'BINARY' | 'binary' | 'VARBINARY' | 'varbinary' | 'BYTEA' | 'bytea' ? Buffer : T['type'] extends 'DATE' | 'date' | 'DATETIME' | 'datetime' | 'TIMESTAMP' | 'timestamp' | 'TIMESTAMPTZ' | 'timestamptz' ? string : string : Exclude<T['tsType'], undefined>;
444
+ ] extends [T['tsType']] ? NormalizedColumnType<T> extends 'int' | 'integer' ? number : NormalizedColumnType<T> extends 'bigint' ? number | bigint : NormalizedColumnType<T> extends 'decimal' | 'float' | 'double' ? number : NormalizedColumnType<T> extends 'boolean' ? boolean : NormalizedColumnType<T> extends 'json' ? unknown : NormalizedColumnType<T> extends 'blob' | 'binary' | 'varbinary' | 'bytea' ? Buffer : NormalizedColumnType<T> extends 'date' | 'datetime' | 'timestamp' | 'timestamptz' ? string : string : Exclude<T['tsType'], undefined>;
416
445
  /**
417
446
  * Infers a row shape from a table definition
418
447
  */
@@ -660,6 +689,18 @@ interface CaseExpressionNode {
660
689
  /** Optional alias for the result */
661
690
  alias?: string;
662
691
  }
692
+ /**
693
+ * AST node representing a CAST expression (CAST(value AS type)).
694
+ */
695
+ interface CastExpressionNode {
696
+ type: 'Cast';
697
+ /** Expression being cast */
698
+ expression: OperandNode;
699
+ /** SQL type literal, e.g. "varchar(255)" */
700
+ castType: string;
701
+ /** Optional alias for the result */
702
+ alias?: string;
703
+ }
663
704
  /**
664
705
  * AST node representing a window function
665
706
  */
@@ -688,12 +729,13 @@ interface ArithmeticExpressionNode {
688
729
  /**
689
730
  * Union type representing any operand that can be used in expressions
690
731
  */
691
- type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode;
732
+ type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode | ArithmeticExpressionNode;
692
733
  declare const isOperandNode: (node: unknown) => node is OperandNode;
693
734
  declare const isFunctionNode: (node: unknown) => node is FunctionNode;
694
735
  declare const isCaseExpressionNode: (node: unknown) => node is CaseExpressionNode;
736
+ declare const isCastExpressionNode: (node: unknown) => node is CastExpressionNode;
695
737
  declare const isWindowFunctionNode: (node: unknown) => node is WindowFunctionNode;
696
- declare const isExpressionSelectionNode: (node: ColumnRef | FunctionNode | CaseExpressionNode | WindowFunctionNode) => node is FunctionNode | CaseExpressionNode | WindowFunctionNode;
738
+ declare const isExpressionSelectionNode: (node: ColumnRef | FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode) => node is FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode;
697
739
  /**
698
740
  * AST node representing a binary expression (e.g., column = value)
699
741
  */
@@ -927,6 +969,10 @@ declare const caseWhen: (conditions: {
927
969
  when: ExpressionNode;
928
970
  then: OperandNode | ColumnRef | string | number | boolean | null;
929
971
  }[], elseValue?: OperandNode | ColumnRef | string | number | boolean | null) => CaseExpressionNode;
972
+ /**
973
+ * Builds a CAST expression node for casting values to SQL types.
974
+ */
975
+ declare const cast: (expression: OperandNode | ColumnRef | string | number | boolean | null, castType: string) => CastExpressionNode;
930
976
  /**
931
977
  * Creates an EXISTS expression
932
978
  * @param subquery - Subquery to check for existence
@@ -1068,6 +1114,7 @@ interface OperandVisitor<R> {
1068
1114
  visitJsonPath?(node: JsonPathNode): R;
1069
1115
  visitScalarSubquery?(node: ScalarSubqueryNode): R;
1070
1116
  visitCaseExpression?(node: CaseExpressionNode): R;
1117
+ visitCast?(node: CastExpressionNode): R;
1071
1118
  visitWindowFunction?(node: WindowFunctionNode): R;
1072
1119
  visitAliasRef?(node: AliasRefNode): R;
1073
1120
  otherwise?(node: OperandNode): R;
@@ -1227,7 +1274,7 @@ interface SelectQueryNode {
1227
1274
  /** FROM clause table (either a Table or a FunctionTable) */
1228
1275
  from: TableSourceNode;
1229
1276
  /** SELECT clause columns */
1230
- columns: (ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode)[];
1277
+ columns: (ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode)[];
1231
1278
  /** JOIN clauses */
1232
1279
  joins: JoinNode[];
1233
1280
  /** Optional WHERE clause */
@@ -1559,7 +1606,7 @@ type DialectKey = 'postgres' | 'mysql' | 'sqlite' | 'mssql' | (string & {});
1559
1606
  /**
1560
1607
  * Node types that can be used in query projections
1561
1608
  */
1562
- type ProjectionNode = ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode;
1609
+ type ProjectionNode = ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode;
1563
1610
  /**
1564
1611
  * Manages the state of a SELECT query being built
1565
1612
  */
@@ -1862,7 +1909,7 @@ declare class QueryAstService {
1862
1909
  * @param columns - Columns to select (key: alias, value: column definition or expression)
1863
1910
  * @returns Column selection result with updated state and added columns
1864
1911
  */
1865
- select(columns: Record<string, ColumnDef | FunctionNode | CaseExpressionNode | WindowFunctionNode>): ColumnSelectionResult;
1912
+ select(columns: Record<string, ColumnDef | FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode>): ColumnSelectionResult;
1866
1913
  /**
1867
1914
  * Selects raw column expressions (best-effort parser for simple references/functions)
1868
1915
  * @param cols - Raw column expressions
@@ -2932,6 +2979,9 @@ interface HydrationContext<E extends DomainEvent = AnyDomainEvent> {
2932
2979
  entityContext: EntityContext;
2933
2980
  }
2934
2981
 
2982
+ /**
2983
+ * Options for controlling the behavior of save graph operations.
2984
+ */
2935
2985
  interface SaveGraphOptions {
2936
2986
  /** Remove existing collection members that are not present in the payload */
2937
2987
  pruneMissing?: boolean;
@@ -4132,6 +4182,7 @@ interface DatabaseColumn {
4132
4182
  generated?: 'always' | 'byDefault';
4133
4183
  unique?: boolean | string;
4134
4184
  references?: ForeignKeyReference;
4185
+ comment?: string;
4135
4186
  check?: string;
4136
4187
  }
4137
4188
  /** Represents an index in the database schema. */
@@ -4154,6 +4205,7 @@ interface DatabaseTable {
4154
4205
  primaryKey?: string[];
4155
4206
  indexes?: DatabaseIndex[];
4156
4207
  checks?: DatabaseCheck[];
4208
+ comment?: string;
4157
4209
  }
4158
4210
  /** Represents the overall database schema. */
4159
4211
  interface DatabaseSchema {
@@ -4881,6 +4933,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
4881
4933
  visitScalarSubquery(node: ScalarSubqueryNode): string;
4882
4934
  visitCaseExpression(node: CaseExpressionNode): string;
4883
4935
  visitWindowFunction(node: WindowFunctionNode): string;
4936
+ visitCast(node: CastExpressionNode): string;
4884
4937
  visitAliasRef(node: AliasRefNode): string;
4885
4938
  /**
4886
4939
  * Prints a binary expression to TypeScript code
@@ -4961,6 +5014,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
4961
5014
  * @returns TypeScript code representation
4962
5015
  */
4963
5016
  private printWindowFunctionOperand;
5017
+ private printCastOperand;
4964
5018
  /**
4965
5019
  * Converts method chain lines to inline format
4966
5020
  * @param lines - Method chain lines
@@ -4998,10 +5052,45 @@ declare const createEntityProxy: <TTable extends TableDef, TLazy extends keyof R
4998
5052
  */
4999
5053
  declare const createEntityFromRow: <TTable extends TableDef, TResult extends EntityInstance<TTable> = EntityInstance<TTable>>(ctx: EntityContext, table: TTable, row: Record<string, unknown>, lazyRelations?: (keyof RelationMap<TTable>)[]) => TResult;
5000
5054
 
5055
+ /**
5056
+ * An array of database rows, each represented as a record of string keys to unknown values.
5057
+ */
5001
5058
  type Rows$3 = Record<string, unknown>[];
5059
+ /**
5060
+ * Loads related entities for a has-many relation in batch.
5061
+ * @param ctx - The entity context.
5062
+ * @param rootTable - The root table of the relation.
5063
+ * @param _relationName - The name of the relation (unused).
5064
+ * @param relation - The has-many relation definition.
5065
+ * @returns A promise resolving to a map of root keys to arrays of related rows.
5066
+ */
5002
5067
  declare const loadHasManyRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: HasManyRelation) => Promise<Map<string, Rows$3>>;
5068
+ /**
5069
+ * Loads related entities for a has-one relation in batch.
5070
+ * @param ctx - The entity context.
5071
+ * @param rootTable - The root table of the relation.
5072
+ * @param _relationName - The name of the relation (unused).
5073
+ * @param relation - The has-one relation definition.
5074
+ * @returns A promise resolving to a map of root keys to single related rows.
5075
+ */
5003
5076
  declare const loadHasOneRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: HasOneRelation) => Promise<Map<string, Record<string, unknown>>>;
5077
+ /**
5078
+ * Loads related entities for a belongs-to relation in batch.
5079
+ * @param ctx - The entity context.
5080
+ * @param rootTable - The root table of the relation.
5081
+ * @param _relationName - The name of the relation (unused).
5082
+ * @param relation - The belongs-to relation definition.
5083
+ * @returns A promise resolving to a map of foreign keys to single related rows.
5084
+ */
5004
5085
  declare const loadBelongsToRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: BelongsToRelation) => Promise<Map<string, Record<string, unknown>>>;
5086
+ /**
5087
+ * Loads related entities for a belongs-to-many relation in batch, including pivot data.
5088
+ * @param ctx - The entity context.
5089
+ * @param rootTable - The root table of the relation.
5090
+ * @param _relationName - The name of the relation (unused).
5091
+ * @param relation - The belongs-to-many relation definition.
5092
+ * @returns A promise resolving to a map of root keys to arrays of related rows with pivot data.
5093
+ */
5005
5094
  declare const loadBelongsToManyRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: BelongsToManyRelation) => Promise<Map<string, Rows$3>>;
5006
5095
 
5007
5096
  /**
@@ -5206,6 +5295,7 @@ declare function Entity(options?: EntityOptions): DualModeClassDecorator;
5206
5295
  interface ColumnOptions {
5207
5296
  type: ColumnType;
5208
5297
  args?: ColumnDef['args'];
5298
+ dialectTypes?: ColumnDef['dialectTypes'];
5209
5299
  notNull?: boolean;
5210
5300
  primary?: boolean;
5211
5301
  tsType?: ColumnDef['tsType'];
@@ -5459,4 +5549,4 @@ type PooledExecutorFactoryOptions<TConn> = {
5459
5549
  */
5460
5550
  declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
5461
5551
 
5462
- export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type CascadeMode, type CaseExpressionNode, type CheckConstraint, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, 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 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 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 QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, 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, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, aliasRef, and, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bootstrapEntities, caseWhen, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, col, columnOperand, concat, concatWs, correlateBy, cos, cot, count, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getColumn, getSchemaIntrospector, getTableDefFromEntity, groupConcat, gt, gte, hasMany, hasOne, hydrateRows, inList, inSubquery, instr, introspectSchema, isCaseExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, max, min, mod, month, mul, neq, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, or, outerRef, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, repeat, replace, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, sel, selectFromEntity, sign, sin, space, sqrt, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };
5552
+ export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, 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 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 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 QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, 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, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, aliasRef, and, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bootstrapEntities, caseWhen, cast, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, col, columnOperand, concat, concatWs, correlateBy, cos, cot, count, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getColumn, getSchemaIntrospector, getTableDefFromEntity, groupConcat, gt, gte, hasMany, hasOne, hydrateRows, inList, inSubquery, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, max, min, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, or, outerRef, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, renderTypeWithArgs, repeat, replace, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, sel, selectFromEntity, sign, sin, space, sqrt, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,24 @@
1
1
  /**
2
- * Supported column data types for database schema definitions
2
+ * Canonical, dialect-agnostic column data types.
3
+ * Keep this intentionally small; dialect-specific names should be expressed via `dialectTypes`.
3
4
  */
4
- type ColumnType = 'INT' | 'INTEGER' | 'BIGINT' | 'VARCHAR' | 'TEXT' | 'JSON' | 'ENUM' | 'DECIMAL' | 'FLOAT' | 'DOUBLE' | 'UUID' | 'BINARY' | 'VARBINARY' | 'BLOB' | 'BYTEA' | 'DATE' | 'DATETIME' | 'TIMESTAMP' | 'TIMESTAMPTZ' | 'BOOLEAN' | 'int' | 'integer' | 'bigint' | 'varchar' | 'text' | 'json' | 'enum' | 'decimal' | 'float' | 'double' | 'uuid' | 'binary' | 'varbinary' | 'blob' | 'bytea' | 'date' | 'datetime' | 'timestamp' | 'timestamptz' | 'boolean';
5
+ declare const STANDARD_COLUMN_TYPES: readonly ["INT", "INTEGER", "BIGINT", "VARCHAR", "TEXT", "JSON", "ENUM", "DECIMAL", "FLOAT", "DOUBLE", "UUID", "BINARY", "VARBINARY", "BLOB", "DATE", "DATETIME", "TIMESTAMP", "TIMESTAMPTZ", "BOOLEAN"];
6
+ /** Known logical types the ORM understands. */
7
+ type StandardColumnType = (typeof STANDARD_COLUMN_TYPES)[number];
8
+ /**
9
+ * Column type value.
10
+ * We allow arbitrary strings so new/dialect-specific types don't require touching this module.
11
+ */
12
+ type ColumnType = StandardColumnType | (string & {});
13
+ /**
14
+ * Normalizes a column type to its canonical lowercase form when it's one of the known logical types.
15
+ * Unknown/custom types are returned untouched to avoid clobbering dialect-specific casing.
16
+ */
17
+ declare const normalizeColumnType: (type: ColumnType) => ColumnType;
18
+ /**
19
+ * Renders a raw SQL type name with optional parameters.
20
+ */
21
+ declare const renderTypeWithArgs: (sqlType: string, args?: unknown[]) => string;
5
22
  type ReferentialAction = 'NO ACTION' | 'RESTRICT' | 'CASCADE' | 'SET NULL' | 'SET DEFAULT';
6
23
  interface RawDefaultValue {
7
24
  raw: string;
@@ -29,6 +46,8 @@ interface ColumnDef<T extends ColumnType = ColumnType, TRuntime = unknown> {
29
46
  name: string;
30
47
  /** Data type of the column */
31
48
  type: T;
49
+ /** Optional explicit SQL type per dialect (e.g., { postgres: 'bytea' }) */
50
+ dialectTypes?: Partial<Record<string, string>>;
32
51
  /** Optional override for the inferred TypeScript type */
33
52
  tsType?: TRuntime;
34
53
  /** Whether this column is a primary key */
@@ -132,6 +151,15 @@ declare const col: {
132
151
  * @param values - Enum values
133
152
  */
134
153
  enum: (values: string[]) => ColumnDef<"ENUM">;
154
+ /**
155
+ * Creates a column definition with a custom SQL type.
156
+ * Useful for dialect-specific types without polluting the standard set.
157
+ */
158
+ custom: (type: string, opts?: {
159
+ dialect?: string;
160
+ args?: unknown[];
161
+ tsType?: unknown;
162
+ }) => ColumnDef;
135
163
  /**
136
164
  * Marks a column definition as a primary key
137
165
  * @param def - Column definition to modify
@@ -407,12 +435,13 @@ declare function getColumn<T extends TableDef>(table: T, key: string): ColumnDef
407
435
  * Resolves a relation definition to its target table type.
408
436
  */
409
437
  type RelationTargetTable<TRel extends RelationDef> = TRel extends HasManyRelation<infer TTarget> ? TTarget : TRel extends HasOneRelation<infer TTarget> ? TTarget : TRel extends BelongsToRelation<infer TTarget> ? TTarget : TRel extends BelongsToManyRelation<infer TTarget> ? TTarget : never;
438
+ type NormalizedColumnType<T extends ColumnDef> = Lowercase<T['type'] & string>;
410
439
  /**
411
440
  * Maps a ColumnDef to its TypeScript type representation
412
441
  */
413
442
  type ColumnToTs<T extends ColumnDef> = [
414
443
  unknown
415
- ] extends [T['tsType']] ? T['type'] extends 'INT' | 'INTEGER' | 'int' | 'integer' ? number : T['type'] extends 'BIGINT' | 'bigint' ? number | bigint : T['type'] extends 'DECIMAL' | 'decimal' | 'FLOAT' | 'float' | 'DOUBLE' | 'double' ? number : T['type'] extends 'BOOLEAN' | 'boolean' ? boolean : T['type'] extends 'JSON' | 'json' ? unknown : T['type'] extends 'BLOB' | 'blob' | 'BINARY' | 'binary' | 'VARBINARY' | 'varbinary' | 'BYTEA' | 'bytea' ? Buffer : T['type'] extends 'DATE' | 'date' | 'DATETIME' | 'datetime' | 'TIMESTAMP' | 'timestamp' | 'TIMESTAMPTZ' | 'timestamptz' ? string : string : Exclude<T['tsType'], undefined>;
444
+ ] extends [T['tsType']] ? NormalizedColumnType<T> extends 'int' | 'integer' ? number : NormalizedColumnType<T> extends 'bigint' ? number | bigint : NormalizedColumnType<T> extends 'decimal' | 'float' | 'double' ? number : NormalizedColumnType<T> extends 'boolean' ? boolean : NormalizedColumnType<T> extends 'json' ? unknown : NormalizedColumnType<T> extends 'blob' | 'binary' | 'varbinary' | 'bytea' ? Buffer : NormalizedColumnType<T> extends 'date' | 'datetime' | 'timestamp' | 'timestamptz' ? string : string : Exclude<T['tsType'], undefined>;
416
445
  /**
417
446
  * Infers a row shape from a table definition
418
447
  */
@@ -660,6 +689,18 @@ interface CaseExpressionNode {
660
689
  /** Optional alias for the result */
661
690
  alias?: string;
662
691
  }
692
+ /**
693
+ * AST node representing a CAST expression (CAST(value AS type)).
694
+ */
695
+ interface CastExpressionNode {
696
+ type: 'Cast';
697
+ /** Expression being cast */
698
+ expression: OperandNode;
699
+ /** SQL type literal, e.g. "varchar(255)" */
700
+ castType: string;
701
+ /** Optional alias for the result */
702
+ alias?: string;
703
+ }
663
704
  /**
664
705
  * AST node representing a window function
665
706
  */
@@ -688,12 +729,13 @@ interface ArithmeticExpressionNode {
688
729
  /**
689
730
  * Union type representing any operand that can be used in expressions
690
731
  */
691
- type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode;
732
+ type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode | ArithmeticExpressionNode;
692
733
  declare const isOperandNode: (node: unknown) => node is OperandNode;
693
734
  declare const isFunctionNode: (node: unknown) => node is FunctionNode;
694
735
  declare const isCaseExpressionNode: (node: unknown) => node is CaseExpressionNode;
736
+ declare const isCastExpressionNode: (node: unknown) => node is CastExpressionNode;
695
737
  declare const isWindowFunctionNode: (node: unknown) => node is WindowFunctionNode;
696
- declare const isExpressionSelectionNode: (node: ColumnRef | FunctionNode | CaseExpressionNode | WindowFunctionNode) => node is FunctionNode | CaseExpressionNode | WindowFunctionNode;
738
+ declare const isExpressionSelectionNode: (node: ColumnRef | FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode) => node is FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode;
697
739
  /**
698
740
  * AST node representing a binary expression (e.g., column = value)
699
741
  */
@@ -927,6 +969,10 @@ declare const caseWhen: (conditions: {
927
969
  when: ExpressionNode;
928
970
  then: OperandNode | ColumnRef | string | number | boolean | null;
929
971
  }[], elseValue?: OperandNode | ColumnRef | string | number | boolean | null) => CaseExpressionNode;
972
+ /**
973
+ * Builds a CAST expression node for casting values to SQL types.
974
+ */
975
+ declare const cast: (expression: OperandNode | ColumnRef | string | number | boolean | null, castType: string) => CastExpressionNode;
930
976
  /**
931
977
  * Creates an EXISTS expression
932
978
  * @param subquery - Subquery to check for existence
@@ -1068,6 +1114,7 @@ interface OperandVisitor<R> {
1068
1114
  visitJsonPath?(node: JsonPathNode): R;
1069
1115
  visitScalarSubquery?(node: ScalarSubqueryNode): R;
1070
1116
  visitCaseExpression?(node: CaseExpressionNode): R;
1117
+ visitCast?(node: CastExpressionNode): R;
1071
1118
  visitWindowFunction?(node: WindowFunctionNode): R;
1072
1119
  visitAliasRef?(node: AliasRefNode): R;
1073
1120
  otherwise?(node: OperandNode): R;
@@ -1227,7 +1274,7 @@ interface SelectQueryNode {
1227
1274
  /** FROM clause table (either a Table or a FunctionTable) */
1228
1275
  from: TableSourceNode;
1229
1276
  /** SELECT clause columns */
1230
- columns: (ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode)[];
1277
+ columns: (ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode)[];
1231
1278
  /** JOIN clauses */
1232
1279
  joins: JoinNode[];
1233
1280
  /** Optional WHERE clause */
@@ -1559,7 +1606,7 @@ type DialectKey = 'postgres' | 'mysql' | 'sqlite' | 'mssql' | (string & {});
1559
1606
  /**
1560
1607
  * Node types that can be used in query projections
1561
1608
  */
1562
- type ProjectionNode = ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode;
1609
+ type ProjectionNode = ColumnNode | FunctionNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode;
1563
1610
  /**
1564
1611
  * Manages the state of a SELECT query being built
1565
1612
  */
@@ -1862,7 +1909,7 @@ declare class QueryAstService {
1862
1909
  * @param columns - Columns to select (key: alias, value: column definition or expression)
1863
1910
  * @returns Column selection result with updated state and added columns
1864
1911
  */
1865
- select(columns: Record<string, ColumnDef | FunctionNode | CaseExpressionNode | WindowFunctionNode>): ColumnSelectionResult;
1912
+ select(columns: Record<string, ColumnDef | FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode>): ColumnSelectionResult;
1866
1913
  /**
1867
1914
  * Selects raw column expressions (best-effort parser for simple references/functions)
1868
1915
  * @param cols - Raw column expressions
@@ -2932,6 +2979,9 @@ interface HydrationContext<E extends DomainEvent = AnyDomainEvent> {
2932
2979
  entityContext: EntityContext;
2933
2980
  }
2934
2981
 
2982
+ /**
2983
+ * Options for controlling the behavior of save graph operations.
2984
+ */
2935
2985
  interface SaveGraphOptions {
2936
2986
  /** Remove existing collection members that are not present in the payload */
2937
2987
  pruneMissing?: boolean;
@@ -4132,6 +4182,7 @@ interface DatabaseColumn {
4132
4182
  generated?: 'always' | 'byDefault';
4133
4183
  unique?: boolean | string;
4134
4184
  references?: ForeignKeyReference;
4185
+ comment?: string;
4135
4186
  check?: string;
4136
4187
  }
4137
4188
  /** Represents an index in the database schema. */
@@ -4154,6 +4205,7 @@ interface DatabaseTable {
4154
4205
  primaryKey?: string[];
4155
4206
  indexes?: DatabaseIndex[];
4156
4207
  checks?: DatabaseCheck[];
4208
+ comment?: string;
4157
4209
  }
4158
4210
  /** Represents the overall database schema. */
4159
4211
  interface DatabaseSchema {
@@ -4881,6 +4933,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
4881
4933
  visitScalarSubquery(node: ScalarSubqueryNode): string;
4882
4934
  visitCaseExpression(node: CaseExpressionNode): string;
4883
4935
  visitWindowFunction(node: WindowFunctionNode): string;
4936
+ visitCast(node: CastExpressionNode): string;
4884
4937
  visitAliasRef(node: AliasRefNode): string;
4885
4938
  /**
4886
4939
  * Prints a binary expression to TypeScript code
@@ -4961,6 +5014,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
4961
5014
  * @returns TypeScript code representation
4962
5015
  */
4963
5016
  private printWindowFunctionOperand;
5017
+ private printCastOperand;
4964
5018
  /**
4965
5019
  * Converts method chain lines to inline format
4966
5020
  * @param lines - Method chain lines
@@ -4998,10 +5052,45 @@ declare const createEntityProxy: <TTable extends TableDef, TLazy extends keyof R
4998
5052
  */
4999
5053
  declare const createEntityFromRow: <TTable extends TableDef, TResult extends EntityInstance<TTable> = EntityInstance<TTable>>(ctx: EntityContext, table: TTable, row: Record<string, unknown>, lazyRelations?: (keyof RelationMap<TTable>)[]) => TResult;
5000
5054
 
5055
+ /**
5056
+ * An array of database rows, each represented as a record of string keys to unknown values.
5057
+ */
5001
5058
  type Rows$3 = Record<string, unknown>[];
5059
+ /**
5060
+ * Loads related entities for a has-many relation in batch.
5061
+ * @param ctx - The entity context.
5062
+ * @param rootTable - The root table of the relation.
5063
+ * @param _relationName - The name of the relation (unused).
5064
+ * @param relation - The has-many relation definition.
5065
+ * @returns A promise resolving to a map of root keys to arrays of related rows.
5066
+ */
5002
5067
  declare const loadHasManyRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: HasManyRelation) => Promise<Map<string, Rows$3>>;
5068
+ /**
5069
+ * Loads related entities for a has-one relation in batch.
5070
+ * @param ctx - The entity context.
5071
+ * @param rootTable - The root table of the relation.
5072
+ * @param _relationName - The name of the relation (unused).
5073
+ * @param relation - The has-one relation definition.
5074
+ * @returns A promise resolving to a map of root keys to single related rows.
5075
+ */
5003
5076
  declare const loadHasOneRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: HasOneRelation) => Promise<Map<string, Record<string, unknown>>>;
5077
+ /**
5078
+ * Loads related entities for a belongs-to relation in batch.
5079
+ * @param ctx - The entity context.
5080
+ * @param rootTable - The root table of the relation.
5081
+ * @param _relationName - The name of the relation (unused).
5082
+ * @param relation - The belongs-to relation definition.
5083
+ * @returns A promise resolving to a map of foreign keys to single related rows.
5084
+ */
5004
5085
  declare const loadBelongsToRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: BelongsToRelation) => Promise<Map<string, Record<string, unknown>>>;
5086
+ /**
5087
+ * Loads related entities for a belongs-to-many relation in batch, including pivot data.
5088
+ * @param ctx - The entity context.
5089
+ * @param rootTable - The root table of the relation.
5090
+ * @param _relationName - The name of the relation (unused).
5091
+ * @param relation - The belongs-to-many relation definition.
5092
+ * @returns A promise resolving to a map of root keys to arrays of related rows with pivot data.
5093
+ */
5005
5094
  declare const loadBelongsToManyRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: BelongsToManyRelation) => Promise<Map<string, Rows$3>>;
5006
5095
 
5007
5096
  /**
@@ -5206,6 +5295,7 @@ declare function Entity(options?: EntityOptions): DualModeClassDecorator;
5206
5295
  interface ColumnOptions {
5207
5296
  type: ColumnType;
5208
5297
  args?: ColumnDef['args'];
5298
+ dialectTypes?: ColumnDef['dialectTypes'];
5209
5299
  notNull?: boolean;
5210
5300
  primary?: boolean;
5211
5301
  tsType?: ColumnDef['tsType'];
@@ -5459,4 +5549,4 @@ type PooledExecutorFactoryOptions<TConn> = {
5459
5549
  */
5460
5550
  declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
5461
5551
 
5462
- export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type CascadeMode, type CaseExpressionNode, type CheckConstraint, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, 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 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 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 QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, 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, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, aliasRef, and, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bootstrapEntities, caseWhen, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, col, columnOperand, concat, concatWs, correlateBy, cos, cot, count, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getColumn, getSchemaIntrospector, getTableDefFromEntity, groupConcat, gt, gte, hasMany, hasOne, hydrateRows, inList, inSubquery, instr, introspectSchema, isCaseExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, max, min, mod, month, mul, neq, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, or, outerRef, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, repeat, replace, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, sel, selectFromEntity, sign, sin, space, sqrt, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };
5552
+ export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, DefaultBelongsToReference, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, 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 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 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 QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, 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, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, aliasRef, and, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bootstrapEntities, caseWhen, cast, ceil, ceiling, char, charLength, clearExpressionDispatchers, clearOperandDispatchers, col, columnOperand, concat, concatWs, correlateBy, cos, cot, count, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getColumn, getSchemaIntrospector, getTableDefFromEntity, groupConcat, gt, gte, hasMany, hasOne, hydrateRows, inList, inSubquery, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonPath, lag, lastValue, lead, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, locate, log, log10, logBase, lower, lpad, lt, lte, ltrim, max, min, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, or, outerRef, pi, position, pow, power, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, renderColumnDefinition, renderTypeWithArgs, repeat, replace, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, sel, selectFromEntity, sign, sin, space, sqrt, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, visitExpression, visitOperand, weekOfYear, windowFunction, year };