@kubb/plugin-ts 3.2.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OJLL42LQ.js → chunk-2FMMBGL3.js} +47 -43
- package/dist/chunk-2FMMBGL3.js.map +1 -0
- package/dist/{chunk-KFZ72XC5.cjs → chunk-663J2WTL.cjs} +19 -15
- package/dist/chunk-663J2WTL.cjs.map +1 -0
- package/dist/{chunk-UE4AMVPZ.cjs → chunk-PNGMUZT2.cjs} +45 -42
- package/dist/chunk-PNGMUZT2.cjs.map +1 -0
- package/dist/{chunk-S2CJKQ76.js → chunk-XCUOQALP.js} +11 -7
- package/dist/chunk-XCUOQALP.js.map +1 -0
- package/dist/components.cjs +3 -3
- package/dist/components.d.cts +3 -2
- package/dist/components.d.ts +3 -2
- package/dist/components.js +1 -1
- package/dist/generators.cjs +4 -4
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{types-Dy6NIaQp.d.cts → types-9taMMp9y.d.cts} +6 -0
- package/dist/{types-Dy6NIaQp.d.ts → types-9taMMp9y.d.ts} +6 -0
- package/package.json +9 -9
- package/src/components/Type.tsx +46 -40
- package/src/generators/__snapshots__/bodyUploadFileApiAssetsPost.ts +5 -5
- package/src/generators/__snapshots__/catTypeAsConst.ts +10 -10
- package/src/generators/__snapshots__/createPet.ts +27 -28
- package/src/generators/__snapshots__/createPetWithUnknownTypeUnknown.ts +27 -28
- package/src/generators/__snapshots__/deletePet.ts +5 -6
- package/src/generators/__snapshots__/dogTypeAsConst.ts +10 -10
- package/src/generators/__snapshots__/enumAllOf.ts +7 -7
- package/src/generators/__snapshots__/enumArray.ts +12 -16
- package/src/generators/__snapshots__/enumInObject.ts +10 -10
- package/src/generators/__snapshots__/enumItems.ts +5 -5
- package/src/generators/__snapshots__/enumNames.ts +3 -3
- package/src/generators/__snapshots__/enumNamesConst.ts +3 -3
- package/src/generators/__snapshots__/enumNamesLiteral.ts +2 -2
- package/src/generators/__snapshots__/enumNamesPascalConst.ts +5 -5
- package/src/generators/__snapshots__/enumNamesType.ts +5 -5
- package/src/generators/__snapshots__/enumNullableMember.ts +5 -5
- package/src/generators/__snapshots__/enumNullableType.ts +5 -5
- package/src/generators/__snapshots__/enumString.ts +7 -7
- package/src/generators/__snapshots__/enumVarNamesType.ts +5 -5
- package/src/generators/__snapshots__/getPets.ts +19 -20
- package/src/generators/__snapshots__/mixedValueTypeConst.ts +6 -6
- package/src/generators/__snapshots__/nullConstNull.ts +4 -5
- package/src/generators/__snapshots__/numberValueConst.ts +6 -6
- package/src/generators/__snapshots__/petMapper.ts +14 -14
- package/src/generators/__snapshots__/petQuestionToken.ts +18 -19
- package/src/generators/__snapshots__/petQuestionTokenAndUndefined.ts +18 -19
- package/src/generators/__snapshots__/petUndefined.ts +18 -19
- package/src/generators/__snapshots__/pets.ts +13 -13
- package/src/generators/__snapshots__/petsInterface.ts +14 -0
- package/src/generators/__snapshots__/petsStoreAdvancedDiscriminator.ts +32 -29
- package/src/generators/__snapshots__/petsStoreDiscriminator.ts +10 -10
- package/src/generators/__snapshots__/petsStoreRef.ts +1 -1
- package/src/generators/__snapshots__/plainDateDate.ts +1 -1
- package/src/generators/__snapshots__/plainDateString.ts +1 -1
- package/src/generators/__snapshots__/plainEmail.ts +1 -1
- package/src/generators/__snapshots__/plainFile.ts +1 -1
- package/src/generators/__snapshots__/plainTimeDate.ts +1 -1
- package/src/generators/__snapshots__/plainUuid.ts +1 -1
- package/src/generators/__snapshots__/readOnly.ts +19 -20
- package/src/generators/__snapshots__/showPetById.ts +24 -25
- package/src/generators/__snapshots__/stringValueConst.ts +6 -6
- package/src/generators/typeGenerator.tsx +4 -2
- package/src/{parser/index.ts → parser.ts} +2 -1
- package/src/plugin.ts +2 -0
- package/src/types.ts +6 -0
- package/dist/chunk-KFZ72XC5.cjs.map +0 -1
- package/dist/chunk-OJLL42LQ.js.map +0 -1
- package/dist/chunk-S2CJKQ76.js.map +0 -1
- package/dist/chunk-UE4AMVPZ.cjs.map +0 -1
|
@@ -3,7 +3,8 @@ import { jsxs, Fragment, jsx } from '@kubb/react/jsx-runtime';
|
|
|
3
3
|
import transformers2 from '@kubb/core/transformers';
|
|
4
4
|
import { print } from '@kubb/parser-ts';
|
|
5
5
|
import * as factory from '@kubb/parser-ts/factory';
|
|
6
|
-
import {
|
|
6
|
+
import { createTypeDeclaration } from '@kubb/parser-ts/factory';
|
|
7
|
+
import { schemaKeywords, isKeyword, SchemaGenerator } from '@kubb/plugin-oas';
|
|
7
8
|
|
|
8
9
|
var __create = Object.create;
|
|
9
10
|
var __defProp = Object.defineProperty;
|
|
@@ -34,9 +35,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
34
35
|
mod
|
|
35
36
|
));
|
|
36
37
|
|
|
37
|
-
// ../../node_modules/.pnpm/tsup@8.3.5_@microsoft+api-extractor@7.48.
|
|
38
|
+
// ../../node_modules/.pnpm/tsup@8.3.5_@microsoft+api-extractor@7.48.1_@types+node@20.17.10__@swc+core@1.7.22_jiti@2.4.1__77u6eq5nvhzfov6ddvuxt4wipe/node_modules/tsup/assets/esm_shims.js
|
|
38
39
|
var init_esm_shims = __esm({
|
|
39
|
-
"../../node_modules/.pnpm/tsup@8.3.5_@microsoft+api-extractor@7.48.
|
|
40
|
+
"../../node_modules/.pnpm/tsup@8.3.5_@microsoft+api-extractor@7.48.1_@types+node@20.17.10__@swc+core@1.7.22_jiti@2.4.1__77u6eq5nvhzfov6ddvuxt4wipe/node_modules/tsup/assets/esm_shims.js"() {
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
43
|
|
|
@@ -2215,7 +2216,7 @@ function OasType({ name, typeName, api }) {
|
|
|
2215
2216
|
init_esm_shims();
|
|
2216
2217
|
var import_react3 = __toESM(require_react());
|
|
2217
2218
|
|
|
2218
|
-
// src/parser
|
|
2219
|
+
// src/parser.ts
|
|
2219
2220
|
init_esm_shims();
|
|
2220
2221
|
var typeKeywordMapper = {
|
|
2221
2222
|
any: () => factory.keywordTypeNodes.any,
|
|
@@ -2423,52 +2424,61 @@ function parse({ parent, current, siblings }, options) {
|
|
|
2423
2424
|
}
|
|
2424
2425
|
return void 0;
|
|
2425
2426
|
}
|
|
2426
|
-
function Type2({ name, typedName, tree, keysToOmit, optionalType, enumType, mapper, description }) {
|
|
2427
|
+
function Type2({ name, typedName, tree, keysToOmit, optionalType, syntaxType, enumType, mapper, description }) {
|
|
2427
2428
|
const typeNodes = [];
|
|
2428
2429
|
if (!tree.length) {
|
|
2429
2430
|
return "";
|
|
2430
2431
|
}
|
|
2431
|
-
const
|
|
2432
|
-
const isNullable = tree.some((item) => item.keyword === schemaKeywords.nullable);
|
|
2433
|
-
const isOptional = tree.some((item) => item.keyword === schemaKeywords.optional);
|
|
2432
|
+
const schema = tree.find((item) => item.keyword === schemaKeywords.schema);
|
|
2434
2433
|
let type = tree.map(
|
|
2435
|
-
(
|
|
2436
|
-
{ parent: void 0, current:
|
|
2434
|
+
(schema2, _index, siblings) => parse(
|
|
2435
|
+
{ parent: void 0, current: schema2, siblings },
|
|
2437
2436
|
{
|
|
2438
2437
|
name,
|
|
2439
|
-
|
|
2438
|
+
typedName,
|
|
2440
2439
|
description,
|
|
2441
2440
|
keysToOmit,
|
|
2442
2441
|
optionalType,
|
|
2443
2442
|
enumType,
|
|
2444
|
-
mapper
|
|
2443
|
+
mapper,
|
|
2444
|
+
syntaxType
|
|
2445
2445
|
}
|
|
2446
2446
|
)
|
|
2447
2447
|
).filter(Boolean).at(0) || typeKeywordMapper.undefined();
|
|
2448
|
-
if (
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
}
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
}
|
|
2448
|
+
if (schema && isKeyword(schema, schemaKeywords.schema) && schema.args.type !== "object") {
|
|
2449
|
+
const isNullish = tree.some((item) => item.keyword === schemaKeywords.nullish);
|
|
2450
|
+
const isNullable = tree.some((item) => item.keyword === schemaKeywords.nullable);
|
|
2451
|
+
const isOptional = tree.some((item) => item.keyword === schemaKeywords.optional);
|
|
2452
|
+
if (isNullable) {
|
|
2453
|
+
type = factory.createUnionDeclaration({
|
|
2454
|
+
nodes: [type, factory.keywordTypeNodes.null]
|
|
2455
|
+
});
|
|
2456
|
+
}
|
|
2457
|
+
if (isNullish && ["undefined", "questionTokenAndUndefined"].includes(optionalType)) {
|
|
2458
|
+
type = factory.createUnionDeclaration({
|
|
2459
|
+
nodes: [type, factory.keywordTypeNodes.undefined]
|
|
2460
|
+
});
|
|
2461
|
+
}
|
|
2462
|
+
if (isOptional && ["undefined", "questionTokenAndUndefined"].includes(optionalType)) {
|
|
2463
|
+
type = factory.createUnionDeclaration({
|
|
2464
|
+
nodes: [type, factory.keywordTypeNodes.undefined]
|
|
2465
|
+
});
|
|
2466
|
+
}
|
|
2462
2467
|
}
|
|
2463
|
-
const
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
type
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2468
|
+
const useTypeGeneration = syntaxType === "type" || [factory.syntaxKind.union].includes(type.kind) || !!keysToOmit?.length;
|
|
2469
|
+
typeNodes.push(
|
|
2470
|
+
createTypeDeclaration({
|
|
2471
|
+
name,
|
|
2472
|
+
isExportable: true,
|
|
2473
|
+
type: keysToOmit?.length ? factory.createOmitDeclaration({
|
|
2474
|
+
keys: keysToOmit,
|
|
2475
|
+
type,
|
|
2476
|
+
nonNullable: true
|
|
2477
|
+
}) : type,
|
|
2478
|
+
syntax: useTypeGeneration ? "type" : "interface",
|
|
2479
|
+
description: description ? transformers2.jsStringEscape(description) : void 0
|
|
2480
|
+
})
|
|
2481
|
+
);
|
|
2472
2482
|
const enumSchemas = SchemaGenerator.deepSearch(tree, schemaKeywords.enum);
|
|
2473
2483
|
const enums = [...new Set(enumSchemas)].map((enumSchema) => {
|
|
2474
2484
|
const name2 = enumType === "asPascalConst" ? transformers2.pascalCase(enumSchema.args.name) : transformers2.camelCase(enumSchema.args.name);
|
|
@@ -2486,12 +2496,6 @@ function Type2({ name, typedName, tree, keysToOmit, optionalType, enumType, mapp
|
|
|
2486
2496
|
typeName
|
|
2487
2497
|
};
|
|
2488
2498
|
});
|
|
2489
|
-
typeNodes.push(
|
|
2490
|
-
factory.appendJSDocToNode({
|
|
2491
|
-
node,
|
|
2492
|
-
comments: [description ? `@description ${transformers2.jsStringEscape(description)}` : void 0].filter(Boolean)
|
|
2493
|
-
})
|
|
2494
|
-
);
|
|
2495
2499
|
return /* @__PURE__ */ jsxs(import_react3.Fragment, { children: [
|
|
2496
2500
|
enums.map(({ name: name2, nameNode, typeName, typeNode }, index) => /* @__PURE__ */ jsxs(import_react3.Fragment, { children: [
|
|
2497
2501
|
nameNode && /* @__PURE__ */ jsx(File.Source, { name: name2, isExportable: true, isIndexable: true, children: print([nameNode]) }),
|
|
@@ -2535,5 +2539,5 @@ react/cjs/react.development.js:
|
|
|
2535
2539
|
*/
|
|
2536
2540
|
|
|
2537
2541
|
export { OasType, Type2 as Type, init_esm_shims };
|
|
2538
|
-
//# sourceMappingURL=chunk-
|
|
2539
|
-
//# sourceMappingURL=chunk-
|
|
2542
|
+
//# sourceMappingURL=chunk-2FMMBGL3.js.map
|
|
2543
|
+
//# sourceMappingURL=chunk-2FMMBGL3.js.map
|