@kubb/plugin-ts 5.0.0-beta.81 → 5.0.0-beta.85

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
@@ -37,13 +37,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
37
37
  enumerable: true
38
38
  }) : target, mod));
39
39
  //#endregion
40
- let _kubb_ast_utils = require("@kubb/ast/utils");
41
40
  let _kubb_parser_ts = require("@kubb/parser-ts");
42
- let _kubb_renderer_jsx = require("@kubb/renderer-jsx");
41
+ let kubb_jsx = require("kubb/jsx");
42
+ let kubb_kit = require("kubb/kit");
43
43
  let typescript = require("typescript");
44
44
  typescript = __toESM(typescript, 1);
45
- let _kubb_renderer_jsx_jsx_runtime = require("@kubb/renderer-jsx/jsx-runtime");
46
- let _kubb_core = require("@kubb/core");
45
+ let kubb_jsx_jsx_runtime = require("kubb/jsx/jsx-runtime");
47
46
  //#region ../../internals/utils/src/casing.ts
48
47
  /**
49
48
  * Shared implementation for camelCase and PascalCase conversion.
@@ -255,6 +254,67 @@ function ensureValidVarName(name) {
255
254
  return `_${name}`;
256
255
  }
257
256
  //#endregion
257
+ //#region ../../internals/utils/src/strings.ts
258
+ /**
259
+ * Strips a single matching pair of `"..."`, `'...'`, or `` `...` `` from both ends of `text`.
260
+ * Returns the string unchanged when no balanced quote pair is found.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * trimQuotes('"hello"') // 'hello'
265
+ * trimQuotes('hello') // 'hello'
266
+ * ```
267
+ */
268
+ function trimQuotes(text) {
269
+ if (text.length >= 2) {
270
+ const first = text[0];
271
+ const last = text[text.length - 1];
272
+ if (first === "\"" && last === "\"" || first === "'" && last === "'" || first === "`" && last === "`") return text.slice(1, -1);
273
+ }
274
+ return text;
275
+ }
276
+ /**
277
+ * Serializes a primitive to a single-quoted string literal, stripping any surrounding quotes first.
278
+ *
279
+ * Escaping runs through `JSON.stringify`, then the result switches to single quotes so the generated
280
+ * code matches the repo style without a formatter.
281
+ *
282
+ * @example
283
+ * ```ts
284
+ * stringify('hello') // "'hello'"
285
+ * stringify('"hello"') // "'hello'"
286
+ * ```
287
+ */
288
+ function stringify(value) {
289
+ if (value === void 0 || value === null) return "''";
290
+ return `'${JSON.stringify(trimQuotes(value.toString())).slice(1, -1).replace(/\\"/g, "\"").replace(/'/g, "\\'")}'`;
291
+ }
292
+ /**
293
+ * Escapes characters that are not allowed inside JS string literals, covering quotes, backslashes,
294
+ * and the Unicode line terminators U+2028 and U+2029.
295
+ *
296
+ * @see http://www.ecma-international.org/ecma-262/5.1/#sec-7.8.4
297
+ *
298
+ * @example
299
+ * ```ts
300
+ * jsStringEscape('say "hi"\nbye') // 'say \\"hi\\"\\nbye'
301
+ * ```
302
+ */
303
+ function jsStringEscape(input) {
304
+ return `${input}`.replace(/["'\\\n\r\u2028\u2029]/g, (character) => {
305
+ switch (character) {
306
+ case "\"":
307
+ case "'":
308
+ case "\\": return `\\${character}`;
309
+ case "\n": return "\\n";
310
+ case "\r": return "\\r";
311
+ case "\u2028": return "\\u2028";
312
+ case "\u2029": return "\\u2029";
313
+ default: return "";
314
+ }
315
+ });
316
+ }
317
+ //#endregion
258
318
  //#region src/constants.ts
259
319
  /**
260
320
  * `optionalType` values that cause a property's type to include `| undefined`.
@@ -795,7 +855,7 @@ function buildTupleNode(node, print) {
795
855
  */
796
856
  function buildPropertyType(schema, baseType, optionalType, optional) {
797
857
  const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(optionalType);
798
- const meta = (0, _kubb_ast_utils.syncSchemaRef)(schema);
858
+ const meta = kubb_kit.ast.syncSchemaRef(schema);
799
859
  let type = baseType;
800
860
  if (meta.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
801
861
  if ((optional || meta.nullish || meta.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
@@ -839,10 +899,10 @@ function buildIndexSignatures(node, propertyCount, print) {
839
899
  * resolve to the same name, which TypeScript merges into a single value+type declaration.
840
900
  */
841
901
  function getEnumNames({ node, enum: enumOptions, resolver }) {
842
- const resolved = resolver.resolveTypeName(node.name);
902
+ const resolved = resolver.name(node.name);
843
903
  return {
844
904
  enumName: enumOptions.constCasing === "pascalCase" ? resolved : camelCase(node.name),
845
- typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumOptions.type) ? resolver.resolveEnumKeyName(node, enumOptions.typeSuffix) : resolved
905
+ typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumOptions.type) ? resolver.enum.keyName(node, enumOptions.typeSuffix) : resolved
846
906
  };
847
907
  }
848
908
  /**
@@ -866,21 +926,21 @@ function Enum({ node, enum: enumOptions, resolver }) {
866
926
  name: enumName,
867
927
  typeName,
868
928
  enums: node.namedEnumValues?.map((v) => [
869
- (0, _kubb_ast_utils.trimQuotes)(v.name.toString()),
929
+ trimQuotes(v.name.toString()),
870
930
  v.value,
871
931
  v.description
872
- ]) ?? node.enumValues?.filter((v) => v !== null && v !== void 0).map((v) => [(0, _kubb_ast_utils.trimQuotes)(v.toString()), v]) ?? [],
932
+ ]) ?? node.enumValues?.filter((v) => v !== null && v !== void 0).map((v) => [trimQuotes(v.toString()), v]) ?? [],
873
933
  type: enumOptions.type,
874
934
  enumKeyCasing: enumOptions.keyCasing
875
935
  });
876
936
  const namesMerge = !!nameNode && enumName === typeName;
877
- return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [nameNode && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
937
+ return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [nameNode && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
878
938
  name: enumName,
879
939
  isExportable: true,
880
940
  isIndexable: true,
881
941
  isTypeOnly: false,
882
942
  children: _kubb_parser_ts.parserTs.print(nameNode)
883
- }), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
943
+ }), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
884
944
  name: typeName,
885
945
  isIndexable: !namesMerge,
886
946
  isExportable: !namesMerge && ENUM_TYPES_WITH_RUNTIME_VALUE.has(enumOptions.type),
@@ -1041,99 +1101,97 @@ function isSchemaOptional(schema) {
1041
1101
  return Boolean("optional" in schema && schema.optional || "nullish" in schema && schema.nullish);
1042
1102
  }
1043
1103
  function buildPropertyJSDocComments(schema, optional) {
1044
- const meta = (0, _kubb_ast_utils.syncSchemaRef)(schema);
1104
+ const meta = kubb_kit.ast.syncSchemaRef(schema);
1045
1105
  const isArray = meta?.primitive === "array";
1046
1106
  const hasDescription = meta && "description" in meta && meta.description;
1047
1107
  const formatComment = meta && "format" in meta && meta.format ? hasDescription ? [" ", `Format: \`${meta.format}\``] : ["@description", `Format: \`${meta.format}\``] : [];
1048
1108
  const exampleValues = meta?.examples ?? [];
1049
1109
  return [
1050
- hasDescription ? `@description ${(0, _kubb_ast_utils.jsStringEscape)(meta.description)}` : null,
1110
+ hasDescription ? `@description ${jsStringEscape(meta.description)}` : null,
1051
1111
  ...formatComment,
1052
1112
  meta && "deprecated" in meta && meta.deprecated ? "@deprecated" : null,
1053
1113
  !isArray && meta && "min" in meta && meta.min !== void 0 ? `@minLength ${meta.min}` : null,
1054
1114
  !isArray && meta && "max" in meta && meta.max !== void 0 ? `@maxLength ${meta.max}` : null,
1055
1115
  meta && "pattern" in meta && meta.pattern ? `@pattern ${meta.pattern}` : null,
1056
- meta && "default" in meta && meta.default !== void 0 ? `@default ${"primitive" in meta && meta.primitive === "string" ? (0, _kubb_ast_utils.stringify)(meta.default) : meta.default}` : null,
1116
+ meta && "default" in meta && meta.default !== void 0 ? `@default ${"primitive" in meta && meta.primitive === "string" ? stringify(meta.default) : meta.default}` : null,
1057
1117
  ...exampleValues.map((example) => `@example ${example}`),
1058
1118
  meta && "primitive" in meta && meta.primitive ? [`@type ${meta.primitive}`, optional ?? isSchemaOptional(schema) ? " | undefined" : null].filter(Boolean).join("") : null
1059
1119
  ].filter(Boolean);
1060
1120
  }
1061
- function buildParams(node, { params, resolver }) {
1062
- return _kubb_core.ast.factory.createSchema({
1121
+ /**
1122
+ * Builds the object schema for a group of parameters sharing one `in` location (path, query, or
1123
+ * header), embedding each param's own schema (and JSDoc) directly rather than referencing a
1124
+ * separate per-param type — the group itself is the only type these params get exported as.
1125
+ */
1126
+ function buildParams({ params }) {
1127
+ return kubb_kit.ast.factory.createSchema({
1063
1128
  type: "object",
1064
- properties: params.map((param) => _kubb_core.ast.factory.createProperty({
1129
+ properties: params.map((param) => kubb_kit.ast.factory.createProperty({
1065
1130
  name: param.name,
1066
1131
  required: param.required,
1067
- schema: _kubb_core.ast.factory.createSchema({
1068
- type: "ref",
1069
- name: resolver.resolveParamName(node, param),
1132
+ schema: kubb_kit.ast.factory.createSchema({
1133
+ ...param.schema,
1070
1134
  optional: !param.required
1071
1135
  })
1072
1136
  }))
1073
1137
  });
1074
1138
  }
1075
- function buildData(node, { resolver }) {
1139
+ function buildOptions(node, { resolver }) {
1076
1140
  const { path: pathParams, query: queryParams, header: headerParams } = getOperationParameters(node, { paramsCasing: "original" });
1077
1141
  const hasBody = Boolean(node.requestBody?.content?.[0]?.schema);
1078
1142
  const hasRequiredPath = pathParams.some((param) => param.required);
1079
1143
  const hasRequiredQuery = queryParams.some((param) => param.required);
1080
1144
  const hasRequiredHeader = headerParams.some((param) => param.required);
1081
- return _kubb_core.ast.factory.createSchema({
1145
+ return kubb_kit.ast.factory.createSchema({
1082
1146
  type: "object",
1083
1147
  deprecated: node.deprecated,
1084
1148
  properties: [
1085
- _kubb_core.ast.factory.createProperty({
1149
+ kubb_kit.ast.factory.createProperty({
1086
1150
  name: "body",
1087
1151
  required: hasBody,
1088
- schema: hasBody ? _kubb_core.ast.factory.createSchema({
1152
+ schema: hasBody ? kubb_kit.ast.factory.createSchema({
1089
1153
  type: "ref",
1090
- name: resolver.resolveDataName(node)
1091
- }) : _kubb_core.ast.factory.createSchema({
1154
+ name: resolver.response.body(node)
1155
+ }) : kubb_kit.ast.factory.createSchema({
1092
1156
  type: "never",
1093
1157
  primitive: void 0,
1094
1158
  optional: true
1095
1159
  })
1096
1160
  }),
1097
- _kubb_core.ast.factory.createProperty({
1161
+ kubb_kit.ast.factory.createProperty({
1098
1162
  name: "path",
1099
1163
  required: hasRequiredPath,
1100
- schema: pathParams.length > 0 ? _kubb_core.ast.factory.createSchema({
1101
- ...buildParams(node, {
1102
- params: pathParams,
1103
- resolver
1104
- }),
1164
+ schema: pathParams.length > 0 ? kubb_kit.ast.factory.createSchema({
1165
+ type: "ref",
1166
+ name: resolver.param.path(node, pathParams[0]),
1105
1167
  optional: !hasRequiredPath
1106
- }) : _kubb_core.ast.factory.createSchema({
1168
+ }) : kubb_kit.ast.factory.createSchema({
1107
1169
  type: "never",
1108
1170
  primitive: void 0,
1109
1171
  optional: true
1110
1172
  })
1111
1173
  }),
1112
- _kubb_core.ast.factory.createProperty({
1174
+ kubb_kit.ast.factory.createProperty({
1113
1175
  name: "query",
1114
1176
  required: hasRequiredQuery,
1115
- schema: queryParams.length > 0 ? _kubb_core.ast.factory.createSchema({
1116
- ...buildParams(node, {
1117
- params: queryParams,
1118
- resolver
1119
- }),
1177
+ schema: queryParams.length > 0 ? kubb_kit.ast.factory.createSchema({
1178
+ type: "ref",
1179
+ name: resolver.param.query(node, queryParams[0]),
1120
1180
  optional: !hasRequiredQuery
1121
- }) : _kubb_core.ast.factory.createSchema({
1181
+ }) : kubb_kit.ast.factory.createSchema({
1122
1182
  type: "never",
1123
1183
  primitive: void 0,
1124
1184
  optional: true
1125
1185
  })
1126
1186
  }),
1127
- _kubb_core.ast.factory.createProperty({
1187
+ kubb_kit.ast.factory.createProperty({
1128
1188
  name: "headers",
1129
1189
  required: hasRequiredHeader,
1130
- schema: headerParams.length > 0 ? _kubb_core.ast.factory.createSchema({
1131
- ...buildParams(node, {
1132
- params: headerParams,
1133
- resolver
1134
- }),
1190
+ schema: headerParams.length > 0 ? kubb_kit.ast.factory.createSchema({
1191
+ type: "ref",
1192
+ name: resolver.param.headers(node, headerParams[0]),
1135
1193
  optional: !hasRequiredHeader
1136
- }) : _kubb_core.ast.factory.createSchema({
1194
+ }) : kubb_kit.ast.factory.createSchema({
1137
1195
  type: "never",
1138
1196
  primitive: void 0,
1139
1197
  optional: true
@@ -1149,27 +1207,27 @@ function buildData(node, { resolver }) {
1149
1207
  * query hooks and `result.data` use.
1150
1208
  */
1151
1209
  function buildResponseRecordEntry(node, res, resolver) {
1152
- const statusName = resolver.resolveResponseStatusName(node, res.statusCode);
1210
+ const statusName = resolver.response.status(node, res.statusCode);
1153
1211
  const variants = (res.content ?? []).filter((entry) => entry.schema);
1154
- if (variants.length <= 1) return _kubb_core.ast.factory.createSchema({
1212
+ if (variants.length <= 1) return kubb_kit.ast.factory.createSchema({
1155
1213
  type: "ref",
1156
1214
  name: statusName
1157
1215
  });
1158
- return _kubb_core.ast.factory.createSchema({
1216
+ return kubb_kit.ast.factory.createSchema({
1159
1217
  type: "union",
1160
- members: resolveContentTypeVariants(variants, statusName).map((variant) => _kubb_core.ast.factory.createSchema({
1218
+ members: resolveContentTypeVariants(variants, statusName).map((variant) => kubb_kit.ast.factory.createSchema({
1161
1219
  type: "object",
1162
- properties: [_kubb_core.ast.factory.createProperty({
1220
+ properties: [kubb_kit.ast.factory.createProperty({
1163
1221
  name: "contentType",
1164
1222
  required: true,
1165
- schema: _kubb_core.ast.factory.createSchema({
1223
+ schema: kubb_kit.ast.factory.createSchema({
1166
1224
  type: "enum",
1167
1225
  enumValues: [variant.contentType]
1168
1226
  })
1169
- }), _kubb_core.ast.factory.createProperty({
1227
+ }), kubb_kit.ast.factory.createProperty({
1170
1228
  name: "data",
1171
1229
  required: true,
1172
- schema: _kubb_core.ast.factory.createSchema({
1230
+ schema: kubb_kit.ast.factory.createSchema({
1173
1231
  type: "ref",
1174
1232
  name: variant.name
1175
1233
  })
@@ -1178,9 +1236,9 @@ function buildResponseRecordEntry(node, res, resolver) {
1178
1236
  });
1179
1237
  }
1180
1238
  function buildResponses(node, { resolver }) {
1181
- return _kubb_core.ast.factory.createSchema({
1239
+ return kubb_kit.ast.factory.createSchema({
1182
1240
  type: "object",
1183
- properties: node.responses.map((res) => _kubb_core.ast.factory.createProperty({
1241
+ properties: node.responses.map((res) => kubb_kit.ast.factory.createProperty({
1184
1242
  name: String(res.statusCode),
1185
1243
  required: true,
1186
1244
  schema: buildResponseRecordEntry(node, res, resolver)
@@ -1190,19 +1248,19 @@ function buildResponses(node, { resolver }) {
1190
1248
  function buildResponseUnion(node, { resolver }) {
1191
1249
  const responsesWithSchema = node.responses.filter((res) => res.content?.some((entry) => entry.schema));
1192
1250
  if (responsesWithSchema.length === 0) return null;
1193
- return _kubb_core.ast.factory.createSchema({
1251
+ return kubb_kit.ast.factory.createSchema({
1194
1252
  type: "union",
1195
- members: responsesWithSchema.map((res) => _kubb_core.ast.factory.createSchema({
1253
+ members: responsesWithSchema.map((res) => kubb_kit.ast.factory.createSchema({
1196
1254
  type: "ref",
1197
- name: resolver.resolveResponseStatusName(node, res.statusCode)
1255
+ name: resolver.response.status(node, res.statusCode)
1198
1256
  }))
1199
1257
  });
1200
1258
  }
1201
1259
  //#endregion
1202
1260
  //#region src/components/Type.tsx
1203
1261
  function Type({ name, node, printer, enum: enumOptions, resolver }) {
1204
- const enumSchemaNodes = _kubb_core.ast.collect(node, { schema(n) {
1205
- const enumNode = _kubb_core.ast.narrowSchema(n, _kubb_core.ast.schemaTypes.enum);
1262
+ const enumSchemaNodes = kubb_kit.ast.collect(node, { schema(n) {
1263
+ const enumNode = kubb_kit.ast.narrowSchema(n, kubb_kit.ast.schemaTypes.enum);
1206
1264
  if (enumNode?.name && !isInlineConstEnum(enumNode, printer.options.enumSchemaNames)) return enumNode;
1207
1265
  } });
1208
1266
  const output = printer.print(node);
@@ -1219,11 +1277,11 @@ function Type({ name, node, printer, enum: enumOptions, resolver }) {
1219
1277
  });
1220
1278
  const shouldExportEnums = enumOptions.type !== "inlineLiteral";
1221
1279
  const shouldExportType = enumOptions.type === "inlineLiteral" || enums.every((item) => item.typeName !== name);
1222
- return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [shouldExportEnums && enums.map(({ node }) => /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(Enum, {
1280
+ return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [shouldExportEnums && enums.map(({ node }) => /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Enum, {
1223
1281
  node,
1224
1282
  enum: enumOptions,
1225
1283
  resolver
1226
- }, node.name)), shouldExportType && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1284
+ }, node.name)), shouldExportType && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
1227
1285
  name,
1228
1286
  isTypeOnly: true,
1229
1287
  isExportable: true,
@@ -1257,7 +1315,7 @@ const { isNonNullable } = factory_exports;
1257
1315
  * const declaration = printer.print(schemaNode) // ts.TypeAliasDeclaration | ts.InterfaceDeclaration
1258
1316
  * ```
1259
1317
  */
1260
- const printerTs = _kubb_core.ast.createPrinter((options) => {
1318
+ const printerTs = kubb_kit.ast.createPrinter((options) => {
1261
1319
  const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(options.optionalType);
1262
1320
  return {
1263
1321
  name: "typescript",
@@ -1287,8 +1345,8 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
1287
1345
  time: dateOrStringNode,
1288
1346
  ref(node) {
1289
1347
  if (!node.name) return null;
1290
- const refName = node.ref ? this.options.nameMapping?.get(node.ref) ?? (0, _kubb_ast_utils.extractRefName)(node.ref) ?? node.name : node.name;
1291
- return createTypeReferenceNode(node.ref && ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enum.type) && this.options.enum.typeSuffix && this.options.enumSchemaNames?.has(refName) ? this.options.resolver.resolveEnumKeyName({ name: refName }, this.options.enum.typeSuffix) : node.ref ? this.options.resolver.resolveTypeName(refName) : refName, void 0);
1348
+ const refName = node.ref ? this.options.nameMapping?.get(node.ref) ?? kubb_kit.ast.extractRefName(node.ref) ?? node.name : node.name;
1349
+ return createTypeReferenceNode(node.ref && ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enum.type) && this.options.enum.typeSuffix && this.options.enumSchemaNames?.has(refName) ? this.options.resolver.enum.keyName({ name: refName }, this.options.enum.typeSuffix) : node.ref ? this.options.resolver.name(refName) : refName, void 0);
1292
1350
  },
1293
1351
  enum(node) {
1294
1352
  const values = node.namedEnumValues?.map((v) => v.value) ?? node.enumValues ?? [];
@@ -1296,18 +1354,18 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
1296
1354
  withParentheses: true,
1297
1355
  nodes: values.filter((v) => v !== null && v !== void 0).map((value) => constToTypeNode(value, typeof value)).filter(isNonNullable)
1298
1356
  }) ?? void 0;
1299
- return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enum.type) && this.options.enum.typeSuffix ? this.options.resolver.resolveEnumKeyName(node, this.options.enum.typeSuffix) : this.options.resolver.resolveTypeName(node.name), void 0);
1357
+ return createTypeReferenceNode(ENUM_TYPES_WITH_KEY_SUFFIX.has(this.options.enum.type) && this.options.enum.typeSuffix ? this.options.resolver.enum.keyName(node, this.options.enum.typeSuffix) : this.options.resolver.name(node.name), void 0);
1300
1358
  },
1301
1359
  union(node) {
1302
1360
  const members = node.members ?? [];
1303
1361
  const hasStringLiteral = members.some((m) => {
1304
- return _kubb_core.ast.narrowSchema(m, _kubb_core.ast.schemaTypes.enum)?.primitive === "string";
1362
+ return kubb_kit.ast.narrowSchema(m, kubb_kit.ast.schemaTypes.enum)?.primitive === "string";
1305
1363
  });
1306
- const hasPlainString = members.some((m) => (0, _kubb_ast_utils.isStringType)(m));
1364
+ const hasPlainString = members.some((m) => kubb_kit.ast.isStringType(m));
1307
1365
  if (hasStringLiteral && hasPlainString) return createUnionDeclaration({
1308
1366
  withParentheses: true,
1309
1367
  nodes: members.map((m) => {
1310
- if ((0, _kubb_ast_utils.isStringType)(m)) return createIntersectionDeclaration({
1368
+ if (kubb_kit.ast.isStringType(m)) return createIntersectionDeclaration({
1311
1369
  nodes: [keywordTypeNodes.string, createTypeLiteralNode([])],
1312
1370
  withParentheses: true
1313
1371
  });
@@ -1327,7 +1385,7 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
1327
1385
  },
1328
1386
  array(node) {
1329
1387
  return createArrayDeclaration({
1330
- nodes: (0, _kubb_ast_utils.mapSchemaItems)(node, (item) => this.transform(item)).map(({ output }) => output).filter(isNonNullable),
1388
+ nodes: kubb_kit.ast.mapSchemaItems(node, (item) => this.transform(item)).map(({ output }) => output).filter(isNonNullable),
1331
1389
  arrayType: this.options.arrayType
1332
1390
  }) ?? null;
1333
1391
  },
@@ -1337,11 +1395,11 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
1337
1395
  object(node) {
1338
1396
  const { transform, options } = this;
1339
1397
  const addsQuestionToken = OPTIONAL_ADDS_QUESTION_TOKEN.has(options.optionalType);
1340
- const propertyNodes = (0, _kubb_ast_utils.mapSchemaProperties)(node, (schema) => transform(schema)).map(({ name, property, output }) => {
1398
+ const propertyNodes = kubb_kit.ast.mapSchemaProperties(node, (schema) => transform(schema)).map(({ name, property, output }) => {
1341
1399
  const baseType = output ?? keywordTypeNodes.unknown;
1342
1400
  const optional = !property.required || !!property.schema.optional || !!property.schema.nullish;
1343
1401
  const type = buildPropertyType(property.schema, baseType, options.optionalType, optional);
1344
- const propMeta = (0, _kubb_ast_utils.syncSchemaRef)(property.schema);
1402
+ const propMeta = kubb_kit.ast.syncSchemaRef(property.schema);
1345
1403
  return appendJSDocToNode({
1346
1404
  node: createPropertySignature({
1347
1405
  questionToken: optional ? addsQuestionToken : false,
@@ -1362,7 +1420,7 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
1362
1420
  const { name, syntaxType = "type", description, keysToOmit } = this.options;
1363
1421
  const transformed = this.transform(node);
1364
1422
  if (!transformed) return null;
1365
- const meta = (0, _kubb_ast_utils.syncSchemaRef)(node);
1423
+ const meta = kubb_kit.ast.syncSchemaRef(node);
1366
1424
  if (!name) {
1367
1425
  const withNullable = meta.nullable ? createUnionDeclaration({ nodes: [transformed, keywordTypeNodes.null] }) : transformed;
1368
1426
  const result = (meta.nullish || meta.optional) && addsUndefined ? createUnionDeclaration({ nodes: [withNullable, keywordTypeNodes.undefined] }) : withNullable;
@@ -1399,37 +1457,35 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
1399
1457
  * types. Drop-replace with a custom `Generator<PluginTs>` to change how
1400
1458
  * TypeScript output is produced.
1401
1459
  */
1402
- const typeGenerator = (0, _kubb_core.defineGenerator)({
1460
+ const typeGenerator = (0, kubb_kit.defineGenerator)({
1403
1461
  name: "typescript",
1404
- renderer: _kubb_renderer_jsx.jsxRenderer,
1462
+ renderer: kubb_jsx.jsxRenderer,
1405
1463
  schema(node, ctx) {
1406
1464
  const { enum: enumOptions, syntaxType, optionalType, arrayType, output, group, printer } = ctx.options;
1407
1465
  const { adapter, config, resolver, root } = ctx;
1408
1466
  if (!node.name) return;
1409
1467
  const enumSchemaNames = new Set(ctx.meta.enumNames);
1410
1468
  function resolveImportName(schemaName) {
1411
- if (ENUM_TYPES_WITH_KEY_SUFFIX.has(enumOptions.type) && enumOptions.typeSuffix && enumSchemaNames.has(schemaName)) return resolver.resolveEnumKeyName({ name: schemaName }, enumOptions.typeSuffix);
1412
- return resolver.resolveTypeName(schemaName);
1469
+ if (ENUM_TYPES_WITH_KEY_SUFFIX.has(enumOptions.type) && enumOptions.typeSuffix && enumSchemaNames.has(schemaName)) return resolver.enum.keyName({ name: schemaName }, enumOptions.typeSuffix);
1470
+ return resolver.name(schemaName);
1413
1471
  }
1414
1472
  const imports = adapter.getImports(node, (schemaName) => ({
1415
1473
  name: resolveImportName(schemaName),
1416
- path: resolver.resolveFile({
1474
+ path: resolver.file({
1417
1475
  name: schemaName,
1418
- extname: ".ts"
1419
- }, {
1476
+ extname: ".ts",
1420
1477
  root,
1421
1478
  output,
1422
1479
  group: group ?? void 0
1423
1480
  }).path
1424
1481
  }));
1425
- const enumNode = _kubb_core.ast.narrowSchema(node, _kubb_core.ast.schemaTypes.enum);
1482
+ const enumNode = kubb_kit.ast.narrowSchema(node, kubb_kit.ast.schemaTypes.enum);
1426
1483
  const isEnumSchema = !!enumNode && !isInlineConstEnum(enumNode, enumSchemaNames);
1427
1484
  const meta = {
1428
- name: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumOptions.type) && isEnumSchema ? resolver.resolveEnumKeyName(node, enumOptions.typeSuffix) : resolver.resolveTypeName(node.name),
1429
- file: resolver.resolveFile({
1485
+ name: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumOptions.type) && isEnumSchema ? resolver.enum.keyName(node, enumOptions.typeSuffix) : resolver.name(node.name),
1486
+ file: resolver.file({
1430
1487
  name: node.name,
1431
- extname: ".ts"
1432
- }, {
1488
+ extname: ".ts",
1433
1489
  root,
1434
1490
  output,
1435
1491
  group: group ?? void 0
@@ -1447,11 +1503,11 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1447
1503
  nameMapping: adapter.options.nameMapping,
1448
1504
  nodes: printer?.nodes
1449
1505
  });
1450
- return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
1506
+ return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
1451
1507
  baseName: meta.file.baseName,
1452
1508
  path: meta.file.path,
1453
1509
  meta: meta.file.meta,
1454
- banner: resolver.resolveBanner(ctx.meta, {
1510
+ banner: resolver.default.banner(ctx.meta, {
1455
1511
  output,
1456
1512
  config,
1457
1513
  file: {
@@ -1459,7 +1515,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1459
1515
  baseName: meta.file.baseName
1460
1516
  }
1461
1517
  }),
1462
- footer: resolver.resolveFooter(ctx.meta, {
1518
+ footer: resolver.default.footer(ctx.meta, {
1463
1519
  output,
1464
1520
  config,
1465
1521
  file: {
@@ -1467,7 +1523,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1467
1523
  baseName: meta.file.baseName
1468
1524
  }
1469
1525
  }),
1470
- children: [imports.map((imp) => /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
1526
+ children: [imports.map((imp) => /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1471
1527
  root: meta.file.path,
1472
1528
  path: imp.path,
1473
1529
  name: imp.name,
@@ -1476,7 +1532,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1476
1532
  node.name,
1477
1533
  imp.path,
1478
1534
  imp.isTypeOnly
1479
- ].join("-"))), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(Type, {
1535
+ ].join("-"))), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Type, {
1480
1536
  name: meta.name,
1481
1537
  node,
1482
1538
  enum: enumOptions,
@@ -1489,29 +1545,27 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1489
1545
  const { enum: enumOptions, optionalType, arrayType, syntaxType, group, output, printer } = ctx.options;
1490
1546
  const { adapter, config, resolver, root } = ctx;
1491
1547
  const params = caseParams(node.parameters, "camelcase");
1492
- const meta = { file: resolver.resolveFile({
1548
+ const meta = { file: resolver.file({
1493
1549
  name: node.operationId,
1494
1550
  extname: ".ts",
1495
1551
  tag: node.tags[0] ?? "default",
1496
- path: node.path
1497
- }, {
1552
+ path: node.path,
1498
1553
  root,
1499
1554
  output,
1500
1555
  group: group ?? void 0
1501
1556
  }) };
1502
1557
  const enumSchemaNames = new Set(ctx.meta.enumNames);
1503
1558
  function resolveImportName(schemaName) {
1504
- if (ENUM_TYPES_WITH_KEY_SUFFIX.has(enumOptions.type) && enumOptions.typeSuffix && enumSchemaNames.has(schemaName)) return resolver.resolveEnumKeyName({ name: schemaName }, enumOptions.typeSuffix);
1505
- return resolver.resolveTypeName(schemaName);
1559
+ if (ENUM_TYPES_WITH_KEY_SUFFIX.has(enumOptions.type) && enumOptions.typeSuffix && enumSchemaNames.has(schemaName)) return resolver.enum.keyName({ name: schemaName }, enumOptions.typeSuffix);
1560
+ return resolver.name(schemaName);
1506
1561
  }
1507
1562
  function renderSchemaType({ schema, name, keysToOmit }) {
1508
1563
  if (!schema) return null;
1509
1564
  const imports = adapter.getImports(schema, (schemaName) => ({
1510
1565
  name: resolveImportName(schemaName),
1511
- path: resolver.resolveFile({
1566
+ path: resolver.file({
1512
1567
  name: schemaName,
1513
- extname: ".ts"
1514
- }, {
1568
+ extname: ".ts",
1515
1569
  root,
1516
1570
  output,
1517
1571
  group: group ?? void 0
@@ -1530,7 +1584,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1530
1584
  nameMapping: adapter.options.nameMapping,
1531
1585
  nodes: printer?.nodes
1532
1586
  });
1533
- return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [imports.map((imp) => /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Import, {
1587
+ return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [imports.map((imp) => /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
1534
1588
  root: meta.file.path,
1535
1589
  path: imp.path,
1536
1590
  name: imp.name,
@@ -1539,7 +1593,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1539
1593
  name,
1540
1594
  imp.path,
1541
1595
  imp.isTypeOnly
1542
- ].join("-"))), /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(Type, {
1596
+ ].join("-"))), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Type, {
1543
1597
  name,
1544
1598
  node: schema,
1545
1599
  enum: enumOptions,
@@ -1555,14 +1609,14 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1555
1609
  */
1556
1610
  function buildContentTypeVariants(entries, baseName, decorate) {
1557
1611
  const variants = resolveContentTypeVariants(entries, baseName);
1558
- const unionSchema = _kubb_core.ast.factory.createSchema({
1612
+ const unionSchema = kubb_kit.ast.factory.createSchema({
1559
1613
  type: "union",
1560
- members: variants.map((variant) => _kubb_core.ast.factory.createSchema({
1614
+ members: variants.map((variant) => kubb_kit.ast.factory.createSchema({
1561
1615
  type: "ref",
1562
1616
  name: variant.name
1563
1617
  }))
1564
1618
  });
1565
- return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx_jsx_runtime.Fragment, { children: [variants.map((variant) => renderSchemaType({
1619
+ return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [variants.map((variant) => renderSchemaType({
1566
1620
  schema: decorate ? decorate(variant.schema) : variant.schema,
1567
1621
  name: variant.name,
1568
1622
  keysToOmit: variant.keysToOmit
@@ -1571,13 +1625,24 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1571
1625
  name: baseName
1572
1626
  })] });
1573
1627
  }
1574
- const paramTypes = params.map((param) => renderSchemaType({
1575
- schema: {
1576
- ...param.schema,
1577
- optional: !param.required
1578
- },
1579
- name: resolver.resolveParamName(node, param)
1580
- }));
1628
+ const { path: pathParams, query: queryParams, header: headerParams } = getOperationParameters({
1629
+ ...node,
1630
+ parameters: params
1631
+ }, { paramsCasing: "original" });
1632
+ const paramGroupTypes = [
1633
+ pathParams.length > 0 && renderSchemaType({
1634
+ schema: buildParams({ params: pathParams }),
1635
+ name: resolver.param.path(node, pathParams[0])
1636
+ }),
1637
+ queryParams.length > 0 && renderSchemaType({
1638
+ schema: buildParams({ params: queryParams }),
1639
+ name: resolver.param.query(node, queryParams[0])
1640
+ }),
1641
+ headerParams.length > 0 && renderSchemaType({
1642
+ schema: buildParams({ params: headerParams }),
1643
+ name: resolver.param.headers(node, headerParams[0])
1644
+ })
1645
+ ];
1581
1646
  const requestBodyContent = node.requestBody?.content ?? [];
1582
1647
  function buildRequestType() {
1583
1648
  if (requestBodyContent.length === 0) return null;
@@ -1589,11 +1654,11 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1589
1654
  ...entry.schema,
1590
1655
  description: node.requestBody.description ?? entry.schema.description
1591
1656
  },
1592
- name: resolver.resolveDataName(node),
1657
+ name: resolver.response.body(node),
1593
1658
  keysToOmit: entry.keysToOmit
1594
1659
  });
1595
1660
  }
1596
- return buildContentTypeVariants(requestBodyContent, resolver.resolveDataName(node), (schema) => ({
1661
+ return buildContentTypeVariants(requestBodyContent, resolver.response.body(node), (schema) => ({
1597
1662
  ...schema,
1598
1663
  description: node.requestBody.description ?? schema.description
1599
1664
  }));
@@ -1601,29 +1666,29 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1601
1666
  const requestType = buildRequestType();
1602
1667
  const responseTypes = node.responses.map((res) => {
1603
1668
  const variants = (res.content ?? []).filter((entry) => entry.schema);
1604
- if (variants.length > 1) return buildContentTypeVariants(variants, resolver.resolveResponseStatusName(node, res.statusCode));
1669
+ if (variants.length > 1) return buildContentTypeVariants(variants, resolver.response.status(node, res.statusCode));
1605
1670
  const primary = variants[0] ?? res.content?.[0];
1606
1671
  return renderSchemaType({
1607
1672
  schema: primary?.schema ?? null,
1608
- name: resolver.resolveResponseStatusName(node, res.statusCode),
1673
+ name: resolver.response.status(node, res.statusCode),
1609
1674
  keysToOmit: primary?.keysToOmit
1610
1675
  });
1611
1676
  });
1612
- const dataType = renderSchemaType({
1613
- schema: buildData({
1677
+ const optionsType = renderSchemaType({
1678
+ schema: buildOptions({
1614
1679
  ...node,
1615
1680
  parameters: params
1616
1681
  }, { resolver }),
1617
- name: resolver.resolveRequestConfigName(node)
1682
+ name: resolver.response.options(node)
1618
1683
  });
1619
1684
  const responsesType = renderSchemaType({
1620
1685
  schema: buildResponses(node, { resolver }),
1621
- name: resolver.resolveResponsesName(node)
1686
+ name: resolver.response.responses(node)
1622
1687
  });
1623
1688
  function buildResponseType() {
1624
1689
  const hasSchema = (res) => (res.content ?? []).some((entry) => entry.schema);
1625
1690
  if (!node.responses.some(hasSchema)) return null;
1626
- const responseName = resolver.resolveResponseName(node);
1691
+ const responseName = resolver.response.response(node);
1627
1692
  const responsesWithSchema = node.responses.filter(hasSchema);
1628
1693
  if (new Set(responsesWithSchema.flatMap((res) => (res.content ?? []).flatMap((entry) => entry.schema ? adapter.getImports(entry.schema, (schemaName) => ({
1629
1694
  name: resolveImportName(schemaName),
@@ -1638,11 +1703,11 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1638
1703
  });
1639
1704
  }
1640
1705
  const responseType = buildResponseType();
1641
- return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
1706
+ return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
1642
1707
  baseName: meta.file.baseName,
1643
1708
  path: meta.file.path,
1644
1709
  meta: meta.file.meta,
1645
- banner: resolver.resolveBanner(ctx.meta, {
1710
+ banner: resolver.default.banner(ctx.meta, {
1646
1711
  output,
1647
1712
  config,
1648
1713
  file: {
@@ -1650,7 +1715,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1650
1715
  baseName: meta.file.baseName
1651
1716
  }
1652
1717
  }),
1653
- footer: resolver.resolveFooter(ctx.meta, {
1718
+ footer: resolver.default.footer(ctx.meta, {
1654
1719
  output,
1655
1720
  config,
1656
1721
  file: {
@@ -1659,10 +1724,10 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1659
1724
  }
1660
1725
  }),
1661
1726
  children: [
1662
- paramTypes,
1727
+ paramGroupTypes,
1663
1728
  responseTypes,
1664
1729
  requestType,
1665
- dataType,
1730
+ optionsType,
1666
1731
  responsesType,
1667
1732
  responseType
1668
1733
  ]
@@ -1677,64 +1742,61 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1677
1742
  * to reference the exact names `plugin-ts` produces without duplicating the
1678
1743
  * casing/file-layout rules.
1679
1744
  *
1680
- * The `default` method is supplied by `defineResolver`. It uses PascalCase for
1681
- * type names and PascalCase file paths (dotted names become `/`-joined) for files.
1745
+ * The `default` helpers are supplied by `createResolver`. This plugin overrides the top-level `name`
1746
+ * to use PascalCase for value and type names and `file` to write PascalCase file paths (dotted names
1747
+ * become `/`-joined), and groups the operation-specific naming under the `param`, `response`, and
1748
+ * `enum` namespaces.
1682
1749
  *
1683
1750
  * @example Resolve a type and file name
1684
1751
  * ```ts
1685
1752
  * import { resolverTs } from '@kubb/plugin-ts'
1686
1753
  *
1687
- * resolverTs.default('list pets', 'type') // 'ListPets'
1688
- * resolverTs.resolvePathName('list pets', 'file') // 'ListPets'
1689
- * resolverTs.resolveResponseStatusName(node, 200) // 'ListPetsStatus200'
1754
+ * resolverTs.name('list pets') // 'ListPets'
1755
+ * resolverTs.response.status(node, 200) // 'ListPetsStatus200'
1690
1756
  * ```
1691
1757
  */
1692
- const resolverTs = (0, _kubb_core.defineResolver)(() => {
1693
- return {
1694
- name: "default",
1695
- pluginName: "plugin-ts",
1696
- default(name, type) {
1697
- if (type === "file") return toFilePath(name, pascalCase);
1698
- return ensureValidVarName(pascalCase(name));
1699
- },
1700
- resolveTypeName(name) {
1701
- return ensureValidVarName(pascalCase(name));
1702
- },
1703
- resolvePathName(name, type) {
1704
- if (type === "file") return toFilePath(name, pascalCase);
1705
- return ensureValidVarName(pascalCase(name));
1706
- },
1707
- resolveParamName(node, param) {
1708
- return this.resolveTypeName(`${node.operationId} ${param.in} ${param.name}`);
1709
- },
1710
- resolveResponseStatusName(node, statusCode) {
1711
- return this.resolveTypeName(`${node.operationId} Status ${statusCode}`);
1712
- },
1713
- resolveDataName(node) {
1714
- return this.resolveTypeName(`${node.operationId} Data`);
1758
+ const resolverTs = (0, kubb_kit.createResolver)({
1759
+ pluginName: "plugin-ts",
1760
+ name(name) {
1761
+ return ensureValidVarName(pascalCase(name));
1762
+ },
1763
+ file: { baseName({ name, extname }) {
1764
+ return `${toFilePath(name, pascalCase)}${extname}`;
1765
+ } },
1766
+ param: {
1767
+ name(node, param) {
1768
+ return this.name(`${node.operationId} ${param.in} ${param.name}`);
1715
1769
  },
1716
- resolveRequestConfigName(node) {
1717
- return this.resolveTypeName(`${node.operationId} RequestConfig`);
1770
+ path(node) {
1771
+ return this.name(`${node.operationId} Path`);
1718
1772
  },
1719
- resolveResponsesName(node) {
1720
- return this.resolveTypeName(`${node.operationId} Responses`);
1773
+ query(node) {
1774
+ return this.name(`${node.operationId} Query`);
1721
1775
  },
1722
- resolveResponseName(node) {
1723
- return this.resolveTypeName(`${node.operationId} Response`);
1776
+ headers(node) {
1777
+ return this.name(`${node.operationId} Headers`);
1778
+ }
1779
+ },
1780
+ response: {
1781
+ status(node, statusCode) {
1782
+ return this.name(`${node.operationId} Status ${statusCode}`);
1724
1783
  },
1725
- resolveEnumKeyName(node, enumTypeSuffix = "key") {
1726
- return `${this.resolveTypeName(node.name ?? "")}${enumTypeSuffix}`;
1784
+ options(node) {
1785
+ return this.name(`${node.operationId} Options`);
1727
1786
  },
1728
- resolvePathParamsName(node, param) {
1729
- return this.resolveParamName(node, param);
1787
+ responses(node) {
1788
+ return this.name(`${node.operationId} Responses`);
1730
1789
  },
1731
- resolveQueryParamsName(node, param) {
1732
- return this.resolveParamName(node, param);
1790
+ response(node) {
1791
+ return this.name(`${node.operationId} Response`);
1733
1792
  },
1734
- resolveHeaderParamsName(node, param) {
1735
- return this.resolveParamName(node, param);
1793
+ body(node) {
1794
+ return this.name(`${node.operationId} Body`);
1736
1795
  }
1737
- };
1796
+ },
1797
+ enum: { keyName(node, enumTypeSuffix = "key") {
1798
+ return `${this.name(node.name ?? "")}${enumTypeSuffix}`;
1799
+ } }
1738
1800
  });
1739
1801
  //#endregion
1740
1802
  //#region src/plugin.ts
@@ -1751,7 +1813,7 @@ const pluginTsName = "plugin-ts";
1751
1813
  *
1752
1814
  * @example
1753
1815
  * ```ts
1754
- * import { defineConfig } from 'kubb'
1816
+ * import { defineConfig } from 'kubb/config'
1755
1817
  * import { pluginTs } from '@kubb/plugin-ts'
1756
1818
  *
1757
1819
  * export default defineConfig({
@@ -1767,7 +1829,7 @@ const pluginTsName = "plugin-ts";
1767
1829
  * })
1768
1830
  * ```
1769
1831
  */
1770
- const pluginTs = (0, _kubb_core.definePlugin)((options) => {
1832
+ const pluginTs = (0, kubb_kit.definePlugin)((options) => {
1771
1833
  const { output = {
1772
1834
  path: "types",
1773
1835
  barrel: { type: "named" }
@@ -1795,10 +1857,7 @@ const pluginTs = (0, _kubb_core.definePlugin)((options) => {
1795
1857
  syntaxType,
1796
1858
  printer
1797
1859
  });
1798
- ctx.setResolver(userResolver ? {
1799
- ...resolverTs,
1800
- ...userResolver
1801
- } : resolverTs);
1860
+ ctx.setResolver(userResolver ? kubb_kit.Resolver.merge(resolverTs, userResolver) : resolverTs);
1802
1861
  if (userMacros?.length) ctx.setMacros(userMacros);
1803
1862
  ctx.addGenerator(typeGenerator);
1804
1863
  } }
@@ -2059,12 +2118,12 @@ function functionPrinter(options) {
2059
2118
  */
2060
2119
  function resolveParamType({ node, param, resolver }) {
2061
2120
  if (!resolver) return param.schema.primitive ?? "unknown";
2062
- const individualName = resolver.resolveParamName(node, param);
2121
+ const individualName = resolver.param.name(node, param);
2063
2122
  const groupLocation = param.in === "path" || param.in === "query" || param.in === "header" ? param.in : void 0;
2064
2123
  const groupResolvers = {
2065
- path: resolver.resolvePathParamsName,
2066
- query: resolver.resolveQueryParamsName,
2067
- header: resolver.resolveHeaderParamsName
2124
+ path: resolver.param.path,
2125
+ query: resolver.param.query,
2126
+ header: resolver.param.headers
2068
2127
  };
2069
2128
  const groupName = groupLocation ? groupResolvers[groupLocation].call(resolver, node, param) : void 0;
2070
2129
  if (groupName && groupName !== individualName) return createIndexedAccessType({
@@ -2082,8 +2141,8 @@ function resolveParamType({ node, param, resolver }) {
2082
2141
  function resolveGroupType({ node, params, group, resolver }) {
2083
2142
  if (!resolver || !params.length) return null;
2084
2143
  const firstParam = params[0];
2085
- const groupName = (group === "query" ? resolver.resolveQueryParamsName : resolver.resolveHeaderParamsName).call(resolver, node, firstParam);
2086
- if (groupName === resolver.resolveParamName(node, firstParam)) return null;
2144
+ const groupName = (group === "query" ? resolver.param.query : resolver.param.headers).call(resolver, node, firstParam);
2145
+ if (groupName === resolver.param.name(node, firstParam)) return null;
2087
2146
  return {
2088
2147
  type: groupName,
2089
2148
  optional: params.every((p) => !p.required)
@@ -2119,7 +2178,7 @@ function createOperationParams(node, options) {
2119
2178
  optional: !param.required
2120
2179
  });
2121
2180
  const emptyObjectDefault = (props) => props.every((p) => p.optional) ? "{}" : void 0;
2122
- const bodyType = node.requestBody?.content?.[0]?.schema ? wrapType(resolver?.resolveDataName(node) ?? "unknown") : void 0;
2181
+ const bodyType = node.requestBody?.content?.[0]?.schema ? wrapType(resolver?.response.body(node) ?? "unknown") : void 0;
2123
2182
  const bodyProperty = bodyType ? [{
2124
2183
  name: dataName,
2125
2184
  type: bodyType,
@@ -2163,7 +2222,7 @@ function createOperationParams(node, options) {
2163
2222
  }));
2164
2223
  } else {
2165
2224
  if (pathParamsType === "inlineSpread" && pathParams.length) {
2166
- const spreadType = resolver?.resolvePathParamsName(node, pathParams[0]);
2225
+ const spreadType = resolver?.param.path(node, pathParams[0]);
2167
2226
  params.push(createFunctionParameter({
2168
2227
  name: pathName,
2169
2228
  type: spreadType ? wrapType(spreadType) : void 0,
@@ -2233,6 +2292,7 @@ function buildTypeLiteral({ node, params, resolver }) {
2233
2292
  //#endregion
2234
2293
  exports.Enum = Enum;
2235
2294
  exports.Type = Type;
2295
+ exports.buildParams = buildParams;
2236
2296
  exports.createFunctionParameter = createFunctionParameter;
2237
2297
  exports.createFunctionParameters = createFunctionParameters;
2238
2298
  exports.createIndexedAccessType = createIndexedAccessType;