metal-orm 1.0.91 → 1.0.93

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 CHANGED
@@ -91,6 +91,7 @@ __export(index_exports, {
91
91
  aliasRef: () => aliasRef,
92
92
  and: () => and,
93
93
  applyFilter: () => applyFilter,
94
+ applyNullability: () => applyNullability,
94
95
  arrayAppend: () => arrayAppend,
95
96
  asType: () => asType,
96
97
  ascii: () => ascii,
@@ -108,6 +109,7 @@ __export(index_exports, {
108
109
  bootstrapEntities: () => bootstrapEntities,
109
110
  buildFilterExpression: () => buildFilterExpression,
110
111
  calculateTotalPages: () => calculateTotalPages,
112
+ canonicalizeSchema: () => canonicalizeSchema,
111
113
  caseWhen: () => caseWhen,
112
114
  cast: () => cast,
113
115
  cbrt: () => cbrt,
@@ -122,10 +124,12 @@ __export(index_exports, {
122
124
  col: () => col,
123
125
  collate: () => collate,
124
126
  columnOperand: () => columnOperand,
127
+ columnToFilterSchema: () => columnToFilterSchema,
125
128
  columnToOpenApiSchema: () => columnToOpenApiSchema,
126
129
  columnTypeToOpenApiFormat: () => columnTypeToOpenApiFormat,
127
130
  columnTypeToOpenApiType: () => columnTypeToOpenApiType,
128
131
  computePaginationMetadata: () => computePaginationMetadata,
132
+ computeSchemaHash: () => computeSchemaHash,
129
133
  concat: () => concat,
130
134
  concatWs: () => concatWs,
131
135
  correlateBy: () => correlateBy,
@@ -134,6 +138,7 @@ __export(index_exports, {
134
138
  count: () => count,
135
139
  countAll: () => countAll,
136
140
  createApiComponentsSection: () => createApiComponentsSection,
141
+ createDeterministicNamingState: () => createDeterministicNamingState,
137
142
  createDtoToOpenApiSchema: () => createDtoToOpenApiSchema,
138
143
  createEntityFromRow: () => createEntityFromRow,
139
144
  createEntityProxy: () => createEntityProxy,
@@ -192,6 +197,8 @@ __export(index_exports, {
192
197
  getColumn: () => getColumn,
193
198
  getColumnMap: () => getColumnMap,
194
199
  getDecoratorMetadata: () => getDecoratorMetadata,
200
+ getDeterministicComponentName: () => getDeterministicComponentName,
201
+ getOpenApiVersionForDialect: () => getOpenApiVersionForDialect,
195
202
  getSchemaIntrospector: () => getSchemaIntrospector,
196
203
  getTableDefFromEntity: () => getTableDefFromEntity,
197
204
  greatest: () => greatest,
@@ -219,6 +226,7 @@ __export(index_exports, {
219
226
  isFunctionNode: () => isFunctionNode,
220
227
  isNotNull: () => isNotNull,
221
228
  isNull: () => isNull,
229
+ isNullableColumn: () => isNullableColumn,
222
230
  isOperandNode: () => isOperandNode,
223
231
  isTableDef: () => isTableDef2,
224
232
  isValueOperandInput: () => isValueOperandInput,
@@ -6512,7 +6520,7 @@ var buildTableDef = (meta) => {
6512
6520
  for (const [key, def] of Object.entries(meta.columns)) {
6513
6521
  columns[key] = {
6514
6522
  ...def,
6515
- name: key,
6523
+ name: def.name ?? key,
6516
6524
  table: meta.tableName
6517
6525
  };
6518
6526
  }
@@ -12690,7 +12698,8 @@ var normalizeColumnInput = (input) => {
12690
12698
  generated: asDefinition.generated,
12691
12699
  check: asDefinition.check,
12692
12700
  references: asDefinition.references,
12693
- comment: asDefinition.comment
12701
+ comment: asDefinition.comment,
12702
+ name: asOptions.name ?? asDefinition.name
12694
12703
  };
12695
12704
  if (!column.type) {
12696
12705
  throw new Error("Column decorator requires a column type");
@@ -13737,7 +13746,38 @@ function mergeSchemas(base, override) {
13737
13746
  required: override.required ?? base.required
13738
13747
  };
13739
13748
  }
13740
- function generateOpenApiDocument(info, routes) {
13749
+ function applyNullability(schema, isNullable, dialect) {
13750
+ if (!isNullable) {
13751
+ const { nullable: _2, ...clean2 } = schema;
13752
+ return clean2;
13753
+ }
13754
+ if (dialect === "openapi-3.0") {
13755
+ return { ...schema, nullable: true };
13756
+ }
13757
+ const type = schema.type;
13758
+ if (Array.isArray(type)) {
13759
+ if (!type.includes("null")) {
13760
+ const { nullable: _2, ...clean2 } = schema;
13761
+ return { ...clean2, type: [...type, "null"] };
13762
+ }
13763
+ } else if (type) {
13764
+ const { nullable: _2, ...clean2 } = schema;
13765
+ return { ...clean2, type: [type, "null"] };
13766
+ } else {
13767
+ const { nullable: _2, ...clean2 } = schema;
13768
+ return { ...clean2, type: ["null"] };
13769
+ }
13770
+ const { nullable: _, ...clean } = schema;
13771
+ return clean;
13772
+ }
13773
+ function isNullableColumn(col2) {
13774
+ return !col2.notNull;
13775
+ }
13776
+ function getOpenApiVersionForDialect(dialect) {
13777
+ return dialect === "openapi-3.0" ? "3.0.3" : "3.1.0";
13778
+ }
13779
+ function generateOpenApiDocument(info, routes, options) {
13780
+ const dialect = options?.dialect ?? "openapi-3.1";
13741
13781
  const paths = {};
13742
13782
  for (const route of routes) {
13743
13783
  if (!paths[route.path]) {
@@ -13746,7 +13786,7 @@ function generateOpenApiDocument(info, routes) {
13746
13786
  paths[route.path][route.method] = route.operation;
13747
13787
  }
13748
13788
  return {
13749
- openapi: "3.1.0",
13789
+ openapi: getOpenApiVersionForDialect(dialect),
13750
13790
  info: {
13751
13791
  title: info.title,
13752
13792
  version: info.version,
@@ -13780,34 +13820,33 @@ function getColumnMap(target) {
13780
13820
  }
13781
13821
 
13782
13822
  // src/dto/openapi/generators/column.ts
13783
- function columnToOpenApiSchema(col2) {
13823
+ function columnToOpenApiSchema(col2, dialect = "openapi-3.1") {
13784
13824
  const schema = {
13785
13825
  type: columnTypeToOpenApiType(col2),
13786
13826
  format: columnTypeToOpenApiFormat(col2)
13787
13827
  };
13788
- if (!col2.notNull) {
13789
- schema.nullable = true;
13790
- }
13828
+ const nullable = isNullableColumn(col2);
13829
+ const result = applyNullability(schema, nullable, dialect);
13791
13830
  if (col2.comment) {
13792
- schema.description = col2.comment;
13831
+ result.description = col2.comment;
13793
13832
  }
13794
13833
  if (col2.type.toUpperCase() === "ENUM" && col2.args && Array.isArray(col2.args) && col2.args.every((v) => typeof v === "string")) {
13795
- schema.enum = col2.args;
13834
+ result.enum = col2.args;
13796
13835
  }
13797
13836
  const args = col2.args;
13798
13837
  if (args && args.length > 0) {
13799
13838
  if (col2.type.toUpperCase() === "VARCHAR" || col2.type.toUpperCase() === "CHAR") {
13800
13839
  const length2 = args[0];
13801
13840
  if (length2) {
13802
- schema.example = "a".repeat(length2);
13841
+ result.example = "a".repeat(length2);
13803
13842
  }
13804
13843
  }
13805
13844
  }
13806
- return schema;
13845
+ return result;
13807
13846
  }
13808
13847
 
13809
13848
  // src/dto/openapi/generators/dto.ts
13810
- function dtoToOpenApiSchema(target, exclude2) {
13849
+ function dtoToOpenApiSchema(target, exclude2, dialect = "openapi-3.1") {
13811
13850
  const columns = getColumnMap(target);
13812
13851
  const properties = {};
13813
13852
  const required = [];
@@ -13815,7 +13854,7 @@ function dtoToOpenApiSchema(target, exclude2) {
13815
13854
  if (exclude2?.includes(key)) {
13816
13855
  continue;
13817
13856
  }
13818
- properties[key] = columnToOpenApiSchema(col2);
13857
+ properties[key] = columnToOpenApiSchema(col2, dialect);
13819
13858
  if (col2.notNull || col2.primary) {
13820
13859
  required.push(key);
13821
13860
  }
@@ -13826,7 +13865,7 @@ function dtoToOpenApiSchema(target, exclude2) {
13826
13865
  ...required.length > 0 && { required }
13827
13866
  };
13828
13867
  }
13829
- function createDtoToOpenApiSchema(target, exclude2) {
13868
+ function createDtoToOpenApiSchema(target, exclude2, dialect = "openapi-3.1") {
13830
13869
  const columns = getColumnMap(target);
13831
13870
  const properties = {};
13832
13871
  const required = [];
@@ -13837,7 +13876,7 @@ function createDtoToOpenApiSchema(target, exclude2) {
13837
13876
  if (col2.autoIncrement || col2.generated) {
13838
13877
  continue;
13839
13878
  }
13840
- properties[key] = columnToOpenApiSchema(col2);
13879
+ properties[key] = columnToOpenApiSchema(col2, dialect);
13841
13880
  if (col2.notNull && !col2.default) {
13842
13881
  required.push(key);
13843
13882
  }
@@ -13848,7 +13887,7 @@ function createDtoToOpenApiSchema(target, exclude2) {
13848
13887
  ...required.length > 0 && { required }
13849
13888
  };
13850
13889
  }
13851
- function updateDtoToOpenApiSchema(target, exclude2) {
13890
+ function updateDtoToOpenApiSchema(target, exclude2, dialect = "openapi-3.1") {
13852
13891
  const columns = getColumnMap(target);
13853
13892
  const properties = {};
13854
13893
  for (const [key, col2] of Object.entries(columns)) {
@@ -13858,10 +13897,7 @@ function updateDtoToOpenApiSchema(target, exclude2) {
13858
13897
  if (col2.autoIncrement || col2.generated) {
13859
13898
  continue;
13860
13899
  }
13861
- properties[key] = {
13862
- ...columnToOpenApiSchema(col2),
13863
- ...!col2.notNull ? { nullable: true } : {}
13864
- };
13900
+ properties[key] = columnToOpenApiSchema(col2, dialect);
13865
13901
  }
13866
13902
  return {
13867
13903
  type: "object",
@@ -13871,58 +13907,49 @@ function updateDtoToOpenApiSchema(target, exclude2) {
13871
13907
 
13872
13908
  // src/dto/openapi/generators/filter.ts
13873
13909
  function filterFieldToOpenApiSchema(col2) {
13874
- const normalizedType = col2.type.toUpperCase();
13875
- columnTypeToOpenApiType(col2);
13876
- let filterProperties = {};
13877
- if (["INT", "INTEGER", "BIGINT", "DECIMAL", "FLOAT", "DOUBLE"].includes(normalizedType)) {
13878
- filterProperties = {
13879
- equals: { type: "number" },
13880
- not: { type: "number" },
13881
- in: { type: "array", items: { type: "number" } },
13882
- notIn: { type: "array", items: { type: "number" } },
13883
- lt: { type: "number" },
13884
- lte: { type: "number" },
13885
- gt: { type: "number" },
13886
- gte: { type: "number" }
13887
- };
13888
- } else if (["BOOLEAN"].includes(normalizedType)) {
13889
- filterProperties = {
13890
- equals: { type: "boolean" },
13891
- not: { type: "boolean" }
13892
- };
13893
- } else if (["DATE", "DATETIME", "TIMESTAMP", "TIMESTAMPTZ"].includes(normalizedType)) {
13894
- filterProperties = {
13895
- equals: { type: "string", format: "date-time" },
13896
- not: { type: "string", format: "date-time" },
13897
- in: { type: "array", items: { type: "string", format: "date-time" } },
13898
- notIn: { type: "array", items: { type: "string", format: "date-time" } },
13899
- lt: { type: "string", format: "date-time" },
13900
- lte: { type: "string", format: "date-time" },
13901
- gt: { type: "string", format: "date-time" },
13902
- gte: { type: "string", format: "date-time" }
13903
- };
13904
- } else {
13905
- filterProperties = {
13906
- equals: { type: "string" },
13907
- not: { type: "string" },
13908
- in: { type: "array", items: { type: "string" } },
13909
- notIn: { type: "array", items: { type: "string" } },
13910
- contains: { type: "string" },
13911
- startsWith: { type: "string" },
13912
- endsWith: { type: "string" },
13913
- mode: { type: "string", enum: ["default", "insensitive"] }
13914
- };
13910
+ const openApiType = columnTypeToOpenApiType(col2);
13911
+ const openApiFormat = columnTypeToOpenApiFormat(col2);
13912
+ const filterProperties = {};
13913
+ filterProperties.equals = { type: openApiType, format: openApiFormat };
13914
+ filterProperties.not = { type: openApiType, format: openApiFormat };
13915
+ filterProperties.in = { type: "array", items: { type: openApiType, format: openApiFormat } };
13916
+ filterProperties.notIn = { type: "array", items: { type: openApiType, format: openApiFormat } };
13917
+ const isNumeric = openApiType === "integer" || openApiType === "number";
13918
+ const isDateOrTime = openApiType === "string" && (openApiFormat === "date" || openApiFormat === "date-time");
13919
+ const isString = openApiType === "string" && !isDateOrTime;
13920
+ if (isNumeric) {
13921
+ filterProperties.lt = { type: openApiType, format: openApiFormat };
13922
+ filterProperties.lte = { type: openApiType, format: openApiFormat };
13923
+ filterProperties.gt = { type: openApiType, format: openApiFormat };
13924
+ filterProperties.gte = { type: openApiType, format: openApiFormat };
13925
+ }
13926
+ if (isDateOrTime) {
13927
+ filterProperties.lt = { type: openApiType, format: openApiFormat };
13928
+ filterProperties.lte = { type: openApiType, format: openApiFormat };
13929
+ filterProperties.gt = { type: openApiType, format: openApiFormat };
13930
+ filterProperties.gte = { type: openApiType, format: openApiFormat };
13931
+ }
13932
+ if (isString) {
13933
+ filterProperties.contains = { type: "string" };
13934
+ filterProperties.startsWith = { type: "string" };
13935
+ filterProperties.endsWith = { type: "string" };
13936
+ filterProperties.mode = { type: "string", enum: ["default", "insensitive"] };
13915
13937
  }
13916
13938
  return {
13917
13939
  type: "object",
13918
13940
  properties: filterProperties
13919
13941
  };
13920
13942
  }
13921
- function whereInputToOpenApiSchema(target) {
13943
+ function columnToFilterSchema(col2, dialect = "openapi-3.1") {
13944
+ const filterSchema = filterFieldToOpenApiSchema(col2);
13945
+ const nullable = isNullableColumn(col2);
13946
+ return applyNullability(filterSchema, nullable, dialect);
13947
+ }
13948
+ function whereInputToOpenApiSchema(target, dialect = "openapi-3.1") {
13922
13949
  const columns = getColumnMap(target);
13923
13950
  const properties = {};
13924
13951
  for (const [key, col2] of Object.entries(columns)) {
13925
- properties[key] = filterFieldToOpenApiSchema(col2);
13952
+ properties[key] = columnToFilterSchema(col2, dialect);
13926
13953
  }
13927
13954
  return {
13928
13955
  type: "object",
@@ -13931,16 +13958,26 @@ function whereInputToOpenApiSchema(target) {
13931
13958
  }
13932
13959
 
13933
13960
  // src/dto/openapi/generators/relation-filter.ts
13934
- function relationFilterToOpenApiSchema(relation, options) {
13961
+ function relationFilterToOpenApiSchema(relation, options, dialect = "openapi-3.1", depth = 0) {
13935
13962
  if (relation.type === RelationKinds.BelongsTo || relation.type === RelationKinds.HasOne) {
13936
- return singleRelationFilterToOpenApiSchema(relation.target, options);
13963
+ return singleRelationFilterToOpenApiSchema(
13964
+ relation.target,
13965
+ options,
13966
+ dialect,
13967
+ depth
13968
+ );
13937
13969
  }
13938
13970
  if (relation.type === RelationKinds.HasMany || relation.type === RelationKinds.BelongsToMany) {
13939
- return manyRelationFilterToOpenApiSchema(relation.target, options);
13971
+ return manyRelationFilterToOpenApiSchema(
13972
+ relation.target,
13973
+ options,
13974
+ dialect,
13975
+ depth
13976
+ );
13940
13977
  }
13941
13978
  return { type: "object", properties: {} };
13942
13979
  }
13943
- function singleRelationFilterToOpenApiSchema(target, options) {
13980
+ function singleRelationFilterToOpenApiSchema(target, options, dialect = "openapi-3.1", depth = 0) {
13944
13981
  const columns = getColumnMap(target);
13945
13982
  const properties = {};
13946
13983
  const required = [];
@@ -13951,35 +13988,44 @@ function singleRelationFilterToOpenApiSchema(target, options) {
13951
13988
  if (options?.include && !options.include.includes(key)) {
13952
13989
  continue;
13953
13990
  }
13954
- properties[key] = columnToOpenApiSchema(col2);
13991
+ properties[key] = columnToFilterSchema(col2, dialect);
13955
13992
  if (col2.notNull || col2.primary) {
13956
13993
  required.push(key);
13957
13994
  }
13958
13995
  }
13996
+ if (depth > 0) {
13997
+ const tableDef = target;
13998
+ if (tableDef.relations) {
13999
+ for (const [relationName, relation] of Object.entries(tableDef.relations)) {
14000
+ properties[relationName] = relationFilterToOpenApiSchema(relation, void 0, dialect, depth - 1);
14001
+ }
14002
+ }
14003
+ }
13959
14004
  return {
13960
14005
  type: "object",
13961
14006
  properties,
13962
14007
  ...required.length > 0 && { required }
13963
14008
  };
13964
14009
  }
13965
- function manyRelationFilterToOpenApiSchema(target, options) {
14010
+ function manyRelationFilterToOpenApiSchema(target, options, dialect = "openapi-3.1", depth = 0) {
14011
+ const nestedSchema = depth > 0 ? nestedWhereInputToOpenApiSchema(target, depth, dialect) : {
14012
+ type: "object",
14013
+ properties: generateNestedProperties(target, options, dialect)
14014
+ };
13966
14015
  return {
13967
14016
  type: "object",
13968
14017
  properties: {
13969
14018
  some: {
13970
- type: "object",
13971
- description: "Filter related records that match all conditions",
13972
- properties: generateNestedProperties(target, options)
14019
+ ...nestedSchema,
14020
+ description: "Filter related records that match all conditions"
13973
14021
  },
13974
14022
  every: {
13975
- type: "object",
13976
- description: "Filter related records where all match conditions",
13977
- properties: generateNestedProperties(target, options)
14023
+ ...nestedSchema,
14024
+ description: "Filter related records where all match conditions"
13978
14025
  },
13979
14026
  none: {
13980
- type: "object",
13981
- description: "Filter where no related records match",
13982
- properties: generateNestedProperties(target, options)
14027
+ ...nestedSchema,
14028
+ description: "Filter where no related records match"
13983
14029
  },
13984
14030
  isEmpty: {
13985
14031
  type: "boolean",
@@ -13992,7 +14038,7 @@ function manyRelationFilterToOpenApiSchema(target, options) {
13992
14038
  }
13993
14039
  };
13994
14040
  }
13995
- function generateNestedProperties(target, options) {
14041
+ function generateNestedProperties(target, options, dialect = "openapi-3.1") {
13996
14042
  const columns = getColumnMap(target);
13997
14043
  const properties = {};
13998
14044
  for (const [key, col2] of Object.entries(columns)) {
@@ -14002,11 +14048,11 @@ function generateNestedProperties(target, options) {
14002
14048
  if (options?.include && !options.include.includes(key)) {
14003
14049
  continue;
14004
14050
  }
14005
- properties[key] = columnToOpenApiSchema(col2);
14051
+ properties[key] = columnToFilterSchema(col2, dialect);
14006
14052
  }
14007
14053
  return properties;
14008
14054
  }
14009
- function whereInputWithRelationsToOpenApiSchema(target, options) {
14055
+ function whereInputWithRelationsToOpenApiSchema(target, options, dialect = "openapi-3.1") {
14010
14056
  const columns = getColumnMap(target);
14011
14057
  const properties = {};
14012
14058
  const depth = options?.maxDepth ?? 3;
@@ -14017,7 +14063,7 @@ function whereInputWithRelationsToOpenApiSchema(target, options) {
14017
14063
  if (options?.columnInclude && !options.columnInclude.includes(key)) {
14018
14064
  continue;
14019
14065
  }
14020
- properties[key] = columnToOpenApiSchema(col2);
14066
+ properties[key] = columnToFilterSchema(col2, dialect);
14021
14067
  }
14022
14068
  const tableDef = target;
14023
14069
  if (tableDef.relations && depth > 0) {
@@ -14031,7 +14077,7 @@ function whereInputWithRelationsToOpenApiSchema(target, options) {
14031
14077
  properties[relationName] = relationFilterToOpenApiSchema(relation, {
14032
14078
  exclude: options?.columnExclude,
14033
14079
  include: options?.columnInclude
14034
- });
14080
+ }, dialect);
14035
14081
  }
14036
14082
  }
14037
14083
  return {
@@ -14039,32 +14085,19 @@ function whereInputWithRelationsToOpenApiSchema(target, options) {
14039
14085
  properties
14040
14086
  };
14041
14087
  }
14042
- function nestedWhereInputToOpenApiSchema(target, depth = 2) {
14088
+ function nestedWhereInputToOpenApiSchema(target, depth = 2, dialect = "openapi-3.1") {
14043
14089
  if (depth <= 0) {
14044
14090
  return { type: "object", properties: {} };
14045
14091
  }
14046
14092
  const columns = getColumnMap(target);
14047
14093
  const properties = {};
14048
14094
  for (const [key, col2] of Object.entries(columns)) {
14049
- properties[key] = columnToOpenApiSchema(col2);
14095
+ properties[key] = columnToFilterSchema(col2, dialect);
14050
14096
  }
14051
14097
  const tableDef = target;
14052
14098
  if (tableDef.relations) {
14053
14099
  for (const [relationName, relation] of Object.entries(tableDef.relations)) {
14054
- properties[relationName] = relationFilterToOpenApiSchema(relation);
14055
- if (depth > 1) {
14056
- if (relation.type === RelationKinds.BelongsTo || relation.type === RelationKinds.HasOne) {
14057
- properties[relationName] = singleRelationFilterToOpenApiSchema(relation.target);
14058
- } else if (relation.type === RelationKinds.HasMany || relation.type === RelationKinds.BelongsToMany) {
14059
- properties[relationName] = {
14060
- type: "object",
14061
- properties: {
14062
- some: nestedWhereInputToOpenApiSchema(relation.target, depth - 1),
14063
- every: nestedWhereInputToOpenApiSchema(relation.target, depth - 1)
14064
- }
14065
- };
14066
- }
14067
- }
14100
+ properties[relationName] = relationFilterToOpenApiSchema(relation, void 0, dialect, depth - 1);
14068
14101
  }
14069
14102
  }
14070
14103
  return {
@@ -14138,10 +14171,7 @@ function updateDtoWithRelationsToOpenApiSchema(target, _options) {
14138
14171
  if (col2.autoIncrement || col2.generated) {
14139
14172
  continue;
14140
14173
  }
14141
- properties[key] = {
14142
- ...columnToOpenApiSchema(col2),
14143
- nullable: true
14144
- };
14174
+ properties[key] = columnToOpenApiSchema(col2);
14145
14175
  }
14146
14176
  const tableDef = target;
14147
14177
  if (_options?.includeRelations !== false && tableDef.relations) {
@@ -14165,10 +14195,7 @@ function updateDtoToOpenApiSchemaForComponent(target) {
14165
14195
  if (col2.autoIncrement || col2.generated) {
14166
14196
  continue;
14167
14197
  }
14168
- properties[key] = {
14169
- ...columnToOpenApiSchema(col2),
14170
- nullable: true
14171
- };
14198
+ properties[key] = columnToOpenApiSchema(col2);
14172
14199
  }
14173
14200
  return {
14174
14201
  type: "object",
@@ -14238,7 +14265,7 @@ function createDtoToOpenApiSchemaForComponent(target) {
14238
14265
  properties
14239
14266
  };
14240
14267
  }
14241
- function whereInputWithRelationsToOpenApiSchema2(target, options) {
14268
+ function whereInputWithRelationsToOpenApiSchema2(target, options, dialect = "openapi-3.1") {
14242
14269
  const columns = getColumnMap(target);
14243
14270
  const properties = {};
14244
14271
  const depth = options?.maxDepth ?? 3;
@@ -14249,7 +14276,7 @@ function whereInputWithRelationsToOpenApiSchema2(target, options) {
14249
14276
  if (options?.columnInclude && !options.columnInclude.includes(key)) {
14250
14277
  continue;
14251
14278
  }
14252
- properties[key] = columnToOpenApiSchema(col2);
14279
+ properties[key] = columnToFilterSchema(col2, dialect);
14253
14280
  }
14254
14281
  const tableDef = target;
14255
14282
  if (tableDef.relations && depth > 0) {
@@ -14261,9 +14288,9 @@ function whereInputWithRelationsToOpenApiSchema2(target, options) {
14261
14288
  continue;
14262
14289
  }
14263
14290
  properties[relationName] = relationFilterToOpenApiSchema2(relation, {
14264
- exclude: options?.columnExclude,
14265
- include: options?.columnInclude
14266
- });
14291
+ exclude: options.columnExclude,
14292
+ include: options.columnInclude
14293
+ }, dialect);
14267
14294
  }
14268
14295
  }
14269
14296
  return {
@@ -14271,16 +14298,16 @@ function whereInputWithRelationsToOpenApiSchema2(target, options) {
14271
14298
  properties
14272
14299
  };
14273
14300
  }
14274
- function relationFilterToOpenApiSchema2(relation, options) {
14301
+ function relationFilterToOpenApiSchema2(relation, options, dialect = "openapi-3.1") {
14275
14302
  if (relation.type === RelationKinds.BelongsTo || relation.type === RelationKinds.HasOne) {
14276
- return singleRelationFilterToOpenApiSchema2(relation.target, options);
14303
+ return singleRelationFilterToOpenApiSchema2(relation.target, options, dialect);
14277
14304
  }
14278
14305
  if (relation.type === RelationKinds.HasMany || relation.type === RelationKinds.BelongsToMany) {
14279
14306
  return manyRelationFilterToOpenApiSchema2(relation.target);
14280
14307
  }
14281
14308
  return { type: "object", properties: {} };
14282
14309
  }
14283
- function singleRelationFilterToOpenApiSchema2(target, options) {
14310
+ function singleRelationFilterToOpenApiSchema2(target, options, dialect = "openapi-3.1") {
14284
14311
  const columns = getColumnMap(target);
14285
14312
  const properties = {};
14286
14313
  for (const [key, col2] of Object.entries(columns)) {
@@ -14290,7 +14317,7 @@ function singleRelationFilterToOpenApiSchema2(target, options) {
14290
14317
  if (options?.include && !options.include.includes(key)) {
14291
14318
  continue;
14292
14319
  }
14293
- properties[key] = columnToOpenApiSchema(col2);
14320
+ properties[key] = columnToFilterSchema(col2, dialect);
14294
14321
  }
14295
14322
  return {
14296
14323
  type: "object",
@@ -14331,7 +14358,7 @@ function generateNestedProperties2(target) {
14331
14358
  const columns = getColumnMap(target);
14332
14359
  const properties = {};
14333
14360
  for (const [key, col2] of Object.entries(columns)) {
14334
- properties[key] = columnToOpenApiSchema(col2);
14361
+ properties[key] = columnToFilterSchema(col2);
14335
14362
  }
14336
14363
  return properties;
14337
14364
  }
@@ -14360,6 +14387,67 @@ function parameterToRef(paramName) {
14360
14387
  function responseToRef(responseName) {
14361
14388
  return createRef(`responses/${responseName}`);
14362
14389
  }
14390
+ function canonicalizeSchema(schema) {
14391
+ if (typeof schema !== "object" || schema === null) {
14392
+ return schema;
14393
+ }
14394
+ if (Array.isArray(schema)) {
14395
+ return schema.map(canonicalizeSchema);
14396
+ }
14397
+ const canonical = {};
14398
+ const keys = Object.keys(schema).sort();
14399
+ for (const key of keys) {
14400
+ if (key === "description" || key === "example") {
14401
+ continue;
14402
+ }
14403
+ const value = schema[key];
14404
+ if (typeof value === "object" && value !== null) {
14405
+ canonical[key] = canonicalizeSchema(value);
14406
+ } else {
14407
+ canonical[key] = value;
14408
+ }
14409
+ }
14410
+ return canonical;
14411
+ }
14412
+ function computeSchemaHash(schema) {
14413
+ const canonical = canonicalizeSchema(schema);
14414
+ const json = JSON.stringify(canonical);
14415
+ let hash = 0;
14416
+ for (let i = 0; i < json.length; i++) {
14417
+ const char2 = json.charCodeAt(i);
14418
+ hash = (hash << 5) - hash + char2;
14419
+ hash = hash & hash;
14420
+ }
14421
+ const hex = Math.abs(hash).toString(16);
14422
+ return hex.padStart(8, "0").slice(0, 6);
14423
+ }
14424
+ function createDeterministicNamingState() {
14425
+ return {
14426
+ contentHashToName: /* @__PURE__ */ new Map(),
14427
+ nameToContentHash: /* @__PURE__ */ new Map()
14428
+ };
14429
+ }
14430
+ function getDeterministicComponentName(baseName, schema, state) {
14431
+ const hash = computeSchemaHash(schema);
14432
+ const normalizedBase = baseName.replace(/[^A-Za-z0-9_]/g, "");
14433
+ const existingName = state.contentHashToName.get(hash);
14434
+ if (existingName) {
14435
+ return existingName;
14436
+ }
14437
+ if (!state.nameToContentHash.has(normalizedBase)) {
14438
+ state.contentHashToName.set(hash, normalizedBase);
14439
+ state.nameToContentHash.set(normalizedBase, hash);
14440
+ return normalizedBase;
14441
+ }
14442
+ const existingHash = state.nameToContentHash.get(normalizedBase);
14443
+ if (existingHash === hash) {
14444
+ return normalizedBase;
14445
+ }
14446
+ const uniqueName = `${normalizedBase}_${hash}`;
14447
+ state.contentHashToName.set(hash, uniqueName);
14448
+ state.nameToContentHash.set(uniqueName, hash);
14449
+ return uniqueName;
14450
+ }
14363
14451
  function replaceWithRefs(schema, schemaMap, path = "components/schemas") {
14364
14452
  if (typeof schema === "object" && schema !== null) {
14365
14453
  if ("$ref" in schema) {
@@ -14581,6 +14669,7 @@ function pagedResponseToOpenApiSchema(itemSchema) {
14581
14669
  aliasRef,
14582
14670
  and,
14583
14671
  applyFilter,
14672
+ applyNullability,
14584
14673
  arrayAppend,
14585
14674
  asType,
14586
14675
  ascii,
@@ -14598,6 +14687,7 @@ function pagedResponseToOpenApiSchema(itemSchema) {
14598
14687
  bootstrapEntities,
14599
14688
  buildFilterExpression,
14600
14689
  calculateTotalPages,
14690
+ canonicalizeSchema,
14601
14691
  caseWhen,
14602
14692
  cast,
14603
14693
  cbrt,
@@ -14612,10 +14702,12 @@ function pagedResponseToOpenApiSchema(itemSchema) {
14612
14702
  col,
14613
14703
  collate,
14614
14704
  columnOperand,
14705
+ columnToFilterSchema,
14615
14706
  columnToOpenApiSchema,
14616
14707
  columnTypeToOpenApiFormat,
14617
14708
  columnTypeToOpenApiType,
14618
14709
  computePaginationMetadata,
14710
+ computeSchemaHash,
14619
14711
  concat,
14620
14712
  concatWs,
14621
14713
  correlateBy,
@@ -14624,6 +14716,7 @@ function pagedResponseToOpenApiSchema(itemSchema) {
14624
14716
  count,
14625
14717
  countAll,
14626
14718
  createApiComponentsSection,
14719
+ createDeterministicNamingState,
14627
14720
  createDtoToOpenApiSchema,
14628
14721
  createEntityFromRow,
14629
14722
  createEntityProxy,
@@ -14682,6 +14775,8 @@ function pagedResponseToOpenApiSchema(itemSchema) {
14682
14775
  getColumn,
14683
14776
  getColumnMap,
14684
14777
  getDecoratorMetadata,
14778
+ getDeterministicComponentName,
14779
+ getOpenApiVersionForDialect,
14685
14780
  getSchemaIntrospector,
14686
14781
  getTableDefFromEntity,
14687
14782
  greatest,
@@ -14709,6 +14804,7 @@ function pagedResponseToOpenApiSchema(itemSchema) {
14709
14804
  isFunctionNode,
14710
14805
  isNotNull,
14711
14806
  isNull,
14807
+ isNullableColumn,
14712
14808
  isOperandNode,
14713
14809
  isTableDef,
14714
14810
  isValueOperandInput,