@kubb/plugin-vue-query 4.29.1 → 4.31.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 (42) hide show
  1. package/dist/{Query-BpdIIfn2.cjs → Query-D3VPmttB.cjs} +5 -9
  2. package/dist/Query-D3VPmttB.cjs.map +1 -0
  3. package/dist/{Query-4nkhGb9c.js → Query-DVuOyLhX.js} +5 -9
  4. package/dist/Query-DVuOyLhX.js.map +1 -0
  5. package/dist/components.cjs +1 -1
  6. package/dist/components.d.ts +3 -2
  7. package/dist/components.js +1 -1
  8. package/dist/generators.cjs +1 -1
  9. package/dist/generators.d.ts +4 -3
  10. package/dist/generators.js +1 -1
  11. package/dist/index.cjs +2 -2
  12. package/dist/index.d.ts +2 -1
  13. package/dist/index.js +2 -2
  14. package/dist/{queryGenerator-e6WGv0jo.cjs → queryGenerator-C2f5Ycgw.cjs} +8 -8
  15. package/dist/queryGenerator-C2f5Ycgw.cjs.map +1 -0
  16. package/dist/{queryGenerator-gk8pNl_4.js → queryGenerator-CHpHlXsx.js} +8 -8
  17. package/dist/queryGenerator-CHpHlXsx.js.map +1 -0
  18. package/package.json +11 -10
  19. package/src/components/InfiniteQueryOptions.tsx +4 -3
  20. package/src/components/QueryOptions.tsx +6 -5
  21. package/src/generators/infiniteQueryGenerator.tsx +4 -2
  22. package/src/generators/mutationGenerator.tsx +4 -2
  23. package/src/generators/queryGenerator.tsx +4 -2
  24. package/dist/Query-4nkhGb9c.js.map +0 -1
  25. package/dist/Query-BpdIIfn2.cjs.map +0 -1
  26. package/dist/queryGenerator-e6WGv0jo.cjs.map +0 -1
  27. package/dist/queryGenerator-gk8pNl_4.js.map +0 -1
  28. package/dist/types-CrWaSUV7.d.ts +0 -178
  29. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +0 -102
  30. package/src/generators/__snapshots__/clientGetImportPath.ts +0 -91
  31. package/src/generators/__snapshots__/clientPostImportPath.ts +0 -77
  32. package/src/generators/__snapshots__/findByTags.ts +0 -91
  33. package/src/generators/__snapshots__/findByTagsObject.ts +0 -88
  34. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +0 -91
  35. package/src/generators/__snapshots__/findByTagsTemplateString.ts +0 -92
  36. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +0 -91
  37. package/src/generators/__snapshots__/findByTagsWithZod.ts +0 -91
  38. package/src/generators/__snapshots__/findInfiniteByTags.ts +0 -105
  39. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +0 -105
  40. package/src/generators/__snapshots__/postAsQuery.ts +0 -104
  41. package/src/generators/__snapshots__/updatePetById.ts +0 -77
  42. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +0 -77
@@ -1,105 +0,0 @@
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 { InfiniteData, QueryKey, QueryClient, UseInfiniteQueryOptions, UseInfiniteQueryReturnType } from '@tanstack/react-query'
7
- import type { MaybeRefOrGetter } from 'vue'
8
- import { fetch } from './test/.kubb/fetch'
9
- import { infiniteQueryOptions, useInfiniteQuery } from '@tanstack/react-query'
10
- import { toValue } from 'vue'
11
-
12
- export const findPetsByTagsInfiniteQueryKey = (params?: MaybeRefOrGetter<FindPetsByTagsQueryParams>) =>
13
- [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
14
-
15
- export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>
16
-
17
- /**
18
- * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
19
- * @summary Finds Pets by tags
20
- * {@link /pet/findByTags}
21
- */
22
- export async function findPetsByTagsInfinite(
23
- headers: FindPetsByTagsHeaderParams,
24
- params?: FindPetsByTagsQueryParams,
25
- config: Partial<RequestConfig> & { client?: Client } = {},
26
- ) {
27
- const { client: request = fetch, ...requestConfig } = config
28
-
29
- const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
30
- method: 'GET',
31
- url: `/pet/findByTags`,
32
- params,
33
- ...requestConfig,
34
- headers: { ...headers, ...requestConfig.headers },
35
- })
36
- return findPetsByTagsQueryResponse.parse(res.data)
37
- }
38
-
39
- export function findPetsByTagsInfiniteQueryOptions(
40
- headers: MaybeRefOrGetter<FindPetsByTagsHeaderParams>,
41
- params?: MaybeRefOrGetter<FindPetsByTagsQueryParams>,
42
- config: Partial<RequestConfig> & { client?: Client } = {},
43
- ) {
44
- const queryKey = findPetsByTagsInfiniteQueryKey(params)
45
- return infiniteQueryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, FindPetsByTagsQueryResponse, typeof queryKey, number>({
46
- queryKey,
47
- queryFn: async ({ signal, pageParam }) => {
48
- if (!config.signal) {
49
- config.signal = signal
50
- }
51
-
52
- if (!params) {
53
- params = {}
54
- }
55
- params['pageSize'] = pageParam as unknown as FindPetsByTagsQueryParams['pageSize']
56
- return findPetsByTagsInfinite(toValue(headers), toValue(params), toValue(config))
57
- },
58
- initialPageParam: 0,
59
- getNextPageParam: (lastPage) => lastPage['cursor'],
60
- getPreviousPageParam: (firstPage) => firstPage['cursor'],
61
- })
62
- }
63
-
64
- /**
65
- * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
66
- * @summary Finds Pets by tags
67
- * {@link /pet/findByTags}
68
- */
69
- export function useFindPetsByTagsInfinite<
70
- TData = InfiniteData<FindPetsByTagsQueryResponse>,
71
- TQueryData = FindPetsByTagsQueryResponse,
72
- TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey,
73
- >(
74
- headers: MaybeRefOrGetter<FindPetsByTagsHeaderParams>,
75
- params?: MaybeRefOrGetter<FindPetsByTagsQueryParams>,
76
- options: {
77
- query?: Partial<UseInfiniteQueryOptions<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, TQueryData, TQueryKey, TQueryData>> & {
78
- client?: QueryClient
79
- }
80
- client?: Partial<RequestConfig> & { client?: Client }
81
- } = {},
82
- ) {
83
- const { query: queryConfig = {}, client: config = {} } = options ?? {}
84
- const { client: queryClient, ...queryOptions } = queryConfig
85
- const queryKey = (queryOptions && 'queryKey' in queryOptions ? toValue(queryOptions.queryKey) : undefined) ?? findPetsByTagsInfiniteQueryKey(params)
86
-
87
- const query = useInfiniteQuery(
88
- {
89
- ...findPetsByTagsInfiniteQueryOptions(headers, params, config),
90
- ...queryOptions,
91
- queryKey,
92
- } as unknown as UseInfiniteQueryOptions<
93
- FindPetsByTagsQueryResponse,
94
- ResponseErrorConfig<FindPetsByTags400>,
95
- FindPetsByTagsQueryResponse,
96
- TQueryKey,
97
- FindPetsByTagsQueryResponse
98
- >,
99
- toValue(queryClient),
100
- ) as UseInfiniteQueryReturnType<TData, ResponseErrorConfig<FindPetsByTags400>> & { queryKey: TQueryKey }
101
-
102
- query.queryKey = queryKey as TQueryKey
103
-
104
- return query
105
- }
@@ -1,104 +0,0 @@
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 { QueryKey, QueryClient, UseQueryOptions, UseQueryReturnType } from 'custom-query'
7
- import type { MaybeRefOrGetter } from 'vue'
8
- import { fetch } from './test/.kubb/fetch'
9
- import { queryOptions, useQuery } from 'custom-query'
10
- import { toValue } from 'vue'
11
-
12
- export const updatePetWithFormQueryKey = (
13
- petId: MaybeRefOrGetter<UpdatePetWithFormPathParams['petId']>,
14
- data?: MaybeRefOrGetter<UpdatePetWithFormMutationRequest>,
15
- params?: MaybeRefOrGetter<UpdatePetWithFormQueryParams>,
16
- ) => [{ url: '/pet/:petId', params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const
17
-
18
- export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>
19
-
20
- /**
21
- * @summary Updates a pet in the store with form data
22
- * {@link /pet/:petId}
23
- */
24
- export async function updatePetWithForm(
25
- petId: UpdatePetWithFormPathParams['petId'],
26
- data?: UpdatePetWithFormMutationRequest,
27
- params?: UpdatePetWithFormQueryParams,
28
- config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> & { client?: Client } = {},
29
- ) {
30
- const { client: request = fetch, ...requestConfig } = config
31
-
32
- const requestData = updatePetWithFormMutationRequest.parse(data)
33
-
34
- const res = await request<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationRequest>({
35
- method: 'POST',
36
- url: `/pet/${petId}`,
37
- params,
38
- data: requestData,
39
- ...requestConfig,
40
- })
41
- return updatePetWithFormMutationResponse.parse(res.data)
42
- }
43
-
44
- export function updatePetWithFormQueryOptions(
45
- petId: MaybeRefOrGetter<UpdatePetWithFormPathParams['petId']>,
46
- data?: MaybeRefOrGetter<UpdatePetWithFormMutationRequest>,
47
- params?: MaybeRefOrGetter<UpdatePetWithFormQueryParams>,
48
- config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> & { client?: Client } = {},
49
- ) {
50
- const queryKey = updatePetWithFormQueryKey(petId, data, params)
51
- return queryOptions<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationResponse, typeof queryKey>({
52
- enabled: !!petId,
53
- queryKey,
54
- queryFn: async ({ signal }) => {
55
- if (!config.signal) {
56
- config.signal = signal
57
- }
58
- return updatePetWithForm(toValue(petId), toValue(data), toValue(params), toValue(config))
59
- },
60
- })
61
- }
62
-
63
- /**
64
- * @summary Updates a pet in the store with form data
65
- * {@link /pet/:petId}
66
- */
67
- export function useUpdatePetWithForm<
68
- TData = UpdatePetWithFormMutationResponse,
69
- TQueryData = UpdatePetWithFormMutationResponse,
70
- TQueryKey extends QueryKey = UpdatePetWithFormQueryKey,
71
- >(
72
- petId: MaybeRefOrGetter<UpdatePetWithFormPathParams['petId']>,
73
- data?: MaybeRefOrGetter<UpdatePetWithFormMutationRequest>,
74
- params?: MaybeRefOrGetter<UpdatePetWithFormQueryParams>,
75
- options: {
76
- query?: Partial<UseQueryOptions<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, TData, TQueryData, TQueryKey>> & {
77
- client?: QueryClient
78
- }
79
- client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> & { client?: Client }
80
- } = {},
81
- ) {
82
- const { query: queryConfig = {}, client: config = {} } = options ?? {}
83
- const { client: queryClient, ...queryOptions } = queryConfig
84
- const queryKey = (queryOptions && 'queryKey' in queryOptions ? toValue(queryOptions.queryKey) : undefined) ?? updatePetWithFormQueryKey(petId, data, params)
85
-
86
- const query = useQuery(
87
- {
88
- ...updatePetWithFormQueryOptions(petId, data, params, config),
89
- ...queryOptions,
90
- queryKey,
91
- } as unknown as UseQueryOptions<
92
- UpdatePetWithFormMutationResponse,
93
- ResponseErrorConfig<UpdatePetWithForm405>,
94
- TData,
95
- UpdatePetWithFormMutationResponse,
96
- TQueryKey
97
- >,
98
- toValue(queryClient),
99
- ) as UseQueryReturnType<TData, ResponseErrorConfig<UpdatePetWithForm405>> & { queryKey: TQueryKey }
100
-
101
- query.queryKey = queryKey as TQueryKey
102
-
103
- return query
104
- }
@@ -1,77 +0,0 @@
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 { MutationObserverOptions, QueryClient } from '@tanstack/vue-query'
7
- import type { MaybeRefOrGetter } from 'vue'
8
- import { fetch } from './test/.kubb/fetch'
9
- import { useMutation } from '@tanstack/vue-query'
10
-
11
- export const updatePetWithFormMutationKey = () => [{ url: '/pet/:petId' }] as const
12
-
13
- export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
14
-
15
- /**
16
- * @summary Updates a pet in the store with form data
17
- * {@link /pet/:petId}
18
- */
19
- export async function updatePetWithForm(
20
- petId: UpdatePetWithFormPathParams['petId'],
21
- data?: UpdatePetWithFormMutationRequest,
22
- params?: UpdatePetWithFormQueryParams,
23
- config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> & { client?: Client } = {},
24
- ) {
25
- const { client: request = fetch, ...requestConfig } = config
26
-
27
- const requestData = updatePetWithFormMutationRequest.parse(data)
28
-
29
- const res = await request<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationRequest>({
30
- method: 'POST',
31
- url: `/pet/${petId}`,
32
- params,
33
- data: requestData,
34
- ...requestConfig,
35
- })
36
- return updatePetWithFormMutationResponse.parse(res.data)
37
- }
38
-
39
- /**
40
- * @summary Updates a pet in the store with form data
41
- * {@link /pet/:petId}
42
- */
43
- export function useUpdatePetWithForm<TContext>(
44
- options: {
45
- mutation?: MutationObserverOptions<
46
- UpdatePetWithFormMutationResponse,
47
- ResponseErrorConfig<UpdatePetWithForm405>,
48
- {
49
- petId: MaybeRefOrGetter<UpdatePetWithFormPathParams['petId']>
50
- data?: MaybeRefOrGetter<UpdatePetWithFormMutationRequest>
51
- params?: MaybeRefOrGetter<UpdatePetWithFormQueryParams>
52
- },
53
- TContext
54
- > & { client?: QueryClient }
55
- client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> & { client?: Client }
56
- } = {},
57
- ) {
58
- const { mutation = {}, client: config = {} } = options ?? {}
59
- const { client: queryClient, ...mutationOptions } = mutation
60
- const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
61
-
62
- return useMutation<
63
- UpdatePetWithFormMutationResponse,
64
- ResponseErrorConfig<UpdatePetWithForm405>,
65
- { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams },
66
- TContext
67
- >(
68
- {
69
- mutationFn: async ({ petId, data, params }) => {
70
- return updatePetWithForm(petId, data, params, config)
71
- },
72
- mutationKey,
73
- ...mutationOptions,
74
- },
75
- queryClient,
76
- )
77
- }
@@ -1,77 +0,0 @@
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 { MutationObserverOptions, QueryClient } from '@tanstack/vue-query'
7
- import type { MaybeRefOrGetter } from 'vue'
8
- import { fetch } from './test/.kubb/fetch'
9
- import { useMutation } from '@tanstack/vue-query'
10
-
11
- export const updatePetWithFormMutationKey = () => [{ url: '/pet/:petId' }] as const
12
-
13
- export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
14
-
15
- /**
16
- * @summary Updates a pet in the store with form data
17
- * {@link /pet/:petId}
18
- */
19
- export async function updatePetWithForm(
20
- { petId }: { petId: UpdatePetWithFormPathParams['petId'] },
21
- data?: UpdatePetWithFormMutationRequest,
22
- params?: UpdatePetWithFormQueryParams,
23
- config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> & { client?: Client } = {},
24
- ) {
25
- const { client: request = fetch, ...requestConfig } = config
26
-
27
- const requestData = updatePetWithFormMutationRequest.parse(data)
28
-
29
- const res = await request<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, UpdatePetWithFormMutationRequest>({
30
- method: 'POST',
31
- url: `/pet/${petId}`,
32
- params,
33
- data: requestData,
34
- ...requestConfig,
35
- })
36
- return updatePetWithFormMutationResponse.parse(res.data)
37
- }
38
-
39
- /**
40
- * @summary Updates a pet in the store with form data
41
- * {@link /pet/:petId}
42
- */
43
- export function useUpdatePetWithForm<TContext>(
44
- options: {
45
- mutation?: MutationObserverOptions<
46
- UpdatePetWithFormMutationResponse,
47
- ResponseErrorConfig<UpdatePetWithForm405>,
48
- {
49
- petId: MaybeRefOrGetter<UpdatePetWithFormPathParams['petId']>
50
- data?: MaybeRefOrGetter<UpdatePetWithFormMutationRequest>
51
- params?: MaybeRefOrGetter<UpdatePetWithFormQueryParams>
52
- },
53
- TContext
54
- > & { client?: QueryClient }
55
- client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> & { client?: Client }
56
- } = {},
57
- ) {
58
- const { mutation = {}, client: config = {} } = options ?? {}
59
- const { client: queryClient, ...mutationOptions } = mutation
60
- const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
61
-
62
- return useMutation<
63
- UpdatePetWithFormMutationResponse,
64
- ResponseErrorConfig<UpdatePetWithForm405>,
65
- { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams },
66
- TContext
67
- >(
68
- {
69
- mutationFn: async ({ petId, data, params }) => {
70
- return updatePetWithForm({ petId }, data, params, config)
71
- },
72
- mutationKey,
73
- ...mutationOptions,
74
- },
75
- queryClient,
76
- )
77
- }