metal-orm 1.0.56 → 1.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -33
- package/dist/index.cjs +1461 -195
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +541 -114
- package/dist/index.d.ts +541 -114
- package/dist/index.js +1424 -195
- package/dist/index.js.map +1 -1
- package/package.json +69 -69
- package/src/codegen/naming-strategy.ts +3 -1
- package/src/codegen/typescript.ts +20 -10
- package/src/core/ast/aggregate-functions.ts +14 -0
- package/src/core/ast/builders.ts +38 -20
- package/src/core/ast/expression-builders.ts +70 -2
- package/src/core/ast/expression-nodes.ts +305 -274
- package/src/core/ast/expression-visitor.ts +11 -1
- package/src/core/ast/expression.ts +4 -0
- package/src/core/ast/query.ts +3 -0
- package/src/core/ddl/introspect/catalogs/mysql.ts +5 -0
- package/src/core/ddl/introspect/catalogs/sqlite.ts +3 -0
- package/src/core/ddl/introspect/functions/mssql.ts +13 -0
- package/src/core/ddl/introspect/mssql.ts +4 -0
- package/src/core/ddl/introspect/mysql.ts +4 -0
- package/src/core/ddl/introspect/sqlite.ts +4 -0
- package/src/core/dialect/abstract.ts +552 -531
- package/src/core/dialect/base/function-table-formatter.ts +9 -30
- package/src/core/dialect/base/sql-dialect.ts +24 -0
- package/src/core/dialect/mssql/functions.ts +40 -2
- package/src/core/dialect/mysql/functions.ts +16 -2
- package/src/core/dialect/postgres/functions.ts +66 -2
- package/src/core/dialect/postgres/index.ts +17 -4
- package/src/core/dialect/postgres/table-functions.ts +27 -0
- package/src/core/dialect/sqlite/functions.ts +34 -0
- package/src/core/dialect/sqlite/index.ts +17 -1
- package/src/core/driver/database-driver.ts +9 -1
- package/src/core/driver/mssql-driver.ts +3 -0
- package/src/core/driver/mysql-driver.ts +3 -0
- package/src/core/driver/postgres-driver.ts +3 -0
- package/src/core/driver/sqlite-driver.ts +3 -0
- package/src/core/execution/executors/mssql-executor.ts +5 -0
- package/src/core/execution/executors/mysql-executor.ts +5 -0
- package/src/core/execution/executors/postgres-executor.ts +5 -0
- package/src/core/execution/executors/sqlite-executor.ts +5 -0
- package/src/core/functions/array.ts +26 -0
- package/src/core/functions/control-flow.ts +69 -0
- package/src/core/functions/datetime.ts +50 -0
- package/src/core/functions/definitions/aggregate.ts +16 -0
- package/src/core/functions/definitions/control-flow.ts +24 -0
- package/src/core/functions/definitions/datetime.ts +36 -0
- package/src/core/functions/definitions/helpers.ts +29 -0
- package/src/core/functions/definitions/json.ts +49 -0
- package/src/core/functions/definitions/numeric.ts +55 -0
- package/src/core/functions/definitions/string.ts +43 -0
- package/src/core/functions/function-registry.ts +48 -0
- package/src/core/functions/group-concat-helpers.ts +57 -0
- package/src/core/functions/json.ts +38 -0
- package/src/core/functions/numeric.ts +14 -0
- package/src/core/functions/standard-strategy.ts +86 -115
- package/src/core/functions/standard-table-strategy.ts +13 -0
- package/src/core/functions/table-types.ts +15 -0
- package/src/core/functions/text.ts +57 -0
- package/src/core/sql/sql.ts +59 -38
- package/src/decorators/bootstrap.ts +41 -4
- package/src/index.ts +18 -11
- package/src/orm/entity-meta.ts +6 -3
- package/src/orm/entity.ts +81 -14
- package/src/orm/execute.ts +87 -20
- package/src/orm/hydration-context.ts +10 -0
- package/src/orm/identity-map.ts +19 -0
- package/src/orm/interceptor-pipeline.ts +4 -0
- package/src/orm/lazy-batch.ts +237 -54
- package/src/orm/relations/belongs-to.ts +19 -2
- package/src/orm/relations/has-many.ts +23 -9
- package/src/orm/relations/has-one.ts +19 -2
- package/src/orm/relations/many-to-many.ts +59 -4
- package/src/orm/save-graph-types.ts +2 -2
- package/src/orm/save-graph.ts +18 -18
- package/src/query-builder/relation-conditions.ts +80 -59
- package/src/query-builder/relation-service.ts +399 -95
- package/src/query-builder/relation-types.ts +2 -2
- package/src/query-builder/select.ts +124 -106
- package/src/schema/table-guards.ts +6 -0
- package/src/schema/types.ts +109 -85
package/dist/index.d.ts
CHANGED
|
@@ -453,7 +453,7 @@ type InferRow<TTable extends TableDef> = {
|
|
|
453
453
|
[K in keyof TTable['columns']]: ColumnToTs<TTable['columns'][K]>;
|
|
454
454
|
};
|
|
455
455
|
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> & {
|
|
456
|
-
_pivot?: unknown
|
|
456
|
+
_pivot?: Record<string, unknown>;
|
|
457
457
|
})[] : never;
|
|
458
458
|
/**
|
|
459
459
|
* Maps relation names to the expected row results
|
|
@@ -461,7 +461,14 @@ type RelationResult$1<T extends RelationDef> = T extends HasManyRelation<infer T
|
|
|
461
461
|
type RelationMap<TTable extends TableDef> = {
|
|
462
462
|
[K in keyof TTable['relations']]: RelationResult$1<TTable['relations'][K]>;
|
|
463
463
|
};
|
|
464
|
+
type RelationWrapper$1<TRel extends RelationDef> = TRel extends HasManyRelation<infer TTarget> ? HasManyCollection<EntityInstance<TTarget>> & ReadonlyArray<EntityInstance<TTarget>> : TRel extends HasOneRelation<infer TTarget> ? HasOneReference<EntityInstance<TTarget>> : TRel extends BelongsToManyRelation<infer TTarget> ? ManyToManyCollection<EntityInstance<TTarget> & {
|
|
465
|
+
_pivot?: Record<string, unknown>;
|
|
466
|
+
}> & ReadonlyArray<EntityInstance<TTarget> & {
|
|
467
|
+
_pivot?: Record<string, unknown>;
|
|
468
|
+
}> : TRel extends BelongsToRelation<infer TTarget> ? BelongsToReference<EntityInstance<TTarget>> : never;
|
|
464
469
|
interface HasManyCollection<TChild> {
|
|
470
|
+
length: number;
|
|
471
|
+
[Symbol.iterator](): Iterator<TChild>;
|
|
465
472
|
load(): Promise<TChild[]>;
|
|
466
473
|
getItems(): TChild[];
|
|
467
474
|
add(data: Partial<TChild>): TChild;
|
|
@@ -469,17 +476,21 @@ interface HasManyCollection<TChild> {
|
|
|
469
476
|
remove(entity: TChild): void;
|
|
470
477
|
clear(): void;
|
|
471
478
|
}
|
|
472
|
-
interface
|
|
479
|
+
interface BelongsToReferenceApi<TParent extends object = object> {
|
|
473
480
|
load(): Promise<TParent | null>;
|
|
474
481
|
get(): TParent | null;
|
|
475
482
|
set(data: Partial<TParent> | TParent | null): TParent | null;
|
|
476
483
|
}
|
|
477
|
-
|
|
484
|
+
type BelongsToReference<TParent extends object = object> = BelongsToReferenceApi<TParent> & Partial<TParent>;
|
|
485
|
+
interface HasOneReferenceApi<TChild extends object = object> {
|
|
478
486
|
load(): Promise<TChild | null>;
|
|
479
487
|
get(): TChild | null;
|
|
480
488
|
set(data: Partial<TChild> | TChild | null): TChild | null;
|
|
481
489
|
}
|
|
490
|
+
type HasOneReference<TChild extends object = object> = HasOneReferenceApi<TChild> & Partial<TChild>;
|
|
482
491
|
interface ManyToManyCollection<TTarget> {
|
|
492
|
+
length: number;
|
|
493
|
+
[Symbol.iterator](): Iterator<TTarget>;
|
|
483
494
|
load(): Promise<TTarget[]>;
|
|
484
495
|
getItems(): TTarget[];
|
|
485
496
|
attach(target: TTarget | number | string): void;
|
|
@@ -487,10 +498,15 @@ interface ManyToManyCollection<TTarget> {
|
|
|
487
498
|
syncByIds(ids: (number | string)[]): Promise<void>;
|
|
488
499
|
}
|
|
489
500
|
type EntityInstance<TTable extends TableDef, TRow = InferRow<TTable>> = TRow & {
|
|
490
|
-
[K in keyof RelationMap<TTable>]:
|
|
501
|
+
[K in keyof RelationMap<TTable>]: RelationWrapper$1<TTable['relations'][K]>;
|
|
491
502
|
} & {
|
|
492
503
|
$load<K extends keyof RelationMap<TTable>>(relation: K): Promise<RelationMap<TTable>[K]>;
|
|
493
504
|
};
|
|
505
|
+
type Primitive = string | number | boolean | Date | bigint | Buffer | null | undefined;
|
|
506
|
+
type IsAny<T> = 0 extends (1 & T) ? true : false;
|
|
507
|
+
type SelectableKeys<T> = {
|
|
508
|
+
[K in keyof T]-?: IsAny<T[K]> extends true ? never : NonNullable<T[K]> extends Primitive ? K : never;
|
|
509
|
+
}[keyof T];
|
|
494
510
|
|
|
495
511
|
/**
|
|
496
512
|
* SQL operators used in query conditions
|
|
@@ -533,6 +549,25 @@ declare const SQL_OPERATORS: {
|
|
|
533
549
|
/** NOT EXISTS operator */
|
|
534
550
|
readonly NOT_EXISTS: "NOT EXISTS";
|
|
535
551
|
};
|
|
552
|
+
/**
|
|
553
|
+
* SQL bitwise operators
|
|
554
|
+
*/
|
|
555
|
+
declare const BITWISE_OPERATORS: {
|
|
556
|
+
/** Bitwise AND */
|
|
557
|
+
readonly AND: "&";
|
|
558
|
+
/** Bitwise OR */
|
|
559
|
+
readonly OR: "|";
|
|
560
|
+
/** Bitwise XOR */
|
|
561
|
+
readonly XOR: "^";
|
|
562
|
+
/** Bitwise Shift Left */
|
|
563
|
+
readonly SHIFT_LEFT: "<<";
|
|
564
|
+
/** Bitwise Shift Right */
|
|
565
|
+
readonly SHIFT_RIGHT: ">>";
|
|
566
|
+
};
|
|
567
|
+
/**
|
|
568
|
+
* Type representing supported bitwise operators
|
|
569
|
+
*/
|
|
570
|
+
type BitwiseOperator = (typeof BITWISE_OPERATORS)[keyof typeof BITWISE_OPERATORS];
|
|
536
571
|
/**
|
|
537
572
|
* Type representing any supported SQL operator
|
|
538
573
|
*/
|
|
@@ -705,6 +740,16 @@ interface CastExpressionNode {
|
|
|
705
740
|
/** Optional alias for the result */
|
|
706
741
|
alias?: string;
|
|
707
742
|
}
|
|
743
|
+
/**
|
|
744
|
+
* AST node representing a COLLATE expression (expression COLLATE collationName).
|
|
745
|
+
*/
|
|
746
|
+
interface CollateExpressionNode {
|
|
747
|
+
type: 'Collate';
|
|
748
|
+
/** Expression to be collated */
|
|
749
|
+
expression: OperandNode;
|
|
750
|
+
/** Collation name */
|
|
751
|
+
collation: string;
|
|
752
|
+
}
|
|
708
753
|
/**
|
|
709
754
|
* AST node representing a window function
|
|
710
755
|
*/
|
|
@@ -733,11 +778,12 @@ interface ArithmeticExpressionNode {
|
|
|
733
778
|
/**
|
|
734
779
|
* Union type representing any operand that can be used in expressions
|
|
735
780
|
*/
|
|
736
|
-
type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode | ArithmeticExpressionNode;
|
|
781
|
+
type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode | ArithmeticExpressionNode | BitwiseExpressionNode | CollateExpressionNode;
|
|
737
782
|
declare const isOperandNode: (node: unknown) => node is OperandNode;
|
|
738
783
|
declare const isFunctionNode: (node: unknown) => node is FunctionNode;
|
|
739
784
|
declare const isCaseExpressionNode: (node: unknown) => node is CaseExpressionNode;
|
|
740
785
|
declare const isCastExpressionNode: (node: unknown) => node is CastExpressionNode;
|
|
786
|
+
declare const isCollateExpressionNode: (node: unknown) => node is CollateExpressionNode;
|
|
741
787
|
declare const isWindowFunctionNode: (node: unknown) => node is WindowFunctionNode;
|
|
742
788
|
declare const isExpressionSelectionNode: (node: ColumnRef | FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode) => node is FunctionNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode;
|
|
743
789
|
/**
|
|
@@ -754,6 +800,18 @@ interface BinaryExpressionNode {
|
|
|
754
800
|
/** Optional escape character for LIKE expressions */
|
|
755
801
|
escape?: LiteralNode;
|
|
756
802
|
}
|
|
803
|
+
/**
|
|
804
|
+
* AST node representing a bitwise expression (e.g., a & b)
|
|
805
|
+
*/
|
|
806
|
+
interface BitwiseExpressionNode {
|
|
807
|
+
type: 'BitwiseExpression';
|
|
808
|
+
/** Left operand */
|
|
809
|
+
left: OperandNode;
|
|
810
|
+
/** Bitwise operator */
|
|
811
|
+
operator: BitwiseOperator;
|
|
812
|
+
/** Right operand */
|
|
813
|
+
right: OperandNode;
|
|
814
|
+
}
|
|
757
815
|
/**
|
|
758
816
|
* AST node representing a logical expression (AND/OR)
|
|
759
817
|
*/
|
|
@@ -813,7 +871,7 @@ interface BetweenExpressionNode {
|
|
|
813
871
|
/**
|
|
814
872
|
* Union type representing any supported expression node
|
|
815
873
|
*/
|
|
816
|
-
type ExpressionNode = BinaryExpressionNode | LogicalExpressionNode | NullExpressionNode | InExpressionNode | ExistsExpressionNode | BetweenExpressionNode | ArithmeticExpressionNode;
|
|
874
|
+
type ExpressionNode = BinaryExpressionNode | LogicalExpressionNode | NullExpressionNode | InExpressionNode | ExistsExpressionNode | BetweenExpressionNode | ArithmeticExpressionNode | BitwiseExpressionNode;
|
|
817
875
|
|
|
818
876
|
type LiteralValue = LiteralNode['value'];
|
|
819
877
|
type ValueOperandInput = OperandNode | LiteralValue;
|
|
@@ -956,6 +1014,26 @@ declare const add: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRe
|
|
|
956
1014
|
declare const sub: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => ArithmeticExpressionNode;
|
|
957
1015
|
declare const mul: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => ArithmeticExpressionNode;
|
|
958
1016
|
declare const div: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => ArithmeticExpressionNode;
|
|
1017
|
+
/**
|
|
1018
|
+
* Creates a bitwise AND expression (left & right)
|
|
1019
|
+
*/
|
|
1020
|
+
declare const bitAnd: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
|
|
1021
|
+
/**
|
|
1022
|
+
* Creates a bitwise OR expression (left | right)
|
|
1023
|
+
*/
|
|
1024
|
+
declare const bitOr: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
|
|
1025
|
+
/**
|
|
1026
|
+
* Creates a bitwise XOR expression (left ^ right)
|
|
1027
|
+
*/
|
|
1028
|
+
declare const bitXor: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
|
|
1029
|
+
/**
|
|
1030
|
+
* Creates a bitwise shift left expression (left << right)
|
|
1031
|
+
*/
|
|
1032
|
+
declare const shiftLeft: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
|
|
1033
|
+
/**
|
|
1034
|
+
* Creates a bitwise shift right expression (left >> right)
|
|
1035
|
+
*/
|
|
1036
|
+
declare const shiftRight: (left: OperandNode | ColumnRef, right: OperandNode | ColumnRef | string | number) => BitwiseExpressionNode;
|
|
959
1037
|
/**
|
|
960
1038
|
* Creates a JSON path expression
|
|
961
1039
|
* @param col - Source column
|
|
@@ -989,6 +1067,13 @@ declare const exists: (subquery: SelectQueryNode) => ExistsExpressionNode;
|
|
|
989
1067
|
* @returns NOT EXISTS expression node
|
|
990
1068
|
*/
|
|
991
1069
|
declare const notExists: (subquery: SelectQueryNode) => ExistsExpressionNode;
|
|
1070
|
+
/**
|
|
1071
|
+
* Creates a COLLATE expression (expression COLLATE collationName)
|
|
1072
|
+
* @param expression - Expression to be collated
|
|
1073
|
+
* @param collation - Collation name
|
|
1074
|
+
* @returns COLLATE expression node
|
|
1075
|
+
*/
|
|
1076
|
+
declare const collate: (expression: OperandNode | ColumnRef | string | number | boolean | null, collation: string) => CollateExpressionNode;
|
|
992
1077
|
|
|
993
1078
|
/**
|
|
994
1079
|
* Creates a ROW_NUMBER window function
|
|
@@ -1099,6 +1184,18 @@ type GroupConcatOptions = {
|
|
|
1099
1184
|
* Aggregates grouped strings into a single value.
|
|
1100
1185
|
*/
|
|
1101
1186
|
declare const groupConcat: (col: ColumnRef | ColumnNode, options?: GroupConcatOptions) => FunctionNode;
|
|
1187
|
+
/**
|
|
1188
|
+
* Creates a STDDEV function expression
|
|
1189
|
+
* @param col - Column to calculate standard deviation for
|
|
1190
|
+
* @returns Function node with STDDEV
|
|
1191
|
+
*/
|
|
1192
|
+
declare const stddev: (col: ColumnRef | ColumnNode) => FunctionNode;
|
|
1193
|
+
/**
|
|
1194
|
+
* Creates a VARIANCE function expression
|
|
1195
|
+
* @param col - Column to calculate variance for
|
|
1196
|
+
* @returns Function node with VARIANCE
|
|
1197
|
+
*/
|
|
1198
|
+
declare const variance: (col: ColumnRef | ColumnNode) => FunctionNode;
|
|
1102
1199
|
|
|
1103
1200
|
/**
|
|
1104
1201
|
* Visitor for expression nodes
|
|
@@ -1111,6 +1208,7 @@ interface ExpressionVisitor<R> {
|
|
|
1111
1208
|
visitExistsExpression?(node: ExistsExpressionNode): R;
|
|
1112
1209
|
visitBetweenExpression?(node: BetweenExpressionNode): R;
|
|
1113
1210
|
visitArithmeticExpression?(node: ArithmeticExpressionNode): R;
|
|
1211
|
+
visitBitwiseExpression?(node: BitwiseExpressionNode): R;
|
|
1114
1212
|
otherwise?(node: ExpressionNode): R;
|
|
1115
1213
|
}
|
|
1116
1214
|
/**
|
|
@@ -1125,6 +1223,7 @@ interface OperandVisitor<R> {
|
|
|
1125
1223
|
visitCaseExpression?(node: CaseExpressionNode): R;
|
|
1126
1224
|
visitCast?(node: CastExpressionNode): R;
|
|
1127
1225
|
visitWindowFunction?(node: WindowFunctionNode): R;
|
|
1226
|
+
visitCollate?(node: CollateExpressionNode): R;
|
|
1128
1227
|
visitAliasRef?(node: AliasRefNode): R;
|
|
1129
1228
|
otherwise?(node: OperandNode): R;
|
|
1130
1229
|
}
|
|
@@ -1199,6 +1298,7 @@ interface TableNode {
|
|
|
1199
1298
|
*/
|
|
1200
1299
|
interface FunctionTableNode {
|
|
1201
1300
|
type: 'FunctionTable';
|
|
1301
|
+
key?: string;
|
|
1202
1302
|
/** Function name */
|
|
1203
1303
|
name: string;
|
|
1204
1304
|
/** Optional schema for the function (some dialects) */
|
|
@@ -1445,6 +1545,17 @@ interface FunctionStrategy {
|
|
|
1445
1545
|
getRenderer(functionName: string): FunctionRenderer | undefined;
|
|
1446
1546
|
}
|
|
1447
1547
|
|
|
1548
|
+
interface TableFunctionRenderContext {
|
|
1549
|
+
node: FunctionTableNode;
|
|
1550
|
+
compiledArgs: string[];
|
|
1551
|
+
compileOperand: (operand: OperandNode) => string;
|
|
1552
|
+
quoteIdentifier: (id: string) => string;
|
|
1553
|
+
}
|
|
1554
|
+
type TableFunctionRenderer = (ctx: TableFunctionRenderContext) => string;
|
|
1555
|
+
interface TableFunctionStrategy {
|
|
1556
|
+
getRenderer(key: string): TableFunctionRenderer | undefined;
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1448
1559
|
/**
|
|
1449
1560
|
* Context for SQL compilation with parameter management
|
|
1450
1561
|
*/
|
|
@@ -1564,13 +1675,14 @@ declare abstract class Dialect implements SelectCompiler, InsertCompiler, Update
|
|
|
1564
1675
|
private readonly expressionCompilers;
|
|
1565
1676
|
private readonly operandCompilers;
|
|
1566
1677
|
protected readonly functionStrategy: FunctionStrategy;
|
|
1567
|
-
protected
|
|
1678
|
+
protected readonly tableFunctionStrategy: TableFunctionStrategy;
|
|
1679
|
+
protected constructor(functionStrategy?: FunctionStrategy, tableFunctionStrategy?: TableFunctionStrategy);
|
|
1568
1680
|
/**
|
|
1569
1681
|
* Creates a new Dialect instance (for testing purposes)
|
|
1570
1682
|
* @param functionStrategy - Optional function strategy
|
|
1571
1683
|
* @returns New Dialect instance
|
|
1572
1684
|
*/
|
|
1573
|
-
static create(functionStrategy?: FunctionStrategy): Dialect;
|
|
1685
|
+
static create(functionStrategy?: FunctionStrategy, tableFunctionStrategy?: TableFunctionStrategy): Dialect;
|
|
1574
1686
|
/**
|
|
1575
1687
|
* Registers an expression compiler for a specific node type
|
|
1576
1688
|
* @param type - Expression node type
|
|
@@ -2040,7 +2152,7 @@ type RelationIncludeJoinKind = typeof JOIN_KINDS.LEFT | typeof JOIN_KINDS.INNER;
|
|
|
2040
2152
|
* Options for including a relation in a query
|
|
2041
2153
|
*/
|
|
2042
2154
|
interface RelationIncludeOptions {
|
|
2043
|
-
columns?: string[];
|
|
2155
|
+
columns?: readonly string[];
|
|
2044
2156
|
aliasPrefix?: string;
|
|
2045
2157
|
filter?: ExpressionNode;
|
|
2046
2158
|
joinKind?: RelationIncludeJoinKind;
|
|
@@ -2073,7 +2185,7 @@ declare class RelationService {
|
|
|
2073
2185
|
* @param extraCondition - Additional join condition
|
|
2074
2186
|
* @returns Relation result with updated state and hydration
|
|
2075
2187
|
*/
|
|
2076
|
-
joinRelation(relationName: string, joinKind: JoinKind, extraCondition?: ExpressionNode): RelationResult;
|
|
2188
|
+
joinRelation(relationName: string, joinKind: JoinKind, extraCondition?: ExpressionNode, tableSource?: TableSourceNode): RelationResult;
|
|
2077
2189
|
/**
|
|
2078
2190
|
* Matches records based on a relation with an optional predicate
|
|
2079
2191
|
* @param relationName - Name of the relation to match
|
|
@@ -2112,6 +2224,17 @@ declare class RelationService {
|
|
|
2112
2224
|
* @returns Relation result with updated state and hydration
|
|
2113
2225
|
*/
|
|
2114
2226
|
private selectColumns;
|
|
2227
|
+
private combineWithAnd;
|
|
2228
|
+
private splitFilterExpressions;
|
|
2229
|
+
private flattenAnd;
|
|
2230
|
+
private isExpressionSelfContained;
|
|
2231
|
+
private collectReferencedTables;
|
|
2232
|
+
private collectFromExpression;
|
|
2233
|
+
private collectFromOperand;
|
|
2234
|
+
private collectFromOrderingTerm;
|
|
2235
|
+
private createFilteredRelationCte;
|
|
2236
|
+
private generateUniqueCteName;
|
|
2237
|
+
private resolveTargetTableName;
|
|
2115
2238
|
/**
|
|
2116
2239
|
* Gets a relation definition by name
|
|
2117
2240
|
* @param relationName - Name of the relation
|
|
@@ -2546,6 +2669,10 @@ interface QueryContext {
|
|
|
2546
2669
|
params: unknown[];
|
|
2547
2670
|
}
|
|
2548
2671
|
type QueryInterceptor = (ctx: QueryContext, next: () => Promise<QueryResult[]>) => Promise<QueryResult[]>;
|
|
2672
|
+
/**
|
|
2673
|
+
* Pipeline for query interceptors.
|
|
2674
|
+
* Interceptors can wrap query execution to add logging, tracing, caching, etc.
|
|
2675
|
+
*/
|
|
2549
2676
|
declare class InterceptorPipeline {
|
|
2550
2677
|
private interceptors;
|
|
2551
2678
|
use(interceptor: QueryInterceptor): void;
|
|
@@ -2621,12 +2748,31 @@ declare class Orm<E extends DomainEvent = OrmDomainEvent> {
|
|
|
2621
2748
|
dispose(): Promise<void>;
|
|
2622
2749
|
}
|
|
2623
2750
|
|
|
2751
|
+
/**
|
|
2752
|
+
* Simple identity map for tracking entities within a session.
|
|
2753
|
+
* Ensures that the same database record is represented by a single entity instance.
|
|
2754
|
+
*/
|
|
2624
2755
|
declare class IdentityMap {
|
|
2625
2756
|
private readonly buckets;
|
|
2626
2757
|
get bucketsMap(): Map<string, Map<string, TrackedEntity>>;
|
|
2758
|
+
/**
|
|
2759
|
+
* Retrieves an entity from the identity map if it exists.
|
|
2760
|
+
* @param table The table definition of the entity.
|
|
2761
|
+
* @param pk The primary key value.
|
|
2762
|
+
* @returns The entity instance if found, undefined otherwise.
|
|
2763
|
+
*/
|
|
2627
2764
|
getEntity(table: TableDef, pk: string | number): unknown | undefined;
|
|
2765
|
+
/**
|
|
2766
|
+
* Registers a tracked entity in the identity map.
|
|
2767
|
+
* @param tracked The tracked entity metadata and instance.
|
|
2768
|
+
*/
|
|
2628
2769
|
register(tracked: TrackedEntity): void;
|
|
2629
2770
|
remove(tracked: TrackedEntity): void;
|
|
2771
|
+
/**
|
|
2772
|
+
* Returns all tracked entities for a specific table.
|
|
2773
|
+
* @param table The table definition.
|
|
2774
|
+
* @returns Array of tracked entities.
|
|
2775
|
+
*/
|
|
2630
2776
|
getEntitiesForTable(table: TableDef): TrackedEntity[];
|
|
2631
2777
|
clear(): void;
|
|
2632
2778
|
private toIdentityKey;
|
|
@@ -3054,11 +3200,21 @@ interface EntityContext {
|
|
|
3054
3200
|
registerRelationChange(root: unknown, relationKey: RelationKey, rootTable: TableDef, relationName: string, relation: RelationDef, change: RelationChange<unknown>): void;
|
|
3055
3201
|
}
|
|
3056
3202
|
|
|
3203
|
+
/**
|
|
3204
|
+
* Context used during the hydration of entities from database results.
|
|
3205
|
+
* It carries necessary services and processors to handle identity management,
|
|
3206
|
+
* unit of work registration, and relation changes.
|
|
3207
|
+
*/
|
|
3057
3208
|
interface HydrationContext<E extends DomainEvent = AnyDomainEvent> {
|
|
3209
|
+
/** The identity map used to track and reuse entity instances. */
|
|
3058
3210
|
identityMap: IdentityMap;
|
|
3211
|
+
/** The unit of work used to track changes in hydrated entities. */
|
|
3059
3212
|
unitOfWork: UnitOfWork;
|
|
3213
|
+
/** The bus used to dispatch domain events during or after hydration. */
|
|
3060
3214
|
domainEvents: DomainEventBus<E, OrmSession<E>>;
|
|
3215
|
+
/** Processor for handling changes in entity relations during hydration. */
|
|
3061
3216
|
relationChanges: RelationChangeProcessor;
|
|
3217
|
+
/** Context providing access to entity-specific metadata and services. */
|
|
3062
3218
|
entityContext: EntityContext;
|
|
3063
3219
|
}
|
|
3064
3220
|
|
|
@@ -3078,14 +3234,14 @@ interface SaveGraphOptions {
|
|
|
3078
3234
|
|
|
3079
3235
|
type AnyId = number | string;
|
|
3080
3236
|
type AnyFn = (...args: unknown[]) => unknown;
|
|
3081
|
-
type RelationWrapper = HasManyCollection<unknown> | HasOneReference
|
|
3237
|
+
type RelationWrapper = HasManyCollection<unknown> | HasOneReference | BelongsToReference | ManyToManyCollection<unknown>;
|
|
3082
3238
|
type FunctionKeys<T> = {
|
|
3083
3239
|
[K in keyof T & string]-?: T[K] extends AnyFn ? K : never;
|
|
3084
3240
|
}[keyof T & string];
|
|
3085
|
-
type RelationKeys<T> = {
|
|
3241
|
+
type RelationKeys$1<T> = {
|
|
3086
3242
|
[K in keyof T & string]-?: NonNullable<T[K]> extends RelationWrapper ? K : never;
|
|
3087
3243
|
}[keyof T & string];
|
|
3088
|
-
type ColumnKeys<T> = Exclude<keyof T & string, FunctionKeys<T> | RelationKeys<T>>;
|
|
3244
|
+
type ColumnKeys<T> = Exclude<keyof T & string, FunctionKeys<T> | RelationKeys$1<T>>;
|
|
3089
3245
|
type SaveGraphJsonScalar<T> = T extends Date ? string : T;
|
|
3090
3246
|
/**
|
|
3091
3247
|
* Input scalar type for `OrmSession.saveGraph` payloads.
|
|
@@ -3098,7 +3254,7 @@ type ColumnInput$1<TEntity> = {
|
|
|
3098
3254
|
};
|
|
3099
3255
|
type RelationInputValue<T> = T extends HasManyCollection<infer C> ? Array<SaveGraphInputPayload<C> | AnyId> : T extends HasOneReference<infer C> ? SaveGraphInputPayload<C> | AnyId | null : T extends BelongsToReference<infer P> ? SaveGraphInputPayload<P> | AnyId | null : T extends ManyToManyCollection<infer Tgt> ? Array<SaveGraphInputPayload<Tgt> | AnyId> : never;
|
|
3100
3256
|
type RelationInput<TEntity> = {
|
|
3101
|
-
[K in RelationKeys<TEntity>]?: RelationInputValue<NonNullable<TEntity[K]>>;
|
|
3257
|
+
[K in RelationKeys$1<TEntity>]?: RelationInputValue<NonNullable<TEntity[K]>>;
|
|
3102
3258
|
};
|
|
3103
3259
|
/**
|
|
3104
3260
|
* Typed payload accepted by `OrmSession.saveGraph`:
|
|
@@ -3351,6 +3507,7 @@ declare class SelectQueryBuilder<T = unknown, TTable extends TableDef = TableDef
|
|
|
3351
3507
|
private readonly columnSelector;
|
|
3352
3508
|
private readonly relationManager;
|
|
3353
3509
|
private readonly lazyRelations;
|
|
3510
|
+
private readonly lazyRelationOptions;
|
|
3354
3511
|
/**
|
|
3355
3512
|
* Creates a new SelectQueryBuilder instance
|
|
3356
3513
|
* @param table - Table definition to query
|
|
@@ -3358,7 +3515,7 @@ declare class SelectQueryBuilder<T = unknown, TTable extends TableDef = TableDef
|
|
|
3358
3515
|
* @param hydration - Optional hydration manager
|
|
3359
3516
|
* @param dependencies - Optional query builder dependencies
|
|
3360
3517
|
*/
|
|
3361
|
-
constructor(table: TTable, state?: SelectQueryState, hydration?: HydrationManager, dependencies?: Partial<SelectQueryBuilderDependencies>, lazyRelations?: Set<string>);
|
|
3518
|
+
constructor(table: TTable, state?: SelectQueryState, hydration?: HydrationManager, dependencies?: Partial<SelectQueryBuilderDependencies>, lazyRelations?: Set<string>, lazyRelationOptions?: Map<string, RelationIncludeOptions>);
|
|
3362
3519
|
/**
|
|
3363
3520
|
* Creates a new SelectQueryBuilder instance with updated context and lazy relations
|
|
3364
3521
|
* @param context - Updated query context
|
|
@@ -3536,15 +3693,12 @@ declare class SelectQueryBuilder<T = unknown, TTable extends TableDef = TableDef
|
|
|
3536
3693
|
/**
|
|
3537
3694
|
* Includes a relation lazily in the query results
|
|
3538
3695
|
* @param relationName - Name of the relation to include lazily
|
|
3696
|
+
* @param options - Optional include options for lazy loading
|
|
3539
3697
|
* @returns New query builder instance with lazy relation inclusion
|
|
3540
3698
|
*/
|
|
3541
|
-
includeLazy<K extends keyof RelationMap<TTable>>(relationName: K): SelectQueryBuilder<T, TTable>;
|
|
3542
|
-
/**
|
|
3543
|
-
* Selects columns for a related table in a single hop.
|
|
3544
|
-
*/
|
|
3545
|
-
selectRelationColumns<K extends keyof TTable['relations'] & string, TRel extends RelationDef = TTable['relations'][K], TTarget extends TableDef = RelationTargetTable<TRel>, C extends keyof TTarget['columns'] & string = keyof TTarget['columns'] & string>(relationName: K, ...cols: C[]): SelectQueryBuilder<T, TTable>;
|
|
3699
|
+
includeLazy<K extends keyof RelationMap<TTable>>(relationName: K, options?: RelationIncludeOptions): SelectQueryBuilder<T, TTable>;
|
|
3546
3700
|
/**
|
|
3547
|
-
* Convenience alias for
|
|
3701
|
+
* Convenience alias for including only specific columns from a relation.
|
|
3548
3702
|
*/
|
|
3549
3703
|
includePick<K extends keyof TTable['relations'] & string, TRel extends RelationDef = TTable['relations'][K], TTarget extends TableDef = RelationTargetTable<TRel>, C extends keyof TTarget['columns'] & string = keyof TTarget['columns'] & string>(relationName: K, cols: C[]): SelectQueryBuilder<T, TTable>;
|
|
3550
3704
|
/**
|
|
@@ -3558,6 +3712,11 @@ declare class SelectQueryBuilder<T = unknown, TTable extends TableDef = TableDef
|
|
|
3558
3712
|
* @returns Array of lazy relation names
|
|
3559
3713
|
*/
|
|
3560
3714
|
getLazyRelations(): (keyof RelationMap<TTable>)[];
|
|
3715
|
+
/**
|
|
3716
|
+
* Gets lazy relation include options
|
|
3717
|
+
* @returns Map of relation names to include options
|
|
3718
|
+
*/
|
|
3719
|
+
getLazyRelationOptions(): Map<string, RelationIncludeOptions>;
|
|
3561
3720
|
/**
|
|
3562
3721
|
* Gets the table definition for this query builder
|
|
3563
3722
|
* @returns Table definition
|
|
@@ -4136,6 +4295,11 @@ interface ReturningStrategy {
|
|
|
4136
4295
|
formatReturningColumns(returning: ColumnNode[], quoteIdentifier: (id: string) => string): string;
|
|
4137
4296
|
}
|
|
4138
4297
|
|
|
4298
|
+
/**
|
|
4299
|
+
* Base class for SQL dialects.
|
|
4300
|
+
* Provides a common framework for compiling AST nodes into SQL strings.
|
|
4301
|
+
* Specific dialects should extend this class and implement dialect-specific logic.
|
|
4302
|
+
*/
|
|
4139
4303
|
declare abstract class SqlDialectBase extends Dialect {
|
|
4140
4304
|
abstract quoteIdentifier(id: string): string;
|
|
4141
4305
|
protected paginationStrategy: PaginationStrategy;
|
|
@@ -4505,75 +4669,75 @@ declare const registerSchemaIntrospector: (dialect: DialectName, introspector: S
|
|
|
4505
4669
|
*/
|
|
4506
4670
|
declare const getSchemaIntrospector: (dialect: DialectName) => SchemaIntrospector | undefined;
|
|
4507
4671
|
|
|
4508
|
-
type OperandInput$
|
|
4672
|
+
type OperandInput$5 = OperandNode | ColumnDef | string | number | boolean | null;
|
|
4509
4673
|
/**
|
|
4510
4674
|
* Converts a string to lowercase.
|
|
4511
4675
|
* @param value - The string value.
|
|
4512
4676
|
* @returns A FunctionNode representing the LOWER SQL function.
|
|
4513
4677
|
*/
|
|
4514
|
-
declare const lower: (value: OperandInput$
|
|
4678
|
+
declare const lower: (value: OperandInput$5) => FunctionNode;
|
|
4515
4679
|
/**
|
|
4516
4680
|
* Converts a string to uppercase.
|
|
4517
4681
|
* @param value - The string value.
|
|
4518
4682
|
* @returns A FunctionNode representing the UPPER SQL function.
|
|
4519
4683
|
*/
|
|
4520
|
-
declare const upper: (value: OperandInput$
|
|
4684
|
+
declare const upper: (value: OperandInput$5) => FunctionNode;
|
|
4521
4685
|
/**
|
|
4522
4686
|
* Returns the ASCII code of the first character of a string.
|
|
4523
4687
|
* @param value - The string value.
|
|
4524
4688
|
* @returns A FunctionNode representing the ASCII SQL function.
|
|
4525
4689
|
*/
|
|
4526
|
-
declare const ascii: (value: OperandInput$
|
|
4690
|
+
declare const ascii: (value: OperandInput$5) => FunctionNode;
|
|
4527
4691
|
/**
|
|
4528
4692
|
* Returns a string from one or more ASCII codes.
|
|
4529
4693
|
* @param codes - The ASCII codes.
|
|
4530
4694
|
* @returns A FunctionNode representing the CHAR SQL function.
|
|
4531
4695
|
*/
|
|
4532
|
-
declare const char: (...codes: OperandInput$
|
|
4696
|
+
declare const char: (...codes: OperandInput$5[]) => FunctionNode;
|
|
4533
4697
|
/**
|
|
4534
4698
|
* Returns the number of characters in a string.
|
|
4535
4699
|
* @param value - The string value.
|
|
4536
4700
|
* @returns A FunctionNode representing the CHAR_LENGTH SQL function.
|
|
4537
4701
|
*/
|
|
4538
|
-
declare const charLength: (value: OperandInput$
|
|
4702
|
+
declare const charLength: (value: OperandInput$5) => FunctionNode;
|
|
4539
4703
|
/**
|
|
4540
4704
|
* Returns the length of a string in bytes or characters.
|
|
4541
4705
|
* @param value - The string value.
|
|
4542
4706
|
* @returns A FunctionNode representing the LENGTH SQL function.
|
|
4543
4707
|
*/
|
|
4544
|
-
declare const length: (value: OperandInput$
|
|
4708
|
+
declare const length: (value: OperandInput$5) => FunctionNode;
|
|
4545
4709
|
/**
|
|
4546
4710
|
* Removes leading and trailing whitespace or specified characters from a string.
|
|
4547
4711
|
* @param value - The string value.
|
|
4548
4712
|
* @param chars - The characters to trim (optional).
|
|
4549
4713
|
* @returns A FunctionNode representing the TRIM SQL function.
|
|
4550
4714
|
*/
|
|
4551
|
-
declare const trim: (value: OperandInput$
|
|
4715
|
+
declare const trim: (value: OperandInput$5, chars?: OperandInput$5) => FunctionNode;
|
|
4552
4716
|
/**
|
|
4553
4717
|
* Removes leading whitespace from a string.
|
|
4554
4718
|
* @param value - The string value.
|
|
4555
4719
|
* @returns A FunctionNode representing the LTRIM SQL function.
|
|
4556
4720
|
*/
|
|
4557
|
-
declare const ltrim: (value: OperandInput$
|
|
4721
|
+
declare const ltrim: (value: OperandInput$5) => FunctionNode;
|
|
4558
4722
|
/**
|
|
4559
4723
|
* Removes trailing whitespace from a string.
|
|
4560
4724
|
* @param value - The string value.
|
|
4561
4725
|
* @returns A FunctionNode representing the RTRIM SQL function.
|
|
4562
4726
|
*/
|
|
4563
|
-
declare const rtrim: (value: OperandInput$
|
|
4727
|
+
declare const rtrim: (value: OperandInput$5) => FunctionNode;
|
|
4564
4728
|
/**
|
|
4565
4729
|
* Concatenates two or more strings.
|
|
4566
4730
|
* @param args - The strings to concatenate.
|
|
4567
4731
|
* @returns A FunctionNode representing the CONCAT SQL function.
|
|
4568
4732
|
*/
|
|
4569
|
-
declare const concat: (...args: OperandInput$
|
|
4733
|
+
declare const concat: (...args: OperandInput$5[]) => FunctionNode;
|
|
4570
4734
|
/**
|
|
4571
4735
|
* Concatenates strings with a separator.
|
|
4572
4736
|
* @param separator - The separator string.
|
|
4573
4737
|
* @param args - The strings to concatenate.
|
|
4574
4738
|
* @returns A FunctionNode representing the CONCAT_WS SQL function.
|
|
4575
4739
|
*/
|
|
4576
|
-
declare const concatWs: (separator: OperandInput$
|
|
4740
|
+
declare const concatWs: (separator: OperandInput$5, ...args: OperandInput$5[]) => FunctionNode;
|
|
4577
4741
|
/**
|
|
4578
4742
|
* Extracts a substring from a string.
|
|
4579
4743
|
* @param value - The string value.
|
|
@@ -4581,35 +4745,35 @@ declare const concatWs: (separator: OperandInput$2, ...args: OperandInput$2[]) =
|
|
|
4581
4745
|
* @param length - The length of the substring (optional).
|
|
4582
4746
|
* @returns A FunctionNode representing the SUBSTR SQL function.
|
|
4583
4747
|
*/
|
|
4584
|
-
declare const substr: (value: OperandInput$
|
|
4748
|
+
declare const substr: (value: OperandInput$5, start: OperandInput$5, length?: OperandInput$5) => FunctionNode;
|
|
4585
4749
|
/**
|
|
4586
4750
|
* Returns the leftmost characters of a string.
|
|
4587
4751
|
* @param value - The string value.
|
|
4588
4752
|
* @param len - The number of characters to return.
|
|
4589
4753
|
* @returns A FunctionNode representing the LEFT SQL function.
|
|
4590
4754
|
*/
|
|
4591
|
-
declare const left: (value: OperandInput$
|
|
4755
|
+
declare const left: (value: OperandInput$5, len: OperandInput$5) => FunctionNode;
|
|
4592
4756
|
/**
|
|
4593
4757
|
* Returns the rightmost characters of a string.
|
|
4594
4758
|
* @param value - The string value.
|
|
4595
4759
|
* @param len - The number of characters to return.
|
|
4596
4760
|
* @returns A FunctionNode representing the RIGHT SQL function.
|
|
4597
4761
|
*/
|
|
4598
|
-
declare const right: (value: OperandInput$
|
|
4762
|
+
declare const right: (value: OperandInput$5, len: OperandInput$5) => FunctionNode;
|
|
4599
4763
|
/**
|
|
4600
4764
|
* Returns the position of a substring in a string.
|
|
4601
4765
|
* @param substring - The substring to search for.
|
|
4602
4766
|
* @param value - The string to search in.
|
|
4603
4767
|
* @returns A FunctionNode representing the POSITION SQL function.
|
|
4604
4768
|
*/
|
|
4605
|
-
declare const position: (substring: OperandInput$
|
|
4769
|
+
declare const position: (substring: OperandInput$5, value: OperandInput$5) => FunctionNode;
|
|
4606
4770
|
/**
|
|
4607
4771
|
* Returns the position of a substring in a string.
|
|
4608
4772
|
* @param value - The string to search in.
|
|
4609
4773
|
* @param substring - The substring to search for.
|
|
4610
4774
|
* @returns A FunctionNode representing the INSTR SQL function.
|
|
4611
4775
|
*/
|
|
4612
|
-
declare const instr: (value: OperandInput$
|
|
4776
|
+
declare const instr: (value: OperandInput$5, substring: OperandInput$5) => FunctionNode;
|
|
4613
4777
|
/**
|
|
4614
4778
|
* Returns the position of a substring in a string, optionally starting from a position.
|
|
4615
4779
|
* @param substring - The substring to search for.
|
|
@@ -4617,7 +4781,7 @@ declare const instr: (value: OperandInput$2, substring: OperandInput$2) => Funct
|
|
|
4617
4781
|
* @param start - The starting position (optional).
|
|
4618
4782
|
* @returns A FunctionNode representing the LOCATE SQL function.
|
|
4619
4783
|
*/
|
|
4620
|
-
declare const locate: (substring: OperandInput$
|
|
4784
|
+
declare const locate: (substring: OperandInput$5, value: OperandInput$5, start?: OperandInput$5) => FunctionNode;
|
|
4621
4785
|
/**
|
|
4622
4786
|
* Replaces occurrences of a substring in a string.
|
|
4623
4787
|
* @param value - The string to search in.
|
|
@@ -4625,14 +4789,14 @@ declare const locate: (substring: OperandInput$2, value: OperandInput$2, start?:
|
|
|
4625
4789
|
* @param replacement - The replacement string.
|
|
4626
4790
|
* @returns A FunctionNode representing the REPLACE SQL function.
|
|
4627
4791
|
*/
|
|
4628
|
-
declare const replace: (value: OperandInput$
|
|
4792
|
+
declare const replace: (value: OperandInput$5, search: OperandInput$5, replacement: OperandInput$5) => FunctionNode;
|
|
4629
4793
|
/**
|
|
4630
4794
|
* Repeats a string a specified number of times.
|
|
4631
4795
|
* @param value - The string to repeat.
|
|
4632
4796
|
* @param count - The number of times to repeat.
|
|
4633
4797
|
* @returns A FunctionNode representing the REPEAT SQL function.
|
|
4634
4798
|
*/
|
|
4635
|
-
declare const repeat: (value: OperandInput$
|
|
4799
|
+
declare const repeat: (value: OperandInput$5, count: OperandInput$5) => FunctionNode;
|
|
4636
4800
|
/**
|
|
4637
4801
|
* Left-pads a string to a certain length with another string.
|
|
4638
4802
|
* @param value - The string to pad.
|
|
@@ -4640,7 +4804,7 @@ declare const repeat: (value: OperandInput$2, count: OperandInput$2) => Function
|
|
|
4640
4804
|
* @param pad - The padding string.
|
|
4641
4805
|
* @returns A FunctionNode representing the LPAD SQL function.
|
|
4642
4806
|
*/
|
|
4643
|
-
declare const lpad: (value: OperandInput$
|
|
4807
|
+
declare const lpad: (value: OperandInput$5, len: OperandInput$5, pad: OperandInput$5) => FunctionNode;
|
|
4644
4808
|
/**
|
|
4645
4809
|
* Right-pads a string to a certain length with another string.
|
|
4646
4810
|
* @param value - The string to pad.
|
|
@@ -4648,120 +4812,169 @@ declare const lpad: (value: OperandInput$2, len: OperandInput$2, pad: OperandInp
|
|
|
4648
4812
|
* @param pad - The padding string.
|
|
4649
4813
|
* @returns A FunctionNode representing the RPAD SQL function.
|
|
4650
4814
|
*/
|
|
4651
|
-
declare const rpad: (value: OperandInput$
|
|
4815
|
+
declare const rpad: (value: OperandInput$5, len: OperandInput$5, pad: OperandInput$5) => FunctionNode;
|
|
4652
4816
|
/**
|
|
4653
4817
|
* Returns a string consisting of a specified number of spaces.
|
|
4654
4818
|
* @param count - The number of spaces.
|
|
4655
4819
|
* @returns A FunctionNode representing the SPACE SQL function.
|
|
4656
4820
|
*/
|
|
4657
|
-
declare const space: (count: OperandInput$
|
|
4821
|
+
declare const space: (count: OperandInput$5) => FunctionNode;
|
|
4822
|
+
/**
|
|
4823
|
+
* Reverses a string.
|
|
4824
|
+
* @param value - The string value.
|
|
4825
|
+
* @returns A FunctionNode representing the REVERSE SQL function.
|
|
4826
|
+
*/
|
|
4827
|
+
declare const reverse: (value: OperandInput$5) => FunctionNode;
|
|
4828
|
+
/**
|
|
4829
|
+
* Capitalizes the first letter of each word in a string.
|
|
4830
|
+
* @param value - The string value.
|
|
4831
|
+
* @returns A FunctionNode representing the INITCAP SQL function.
|
|
4832
|
+
*/
|
|
4833
|
+
declare const initcap: (value: OperandInput$5) => FunctionNode;
|
|
4834
|
+
/**
|
|
4835
|
+
* Returns the MD5 hash of a string.
|
|
4836
|
+
* @param value - The string value.
|
|
4837
|
+
* @returns A FunctionNode representing the MD5 SQL function.
|
|
4838
|
+
*/
|
|
4839
|
+
declare const md5: (value: OperandInput$5) => FunctionNode;
|
|
4840
|
+
/**
|
|
4841
|
+
* Returns the SHA-1 hash of a string.
|
|
4842
|
+
* @param value - The string value.
|
|
4843
|
+
* @returns A FunctionNode representing the SHA1 SQL function.
|
|
4844
|
+
*/
|
|
4845
|
+
declare const sha1: (value: OperandInput$5) => FunctionNode;
|
|
4846
|
+
/**
|
|
4847
|
+
* Returns the SHA-2 hash of a string with a specified bit length.
|
|
4848
|
+
* @param value - The string value.
|
|
4849
|
+
* @param bits - The bit length (e.g., 224, 256, 384, 512).
|
|
4850
|
+
* @returns A FunctionNode representing the SHA2 SQL function.
|
|
4851
|
+
*/
|
|
4852
|
+
declare const sha2: (value: OperandInput$5, bits: OperandInput$5) => FunctionNode;
|
|
4853
|
+
/**
|
|
4854
|
+
* Returns the length of a string in bits.
|
|
4855
|
+
* @param value - The string value.
|
|
4856
|
+
* @returns A FunctionNode representing the BIT_LENGTH SQL function.
|
|
4857
|
+
*/
|
|
4858
|
+
declare const bitLength: (value: OperandInput$5) => FunctionNode;
|
|
4859
|
+
/**
|
|
4860
|
+
* Returns the length of a string in bytes.
|
|
4861
|
+
* @param value - The string value.
|
|
4862
|
+
* @returns A FunctionNode representing the OCTET_LENGTH SQL function.
|
|
4863
|
+
*/
|
|
4864
|
+
declare const octetLength: (value: OperandInput$5) => FunctionNode;
|
|
4865
|
+
/**
|
|
4866
|
+
* Returns a string from an ASCII code.
|
|
4867
|
+
* @param code - The ASCII code.
|
|
4868
|
+
* @returns A FunctionNode representing the CHR/CHAR SQL function.
|
|
4869
|
+
*/
|
|
4870
|
+
declare const chr: (code: OperandInput$5) => FunctionNode;
|
|
4658
4871
|
|
|
4659
|
-
type OperandInput$
|
|
4872
|
+
type OperandInput$4 = OperandNode | ColumnDef | string | number | boolean | null;
|
|
4660
4873
|
/**
|
|
4661
4874
|
* Returns the absolute value of a number.
|
|
4662
4875
|
* @param value - The numeric value.
|
|
4663
4876
|
* @returns A FunctionNode representing the ABS SQL function.
|
|
4664
4877
|
*/
|
|
4665
|
-
declare const abs: (value: OperandInput$
|
|
4878
|
+
declare const abs: (value: OperandInput$4) => FunctionNode;
|
|
4666
4879
|
/**
|
|
4667
4880
|
* Returns the arccosine (inverse cosine) of a number.
|
|
4668
4881
|
* @param value - The numeric value.
|
|
4669
4882
|
* @returns A FunctionNode representing the ACOS SQL function.
|
|
4670
4883
|
*/
|
|
4671
|
-
declare const acos: (value: OperandInput$
|
|
4884
|
+
declare const acos: (value: OperandInput$4) => FunctionNode;
|
|
4672
4885
|
/**
|
|
4673
4886
|
* Returns the arcsine (inverse sine) of a number.
|
|
4674
4887
|
* @param value - The numeric value.
|
|
4675
4888
|
* @returns A FunctionNode representing the ASIN SQL function.
|
|
4676
4889
|
*/
|
|
4677
|
-
declare const asin: (value: OperandInput$
|
|
4890
|
+
declare const asin: (value: OperandInput$4) => FunctionNode;
|
|
4678
4891
|
/**
|
|
4679
4892
|
* Returns the arctangent (inverse tangent) of a number.
|
|
4680
4893
|
* @param value - The numeric value.
|
|
4681
4894
|
* @returns A FunctionNode representing the ATAN SQL function.
|
|
4682
4895
|
*/
|
|
4683
|
-
declare const atan: (value: OperandInput$
|
|
4896
|
+
declare const atan: (value: OperandInput$4) => FunctionNode;
|
|
4684
4897
|
/**
|
|
4685
4898
|
* Returns the arctangent of the two arguments.
|
|
4686
4899
|
* @param y - The y-coordinate.
|
|
4687
4900
|
* @param x - The x-coordinate.
|
|
4688
4901
|
* @returns A FunctionNode representing the ATAN2 SQL function.
|
|
4689
4902
|
*/
|
|
4690
|
-
declare const atan2: (y: OperandInput$
|
|
4903
|
+
declare const atan2: (y: OperandInput$4, x: OperandInput$4) => FunctionNode;
|
|
4691
4904
|
/**
|
|
4692
4905
|
* Returns the smallest integer greater than or equal to a number.
|
|
4693
4906
|
* @param value - The numeric value.
|
|
4694
4907
|
* @returns A FunctionNode representing the CEIL SQL function.
|
|
4695
4908
|
*/
|
|
4696
|
-
declare const ceil: (value: OperandInput$
|
|
4909
|
+
declare const ceil: (value: OperandInput$4) => FunctionNode;
|
|
4697
4910
|
/**
|
|
4698
4911
|
* Alias for ceil. Returns the smallest integer greater than or equal to a number.
|
|
4699
4912
|
* @param value - The numeric value.
|
|
4700
4913
|
* @returns A FunctionNode representing the CEILING SQL function.
|
|
4701
4914
|
*/
|
|
4702
|
-
declare const ceiling: (value: OperandInput$
|
|
4915
|
+
declare const ceiling: (value: OperandInput$4) => FunctionNode;
|
|
4703
4916
|
/**
|
|
4704
4917
|
* Returns the cosine of a number (in radians).
|
|
4705
4918
|
* @param value - The numeric value in radians.
|
|
4706
4919
|
* @returns A FunctionNode representing the COS SQL function.
|
|
4707
4920
|
*/
|
|
4708
|
-
declare const cos: (value: OperandInput$
|
|
4921
|
+
declare const cos: (value: OperandInput$4) => FunctionNode;
|
|
4709
4922
|
/**
|
|
4710
4923
|
* Returns the cotangent of a number.
|
|
4711
4924
|
* @param value - The numeric value.
|
|
4712
4925
|
* @returns A FunctionNode representing the COT SQL function.
|
|
4713
4926
|
*/
|
|
4714
|
-
declare const cot: (value: OperandInput$
|
|
4927
|
+
declare const cot: (value: OperandInput$4) => FunctionNode;
|
|
4715
4928
|
/**
|
|
4716
4929
|
* Converts radians to degrees.
|
|
4717
4930
|
* @param value - The angle in radians.
|
|
4718
4931
|
* @returns A FunctionNode representing the DEGREES SQL function.
|
|
4719
4932
|
*/
|
|
4720
|
-
declare const degrees: (value: OperandInput$
|
|
4933
|
+
declare const degrees: (value: OperandInput$4) => FunctionNode;
|
|
4721
4934
|
/**
|
|
4722
4935
|
* Returns e raised to the power of the argument.
|
|
4723
4936
|
* @param value - The exponent.
|
|
4724
4937
|
* @returns A FunctionNode representing the EXP SQL function.
|
|
4725
4938
|
*/
|
|
4726
|
-
declare const exp: (value: OperandInput$
|
|
4939
|
+
declare const exp: (value: OperandInput$4) => FunctionNode;
|
|
4727
4940
|
/**
|
|
4728
4941
|
* Returns the largest integer less than or equal to a number.
|
|
4729
4942
|
* @param value - The numeric value.
|
|
4730
4943
|
* @returns A FunctionNode representing the FLOOR SQL function.
|
|
4731
4944
|
*/
|
|
4732
|
-
declare const floor: (value: OperandInput$
|
|
4945
|
+
declare const floor: (value: OperandInput$4) => FunctionNode;
|
|
4733
4946
|
/**
|
|
4734
4947
|
* Returns the natural logarithm (base e) of a number.
|
|
4735
4948
|
* @param value - The numeric value.
|
|
4736
4949
|
* @returns A FunctionNode representing the LN SQL function.
|
|
4737
4950
|
*/
|
|
4738
|
-
declare const ln: (value: OperandInput$
|
|
4951
|
+
declare const ln: (value: OperandInput$4) => FunctionNode;
|
|
4739
4952
|
/**
|
|
4740
4953
|
* Returns the base-10 logarithm of a number.
|
|
4741
4954
|
* @param value - The numeric value.
|
|
4742
4955
|
* @returns A FunctionNode representing the LOG SQL function.
|
|
4743
4956
|
*/
|
|
4744
|
-
declare const log: (value: OperandInput$
|
|
4957
|
+
declare const log: (value: OperandInput$4) => FunctionNode;
|
|
4745
4958
|
/**
|
|
4746
4959
|
* Returns the base-10 logarithm of a number.
|
|
4747
4960
|
* @param value - The numeric value.
|
|
4748
4961
|
* @returns A FunctionNode representing the LOG10 SQL function.
|
|
4749
4962
|
*/
|
|
4750
|
-
declare const log10: (value: OperandInput$
|
|
4963
|
+
declare const log10: (value: OperandInput$4) => FunctionNode;
|
|
4751
4964
|
/**
|
|
4752
4965
|
* Returns the logarithm of a number for a specific base.
|
|
4753
4966
|
* @param base - The base of the logarithm.
|
|
4754
4967
|
* @param value - The numeric value.
|
|
4755
4968
|
* @returns A FunctionNode representing the LOG_BASE SQL function.
|
|
4756
4969
|
*/
|
|
4757
|
-
declare const logBase: (base: OperandInput$
|
|
4970
|
+
declare const logBase: (base: OperandInput$4, value: OperandInput$4) => FunctionNode;
|
|
4758
4971
|
/**
|
|
4759
4972
|
* Returns the remainder of dividing x by y.
|
|
4760
4973
|
* @param x - The dividend.
|
|
4761
4974
|
* @param y - The divisor.
|
|
4762
4975
|
* @returns A FunctionNode representing the MOD SQL function.
|
|
4763
4976
|
*/
|
|
4764
|
-
declare const mod: (x: OperandInput$
|
|
4977
|
+
declare const mod: (x: OperandInput$4, y: OperandInput$4) => FunctionNode;
|
|
4765
4978
|
/**
|
|
4766
4979
|
* Returns the value of PI (approximately 3.14159...).
|
|
4767
4980
|
* @returns A FunctionNode representing the PI SQL function.
|
|
@@ -4773,20 +4986,20 @@ declare const pi: () => FunctionNode;
|
|
|
4773
4986
|
* @param y - The exponent.
|
|
4774
4987
|
* @returns A FunctionNode representing the POWER SQL function.
|
|
4775
4988
|
*/
|
|
4776
|
-
declare const power: (x: OperandInput$
|
|
4989
|
+
declare const power: (x: OperandInput$4, y: OperandInput$4) => FunctionNode;
|
|
4777
4990
|
/**
|
|
4778
4991
|
* Alias for power. Returns x raised to the power of y.
|
|
4779
4992
|
* @param x - The base.
|
|
4780
4993
|
* @param y - The exponent.
|
|
4781
4994
|
* @returns A FunctionNode representing the POW SQL function.
|
|
4782
4995
|
*/
|
|
4783
|
-
declare const pow: (x: OperandInput$
|
|
4996
|
+
declare const pow: (x: OperandInput$4, y: OperandInput$4) => FunctionNode;
|
|
4784
4997
|
/**
|
|
4785
4998
|
* Converts degrees to radians.
|
|
4786
4999
|
* @param value - The angle in degrees.
|
|
4787
5000
|
* @returns A FunctionNode representing the RADIANS SQL function.
|
|
4788
5001
|
*/
|
|
4789
|
-
declare const radians: (value: OperandInput$
|
|
5002
|
+
declare const radians: (value: OperandInput$4) => FunctionNode;
|
|
4790
5003
|
/**
|
|
4791
5004
|
* Returns a random number between 0 and 1.
|
|
4792
5005
|
* @returns A FunctionNode representing the RANDOM SQL function.
|
|
@@ -4803,47 +5016,59 @@ declare const rand: () => FunctionNode;
|
|
|
4803
5016
|
* @param decimals - The number of decimal places (optional).
|
|
4804
5017
|
* @returns A FunctionNode representing the ROUND SQL function.
|
|
4805
5018
|
*/
|
|
4806
|
-
declare const round: (value: OperandInput$
|
|
5019
|
+
declare const round: (value: OperandInput$4, decimals?: OperandInput$4) => FunctionNode;
|
|
4807
5020
|
/**
|
|
4808
5021
|
* Returns the sign of a number (-1 for negative, 0 for zero, 1 for positive).
|
|
4809
5022
|
* @param value - The numeric value.
|
|
4810
5023
|
* @returns A FunctionNode representing the SIGN SQL function.
|
|
4811
5024
|
*/
|
|
4812
|
-
declare const sign: (value: OperandInput$
|
|
5025
|
+
declare const sign: (value: OperandInput$4) => FunctionNode;
|
|
4813
5026
|
/**
|
|
4814
5027
|
* Returns the sine of a number (in radians).
|
|
4815
5028
|
* @param value - The numeric value in radians.
|
|
4816
5029
|
* @returns A FunctionNode representing the SIN SQL function.
|
|
4817
5030
|
*/
|
|
4818
|
-
declare const sin: (value: OperandInput$
|
|
5031
|
+
declare const sin: (value: OperandInput$4) => FunctionNode;
|
|
4819
5032
|
/**
|
|
4820
5033
|
* Returns the square root of a number.
|
|
4821
5034
|
* @param value - The numeric value.
|
|
4822
5035
|
* @returns A FunctionNode representing the SQRT SQL function.
|
|
4823
5036
|
*/
|
|
4824
|
-
declare const sqrt: (value: OperandInput$
|
|
5037
|
+
declare const sqrt: (value: OperandInput$4) => FunctionNode;
|
|
4825
5038
|
/**
|
|
4826
5039
|
* Returns the tangent of a number (in radians).
|
|
4827
5040
|
* @param value - The numeric value in radians.
|
|
4828
5041
|
* @returns A FunctionNode representing the TAN SQL function.
|
|
4829
5042
|
*/
|
|
4830
|
-
declare const tan: (value: OperandInput$
|
|
5043
|
+
declare const tan: (value: OperandInput$4) => FunctionNode;
|
|
4831
5044
|
/**
|
|
4832
5045
|
* Truncates a number to a specified number of decimal places without rounding.
|
|
4833
5046
|
* @param value - The numeric value to truncate.
|
|
4834
5047
|
* @param decimals - The number of decimal places (optional).
|
|
4835
5048
|
* @returns A FunctionNode representing the TRUNC SQL function.
|
|
4836
5049
|
*/
|
|
4837
|
-
declare const trunc: (value: OperandInput$
|
|
5050
|
+
declare const trunc: (value: OperandInput$4, decimals?: OperandInput$4) => FunctionNode;
|
|
4838
5051
|
/**
|
|
4839
5052
|
* Alias for trunc. Truncates a number to a specified number of decimal places without rounding.
|
|
4840
5053
|
* @param value - The numeric value to truncate.
|
|
4841
5054
|
* @param decimals - The number of decimal places.
|
|
4842
5055
|
* @returns A FunctionNode representing the TRUNCATE SQL function.
|
|
4843
5056
|
*/
|
|
4844
|
-
declare const truncate: (value: OperandInput$
|
|
5057
|
+
declare const truncate: (value: OperandInput$4, decimals: OperandInput$4) => FunctionNode;
|
|
5058
|
+
/**
|
|
5059
|
+
* Returns the base-2 logarithm of a number.
|
|
5060
|
+
* @param value - The numeric value.
|
|
5061
|
+
* @returns A FunctionNode representing the LOG2 SQL function.
|
|
5062
|
+
*/
|
|
5063
|
+
declare const log2: (value: OperandInput$4) => FunctionNode;
|
|
5064
|
+
/**
|
|
5065
|
+
* Returns the cube root of a number.
|
|
5066
|
+
* @param value - The numeric value.
|
|
5067
|
+
* @returns A FunctionNode representing the CBRT SQL function.
|
|
5068
|
+
*/
|
|
5069
|
+
declare const cbrt: (value: OperandInput$4) => FunctionNode;
|
|
4845
5070
|
|
|
4846
|
-
type OperandInput = OperandNode | ColumnDef | string | number | boolean | null;
|
|
5071
|
+
type OperandInput$3 = OperandNode | ColumnDef | string | number | boolean | null;
|
|
4847
5072
|
/**
|
|
4848
5073
|
* Returns the current local date and time.
|
|
4849
5074
|
* @returns A FunctionNode representing the NOW() SQL function.
|
|
@@ -4864,31 +5089,41 @@ declare const currentTime: () => FunctionNode;
|
|
|
4864
5089
|
* @returns A FunctionNode representing the UTC_NOW() SQL function.
|
|
4865
5090
|
*/
|
|
4866
5091
|
declare const utcNow: () => FunctionNode;
|
|
5092
|
+
/**
|
|
5093
|
+
* Returns the current local time.
|
|
5094
|
+
* @returns A FunctionNode representing the LOCALTIME SQL function.
|
|
5095
|
+
*/
|
|
5096
|
+
declare const localTime: () => FunctionNode;
|
|
5097
|
+
/**
|
|
5098
|
+
* Returns the current local timestamp.
|
|
5099
|
+
* @returns A FunctionNode representing the LOCALTIMESTAMP SQL function.
|
|
5100
|
+
*/
|
|
5101
|
+
declare const localTimestamp: () => FunctionNode;
|
|
4867
5102
|
/**
|
|
4868
5103
|
* Extracts a specified part from a date or datetime value.
|
|
4869
5104
|
* @param part - The date part to extract (e.g., 'YEAR', 'MONTH', 'DAY', 'HOUR', 'MINUTE', 'SECOND').
|
|
4870
5105
|
* @param date - The date or datetime value to extract from.
|
|
4871
5106
|
* @returns A FunctionNode representing the EXTRACT SQL function.
|
|
4872
5107
|
*/
|
|
4873
|
-
declare const extract: (part: OperandInput, date: OperandInput) => FunctionNode;
|
|
5108
|
+
declare const extract: (part: OperandInput$3, date: OperandInput$3) => FunctionNode;
|
|
4874
5109
|
/**
|
|
4875
5110
|
* Extracts the year from a date or datetime value.
|
|
4876
5111
|
* @param date - The date or datetime value.
|
|
4877
5112
|
* @returns A FunctionNode representing the YEAR SQL function.
|
|
4878
5113
|
*/
|
|
4879
|
-
declare const year: (date: OperandInput) => FunctionNode;
|
|
5114
|
+
declare const year: (date: OperandInput$3) => FunctionNode;
|
|
4880
5115
|
/**
|
|
4881
5116
|
* Extracts the month from a date or datetime value.
|
|
4882
5117
|
* @param date - The date or datetime value.
|
|
4883
5118
|
* @returns A FunctionNode representing the MONTH SQL function.
|
|
4884
5119
|
*/
|
|
4885
|
-
declare const month: (date: OperandInput) => FunctionNode;
|
|
5120
|
+
declare const month: (date: OperandInput$3) => FunctionNode;
|
|
4886
5121
|
/**
|
|
4887
5122
|
* Extracts the day of the month from a date or datetime value.
|
|
4888
5123
|
* @param date - The date or datetime value.
|
|
4889
5124
|
* @returns A FunctionNode representing the DAY SQL function.
|
|
4890
5125
|
*/
|
|
4891
|
-
declare const day: (date: OperandInput) => FunctionNode;
|
|
5126
|
+
declare const day: (date: OperandInput$3) => FunctionNode;
|
|
4892
5127
|
/**
|
|
4893
5128
|
* Adds a specified time interval to a date or datetime value.
|
|
4894
5129
|
* @param date - The date or datetime value to add to.
|
|
@@ -4896,7 +5131,7 @@ declare const day: (date: OperandInput) => FunctionNode;
|
|
|
4896
5131
|
* @param unit - The unit type (e.g., 'DAY', 'MONTH', 'YEAR', 'HOUR', 'MINUTE', 'SECOND').
|
|
4897
5132
|
* @returns A FunctionNode representing the DATE_ADD SQL function.
|
|
4898
5133
|
*/
|
|
4899
|
-
declare const dateAdd: (date: OperandInput, interval: OperandInput, unit: OperandInput) => FunctionNode;
|
|
5134
|
+
declare const dateAdd: (date: OperandInput$3, interval: OperandInput$3, unit: OperandInput$3) => FunctionNode;
|
|
4900
5135
|
/**
|
|
4901
5136
|
* Subtracts a specified time interval from a date or datetime value.
|
|
4902
5137
|
* @param date - The date or datetime value to subtract from.
|
|
@@ -4904,21 +5139,21 @@ declare const dateAdd: (date: OperandInput, interval: OperandInput, unit: Operan
|
|
|
4904
5139
|
* @param unit - The unit type (e.g., 'DAY', 'MONTH', 'YEAR', 'HOUR', 'MINUTE', 'SECOND').
|
|
4905
5140
|
* @returns A FunctionNode representing the DATE_SUB SQL function.
|
|
4906
5141
|
*/
|
|
4907
|
-
declare const dateSub: (date: OperandInput, interval: OperandInput, unit: OperandInput) => FunctionNode;
|
|
5142
|
+
declare const dateSub: (date: OperandInput$3, interval: OperandInput$3, unit: OperandInput$3) => FunctionNode;
|
|
4908
5143
|
/**
|
|
4909
5144
|
* Returns the difference between two dates in days.
|
|
4910
5145
|
* @param date1 - The end date.
|
|
4911
5146
|
* @param date2 - The start date.
|
|
4912
5147
|
* @returns A FunctionNode representing the DATE_DIFF SQL function.
|
|
4913
5148
|
*/
|
|
4914
|
-
declare const dateDiff: (date1: OperandInput, date2: OperandInput) => FunctionNode;
|
|
5149
|
+
declare const dateDiff: (date1: OperandInput$3, date2: OperandInput$3) => FunctionNode;
|
|
4915
5150
|
/**
|
|
4916
5151
|
* Converts a date or datetime value to a formatted string.
|
|
4917
5152
|
* @param date - The date or datetime value to format.
|
|
4918
5153
|
* @param format - The format string (dialect-specific).
|
|
4919
5154
|
* @returns A FunctionNode representing the DATE_FORMAT SQL function.
|
|
4920
5155
|
*/
|
|
4921
|
-
declare const dateFormat: (date: OperandInput, format: OperandInput) => FunctionNode;
|
|
5156
|
+
declare const dateFormat: (date: OperandInput$3, format: OperandInput$3) => FunctionNode;
|
|
4922
5157
|
/**
|
|
4923
5158
|
* Returns the current Unix timestamp (seconds since 1970-01-01 00:00:00 UTC).
|
|
4924
5159
|
* @returns A FunctionNode representing the UNIX_TIMESTAMP SQL function.
|
|
@@ -4929,32 +5164,106 @@ declare const unixTimestamp: () => FunctionNode;
|
|
|
4929
5164
|
* @param timestamp - Unix timestamp in seconds.
|
|
4930
5165
|
* @returns A FunctionNode representing the FROM_UNIXTIME SQL function.
|
|
4931
5166
|
*/
|
|
4932
|
-
declare const fromUnixTime: (timestamp: OperandInput) => FunctionNode;
|
|
5167
|
+
declare const fromUnixTime: (timestamp: OperandInput$3) => FunctionNode;
|
|
4933
5168
|
/**
|
|
4934
5169
|
* Returns the last day of the month for a given date.
|
|
4935
5170
|
* @param date - The date value.
|
|
4936
5171
|
* @returns A FunctionNode representing the END_OF_MONTH SQL function.
|
|
4937
5172
|
*/
|
|
4938
|
-
declare const endOfMonth: (date: OperandInput) => FunctionNode;
|
|
5173
|
+
declare const endOfMonth: (date: OperandInput$3) => FunctionNode;
|
|
4939
5174
|
/**
|
|
4940
5175
|
* Returns the index of the weekday for a given date (1 = Sunday, 2 = Monday, etc.).
|
|
4941
5176
|
* @param date - The date value.
|
|
4942
5177
|
* @returns A FunctionNode representing the DAY_OF_WEEK SQL function.
|
|
4943
5178
|
*/
|
|
4944
|
-
declare const dayOfWeek: (date: OperandInput) => FunctionNode;
|
|
5179
|
+
declare const dayOfWeek: (date: OperandInput$3) => FunctionNode;
|
|
4945
5180
|
/**
|
|
4946
5181
|
* Returns the week number of the year for a given date.
|
|
4947
5182
|
* @param date - The date value.
|
|
4948
5183
|
* @returns A FunctionNode representing the WEEK_OF_YEAR SQL function.
|
|
4949
5184
|
*/
|
|
4950
|
-
declare const weekOfYear: (date: OperandInput) => FunctionNode;
|
|
5185
|
+
declare const weekOfYear: (date: OperandInput$3) => FunctionNode;
|
|
4951
5186
|
/**
|
|
4952
5187
|
* Truncates a date or datetime value to a specified precision (e.g., first day of the month/year).
|
|
4953
5188
|
* @param part - The truncation precision (e.g., 'YEAR', 'MONTH', 'DAY').
|
|
4954
5189
|
* @param date - The date or datetime value to truncate.
|
|
4955
5190
|
* @returns A FunctionNode representing the DATE_TRUNC SQL function.
|
|
4956
5191
|
*/
|
|
4957
|
-
declare const dateTrunc: (part: OperandInput, date: OperandInput) => FunctionNode;
|
|
5192
|
+
declare const dateTrunc: (part: OperandInput$3, date: OperandInput$3) => FunctionNode;
|
|
5193
|
+
/**
|
|
5194
|
+
* Returns the difference between two timestamps as an interval.
|
|
5195
|
+
* @param timestamp - The end timestamp.
|
|
5196
|
+
* @param baseTimestamp - The start timestamp (optional, defaults to current time).
|
|
5197
|
+
* @returns A FunctionNode representing the AGE SQL function.
|
|
5198
|
+
*/
|
|
5199
|
+
declare const age: (timestamp: OperandInput$3, baseTimestamp?: OperandInput$3) => FunctionNode;
|
|
5200
|
+
/**
|
|
5201
|
+
* Extracts the hour from a date or datetime value.
|
|
5202
|
+
* @param date - The date or datetime value.
|
|
5203
|
+
* @returns A FunctionNode representing the HOUR SQL function.
|
|
5204
|
+
*/
|
|
5205
|
+
declare const hour: (date: OperandInput$3) => FunctionNode;
|
|
5206
|
+
/**
|
|
5207
|
+
* Extracts the minute from a date or datetime value.
|
|
5208
|
+
* @param date - The date or datetime value.
|
|
5209
|
+
* @returns A FunctionNode representing the MINUTE SQL function.
|
|
5210
|
+
*/
|
|
5211
|
+
declare const minute: (date: OperandInput$3) => FunctionNode;
|
|
5212
|
+
/**
|
|
5213
|
+
* Extracts the second from a date or datetime value.
|
|
5214
|
+
* @param date - The date or datetime value.
|
|
5215
|
+
* @returns A FunctionNode representing the SECOND SQL function.
|
|
5216
|
+
*/
|
|
5217
|
+
declare const second: (date: OperandInput$3) => FunctionNode;
|
|
5218
|
+
/**
|
|
5219
|
+
* Extracts the quarter from a date or datetime value (1-4).
|
|
5220
|
+
* @param date - The date or datetime value.
|
|
5221
|
+
* @returns A FunctionNode representing the QUARTER SQL function.
|
|
5222
|
+
*/
|
|
5223
|
+
declare const quarter: (date: OperandInput$3) => FunctionNode;
|
|
5224
|
+
|
|
5225
|
+
type OperandInput$2 = OperandNode | ColumnDef | string | number | boolean | null;
|
|
5226
|
+
/**
|
|
5227
|
+
* Returns the first non-null value in a list.
|
|
5228
|
+
* @param args - The list of values to check.
|
|
5229
|
+
* @returns A FunctionNode representing the COALESCE SQL function.
|
|
5230
|
+
*/
|
|
5231
|
+
declare const coalesce: (...args: OperandInput$2[]) => FunctionNode;
|
|
5232
|
+
/**
|
|
5233
|
+
* Returns null if the two arguments are equal, otherwise returns the first argument.
|
|
5234
|
+
* @param val1 - The first value.
|
|
5235
|
+
* @param val2 - The second value.
|
|
5236
|
+
* @returns A FunctionNode representing the NULLIF SQL function.
|
|
5237
|
+
*/
|
|
5238
|
+
declare const nullif: (val1: OperandInput$2, val2: OperandInput$2) => FunctionNode;
|
|
5239
|
+
/**
|
|
5240
|
+
* Returns the largest value in a list.
|
|
5241
|
+
* @param args - The list of values to compare.
|
|
5242
|
+
* @returns A FunctionNode representing the GREATEST SQL function.
|
|
5243
|
+
*/
|
|
5244
|
+
declare const greatest: (...args: OperandInput$2[]) => FunctionNode;
|
|
5245
|
+
/**
|
|
5246
|
+
* Returns the smallest value in a list.
|
|
5247
|
+
* @param args - The list of values to compare.
|
|
5248
|
+
* @returns A FunctionNode representing the LEAST SQL function.
|
|
5249
|
+
*/
|
|
5250
|
+
declare const least: (...args: OperandInput$2[]) => FunctionNode;
|
|
5251
|
+
/**
|
|
5252
|
+
* Returns the first argument if it is not null, otherwise returns the second argument.
|
|
5253
|
+
* @param val - The value to check.
|
|
5254
|
+
* @param defaultValue - The default value to return if val is null.
|
|
5255
|
+
* @returns A FunctionNode representing the COALESCE SQL function.
|
|
5256
|
+
*/
|
|
5257
|
+
declare const ifNull: (val: OperandInput$2, defaultValue: OperandInput$2) => FunctionNode;
|
|
5258
|
+
|
|
5259
|
+
type OperandInput$1 = OperandNode | ColumnDef | string | number | boolean | null;
|
|
5260
|
+
declare const jsonLength: (target: OperandInput$1, path?: OperandInput$1) => FunctionNode;
|
|
5261
|
+
declare const jsonSet: (target: OperandInput$1, path: OperandInput$1, value: OperandInput$1) => FunctionNode;
|
|
5262
|
+
declare const jsonArrayAgg: (value: OperandInput$1) => FunctionNode;
|
|
5263
|
+
declare const jsonContains: (target: OperandInput$1, candidate: OperandInput$1, path?: OperandInput$1) => FunctionNode;
|
|
5264
|
+
|
|
5265
|
+
type OperandInput = OperandNode | ColumnDef | string | number | boolean | null;
|
|
5266
|
+
declare const arrayAppend: (array: OperandInput, value: OperandInput) => FunctionNode;
|
|
4958
5267
|
|
|
4959
5268
|
/**
|
|
4960
5269
|
* Browser-compatible implementation of AsyncLocalStorage.
|
|
@@ -5062,6 +5371,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
5062
5371
|
visitCaseExpression(node: CaseExpressionNode): string;
|
|
5063
5372
|
visitWindowFunction(node: WindowFunctionNode): string;
|
|
5064
5373
|
visitCast(node: CastExpressionNode): string;
|
|
5374
|
+
visitCollate(node: CollateExpressionNode): string;
|
|
5065
5375
|
visitAliasRef(node: AliasRefNode): string;
|
|
5066
5376
|
/**
|
|
5067
5377
|
* Prints a binary expression to TypeScript code
|
|
@@ -5143,6 +5453,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
5143
5453
|
*/
|
|
5144
5454
|
private printWindowFunctionOperand;
|
|
5145
5455
|
private printCastOperand;
|
|
5456
|
+
private printCollateOperand;
|
|
5146
5457
|
/**
|
|
5147
5458
|
* Converts method chain lines to inline format
|
|
5148
5459
|
* @param lines - Method chain lines
|
|
@@ -5157,6 +5468,36 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
5157
5468
|
private mapOp;
|
|
5158
5469
|
}
|
|
5159
5470
|
|
|
5471
|
+
/**
|
|
5472
|
+
* Metadata stored on entity instances for ORM internal use
|
|
5473
|
+
* @typeParam TTable - Table definition type
|
|
5474
|
+
*/
|
|
5475
|
+
interface EntityMeta<TTable extends TableDef> {
|
|
5476
|
+
/** Entity context */
|
|
5477
|
+
ctx: EntityContext;
|
|
5478
|
+
/** Table definition */
|
|
5479
|
+
table: TTable;
|
|
5480
|
+
/** Relations that should be loaded lazily */
|
|
5481
|
+
lazyRelations: (keyof RelationMap<TTable>)[];
|
|
5482
|
+
/** Include options for lazy relations */
|
|
5483
|
+
lazyRelationOptions: Map<string, RelationIncludeOptions>;
|
|
5484
|
+
/** Cache for relation promises */
|
|
5485
|
+
relationCache: Map<string, Promise<unknown>>;
|
|
5486
|
+
/** Hydration data for relations */
|
|
5487
|
+
relationHydration: Map<string, Map<string, unknown>>;
|
|
5488
|
+
/** Relation wrapper instances */
|
|
5489
|
+
relationWrappers: Map<string, unknown>;
|
|
5490
|
+
}
|
|
5491
|
+
|
|
5492
|
+
/**
|
|
5493
|
+
* Caches relation loader results across entities of the same type.
|
|
5494
|
+
* @template T - The cache type
|
|
5495
|
+
* @param meta - The entity metadata
|
|
5496
|
+
* @param relationName - The relation name
|
|
5497
|
+
* @param factory - The factory function to create the cache
|
|
5498
|
+
* @returns Promise with the cached relation data
|
|
5499
|
+
*/
|
|
5500
|
+
declare const relationLoaderCache: <T extends Map<string, unknown>>(meta: EntityMeta<TableDef>, relationName: string, factory: () => Promise<T>) => Promise<T>;
|
|
5160
5501
|
/**
|
|
5161
5502
|
* Creates an entity proxy with lazy loading capabilities.
|
|
5162
5503
|
* @template TTable - The table type
|
|
@@ -5167,7 +5508,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
5167
5508
|
* @param lazyRelations - Optional lazy relations
|
|
5168
5509
|
* @returns The entity instance
|
|
5169
5510
|
*/
|
|
5170
|
-
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>;
|
|
5511
|
+
declare const createEntityProxy: <TTable extends TableDef, TLazy extends keyof RelationMap<TTable> = keyof RelationMap<TTable>>(ctx: EntityContext, table: TTable, row: Record<string, unknown>, lazyRelations?: TLazy[], lazyRelationOptions?: Map<string, RelationIncludeOptions>) => EntityInstance<TTable>;
|
|
5171
5512
|
/**
|
|
5172
5513
|
* Creates an entity instance from a database row.
|
|
5173
5514
|
* @template TTable - The table type
|
|
@@ -5178,7 +5519,7 @@ declare const createEntityProxy: <TTable extends TableDef, TLazy extends keyof R
|
|
|
5178
5519
|
* @param lazyRelations - Optional lazy relations
|
|
5179
5520
|
* @returns The entity instance
|
|
5180
5521
|
*/
|
|
5181
|
-
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;
|
|
5522
|
+
declare const createEntityFromRow: <TTable extends TableDef, TResult extends EntityInstance<TTable> = EntityInstance<TTable>>(ctx: EntityContext, table: TTable, row: Record<string, unknown>, lazyRelations?: (keyof RelationMap<TTable>)[], lazyRelationOptions?: Map<string, RelationIncludeOptions>) => TResult;
|
|
5182
5523
|
|
|
5183
5524
|
/**
|
|
5184
5525
|
* An array of database rows, each represented as a record of string keys to unknown values.
|
|
@@ -5192,7 +5533,7 @@ type Rows$3 = Record<string, unknown>[];
|
|
|
5192
5533
|
* @param relation - The has-many relation definition.
|
|
5193
5534
|
* @returns A promise resolving to a map of root keys to arrays of related rows.
|
|
5194
5535
|
*/
|
|
5195
|
-
declare const loadHasManyRelation: (ctx: EntityContext, rootTable: TableDef,
|
|
5536
|
+
declare const loadHasManyRelation: (ctx: EntityContext, rootTable: TableDef, relationName: string, relation: HasManyRelation, options?: RelationIncludeOptions) => Promise<Map<string, Rows$3>>;
|
|
5196
5537
|
/**
|
|
5197
5538
|
* Loads related entities for a has-one relation in batch.
|
|
5198
5539
|
* @param ctx - The entity context.
|
|
@@ -5201,7 +5542,7 @@ declare const loadHasManyRelation: (ctx: EntityContext, rootTable: TableDef, _re
|
|
|
5201
5542
|
* @param relation - The has-one relation definition.
|
|
5202
5543
|
* @returns A promise resolving to a map of root keys to single related rows.
|
|
5203
5544
|
*/
|
|
5204
|
-
declare const loadHasOneRelation: (ctx: EntityContext, rootTable: TableDef,
|
|
5545
|
+
declare const loadHasOneRelation: (ctx: EntityContext, rootTable: TableDef, relationName: string, relation: HasOneRelation, options?: RelationIncludeOptions) => Promise<Map<string, Record<string, unknown>>>;
|
|
5205
5546
|
/**
|
|
5206
5547
|
* Loads related entities for a belongs-to relation in batch.
|
|
5207
5548
|
* @param ctx - The entity context.
|
|
@@ -5210,7 +5551,7 @@ declare const loadHasOneRelation: (ctx: EntityContext, rootTable: TableDef, _rel
|
|
|
5210
5551
|
* @param relation - The belongs-to relation definition.
|
|
5211
5552
|
* @returns A promise resolving to a map of foreign keys to single related rows.
|
|
5212
5553
|
*/
|
|
5213
|
-
declare const loadBelongsToRelation: (ctx: EntityContext, rootTable: TableDef,
|
|
5554
|
+
declare const loadBelongsToRelation: (ctx: EntityContext, rootTable: TableDef, relationName: string, relation: BelongsToRelation, options?: RelationIncludeOptions) => Promise<Map<string, Record<string, unknown>>>;
|
|
5214
5555
|
/**
|
|
5215
5556
|
* Loads related entities for a belongs-to-many relation in batch, including pivot data.
|
|
5216
5557
|
* @param ctx - The entity context.
|
|
@@ -5219,26 +5560,7 @@ declare const loadBelongsToRelation: (ctx: EntityContext, rootTable: TableDef, _
|
|
|
5219
5560
|
* @param relation - The belongs-to-many relation definition.
|
|
5220
5561
|
* @returns A promise resolving to a map of root keys to arrays of related rows with pivot data.
|
|
5221
5562
|
*/
|
|
5222
|
-
declare const loadBelongsToManyRelation: (ctx: EntityContext, rootTable: TableDef,
|
|
5223
|
-
|
|
5224
|
-
/**
|
|
5225
|
-
* Metadata stored on entity instances for ORM internal use
|
|
5226
|
-
* @typeParam TTable - Table definition type
|
|
5227
|
-
*/
|
|
5228
|
-
interface EntityMeta<TTable extends TableDef> {
|
|
5229
|
-
/** Entity context */
|
|
5230
|
-
ctx: EntityContext;
|
|
5231
|
-
/** Table definition */
|
|
5232
|
-
table: TTable;
|
|
5233
|
-
/** Relations that should be loaded lazily */
|
|
5234
|
-
lazyRelations: (keyof RelationMap<TTable>)[];
|
|
5235
|
-
/** Cache for relation promises */
|
|
5236
|
-
relationCache: Map<string, Promise<unknown>>;
|
|
5237
|
-
/** Hydration data for relations */
|
|
5238
|
-
relationHydration: Map<string, Map<string, unknown>>;
|
|
5239
|
-
/** Relation wrapper instances */
|
|
5240
|
-
relationWrappers: Map<string, unknown>;
|
|
5241
|
-
}
|
|
5563
|
+
declare const loadBelongsToManyRelation: (ctx: EntityContext, rootTable: TableDef, relationName: string, relation: BelongsToManyRelation, options?: RelationIncludeOptions) => Promise<Map<string, Rows$3>>;
|
|
5242
5564
|
|
|
5243
5565
|
type Rows$2 = Record<string, unknown>[];
|
|
5244
5566
|
/**
|
|
@@ -5282,6 +5604,14 @@ declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChi
|
|
|
5282
5604
|
* @returns Array of child entities
|
|
5283
5605
|
*/
|
|
5284
5606
|
getItems(): TChild[];
|
|
5607
|
+
/**
|
|
5608
|
+
* Array-compatible length for testing frameworks.
|
|
5609
|
+
*/
|
|
5610
|
+
get length(): number;
|
|
5611
|
+
/**
|
|
5612
|
+
* Enables iteration over the collection like an array.
|
|
5613
|
+
*/
|
|
5614
|
+
[Symbol.iterator](): Iterator<TChild>;
|
|
5285
5615
|
/**
|
|
5286
5616
|
* Adds a new child entity to the collection.
|
|
5287
5617
|
* @param data - Partial data for the new entity
|
|
@@ -5312,7 +5642,13 @@ declare class DefaultHasManyCollection<TChild> implements HasManyCollection<TChi
|
|
|
5312
5642
|
}
|
|
5313
5643
|
|
|
5314
5644
|
type Rows$1 = Record<string, unknown>;
|
|
5315
|
-
|
|
5645
|
+
/**
|
|
5646
|
+
* Default implementation of a belongs-to reference.
|
|
5647
|
+
* Manages a reference to a parent entity from a child entity through a foreign key.
|
|
5648
|
+
*
|
|
5649
|
+
* @template TParent The type of the parent entity.
|
|
5650
|
+
*/
|
|
5651
|
+
declare class DefaultBelongsToReference<TParent extends object> implements BelongsToReferenceApi<TParent> {
|
|
5316
5652
|
private readonly ctx;
|
|
5317
5653
|
private readonly meta;
|
|
5318
5654
|
private readonly root;
|
|
@@ -5324,6 +5660,17 @@ declare class DefaultBelongsToReference<TParent> implements BelongsToReference<T
|
|
|
5324
5660
|
private readonly targetKey;
|
|
5325
5661
|
private loaded;
|
|
5326
5662
|
private current;
|
|
5663
|
+
/**
|
|
5664
|
+
* @param ctx The entity context for tracking changes.
|
|
5665
|
+
* @param meta Metadata for the child entity.
|
|
5666
|
+
* @param root The child entity instance (carrying the foreign key).
|
|
5667
|
+
* @param relationName The name of the relation.
|
|
5668
|
+
* @param relation Relation definition.
|
|
5669
|
+
* @param rootTable Table definition of the child entity.
|
|
5670
|
+
* @param loader Function to load the parent entity.
|
|
5671
|
+
* @param createEntity Function to create entity instances from rows.
|
|
5672
|
+
* @param targetKey The primary key of the target (parent) table.
|
|
5673
|
+
*/
|
|
5327
5674
|
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);
|
|
5328
5675
|
load(): Promise<TParent | null>;
|
|
5329
5676
|
get(): TParent | null;
|
|
@@ -5334,6 +5681,13 @@ declare class DefaultBelongsToReference<TParent> implements BelongsToReference<T
|
|
|
5334
5681
|
}
|
|
5335
5682
|
|
|
5336
5683
|
type Rows = Record<string, unknown>[];
|
|
5684
|
+
/**
|
|
5685
|
+
* Default implementation of a many-to-many collection.
|
|
5686
|
+
* Manages the relationship between two entities through a pivot table.
|
|
5687
|
+
* Supports lazy loading, attaching/detaching entities, and syncing by IDs.
|
|
5688
|
+
*
|
|
5689
|
+
* @template TTarget The type of the target entities in the collection.
|
|
5690
|
+
*/
|
|
5337
5691
|
declare class DefaultManyToManyCollection<TTarget> implements ManyToManyCollection<TTarget> {
|
|
5338
5692
|
private readonly ctx;
|
|
5339
5693
|
private readonly meta;
|
|
@@ -5346,11 +5700,53 @@ declare class DefaultManyToManyCollection<TTarget> implements ManyToManyCollecti
|
|
|
5346
5700
|
private readonly localKey;
|
|
5347
5701
|
private loaded;
|
|
5348
5702
|
private items;
|
|
5703
|
+
/**
|
|
5704
|
+
* @param ctx The entity context for tracking changes.
|
|
5705
|
+
* @param meta Metadata for the root entity.
|
|
5706
|
+
* @param root The root entity instance.
|
|
5707
|
+
* @param relationName The name of the relation.
|
|
5708
|
+
* @param relation Relation definition.
|
|
5709
|
+
* @param rootTable Table definition of the root entity.
|
|
5710
|
+
* @param loader Function to load the collection items.
|
|
5711
|
+
* @param createEntity Function to create entity instances from rows.
|
|
5712
|
+
* @param localKey The local key used for joining.
|
|
5713
|
+
*/
|
|
5349
5714
|
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);
|
|
5715
|
+
/**
|
|
5716
|
+
* Loads the collection items if not already loaded.
|
|
5717
|
+
* @returns A promise that resolves to the array of target entities.
|
|
5718
|
+
*/
|
|
5350
5719
|
load(): Promise<TTarget[]>;
|
|
5720
|
+
/**
|
|
5721
|
+
* Returns the currently loaded items.
|
|
5722
|
+
* @returns Array of target entities.
|
|
5723
|
+
*/
|
|
5351
5724
|
getItems(): TTarget[];
|
|
5725
|
+
/**
|
|
5726
|
+
* Array-compatible length for testing frameworks.
|
|
5727
|
+
*/
|
|
5728
|
+
get length(): number;
|
|
5729
|
+
/**
|
|
5730
|
+
* Enables iteration over the collection like an array.
|
|
5731
|
+
*/
|
|
5732
|
+
[Symbol.iterator](): Iterator<TTarget>;
|
|
5733
|
+
/**
|
|
5734
|
+
* Attaches an entity to the collection.
|
|
5735
|
+
* Registers an 'attach' change in the entity context.
|
|
5736
|
+
* @param target Entity instance or its primary key value.
|
|
5737
|
+
*/
|
|
5352
5738
|
attach(target: TTarget | number | string): void;
|
|
5739
|
+
/**
|
|
5740
|
+
* Detaches an entity from the collection.
|
|
5741
|
+
* Registers a 'detach' change in the entity context.
|
|
5742
|
+
* @param target Entity instance or its primary key value.
|
|
5743
|
+
*/
|
|
5353
5744
|
detach(target: TTarget | number | string): void;
|
|
5745
|
+
/**
|
|
5746
|
+
* Syncs the collection with a list of IDs.
|
|
5747
|
+
* Attaches missing IDs and detaches IDs not in the list.
|
|
5748
|
+
* @param ids Array of primary key values to sync with.
|
|
5749
|
+
*/
|
|
5354
5750
|
syncByIds(ids: (number | string)[]): Promise<void>;
|
|
5355
5751
|
private ensureEntity;
|
|
5356
5752
|
private extractId;
|
|
@@ -5560,7 +5956,18 @@ declare const getTableDefFromEntity: <TTable extends TableDef = TableDef>(ctor:
|
|
|
5560
5956
|
* @param ctor - The entity constructor.
|
|
5561
5957
|
* @returns A select query builder for the entity.
|
|
5562
5958
|
*/
|
|
5563
|
-
|
|
5959
|
+
type NonFunctionKeys<T> = {
|
|
5960
|
+
[K in keyof T]-?: T[K] extends (...args: unknown[]) => unknown ? never : K;
|
|
5961
|
+
}[keyof T];
|
|
5962
|
+
type RelationKeys<TEntity extends object> = Exclude<NonFunctionKeys<TEntity>, SelectableKeys<TEntity>> & string;
|
|
5963
|
+
type EntityTable<TEntity extends object> = Omit<TableDef<{
|
|
5964
|
+
[K in SelectableKeys<TEntity>]: ColumnDef;
|
|
5965
|
+
}>, 'relations'> & {
|
|
5966
|
+
relations: {
|
|
5967
|
+
[K in RelationKeys<TEntity>]: NonNullable<TEntity[K]> extends HasManyCollection<infer TChild> ? HasManyRelation<EntityTable<NonNullable<TChild> & object>> : NonNullable<TEntity[K]> extends ManyToManyCollection<infer TTarget> ? BelongsToManyRelation<EntityTable<NonNullable<TTarget> & object>> : NonNullable<TEntity[K]> extends HasOneReference<infer TChild> ? HasOneRelation<EntityTable<NonNullable<TChild> & object>> : NonNullable<TEntity[K]> extends BelongsToReference<infer TParent> ? BelongsToRelation<EntityTable<NonNullable<TParent> & object>> : NonNullable<TEntity[K]> extends object ? BelongsToRelation<EntityTable<NonNullable<TEntity[K]> & object>> : never;
|
|
5968
|
+
};
|
|
5969
|
+
};
|
|
5970
|
+
declare const selectFromEntity: <TEntity extends object>(ctor: EntityConstructor<TEntity>) => SelectQueryBuilder<unknown, EntityTable<TEntity>>;
|
|
5564
5971
|
/**
|
|
5565
5972
|
* Public API: opt-in ergonomic entity reference (decorator-level).
|
|
5566
5973
|
*
|
|
@@ -5626,6 +6033,11 @@ interface PostgresClientLike {
|
|
|
5626
6033
|
rows: Array<Record<string, unknown>>;
|
|
5627
6034
|
}>;
|
|
5628
6035
|
}
|
|
6036
|
+
/**
|
|
6037
|
+
* Creates a database executor for PostgreSQL.
|
|
6038
|
+
* @param client A PostgreSQL client or pool instance.
|
|
6039
|
+
* @returns A DbExecutor implementation for Postgres.
|
|
6040
|
+
*/
|
|
5629
6041
|
declare function createPostgresExecutor(client: PostgresClientLike): DbExecutor;
|
|
5630
6042
|
|
|
5631
6043
|
interface MysqlClientLike {
|
|
@@ -5634,6 +6046,11 @@ interface MysqlClientLike {
|
|
|
5634
6046
|
commit?(): Promise<void>;
|
|
5635
6047
|
rollback?(): Promise<void>;
|
|
5636
6048
|
}
|
|
6049
|
+
/**
|
|
6050
|
+
* Creates a database executor for MySQL.
|
|
6051
|
+
* @param client A MySQL client instance.
|
|
6052
|
+
* @returns A DbExecutor implementation for MySQL.
|
|
6053
|
+
*/
|
|
5637
6054
|
declare function createMysqlExecutor(client: MysqlClientLike): DbExecutor;
|
|
5638
6055
|
|
|
5639
6056
|
interface SqliteClientLike {
|
|
@@ -5643,6 +6060,11 @@ interface SqliteClientLike {
|
|
|
5643
6060
|
commitTransaction?(): Promise<void>;
|
|
5644
6061
|
rollbackTransaction?(): Promise<void>;
|
|
5645
6062
|
}
|
|
6063
|
+
/**
|
|
6064
|
+
* Creates a database executor for SQLite.
|
|
6065
|
+
* @param client A SQLite client instance.
|
|
6066
|
+
* @returns A DbExecutor implementation for SQLite.
|
|
6067
|
+
*/
|
|
5646
6068
|
declare function createSqliteExecutor(client: SqliteClientLike): DbExecutor;
|
|
5647
6069
|
|
|
5648
6070
|
interface MssqlClientLike {
|
|
@@ -5653,6 +6075,11 @@ interface MssqlClientLike {
|
|
|
5653
6075
|
commit?(): Promise<void>;
|
|
5654
6076
|
rollback?(): Promise<void>;
|
|
5655
6077
|
}
|
|
6078
|
+
/**
|
|
6079
|
+
* Creates a database executor for Microsoft SQL Server.
|
|
6080
|
+
* @param client A SQL Server client instance.
|
|
6081
|
+
* @returns A DbExecutor implementation for MSSQL.
|
|
6082
|
+
*/
|
|
5656
6083
|
declare function createMssqlExecutor(client: MssqlClientLike): DbExecutor;
|
|
5657
6084
|
interface TediousColumn {
|
|
5658
6085
|
metadata: {
|
|
@@ -5712,4 +6139,4 @@ type PooledExecutorFactoryOptions<TConn> = {
|
|
|
5712
6139
|
*/
|
|
5713
6140
|
declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
|
|
5714
6141
|
|
|
5715
|
-
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 Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type 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 SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, 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, countAll, 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, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, groupConcat, gt, gte, hasMany, hasOne, hydrateRows, inList, inSubquery, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonPath, jsonify, 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 };
|
|
6142
|
+
export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, 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 HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, type IntrospectOptions, type JsonPathNode, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, 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 SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, denseRank, diffSchema, div, endOfMonth, entityRef, eq, esel, executeHydrated, executeHydratedWithContexts, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, second, sel, selectFromEntity, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|