@kubb/plugin-ts 5.0.0-beta.81 → 5.0.0-beta.84
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 +66 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.js +17 -18
- package/dist/index.js.map +1 -1
- package/package.json +4 -6
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
|
|
40
|
+
let kubb_kit = require("kubb/kit");
|
|
41
41
|
let _kubb_parser_ts = require("@kubb/parser-ts");
|
|
42
|
-
let
|
|
42
|
+
let kubb_jsx = require("kubb/jsx");
|
|
43
43
|
let typescript = require("typescript");
|
|
44
44
|
typescript = __toESM(typescript, 1);
|
|
45
|
-
let
|
|
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.
|
|
@@ -795,7 +794,7 @@ function buildTupleNode(node, print) {
|
|
|
795
794
|
*/
|
|
796
795
|
function buildPropertyType(schema, baseType, optionalType, optional) {
|
|
797
796
|
const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(optionalType);
|
|
798
|
-
const meta =
|
|
797
|
+
const meta = kubb_kit.ast.syncSchemaRef(schema);
|
|
799
798
|
let type = baseType;
|
|
800
799
|
if (meta.nullable) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.null] });
|
|
801
800
|
if ((optional || meta.nullish || meta.optional) && addsUndefined) type = createUnionDeclaration({ nodes: [type, keywordTypeNodes.undefined] });
|
|
@@ -866,21 +865,21 @@ function Enum({ node, enum: enumOptions, resolver }) {
|
|
|
866
865
|
name: enumName,
|
|
867
866
|
typeName,
|
|
868
867
|
enums: node.namedEnumValues?.map((v) => [
|
|
869
|
-
|
|
868
|
+
kubb_kit.ast.trimQuotes(v.name.toString()),
|
|
870
869
|
v.value,
|
|
871
870
|
v.description
|
|
872
|
-
]) ?? node.enumValues?.filter((v) => v !== null && v !== void 0).map((v) => [
|
|
871
|
+
]) ?? node.enumValues?.filter((v) => v !== null && v !== void 0).map((v) => [kubb_kit.ast.trimQuotes(v.toString()), v]) ?? [],
|
|
873
872
|
type: enumOptions.type,
|
|
874
873
|
enumKeyCasing: enumOptions.keyCasing
|
|
875
874
|
});
|
|
876
875
|
const namesMerge = !!nameNode && enumName === typeName;
|
|
877
|
-
return /* @__PURE__ */ (0,
|
|
876
|
+
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
877
|
name: enumName,
|
|
879
878
|
isExportable: true,
|
|
880
879
|
isIndexable: true,
|
|
881
880
|
isTypeOnly: false,
|
|
882
881
|
children: _kubb_parser_ts.parserTs.print(nameNode)
|
|
883
|
-
}), /* @__PURE__ */ (0,
|
|
882
|
+
}), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
884
883
|
name: typeName,
|
|
885
884
|
isIndexable: !namesMerge,
|
|
886
885
|
isExportable: !namesMerge && ENUM_TYPES_WITH_RUNTIME_VALUE.has(enumOptions.type),
|
|
@@ -1041,30 +1040,30 @@ function isSchemaOptional(schema) {
|
|
|
1041
1040
|
return Boolean("optional" in schema && schema.optional || "nullish" in schema && schema.nullish);
|
|
1042
1041
|
}
|
|
1043
1042
|
function buildPropertyJSDocComments(schema, optional) {
|
|
1044
|
-
const meta =
|
|
1043
|
+
const meta = kubb_kit.ast.syncSchemaRef(schema);
|
|
1045
1044
|
const isArray = meta?.primitive === "array";
|
|
1046
1045
|
const hasDescription = meta && "description" in meta && meta.description;
|
|
1047
1046
|
const formatComment = meta && "format" in meta && meta.format ? hasDescription ? [" ", `Format: \`${meta.format}\``] : ["@description", `Format: \`${meta.format}\``] : [];
|
|
1048
1047
|
const exampleValues = meta?.examples ?? [];
|
|
1049
1048
|
return [
|
|
1050
|
-
hasDescription ? `@description ${
|
|
1049
|
+
hasDescription ? `@description ${kubb_kit.ast.jsStringEscape(meta.description)}` : null,
|
|
1051
1050
|
...formatComment,
|
|
1052
1051
|
meta && "deprecated" in meta && meta.deprecated ? "@deprecated" : null,
|
|
1053
1052
|
!isArray && meta && "min" in meta && meta.min !== void 0 ? `@minLength ${meta.min}` : null,
|
|
1054
1053
|
!isArray && meta && "max" in meta && meta.max !== void 0 ? `@maxLength ${meta.max}` : null,
|
|
1055
1054
|
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" ?
|
|
1055
|
+
meta && "default" in meta && meta.default !== void 0 ? `@default ${"primitive" in meta && meta.primitive === "string" ? kubb_kit.ast.stringify(meta.default) : meta.default}` : null,
|
|
1057
1056
|
...exampleValues.map((example) => `@example ${example}`),
|
|
1058
1057
|
meta && "primitive" in meta && meta.primitive ? [`@type ${meta.primitive}`, optional ?? isSchemaOptional(schema) ? " | undefined" : null].filter(Boolean).join("") : null
|
|
1059
1058
|
].filter(Boolean);
|
|
1060
1059
|
}
|
|
1061
1060
|
function buildParams(node, { params, resolver }) {
|
|
1062
|
-
return
|
|
1061
|
+
return kubb_kit.ast.factory.createSchema({
|
|
1063
1062
|
type: "object",
|
|
1064
|
-
properties: params.map((param) =>
|
|
1063
|
+
properties: params.map((param) => kubb_kit.ast.factory.createProperty({
|
|
1065
1064
|
name: param.name,
|
|
1066
1065
|
required: param.required,
|
|
1067
|
-
schema:
|
|
1066
|
+
schema: kubb_kit.ast.factory.createSchema({
|
|
1068
1067
|
type: "ref",
|
|
1069
1068
|
name: resolver.resolveParamName(node, param),
|
|
1070
1069
|
optional: !param.required
|
|
@@ -1078,62 +1077,62 @@ function buildData(node, { resolver }) {
|
|
|
1078
1077
|
const hasRequiredPath = pathParams.some((param) => param.required);
|
|
1079
1078
|
const hasRequiredQuery = queryParams.some((param) => param.required);
|
|
1080
1079
|
const hasRequiredHeader = headerParams.some((param) => param.required);
|
|
1081
|
-
return
|
|
1080
|
+
return kubb_kit.ast.factory.createSchema({
|
|
1082
1081
|
type: "object",
|
|
1083
1082
|
deprecated: node.deprecated,
|
|
1084
1083
|
properties: [
|
|
1085
|
-
|
|
1084
|
+
kubb_kit.ast.factory.createProperty({
|
|
1086
1085
|
name: "body",
|
|
1087
1086
|
required: hasBody,
|
|
1088
|
-
schema: hasBody ?
|
|
1087
|
+
schema: hasBody ? kubb_kit.ast.factory.createSchema({
|
|
1089
1088
|
type: "ref",
|
|
1090
1089
|
name: resolver.resolveDataName(node)
|
|
1091
|
-
}) :
|
|
1090
|
+
}) : kubb_kit.ast.factory.createSchema({
|
|
1092
1091
|
type: "never",
|
|
1093
1092
|
primitive: void 0,
|
|
1094
1093
|
optional: true
|
|
1095
1094
|
})
|
|
1096
1095
|
}),
|
|
1097
|
-
|
|
1096
|
+
kubb_kit.ast.factory.createProperty({
|
|
1098
1097
|
name: "path",
|
|
1099
1098
|
required: hasRequiredPath,
|
|
1100
|
-
schema: pathParams.length > 0 ?
|
|
1099
|
+
schema: pathParams.length > 0 ? kubb_kit.ast.factory.createSchema({
|
|
1101
1100
|
...buildParams(node, {
|
|
1102
1101
|
params: pathParams,
|
|
1103
1102
|
resolver
|
|
1104
1103
|
}),
|
|
1105
1104
|
optional: !hasRequiredPath
|
|
1106
|
-
}) :
|
|
1105
|
+
}) : kubb_kit.ast.factory.createSchema({
|
|
1107
1106
|
type: "never",
|
|
1108
1107
|
primitive: void 0,
|
|
1109
1108
|
optional: true
|
|
1110
1109
|
})
|
|
1111
1110
|
}),
|
|
1112
|
-
|
|
1111
|
+
kubb_kit.ast.factory.createProperty({
|
|
1113
1112
|
name: "query",
|
|
1114
1113
|
required: hasRequiredQuery,
|
|
1115
|
-
schema: queryParams.length > 0 ?
|
|
1114
|
+
schema: queryParams.length > 0 ? kubb_kit.ast.factory.createSchema({
|
|
1116
1115
|
...buildParams(node, {
|
|
1117
1116
|
params: queryParams,
|
|
1118
1117
|
resolver
|
|
1119
1118
|
}),
|
|
1120
1119
|
optional: !hasRequiredQuery
|
|
1121
|
-
}) :
|
|
1120
|
+
}) : kubb_kit.ast.factory.createSchema({
|
|
1122
1121
|
type: "never",
|
|
1123
1122
|
primitive: void 0,
|
|
1124
1123
|
optional: true
|
|
1125
1124
|
})
|
|
1126
1125
|
}),
|
|
1127
|
-
|
|
1126
|
+
kubb_kit.ast.factory.createProperty({
|
|
1128
1127
|
name: "headers",
|
|
1129
1128
|
required: hasRequiredHeader,
|
|
1130
|
-
schema: headerParams.length > 0 ?
|
|
1129
|
+
schema: headerParams.length > 0 ? kubb_kit.ast.factory.createSchema({
|
|
1131
1130
|
...buildParams(node, {
|
|
1132
1131
|
params: headerParams,
|
|
1133
1132
|
resolver
|
|
1134
1133
|
}),
|
|
1135
1134
|
optional: !hasRequiredHeader
|
|
1136
|
-
}) :
|
|
1135
|
+
}) : kubb_kit.ast.factory.createSchema({
|
|
1137
1136
|
type: "never",
|
|
1138
1137
|
primitive: void 0,
|
|
1139
1138
|
optional: true
|
|
@@ -1151,25 +1150,25 @@ function buildData(node, { resolver }) {
|
|
|
1151
1150
|
function buildResponseRecordEntry(node, res, resolver) {
|
|
1152
1151
|
const statusName = resolver.resolveResponseStatusName(node, res.statusCode);
|
|
1153
1152
|
const variants = (res.content ?? []).filter((entry) => entry.schema);
|
|
1154
|
-
if (variants.length <= 1) return
|
|
1153
|
+
if (variants.length <= 1) return kubb_kit.ast.factory.createSchema({
|
|
1155
1154
|
type: "ref",
|
|
1156
1155
|
name: statusName
|
|
1157
1156
|
});
|
|
1158
|
-
return
|
|
1157
|
+
return kubb_kit.ast.factory.createSchema({
|
|
1159
1158
|
type: "union",
|
|
1160
|
-
members: resolveContentTypeVariants(variants, statusName).map((variant) =>
|
|
1159
|
+
members: resolveContentTypeVariants(variants, statusName).map((variant) => kubb_kit.ast.factory.createSchema({
|
|
1161
1160
|
type: "object",
|
|
1162
|
-
properties: [
|
|
1161
|
+
properties: [kubb_kit.ast.factory.createProperty({
|
|
1163
1162
|
name: "contentType",
|
|
1164
1163
|
required: true,
|
|
1165
|
-
schema:
|
|
1164
|
+
schema: kubb_kit.ast.factory.createSchema({
|
|
1166
1165
|
type: "enum",
|
|
1167
1166
|
enumValues: [variant.contentType]
|
|
1168
1167
|
})
|
|
1169
|
-
}),
|
|
1168
|
+
}), kubb_kit.ast.factory.createProperty({
|
|
1170
1169
|
name: "data",
|
|
1171
1170
|
required: true,
|
|
1172
|
-
schema:
|
|
1171
|
+
schema: kubb_kit.ast.factory.createSchema({
|
|
1173
1172
|
type: "ref",
|
|
1174
1173
|
name: variant.name
|
|
1175
1174
|
})
|
|
@@ -1178,9 +1177,9 @@ function buildResponseRecordEntry(node, res, resolver) {
|
|
|
1178
1177
|
});
|
|
1179
1178
|
}
|
|
1180
1179
|
function buildResponses(node, { resolver }) {
|
|
1181
|
-
return
|
|
1180
|
+
return kubb_kit.ast.factory.createSchema({
|
|
1182
1181
|
type: "object",
|
|
1183
|
-
properties: node.responses.map((res) =>
|
|
1182
|
+
properties: node.responses.map((res) => kubb_kit.ast.factory.createProperty({
|
|
1184
1183
|
name: String(res.statusCode),
|
|
1185
1184
|
required: true,
|
|
1186
1185
|
schema: buildResponseRecordEntry(node, res, resolver)
|
|
@@ -1190,9 +1189,9 @@ function buildResponses(node, { resolver }) {
|
|
|
1190
1189
|
function buildResponseUnion(node, { resolver }) {
|
|
1191
1190
|
const responsesWithSchema = node.responses.filter((res) => res.content?.some((entry) => entry.schema));
|
|
1192
1191
|
if (responsesWithSchema.length === 0) return null;
|
|
1193
|
-
return
|
|
1192
|
+
return kubb_kit.ast.factory.createSchema({
|
|
1194
1193
|
type: "union",
|
|
1195
|
-
members: responsesWithSchema.map((res) =>
|
|
1194
|
+
members: responsesWithSchema.map((res) => kubb_kit.ast.factory.createSchema({
|
|
1196
1195
|
type: "ref",
|
|
1197
1196
|
name: resolver.resolveResponseStatusName(node, res.statusCode)
|
|
1198
1197
|
}))
|
|
@@ -1201,8 +1200,8 @@ function buildResponseUnion(node, { resolver }) {
|
|
|
1201
1200
|
//#endregion
|
|
1202
1201
|
//#region src/components/Type.tsx
|
|
1203
1202
|
function Type({ name, node, printer, enum: enumOptions, resolver }) {
|
|
1204
|
-
const enumSchemaNodes =
|
|
1205
|
-
const enumNode =
|
|
1203
|
+
const enumSchemaNodes = kubb_kit.ast.collect(node, { schema(n) {
|
|
1204
|
+
const enumNode = kubb_kit.ast.narrowSchema(n, kubb_kit.ast.schemaTypes.enum);
|
|
1206
1205
|
if (enumNode?.name && !isInlineConstEnum(enumNode, printer.options.enumSchemaNames)) return enumNode;
|
|
1207
1206
|
} });
|
|
1208
1207
|
const output = printer.print(node);
|
|
@@ -1219,11 +1218,11 @@ function Type({ name, node, printer, enum: enumOptions, resolver }) {
|
|
|
1219
1218
|
});
|
|
1220
1219
|
const shouldExportEnums = enumOptions.type !== "inlineLiteral";
|
|
1221
1220
|
const shouldExportType = enumOptions.type === "inlineLiteral" || enums.every((item) => item.typeName !== name);
|
|
1222
|
-
return /* @__PURE__ */ (0,
|
|
1221
|
+
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
1222
|
node,
|
|
1224
1223
|
enum: enumOptions,
|
|
1225
1224
|
resolver
|
|
1226
|
-
}, node.name)), shouldExportType && /* @__PURE__ */ (0,
|
|
1225
|
+
}, node.name)), shouldExportType && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Source, {
|
|
1227
1226
|
name,
|
|
1228
1227
|
isTypeOnly: true,
|
|
1229
1228
|
isExportable: true,
|
|
@@ -1257,7 +1256,7 @@ const { isNonNullable } = factory_exports;
|
|
|
1257
1256
|
* const declaration = printer.print(schemaNode) // ts.TypeAliasDeclaration | ts.InterfaceDeclaration
|
|
1258
1257
|
* ```
|
|
1259
1258
|
*/
|
|
1260
|
-
const printerTs =
|
|
1259
|
+
const printerTs = kubb_kit.ast.createPrinter((options) => {
|
|
1261
1260
|
const addsUndefined = OPTIONAL_ADDS_UNDEFINED.has(options.optionalType);
|
|
1262
1261
|
return {
|
|
1263
1262
|
name: "typescript",
|
|
@@ -1287,7 +1286,7 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
|
|
|
1287
1286
|
time: dateOrStringNode,
|
|
1288
1287
|
ref(node) {
|
|
1289
1288
|
if (!node.name) return null;
|
|
1290
|
-
const refName = node.ref ? this.options.nameMapping?.get(node.ref) ??
|
|
1289
|
+
const refName = node.ref ? this.options.nameMapping?.get(node.ref) ?? kubb_kit.ast.extractRefName(node.ref) ?? node.name : node.name;
|
|
1291
1290
|
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);
|
|
1292
1291
|
},
|
|
1293
1292
|
enum(node) {
|
|
@@ -1301,13 +1300,13 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
|
|
|
1301
1300
|
union(node) {
|
|
1302
1301
|
const members = node.members ?? [];
|
|
1303
1302
|
const hasStringLiteral = members.some((m) => {
|
|
1304
|
-
return
|
|
1303
|
+
return kubb_kit.ast.narrowSchema(m, kubb_kit.ast.schemaTypes.enum)?.primitive === "string";
|
|
1305
1304
|
});
|
|
1306
|
-
const hasPlainString = members.some((m) =>
|
|
1305
|
+
const hasPlainString = members.some((m) => kubb_kit.ast.isStringType(m));
|
|
1307
1306
|
if (hasStringLiteral && hasPlainString) return createUnionDeclaration({
|
|
1308
1307
|
withParentheses: true,
|
|
1309
1308
|
nodes: members.map((m) => {
|
|
1310
|
-
if (
|
|
1309
|
+
if (kubb_kit.ast.isStringType(m)) return createIntersectionDeclaration({
|
|
1311
1310
|
nodes: [keywordTypeNodes.string, createTypeLiteralNode([])],
|
|
1312
1311
|
withParentheses: true
|
|
1313
1312
|
});
|
|
@@ -1327,7 +1326,7 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
|
|
|
1327
1326
|
},
|
|
1328
1327
|
array(node) {
|
|
1329
1328
|
return createArrayDeclaration({
|
|
1330
|
-
nodes:
|
|
1329
|
+
nodes: kubb_kit.ast.mapSchemaItems(node, (item) => this.transform(item)).map(({ output }) => output).filter(isNonNullable),
|
|
1331
1330
|
arrayType: this.options.arrayType
|
|
1332
1331
|
}) ?? null;
|
|
1333
1332
|
},
|
|
@@ -1337,11 +1336,11 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
|
|
|
1337
1336
|
object(node) {
|
|
1338
1337
|
const { transform, options } = this;
|
|
1339
1338
|
const addsQuestionToken = OPTIONAL_ADDS_QUESTION_TOKEN.has(options.optionalType);
|
|
1340
|
-
const propertyNodes =
|
|
1339
|
+
const propertyNodes = kubb_kit.ast.mapSchemaProperties(node, (schema) => transform(schema)).map(({ name, property, output }) => {
|
|
1341
1340
|
const baseType = output ?? keywordTypeNodes.unknown;
|
|
1342
1341
|
const optional = !property.required || !!property.schema.optional || !!property.schema.nullish;
|
|
1343
1342
|
const type = buildPropertyType(property.schema, baseType, options.optionalType, optional);
|
|
1344
|
-
const propMeta =
|
|
1343
|
+
const propMeta = kubb_kit.ast.syncSchemaRef(property.schema);
|
|
1345
1344
|
return appendJSDocToNode({
|
|
1346
1345
|
node: createPropertySignature({
|
|
1347
1346
|
questionToken: optional ? addsQuestionToken : false,
|
|
@@ -1362,7 +1361,7 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
|
|
|
1362
1361
|
const { name, syntaxType = "type", description, keysToOmit } = this.options;
|
|
1363
1362
|
const transformed = this.transform(node);
|
|
1364
1363
|
if (!transformed) return null;
|
|
1365
|
-
const meta =
|
|
1364
|
+
const meta = kubb_kit.ast.syncSchemaRef(node);
|
|
1366
1365
|
if (!name) {
|
|
1367
1366
|
const withNullable = meta.nullable ? createUnionDeclaration({ nodes: [transformed, keywordTypeNodes.null] }) : transformed;
|
|
1368
1367
|
const result = (meta.nullish || meta.optional) && addsUndefined ? createUnionDeclaration({ nodes: [withNullable, keywordTypeNodes.undefined] }) : withNullable;
|
|
@@ -1399,9 +1398,9 @@ const printerTs = _kubb_core.ast.createPrinter((options) => {
|
|
|
1399
1398
|
* types. Drop-replace with a custom `Generator<PluginTs>` to change how
|
|
1400
1399
|
* TypeScript output is produced.
|
|
1401
1400
|
*/
|
|
1402
|
-
const typeGenerator = (0,
|
|
1401
|
+
const typeGenerator = (0, kubb_kit.defineGenerator)({
|
|
1403
1402
|
name: "typescript",
|
|
1404
|
-
renderer:
|
|
1403
|
+
renderer: kubb_jsx.jsxRenderer,
|
|
1405
1404
|
schema(node, ctx) {
|
|
1406
1405
|
const { enum: enumOptions, syntaxType, optionalType, arrayType, output, group, printer } = ctx.options;
|
|
1407
1406
|
const { adapter, config, resolver, root } = ctx;
|
|
@@ -1422,7 +1421,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1422
1421
|
group: group ?? void 0
|
|
1423
1422
|
}).path
|
|
1424
1423
|
}));
|
|
1425
|
-
const enumNode =
|
|
1424
|
+
const enumNode = kubb_kit.ast.narrowSchema(node, kubb_kit.ast.schemaTypes.enum);
|
|
1426
1425
|
const isEnumSchema = !!enumNode && !isInlineConstEnum(enumNode, enumSchemaNames);
|
|
1427
1426
|
const meta = {
|
|
1428
1427
|
name: ENUM_TYPES_WITH_KEY_SUFFIX.has(enumOptions.type) && isEnumSchema ? resolver.resolveEnumKeyName(node, enumOptions.typeSuffix) : resolver.resolveTypeName(node.name),
|
|
@@ -1447,7 +1446,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1447
1446
|
nameMapping: adapter.options.nameMapping,
|
|
1448
1447
|
nodes: printer?.nodes
|
|
1449
1448
|
});
|
|
1450
|
-
return /* @__PURE__ */ (0,
|
|
1449
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1451
1450
|
baseName: meta.file.baseName,
|
|
1452
1451
|
path: meta.file.path,
|
|
1453
1452
|
meta: meta.file.meta,
|
|
@@ -1467,7 +1466,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1467
1466
|
baseName: meta.file.baseName
|
|
1468
1467
|
}
|
|
1469
1468
|
}),
|
|
1470
|
-
children: [imports.map((imp) => /* @__PURE__ */ (0,
|
|
1469
|
+
children: [imports.map((imp) => /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(kubb_jsx.File.Import, {
|
|
1471
1470
|
root: meta.file.path,
|
|
1472
1471
|
path: imp.path,
|
|
1473
1472
|
name: imp.name,
|
|
@@ -1476,7 +1475,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1476
1475
|
node.name,
|
|
1477
1476
|
imp.path,
|
|
1478
1477
|
imp.isTypeOnly
|
|
1479
|
-
].join("-"))), /* @__PURE__ */ (0,
|
|
1478
|
+
].join("-"))), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Type, {
|
|
1480
1479
|
name: meta.name,
|
|
1481
1480
|
node,
|
|
1482
1481
|
enum: enumOptions,
|
|
@@ -1530,7 +1529,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1530
1529
|
nameMapping: adapter.options.nameMapping,
|
|
1531
1530
|
nodes: printer?.nodes
|
|
1532
1531
|
});
|
|
1533
|
-
return /* @__PURE__ */ (0,
|
|
1532
|
+
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
1533
|
root: meta.file.path,
|
|
1535
1534
|
path: imp.path,
|
|
1536
1535
|
name: imp.name,
|
|
@@ -1539,7 +1538,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1539
1538
|
name,
|
|
1540
1539
|
imp.path,
|
|
1541
1540
|
imp.isTypeOnly
|
|
1542
|
-
].join("-"))), /* @__PURE__ */ (0,
|
|
1541
|
+
].join("-"))), /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Type, {
|
|
1543
1542
|
name,
|
|
1544
1543
|
node: schema,
|
|
1545
1544
|
enum: enumOptions,
|
|
@@ -1555,14 +1554,14 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1555
1554
|
*/
|
|
1556
1555
|
function buildContentTypeVariants(entries, baseName, decorate) {
|
|
1557
1556
|
const variants = resolveContentTypeVariants(entries, baseName);
|
|
1558
|
-
const unionSchema =
|
|
1557
|
+
const unionSchema = kubb_kit.ast.factory.createSchema({
|
|
1559
1558
|
type: "union",
|
|
1560
|
-
members: variants.map((variant) =>
|
|
1559
|
+
members: variants.map((variant) => kubb_kit.ast.factory.createSchema({
|
|
1561
1560
|
type: "ref",
|
|
1562
1561
|
name: variant.name
|
|
1563
1562
|
}))
|
|
1564
1563
|
});
|
|
1565
|
-
return /* @__PURE__ */ (0,
|
|
1564
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx_jsx_runtime.Fragment, { children: [variants.map((variant) => renderSchemaType({
|
|
1566
1565
|
schema: decorate ? decorate(variant.schema) : variant.schema,
|
|
1567
1566
|
name: variant.name,
|
|
1568
1567
|
keysToOmit: variant.keysToOmit
|
|
@@ -1638,7 +1637,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1638
1637
|
});
|
|
1639
1638
|
}
|
|
1640
1639
|
const responseType = buildResponseType();
|
|
1641
|
-
return /* @__PURE__ */ (0,
|
|
1640
|
+
return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
|
|
1642
1641
|
baseName: meta.file.baseName,
|
|
1643
1642
|
path: meta.file.path,
|
|
1644
1643
|
meta: meta.file.meta,
|
|
@@ -1689,7 +1688,7 @@ const typeGenerator = (0, _kubb_core.defineGenerator)({
|
|
|
1689
1688
|
* resolverTs.resolveResponseStatusName(node, 200) // 'ListPetsStatus200'
|
|
1690
1689
|
* ```
|
|
1691
1690
|
*/
|
|
1692
|
-
const resolverTs = (0,
|
|
1691
|
+
const resolverTs = (0, kubb_kit.defineResolver)(() => {
|
|
1693
1692
|
return {
|
|
1694
1693
|
name: "default",
|
|
1695
1694
|
pluginName: "plugin-ts",
|
|
@@ -1751,7 +1750,7 @@ const pluginTsName = "plugin-ts";
|
|
|
1751
1750
|
*
|
|
1752
1751
|
* @example
|
|
1753
1752
|
* ```ts
|
|
1754
|
-
* import { defineConfig } from 'kubb'
|
|
1753
|
+
* import { defineConfig } from 'kubb/config'
|
|
1755
1754
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
1756
1755
|
*
|
|
1757
1756
|
* export default defineConfig({
|
|
@@ -1767,7 +1766,7 @@ const pluginTsName = "plugin-ts";
|
|
|
1767
1766
|
* })
|
|
1768
1767
|
* ```
|
|
1769
1768
|
*/
|
|
1770
|
-
const pluginTs = (0,
|
|
1769
|
+
const pluginTs = (0, kubb_kit.definePlugin)((options) => {
|
|
1771
1770
|
const { output = {
|
|
1772
1771
|
path: "types",
|
|
1773
1772
|
barrel: { type: "named" }
|