@kubb/plugin-vue-query 0.0.0-canary-20241213202051 → 0.0.0-canary-20241213215524
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/package.json +11 -11
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +55 -36
- package/src/generators/__snapshots__/clientGetImportPath.ts +55 -36
- package/src/generators/__snapshots__/clientPostImportPath.ts +51 -33
- package/src/generators/__snapshots__/findByTags.ts +55 -36
- package/src/generators/__snapshots__/findByTagsObject.ts +57 -46
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +55 -36
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +56 -36
- package/src/generators/__snapshots__/findByTagsWithZod.ts +55 -36
- package/src/generators/__snapshots__/findInfiniteByTags.ts +62 -41
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +62 -41
- package/src/generators/__snapshots__/postAsQuery.ts +68 -38
- package/src/generators/__snapshots__/updatePetById.ts +51 -33
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +51 -35
|
@@ -1,52 +1,82 @@
|
|
|
1
|
-
import client from
|
|
2
|
-
import type { RequestConfig } from
|
|
3
|
-
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from
|
|
4
|
-
import type { MaybeRef } from
|
|
5
|
-
import { queryOptions, useQuery } from
|
|
6
|
-
import { unref } from
|
|
1
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
2
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from 'custom-query'
|
|
4
|
+
import type { MaybeRef } from 'vue'
|
|
5
|
+
import { queryOptions, useQuery } from 'custom-query'
|
|
6
|
+
import { unref } from 'vue'
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
export const updatePetWithFormQueryKey = (
|
|
9
|
+
petId: MaybeRef<UpdatePetWithFormPathParams['petId']>,
|
|
10
|
+
data?: MaybeRef<UpdatePetWithFormMutationRequest>,
|
|
11
|
+
params?: MaybeRef<UpdatePetWithFormQueryParams>,
|
|
12
|
+
) => [{ url: '/pet/:petId', params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
/**
|
|
13
17
|
* @summary Updates a pet in the store with form data
|
|
14
18
|
* {@link /pet/:petId}
|
|
15
19
|
*/
|
|
16
|
-
async function updatePetWithForm(
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
async function updatePetWithForm(
|
|
21
|
+
petId: UpdatePetWithFormPathParams['petId'],
|
|
22
|
+
data?: UpdatePetWithFormMutationRequest,
|
|
23
|
+
params?: UpdatePetWithFormQueryParams,
|
|
24
|
+
config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
|
|
25
|
+
) {
|
|
26
|
+
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
|
|
27
|
+
method: 'POST',
|
|
28
|
+
url: `/pet/${petId}`,
|
|
29
|
+
params,
|
|
30
|
+
data,
|
|
31
|
+
...config,
|
|
32
|
+
})
|
|
33
|
+
return updatePetWithFormMutationResponse.parse(res.data)
|
|
19
34
|
}
|
|
20
35
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
36
|
+
export function updatePetWithFormQueryOptions(
|
|
37
|
+
petId: MaybeRef<UpdatePetWithFormPathParams['petId']>,
|
|
38
|
+
data?: MaybeRef<UpdatePetWithFormMutationRequest>,
|
|
39
|
+
params?: MaybeRef<UpdatePetWithFormQueryParams>,
|
|
40
|
+
config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
|
|
41
|
+
) {
|
|
42
|
+
const queryKey = updatePetWithFormQueryKey(petId, data, params)
|
|
43
|
+
return queryOptions({
|
|
44
|
+
enabled: !!petId,
|
|
45
|
+
queryKey,
|
|
46
|
+
queryFn: async ({ signal }) => {
|
|
47
|
+
config.signal = signal
|
|
48
|
+
return updatePetWithForm(unref(petId), unref(data), unref(params), unref(config))
|
|
49
|
+
},
|
|
50
|
+
})
|
|
31
51
|
}
|
|
32
52
|
|
|
33
|
-
|
|
53
|
+
/**
|
|
34
54
|
* @summary Updates a pet in the store with form data
|
|
35
55
|
* {@link /pet/:petId}
|
|
36
56
|
*/
|
|
37
|
-
export function useUpdatePetWithForm<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
export function useUpdatePetWithForm<
|
|
58
|
+
TData = UpdatePetWithFormMutationResponse,
|
|
59
|
+
TQueryData = UpdatePetWithFormMutationResponse,
|
|
60
|
+
TQueryKey extends QueryKey = UpdatePetWithFormQueryKey,
|
|
61
|
+
>(
|
|
62
|
+
petId: MaybeRef<UpdatePetWithFormPathParams['petId']>,
|
|
63
|
+
data?: MaybeRef<UpdatePetWithFormMutationRequest>,
|
|
64
|
+
params?: MaybeRef<UpdatePetWithFormQueryParams>,
|
|
65
|
+
options: {
|
|
66
|
+
query?: Partial<QueryObserverOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, TData, TQueryData, TQueryKey>>
|
|
67
|
+
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
|
|
68
|
+
} = {},
|
|
69
|
+
) {
|
|
70
|
+
const { query: queryOptions, client: config = {} } = options ?? {}
|
|
71
|
+
const queryKey = queryOptions?.queryKey ?? updatePetWithFormQueryKey(petId, data, params)
|
|
72
|
+
|
|
73
|
+
const query = useQuery({
|
|
74
|
+
...(updatePetWithFormQueryOptions(petId, data, params, config) as unknown as QueryObserverOptions),
|
|
75
|
+
queryKey: queryKey as QueryKey,
|
|
76
|
+
...(queryOptions as unknown as Omit<QueryObserverOptions, 'queryKey'>),
|
|
77
|
+
}) as UseQueryReturnType<TData, UpdatePetWithForm405> & { queryKey: TQueryKey }
|
|
78
|
+
|
|
79
|
+
query.queryKey = queryKey as TQueryKey
|
|
80
|
+
|
|
81
|
+
return query
|
|
52
82
|
}
|
|
@@ -1,45 +1,63 @@
|
|
|
1
|
-
import client from
|
|
2
|
-
import type { RequestConfig } from
|
|
3
|
-
import type { MutationObserverOptions } from
|
|
4
|
-
import type { MaybeRef } from
|
|
5
|
-
import { useMutation } from
|
|
1
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
2
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { MutationObserverOptions } from '@tanstack/vue-query'
|
|
4
|
+
import type { MaybeRef } from 'vue'
|
|
5
|
+
import { useMutation } from '@tanstack/vue-query'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
12
|
* @summary Updates a pet in the store with form data
|
|
13
13
|
* {@link /pet/:petId}
|
|
14
14
|
*/
|
|
15
|
-
async function updatePetWithForm(
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
async function updatePetWithForm(
|
|
16
|
+
petId: UpdatePetWithFormPathParams['petId'],
|
|
17
|
+
data?: UpdatePetWithFormMutationRequest,
|
|
18
|
+
params?: UpdatePetWithFormQueryParams,
|
|
19
|
+
config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
|
|
20
|
+
) {
|
|
21
|
+
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
|
|
22
|
+
method: 'POST',
|
|
23
|
+
url: `/pet/${petId}`,
|
|
24
|
+
params,
|
|
25
|
+
data,
|
|
26
|
+
...config,
|
|
27
|
+
})
|
|
28
|
+
return updatePetWithFormMutationResponse.parse(res.data)
|
|
18
29
|
}
|
|
19
30
|
|
|
20
|
-
|
|
31
|
+
/**
|
|
21
32
|
* @summary Updates a pet in the store with form data
|
|
22
33
|
* {@link /pet/:petId}
|
|
23
34
|
*/
|
|
24
|
-
export function useUpdatePetWithForm(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
35
|
+
export function useUpdatePetWithForm(
|
|
36
|
+
options: {
|
|
37
|
+
mutation?: MutationObserverOptions<
|
|
38
|
+
UpdatePetWithFormMutationResponse,
|
|
39
|
+
UpdatePetWithForm405,
|
|
40
|
+
{
|
|
41
|
+
petId: MaybeRef<UpdatePetWithFormPathParams['petId']>
|
|
42
|
+
data?: MaybeRef<UpdatePetWithFormMutationRequest>
|
|
43
|
+
params?: MaybeRef<UpdatePetWithFormQueryParams>
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
|
|
47
|
+
} = {},
|
|
48
|
+
) {
|
|
49
|
+
const { mutation: mutationOptions, client: config = {} } = options ?? {}
|
|
50
|
+
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
|
|
51
|
+
|
|
52
|
+
return useMutation<
|
|
53
|
+
UpdatePetWithFormMutationResponse,
|
|
54
|
+
UpdatePetWithForm405,
|
|
55
|
+
{ petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
|
|
56
|
+
>({
|
|
57
|
+
mutationFn: async ({ petId, data, params }) => {
|
|
58
|
+
return updatePetWithForm(petId, data, params, config)
|
|
59
|
+
},
|
|
60
|
+
mutationKey,
|
|
61
|
+
...mutationOptions,
|
|
62
|
+
})
|
|
45
63
|
}
|
|
@@ -1,47 +1,63 @@
|
|
|
1
|
-
import client from
|
|
2
|
-
import type { RequestConfig } from
|
|
3
|
-
import type { MutationObserverOptions } from
|
|
4
|
-
import type { MaybeRef } from
|
|
5
|
-
import { useMutation } from
|
|
1
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
2
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { MutationObserverOptions } from '@tanstack/vue-query'
|
|
4
|
+
import type { MaybeRef } from 'vue'
|
|
5
|
+
import { useMutation } from '@tanstack/vue-query'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
12
|
* @summary Updates a pet in the store with form data
|
|
13
13
|
* {@link /pet/:petId}
|
|
14
14
|
*/
|
|
15
|
-
async function updatePetWithForm(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
async function updatePetWithForm(
|
|
16
|
+
{ petId }: { petId: UpdatePetWithFormPathParams['petId'] },
|
|
17
|
+
data?: UpdatePetWithFormMutationRequest,
|
|
18
|
+
params?: UpdatePetWithFormQueryParams,
|
|
19
|
+
config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
|
|
20
|
+
) {
|
|
21
|
+
const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
|
|
22
|
+
method: 'POST',
|
|
23
|
+
url: `/pet/${petId}`,
|
|
24
|
+
params,
|
|
25
|
+
data,
|
|
26
|
+
...config,
|
|
27
|
+
})
|
|
28
|
+
return updatePetWithFormMutationResponse.parse(res.data)
|
|
20
29
|
}
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
/**
|
|
23
32
|
* @summary Updates a pet in the store with form data
|
|
24
33
|
* {@link /pet/:petId}
|
|
25
34
|
*/
|
|
26
|
-
export function useUpdatePetWithForm(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
35
|
+
export function useUpdatePetWithForm(
|
|
36
|
+
options: {
|
|
37
|
+
mutation?: MutationObserverOptions<
|
|
38
|
+
UpdatePetWithFormMutationResponse,
|
|
39
|
+
UpdatePetWithForm405,
|
|
40
|
+
{
|
|
41
|
+
petId: MaybeRef<UpdatePetWithFormPathParams['petId']>
|
|
42
|
+
data?: MaybeRef<UpdatePetWithFormMutationRequest>
|
|
43
|
+
params?: MaybeRef<UpdatePetWithFormQueryParams>
|
|
44
|
+
}
|
|
45
|
+
>
|
|
46
|
+
client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
|
|
47
|
+
} = {},
|
|
48
|
+
) {
|
|
49
|
+
const { mutation: mutationOptions, client: config = {} } = options ?? {}
|
|
50
|
+
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
|
|
51
|
+
|
|
52
|
+
return useMutation<
|
|
53
|
+
UpdatePetWithFormMutationResponse,
|
|
54
|
+
UpdatePetWithForm405,
|
|
55
|
+
{ petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
|
|
56
|
+
>({
|
|
57
|
+
mutationFn: async ({ petId, data, params }) => {
|
|
58
|
+
return updatePetWithForm({ petId }, data, params, config)
|
|
59
|
+
},
|
|
60
|
+
mutationKey,
|
|
61
|
+
...mutationOptions,
|
|
62
|
+
})
|
|
47
63
|
}
|