@kubb/plugin-react-query 5.0.0-alpha.9 → 5.0.0-beta.100

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 (47) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +38 -93
  3. package/dist/index.cjs +2317 -149
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.ts +494 -6
  6. package/dist/index.js +2283 -143
  7. package/dist/index.js.map +1 -1
  8. package/package.json +47 -75
  9. package/dist/components-BHQT9ZLc.cjs +0 -1634
  10. package/dist/components-BHQT9ZLc.cjs.map +0 -1
  11. package/dist/components-CpyHYGOw.js +0 -1520
  12. package/dist/components-CpyHYGOw.js.map +0 -1
  13. package/dist/components.cjs +0 -13
  14. package/dist/components.d.ts +0 -398
  15. package/dist/components.js +0 -2
  16. package/dist/generators-DP07m3rH.cjs +0 -1469
  17. package/dist/generators-DP07m3rH.cjs.map +0 -1
  18. package/dist/generators-DkQwKTc2.js +0 -1427
  19. package/dist/generators-DkQwKTc2.js.map +0 -1
  20. package/dist/generators.cjs +0 -9
  21. package/dist/generators.d.ts +0 -523
  22. package/dist/generators.js +0 -2
  23. package/dist/types-D5S7Ny9r.d.ts +0 -270
  24. package/src/components/InfiniteQuery.tsx +0 -220
  25. package/src/components/InfiniteQueryOptions.tsx +0 -289
  26. package/src/components/Mutation.tsx +0 -158
  27. package/src/components/MutationKey.tsx +0 -1
  28. package/src/components/MutationOptions.tsx +0 -122
  29. package/src/components/Query.tsx +0 -194
  30. package/src/components/QueryKey.tsx +0 -1
  31. package/src/components/QueryOptions.tsx +0 -181
  32. package/src/components/SuspenseInfiniteQuery.tsx +0 -220
  33. package/src/components/SuspenseInfiniteQueryOptions.tsx +0 -289
  34. package/src/components/SuspenseQuery.tsx +0 -204
  35. package/src/components/index.ts +0 -11
  36. package/src/generators/customHookOptionsFileGenerator.tsx +0 -98
  37. package/src/generators/hookOptionsGenerator.tsx +0 -196
  38. package/src/generators/index.ts +0 -7
  39. package/src/generators/infiniteQueryGenerator.tsx +0 -214
  40. package/src/generators/mutationGenerator.tsx +0 -195
  41. package/src/generators/queryGenerator.tsx +0 -194
  42. package/src/generators/suspenseInfiniteQueryGenerator.tsx +0 -202
  43. package/src/generators/suspenseQueryGenerator.tsx +0 -207
  44. package/src/index.ts +0 -2
  45. package/src/plugin.ts +0 -239
  46. package/src/types.ts +0 -205
  47. /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
@@ -1,194 +0,0 @@
1
- import path from 'node:path'
2
- import { usePluginDriver } from '@kubb/core/hooks'
3
- import { pluginClientName } from '@kubb/plugin-client'
4
- import { Client } from '@kubb/plugin-client/components'
5
- import { createReactGenerator } from '@kubb/plugin-oas/generators'
6
- import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
7
- import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
8
- import { pluginTsName } from '@kubb/plugin-ts'
9
- import { pluginZodName } from '@kubb/plugin-zod'
10
- import { File } from '@kubb/react-fabric'
11
- import { difference } from 'remeda'
12
- import { Query, QueryKey, QueryOptions } from '../components'
13
- import type { PluginReactQuery } from '../types'
14
-
15
- export const queryGenerator = createReactGenerator<PluginReactQuery>({
16
- name: 'react-query',
17
- Operation({ config, plugin, operation, generator }) {
18
- const {
19
- options,
20
- options: { output },
21
- } = plugin
22
- const driver = usePluginDriver()
23
-
24
- const oas = useOas()
25
- const { getSchemas, getName, getFile } = useOperationManager(generator)
26
-
27
- const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)
28
- const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
29
- (method) => operation.method === method,
30
- )
31
-
32
- const importPath = options.query ? options.query.importPath : '@tanstack/react-query'
33
-
34
- const query = {
35
- name: getName(operation, { type: 'function', prefix: 'use' }),
36
- typeName: getName(operation, { type: 'type' }),
37
- file: getFile(operation, { prefix: 'use' }),
38
- }
39
-
40
- const hasClientPlugin = !!driver.getPluginByName(pluginClientName)
41
- // Class-based clients are not compatible with query hooks, so we generate inline clients
42
- const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'
43
- const client = {
44
- name: shouldUseClientPlugin
45
- ? getName(operation, {
46
- type: 'function',
47
- pluginName: pluginClientName,
48
- })
49
- : getName(operation, {
50
- type: 'function',
51
- }),
52
- file: getFile(operation, { pluginName: pluginClientName }),
53
- }
54
-
55
- const queryOptions = {
56
- name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),
57
- }
58
-
59
- const queryKey = {
60
- name: getName(operation, { type: 'const', suffix: 'QueryKey' }),
61
- typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),
62
- }
63
-
64
- const type = {
65
- file: getFile(operation, { pluginName: pluginTsName }),
66
- //todo remove type?
67
- schemas: getSchemas(operation, {
68
- pluginName: pluginTsName,
69
- type: 'type',
70
- }),
71
- }
72
-
73
- const zod = {
74
- // grouping is coming from react-query instead of zod option, we need to pass the options of zod instead
75
- file: getFile(operation, { pluginName: pluginZodName }),
76
- schemas: getSchemas(operation, {
77
- pluginName: pluginZodName,
78
- type: 'function',
79
- }),
80
- }
81
-
82
- if (!isQuery || isMutation) {
83
- return null
84
- }
85
-
86
- return (
87
- <File
88
- baseName={query.file.baseName}
89
- path={query.file.path}
90
- meta={query.file.meta}
91
- banner={getBanner({ oas, output, config: driver.config })}
92
- footer={getFooter({ oas, output })}
93
- >
94
- {options.parser === 'zod' && (
95
- <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />
96
- )}
97
- {options.client.importPath ? (
98
- <>
99
- {!shouldUseClientPlugin && <File.Import name={'fetch'} path={options.client.importPath} />}
100
- <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />
101
- {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}
102
- </>
103
- ) : (
104
- <>
105
- {!shouldUseClientPlugin && (
106
- <File.Import name={['fetch']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />
107
- )}
108
- <File.Import
109
- name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
110
- root={query.file.path}
111
- path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}
112
- isTypeOnly
113
- />
114
- {options.client.dataReturnType === 'full' && (
115
- <File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />
116
- )}
117
- </>
118
- )}
119
-
120
- {shouldUseClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}
121
- {!shouldUseClientPlugin && (
122
- <File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />
123
- )}
124
- {options.customOptions && <File.Import name={[options.customOptions.name]} path={options.customOptions.importPath} />}
125
- <File.Import
126
- name={[
127
- type.schemas.request?.name,
128
- type.schemas.response.name,
129
- type.schemas.pathParams?.name,
130
- type.schemas.queryParams?.name,
131
- type.schemas.headerParams?.name,
132
- ...(type.schemas.statusCodes?.map((item) => item.name) || []),
133
- ].filter(Boolean)}
134
- root={query.file.path}
135
- path={type.file.path}
136
- isTypeOnly
137
- />
138
- <QueryKey
139
- name={queryKey.name}
140
- typeName={queryKey.typeName}
141
- operation={operation}
142
- pathParamsType={options.pathParamsType}
143
- typeSchemas={type.schemas}
144
- paramsCasing={options.paramsCasing}
145
- transformer={options.queryKey}
146
- />
147
- {!shouldUseClientPlugin && (
148
- <Client
149
- name={client.name}
150
- baseURL={options.client.baseURL}
151
- operation={operation}
152
- typeSchemas={type.schemas}
153
- zodSchemas={zod.schemas}
154
- dataReturnType={options.client.dataReturnType || 'data'}
155
- paramsType={options.paramsType}
156
- paramsCasing={options.client?.paramsCasing || options.paramsCasing}
157
- pathParamsType={options.pathParamsType}
158
- parser={options.parser}
159
- />
160
- )}
161
- <File.Import name={['queryOptions']} path={importPath} />
162
- <QueryOptions
163
- name={queryOptions.name}
164
- clientName={client.name}
165
- queryKeyName={queryKey.name}
166
- typeSchemas={type.schemas}
167
- paramsCasing={options.paramsCasing}
168
- paramsType={options.paramsType}
169
- pathParamsType={options.pathParamsType}
170
- dataReturnType={options.client.dataReturnType || 'data'}
171
- />
172
- {options.query && (
173
- <>
174
- <File.Import name={['useQuery']} path={importPath} />
175
- <File.Import name={['QueryKey', 'QueryClient', 'QueryObserverOptions', 'UseQueryResult', 'QueryClient']} path={importPath} isTypeOnly />
176
- <Query
177
- name={query.name}
178
- queryOptionsName={queryOptions.name}
179
- typeSchemas={type.schemas}
180
- paramsCasing={options.paramsCasing}
181
- paramsType={options.paramsType}
182
- pathParamsType={options.pathParamsType}
183
- operation={operation}
184
- dataReturnType={options.client.dataReturnType || 'data'}
185
- queryKeyName={queryKey.name}
186
- queryKeyTypeName={queryKey.typeName}
187
- customOptions={options.customOptions}
188
- />
189
- </>
190
- )}
191
- </File>
192
- )
193
- },
194
- })
@@ -1,202 +0,0 @@
1
- import path from 'node:path'
2
- import { usePluginDriver } from '@kubb/core/hooks'
3
- import { pluginClientName } from '@kubb/plugin-client'
4
- import { Client } from '@kubb/plugin-client/components'
5
- import { createReactGenerator } from '@kubb/plugin-oas/generators'
6
- import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
7
- import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
8
- import { pluginTsName } from '@kubb/plugin-ts'
9
- import { pluginZodName } from '@kubb/plugin-zod'
10
- import { File } from '@kubb/react-fabric'
11
- import { difference } from 'remeda'
12
- import { QueryKey, SuspenseInfiniteQuery, SuspenseInfiniteQueryOptions } from '../components'
13
- import type { PluginReactQuery } from '../types'
14
-
15
- export const suspenseInfiniteQueryGenerator = createReactGenerator<PluginReactQuery>({
16
- name: 'react-suspense-infinite-query',
17
- Operation({ config, operation, generator, plugin }) {
18
- const {
19
- options,
20
- options: { output },
21
- } = plugin
22
- const driver = usePluginDriver()
23
-
24
- const oas = useOas()
25
- const { getSchemas, getName, getFile } = useOperationManager(generator)
26
-
27
- const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)
28
- const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
29
- (method) => operation.method === method,
30
- )
31
- const isSuspense = !!options.suspense
32
- const infiniteOptions = options.infinite && typeof options.infinite === 'object' ? options.infinite : undefined
33
-
34
- const importPath = options.query ? options.query.importPath : '@tanstack/react-query'
35
-
36
- const query = {
37
- name: getName(operation, { type: 'function', prefix: 'use', suffix: 'suspenseInfinite' }),
38
- typeName: getName(operation, { type: 'type' }),
39
- file: getFile(operation, { prefix: 'use', suffix: 'suspenseInfinite' }),
40
- }
41
-
42
- const hasClientPlugin = !!driver.getPluginByName(pluginClientName)
43
- // Class-based clients are not compatible with query hooks, so we generate inline clients
44
- const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'
45
- const client = {
46
- name: shouldUseClientPlugin
47
- ? getName(operation, {
48
- type: 'function',
49
- pluginName: pluginClientName,
50
- })
51
- : getName(operation, {
52
- type: 'function',
53
- suffix: 'suspenseInfinite',
54
- }),
55
- file: getFile(operation, { pluginName: pluginClientName }),
56
- }
57
-
58
- const queryOptions = {
59
- name: getName(operation, { type: 'function', suffix: 'SuspenseInfiniteQueryOptions' }),
60
- }
61
-
62
- const queryKey = {
63
- name: getName(operation, { type: 'const', suffix: 'SuspenseInfiniteQueryKey' }),
64
- typeName: getName(operation, { type: 'type', suffix: 'SuspenseInfiniteQueryKey' }),
65
- }
66
-
67
- const type = {
68
- file: getFile(operation, { pluginName: pluginTsName }),
69
- //todo remove type?
70
- schemas: getSchemas(operation, { pluginName: pluginTsName, type: 'type' }),
71
- }
72
-
73
- const zod = {
74
- file: getFile(operation, { pluginName: pluginZodName }),
75
- schemas: getSchemas(operation, { pluginName: pluginZodName, type: 'function' }),
76
- }
77
-
78
- if (!isQuery || isMutation || !isSuspense || !infiniteOptions) {
79
- return null
80
- }
81
-
82
- return (
83
- <File
84
- baseName={query.file.baseName}
85
- path={query.file.path}
86
- meta={query.file.meta}
87
- banner={getBanner({ oas, output, config: driver.config })}
88
- footer={getFooter({ oas, output })}
89
- >
90
- {options.parser === 'zod' && (
91
- <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />
92
- )}
93
- {options.client.importPath ? (
94
- <>
95
- {!shouldUseClientPlugin && <File.Import name={'fetch'} path={options.client.importPath} />}
96
- <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />
97
- {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}
98
- </>
99
- ) : (
100
- <>
101
- {!shouldUseClientPlugin && (
102
- <File.Import name={['fetch']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />
103
- )}
104
- <File.Import
105
- name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
106
- root={query.file.path}
107
- path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}
108
- isTypeOnly
109
- />
110
- {options.client.dataReturnType === 'full' && (
111
- <File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />
112
- )}
113
- </>
114
- )}
115
-
116
- {shouldUseClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}
117
- {!shouldUseClientPlugin && (
118
- <File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />
119
- )}
120
- {options.customOptions && <File.Import name={[options.customOptions.name]} path={options.customOptions.importPath} />}
121
- <File.Import
122
- name={[
123
- type.schemas.request?.name,
124
- type.schemas.response.name,
125
- type.schemas.pathParams?.name,
126
- type.schemas.queryParams?.name,
127
- type.schemas.headerParams?.name,
128
- ...(type.schemas.statusCodes?.map((item) => item.name) || []),
129
- ].filter(Boolean)}
130
- root={query.file.path}
131
- path={type.file.path}
132
- isTypeOnly
133
- />
134
- <QueryKey
135
- name={queryKey.name}
136
- typeName={queryKey.typeName}
137
- operation={operation}
138
- paramsCasing={options.paramsCasing}
139
- pathParamsType={options.pathParamsType}
140
- typeSchemas={type.schemas}
141
- transformer={options.queryKey}
142
- />
143
- {!shouldUseClientPlugin && (
144
- <Client
145
- name={client.name}
146
- baseURL={options.client.baseURL}
147
- operation={operation}
148
- typeSchemas={type.schemas}
149
- zodSchemas={zod.schemas}
150
- dataReturnType={options.client.dataReturnType || 'data'}
151
- paramsCasing={options.client?.paramsCasing || options.paramsCasing}
152
- paramsType={options.paramsType}
153
- pathParamsType={options.pathParamsType}
154
- parser={options.parser}
155
- />
156
- )}
157
- {infiniteOptions && (
158
- <>
159
- <File.Import name={['InfiniteData']} isTypeOnly path={importPath} />
160
- <File.Import name={['infiniteQueryOptions']} path={importPath} />
161
- <SuspenseInfiniteQueryOptions
162
- name={queryOptions.name}
163
- clientName={client.name}
164
- queryKeyName={queryKey.name}
165
- typeSchemas={type.schemas}
166
- paramsCasing={options.paramsCasing}
167
- paramsType={options.paramsType}
168
- pathParamsType={options.pathParamsType}
169
- dataReturnType={options.client.dataReturnType || 'data'}
170
- cursorParam={infiniteOptions.cursorParam}
171
- nextParam={infiniteOptions.nextParam}
172
- previousParam={infiniteOptions.previousParam}
173
- initialPageParam={infiniteOptions.initialPageParam}
174
- queryParam={infiniteOptions.queryParam}
175
- />
176
- </>
177
- )}
178
- {infiniteOptions && (
179
- <>
180
- <File.Import name={['useSuspenseInfiniteQuery']} path={importPath} />
181
- <File.Import name={['QueryKey', 'QueryClient', 'UseSuspenseInfiniteQueryOptions', 'UseSuspenseInfiniteQueryResult']} path={importPath} isTypeOnly />
182
- <SuspenseInfiniteQuery
183
- name={query.name}
184
- queryOptionsName={queryOptions.name}
185
- typeSchemas={type.schemas}
186
- paramsCasing={options.paramsCasing}
187
- paramsType={options.paramsType}
188
- pathParamsType={options.pathParamsType}
189
- operation={operation}
190
- dataReturnType={options.client.dataReturnType || 'data'}
191
- queryKeyName={queryKey.name}
192
- queryKeyTypeName={queryKey.typeName}
193
- customOptions={options.customOptions}
194
- initialPageParam={infiniteOptions.initialPageParam}
195
- queryParam={infiniteOptions.queryParam}
196
- />
197
- </>
198
- )}
199
- </File>
200
- )
201
- },
202
- })
@@ -1,207 +0,0 @@
1
- import path from 'node:path'
2
- import { usePluginDriver } from '@kubb/core/hooks'
3
- import { pluginClientName } from '@kubb/plugin-client'
4
- import { Client } from '@kubb/plugin-client/components'
5
- import { createReactGenerator } from '@kubb/plugin-oas/generators'
6
- import { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'
7
- import { getBanner, getFooter } from '@kubb/plugin-oas/utils'
8
- import { pluginTsName } from '@kubb/plugin-ts'
9
- import { pluginZodName } from '@kubb/plugin-zod'
10
- import { File } from '@kubb/react-fabric'
11
- import { difference } from 'remeda'
12
- import { QueryKey, QueryOptions, SuspenseQuery } from '../components'
13
- import type { PluginReactQuery } from '../types'
14
-
15
- export const suspenseQueryGenerator = createReactGenerator<PluginReactQuery>({
16
- name: 'react-suspense-query',
17
- Operation({ config, operation, generator, plugin }) {
18
- const {
19
- options,
20
- options: { output },
21
- } = plugin
22
- const driver = usePluginDriver()
23
-
24
- const oas = useOas()
25
- const { getSchemas, getName, getFile } = useOperationManager(generator)
26
-
27
- const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)
28
- const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(
29
- (method) => operation.method === method,
30
- )
31
-
32
- const isSuspense = !!options.suspense
33
-
34
- const importPath = options.query ? options.query.importPath : '@tanstack/react-query'
35
-
36
- const query = {
37
- name: getName(operation, {
38
- type: 'function',
39
- prefix: 'use',
40
- suffix: 'suspense',
41
- }),
42
- typeName: getName(operation, { type: 'type' }),
43
- file: getFile(operation, { prefix: 'use', suffix: 'suspense' }),
44
- }
45
-
46
- const hasClientPlugin = !!driver.getPluginByName(pluginClientName)
47
- // Class-based clients are not compatible with query hooks, so we generate inline clients
48
- const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'
49
- const client = {
50
- name: shouldUseClientPlugin
51
- ? getName(operation, {
52
- type: 'function',
53
- pluginName: pluginClientName,
54
- })
55
- : getName(operation, {
56
- type: 'function',
57
- suffix: 'suspense',
58
- }),
59
- file: getFile(operation, { pluginName: pluginClientName }),
60
- }
61
-
62
- const queryOptions = {
63
- name: getName(operation, {
64
- type: 'function',
65
- suffix: 'SuspenseQueryOptions',
66
- }),
67
- }
68
-
69
- const queryKey = {
70
- name: getName(operation, { type: 'const', suffix: 'SuspenseQueryKey' }),
71
- typeName: getName(operation, {
72
- type: 'type',
73
- suffix: 'SuspenseQueryKey',
74
- }),
75
- }
76
-
77
- const type = {
78
- file: getFile(operation, { pluginName: pluginTsName }),
79
- //todo remove type?
80
- schemas: getSchemas(operation, {
81
- pluginName: pluginTsName,
82
- type: 'type',
83
- }),
84
- }
85
-
86
- const zod = {
87
- file: getFile(operation, { pluginName: pluginZodName }),
88
- schemas: getSchemas(operation, {
89
- pluginName: pluginZodName,
90
- type: 'function',
91
- }),
92
- }
93
-
94
- if (!isQuery || isMutation || !isSuspense) {
95
- return null
96
- }
97
-
98
- return (
99
- <File
100
- baseName={query.file.baseName}
101
- path={query.file.path}
102
- meta={query.file.meta}
103
- banner={getBanner({ oas, output, config: driver.config })}
104
- footer={getFooter({ oas, output })}
105
- >
106
- {options.parser === 'zod' && (
107
- <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />
108
- )}
109
- {options.client.importPath ? (
110
- <>
111
- {!shouldUseClientPlugin && <File.Import name={'fetch'} path={options.client.importPath} />}
112
- <File.Import name={['Client', 'RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />
113
- {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}
114
- </>
115
- ) : (
116
- <>
117
- {!shouldUseClientPlugin && (
118
- <File.Import name={['fetch']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />
119
- )}
120
- <File.Import
121
- name={['Client', 'RequestConfig', 'ResponseErrorConfig']}
122
- root={query.file.path}
123
- path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}
124
- isTypeOnly
125
- />
126
- {options.client.dataReturnType === 'full' && (
127
- <File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />
128
- )}
129
- </>
130
- )}
131
- {shouldUseClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}
132
- {!shouldUseClientPlugin && (
133
- <File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />
134
- )}
135
- {options.customOptions && <File.Import name={[options.customOptions.name]} path={options.customOptions.importPath} />}
136
- <File.Import
137
- name={[
138
- type.schemas.request?.name,
139
- type.schemas.response.name,
140
- type.schemas.pathParams?.name,
141
- type.schemas.queryParams?.name,
142
- type.schemas.headerParams?.name,
143
- ...(type.schemas.statusCodes?.map((item) => item.name) || []),
144
- ].filter(Boolean)}
145
- root={query.file.path}
146
- path={type.file.path}
147
- isTypeOnly
148
- />
149
- <QueryKey
150
- name={queryKey.name}
151
- typeName={queryKey.typeName}
152
- operation={operation}
153
- paramsCasing={options.paramsCasing}
154
- pathParamsType={options.pathParamsType}
155
- typeSchemas={type.schemas}
156
- transformer={options.queryKey}
157
- />
158
-
159
- {!shouldUseClientPlugin && (
160
- <Client
161
- name={client.name}
162
- baseURL={options.client.baseURL}
163
- operation={operation}
164
- typeSchemas={type.schemas}
165
- zodSchemas={zod.schemas}
166
- dataReturnType={options.client.dataReturnType || 'data'}
167
- paramsCasing={options.client?.paramsCasing || options.paramsCasing}
168
- paramsType={options.paramsType}
169
- pathParamsType={options.pathParamsType}
170
- parser={options.parser}
171
- />
172
- )}
173
- <File.Import name={['queryOptions']} path={importPath} />
174
- <QueryOptions
175
- name={queryOptions.name}
176
- clientName={client.name}
177
- queryKeyName={queryKey.name}
178
- typeSchemas={type.schemas}
179
- paramsCasing={options.paramsCasing}
180
- paramsType={options.paramsType}
181
- pathParamsType={options.pathParamsType}
182
- dataReturnType={options.client.dataReturnType}
183
- />
184
- {options.suspense && (
185
- <>
186
- <File.Import name={['useSuspenseQuery']} path={importPath} />
187
- <File.Import name={['QueryKey', 'QueryClient', 'UseSuspenseQueryOptions', 'UseSuspenseQueryResult']} path={importPath} isTypeOnly />
188
-
189
- <SuspenseQuery
190
- name={query.name}
191
- queryOptionsName={queryOptions.name}
192
- typeSchemas={type.schemas}
193
- paramsType={options.paramsType}
194
- paramsCasing={options.paramsCasing}
195
- pathParamsType={options.pathParamsType}
196
- operation={operation}
197
- dataReturnType={options.client.dataReturnType || 'data'}
198
- queryKeyName={queryKey.name}
199
- queryKeyTypeName={queryKey.typeName}
200
- customOptions={options.customOptions}
201
- />
202
- </>
203
- )}
204
- </File>
205
- )
206
- },
207
- })
package/src/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { pluginReactQuery, pluginReactQueryName } from './plugin.ts'
2
- export type { PluginReactQuery } from './types.ts'