@kubb/plugin-ts 5.0.0-beta.76 → 5.0.0-beta.79

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
@@ -137,7 +137,7 @@ function toFilePath(name, caseLast = camelCase) {
137
137
  * JavaScript and Java reserved words.
138
138
  * @link https://github.com/jonschlinkert/reserved/blob/master/index.js
139
139
  */
140
- const reservedWords = new Set([
140
+ const reservedWords = /* @__PURE__ */ new Set([
141
141
  "abstract",
142
142
  "arguments",
143
143
  "boolean",
@@ -259,19 +259,19 @@ function ensureValidVarName(name) {
259
259
  /**
260
260
  * `optionalType` values that cause a property's type to include `| undefined`.
261
261
  */
262
- const OPTIONAL_ADDS_UNDEFINED = new Set(["undefined", "questionTokenAndUndefined"]);
262
+ const OPTIONAL_ADDS_UNDEFINED = /* @__PURE__ */ new Set(["undefined", "questionTokenAndUndefined"]);
263
263
  /**
264
264
  * `optionalType` values that render the property key with a `?` token.
265
265
  */
266
- const OPTIONAL_ADDS_QUESTION_TOKEN = new Set(["questionToken", "questionTokenAndUndefined"]);
266
+ const OPTIONAL_ADDS_QUESTION_TOKEN = /* @__PURE__ */ new Set(["questionToken", "questionTokenAndUndefined"]);
267
267
  /**
268
268
  * `enum.type` values that append a `typeSuffix` to the generated enum type alias.
269
269
  */
270
- const ENUM_TYPES_WITH_KEY_SUFFIX = new Set(["asConst"]);
270
+ const ENUM_TYPES_WITH_KEY_SUFFIX = /* @__PURE__ */ new Set(["asConst"]);
271
271
  /**
272
272
  * `enum.type` values that require a runtime value declaration (object, enum, or literal).
273
273
  */
274
- const ENUM_TYPES_WITH_RUNTIME_VALUE = new Set([
274
+ const ENUM_TYPES_WITH_RUNTIME_VALUE = /* @__PURE__ */ new Set([
275
275
  "enum",
276
276
  "asConst",
277
277
  "constEnum",
@@ -281,7 +281,7 @@ const ENUM_TYPES_WITH_RUNTIME_VALUE = new Set([
281
281
  /**
282
282
  * `enum.type` values whose type declaration is type-only (no runtime value emitted for the type alias).
283
283
  */
284
- const ENUM_TYPES_WITH_TYPE_ONLY = new Set([
284
+ const ENUM_TYPES_WITH_TYPE_ONLY = /* @__PURE__ */ new Set([
285
285
  "asConst",
286
286
  "literal",
287
287
  void 0
@@ -589,7 +589,7 @@ function applyEnumKeyCasing(key, casing = "none") {
589
589
  * type: 'enum',
590
590
  * name: 'petType',
591
591
  * typeName: 'PetType',
592
- * enums: [['cat', 'cat'], ['dog', 'dog']],
592
+ * enums: [['cat', 'cat', 'A cat'], ['dog', 'dog']],
593
593
  * })
594
594
  * ```
595
595
  */
@@ -602,30 +602,39 @@ function createEnumDeclaration({ type = "enum", name, typeName, enums, enumKeyCa
602
602
  if (typeof value === "boolean") return factory.createLiteralTypeNode(value ? factory.createTrue() : factory.createFalse());
603
603
  if (value !== null && value !== void 0) return factory.createLiteralTypeNode(factory.createStringLiteral(value.toString()));
604
604
  }).filter((node) => node !== void 0)))];
605
- if (type === "enum" || type === "constEnum") return [void 0, factory.createEnumDeclaration([factory.createToken(typescript.default.SyntaxKind.ExportKeyword), type === "constEnum" ? factory.createToken(typescript.default.SyntaxKind.ConstKeyword) : void 0].filter((modifier) => modifier !== void 0), factory.createIdentifier(typeName), enums.map(([key, value]) => {
605
+ if (type === "enum" || type === "constEnum") return [void 0, factory.createEnumDeclaration([factory.createToken(typescript.default.SyntaxKind.ExportKeyword), type === "constEnum" ? factory.createToken(typescript.default.SyntaxKind.ConstKeyword) : void 0].filter((modifier) => modifier !== void 0), factory.createIdentifier(typeName), enums.map(([key, value, description]) => {
606
606
  let initializer = factory.createStringLiteral(value?.toString());
607
607
  if (Number.parseInt(value.toString(), 10) === value && isNumber(Number.parseInt(value.toString(), 10))) if (value < 0) initializer = factory.createPrefixUnaryExpression(typescript.default.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value)));
608
608
  else initializer = factory.createNumericLiteral(value);
609
609
  if (typeof value === "boolean") initializer = value ? factory.createTrue() : factory.createFalse();
610
610
  if (isNumber(Number.parseInt(key.toString(), 10))) {
611
611
  const casingKey = applyEnumKeyCasing(`${typeName}_${key}`, enumKeyCasing);
612
- return factory.createEnumMember(propertyName(casingKey), initializer);
612
+ return appendJSDocToNode({
613
+ node: factory.createEnumMember(propertyName(casingKey), initializer),
614
+ comments: [description]
615
+ });
613
616
  }
614
617
  if (key !== null && key !== void 0) {
615
618
  const casingKey = applyEnumKeyCasing(key.toString(), enumKeyCasing);
616
- return factory.createEnumMember(propertyName(casingKey), initializer);
619
+ return appendJSDocToNode({
620
+ node: factory.createEnumMember(propertyName(casingKey), initializer),
621
+ comments: [description]
622
+ });
617
623
  }
618
624
  }).filter((member) => member !== void 0))];
619
625
  const identifierName = name;
620
626
  if (enums.length === 0) return [void 0, factory.createTypeAliasDeclaration([factory.createToken(typescript.default.SyntaxKind.ExportKeyword)], factory.createIdentifier(typeName), void 0, factory.createKeywordTypeNode(typescript.default.SyntaxKind.NeverKeyword))];
621
- return [factory.createVariableStatement([factory.createToken(typescript.default.SyntaxKind.ExportKeyword)], factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createIdentifier(identifierName), void 0, void 0, factory.createAsExpression(factory.createObjectLiteralExpression(enums.map(([key, value]) => {
627
+ return [factory.createVariableStatement([factory.createToken(typescript.default.SyntaxKind.ExportKeyword)], factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createIdentifier(identifierName), void 0, void 0, factory.createAsExpression(factory.createObjectLiteralExpression(enums.map(([key, value, description]) => {
622
628
  let initializer = factory.createStringLiteral(value?.toString());
623
629
  if (isNumber(value)) if (value < 0) initializer = factory.createPrefixUnaryExpression(typescript.default.SyntaxKind.MinusToken, factory.createNumericLiteral(Math.abs(value)));
624
630
  else initializer = factory.createNumericLiteral(value);
625
631
  if (typeof value === "boolean") initializer = value ? factory.createTrue() : factory.createFalse();
626
632
  if (key !== null && key !== void 0) {
627
633
  const casingKey = applyEnumKeyCasing(key.toString(), enumKeyCasing);
628
- return factory.createPropertyAssignment(propertyName(casingKey), initializer);
634
+ return appendJSDocToNode({
635
+ node: factory.createPropertyAssignment(propertyName(casingKey), initializer),
636
+ comments: [description]
637
+ });
629
638
  }
630
639
  }).filter((property) => property !== void 0), true), factory.createTypeReferenceNode(factory.createIdentifier("const"), void 0)))], typescript.default.NodeFlags.Const)), factory.createTypeAliasDeclaration([factory.createToken(typescript.default.SyntaxKind.ExportKeyword)], factory.createIdentifier(typeName), void 0, factory.createIndexedAccessTypeNode(factory.createParenthesizedType(factory.createTypeQueryNode(factory.createIdentifier(identifierName), void 0)), factory.createTypeOperatorNode(typescript.default.SyntaxKind.KeyOfKeyword, factory.createTypeQueryNode(factory.createIdentifier(identifierName), void 0))))];
631
640
  }
@@ -830,7 +839,7 @@ function buildIndexSignatures(node, propertyCount, print) {
830
839
  * resolve to the same name, which TypeScript merges into a single value+type declaration.
831
840
  */
832
841
  function getEnumNames({ node, enum: enumOptions, resolver }) {
833
- const resolved = resolver.default(node.name, "type");
842
+ const resolved = resolver.resolveTypeName(node.name);
834
843
  return {
835
844
  enumName: enumOptions.constCasing === "pascalCase" ? resolved : camelCase(node.name),
836
845
  typeName: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumOptions.type) ? resolver.resolveEnumKeyName(node, enumOptions.typeSuffix) : resolved
@@ -856,7 +865,11 @@ function Enum({ node, enum: enumOptions, resolver }) {
856
865
  const [nameNode, typeNode] = createEnumDeclaration({
857
866
  name: enumName,
858
867
  typeName,
859
- enums: node.namedEnumValues?.map((v) => [(0, _kubb_ast_utils.trimQuotes)(v.name.toString()), v.value]) ?? node.enumValues?.filter((v) => v !== null && v !== void 0).map((v) => [(0, _kubb_ast_utils.trimQuotes)(v.toString()), v]) ?? [],
868
+ enums: node.namedEnumValues?.map((v) => [
869
+ (0, _kubb_ast_utils.trimQuotes)(v.name.toString()),
870
+ v.value,
871
+ v.description
872
+ ]) ?? node.enumValues?.filter((v) => v !== null && v !== void 0).map((v) => [(0, _kubb_ast_utils.trimQuotes)(v.toString()), v]) ?? [],
860
873
  type: enumOptions.type,
861
874
  enumKeyCasing: enumOptions.keyCasing
862
875
  });
@@ -876,39 +889,6 @@ function Enum({ node, enum: enumOptions, resolver }) {
876
889
  })] });
877
890
  }
878
891
  //#endregion
879
- //#region src/components/Type.tsx
880
- function Type({ name, node, printer, enum: enumOptions, resolver }) {
881
- const enumSchemaNodes = _kubb_core.ast.collect(node, { schema(n) {
882
- const enumNode = _kubb_core.ast.narrowSchema(n, _kubb_core.ast.schemaTypes.enum);
883
- if (enumNode?.name) return enumNode;
884
- } });
885
- const output = printer.print(node);
886
- if (!output) return;
887
- const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((node) => {
888
- return {
889
- node,
890
- ...getEnumNames({
891
- node,
892
- enum: enumOptions,
893
- resolver
894
- })
895
- };
896
- });
897
- const shouldExportEnums = enumOptions.type !== "inlineLiteral";
898
- const shouldExportType = enumOptions.type === "inlineLiteral" || enums.every((item) => item.typeName !== name);
899
- 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, {
900
- node,
901
- enum: enumOptions,
902
- resolver
903
- }, node.name)), shouldExportType && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
904
- name,
905
- isTypeOnly: true,
906
- isExportable: true,
907
- isIndexable: true,
908
- children: output
909
- })] });
910
- }
911
- //#endregion
912
892
  //#region ../../internals/shared/src/params.ts
913
893
  const caseParamsCache = /* @__PURE__ */ new WeakMap();
914
894
  /**
@@ -929,6 +909,23 @@ function caseParams(params, casing) {
929
909
  caseParamsCache.set(params, result);
930
910
  return result;
931
911
  }
912
+ /**
913
+ * Drops parameters that collapse to the same property identity once camelCased, keeping the first.
914
+ *
915
+ * Some specs declare the same parameter twice under different casings (for example AWS S3 lists both
916
+ * `max-uploads` and `MaxUploads`). Both resolve to one output property, so emitting both would yield
917
+ * an object type with a duplicate member, which TypeScript rejects. De-duplicate by the camelCased
918
+ * identity so the resulting group is collision-free regardless of the names each caller carries.
919
+ */
920
+ function dedupeByCasedName(params) {
921
+ const seen = /* @__PURE__ */ new Set();
922
+ return params.filter((param) => {
923
+ const key = camelCase(param.name);
924
+ if (seen.has(key)) return false;
925
+ seen.add(key);
926
+ return true;
927
+ });
928
+ }
932
929
  //#endregion
933
930
  //#region ../../internals/shared/src/operation.ts
934
931
  /**
@@ -982,10 +979,10 @@ function resolveContentTypeVariants(entries, baseName) {
982
979
  function getOperationParameters(node, options = {}) {
983
980
  const params = caseParams(node.parameters, options.paramsCasing === "original" ? void 0 : "camelcase");
984
981
  return {
985
- path: params.filter((param) => param.in === "path"),
986
- query: params.filter((param) => param.in === "query"),
987
- header: params.filter((param) => param.in === "header"),
988
- cookie: params.filter((param) => param.in === "cookie")
982
+ path: dedupeByCasedName(params.filter((param) => param.in === "path")),
983
+ query: dedupeByCasedName(params.filter((param) => param.in === "query")),
984
+ header: dedupeByCasedName(params.filter((param) => param.in === "header")),
985
+ cookie: dedupeByCasedName(params.filter((param) => param.in === "cookie"))
989
986
  };
990
987
  }
991
988
  //#endregion
@@ -1022,6 +1019,18 @@ function createGroupConfig(group) {
1022
1019
  //#endregion
1023
1020
  //#region src/utils.ts
1024
1021
  /**
1022
+ * Tells whether a `const` (single-value enum) should render as a bare literal type (`'active'`)
1023
+ * rather than a named enum reference or a runtime enum declaration.
1024
+ *
1025
+ * The parser folds `const` into a single-value enum node. The adapter decides which schemas are
1026
+ * named enums and lists them in `enumSchemaNames`, and references to those names get suffixed (for
1027
+ * example `StatusKey`). A const renders as a literal only when the adapter has not registered it as
1028
+ * a named enum, which keeps the declaration and its references in sync across adapter versions.
1029
+ */
1030
+ function isInlineConstEnum(node, enumSchemaNames) {
1031
+ return (node.namedEnumValues ?? node.enumValues ?? []).length === 1 && !(node.name && enumSchemaNames?.has(node.name));
1032
+ }
1033
+ /**
1025
1034
  * Collects JSDoc annotation strings for a schema node.
1026
1035
  *
1027
1036
  * Only uses official JSDoc tags from https://jsdoc.app/: `@description`, `@deprecated`, `@default`, `@example`, `@type`.
@@ -1133,17 +1142,48 @@ function buildData(node, { resolver }) {
1133
1142
  ]
1134
1143
  });
1135
1144
  }
1145
+ /**
1146
+ * The schema a status occupies in the `<Name>Responses` record. A status that documents several
1147
+ * content types becomes a `{ contentType; data }` union so the runtime can surface the negotiated type
1148
+ * on `result.parsed`, while the standalone `<Name>StatusNNN` alias stays the plain body union that the
1149
+ * query hooks and `result.data` use.
1150
+ */
1151
+ function buildResponseRecordEntry(node, res, resolver) {
1152
+ const statusName = resolver.resolveResponseStatusName(node, res.statusCode);
1153
+ const variants = (res.content ?? []).filter((entry) => entry.schema);
1154
+ if (variants.length <= 1) return _kubb_core.ast.factory.createSchema({
1155
+ type: "ref",
1156
+ name: statusName
1157
+ });
1158
+ return _kubb_core.ast.factory.createSchema({
1159
+ type: "union",
1160
+ members: resolveContentTypeVariants(variants, statusName).map((variant) => _kubb_core.ast.factory.createSchema({
1161
+ type: "object",
1162
+ properties: [_kubb_core.ast.factory.createProperty({
1163
+ name: "contentType",
1164
+ required: true,
1165
+ schema: _kubb_core.ast.factory.createSchema({
1166
+ type: "enum",
1167
+ enumValues: [variant.contentType]
1168
+ })
1169
+ }), _kubb_core.ast.factory.createProperty({
1170
+ name: "data",
1171
+ required: true,
1172
+ schema: _kubb_core.ast.factory.createSchema({
1173
+ type: "ref",
1174
+ name: variant.name
1175
+ })
1176
+ })]
1177
+ }))
1178
+ });
1179
+ }
1136
1180
  function buildResponses(node, { resolver }) {
1137
- if (node.responses.length === 0) return null;
1138
1181
  return _kubb_core.ast.factory.createSchema({
1139
1182
  type: "object",
1140
1183
  properties: node.responses.map((res) => _kubb_core.ast.factory.createProperty({
1141
1184
  name: String(res.statusCode),
1142
1185
  required: true,
1143
- schema: _kubb_core.ast.factory.createSchema({
1144
- type: "ref",
1145
- name: resolver.resolveResponseStatusName(node, res.statusCode)
1146
- })
1186
+ schema: buildResponseRecordEntry(node, res, resolver)
1147
1187
  }))
1148
1188
  });
1149
1189
  }
@@ -1159,6 +1199,39 @@ function buildResponseUnion(node, { resolver }) {
1159
1199
  });
1160
1200
  }
1161
1201
  //#endregion
1202
+ //#region src/components/Type.tsx
1203
+ 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);
1206
+ if (enumNode?.name && !isInlineConstEnum(enumNode, printer.options.enumSchemaNames)) return enumNode;
1207
+ } });
1208
+ const output = printer.print(node);
1209
+ if (!output) return;
1210
+ const enums = [...new Map(enumSchemaNodes.map((n) => [n.name, n])).values()].map((node) => {
1211
+ return {
1212
+ node,
1213
+ ...getEnumNames({
1214
+ node,
1215
+ enum: enumOptions,
1216
+ resolver
1217
+ })
1218
+ };
1219
+ });
1220
+ const shouldExportEnums = enumOptions.type !== "inlineLiteral";
1221
+ 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, {
1223
+ node,
1224
+ enum: enumOptions,
1225
+ resolver
1226
+ }, node.name)), shouldExportType && /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsx)(_kubb_renderer_jsx.File.Source, {
1227
+ name,
1228
+ isTypeOnly: true,
1229
+ isExportable: true,
1230
+ isIndexable: true,
1231
+ children: output
1232
+ })] });
1233
+ }
1234
+ //#endregion
1162
1235
  //#region src/printers/printerTs.ts
1163
1236
  const { isNonNullable } = factory_exports;
1164
1237
  /**
@@ -1214,16 +1287,16 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
1214
1287
  time: dateOrStringNode,
1215
1288
  ref(node) {
1216
1289
  if (!node.name) return null;
1217
- const refName = node.ref ? (0, _kubb_ast_utils.extractRefName)(node.ref) ?? node.name : node.name;
1218
- 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.default(refName, "type") : refName, void 0);
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);
1219
1292
  },
1220
1293
  enum(node) {
1221
1294
  const values = node.namedEnumValues?.map((v) => v.value) ?? node.enumValues ?? [];
1222
- if (this.options.enum.type === "inlineLiteral" || !node.name) return createUnionDeclaration({
1295
+ if (this.options.enum.type === "inlineLiteral" || !node.name || isInlineConstEnum(node, this.options.enumSchemaNames)) return createUnionDeclaration({
1223
1296
  withParentheses: true,
1224
1297
  nodes: values.filter((v) => v !== null && v !== void 0).map((value) => constToTypeNode(value, typeof value)).filter(isNonNullable)
1225
1298
  }) ?? void 0;
1226
- 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.default(node.name, "type"), 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);
1227
1300
  },
1228
1301
  union(node) {
1229
1302
  const members = node.members ?? [];
@@ -1349,7 +1422,8 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1349
1422
  group: group ?? void 0
1350
1423
  }).path
1351
1424
  }));
1352
- const isEnumSchema = !!_kubb_core.ast.narrowSchema(node, _kubb_core.ast.schemaTypes.enum);
1425
+ const enumNode = _kubb_core.ast.narrowSchema(node, _kubb_core.ast.schemaTypes.enum);
1426
+ const isEnumSchema = !!enumNode && !isInlineConstEnum(enumNode, enumSchemaNames);
1353
1427
  const meta = {
1354
1428
  name: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumOptions.type) && isEnumSchema ? resolver.resolveEnumKeyName(node, enumOptions.typeSuffix) : resolver.resolveTypeName(node.name),
1355
1429
  file: resolver.resolveFile({
@@ -1370,6 +1444,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1370
1444
  description: node.description,
1371
1445
  resolver,
1372
1446
  enumSchemaNames,
1447
+ nameMapping: adapter.options.nameMapping,
1373
1448
  nodes: printer?.nodes
1374
1449
  });
1375
1450
  return /* @__PURE__ */ (0, _kubb_renderer_jsx_jsx_runtime.jsxs)(_kubb_renderer_jsx.File, {
@@ -1452,6 +1527,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1452
1527
  keysToOmit,
1453
1528
  resolver,
1454
1529
  enumSchemaNames,
1530
+ nameMapping: adapter.options.nameMapping,
1455
1531
  nodes: printer?.nodes
1456
1532
  });
1457
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, {
@@ -1472,8 +1548,10 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
1472
1548
  })] });
1473
1549
  }
1474
1550
  /**
1475
- * Emits an individual type per content type plus a union alias under `baseName`.
1476
- * Shared by the request body and multi-content-type responses.
1551
+ * Emits an individual type per content type plus a plain union alias under `baseName`. Shared by
1552
+ * the request body and multi-content-type responses. The response record discriminates these
1553
+ * variants by content type in {@link buildResponses}; the standalone alias stays a plain union so
1554
+ * query hooks and `result.data` keep the bare body.
1477
1555
  */
1478
1556
  function buildContentTypeVariants(entries, baseName, decorate) {
1479
1557
  const variants = resolveContentTypeVariants(entries, baseName);