@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.
@@ -2,7 +2,7 @@ import {
2
2
  __commonJS,
3
3
  __toESM,
4
4
  init_esm_shims
5
- } from "./chunk-3LGDZFZS.js";
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: true, isTypeOnly: true, children: print(typeNode) })
2532
- ] }, index)),
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: operation.method === "get" ? `${name}Query` : `${name}Mutation`,
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: factoryName, isExportable: true, children: printCombinedSchema({ name: factoryName, operation, schemas, pluginManager }) })
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.write) {
2779
- const indexFiles = await this.fileManager.getIndexFiles({
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
- plugin: this.plugin,
2791
+ meta: {
2792
+ pluginKey: this.plugin.key
2793
+ },
2784
2794
  logger: this.logger
2785
2795
  });
2786
- await this.addFile(...indexFiles);
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-3TP3WKCF.js.map
2833
+ //# sourceMappingURL=chunk-DH5UFT3R.js.map