@kubb/plugin-ts 3.0.0-alpha.6 → 3.0.0-alpha.7
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-3TP3WKCF.js → chunk-DH5UFT3R.js} +24 -14
- package/dist/{chunk-3TP3WKCF.js.map → chunk-DH5UFT3R.js.map} +1 -1
- package/dist/{chunk-QBRUTU67.cjs → chunk-NNQVIJV5.cjs} +38 -28
- package/dist/chunk-NNQVIJV5.cjs.map +1 -0
- package/dist/{chunk-YUTLPFP7.cjs → chunk-SEH6NUCX.cjs} +3 -3
- package/dist/{chunk-YUTLPFP7.cjs.map → chunk-SEH6NUCX.cjs.map} +1 -1
- package/dist/{chunk-3LGDZFZS.js → chunk-TTGZBH7H.js} +3 -3
- package/dist/{chunk-3LGDZFZS.js.map → chunk-TTGZBH7H.js.map} +1 -1
- package/dist/components.cjs +4 -4
- package/dist/components.js +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/oas.cjs +2 -2
- package/dist/oas.js +1 -1
- package/package.json +11 -11
- package/src/components/OasType.tsx +1 -1
- package/src/components/OperationSchema.tsx +5 -3
- package/src/components/Schema.tsx +12 -13
- package/src/components/__snapshots__/Schema/pets.ts +6 -6
- package/src/components/__snapshots__/Schema/showPetById.ts +6 -6
- package/src/parser/index.ts +1 -0
- package/src/plugin.ts +10 -4
- package/src/types.ts +2 -1
- package/dist/chunk-QBRUTU67.cjs.map +0 -1
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
__commonJS,
|
|
3
3
|
__toESM,
|
|
4
4
|
init_esm_shims
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TTGZBH7H.js";
|
|
6
6
|
|
|
7
7
|
// ../../node_modules/.pnpm/react@18.3.1/node_modules/react/cjs/react.production.min.js
|
|
8
8
|
var require_react_production_min = __commonJS({
|
|
@@ -2171,7 +2171,7 @@ init_esm_shims();
|
|
|
2171
2171
|
|
|
2172
2172
|
// src/plugin.ts
|
|
2173
2173
|
init_esm_shims();
|
|
2174
|
-
import path from "path";
|
|
2174
|
+
import path from "node:path";
|
|
2175
2175
|
import { FileManager, PluginManager, createPlugin } from "@kubb/core";
|
|
2176
2176
|
import { camelCase, pascalCase } from "@kubb/core/transformers";
|
|
2177
2177
|
import { renderTemplate } from "@kubb/core/utils";
|
|
@@ -2185,8 +2185,8 @@ import { App as App2, createRoot as createRoot2 } from "@kubb/react";
|
|
|
2185
2185
|
|
|
2186
2186
|
// src/components/OasType.tsx
|
|
2187
2187
|
init_esm_shims();
|
|
2188
|
-
import { File, Type, useApp } from "@kubb/react";
|
|
2189
2188
|
import { useOas } from "@kubb/plugin-oas/hooks";
|
|
2189
|
+
import { File, Type, useApp } from "@kubb/react";
|
|
2190
2190
|
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
2191
2191
|
function Template({ name, typeName, api }) {
|
|
2192
2192
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -2450,6 +2450,9 @@ function Schema(props) {
|
|
|
2450
2450
|
options: { mapper, enumType, optionalType }
|
|
2451
2451
|
}
|
|
2452
2452
|
} = useApp2();
|
|
2453
|
+
if (enumType === "asPascalConst") {
|
|
2454
|
+
pluginManager.logger.emit("warning", `enumType '${enumType}' is deprecated`);
|
|
2455
|
+
}
|
|
2453
2456
|
const resolvedName = pluginManager.resolveName({
|
|
2454
2457
|
name,
|
|
2455
2458
|
pluginKey: [pluginTsName],
|
|
@@ -2504,7 +2507,7 @@ function Schema(props) {
|
|
|
2504
2507
|
});
|
|
2505
2508
|
const enumSchemas = SchemaGenerator.deepSearch(tree, schemaKeywords2.enum);
|
|
2506
2509
|
const enums = enumSchemas.map((enumSchema) => {
|
|
2507
|
-
const name2 = transformers2.camelCase(enumSchema.args.name);
|
|
2510
|
+
const name2 = enumType === "asPascalConst" ? transformers2.pascalCase(enumSchema.args.name) : transformers2.camelCase(enumSchema.args.name);
|
|
2508
2511
|
const typeName2 = enumSchema.args.typeName;
|
|
2509
2512
|
const [nameNode, typeNode] = factory2.createEnumDeclaration({
|
|
2510
2513
|
name: name2,
|
|
@@ -2528,15 +2531,15 @@ function Schema(props) {
|
|
|
2528
2531
|
return /* @__PURE__ */ jsxs2(import_react3.Fragment, { children: [
|
|
2529
2532
|
enums.map(({ name: name2, nameNode, typeName: typeName2, typeNode }, index) => /* @__PURE__ */ jsxs2(import_react3.Fragment, { children: [
|
|
2530
2533
|
nameNode && /* @__PURE__ */ jsx2(File2.Source, { name: name2, isExportable: true, children: print(nameNode) }),
|
|
2531
|
-
/* @__PURE__ */ jsx2(File2.Source, { name: typeName2, isExportable:
|
|
2532
|
-
] },
|
|
2534
|
+
/* @__PURE__ */ jsx2(File2.Source, { name: typeName2, isExportable: ["enum", "asConst", "constEnum", "literal", void 0].includes(enumType), isTypeOnly: true, children: print(typeNode) })
|
|
2535
|
+
] }, [name2, nameNode].join("-"))),
|
|
2533
2536
|
enums.every((item) => item.typeName !== resolvedName) && /* @__PURE__ */ jsx2(File2.Source, { name: typeName, isTypeOnly: true, isExportable: true, children: print(typeNodes) })
|
|
2534
2537
|
] });
|
|
2535
2538
|
}
|
|
2536
2539
|
Schema.File = function({}) {
|
|
2537
2540
|
const { pluginManager } = useApp2();
|
|
2538
2541
|
const { schema } = useSchema();
|
|
2539
|
-
return /* @__PURE__ */ jsx2(Oas.Schema.File, { output: pluginManager.config.output.path, children: /* @__PURE__ */ jsx2(Schema, { description: schema?.description }) });
|
|
2542
|
+
return /* @__PURE__ */ jsx2(Oas.Schema.File, { isTypeOnly: true, output: pluginManager.config.output.path, children: /* @__PURE__ */ jsx2(Schema, { description: schema?.description }) });
|
|
2540
2543
|
};
|
|
2541
2544
|
|
|
2542
2545
|
// src/SchemaGenerator.tsx
|
|
@@ -2617,7 +2620,7 @@ function printCombinedSchema({
|
|
|
2617
2620
|
});
|
|
2618
2621
|
}
|
|
2619
2622
|
const namespaceNode = factory3.createTypeAliasDeclaration({
|
|
2620
|
-
name
|
|
2623
|
+
name,
|
|
2621
2624
|
type: factory3.createTypeLiteralNode(
|
|
2622
2625
|
Object.keys(properties).map((key) => {
|
|
2623
2626
|
const type = properties[key];
|
|
@@ -2660,9 +2663,10 @@ OperationSchema.File = function({}) {
|
|
|
2660
2663
|
/* @__PURE__ */ jsx4(OperationSchema, { description, keysToOmit })
|
|
2661
2664
|
] }, i);
|
|
2662
2665
|
};
|
|
2666
|
+
const combinedSchemaName = operation.method === "get" ? `${factoryName}Query` : `${factoryName}Mutation`;
|
|
2663
2667
|
return /* @__PURE__ */ jsxs3(File3, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
2664
2668
|
items.map(mapItem),
|
|
2665
|
-
/* @__PURE__ */ jsx4(File3.Source, { name:
|
|
2669
|
+
/* @__PURE__ */ jsx4(File3.Source, { name: combinedSchemaName, isExportable: true, isTypeOnly: true, children: printCombinedSchema({ name: combinedSchemaName, operation, schemas, pluginManager }) })
|
|
2666
2670
|
] });
|
|
2667
2671
|
};
|
|
2668
2672
|
|
|
@@ -2712,6 +2716,10 @@ var pluginTs = createPlugin((options) => {
|
|
|
2712
2716
|
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`;
|
|
2713
2717
|
return {
|
|
2714
2718
|
name: pluginTsName,
|
|
2719
|
+
output: {
|
|
2720
|
+
exportType: "barrelNamed",
|
|
2721
|
+
...output
|
|
2722
|
+
},
|
|
2715
2723
|
options: {
|
|
2716
2724
|
extName: output.extName,
|
|
2717
2725
|
transformers: transformers4,
|
|
@@ -2775,15 +2783,17 @@ var pluginTs = createPlugin((options) => {
|
|
|
2775
2783
|
});
|
|
2776
2784
|
const operationFiles = await operationGenerator.build();
|
|
2777
2785
|
await this.addFile(...operationFiles);
|
|
2778
|
-
if (this.config.output.
|
|
2779
|
-
const
|
|
2786
|
+
if (this.config.output.exportType) {
|
|
2787
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
2780
2788
|
root,
|
|
2781
2789
|
output,
|
|
2782
2790
|
files: this.fileManager.files,
|
|
2783
|
-
|
|
2791
|
+
meta: {
|
|
2792
|
+
pluginKey: this.plugin.key
|
|
2793
|
+
},
|
|
2784
2794
|
logger: this.logger
|
|
2785
2795
|
});
|
|
2786
|
-
await this.addFile(...
|
|
2796
|
+
await this.addFile(...barrelFiles);
|
|
2787
2797
|
}
|
|
2788
2798
|
}
|
|
2789
2799
|
};
|
|
@@ -2820,4 +2830,4 @@ react/cjs/react.development.js:
|
|
|
2820
2830
|
* LICENSE file in the root directory of this source tree.
|
|
2821
2831
|
*)
|
|
2822
2832
|
*/
|
|
2823
|
-
//# sourceMappingURL=chunk-
|
|
2833
|
+
//# sourceMappingURL=chunk-DH5UFT3R.js.map
|