@kubb/plugin-ts 3.0.0-alpha.5 → 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.
@@ -0,0 +1,42 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+
30
+ // ../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js
31
+ var init_esm_shims = __esm({
32
+ "../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js"() {
33
+ "use strict";
34
+ }
35
+ });
36
+
37
+ export {
38
+ __commonJS,
39
+ __toESM,
40
+ init_esm_shims
41
+ };
42
+ //# sourceMappingURL=chunk-TTGZBH7H.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/.pnpm/tsup@8.2.4_@microsoft+api-extractor@7.47.7_@types+node@20.16.2__jiti@1.21.6_postcss@8.4.41_typescript@5.5.4_yaml@2.4.5/node_modules/tsup/assets/esm_shims.js"],"sourcesContent":["// Shim globals in esm bundle\nimport { fileURLToPath } from 'url'\nimport path from 'path'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -2,10 +2,16 @@
2
2
 
3
3
 
4
4
 
5
- var _chunk4BU6YJ3Vcjs = require('./chunk-4BU6YJ3V.cjs');
5
+ var _chunkNNQVIJV5cjs = require('./chunk-NNQVIJV5.cjs');
6
6
 
7
7
 
8
+ var _chunkSEH6NUCXcjs = require('./chunk-SEH6NUCX.cjs');
8
9
 
10
+ // src/components/index.ts
11
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
9
12
 
10
- exports.OasType = _chunk4BU6YJ3Vcjs.OasType; exports.OperationSchema = _chunk4BU6YJ3Vcjs.OperationSchema; exports.Schema = _chunk4BU6YJ3Vcjs.Schema;
13
+
14
+
15
+
16
+ exports.OasType = _chunkNNQVIJV5cjs.OasType; exports.OperationSchema = _chunkNNQVIJV5cjs.OperationSchema; exports.Schema = _chunkNNQVIJV5cjs.Schema;
11
17
  //# sourceMappingURL=components.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-ts/dist/components.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,oJAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-ts/dist/components.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-ts/dist/components.cjs","../src/components/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACTA,8CAAA,CAAA;ADWA;AACE;AACA;AACA;AACF,oJAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-ts/dist/components.cjs","sourcesContent":[null,"export { OasType } from './OasType.tsx'\nexport { OperationSchema } from './OperationSchema.tsx'\nexport { Schema } from './Schema.tsx'\n"]}
@@ -2,7 +2,13 @@ import {
2
2
  OasType,
3
3
  OperationSchema,
4
4
  Schema
5
- } from "./chunk-WURR7AAD.js";
5
+ } from "./chunk-DH5UFT3R.js";
6
+ import {
7
+ init_esm_shims
8
+ } from "./chunk-TTGZBH7H.js";
9
+
10
+ // src/components/index.ts
11
+ init_esm_shims();
6
12
  export {
7
13
  OasType,
8
14
  OperationSchema,
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/components/index.ts"],"sourcesContent":["export { OasType } from './OasType.tsx'\nexport { OperationSchema } from './OperationSchema.tsx'\nexport { Schema } from './Schema.tsx'\n"],"mappings":";;;;;;;;;;AAAA;","names":[]}
package/dist/index.cjs CHANGED
@@ -1,9 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunk4BU6YJ3Vcjs = require('./chunk-4BU6YJ3V.cjs');
4
+ var _chunkNNQVIJV5cjs = require('./chunk-NNQVIJV5.cjs');
5
+ require('./chunk-SEH6NUCX.cjs');
5
6
 
6
7
 
7
8
 
8
- exports.pluginTs = _chunk4BU6YJ3Vcjs.pluginTs; exports.pluginTsName = _chunk4BU6YJ3Vcjs.pluginTsName;
9
+ exports.pluginTs = _chunkNNQVIJV5cjs.pluginTs; exports.pluginTsName = _chunkNNQVIJV5cjs.pluginTsName;
9
10
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-ts/dist/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,qGAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-ts/dist/index.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-ts/dist/index.cjs"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACF,qGAAC","file":"/home/runner/work/kubb/kubb/packages/plugin-ts/dist/index.cjs"}
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
2
  import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
3
3
  import * as KubbFile from '@kubb/fs/types';
4
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
5
4
  import { ts } from '@kubb/parser-ts';
5
+ import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
6
6
 
7
7
  type Options = {
8
8
  output?: {
@@ -58,6 +58,7 @@ type Options = {
58
58
  /**
59
59
  * Choose to use `enum` or `as const` for enums
60
60
  * @default 'asConst'
61
+ * asPascalConst is deprecated
61
62
  */
62
63
  enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
63
64
  /**
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as _kubb_core from '@kubb/core';
2
2
  import { PluginFactoryOptions, ResolveNameParams } from '@kubb/core';
3
3
  import * as KubbFile from '@kubb/fs/types';
4
- import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
5
4
  import { ts } from '@kubb/parser-ts';
5
+ import { ResolvePathOptions, Exclude, Include, Override } from '@kubb/plugin-oas';
6
6
 
7
7
  type Options = {
8
8
  output?: {
@@ -58,6 +58,7 @@ type Options = {
58
58
  /**
59
59
  * Choose to use `enum` or `as const` for enums
60
60
  * @default 'asConst'
61
+ * asPascalConst is deprecated
61
62
  */
62
63
  enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal';
63
64
  /**
package/dist/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  pluginTs,
3
3
  pluginTsName
4
- } from "./chunk-WURR7AAD.js";
4
+ } from "./chunk-DH5UFT3R.js";
5
+ import "./chunk-TTGZBH7H.js";
5
6
  export {
6
7
  pluginTs,
7
8
  pluginTsName
package/dist/oas.cjs CHANGED
@@ -1 +1,7 @@
1
- "use strict";//# sourceMappingURL=oas.cjs.map
1
+ "use strict";
2
+
3
+ var _chunkSEH6NUCXcjs = require('./chunk-SEH6NUCX.cjs');
4
+
5
+ // src/oas/index.ts
6
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
7
+ //# sourceMappingURL=oas.cjs.map
package/dist/oas.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-ts/dist/oas.cjs"],"names":[],"mappings":"AAAA","file":"/home/runner/work/kubb/kubb/packages/plugin-ts/dist/oas.cjs"}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-ts/dist/oas.cjs","../src/oas/index.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACA;ACJA,8CAAA,CAAA","file":"/home/runner/work/kubb/kubb/packages/plugin-ts/dist/oas.cjs","sourcesContent":[null,"export type { Infer, Response, RequestParams, Model } from '@kubb/oas'\n"]}
package/dist/oas.js CHANGED
@@ -1 +1,7 @@
1
+ import {
2
+ init_esm_shims
3
+ } from "./chunk-TTGZBH7H.js";
4
+
5
+ // src/oas/index.ts
6
+ init_esm_shims();
1
7
  //# sourceMappingURL=oas.js.map
package/dist/oas.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/oas/index.ts"],"sourcesContent":["export type { Infer, Response, RequestParams, Model } from '@kubb/oas'\n"],"mappings":";;;;;AAAA;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-ts",
3
- "version": "3.0.0-alpha.5",
3
+ "version": "3.0.0-alpha.7",
4
4
  "description": "Generator plugin-ts",
5
5
  "keywords": [
6
6
  "zod",
@@ -50,12 +50,12 @@
50
50
  "!/**/__tests__/**"
51
51
  ],
52
52
  "dependencies": {
53
- "@kubb/core": "3.0.0-alpha.5",
54
- "@kubb/fs": "3.0.0-alpha.5",
55
- "@kubb/oas": "3.0.0-alpha.5",
56
- "@kubb/parser-ts": "3.0.0-alpha.5",
57
- "@kubb/plugin-oas": "3.0.0-alpha.5",
58
- "@kubb/react": "3.0.0-alpha.5"
53
+ "@kubb/core": "3.0.0-alpha.7",
54
+ "@kubb/fs": "3.0.0-alpha.7",
55
+ "@kubb/oas": "3.0.0-alpha.7",
56
+ "@kubb/parser-ts": "3.0.0-alpha.7",
57
+ "@kubb/plugin-oas": "3.0.0-alpha.7",
58
+ "@kubb/react": "3.0.0-alpha.7"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@types/react": "^18.3.4",
@@ -63,12 +63,12 @@
63
63
  "react": "^18.3.1",
64
64
  "tsup": "^8.2.4",
65
65
  "typescript": "^5.5.4",
66
- "@kubb/config-biome": "3.0.0-alpha.5",
67
- "@kubb/config-ts": "3.0.0-alpha.5",
68
- "@kubb/config-tsup": "3.0.0-alpha.5"
66
+ "@kubb/config-biome": "3.0.0-alpha.7",
67
+ "@kubb/config-ts": "3.0.0-alpha.7",
68
+ "@kubb/config-tsup": "3.0.0-alpha.7"
69
69
  },
70
70
  "peerDependencies": {
71
- "@kubb/react": "3.0.0-alpha.5"
71
+ "@kubb/react": "3.0.0-alpha.7"
72
72
  },
73
73
  "engines": {
74
74
  "node": ">=20"
@@ -1,5 +1,5 @@
1
- import { Parser, File, Type, useApp } from '@kubb/react'
2
1
  import { useOas } from '@kubb/plugin-oas/hooks'
2
+ import { File, Type, useApp } from '@kubb/react'
3
3
 
4
4
  import type { OasTypes } from '@kubb/oas'
5
5
  import type { ReactNode } from 'react'
@@ -17,11 +17,15 @@ type TemplateProps = {
17
17
  function Template({ name, typeName, api }: TemplateProps): ReactNode {
18
18
  return (
19
19
  <>
20
- {`export const ${name} = ${JSON.stringify(api, undefined, 2)} as const`}
20
+ <File.Source name={name} isExportable>
21
+ {`export const ${name} = ${JSON.stringify(api, undefined, 2)} as const`}
22
+ </File.Source>
21
23
  <br />
22
- <Type name={typeName} export>
23
- {`Infer<typeof ${name}>`}
24
- </Type>
24
+ <File.Source name={typeName} isExportable isTypeOnly>
25
+ <Type name={typeName} export>
26
+ {`Infer<typeof ${name}>`}
27
+ </Type>
28
+ </File.Source>
25
29
  </>
26
30
  )
27
31
  }
@@ -62,14 +66,10 @@ OasType.File = function ({ name, typeName, templates = defaultTemplates }: FileP
62
66
  const Template = templates.default
63
67
 
64
68
  return (
65
- <Parser language="typescript">
66
- <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
67
- <File.Import name={['Infer']} path="@kubb/oas" isTypeOnly />
68
- <File.Source>
69
- <OasType Template={Template} name={name} typeName={typeName} />
70
- </File.Source>
71
- </File>
72
- </Parser>
69
+ <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
70
+ <File.Import name={['Infer']} path="@kubb/oas" isTypeOnly />
71
+ <OasType Template={Template} name={name} typeName={typeName} />
72
+ </File>
73
73
  )
74
74
  }
75
75
 
@@ -3,7 +3,7 @@ import { print } from '@kubb/parser-ts'
3
3
  import * as factory from '@kubb/parser-ts/factory'
4
4
  import { Oas } from '@kubb/plugin-oas/components'
5
5
  import { useOas, useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'
6
- import { File, Parser, useApp } from '@kubb/react'
6
+ import { File, useApp } from '@kubb/react'
7
7
 
8
8
  import { SchemaGenerator } from '../SchemaGenerator.tsx'
9
9
 
@@ -85,7 +85,7 @@ function printCombinedSchema({
85
85
  }
86
86
 
87
87
  const namespaceNode = factory.createTypeAliasDeclaration({
88
- name: operation.method === 'get' ? `${name}Query` : `${name}Mutation`,
88
+ name,
89
89
  type: factory.createTypeLiteralNode(
90
90
  Object.keys(properties)
91
91
  .map((key) => {
@@ -119,7 +119,7 @@ export function OperationSchema({ keysToOmit, description }: Props): ReactNode {
119
119
  type FileProps = {}
120
120
 
121
121
  OperationSchema.File = function ({}: FileProps): ReactNode {
122
- const { pluginManager, plugin, mode, fileManager } = useApp<PluginTs>()
122
+ const { pluginManager, plugin, mode } = useApp<PluginTs>()
123
123
  const oas = useOas()
124
124
  const { getSchemas, getFile, getName } = useOperationManager()
125
125
  const operation = useOperation()
@@ -141,21 +141,21 @@ OperationSchema.File = function ({}: FileProps): ReactNode {
141
141
 
142
142
  return (
143
143
  <Oas.Schema key={i} name={name} value={schema} tree={tree}>
144
- {mode === 'split' && <Oas.Schema.Imports extName={plugin.options.extName} isTypeOnly />}
145
- <File.Source>
146
- <OperationSchema description={description} keysToOmit={keysToOmit} />
147
- </File.Source>
144
+ {mode === 'split' && <Oas.Schema.Imports isTypeOnly />}
145
+ <OperationSchema description={description} keysToOmit={keysToOmit} />
148
146
  </Oas.Schema>
149
147
  )
150
148
  }
151
149
 
150
+ const combinedSchemaName = operation.method === 'get' ? `${factoryName}Query` : `${factoryName}Mutation`
151
+
152
152
  return (
153
- <Parser language="typescript">
154
- <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
155
- {items.map(mapItem)}
153
+ <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
154
+ {items.map(mapItem)}
156
155
 
157
- <File.Source>{printCombinedSchema({ name: factoryName, operation, schemas, pluginManager })}</File.Source>
158
- </File>
159
- </Parser>
156
+ <File.Source name={combinedSchemaName} isExportable isTypeOnly>
157
+ {printCombinedSchema({ name: combinedSchemaName, operation, schemas, pluginManager })}
158
+ </File.Source>
159
+ </File>
160
160
  )
161
161
  }
@@ -6,7 +6,7 @@ import { print, type ts } from '@kubb/parser-ts'
6
6
  import * as factory from '@kubb/parser-ts/factory'
7
7
  import { SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'
8
8
  import { useSchema } from '@kubb/plugin-oas/hooks'
9
- import type { ReactNode } from 'react'
9
+ import { Fragment, type ReactNode } from 'react'
10
10
  import { parse, typeKeywordMapper } from '../parser/index.ts'
11
11
  import { pluginTsName } from '../plugin.ts'
12
12
  import type { PluginTs } from '../types.ts'
@@ -26,6 +26,10 @@ export function Schema(props: Props): ReactNode {
26
26
  },
27
27
  } = useApp<PluginTs>()
28
28
 
29
+ if (enumType === 'asPascalConst') {
30
+ pluginManager.logger.emit('warning', `enumType '${enumType}' is deprecated`)
31
+ }
32
+
29
33
  // all checks are also inside this.schema(React)
30
34
  const resolvedName = pluginManager.resolveName({
31
35
  name,
@@ -39,8 +43,7 @@ export function Schema(props: Props): ReactNode {
39
43
  type: 'type',
40
44
  })
41
45
 
42
- const nodes: ts.Node[] = []
43
- const extraNodes: ts.Node[] = []
46
+ const typeNodes: ts.Node[] = []
44
47
 
45
48
  if (!tree.length) {
46
49
  return ''
@@ -52,7 +55,17 @@ export function Schema(props: Props): ReactNode {
52
55
 
53
56
  let type =
54
57
  (tree
55
- .map((schema) => parse(undefined, schema, { name: resolvedName, typeName, description, keysToOmit, optionalType, enumType, mapper }))
58
+ .map((schema) =>
59
+ parse(undefined, schema, {
60
+ name: resolvedName,
61
+ typeName,
62
+ description,
63
+ keysToOmit,
64
+ optionalType,
65
+ enumType,
66
+ mapper,
67
+ }),
68
+ )
56
69
  .filter(Boolean)
57
70
  .at(0) as ts.TypeNode) || typeKeywordMapper.undefined()
58
71
 
@@ -87,36 +100,58 @@ export function Schema(props: Props): ReactNode {
87
100
  })
88
101
 
89
102
  const enumSchemas = SchemaGenerator.deepSearch(tree, schemaKeywords.enum)
90
- if (enumSchemas) {
91
- enumSchemas.forEach((enumSchema) => {
92
- extraNodes.push(
93
- ...factory.createEnumDeclaration({
94
- name: transformers.camelCase(enumSchema.args.name),
95
- typeName: enumSchema.args.typeName,
96
- enums: enumSchema.args.items
97
- .map((item) => (item.value === undefined ? undefined : [transformers.trimQuotes(item.name?.toString()), item.value]))
98
- .filter(Boolean) as unknown as [string, string][],
99
- type: enumType,
100
- }),
101
- )
103
+
104
+ const enums = enumSchemas.map((enumSchema) => {
105
+ const name = enumType === 'asPascalConst' ? transformers.pascalCase(enumSchema.args.name) : transformers.camelCase(enumSchema.args.name)
106
+ const typeName = enumSchema.args.typeName
107
+
108
+ const [nameNode, typeNode] = factory.createEnumDeclaration({
109
+ name,
110
+ typeName,
111
+ enums: enumSchema.args.items
112
+ .map((item) => (item.value === undefined ? undefined : [transformers.trimQuotes(item.name?.toString()), item.value]))
113
+ .filter(Boolean) as unknown as [string, string][],
114
+ type: enumType,
102
115
  })
103
- }
104
116
 
105
- nodes.push(
117
+ return {
118
+ nameNode,
119
+ typeNode,
120
+ name,
121
+ typeName,
122
+ }
123
+ })
124
+
125
+ typeNodes.push(
106
126
  factory.appendJSDocToNode({
107
127
  node,
108
128
  comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),
109
129
  }),
110
130
  )
111
131
 
112
- const filterdNodes = nodes.filter(
113
- (node: ts.Node) =>
114
- !extraNodes.some(
115
- (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,
116
- ),
132
+ return (
133
+ <Fragment>
134
+ {enums.map(({ name, nameNode, typeName, typeNode }, index) => (
135
+ <Fragment key={[name, nameNode].join('-')}>
136
+ {nameNode && (
137
+ <File.Source name={name} isExportable>
138
+ {print(nameNode)}
139
+ </File.Source>
140
+ )}
141
+ {
142
+ <File.Source name={typeName} isExportable={['enum', 'asConst', 'constEnum', 'literal', undefined].includes(enumType)} isTypeOnly>
143
+ {print(typeNode)}
144
+ </File.Source>
145
+ }
146
+ </Fragment>
147
+ ))}
148
+ {enums.every((item) => item.typeName !== resolvedName) && (
149
+ <File.Source name={typeName} isTypeOnly isExportable>
150
+ {print(typeNodes)}
151
+ </File.Source>
152
+ )}
153
+ </Fragment>
117
154
  )
118
-
119
- return print([...extraNodes, ...filterdNodes])
120
155
  }
121
156
 
122
157
  type FileProps = {}
@@ -126,10 +161,8 @@ Schema.File = function ({}: FileProps): ReactNode {
126
161
  const { schema } = useSchema()
127
162
 
128
163
  return (
129
- <Oas.Schema.File output={pluginManager.config.output.path}>
130
- <File.Source>
131
- <Schema description={schema?.description} />
132
- </File.Source>
164
+ <Oas.Schema.File isTypeOnly output={pluginManager.config.output.path}>
165
+ <Schema description={schema?.description} />
133
166
  </Oas.Schema.File>
134
167
  )
135
168
  }
@@ -1,23 +1,27 @@
1
1
  /**
2
2
  * @description Null response
3
- */
4
- export type CreatePets201 = any
3
+ */
4
+ export type createPets201 = any;
5
+
5
6
  /**
6
7
  * @description unexpected error
7
- */
8
- export type CreatePetsError = Error
9
- export type CreatePetsMutationRequest = {
10
- /**
11
- * @type string
12
- */
13
- name: string
14
- /**
15
- * @type string
16
- */
17
- tag: string
18
- }
19
- export type CreatePetsMutationResponse = any
8
+ */
9
+ export type createPetsError = error;
10
+
11
+ export type createPetsMutationRequest = {
12
+ /**
13
+ * @type string
14
+ */
15
+ name: string;
16
+ /**
17
+ * @type string
18
+ */
19
+ tag: string;
20
+ };
21
+
22
+ export type createPetsMutationResponse = any;
23
+
20
24
  export type CreatePetsMutation = {
21
- Response: CreatePetsMutationResponse
22
- Request: CreatePetsMutationRequest
23
- }
25
+ Response: createPetsMutationResponse;
26
+ Request: createPetsMutationRequest;
27
+ };
@@ -1,28 +1,32 @@
1
- export type ShowPetByIdPathParams = {
2
- /**
3
- * @description The id of the pet to retrieve
4
- * @type string
5
- */
6
- petId: string
7
- /**
8
- * @description The id of the pet to retrieve
9
- * @type string
10
- */
11
- testId: string
12
- }
1
+ export type showPetByIdPathParams = {
2
+ /**
3
+ * @description The id of the pet to retrieve
4
+ * @type string
5
+ */
6
+ petId: string;
7
+ /**
8
+ * @description The id of the pet to retrieve
9
+ * @type string
10
+ */
11
+ testId: string;
12
+ };
13
+
13
14
  /**
14
15
  * @description Expected response to a valid request
15
- */
16
- export type ShowPetById200 = Pet
16
+ */
17
+ export type showPetById200 = pet;
18
+
17
19
  /**
18
20
  * @description unexpected error
19
- */
20
- export type ShowPetByIdError = Error
21
+ */
22
+ export type showPetByIdError = error;
23
+
21
24
  /**
22
25
  * @description Expected response to a valid request
23
- */
24
- export type ShowPetByIdQueryResponse = Pet
26
+ */
27
+ export type showPetByIdQueryResponse = pet;
28
+
25
29
  export type ShowPetByIdQuery = {
26
- Response: ShowPetByIdQueryResponse
27
- PathParams: ShowPetByIdPathParams
28
- }
30
+ Response: showPetByIdQueryResponse;
31
+ PathParams: showPetByIdPathParams;
32
+ };
@@ -120,6 +120,7 @@ type ParserOptions = {
120
120
  optionalType: 'questionToken' | 'undefined' | 'questionTokenAndUndefined'
121
121
  /**
122
122
  * @default `'asConst'`
123
+ * asPascalConst is deprecated
123
124
  */
124
125
  enumType: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'
125
126
  keysToOmit?: string[]
package/src/plugin.ts CHANGED
@@ -34,6 +34,10 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
34
34
 
35
35
  return {
36
36
  name: pluginTsName,
37
+ output: {
38
+ exportType: 'barrelNamed',
39
+ ...output,
40
+ },
37
41
  options: {
38
42
  extName: output.extName,
39
43
  transformers,
@@ -112,24 +116,20 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
112
116
 
113
117
  const operationFiles = await operationGenerator.build()
114
118
  await this.addFile(...operationFiles)
115
- },
116
- async buildEnd() {
117
- if (this.config.output.write === false) {
118
- return
119
- }
120
119
 
121
- const root = path.resolve(this.config.root, this.config.output.path)
122
- const files = await this.fileManager.getIndexFiles({
123
- root,
124
- output,
125
- plugin: this.plugin,
126
- logger: this.logger,
127
- })
128
-
129
- await this.fileManager.processFiles({
130
- logger: this.logger,
131
- files,
132
- })
120
+ if (this.config.output.exportType) {
121
+ const barrelFiles = await this.fileManager.getBarrelFiles({
122
+ root,
123
+ output,
124
+ files: this.fileManager.files,
125
+ meta: {
126
+ pluginKey: this.plugin.key,
127
+ },
128
+ logger: this.logger,
129
+ })
130
+
131
+ await this.addFile(...barrelFiles)
132
+ }
133
133
  },
134
134
  }
135
135
  })
package/src/types.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Plugin, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
2
2
  import type * as KubbFile from '@kubb/fs/types'
3
- import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'
4
3
  import type { ts } from '@kubb/parser-ts'
4
+ import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'
5
5
 
6
6
  export type Options = {
7
7
  output?: {
@@ -57,6 +57,7 @@ export type Options = {
57
57
  /**
58
58
  * Choose to use `enum` or `as const` for enums
59
59
  * @default 'asConst'
60
+ * asPascalConst is deprecated
60
61
  */
61
62
  enumType?: 'enum' | 'asConst' | 'asPascalConst' | 'constEnum' | 'literal'
62
63
  /**