@kubb/plugin-react-query 4.15.1 → 4.16.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.
- package/dist/{components-B6lqcqgn.js → components-DVc9iach.js} +259 -217
- package/dist/components-DVc9iach.js.map +1 -0
- package/dist/{components-6nRaAppd.cjs → components-YtTYHVwV.cjs} +259 -217
- package/dist/components-YtTYHVwV.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-CYoqgYAV.cjs → generators-C6VGGGTj.cjs} +2 -2
- package/dist/{generators-CYoqgYAV.cjs.map → generators-C6VGGGTj.cjs.map} +1 -1
- package/dist/{generators-cZao868O.js → generators-DzaRYGiz.js} +2 -2
- package/dist/{generators-cZao868O.js.map → generators-DzaRYGiz.js.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/generators.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +10 -10
- package/src/components/InfiniteQuery.tsx +35 -30
- package/src/components/InfiniteQueryOptions.tsx +38 -27
- package/src/components/Mutation.tsx +3 -1
- package/src/components/Query.tsx +31 -23
- package/src/components/QueryKey.tsx +8 -6
- package/src/components/QueryOptions.tsx +48 -26
- package/src/components/SuspenseInfiniteQuery.tsx +31 -26
- package/src/components/SuspenseInfiniteQueryOptions.tsx +38 -27
- package/src/components/SuspenseQuery.tsx +35 -24
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +1 -1
- package/src/generators/__snapshots__/clientGetImportPath.ts +1 -1
- package/src/generators/__snapshots__/findByStatusAllOptional.ts +82 -0
- package/src/generators/__snapshots__/findByStatusAllOptionalInline.ts +76 -0
- package/src/generators/__snapshots__/findByTags.ts +1 -1
- package/src/generators/__snapshots__/findByTagsObject.ts +1 -1
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +1 -1
- package/src/generators/__snapshots__/findByTagsTemplateString.ts +1 -1
- package/src/generators/__snapshots__/findByTagsWithCustomOptions.ts +1 -1
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +1 -1
- package/src/generators/__snapshots__/findByTagsWithZod.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByStatusAllOptional.ts +97 -0
- package/src/generators/__snapshots__/findInfiniteByTags.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByTagsNextAndPreviousParam.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByTagsNextParam.ts +1 -1
- package/src/generators/__snapshots__/findInfiniteByTagsWithCustomOptions.ts +1 -1
- package/src/generators/__snapshots__/findSuspenseByStatusAllOptional.ts +79 -0
- package/src/generators/__snapshots__/findSuspenseByTags.ts +1 -1
- package/src/generators/__snapshots__/findSuspenseByTagsWithCustomOptions.ts +1 -1
- package/src/generators/__snapshots__/findSuspenseInfiniteByStatusAllOptional.ts +97 -0
- package/src/generators/__snapshots__/findSuspenseInfiniteByTags.ts +2 -1
- package/src/generators/__snapshots__/findSuspenseInfiniteByTagsCursor.ts +2 -1
- package/src/generators/__snapshots__/findSuspenseInfiniteByTagsWithCustomOptions.ts +2 -1
- package/src/generators/__snapshots__/postAsQuery.ts +2 -2
- package/dist/components-6nRaAppd.cjs.map +0 -1
- package/dist/components-B6lqcqgn.js.map +0 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by Kubb (https://kubb.dev/).
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
|
|
6
|
+
import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
|
|
7
|
+
import { fetch } from './test/.kubb/fetch'
|
|
8
|
+
import { queryOptions, useQuery } from '@tanstack/react-query'
|
|
9
|
+
|
|
10
|
+
export const findPetsByStatusQueryKey = (params: FindPetsByStatusQueryParams = {}) => [{ url: '/pet/findByStatus' }, ...(params ? [params] : [])] as const
|
|
11
|
+
|
|
12
|
+
export type FindPetsByStatusQueryKey = ReturnType<typeof findPetsByStatusQueryKey>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @description Multiple status values can be provided with comma separated strings
|
|
16
|
+
* @summary Finds Pets by status
|
|
17
|
+
* {@link /pet/findByStatus}
|
|
18
|
+
*/
|
|
19
|
+
export async function findPetsByStatus(params?: FindPetsByStatusQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {
|
|
20
|
+
const { client: request = fetch, ...requestConfig } = config
|
|
21
|
+
|
|
22
|
+
const res = await request<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, unknown>({
|
|
23
|
+
method: 'GET',
|
|
24
|
+
url: `/pet/findByStatus`,
|
|
25
|
+
params,
|
|
26
|
+
...requestConfig,
|
|
27
|
+
})
|
|
28
|
+
return findPetsByStatusQueryResponse.parse(res.data)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function findPetsByStatusQueryOptions(params?: FindPetsByStatusQueryParams, config: Partial<RequestConfig> & { client?: typeof fetch } = {}) {
|
|
32
|
+
const queryKey = findPetsByStatusQueryKey(params)
|
|
33
|
+
return queryOptions<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, FindPetsByStatusQueryResponse, typeof queryKey>({
|
|
34
|
+
queryKey,
|
|
35
|
+
queryFn: async ({ signal }) => {
|
|
36
|
+
config.signal = signal
|
|
37
|
+
return findPetsByStatus(params, config)
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @description Multiple status values can be provided with comma separated strings
|
|
44
|
+
* @summary Finds Pets by status
|
|
45
|
+
* {@link /pet/findByStatus}
|
|
46
|
+
*/
|
|
47
|
+
export function useFindPetsByStatus<
|
|
48
|
+
TData = FindPetsByStatusQueryResponse,
|
|
49
|
+
TQueryData = FindPetsByStatusQueryResponse,
|
|
50
|
+
TQueryKey extends QueryKey = FindPetsByStatusQueryKey,
|
|
51
|
+
>(
|
|
52
|
+
params?: FindPetsByStatusQueryParams,
|
|
53
|
+
options: {
|
|
54
|
+
query?: Partial<QueryObserverOptions<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, TData, TQueryData, TQueryKey>> & {
|
|
55
|
+
client?: QueryClient
|
|
56
|
+
}
|
|
57
|
+
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
58
|
+
} = {},
|
|
59
|
+
) {
|
|
60
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
61
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
62
|
+
const queryKey = queryOptions?.queryKey ?? findPetsByStatusQueryKey(params)
|
|
63
|
+
|
|
64
|
+
const query = useQuery(
|
|
65
|
+
{
|
|
66
|
+
...findPetsByStatusQueryOptions(params, config),
|
|
67
|
+
queryKey,
|
|
68
|
+
...queryOptions,
|
|
69
|
+
} as unknown as QueryObserverOptions,
|
|
70
|
+
queryClient,
|
|
71
|
+
) as UseQueryResult<TData, ResponseErrorConfig<FindPetsByStatus400>> & { queryKey: TQueryKey }
|
|
72
|
+
|
|
73
|
+
query.queryKey = queryKey as TQueryKey
|
|
74
|
+
|
|
75
|
+
return query
|
|
76
|
+
}
|
|
@@ -7,7 +7,7 @@ import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { queryOptions, useQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsQueryKey = (params
|
|
10
|
+
export const findPetsByTagsQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
12
12
|
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@ import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { queryOptions, useQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsQueryKey = (params
|
|
10
|
+
export const findPetsByTagsQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
12
12
|
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@ import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { queryOptions, useQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsQueryKey = (params
|
|
10
|
+
export const findPetsByTagsQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
12
12
|
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@ import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { queryOptions, useQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsQueryKey = (params
|
|
10
|
+
export const findPetsByTagsQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
12
12
|
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
|
|
13
13
|
|
|
@@ -8,7 +8,7 @@ import { fetch } from './test/.kubb/fetch'
|
|
|
8
8
|
import { queryOptions, useQuery } from '@tanstack/react-query'
|
|
9
9
|
import { useCustomHookOptions } from 'useCustomHookOptions.ts'
|
|
10
10
|
|
|
11
|
-
export const findPetsByTagsQueryKey = (params
|
|
11
|
+
export const findPetsByTagsQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
12
12
|
|
|
13
13
|
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
|
|
14
14
|
|
|
@@ -7,7 +7,7 @@ import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { queryOptions, useQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsQueryKey = (params
|
|
10
|
+
export const findPetsByTagsQueryKey = (params: FindPetsByTagsQueryParams = {}) => ['test', { url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
12
12
|
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@ import type { QueryKey, QueryClient, QueryObserverOptions, UseQueryResult } from
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { queryOptions, useQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsQueryKey = (params
|
|
10
|
+
export const findPetsByTagsQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
12
12
|
export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
|
|
13
13
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by Kubb (https://kubb.dev/).
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
|
|
6
|
+
import type { InfiniteData, QueryKey, QueryClient, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
|
|
7
|
+
import { fetch } from './test/.kubb/fetch'
|
|
8
|
+
import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'
|
|
9
|
+
|
|
10
|
+
export const findPetsByStatusInfiniteQueryKey = (params: FindPetsByStatusQueryParams = {}) =>
|
|
11
|
+
[{ url: '/pet/findByStatus' }, ...(params ? [params] : [])] as const
|
|
12
|
+
|
|
13
|
+
export type FindPetsByStatusInfiniteQueryKey = ReturnType<typeof findPetsByStatusInfiniteQueryKey>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @description Multiple status values can be provided with comma separated strings
|
|
17
|
+
* @summary Finds Pets by status
|
|
18
|
+
* {@link /pet/findByStatus}
|
|
19
|
+
*/
|
|
20
|
+
export async function findPetsByStatusInfinite(
|
|
21
|
+
{ params }: { params?: FindPetsByStatusQueryParams } = {},
|
|
22
|
+
config: Partial<RequestConfig> & { client?: typeof fetch } = {},
|
|
23
|
+
) {
|
|
24
|
+
const { client: request = fetch, ...requestConfig } = config
|
|
25
|
+
|
|
26
|
+
const res = await request<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, unknown>({
|
|
27
|
+
method: 'GET',
|
|
28
|
+
url: `/pet/findByStatus`,
|
|
29
|
+
params,
|
|
30
|
+
...requestConfig,
|
|
31
|
+
})
|
|
32
|
+
return findPetsByStatusQueryResponse.parse(res.data)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function findPetsByStatusInfiniteQueryOptions(
|
|
36
|
+
{ params }: { params?: FindPetsByStatusQueryParams } = {},
|
|
37
|
+
config: Partial<RequestConfig> & { client?: typeof fetch } = {},
|
|
38
|
+
) {
|
|
39
|
+
const queryKey = findPetsByStatusInfiniteQueryKey(params)
|
|
40
|
+
return infiniteQueryOptions<
|
|
41
|
+
FindPetsByStatusQueryResponse,
|
|
42
|
+
ResponseErrorConfig<FindPetsByStatus400>,
|
|
43
|
+
InfiniteData<FindPetsByStatusQueryResponse>,
|
|
44
|
+
typeof queryKey,
|
|
45
|
+
NonNullable<FindPetsByStatusQueryParams['status']>
|
|
46
|
+
>({
|
|
47
|
+
queryKey,
|
|
48
|
+
queryFn: async ({ signal, pageParam }) => {
|
|
49
|
+
config.signal = signal
|
|
50
|
+
|
|
51
|
+
params = {
|
|
52
|
+
...(params ?? {}),
|
|
53
|
+
['status']: pageParam as unknown as FindPetsByStatusQueryParams['status'],
|
|
54
|
+
} as FindPetsByStatusQueryParams
|
|
55
|
+
return findPetsByStatusInfinite({ params }, config)
|
|
56
|
+
},
|
|
57
|
+
initialPageParam: 'available',
|
|
58
|
+
getNextPageParam: (lastPage, _allPages, lastPageParam) => (Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1),
|
|
59
|
+
getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => (firstPageParam <= 1 ? undefined : firstPageParam - 1),
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @description Multiple status values can be provided with comma separated strings
|
|
65
|
+
* @summary Finds Pets by status
|
|
66
|
+
* {@link /pet/findByStatus}
|
|
67
|
+
*/
|
|
68
|
+
export function useFindPetsByStatusInfinite<
|
|
69
|
+
TQueryFnData = FindPetsByStatusQueryResponse,
|
|
70
|
+
TError = ResponseErrorConfig<FindPetsByStatus400>,
|
|
71
|
+
TData = InfiniteData<TQueryFnData>,
|
|
72
|
+
TQueryKey extends QueryKey = FindPetsByStatusInfiniteQueryKey,
|
|
73
|
+
TPageParam = NonNullable<FindPetsByStatusQueryParams['status']>,
|
|
74
|
+
>(
|
|
75
|
+
{ params }: { params?: FindPetsByStatusQueryParams } = {},
|
|
76
|
+
options: {
|
|
77
|
+
query?: Partial<InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>> & { client?: QueryClient }
|
|
78
|
+
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
79
|
+
} = {},
|
|
80
|
+
) {
|
|
81
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
82
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
83
|
+
const queryKey = queryOptions?.queryKey ?? findPetsByStatusInfiniteQueryKey(params)
|
|
84
|
+
|
|
85
|
+
const query = useInfiniteQuery(
|
|
86
|
+
{
|
|
87
|
+
...findPetsByStatusInfiniteQueryOptions({ params }, config),
|
|
88
|
+
queryKey,
|
|
89
|
+
...queryOptions,
|
|
90
|
+
} as unknown as InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,
|
|
91
|
+
queryClient,
|
|
92
|
+
) as UseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }
|
|
93
|
+
|
|
94
|
+
query.queryKey = queryKey as TQueryKey
|
|
95
|
+
|
|
96
|
+
return query
|
|
97
|
+
}
|
|
@@ -7,7 +7,7 @@ import type { InfiniteData, QueryKey, QueryClient, InfiniteQueryObserverOptions,
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsInfiniteQueryKey = (params
|
|
10
|
+
export const findPetsByTagsInfiniteQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
12
12
|
export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@ import type { InfiniteData, QueryKey, QueryClient, InfiniteQueryObserverOptions,
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsInfiniteQueryKey = (params
|
|
10
|
+
export const findPetsByTagsInfiniteQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
12
12
|
export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@ import type { InfiniteData, QueryKey, QueryClient, InfiniteQueryObserverOptions,
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsInfiniteQueryKey = (params
|
|
10
|
+
export const findPetsByTagsInfiniteQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
12
12
|
export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>
|
|
13
13
|
|
|
@@ -8,7 +8,7 @@ import { fetch } from './test/.kubb/fetch'
|
|
|
8
8
|
import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'
|
|
9
9
|
import { useCustomHookOptions } from 'useCustomHookOptions.ts'
|
|
10
10
|
|
|
11
|
-
export const findPetsByTagsInfiniteQueryKey = (params
|
|
11
|
+
export const findPetsByTagsInfiniteQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
12
12
|
|
|
13
13
|
export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>
|
|
14
14
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by Kubb (https://kubb.dev/).
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
|
|
6
|
+
import type { QueryKey, QueryClient, UseSuspenseQueryOptions, UseSuspenseQueryResult } from '@tanstack/react-query'
|
|
7
|
+
import { fetch } from './test/.kubb/fetch'
|
|
8
|
+
import { queryOptions, useSuspenseQuery } from '@tanstack/react-query'
|
|
9
|
+
|
|
10
|
+
export const findPetsByStatusSuspenseQueryKey = (params: FindPetsByStatusQueryParams = {}) =>
|
|
11
|
+
[{ url: '/pet/findByStatus' }, ...(params ? [params] : [])] as const
|
|
12
|
+
|
|
13
|
+
export type FindPetsByStatusSuspenseQueryKey = ReturnType<typeof findPetsByStatusSuspenseQueryKey>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @description Multiple status values can be provided with comma separated strings
|
|
17
|
+
* @summary Finds Pets by status
|
|
18
|
+
* {@link /pet/findByStatus}
|
|
19
|
+
*/
|
|
20
|
+
export async function findPetsByStatusSuspense(
|
|
21
|
+
{ params }: { params?: FindPetsByStatusQueryParams } = {},
|
|
22
|
+
config: Partial<RequestConfig> & { client?: typeof fetch } = {},
|
|
23
|
+
) {
|
|
24
|
+
const { client: request = fetch, ...requestConfig } = config
|
|
25
|
+
|
|
26
|
+
const res = await request<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, unknown>({
|
|
27
|
+
method: 'GET',
|
|
28
|
+
url: `/pet/findByStatus`,
|
|
29
|
+
params,
|
|
30
|
+
...requestConfig,
|
|
31
|
+
})
|
|
32
|
+
return findPetsByStatusQueryResponse.parse(res.data)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function findPetsByStatusSuspenseQueryOptions(
|
|
36
|
+
{ params }: { params?: FindPetsByStatusQueryParams } = {},
|
|
37
|
+
config: Partial<RequestConfig> & { client?: typeof fetch } = {},
|
|
38
|
+
) {
|
|
39
|
+
const queryKey = findPetsByStatusSuspenseQueryKey(params)
|
|
40
|
+
return queryOptions<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, FindPetsByStatusQueryResponse, typeof queryKey>({
|
|
41
|
+
queryKey,
|
|
42
|
+
queryFn: async ({ signal }) => {
|
|
43
|
+
config.signal = signal
|
|
44
|
+
return findPetsByStatusSuspense({ params }, config)
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @description Multiple status values can be provided with comma separated strings
|
|
51
|
+
* @summary Finds Pets by status
|
|
52
|
+
* {@link /pet/findByStatus}
|
|
53
|
+
*/
|
|
54
|
+
export function useFindPetsByStatusSuspense<TData = FindPetsByStatusQueryResponse, TQueryKey extends QueryKey = FindPetsByStatusSuspenseQueryKey>(
|
|
55
|
+
{ params }: { params?: FindPetsByStatusQueryParams } = {},
|
|
56
|
+
options: {
|
|
57
|
+
query?: Partial<UseSuspenseQueryOptions<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, TData, TQueryKey>> & {
|
|
58
|
+
client?: QueryClient
|
|
59
|
+
}
|
|
60
|
+
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
61
|
+
} = {},
|
|
62
|
+
) {
|
|
63
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
64
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
65
|
+
const queryKey = queryOptions?.queryKey ?? findPetsByStatusSuspenseQueryKey(params)
|
|
66
|
+
|
|
67
|
+
const query = useSuspenseQuery(
|
|
68
|
+
{
|
|
69
|
+
...findPetsByStatusSuspenseQueryOptions({ params }, config),
|
|
70
|
+
queryKey,
|
|
71
|
+
...queryOptions,
|
|
72
|
+
} as unknown as UseSuspenseQueryOptions,
|
|
73
|
+
queryClient,
|
|
74
|
+
) as UseSuspenseQueryResult<TData, ResponseErrorConfig<FindPetsByStatus400>> & { queryKey: TQueryKey }
|
|
75
|
+
|
|
76
|
+
query.queryKey = queryKey as TQueryKey
|
|
77
|
+
|
|
78
|
+
return query
|
|
79
|
+
}
|
|
@@ -7,7 +7,7 @@ import type { QueryKey, QueryClient, UseSuspenseQueryOptions, UseSuspenseQueryRe
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { queryOptions, useSuspenseQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsSuspenseQueryKey = (params
|
|
10
|
+
export const findPetsByTagsSuspenseQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
11
|
|
|
12
12
|
export type FindPetsByTagsSuspenseQueryKey = ReturnType<typeof findPetsByTagsSuspenseQueryKey>
|
|
13
13
|
|
|
@@ -8,7 +8,7 @@ import { fetch } from './test/.kubb/fetch'
|
|
|
8
8
|
import { queryOptions, useSuspenseQuery } from '@tanstack/react-query'
|
|
9
9
|
import { useCustomHookOptions } from 'useCustomHookOptions.ts'
|
|
10
10
|
|
|
11
|
-
export const findPetsByTagsSuspenseQueryKey = (params
|
|
11
|
+
export const findPetsByTagsSuspenseQueryKey = (params: FindPetsByTagsQueryParams = {}) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
12
12
|
|
|
13
13
|
export type FindPetsByTagsSuspenseQueryKey = ReturnType<typeof findPetsByTagsSuspenseQueryKey>
|
|
14
14
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generated by Kubb (https://kubb.dev/).
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
|
|
6
|
+
import type { InfiniteData, QueryKey, QueryClient, UseSuspenseInfiniteQueryOptions, UseSuspenseInfiniteQueryResult } from '@tanstack/react-query'
|
|
7
|
+
import { fetch } from './test/.kubb/fetch'
|
|
8
|
+
import { infiniteQueryOptions, useSuspenseInfiniteQuery } from '@tanstack/react-query'
|
|
9
|
+
|
|
10
|
+
export const findPetsByStatusSuspenseInfiniteQueryKey = (params: FindPetsByStatusQueryParams = {}) =>
|
|
11
|
+
[{ url: '/pet/findByStatus' }, ...(params ? [params] : [])] as const
|
|
12
|
+
|
|
13
|
+
export type FindPetsByStatusSuspenseInfiniteQueryKey = ReturnType<typeof findPetsByStatusSuspenseInfiniteQueryKey>
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @description Multiple status values can be provided with comma separated strings
|
|
17
|
+
* @summary Finds Pets by status
|
|
18
|
+
* {@link /pet/findByStatus}
|
|
19
|
+
*/
|
|
20
|
+
export async function findPetsByStatusSuspenseInfinite(
|
|
21
|
+
{ params }: { params?: FindPetsByStatusQueryParams } = {},
|
|
22
|
+
config: Partial<RequestConfig> & { client?: typeof fetch } = {},
|
|
23
|
+
) {
|
|
24
|
+
const { client: request = fetch, ...requestConfig } = config
|
|
25
|
+
|
|
26
|
+
const res = await request<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, unknown>({
|
|
27
|
+
method: 'GET',
|
|
28
|
+
url: `/pet/findByStatus`,
|
|
29
|
+
params,
|
|
30
|
+
...requestConfig,
|
|
31
|
+
})
|
|
32
|
+
return findPetsByStatusQueryResponse.parse(res.data)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function findPetsByStatusSuspenseInfiniteQueryOptions(
|
|
36
|
+
{ params }: { params?: FindPetsByStatusQueryParams } = {},
|
|
37
|
+
config: Partial<RequestConfig> & { client?: typeof fetch } = {},
|
|
38
|
+
) {
|
|
39
|
+
const queryKey = findPetsByStatusSuspenseInfiniteQueryKey(params)
|
|
40
|
+
return infiniteQueryOptions<
|
|
41
|
+
FindPetsByStatusQueryResponse,
|
|
42
|
+
ResponseErrorConfig<FindPetsByStatus400>,
|
|
43
|
+
InfiniteData<FindPetsByStatusQueryResponse>,
|
|
44
|
+
typeof queryKey,
|
|
45
|
+
NonNullable<FindPetsByStatusQueryParams['status']>
|
|
46
|
+
>({
|
|
47
|
+
queryKey,
|
|
48
|
+
queryFn: async ({ signal, pageParam }) => {
|
|
49
|
+
config.signal = signal
|
|
50
|
+
|
|
51
|
+
params = {
|
|
52
|
+
...(params ?? {}),
|
|
53
|
+
['status']: pageParam as unknown as FindPetsByStatusQueryParams['status'],
|
|
54
|
+
} as FindPetsByStatusQueryParams
|
|
55
|
+
return findPetsByStatusSuspenseInfinite({ params }, config)
|
|
56
|
+
},
|
|
57
|
+
initialPageParam: 'available',
|
|
58
|
+
getNextPageParam: (lastPage, _allPages, lastPageParam) => (Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1),
|
|
59
|
+
getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => (firstPageParam <= 1 ? undefined : firstPageParam - 1),
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* @description Multiple status values can be provided with comma separated strings
|
|
65
|
+
* @summary Finds Pets by status
|
|
66
|
+
* {@link /pet/findByStatus}
|
|
67
|
+
*/
|
|
68
|
+
export function useFindPetsByStatusSuspenseInfinite<
|
|
69
|
+
TQueryFnData = FindPetsByStatusQueryResponse,
|
|
70
|
+
TError = ResponseErrorConfig<FindPetsByStatus400>,
|
|
71
|
+
TData = InfiniteData<TQueryFnData>,
|
|
72
|
+
TQueryKey extends QueryKey = FindPetsByStatusSuspenseInfiniteQueryKey,
|
|
73
|
+
TPageParam = NonNullable<FindPetsByStatusQueryParams['status']>,
|
|
74
|
+
>(
|
|
75
|
+
{ params }: { params?: FindPetsByStatusQueryParams } = {},
|
|
76
|
+
options: {
|
|
77
|
+
query?: Partial<UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>> & { client?: QueryClient }
|
|
78
|
+
client?: Partial<RequestConfig> & { client?: typeof fetch }
|
|
79
|
+
} = {},
|
|
80
|
+
) {
|
|
81
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
82
|
+
const { client: queryClient, ...queryOptions } = queryConfig
|
|
83
|
+
const queryKey = queryOptions?.queryKey ?? findPetsByStatusSuspenseInfiniteQueryKey(params)
|
|
84
|
+
|
|
85
|
+
const query = useSuspenseInfiniteQuery(
|
|
86
|
+
{
|
|
87
|
+
...findPetsByStatusSuspenseInfiniteQueryOptions({ params }, config),
|
|
88
|
+
queryKey,
|
|
89
|
+
...queryOptions,
|
|
90
|
+
} as unknown as UseSuspenseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,
|
|
91
|
+
queryClient,
|
|
92
|
+
) as UseSuspenseInfiniteQueryResult<TData, TError> & { queryKey: TQueryKey }
|
|
93
|
+
|
|
94
|
+
query.queryKey = queryKey as TQueryKey
|
|
95
|
+
|
|
96
|
+
return query
|
|
97
|
+
}
|
|
@@ -7,7 +7,8 @@ import type { InfiniteData, QueryKey, QueryClient, UseSuspenseInfiniteQueryOptio
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { infiniteQueryOptions, useSuspenseInfiniteQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsSuspenseInfiniteQueryKey = (params
|
|
10
|
+
export const findPetsByTagsSuspenseInfiniteQueryKey = (params: FindPetsByTagsQueryParams = {}) =>
|
|
11
|
+
[{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
12
|
|
|
12
13
|
export type FindPetsByTagsSuspenseInfiniteQueryKey = ReturnType<typeof findPetsByTagsSuspenseInfiniteQueryKey>
|
|
13
14
|
|
|
@@ -7,7 +7,8 @@ import type { InfiniteData, QueryKey, QueryClient, UseSuspenseInfiniteQueryOptio
|
|
|
7
7
|
import { fetch } from './test/.kubb/fetch'
|
|
8
8
|
import { infiniteQueryOptions, useSuspenseInfiniteQuery } from '@tanstack/react-query'
|
|
9
9
|
|
|
10
|
-
export const findPetsByTagsSuspenseInfiniteQueryKey = (params
|
|
10
|
+
export const findPetsByTagsSuspenseInfiniteQueryKey = (params: FindPetsByTagsQueryParams = {}) =>
|
|
11
|
+
[{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
11
12
|
|
|
12
13
|
export type FindPetsByTagsSuspenseInfiniteQueryKey = ReturnType<typeof findPetsByTagsSuspenseInfiniteQueryKey>
|
|
13
14
|
|
|
@@ -8,7 +8,8 @@ import { fetch } from './test/.kubb/fetch'
|
|
|
8
8
|
import { infiniteQueryOptions, useSuspenseInfiniteQuery } from '@tanstack/react-query'
|
|
9
9
|
import { useCustomHookOptions } from 'useCustomHookOptions.ts'
|
|
10
10
|
|
|
11
|
-
export const findPetsByTagsSuspenseInfiniteQueryKey = (params
|
|
11
|
+
export const findPetsByTagsSuspenseInfiniteQueryKey = (params: FindPetsByTagsQueryParams = {}) =>
|
|
12
|
+
[{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
12
13
|
|
|
13
14
|
export type FindPetsByTagsSuspenseInfiniteQueryKey = ReturnType<typeof findPetsByTagsSuspenseInfiniteQueryKey>
|
|
14
15
|
|
|
@@ -9,8 +9,8 @@ import { queryOptions, useQuery } from 'custom-query'
|
|
|
9
9
|
|
|
10
10
|
export const updatePetWithFormQueryKey = (
|
|
11
11
|
petId: UpdatePetWithFormPathParams['petId'],
|
|
12
|
-
data
|
|
13
|
-
params
|
|
12
|
+
data: UpdatePetWithFormMutationRequest = {},
|
|
13
|
+
params: UpdatePetWithFormQueryParams = {},
|
|
14
14
|
) => [{ url: '/pet/:pet_id', params: { pet_id: pet_id } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const
|
|
15
15
|
|
|
16
16
|
export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>
|