metal-orm 1.0.42 → 1.0.43

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 (86) hide show
  1. package/README.md +22 -7
  2. package/dist/index.cjs +130 -74
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +121 -96
  5. package/dist/index.d.ts +121 -96
  6. package/dist/index.js +128 -74
  7. package/dist/index.js.map +1 -1
  8. package/package.json +8 -2
  9. package/scripts/run-eslint.mjs +34 -0
  10. package/src/codegen/typescript.ts +32 -15
  11. package/src/core/ast/builders.ts +7 -2
  12. package/src/core/ast/expression-builders.ts +0 -2
  13. package/src/core/ast/expression-nodes.ts +14 -5
  14. package/src/core/ast/expression-visitor.ts +11 -8
  15. package/src/core/ast/join-node.ts +1 -1
  16. package/src/core/ast/query.ts +6 -6
  17. package/src/core/ast/window-functions.ts +10 -2
  18. package/src/core/ddl/dialects/base-schema-dialect.ts +30 -3
  19. package/src/core/ddl/dialects/mssql-schema-dialect.ts +4 -0
  20. package/src/core/ddl/dialects/mysql-schema-dialect.ts +2 -0
  21. package/src/core/ddl/dialects/postgres-schema-dialect.ts +13 -1
  22. package/src/core/ddl/dialects/render-reference.test.ts +69 -0
  23. package/src/core/ddl/dialects/sqlite-schema-dialect.ts +9 -0
  24. package/src/core/ddl/introspect/mssql.ts +42 -8
  25. package/src/core/ddl/introspect/mysql.ts +30 -6
  26. package/src/core/ddl/introspect/postgres.ts +88 -34
  27. package/src/core/ddl/introspect/run-select.ts +6 -4
  28. package/src/core/ddl/introspect/sqlite.ts +56 -11
  29. package/src/core/ddl/introspect/types.ts +0 -1
  30. package/src/core/ddl/introspect/utils.ts +3 -3
  31. package/src/core/ddl/schema-dialect.ts +1 -0
  32. package/src/core/ddl/schema-generator.ts +4 -12
  33. package/src/core/ddl/sql-writing.ts +4 -4
  34. package/src/core/dialect/abstract.ts +18 -6
  35. package/src/core/dialect/base/function-table-formatter.ts +3 -2
  36. package/src/core/dialect/base/join-compiler.ts +5 -3
  37. package/src/core/dialect/base/returning-strategy.ts +1 -0
  38. package/src/core/dialect/base/sql-dialect.ts +3 -3
  39. package/src/core/dialect/mssql/functions.ts +24 -25
  40. package/src/core/dialect/mssql/index.ts +1 -4
  41. package/src/core/dialect/mysql/functions.ts +0 -1
  42. package/src/core/dialect/postgres/functions.ts +33 -34
  43. package/src/core/dialect/postgres/index.ts +1 -0
  44. package/src/core/dialect/sqlite/functions.ts +18 -19
  45. package/src/core/dialect/sqlite/index.ts +2 -0
  46. package/src/core/execution/db-executor.ts +1 -1
  47. package/src/core/execution/executors/mysql-executor.ts +2 -2
  48. package/src/core/execution/executors/postgres-executor.ts +1 -1
  49. package/src/core/execution/pooling/pool.ts +2 -0
  50. package/src/core/functions/datetime.ts +1 -1
  51. package/src/core/functions/numeric.ts +1 -1
  52. package/src/core/functions/text.ts +1 -1
  53. package/src/decorators/bootstrap.ts +27 -8
  54. package/src/decorators/column.ts +3 -11
  55. package/src/decorators/decorator-metadata.ts +3 -9
  56. package/src/decorators/entity.ts +21 -5
  57. package/src/decorators/relations.ts +2 -11
  58. package/src/orm/entity-context.ts +8 -8
  59. package/src/orm/entity-meta.ts +8 -8
  60. package/src/orm/entity-metadata.ts +11 -9
  61. package/src/orm/entity.ts +28 -29
  62. package/src/orm/execute.ts +4 -4
  63. package/src/orm/hydration.ts +42 -39
  64. package/src/orm/identity-map.ts +1 -1
  65. package/src/orm/lazy-batch.ts +9 -9
  66. package/src/orm/orm-session.ts +24 -23
  67. package/src/orm/orm.ts +2 -5
  68. package/src/orm/relation-change-processor.ts +12 -11
  69. package/src/orm/relations/belongs-to.ts +11 -11
  70. package/src/orm/relations/has-many.ts +10 -10
  71. package/src/orm/relations/has-one.ts +8 -7
  72. package/src/orm/relations/many-to-many.ts +13 -13
  73. package/src/orm/runtime-types.ts +4 -4
  74. package/src/orm/save-graph.ts +31 -25
  75. package/src/orm/unit-of-work.ts +17 -17
  76. package/src/query-builder/delete.ts +4 -3
  77. package/src/query-builder/hydration-manager.ts +6 -5
  78. package/src/query-builder/insert.ts +12 -8
  79. package/src/query-builder/query-ast-service.ts +2 -2
  80. package/src/query-builder/raw-column-parser.ts +2 -1
  81. package/src/query-builder/select-helpers.ts +2 -2
  82. package/src/query-builder/select.ts +31 -31
  83. package/src/query-builder/update.ts +4 -3
  84. package/src/schema/column.ts +26 -26
  85. package/src/schema/table.ts +47 -18
  86. package/src/schema/types.ts +22 -22
package/dist/index.d.cts CHANGED
@@ -50,7 +50,7 @@ interface ColumnDef<T extends ColumnType = ColumnType, TRuntime = unknown> {
50
50
  /** Column comment/description */
51
51
  comment?: string;
52
52
  /** Additional arguments for the column type (e.g., VARCHAR length) */
53
- args?: any[];
53
+ args?: unknown[];
54
54
  /** Table name this column belongs to (filled at runtime by defineTable) */
55
55
  table?: string;
56
56
  }
@@ -312,12 +312,12 @@ interface TableOptions {
312
312
  collation?: string;
313
313
  }
314
314
  interface TableHooks {
315
- beforeInsert?(ctx: unknown, entity: any): Promise<void> | void;
316
- afterInsert?(ctx: unknown, entity: any): Promise<void> | void;
317
- beforeUpdate?(ctx: unknown, entity: any): Promise<void> | void;
318
- afterUpdate?(ctx: unknown, entity: any): Promise<void> | void;
319
- beforeDelete?(ctx: unknown, entity: any): Promise<void> | void;
320
- afterDelete?(ctx: unknown, entity: any): Promise<void> | void;
315
+ beforeInsert?(ctx: unknown, entity: unknown): Promise<void> | void;
316
+ afterInsert?(ctx: unknown, entity: unknown): Promise<void> | void;
317
+ beforeUpdate?(ctx: unknown, entity: unknown): Promise<void> | void;
318
+ afterUpdate?(ctx: unknown, entity: unknown): Promise<void> | void;
319
+ beforeDelete?(ctx: unknown, entity: unknown): Promise<void> | void;
320
+ afterDelete?(ctx: unknown, entity: unknown): Promise<void> | void;
321
321
  }
322
322
  /**
323
323
  * Definition of a database table with its columns and relationships
@@ -386,6 +386,22 @@ type TableRef$1<T extends TableDef> = T & {
386
386
  * t.$.name is the "name" column (escape hatch)
387
387
  */
388
388
  declare const tableRef: <T extends TableDef>(table: T) => TableRef$1<T>;
389
+ /**
390
+ * Public API: dynamic column lookup by string key.
391
+ *
392
+ * Useful when the column name is only known at runtime, or when a column name
393
+ * collides with a real table field (e.g. "name").
394
+ *
395
+ * @example
396
+ * ```ts
397
+ * const t = tableRef(todos);
398
+ * const key = runtimeKey();
399
+ * where(eq(getColumn(t, key), 123));
400
+ * // or: t.$.name (escape hatch)
401
+ * ```
402
+ */
403
+ declare function getColumn<T extends TableDef, K extends keyof T['columns'] & string>(table: T, key: K): T['columns'][K];
404
+ declare function getColumn<T extends TableDef>(table: T, key: string): ColumnDef;
389
405
 
390
406
  /**
391
407
  * Resolves a relation definition to its target table type.
@@ -404,7 +420,7 @@ type InferRow<TTable extends TableDef> = {
404
420
  [K in keyof TTable['columns']]: ColumnToTs<TTable['columns'][K]>;
405
421
  };
406
422
  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> ? (InferRow<TTarget> & {
407
- _pivot?: any;
423
+ _pivot?: unknown;
408
424
  })[] : never;
409
425
  /**
410
426
  * Maps relation names to the expected row results
@@ -673,10 +689,10 @@ interface ArithmeticExpressionNode {
673
689
  * Union type representing any operand that can be used in expressions
674
690
  */
675
691
  type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | WindowFunctionNode;
676
- declare const isOperandNode: (node: any) => node is OperandNode;
677
- declare const isFunctionNode: (node: any) => node is FunctionNode;
678
- declare const isCaseExpressionNode: (node: any) => node is CaseExpressionNode;
679
- declare const isWindowFunctionNode: (node: any) => node is WindowFunctionNode;
692
+ declare const isOperandNode: (node: unknown) => node is OperandNode;
693
+ declare const isFunctionNode: (node: unknown) => node is FunctionNode;
694
+ declare const isCaseExpressionNode: (node: unknown) => node is CaseExpressionNode;
695
+ declare const isWindowFunctionNode: (node: unknown) => node is WindowFunctionNode;
680
696
  declare const isExpressionSelectionNode: (node: ColumnRef | FunctionNode | CaseExpressionNode | WindowFunctionNode) => node is FunctionNode | CaseExpressionNode | WindowFunctionNode;
681
697
  /**
682
698
  * AST node representing a binary expression (e.g., column = value)
@@ -946,7 +962,7 @@ declare const ntile: (n: number) => WindowFunctionNode;
946
962
  * @param defaultValue - Default value if no row exists
947
963
  * @returns Window function node for LAG
948
964
  */
949
- declare const lag: (col: ColumnRef | ColumnNode, offset?: number, defaultValue?: any) => WindowFunctionNode;
965
+ declare const lag: (col: ColumnRef | ColumnNode, offset?: number, defaultValue?: LiteralNode["value"]) => WindowFunctionNode;
950
966
  /**
951
967
  * Creates a LEAD window function
952
968
  * @param col - Column to lead
@@ -954,7 +970,7 @@ declare const lag: (col: ColumnRef | ColumnNode, offset?: number, defaultValue?:
954
970
  * @param defaultValue - Default value if no row exists
955
971
  * @returns Window function node for LEAD
956
972
  */
957
- declare const lead: (col: ColumnRef | ColumnNode, offset?: number, defaultValue?: any) => WindowFunctionNode;
973
+ declare const lead: (col: ColumnRef | ColumnNode, offset?: number, defaultValue?: LiteralNode["value"]) => WindowFunctionNode;
958
974
  /**
959
975
  * Creates a FIRST_VALUE window function
960
976
  * @param col - Column to get first value from
@@ -1050,8 +1066,8 @@ interface OperandVisitor<R> {
1050
1066
  visitAliasRef?(node: AliasRefNode): R;
1051
1067
  otherwise?(node: OperandNode): R;
1052
1068
  }
1053
- type ExpressionDispatch = <R>(node: any, visitor: ExpressionVisitor<R>) => R;
1054
- type OperandDispatch = <R>(node: any, visitor: OperandVisitor<R>) => R;
1069
+ type ExpressionDispatch = <R>(node: ExpressionNode, visitor: ExpressionVisitor<R>) => R;
1070
+ type OperandDispatch = <R>(node: OperandNode, visitor: OperandVisitor<R>) => R;
1055
1071
  /**
1056
1072
  * Registers a dispatcher for a custom expression node type.
1057
1073
  * Allows new node kinds without modifying the core switch.
@@ -1126,7 +1142,7 @@ interface FunctionTableNode {
1126
1142
  /** Optional schema for the function (some dialects) */
1127
1143
  schema?: string;
1128
1144
  /** Function arguments as operand nodes */
1129
- args?: any[];
1145
+ args?: OperandNode[];
1130
1146
  /** Optional alias for the function table */
1131
1147
  alias?: string;
1132
1148
  /** LATERAL flag */
@@ -1421,7 +1437,7 @@ declare abstract class Dialect implements SelectCompiler, InsertCompiler, Update
1421
1437
  * @returns SQL WHERE clause or empty string
1422
1438
  */
1423
1439
  protected compileWhere(where: ExpressionNode | undefined, ctx: CompilerContext): string;
1424
- protected compileReturning(returning: ColumnNode[] | undefined, ctx: CompilerContext): string;
1440
+ protected compileReturning(returning: ColumnNode[] | undefined, _ctx: CompilerContext): string;
1425
1441
  /**
1426
1442
  * Generates subquery for EXISTS expressions
1427
1443
  * Rule: Always forces SELECT 1, ignoring column list
@@ -1442,12 +1458,12 @@ declare abstract class Dialect implements SelectCompiler, InsertCompiler, Update
1442
1458
  * @param index - Parameter index
1443
1459
  * @returns Formatted placeholder string
1444
1460
  */
1445
- protected formatPlaceholder(index: number): string;
1461
+ protected formatPlaceholder(_index: number): string;
1446
1462
  /**
1447
1463
  * Whether the current dialect supports a given set operation.
1448
1464
  * Override in concrete dialects to restrict support.
1449
1465
  */
1450
- protected supportsSetOperation(kind: SetOperationKind): boolean;
1466
+ protected supportsSetOperation(_kind: SetOperationKind): boolean;
1451
1467
  /**
1452
1468
  * Validates set-operation semantics:
1453
1469
  * - Ensures the dialect supports requested operators.
@@ -1510,7 +1526,7 @@ declare abstract class Dialect implements SelectCompiler, InsertCompiler, Update
1510
1526
  protected compileOrderingTerm(term: OrderingTerm, ctx: CompilerContext): string;
1511
1527
  private registerDefaultExpressionCompilers;
1512
1528
  private registerDefaultOperandCompilers;
1513
- protected compileJsonPath(node: JsonPathNode): string;
1529
+ protected compileJsonPath(_node: JsonPathNode): string;
1514
1530
  /**
1515
1531
  * Compiles a function operand, using the dialect's function strategy.
1516
1532
  */
@@ -2062,7 +2078,7 @@ interface SimpleQueryRunner {
2062
2078
  declare function createExecutorFromQueryRunner(runner: SimpleQueryRunner): DbExecutor;
2063
2079
 
2064
2080
  type EntityConstructor<T = object> = new (...args: any[]) => T;
2065
- type EntityOrTableTarget = EntityConstructor<any> | TableDef;
2081
+ type EntityOrTableTarget = EntityConstructor | TableDef;
2066
2082
  type EntityOrTableTargetResolver = EntityOrTableTarget | (() => EntityOrTableTarget);
2067
2083
 
2068
2084
  /**
@@ -2087,13 +2103,13 @@ interface TrackedEntity {
2087
2103
  /** The table definition this entity belongs to */
2088
2104
  table: TableDef;
2089
2105
  /** The actual entity instance */
2090
- entity: any;
2106
+ entity: unknown;
2091
2107
  /** Primary key value of the entity */
2092
2108
  pk: string | number | null;
2093
2109
  /** Current status of the entity */
2094
2110
  status: EntityStatus;
2095
2111
  /** Original values of the entity when it was loaded */
2096
- original: Record<string, any> | null;
2112
+ original: Record<string, unknown> | null;
2097
2113
  }
2098
2114
  /**
2099
2115
  * Type representing a key for relation navigation
@@ -2121,7 +2137,7 @@ type RelationChange<T> = {
2121
2137
  */
2122
2138
  interface RelationChangeEntry {
2123
2139
  /** Root entity that owns the relation */
2124
- root: any;
2140
+ root: unknown;
2125
2141
  /** Key of the relation being changed */
2126
2142
  relationKey: RelationKey;
2127
2143
  /** Table definition of the root entity */
@@ -2131,7 +2147,7 @@ interface RelationChangeEntry {
2131
2147
  /** Relation definition */
2132
2148
  relation: RelationDef;
2133
2149
  /** The change being applied */
2134
- change: RelationChange<any>;
2150
+ change: RelationChange<unknown>;
2135
2151
  }
2136
2152
  /**
2137
2153
  * Represents a domain event that can be emitted by entities
@@ -2191,9 +2207,8 @@ declare class InterceptorPipeline {
2191
2207
 
2192
2208
  /**
2193
2209
  * Options for creating an ORM instance.
2194
- * @template E - The domain event type
2195
2210
  */
2196
- interface OrmOptions<E extends DomainEvent = OrmDomainEvent> {
2211
+ interface OrmOptions {
2197
2212
  /** The database dialect */
2198
2213
  dialect: Dialect;
2199
2214
  /** The database executor factory */
@@ -2238,7 +2253,7 @@ declare class Orm<E extends DomainEvent = OrmDomainEvent> {
2238
2253
  * Creates a new ORM instance.
2239
2254
  * @param opts - ORM options
2240
2255
  */
2241
- constructor(opts: OrmOptions<E>);
2256
+ constructor(opts: OrmOptions);
2242
2257
  /**
2243
2258
  * Creates a new ORM session.
2244
2259
  * @param options - Optional session options
@@ -2262,7 +2277,7 @@ declare class Orm<E extends DomainEvent = OrmDomainEvent> {
2262
2277
  declare class IdentityMap {
2263
2278
  private readonly buckets;
2264
2279
  get bucketsMap(): Map<string, Map<string, TrackedEntity>>;
2265
- getEntity(table: TableDef, pk: string | number): any | undefined;
2280
+ getEntity(table: TableDef, pk: string | number): unknown | undefined;
2266
2281
  register(tracked: TrackedEntity): void;
2267
2282
  remove(tracked: TrackedEntity): void;
2268
2283
  getEntitiesForTable(table: TableDef): TrackedEntity[];
@@ -2302,7 +2317,7 @@ declare class UnitOfWork {
2302
2317
  * @param pk - The primary key value
2303
2318
  * @returns The entity or undefined if not found
2304
2319
  */
2305
- getEntity(table: TableDef, pk: string | number): any | undefined;
2320
+ getEntity(table: TableDef, pk: string | number): unknown | undefined;
2306
2321
  /**
2307
2322
  * Gets all tracked entities for a specific table.
2308
2323
  * @param table - The table definition
@@ -2314,38 +2329,38 @@ declare class UnitOfWork {
2314
2329
  * @param entity - The entity to find
2315
2330
  * @returns The tracked entity or undefined if not found
2316
2331
  */
2317
- findTracked(entity: any): TrackedEntity | undefined;
2332
+ findTracked(entity: unknown): TrackedEntity | undefined;
2318
2333
  /**
2319
2334
  * Sets an entity in the identity map.
2320
2335
  * @param table - The table definition
2321
2336
  * @param pk - The primary key value
2322
2337
  * @param entity - The entity instance
2323
2338
  */
2324
- setEntity(table: TableDef, pk: string | number, entity: any): void;
2339
+ setEntity(table: TableDef, pk: string | number, entity: unknown): void;
2325
2340
  /**
2326
2341
  * Tracks a new entity.
2327
2342
  * @param table - The table definition
2328
2343
  * @param entity - The entity instance
2329
2344
  * @param pk - Optional primary key value
2330
2345
  */
2331
- trackNew(table: TableDef, entity: any, pk?: string | number): void;
2346
+ trackNew(table: TableDef, entity: unknown, pk?: string | number): void;
2332
2347
  /**
2333
2348
  * Tracks a managed entity.
2334
2349
  * @param table - The table definition
2335
2350
  * @param pk - The primary key value
2336
2351
  * @param entity - The entity instance
2337
2352
  */
2338
- trackManaged(table: TableDef, pk: string | number, entity: any): void;
2353
+ trackManaged(table: TableDef, pk: string | number, entity: unknown): void;
2339
2354
  /**
2340
2355
  * Marks an entity as dirty (modified).
2341
2356
  * @param entity - The entity to mark as dirty
2342
2357
  */
2343
- markDirty(entity: any): void;
2358
+ markDirty(entity: unknown): void;
2344
2359
  /**
2345
2360
  * Marks an entity as removed.
2346
2361
  * @param entity - The entity to mark as removed
2347
2362
  */
2348
- markRemoved(entity: any): void;
2363
+ markRemoved(entity: unknown): void;
2349
2364
  /**
2350
2365
  * Flushes pending changes to the database.
2351
2366
  */
@@ -2631,14 +2646,14 @@ interface ExecutionContext {
2631
2646
  interface EntityContext {
2632
2647
  dialect: Dialect;
2633
2648
  executor: DbExecutor;
2634
- getEntity(table: TableDef, pk: any): any;
2635
- setEntity(table: TableDef, pk: any, entity: any): void;
2636
- trackNew(table: TableDef, entity: any, pk?: any): void;
2637
- trackManaged(table: TableDef, pk: any, entity: any): void;
2638
- markDirty(entity: any): void;
2639
- markRemoved(entity: any): void;
2649
+ getEntity(table: TableDef, pk: unknown): unknown;
2650
+ setEntity(table: TableDef, pk: unknown, entity: unknown): void;
2651
+ trackNew(table: TableDef, entity: unknown, pk?: unknown): void;
2652
+ trackManaged(table: TableDef, pk: unknown, entity: unknown): void;
2653
+ markDirty(entity: unknown): void;
2654
+ markRemoved(entity: unknown): void;
2640
2655
  getEntitiesForTable(table: TableDef): TrackedEntity[];
2641
- registerRelationChange(root: any, relationKey: RelationKey, rootTable: TableDef, relationName: string, relation: RelationDef, change: RelationChange<any>): void;
2656
+ registerRelationChange(root: unknown, relationKey: RelationKey, rootTable: TableDef, relationName: string, relation: RelationDef, change: RelationChange<unknown>): void;
2642
2657
  }
2643
2658
 
2644
2659
  interface HydrationContext<E extends DomainEvent = AnyDomainEvent> {
@@ -2731,38 +2746,38 @@ declare class OrmSession<E extends DomainEvent = OrmDomainEvent> implements Enti
2731
2746
  * @param pk - The primary key value
2732
2747
  * @returns The entity or undefined if not found
2733
2748
  */
2734
- getEntity(table: TableDef, pk: any): any | undefined;
2749
+ getEntity(table: TableDef, pk: unknown): unknown | undefined;
2735
2750
  /**
2736
2751
  * Sets an entity in the identity map.
2737
2752
  * @param table - The table definition
2738
2753
  * @param pk - The primary key value
2739
2754
  * @param entity - The entity instance
2740
2755
  */
2741
- setEntity(table: TableDef, pk: any, entity: any): void;
2756
+ setEntity(table: TableDef, pk: unknown, entity: unknown): void;
2742
2757
  /**
2743
2758
  * Tracks a new entity.
2744
2759
  * @param table - The table definition
2745
2760
  * @param entity - The entity instance
2746
2761
  * @param pk - Optional primary key value
2747
2762
  */
2748
- trackNew(table: TableDef, entity: any, pk?: any): void;
2763
+ trackNew(table: TableDef, entity: unknown, pk?: unknown): void;
2749
2764
  /**
2750
2765
  * Tracks a managed entity.
2751
2766
  * @param table - The table definition
2752
2767
  * @param pk - The primary key value
2753
2768
  * @param entity - The entity instance
2754
2769
  */
2755
- trackManaged(table: TableDef, pk: any, entity: any): void;
2770
+ trackManaged(table: TableDef, pk: unknown, entity: unknown): void;
2756
2771
  /**
2757
2772
  * Marks an entity as dirty (modified).
2758
2773
  * @param entity - The entity to mark as dirty
2759
2774
  */
2760
- markDirty(entity: any): void;
2775
+ markDirty(entity: unknown): void;
2761
2776
  /**
2762
2777
  * Marks an entity as removed.
2763
2778
  * @param entity - The entity to mark as removed
2764
2779
  */
2765
- markRemoved(entity: any): void;
2780
+ markRemoved(entity: unknown): void;
2766
2781
  /**
2767
2782
  * Registers a relation change.
2768
2783
  * @param root - The root entity
@@ -2772,7 +2787,7 @@ declare class OrmSession<E extends DomainEvent = OrmDomainEvent> implements Enti
2772
2787
  * @param relation - The relation definition
2773
2788
  * @param change - The relation change
2774
2789
  */
2775
- registerRelationChange: (root: any, relationKey: RelationKey, rootTable: TableDef, relationName: string, relation: RelationDef, change: RelationChange<any>) => void;
2790
+ registerRelationChange: (root: unknown, relationKey: RelationKey, rootTable: TableDef, relationName: string, relation: RelationDef, change: RelationChange<unknown>) => void;
2776
2791
  /**
2777
2792
  * Gets all tracked entities for a specific table.
2778
2793
  * @param table - The table definition
@@ -2800,21 +2815,21 @@ declare class OrmSession<E extends DomainEvent = OrmDomainEvent> implements Enti
2800
2815
  * @returns The entity instance or null if not found
2801
2816
  * @throws If entity metadata is not bootstrapped or table has no primary key
2802
2817
  */
2803
- find<TCtor extends EntityConstructor<any>>(entityClass: TCtor, id: any): Promise<InstanceType<TCtor> | null>;
2818
+ find<TCtor extends EntityConstructor<object>>(entityClass: TCtor, id: unknown): Promise<InstanceType<TCtor> | null>;
2804
2819
  /**
2805
2820
  * Finds a single entity using a query builder.
2806
2821
  * @template TTable - The table type
2807
2822
  * @param qb - The query builder
2808
2823
  * @returns The first entity instance or null if not found
2809
2824
  */
2810
- findOne<TTable extends TableDef>(qb: SelectQueryBuilder<any, TTable>): Promise<EntityInstance<TTable> | null>;
2825
+ findOne<TTable extends TableDef>(qb: SelectQueryBuilder<unknown, TTable>): Promise<EntityInstance<TTable> | null>;
2811
2826
  /**
2812
2827
  * Finds multiple entities using a query builder.
2813
2828
  * @template TTable - The table type
2814
2829
  * @param qb - The query builder
2815
2830
  * @returns Array of entity instances
2816
2831
  */
2817
- findMany<TTable extends TableDef>(qb: SelectQueryBuilder<any, TTable>): Promise<EntityInstance<TTable>[]>;
2832
+ findMany<TTable extends TableDef>(qb: SelectQueryBuilder<unknown, TTable>): Promise<EntityInstance<TTable>[]>;
2818
2833
  /**
2819
2834
  * Saves an entity graph (root + nested relations) based on a DTO-like payload.
2820
2835
  * @param entityClass - Root entity constructor
@@ -2822,7 +2837,7 @@ declare class OrmSession<E extends DomainEvent = OrmDomainEvent> implements Enti
2822
2837
  * @param options - Graph save options
2823
2838
  * @returns The root entity instance
2824
2839
  */
2825
- saveGraph<TCtor extends EntityConstructor<any>>(entityClass: TCtor, payload: Record<string, any>, options?: SaveGraphOptions & {
2840
+ saveGraph<TCtor extends EntityConstructor<object>>(entityClass: TCtor, payload: Record<string, unknown>, options?: SaveGraphOptions & {
2826
2841
  transactional?: boolean;
2827
2842
  }): Promise<InstanceType<TCtor>>;
2828
2843
  /**
@@ -2883,7 +2898,7 @@ type DeepSelectConfig<TTable extends TableDef> = {
2883
2898
  type WhereHasOptions = {
2884
2899
  correlate?: ExpressionNode;
2885
2900
  };
2886
- type RelationCallback = <TChildTable extends TableDef>(qb: SelectQueryBuilder<any, TChildTable>) => SelectQueryBuilder<any, TChildTable>;
2901
+ type RelationCallback = <TChildTable extends TableDef>(qb: SelectQueryBuilder<unknown, TChildTable>) => SelectQueryBuilder<unknown, TChildTable>;
2887
2902
  /**
2888
2903
 
2889
2904
  * Main query builder class for constructing SQL SELECT queries
@@ -2893,7 +2908,7 @@ type RelationCallback = <TChildTable extends TableDef>(qb: SelectQueryBuilder<an
2893
2908
  * @typeParam TTable - Table definition being queried
2894
2909
 
2895
2910
  */
2896
- declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
2911
+ declare class SelectQueryBuilder<T = unknown, TTable extends TableDef = TableDef> {
2897
2912
  private readonly env;
2898
2913
  private readonly context;
2899
2914
  private readonly columnSelector;
@@ -2963,7 +2978,7 @@ declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
2963
2978
  * @returns New query builder instance with the CTE
2964
2979
 
2965
2980
  */
2966
- with(name: string, query: SelectQueryBuilder<any, TableDef<any>> | SelectQueryNode, columns?: string[]): SelectQueryBuilder<T, TTable>;
2981
+ with<TSub extends TableDef>(name: string, query: SelectQueryBuilder<unknown, TSub> | SelectQueryNode, columns?: string[]): SelectQueryBuilder<T, TTable>;
2967
2982
  /**
2968
2983
 
2969
2984
  * Adds a recursive Common Table Expression (CTE) to the query
@@ -2977,7 +2992,7 @@ declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
2977
2992
  * @returns New query builder instance with the recursive CTE
2978
2993
 
2979
2994
  */
2980
- withRecursive(name: string, query: SelectQueryBuilder<any, TableDef<any>> | SelectQueryNode, columns?: string[]): SelectQueryBuilder<T, TTable>;
2995
+ withRecursive<TSub extends TableDef>(name: string, query: SelectQueryBuilder<unknown, TSub> | SelectQueryNode, columns?: string[]): SelectQueryBuilder<T, TTable>;
2981
2996
  /**
2982
2997
  * Replaces the FROM clause with a derived table (subquery with alias)
2983
2998
  * @param subquery - Subquery to use as the FROM source
@@ -2985,7 +3000,7 @@ declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
2985
3000
  * @param columnAliases - Optional column alias list
2986
3001
  * @returns New query builder instance with updated FROM
2987
3002
  */
2988
- fromSubquery(subquery: SelectQueryBuilder<any, TableDef<any>> | SelectQueryNode, alias: string, columnAliases?: string[]): SelectQueryBuilder<T, TTable>;
3003
+ fromSubquery<TSub extends TableDef>(subquery: SelectQueryBuilder<unknown, TSub> | SelectQueryNode, alias: string, columnAliases?: string[]): SelectQueryBuilder<T, TTable>;
2989
3004
  /**
2990
3005
 
2991
3006
  * Selects a subquery as a column
@@ -2997,7 +3012,7 @@ declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
2997
3012
  * @returns New query builder instance with the subquery selection
2998
3013
 
2999
3014
  */
3000
- selectSubquery(alias: string, sub: SelectQueryBuilder<any, TableDef<any>> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
3015
+ selectSubquery<TSub extends TableDef>(alias: string, sub: SelectQueryBuilder<unknown, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
3001
3016
  /**
3002
3017
  * Adds a JOIN against a derived table (subquery with alias)
3003
3018
  * @param subquery - Subquery to join
@@ -3007,7 +3022,7 @@ declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
3007
3022
  * @param columnAliases - Optional column alias list for the derived table
3008
3023
  * @returns New query builder instance with the derived-table join
3009
3024
  */
3010
- joinSubquery(subquery: SelectQueryBuilder<any, TableDef<any>> | SelectQueryNode, alias: string, condition: BinaryExpressionNode, joinKind?: JoinKind, columnAliases?: string[]): SelectQueryBuilder<T, TTable>;
3025
+ joinSubquery<TSub extends TableDef>(subquery: SelectQueryBuilder<unknown, TSub> | SelectQueryNode, alias: string, condition: BinaryExpressionNode, joinKind?: JoinKind, columnAliases?: string[]): SelectQueryBuilder<T, TTable>;
3011
3026
  /**
3012
3027
 
3013
3028
  * Adds an INNER JOIN to the query
@@ -3175,7 +3190,7 @@ declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
3175
3190
  * @returns New query builder instance with the set operation
3176
3191
 
3177
3192
  */
3178
- union(query: SelectQueryBuilder<any, TableDef<any>> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
3193
+ union<TSub extends TableDef>(query: SelectQueryBuilder<unknown, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
3179
3194
  /**
3180
3195
 
3181
3196
  * Combines this query with another using UNION ALL
@@ -3185,7 +3200,7 @@ declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
3185
3200
  * @returns New query builder instance with the set operation
3186
3201
 
3187
3202
  */
3188
- unionAll(query: SelectQueryBuilder<any, TableDef<any>> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
3203
+ unionAll<TSub extends TableDef>(query: SelectQueryBuilder<unknown, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
3189
3204
  /**
3190
3205
 
3191
3206
  * Combines this query with another using INTERSECT
@@ -3195,7 +3210,7 @@ declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
3195
3210
  * @returns New query builder instance with the set operation
3196
3211
 
3197
3212
  */
3198
- intersect(query: SelectQueryBuilder<any, TableDef<any>> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
3213
+ intersect<TSub extends TableDef>(query: SelectQueryBuilder<unknown, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
3199
3214
  /**
3200
3215
 
3201
3216
  * Combines this query with another using EXCEPT
@@ -3205,7 +3220,7 @@ declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
3205
3220
  * @returns New query builder instance with the set operation
3206
3221
 
3207
3222
  */
3208
- except(query: SelectQueryBuilder<any, TableDef<any>> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
3223
+ except<TSub extends TableDef>(query: SelectQueryBuilder<unknown, TSub> | SelectQueryNode): SelectQueryBuilder<T, TTable>;
3209
3224
  /**
3210
3225
 
3211
3226
  * Adds a WHERE EXISTS condition to the query
@@ -3215,7 +3230,7 @@ declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
3215
3230
  * @returns New query builder instance with the WHERE EXISTS condition
3216
3231
 
3217
3232
  */
3218
- whereExists(subquery: SelectQueryBuilder<any, TableDef<any>> | SelectQueryNode, correlate?: ExpressionNode): SelectQueryBuilder<T, TTable>;
3233
+ whereExists<TSub extends TableDef>(subquery: SelectQueryBuilder<unknown, TSub> | SelectQueryNode, correlate?: ExpressionNode): SelectQueryBuilder<T, TTable>;
3219
3234
  /**
3220
3235
 
3221
3236
  * Adds a WHERE NOT EXISTS condition to the query
@@ -3225,7 +3240,7 @@ declare class SelectQueryBuilder<T = any, TTable extends TableDef = TableDef> {
3225
3240
  * @returns New query builder instance with the WHERE NOT EXISTS condition
3226
3241
 
3227
3242
  */
3228
- whereNotExists(subquery: SelectQueryBuilder<any, TableDef<any>> | SelectQueryNode, correlate?: ExpressionNode): SelectQueryBuilder<T, TTable>;
3243
+ whereNotExists<TSub extends TableDef>(subquery: SelectQueryBuilder<unknown, TSub> | SelectQueryNode, correlate?: ExpressionNode): SelectQueryBuilder<T, TTable>;
3229
3244
  /**
3230
3245
 
3231
3246
  * Adds a WHERE EXISTS condition based on a relationship
@@ -3315,12 +3330,12 @@ declare const createLiteral: (val: string | number) => LiteralNode;
3315
3330
  */
3316
3331
  declare function sel<TTable extends TableDef, K extends keyof TTable['columns'] & string>(table: TTable, ...cols: K[]): Record<K, TTable['columns'][K]>;
3317
3332
  type Ctor<T> = {
3318
- new (...args: any[]): T;
3333
+ new (...args: unknown[]): T;
3319
3334
  };
3320
3335
  /**
3321
3336
  * Build a typed selection map from an entity constructor.
3322
3337
  */
3323
- declare function esel<TEntity, K extends keyof TEntity & string>(entity: Ctor<TEntity>, ...props: K[]): Record<K, ColumnDef>;
3338
+ declare function esel<TEntity extends object, K extends keyof TEntity & string>(entity: Ctor<TEntity>, ...props: K[]): Record<K, ColumnDef>;
3324
3339
 
3325
3340
  /**
3326
3341
  * Maintains immutable state for building INSERT queries
@@ -3350,7 +3365,7 @@ declare class InsertQueryBuilder<T> {
3350
3365
  private clone;
3351
3366
  values(rowOrRows: Record<string, unknown> | Record<string, unknown>[]): InsertQueryBuilder<T>;
3352
3367
  columns(...columns: (ColumnDef | ColumnNode)[]): InsertQueryBuilder<T>;
3353
- fromSelect(query: SelectQueryNode | SelectQueryBuilder<any, TableDef<any>>, columns?: (ColumnDef | ColumnNode)[]): InsertQueryBuilder<T>;
3368
+ fromSelect<TSource extends TableDef>(query: SelectQueryNode | SelectQueryBuilder<unknown, TSource>, columns?: (ColumnDef | ColumnNode)[]): InsertQueryBuilder<T>;
3354
3369
  returning(...columns: (ColumnDef | ColumnNode)[]): InsertQueryBuilder<T>;
3355
3370
  private resolveColumnNodes;
3356
3371
  private resolveSelectQuery;
@@ -3680,6 +3695,7 @@ interface SchemaDialect {
3680
3695
  renderIndex(table: TableDef, index: IndexDef): string;
3681
3696
  renderTableOptions(table: TableDef): string | undefined;
3682
3697
  supportsPartialIndexes(): boolean;
3698
+ preferInlinePkAutoincrement(column: ColumnDef, table: TableDef, pk: string[]): boolean;
3683
3699
  dropColumnSql?(table: DatabaseTable, column: string): string[];
3684
3700
  dropIndexSql?(table: DatabaseTable, index: string): string[];
3685
3701
  dropTableSql?(table: DatabaseTable): string[];
@@ -4075,17 +4091,18 @@ declare class AsyncLocalStorage<T> {
4075
4091
  getStore(): T | undefined;
4076
4092
  }
4077
4093
 
4094
+ /**
4095
+ * Hydrates query results according to a hydration plan
4096
+ * @param rows - Raw database rows
4097
+
4078
4098
  /**
4079
4099
  * Hydrates query results according to a hydration plan
4080
4100
  * @param rows - Raw database rows
4081
4101
  * @param plan - Hydration plan
4082
4102
  * @returns Hydrated result objects with nested relations
4083
4103
  */
4084
- declare const hydrateRows: (rows: Record<string, any>[], plan?: HydrationPlan) => Record<string, any>[];
4104
+ declare const hydrateRows: (rows: Record<string, unknown>[], plan?: HydrationPlan) => Record<string, unknown>[];
4085
4105
 
4086
- /**
4087
- * Generates TypeScript code from query AST nodes
4088
- */
4089
4106
  declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandVisitor<string> {
4090
4107
  private namingStrategy;
4091
4108
  constructor(namingStrategy?: NamingStrategy);
@@ -4117,6 +4134,8 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
4117
4134
  * Prints an ordering term (operand/expression/alias) to TypeScript code.
4118
4135
  */
4119
4136
  private printOrderingTerm;
4137
+ private getSelectionKey;
4138
+ private isNamedSelection;
4120
4139
  visitBinaryExpression(binary: BinaryExpressionNode): string;
4121
4140
  visitLogicalExpression(logical: LogicalExpressionNode): string;
4122
4141
  visitNullExpression(nullExpr: NullExpressionNode): string;
@@ -4235,7 +4254,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
4235
4254
  * @param lazyRelations - Optional lazy relations
4236
4255
  * @returns The entity instance
4237
4256
  */
4238
- declare const createEntityProxy: <TTable extends TableDef, TLazy extends keyof RelationMap<TTable> = keyof RelationMap<TTable>>(ctx: EntityContext, table: TTable, row: Record<string, any>, lazyRelations?: TLazy[]) => EntityInstance<TTable>;
4257
+ declare const createEntityProxy: <TTable extends TableDef, TLazy extends keyof RelationMap<TTable> = keyof RelationMap<TTable>>(ctx: EntityContext, table: TTable, row: Record<string, unknown>, lazyRelations?: TLazy[]) => EntityInstance<TTable>;
4239
4258
  /**
4240
4259
  * Creates an entity instance from a database row.
4241
4260
  * @template TTable - The table type
@@ -4246,12 +4265,12 @@ declare const createEntityProxy: <TTable extends TableDef, TLazy extends keyof R
4246
4265
  * @param lazyRelations - Optional lazy relations
4247
4266
  * @returns The entity instance
4248
4267
  */
4249
- declare const createEntityFromRow: <TTable extends TableDef, TResult extends EntityInstance<TTable> = EntityInstance<TTable>>(ctx: EntityContext, table: TTable, row: Record<string, any>, lazyRelations?: (keyof RelationMap<TTable>)[]) => TResult;
4268
+ 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;
4250
4269
 
4251
- type Rows$3 = Record<string, any>[];
4270
+ type Rows$3 = Record<string, unknown>[];
4252
4271
  declare const loadHasManyRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: HasManyRelation) => Promise<Map<string, Rows$3>>;
4253
- declare const loadHasOneRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: HasOneRelation) => Promise<Map<string, Record<string, any>>>;
4254
- declare const loadBelongsToRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: BelongsToRelation) => Promise<Map<string, Record<string, any>>>;
4272
+ declare const loadHasOneRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: HasOneRelation) => Promise<Map<string, Record<string, unknown>>>;
4273
+ declare const loadBelongsToRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: BelongsToRelation) => Promise<Map<string, Record<string, unknown>>>;
4255
4274
  declare const loadBelongsToManyRelation: (ctx: EntityContext, rootTable: TableDef, _relationName: string, relation: BelongsToManyRelation) => Promise<Map<string, Rows$3>>;
4256
4275
 
4257
4276
  /**
@@ -4266,14 +4285,14 @@ interface EntityMeta<TTable extends TableDef> {
4266
4285
  /** Relations that should be loaded lazily */
4267
4286
  lazyRelations: (keyof RelationMap<TTable>)[];
4268
4287
  /** Cache for relation promises */
4269
- relationCache: Map<string, Promise<any>>;
4288
+ relationCache: Map<string, Promise<unknown>>;
4270
4289
  /** Hydration data for relations */
4271
- relationHydration: Map<string, Map<string, any>>;
4290
+ relationHydration: Map<string, Map<string, unknown>>;
4272
4291
  /** Relation wrapper instances */
4273
4292
  relationWrappers: Map<string, unknown>;
4274
4293
  }
4275
4294
 
4276
- type Rows$2 = Record<string, any>[];
4295
+ type Rows$2 = Record<string, unknown>[];
4277
4296
  declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChild> {
4278
4297
  private readonly ctx;
4279
4298
  private readonly meta;
@@ -4288,7 +4307,7 @@ declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChi
4288
4307
  private items;
4289
4308
  private readonly added;
4290
4309
  private readonly removed;
4291
- constructor(ctx: EntityContext, meta: EntityMeta<any>, root: any, relationName: string, relation: HasManyRelation, rootTable: TableDef, loader: () => Promise<Map<string, Rows$2>>, createEntity: (row: Record<string, any>) => TChild, localKey: string);
4310
+ constructor(ctx: EntityContext, meta: EntityMeta<TableDef>, root: unknown, relationName: string, relation: HasManyRelation, rootTable: TableDef, loader: () => Promise<Map<string, Rows$2>>, createEntity: (row: Record<string, unknown>) => TChild, localKey: string);
4292
4311
  load(): Promise<TChild[]>;
4293
4312
  getItems(): TChild[];
4294
4313
  add(data: Partial<TChild>): TChild;
@@ -4300,7 +4319,7 @@ declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChi
4300
4319
  toJSON(): TChild[];
4301
4320
  }
4302
4321
 
4303
- type Rows$1 = Record<string, any>;
4322
+ type Rows$1 = Record<string, unknown>;
4304
4323
  declare class DefaultBelongsToReference<TParent> implements BelongsToReference<TParent> {
4305
4324
  private readonly ctx;
4306
4325
  private readonly meta;
@@ -4313,7 +4332,7 @@ declare class DefaultBelongsToReference<TParent> implements BelongsToReference<T
4313
4332
  private readonly targetKey;
4314
4333
  private loaded;
4315
4334
  private current;
4316
- constructor(ctx: EntityContext, meta: EntityMeta<any>, root: any, relationName: string, relation: BelongsToRelation, rootTable: TableDef, loader: () => Promise<Map<string, Rows$1>>, createEntity: (row: Record<string, any>) => TParent, targetKey: string);
4335
+ constructor(ctx: EntityContext, meta: EntityMeta<TableDef>, root: unknown, relationName: string, relation: BelongsToRelation, rootTable: TableDef, loader: () => Promise<Map<string, Rows$1>>, createEntity: (row: Record<string, unknown>) => TParent, targetKey: string);
4317
4336
  load(): Promise<TParent | null>;
4318
4337
  get(): TParent | null;
4319
4338
  set(data: Partial<TParent> | TParent | null): TParent | null;
@@ -4322,7 +4341,7 @@ declare class DefaultBelongsToReference<TParent> implements BelongsToReference<T
4322
4341
  toJSON(): TParent | null;
4323
4342
  }
4324
4343
 
4325
- type Rows = Record<string, any>[];
4344
+ type Rows = Record<string, unknown>[];
4326
4345
  declare class DefaultManyToManyCollection<TTarget> implements ManyToManyCollection<TTarget> {
4327
4346
  private readonly ctx;
4328
4347
  private readonly meta;
@@ -4335,7 +4354,7 @@ declare class DefaultManyToManyCollection<TTarget> implements ManyToManyCollecti
4335
4354
  private readonly localKey;
4336
4355
  private loaded;
4337
4356
  private items;
4338
- constructor(ctx: EntityContext, meta: EntityMeta<any>, root: any, relationName: string, relation: BelongsToManyRelation, rootTable: TableDef, loader: () => Promise<Map<string, Rows>>, createEntity: (row: Record<string, any>) => TTarget, localKey: string);
4357
+ constructor(ctx: EntityContext, meta: EntityMeta<TableDef>, root: unknown, relationName: string, relation: BelongsToManyRelation, rootTable: TableDef, loader: () => Promise<Map<string, Rows>>, createEntity: (row: Record<string, unknown>) => TTarget, localKey: string);
4339
4358
  load(): Promise<TTarget[]>;
4340
4359
  getItems(): TTarget[];
4341
4360
  attach(target: TTarget | number | string): void;
@@ -4349,14 +4368,13 @@ declare class DefaultManyToManyCollection<TTarget> implements ManyToManyCollecti
4349
4368
  toJSON(): TTarget[];
4350
4369
  }
4351
4370
 
4352
- declare function executeHydrated<TTable extends TableDef>(session: OrmSession, qb: SelectQueryBuilder<any, TTable>): Promise<EntityInstance<TTable>[]>;
4353
- declare function executeHydratedWithContexts<TTable extends TableDef>(_execCtx: ExecutionContext, hydCtx: HydrationContext, qb: SelectQueryBuilder<any, TTable>): Promise<EntityInstance<TTable>[]>;
4371
+ declare function executeHydrated<TTable extends TableDef>(session: OrmSession, qb: SelectQueryBuilder<unknown, TTable>): Promise<EntityInstance<TTable>[]>;
4372
+ declare function executeHydratedWithContexts<TTable extends TableDef>(_execCtx: ExecutionContext, hydCtx: HydrationContext, qb: SelectQueryBuilder<unknown, TTable>): Promise<EntityInstance<TTable>[]>;
4354
4373
 
4355
4374
  interface StandardDecoratorContext {
4356
4375
  kind: string;
4357
4376
  name?: string | symbol;
4358
4377
  metadata?: Record<PropertyKey, unknown>;
4359
- addInitializer?(initializer: (this: unknown) => void): void;
4360
4378
  static?: boolean;
4361
4379
  private?: boolean;
4362
4380
  }
@@ -4382,7 +4400,7 @@ interface ColumnOptions {
4382
4400
  primary?: boolean;
4383
4401
  tsType?: ColumnDef['tsType'];
4384
4402
  }
4385
- type ColumnInput = ColumnOptions | ColumnDef<any, any>;
4403
+ type ColumnInput = ColumnOptions | ColumnDef;
4386
4404
  declare function Column(definition: ColumnInput): DualModePropertyDecorator;
4387
4405
  declare function PrimaryKey(definition: ColumnInput): DualModePropertyDecorator;
4388
4406
 
@@ -4417,8 +4435,15 @@ declare function BelongsTo(options: BelongsToOptions): DualModePropertyDecorator
4417
4435
  declare function BelongsToMany(options: BelongsToManyOptions): DualModePropertyDecorator;
4418
4436
 
4419
4437
  declare const bootstrapEntities: () => TableDef[];
4420
- declare const getTableDefFromEntity: <TTable extends TableDef = TableDef>(ctor: EntityConstructor<any>) => TTable | undefined;
4421
- declare const selectFromEntity: <TTable extends TableDef = TableDef>(ctor: EntityConstructor<any>) => SelectQueryBuilder<any, TTable>;
4438
+ declare const getTableDefFromEntity: <TTable extends TableDef = TableDef>(ctor: EntityConstructor) => TTable | undefined;
4439
+ declare const selectFromEntity: <TTable extends TableDef = TableDef>(ctor: EntityConstructor) => SelectQueryBuilder<unknown, TTable>;
4440
+ /**
4441
+ * Public API: opt-in ergonomic entity reference (decorator-level).
4442
+ *
4443
+ * Lazily bootstraps entity metadata (via getTableDefFromEntity) and returns a
4444
+ * `tableRef(...)`-style proxy so users can write `u.id` instead of `u.columns.id`.
4445
+ */
4446
+ declare const entityRef: <TTable extends TableDef = TableDef>(ctor: EntityConstructor) => TableRef$1<TTable>;
4422
4447
 
4423
4448
  type PoolOptions = {
4424
4449
  /** Maximum number of live resources (idle + leased). */
@@ -4480,7 +4505,7 @@ interface PostgresClientLike {
4480
4505
  declare function createPostgresExecutor(client: PostgresClientLike): DbExecutor;
4481
4506
 
4482
4507
  interface MysqlClientLike {
4483
- query(sql: string, params?: unknown[]): Promise<[any, any?]>;
4508
+ query(sql: string, params?: unknown[]): Promise<[unknown, unknown?]>;
4484
4509
  beginTransaction?(): Promise<void>;
4485
4510
  commit?(): Promise<void>;
4486
4511
  rollback?(): Promise<void>;
@@ -4563,4 +4588,4 @@ type PooledExecutorFactoryOptions<TConn> = {
4563
4588
  */
4564
4589
  declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
4565
4590
 
4566
- 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, createColumn, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createLiteral, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, denseRank, diffSchema, div, endOfMonth, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, 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 };
4591
+ 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, createColumn, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createLiteral, 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 };