@kubb/plugin-vue-query 3.0.0-alpha.26 → 3.0.0-alpha.29
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/{chunk-N4EZ7N3M.cjs → chunk-7W4STCTH.cjs} +26 -19
- package/dist/chunk-7W4STCTH.cjs.map +1 -0
- package/dist/{chunk-WOSAUHMD.cjs → chunk-FSQSBTBH.cjs} +50 -35
- package/dist/chunk-FSQSBTBH.cjs.map +1 -0
- package/dist/{chunk-ECTNESSL.js → chunk-JI524ZTZ.js} +13 -6
- package/dist/chunk-JI524ZTZ.js.map +1 -0
- package/dist/{chunk-GL6WLGO3.js → chunk-V6YETPDM.js} +50 -35
- package/dist/chunk-V6YETPDM.js.map +1 -0
- package/dist/components.cjs +8 -8
- package/dist/components.js +1 -1
- package/dist/generators.cjs +5 -5
- package/dist/generators.js +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.js +2 -2
- package/package.json +11 -11
- package/src/components/InfiniteQuery.tsx +2 -2
- package/src/components/InfiniteQueryOptions.tsx +10 -1
- package/src/components/Mutation.tsx +42 -33
- package/src/components/Query.tsx +2 -2
- package/src/components/QueryOptions.tsx +10 -1
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +5 -4
- package/src/generators/__snapshots__/clientGetImportPath.ts +5 -4
- package/src/generators/__snapshots__/clientPostImportPath.ts +9 -12
- package/src/generators/__snapshots__/findByTags.ts +5 -4
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +5 -4
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +5 -4
- package/src/generators/__snapshots__/findByTagsWithZod.ts +5 -4
- package/src/generators/__snapshots__/findInfiniteByTags.ts +5 -4
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +5 -4
- package/src/generators/__snapshots__/postAsQuery.ts +6 -4
- package/src/generators/__snapshots__/updatePetById.ts +9 -12
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +9 -12
- package/src/generators/infiniteQueryGenerator.tsx +5 -1
- package/src/generators/mutationGenerator.tsx +1 -1
- package/src/generators/queryGenerator.tsx +1 -1
- package/dist/chunk-ECTNESSL.js.map +0 -1
- package/dist/chunk-GL6WLGO3.js.map +0 -1
- package/dist/chunk-N4EZ7N3M.cjs.map +0 -1
- package/dist/chunk-WOSAUHMD.cjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-vue-query",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.29",
|
|
4
4
|
"description": "Generator vue-query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"faker",
|
|
@@ -62,24 +62,24 @@
|
|
|
62
62
|
"!/**/__tests__/**"
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@kubb/core": "3.0.0-alpha.
|
|
66
|
-
"@kubb/fs": "3.0.0-alpha.
|
|
67
|
-
"@kubb/oas": "3.0.0-alpha.
|
|
68
|
-
"@kubb/plugin-oas": "3.0.0-alpha.
|
|
69
|
-
"@kubb/plugin-ts": "3.0.0-alpha.
|
|
70
|
-
"@kubb/plugin-zod": "3.0.0-alpha.
|
|
71
|
-
"@kubb/react": "3.0.0-alpha.
|
|
65
|
+
"@kubb/core": "3.0.0-alpha.29",
|
|
66
|
+
"@kubb/fs": "3.0.0-alpha.29",
|
|
67
|
+
"@kubb/oas": "3.0.0-alpha.29",
|
|
68
|
+
"@kubb/plugin-oas": "3.0.0-alpha.29",
|
|
69
|
+
"@kubb/plugin-ts": "3.0.0-alpha.29",
|
|
70
|
+
"@kubb/plugin-zod": "3.0.0-alpha.29",
|
|
71
|
+
"@kubb/react": "3.0.0-alpha.29"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@types/react": "^18.3.9",
|
|
75
75
|
"react": "^18.3.1",
|
|
76
76
|
"tsup": "^8.3.0",
|
|
77
77
|
"typescript": "^5.6.2",
|
|
78
|
-
"@kubb/config-ts": "3.0.0-alpha.
|
|
79
|
-
"@kubb/config-tsup": "3.0.0-alpha.
|
|
78
|
+
"@kubb/config-ts": "3.0.0-alpha.29",
|
|
79
|
+
"@kubb/config-tsup": "3.0.0-alpha.29"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
|
-
"@kubb/react": "3.0.0-alpha.
|
|
82
|
+
"@kubb/react": "3.0.0-alpha.29"
|
|
83
83
|
},
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": ">=20"
|
|
@@ -85,7 +85,7 @@ export function InfiniteQuery({
|
|
|
85
85
|
operation,
|
|
86
86
|
}: Props): ReactNode {
|
|
87
87
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
88
|
-
const returnType = '
|
|
88
|
+
const returnType = `UseInfiniteQueryReturnType<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'].join(', ')}> & { queryKey: TQueryKey }`
|
|
89
89
|
const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
|
|
90
90
|
|
|
91
91
|
const queryKeyParams = QueryKey.getParams({
|
|
@@ -121,7 +121,7 @@ export function InfiniteQuery({
|
|
|
121
121
|
|
|
122
122
|
const query = useInfiniteQuery({
|
|
123
123
|
...${queryOptions},
|
|
124
|
-
queryKey,
|
|
124
|
+
queryKey: queryKey as QueryKey,
|
|
125
125
|
...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
|
|
126
126
|
}) as ${returnType}
|
|
127
127
|
|
|
@@ -107,14 +107,23 @@ export function InfiniteQueryOptions({
|
|
|
107
107
|
}`
|
|
108
108
|
: ''
|
|
109
109
|
|
|
110
|
+
const enabled = Object.entries(queryKeyParams.flatParams)
|
|
111
|
+
.map(([key, item]) => (item && !item.optional ? key : undefined))
|
|
112
|
+
.filter(Boolean)
|
|
113
|
+
.join('&& ')
|
|
114
|
+
|
|
115
|
+
const enabledText = enabled ? `enabled: !!(${enabled})` : ''
|
|
116
|
+
|
|
110
117
|
return (
|
|
111
118
|
<File.Source name={name} isExportable isIndexable>
|
|
112
119
|
<Function name={name} export params={params.toConstructor()}>
|
|
113
120
|
{`
|
|
114
121
|
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
115
122
|
return infiniteQueryOptions({
|
|
123
|
+
${enabledText}
|
|
116
124
|
queryKey,
|
|
117
|
-
queryFn: async ({ pageParam }) => {
|
|
125
|
+
queryFn: async ({ signal, pageParam }) => {
|
|
126
|
+
config.signal = signal
|
|
118
127
|
${infiniteOverrideParams}
|
|
119
128
|
return ${clientName}(${clientParams.toCall()})
|
|
120
129
|
},
|
|
@@ -4,6 +4,7 @@ import { type Operation, isOptional } from '@kubb/oas'
|
|
|
4
4
|
import { Client } from '@kubb/plugin-client/components'
|
|
5
5
|
import type { OperationSchemas } from '@kubb/plugin-oas'
|
|
6
6
|
import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
|
|
7
|
+
import type { Params } from '@kubb/react/types'
|
|
7
8
|
import type { ReactNode } from 'react'
|
|
8
9
|
import type { PluginVueQuery } from '../types.ts'
|
|
9
10
|
import { MutationKey } from './MutationKey.tsx'
|
|
@@ -30,7 +31,7 @@ type GetParamsProps = {
|
|
|
30
31
|
|
|
31
32
|
function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
32
33
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
33
|
-
const
|
|
34
|
+
const mutationParams = FunctionParams.factory({
|
|
34
35
|
...getPathParams(typeSchemas.pathParams, {
|
|
35
36
|
typed: true,
|
|
36
37
|
override(item) {
|
|
@@ -59,7 +60,7 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
|
59
60
|
}
|
|
60
61
|
: undefined,
|
|
61
62
|
})
|
|
62
|
-
const TRequest =
|
|
63
|
+
const TRequest = mutationParams.toConstructor({ valueAsType: true })
|
|
63
64
|
|
|
64
65
|
return FunctionParams.factory({
|
|
65
66
|
options: {
|
|
@@ -75,8 +76,6 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
|
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
export function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props): ReactNode {
|
|
78
|
-
const returnType = 'ReturnType<typeof mutation> & { mutationKey: MutationKey }'
|
|
79
|
-
|
|
80
79
|
const mutationKeyParams = MutationKey.getParams({
|
|
81
80
|
pathParamsType,
|
|
82
81
|
typeSchemas,
|
|
@@ -94,35 +93,48 @@ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typ
|
|
|
94
93
|
})
|
|
95
94
|
|
|
96
95
|
const mutationParams = FunctionParams.factory({
|
|
96
|
+
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
97
|
+
data: typeSchemas.request?.name
|
|
98
|
+
? {
|
|
99
|
+
type: typeSchemas.request?.name,
|
|
100
|
+
optional: isOptional(typeSchemas.request?.schema),
|
|
101
|
+
}
|
|
102
|
+
: undefined,
|
|
103
|
+
params: typeSchemas.queryParams?.name
|
|
104
|
+
? {
|
|
105
|
+
type: typeSchemas.queryParams?.name,
|
|
106
|
+
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
107
|
+
}
|
|
108
|
+
: undefined,
|
|
109
|
+
headers: typeSchemas.headerParams?.name
|
|
110
|
+
? {
|
|
111
|
+
type: typeSchemas.headerParams?.name,
|
|
112
|
+
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
113
|
+
}
|
|
114
|
+
: undefined,
|
|
115
|
+
})
|
|
116
|
+
const dataParams = FunctionParams.factory({
|
|
97
117
|
data: {
|
|
98
118
|
// No use of pathParams because useMutation can only take one argument in object form,
|
|
99
119
|
// see https://tanstack.com/query/latest/docs/framework/react/reference/useMutation#usemutation
|
|
100
120
|
mode: 'object',
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
? {
|
|
112
|
-
type: typeSchemas.queryParams?.name,
|
|
113
|
-
optional: isOptional(typeSchemas.queryParams?.schema),
|
|
114
|
-
}
|
|
115
|
-
: undefined,
|
|
116
|
-
headers: typeSchemas.headerParams?.name
|
|
117
|
-
? {
|
|
118
|
-
type: typeSchemas.headerParams?.name,
|
|
119
|
-
optional: isOptional(typeSchemas.headerParams?.schema),
|
|
120
|
-
}
|
|
121
|
-
: undefined,
|
|
122
|
-
},
|
|
121
|
+
children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
|
|
122
|
+
if (value) {
|
|
123
|
+
acc[key] = {
|
|
124
|
+
...value,
|
|
125
|
+
type: undefined,
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return acc
|
|
130
|
+
}, {} as Params),
|
|
123
131
|
},
|
|
124
132
|
})
|
|
125
133
|
|
|
134
|
+
const TRequest = mutationParams.toConstructor({ valueAsType: true })
|
|
135
|
+
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
136
|
+
const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `{${TRequest}}`].join(', ')
|
|
137
|
+
|
|
126
138
|
return (
|
|
127
139
|
<File.Source name={name} isExportable isIndexable>
|
|
128
140
|
<Function
|
|
@@ -137,16 +149,13 @@ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typ
|
|
|
137
149
|
const { mutation: mutationOptions, client: config = {} } = options ?? {}
|
|
138
150
|
const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
139
151
|
|
|
140
|
-
|
|
141
|
-
mutationFn: async(${
|
|
152
|
+
return useMutation<${generics}>({
|
|
153
|
+
mutationFn: async(${dataParams.toConstructor()}) => {
|
|
142
154
|
return ${clientName}(${clientParams.toCall()})
|
|
143
155
|
},
|
|
156
|
+
mutationKey,
|
|
144
157
|
...mutationOptions
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
mutation.mutationKey = mutationKey as MutationKey
|
|
148
|
-
|
|
149
|
-
return mutation
|
|
158
|
+
})
|
|
150
159
|
`}
|
|
151
160
|
</Function>
|
|
152
161
|
</File.Source>
|
package/src/components/Query.tsx
CHANGED
|
@@ -76,7 +76,7 @@ function getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsPro
|
|
|
76
76
|
|
|
77
77
|
export function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation }: Props): ReactNode {
|
|
78
78
|
const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
|
|
79
|
-
const returnType = '
|
|
79
|
+
const returnType = `UseQueryReturnType<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'].join(', ')}> & { queryKey: TQueryKey }`
|
|
80
80
|
const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
|
|
81
81
|
|
|
82
82
|
const queryKeyParams = QueryKey.getParams({
|
|
@@ -112,7 +112,7 @@ export function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
|
|
|
112
112
|
|
|
113
113
|
const query = useQuery({
|
|
114
114
|
...${queryOptions},
|
|
115
|
-
queryKey,
|
|
115
|
+
queryKey: queryKey as QueryKey,
|
|
116
116
|
...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
|
|
117
117
|
}) as ${returnType}
|
|
118
118
|
|
|
@@ -72,14 +72,23 @@ export function QueryOptions({ name, clientName, typeSchemas, pathParamsType, qu
|
|
|
72
72
|
typeSchemas,
|
|
73
73
|
})
|
|
74
74
|
|
|
75
|
+
const enabled = Object.entries(queryKeyParams.flatParams)
|
|
76
|
+
.map(([key, item]) => (item && !item.optional ? key : undefined))
|
|
77
|
+
.filter(Boolean)
|
|
78
|
+
.join('&& ')
|
|
79
|
+
|
|
80
|
+
const enabledText = enabled ? `enabled: !!(${enabled})` : ''
|
|
81
|
+
|
|
75
82
|
return (
|
|
76
83
|
<File.Source name={name} isExportable isIndexable>
|
|
77
84
|
<Function name={name} export params={params.toConstructor()}>
|
|
78
85
|
{`
|
|
79
86
|
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
80
87
|
return queryOptions({
|
|
88
|
+
${enabledText}
|
|
81
89
|
queryKey,
|
|
82
|
-
queryFn: async () => {
|
|
90
|
+
queryFn: async ({ signal }) => {
|
|
91
|
+
config.signal = signal
|
|
83
92
|
return ${clientName}(${clientParams.toCall({
|
|
84
93
|
transformName(name) {
|
|
85
94
|
return `unref(${name})`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { QueryKey, QueryObserverOptions } from "@tanstack/react-query";
|
|
3
|
+
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useQuery, queryOptions } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
@@ -23,7 +23,8 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
|
|
|
23
23
|
const queryKey = findPetsByTagsQueryKey(params);
|
|
24
24
|
return queryOptions({
|
|
25
25
|
queryKey,
|
|
26
|
-
queryFn: async () => {
|
|
26
|
+
queryFn: async ({ signal }) => {
|
|
27
|
+
config.signal = signal;
|
|
27
28
|
return findPetsByTags(unref(headers), unref(params), unref(config));
|
|
28
29
|
},
|
|
29
30
|
});
|
|
@@ -42,9 +43,9 @@ export function useFindPetsByTags<TData = ResponseConfig<FindPetsByTagsQueryResp
|
|
|
42
43
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
|
|
43
44
|
const query = useQuery({
|
|
44
45
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
|
|
45
|
-
queryKey,
|
|
46
|
+
queryKey: queryKey as QueryKey,
|
|
46
47
|
...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
|
|
47
|
-
}) as
|
|
48
|
+
}) as UseQueryReturnType<TData, FindPetsByTags400> & {
|
|
48
49
|
queryKey: TQueryKey;
|
|
49
50
|
};
|
|
50
51
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import client from "axios";
|
|
2
|
-
import type { QueryKey, QueryObserverOptions } from "@tanstack/react-query";
|
|
2
|
+
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
3
3
|
import type { RequestConfig } from "axios";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useQuery, queryOptions } from "@tanstack/react-query";
|
|
@@ -23,7 +23,8 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
|
|
|
23
23
|
const queryKey = findPetsByTagsQueryKey(params);
|
|
24
24
|
return queryOptions({
|
|
25
25
|
queryKey,
|
|
26
|
-
queryFn: async () => {
|
|
26
|
+
queryFn: async ({ signal }) => {
|
|
27
|
+
config.signal = signal;
|
|
27
28
|
return findPetsByTags(unref(headers), unref(params), unref(config));
|
|
28
29
|
},
|
|
29
30
|
});
|
|
@@ -42,9 +43,9 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
|
|
|
42
43
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
|
|
43
44
|
const query = useQuery({
|
|
44
45
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
|
|
45
|
-
queryKey,
|
|
46
|
+
queryKey: queryKey as QueryKey,
|
|
46
47
|
...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
|
|
47
|
-
}) as
|
|
48
|
+
}) as UseQueryReturnType<TData, FindPetsByTags400> & {
|
|
48
49
|
queryKey: TQueryKey;
|
|
49
50
|
};
|
|
50
51
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import client from "axios";
|
|
2
|
-
import type { MutationObserverOptions
|
|
2
|
+
import type { MutationObserverOptions } from "@tanstack/react-query";
|
|
3
3
|
import type { RequestConfig } from "axios";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useMutation } from "@tanstack/react-query";
|
|
@@ -31,18 +31,15 @@ export function useUpdatePetWithForm(options: {
|
|
|
31
31
|
} = {}) {
|
|
32
32
|
const { mutation: mutationOptions, client: config = {} } = options ?? {};
|
|
33
33
|
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}) => {
|
|
34
|
+
return useMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
|
|
35
|
+
petId: UpdatePetWithFormPathParams["petId"];
|
|
36
|
+
data?: UpdatePetWithFormMutationRequest;
|
|
37
|
+
params?: UpdatePetWithFormQueryParams;
|
|
38
|
+
}>({
|
|
39
|
+
mutationFn: async ({ petId, data, params }) => {
|
|
40
40
|
return updatePetWithForm(petId, data, params, config);
|
|
41
41
|
},
|
|
42
|
+
mutationKey,
|
|
42
43
|
...mutationOptions
|
|
43
|
-
})
|
|
44
|
-
mutationKey: MutationKey;
|
|
45
|
-
};
|
|
46
|
-
mutation.mutationKey = mutationKey as MutationKey;
|
|
47
|
-
return mutation;
|
|
44
|
+
});
|
|
48
45
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { QueryKey, QueryObserverOptions } from "@tanstack/react-query";
|
|
3
|
+
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useQuery, queryOptions } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
@@ -23,7 +23,8 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
|
|
|
23
23
|
const queryKey = findPetsByTagsQueryKey(params);
|
|
24
24
|
return queryOptions({
|
|
25
25
|
queryKey,
|
|
26
|
-
queryFn: async () => {
|
|
26
|
+
queryFn: async ({ signal }) => {
|
|
27
|
+
config.signal = signal;
|
|
27
28
|
return findPetsByTags(unref(headers), unref(params), unref(config));
|
|
28
29
|
},
|
|
29
30
|
});
|
|
@@ -42,9 +43,9 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
|
|
|
42
43
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
|
|
43
44
|
const query = useQuery({
|
|
44
45
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
|
|
45
|
-
queryKey,
|
|
46
|
+
queryKey: queryKey as QueryKey,
|
|
46
47
|
...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
|
|
47
|
-
}) as
|
|
48
|
+
}) as UseQueryReturnType<TData, FindPetsByTags400> & {
|
|
48
49
|
queryKey: TQueryKey;
|
|
49
50
|
};
|
|
50
51
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { QueryKey, QueryObserverOptions } from "@tanstack/react-query";
|
|
3
|
+
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useQuery, queryOptions } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
@@ -23,7 +23,8 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
|
|
|
23
23
|
const queryKey = findPetsByTagsQueryKey(params);
|
|
24
24
|
return queryOptions({
|
|
25
25
|
queryKey,
|
|
26
|
-
queryFn: async () => {
|
|
26
|
+
queryFn: async ({ signal }) => {
|
|
27
|
+
config.signal = signal;
|
|
27
28
|
return findPetsByTags(unref(headers), unref(params), unref(config));
|
|
28
29
|
},
|
|
29
30
|
});
|
|
@@ -42,9 +43,9 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
|
|
|
42
43
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
|
|
43
44
|
const query = useQuery({
|
|
44
45
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
|
|
45
|
-
queryKey,
|
|
46
|
+
queryKey: queryKey as QueryKey,
|
|
46
47
|
...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
|
|
47
|
-
}) as
|
|
48
|
+
}) as UseQueryReturnType<TData, FindPetsByTags400> & {
|
|
48
49
|
queryKey: TQueryKey;
|
|
49
50
|
};
|
|
50
51
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { QueryKey, QueryObserverOptions } from "@tanstack/react-query";
|
|
3
|
+
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useQuery, queryOptions } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
@@ -23,7 +23,8 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
|
|
|
23
23
|
const queryKey = findPetsByTagsQueryKey(params);
|
|
24
24
|
return queryOptions({
|
|
25
25
|
queryKey,
|
|
26
|
-
queryFn: async () => {
|
|
26
|
+
queryFn: async ({ signal }) => {
|
|
27
|
+
config.signal = signal;
|
|
27
28
|
return findPetsByTags(unref(headers), unref(params), unref(config));
|
|
28
29
|
},
|
|
29
30
|
});
|
|
@@ -42,9 +43,9 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
|
|
|
42
43
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
|
|
43
44
|
const query = useQuery({
|
|
44
45
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
|
|
45
|
-
queryKey,
|
|
46
|
+
queryKey: queryKey as QueryKey,
|
|
46
47
|
...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
|
|
47
|
-
}) as
|
|
48
|
+
}) as UseQueryReturnType<TData, FindPetsByTags400> & {
|
|
48
49
|
queryKey: TQueryKey;
|
|
49
50
|
};
|
|
50
51
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { QueryKey, QueryObserverOptions } from "@tanstack/react-query";
|
|
3
|
+
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useQuery, queryOptions } from "@tanstack/react-query";
|
|
6
6
|
import { unref } from "vue";
|
|
@@ -23,7 +23,8 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
|
|
|
23
23
|
const queryKey = findPetsByTagsQueryKey(params);
|
|
24
24
|
return queryOptions({
|
|
25
25
|
queryKey,
|
|
26
|
-
queryFn: async () => {
|
|
26
|
+
queryFn: async ({ signal }) => {
|
|
27
|
+
config.signal = signal;
|
|
27
28
|
return findPetsByTags(unref(headers), unref(params), unref(config));
|
|
28
29
|
},
|
|
29
30
|
});
|
|
@@ -42,9 +43,9 @@ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryDat
|
|
|
42
43
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
|
|
43
44
|
const query = useQuery({
|
|
44
45
|
...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
|
|
45
|
-
queryKey,
|
|
46
|
+
queryKey: queryKey as QueryKey,
|
|
46
47
|
...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
|
|
47
|
-
}) as
|
|
48
|
+
}) as UseQueryReturnType<TData, FindPetsByTags400> & {
|
|
48
49
|
queryKey: TQueryKey;
|
|
49
50
|
};
|
|
50
51
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { QueryKey, InfiniteQueryObserverOptions } from "@tanstack/react-query";
|
|
3
|
+
import type { QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useInfiniteQuery, infiniteQueryOptions } from "@tanstack/react-query";
|
|
6
6
|
|
|
@@ -22,7 +22,8 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
|
|
|
22
22
|
const queryKey = findPetsByTagsInfiniteQueryKey(params);
|
|
23
23
|
return infiniteQueryOptions({
|
|
24
24
|
queryKey,
|
|
25
|
-
queryFn: async ({ pageParam }) => {
|
|
25
|
+
queryFn: async ({ signal, pageParam }) => {
|
|
26
|
+
config.signal = signal;
|
|
26
27
|
if (params) {
|
|
27
28
|
params["pageSize"] = pageParam as unknown as FindPetsByTagsQueryParams["pageSize"];
|
|
28
29
|
}
|
|
@@ -47,9 +48,9 @@ export function useFindPetsByTagsInfinite<TData = FindPetsByTagsQueryResponse, T
|
|
|
47
48
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params);
|
|
48
49
|
const query = useInfiniteQuery({
|
|
49
50
|
...findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions,
|
|
50
|
-
queryKey,
|
|
51
|
+
queryKey: queryKey as QueryKey,
|
|
51
52
|
...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
|
|
52
|
-
}) as
|
|
53
|
+
}) as UseInfiniteQueryReturnType<TData, FindPetsByTags400> & {
|
|
53
54
|
queryKey: TQueryKey;
|
|
54
55
|
};
|
|
55
56
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { QueryKey, InfiniteQueryObserverOptions } from "@tanstack/react-query";
|
|
3
|
+
import type { QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useInfiniteQuery, infiniteQueryOptions } from "@tanstack/react-query";
|
|
6
6
|
|
|
@@ -22,7 +22,8 @@ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: Find
|
|
|
22
22
|
const queryKey = findPetsByTagsInfiniteQueryKey(params);
|
|
23
23
|
return infiniteQueryOptions({
|
|
24
24
|
queryKey,
|
|
25
|
-
queryFn: async ({ pageParam }) => {
|
|
25
|
+
queryFn: async ({ signal, pageParam }) => {
|
|
26
|
+
config.signal = signal;
|
|
26
27
|
if (params) {
|
|
27
28
|
params["pageSize"] = pageParam as unknown as FindPetsByTagsQueryParams["pageSize"];
|
|
28
29
|
}
|
|
@@ -47,9 +48,9 @@ export function useFindPetsByTagsInfinite<TData = FindPetsByTagsQueryResponse, T
|
|
|
47
48
|
const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params);
|
|
48
49
|
const query = useInfiniteQuery({
|
|
49
50
|
...findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions,
|
|
50
|
-
queryKey,
|
|
51
|
+
queryKey: queryKey as QueryKey,
|
|
51
52
|
...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
|
|
52
|
-
}) as
|
|
53
|
+
}) as UseInfiniteQueryReturnType<TData, FindPetsByTags400> & {
|
|
53
54
|
queryKey: TQueryKey;
|
|
54
55
|
};
|
|
55
56
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { QueryKey, QueryObserverOptions } from "custom-query";
|
|
3
|
+
import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "custom-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useQuery, queryOptions } from "custom-query";
|
|
6
6
|
import { unref } from "vue";
|
|
@@ -21,8 +21,10 @@ async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], da
|
|
|
21
21
|
export function updatePetWithFormQueryOptions(petId: MaybeRef<UpdatePetWithFormPathParams["petId"]>, data?: MaybeRef<UpdatePetWithFormMutationRequest>, params?: MaybeRef<UpdatePetWithFormQueryParams>, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
|
|
22
22
|
const queryKey = updatePetWithFormQueryKey(petId, data, params);
|
|
23
23
|
return queryOptions({
|
|
24
|
+
enabled: !!(petId),
|
|
24
25
|
queryKey,
|
|
25
|
-
queryFn: async () => {
|
|
26
|
+
queryFn: async ({ signal }) => {
|
|
27
|
+
config.signal = signal;
|
|
26
28
|
return updatePetWithForm(unref(petId), unref(data), unref(params), unref(config));
|
|
27
29
|
},
|
|
28
30
|
});
|
|
@@ -40,9 +42,9 @@ export function useUpdatePetWithForm<TData = UpdatePetWithFormMutationResponse,
|
|
|
40
42
|
const queryKey = queryOptions?.queryKey ?? updatePetWithFormQueryKey(petId, data, params);
|
|
41
43
|
const query = useQuery({
|
|
42
44
|
...updatePetWithFormQueryOptions(petId, data, params, config) as unknown as QueryObserverOptions,
|
|
43
|
-
queryKey,
|
|
45
|
+
queryKey: queryKey as QueryKey,
|
|
44
46
|
...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
|
|
45
|
-
}) as
|
|
47
|
+
}) as UseQueryReturnType<TData, UpdatePetWithForm405> & {
|
|
46
48
|
queryKey: TQueryKey;
|
|
47
49
|
};
|
|
48
50
|
query.queryKey = queryKey as TQueryKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { MutationObserverOptions
|
|
3
|
+
import type { MutationObserverOptions } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useMutation } from "@tanstack/react-query";
|
|
6
6
|
|
|
@@ -31,18 +31,15 @@ export function useUpdatePetWithForm(options: {
|
|
|
31
31
|
} = {}) {
|
|
32
32
|
const { mutation: mutationOptions, client: config = {} } = options ?? {};
|
|
33
33
|
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}) => {
|
|
34
|
+
return useMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
|
|
35
|
+
petId: UpdatePetWithFormPathParams["petId"];
|
|
36
|
+
data?: UpdatePetWithFormMutationRequest;
|
|
37
|
+
params?: UpdatePetWithFormQueryParams;
|
|
38
|
+
}>({
|
|
39
|
+
mutationFn: async ({ petId, data, params }) => {
|
|
40
40
|
return updatePetWithForm(petId, data, params, config);
|
|
41
41
|
},
|
|
42
|
+
mutationKey,
|
|
42
43
|
...mutationOptions
|
|
43
|
-
})
|
|
44
|
-
mutationKey: MutationKey;
|
|
45
|
-
};
|
|
46
|
-
mutation.mutationKey = mutationKey as MutationKey;
|
|
47
|
-
return mutation;
|
|
44
|
+
});
|
|
48
45
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import client from "@kubb/plugin-client/client";
|
|
2
2
|
import type { RequestConfig } from "@kubb/plugin-client/client";
|
|
3
|
-
import type { MutationObserverOptions
|
|
3
|
+
import type { MutationObserverOptions } from "@tanstack/react-query";
|
|
4
4
|
import type { MaybeRef } from "vue";
|
|
5
5
|
import { useMutation } from "@tanstack/react-query";
|
|
6
6
|
|
|
@@ -33,18 +33,15 @@ export function useUpdatePetWithForm(options: {
|
|
|
33
33
|
} = {}) {
|
|
34
34
|
const { mutation: mutationOptions, client: config = {} } = options ?? {};
|
|
35
35
|
const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}) => {
|
|
36
|
+
return useMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
|
|
37
|
+
petId: UpdatePetWithFormPathParams["petId"];
|
|
38
|
+
data?: UpdatePetWithFormMutationRequest;
|
|
39
|
+
params?: UpdatePetWithFormQueryParams;
|
|
40
|
+
}>({
|
|
41
|
+
mutationFn: async ({ petId, data, params }) => {
|
|
42
42
|
return updatePetWithForm({ petId }, data, params, config);
|
|
43
43
|
},
|
|
44
|
+
mutationKey,
|
|
44
45
|
...mutationOptions
|
|
45
|
-
})
|
|
46
|
-
mutationKey: MutationKey;
|
|
47
|
-
};
|
|
48
|
-
mutation.mutationKey = mutationKey as MutationKey;
|
|
49
|
-
return mutation;
|
|
46
|
+
});
|
|
50
47
|
}
|