@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,16 +2,16 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkQBRUTU67cjs = require('./chunk-QBRUTU67.cjs');
5
+ var _chunkNNQVIJV5cjs = require('./chunk-NNQVIJV5.cjs');
6
6
 
7
7
 
8
- var _chunkYUTLPFP7cjs = require('./chunk-YUTLPFP7.cjs');
8
+ var _chunkSEH6NUCXcjs = require('./chunk-SEH6NUCX.cjs');
9
9
 
10
10
  // src/components/index.ts
11
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
11
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
12
12
 
13
13
 
14
14
 
15
15
 
16
- exports.OasType = _chunkQBRUTU67cjs.OasType; exports.OperationSchema = _chunkQBRUTU67cjs.OperationSchema; exports.Schema = _chunkQBRUTU67cjs.Schema;
16
+ exports.OasType = _chunkNNQVIJV5cjs.OasType; exports.OperationSchema = _chunkNNQVIJV5cjs.OperationSchema; exports.Schema = _chunkNNQVIJV5cjs.Schema;
17
17
  //# sourceMappingURL=components.cjs.map
@@ -2,10 +2,10 @@ import {
2
2
  OasType,
3
3
  OperationSchema,
4
4
  Schema
5
- } from "./chunk-3TP3WKCF.js";
5
+ } from "./chunk-DH5UFT3R.js";
6
6
  import {
7
7
  init_esm_shims
8
- } from "./chunk-3LGDZFZS.js";
8
+ } from "./chunk-TTGZBH7H.js";
9
9
 
10
10
  // src/components/index.ts
11
11
  init_esm_shims();
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
3
 
4
- var _chunkQBRUTU67cjs = require('./chunk-QBRUTU67.cjs');
5
- require('./chunk-YUTLPFP7.cjs');
4
+ var _chunkNNQVIJV5cjs = require('./chunk-NNQVIJV5.cjs');
5
+ require('./chunk-SEH6NUCX.cjs');
6
6
 
7
7
 
8
8
 
9
- exports.pluginTs = _chunkQBRUTU67cjs.pluginTs; exports.pluginTsName = _chunkQBRUTU67cjs.pluginTsName;
9
+ exports.pluginTs = _chunkNNQVIJV5cjs.pluginTs; exports.pluginTsName = _chunkNNQVIJV5cjs.pluginTsName;
10
10
  //# sourceMappingURL=index.cjs.map
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,8 +1,8 @@
1
1
  import {
2
2
  pluginTs,
3
3
  pluginTsName
4
- } from "./chunk-3TP3WKCF.js";
5
- import "./chunk-3LGDZFZS.js";
4
+ } from "./chunk-DH5UFT3R.js";
5
+ import "./chunk-TTGZBH7H.js";
6
6
  export {
7
7
  pluginTs,
8
8
  pluginTsName
package/dist/oas.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
- var _chunkYUTLPFP7cjs = require('./chunk-YUTLPFP7.cjs');
3
+ var _chunkSEH6NUCXcjs = require('./chunk-SEH6NUCX.cjs');
4
4
 
5
5
  // src/oas/index.ts
6
- _chunkYUTLPFP7cjs.init_cjs_shims.call(void 0, );
6
+ _chunkSEH6NUCXcjs.init_cjs_shims.call(void 0, );
7
7
  //# sourceMappingURL=oas.cjs.map
package/dist/oas.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  init_esm_shims
3
- } from "./chunk-3LGDZFZS.js";
3
+ } from "./chunk-TTGZBH7H.js";
4
4
 
5
5
  // src/oas/index.ts
6
6
  init_esm_shims();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-ts",
3
- "version": "3.0.0-alpha.6",
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.6",
54
- "@kubb/fs": "3.0.0-alpha.6",
55
- "@kubb/oas": "3.0.0-alpha.6",
56
- "@kubb/parser-ts": "3.0.0-alpha.6",
57
- "@kubb/plugin-oas": "3.0.0-alpha.6",
58
- "@kubb/react": "3.0.0-alpha.6"
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.6",
67
- "@kubb/config-ts": "3.0.0-alpha.6",
68
- "@kubb/config-tsup": "3.0.0-alpha.6"
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.6"
71
+ "@kubb/react": "3.0.0-alpha.7"
72
72
  },
73
73
  "engines": {
74
74
  "node": ">=20"
@@ -1,5 +1,5 @@
1
- import { 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'
@@ -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) => {
@@ -147,12 +147,14 @@ OperationSchema.File = function ({}: FileProps): ReactNode {
147
147
  )
148
148
  }
149
149
 
150
+ const combinedSchemaName = operation.method === 'get' ? `${factoryName}Query` : `${factoryName}Mutation`
151
+
150
152
  return (
151
153
  <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
152
154
  {items.map(mapItem)}
153
155
 
154
- <File.Source name={factoryName} isExportable>
155
- {printCombinedSchema({ name: factoryName, operation, schemas, pluginManager })}
156
+ <File.Source name={combinedSchemaName} isExportable isTypeOnly>
157
+ {printCombinedSchema({ name: combinedSchemaName, operation, schemas, pluginManager })}
156
158
  </File.Source>
157
159
  </File>
158
160
  )
@@ -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,
@@ -98,7 +102,7 @@ export function Schema(props: Props): ReactNode {
98
102
  const enumSchemas = SchemaGenerator.deepSearch(tree, schemaKeywords.enum)
99
103
 
100
104
  const enums = enumSchemas.map((enumSchema) => {
101
- const name = transformers.camelCase(enumSchema.args.name)
105
+ const name = enumType === 'asPascalConst' ? transformers.pascalCase(enumSchema.args.name) : transformers.camelCase(enumSchema.args.name)
102
106
  const typeName = enumSchema.args.typeName
103
107
 
104
108
  const [nameNode, typeNode] = factory.createEnumDeclaration({
@@ -125,25 +129,20 @@ export function Schema(props: Props): ReactNode {
125
129
  }),
126
130
  )
127
131
 
128
- // const filterdNodes = typeNodes.filter(
129
- // (node: ts.Node) =>
130
- // !enumNodes.some(
131
- // (extraNode: ts.Node) => (extraNode as ts.TypeAliasDeclaration)?.name?.escapedText === (node as ts.TypeAliasDeclaration)?.name?.escapedText,
132
- // ),
133
- // )
134
-
135
132
  return (
136
133
  <Fragment>
137
134
  {enums.map(({ name, nameNode, typeName, typeNode }, index) => (
138
- <Fragment key={index}>
135
+ <Fragment key={[name, nameNode].join('-')}>
139
136
  {nameNode && (
140
137
  <File.Source name={name} isExportable>
141
138
  {print(nameNode)}
142
139
  </File.Source>
143
140
  )}
144
- <File.Source name={typeName} isExportable isTypeOnly>
145
- {print(typeNode)}
146
- </File.Source>
141
+ {
142
+ <File.Source name={typeName} isExportable={['enum', 'asConst', 'constEnum', 'literal', undefined].includes(enumType)} isTypeOnly>
143
+ {print(typeNode)}
144
+ </File.Source>
145
+ }
147
146
  </Fragment>
148
147
  ))}
149
148
  {enums.every((item) => item.typeName !== resolvedName) && (
@@ -162,7 +161,7 @@ Schema.File = function ({}: FileProps): ReactNode {
162
161
  const { schema } = useSchema()
163
162
 
164
163
  return (
165
- <Oas.Schema.File output={pluginManager.config.output.path}>
164
+ <Oas.Schema.File isTypeOnly output={pluginManager.config.output.path}>
166
165
  <Schema description={schema?.description} />
167
166
  </Oas.Schema.File>
168
167
  )
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * @description Null response
3
3
  */
4
- export type CreatePets201 = any;
4
+ export type createPets201 = any;
5
5
 
6
6
  /**
7
7
  * @description unexpected error
8
8
  */
9
- export type CreatePetsError = Error;
9
+ export type createPetsError = error;
10
10
 
11
- export type CreatePetsMutationRequest = {
11
+ export type createPetsMutationRequest = {
12
12
  /**
13
13
  * @type string
14
14
  */
@@ -19,9 +19,9 @@ export type CreatePetsMutationRequest = {
19
19
  tag: string;
20
20
  };
21
21
 
22
- export type CreatePetsMutationResponse = any;
22
+ export type createPetsMutationResponse = any;
23
23
 
24
24
  export type CreatePetsMutation = {
25
- Response: CreatePetsMutationResponse;
26
- Request: CreatePetsMutationRequest;
25
+ Response: createPetsMutationResponse;
26
+ Request: createPetsMutationRequest;
27
27
  };
@@ -1,4 +1,4 @@
1
- export type ShowPetByIdPathParams = {
1
+ export type showPetByIdPathParams = {
2
2
  /**
3
3
  * @description The id of the pet to retrieve
4
4
  * @type string
@@ -14,19 +14,19 @@ export type ShowPetByIdPathParams = {
14
14
  /**
15
15
  * @description Expected response to a valid request
16
16
  */
17
- export type ShowPetById200 = Pet;
17
+ export type showPetById200 = pet;
18
18
 
19
19
  /**
20
20
  * @description unexpected error
21
21
  */
22
- export type ShowPetByIdError = Error;
22
+ export type showPetByIdError = error;
23
23
 
24
24
  /**
25
25
  * @description Expected response to a valid request
26
26
  */
27
- export type ShowPetByIdQueryResponse = Pet;
27
+ export type showPetByIdQueryResponse = pet;
28
28
 
29
29
  export type ShowPetByIdQuery = {
30
- Response: ShowPetByIdQueryResponse;
31
- PathParams: ShowPetByIdPathParams;
30
+ Response: showPetByIdQueryResponse;
31
+ PathParams: showPetByIdPathParams;
32
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,
@@ -113,16 +117,18 @@ export const pluginTs = createPlugin<PluginTs>((options) => {
113
117
  const operationFiles = await operationGenerator.build()
114
118
  await this.addFile(...operationFiles)
115
119
 
116
- if (this.config.output.write) {
117
- const indexFiles = await this.fileManager.getIndexFiles({
120
+ if (this.config.output.exportType) {
121
+ const barrelFiles = await this.fileManager.getBarrelFiles({
118
122
  root,
119
123
  output,
120
124
  files: this.fileManager.files,
121
- plugin: this.plugin,
125
+ meta: {
126
+ pluginKey: this.plugin.key,
127
+ },
122
128
  logger: this.logger,
123
129
  })
124
130
 
125
- await this.addFile(...indexFiles)
131
+ await this.addFile(...barrelFiles)
126
132
  }
127
133
  },
128
134
  }
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
  /**