metal-orm 1.0.81 → 1.0.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +58 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -2
- package/dist/index.d.ts +21 -2
- package/dist/index.js +57 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/codegen/typescript.ts +40 -29
- package/src/core/ast/expression-nodes.ts +32 -21
- package/src/core/ast/expression-visitor.ts +6 -1
- package/src/core/ast/expression.ts +1 -0
- package/src/core/ast/param-proxy.ts +50 -0
- package/src/core/dialect/abstract.ts +12 -10
- package/src/openapi/query-parameters.ts +1 -0
- package/src/query-builder/relation-filter-utils.ts +1 -0
package/dist/index.d.cts
CHANGED
|
@@ -656,6 +656,14 @@ interface LiteralNode {
|
|
|
656
656
|
/** The literal value (string, number, boolean, Date, or null) */
|
|
657
657
|
value: string | number | boolean | Date | null;
|
|
658
658
|
}
|
|
659
|
+
/**
|
|
660
|
+
* AST node representing a named parameter placeholder
|
|
661
|
+
*/
|
|
662
|
+
interface ParamNode {
|
|
663
|
+
type: 'Param';
|
|
664
|
+
/** Stable parameter name */
|
|
665
|
+
name: string;
|
|
666
|
+
}
|
|
659
667
|
/**
|
|
660
668
|
* AST node representing a reference to a SELECT alias (for ORDER BY / GROUP BY).
|
|
661
669
|
*/
|
|
@@ -786,7 +794,7 @@ interface ArithmeticExpressionNode {
|
|
|
786
794
|
/**
|
|
787
795
|
* Union type representing any operand that can be used in expressions
|
|
788
796
|
*/
|
|
789
|
-
type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode | ArithmeticExpressionNode | BitwiseExpressionNode | CollateExpressionNode;
|
|
797
|
+
type OperandNode = AliasRefNode | ColumnNode | LiteralNode | ParamNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode | ArithmeticExpressionNode | BitwiseExpressionNode | CollateExpressionNode;
|
|
790
798
|
declare const isOperandNode: (node: unknown) => node is OperandNode;
|
|
791
799
|
declare const isFunctionNode: (node: unknown) => node is FunctionNode;
|
|
792
800
|
declare const isCaseExpressionNode: (node: unknown) => node is CaseExpressionNode;
|
|
@@ -1446,6 +1454,7 @@ interface ExpressionVisitor<R> {
|
|
|
1446
1454
|
interface OperandVisitor<R> {
|
|
1447
1455
|
visitColumn?(node: ColumnNode): R;
|
|
1448
1456
|
visitLiteral?(node: LiteralNode): R;
|
|
1457
|
+
visitParam?(node: ParamNode): R;
|
|
1449
1458
|
visitFunction?(node: FunctionNode): R;
|
|
1450
1459
|
visitJsonPath?(node: JsonPathNode): R;
|
|
1451
1460
|
visitScalarSubquery?(node: ScalarSubqueryNode): R;
|
|
@@ -1486,6 +1495,14 @@ declare const visitExpression: <R>(node: ExpressionNode, visitor: ExpressionVisi
|
|
|
1486
1495
|
*/
|
|
1487
1496
|
declare const visitOperand: <R>(node: OperandNode, visitor: OperandVisitor<R>) => R;
|
|
1488
1497
|
|
|
1498
|
+
type ParamProxy = ParamNode & {
|
|
1499
|
+
[key: string]: ParamProxy;
|
|
1500
|
+
};
|
|
1501
|
+
type ParamProxyRoot = {
|
|
1502
|
+
[key: string]: ParamProxy;
|
|
1503
|
+
};
|
|
1504
|
+
declare const createParamProxy: () => ParamProxyRoot;
|
|
1505
|
+
|
|
1489
1506
|
/**
|
|
1490
1507
|
* Adapts a schema ColumnDef to an AST-friendly ColumnRef.
|
|
1491
1508
|
*/
|
|
@@ -6326,6 +6343,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
6326
6343
|
visitArithmeticExpression(arithExpr: ArithmeticExpressionNode): string;
|
|
6327
6344
|
visitColumn(node: ColumnNode): string;
|
|
6328
6345
|
visitLiteral(node: LiteralNode): string;
|
|
6346
|
+
visitParam(node: ParamNode): string;
|
|
6329
6347
|
visitFunction(node: FunctionNode): string;
|
|
6330
6348
|
visitJsonPath(node: JsonPathNode): string;
|
|
6331
6349
|
visitScalarSubquery(node: ScalarSubqueryNode): string;
|
|
@@ -6383,6 +6401,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
6383
6401
|
* @returns TypeScript code representation
|
|
6384
6402
|
*/
|
|
6385
6403
|
private printLiteralOperand;
|
|
6404
|
+
private printParamOperand;
|
|
6386
6405
|
/**
|
|
6387
6406
|
* Prints a function operand to TypeScript code
|
|
6388
6407
|
* @param fn - Function node
|
|
@@ -7187,4 +7206,4 @@ type PooledExecutorFactoryOptions<TConn> = {
|
|
|
7187
7206
|
*/
|
|
7188
7207
|
declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
|
|
7189
7208
|
|
|
7190
|
-
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 ColumnSchemaOptions, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, type InputRelationMode, type InputSchemaMode, type InputSchemaOptions, InsertQueryBuilder, InterceptorPipeline, type IntrospectOptions, type JsonPathNode, type JsonSchemaFormat, type JsonSchemaProperty, type JsonSchemaType, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OpenApiParameter, type OpenApiSchema, type OpenApiSchemaBundle, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type OutputSchemaOptions, type PaginatedResult, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type SaveGraphSessionOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaExtractionContext, type SchemaGenerateResult, type SchemaIntrospector, type SchemaOptions, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterParameters, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, entityRefs, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractSchema, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, getTemporalFormat, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, mapColumnType, mapRelationType, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|
|
7209
|
+
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 ColumnSchemaOptions, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, type InputRelationMode, type InputSchemaMode, type InputSchemaOptions, InsertQueryBuilder, InterceptorPipeline, type IntrospectOptions, type JsonPathNode, type JsonSchemaFormat, type JsonSchemaProperty, type JsonSchemaType, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OpenApiParameter, type OpenApiSchema, type OpenApiSchemaBundle, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type OutputSchemaOptions, type PaginatedResult, type ParamNode, type ParamProxy, type ParamProxyRoot, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type SaveGraphSessionOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaExtractionContext, type SchemaGenerateResult, type SchemaIntrospector, type SchemaOptions, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterParameters, 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, createParamProxy, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, entityRefs, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractSchema, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, getTemporalFormat, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, mapColumnType, mapRelationType, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|
package/dist/index.d.ts
CHANGED
|
@@ -656,6 +656,14 @@ interface LiteralNode {
|
|
|
656
656
|
/** The literal value (string, number, boolean, Date, or null) */
|
|
657
657
|
value: string | number | boolean | Date | null;
|
|
658
658
|
}
|
|
659
|
+
/**
|
|
660
|
+
* AST node representing a named parameter placeholder
|
|
661
|
+
*/
|
|
662
|
+
interface ParamNode {
|
|
663
|
+
type: 'Param';
|
|
664
|
+
/** Stable parameter name */
|
|
665
|
+
name: string;
|
|
666
|
+
}
|
|
659
667
|
/**
|
|
660
668
|
* AST node representing a reference to a SELECT alias (for ORDER BY / GROUP BY).
|
|
661
669
|
*/
|
|
@@ -786,7 +794,7 @@ interface ArithmeticExpressionNode {
|
|
|
786
794
|
/**
|
|
787
795
|
* Union type representing any operand that can be used in expressions
|
|
788
796
|
*/
|
|
789
|
-
type OperandNode = AliasRefNode | ColumnNode | LiteralNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode | ArithmeticExpressionNode | BitwiseExpressionNode | CollateExpressionNode;
|
|
797
|
+
type OperandNode = AliasRefNode | ColumnNode | LiteralNode | ParamNode | FunctionNode | JsonPathNode | ScalarSubqueryNode | CaseExpressionNode | CastExpressionNode | WindowFunctionNode | ArithmeticExpressionNode | BitwiseExpressionNode | CollateExpressionNode;
|
|
790
798
|
declare const isOperandNode: (node: unknown) => node is OperandNode;
|
|
791
799
|
declare const isFunctionNode: (node: unknown) => node is FunctionNode;
|
|
792
800
|
declare const isCaseExpressionNode: (node: unknown) => node is CaseExpressionNode;
|
|
@@ -1446,6 +1454,7 @@ interface ExpressionVisitor<R> {
|
|
|
1446
1454
|
interface OperandVisitor<R> {
|
|
1447
1455
|
visitColumn?(node: ColumnNode): R;
|
|
1448
1456
|
visitLiteral?(node: LiteralNode): R;
|
|
1457
|
+
visitParam?(node: ParamNode): R;
|
|
1449
1458
|
visitFunction?(node: FunctionNode): R;
|
|
1450
1459
|
visitJsonPath?(node: JsonPathNode): R;
|
|
1451
1460
|
visitScalarSubquery?(node: ScalarSubqueryNode): R;
|
|
@@ -1486,6 +1495,14 @@ declare const visitExpression: <R>(node: ExpressionNode, visitor: ExpressionVisi
|
|
|
1486
1495
|
*/
|
|
1487
1496
|
declare const visitOperand: <R>(node: OperandNode, visitor: OperandVisitor<R>) => R;
|
|
1488
1497
|
|
|
1498
|
+
type ParamProxy = ParamNode & {
|
|
1499
|
+
[key: string]: ParamProxy;
|
|
1500
|
+
};
|
|
1501
|
+
type ParamProxyRoot = {
|
|
1502
|
+
[key: string]: ParamProxy;
|
|
1503
|
+
};
|
|
1504
|
+
declare const createParamProxy: () => ParamProxyRoot;
|
|
1505
|
+
|
|
1489
1506
|
/**
|
|
1490
1507
|
* Adapts a schema ColumnDef to an AST-friendly ColumnRef.
|
|
1491
1508
|
*/
|
|
@@ -6326,6 +6343,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
6326
6343
|
visitArithmeticExpression(arithExpr: ArithmeticExpressionNode): string;
|
|
6327
6344
|
visitColumn(node: ColumnNode): string;
|
|
6328
6345
|
visitLiteral(node: LiteralNode): string;
|
|
6346
|
+
visitParam(node: ParamNode): string;
|
|
6329
6347
|
visitFunction(node: FunctionNode): string;
|
|
6330
6348
|
visitJsonPath(node: JsonPathNode): string;
|
|
6331
6349
|
visitScalarSubquery(node: ScalarSubqueryNode): string;
|
|
@@ -6383,6 +6401,7 @@ declare class TypeScriptGenerator implements ExpressionVisitor<string>, OperandV
|
|
|
6383
6401
|
* @returns TypeScript code representation
|
|
6384
6402
|
*/
|
|
6385
6403
|
private printLiteralOperand;
|
|
6404
|
+
private printParamOperand;
|
|
6386
6405
|
/**
|
|
6387
6406
|
* Prints a function operand to TypeScript code
|
|
6388
6407
|
* @param fn - Function node
|
|
@@ -7187,4 +7206,4 @@ type PooledExecutorFactoryOptions<TConn> = {
|
|
|
7187
7206
|
*/
|
|
7188
7207
|
declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
|
|
7189
7208
|
|
|
7190
|
-
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 ColumnSchemaOptions, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, type InputRelationMode, type InputSchemaMode, type InputSchemaOptions, InsertQueryBuilder, InterceptorPipeline, type IntrospectOptions, type JsonPathNode, type JsonSchemaFormat, type JsonSchemaProperty, type JsonSchemaType, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OpenApiParameter, type OpenApiSchema, type OpenApiSchemaBundle, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type OutputSchemaOptions, type PaginatedResult, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type SaveGraphSessionOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaExtractionContext, type SchemaGenerateResult, type SchemaIntrospector, type SchemaOptions, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterParameters, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, entityRefs, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractSchema, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, getTemporalFormat, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, mapColumnType, mapRelationType, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|
|
7209
|
+
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 ColumnSchemaOptions, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, type InputRelationMode, type InputSchemaMode, type InputSchemaOptions, InsertQueryBuilder, InterceptorPipeline, type IntrospectOptions, type JsonPathNode, type JsonSchemaFormat, type JsonSchemaProperty, type JsonSchemaType, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OpenApiParameter, type OpenApiSchema, type OpenApiSchemaBundle, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type OutputSchemaOptions, type PaginatedResult, type ParamNode, type ParamProxy, type ParamProxyRoot, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryContext, type QueryInterceptor, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type SaveGraphSessionOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaExtractionContext, type SchemaGenerateResult, type SchemaIntrospector, type SchemaOptions, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, buildFilterParameters, 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, createParamProxy, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, entityRefs, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, extractSchema, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, getTemporalFormat, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, mapColumnType, mapRelationType, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, schemaToJson, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
|
package/dist/index.js
CHANGED
|
@@ -360,6 +360,7 @@ var operandTypes = /* @__PURE__ */ new Set([
|
|
|
360
360
|
"AliasRef",
|
|
361
361
|
"Column",
|
|
362
362
|
"Literal",
|
|
363
|
+
"Param",
|
|
363
364
|
"Function",
|
|
364
365
|
"JsonPath",
|
|
365
366
|
"ScalarSubquery",
|
|
@@ -799,6 +800,9 @@ var visitOperand = (node, visitor) => {
|
|
|
799
800
|
case "Literal":
|
|
800
801
|
if (visitor.visitLiteral) return visitor.visitLiteral(node);
|
|
801
802
|
break;
|
|
803
|
+
case "Param":
|
|
804
|
+
if (visitor.visitParam) return visitor.visitParam(node);
|
|
805
|
+
break;
|
|
802
806
|
case "Function":
|
|
803
807
|
if (visitor.visitFunction) return visitor.visitFunction(node);
|
|
804
808
|
break;
|
|
@@ -830,6 +834,47 @@ var visitOperand = (node, visitor) => {
|
|
|
830
834
|
return unsupportedOperand(node);
|
|
831
835
|
};
|
|
832
836
|
|
|
837
|
+
// src/core/ast/param-proxy.ts
|
|
838
|
+
var buildParamProxy = (name) => {
|
|
839
|
+
const target = { type: "Param", name };
|
|
840
|
+
return new Proxy(target, {
|
|
841
|
+
get(t, prop, receiver) {
|
|
842
|
+
if (prop === "then") return void 0;
|
|
843
|
+
if (typeof prop === "symbol") {
|
|
844
|
+
return Reflect.get(t, prop, receiver);
|
|
845
|
+
}
|
|
846
|
+
if (typeof prop === "string" && prop.startsWith("$")) {
|
|
847
|
+
const trimmed = prop.slice(1);
|
|
848
|
+
const nextName2 = name ? `${name}.${trimmed}` : trimmed;
|
|
849
|
+
return buildParamProxy(nextName2);
|
|
850
|
+
}
|
|
851
|
+
if (prop in t) {
|
|
852
|
+
return t[prop];
|
|
853
|
+
}
|
|
854
|
+
const nextName = name ? `${name}.${prop}` : prop;
|
|
855
|
+
return buildParamProxy(nextName);
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
};
|
|
859
|
+
var createParamProxy = () => {
|
|
860
|
+
const target = {};
|
|
861
|
+
return new Proxy(target, {
|
|
862
|
+
get(t, prop, receiver) {
|
|
863
|
+
if (prop === "then") return void 0;
|
|
864
|
+
if (typeof prop === "symbol") {
|
|
865
|
+
return Reflect.get(t, prop, receiver);
|
|
866
|
+
}
|
|
867
|
+
if (typeof prop === "string" && prop.startsWith("$")) {
|
|
868
|
+
return buildParamProxy(prop.slice(1));
|
|
869
|
+
}
|
|
870
|
+
if (prop in t) {
|
|
871
|
+
return t[prop];
|
|
872
|
+
}
|
|
873
|
+
return buildParamProxy(String(prop));
|
|
874
|
+
}
|
|
875
|
+
});
|
|
876
|
+
};
|
|
877
|
+
|
|
833
878
|
// src/core/ast/adapters.ts
|
|
834
879
|
var hasAlias = (obj) => typeof obj === "object" && obj !== null && "alias" in obj;
|
|
835
880
|
var toColumnRef = (col2) => ({
|
|
@@ -1539,6 +1584,7 @@ var Dialect = class _Dialect {
|
|
|
1539
1584
|
}
|
|
1540
1585
|
registerDefaultOperandCompilers() {
|
|
1541
1586
|
this.registerOperandCompiler("Literal", (literal, ctx) => ctx.addParameter(literal.value));
|
|
1587
|
+
this.registerOperandCompiler("Param", (_param, ctx) => ctx.addParameter(null));
|
|
1542
1588
|
this.registerOperandCompiler("AliasRef", (alias, _ctx) => {
|
|
1543
1589
|
void _ctx;
|
|
1544
1590
|
return this.quoteIdentifier(alias.name);
|
|
@@ -4062,6 +4108,7 @@ var collectFromOperand = (node, collector) => {
|
|
|
4062
4108
|
break;
|
|
4063
4109
|
case "Literal":
|
|
4064
4110
|
case "AliasRef":
|
|
4111
|
+
case "Param":
|
|
4065
4112
|
break;
|
|
4066
4113
|
default:
|
|
4067
4114
|
break;
|
|
@@ -7328,6 +7375,7 @@ var collectFilterColumns = (expr, table, rootTables) => {
|
|
|
7328
7375
|
}
|
|
7329
7376
|
case "AliasRef":
|
|
7330
7377
|
case "Literal":
|
|
7378
|
+
case "Param":
|
|
7331
7379
|
return;
|
|
7332
7380
|
default:
|
|
7333
7381
|
return;
|
|
@@ -11367,6 +11415,7 @@ var TypeScriptGenerator = class {
|
|
|
11367
11415
|
case "WindowFunction":
|
|
11368
11416
|
case "Cast":
|
|
11369
11417
|
case "Collate":
|
|
11418
|
+
case "Param":
|
|
11370
11419
|
return this.printOperand(term);
|
|
11371
11420
|
default:
|
|
11372
11421
|
return this.printExpression(term);
|
|
@@ -11411,6 +11460,9 @@ var TypeScriptGenerator = class {
|
|
|
11411
11460
|
visitLiteral(node) {
|
|
11412
11461
|
return this.printLiteralOperand(node);
|
|
11413
11462
|
}
|
|
11463
|
+
visitParam(node) {
|
|
11464
|
+
return this.printParamOperand(node);
|
|
11465
|
+
}
|
|
11414
11466
|
visitFunction(node) {
|
|
11415
11467
|
return this.printFunctionOperand(node);
|
|
11416
11468
|
}
|
|
@@ -11532,6 +11584,10 @@ var TypeScriptGenerator = class {
|
|
|
11532
11584
|
if (literal.value === null) return "null";
|
|
11533
11585
|
return typeof literal.value === "string" ? `'${literal.value}'` : String(literal.value);
|
|
11534
11586
|
}
|
|
11587
|
+
printParamOperand(param) {
|
|
11588
|
+
const name = param.name.replace(/'/g, "\\'");
|
|
11589
|
+
return `{ type: 'Param', name: '${name}' }`;
|
|
11590
|
+
}
|
|
11535
11591
|
/**
|
|
11536
11592
|
* Prints a function operand to TypeScript code
|
|
11537
11593
|
* @param fn - Function node
|
|
@@ -13839,6 +13895,7 @@ export {
|
|
|
13839
13895
|
createExecutorFromQueryRunner,
|
|
13840
13896
|
createMssqlExecutor,
|
|
13841
13897
|
createMysqlExecutor,
|
|
13898
|
+
createParamProxy,
|
|
13842
13899
|
createPooledExecutorFactory,
|
|
13843
13900
|
createPostgresExecutor,
|
|
13844
13901
|
createQueryLoggingExecutor,
|