@kubb/plugin-client 5.0.0-alpha.3 → 5.0.0-alpha.31

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.
Files changed (42) hide show
  1. package/dist/clients/axios.d.ts +2 -2
  2. package/dist/index.cjs +1893 -74
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +480 -4
  5. package/dist/index.js +1885 -77
  6. package/dist/index.js.map +1 -1
  7. package/package.json +10 -25
  8. package/src/components/ClassClient.tsx +42 -138
  9. package/src/components/Client.tsx +85 -124
  10. package/src/components/ClientLegacy.tsx +501 -0
  11. package/src/components/Operations.tsx +8 -8
  12. package/src/components/StaticClassClient.tsx +41 -135
  13. package/src/components/Url.tsx +37 -46
  14. package/src/generators/classClientGenerator.tsx +125 -148
  15. package/src/generators/clientGenerator.tsx +93 -82
  16. package/src/generators/groupedClientGenerator.tsx +47 -50
  17. package/src/generators/operationsGenerator.tsx +9 -17
  18. package/src/generators/staticClassClientGenerator.tsx +159 -164
  19. package/src/index.ts +11 -1
  20. package/src/plugin.ts +115 -108
  21. package/src/presets.ts +25 -0
  22. package/src/resolvers/resolverClient.ts +26 -0
  23. package/src/resolvers/resolverClientLegacy.ts +26 -0
  24. package/src/types.ts +105 -40
  25. package/src/utils.ts +148 -0
  26. package/dist/StaticClassClient-By-aMAe4.cjs +0 -677
  27. package/dist/StaticClassClient-By-aMAe4.cjs.map +0 -1
  28. package/dist/StaticClassClient-CCn9g9eF.js +0 -636
  29. package/dist/StaticClassClient-CCn9g9eF.js.map +0 -1
  30. package/dist/components.cjs +0 -7
  31. package/dist/components.d.ts +0 -216
  32. package/dist/components.js +0 -2
  33. package/dist/generators-C2jT7XCH.js +0 -723
  34. package/dist/generators-C2jT7XCH.js.map +0 -1
  35. package/dist/generators-qkDW17Hf.cjs +0 -753
  36. package/dist/generators-qkDW17Hf.cjs.map +0 -1
  37. package/dist/generators.cjs +0 -7
  38. package/dist/generators.d.ts +0 -512
  39. package/dist/generators.js +0 -2
  40. package/dist/types-CdM4DK1M.d.ts +0 -169
  41. package/src/components/index.ts +0 -5
  42. package/src/generators/index.ts +0 -5
@@ -1,47 +1,40 @@
1
1
  import { camelCase } from '@internals/utils'
2
- import { usePluginManager } from '@kubb/core/hooks'
3
- import type { KubbFile } from '@kubb/fabric-core/types'
4
- import { createReactGenerator } from '@kubb/plugin-oas/generators'
5
- import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
6
- import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
2
+ import type { KubbFile } from '@kubb/core'
3
+ import { defineGenerator } from '@kubb/core'
7
4
  import { File, Function } from '@kubb/react-fabric'
8
5
  import type { PluginClient } from '../types'
9
6
 
10
- export const groupedClientGenerator = createReactGenerator<PluginClient>({
7
+ export const groupedClientGenerator = defineGenerator<PluginClient>({
11
8
  name: 'groupedClient',
12
- Operations({ operations, generator, plugin }) {
13
- const { options, name: pluginName } = plugin
14
- const pluginManager = usePluginManager()
9
+ operations(nodes, options) {
10
+ const { config, resolver, adapter, root } = this
11
+ const { output, group } = options
15
12
 
16
- const oas = useOas()
17
- const { getName, getFile, getGroup } = useOperationManager(generator)
13
+ const controllers = nodes.reduce(
14
+ (acc, operationNode) => {
15
+ if (group?.type === 'tag') {
16
+ const tag = operationNode.tags[0]
17
+ const name = tag ? group?.name?.({ group: camelCase(tag) }) : undefined
18
18
 
19
- const controllers = operations.reduce(
20
- (acc, operation) => {
21
- if (options.group?.type === 'tag') {
22
- const group = getGroup(operation)
23
- const name = group?.tag ? options.group?.name?.({ group: camelCase(group.tag) }) : undefined
24
-
25
- if (!group?.tag || !name) {
19
+ if (!tag || !name) {
26
20
  return acc
27
21
  }
28
22
 
29
- const file = pluginManager.getFile({
30
- name,
31
- extname: '.ts',
32
- pluginName,
33
- options: { group },
34
- })
23
+ const file = resolver.resolveFile({ name, extname: '.ts', tag }, { root, output, group })
24
+ const clientFile = resolver.resolveFile(
25
+ { name: operationNode.operationId, extname: '.ts', tag: operationNode.tags[0] ?? 'default', path: operationNode.path },
26
+ { root, output, group },
27
+ )
35
28
 
36
29
  const client = {
37
- name: getName(operation, { type: 'function' }),
38
- file: getFile(operation),
30
+ name: resolver.resolveName(operationNode.operationId),
31
+ file: clientFile,
39
32
  }
40
33
 
41
- const previousFile = acc.find((item) => item.file.path === file.path)
34
+ const previous = acc.find((item) => item.file.path === file.path)
42
35
 
43
- if (previousFile) {
44
- previousFile.clients.push(client)
36
+ if (previous) {
37
+ previous.clients.push(client)
45
38
  } else {
46
39
  acc.push({ name, file, clients: [client] })
47
40
  }
@@ -52,27 +45,31 @@ export const groupedClientGenerator = createReactGenerator<PluginClient>({
52
45
  [] as Array<{ name: string; file: KubbFile.File; clients: Array<{ name: string; file: KubbFile.File }> }>,
53
46
  )
54
47
 
55
- return controllers.map(({ name, file, clients }) => {
56
- return (
57
- <File
58
- key={file.path}
59
- baseName={file.baseName}
60
- path={file.path}
61
- meta={file.meta}
62
- banner={getBanner({ oas, output: options.output, config: pluginManager.config })}
63
- footer={getFooter({ oas, output: options.output })}
64
- >
65
- {clients.map((client) => (
66
- <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />
67
- ))}
48
+ return (
49
+ <>
50
+ {controllers.map(({ name, file, clients }) => {
51
+ return (
52
+ <File
53
+ key={file.path}
54
+ baseName={file.baseName}
55
+ path={file.path}
56
+ meta={file.meta}
57
+ banner={resolver.resolveBanner(adapter.rootNode, { output, config })}
58
+ footer={resolver.resolveFooter(adapter.rootNode, { output, config })}
59
+ >
60
+ {clients.map((client) => (
61
+ <File.Import key={client.name} name={[client.name]} root={file.path} path={client.file.path} />
62
+ ))}
68
63
 
69
- <File.Source name={name} isExportable isIndexable>
70
- <Function export name={name}>
71
- {`return { ${clients.map((client) => client.name).join(', ')} }`}
72
- </Function>
73
- </File.Source>
74
- </File>
75
- )
76
- })
64
+ <File.Source name={name} isExportable isIndexable>
65
+ <Function export name={name}>
66
+ {`return { ${clients.map((client) => client.name).join(', ')} }`}
67
+ </Function>
68
+ </File.Source>
69
+ </File>
70
+ )
71
+ })}
72
+ </>
73
+ )
77
74
  },
78
75
  })
@@ -1,34 +1,26 @@
1
- import { usePluginManager } from '@kubb/core/hooks'
2
- import { createReactGenerator } from '@kubb/plugin-oas/generators'
3
- import { useOas } from '@kubb/plugin-oas/hooks'
4
- import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
1
+ import { defineGenerator } from '@kubb/core'
5
2
  import { File } from '@kubb/react-fabric'
6
3
  import { Operations } from '../components/Operations'
7
4
  import type { PluginClient } from '../types'
8
5
 
9
- export const operationsGenerator = createReactGenerator<PluginClient>({
6
+ export const operationsGenerator = defineGenerator<PluginClient>({
10
7
  name: 'client',
11
- Operations({ operations, plugin }) {
12
- const {
13
- name: pluginName,
14
- options: { output },
15
- } = plugin
16
- const pluginManager = usePluginManager()
17
-
18
- const oas = useOas()
8
+ operations(nodes, options) {
9
+ const { config, resolver, adapter, root } = this
10
+ const { output, group } = options
19
11
 
20
12
  const name = 'operations'
21
- const file = pluginManager.getFile({ name, extname: '.ts', pluginName })
13
+ const file = resolver.resolveFile({ name, extname: '.ts' }, { root, output, group })
22
14
 
23
15
  return (
24
16
  <File
25
17
  baseName={file.baseName}
26
18
  path={file.path}
27
19
  meta={file.meta}
28
- banner={getBanner({ oas, output, config: pluginManager.config })}
29
- footer={getFooter({ oas, output })}
20
+ banner={resolver.resolveBanner(adapter.rootNode, { output, config })}
21
+ footer={resolver.resolveFooter(adapter.rootNode, { output, config })}
30
22
  >
31
- <Operations name={name} operations={operations} />
23
+ <Operations name={name} nodes={nodes} />
32
24
  </File>
33
25
  )
34
26
  },
@@ -1,25 +1,23 @@
1
1
  import path from 'node:path'
2
2
  import { camelCase, pascalCase } from '@internals/utils'
3
- import { usePluginManager } from '@kubb/core/hooks'
4
- import type { KubbFile } from '@kubb/fabric-core/types'
5
- import type { Operation } from '@kubb/oas'
6
- import type { OperationSchemas } from '@kubb/plugin-oas'
7
- import { createReactGenerator } from '@kubb/plugin-oas/generators'
8
- import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
9
- import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
3
+ import type { OperationNode } from '@kubb/ast/types'
4
+ import type { KubbFile } from '@kubb/core'
5
+ import { defineGenerator } from '@kubb/core'
6
+ import type { PluginTs } from '@kubb/plugin-ts'
10
7
  import { pluginTsName } from '@kubb/plugin-ts'
8
+ import type { PluginZod } from '@kubb/plugin-zod'
11
9
  import { pluginZodName } from '@kubb/plugin-zod'
12
10
  import { File } from '@kubb/react-fabric'
13
11
  import { StaticClassClient } from '../components/StaticClassClient'
14
12
  import type { PluginClient } from '../types'
15
13
 
16
14
  type OperationData = {
17
- operation: Operation
15
+ node: OperationNode
18
16
  name: string
19
- typeSchemas: OperationSchemas
20
- zodSchemas: OperationSchemas | undefined
17
+ tsResolver: PluginTs['resolver']
18
+ zodResolver: PluginZod['resolver'] | undefined
21
19
  typeFile: KubbFile.File
22
- zodFile: KubbFile.File
20
+ zodFile: KubbFile.File | undefined
23
21
  }
24
22
 
25
23
  type Controller = {
@@ -28,74 +26,85 @@ type Controller = {
28
26
  operations: Array<OperationData>
29
27
  }
30
28
 
31
- export const staticClassClientGenerator = createReactGenerator<PluginClient>({
32
- name: 'staticClassClient',
33
- Operations({ operations, generator, plugin, config }) {
34
- const { options, name: pluginName } = plugin
35
- const pluginManager = usePluginManager()
36
-
37
- const oas = useOas()
38
- const { getName, getFile, getGroup, getSchemas } = useOperationManager(generator)
29
+ function resolveTypeImportNames(node: OperationNode, tsResolver: PluginTs['resolver']): Array<string> {
30
+ const names: Array<string | undefined> = [
31
+ node.requestBody?.schema ? tsResolver.resolveDataName(node) : undefined,
32
+ tsResolver.resolveResponseName(node),
33
+ ...node.parameters.filter((p) => p.in === 'path').map((p) => tsResolver.resolvePathParamsName(node, p)),
34
+ ...node.parameters.filter((p) => p.in === 'query').map((p) => tsResolver.resolveQueryParamsName(node, p)),
35
+ ...node.parameters.filter((p) => p.in === 'header').map((p) => tsResolver.resolveHeaderParamsName(node, p)),
36
+ ...node.responses.map((res) => tsResolver.resolveResponseStatusName(node, res.statusCode)),
37
+ ]
38
+ return names.filter((n): n is string => Boolean(n))
39
+ }
39
40
 
40
- function buildOperationData(operation: Operation): OperationData {
41
- const type = {
42
- file: getFile(operation, { pluginName: pluginTsName }),
43
- schemas: getSchemas(operation, { pluginName: pluginTsName, type: 'type' }),
44
- }
41
+ function resolveZodImportNames(node: OperationNode, zodResolver: PluginZod['resolver']): Array<string> {
42
+ const names: Array<string | undefined> = [zodResolver.resolveResponseName?.(node), node.requestBody?.schema ? zodResolver.resolveDataName?.(node) : undefined]
43
+ return names.filter((n): n is string => Boolean(n))
44
+ }
45
45
 
46
- const zod = {
47
- file: getFile(operation, { pluginName: pluginZodName }),
48
- schemas: getSchemas(operation, { pluginName: pluginZodName, type: 'function' }),
49
- }
46
+ export const staticClassClientGenerator = defineGenerator<PluginClient>({
47
+ name: 'staticClassClient',
48
+ operations(nodes, options) {
49
+ const { adapter, config, driver, resolver, root } = this
50
+ const { output, group, dataReturnType, paramsCasing, paramsType, pathParamsType, parser, importPath } = options
51
+ const baseURL = options.baseURL ?? adapter.rootNode?.meta?.baseURL
52
+
53
+ const pluginTs = driver.getPlugin(pluginTsName)
54
+ if (!pluginTs?.resolver) return null
55
+
56
+ const tsResolver = pluginTs.resolver
57
+ const tsPluginOptions = pluginTs.options
58
+ const pluginZod = parser === 'zod' ? driver.getPlugin(pluginZodName) : undefined
59
+ const zodResolver = pluginZod?.resolver
60
+
61
+ function buildOperationData(node: OperationNode): OperationData {
62
+ const typeFile = tsResolver.resolveFile(
63
+ { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },
64
+ { root, output: tsPluginOptions?.output ?? output, group: tsPluginOptions?.group },
65
+ )
66
+ const zodFile =
67
+ zodResolver && pluginZod?.options
68
+ ? zodResolver.resolveFile(
69
+ { name: node.operationId, extname: '.ts', tag: node.tags[0] ?? 'default', path: node.path },
70
+ { root, output: pluginZod.options.output ?? output, group: pluginZod.options.group },
71
+ )
72
+ : undefined
50
73
 
51
74
  return {
52
- operation,
53
- name: getName(operation, { type: 'function' }),
54
- typeSchemas: type.schemas,
55
- zodSchemas: zod.schemas,
56
- typeFile: type.file,
57
- zodFile: zod.file,
75
+ node: node,
76
+ name: resolver.resolveName(node.operationId),
77
+ tsResolver,
78
+ zodResolver,
79
+ typeFile,
80
+ zodFile,
58
81
  }
59
82
  }
60
83
 
61
- // Group operations by tag
62
- const controllers = operations.reduce(
63
- (acc, operation) => {
64
- const group = getGroup(operation)
65
- const groupName = group?.tag ? (options.group?.name?.({ group: camelCase(group.tag) }) ?? pascalCase(group.tag)) : 'Client'
84
+ const controllers = nodes.reduce(
85
+ (acc, operationNode) => {
86
+ const tag = operationNode.tags[0]
87
+ const groupName = tag ? (group?.name?.({ group: camelCase(tag) }) ?? pascalCase(tag)) : 'Client'
66
88
 
67
- if (!group?.tag && !options.group) {
68
- // If no grouping, put all operations in a single class
89
+ if (!tag && !group) {
69
90
  const name = 'ApiClient'
70
- const file = pluginManager.getFile({
71
- name,
72
- extname: '.ts',
73
- pluginName,
74
- })
91
+ const file = resolver.resolveFile({ name, extname: '.ts' }, { root, output, group })
92
+ const operationData = buildOperationData(operationNode)
93
+ const previous = acc.find((item) => item.file.path === file.path)
75
94
 
76
- const operationData = buildOperationData(operation)
77
- const previousFile = acc.find((item) => item.file.path === file.path)
78
-
79
- if (previousFile) {
80
- previousFile.operations.push(operationData)
95
+ if (previous) {
96
+ previous.operations.push(operationData)
81
97
  } else {
82
98
  acc.push({ name, file, operations: [operationData] })
83
99
  }
84
- } else if (group?.tag) {
85
- // Group by tag
100
+ } else if (tag) {
86
101
  const name = groupName
87
- const file = pluginManager.getFile({
88
- name,
89
- extname: '.ts',
90
- pluginName,
91
- options: { group },
92
- })
93
-
94
- const operationData = buildOperationData(operation)
95
- const previousFile = acc.find((item) => item.file.path === file.path)
96
-
97
- if (previousFile) {
98
- previousFile.operations.push(operationData)
102
+ const file = resolver.resolveFile({ name, extname: '.ts', tag }, { root, output, group })
103
+ const operationData = buildOperationData(operationNode)
104
+ const previous = acc.find((item) => item.file.path === file.path)
105
+
106
+ if (previous) {
107
+ previous.operations.push(operationData)
99
108
  } else {
100
109
  acc.push({ name, file, operations: [operationData] })
101
110
  }
@@ -111,22 +120,15 @@ export const staticClassClientGenerator = createReactGenerator<PluginClient>({
111
120
  const typeFilesByPath = new Map<string, KubbFile.File>()
112
121
 
113
122
  ops.forEach((op) => {
114
- const { typeSchemas, typeFile } = op
115
-
116
- if (!typeImportsByFile.has(typeFile.path)) {
117
- typeImportsByFile.set(typeFile.path, new Set())
123
+ const names = resolveTypeImportNames(op.node, tsResolver)
124
+ if (!typeImportsByFile.has(op.typeFile.path)) {
125
+ typeImportsByFile.set(op.typeFile.path, new Set())
118
126
  }
119
- const typeImports = typeImportsByFile.get(typeFile.path)!
120
-
121
- if (typeSchemas.request?.name) typeImports.add(typeSchemas.request.name)
122
- if (typeSchemas.response?.name) typeImports.add(typeSchemas.response.name)
123
- if (typeSchemas.pathParams?.name) typeImports.add(typeSchemas.pathParams.name)
124
- if (typeSchemas.queryParams?.name) typeImports.add(typeSchemas.queryParams.name)
125
- if (typeSchemas.headerParams?.name) typeImports.add(typeSchemas.headerParams.name)
126
- typeSchemas.statusCodes?.forEach((item) => {
127
- if (item?.name) typeImports.add(item.name)
127
+ const imports = typeImportsByFile.get(op.typeFile.path)!
128
+ names.forEach((n) => {
129
+ imports.add(n)
128
130
  })
129
- typeFilesByPath.set(typeFile.path, typeFile)
131
+ typeFilesByPath.set(op.typeFile.path, op.typeFile)
130
132
  })
131
133
 
132
134
  return { typeImportsByFile, typeFilesByPath }
@@ -137,97 +139,90 @@ export const staticClassClientGenerator = createReactGenerator<PluginClient>({
137
139
  const zodFilesByPath = new Map<string, KubbFile.File>()
138
140
 
139
141
  ops.forEach((op) => {
140
- const { zodSchemas, zodFile } = op
141
-
142
- if (!zodImportsByFile.has(zodFile.path)) {
143
- zodImportsByFile.set(zodFile.path, new Set())
142
+ if (!op.zodFile || !zodResolver) return
143
+ const names = resolveZodImportNames(op.node, zodResolver)
144
+ if (!zodImportsByFile.has(op.zodFile.path)) {
145
+ zodImportsByFile.set(op.zodFile.path, new Set())
144
146
  }
145
- const zodImports = zodImportsByFile.get(zodFile.path)!
146
-
147
- if (zodSchemas?.response?.name) zodImports.add(zodSchemas.response.name)
148
- if (zodSchemas?.request?.name) zodImports.add(zodSchemas.request.name)
149
- zodFilesByPath.set(zodFile.path, zodFile)
147
+ const imports = zodImportsByFile.get(op.zodFile.path)!
148
+ names.forEach((n) => {
149
+ imports.add(n)
150
+ })
151
+ zodFilesByPath.set(op.zodFile.path, op.zodFile)
150
152
  })
151
153
 
152
154
  return { zodImportsByFile, zodFilesByPath }
153
155
  }
154
156
 
155
- return controllers.map(({ name, file, operations: ops }) => {
156
- const { typeImportsByFile, typeFilesByPath } = collectTypeImports(ops)
157
- const { zodImportsByFile, zodFilesByPath } =
158
- options.parser === 'zod'
159
- ? collectZodImports(ops)
160
- : { zodImportsByFile: new Map<string, Set<string>>(), zodFilesByPath: new Map<string, KubbFile.File>() }
161
- const hasFormData = ops.some((op) => op.operation.getContentType() === 'multipart/form-data')
162
-
163
- return (
164
- <File
165
- key={file.path}
166
- baseName={file.baseName}
167
- path={file.path}
168
- meta={file.meta}
169
- banner={getBanner({ oas, output: options.output, config: pluginManager.config })}
170
- footer={getFooter({ oas, output: options.output })}
171
- >
172
- {options.importPath ? (
173
- <>
174
- <File.Import name={'fetch'} path={options.importPath} />
175
- <File.Import name={['mergeConfig']} path={options.importPath} />
176
- <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.importPath} isTypeOnly />
177
- </>
178
- ) : (
179
- <>
180
- <File.Import name={['fetch']} root={file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />
181
- <File.Import name={['mergeConfig']} root={file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />
182
- <File.Import
183
- name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
184
- root={file.path}
185
- path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}
186
- isTypeOnly
157
+ return (
158
+ <>
159
+ {controllers.map(({ name, file, operations: ops }) => {
160
+ const { typeImportsByFile, typeFilesByPath } = collectTypeImports(ops)
161
+ const { zodImportsByFile, zodFilesByPath } =
162
+ parser === 'zod' ? collectZodImports(ops) : { zodImportsByFile: new Map<string, Set<string>>(), zodFilesByPath: new Map<string, KubbFile.File>() }
163
+ const hasFormData = ops.some((op) => op.node.requestBody?.contentType === 'multipart/form-data')
164
+
165
+ return (
166
+ <File
167
+ key={file.path}
168
+ baseName={file.baseName}
169
+ path={file.path}
170
+ meta={file.meta}
171
+ banner={resolver.resolveBanner(adapter.rootNode, { output, config })}
172
+ footer={resolver.resolveFooter(adapter.rootNode, { output, config })}
173
+ >
174
+ {importPath ? (
175
+ <>
176
+ <File.Import name={'fetch'} path={importPath} />
177
+ <File.Import name={['mergeConfig']} path={importPath} />
178
+ <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={importPath} isTypeOnly />
179
+ </>
180
+ ) : (
181
+ <>
182
+ <File.Import name={['fetch']} root={file.path} path={path.resolve(root, '.kubb/fetch.ts')} />
183
+ <File.Import name={['mergeConfig']} root={file.path} path={path.resolve(root, '.kubb/fetch.ts')} />
184
+ <File.Import
185
+ name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
186
+ root={file.path}
187
+ path={path.resolve(root, '.kubb/fetch.ts')}
188
+ isTypeOnly
189
+ />
190
+ </>
191
+ )}
192
+
193
+ {hasFormData && <File.Import name={['buildFormData']} root={file.path} path={path.resolve(root, '.kubb/config.ts')} />}
194
+
195
+ {Array.from(typeImportsByFile.entries()).map(([filePath, importSet]) => {
196
+ const typeFile = typeFilesByPath.get(filePath)
197
+ if (!typeFile) return null
198
+ const importNames = Array.from(importSet).filter(Boolean)
199
+ if (importNames.length === 0) return null
200
+ return <File.Import key={filePath} name={importNames} root={file.path} path={typeFile.path} isTypeOnly />
201
+ })}
202
+
203
+ {parser === 'zod' &&
204
+ Array.from(zodImportsByFile.entries()).map(([filePath, importSet]) => {
205
+ const zodFile = zodFilesByPath.get(filePath)
206
+ if (!zodFile) return null
207
+ const importNames = Array.from(importSet).filter(Boolean)
208
+ if (importNames.length === 0) return null
209
+ return <File.Import key={filePath} name={importNames} root={file.path} path={zodFile.path} />
210
+ })}
211
+
212
+ <StaticClassClient
213
+ name={name}
214
+ operations={ops}
215
+ baseURL={baseURL}
216
+ dataReturnType={dataReturnType}
217
+ pathParamsType={pathParamsType}
218
+ paramsCasing={paramsCasing}
219
+ paramsType={paramsType}
220
+ parser={parser}
187
221
  />
188
- </>
189
- )}
190
-
191
- {hasFormData && <File.Import name={['buildFormData']} root={file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />}
192
-
193
- {Array.from(typeImportsByFile.entries()).map(([filePath, imports]) => {
194
- const typeFile = typeFilesByPath.get(filePath)
195
- if (!typeFile) {
196
- return null
197
- }
198
- const importNames = Array.from(imports).filter(Boolean)
199
- if (importNames.length === 0) {
200
- return null
201
- }
202
- return <File.Import key={filePath} name={importNames} root={file.path} path={typeFile.path} isTypeOnly />
203
- })}
204
-
205
- {options.parser === 'zod' &&
206
- Array.from(zodImportsByFile.entries()).map(([filePath, imports]) => {
207
- const zodFile = zodFilesByPath.get(filePath)
208
- if (!zodFile) {
209
- return null
210
- }
211
- const importNames = Array.from(imports).filter(Boolean)
212
- if (importNames.length === 0) {
213
- return null
214
- }
215
-
216
- return <File.Import key={filePath} name={importNames} root={file.path} path={zodFile.path} />
217
- })}
218
-
219
- <StaticClassClient
220
- name={name}
221
- operations={ops}
222
- baseURL={options.baseURL}
223
- dataReturnType={options.dataReturnType}
224
- pathParamsType={options.pathParamsType}
225
- paramsCasing={options.paramsCasing}
226
- paramsType={options.paramsType}
227
- parser={options.parser}
228
- />
229
- </File>
230
- )
231
- })
222
+ </File>
223
+ )
224
+ })}
225
+ </>
226
+ )
232
227
  },
233
228
  })
package/src/index.ts CHANGED
@@ -1,2 +1,12 @@
1
+ export { Client } from './components/Client.tsx'
2
+ export { ClientLegacy, UrlLegacy } from './components/ClientLegacy.tsx'
3
+ export { classClientGenerator } from './generators/classClientGenerator.tsx'
4
+ export { clientGenerator } from './generators/clientGenerator.tsx'
5
+ export { groupedClientGenerator } from './generators/groupedClientGenerator.tsx'
6
+ export { operationsGenerator } from './generators/operationsGenerator.tsx'
7
+ export { staticClassClientGenerator } from './generators/staticClassClientGenerator.tsx'
1
8
  export { pluginClient, pluginClientName } from './plugin.ts'
2
- export type { ClientImportPath, PluginClient } from './types.ts'
9
+ export { presets } from './presets.ts'
10
+ export { resolverClient } from './resolvers/resolverClient.ts'
11
+ export { resolverClientLegacy } from './resolvers/resolverClientLegacy.ts'
12
+ export type { ClientImportPath, PluginClient, ResolverClient } from './types.ts'