metal-orm 1.0.79 → 1.0.80

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -3777,6 +3777,112 @@ interface PaginatedResult<T> {
3777
3777
  pageSize: number;
3778
3778
  }
3779
3779
 
3780
+ /**
3781
+ * OpenAPI 3.1 JSON Schema type representation
3782
+ */
3783
+ type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
3784
+ /**
3785
+ * Common OpenAPI 3.1 JSON Schema formats
3786
+ */
3787
+ type JsonSchemaFormat = 'date-time' | 'date' | 'time' | 'email' | 'uuid' | 'uri' | 'binary' | 'base64';
3788
+ /**
3789
+ * OpenAPI 3.1 JSON Schema property definition
3790
+ */
3791
+ interface JsonSchemaProperty {
3792
+ type?: JsonSchemaType | JsonSchemaType[];
3793
+ format?: JsonSchemaFormat;
3794
+ description?: string;
3795
+ nullable?: boolean;
3796
+ minimum?: number;
3797
+ maximum?: number;
3798
+ minLength?: number;
3799
+ maxLength?: number;
3800
+ pattern?: string;
3801
+ enum?: (string | number | boolean)[];
3802
+ default?: unknown;
3803
+ example?: unknown;
3804
+ properties?: Record<string, JsonSchemaProperty>;
3805
+ required?: string[];
3806
+ items?: JsonSchemaProperty;
3807
+ $ref?: string;
3808
+ anyOf?: JsonSchemaProperty[];
3809
+ allOf?: JsonSchemaProperty[];
3810
+ oneOf?: JsonSchemaProperty[];
3811
+ [key: string]: unknown;
3812
+ }
3813
+ /**
3814
+ * Complete OpenAPI 3.1 Schema for an entity or query result
3815
+ */
3816
+ interface OpenApiSchema {
3817
+ type: 'object';
3818
+ properties: Record<string, JsonSchemaProperty>;
3819
+ required: string[];
3820
+ description?: string;
3821
+ }
3822
+ /**
3823
+ * Schema generation options
3824
+ */
3825
+ interface SchemaOptions {
3826
+ /** Use selected columns only (from select/include) vs full entity */
3827
+ mode?: 'selected' | 'full';
3828
+ /** Include description from column comments */
3829
+ includeDescriptions?: boolean;
3830
+ /** Include enum values for enum columns */
3831
+ includeEnums?: boolean;
3832
+ /** Include column examples if available */
3833
+ includeExamples?: boolean;
3834
+ /** Format output for pretty printing (debugging) */
3835
+ pretty?: boolean;
3836
+ /** Maximum depth for relation recursion */
3837
+ maxDepth?: number;
3838
+ }
3839
+ /**
3840
+ * Schema extraction context for handling circular references
3841
+ */
3842
+ interface SchemaExtractionContext {
3843
+ /** Set of already visited tables to detect cycles */
3844
+ visitedTables: Set<string>;
3845
+ /** Map of table names to their generated schemas */
3846
+ schemaCache: Map<string, OpenApiSchema>;
3847
+ /** Current extraction depth */
3848
+ depth: number;
3849
+ /** Maximum depth to recurse */
3850
+ maxDepth: number;
3851
+ }
3852
+
3853
+ /**
3854
+ * Maps SQL column types to OpenAPI JSON Schema types
3855
+ */
3856
+ declare const mapColumnType: (column: ColumnDef) => JsonSchemaProperty;
3857
+ /**
3858
+ * Maps relation type to array or single object
3859
+ */
3860
+ declare const mapRelationType: (relationType: string) => {
3861
+ type: "object" | "array";
3862
+ isNullable: boolean;
3863
+ };
3864
+ /**
3865
+ * Gets the OpenAPI format for temporal columns
3866
+ */
3867
+ declare const getTemporalFormat: (sqlType: string) => JsonSchemaFormat | undefined;
3868
+
3869
+ /**
3870
+ * Extracts OpenAPI 3.1 schema from a query builder's hydration plan
3871
+ * @param table - Table definition
3872
+ * @param plan - Hydration plan from query builder
3873
+ * @param projectionNodes - Projection AST nodes (for computed fields)
3874
+ * @param options - Schema generation options
3875
+ * @returns OpenAPI 3.1 JSON Schema
3876
+ */
3877
+ declare const extractSchema: (table: TableDef, plan: HydrationPlan | undefined, projectionNodes: ProjectionNode[] | undefined, options?: SchemaOptions) => OpenApiSchema;
3878
+ /**
3879
+ * Converts a schema to a JSON string with optional pretty printing
3880
+ * @param schema - OpenAPI schema
3881
+ * @param pretty - Whether to pretty print
3882
+ * @returns JSON string
3883
+ */
3884
+ declare const schemaToJson: (schema: OpenApiSchema, pretty?: boolean) => string;
3885
+
3780
3886
  type SelectDialectInput = Dialect | DialectKey;
3781
3887
 
3782
3888
  type ColumnSelectionValue = ColumnDef | FunctionNode | CaseExpressionNode | WindowFunctionNode | TypedExpression<unknown>;
@@ -4385,13 +4491,22 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
4385
4491
  */
4386
4492
  toSql(dialect: SelectDialectInput): string;
4387
4493
  /**
4388
- * Gets the hydration plan for the query
4494
+ * Gets hydration plan for query
4389
4495
  * @returns Hydration plan or undefined if none exists
4390
4496
  * @example
4391
4497
  * const plan = qb.include('posts').getHydrationPlan();
4392
4498
  * console.log(plan?.relations); // Information about included relations
4393
4499
  */
4394
4500
  getHydrationPlan(): HydrationPlan | undefined;
4501
+ /**
4502
+ * Gets OpenAPI 3.1 JSON Schema for query result
4503
+ * @param options - Schema generation options
4504
+ * @returns OpenAPI 3.1 JSON Schema for query result
4505
+ * @example
4506
+ * const schema = qb.select('id', 'title', 'author').getSchema();
4507
+ * console.log(JSON.stringify(schema, null, 2));
4508
+ */
4509
+ getSchema(options?: SchemaOptions): OpenApiSchema;
4395
4510
  /**
4396
4511
  * Gets the Abstract Syntax Tree (AST) representation of the query
4397
4512
  * @returns Query AST with hydration applied
@@ -5048,6 +5163,7 @@ declare class PostgresDialect extends SqlDialectBase {
5048
5163
  * @returns Quoted identifier
5049
5164
  */
5050
5165
  quoteIdentifier(id: string): string;
5166
+ protected formatPlaceholder(index: number): string;
5051
5167
  /**
5052
5168
  * Compiles JSON path expression using PostgreSQL syntax
5053
5169
  * @param node - JSON path node
@@ -7015,4 +7131,4 @@ type PooledExecutorFactoryOptions<TConn> = {
7015
7131
  */
7016
7132
  declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
7017
7133
 
7018
- export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, type IntrospectOptions, type JsonPathNode, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type PaginatedResult, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type SaveGraphSessionOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, entityRefs, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
7134
+ export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, 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 OpenApiSchema, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, 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, 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 };
package/dist/index.d.ts CHANGED
@@ -3777,6 +3777,112 @@ interface PaginatedResult<T> {
3777
3777
  pageSize: number;
3778
3778
  }
3779
3779
 
3780
+ /**
3781
+ * OpenAPI 3.1 JSON Schema type representation
3782
+ */
3783
+ type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';
3784
+ /**
3785
+ * Common OpenAPI 3.1 JSON Schema formats
3786
+ */
3787
+ type JsonSchemaFormat = 'date-time' | 'date' | 'time' | 'email' | 'uuid' | 'uri' | 'binary' | 'base64';
3788
+ /**
3789
+ * OpenAPI 3.1 JSON Schema property definition
3790
+ */
3791
+ interface JsonSchemaProperty {
3792
+ type?: JsonSchemaType | JsonSchemaType[];
3793
+ format?: JsonSchemaFormat;
3794
+ description?: string;
3795
+ nullable?: boolean;
3796
+ minimum?: number;
3797
+ maximum?: number;
3798
+ minLength?: number;
3799
+ maxLength?: number;
3800
+ pattern?: string;
3801
+ enum?: (string | number | boolean)[];
3802
+ default?: unknown;
3803
+ example?: unknown;
3804
+ properties?: Record<string, JsonSchemaProperty>;
3805
+ required?: string[];
3806
+ items?: JsonSchemaProperty;
3807
+ $ref?: string;
3808
+ anyOf?: JsonSchemaProperty[];
3809
+ allOf?: JsonSchemaProperty[];
3810
+ oneOf?: JsonSchemaProperty[];
3811
+ [key: string]: unknown;
3812
+ }
3813
+ /**
3814
+ * Complete OpenAPI 3.1 Schema for an entity or query result
3815
+ */
3816
+ interface OpenApiSchema {
3817
+ type: 'object';
3818
+ properties: Record<string, JsonSchemaProperty>;
3819
+ required: string[];
3820
+ description?: string;
3821
+ }
3822
+ /**
3823
+ * Schema generation options
3824
+ */
3825
+ interface SchemaOptions {
3826
+ /** Use selected columns only (from select/include) vs full entity */
3827
+ mode?: 'selected' | 'full';
3828
+ /** Include description from column comments */
3829
+ includeDescriptions?: boolean;
3830
+ /** Include enum values for enum columns */
3831
+ includeEnums?: boolean;
3832
+ /** Include column examples if available */
3833
+ includeExamples?: boolean;
3834
+ /** Format output for pretty printing (debugging) */
3835
+ pretty?: boolean;
3836
+ /** Maximum depth for relation recursion */
3837
+ maxDepth?: number;
3838
+ }
3839
+ /**
3840
+ * Schema extraction context for handling circular references
3841
+ */
3842
+ interface SchemaExtractionContext {
3843
+ /** Set of already visited tables to detect cycles */
3844
+ visitedTables: Set<string>;
3845
+ /** Map of table names to their generated schemas */
3846
+ schemaCache: Map<string, OpenApiSchema>;
3847
+ /** Current extraction depth */
3848
+ depth: number;
3849
+ /** Maximum depth to recurse */
3850
+ maxDepth: number;
3851
+ }
3852
+
3853
+ /**
3854
+ * Maps SQL column types to OpenAPI JSON Schema types
3855
+ */
3856
+ declare const mapColumnType: (column: ColumnDef) => JsonSchemaProperty;
3857
+ /**
3858
+ * Maps relation type to array or single object
3859
+ */
3860
+ declare const mapRelationType: (relationType: string) => {
3861
+ type: "object" | "array";
3862
+ isNullable: boolean;
3863
+ };
3864
+ /**
3865
+ * Gets the OpenAPI format for temporal columns
3866
+ */
3867
+ declare const getTemporalFormat: (sqlType: string) => JsonSchemaFormat | undefined;
3868
+
3869
+ /**
3870
+ * Extracts OpenAPI 3.1 schema from a query builder's hydration plan
3871
+ * @param table - Table definition
3872
+ * @param plan - Hydration plan from query builder
3873
+ * @param projectionNodes - Projection AST nodes (for computed fields)
3874
+ * @param options - Schema generation options
3875
+ * @returns OpenAPI 3.1 JSON Schema
3876
+ */
3877
+ declare const extractSchema: (table: TableDef, plan: HydrationPlan | undefined, projectionNodes: ProjectionNode[] | undefined, options?: SchemaOptions) => OpenApiSchema;
3878
+ /**
3879
+ * Converts a schema to a JSON string with optional pretty printing
3880
+ * @param schema - OpenAPI schema
3881
+ * @param pretty - Whether to pretty print
3882
+ * @returns JSON string
3883
+ */
3884
+ declare const schemaToJson: (schema: OpenApiSchema, pretty?: boolean) => string;
3885
+
3780
3886
  type SelectDialectInput = Dialect | DialectKey;
3781
3887
 
3782
3888
  type ColumnSelectionValue = ColumnDef | FunctionNode | CaseExpressionNode | WindowFunctionNode | TypedExpression<unknown>;
@@ -4385,13 +4491,22 @@ declare class SelectQueryBuilder<T = EntityInstance<TableDef>, TTable extends Ta
4385
4491
  */
4386
4492
  toSql(dialect: SelectDialectInput): string;
4387
4493
  /**
4388
- * Gets the hydration plan for the query
4494
+ * Gets hydration plan for query
4389
4495
  * @returns Hydration plan or undefined if none exists
4390
4496
  * @example
4391
4497
  * const plan = qb.include('posts').getHydrationPlan();
4392
4498
  * console.log(plan?.relations); // Information about included relations
4393
4499
  */
4394
4500
  getHydrationPlan(): HydrationPlan | undefined;
4501
+ /**
4502
+ * Gets OpenAPI 3.1 JSON Schema for query result
4503
+ * @param options - Schema generation options
4504
+ * @returns OpenAPI 3.1 JSON Schema for query result
4505
+ * @example
4506
+ * const schema = qb.select('id', 'title', 'author').getSchema();
4507
+ * console.log(JSON.stringify(schema, null, 2));
4508
+ */
4509
+ getSchema(options?: SchemaOptions): OpenApiSchema;
4395
4510
  /**
4396
4511
  * Gets the Abstract Syntax Tree (AST) representation of the query
4397
4512
  * @returns Query AST with hydration applied
@@ -5048,6 +5163,7 @@ declare class PostgresDialect extends SqlDialectBase {
5048
5163
  * @returns Quoted identifier
5049
5164
  */
5050
5165
  quoteIdentifier(id: string): string;
5166
+ protected formatPlaceholder(index: number): string;
5051
5167
  /**
5052
5168
  * Compiles JSON path expression using PostgreSQL syntax
5053
5169
  * @param node - JSON path node
@@ -7015,4 +7131,4 @@ type PooledExecutorFactoryOptions<TConn> = {
7015
7131
  */
7016
7132
  declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
7017
7133
 
7018
- export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, type IntrospectOptions, type JsonPathNode, type Jsonify, type JsonifyScalar, type LiteralNode, type LiteralValue, type LogicalExpressionNode, type ManyToManyCollection, type MssqlClientLike, MySqlDialect, type MysqlClientLike, type NullExpressionNode, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, type PaginatedResult, Pool, type PoolAdapter, type PoolLease, type PoolOptions, type PooledConnectionAdapter, type PostgresClientLike, PostgresDialect, PrimaryKey, type Primitive, PrototypeMaterializationStrategy, type QueryLogEntry, type QueryLogger, type QueryResult, type RawDefaultValue, type ReferentialAction, type RelationChange, type RelationChangeEntry, type RelationDef, type RelationKey$1 as RelationKey, RelationKinds, type RelationMap, type RelationTargetTable, type RelationType, type RenderColumnOptions, STANDARD_COLUMN_TYPES, type SaveGraphInputPayload, type SaveGraphInputScalar, type SaveGraphJsonScalar, type SaveGraphSessionOptions, type ScalarSubqueryNode, type SchemaChange, type SchemaChangeKind, type SchemaDiffOptions, type SchemaGenerateResult, type SchemaIntrospector, type SchemaPlan, SelectQueryBuilder, type SelectQueryInput, type SelectableKeys, type SimpleQueryRunner, SqlServerDialect, type SqliteClientLike, SqliteDialect, type StandardColumnType, type SynchronizeOptions, type TableDef, type TableHooks, type TableOptions, type TableRef$1 as TableRef, type TediousColumn, type TediousConnectionLike, type TediousModule, type TediousRequest, type TediousRequestCtor, type TediousTypes, type TrackedEntity, TypeScriptGenerator, type TypedExpression, type TypedLike, UpdateQueryBuilder, type ValueOperandInput, type WindowFunctionNode, abs, acos, add, addDomainEvent, age, aliasRef, and, arrayAppend, asType, ascii, asin, atan, atan2, avg, belongsTo, belongsToMany, between, bitAnd, bitLength, bitOr, bitXor, bootstrapEntities, caseWhen, cast, cbrt, ceil, ceiling, char, charLength, chr, clearExpressionDispatchers, clearOperandDispatchers, coalesce, col, collate, columnOperand, concat, concatWs, correlateBy, cos, cot, count, countAll, createEntityFromRow, createEntityProxy, createExecutorFromQueryRunner, createMssqlExecutor, createMysqlExecutor, createPooledExecutorFactory, createPostgresExecutor, createQueryLoggingExecutor, createSqliteExecutor, createTediousExecutor, createTediousMssqlClient, currentDate, currentTime, dateAdd, dateDiff, dateFormat, dateSub, dateTrunc, day, dayOfWeek, defineTable, degrees, deleteFrom, denseRank, diffSchema, div, endOfMonth, entityRef, entityRefs, eq, esel, executeHydrated, executeHydratedPlain, executeHydratedPlainWithContexts, executeHydratedWithContexts, executeSchemaSql, executeSchemaSqlFor, exists, exp, extract, firstValue, floor, fromUnixTime, generateCreateTableSql, generateSchemaSql, generateSchemaSqlFor, getColumn, getDecoratorMetadata, getSchemaIntrospector, getTableDefFromEntity, greatest, groupConcat, gt, gte, hasMany, hasOne, hour, hydrateRows, ifNull, inList, inSubquery, initcap, insertInto, instr, introspectSchema, isCaseExpressionNode, isCastExpressionNode, isCollateExpressionNode, isExpressionSelectionNode, isFunctionNode, isNotNull, isNull, isOperandNode, isValueOperandInput, isWindowFunctionNode, jsonArrayAgg, jsonContains, jsonLength, jsonPath, jsonSet, jsonify, lag, lastValue, lead, least, left, length, like, ln, loadBelongsToManyRelation, loadBelongsToRelation, loadHasManyRelation, loadHasOneRelation, localTime, localTimestamp, locate, log, log10, log2, logBase, lower, lpad, lt, lte, ltrim, materializeAs, max, md5, min, minute, mod, month, mul, neq, normalizeColumnType, notBetween, notExists, notInList, notInSubquery, notLike, now, ntile, nullif, octetLength, or, outerRef, pi, position, pow, power, quarter, radians, rand, random, rank, registerExpressionDispatcher, registerOperandDispatcher, registerSchemaIntrospector, relationLoaderCache, renderColumnDefinition, renderTypeWithArgs, repeat, replace, reverse, right, round, rowNumber, rowsToQueryResult, rpad, rtrim, second, sel, selectFrom, selectFromEntity, setRelations, sha1, sha2, shiftLeft, shiftRight, sign, sin, space, sqrt, stddev, sub, substr, sum, synchronizeSchema, tableRef, tan, toColumnRef, toTableRef, trim, trunc, truncate, unixTimestamp, update, upper, utcNow, valueToOperand, variance, visitExpression, visitOperand, weekOfYear, windowFunction, year };
7134
+ export { type AliasRefNode, type AnyDomainEvent, type ArithmeticExpressionNode, type TableRef as AstTableRef, AsyncLocalStorage, BelongsTo, BelongsToMany, type BelongsToManyOptions, type BelongsToManyRelation, type BelongsToOptions, type BelongsToReference, type BelongsToReferenceApi, type BelongsToRelation, type BetweenExpressionNode, type BinaryExpressionNode, type BitwiseExpressionNode, type CascadeMode, type CaseExpressionNode, type CastExpressionNode, type CheckConstraint, type CollateExpressionNode, Column, type ColumnDef, type ColumnDiff, type ColumnInput, type ColumnNode, type ColumnOptions, type ColumnRef, type ColumnToTs, type ColumnType, ConstructorMaterializationStrategy, type CreateTediousClientOptions, type DatabaseCheck, type DatabaseColumn, type DatabaseIndex, type DatabaseSchema, type DatabaseTable, type DbExecutor, type DbExecutorFactory, type DecoratedEntityInstance, DefaultBelongsToReference, DefaultEntityMaterializer, DefaultHasManyCollection, DefaultManyToManyCollection, type DefaultValue, DeleteQueryBuilder, type DialectName, type DomainEvent, DomainEventBus, type DomainEventHandler, Entity, type EntityContext, type EntityInstance, type EntityMaterializationStrategy, type EntityMaterializer, type EntityOptions, type PrimaryKey$1 as EntityPrimaryKey, EntityStatus, type ExecutionContext, type ExistsExpressionNode, type ExpressionNode, type ExpressionVisitor, type ForeignKeyReference, type FunctionNode, type GroupConcatOptions, type HasDomainEvents, HasMany, type HasManyCollection, type HasManyOptions, type HasManyRelation, HasOne, type HasOneOptions, type HasOneReference, type HasOneReferenceApi, type HasOneRelation, type HydrationContext, type HydrationMetadata, type HydrationPivotPlan, type HydrationPlan, type HydrationRelationPlan, type InExpressionNode, type InExpressionRight, type IndexColumn, type IndexDef, type InferRow, type InitialHandlers, InsertQueryBuilder, 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 OpenApiSchema, type OperandNode, type OperandVisitor, Orm, type OrmDomainEvent, type OrmInterceptor, type OrmOptions, OrmSession, type OrmSessionOptions, 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, 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 };