@kubb/plugin-react-query 3.0.0-alpha.14 → 3.0.0-alpha.16

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 (73) hide show
  1. package/dist/chunk-ESENIDWJ.js +608 -0
  2. package/dist/chunk-ESENIDWJ.js.map +1 -0
  3. package/dist/chunk-JQEH3UHY.cjs +618 -0
  4. package/dist/chunk-JQEH3UHY.cjs.map +1 -0
  5. package/dist/chunk-KRG2LWHM.cjs +606 -0
  6. package/dist/chunk-KRG2LWHM.cjs.map +1 -0
  7. package/dist/chunk-ME7ZFS5H.js +596 -0
  8. package/dist/chunk-ME7ZFS5H.js.map +1 -0
  9. package/dist/components.cjs +17 -5
  10. package/dist/components.d.cts +143 -5
  11. package/dist/components.d.ts +143 -5
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +25 -0
  14. package/dist/generators.cjs.map +1 -0
  15. package/dist/generators.d.cts +15 -0
  16. package/dist/generators.d.ts +15 -0
  17. package/dist/generators.js +4 -0
  18. package/dist/generators.js.map +1 -0
  19. package/dist/index.cjs +33 -76
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +2 -4
  22. package/dist/index.d.ts +2 -4
  23. package/dist/index.js +34 -77
  24. package/dist/index.js.map +1 -1
  25. package/dist/types-DJxL-JeY.d.cts +195 -0
  26. package/dist/types-DJxL-JeY.d.ts +195 -0
  27. package/package.json +23 -15
  28. package/src/components/InfiniteQuery.tsx +129 -0
  29. package/src/components/InfiniteQueryOptions.tsx +121 -0
  30. package/src/components/Mutation.tsx +112 -304
  31. package/src/components/Query.tsx +91 -593
  32. package/src/components/QueryKey.tsx +51 -182
  33. package/src/components/QueryOptions.tsx +64 -465
  34. package/src/components/SuspenseQuery.tsx +129 -0
  35. package/src/components/index.ts +3 -0
  36. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +64 -0
  37. package/src/generators/__snapshots__/clientGetImportPath.ts +64 -0
  38. package/src/generators/__snapshots__/clientPostImportPath.ts +59 -0
  39. package/src/generators/__snapshots__/findByTags.ts +64 -0
  40. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +64 -0
  41. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +64 -0
  42. package/src/generators/__snapshots__/findByTagsWithZod.ts +64 -0
  43. package/src/generators/__snapshots__/findInfiniteByTags.ts +74 -0
  44. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +74 -0
  45. package/src/generators/__snapshots__/getAsMutation.ts +31 -0
  46. package/src/generators/__snapshots__/postAsQuery.ts +77 -0
  47. package/src/generators/__snapshots__/updatePetById.ts +59 -0
  48. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +63 -0
  49. package/src/generators/index.ts +4 -0
  50. package/src/generators/infiniteQueryGenerator.tsx +124 -0
  51. package/src/generators/mutationGenerator.tsx +94 -0
  52. package/src/generators/queryGenerator.tsx +121 -0
  53. package/src/generators/suspenseQueryGenerator.tsx +120 -0
  54. package/src/plugin.ts +38 -49
  55. package/src/types.ts +35 -59
  56. package/dist/chunk-AGLJPONA.cjs +0 -1423
  57. package/dist/chunk-AGLJPONA.cjs.map +0 -1
  58. package/dist/chunk-I7X4HNDR.js +0 -1413
  59. package/dist/chunk-I7X4HNDR.js.map +0 -1
  60. package/dist/index-BzoLlZve.d.cts +0 -537
  61. package/dist/index-BzoLlZve.d.ts +0 -537
  62. package/src/OperationGenerator.tsx +0 -57
  63. package/src/__snapshots__/mutateAsQuery/updatePetWithForm.ts +0 -69
  64. package/src/__snapshots__/pathParamsTypeInline/getPetById.ts +0 -62
  65. package/src/__snapshots__/pathParamsTypeObject/getPetById.ts +0 -68
  66. package/src/__snapshots__/queryOptions/getPetById.ts +0 -41
  67. package/src/__snapshots__/queryWithoutQueryOptions/getPetById.ts +0 -51
  68. package/src/__snapshots__/variablesTypeMutate/deletePet.ts +0 -24
  69. package/src/components/QueryImports.tsx +0 -167
  70. package/src/components/SchemaType.tsx +0 -74
  71. package/src/components/__snapshots__/gen/showPetById.ts +0 -67
  72. package/src/components/__snapshots__/gen/useCreatePets.ts +0 -46
  73. package/src/components/__snapshots__/gen/useCreatePetsMutate.ts +0 -46
@@ -0,0 +1,64 @@
1
+ import client from '@kubb/plugin-client/client'
2
+ import type { RequestConfig, ResponseConfig } from '@kubb/plugin-client/client'
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
4
+ import { useQuery, queryOptions } from '@tanstack/react-query'
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
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 { ...res, data: findPetsByTagsQueryResponse.parse(res.data) }
24
+ }
25
+
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async () => {
31
+ return findPetsByTags(headers, params, config)
32
+ },
33
+ })
34
+ }
35
+
36
+ /**
37
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
38
+ * @summary Finds Pets by tags
39
+ * @link /pet/findByTags
40
+ */
41
+ export function useFindPetsByTags<
42
+ TData = ResponseConfig<FindPetsByTagsQueryResponse>,
43
+ TQueryData = ResponseConfig<FindPetsByTagsQueryResponse>,
44
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
45
+ >(
46
+ headers: FindPetsByTagsHeaderParams,
47
+ params?: FindPetsByTagsQueryParams,
48
+ options: {
49
+ query?: Partial<QueryObserverOptions<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, TData, TQueryData, TQueryKey>>
50
+ client?: Partial<RequestConfig>
51
+ } = {},
52
+ ) {
53
+ const { query: queryOptions, client: config = {} } = options ?? {}
54
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
55
+ const query = useQuery({
56
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
57
+ queryKey,
58
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
59
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
60
+ queryKey: TQueryKey
61
+ }
62
+ query.queryKey = queryKey as TQueryKey
63
+ return query
64
+ }
@@ -0,0 +1,64 @@
1
+ import client from 'axios'
2
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from '@tanstack/react-query'
3
+ import type { RequestConfig } from 'axios'
4
+ import { useQuery, queryOptions } from '@tanstack/react-query'
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
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)
24
+ }
25
+
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async () => {
31
+ return findPetsByTags(headers, params, config)
32
+ },
33
+ })
34
+ }
35
+
36
+ /**
37
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
38
+ * @summary Finds Pets by tags
39
+ * @link /pet/findByTags
40
+ */
41
+ export function useFindPetsByTags<
42
+ TData = FindPetsByTagsQueryResponse,
43
+ TQueryData = FindPetsByTagsQueryResponse,
44
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
45
+ >(
46
+ headers: FindPetsByTagsHeaderParams,
47
+ params?: FindPetsByTagsQueryParams,
48
+ options: {
49
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
50
+ client?: Partial<RequestConfig>
51
+ } = {},
52
+ ) {
53
+ const { query: queryOptions, client: config = {} } = options ?? {}
54
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
55
+ const query = useQuery({
56
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
57
+ queryKey,
58
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
59
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
60
+ queryKey: TQueryKey
61
+ }
62
+ query.queryKey = queryKey as TQueryKey
63
+ return query
64
+ }
@@ -0,0 +1,59 @@
1
+ import client from 'axios'
2
+ import type { UseMutationOptions } from '@tanstack/react-query'
3
+ import type { RequestConfig } from 'axios'
4
+ import { useMutation } from '@tanstack/react-query'
5
+
6
+ /**
7
+ * @summary Updates a pet in the store with form data
8
+ * @link /pet/:petId
9
+ */
10
+ async function updatePetWithForm(
11
+ petId: UpdatePetWithFormPathParams['petId'],
12
+ data?: UpdatePetWithFormMutationRequest,
13
+ params?: UpdatePetWithFormQueryParams,
14
+ config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
15
+ ) {
16
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
17
+ method: 'post',
18
+ url: `/pet/${petId}`,
19
+ params,
20
+ data,
21
+ ...config,
22
+ })
23
+ return updatePetWithFormMutationResponse.parse(res.data)
24
+ }
25
+
26
+ /**
27
+ * @summary Updates a pet in the store with form data
28
+ * @link /pet/:petId
29
+ */
30
+ export function useUpdatePetWithForm(
31
+ options: {
32
+ mutation?: UseMutationOptions<
33
+ UpdatePetWithFormMutationResponse,
34
+ UpdatePetWithForm405,
35
+ {
36
+ petId: UpdatePetWithFormPathParams['petId']
37
+ data?: UpdatePetWithFormMutationRequest
38
+ params?: UpdatePetWithFormQueryParams
39
+ }
40
+ >
41
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
42
+ } = {},
43
+ ) {
44
+ const { mutation: mutationOptions, client: config = {} } = options ?? {}
45
+ return useMutation({
46
+ mutationFn: async ({
47
+ petId,
48
+ data,
49
+ params,
50
+ }: {
51
+ petId: UpdatePetWithFormPathParams['petId']
52
+ data?: UpdatePetWithFormMutationRequest
53
+ params?: UpdatePetWithFormQueryParams
54
+ }) => {
55
+ return updatePetWithForm(petId, data, params, config)
56
+ },
57
+ ...mutationOptions,
58
+ })
59
+ }
@@ -0,0 +1,64 @@
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 { useQuery, queryOptions } from '@tanstack/react-query'
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
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)
24
+ }
25
+
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async () => {
31
+ return findPetsByTags(headers, params, config)
32
+ },
33
+ })
34
+ }
35
+
36
+ /**
37
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
38
+ * @summary Finds Pets by tags
39
+ * @link /pet/findByTags
40
+ */
41
+ export function useFindPetsByTags<
42
+ TData = FindPetsByTagsQueryResponse,
43
+ TQueryData = FindPetsByTagsQueryResponse,
44
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
45
+ >(
46
+ headers: FindPetsByTagsHeaderParams,
47
+ params?: FindPetsByTagsQueryParams,
48
+ options: {
49
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
50
+ client?: Partial<RequestConfig>
51
+ } = {},
52
+ ) {
53
+ const { query: queryOptions, client: config = {} } = options ?? {}
54
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
55
+ const query = useQuery({
56
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
57
+ queryKey,
58
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
59
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
60
+ queryKey: TQueryKey
61
+ }
62
+ query.queryKey = queryKey as TQueryKey
63
+ return query
64
+ }
@@ -0,0 +1,64 @@
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 { useQuery, queryOptions } from '@tanstack/react-query'
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
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)
24
+ }
25
+
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async () => {
31
+ return findPetsByTags(headers, params, config)
32
+ },
33
+ })
34
+ }
35
+
36
+ /**
37
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
38
+ * @summary Finds Pets by tags
39
+ * @link /pet/findByTags
40
+ */
41
+ export function useFindPetsByTags<
42
+ TData = FindPetsByTagsQueryResponse,
43
+ TQueryData = FindPetsByTagsQueryResponse,
44
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
45
+ >(
46
+ headers: FindPetsByTagsHeaderParams,
47
+ params?: FindPetsByTagsQueryParams,
48
+ options: {
49
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
50
+ client?: Partial<RequestConfig>
51
+ } = {},
52
+ ) {
53
+ const { query: queryOptions, client: config = {} } = options ?? {}
54
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
55
+ const query = useQuery({
56
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
57
+ queryKey,
58
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
59
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
60
+ queryKey: TQueryKey
61
+ }
62
+ query.queryKey = queryKey as TQueryKey
63
+ return query
64
+ }
@@ -0,0 +1,64 @@
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 { useQuery, queryOptions } from '@tanstack/react-query'
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [test, { url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
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)
24
+ }
25
+
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async () => {
31
+ return findPetsByTags(headers, params, config)
32
+ },
33
+ })
34
+ }
35
+
36
+ /**
37
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
38
+ * @summary Finds Pets by tags
39
+ * @link /pet/findByTags
40
+ */
41
+ export function useFindPetsByTags<
42
+ TData = FindPetsByTagsQueryResponse,
43
+ TQueryData = FindPetsByTagsQueryResponse,
44
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
45
+ >(
46
+ headers: FindPetsByTagsHeaderParams,
47
+ params?: FindPetsByTagsQueryParams,
48
+ options: {
49
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
50
+ client?: Partial<RequestConfig>
51
+ } = {},
52
+ ) {
53
+ const { query: queryOptions, client: config = {} } = options ?? {}
54
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
55
+ const query = useQuery({
56
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
57
+ queryKey,
58
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
59
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
60
+ queryKey: TQueryKey
61
+ }
62
+ query.queryKey = queryKey as TQueryKey
63
+ return query
64
+ }
@@ -0,0 +1,64 @@
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 { useQuery, queryOptions } from '@tanstack/react-query'
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
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)
24
+ }
25
+
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params)
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async () => {
31
+ return findPetsByTags(headers, params, config)
32
+ },
33
+ })
34
+ }
35
+
36
+ /**
37
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
38
+ * @summary Finds Pets by tags
39
+ * @link /pet/findByTags
40
+ */
41
+ export function useFindPetsByTags<
42
+ TData = FindPetsByTagsQueryResponse,
43
+ TQueryData = FindPetsByTagsQueryResponse,
44
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
45
+ >(
46
+ headers: FindPetsByTagsHeaderParams,
47
+ params?: FindPetsByTagsQueryParams,
48
+ options: {
49
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
50
+ client?: Partial<RequestConfig>
51
+ } = {},
52
+ ) {
53
+ const { query: queryOptions, client: config = {} } = options ?? {}
54
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
55
+ const query = useQuery({
56
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions),
57
+ queryKey,
58
+ ...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
59
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
60
+ queryKey: TQueryKey
61
+ }
62
+ query.queryKey = queryKey as TQueryKey
63
+ return query
64
+ }
@@ -0,0 +1,74 @@
1
+ import client from '@kubb/plugin-client/client'
2
+ import type { RequestConfig } from '@kubb/plugin-client/client'
3
+ import type { QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
4
+ import { useInfiniteQuery, infiniteQueryOptions } from '@tanstack/react-query'
5
+
6
+ export const findPetsByTagsInfiniteQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
+
8
+ export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
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)
24
+ }
25
+
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 ({ pageParam }) => {
35
+ if (params) {
36
+ params['pageSize'] = pageParam as unknown as FindPetsByTagsQueryParams['pageSize']
37
+ }
38
+ return findPetsByTags(headers, params, config)
39
+ },
40
+ initialPageParam: 0,
41
+ getNextPageParam: (lastPage, _allPages, lastPageParam) => (Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1),
42
+ getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => (firstPageParam <= 1 ? undefined : firstPageParam - 1),
43
+ })
44
+ }
45
+
46
+ /**
47
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
48
+ * @summary Finds Pets by tags
49
+ * @link /pet/findByTags
50
+ */
51
+ export function useFindPetsByTagsInfinite<
52
+ TData = FindPetsByTagsQueryResponse,
53
+ TQueryData = FindPetsByTagsQueryResponse,
54
+ TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey,
55
+ >(
56
+ headers: FindPetsByTagsHeaderParams,
57
+ params?: FindPetsByTagsQueryParams,
58
+ options: {
59
+ query?: Partial<InfiniteQueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
60
+ client?: Partial<RequestConfig>
61
+ } = {},
62
+ ) {
63
+ const { query: queryOptions, client: config = {} } = options ?? {}
64
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params)
65
+ const query = useInfiniteQuery({
66
+ ...(findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions),
67
+ queryKey,
68
+ ...(queryOptions as unknown as Omit<InfiniteQueryObserverOptions, 'queryKey'>),
69
+ }) as UseInfiniteQueryResult<TData, FindPetsByTags400> & {
70
+ queryKey: TQueryKey
71
+ }
72
+ query.queryKey = queryKey as TQueryKey
73
+ return query
74
+ }
@@ -0,0 +1,74 @@
1
+ import client from '@kubb/plugin-client/client'
2
+ import type { RequestConfig } from '@kubb/plugin-client/client'
3
+ import type { QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from '@tanstack/react-query'
4
+ import { useInfiniteQuery, infiniteQueryOptions } from '@tanstack/react-query'
5
+
6
+ export const findPetsByTagsInfiniteQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
+
8
+ export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
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)
24
+ }
25
+
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 ({ pageParam }) => {
35
+ if (params) {
36
+ params['pageSize'] = pageParam as unknown as FindPetsByTagsQueryParams['pageSize']
37
+ }
38
+ return findPetsByTags(headers, params, config)
39
+ },
40
+ initialPageParam: 0,
41
+ getNextPageParam: (lastPage) => lastPage['cursor'],
42
+ getPreviousPageParam: (firstPage) => firstPage['cursor'],
43
+ })
44
+ }
45
+
46
+ /**
47
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
48
+ * @summary Finds Pets by tags
49
+ * @link /pet/findByTags
50
+ */
51
+ export function useFindPetsByTagsInfinite<
52
+ TData = FindPetsByTagsQueryResponse,
53
+ TQueryData = FindPetsByTagsQueryResponse,
54
+ TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey,
55
+ >(
56
+ headers: FindPetsByTagsHeaderParams,
57
+ params?: FindPetsByTagsQueryParams,
58
+ options: {
59
+ query?: Partial<InfiniteQueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
60
+ client?: Partial<RequestConfig>
61
+ } = {},
62
+ ) {
63
+ const { query: queryOptions, client: config = {} } = options ?? {}
64
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params)
65
+ const query = useInfiniteQuery({
66
+ ...(findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions),
67
+ queryKey,
68
+ ...(queryOptions as unknown as Omit<InfiniteQueryObserverOptions, 'queryKey'>),
69
+ }) as UseInfiniteQueryResult<TData, FindPetsByTags400> & {
70
+ queryKey: TQueryKey
71
+ }
72
+ query.queryKey = queryKey as TQueryKey
73
+ return query
74
+ }
@@ -0,0 +1,31 @@
1
+ import client from '@kubb/plugin-client/client'
2
+ import type { RequestConfig } from '@kubb/plugin-client/client'
3
+ import type { UseMutationOptions } from 'custom-swr/mutation'
4
+ import { useMutation } from 'custom-swr/mutation'
5
+
6
+ /**
7
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
8
+ * @summary Finds Pets by tags
9
+ * @link /pet/findByTags
10
+ */
11
+ export function findPetsByTags(
12
+ options: {
13
+ mutation?: UseMutationOptions<
14
+ FindPetsByTagsQueryResponse,
15
+ FindPetsByTags400,
16
+ {
17
+ headers: FindPetsByTagsHeaderParams
18
+ params?: FindPetsByTagsQueryParams
19
+ }
20
+ >
21
+ client?: Partial<RequestConfig>
22
+ } = {},
23
+ ) {
24
+ const { mutation: mutationOptions, client: config = {} } = options ?? {}
25
+ return useMutation({
26
+ mutationFn: async ({ headers, params }: { headers: FindPetsByTagsHeaderParams; params?: FindPetsByTagsQueryParams }) => {
27
+ return findPetsByTags(headers, params, config)
28
+ },
29
+ ...mutationOptions,
30
+ })
31
+ }