@kubb/plugin-ts 5.3.0-canary.20261025T201031 → 5.3.1

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
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- //#region \0rolldown/runtime.js
5
+ // \0rolldown/runtime.js
6
6
  var __defProp = Object.defineProperty;
7
7
  var __name = (target, value) => __defProp(target, "name", {
8
8
  value,
@@ -17,13 +17,12 @@ var __exportAll = (all, no_symbols) => {
17
17
  if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
18
18
  return target;
19
19
  };
20
- //#endregion
21
20
  let kubb_jsx = require("kubb/jsx");
22
21
  let kubb_kit = require("kubb/kit");
23
22
  let yuku_codegen = require("yuku-codegen");
24
23
  let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
25
24
  let _kubb_parser_ts = require("@kubb/parser-ts");
26
- //#region ../../internals/utils/src/casing.ts
25
+ // ../../internals/utils/src/casing.ts
27
26
  /**
28
27
  * Shared implementation for camelCase and PascalCase conversion.
29
28
  * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
@@ -82,7 +81,7 @@ function pascalCase(text, { prefix = "", suffix = "" } = {}) {
82
81
  * `snakeCase('Hello-World') // 'hello_world'`
83
82
  */
84
83
  function snakeCase(text, { prefix = "", suffix = "" } = {}) {
85
- return `${prefix} ${text} ${suffix}`.trim().replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[\s\-.]+/g, "_").replace(/[^a-zA-Z0-9_]/g, "").toLowerCase().split("_").filter(Boolean).join("_");
84
+ return `${prefix} ${text} ${suffix}`.trim().replace(/([a-z\d])([A-Z])/g, "$1_$2").replace(/[\s\-.]+/g, "_").replace(/[^a-zA-Z0-9_]/g, "").toLowerCase().split("_").filter(Boolean).join("_");
86
85
  }
87
86
  /**
88
87
  * Converts `text` to SCREAMING_SNAKE_CASE.
@@ -96,8 +95,7 @@ function screamingSnakeCase(text, { prefix = "", suffix = "" } = {}) {
96
95
  suffix
97
96
  }).toUpperCase();
98
97
  }
99
- //#endregion
100
- //#region ../../internals/utils/src/reserved.ts
98
+ // ../../internals/utils/src/reserved.ts
101
99
  /**
102
100
  * JavaScript and Java reserved words.
103
101
  * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
@@ -105,6 +103,7 @@ function screamingSnakeCase(text, { prefix = "", suffix = "" } = {}) {
105
103
  const reservedWords = /* @__PURE__ */ new Set([
106
104
  "abstract",
107
105
  "arguments",
106
+ "await",
108
107
  "boolean",
109
108
  "break",
110
109
  "byte",
@@ -235,8 +234,7 @@ function ensureValidVarName(name) {
235
234
  function isIdentifier(name) {
236
235
  return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
237
236
  }
238
- //#endregion
239
- //#region ../../internals/utils/src/strings.ts
237
+ // ../../internals/utils/src/strings.ts
240
238
  /**
241
239
  * Strips a single matching pair of `"..."`, `'...'`, or `` `...` `` from both ends of `text`.
242
240
  * Returns the string unchanged when no balanced quote pair is found.
@@ -283,8 +281,7 @@ function stringify(value) {
283
281
  function jsDocEscape(input) {
284
282
  return `${input}`.replace(/^(\s*)@/gm, "$1\\@");
285
283
  }
286
- //#endregion
287
- //#region ../../internals/utils/src/fs.ts
284
+ // ../../internals/utils/src/fs.ts
288
285
  /**
289
286
  * Builds a nested file path from a dotted name. Splits on dots that precede a letter
290
287
  * (so version numbers embedded in operationIds like `v2025.0` stay intact), camelCases
@@ -308,8 +305,7 @@ function toFilePath(name, caseLast = camelCase) {
308
305
  const parts = name.split(/\.(?=[a-zA-Z])/);
309
306
  return parts.map((part, i) => i === parts.length - 1 ? caseLast(part) : camelCase(part)).filter(Boolean).join("/");
310
307
  }
311
- //#endregion
312
- //#region src/factory.ts
308
+ // src/factory.ts
313
309
  var factory_exports = /* @__PURE__ */ __exportAll({
314
310
  appendJSDocToNode: () => appendJSDocToNode,
315
311
  buildIndexSignatures: () => buildIndexSignatures,
@@ -700,11 +696,20 @@ function createUrlTemplateType(path) {
700
696
  };
701
697
  }
702
698
  /**
703
- * Converts a primitive const value to a TypeScript literal type.
699
+ * Converts a const value to a literal type, preserving nested arrays and objects.
704
700
  */
705
701
  function constToTypeNode(value, format) {
706
- if (format === "boolean") return createLiteralType(value === true);
707
- return createLiteralType(format === "number" && typeof value === "number" ? value : String(value));
702
+ if (value === null) return keywordTypeNodes.null;
703
+ if (Array.isArray(value)) return {
704
+ type: "TSTupleType",
705
+ elementTypes: value.map((item) => constToTypeNode(item))
706
+ };
707
+ if (typeof value === "object") return createTypeLiteralNode(Object.entries(value).map(([name, item]) => createPropertySignature({
708
+ name,
709
+ type: constToTypeNode(item)
710
+ })));
711
+ if ((format ?? typeof value) === "boolean") return createLiteralType(value === true);
712
+ return createLiteralType((format ?? typeof value) === "number" && typeof value === "number" ? value : String(value));
708
713
  }
709
714
  /**
710
715
  * Returns a `Date` reference type when `representation` is `'date'`, otherwise falls back to `string`.
@@ -798,8 +803,7 @@ function buildIndexSignatures(node, propertyCount, printNode) {
798
803
  accessibility: null
799
804
  }];
800
805
  }
801
- //#endregion
802
- //#region src/components/Enum.tsx
806
+ // src/components/Enum.tsx
803
807
  /**
804
808
  * Resolves the runtime identifier name and the TypeScript type name for an enum schema node.
805
809
  *
@@ -813,7 +817,7 @@ function buildIndexSignatures(node, propertyCount, printNode) {
813
817
  function getEnumNames({ node, enum: enumOptions, resolver }) {
814
818
  const resolved = resolver.name(node.name);
815
819
  return {
816
- enumName: enumOptions.constCasing === "pascalCase" ? resolved : camelCase(node.name),
820
+ enumName: enumOptions.constCasing === "pascalCase" ? resolved : ensureValidVarName(camelCase(node.name)),
817
821
  typeName: enumOptions.type === "asConst" ? resolver.enum.keyName(node, enumOptions.typeSuffix) : resolved
818
822
  };
819
823
  }
@@ -866,8 +870,7 @@ function Enum({ node, enum: enumOptions, resolver }) {
866
870
  children: typeNode
867
871
  })] });
868
872
  }
869
- //#endregion
870
- //#region ../../internals/shared/src/operation.ts
873
+ // ../../internals/shared/src/operation.ts
871
874
  /**
872
875
  * Maps a content type to the PascalCase suffix used to name per-content-type variants
873
876
  * (e.g. `application/json` → `Json`, `application/xml` → `Xml`, `multipart/form-data` → `FormData`).
@@ -950,7 +953,10 @@ function getOperationParameters(node) {
950
953
  * shape from the same inputs. `primitive: 'object'` is a no-op for the TS printer and tells the Zod
951
954
  * printer to emit `z.object(…)` rather than a record.
952
955
  */
953
- function buildOptionsSchema(node, resolver) {
956
+ function hasRequestContentTypeChoice(node) {
957
+ return (node.requestBody?.content ?? []).filter((entry) => entry.schema).length > 1;
958
+ }
959
+ function buildOptionsSchema(node, resolver, { pairContentTypes = false } = {}) {
954
960
  const { path, query, header } = getOperationParameters(node);
955
961
  const hasBody = Boolean(node.requestBody?.content?.[0]?.schema);
956
962
  const createNever = () => kubb_kit.ast.factory.createSchema({
@@ -975,29 +981,57 @@ function buildOptionsSchema(node, resolver) {
975
981
  resolve: resolver.param.headers
976
982
  }
977
983
  ];
978
- return kubb_kit.ast.factory.createSchema({
984
+ const createOptions = (body, extra = []) => kubb_kit.ast.factory.createSchema({
979
985
  type: "object",
980
986
  primitive: "object",
981
987
  deprecated: node.deprecated,
982
- properties: [kubb_kit.ast.factory.createProperty({
983
- name: "body",
984
- required: hasBody,
985
- schema: hasBody ? kubb_kit.ast.factory.createSchema({
986
- type: "ref",
987
- name: resolver.response.body(node)
988
- }) : createNever()
989
- }), ...groups.map(({ name, params, resolve }) => {
990
- const required = params.some((param) => param.required);
991
- return kubb_kit.ast.factory.createProperty({
992
- name,
993
- required,
994
- schema: params.length > 0 ? kubb_kit.ast.factory.createSchema({
995
- type: "ref",
996
- name: resolve.call(resolver.param, node, params[0]),
997
- optional: !required
998
- }) : createNever()
999
- });
1000
- })]
988
+ properties: [
989
+ kubb_kit.ast.factory.createProperty({
990
+ name: "body",
991
+ required: hasBody,
992
+ schema: body
993
+ }),
994
+ ...groups.map(({ name, params, resolve }) => {
995
+ const required = params.some((param) => param.required);
996
+ return kubb_kit.ast.factory.createProperty({
997
+ name,
998
+ required,
999
+ schema: params.length > 0 ? kubb_kit.ast.factory.createSchema({
1000
+ type: "ref",
1001
+ name: resolve.call(resolver.param, node, params[0]),
1002
+ optional: !required
1003
+ }) : createNever()
1004
+ });
1005
+ }),
1006
+ ...extra
1007
+ ]
1008
+ });
1009
+ const variants = pairContentTypes && hasRequestContentTypeChoice(node) ? resolveContentTypeVariants(node.requestBody?.content ?? [], resolver.response.body(node)) : [];
1010
+ if (variants.length < 2) return createOptions(hasBody ? kubb_kit.ast.factory.createSchema({
1011
+ type: "ref",
1012
+ name: resolver.response.body(node)
1013
+ }) : createNever());
1014
+ return kubb_kit.ast.factory.createSchema({
1015
+ type: "union",
1016
+ members: variants.map((variant, index) => createOptions(kubb_kit.ast.factory.createSchema({
1017
+ type: "ref",
1018
+ name: variant.name
1019
+ }), [kubb_kit.ast.factory.createProperty({
1020
+ name: "contentType",
1021
+ required: index > 0,
1022
+ schema: kubb_kit.ast.factory.createSchema({
1023
+ type: "object",
1024
+ primitive: "object",
1025
+ properties: [kubb_kit.ast.factory.createProperty({
1026
+ name: "request",
1027
+ required: true,
1028
+ schema: kubb_kit.ast.factory.createSchema({
1029
+ type: "enum",
1030
+ enumValues: [variant.contentType]
1031
+ })
1032
+ })]
1033
+ })
1034
+ })]))
1001
1035
  });
1002
1036
  }
1003
1037
  /**
@@ -1064,17 +1098,24 @@ function isSuccessStatusCode(statusCode) {
1064
1098
  const code = getStatusCodeNumber(statusCode);
1065
1099
  return code !== null && code >= 200 && code < 300;
1066
1100
  }
1067
- //#endregion
1068
- //#region ../../internals/shared/src/resolver.ts
1101
+ // ../../internals/shared/src/resolver.ts
1069
1102
  /**
1070
- * Resolves a single operation parameter name with the
1071
- * `<operationId> <in> <name>` template.
1103
+ * Builds the allocation key for a declaration an operation owns. `scope` names which declaration
1104
+ * it is, so two of them never share an allocation even when a custom resolver gives both the same
1105
+ * name. Leave `scope` empty for the operation's own declaration.
1072
1106
  *
1073
1107
  * @example
1074
- * `operationParamName.call(resolver, node, param) // → 'DeletePetPathPetId'`
1108
+ * ```ts
1109
+ * resolver.resolveName({ key: operationKey(node, 'response', 'status', 404), name })
1110
+ * ```
1075
1111
  */
1076
- function operationParamName(node, param) {
1077
- return this.name(`${node.operationId} ${param.in} ${param.name}`);
1112
+ function operationKey(node, ...scope) {
1113
+ return [
1114
+ "operation",
1115
+ node.method,
1116
+ node.path,
1117
+ ...scope.map(String)
1118
+ ];
1078
1119
  }
1079
1120
  /**
1080
1121
  * Builds the shared `param` namespace. Spread the result into `createResolver`
@@ -1087,15 +1128,33 @@ function operationParamName(node, param) {
1087
1128
  */
1088
1129
  function createOperationParamResolver() {
1089
1130
  return {
1090
- name: operationParamName,
1131
+ name(node, param) {
1132
+ const name = this.name(`${node.operationId} ${param.in} ${param.name}`);
1133
+ return this.resolveName({
1134
+ key: operationKey(node, "param", "name", param.in, param.name),
1135
+ name
1136
+ });
1137
+ },
1091
1138
  path(node) {
1092
- return this.name(`${node.operationId} Path`);
1139
+ const name = this.name(`${node.operationId} Path`);
1140
+ return this.resolveName({
1141
+ key: operationKey(node, "param", "path"),
1142
+ name
1143
+ });
1093
1144
  },
1094
1145
  query(node) {
1095
- return this.name(`${node.operationId} Query`);
1146
+ const name = this.name(`${node.operationId} Query`);
1147
+ return this.resolveName({
1148
+ key: operationKey(node, "param", "query"),
1149
+ name
1150
+ });
1096
1151
  },
1097
1152
  headers(node) {
1098
- return this.name(`${node.operationId} Headers`);
1153
+ const name = this.name(`${node.operationId} Headers`);
1154
+ return this.resolveName({
1155
+ key: operationKey(node, "param", "headers"),
1156
+ name
1157
+ });
1099
1158
  }
1100
1159
  };
1101
1160
  }
@@ -1112,16 +1171,32 @@ function createOperationParamResolver() {
1112
1171
  function createOperationResponseResolver() {
1113
1172
  return {
1114
1173
  status(node, statusCode) {
1115
- return this.name(`${node.operationId} Status ${statusCode}`);
1174
+ const name = this.name(`${node.operationId} Status ${statusCode}`);
1175
+ return this.resolveName({
1176
+ key: operationKey(node, "response", "status", statusCode),
1177
+ name
1178
+ });
1116
1179
  },
1117
1180
  body(node) {
1118
- return this.name(`${node.operationId} Body`);
1181
+ const name = this.name(`${node.operationId} Body`);
1182
+ return this.resolveName({
1183
+ key: operationKey(node, "response", "body"),
1184
+ name
1185
+ });
1119
1186
  },
1120
1187
  responses(node) {
1121
- return this.name(`${node.operationId} Responses`);
1188
+ const name = this.name(`${node.operationId} Responses`);
1189
+ return this.resolveName({
1190
+ key: operationKey(node, "response", "responses"),
1191
+ name
1192
+ });
1122
1193
  },
1123
1194
  response(node) {
1124
- return this.name(`${node.operationId} Response`);
1195
+ const name = this.name(`${node.operationId} Response`);
1196
+ return this.resolveName({
1197
+ key: operationKey(node, "response", "response"),
1198
+ name
1199
+ });
1125
1200
  }
1126
1201
  };
1127
1202
  }
@@ -1139,8 +1214,7 @@ function createCasedFile(caseLast) {
1139
1214
  return `${toFilePath(name, caseLast)}${extname}`;
1140
1215
  } };
1141
1216
  }
1142
- //#endregion
1143
- //#region ../../internals/shared/src/group.ts
1217
+ // ../../internals/shared/src/group.ts
1144
1218
  /**
1145
1219
  * Builds the `group` config a Kubb plugin passes to `ctx.setOptions`, applying the
1146
1220
  * shared default naming so every plugin groups output consistently:
@@ -1170,8 +1244,7 @@ function createGroupConfig(group) {
1170
1244
  name: group.name ? group.name : defaultName
1171
1245
  };
1172
1246
  }
1173
- //#endregion
1174
- //#region ../../internals/shared/src/schemaTraversal.ts
1247
+ // ../../internals/shared/src/schemaTraversal.ts
1175
1248
  /**
1176
1249
  * Maps each property of an object schema to its transformed output. Pairs every result with the
1177
1250
  * original property so the printer keeps full control over modifiers, getters, and key syntax.
@@ -1199,8 +1272,38 @@ function mapSchemaItems(node, transform) {
1199
1272
  output: transform(schema)
1200
1273
  }));
1201
1274
  }
1202
- //#endregion
1203
- //#region src/utils.ts
1275
+ // src/utils.ts
1276
+ /**
1277
+ * Renames inline enum declarations and their uses together.
1278
+ */
1279
+ function resolveInlineEnumNames({ node, owner, resolver, enumOptions }) {
1280
+ return kubb_kit.ast.transform(node, { schema(child) {
1281
+ if (child === node || child.type !== "enum" || !child.name) return;
1282
+ const name = resolver.resolveName({
1283
+ key: [
1284
+ "enum",
1285
+ owner,
1286
+ child.pointer ?? child.name
1287
+ ],
1288
+ name: child.name,
1289
+ normalize: (value) => {
1290
+ const { enumName, typeName } = getEnumNames({
1291
+ node: {
1292
+ ...child,
1293
+ name: value
1294
+ },
1295
+ enum: enumOptions,
1296
+ resolver
1297
+ });
1298
+ return enumOptions.type === "literal" ? [typeName] : [enumName, typeName];
1299
+ }
1300
+ });
1301
+ return name === child.name ? void 0 : {
1302
+ ...child,
1303
+ name
1304
+ };
1305
+ } });
1306
+ }
1204
1307
  function enumTypeName({ resolver, name, enumOptions, isEnum }) {
1205
1308
  return isEnum && enumOptions?.type === "asConst" && enumOptions.typeSuffix ? resolver.enum.keyName({ name }, enumOptions.typeSuffix) : resolver.name(name);
1206
1309
  }
@@ -1233,6 +1336,7 @@ function formatExample(value) {
1233
1336
  function buildPropertyJSDocComments(schema, optional) {
1234
1337
  const meta = (0, kubb_kit.syncSchemaRef)(schema);
1235
1338
  const isArray = meta?.primitive === "array";
1339
+ const isNumeric = meta?.primitive === "number" || meta?.primitive === "integer" || meta?.primitive === "bigint";
1236
1340
  const hasDescription = meta && "description" in meta && meta.description;
1237
1341
  const formatComment = meta && "format" in meta && meta.format ? hasDescription ? [" ", `Format: \`${meta.format}\``] : ["@description", `Format: \`${meta.format}\``] : [];
1238
1342
  const exampleValues = meta?.examples ?? [];
@@ -1240,8 +1344,8 @@ function buildPropertyJSDocComments(schema, optional) {
1240
1344
  hasDescription ? `@description ${jsDocEscape(meta.description)}` : null,
1241
1345
  ...formatComment,
1242
1346
  meta && "deprecated" in meta && meta.deprecated ? "@deprecated" : null,
1243
- !isArray && meta && "min" in meta && meta.min !== void 0 ? `@minLength ${meta.min}` : null,
1244
- !isArray && meta && "max" in meta && meta.max !== void 0 ? `@maxLength ${meta.max}` : null,
1347
+ !isArray && meta && "min" in meta && meta.min !== void 0 ? `@${isNumeric ? "minimum" : "minLength"} ${meta.min}` : null,
1348
+ !isArray && meta && "max" in meta && meta.max !== void 0 ? `@${isNumeric ? "maximum" : "maxLength"} ${meta.max}` : null,
1245
1349
  meta && "pattern" in meta && meta.pattern ? `@pattern ${meta.pattern}` : null,
1246
1350
  meta && "default" in meta && meta.default !== void 0 ? `@default ${"primitive" in meta && meta.primitive === "string" && typeof meta.default === "string" ? stringify(meta.default) : formatExample(meta.default)}` : null,
1247
1351
  ...exampleValues.map((example) => `@example ${formatExample(example)}`)
@@ -1281,8 +1385,7 @@ function buildResponseUnion(node, { resolver }) {
1281
1385
  }))
1282
1386
  });
1283
1387
  }
1284
- //#endregion
1285
- //#region src/printers/printerTs.ts
1388
+ // src/printers/printerTs.ts
1286
1389
  const { isNonNullable } = factory_exports;
1287
1390
  /**
1288
1391
  * Adapts user overrides, which work in strings, to the node-based printer: `this.transform` hands them printed
@@ -1366,6 +1469,7 @@ const printerTs = kubb_kit.ast.createPrinter((options) => {
1366
1469
  },
1367
1470
  enum(node) {
1368
1471
  const values = kubb_kit.ast.getSchemaLiteralValues(node);
1472
+ if (values.some((value) => value !== null && typeof value === "object")) return createUnionDeclaration({ nodes: values.map((value) => constToTypeNode(value)) });
1369
1473
  if (this.options.enum.type === "inlineLiteral" || !node.name || isInlineConstEnum(node, this.options.enumSchemaNames)) return createUnionDeclaration({ nodes: values.filter((v) => v !== null && v !== void 0).map((value) => constToTypeNode(value, typeof value)).filter(isNonNullable) });
1370
1474
  return createTypeReferenceNode(enumTypeName({
1371
1475
  resolver: this.options.resolver,
@@ -1400,6 +1504,12 @@ const printerTs = kubb_kit.ast.createPrinter((options) => {
1400
1504
  },
1401
1505
  object(node) {
1402
1506
  const { transform, options } = this;
1507
+ const keySchema = node.propertyNames && (0, kubb_kit.syncSchemaRef)(node.propertyNames);
1508
+ if (!node.properties.length && !Object.keys(node.patternProperties ?? {}).length && node.propertyNames && keySchema?.type === "enum" && node.additionalProperties !== false) {
1509
+ const keyType = transform(node.propertyNames) ?? keywordTypeNodes.string;
1510
+ const valueSchema = typeof node.additionalProperties === "object" ? node.additionalProperties : kubb_kit.ast.factory.createSchema({ type: "unknown" });
1511
+ return createTypeReferenceNode("Partial", [createTypeReferenceNode("Record", [keyType, buildPropertyType(valueSchema, transform(valueSchema) ?? keywordTypeNodes.unknown, options.optionalType, false)])]);
1512
+ }
1403
1513
  const addsQuestionToken = options.optionalType === "questionToken" || options.optionalType === "questionTokenAndUndefined";
1404
1514
  const propertyNodes = mapSchemaProperties(node, (schema) => transform(schema)).map(({ name, property, output }) => {
1405
1515
  const baseType = output ?? keywordTypeNodes.unknown;
@@ -1451,8 +1561,7 @@ const printerTs = kubb_kit.ast.createPrinter((options) => {
1451
1561
  }
1452
1562
  };
1453
1563
  });
1454
- //#endregion
1455
- //#region src/components/Type.tsx
1564
+ // src/components/Type.tsx
1456
1565
  function Type({ name, node, printer, enum: enumOptions, resolver, inline }) {
1457
1566
  if (inline) {
1458
1567
  const withoutEnums = kubb_kit.ast.transform(node, { schema: (n) => n.type === kubb_kit.ast.schemaTypes.enum && n.name ? {
@@ -1504,8 +1613,7 @@ function Type({ name, node, printer, enum: enumOptions, resolver, inline }) {
1504
1613
  children: output
1505
1614
  })] });
1506
1615
  }
1507
- //#endregion
1508
- //#region src/generators/typeGenerator.tsx
1616
+ // src/generators/typeGenerator.tsx
1509
1617
  /**
1510
1618
  * Built-in generator for `@kubb/plugin-ts`. Emits one TypeScript file per
1511
1619
  * schema in the spec plus per-operation request, response, and parameter
@@ -1518,6 +1626,12 @@ const typeGenerator = (0, kubb_kit.defineGenerator)({
1518
1626
  schema(node, ctx) {
1519
1627
  const { enum: enumOptions, syntaxType, optionalType, arrayType, output, group, printer } = ctx.options;
1520
1628
  const { config, resolver, root } = ctx;
1629
+ if (enumOptions.type !== "inlineLiteral") node = resolveInlineEnumNames({
1630
+ node,
1631
+ owner: node.name ?? "",
1632
+ resolver,
1633
+ enumOptions
1634
+ });
1521
1635
  if (!node.name) return;
1522
1636
  const enumSchemaNames = new Set(ctx.meta.enumNames);
1523
1637
  const importName = (schemaName) => enumTypeName({
@@ -1625,6 +1739,12 @@ const typeGenerator = (0, kubb_kit.defineGenerator)({
1625
1739
  }) : null;
1626
1740
  function renderSchemaType({ schema, name, keysToOmit }) {
1627
1741
  if (!schema) return null;
1742
+ if (!inline && enumOptions.type !== "inlineLiteral") schema = resolveInlineEnumNames({
1743
+ node: schema,
1744
+ owner: node.operationId,
1745
+ resolver,
1746
+ enumOptions
1747
+ });
1628
1748
  const imports = resolver.imports({
1629
1749
  node: schema,
1630
1750
  root,
@@ -1734,13 +1854,13 @@ const typeGenerator = (0, kubb_kit.defineGenerator)({
1734
1854
  schema: primary?.schema ? {
1735
1855
  ...primary.schema,
1736
1856
  pointer: res.pointer ?? primary.schema.pointer
1737
- } : null,
1857
+ } : kubb_kit.ast.factory.createSchema({ type: "unknown" }),
1738
1858
  name: resolver.response.status(node, res.statusCode),
1739
1859
  keysToOmit: primary?.keysToOmit
1740
1860
  });
1741
1861
  });
1742
1862
  const optionsType = renderSchemaType({
1743
- schema: buildOptionsSchema(node, resolver),
1863
+ schema: buildOptionsSchema(node, resolver, { pairContentTypes: true }),
1744
1864
  name: resolver.response.options(node)
1745
1865
  });
1746
1866
  const responsesType = renderSchemaType({
@@ -1749,13 +1869,12 @@ const typeGenerator = (0, kubb_kit.defineGenerator)({
1749
1869
  });
1750
1870
  function buildResponseType() {
1751
1871
  const hasSchema = (res) => (res.content ?? []).some((entry) => entry.schema);
1752
- if (!node.responses.some(hasSchema)) return null;
1753
1872
  const responseName = resolver.response.response(node);
1754
1873
  const responsesWithSchema = node.responses.filter(hasSchema);
1755
1874
  if (new Set(responsesWithSchema.flatMap((res) => (res.content ?? []).flatMap((entry) => entry.schema ? kubb_kit.ast.collectImportedRefNames(entry.schema).map(importName) : []))).has(responseName)) return null;
1756
1875
  return renderSchemaType({
1757
1876
  schema: {
1758
- ...buildResponseUnion(node, { resolver }),
1877
+ ...buildResponseUnion(node, { resolver }) ?? kubb_kit.ast.factory.createSchema({ type: "unknown" }),
1759
1878
  description: "Union of all possible responses"
1760
1879
  },
1761
1880
  name: responseName
@@ -1793,22 +1912,18 @@ const typeGenerator = (0, kubb_kit.defineGenerator)({
1793
1912
  });
1794
1913
  }
1795
1914
  });
1796
- //#endregion
1797
- //#region kubb-extension.json
1915
+ // kubb-extension.json
1798
1916
  var compatibility = {
1799
- "kubb": ">=5.14.0",
1917
+ "kubb": ">=5.14.6",
1800
1918
  "node": ">=22.22"
1801
1919
  };
1802
- //#endregion
1803
- //#region package.json
1804
- var version = "5.3.0-canary.20261025T201031";
1805
- //#endregion
1806
- //#region src/resolvers/resolverTs.ts
1920
+ // package.json
1921
+ var version = "5.3.1";
1922
+ // src/resolvers/resolverTs.ts
1807
1923
  /**
1808
1924
  * Default resolver used by `@kubb/plugin-ts`. Decides the names and file paths
1809
- * for every generated TypeScript type. Import this in other plugins that need
1810
- * to reference the exact names `plugin-ts` produces without duplicating the
1811
- * casing/file-layout rules.
1925
+ * for generated TypeScript types. Other plugins should read the build's resolver
1926
+ * through `driver.getResolver(pluginTsName)` to share its name allocations.
1812
1927
  *
1813
1928
  * The `default` helpers are supplied by `createResolver`. This plugin overrides the top-level `name`
1814
1929
  * to use PascalCase for value and type names and `file` to write PascalCase file paths (dotted names
@@ -1833,15 +1948,18 @@ const resolverTs = (0, kubb_kit.createResolver)({
1833
1948
  response: {
1834
1949
  ...createOperationResponseResolver(),
1835
1950
  options(node) {
1836
- return this.name(`${node.operationId} Options`);
1951
+ const name = this.name(`${node.operationId} Options`);
1952
+ return this.resolveName({
1953
+ key: operationKey(node, "response", "options"),
1954
+ name
1955
+ });
1837
1956
  }
1838
1957
  },
1839
1958
  enum: { keyName(node, enumTypeSuffix = "key") {
1840
1959
  return `${this.name(node.name ?? "")}${enumTypeSuffix}`;
1841
1960
  } }
1842
1961
  });
1843
- //#endregion
1844
- //#region src/plugin.ts
1962
+ // src/plugin.ts
1845
1963
  /**
1846
1964
  * Canonical plugin name for `@kubb/plugin-ts`. Used for driver lookups and
1847
1965
  * cross-plugin dependency references.
@@ -1907,8 +2025,7 @@ const pluginTs = (0, kubb_kit.defineExtension)({
1907
2025
  };
1908
2026
  }
1909
2027
  });
1910
- //#endregion
1911
- //#region src/printers/functionParams.ts
2028
+ // src/printers/functionParams.ts
1912
2029
  /**
1913
2030
  * Narrows a {@link TypeExpression} to a {@link TypeLiteralNode}.
1914
2031
  */
@@ -2017,8 +2134,7 @@ function createFunctionParameters(props = {}) {
2017
2134
  ...props
2018
2135
  };
2019
2136
  }
2020
- //#endregion
2021
- //#region src/printers/functionPrinter.ts
2137
+ // src/printers/functionPrinter.ts
2022
2138
  /**
2023
2139
  * Ordering priority for function parameters: lower = sorted earlier.
2024
2140
  */
@@ -2161,7 +2277,6 @@ function functionPrinter(options) {
2161
2277
  }
2162
2278
  };
2163
2279
  }
2164
- //#endregion
2165
2280
  exports.Enum = Enum;
2166
2281
  exports.Type = Type;
2167
2282
  exports.buildParams = buildParams;