@kubb/plugin-ts 4.0.0 → 4.0.2
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/{components-CTopmaD3.cjs → components-BlMLL1s7.cjs} +17 -11
- package/dist/{components-CTopmaD3.cjs.map → components-BlMLL1s7.cjs.map} +1 -1
- package/dist/{components-BKIt6l3E.js → components-DaYIAKg5.js} +17 -11
- package/dist/{components-BKIt6l3E.js.map → components-DaYIAKg5.js.map} +1 -1
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/generators.cjs +2 -2
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/{plugin-CxMJgMjV.cjs → plugin-CxUQoqgN.cjs} +5 -3
- package/dist/plugin-CxUQoqgN.cjs.map +1 -0
- package/dist/{plugin-nmU_mIiP.js → plugin-D1oIzd18.js} +5 -3
- package/dist/plugin-D1oIzd18.js.map +1 -0
- package/package.json +7 -8
- package/src/components/Type.tsx +20 -8
- package/src/generators/__snapshots__/enumAllOf.ts +2 -2
- package/src/generators/__snapshots__/enumArray20.ts +2 -2
- package/src/generators/__snapshots__/enumInObject.ts +2 -2
- package/src/generators/__snapshots__/enumItems.ts +2 -2
- package/src/generators/__snapshots__/enumNamesType.ts +2 -2
- package/src/generators/__snapshots__/enumNullableMember.ts +2 -2
- package/src/generators/__snapshots__/enumNullableType.ts +2 -2
- package/src/generators/__snapshots__/enumString.ts +2 -2
- package/src/generators/__snapshots__/enumVarNamesType.ts +2 -2
- package/src/generators/__snapshots__/pascalEnum.ts +13 -0
- package/src/generators/typeGenerator.tsx +5 -1
- package/src/parser.ts +4 -3
- package/dist/plugin-CxMJgMjV.cjs.map +0 -1
- package/dist/plugin-nmU_mIiP.js.map +0 -1
|
@@ -1753,7 +1753,7 @@ function parse({ current, siblings, name }, options) {
|
|
|
1753
1753
|
current: schema,
|
|
1754
1754
|
siblings
|
|
1755
1755
|
}, options)).filter(Boolean));
|
|
1756
|
-
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.enum)) return typeKeywordMapper.enum(current.args.typeName);
|
|
1756
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.enum)) return typeKeywordMapper.enum(options.enumType === "asConst" ? `${current.args.typeName}Key` : current.args.typeName);
|
|
1757
1757
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.ref)) return typeKeywordMapper.ref(current.args.name);
|
|
1758
1758
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.blob)) return value();
|
|
1759
1759
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.tuple)) return typeKeywordMapper.tuple(current.args.items.map((schema) => parse({
|
|
@@ -1796,14 +1796,14 @@ function parse({ current, siblings, name }, options) {
|
|
|
1796
1796
|
if (isNullable) type = __kubb_parser_ts_factory.createUnionDeclaration({ nodes: [type, __kubb_parser_ts_factory.keywordTypeNodes.null] });
|
|
1797
1797
|
if (isNullish && ["undefined", "questionTokenAndUndefined"].includes(options.optionalType)) type = __kubb_parser_ts_factory.createUnionDeclaration({ nodes: [type, __kubb_parser_ts_factory.keywordTypeNodes.undefined] });
|
|
1798
1798
|
if (isOptional && ["undefined", "questionTokenAndUndefined"].includes(options.optionalType)) type = __kubb_parser_ts_factory.createUnionDeclaration({ nodes: [type, __kubb_parser_ts_factory.keywordTypeNodes.undefined] });
|
|
1799
|
-
const
|
|
1799
|
+
const propertyNode = __kubb_parser_ts_factory.createPropertySignature({
|
|
1800
1800
|
questionToken: isOptional || isNullish ? ["questionToken", "questionTokenAndUndefined"].includes(options.optionalType) : false,
|
|
1801
1801
|
name: mappedName,
|
|
1802
1802
|
type,
|
|
1803
1803
|
readOnly: isReadonly
|
|
1804
1804
|
});
|
|
1805
1805
|
return __kubb_parser_ts_factory.appendJSDocToNode({
|
|
1806
|
-
node:
|
|
1806
|
+
node: propertyNode,
|
|
1807
1807
|
comments: [
|
|
1808
1808
|
describeSchema ? `@description ${__kubb_core_transformers.default.jsStringEscape(describeSchema.args)}` : void 0,
|
|
1809
1809
|
deprecatedSchema ? "@deprecated" : void 0,
|
|
@@ -1842,6 +1842,7 @@ function Type({ name, typedName, tree, keysToOmit, schema, optionalType, syntaxT
|
|
|
1842
1842
|
const typeNodes = [];
|
|
1843
1843
|
if (!tree.length) return "";
|
|
1844
1844
|
const schemaFromTree = tree.find((item) => item.keyword === __kubb_plugin_oas.schemaKeywords.schema);
|
|
1845
|
+
const enumSchemas = __kubb_plugin_oas.SchemaGenerator.deepSearch(tree, __kubb_plugin_oas.schemaKeywords.enum);
|
|
1845
1846
|
let type = tree.map((current, _index, siblings) => parse({
|
|
1846
1847
|
parent: void 0,
|
|
1847
1848
|
current,
|
|
@@ -1856,6 +1857,15 @@ function Type({ name, typedName, tree, keysToOmit, schema, optionalType, syntaxT
|
|
|
1856
1857
|
mapper,
|
|
1857
1858
|
syntaxType
|
|
1858
1859
|
})).filter(Boolean).at(0) || typeKeywordMapper.undefined();
|
|
1860
|
+
if (enumType === "asConst" && enumSchemas.length > 0) {
|
|
1861
|
+
const isDirectEnum = schema.type === "array" && schema.items !== void 0;
|
|
1862
|
+
const isEnumOnly = "enum" in schema && schema.enum;
|
|
1863
|
+
if (isDirectEnum || isEnumOnly) {
|
|
1864
|
+
const typeNameWithKey = `${enumSchemas[0].args.typeName}Key`;
|
|
1865
|
+
type = __kubb_parser_ts_factory.createTypeReferenceNode(typeNameWithKey);
|
|
1866
|
+
if (schema.type === "array") type = __kubb_parser_ts_factory.createArrayTypeNode(type);
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1859
1869
|
if (schemaFromTree && (0, __kubb_plugin_oas.isKeyword)(schemaFromTree, __kubb_plugin_oas.schemaKeywords.schema)) {
|
|
1860
1870
|
const isNullish = tree.some((item) => item.keyword === __kubb_plugin_oas.schemaKeywords.nullish);
|
|
1861
1871
|
const isNullable = tree.some((item) => item.keyword === __kubb_plugin_oas.schemaKeywords.nullable);
|
|
@@ -1884,10 +1894,9 @@ function Type({ name, typedName, tree, keysToOmit, schema, optionalType, syntaxT
|
|
|
1884
1894
|
schema.example ? `@example ${schema.example}` : void 0
|
|
1885
1895
|
]
|
|
1886
1896
|
}));
|
|
1887
|
-
const enumSchemas = __kubb_plugin_oas.SchemaGenerator.deepSearch(tree, __kubb_plugin_oas.schemaKeywords.enum);
|
|
1888
1897
|
const enums = [...new Set(enumSchemas)].map((enumSchema) => {
|
|
1889
1898
|
const name$1 = enumType === "asPascalConst" ? __kubb_core_transformers.default.pascalCase(enumSchema.args.name) : __kubb_core_transformers.default.camelCase(enumSchema.args.name);
|
|
1890
|
-
const typeName = enumSchema.args.typeName;
|
|
1899
|
+
const typeName = enumType === "asConst" ? `${enumSchema.args.typeName}Key` : enumSchema.args.typeName;
|
|
1891
1900
|
const [nameNode, typeNode] = __kubb_parser_ts_factory.createEnumDeclaration({
|
|
1892
1901
|
name: name$1,
|
|
1893
1902
|
typeName,
|
|
@@ -1922,11 +1931,8 @@ function Type({ name, typedName, tree, keysToOmit, schema, optionalType, syntaxT
|
|
|
1922
1931
|
void 0
|
|
1923
1932
|
].includes(enumType),
|
|
1924
1933
|
children: (0, __kubb_parser_ts.print)([typeNode])
|
|
1925
|
-
})] })),
|
|
1926
|
-
name
|
|
1927
|
-
isTypeOnly: true,
|
|
1928
|
-
isExportable: true,
|
|
1929
|
-
isIndexable: true,
|
|
1934
|
+
})] })), /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
|
|
1935
|
+
name,
|
|
1930
1936
|
children: (0, __kubb_parser_ts.print)(typeNodes)
|
|
1931
1937
|
})] });
|
|
1932
1938
|
}
|
|
@@ -1950,4 +1956,4 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
1950
1956
|
return __toESM;
|
|
1951
1957
|
}
|
|
1952
1958
|
});
|
|
1953
|
-
//# sourceMappingURL=components-
|
|
1959
|
+
//# sourceMappingURL=components-BlMLL1s7.cjs.map
|