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