metal-orm 1.0.87 → 1.0.88

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
@@ -3872,6 +3872,12 @@ interface OpenApiSchema {
3872
3872
  required: string[];
3873
3873
  description?: string;
3874
3874
  }
3875
+ /**
3876
+ * OpenAPI 3.1 components container
3877
+ */
3878
+ interface OpenApiComponents {
3879
+ schemas: Record<string, OpenApiSchema>;
3880
+ }
3875
3881
  /**
3876
3882
  * Column-level schema flags
3877
3883
  */
@@ -3895,6 +3901,12 @@ interface OutputSchemaOptions extends ColumnSchemaOptions {
3895
3901
  mode?: 'selected' | 'full';
3896
3902
  /** Maximum depth for relation recursion */
3897
3903
  maxDepth?: number;
3904
+ /** Inline schemas vs $ref components */
3905
+ refMode?: 'inline' | 'components';
3906
+ /** Selected schemas inline vs components when refMode is components */
3907
+ selectedRefMode?: 'inline' | 'components';
3908
+ /** Customize component names */
3909
+ componentName?: (table: TableDef) => string;
3898
3910
  }
3899
3911
  type InputRelationMode = 'ids' | 'objects' | 'mixed';
3900
3912
  type InputSchemaMode = 'create' | 'update';
@@ -3931,6 +3943,7 @@ interface OpenApiSchemaBundle {
3931
3943
  output: OpenApiSchema;
3932
3944
  input?: OpenApiSchema;
3933
3945
  parameters?: OpenApiParameter[];
3946
+ components?: OpenApiComponents;
3934
3947
  }
3935
3948
  /**
3936
3949
  * Schema extraction context for handling circular references
@@ -3944,6 +3957,8 @@ interface SchemaExtractionContext {
3944
3957
  depth: number;
3945
3958
  /** Maximum depth to recurse */
3946
3959
  maxDepth: number;
3960
+ /** Component registry when using refMode=components */
3961
+ components?: OpenApiComponents;
3947
3962
  }
3948
3963
 
3949
3964
  /**
@@ -7231,4 +7246,4 @@ type PooledExecutorFactoryOptions<TConn> = {
7231
7246
  */
7232
7247
  declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
7233
7248
 
7234
- 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, hasExpressionDispatcher, hasMany, hasOne, hasOperandDispatcher, 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 };
7249
+ 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 OpenApiComponents, 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, hasExpressionDispatcher, hasMany, hasOne, hasOperandDispatcher, 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
@@ -3872,6 +3872,12 @@ interface OpenApiSchema {
3872
3872
  required: string[];
3873
3873
  description?: string;
3874
3874
  }
3875
+ /**
3876
+ * OpenAPI 3.1 components container
3877
+ */
3878
+ interface OpenApiComponents {
3879
+ schemas: Record<string, OpenApiSchema>;
3880
+ }
3875
3881
  /**
3876
3882
  * Column-level schema flags
3877
3883
  */
@@ -3895,6 +3901,12 @@ interface OutputSchemaOptions extends ColumnSchemaOptions {
3895
3901
  mode?: 'selected' | 'full';
3896
3902
  /** Maximum depth for relation recursion */
3897
3903
  maxDepth?: number;
3904
+ /** Inline schemas vs $ref components */
3905
+ refMode?: 'inline' | 'components';
3906
+ /** Selected schemas inline vs components when refMode is components */
3907
+ selectedRefMode?: 'inline' | 'components';
3908
+ /** Customize component names */
3909
+ componentName?: (table: TableDef) => string;
3898
3910
  }
3899
3911
  type InputRelationMode = 'ids' | 'objects' | 'mixed';
3900
3912
  type InputSchemaMode = 'create' | 'update';
@@ -3931,6 +3943,7 @@ interface OpenApiSchemaBundle {
3931
3943
  output: OpenApiSchema;
3932
3944
  input?: OpenApiSchema;
3933
3945
  parameters?: OpenApiParameter[];
3946
+ components?: OpenApiComponents;
3934
3947
  }
3935
3948
  /**
3936
3949
  * Schema extraction context for handling circular references
@@ -3944,6 +3957,8 @@ interface SchemaExtractionContext {
3944
3957
  depth: number;
3945
3958
  /** Maximum depth to recurse */
3946
3959
  maxDepth: number;
3960
+ /** Component registry when using refMode=components */
3961
+ components?: OpenApiComponents;
3947
3962
  }
3948
3963
 
3949
3964
  /**
@@ -7231,4 +7246,4 @@ type PooledExecutorFactoryOptions<TConn> = {
7231
7246
  */
7232
7247
  declare function createPooledExecutorFactory<TConn>(opts: PooledExecutorFactoryOptions<TConn>): DbExecutorFactory;
7233
7248
 
7234
- 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, hasExpressionDispatcher, hasMany, hasOne, hasOperandDispatcher, 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 };
7249
+ 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 OpenApiComponents, 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, hasExpressionDispatcher, hasMany, hasOne, hasOperandDispatcher, 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
@@ -6963,47 +6963,52 @@ var getTemporalFormat = (sqlType) => {
6963
6963
  }
6964
6964
  };
6965
6965
 
6966
- // src/openapi/schema-extractor.ts
6967
- var DEFAULT_MAX_DEPTH = 5;
6968
- var extractSchema = (table, plan, projectionNodes, options = {}) => {
6969
- const outputOptions = resolveOutputOptions(options);
6970
- const outputContext = createContext(outputOptions.maxDepth ?? DEFAULT_MAX_DEPTH);
6971
- const output = extractOutputSchema(table, plan, projectionNodes, outputContext, outputOptions);
6972
- const inputOptions = resolveInputOptions(options);
6973
- if (!inputOptions) {
6974
- return { output };
6966
+ // src/openapi/schema-extractor-utils.ts
6967
+ var hasComputedProjection = (projectionNodes) => Boolean(projectionNodes && projectionNodes.some((node) => node.type !== "Column"));
6968
+ var shouldUseSelectedSchema = (options, plan, projectionNodes) => {
6969
+ if (!plan || options.mode !== "selected") return false;
6970
+ if (hasComputedProjection(projectionNodes)) return false;
6971
+ if (options.refMode === "components" && options.selectedRefMode !== "components") return false;
6972
+ return true;
6973
+ };
6974
+ var resolveComponentName = (table, options) => options.componentName ? options.componentName(table) : table.name;
6975
+ var normalizeColumns = (columns) => Array.from(new Set(columns)).sort((a, b) => a.localeCompare(b));
6976
+ var buildSelectionSignature = (plan) => {
6977
+ const relations = plan.relations.map((relation) => ({
6978
+ name: relation.name,
6979
+ columns: normalizeColumns(relation.columns)
6980
+ })).sort((a, b) => a.name.localeCompare(b.name));
6981
+ return JSON.stringify({
6982
+ root: normalizeColumns(plan.rootColumns),
6983
+ relations
6984
+ });
6985
+ };
6986
+ var hashString = (value) => {
6987
+ let hash = 2166136261;
6988
+ for (let i = 0; i < value.length; i += 1) {
6989
+ hash ^= value.charCodeAt(i);
6990
+ hash = hash * 16777619 >>> 0;
6975
6991
  }
6976
- const inputContext = createContext(inputOptions.maxDepth ?? DEFAULT_MAX_DEPTH);
6977
- const input = extractInputSchema(table, inputContext, inputOptions);
6978
- return { output, input };
6992
+ return hash.toString(16).padStart(8, "0");
6979
6993
  };
6980
- var resolveOutputOptions = (options) => ({
6981
- mode: options.mode ?? "full",
6982
- includeDescriptions: options.includeDescriptions,
6983
- includeEnums: options.includeEnums,
6984
- includeExamples: options.includeExamples,
6985
- includeDefaults: options.includeDefaults,
6986
- includeNullable: options.includeNullable,
6987
- maxDepth: options.maxDepth ?? DEFAULT_MAX_DEPTH
6988
- });
6989
- var resolveInputOptions = (options) => {
6990
- if (options.input === false) return void 0;
6991
- const input = options.input ?? {};
6992
- const mode = input.mode ?? "create";
6993
- return {
6994
- mode,
6995
- includeRelations: input.includeRelations ?? true,
6996
- relationMode: input.relationMode ?? "mixed",
6997
- includeDescriptions: input.includeDescriptions ?? options.includeDescriptions,
6998
- includeEnums: input.includeEnums ?? options.includeEnums,
6999
- includeExamples: input.includeExamples ?? options.includeExamples,
7000
- includeDefaults: input.includeDefaults ?? options.includeDefaults,
7001
- includeNullable: input.includeNullable ?? options.includeNullable,
7002
- maxDepth: input.maxDepth ?? options.maxDepth ?? DEFAULT_MAX_DEPTH,
7003
- omitReadOnly: input.omitReadOnly ?? true,
7004
- excludePrimaryKey: input.excludePrimaryKey ?? false,
7005
- requirePrimaryKey: input.requirePrimaryKey ?? mode === "update"
7006
- };
6994
+ var resolveSelectedComponentName = (table, plan, options) => {
6995
+ const base = resolveComponentName(table, options);
6996
+ const signature = buildSelectionSignature(plan);
6997
+ return `${base}__sel_${hashString(signature)}`;
6998
+ };
6999
+ var ensureComponentRef = (table, componentName, context, schemaFactory) => {
7000
+ if (context.components && !context.components.schemas[componentName]) {
7001
+ if (!context.visitedTables.has(table.name)) {
7002
+ context.components.schemas[componentName] = schemaFactory();
7003
+ }
7004
+ }
7005
+ return { $ref: `#/components/schemas/${componentName}` };
7006
+ };
7007
+ var registerComponentSchema = (name, schema, context) => {
7008
+ if (!context.components) return;
7009
+ if (!context.components.schemas[name]) {
7010
+ context.components.schemas[name] = schema;
7011
+ }
7007
7012
  };
7008
7013
  var createContext = (maxDepth) => ({
7009
7014
  visitedTables: /* @__PURE__ */ new Set(),
@@ -7011,19 +7016,18 @@ var createContext = (maxDepth) => ({
7011
7016
  depth: 0,
7012
7017
  maxDepth
7013
7018
  });
7014
- var extractOutputSchema = (table, plan, projectionNodes, context, options) => {
7015
- const mode = options.mode ?? "full";
7016
- const hasComputedFields = projectionNodes && projectionNodes.some(
7017
- (node) => node.type !== "Column"
7018
- );
7019
- if (hasComputedFields) {
7020
- return extractFromProjectionNodes(table, projectionNodes, context, options);
7021
- }
7022
- if (mode === "selected" && plan) {
7023
- return extractSelectedSchema(table, plan, context, options);
7024
- }
7025
- return extractFullTableSchema(table, context, options);
7026
- };
7019
+ var buildCircularReferenceSchema = (tableName, kind) => ({
7020
+ type: "object",
7021
+ properties: {
7022
+ _ref: {
7023
+ type: "string",
7024
+ description: `Circular ${kind} reference to ${tableName}`
7025
+ }
7026
+ },
7027
+ required: []
7028
+ });
7029
+
7030
+ // src/openapi/schema-extractor-input.ts
7027
7031
  var extractInputSchema = (table, context, options) => {
7028
7032
  const cacheKey = `${table.name}:${options.mode ?? "create"}`;
7029
7033
  if (context.schemaCache.has(cacheKey)) {
@@ -7111,6 +7115,18 @@ var extractInputRelationSchema = (relation, context, options) => {
7111
7115
  nullable: isNullable
7112
7116
  };
7113
7117
  };
7118
+
7119
+ // src/openapi/schema-extractor-output.ts
7120
+ var extractOutputSchema = (table, plan, projectionNodes, context, options) => {
7121
+ const hasComputedFields = hasComputedProjection(projectionNodes);
7122
+ if (hasComputedFields) {
7123
+ return extractFromProjectionNodes(table, projectionNodes, context, options);
7124
+ }
7125
+ if (shouldUseSelectedSchema(options, plan, projectionNodes)) {
7126
+ return extractSelectedSchema(table, plan, context, options);
7127
+ }
7128
+ return extractFullTableSchema(table, context, options);
7129
+ };
7114
7130
  var extractFromProjectionNodes = (table, projectionNodes, context, options) => {
7115
7131
  const properties = {};
7116
7132
  const required = [];
@@ -7316,6 +7332,52 @@ var extractFullTableSchema = (table, context, options) => {
7316
7332
  var extractRelationSchema = (relation, relationPlan, selectedColumns, context, options) => {
7317
7333
  const targetTable = relation.target;
7318
7334
  const { type: relationType, isNullable } = mapRelationType(relation.type);
7335
+ if (options.refMode === "components" && context.components) {
7336
+ if (relationPlan && selectedColumns.length > 0 && options.selectedRefMode === "components") {
7337
+ const plan = {
7338
+ rootTable: targetTable.name,
7339
+ rootPrimaryKey: relationPlan.targetPrimaryKey,
7340
+ rootColumns: selectedColumns,
7341
+ relations: []
7342
+ };
7343
+ const componentName2 = resolveSelectedComponentName(targetTable, plan, options);
7344
+ const ref2 = ensureComponentRef(
7345
+ targetTable,
7346
+ componentName2,
7347
+ context,
7348
+ () => extractSelectedSchema(targetTable, plan, context, options)
7349
+ );
7350
+ if (relationType === "array") {
7351
+ return {
7352
+ type: "array",
7353
+ items: ref2,
7354
+ nullable: isNullable
7355
+ };
7356
+ }
7357
+ return {
7358
+ ...ref2,
7359
+ nullable: isNullable
7360
+ };
7361
+ }
7362
+ const componentName = resolveComponentName(targetTable, options);
7363
+ const ref = ensureComponentRef(
7364
+ targetTable,
7365
+ componentName,
7366
+ context,
7367
+ () => extractFullTableSchema(targetTable, context, options)
7368
+ );
7369
+ if (relationType === "array") {
7370
+ return {
7371
+ type: "array",
7372
+ items: ref,
7373
+ nullable: isNullable
7374
+ };
7375
+ }
7376
+ return {
7377
+ ...ref,
7378
+ nullable: isNullable
7379
+ };
7380
+ }
7319
7381
  let targetSchema;
7320
7382
  if (relationPlan && selectedColumns.length > 0) {
7321
7383
  const plan = {
@@ -7343,16 +7405,68 @@ var extractRelationSchema = (relation, relationPlan, selectedColumns, context, o
7343
7405
  description: targetSchema.description
7344
7406
  };
7345
7407
  };
7346
- var buildCircularReferenceSchema = (tableName, kind) => ({
7347
- type: "object",
7348
- properties: {
7349
- _ref: {
7350
- type: "string",
7351
- description: `Circular ${kind} reference to ${tableName}`
7352
- }
7353
- },
7354
- required: []
7408
+
7409
+ // src/openapi/schema-extractor.ts
7410
+ var DEFAULT_MAX_DEPTH = 5;
7411
+ var extractSchema = (table, plan, projectionNodes, options = {}) => {
7412
+ const outputOptions = resolveOutputOptions(options);
7413
+ const outputContext = createContext(outputOptions.maxDepth ?? DEFAULT_MAX_DEPTH);
7414
+ if (outputOptions.refMode === "components") {
7415
+ outputContext.components = { schemas: {} };
7416
+ }
7417
+ const output = extractOutputSchema(table, plan, projectionNodes, outputContext, outputOptions);
7418
+ const useSelected = shouldUseSelectedSchema(outputOptions, plan, projectionNodes);
7419
+ const hasComputedFields = hasComputedProjection(projectionNodes);
7420
+ if (outputOptions.refMode === "components" && outputContext.components && !hasComputedFields) {
7421
+ const componentName = useSelected && plan ? resolveSelectedComponentName(table, plan, outputOptions) : resolveComponentName(table, outputOptions);
7422
+ registerComponentSchema(componentName, output, outputContext);
7423
+ }
7424
+ const inputOptions = resolveInputOptions(options);
7425
+ if (!inputOptions) {
7426
+ return {
7427
+ output,
7428
+ components: outputContext.components && Object.keys(outputContext.components.schemas).length ? outputContext.components : void 0
7429
+ };
7430
+ }
7431
+ const inputContext = createContext(inputOptions.maxDepth ?? DEFAULT_MAX_DEPTH);
7432
+ const input = extractInputSchema(table, inputContext, inputOptions);
7433
+ return {
7434
+ output,
7435
+ input,
7436
+ components: outputContext.components && Object.keys(outputContext.components.schemas).length ? outputContext.components : void 0
7437
+ };
7438
+ };
7439
+ var resolveOutputOptions = (options) => ({
7440
+ mode: options.mode ?? "full",
7441
+ includeDescriptions: options.includeDescriptions,
7442
+ includeEnums: options.includeEnums,
7443
+ includeExamples: options.includeExamples,
7444
+ includeDefaults: options.includeDefaults,
7445
+ includeNullable: options.includeNullable,
7446
+ maxDepth: options.maxDepth ?? DEFAULT_MAX_DEPTH,
7447
+ refMode: options.refMode ?? "inline",
7448
+ selectedRefMode: options.selectedRefMode ?? "inline",
7449
+ componentName: options.componentName
7355
7450
  });
7451
+ var resolveInputOptions = (options) => {
7452
+ if (options.input === false) return void 0;
7453
+ const input = options.input ?? {};
7454
+ const mode = input.mode ?? "create";
7455
+ return {
7456
+ mode,
7457
+ includeRelations: input.includeRelations ?? true,
7458
+ relationMode: input.relationMode ?? "mixed",
7459
+ includeDescriptions: input.includeDescriptions ?? options.includeDescriptions,
7460
+ includeEnums: input.includeEnums ?? options.includeEnums,
7461
+ includeExamples: input.includeExamples ?? options.includeExamples,
7462
+ includeDefaults: input.includeDefaults ?? options.includeDefaults,
7463
+ includeNullable: input.includeNullable ?? options.includeNullable,
7464
+ maxDepth: input.maxDepth ?? options.maxDepth ?? DEFAULT_MAX_DEPTH,
7465
+ omitReadOnly: input.omitReadOnly ?? true,
7466
+ excludePrimaryKey: input.excludePrimaryKey ?? false,
7467
+ requirePrimaryKey: input.requirePrimaryKey ?? mode === "update"
7468
+ };
7469
+ };
7356
7470
  var schemaToJson = (schema, pretty = false) => {
7357
7471
  return JSON.stringify(schema, null, pretty ? 2 : 0);
7358
7472
  };