@kubb/plugin-react-query 4.27.4 → 4.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/{components-BIXznDjl.cjs → components-Bud7cJEj.cjs} +16 -6
  2. package/dist/components-Bud7cJEj.cjs.map +1 -0
  3. package/dist/{components-CU3hgoxU.js → components-DcRvg3r2.js} +16 -6
  4. package/dist/components-DcRvg3r2.js.map +1 -0
  5. package/dist/components.cjs +1 -1
  6. package/dist/components.js +1 -1
  7. package/dist/{generators-DC1P5_Jn.js → generators-D9wuuYX2.js} +2 -2
  8. package/dist/{generators-DC1P5_Jn.js.map → generators-D9wuuYX2.js.map} +1 -1
  9. package/dist/{generators-CrRdr0my.cjs → generators-FaoMN0Iz.cjs} +2 -2
  10. package/dist/{generators-CrRdr0my.cjs.map → generators-FaoMN0Iz.cjs.map} +1 -1
  11. package/dist/generators.cjs +1 -1
  12. package/dist/generators.d.cts +1 -0
  13. package/dist/generators.d.ts +1 -0
  14. package/dist/generators.js +1 -1
  15. package/dist/index.cjs +2 -2
  16. package/dist/index.js +2 -2
  17. package/package.json +7 -7
  18. package/src/components/InfiniteQueryOptions.tsx +6 -2
  19. package/src/components/QueryOptions.tsx +3 -1
  20. package/src/components/SuspenseInfiniteQueryOptions.tsx +6 -2
  21. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +3 -1
  22. package/src/generators/__snapshots__/clientGetImportPath.ts +3 -1
  23. package/src/generators/__snapshots__/createUsersWithListInputAsQuery.ts +3 -1
  24. package/src/generators/__snapshots__/findByStatusAllOptional.ts +3 -1
  25. package/src/generators/__snapshots__/findByStatusAllOptionalInline.ts +3 -1
  26. package/src/generators/__snapshots__/findByTags.ts +3 -1
  27. package/src/generators/__snapshots__/findByTagsObject.ts +3 -1
  28. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +3 -1
  29. package/src/generators/__snapshots__/findByTagsTemplateString.ts +3 -1
  30. package/src/generators/__snapshots__/findByTagsWithCustomOptions.ts +3 -1
  31. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +3 -1
  32. package/src/generators/__snapshots__/findByTagsWithZod.ts +3 -1
  33. package/src/generators/__snapshots__/findInfiniteByStatusAllOptional.ts +3 -1
  34. package/src/generators/__snapshots__/findInfiniteByTags.ts +3 -1
  35. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +3 -1
  36. package/src/generators/__snapshots__/findInfiniteByTagsNextAndPreviousParam.ts +3 -1
  37. package/src/generators/__snapshots__/findInfiniteByTagsNextParam.ts +3 -1
  38. package/src/generators/__snapshots__/findInfiniteByTagsWithCustomOptions.ts +3 -1
  39. package/src/generators/__snapshots__/findSuspenseByStatusAllOptional.ts +3 -1
  40. package/src/generators/__snapshots__/findSuspenseByTags.ts +3 -1
  41. package/src/generators/__snapshots__/findSuspenseByTagsWithCustomOptions.ts +3 -1
  42. package/src/generators/__snapshots__/findSuspenseInfiniteByStatusAllOptional.ts +3 -1
  43. package/src/generators/__snapshots__/findSuspenseInfiniteByTags.ts +3 -1
  44. package/src/generators/__snapshots__/findSuspenseInfiniteByTagsCursor.ts +3 -1
  45. package/src/generators/__snapshots__/findSuspenseInfiniteByTagsWithCustomOptions.ts +3 -1
  46. package/src/generators/__snapshots__/getPetIdCamelCase.ts +3 -1
  47. package/src/generators/__snapshots__/postAsQuery.ts +3 -1
  48. package/src/generators/__snapshots__/requiredOneOfRequestBody.ts +94 -0
  49. package/src/generators/__snapshots__/requiredOneOfRequestBodyWithClientPlugin.ts +71 -0
  50. package/dist/components-BIXznDjl.cjs.map +0 -1
  51. package/dist/components-CU3hgoxU.js.map +0 -1
@@ -42,7 +42,9 @@ export function findPetsByTagsQueryOptions(
42
42
  return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
43
43
  queryKey,
44
44
  queryFn: async ({ signal }) => {
45
- config.signal = signal
45
+ if (!config.signal) {
46
+ config.signal = signal
47
+ }
46
48
  return findPetsByTags(headers, params, config)
47
49
  },
48
50
  })
@@ -40,7 +40,9 @@ export function findPetsByTagsQueryOptions(
40
40
  return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
41
41
  queryKey,
42
42
  queryFn: async ({ signal }) => {
43
- config.signal = signal
43
+ if (!config.signal) {
44
+ config.signal = signal
45
+ }
44
46
  return findPetsByTags({ headers, params }, config)
45
47
  },
46
48
  })
@@ -42,7 +42,9 @@ export function findPetsByTagsQueryOptions(
42
42
  return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
43
43
  queryKey,
44
44
  queryFn: async ({ signal }) => {
45
- config.signal = signal
45
+ if (!config.signal) {
46
+ config.signal = signal
47
+ }
46
48
  return findPetsByTags(headers, params, config)
47
49
  },
48
50
  })
@@ -43,7 +43,9 @@ export function findPetsByTagsQueryOptions(
43
43
  return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
44
44
  queryKey,
45
45
  queryFn: async ({ signal }) => {
46
- config.signal = signal
46
+ if (!config.signal) {
47
+ config.signal = signal
48
+ }
47
49
  return findPetsByTags(headers, params, config)
48
50
  },
49
51
  })
@@ -43,7 +43,9 @@ export function findPetsByTagsQueryOptions(
43
43
  return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
44
44
  queryKey,
45
45
  queryFn: async ({ signal }) => {
46
- config.signal = signal
46
+ if (!config.signal) {
47
+ config.signal = signal
48
+ }
47
49
  return findPetsByTags(headers, params, config)
48
50
  },
49
51
  })
@@ -42,7 +42,9 @@ export function findPetsByTagsQueryOptions(
42
42
  return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
43
43
  queryKey,
44
44
  queryFn: async ({ signal }) => {
45
- config.signal = signal
45
+ if (!config.signal) {
46
+ config.signal = signal
47
+ }
46
48
  return findPetsByTags(headers, params, config)
47
49
  },
48
50
  })
@@ -42,7 +42,9 @@ export function findPetsByTagsQueryOptions(
42
42
  return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
43
43
  queryKey,
44
44
  queryFn: async ({ signal }) => {
45
- config.signal = signal
45
+ if (!config.signal) {
46
+ config.signal = signal
47
+ }
46
48
  return findPetsByTags(headers, params, config)
47
49
  },
48
50
  })
@@ -46,7 +46,9 @@ export function findPetsByStatusInfiniteQueryOptions(
46
46
  >({
47
47
  queryKey,
48
48
  queryFn: async ({ signal, pageParam }) => {
49
- config.signal = signal
49
+ if (!config.signal) {
50
+ config.signal = signal
51
+ }
50
52
 
51
53
  params = {
52
54
  ...(params ?? {}),
@@ -48,7 +48,9 @@ export function findPetsByTagsInfiniteQueryOptions(
48
48
  >({
49
49
  queryKey,
50
50
  queryFn: async ({ signal, pageParam }) => {
51
- config.signal = signal
51
+ if (!config.signal) {
52
+ config.signal = signal
53
+ }
52
54
 
53
55
  params = {
54
56
  ...(params ?? {}),
@@ -48,7 +48,9 @@ export function findPetsByTagsInfiniteQueryOptions(
48
48
  >({
49
49
  queryKey,
50
50
  queryFn: async ({ signal, pageParam }) => {
51
- config.signal = signal
51
+ if (!config.signal) {
52
+ config.signal = signal
53
+ }
52
54
 
53
55
  if (!params) {
54
56
  params = {}
@@ -48,7 +48,9 @@ export function findPetsByTagsInfiniteQueryOptions(
48
48
  >({
49
49
  queryKey,
50
50
  queryFn: async ({ signal, pageParam }) => {
51
- config.signal = signal
51
+ if (!config.signal) {
52
+ config.signal = signal
53
+ }
52
54
 
53
55
  params = {
54
56
  ...(params ?? {}),
@@ -48,7 +48,9 @@ export function findPetsByTagsInfiniteQueryOptions(
48
48
  >({
49
49
  queryKey,
50
50
  queryFn: async ({ signal, pageParam }) => {
51
- config.signal = signal
51
+ if (!config.signal) {
52
+ config.signal = signal
53
+ }
52
54
 
53
55
  params = {
54
56
  ...(params ?? {}),
@@ -49,7 +49,9 @@ export function findPetsByTagsInfiniteQueryOptions(
49
49
  >({
50
50
  queryKey,
51
51
  queryFn: async ({ signal, pageParam }) => {
52
- config.signal = signal
52
+ if (!config.signal) {
53
+ config.signal = signal
54
+ }
53
55
 
54
56
  params = {
55
57
  ...(params ?? {}),
@@ -40,7 +40,9 @@ export function findPetsByStatusSuspenseQueryOptions(
40
40
  return queryOptions<FindPetsByStatusQueryResponse, ResponseErrorConfig<FindPetsByStatus400>, FindPetsByStatusQueryResponse, typeof queryKey>({
41
41
  queryKey,
42
42
  queryFn: async ({ signal }) => {
43
- config.signal = signal
43
+ if (!config.signal) {
44
+ config.signal = signal
45
+ }
44
46
  return findPetsByStatusSuspense({ params }, config)
45
47
  },
46
48
  })
@@ -42,7 +42,9 @@ export function findPetsByTagsSuspenseQueryOptions(
42
42
  return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
43
43
  queryKey,
44
44
  queryFn: async ({ signal }) => {
45
- config.signal = signal
45
+ if (!config.signal) {
46
+ config.signal = signal
47
+ }
46
48
  return findPetsByTagsSuspense(headers, params, config)
47
49
  },
48
50
  })
@@ -43,7 +43,9 @@ export function findPetsByTagsSuspenseQueryOptions(
43
43
  return queryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey>({
44
44
  queryKey,
45
45
  queryFn: async ({ signal }) => {
46
- config.signal = signal
46
+ if (!config.signal) {
47
+ config.signal = signal
48
+ }
47
49
  return findPetsByTagsSuspense(headers, params, config)
48
50
  },
49
51
  })
@@ -46,7 +46,9 @@ export function findPetsByStatusSuspenseInfiniteQueryOptions(
46
46
  >({
47
47
  queryKey,
48
48
  queryFn: async ({ signal, pageParam }) => {
49
- config.signal = signal
49
+ if (!config.signal) {
50
+ config.signal = signal
51
+ }
50
52
 
51
53
  params = {
52
54
  ...(params ?? {}),
@@ -49,7 +49,9 @@ export function findPetsByTagsSuspenseInfiniteQueryOptions(
49
49
  >({
50
50
  queryKey,
51
51
  queryFn: async ({ signal, pageParam }) => {
52
- config.signal = signal
52
+ if (!config.signal) {
53
+ config.signal = signal
54
+ }
53
55
 
54
56
  params = {
55
57
  ...(params ?? {}),
@@ -49,7 +49,9 @@ export function findPetsByTagsSuspenseInfiniteQueryOptions(
49
49
  >({
50
50
  queryKey,
51
51
  queryFn: async ({ signal, pageParam }) => {
52
- config.signal = signal
52
+ if (!config.signal) {
53
+ config.signal = signal
54
+ }
53
55
 
54
56
  params = {
55
57
  ...(params ?? {}),
@@ -50,7 +50,9 @@ export function findPetsByTagsSuspenseInfiniteQueryOptions(
50
50
  >({
51
51
  queryKey,
52
52
  queryFn: async ({ signal, pageParam }) => {
53
- config.signal = signal
53
+ if (!config.signal) {
54
+ config.signal = signal
55
+ }
54
56
 
55
57
  params = {
56
58
  ...(params ?? {}),
@@ -35,7 +35,9 @@ export function getPetByIdQueryOptions(petId: GetPetByIdPathParams['petId'], con
35
35
  enabled: !!petId,
36
36
  queryKey,
37
37
  queryFn: async ({ signal }) => {
38
- config.signal = signal
38
+ if (!config.signal) {
39
+ config.signal = signal
40
+ }
39
41
  return getPetById(petId, config)
40
42
  },
41
43
  })
@@ -50,7 +50,9 @@ export function updatePetWithFormQueryOptions(
50
50
  enabled: !!petId,
51
51
  queryKey,
52
52
  queryFn: async ({ signal }) => {
53
- config.signal = signal
53
+ if (!config.signal) {
54
+ config.signal = signal
55
+ }
54
56
  return updatePetWithForm(petId, data, params, config)
55
57
  },
56
58
  })
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Generated by Kubb (https://kubb.dev/).
3
+ * Do not edit manually.
4
+ */
5
+ import type { Client, RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
6
+ import type { UseMutationOptions, UseMutationResult, QueryClient } from '@tanstack/react-query'
7
+ import { fetch } from './test/.kubb/fetch'
8
+ import { mutationOptions, useMutation } from '@tanstack/react-query'
9
+
10
+ export const createOrderMutationKey = () => [{ url: '/orders' }] as const
11
+
12
+ export type CreateOrderMutationKey = ReturnType<typeof createOrderMutationKey>
13
+
14
+ /**
15
+ * {@link /orders}
16
+ */
17
+ export async function createOrder(
18
+ data: CreateOrderMutationRequest,
19
+ headers?: CreateOrderHeaderParams,
20
+ config: Partial<RequestConfig<CreateOrderMutationRequest>> & { client?: Client } = {},
21
+ ) {
22
+ const { client: request = fetch, ...requestConfig } = config
23
+
24
+ const requestData = createOrderMutationRequest.parse(data)
25
+
26
+ const res = await request<CreateOrderMutationResponse, ResponseErrorConfig<Error>, CreateOrderMutationRequest>({
27
+ method: 'POST',
28
+ url: `/orders`,
29
+ data: requestData,
30
+ ...requestConfig,
31
+ headers: { ...headers, ...requestConfig.headers },
32
+ })
33
+ return createOrderMutationResponse.parse(res.data)
34
+ }
35
+
36
+ export function createOrderMutationOptions<TContext = unknown>(config: Partial<RequestConfig<CreateOrderMutationRequest>> & { client?: Client } = {}) {
37
+ const mutationKey = createOrderMutationKey()
38
+ return mutationOptions<
39
+ CreateOrderMutationResponse,
40
+ ResponseErrorConfig<Error>,
41
+ { data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
42
+ TContext
43
+ >({
44
+ mutationKey,
45
+ mutationFn: async ({ data, headers }) => {
46
+ return createOrder(data, headers, config)
47
+ },
48
+ })
49
+ }
50
+
51
+ /**
52
+ * {@link /orders}
53
+ */
54
+ export function useCreateOrder<TContext>(
55
+ options: {
56
+ mutation?: UseMutationOptions<
57
+ CreateOrderMutationResponse,
58
+ ResponseErrorConfig<Error>,
59
+ { data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
60
+ TContext
61
+ > & { client?: QueryClient }
62
+ client?: Partial<RequestConfig<CreateOrderMutationRequest>> & { client?: Client }
63
+ } = {},
64
+ ) {
65
+ const { mutation = {}, client: config = {} } = options ?? {}
66
+ const { client: queryClient, ...mutationOptions } = mutation
67
+ const mutationKey = mutationOptions.mutationKey ?? createOrderMutationKey()
68
+
69
+ const baseOptions = createOrderMutationOptions(config) as UseMutationOptions<
70
+ CreateOrderMutationResponse,
71
+ ResponseErrorConfig<Error>,
72
+ { data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
73
+ TContext
74
+ >
75
+
76
+ return useMutation<
77
+ CreateOrderMutationResponse,
78
+ ResponseErrorConfig<Error>,
79
+ { data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
80
+ TContext
81
+ >(
82
+ {
83
+ ...baseOptions,
84
+ mutationKey,
85
+ ...mutationOptions,
86
+ },
87
+ queryClient,
88
+ ) as UseMutationResult<
89
+ CreateOrderMutationResponse,
90
+ ResponseErrorConfig<Error>,
91
+ { data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
92
+ TContext
93
+ >
94
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Generated by Kubb (https://kubb.dev/).
3
+ * Do not edit manually.
4
+ */
5
+ import type { Client, RequestConfig, ResponseErrorConfig } from './test/.kubb/fetch'
6
+ import type { UseMutationOptions, UseMutationResult, QueryClient } from '@tanstack/react-query'
7
+ import { mutationOptions, useMutation } from '@tanstack/react-query'
8
+
9
+ export const createOrderMutationKey = () => [{ url: '/orders' }] as const
10
+
11
+ export type CreateOrderMutationKey = ReturnType<typeof createOrderMutationKey>
12
+
13
+ export function createOrderMutationOptions<TContext = unknown>(config: Partial<RequestConfig<CreateOrderMutationRequest>> & { client?: Client } = {}) {
14
+ const mutationKey = createOrderMutationKey()
15
+ return mutationOptions<
16
+ CreateOrderMutationResponse,
17
+ ResponseErrorConfig<Error>,
18
+ { data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
19
+ TContext
20
+ >({
21
+ mutationKey,
22
+ mutationFn: async ({ data, headers }) => {
23
+ return createOrder(data, headers, config)
24
+ },
25
+ })
26
+ }
27
+
28
+ /**
29
+ * {@link /orders}
30
+ */
31
+ export function useCreateOrder<TContext>(
32
+ options: {
33
+ mutation?: UseMutationOptions<
34
+ CreateOrderMutationResponse,
35
+ ResponseErrorConfig<Error>,
36
+ { data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
37
+ TContext
38
+ > & { client?: QueryClient }
39
+ client?: Partial<RequestConfig<CreateOrderMutationRequest>> & { client?: Client }
40
+ } = {},
41
+ ) {
42
+ const { mutation = {}, client: config = {} } = options ?? {}
43
+ const { client: queryClient, ...mutationOptions } = mutation
44
+ const mutationKey = mutationOptions.mutationKey ?? createOrderMutationKey()
45
+
46
+ const baseOptions = createOrderMutationOptions(config) as UseMutationOptions<
47
+ CreateOrderMutationResponse,
48
+ ResponseErrorConfig<Error>,
49
+ { data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
50
+ TContext
51
+ >
52
+
53
+ return useMutation<
54
+ CreateOrderMutationResponse,
55
+ ResponseErrorConfig<Error>,
56
+ { data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
57
+ TContext
58
+ >(
59
+ {
60
+ ...baseOptions,
61
+ mutationKey,
62
+ ...mutationOptions,
63
+ },
64
+ queryClient,
65
+ ) as UseMutationResult<
66
+ CreateOrderMutationResponse,
67
+ ResponseErrorConfig<Error>,
68
+ { data: CreateOrderMutationRequest; headers?: CreateOrderHeaderParams },
69
+ TContext
70
+ >
71
+ }