@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.
Files changed (43) hide show
  1. package/dist/{chunk-VWLT4KLD.cjs → chunk-4I6UYXEA.cjs} +18 -18
  2. package/dist/{chunk-VWLT4KLD.cjs.map → chunk-4I6UYXEA.cjs.map} +1 -1
  3. package/dist/{chunk-5NA5VRXZ.js → chunk-JICGDXHM.js} +10 -10
  4. package/dist/{chunk-5NA5VRXZ.js.map → chunk-JICGDXHM.js.map} +1 -1
  5. package/dist/{chunk-A24GQ5ZN.js → chunk-QFITPKDT.js} +3 -3
  6. package/dist/{chunk-A24GQ5ZN.js.map → chunk-QFITPKDT.js.map} +1 -1
  7. package/dist/{chunk-EZXV6KB3.cjs → chunk-YNY2PBUX.cjs} +10 -10
  8. package/dist/{chunk-EZXV6KB3.cjs.map → chunk-YNY2PBUX.cjs.map} +1 -1
  9. package/dist/components.cjs +9 -9
  10. package/dist/components.d.cts +1 -1
  11. package/dist/components.d.ts +1 -1
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +6 -6
  14. package/dist/generators.d.cts +1 -1
  15. package/dist/generators.d.ts +1 -1
  16. package/dist/generators.js +2 -2
  17. package/dist/index.cjs +6 -6
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +3 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/{types-ClmUaz7P.d.cts → types-DbdPn2MA.d.cts} +9 -2
  24. package/dist/{types-ClmUaz7P.d.ts → types-DbdPn2MA.d.ts} +9 -2
  25. package/package.json +10 -10
  26. package/src/components/InfiniteQueryOptions.tsx +16 -9
  27. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +49 -34
  28. package/src/generators/__snapshots__/clientGetImportPath.ts +49 -34
  29. package/src/generators/__snapshots__/clientPostImportPath.ts +46 -32
  30. package/src/generators/__snapshots__/findByTags.ts +49 -34
  31. package/src/generators/__snapshots__/findByTagsObject.ts +55 -44
  32. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +49 -34
  33. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +49 -34
  34. package/src/generators/__snapshots__/findByTagsWithZod.ts +49 -34
  35. package/src/generators/__snapshots__/findInfiniteByTags.ts +60 -40
  36. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +60 -40
  37. package/src/generators/__snapshots__/getAsMutation.ts +2 -2
  38. package/src/generators/__snapshots__/getPetIdCamelCase.ts +40 -36
  39. package/src/generators/__snapshots__/postAsQuery.ts +66 -36
  40. package/src/generators/__snapshots__/updatePetById.ts +46 -32
  41. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +46 -34
  42. package/src/generators/infiniteQueryGenerator.tsx +0 -1
  43. package/src/plugin.ts +1 -1
@@ -1,57 +1,77 @@
1
- import client from "@kubb/plugin-client/client";
2
- import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { InfiniteData, QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from "@tanstack/react-query";
4
- import { infiniteQueryOptions, useInfiniteQuery } from "@tanstack/react-query";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { InfiniteData, QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
4
+ import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'
5
5
 
6
- export const findPetsByTagsInfiniteQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+ export const findPetsByTagsInfiniteQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
7
 
8
- export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>;
8
+ export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
12
  * @summary Finds Pets by tags
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
- return findPetsByTagsQueryResponse.parse(res.data);
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
17
+ method: 'GET',
18
+ url: `/pet/findByTags`,
19
+ params,
20
+ headers: { ...headers, ...config.headers },
21
+ ...config,
22
+ })
23
+ return findPetsByTagsQueryResponse.parse(res.data)
18
24
  }
19
25
 
20
- export function findPetsByTagsInfiniteQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
- const queryKey = findPetsByTagsInfiniteQueryKey(params);
22
- return infiniteQueryOptions({
23
- queryKey,
24
- queryFn: async ({ signal, pageParam }) => {
25
- config.signal = signal;
26
- if (params) {
27
- params["pageSize"] = pageParam as unknown as FindPetsByTagsQueryParams["pageSize"];
28
- }
29
- return findPetsByTags(headers, params, config);
30
- },
31
- initialPageParam: 0,
32
- getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1,
33
- getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1
34
- });
26
+ export function findPetsByTagsInfiniteQueryOptions(
27
+ headers: FindPetsByTagsHeaderParams,
28
+ params?: FindPetsByTagsQueryParams,
29
+ config: Partial<RequestConfig> = {},
30
+ ) {
31
+ const queryKey = findPetsByTagsInfiniteQueryKey(params)
32
+ return infiniteQueryOptions({
33
+ queryKey,
34
+ queryFn: async ({ signal, pageParam }) => {
35
+ config.signal = signal
36
+
37
+ if (params) {
38
+ params['pageSize'] = pageParam as unknown as FindPetsByTagsQueryParams['pageSize']
39
+ }
40
+ return findPetsByTags(headers, params, config)
41
+ },
42
+ initialPageParam: 0,
43
+ getNextPageParam: (lastPage, _allPages, lastPageParam) => (Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1),
44
+ getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => (firstPageParam <= 1 ? undefined : firstPageParam - 1),
45
+ })
35
46
  }
36
47
 
37
- /**
48
+ /**
38
49
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
39
50
  * @summary Finds Pets by tags
40
51
  * {@link /pet/findByTags}
41
52
  */
42
- export function useFindPetsByTagsInfinite<TData = InfiniteData<FindPetsByTagsQueryResponse>, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
43
- query?: Partial<InfiniteQueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
44
- client?: Partial<RequestConfig>;
45
- } = {}) {
46
- const { query: queryOptions, client: config = {} } = options ?? {};
47
- const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params);
48
- const query = useInfiniteQuery({
49
- ...findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions,
50
- queryKey,
51
- ...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
52
- }) as UseInfiniteQueryResult<TData, FindPetsByTags400> & {
53
- queryKey: TQueryKey;
54
- };
55
- query.queryKey = queryKey as TQueryKey;
56
- return query;
53
+ export function useFindPetsByTagsInfinite<
54
+ TData = InfiniteData<FindPetsByTagsQueryResponse>,
55
+ TQueryData = FindPetsByTagsQueryResponse,
56
+ TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey,
57
+ >(
58
+ headers: FindPetsByTagsHeaderParams,
59
+ params?: FindPetsByTagsQueryParams,
60
+ options: {
61
+ query?: Partial<InfiniteQueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
62
+ client?: Partial<RequestConfig>
63
+ } = {},
64
+ ) {
65
+ const { query: queryOptions, client: config = {} } = options ?? {}
66
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params)
67
+
68
+ const query = useInfiniteQuery({
69
+ ...(findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions),
70
+ queryKey,
71
+ ...(queryOptions as unknown as Omit<InfiniteQueryObserverOptions, 'queryKey'>),
72
+ }) as UseInfiniteQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
73
+
74
+ query.queryKey = queryKey as TQueryKey
75
+
76
+ return query
57
77
  }
@@ -1,57 +1,77 @@
1
- import client from "@kubb/plugin-client/client";
2
- import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { InfiniteData, QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from "@tanstack/react-query";
4
- import { infiniteQueryOptions, useInfiniteQuery } from "@tanstack/react-query";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { InfiniteData, QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
4
+ import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'
5
5
 
6
- export const findPetsByTagsInfiniteQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+ export const findPetsByTagsInfiniteQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
7
 
8
- export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>;
8
+ export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
12
  * @summary Finds Pets by tags
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
- return findPetsByTagsQueryResponse.parse(res.data);
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
17
+ method: 'GET',
18
+ url: `/pet/findByTags`,
19
+ params,
20
+ headers: { ...headers, ...config.headers },
21
+ ...config,
22
+ })
23
+ return findPetsByTagsQueryResponse.parse(res.data)
18
24
  }
19
25
 
20
- export function findPetsByTagsInfiniteQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
- const queryKey = findPetsByTagsInfiniteQueryKey(params);
22
- return infiniteQueryOptions({
23
- queryKey,
24
- queryFn: async ({ signal, pageParam }) => {
25
- config.signal = signal;
26
- if (params) {
27
- params["pageSize"] = pageParam as unknown as FindPetsByTagsQueryParams["pageSize"];
28
- }
29
- return findPetsByTags(headers, params, config);
30
- },
31
- initialPageParam: 0,
32
- getNextPageParam: (lastPage) => lastPage["cursor"],
33
- getPreviousPageParam: (firstPage) => firstPage["cursor"]
34
- });
26
+ export function findPetsByTagsInfiniteQueryOptions(
27
+ headers: FindPetsByTagsHeaderParams,
28
+ params?: FindPetsByTagsQueryParams,
29
+ config: Partial<RequestConfig> = {},
30
+ ) {
31
+ const queryKey = findPetsByTagsInfiniteQueryKey(params)
32
+ return infiniteQueryOptions({
33
+ queryKey,
34
+ queryFn: async ({ signal, pageParam }) => {
35
+ config.signal = signal
36
+
37
+ if (params) {
38
+ params['pageSize'] = pageParam as unknown as FindPetsByTagsQueryParams['pageSize']
39
+ }
40
+ return findPetsByTags(headers, params, config)
41
+ },
42
+ initialPageParam: 0,
43
+ getNextPageParam: (lastPage) => lastPage['cursor'],
44
+ getPreviousPageParam: (firstPage) => firstPage['cursor'],
45
+ })
35
46
  }
36
47
 
37
- /**
48
+ /**
38
49
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
39
50
  * @summary Finds Pets by tags
40
51
  * {@link /pet/findByTags}
41
52
  */
42
- export function useFindPetsByTagsInfinite<TData = InfiniteData<FindPetsByTagsQueryResponse>, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
43
- query?: Partial<InfiniteQueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
44
- client?: Partial<RequestConfig>;
45
- } = {}) {
46
- const { query: queryOptions, client: config = {} } = options ?? {};
47
- const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params);
48
- const query = useInfiniteQuery({
49
- ...findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions,
50
- queryKey,
51
- ...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
52
- }) as UseInfiniteQueryResult<TData, FindPetsByTags400> & {
53
- queryKey: TQueryKey;
54
- };
55
- query.queryKey = queryKey as TQueryKey;
56
- return query;
53
+ export function useFindPetsByTagsInfinite<
54
+ TData = InfiniteData<FindPetsByTagsQueryResponse>,
55
+ TQueryData = FindPetsByTagsQueryResponse,
56
+ TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey,
57
+ >(
58
+ headers: FindPetsByTagsHeaderParams,
59
+ params?: FindPetsByTagsQueryParams,
60
+ options: {
61
+ query?: Partial<InfiniteQueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
62
+ client?: Partial<RequestConfig>
63
+ } = {},
64
+ ) {
65
+ const { query: queryOptions, client: config = {} } = options ?? {}
66
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params)
67
+
68
+ const query = useInfiniteQuery({
69
+ ...(findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions),
70
+ queryKey,
71
+ ...(queryOptions as unknown as Omit<InfiniteQueryObserverOptions, 'queryKey'>),
72
+ }) as UseInfiniteQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
73
+
74
+ query.queryKey = queryKey as TQueryKey
75
+
76
+ return query
57
77
  }
@@ -1,5 +1,5 @@
1
- import client from '@kubb/plugin-client/client'
2
- import type { RequestConfig } from '@kubb/plugin-client/client'
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
3
  import type { UseMutationOptions } from 'custom-swr/mutation'
4
4
  import { useMutation } from 'custom-swr/mutation'
5
5
 
@@ -1,52 +1,56 @@
1
- import client from "@kubb/plugin-client/client";
2
- import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
4
- import { queryOptions, useQuery } from "@tanstack/react-query";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
4
+ import { queryOptions, useQuery } from '@tanstack/react-query'
5
5
 
6
- export const getPetByIdQueryKey = (petId: GetPetByIdPathParams["pet_id"]) => [{ url: "/pet/:pet_id", params: { petId: petId } }] as const;
6
+ export const getPetByIdQueryKey = (petId: GetPetByIdPathParams['pet_id']) => [{ url: '/pet/:pet_id', params: { petId: petId } }] as const
7
7
 
8
- export type GetPetByIdQueryKey = ReturnType<typeof getPetByIdQueryKey>;
8
+ export type GetPetByIdQueryKey = ReturnType<typeof getPetByIdQueryKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @description Returns a single pet
12
12
  * @summary Find pet by ID
13
13
  * {@link /pet/:pet_id}
14
14
  */
15
- async function getPetById(petId: GetPetByIdPathParams["pet_id"], config: Partial<RequestConfig> = {}) {
16
- const res = await client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, unknown>({ method: "GET", url: `/pet/${petId}`, ...config });
17
- return getPetByIdQueryResponse.parse(res.data);
15
+ async function getPetById(petId: GetPetByIdPathParams['pet_id'], config: Partial<RequestConfig> = {}) {
16
+ const res = await client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, unknown>({ method: 'GET', url: `/pet/${petId}`, ...config })
17
+ return getPetByIdQueryResponse.parse(res.data)
18
18
  }
19
19
 
20
- export function getPetByIdQueryOptions(petId: GetPetByIdPathParams["pet_id"], config: Partial<RequestConfig> = {}) {
21
- const queryKey = getPetByIdQueryKey(petId);
22
- return queryOptions({
23
- enabled: !!(petId),
24
- queryKey,
25
- queryFn: async ({ signal }) => {
26
- config.signal = signal;
27
- return getPetById(petId, config);
28
- },
29
- });
20
+ export function getPetByIdQueryOptions(petId: GetPetByIdPathParams['pet_id'], config: Partial<RequestConfig> = {}) {
21
+ const queryKey = getPetByIdQueryKey(petId)
22
+ return queryOptions({
23
+ enabled: !!petId,
24
+ queryKey,
25
+ queryFn: async ({ signal }) => {
26
+ config.signal = signal
27
+ return getPetById(petId, config)
28
+ },
29
+ })
30
30
  }
31
31
 
32
- /**
32
+ /**
33
33
  * @description Returns a single pet
34
34
  * @summary Find pet by ID
35
35
  * {@link /pet/:pet_id}
36
36
  */
37
- export function useGetPetById<TData = GetPetByIdQueryResponse, TQueryData = GetPetByIdQueryResponse, TQueryKey extends QueryKey = GetPetByIdQueryKey>(petId: GetPetByIdPathParams["pet_id"], options: {
38
- query?: Partial<QueryObserverOptions<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, TData, TQueryData, TQueryKey>>;
39
- client?: Partial<RequestConfig>;
40
- } = {}) {
41
- const { query: queryOptions, client: config = {} } = options ?? {};
42
- const queryKey = queryOptions?.queryKey ?? getPetByIdQueryKey(petId);
43
- const query = useQuery({
44
- ...getPetByIdQueryOptions(petId, config) as unknown as QueryObserverOptions,
45
- queryKey,
46
- ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
47
- }) as UseQueryResult<TData, GetPetById400 | GetPetById404> & {
48
- queryKey: TQueryKey;
49
- };
50
- query.queryKey = queryKey as TQueryKey;
51
- return query;
37
+ export function useGetPetById<TData = GetPetByIdQueryResponse, TQueryData = GetPetByIdQueryResponse, TQueryKey extends QueryKey = GetPetByIdQueryKey>(
38
+ petId: GetPetByIdPathParams['pet_id'],
39
+ options: {
40
+ query?: Partial<QueryObserverOptions<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, TData, TQueryData, TQueryKey>>
41
+ client?: Partial<RequestConfig>
42
+ } = {},
43
+ ) {
44
+ const { query: queryOptions, client: config = {} } = options ?? {}
45
+ const queryKey = queryOptions?.queryKey ?? getPetByIdQueryKey(petId)
46
+
47
+ const query = useQuery({
48
+ ...(getPetByIdQueryOptions(petId, config) as unknown as QueryObserverOptions),
49
+ queryKey,
50
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
51
+ }) as UseQueryResult<TData, GetPetById400 | GetPetById404> & { queryKey: TQueryKey }
52
+
53
+ query.queryKey = queryKey as TQueryKey
54
+
55
+ return query
52
56
  }
@@ -1,50 +1,80 @@
1
- import client from "@kubb/plugin-client/client";
2
- import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { QueryKey, QueryObserverOptions, UseQueryResult } from "custom-query";
4
- import { queryOptions, useQuery } from "custom-query";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from 'custom-query'
4
+ import { queryOptions, useQuery } from 'custom-query'
5
5
 
6
- export const updatePetWithFormQueryKey = (petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams) => [{ url: "/pet/:pet_id", params: { pet_id: pet_id } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const;
6
+ export const updatePetWithFormQueryKey = (
7
+ petId: UpdatePetWithFormPathParams['petId'],
8
+ data?: UpdatePetWithFormMutationRequest,
9
+ params?: UpdatePetWithFormQueryParams,
10
+ ) => [{ url: '/pet/:pet_id', params: { pet_id: pet_id } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const
7
11
 
8
- export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>;
12
+ export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>
9
13
 
10
- /**
14
+ /**
11
15
  * @summary Updates a pet in the store with form data
12
16
  * {@link /pet/:pet_id}
13
17
  */
14
- async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
15
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${pet_id}`, params, data, ...config });
16
- return updatePetWithFormMutationResponse.parse(res.data);
18
+ async function updatePetWithForm(
19
+ petId: UpdatePetWithFormPathParams['petId'],
20
+ data?: UpdatePetWithFormMutationRequest,
21
+ params?: UpdatePetWithFormQueryParams,
22
+ config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
23
+ ) {
24
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
25
+ method: 'POST',
26
+ url: `/pet/${pet_id}`,
27
+ params,
28
+ data,
29
+ ...config,
30
+ })
31
+ return updatePetWithFormMutationResponse.parse(res.data)
17
32
  }
18
33
 
19
- export function updatePetWithFormQueryOptions(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
20
- const queryKey = updatePetWithFormQueryKey(petId, data, params);
21
- return queryOptions({
22
- enabled: !!(petId),
23
- queryKey,
24
- queryFn: async ({ signal }) => {
25
- config.signal = signal;
26
- return updatePetWithForm(petId, data, params, config);
27
- },
28
- });
34
+ export function updatePetWithFormQueryOptions(
35
+ petId: UpdatePetWithFormPathParams['petId'],
36
+ data?: UpdatePetWithFormMutationRequest,
37
+ params?: UpdatePetWithFormQueryParams,
38
+ config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
39
+ ) {
40
+ const queryKey = updatePetWithFormQueryKey(petId, data, params)
41
+ return queryOptions({
42
+ enabled: !!petId,
43
+ queryKey,
44
+ queryFn: async ({ signal }) => {
45
+ config.signal = signal
46
+ return updatePetWithForm(petId, data, params, config)
47
+ },
48
+ })
29
49
  }
30
50
 
31
- /**
51
+ /**
32
52
  * @summary Updates a pet in the store with form data
33
53
  * {@link /pet/:pet_id}
34
54
  */
35
- export function useUpdatePetWithForm<TData = UpdatePetWithFormMutationResponse, TQueryData = UpdatePetWithFormMutationResponse, TQueryKey extends QueryKey = UpdatePetWithFormQueryKey>(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, options: {
36
- query?: Partial<QueryObserverOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, TData, TQueryData, TQueryKey>>;
37
- client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
38
- } = {}) {
39
- const { query: queryOptions, client: config = {} } = options ?? {};
40
- const queryKey = queryOptions?.queryKey ?? updatePetWithFormQueryKey(petId, data, params);
41
- const query = useQuery({
42
- ...updatePetWithFormQueryOptions(petId, data, params, config) as unknown as QueryObserverOptions,
43
- queryKey,
44
- ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
45
- }) as UseQueryResult<TData, UpdatePetWithForm405> & {
46
- queryKey: TQueryKey;
47
- };
48
- query.queryKey = queryKey as TQueryKey;
49
- return query;
55
+ export function useUpdatePetWithForm<
56
+ TData = UpdatePetWithFormMutationResponse,
57
+ TQueryData = UpdatePetWithFormMutationResponse,
58
+ TQueryKey extends QueryKey = UpdatePetWithFormQueryKey,
59
+ >(
60
+ petId: UpdatePetWithFormPathParams['petId'],
61
+ data?: UpdatePetWithFormMutationRequest,
62
+ params?: UpdatePetWithFormQueryParams,
63
+ options: {
64
+ query?: Partial<QueryObserverOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, TData, TQueryData, TQueryKey>>
65
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
66
+ } = {},
67
+ ) {
68
+ const { query: queryOptions, client: config = {} } = options ?? {}
69
+ const queryKey = queryOptions?.queryKey ?? updatePetWithFormQueryKey(petId, data, params)
70
+
71
+ const query = useQuery({
72
+ ...(updatePetWithFormQueryOptions(petId, data, params, config) as unknown as QueryObserverOptions),
73
+ queryKey,
74
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
75
+ }) as UseQueryResult<TData, UpdatePetWithForm405> & { queryKey: TQueryKey }
76
+
77
+ query.queryKey = queryKey as TQueryKey
78
+
79
+ return query
50
80
  }
@@ -1,44 +1,58 @@
1
- import client from "@kubb/plugin-client/client";
2
- import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { UseMutationOptions } from "@tanstack/react-query";
4
- import { useMutation } from "@tanstack/react-query";
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
- export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{pet_id}" }] as const;
6
+ export const updatePetWithFormMutationKey = () => [{ url: '/pet/{pet_id}' }] as const
7
7
 
8
- export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
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(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
15
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${pet_id}`, params, data, ...config });
16
- return updatePetWithFormMutationResponse.parse(res.data);
14
+ async function updatePetWithForm(
15
+ 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)
17
28
  }
18
29
 
19
- /**
30
+ /**
20
31
  * @summary Updates a pet in the store with form data
21
32
  * {@link /pet/:pet_id}
22
33
  */
23
- export function useUpdatePetWithForm(options: {
24
- mutation?: UseMutationOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
25
- petId: UpdatePetWithFormPathParams["petId"];
26
- data?: UpdatePetWithFormMutationRequest;
27
- params?: UpdatePetWithFormQueryParams;
28
- }>;
29
- client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
30
- } = {}) {
31
- const { mutation: mutationOptions, client: config = {} } = options ?? {};
32
- const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
33
- return useMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
34
- petId: UpdatePetWithFormPathParams["petId"];
35
- data?: UpdatePetWithFormMutationRequest;
36
- params?: UpdatePetWithFormQueryParams;
37
- }>({
38
- mutationFn: async ({ petId, data, params }) => {
39
- return updatePetWithForm(petId, data, params, config);
40
- },
41
- mutationKey,
42
- ...mutationOptions
43
- });
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
+ })
44
58
  }