@kubb/plugin-react-query 5.0.0-beta.42 → 5.0.0-beta.56

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 (46) hide show
  1. package/dist/{components-IArDg-DO.js → components-DL0Cai7l.js} +211 -255
  2. package/dist/components-DL0Cai7l.js.map +1 -0
  3. package/dist/{components-DQAYLQW0.cjs → components-yMQOuFmI.cjs} +215 -259
  4. package/dist/components-yMQOuFmI.cjs.map +1 -0
  5. package/dist/components.cjs +1 -1
  6. package/dist/components.d.ts +1 -1
  7. package/dist/components.js +1 -1
  8. package/dist/{generators-B86BJkmW.js → generators-BG-Vcvfg.js} +151 -231
  9. package/dist/generators-BG-Vcvfg.js.map +1 -0
  10. package/dist/{generators-BqGaMUH6.cjs → generators-zGKP8yII.cjs} +149 -229
  11. package/dist/generators-zGKP8yII.cjs.map +1 -0
  12. package/dist/generators.cjs +1 -1
  13. package/dist/generators.d.ts +1 -1
  14. package/dist/generators.js +1 -1
  15. package/dist/index.cjs +35 -12
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +36 -13
  19. package/dist/index.js.map +1 -1
  20. package/dist/{types-Dh4HNR9K.d.ts → types-X7D0NSvJ.d.ts} +11 -15
  21. package/package.json +10 -17
  22. package/src/components/InfiniteQuery.tsx +4 -5
  23. package/src/components/InfiniteQueryOptions.tsx +24 -27
  24. package/src/components/Mutation.tsx +5 -6
  25. package/src/components/MutationOptions.tsx +2 -2
  26. package/src/components/Query.tsx +5 -6
  27. package/src/components/QueryOptions.tsx +6 -25
  28. package/src/components/SuspenseInfiniteQuery.tsx +4 -5
  29. package/src/components/SuspenseInfiniteQueryOptions.tsx +24 -25
  30. package/src/components/SuspenseQuery.tsx +5 -6
  31. package/src/generators/customHookOptionsFileGenerator.tsx +2 -2
  32. package/src/generators/hookOptionsGenerator.tsx +2 -2
  33. package/src/generators/infiniteQueryGenerator.tsx +5 -9
  34. package/src/generators/mutationGenerator.tsx +8 -9
  35. package/src/generators/queryGenerator.tsx +5 -9
  36. package/src/generators/suspenseInfiniteQueryGenerator.tsx +5 -9
  37. package/src/generators/suspenseQueryGenerator.tsx +5 -9
  38. package/src/plugin.ts +4 -4
  39. package/src/resolvers/resolverReactQuery.ts +2 -2
  40. package/src/types.ts +9 -13
  41. package/src/utils.ts +1 -0
  42. package/dist/components-DQAYLQW0.cjs.map +0 -1
  43. package/dist/components-IArDg-DO.js.map +0 -1
  44. package/dist/generators-B86BJkmW.js.map +0 -1
  45. package/dist/generators-BqGaMUH6.cjs.map +0 -1
  46. package/extension.yaml +0 -1484
@@ -4,7 +4,7 @@ import { functionPrinter } from '@kubb/plugin-ts'
4
4
  import { File, Function } from '@kubb/renderer-jsx'
5
5
  import type { KubbReactNode } from '@kubb/renderer-jsx/types'
6
6
  import type { PluginReactQuery } from '../types.ts'
7
- import { buildQueryKeyParams, getComments, resolveErrorNames, resolveSuccessNames } from '../utils.ts'
7
+ import { buildQueryKeyParams, buildStatusUnionType, getComments, resolveErrorNames, resolveSuccessNames } from '../utils.ts'
8
8
  import { getQueryOptionsParams } from './QueryOptions.tsx'
9
9
 
10
10
  type Props = {
@@ -40,7 +40,7 @@ function buildSuspenseQueryParamsNode(
40
40
  const requestName = node.requestBody?.content?.[0]?.schema ? resolver.resolveDataName(node) : null
41
41
  const errorNames = resolveErrorNames(node, resolver)
42
42
 
43
- const TData = dataReturnType === 'data' ? responseName : `ResponseConfig<${responseName}>`
43
+ const TData = dataReturnType === 'data' ? responseName : buildStatusUnionType(node, resolver)
44
44
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
45
45
 
46
46
  const optionsParam = ast.createFunctionParameter({
@@ -81,7 +81,7 @@ export function SuspenseQuery({
81
81
  const responseName = successNames.length > 0 ? successNames.join(' | ') : tsResolver.resolveResponseName(node)
82
82
  const errorNames = resolveErrorNames(node, tsResolver)
83
83
 
84
- const TData = dataReturnType === 'data' ? responseName : `ResponseConfig<${responseName}>`
84
+ const TData = dataReturnType === 'data' ? responseName : buildStatusUnionType(node, tsResolver)
85
85
  const TError = `ResponseErrorConfig<${errorNames.length > 0 ? errorNames.join(' | ') : 'Error'}>`
86
86
  const returnType = `UseSuspenseQueryResult<${'TData'}, ${TError}> & { queryKey: TQueryKey }`
87
87
  const generics = [`TData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
@@ -101,11 +101,10 @@ export function SuspenseQuery({
101
101
  {`
102
102
  const { query: queryConfig = {}, client: config = {} } = options ?? {}
103
103
  const { client: queryClient, ...resolvedOptions } = queryConfig
104
- const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})
105
- ${customOptions ? `const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ''}
104
+ const queryKey = resolvedOptions?.queryKey ?? ${queryKeyName}(${queryKeyParamsCall})${customOptions ? `\n const customOptions = ${customOptions.name}({ hookName: '${name}', operationId: '${node.operationId}' })` : ''}
106
105
 
107
106
  const query = useSuspenseQuery({
108
- ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? '\n...customOptions,' : ''}
107
+ ...${queryOptionsName}(${queryOptionsParamsCall}),${customOptions ? '\n ...customOptions,' : ''}
109
108
  ...resolvedOptions,
110
109
  queryKey,
111
110
  } as unknown as UseSuspenseQueryOptions, queryClient) as ${returnType}
@@ -2,7 +2,7 @@ import fs from 'node:fs'
2
2
  import path from 'node:path'
3
3
 
4
4
  import { defineGenerator } from '@kubb/core'
5
- import { File, Function, jsxRendererSync } from '@kubb/renderer-jsx'
5
+ import { File, Function, jsxRenderer } from '@kubb/renderer-jsx'
6
6
  import type { PluginReactQuery } from '../types'
7
7
 
8
8
  /**
@@ -13,7 +13,7 @@ import type { PluginReactQuery } from '../types'
13
13
  */
14
14
  export const customHookOptionsFileGenerator = defineGenerator<PluginReactQuery>({
15
15
  name: 'react-query-custom-hook-options-file',
16
- renderer: jsxRendererSync,
16
+ renderer: jsxRenderer,
17
17
  operations(nodes, ctx) {
18
18
  const { resolver, config, root } = ctx
19
19
  const { output, customOptions, query, group } = ctx.options
@@ -1,6 +1,6 @@
1
1
  import { getOperationParameters, operationFileEntry } from '@internals/shared'
2
2
  import { ast, defineGenerator } from '@kubb/core'
3
- import { File, jsxRendererSync, Type } from '@kubb/renderer-jsx'
3
+ import { File, jsxRenderer, Type } from '@kubb/renderer-jsx'
4
4
  import type { KubbReactNode } from '@kubb/renderer-jsx/types'
5
5
  import type { PluginReactQuery } from '../types'
6
6
  import { resolveOperationOverrides } from '../utils.ts'
@@ -16,7 +16,7 @@ type MutationOption = PluginReactQuery['resolvedOptions']['mutation']
16
16
  */
17
17
  export const hookOptionsGenerator = defineGenerator<PluginReactQuery>({
18
18
  name: 'react-query-hook-options',
19
- renderer: jsxRendererSync,
19
+ renderer: jsxRenderer,
20
20
  operations(nodes, ctx) {
21
21
  const { resolver, config, root } = ctx
22
22
  const { output, customOptions, query, mutation, suspense, infinite, group, override } = ctx.options
@@ -2,10 +2,10 @@ import path from 'node:path'
2
2
  import { getOperationParameters, operationFileEntry, resolveOperationTypeNames } from '@internals/shared'
3
3
  import { resolveZodSchemaNames } from '@internals/tanstack-query'
4
4
  import { ast, defineGenerator } from '@kubb/core'
5
- import { Client, pluginClientName } from '@kubb/plugin-client'
5
+ import { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'
6
6
  import { pluginTsName } from '@kubb/plugin-ts'
7
7
  import { pluginZodName } from '@kubb/plugin-zod'
8
- import { File, jsxRendererSync } from '@kubb/renderer-jsx'
8
+ import { File, jsxRenderer } from '@kubb/renderer-jsx'
9
9
  import { InfiniteQuery, InfiniteQueryOptions, QueryKey } from '../components'
10
10
  import type { PluginReactQuery } from '../types'
11
11
 
@@ -17,7 +17,7 @@ import type { PluginReactQuery } from '../types'
17
17
  */
18
18
  export const infiniteQueryGenerator = defineGenerator<PluginReactQuery>({
19
19
  name: 'react-infinite-query',
20
- renderer: jsxRendererSync,
20
+ renderer: jsxRenderer,
21
21
  operation(node, ctx) {
22
22
  if (!ast.isHttpOperationNode(node)) return null
23
23
  const { config, driver, resolver, root } = ctx
@@ -69,7 +69,7 @@ export const infiniteQueryGenerator = defineGenerator<PluginReactQuery>({
69
69
  order: 'body-response-first',
70
70
  })
71
71
 
72
- const pluginZod = parser === 'zod' ? driver.getPlugin(pluginZodName) : null
72
+ const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : null
73
73
  const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null
74
74
  const fileZod = zodResolver
75
75
  ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
@@ -78,7 +78,7 @@ export const infiniteQueryGenerator = defineGenerator<PluginReactQuery>({
78
78
  group: pluginZod?.options?.group ?? undefined,
79
79
  })
80
80
  : null
81
- const zodSchemaNames = resolveZodSchemaNames(node, zodResolver)
81
+ const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)
82
82
 
83
83
  const clientPlugin = driver.getPlugin(pluginClientName)
84
84
  const hasClientPlugin = clientPlugin?.name === pluginClientName
@@ -108,7 +108,6 @@ export const infiniteQueryGenerator = defineGenerator<PluginReactQuery>({
108
108
  <>
109
109
  {!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
110
110
  <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
111
- {clientOptions.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={clientOptions.importPath} isTypeOnly />}
112
111
  </>
113
112
  ) : (
114
113
  <>
@@ -119,9 +118,6 @@ export const infiniteQueryGenerator = defineGenerator<PluginReactQuery>({
119
118
  path={path.resolve(root, '.kubb/client.ts')}
120
119
  isTypeOnly
121
120
  />
122
- {clientOptions.dataReturnType === 'full' && (
123
- <File.Import name={['ResponseConfig']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} isTypeOnly />
124
- )}
125
121
  </>
126
122
  )}
127
123
  {shouldUseClientPlugin && clientFile && <File.Import name={[resolvedClientName]} root={meta.file.path} path={clientFile.path} />}
@@ -2,10 +2,10 @@ import path from 'node:path'
2
2
  import { operationFileEntry, resolveOperationTypeNames } from '@internals/shared'
3
3
  import { resolveZodSchemaNames } from '@internals/tanstack-query'
4
4
  import { ast, defineGenerator } from '@kubb/core'
5
- import { Client, pluginClientName } from '@kubb/plugin-client'
5
+ import { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'
6
6
  import { pluginTsName } from '@kubb/plugin-ts'
7
7
  import { pluginZodName } from '@kubb/plugin-zod'
8
- import { File, jsxRendererSync } from '@kubb/renderer-jsx'
8
+ import { File, jsxRenderer } from '@kubb/renderer-jsx'
9
9
  import { Mutation, MutationKey, MutationOptions } from '../components'
10
10
  import type { PluginReactQuery } from '../types'
11
11
 
@@ -16,7 +16,7 @@ import type { PluginReactQuery } from '../types'
16
16
  */
17
17
  export const mutationGenerator = defineGenerator<PluginReactQuery>({
18
18
  name: 'react-query-mutation',
19
- renderer: jsxRendererSync,
19
+ renderer: jsxRenderer,
20
20
  operation(node, ctx) {
21
21
  if (!ast.isHttpOperationNode(node)) return null
22
22
  const { config, driver, resolver, root } = ctx
@@ -54,7 +54,7 @@ export const mutationGenerator = defineGenerator<PluginReactQuery>({
54
54
 
55
55
  const importedTypeNames = resolveOperationTypeNames(node, tsResolver, { paramsCasing, order: 'body-response-first' })
56
56
 
57
- const pluginZod = parser === 'zod' ? driver.getPlugin(pluginZodName) : null
57
+ const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : null
58
58
  const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null
59
59
  const fileZod = zodResolver
60
60
  ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
@@ -63,7 +63,7 @@ export const mutationGenerator = defineGenerator<PluginReactQuery>({
63
63
  group: pluginZod?.options?.group ?? undefined,
64
64
  })
65
65
  : null
66
- const zodSchemaNames = resolveZodSchemaNames(node, zodResolver)
66
+ const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)
67
67
 
68
68
  const clientPlugin = driver.getPlugin(pluginClientName)
69
69
  const hasClientPlugin = clientPlugin?.name === pluginClientName
@@ -93,7 +93,6 @@ export const mutationGenerator = defineGenerator<PluginReactQuery>({
93
93
  <>
94
94
  {!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
95
95
  <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
96
- {clientOptions.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={clientOptions.importPath} isTypeOnly />}
97
96
  </>
98
97
  ) : (
99
98
  <>
@@ -104,15 +103,15 @@ export const mutationGenerator = defineGenerator<PluginReactQuery>({
104
103
  path={path.resolve(root, '.kubb/client.ts')}
105
104
  isTypeOnly
106
105
  />
107
- {clientOptions.dataReturnType === 'full' && (
108
- <File.Import name={['ResponseConfig']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} isTypeOnly />
109
- )}
110
106
  </>
111
107
  )}
112
108
  {shouldUseClientPlugin && clientFile && <File.Import name={[resolvedClientName]} root={meta.file.path} path={clientFile.path} />}
113
109
  {!shouldUseClientPlugin && node.requestBody?.content?.some((e) => e.contentType === 'multipart/form-data') && (
114
110
  <File.Import name={['buildFormData']} root={meta.file.path} path={path.resolve(root, '.kubb/config.ts')} />
115
111
  )}
112
+ {!shouldUseClientPlugin && parser === 'zod' && zodResolver && node.requestBody?.content?.[0]?.schema && (
113
+ <File.Import name={['z']} path="zod" isTypeOnly />
114
+ )}
116
115
  {customOptions && <File.Import name={[customOptions.name]} path={customOptions.importPath} />}
117
116
  {meta.fileTs && importedTypeNames.length > 0 && (
118
117
  <File.Import name={Array.from(new Set(importedTypeNames))} root={meta.file.path} path={meta.fileTs.path} isTypeOnly />
@@ -2,10 +2,10 @@ import path from 'node:path'
2
2
  import { operationFileEntry, resolveOperationTypeNames } from '@internals/shared'
3
3
  import { resolveZodSchemaNames } from '@internals/tanstack-query'
4
4
  import { ast, defineGenerator } from '@kubb/core'
5
- import { Client, pluginClientName } from '@kubb/plugin-client'
5
+ import { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'
6
6
  import { pluginTsName } from '@kubb/plugin-ts'
7
7
  import { pluginZodName } from '@kubb/plugin-zod'
8
- import { File, jsxRendererSync } from '@kubb/renderer-jsx'
8
+ import { File, jsxRenderer } from '@kubb/renderer-jsx'
9
9
  import { Query, QueryKey, QueryOptions } from '../components'
10
10
  import type { PluginReactQuery } from '../types'
11
11
 
@@ -16,7 +16,7 @@ import type { PluginReactQuery } from '../types'
16
16
  */
17
17
  export const queryGenerator = defineGenerator<PluginReactQuery>({
18
18
  name: 'react-query',
19
- renderer: jsxRendererSync,
19
+ renderer: jsxRenderer,
20
20
  operation(node, ctx) {
21
21
  if (!ast.isHttpOperationNode(node)) return null
22
22
  const { config, driver, resolver, root } = ctx
@@ -59,7 +59,7 @@ export const queryGenerator = defineGenerator<PluginReactQuery>({
59
59
  order: 'body-response-first',
60
60
  })
61
61
 
62
- const pluginZod = parser === 'zod' ? driver.getPlugin(pluginZodName) : null
62
+ const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : null
63
63
  const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null
64
64
  const fileZod = zodResolver
65
65
  ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
@@ -68,7 +68,7 @@ export const queryGenerator = defineGenerator<PluginReactQuery>({
68
68
  group: pluginZod?.options?.group ?? undefined,
69
69
  })
70
70
  : null
71
- const zodSchemaNames = resolveZodSchemaNames(node, zodResolver)
71
+ const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)
72
72
 
73
73
  const clientPlugin = driver.getPlugin(pluginClientName)
74
74
  const hasClientPlugin = clientPlugin?.name === pluginClientName
@@ -98,7 +98,6 @@ export const queryGenerator = defineGenerator<PluginReactQuery>({
98
98
  <>
99
99
  {!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
100
100
  <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
101
- {clientOptions.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={clientOptions.importPath} isTypeOnly />}
102
101
  </>
103
102
  ) : (
104
103
  <>
@@ -109,9 +108,6 @@ export const queryGenerator = defineGenerator<PluginReactQuery>({
109
108
  path={path.resolve(root, '.kubb/client.ts')}
110
109
  isTypeOnly
111
110
  />
112
- {clientOptions.dataReturnType === 'full' && (
113
- <File.Import name={['ResponseConfig']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} isTypeOnly />
114
- )}
115
111
  </>
116
112
  )}
117
113
  {shouldUseClientPlugin && clientFile && <File.Import name={[resolvedClientName]} root={meta.file.path} path={clientFile.path} />}
@@ -2,10 +2,10 @@ import path from 'node:path'
2
2
  import { getOperationParameters, operationFileEntry, resolveOperationTypeNames } from '@internals/shared'
3
3
  import { resolveZodSchemaNames } from '@internals/tanstack-query'
4
4
  import { ast, defineGenerator } from '@kubb/core'
5
- import { Client, pluginClientName } from '@kubb/plugin-client'
5
+ import { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'
6
6
  import { pluginTsName } from '@kubb/plugin-ts'
7
7
  import { pluginZodName } from '@kubb/plugin-zod'
8
- import { File, jsxRendererSync } from '@kubb/renderer-jsx'
8
+ import { File, jsxRenderer } from '@kubb/renderer-jsx'
9
9
  import { QueryKey, SuspenseInfiniteQuery, SuspenseInfiniteQueryOptions } from '../components'
10
10
  import type { PluginReactQuery } from '../types'
11
11
 
@@ -17,7 +17,7 @@ import type { PluginReactQuery } from '../types'
17
17
  */
18
18
  export const suspenseInfiniteQueryGenerator = defineGenerator<PluginReactQuery>({
19
19
  name: 'react-suspense-infinite-query',
20
- renderer: jsxRendererSync,
20
+ renderer: jsxRenderer,
21
21
  operation(node, ctx) {
22
22
  if (!ast.isHttpOperationNode(node)) return null
23
23
  const { config, driver, resolver, root } = ctx
@@ -78,7 +78,7 @@ export const suspenseInfiniteQueryGenerator = defineGenerator<PluginReactQuery>(
78
78
 
79
79
  const importedTypeNames = resolveOperationTypeNames(node, tsResolver, { paramsCasing, order: 'body-response-first' })
80
80
 
81
- const pluginZod = parser === 'zod' ? driver.getPlugin(pluginZodName) : null
81
+ const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : null
82
82
  const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null
83
83
  const fileZod = zodResolver
84
84
  ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
@@ -87,7 +87,7 @@ export const suspenseInfiniteQueryGenerator = defineGenerator<PluginReactQuery>(
87
87
  group: pluginZod?.options?.group ?? undefined,
88
88
  })
89
89
  : null
90
- const zodSchemaNames = resolveZodSchemaNames(node, zodResolver)
90
+ const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)
91
91
 
92
92
  const clientPlugin = driver.getPlugin(pluginClientName)
93
93
  const hasClientPlugin = clientPlugin?.name === pluginClientName
@@ -117,7 +117,6 @@ export const suspenseInfiniteQueryGenerator = defineGenerator<PluginReactQuery>(
117
117
  <>
118
118
  {!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
119
119
  <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
120
- {clientOptions.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={clientOptions.importPath} isTypeOnly />}
121
120
  </>
122
121
  ) : (
123
122
  <>
@@ -128,9 +127,6 @@ export const suspenseInfiniteQueryGenerator = defineGenerator<PluginReactQuery>(
128
127
  path={path.resolve(root, '.kubb/client.ts')}
129
128
  isTypeOnly
130
129
  />
131
- {clientOptions.dataReturnType === 'full' && (
132
- <File.Import name={['ResponseConfig']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} isTypeOnly />
133
- )}
134
130
  </>
135
131
  )}
136
132
  {shouldUseClientPlugin && clientFile && <File.Import name={[resolvedClientName]} root={meta.file.path} path={clientFile.path} />}
@@ -2,10 +2,10 @@ import path from 'node:path'
2
2
  import { operationFileEntry, resolveOperationTypeNames } from '@internals/shared'
3
3
  import { resolveZodSchemaNames } from '@internals/tanstack-query'
4
4
  import { ast, defineGenerator } from '@kubb/core'
5
- import { Client, pluginClientName } from '@kubb/plugin-client'
5
+ import { Client, isParserEnabled, pluginClientName } from '@kubb/plugin-client'
6
6
  import { pluginTsName } from '@kubb/plugin-ts'
7
7
  import { pluginZodName } from '@kubb/plugin-zod'
8
- import { File, jsxRendererSync } from '@kubb/renderer-jsx'
8
+ import { File, jsxRenderer } from '@kubb/renderer-jsx'
9
9
  import { QueryKey, QueryOptions, SuspenseQuery } from '../components'
10
10
  import type { PluginReactQuery } from '../types'
11
11
 
@@ -17,7 +17,7 @@ import type { PluginReactQuery } from '../types'
17
17
  */
18
18
  export const suspenseQueryGenerator = defineGenerator<PluginReactQuery>({
19
19
  name: 'react-suspense-query',
20
- renderer: jsxRendererSync,
20
+ renderer: jsxRenderer,
21
21
  operation(node, ctx) {
22
22
  if (!ast.isHttpOperationNode(node)) return null
23
23
  const { config, driver, resolver, root } = ctx
@@ -61,7 +61,7 @@ export const suspenseQueryGenerator = defineGenerator<PluginReactQuery>({
61
61
  order: 'body-response-first',
62
62
  })
63
63
 
64
- const pluginZod = parser === 'zod' ? driver.getPlugin(pluginZodName) : null
64
+ const pluginZod = isParserEnabled(parser) ? driver.getPlugin(pluginZodName) : null
65
65
  const zodResolver = pluginZod ? driver.getResolver(pluginZodName) : null
66
66
  const fileZod = zodResolver
67
67
  ? zodResolver.resolveFile(operationFileEntry(node, node.operationId), {
@@ -70,7 +70,7 @@ export const suspenseQueryGenerator = defineGenerator<PluginReactQuery>({
70
70
  group: pluginZod?.options?.group ?? undefined,
71
71
  })
72
72
  : null
73
- const zodSchemaNames = resolveZodSchemaNames(node, zodResolver)
73
+ const zodSchemaNames = resolveZodSchemaNames(node, zodResolver, parser)
74
74
 
75
75
  const clientPlugin = driver.getPlugin(pluginClientName)
76
76
  const hasClientPlugin = clientPlugin?.name === pluginClientName
@@ -100,7 +100,6 @@ export const suspenseQueryGenerator = defineGenerator<PluginReactQuery>({
100
100
  <>
101
101
  {!shouldUseClientPlugin && <File.Import name={'client'} path={clientOptions.importPath} />}
102
102
  <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={clientOptions.importPath} isTypeOnly />
103
- {clientOptions.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={clientOptions.importPath} isTypeOnly />}
104
103
  </>
105
104
  ) : (
106
105
  <>
@@ -111,9 +110,6 @@ export const suspenseQueryGenerator = defineGenerator<PluginReactQuery>({
111
110
  path={path.resolve(root, '.kubb/client.ts')}
112
111
  isTypeOnly
113
112
  />
114
- {clientOptions.dataReturnType === 'full' && (
115
- <File.Import name={['ResponseConfig']} root={meta.file.path} path={path.resolve(root, '.kubb/client.ts')} isTypeOnly />
116
- )}
117
113
  </>
118
114
  )}
119
115
  {shouldUseClientPlugin && clientFile && <File.Import name={[resolvedClientName]} root={meta.file.path} path={clientFile.path} />}
package/src/plugin.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import path from 'node:path'
2
2
  import { createGroupConfig } from '@internals/shared'
3
3
  import { ast, definePlugin } from '@kubb/core'
4
- import { pluginClientName } from '@kubb/plugin-client'
4
+ import { isParserEnabled, pluginClientName } from '@kubb/plugin-client'
5
5
  import { source as axiosClientSource } from '@kubb/plugin-client/templates/clients/axios.source'
6
6
  import { source as fetchClientSource } from '@kubb/plugin-client/templates/clients/fetch.source'
7
7
  import { source as configSource } from '@kubb/plugin-client/templates/config.source'
@@ -53,7 +53,7 @@ export const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQu
53
53
  */
54
54
  export const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {
55
55
  const {
56
- output = { path: 'hooks', barrelType: 'named' },
56
+ output = { path: 'hooks', barrel: { type: 'named' } },
57
57
  group,
58
58
  exclude = [],
59
59
  include,
@@ -90,12 +90,12 @@ export const pluginReactQuery = definePlugin<PluginReactQuery>((options) => {
90
90
  customHookOptionsFileGenerator,
91
91
  ].filter((generator): generator is NonNullable<typeof generator> => Boolean(generator))
92
92
 
93
- const groupConfig = createGroupConfig(group, { suffix: 'Controller' })
93
+ const groupConfig = createGroupConfig(group)
94
94
 
95
95
  return {
96
96
  name: pluginReactQueryName,
97
97
  options,
98
- dependencies: [pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter((dependency): dependency is string => Boolean(dependency)),
98
+ dependencies: [pluginTsName, isParserEnabled(parser) ? pluginZodName : undefined].filter((dependency): dependency is string => Boolean(dependency)),
99
99
  hooks: {
100
100
  'kubb:plugin:setup'(ctx) {
101
101
  const resolver = userResolver ? { ...resolverReactQuery, ...userResolver } : resolverReactQuery
@@ -1,4 +1,4 @@
1
- import { camelCase } from '@internals/utils'
1
+ import { camelCase, toFilePath } from '@internals/utils'
2
2
  import { defineResolver } from '@kubb/core'
3
3
  import type { PluginReactQuery } from '../types.ts'
4
4
 
@@ -29,7 +29,7 @@ export const resolverReactQuery = defineResolver<PluginReactQuery>(() => ({
29
29
  name: 'default',
30
30
  pluginName: 'plugin-react-query',
31
31
  default(name, type) {
32
- return camelCase(name, { isFile: type === 'file' })
32
+ return type === 'file' ? toFilePath(name) : camelCase(name)
33
33
  },
34
34
  resolveName(name) {
35
35
  return this.default(name, 'function')
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Transformer } from '@internals/tanstack-query'
2
- import type { ast, Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, Resolver } from '@kubb/core'
2
+ import type { ast, Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver } from '@kubb/core'
3
3
  import type { ClientImportPath, PluginClient } from '@kubb/plugin-client'
4
4
 
5
5
  export type { Transformer } from '@internals/tanstack-query'
@@ -224,17 +224,13 @@ type CustomOptions = {
224
224
  name?: string
225
225
  }
226
226
 
227
- export type Options = {
228
- /**
229
- * Where the generated hooks are written and how they are exported.
230
- *
231
- * @default { path: 'hooks', barrel: { type: 'named' } }
232
- */
233
- output?: Output
234
- /**
235
- * Split generated files into subfolders based on the operation's tag.
236
- */
237
- group?: Group
227
+ /**
228
+ * Where the generated hooks are written and how they are exported, plus the optional `group`
229
+ * strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
230
+ *
231
+ * @default { path: 'hooks', barrel: { type: 'named' } }
232
+ */
233
+ export type Options = OutputOptions & {
238
234
  /**
239
235
  * HTTP client used inside every generated hook. Mirrors a subset of
240
236
  * `pluginClient` options.
@@ -337,7 +333,7 @@ type ResolvedOptions = {
337
333
  include: Options['include']
338
334
  override: NonNullable<Options['override']>
339
335
  client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>
340
- parser: Required<NonNullable<Options['parser']>>
336
+ parser: NonNullable<Options['parser']>
341
337
  pathParamsType: NonNullable<Options['pathParamsType']>
342
338
  paramsCasing: Options['paramsCasing']
343
339
  paramsType: NonNullable<Options['paramsType']>
package/src/utils.ts CHANGED
@@ -10,6 +10,7 @@ export {
10
10
  export {
11
11
  buildOperationComments as getComments,
12
12
  buildRequestConfigType,
13
+ buildStatusUnionType,
13
14
  getContentTypeInfo,
14
15
  resolveErrorNames,
15
16
  resolveStatusCodeNames,