@kubb/plugin-react-query 3.1.0 → 3.3.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 (58) hide show
  1. package/dist/{chunk-PBJIUPCN.cjs → chunk-4I6UYXEA.cjs} +33 -18
  2. package/dist/chunk-4I6UYXEA.cjs.map +1 -0
  3. package/dist/{chunk-YGWYQQ6H.js → chunk-JICGDXHM.js} +86 -55
  4. package/dist/chunk-JICGDXHM.js.map +1 -0
  5. package/dist/{chunk-GMONUHPD.js → chunk-QFITPKDT.js} +18 -3
  6. package/dist/chunk-QFITPKDT.js.map +1 -0
  7. package/dist/{chunk-WOYQTGDC.cjs → chunk-YNY2PBUX.cjs} +86 -55
  8. package/dist/chunk-YNY2PBUX.cjs.map +1 -0
  9. package/dist/components.cjs +9 -9
  10. package/dist/components.d.cts +29 -15
  11. package/dist/components.d.ts +29 -15
  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 +8 -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 +6 -4
  22. package/dist/index.js.map +1 -1
  23. package/dist/{types-BBt81Oun.d.cts → types-DbdPn2MA.d.cts} +22 -2
  24. package/dist/{types-BBt81Oun.d.ts → types-DbdPn2MA.d.ts} +22 -2
  25. package/package.json +11 -11
  26. package/src/components/InfiniteQuery.tsx +9 -3
  27. package/src/components/InfiniteQueryOptions.tsx +25 -13
  28. package/src/components/Mutation.tsx +18 -4
  29. package/src/components/MutationKey.tsx +5 -4
  30. package/src/components/Query.tsx +9 -3
  31. package/src/components/QueryKey.tsx +9 -6
  32. package/src/components/QueryOptions.tsx +9 -5
  33. package/src/components/SuspenseQuery.tsx +9 -3
  34. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +49 -34
  35. package/src/generators/__snapshots__/clientGetImportPath.ts +49 -34
  36. package/src/generators/__snapshots__/clientPostImportPath.ts +48 -34
  37. package/src/generators/__snapshots__/findByTags.ts +49 -34
  38. package/src/generators/__snapshots__/findByTagsObject.ts +55 -44
  39. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +49 -34
  40. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +49 -34
  41. package/src/generators/__snapshots__/findByTagsWithZod.ts +49 -34
  42. package/src/generators/__snapshots__/findInfiniteByTags.ts +60 -40
  43. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +60 -40
  44. package/src/generators/__snapshots__/getAsMutation.ts +2 -2
  45. package/src/generators/__snapshots__/getPetIdCamelCase.ts +56 -0
  46. package/src/generators/__snapshots__/postAsQuery.ts +68 -38
  47. package/src/generators/__snapshots__/updatePetById.ts +48 -34
  48. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +48 -36
  49. package/src/generators/infiniteQueryGenerator.tsx +4 -1
  50. package/src/generators/mutationGenerator.tsx +3 -0
  51. package/src/generators/queryGenerator.tsx +4 -0
  52. package/src/generators/suspenseQueryGenerator.tsx +4 -0
  53. package/src/plugin.ts +3 -1
  54. package/src/types.ts +7 -0
  55. package/dist/chunk-GMONUHPD.js.map +0 -1
  56. package/dist/chunk-PBJIUPCN.cjs.map +0 -1
  57. package/dist/chunk-WOYQTGDC.cjs.map +0 -1
  58. package/dist/chunk-YGWYQQ6H.js.map +0 -1
@@ -1,51 +1,66 @@
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 findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
7
 
8
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
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 findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
- const queryKey = findPetsByTagsQueryKey(params);
22
- return queryOptions({
23
- queryKey,
24
- queryFn: async ({ signal }) => {
25
- config.signal = signal;
26
- return findPetsByTags(headers, params, config);
27
- },
28
- });
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async ({ signal }) => {
31
+ config.signal = signal
32
+ return findPetsByTags(headers, params, config)
33
+ },
34
+ })
29
35
  }
30
36
 
31
- /**
37
+ /**
32
38
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
39
  * @summary Finds Pets by tags
34
40
  * {@link /pet/findByTags}
35
41
  */
36
- export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
- query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
- client?: Partial<RequestConfig>;
39
- } = {}) {
40
- const { query: queryOptions, client: config = {} } = options ?? {};
41
- const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
- const query = useQuery({
43
- ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
- queryKey,
45
- ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
- }) as UseQueryResult<TData, FindPetsByTags400> & {
47
- queryKey: TQueryKey;
48
- };
49
- query.queryKey = queryKey as TQueryKey;
50
- return query;
42
+ export function useFindPetsByTags<
43
+ TData = FindPetsByTagsQueryResponse,
44
+ TQueryData = FindPetsByTagsQueryResponse,
45
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
46
+ >(
47
+ headers: FindPetsByTagsHeaderParams,
48
+ params?: FindPetsByTagsQueryParams,
49
+ options: {
50
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
51
+ client?: Partial<RequestConfig>
52
+ } = {},
53
+ ) {
54
+ const { query: queryOptions, client: config = {} } = options ?? {}
55
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
56
+
57
+ const query = useQuery({
58
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
59
+ queryKey,
60
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
61
+ }) as UseQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
62
+
63
+ query.queryKey = queryKey as TQueryKey
64
+
65
+ return query
51
66
  }
@@ -1,51 +1,66 @@
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 findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => ["test", { url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => ['test', { url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
7
 
8
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
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 findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
- const queryKey = findPetsByTagsQueryKey(params);
22
- return queryOptions({
23
- queryKey,
24
- queryFn: async ({ signal }) => {
25
- config.signal = signal;
26
- return findPetsByTags(headers, params, config);
27
- },
28
- });
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async ({ signal }) => {
31
+ config.signal = signal
32
+ return findPetsByTags(headers, params, config)
33
+ },
34
+ })
29
35
  }
30
36
 
31
- /**
37
+ /**
32
38
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
39
  * @summary Finds Pets by tags
34
40
  * {@link /pet/findByTags}
35
41
  */
36
- export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
- query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
- client?: Partial<RequestConfig>;
39
- } = {}) {
40
- const { query: queryOptions, client: config = {} } = options ?? {};
41
- const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
- const query = useQuery({
43
- ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
- queryKey,
45
- ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
- }) as UseQueryResult<TData, FindPetsByTags400> & {
47
- queryKey: TQueryKey;
48
- };
49
- query.queryKey = queryKey as TQueryKey;
50
- return query;
42
+ export function useFindPetsByTags<
43
+ TData = FindPetsByTagsQueryResponse,
44
+ TQueryData = FindPetsByTagsQueryResponse,
45
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
46
+ >(
47
+ headers: FindPetsByTagsHeaderParams,
48
+ params?: FindPetsByTagsQueryParams,
49
+ options: {
50
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
51
+ client?: Partial<RequestConfig>
52
+ } = {},
53
+ ) {
54
+ const { query: queryOptions, client: config = {} } = options ?? {}
55
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
56
+
57
+ const query = useQuery({
58
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
59
+ queryKey,
60
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
61
+ }) as UseQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
62
+
63
+ query.queryKey = queryKey as TQueryKey
64
+
65
+ return query
51
66
  }
@@ -1,51 +1,66 @@
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 findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
7
 
8
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
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 findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
- const queryKey = findPetsByTagsQueryKey(params);
22
- return queryOptions({
23
- queryKey,
24
- queryFn: async ({ signal }) => {
25
- config.signal = signal;
26
- return findPetsByTags(headers, params, config);
27
- },
28
- });
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async ({ signal }) => {
31
+ config.signal = signal
32
+ return findPetsByTags(headers, params, config)
33
+ },
34
+ })
29
35
  }
30
36
 
31
- /**
37
+ /**
32
38
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
39
  * @summary Finds Pets by tags
34
40
  * {@link /pet/findByTags}
35
41
  */
36
- export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
- query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
- client?: Partial<RequestConfig>;
39
- } = {}) {
40
- const { query: queryOptions, client: config = {} } = options ?? {};
41
- const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
- const query = useQuery({
43
- ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
- queryKey,
45
- ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
- }) as UseQueryResult<TData, FindPetsByTags400> & {
47
- queryKey: TQueryKey;
48
- };
49
- query.queryKey = queryKey as TQueryKey;
50
- return query;
42
+ export function useFindPetsByTags<
43
+ TData = FindPetsByTagsQueryResponse,
44
+ TQueryData = FindPetsByTagsQueryResponse,
45
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
46
+ >(
47
+ headers: FindPetsByTagsHeaderParams,
48
+ params?: FindPetsByTagsQueryParams,
49
+ options: {
50
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
51
+ client?: Partial<RequestConfig>
52
+ } = {},
53
+ ) {
54
+ const { query: queryOptions, client: config = {} } = options ?? {}
55
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
56
+
57
+ const query = useQuery({
58
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
59
+ queryKey,
60
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
61
+ }) as UseQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
62
+
63
+ query.queryKey = queryKey as TQueryKey
64
+
65
+ return query
51
66
  }
@@ -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
 
@@ -0,0 +1,56 @@
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
+
6
+ export const getPetByIdQueryKey = (petId: GetPetByIdPathParams['pet_id']) => [{ url: '/pet/:pet_id', params: { petId: petId } }] as const
7
+
8
+ export type GetPetByIdQueryKey = ReturnType<typeof getPetByIdQueryKey>
9
+
10
+ /**
11
+ * @description Returns a single pet
12
+ * @summary Find pet by ID
13
+ * {@link /pet/:pet_id}
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)
18
+ }
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
+ })
30
+ }
31
+
32
+ /**
33
+ * @description Returns a single pet
34
+ * @summary Find pet by ID
35
+ * {@link /pet/:pet_id}
36
+ */
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
56
+ }