@kubb/plugin-react-query 3.2.0 → 3.3.1
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/{chunk-VWLT4KLD.cjs → chunk-4I6UYXEA.cjs} +18 -18
- package/dist/{chunk-VWLT4KLD.cjs.map → chunk-4I6UYXEA.cjs.map} +1 -1
- package/dist/{chunk-5NA5VRXZ.js → chunk-JICGDXHM.js} +10 -10
- package/dist/{chunk-5NA5VRXZ.js.map → chunk-JICGDXHM.js.map} +1 -1
- package/dist/{chunk-A24GQ5ZN.js → chunk-QFITPKDT.js} +3 -3
- package/dist/{chunk-A24GQ5ZN.js.map → chunk-QFITPKDT.js.map} +1 -1
- package/dist/{chunk-EZXV6KB3.cjs → chunk-YNY2PBUX.cjs} +10 -10
- package/dist/{chunk-EZXV6KB3.cjs.map → chunk-YNY2PBUX.cjs.map} +1 -1
- package/dist/components.cjs +9 -9
- package/dist/components.d.cts +1 -1
- package/dist/components.d.ts +1 -1
- package/dist/components.js +1 -1
- package/dist/generators.cjs +6 -6
- 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 -6
- 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 +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{types-ClmUaz7P.d.cts → types-DbdPn2MA.d.cts} +9 -2
- package/dist/{types-ClmUaz7P.d.ts → types-DbdPn2MA.d.ts} +9 -2
- package/package.json +10 -10
- package/src/components/InfiniteQueryOptions.tsx +16 -9
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +49 -34
- package/src/generators/__snapshots__/clientGetImportPath.ts +49 -34
- package/src/generators/__snapshots__/clientPostImportPath.ts +46 -32
- package/src/generators/__snapshots__/findByTags.ts +49 -34
- package/src/generators/__snapshots__/findByTagsObject.ts +55 -44
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +49 -34
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +49 -34
- package/src/generators/__snapshots__/findByTagsWithZod.ts +49 -34
- package/src/generators/__snapshots__/findInfiniteByTags.ts +60 -40
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +60 -40
- package/src/generators/__snapshots__/getAsMutation.ts +2 -2
- package/src/generators/__snapshots__/getPetIdCamelCase.ts +40 -36
- package/src/generators/__snapshots__/postAsQuery.ts +66 -36
- package/src/generators/__snapshots__/updatePetById.ts +46 -32
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +46 -34
- package/src/generators/infiniteQueryGenerator.tsx +0 -1
- package/src/plugin.ts +1 -1
|
@@ -1,46 +1,58 @@
|
|
|
1
|
-
import client from
|
|
2
|
-
import type { RequestConfig } from
|
|
3
|
-
import type { UseMutationOptions } from
|
|
4
|
-
import { useMutation } from
|
|
1
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
2
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { UseMutationOptions } from '@tanstack/react-query'
|
|
4
|
+
import { useMutation } from '@tanstack/react-query'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
export const updatePetWithFormMutationKey = () => [{ url: '/pet/{pet_id}' }] as const
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
11
|
* @summary Updates a pet in the store with form data
|
|
12
12
|
* {@link /pet/:pet_id}
|
|
13
13
|
*/
|
|
14
|
-
async function updatePetWithForm(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
async function updatePetWithForm(
|
|
15
|
+
{ petId }: { petId: UpdatePetWithFormPathParams['petId'] },
|
|
16
|
+
data?: UpdatePetWithFormMutationRequest,
|
|
17
|
+
params?: UpdatePetWithFormQueryParams,
|
|
18
|
+
config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
|
|
19
|
+
) {
|
|
20
|
+
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
|
|
21
|
+
method: 'POST',
|
|
22
|
+
url: `/pet/${pet_id}`,
|
|
23
|
+
params,
|
|
24
|
+
data,
|
|
25
|
+
...config,
|
|
26
|
+
})
|
|
27
|
+
return updatePetWithFormMutationResponse.parse(res.data)
|
|
19
28
|
}
|
|
20
29
|
|
|
21
|
-
|
|
30
|
+
/**
|
|
22
31
|
* @summary Updates a pet in the store with form data
|
|
23
32
|
* {@link /pet/:pet_id}
|
|
24
33
|
*/
|
|
25
|
-
export function useUpdatePetWithForm(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
34
|
+
export function useUpdatePetWithForm(
|
|
35
|
+
options: {
|
|
36
|
+
mutation?: UseMutationOptions<
|
|
37
|
+
UpdatePetWithFormMutationResponse,
|
|
38
|
+
UpdatePetWithForm405,
|
|
39
|
+
{ petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
|
|
40
|
+
>
|
|
41
|
+
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
|
|
42
|
+
} = {},
|
|
43
|
+
) {
|
|
44
|
+
const { mutation: mutationOptions, client: config = {} } = options ?? {}
|
|
45
|
+
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
|
|
46
|
+
|
|
47
|
+
return useMutation<
|
|
48
|
+
UpdatePetWithFormMutationResponse,
|
|
49
|
+
UpdatePetWithForm405,
|
|
50
|
+
{ petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
|
|
51
|
+
>({
|
|
52
|
+
mutationFn: async ({ petId, data, params }) => {
|
|
53
|
+
return updatePetWithForm({ petId }, data, params, config)
|
|
54
|
+
},
|
|
55
|
+
mutationKey,
|
|
56
|
+
...mutationOptions,
|
|
57
|
+
})
|
|
46
58
|
}
|
package/src/plugin.ts
CHANGED
|
@@ -42,7 +42,7 @@ export const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {
|
|
|
42
42
|
options: {
|
|
43
43
|
output,
|
|
44
44
|
client: {
|
|
45
|
-
importPath: '@kubb/plugin-client/
|
|
45
|
+
importPath: '@kubb/plugin-client/clients/axios',
|
|
46
46
|
dataReturnType: 'data',
|
|
47
47
|
...options.client,
|
|
48
48
|
},
|