@kubb/plugin-swr 4.9.0 → 4.9.2
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/{components-g3iA8KuU.cjs → components-CWmdrh07.cjs} +116 -16
- package/dist/components-CWmdrh07.cjs.map +1 -0
- package/dist/{components-BWaOPuUc.js → components-bS6nIkbY.js} +115 -15
- package/dist/components-bS6nIkbY.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +8 -2
- package/dist/components.d.ts +8 -2
- package/dist/components.js +1 -1
- package/dist/{generators-BrOj2FRv.cjs → generators-CVb2gh4h.cjs} +14 -13
- package/dist/generators-CVb2gh4h.cjs.map +1 -0
- package/dist/{generators-c_jy6OIg.js → generators-Cb1LhyE9.js} +14 -13
- package/dist/generators-Cb1LhyE9.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +6 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/{types-OZ02qQEb.d.ts → types-BhMJy6gt.d.ts} +10 -3
- package/dist/{types-BUsu6QX4.d.cts → types-DV16H9Nj.d.cts} +10 -3
- package/package.json +7 -7
- package/src/components/Mutation.tsx +155 -17
- package/src/generators/__snapshots__/updatePetByIdParamsToTrigger.ts +67 -0
- package/src/generators/mutationGenerator.tsx +7 -4
- package/src/generators/queryGenerator.tsx +6 -4
- package/src/plugin.ts +4 -3
- package/src/types.ts +9 -2
- package/dist/components-BWaOPuUc.js.map +0 -1
- package/dist/components-g3iA8KuU.cjs.map +0 -1
- package/dist/generators-BrOj2FRv.cjs.map +0 -1
- package/dist/generators-c_jy6OIg.js.map +0 -1
|
@@ -2,8 +2,8 @@ import { isOptional, type Operation } from '@kubb/oas'
|
|
|
2
2
|
import { Client } from '@kubb/plugin-client/components'
|
|
3
3
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
4
4
|
import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
|
|
5
|
-
import { File, Function, FunctionParams } from '@kubb/react-fabric'
|
|
6
|
-
import type { KubbNode } from '@kubb/react-fabric/types'
|
|
5
|
+
import { File, Function, FunctionParams, Type } from '@kubb/react-fabric'
|
|
6
|
+
import type { KubbNode, Params } from '@kubb/react-fabric/types'
|
|
7
7
|
import type { PluginSwr } from '../types.ts'
|
|
8
8
|
import { MutationKey } from './MutationKey.tsx'
|
|
9
9
|
|
|
@@ -22,6 +22,11 @@ type Props = {
|
|
|
22
22
|
paramsType: PluginSwr['resolvedOptions']['paramsType']
|
|
23
23
|
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']
|
|
24
24
|
pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']
|
|
25
|
+
/**
|
|
26
|
+
* When true, mutation parameters are passed via trigger() instead of as hook arguments
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
paramsToTrigger?: boolean
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
type GetParamsProps = {
|
|
@@ -31,7 +36,8 @@ type GetParamsProps = {
|
|
|
31
36
|
typeSchemas: OperationSchemas
|
|
32
37
|
mutationKeyTypeName: string
|
|
33
38
|
}
|
|
34
|
-
|
|
39
|
+
|
|
40
|
+
// Original getParams - used when paramsToTrigger is false (default)
|
|
35
41
|
function getParams({ pathParamsType, paramsCasing, dataReturnType, typeSchemas, mutationKeyTypeName }: GetParamsProps) {
|
|
36
42
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
37
43
|
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
|
|
@@ -67,6 +73,61 @@ function getParams({ pathParamsType, paramsCasing, dataReturnType, typeSchemas,
|
|
|
67
73
|
})
|
|
68
74
|
}
|
|
69
75
|
|
|
76
|
+
type GetTriggerParamsProps = {
|
|
77
|
+
dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']
|
|
78
|
+
typeSchemas: OperationSchemas
|
|
79
|
+
mutationKeyTypeName: string
|
|
80
|
+
mutationArgTypeName: string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// New getParams - used when paramsToTrigger is true
|
|
84
|
+
function getTriggerParams({ dataReturnType, typeSchemas, mutationKeyTypeName, mutationArgTypeName }: GetTriggerParamsProps) {
|
|
85
|
+
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
86
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
|
|
87
|
+
|
|
88
|
+
return FunctionParams.factory({
|
|
89
|
+
options: {
|
|
90
|
+
type: `
|
|
91
|
+
{
|
|
92
|
+
mutation?: SWRMutationConfiguration<${TData}, ${TError}, ${mutationKeyTypeName} | null, ${mutationArgTypeName}> & { throwOnError?: boolean },
|
|
93
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},
|
|
94
|
+
shouldFetch?: boolean,
|
|
95
|
+
}
|
|
96
|
+
`,
|
|
97
|
+
default: '{}',
|
|
98
|
+
},
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
type GetMutationParamsProps = {
|
|
103
|
+
paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']
|
|
104
|
+
typeSchemas: OperationSchemas
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function getMutationParams({ paramsCasing, typeSchemas }: GetMutationParamsProps) {
|
|
108
|
+
return FunctionParams.factory({
|
|
109
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
110
|
+
data: typeSchemas.request?.name
|
|
111
|
+
? {
|
|
112
|
+
type: typeSchemas.request?.name,
|
|
113
|
+
optional: isOptional(typeSchemas.request?.schema),
|
|
114
|
+
}
|
|
115
|
+
: undefined,
|
|
116
|
+
params: typeSchemas.queryParams?.name
|
|
117
|
+
? {
|
|
118
|
+
type: typeSchemas.queryParams?.name,
|
|
119
|
+
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
120
|
+
}
|
|
121
|
+
: undefined,
|
|
122
|
+
headers: typeSchemas.headerParams?.name
|
|
123
|
+
? {
|
|
124
|
+
type: typeSchemas.headerParams?.name,
|
|
125
|
+
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
126
|
+
}
|
|
127
|
+
: undefined,
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
70
131
|
export function Mutation({
|
|
71
132
|
name,
|
|
72
133
|
clientName,
|
|
@@ -78,22 +139,107 @@ export function Mutation({
|
|
|
78
139
|
dataReturnType,
|
|
79
140
|
typeSchemas,
|
|
80
141
|
operation,
|
|
142
|
+
paramsToTrigger = false,
|
|
81
143
|
}: Props): KubbNode {
|
|
82
144
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
83
145
|
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
|
|
84
146
|
|
|
147
|
+
const mutationKeyParams = MutationKey.getParams({
|
|
148
|
+
pathParamsType,
|
|
149
|
+
typeSchemas,
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
const clientParams = Client.getParams({
|
|
153
|
+
paramsCasing,
|
|
154
|
+
paramsType,
|
|
155
|
+
typeSchemas,
|
|
156
|
+
pathParamsType,
|
|
157
|
+
isConfigurable: true,
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
// Use the new trigger-based approach when paramsToTrigger is true
|
|
161
|
+
if (paramsToTrigger) {
|
|
162
|
+
// Build the mutation params type (for arg destructuring)
|
|
163
|
+
const mutationParams = getMutationParams({
|
|
164
|
+
paramsCasing,
|
|
165
|
+
typeSchemas,
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
// Get the arg type name
|
|
169
|
+
const mutationArgTypeName = `${mutationKeyTypeName.replace('MutationKey', '')}MutationArg`
|
|
170
|
+
|
|
171
|
+
// Check if there are any mutation params (path, data, params, headers)
|
|
172
|
+
const hasMutationParams = Object.keys(mutationParams.params).length > 0
|
|
173
|
+
|
|
174
|
+
// Build the arg type for useSWRMutation
|
|
175
|
+
const argParams = FunctionParams.factory({
|
|
176
|
+
data: {
|
|
177
|
+
mode: 'object',
|
|
178
|
+
children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
|
|
179
|
+
if (value) {
|
|
180
|
+
acc[key] = {
|
|
181
|
+
...value,
|
|
182
|
+
type: undefined,
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return acc
|
|
186
|
+
}, {} as Params),
|
|
187
|
+
},
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
const params = getTriggerParams({
|
|
191
|
+
dataReturnType,
|
|
192
|
+
typeSchemas,
|
|
193
|
+
mutationKeyTypeName,
|
|
194
|
+
mutationArgTypeName,
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
const generics = [TData, TError, `${mutationKeyTypeName} | null`, mutationArgTypeName].filter(Boolean)
|
|
198
|
+
|
|
199
|
+
const mutationArg = mutationParams.toConstructor()
|
|
200
|
+
|
|
201
|
+
return (
|
|
202
|
+
<>
|
|
203
|
+
<File.Source name={mutationArgTypeName} isExportable isIndexable isTypeOnly>
|
|
204
|
+
<Type name={mutationArgTypeName} export>
|
|
205
|
+
{hasMutationParams ? `{${mutationArg}}` : 'never'}
|
|
206
|
+
</Type>
|
|
207
|
+
</File.Source>
|
|
208
|
+
<File.Source name={name} isExportable isIndexable>
|
|
209
|
+
<Function
|
|
210
|
+
name={name}
|
|
211
|
+
export
|
|
212
|
+
params={params.toConstructor()}
|
|
213
|
+
JSDoc={{
|
|
214
|
+
comments: getComments(operation),
|
|
215
|
+
}}
|
|
216
|
+
>
|
|
217
|
+
{`
|
|
218
|
+
const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
|
|
219
|
+
const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
220
|
+
|
|
221
|
+
return useSWRMutation<${generics.join(', ')}>(
|
|
222
|
+
shouldFetch ? mutationKey : null,
|
|
223
|
+
async (_url${hasMutationParams ? `, { arg: ${argParams.toCall()} }` : ''}) => {
|
|
224
|
+
return ${clientName}(${clientParams.toCall()})
|
|
225
|
+
},
|
|
226
|
+
mutationOptions
|
|
227
|
+
)
|
|
228
|
+
`}
|
|
229
|
+
</Function>
|
|
230
|
+
</File.Source>
|
|
231
|
+
</>
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// Original behavior (default)
|
|
85
236
|
const generics = [
|
|
86
237
|
TData,
|
|
87
238
|
TError,
|
|
88
239
|
`${mutationKeyTypeName} | null`,
|
|
89
|
-
typeSchemas.request?.name, //arg
|
|
240
|
+
typeSchemas.request?.name, // TExtraArg - the arg type for useSWRMutation
|
|
90
241
|
].filter(Boolean)
|
|
91
242
|
|
|
92
|
-
const mutationKeyParams = MutationKey.getParams({
|
|
93
|
-
pathParamsType,
|
|
94
|
-
typeSchemas,
|
|
95
|
-
})
|
|
96
|
-
|
|
97
243
|
const params = getParams({
|
|
98
244
|
paramsCasing,
|
|
99
245
|
pathParamsType,
|
|
@@ -102,14 +248,6 @@ export function Mutation({
|
|
|
102
248
|
mutationKeyTypeName,
|
|
103
249
|
})
|
|
104
250
|
|
|
105
|
-
const clientParams = Client.getParams({
|
|
106
|
-
paramsCasing,
|
|
107
|
-
paramsType,
|
|
108
|
-
typeSchemas,
|
|
109
|
-
pathParamsType,
|
|
110
|
-
isConfigurable: true,
|
|
111
|
-
})
|
|
112
|
-
|
|
113
251
|
return (
|
|
114
252
|
<File.Source name={name} isExportable isIndexable>
|
|
115
253
|
<Function
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by Kubb (https://kubb.dev/).
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import useSWRMutation from 'swr/mutation'
|
|
6
|
+
import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
|
|
7
|
+
import type { SWRMutationConfiguration } from 'swr/mutation'
|
|
8
|
+
import { fetch } from './test/.kubb/fetch'
|
|
9
|
+
|
|
10
|
+
export const updatePetWithFormMutationKey = () => [{ url: '/pet/:petId' }] as const
|
|
11
|
+
|
|
12
|
+
export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @summary Updates a pet in the store with form data
|
|
16
|
+
* {@link /pet/:petId}
|
|
17
|
+
*/
|
|
18
|
+
export async function updatePetWithForm(
|
|
19
|
+
petId: UpdatePetWithFormPathParams['petId'],
|
|
20
|
+
params?: UpdatePetWithFormQueryParams,
|
|
21
|
+
config: Partial<RequestConfig> & { client?: typeof fetch } = {},
|
|
22
|
+
) {
|
|
23
|
+
const { client: request = fetch, ...requestConfig } = config
|
|
24
|
+
|
|
25
|
+
const res = await request<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, unknown>({
|
|
26
|
+
method: 'POST',
|
|
27
|
+
url: `/pet/${petId}`,
|
|
28
|
+
params,
|
|
29
|
+
...requestConfig,
|
|
30
|
+
})
|
|
31
|
+
return res.data
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type UpdatePetWithFormMutationArg = { petId: UpdatePetWithFormPathParams['petId']; params?: UpdatePetWithFormQueryParams }
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @summary Updates a pet in the store with form data
|
|
38
|
+
* {@link /pet/:petId}
|
|
39
|
+
*/
|
|
40
|
+
export function useUpdatePetWithForm(
|
|
41
|
+
options: {
|
|
42
|
+
mutation?: SWRMutationConfiguration<
|
|
43
|
+
UpdatePetWithFormMutationResponse,
|
|
44
|
+
ResponseErrorConfig<UpdatePetWithForm405>,
|
|
45
|
+
UpdatePetWithFormMutationKey | null,
|
|
46
|
+
UpdatePetWithFormMutationArg
|
|
47
|
+
> & { throwOnError?: boolean }
|
|
48
|
+
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
49
|
+
shouldFetch?: boolean
|
|
50
|
+
} = {},
|
|
51
|
+
) {
|
|
52
|
+
const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
|
|
53
|
+
const mutationKey = updatePetWithFormMutationKey()
|
|
54
|
+
|
|
55
|
+
return useSWRMutation<
|
|
56
|
+
UpdatePetWithFormMutationResponse,
|
|
57
|
+
ResponseErrorConfig<UpdatePetWithForm405>,
|
|
58
|
+
UpdatePetWithFormMutationKey | null,
|
|
59
|
+
UpdatePetWithFormMutationArg
|
|
60
|
+
>(
|
|
61
|
+
shouldFetch ? mutationKey : null,
|
|
62
|
+
async (_url, { arg: { petId, params } }) => {
|
|
63
|
+
return updatePetWithForm(petId, params, config)
|
|
64
|
+
},
|
|
65
|
+
mutationOptions,
|
|
66
|
+
)
|
|
67
|
+
}
|
|
@@ -49,8 +49,10 @@ export const mutationGenerator = createReactGenerator<PluginSwr>({
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])
|
|
52
|
+
// Class-based clients are not compatible with query hooks, so we generate inline clients
|
|
53
|
+
const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'
|
|
52
54
|
const client = {
|
|
53
|
-
name:
|
|
55
|
+
name: shouldUseClientPlugin
|
|
54
56
|
? getName(operation, {
|
|
55
57
|
type: 'function',
|
|
56
58
|
pluginKey: [pluginClientName],
|
|
@@ -108,8 +110,8 @@ export const mutationGenerator = createReactGenerator<PluginSwr>({
|
|
|
108
110
|
)}
|
|
109
111
|
<File.Import name="useSWRMutation" path={importPath} />
|
|
110
112
|
<File.Import name={['SWRMutationConfiguration', 'SWRMutationResponse']} path={importPath} isTypeOnly />
|
|
111
|
-
{
|
|
112
|
-
{!
|
|
113
|
+
{shouldUseClientPlugin && <File.Import name={[client.name]} root={mutation.file.path} path={client.file.path} />}
|
|
114
|
+
{!shouldUseClientPlugin && (
|
|
113
115
|
<File.Import name={['buildFormData']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />
|
|
114
116
|
)}
|
|
115
117
|
<File.Import
|
|
@@ -136,7 +138,7 @@ export const mutationGenerator = createReactGenerator<PluginSwr>({
|
|
|
136
138
|
transformer={options.mutationKey}
|
|
137
139
|
/>
|
|
138
140
|
|
|
139
|
-
{!
|
|
141
|
+
{!shouldUseClientPlugin && (
|
|
140
142
|
<Client
|
|
141
143
|
name={client.name}
|
|
142
144
|
baseURL={options.client.baseURL}
|
|
@@ -163,6 +165,7 @@ export const mutationGenerator = createReactGenerator<PluginSwr>({
|
|
|
163
165
|
pathParamsType={options.pathParamsType}
|
|
164
166
|
mutationKeyName={mutationKey.name}
|
|
165
167
|
mutationKeyTypeName={mutationKey.typeName}
|
|
168
|
+
paramsToTrigger={options.mutation.paramsToTrigger}
|
|
166
169
|
/>
|
|
167
170
|
)}
|
|
168
171
|
</File>
|
|
@@ -37,8 +37,10 @@ export const queryGenerator = createReactGenerator<PluginSwr>({
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])
|
|
40
|
+
// Class-based clients are not compatible with query hooks, so we generate inline clients
|
|
41
|
+
const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'
|
|
40
42
|
const client = {
|
|
41
|
-
name:
|
|
43
|
+
name: shouldUseClientPlugin
|
|
42
44
|
? getName(operation, {
|
|
43
45
|
type: 'function',
|
|
44
46
|
pluginKey: [pluginClientName],
|
|
@@ -109,8 +111,8 @@ export const queryGenerator = createReactGenerator<PluginSwr>({
|
|
|
109
111
|
)}
|
|
110
112
|
</>
|
|
111
113
|
)}
|
|
112
|
-
{
|
|
113
|
-
{!
|
|
114
|
+
{shouldUseClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}
|
|
115
|
+
{!shouldUseClientPlugin && (
|
|
114
116
|
<File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />
|
|
115
117
|
)}
|
|
116
118
|
|
|
@@ -136,7 +138,7 @@ export const queryGenerator = createReactGenerator<PluginSwr>({
|
|
|
136
138
|
paramsCasing={options.paramsCasing}
|
|
137
139
|
transformer={options.queryKey}
|
|
138
140
|
/>
|
|
139
|
-
{!
|
|
141
|
+
{!shouldUseClientPlugin && (
|
|
140
142
|
<Client
|
|
141
143
|
name={client.name}
|
|
142
144
|
baseURL={options.client.baseURL}
|
package/src/plugin.ts
CHANGED
|
@@ -33,8 +33,8 @@ export const pluginSwr = definePlugin<PluginSwr>((options) => {
|
|
|
33
33
|
contentType,
|
|
34
34
|
} = options
|
|
35
35
|
|
|
36
|
-
const
|
|
37
|
-
const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${
|
|
36
|
+
const clientName = client?.client ?? 'axios'
|
|
37
|
+
const clientImportPath = client?.importPath ?? (!client?.bundle ? `@kubb/plugin-client/clients/${clientName}` : undefined)
|
|
38
38
|
|
|
39
39
|
return {
|
|
40
40
|
name: pluginSwrName,
|
|
@@ -42,7 +42,8 @@ export const pluginSwr = definePlugin<PluginSwr>((options) => {
|
|
|
42
42
|
output,
|
|
43
43
|
client: {
|
|
44
44
|
...options.client,
|
|
45
|
-
client:
|
|
45
|
+
client: clientName,
|
|
46
|
+
clientType: client?.clientType ?? 'function',
|
|
46
47
|
importPath: clientImportPath,
|
|
47
48
|
dataReturnType: client?.dataReturnType ?? 'data',
|
|
48
49
|
},
|
package/src/types.ts
CHANGED
|
@@ -52,6 +52,13 @@ type Mutation = {
|
|
|
52
52
|
* @default 'swr/mutation'
|
|
53
53
|
*/
|
|
54
54
|
importPath?: string
|
|
55
|
+
/**
|
|
56
|
+
* When true, mutation parameters (path params, query params, headers, body) will be passed via `trigger()` instead of as hook arguments.
|
|
57
|
+
* This aligns with React Query's mutation pattern where variables are passed when triggering the mutation.
|
|
58
|
+
* @default false
|
|
59
|
+
* @deprecated This will become the default behavior in v5. Set to `true` to opt-in early.
|
|
60
|
+
*/
|
|
61
|
+
paramsToTrigger?: boolean
|
|
55
62
|
}
|
|
56
63
|
|
|
57
64
|
export type Options = {
|
|
@@ -81,7 +88,7 @@ export type Options = {
|
|
|
81
88
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
82
89
|
*/
|
|
83
90
|
override?: Array<Override<ResolvedOptions>>
|
|
84
|
-
client?: Pick<PluginClient['options'], 'client' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle'>
|
|
91
|
+
client?: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle'>
|
|
85
92
|
queryKey?: QueryKey
|
|
86
93
|
query?: Query | false
|
|
87
94
|
mutationKey?: MutationKey
|
|
@@ -129,7 +136,7 @@ type ResolvedOptions = {
|
|
|
129
136
|
queryKey: QueryKey | undefined
|
|
130
137
|
query: NonNullable<Required<Query>> | false
|
|
131
138
|
mutationKey: MutationKey | undefined
|
|
132
|
-
mutation:
|
|
139
|
+
mutation: (Required<Pick<Mutation, 'methods' | 'importPath'>> & Pick<Mutation, 'paramsToTrigger'>) | false
|
|
133
140
|
paramsCasing: Options['paramsCasing']
|
|
134
141
|
paramsType: NonNullable<Options['paramsType']>
|
|
135
142
|
pathParamsType: NonNullable<Options['pathParamsType']>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-BWaOPuUc.js","names":["getParams","getTransformer: Transformer","getTransformer","getParams","getParams","getTransformer: Transformer","getParams"],"sources":["../src/components/MutationKey.tsx","../src/components/Mutation.tsx","../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport type { Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { File, Function, FunctionParams, Type } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({}: GetParamsProps) {\n return FunctionParams.factory({})\n}\n\nconst getTransformer: Transformer = ({ operation, casing }) => {\n const path = new URLPath(operation.path, { casing })\n\n return [`{ url: '${path.toURLPath()}' }`]\n}\n\nexport function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): KubbNode {\n const params = getParams({ pathParamsType, typeSchemas })\n const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nMutationKey.getParams = getParams\nMutationKey.getTransformer = getTransformer\n","import { isOptional, type Operation } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr } from '../types.ts'\nimport { MutationKey } from './MutationKey.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n clientName: string\n mutationKeyName: string\n mutationKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n mutationKeyTypeName: string\n}\n// TODO add same logic as being done for react-query mutations\nfunction getParams({ pathParamsType, paramsCasing, dataReturnType, typeSchemas, mutationKeyTypeName }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const TExtraArg = typeSchemas.request?.name || 'never'\n\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n mutation?: SWRMutationConfiguration<${TData}, ${TError}, ${mutationKeyTypeName} | null, ${TExtraArg}> & { throwOnError?: boolean },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Mutation({\n name,\n clientName,\n mutationKeyName,\n mutationKeyTypeName,\n paramsType,\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n}: Props): KubbNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const generics = [\n TData,\n TError,\n `${mutationKeyTypeName} | null`,\n typeSchemas.request?.name, //arg: data\n ].filter(Boolean)\n\n const mutationKeyParams = MutationKey.getParams({\n pathParamsType,\n typeSchemas,\n })\n\n const params = getParams({\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n mutationKeyTypeName,\n })\n\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}\n const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})\n\n return useSWRMutation<${generics.join(', ')}>(\n shouldFetch ? mutationKey : null,\n async (_url${typeSchemas.request?.name ? ', { arg: data }' : ''}) => {\n return ${clientName}(${clientParams.toCall()})\n },\n mutationOptions\n )\n `}\n </Function>\n </File.Source>\n )\n}\n","import { URLPath } from '@kubb/core/utils'\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n })\n}\n\nconst getTransformer: Transformer = ({ operation, schemas, casing }) => {\n const path = new URLPath(operation.path, { casing })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n schemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return keys\n}\n\nexport function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): KubbNode {\n const params = getParams({ pathParamsType, paramsCasing, typeSchemas })\n const keys = transformer({\n operation,\n schemas: typeSchemas,\n casing: paramsCasing,\n })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nQueryKey.getParams = getParams\nQueryKey.getTransformer = getTransformer\n","import { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr } from '../types.ts'\n\ntype Props = {\n name: string\n clientName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n}\n\nexport function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType }: Props): KubbNode {\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n return {\n fetcher: async () => {\n return ${clientName}(${clientParams.toCall()})\n },\n }\n `}\n </Function>\n </File.Source>\n )\n}\n\nQueryOptions.getParams = getParams\n","import { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\nimport { QueryOptions } from './QueryOptions.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n queryOptionsName: string\n queryKeyName: string\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n operation: Operation\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: `\n{\n query?: Parameters<typeof useSWR<${[TData, TError].join(', ')}>>[2],\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n immutable?: boolean\n}\n`,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n query?: Parameters<typeof useSWR<${[TData, TError].join(', ')}>>[2],\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n immutable?: boolean\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n typeSchemas,\n queryKeyName,\n queryKeyTypeName,\n queryOptionsName,\n operation,\n dataReturnType,\n paramsType,\n paramsCasing,\n pathParamsType,\n}: Props): KubbNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const generics = [TData, TError, `${queryKeyTypeName} | null`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n paramsCasing,\n })\n const params = getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptionsParams = QueryOptions.getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n typeSchemas,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}\n\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n\n return useSWR<${generics.join(', ')}>(\n shouldFetch ? queryKey : null,\n {\n ...${queryOptionsName}(${queryOptionsParams.toCall()}),\n ...(immutable ? {\n revalidateIfStale: false,\n revalidateOnFocus: false,\n revalidateOnReconnect: false\n } : { }),\n ...queryOptions\n }\n )\n `}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;;AAsBA,SAASA,YAAU,IAAoB;AACrC,QAAO,eAAe,QAAQ,EAAE,CAAC;;AAGnC,MAAMC,oBAA+B,EAAE,WAAW,aAAa;AAG7D,QAAO,CAAC,WAFK,IAAI,QAAQ,UAAU,MAAM,EAAE,QAAQ,CAAC,CAE5B,WAAW,CAAC,KAAK;;AAG3C,SAAgB,YAAY,EAAE,MAAM,aAAa,cAAc,gBAAgB,WAAW,UAAU,cAAcC,oBAAmC;CACnJ,MAAM,SAASF,YAAU;EAAE;EAAgB;EAAa,CAAC;CACzD,MAAM,OAAO,YAAY;EAAE;EAAW,SAAS;EAAa,QAAQ;EAAc,CAAC;AAEnF,QACE,4CACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC,SAAS;GAAY;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAE;aAChE,IAAI,KAAK,KAAK,KAAK,CAAC;IACN;GACL,EACd,oBAAC,KAAK;EAAO,MAAM;EAAU;EAAa;EAAY;YACpD,oBAAC;GAAK,MAAM;GAAU;aACnB,qBAAqB,KAAK;IACtB;GACK,IACb;;AAIP,YAAY,YAAYA;AACxB,YAAY,iBAAiBE;;;;ACnB7B,SAASC,YAAU,EAAE,gBAAgB,cAAc,gBAAgB,aAAa,uBAAuC;CACrH,MAAM,QAAQ,mBAAmB,SAAS,YAAY,SAAS,OAAO,kBAAkB,YAAY,SAAS,KAAK;CAClH,MAAM,SAAS,uBAAuB,YAAY,QAAQ,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,MAAM,IAAI,QAAQ;CAC1G,MAAM,YAAY,YAAY,SAAS,QAAQ;AAE/C,QAAO,eAAe,QAAQ;EAC5B,YAAY;GACV,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pC,oBAAC;GACO;GACN;GACA,QAAQ,OAAO,eAAe;GAC9B,OAAO,EACL,UAAU,YAAY,UAAU,EACjC;aAEA;;;0BAGiB,aAAa,GAAG,eAAe,QAAQ,CAAC;;uBAE3C,SAAS,KAAK,KAAK,CAAC;;;eAG5B,iBAAiB,GAAG,mBAAmB,QAAQ,CAAC;;;;;;;;;;IAU9C;GACC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components-g3iA8KuU.cjs","names":["getParams","FunctionParams","getTransformer: Transformer","URLPath","getTransformer","File","Function","Type","getParams","FunctionParams","Client","File","Function","getParams","FunctionParams","getTransformer: Transformer","URLPath","File","Function","Type","getParams","FunctionParams","Client","File","Function","FunctionParams","File","Function"],"sources":["../src/components/MutationKey.tsx","../src/components/Mutation.tsx","../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport type { Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { File, Function, FunctionParams, Type } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({}: GetParamsProps) {\n return FunctionParams.factory({})\n}\n\nconst getTransformer: Transformer = ({ operation, casing }) => {\n const path = new URLPath(operation.path, { casing })\n\n return [`{ url: '${path.toURLPath()}' }`]\n}\n\nexport function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): KubbNode {\n const params = getParams({ pathParamsType, typeSchemas })\n const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nMutationKey.getParams = getParams\nMutationKey.getTransformer = getTransformer\n","import { isOptional, type Operation } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr } from '../types.ts'\nimport { MutationKey } from './MutationKey.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n clientName: string\n mutationKeyName: string\n mutationKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n mutationKeyTypeName: string\n}\n// TODO add same logic as being done for react-query mutations\nfunction getParams({ pathParamsType, paramsCasing, dataReturnType, typeSchemas, mutationKeyTypeName }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const TExtraArg = typeSchemas.request?.name || 'never'\n\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n mutation?: SWRMutationConfiguration<${TData}, ${TError}, ${mutationKeyTypeName} | null, ${TExtraArg}> & { throwOnError?: boolean },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Mutation({\n name,\n clientName,\n mutationKeyName,\n mutationKeyTypeName,\n paramsType,\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n}: Props): KubbNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const generics = [\n TData,\n TError,\n `${mutationKeyTypeName} | null`,\n typeSchemas.request?.name, //arg: data\n ].filter(Boolean)\n\n const mutationKeyParams = MutationKey.getParams({\n pathParamsType,\n typeSchemas,\n })\n\n const params = getParams({\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n mutationKeyTypeName,\n })\n\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}\n const mutationKey = ${mutationKeyName}(${mutationKeyParams.toCall()})\n\n return useSWRMutation<${generics.join(', ')}>(\n shouldFetch ? mutationKey : null,\n async (_url${typeSchemas.request?.name ? ', { arg: data }' : ''}) => {\n return ${clientName}(${clientParams.toCall()})\n },\n mutationOptions\n )\n `}\n </Function>\n </File.Source>\n )\n}\n","import { URLPath } from '@kubb/core/utils'\nimport { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n })\n}\n\nconst getTransformer: Transformer = ({ operation, schemas, casing }) => {\n const path = new URLPath(operation.path, { casing })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n schemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return keys\n}\n\nexport function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): KubbNode {\n const params = getParams({ pathParamsType, paramsCasing, typeSchemas })\n const keys = transformer({\n operation,\n schemas: typeSchemas,\n casing: paramsCasing,\n })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nQueryKey.getParams = getParams\nQueryKey.getTransformer = getTransformer\n","import { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr } from '../types.ts'\n\ntype Props = {\n name: string\n clientName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n}\n\nexport function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType }: Props): KubbNode {\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n return {\n fetcher: async () => {\n return ${clientName}(${clientParams.toCall()})\n },\n }\n `}\n </Function>\n </File.Source>\n )\n}\n\nQueryOptions.getParams = getParams\n","import { isOptional, type Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react-fabric'\nimport type { KubbNode } from '@kubb/react-fabric/types'\nimport type { PluginSwr } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\nimport { QueryOptions } from './QueryOptions.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n queryOptionsName: string\n queryKeyName: string\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n operation: Operation\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSwr['resolvedOptions']['paramsCasing']\n paramsType: PluginSwr['resolvedOptions']['paramsType']\n pathParamsType: PluginSwr['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSwr['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: `\n{\n query?: Parameters<typeof useSWR<${[TData, TError].join(', ')}>>[2],\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n immutable?: boolean\n}\n`,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n query?: Parameters<typeof useSWR<${[TData, TError].join(', ')}>>[2],\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n shouldFetch?: boolean,\n immutable?: boolean\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n typeSchemas,\n queryKeyName,\n queryKeyTypeName,\n queryOptionsName,\n operation,\n dataReturnType,\n paramsType,\n paramsCasing,\n pathParamsType,\n}: Props): KubbNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const generics = [TData, TError, `${queryKeyTypeName} | null`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n typeSchemas,\n paramsCasing,\n })\n const params = getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptionsParams = QueryOptions.getParams({\n paramsCasing,\n paramsType,\n pathParamsType,\n typeSchemas,\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { query: queryOptions, client: config = {}, shouldFetch = true, immutable } = options ?? {}\n\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n\n return useSWR<${generics.join(', ')}>(\n shouldFetch ? queryKey : null,\n {\n ...${queryOptionsName}(${queryOptionsParams.toCall()}),\n ...(immutable ? {\n revalidateIfStale: false,\n revalidateOnFocus: false,\n revalidateOnReconnect: false\n } : { }),\n ...queryOptions\n }\n )\n `}\n </Function>\n </File.Source>\n )\n}\n"],"mappings":";;;;;;;;;AAsBA,SAASA,YAAU,IAAoB;AACrC,QAAOC,mCAAe,QAAQ,EAAE,CAAC;;AAGnC,MAAMC,oBAA+B,EAAE,WAAW,aAAa;AAG7D,QAAO,CAAC,WAFK,IAAIC,0BAAQ,UAAU,MAAM,EAAE,QAAQ,CAAC,CAE5B,WAAW,CAAC,KAAK;;AAG3C,SAAgB,YAAY,EAAE,MAAM,aAAa,cAAc,gBAAgB,WAAW,UAAU,cAAcC,oBAAmC;CACnJ,MAAM,SAASJ,YAAU;EAAE;EAAgB;EAAa,CAAC;CACzD,MAAM,OAAO,YAAY;EAAE;EAAW,SAAS;EAAa,QAAQ;EAAc,CAAC;AAEnF,QACE,iHACE,yDAACK,yBAAK;EAAa;EAAM;EAAa;YACpC,yDAACC,6BAAS;GAAY;GAAM;GAAO,QAAQ,OAAO,eAAe;GAAE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A,cACA,kBACA,kBACA,WACA,gBACA,YACA,cACA,kBACkB;CAGlB,MAAM,WAAW;EAFH,mBAAmB,SAAS,YAAY,SAAS,OAAO,kBAAkB,YAAY,SAAS,KAAK;EACnG,uBAAuB,YAAY,QAAQ,KAAK,SAAS,KAAK,KAAK,CAAC,KAAK,MAAM,IAAI,QAAQ;EACzE,GAAG,iBAAiB;EAAS;CAE9D,MAAM,iBAAiB,SAAS,UAAU;EACxC;EACA;EACA;EACD,CAAC;CACF,MAAM,SAAS,UAAU;EACvB;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,qBAAqB,aAAa,UAAU;EAChD;EACA;EACA;EACA;EACD,CAAC;AAEF,QACE,yDAACC,yBAAK;EAAa;EAAM;EAAa;YACpC,yDAACC;GACO;GACN;GACA,QAAQ,OAAO,eAAe;GAC9B,OAAO,EACL,mDAAsB,UAAU,EACjC;aAEA;;;0BAGiB,aAAa,GAAG,eAAe,QAAQ,CAAC;;uBAE3C,SAAS,KAAK,KAAK,CAAC;;;eAG5B,iBAAiB,GAAG,mBAAmB,QAAQ,CAAC;;;;;;;;;;IAU9C;GACC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generators-BrOj2FRv.cjs","names":["pluginTsName","pluginZodName","pluginClientName","File","path","MutationKey","Client","Mutation","pluginClientName","pluginTsName","pluginZodName","File","path","QueryKey","Client","QueryOptions","Query"],"sources":["../src/generators/mutationGenerator.tsx","../src/generators/queryGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { usePluginManager } from '@kubb/core/hooks'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { difference } from 'remeda'\nimport { Mutation, MutationKey } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-mutation',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { output },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)\n const isMutation =\n !isQuery &&\n difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method)\n\n const importPath = options.mutation ? options.mutation.importPath : 'swr'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const mutationKey = {\n name: getName(operation, { type: 'const', suffix: 'MutationKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'MutationKey' }),\n }\n\n if (!isMutation) {\n return null\n }\n\n return (\n <File\n baseName={mutation.file.baseName}\n path={mutation.file.path}\n meta={mutation.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={mutation.file.path} path={zod.file.path} />\n )}\n {options.client.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n </>\n ) : (\n <>\n <File.Import name={['fetch']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['RequestConfig', 'ResponseErrorConfig']}\n root={mutation.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import\n name={['ResponseConfig']}\n root={mutation.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n )}\n </>\n )}\n <File.Import name=\"useSWRMutation\" path={importPath} />\n <File.Import name={['SWRMutationConfiguration', 'SWRMutationResponse']} path={importPath} isTypeOnly />\n {!!hasClientPlugin && <File.Import name={[client.name]} root={mutation.file.path} path={client.file.path} />}\n {!hasClientPlugin && (\n <File.Import name={['buildFormData']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n )}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mutation.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <MutationKey\n name={mutationKey.name}\n typeName={mutationKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.mutationKey}\n />\n\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n {options.mutation && (\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n mutationKeyTypeName={mutationKey.typeName}\n />\n )}\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { usePluginManager } from '@kubb/core/hooks'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File } from '@kubb/react-fabric'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-query',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { output },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(\n (method) => operation.method === method,\n )\n const importPath = options.query ? options.query.importPath : 'swr/mutation'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, {\n pluginKey: [pluginTsName],\n type: 'type',\n }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, {\n pluginKey: [pluginZodName],\n type: 'function',\n }),\n }\n\n if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n {options.client.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n </>\n ) : (\n <>\n <File.Import name={['fetch']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['RequestConfig', 'ResponseErrorConfig']}\n root={query.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />\n )}\n </>\n )}\n {!!hasClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n {!hasClientPlugin && (\n <File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n )}\n\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.queryKey}\n />\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n />\n {options.query && (\n <>\n <File.Import name=\"useSWR\" path={importPath} />\n <File.Import name={['SWRResponse']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n dataReturnType={options.client.dataReturnType || 'data'}\n queryKeyName={queryKey.name}\n paramsCasing={options.paramsCasing}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAa,2EAAoD;CAC/D,MAAM;CACN,UAAU,EAAE,QAAQ,WAAW,WAAW,UAAU;EAClD,MAAM,EACJ,SACA,SAAS,EAAE,aACT;EACJ,MAAM,yDAAkC;EAExC,MAAM,2CAAc;EACpB,MAAM,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