@kubb/plugin-swr 3.3.4 → 3.4.0

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 (33) hide show
  1. package/dist/{chunk-4EFF327C.js → chunk-5V4WE7OH.js} +6 -6
  2. package/dist/chunk-5V4WE7OH.js.map +1 -0
  3. package/dist/{chunk-4ZIGOWYH.cjs → chunk-DRK4LTOH.cjs} +11 -11
  4. package/dist/chunk-DRK4LTOH.cjs.map +1 -0
  5. package/dist/{chunk-DJ57MWSH.cjs → chunk-OQB3Y5YU.cjs} +11 -7
  6. package/dist/chunk-OQB3Y5YU.cjs.map +1 -0
  7. package/dist/{chunk-7ELDJ4IB.js → chunk-VNUP6G3W.js} +11 -7
  8. package/dist/chunk-VNUP6G3W.js.map +1 -0
  9. package/dist/components.cjs +6 -6
  10. package/dist/components.js +1 -1
  11. package/dist/generators.cjs +4 -4
  12. package/dist/generators.js +2 -2
  13. package/dist/index.cjs +5 -5
  14. package/dist/index.js +2 -2
  15. package/package.json +13 -13
  16. package/src/components/Mutation.tsx +5 -2
  17. package/src/components/Query.tsx +5 -3
  18. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +17 -7
  19. package/src/generators/__snapshots__/clientGetImportPath.ts +9 -4
  20. package/src/generators/__snapshots__/clientPostImportPath.ts +9 -4
  21. package/src/generators/__snapshots__/findByTags.ts +9 -4
  22. package/src/generators/__snapshots__/findByTagsObject.ts +9 -4
  23. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +9 -4
  24. package/src/generators/__snapshots__/findByTagsWithZod.ts +9 -4
  25. package/src/generators/__snapshots__/postAsQuery.ts +9 -4
  26. package/src/generators/__snapshots__/updatePetById.ts +9 -4
  27. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +9 -4
  28. package/src/generators/mutationGenerator.tsx +1 -1
  29. package/src/generators/queryGenerator.tsx +1 -2
  30. package/dist/chunk-4EFF327C.js.map +0 -1
  31. package/dist/chunk-4ZIGOWYH.cjs.map +0 -1
  32. package/dist/chunk-7ELDJ4IB.js.map +0 -1
  33. package/dist/chunk-DJ57MWSH.cjs.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk4ZIGOWYH_cjs = require('./chunk-4ZIGOWYH.cjs');
4
- var chunkDJ57MWSH_cjs = require('./chunk-DJ57MWSH.cjs');
3
+ var chunkDRK4LTOH_cjs = require('./chunk-DRK4LTOH.cjs');
4
+ var chunkOQB3Y5YU_cjs = require('./chunk-OQB3Y5YU.cjs');
5
5
  var path = require('path');
6
6
  var core = require('@kubb/core');
7
7
  var transformers = require('@kubb/core/transformers');
@@ -28,9 +28,9 @@ var pluginSwr = core.createPlugin((options) => {
28
28
  client,
29
29
  paramsType = "inline",
30
30
  pathParamsType = "inline",
31
- mutationKey = chunkDJ57MWSH_cjs.MutationKey.getTransformer,
32
- queryKey = chunkDJ57MWSH_cjs.QueryKey.getTransformer,
33
- generators = [chunk4ZIGOWYH_cjs.queryGenerator, chunk4ZIGOWYH_cjs.mutationGenerator].filter(Boolean),
31
+ mutationKey = chunkOQB3Y5YU_cjs.MutationKey.getTransformer,
32
+ queryKey = chunkOQB3Y5YU_cjs.QueryKey.getTransformer,
33
+ generators = [chunkDRK4LTOH_cjs.queryGenerator, chunkDRK4LTOH_cjs.mutationGenerator].filter(Boolean),
34
34
  paramsCasing
35
35
  } = options;
36
36
  return {
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { queryGenerator, mutationGenerator } from './chunk-4EFF327C.js';
2
- import { MutationKey, QueryKey } from './chunk-7ELDJ4IB.js';
1
+ import { queryGenerator, mutationGenerator } from './chunk-5V4WE7OH.js';
2
+ import { MutationKey, QueryKey } from './chunk-VNUP6G3W.js';
3
3
  import path from 'node:path';
4
4
  import { createPlugin, FileManager, PluginManager } from '@kubb/core';
5
5
  import { camelCase, pascalCase } from '@kubb/core/transformers';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-swr",
3
- "version": "3.3.4",
3
+ "version": "3.4.0",
4
4
  "description": "Generator plugin-swr",
5
5
  "keywords": [
6
6
  "typescript",
@@ -63,23 +63,23 @@
63
63
  "!/**/__tests__/**"
64
64
  ],
65
65
  "dependencies": {
66
- "remeda": "^2.18.0",
67
- "@kubb/core": "3.3.4",
68
- "@kubb/fs": "3.3.4",
69
- "@kubb/oas": "3.3.4",
70
- "@kubb/plugin-client": "3.3.4",
71
- "@kubb/plugin-oas": "3.3.4",
72
- "@kubb/plugin-ts": "3.3.4",
73
- "@kubb/plugin-zod": "3.3.4",
74
- "@kubb/react": "3.3.4"
66
+ "remeda": "^2.19.0",
67
+ "@kubb/core": "3.4.0",
68
+ "@kubb/fs": "3.4.0",
69
+ "@kubb/oas": "3.4.0",
70
+ "@kubb/plugin-client": "3.4.0",
71
+ "@kubb/plugin-oas": "3.4.0",
72
+ "@kubb/plugin-ts": "3.4.0",
73
+ "@kubb/plugin-zod": "3.4.0",
74
+ "@kubb/react": "3.4.0"
75
75
  },
76
76
  "devDependencies": {
77
- "@types/react": "^18.3.17",
77
+ "@types/react": "^18.3.18",
78
78
  "react": "^18.3.1",
79
79
  "tsup": "^8.3.5",
80
80
  "typescript": "^5.7.2",
81
- "@kubb/config-ts": "3.3.4",
82
- "@kubb/config-tsup": "3.3.4"
81
+ "@kubb/config-ts": "3.4.0",
82
+ "@kubb/config-tsup": "3.4.0"
83
83
  },
84
84
  "peerDependencies": {
85
85
  "@kubb/react": "^3.0.0"
@@ -35,6 +35,7 @@ type GetParamsProps = {
35
35
  // TODO add same logic as being done for react-query mutations
36
36
  function getParams({ pathParamsType, paramsCasing, dataReturnType, typeSchemas, mutationKeyTypeName }: GetParamsProps) {
37
37
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
38
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
38
39
 
39
40
  return FunctionParams.factory({
40
41
  pathParams: {
@@ -56,7 +57,7 @@ function getParams({ pathParamsType, paramsCasing, dataReturnType, typeSchemas,
56
57
  options: {
57
58
  type: `
58
59
  {
59
- mutation?: Parameters<typeof useSWRMutation<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', mutationKeyTypeName, typeSchemas.request?.name].join(', ')}>>[2],
60
+ mutation?: Parameters<typeof useSWRMutation<${[TData, TError, mutationKeyTypeName, typeSchemas.request?.name].join(', ')}>>[2],
60
61
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},
61
62
  shouldFetch?: boolean,
62
63
  }
@@ -79,9 +80,11 @@ export function Mutation({
79
80
  operation,
80
81
  }: Props): ReactNode {
81
82
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
83
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
84
+
82
85
  const generics = [
83
86
  TData,
84
- typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error',
87
+ TError,
85
88
  `${mutationKeyTypeName} | null`,
86
89
  typeSchemas.request?.name, //arg: data
87
90
  ].filter(Boolean)
@@ -36,6 +36,7 @@ type GetParamsProps = {
36
36
 
37
37
  function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, queryKeyTypeName }: GetParamsProps) {
38
38
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
39
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
39
40
 
40
41
  if (paramsType === 'object') {
41
42
  return FunctionParams.factory({
@@ -66,7 +67,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
66
67
  options: {
67
68
  type: `
68
69
  {
69
- query?: Parameters<typeof useSWR<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `${queryKeyTypeName} | null`].join(', ')}, any>>[2],
70
+ query?: Parameters<typeof useSWR<${[TData, TError, `${queryKeyTypeName} | null`].join(', ')}, any>>[2],
70
71
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},
71
72
  shouldFetch?: boolean,
72
73
  }
@@ -105,7 +106,7 @@ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, t
105
106
  options: {
106
107
  type: `
107
108
  {
108
- query?: Parameters<typeof useSWR<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `${queryKeyTypeName} | null`].join(', ')}, any>>[2],
109
+ query?: Parameters<typeof useSWR<${[TData, TError, `${queryKeyTypeName} | null`].join(', ')}, any>>[2],
109
110
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},
110
111
  shouldFetch?: boolean,
111
112
  }
@@ -128,7 +129,8 @@ export function Query({
128
129
  pathParamsType,
129
130
  }: Props): ReactNode {
130
131
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
131
- const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `${queryKeyTypeName} | null`]
132
+ const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`
133
+ const generics = [TData, TError, `${queryKeyTypeName} | null`]
132
134
 
133
135
  const queryKeyParams = QueryKey.getParams({
134
136
  pathParamsType,
@@ -1,6 +1,6 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
2
  import useSWR from 'swr'
3
- import type { RequestConfig, ResponseConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { RequestConfig, ResponseErrorConfig, ResponseConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
5
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
@@ -12,7 +12,12 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
12
12
  * {@link /pet/findByTags}
13
13
  */
14
14
  async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
15
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
16
+ method: 'GET',
17
+ url: `/pet/findByTags`,
18
+ params,
19
+ ...config,
20
+ })
16
21
  return res
17
22
  }
18
23
 
@@ -32,7 +37,9 @@ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTags
32
37
  export function useFindPetsByTags(
33
38
  { params }: { params?: FindPetsByTagsQueryParams },
34
39
  options: {
35
- query?: Parameters<typeof useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
40
+ query?: Parameters<
41
+ typeof useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null, any>
42
+ >[2]
36
43
  client?: Partial<RequestConfig>
37
44
  shouldFetch?: boolean
38
45
  } = {},
@@ -41,8 +48,11 @@ export function useFindPetsByTags(
41
48
 
42
49
  const queryKey = findPetsByTagsQueryKey(params)
43
50
 
44
- return useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
- ...findPetsByTagsQueryOptions({ params }, config),
46
- ...queryOptions,
47
- })
51
+ return useSWR<ResponseConfig<FindPetsByTagsQueryResponse>, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(
52
+ shouldFetch ? queryKey : null,
53
+ {
54
+ ...findPetsByTagsQueryOptions({ params }, config),
55
+ ...queryOptions,
56
+ },
57
+ )
48
58
  }
@@ -1,6 +1,6 @@
1
1
  import client from 'axios'
2
2
  import useSWR from 'swr'
3
- import type { RequestConfig } from 'axios'
3
+ import type { RequestConfig, ResponseErrorConfig } from 'axios'
4
4
 
5
5
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
@@ -12,7 +12,12 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
12
12
  * {@link /pet/findByTags}
13
13
  */
14
14
  async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
15
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
16
+ method: 'GET',
17
+ url: `/pet/findByTags`,
18
+ params,
19
+ ...config,
20
+ })
16
21
  return res.data
17
22
  }
18
23
 
@@ -32,7 +37,7 @@ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTags
32
37
  export function useFindPetsByTags(
33
38
  { params }: { params?: FindPetsByTagsQueryParams },
34
39
  options: {
35
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
40
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null, any>>[2]
36
41
  client?: Partial<RequestConfig>
37
42
  shouldFetch?: boolean
38
43
  } = {},
@@ -41,7 +46,7 @@ export function useFindPetsByTags(
41
46
 
42
47
  const queryKey = findPetsByTagsQueryKey(params)
43
48
 
44
- return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
49
+ return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
50
  ...findPetsByTagsQueryOptions({ params }, config),
46
51
  ...queryOptions,
47
52
  })
@@ -1,6 +1,6 @@
1
1
  import client from 'axios'
2
2
  import useSWRMutation from 'swr/mutation'
3
- import type { RequestConfig } from 'axios'
3
+ import type { RequestConfig, ResponseErrorConfig } from 'axios'
4
4
 
5
5
  export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
6
6
 
@@ -11,7 +11,12 @@ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMu
11
11
  * {@link /pet/:petId}
12
12
  */
13
13
  async function updatePetWithForm(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig> = {}) {
14
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: 'POST', url: `/pet/${petId}`, params, ...config })
14
+ const res = await client<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, unknown>({
15
+ method: 'POST',
16
+ url: `/pet/${petId}`,
17
+ params,
18
+ ...config,
19
+ })
15
20
  return res.data
16
21
  }
17
22
 
@@ -23,7 +28,7 @@ export function useUpdatePetWithForm(
23
28
  petId: UpdatePetWithFormPathParams['petId'],
24
29
  params?: UpdatePetWithFormQueryParams,
25
30
  options: {
26
- mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey>>[2]
31
+ mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationKey>>[2]
27
32
  client?: Partial<RequestConfig>
28
33
  shouldFetch?: boolean
29
34
  } = {},
@@ -31,7 +36,7 @@ export function useUpdatePetWithForm(
31
36
  const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
32
37
  const mutationKey = updatePetWithFormMutationKey()
33
38
 
34
- return useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey | null>(
39
+ return useSWRMutation<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationKey | null>(
35
40
  shouldFetch ? mutationKey : null,
36
41
  async (_url) => {
37
42
  return updatePetWithForm(petId, params, config)
@@ -1,6 +1,6 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
2
  import useSWR from 'swr'
3
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
5
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
@@ -12,7 +12,12 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
12
12
  * {@link /pet/findByTags}
13
13
  */
14
14
  async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
15
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
16
+ method: 'GET',
17
+ url: `/pet/findByTags`,
18
+ params,
19
+ ...config,
20
+ })
16
21
  return res.data
17
22
  }
18
23
 
@@ -32,7 +37,7 @@ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTags
32
37
  export function useFindPetsByTags(
33
38
  { params }: { params?: FindPetsByTagsQueryParams },
34
39
  options: {
35
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
40
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null, any>>[2]
36
41
  client?: Partial<RequestConfig>
37
42
  shouldFetch?: boolean
38
43
  } = {},
@@ -41,7 +46,7 @@ export function useFindPetsByTags(
41
46
 
42
47
  const queryKey = findPetsByTagsQueryKey(params)
43
48
 
44
- return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
49
+ return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
50
  ...findPetsByTagsQueryOptions({ params }, config),
46
51
  ...queryOptions,
47
52
  })
@@ -1,6 +1,6 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
2
  import useSWR from 'swr'
3
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
5
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
@@ -12,7 +12,12 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
12
12
  * {@link /pet/findByTags}
13
13
  */
14
14
  async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
15
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
16
+ method: 'GET',
17
+ url: `/pet/findByTags`,
18
+ params,
19
+ ...config,
20
+ })
16
21
  return res.data
17
22
  }
18
23
 
@@ -32,7 +37,7 @@ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTags
32
37
  export function useFindPetsByTags(
33
38
  { params }: { params?: FindPetsByTagsQueryParams },
34
39
  options: {
35
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
40
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null, any>>[2]
36
41
  client?: Partial<RequestConfig>
37
42
  shouldFetch?: boolean
38
43
  } = {},
@@ -41,7 +46,7 @@ export function useFindPetsByTags(
41
46
 
42
47
  const queryKey = findPetsByTagsQueryKey(params)
43
48
 
44
- return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
49
+ return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
50
  ...findPetsByTagsQueryOptions({ params }, config),
46
51
  ...queryOptions,
47
52
  })
@@ -1,6 +1,6 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
2
  import useSWR from 'swr'
3
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
5
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
@@ -12,7 +12,12 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
12
12
  * {@link /pet/findByTags}
13
13
  */
14
14
  async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
15
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
16
+ method: 'GET',
17
+ url: `/pet/findByTags`,
18
+ params,
19
+ ...config,
20
+ })
16
21
  return res.data
17
22
  }
18
23
 
@@ -32,7 +37,7 @@ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTags
32
37
  export function useFindPetsByTags(
33
38
  { params }: { params?: FindPetsByTagsQueryParams },
34
39
  options: {
35
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
40
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null, any>>[2]
36
41
  client?: Partial<RequestConfig>
37
42
  shouldFetch?: boolean
38
43
  } = {},
@@ -41,7 +46,7 @@ export function useFindPetsByTags(
41
46
 
42
47
  const queryKey = findPetsByTagsQueryKey(params)
43
48
 
44
- return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
49
+ return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
50
  ...findPetsByTagsQueryOptions({ params }, config),
46
51
  ...queryOptions,
47
52
  })
@@ -1,6 +1,6 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
2
  import useSWR from 'swr'
3
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
5
  export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
6
6
 
@@ -12,7 +12,12 @@ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
12
12
  * {@link /pet/findByTags}
13
13
  */
14
14
  async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
15
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
15
+ const res = await client<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
16
+ method: 'GET',
17
+ url: `/pet/findByTags`,
18
+ params,
19
+ ...config,
20
+ })
16
21
  return findPetsByTagsQueryResponse.parse(res.data)
17
22
  }
18
23
 
@@ -32,7 +37,7 @@ export function findPetsByTagsQueryOptions({ params }: { params?: FindPetsByTags
32
37
  export function useFindPetsByTags(
33
38
  { params }: { params?: FindPetsByTagsQueryParams },
34
39
  options: {
35
- query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null, any>>[2]
40
+ query?: Parameters<typeof useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null, any>>[2]
36
41
  client?: Partial<RequestConfig>
37
42
  shouldFetch?: boolean
38
43
  } = {},
@@ -41,7 +46,7 @@ export function useFindPetsByTags(
41
46
 
42
47
  const queryKey = findPetsByTagsQueryKey(params)
43
48
 
44
- return useSWR<FindPetsByTagsQueryResponse, FindPetsByTags400, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
49
+ return useSWR<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryKey | null>(shouldFetch ? queryKey : null, {
45
50
  ...findPetsByTagsQueryOptions({ params }, config),
46
51
  ...queryOptions,
47
52
  })
@@ -1,6 +1,6 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
2
  import useSWR from 'custom-swr'
3
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
5
  export const updatePetWithFormQueryKey = (petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithFormQueryParams) =>
6
6
  [{ url: '/pet/:petId', params: { petId: petId } }, ...(params ? [params] : [])] as const
@@ -15,7 +15,12 @@ async function updatePetWithForm(
15
15
  { petId, params }: { petId: UpdatePetWithFormPathParams['petId']; params?: UpdatePetWithFormQueryParams },
16
16
  config: Partial<RequestConfig> = {},
17
17
  ) {
18
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: 'POST', url: `/pet/${petId}`, params, ...config })
18
+ const res = await client<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, unknown>({
19
+ method: 'POST',
20
+ url: `/pet/${petId}`,
21
+ params,
22
+ ...config,
23
+ })
19
24
  return res.data
20
25
  }
21
26
 
@@ -37,7 +42,7 @@ export function updatePetWithFormQueryOptions(
37
42
  export function useUpdatePetWithForm(
38
43
  { petId, params }: { petId: UpdatePetWithFormPathParams['petId']; params?: UpdatePetWithFormQueryParams },
39
44
  options: {
40
- query?: Parameters<typeof useSWR<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormQueryKey | null, any>>[2]
45
+ query?: Parameters<typeof useSWR<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormQueryKey | null, any>>[2]
41
46
  client?: Partial<RequestConfig>
42
47
  shouldFetch?: boolean
43
48
  } = {},
@@ -46,7 +51,7 @@ export function useUpdatePetWithForm(
46
51
 
47
52
  const queryKey = updatePetWithFormQueryKey(petId, params)
48
53
 
49
- return useSWR<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormQueryKey | null>(shouldFetch ? queryKey : null, {
54
+ return useSWR<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormQueryKey | null>(shouldFetch ? queryKey : null, {
50
55
  ...updatePetWithFormQueryOptions({ petId, params }, config),
51
56
  ...queryOptions,
52
57
  })
@@ -1,6 +1,6 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
2
  import useSWRMutation from 'swr/mutation'
3
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
5
  export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
6
6
 
@@ -11,7 +11,12 @@ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMu
11
11
  * {@link /pet/:petId}
12
12
  */
13
13
  async function updatePetWithForm(petId: UpdatePetWithFormPathParams['petId'], params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig> = {}) {
14
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: 'POST', url: `/pet/${petId}`, params, ...config })
14
+ const res = await client<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, unknown>({
15
+ method: 'POST',
16
+ url: `/pet/${petId}`,
17
+ params,
18
+ ...config,
19
+ })
15
20
  return res.data
16
21
  }
17
22
 
@@ -23,7 +28,7 @@ export function useUpdatePetWithForm(
23
28
  petId: UpdatePetWithFormPathParams['petId'],
24
29
  params?: UpdatePetWithFormQueryParams,
25
30
  options: {
26
- mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey>>[2]
31
+ mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationKey>>[2]
27
32
  client?: Partial<RequestConfig>
28
33
  shouldFetch?: boolean
29
34
  } = {},
@@ -31,7 +36,7 @@ export function useUpdatePetWithForm(
31
36
  const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
32
37
  const mutationKey = updatePetWithFormMutationKey()
33
38
 
34
- return useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey | null>(
39
+ return useSWRMutation<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationKey | null>(
35
40
  shouldFetch ? mutationKey : null,
36
41
  async (_url) => {
37
42
  return updatePetWithForm(petId, params, config)
@@ -1,6 +1,6 @@
1
1
  import client from '@kubb/plugin-client/clients/axios'
2
2
  import useSWRMutation from 'swr/mutation'
3
- import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { RequestConfig, ResponseErrorConfig } from '@kubb/plugin-client/clients/axios'
4
4
 
5
5
  export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
6
6
 
@@ -15,7 +15,12 @@ async function updatePetWithForm(
15
15
  params?: UpdatePetWithFormQueryParams,
16
16
  config: Partial<RequestConfig> = {},
17
17
  ) {
18
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, unknown>({ method: 'POST', url: `/pet/${petId}`, params, ...config })
18
+ const res = await client<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, unknown>({
19
+ method: 'POST',
20
+ url: `/pet/${petId}`,
21
+ params,
22
+ ...config,
23
+ })
19
24
  return res.data
20
25
  }
21
26
 
@@ -27,7 +32,7 @@ export function useUpdatePetWithForm(
27
32
  { petId }: { petId: UpdatePetWithFormPathParams['petId'] },
28
33
  params?: UpdatePetWithFormQueryParams,
29
34
  options: {
30
- mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey>>[2]
35
+ mutation?: Parameters<typeof useSWRMutation<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationKey>>[2]
31
36
  client?: Partial<RequestConfig>
32
37
  shouldFetch?: boolean
33
38
  } = {},
@@ -35,7 +40,7 @@ export function useUpdatePetWithForm(
35
40
  const { mutation: mutationOptions, client: config = {}, shouldFetch = true } = options ?? {}
36
41
  const mutationKey = updatePetWithFormMutationKey()
37
42
 
38
- return useSWRMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationKey | null>(
43
+ return useSWRMutation<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationKey | null>(
39
44
  shouldFetch ? mutationKey : null,
40
45
  async (_url) => {
41
46
  return updatePetWithForm({ petId }, params, config)
@@ -63,7 +63,7 @@ export const mutationGenerator = createReactGenerator<PluginSwr>({
63
63
  <File.Import name="useSWRMutation" path={importPath} />
64
64
  <File.Import name={['SWRMutationResponse']} path={importPath} isTypeOnly />
65
65
  <File.Import name={'client'} path={options.client.importPath} />
66
- <File.Import name={['RequestConfig', 'ResponseConfig']} path={options.client.importPath} isTypeOnly />
66
+ <File.Import name={['RequestConfig', 'ResponseConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />
67
67
  <File.Import
68
68
  name={[
69
69
  type.schemas.request?.name,
@@ -1,4 +1,3 @@
1
- import { pluginClientName } from '@kubb/plugin-client'
2
1
  import { Client } from '@kubb/plugin-client/components'
3
2
  import { createReactGenerator } from '@kubb/plugin-oas'
4
3
  import { useOperationManager } from '@kubb/plugin-oas/hooks'
@@ -64,7 +63,7 @@ export const queryGenerator = createReactGenerator<PluginSwr>({
64
63
  {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}
65
64
 
66
65
  <File.Import name={'client'} path={options.client.importPath} />
67
- <File.Import name={['RequestConfig']} path={options.client.importPath} isTypeOnly />
66
+ <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />
68
67
  {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}
69
68
 
70
69
  <File.Import
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/generators/queryGenerator.tsx","../src/generators/mutationGenerator.tsx"],"names":["createReactGenerator","useApp","useOperationManager","difference","pluginTsName","pluginZodName","jsxs","File","jsx","Client"],"mappings":";;;;;;;;;;;AAYO,IAAM,iBAAiB,oBAAgC,CAAA;AAAA,EAC5D,IAAM,EAAA,WAAA;AAAA,EACN,SAAU,CAAA,EAAE,OAAS,EAAA,SAAA,EAAa,EAAA;AAChC,IAAM,MAAA;AAAA,MACJ,MAAQ,EAAA;AAAA,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OAAQ,CAAA;AAAA;AAAA,OAClB;AAAA,MACC,OAAA,CAAQ,4BACPD,GAAAA;AAAA,QAAC,QAAA;AAAA,QAAA;AAAA,UACC,MAAM,QAAS,CAAA,IAAA;AAAA,UACf,YAAY,MAAO,CAAA,IAAA;AAAA,UACnB,UAAU,QAAS,CAAA,QAAA;AAAA,UACnB,aAAa,IAAK,CAAA,OAAA;AAAA,UAClB,SAAA;AAAA,UACA,cAAA,EAAgB,QAAQ,MAAO,CAAA,cAAA;AAAA,UAC/B,YAAY,OAAQ,CAAA,UAAA;AAAA,UACpB,cAAc,OAAQ,CAAA,YAAA;AAAA,UACtB,gBAAgB,OAAQ,CAAA,cAAA;AAAA,UACxB,iBAAiB,WAAY,CAAA,IAAA;AAAA,UAC7B,qBAAqB,WAAY,CAAA;AAAA;AAAA;AACnC,KAEJ,EAAA,CAAA;AAAA;AAGN,CAAC","file":"chunk-4EFF327C.js","sourcesContent":["import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Query, QueryOptions } from '../components'\nimport { QueryKey } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginSwr>()\n const { getSchemas, getName, getFile } = useOperationManager()\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 client = {\n name: getName(operation, { type: 'function' }),\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, { 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 if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File baseName={query.file.baseName} path={query.file.path} meta={query.file.meta} banner={output?.banner} footer={output?.footer}>\n {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}\n\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['RequestConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\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 <Client\n name={client.name}\n isExportable={false}\n isIndexable={false}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\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}\n queryKeyName={queryKey.name}\n paramsCasing={options.paramsCasing}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n","import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { MutationKey } from '../components'\nimport { Mutation } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-mutation',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n } = useApp<PluginSwr>()\n const { getSchemas, getName, getFile } = useOperationManager()\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 client = {\n name: getName(operation, { type: 'function' }),\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 baseName={mutation.file.baseName} path={mutation.file.path} meta={mutation.file.meta} banner={output?.banner} footer={output?.footer}>\n {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={mutation.file.path} path={zod.file.path} />}\n <File.Import name=\"useSWRMutation\" path={importPath} />\n <File.Import name={['SWRMutationResponse']} path={importPath} isTypeOnly />\n <File.Import name={'client'} path={options.client.importPath} />\n <File.Import name={['RequestConfig', 'ResponseConfig']} path={options.client.importPath} isTypeOnly />\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 <Client\n name={client.name}\n isExportable={false}\n isIndexable={false}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\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}\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"]}