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