@kubb/plugin-vue-query 3.0.0-beta.8 → 3.0.0

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 (56) hide show
  1. package/dist/{chunk-S7SEIU2L.cjs → chunk-A7SD37VK.cjs} +114 -97
  2. package/dist/chunk-A7SD37VK.cjs.map +1 -0
  3. package/dist/{chunk-V6YETPDM.js → chunk-DHJLKFYS.js} +240 -26
  4. package/dist/chunk-DHJLKFYS.js.map +1 -0
  5. package/dist/{chunk-FSQSBTBH.cjs → chunk-J4RZRRHQ.cjs} +240 -26
  6. package/dist/chunk-J4RZRRHQ.cjs.map +1 -0
  7. package/dist/{chunk-VAPLKIAH.js → chunk-O4EGNKUX.js} +106 -89
  8. package/dist/chunk-O4EGNKUX.js.map +1 -0
  9. package/dist/components.cjs +8 -8
  10. package/dist/components.d.cts +25 -14
  11. package/dist/components.d.ts +25 -14
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +5 -5
  14. package/dist/generators.d.cts +1 -1
  15. package/dist/generators.d.ts +1 -1
  16. package/dist/generators.js +2 -2
  17. package/dist/index.cjs +23 -24
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +22 -23
  22. package/dist/index.js.map +1 -1
  23. package/dist/types-C8LfCZUP.d.cts +389 -0
  24. package/dist/types-C8LfCZUP.d.ts +389 -0
  25. package/package.json +13 -13
  26. package/src/components/InfiniteQuery.tsx +54 -1
  27. package/src/components/InfiniteQueryOptions.tsx +49 -2
  28. package/src/components/Mutation.tsx +7 -3
  29. package/src/components/MutationKey.tsx +11 -5
  30. package/src/components/Query.tsx +65 -2
  31. package/src/components/QueryKey.tsx +17 -7
  32. package/src/components/QueryOptions.tsx +50 -3
  33. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +1 -1
  34. package/src/generators/__snapshots__/clientGetImportPath.ts +1 -1
  35. package/src/generators/__snapshots__/clientPostImportPath.ts +2 -2
  36. package/src/generators/__snapshots__/findByTags.ts +1 -1
  37. package/src/generators/__snapshots__/findByTagsObject.ts +62 -0
  38. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +1 -1
  39. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
  40. package/src/generators/__snapshots__/findByTagsWithZod.ts +1 -1
  41. package/src/generators/__snapshots__/findInfiniteByTags.ts +1 -1
  42. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +1 -1
  43. package/src/generators/__snapshots__/postAsQuery.ts +1 -1
  44. package/src/generators/__snapshots__/updatePetById.ts +2 -2
  45. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +3 -5
  46. package/src/generators/infiniteQueryGenerator.tsx +39 -32
  47. package/src/generators/mutationGenerator.tsx +23 -16
  48. package/src/generators/queryGenerator.tsx +24 -18
  49. package/src/plugin.ts +21 -21
  50. package/src/types.ts +35 -14
  51. package/dist/chunk-FSQSBTBH.cjs.map +0 -1
  52. package/dist/chunk-S7SEIU2L.cjs.map +0 -1
  53. package/dist/chunk-V6YETPDM.js.map +0 -1
  54. package/dist/chunk-VAPLKIAH.js.map +0 -1
  55. package/dist/types-BGseXQR_.d.cts +0 -208
  56. package/dist/types-BGseXQR_.d.ts +0 -208
@@ -4,7 +4,7 @@ import { File, Function, FunctionParams, Type } from '@kubb/react'
4
4
  import type { Operation } from '@kubb/oas'
5
5
  import type { OperationSchemas } from '@kubb/plugin-oas'
6
6
  import type { ReactNode } from 'react'
7
- import type { PluginVueQuery } from '../types'
7
+ import type { PluginVueQuery, Transformer } from '../types'
8
8
 
9
9
  type Props = {
10
10
  name: string
@@ -12,7 +12,7 @@ type Props = {
12
12
  typeSchemas: OperationSchemas
13
13
  operation: Operation
14
14
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
15
- keysFn: ((keys: unknown[]) => unknown[]) | undefined
15
+ transformer: Transformer | undefined
16
16
  }
17
17
 
18
18
  type GetParamsProps = {
@@ -24,16 +24,21 @@ function getParams({}: GetParamsProps) {
24
24
  return FunctionParams.factory({})
25
25
  }
26
26
 
27
- export function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, keysFn = (name) => name }: Props): ReactNode {
27
+ const getTransformer: Transformer = ({ operation }) => {
28
28
  const path = new URLPath(operation.path)
29
+
30
+ return [JSON.stringify({ url: path.path })].filter(Boolean)
31
+ }
32
+
33
+ export function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
29
34
  const params = getParams({ pathParamsType, typeSchemas })
30
- const keys = [JSON.stringify({ url: path.path })].filter(Boolean)
35
+ const keys = transformer({ operation, schemas: typeSchemas })
31
36
 
32
37
  return (
33
38
  <>
34
39
  <File.Source name={name} isExportable isIndexable>
35
40
  <Function.Arrow name={name} export params={params.toConstructor()} singleLine>
36
- {`[${keysFn(keys).join(', ')}] as const`}
41
+ {`[${keys.join(', ')}] as const`}
37
42
  </Function.Arrow>
38
43
  </File.Source>
39
44
  <File.Source name={typeName} isExportable isIndexable isTypeOnly>
@@ -46,3 +51,4 @@ export function MutationKey({ name, typeSchemas, pathParamsType, operation, type
46
51
  }
47
52
 
48
53
  MutationKey.getParams = getParams
54
+ MutationKey.getTransformer = getTransformer
@@ -3,6 +3,7 @@ import { File, Function, FunctionParams } from '@kubb/react'
3
3
  import { type Operation, isOptional } from '@kubb/oas'
4
4
  import type { OperationSchemas } from '@kubb/plugin-oas'
5
5
  import { getComments, getPathParams } from '@kubb/plugin-oas/utils'
6
+ import type { PluginReactQuery } from '@kubb/plugin-react-query'
6
7
  import type { ReactNode } from 'react'
7
8
  import type { PluginVueQuery } from '../types.ts'
8
9
  import { QueryKey } from './QueryKey.tsx'
@@ -18,22 +19,72 @@ type Props = {
18
19
  queryKeyTypeName: string
19
20
  typeSchemas: OperationSchemas
20
21
  operation: Operation
22
+ paramsType: PluginVueQuery['resolvedOptions']['paramsType']
21
23
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
22
24
  dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
23
25
  }
24
26
 
25
27
  type GetParamsProps = {
28
+ paramsType: PluginVueQuery['resolvedOptions']['paramsType']
26
29
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
27
30
  dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
28
31
  typeSchemas: OperationSchemas
29
32
  }
30
33
 
31
- function getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
34
+ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
32
35
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
33
36
 
37
+ if (paramsType === 'object') {
38
+ return FunctionParams.factory({
39
+ data: {
40
+ mode: 'object',
41
+ children: {
42
+ ...getPathParams(typeSchemas.pathParams, {
43
+ typed: true,
44
+ override(item) {
45
+ return {
46
+ ...item,
47
+ type: `MaybeRef<${item.type}>`,
48
+ }
49
+ },
50
+ }),
51
+ data: typeSchemas.request?.name
52
+ ? {
53
+ type: `MaybeRef<${typeSchemas.request?.name}>`,
54
+ optional: isOptional(typeSchemas.request?.schema),
55
+ }
56
+ : undefined,
57
+ params: typeSchemas.queryParams?.name
58
+ ? {
59
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
60
+ optional: isOptional(typeSchemas.queryParams?.schema),
61
+ }
62
+ : undefined,
63
+ headers: typeSchemas.headerParams?.name
64
+ ? {
65
+ type: `MaybeRef<${typeSchemas.headerParams?.name}>`,
66
+ optional: isOptional(typeSchemas.headerParams?.schema),
67
+ }
68
+ : undefined,
69
+ },
70
+ },
71
+ options: {
72
+ type: `
73
+ {
74
+ query?: Partial<QueryObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
75
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}
76
+ }
77
+ `,
78
+ default: '{}',
79
+ },
80
+ })
81
+ }
82
+
34
83
  return FunctionParams.factory({
35
84
  pathParams: {
36
85
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
86
+ type: typeSchemas.pathParams?.name,
87
+ optional: isOptional(typeSchemas.pathParams?.schema),
37
88
  children: getPathParams(typeSchemas.pathParams, {
38
89
  typed: true,
39
90
  override(item) {
@@ -74,7 +125,17 @@ function getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsPro
74
125
  })
75
126
  }
76
127
 
77
- export function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation }: Props): ReactNode {
128
+ export function Query({
129
+ name,
130
+ queryKeyTypeName,
131
+ queryOptionsName,
132
+ queryKeyName,
133
+ paramsType,
134
+ pathParamsType,
135
+ dataReturnType,
136
+ typeSchemas,
137
+ operation,
138
+ }: Props): ReactNode {
78
139
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
79
140
  const returnType = `UseQueryReturnType<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'].join(', ')}> & { queryKey: TQueryKey }`
80
141
  const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
@@ -84,10 +145,12 @@ export function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
84
145
  typeSchemas,
85
146
  })
86
147
  const queryOptionsParams = QueryOptions.getParams({
148
+ paramsType,
87
149
  pathParamsType,
88
150
  typeSchemas,
89
151
  })
90
152
  const params = getParams({
153
+ paramsType,
91
154
  pathParamsType,
92
155
  dataReturnType,
93
156
  typeSchemas,
@@ -5,7 +5,7 @@ import { File, Function, FunctionParams, Type } from '@kubb/react'
5
5
  import { type Operation, isOptional } from '@kubb/oas'
6
6
  import type { OperationSchemas } from '@kubb/plugin-oas'
7
7
  import type { ReactNode } from 'react'
8
- import type { PluginVueQuery } from '../types'
8
+ import type { PluginVueQuery, Transformer } from '../types'
9
9
 
10
10
  type Props = {
11
11
  name: string
@@ -13,7 +13,7 @@ type Props = {
13
13
  typeSchemas: OperationSchemas
14
14
  operation: Operation
15
15
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
16
- keysFn: ((keys: unknown[]) => unknown[]) | undefined
16
+ transformer: Transformer | undefined
17
17
  }
18
18
 
19
19
  type GetParamsProps = {
@@ -50,23 +50,32 @@ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
50
50
  })
51
51
  }
52
52
 
53
- export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, keysFn = (name) => name }: Props): ReactNode {
53
+ const getTransformer: Transformer = ({ operation, schemas }) => {
54
54
  const path = new URLPath(operation.path)
55
- const params = getParams({ pathParamsType, typeSchemas })
56
55
  const keys = [
57
56
  path.toObject({
58
57
  type: 'path',
59
58
  stringify: true,
60
59
  }),
61
- typeSchemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,
62
- typeSchemas.request?.name ? '...(data ? [data] : [])' : undefined,
60
+ schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,
61
+ schemas.request?.name ? '...(data ? [data] : [])' : undefined,
63
62
  ].filter(Boolean)
64
63
 
64
+ return keys
65
+ }
66
+
67
+ export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
68
+ const params = getParams({ pathParamsType, typeSchemas })
69
+ const keys = transformer({
70
+ operation,
71
+ schemas: typeSchemas,
72
+ })
73
+
65
74
  return (
66
75
  <>
67
76
  <File.Source name={name} isExportable isIndexable>
68
77
  <Function.Arrow name={name} export params={params.toConstructor()} singleLine>
69
- {`[${keysFn(keys).join(', ')}] as const`}
78
+ {`[${keys.join(', ')}] as const`}
70
79
  </Function.Arrow>
71
80
  </File.Source>
72
81
  <File.Source name={typeName} isExportable isIndexable isTypeOnly>
@@ -79,3 +88,4 @@ export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeNam
79
88
  }
80
89
 
81
90
  QueryKey.getParams = getParams
91
+ QueryKey.getTransformer = getTransformer
@@ -6,6 +6,7 @@ import type { ReactNode } from 'react'
6
6
  import { isOptional } from '@kubb/oas'
7
7
  import { Client } from '@kubb/plugin-client/components'
8
8
  import type { OperationSchemas } from '@kubb/plugin-oas'
9
+ import type { PluginReactQuery } from '@kubb/plugin-react-query'
9
10
  import type { PluginVueQuery } from '../types.ts'
10
11
  import { QueryKey } from './QueryKey.tsx'
11
12
 
@@ -14,18 +15,63 @@ type Props = {
14
15
  clientName: string
15
16
  queryKeyName: string
16
17
  typeSchemas: OperationSchemas
18
+ paramsType: PluginVueQuery['resolvedOptions']['paramsType']
17
19
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
18
20
  }
19
21
 
20
22
  type GetParamsProps = {
23
+ paramsType: PluginVueQuery['resolvedOptions']['paramsType']
21
24
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
22
25
  typeSchemas: OperationSchemas
23
26
  }
24
27
 
25
- function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
28
+ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
29
+ if (paramsType === 'object') {
30
+ return FunctionParams.factory({
31
+ data: {
32
+ mode: 'object',
33
+ children: {
34
+ ...getPathParams(typeSchemas.pathParams, {
35
+ typed: true,
36
+ override(item) {
37
+ return {
38
+ ...item,
39
+ type: `MaybeRef<${item.type}>`,
40
+ }
41
+ },
42
+ }),
43
+ data: typeSchemas.request?.name
44
+ ? {
45
+ type: `MaybeRef<${typeSchemas.request?.name}>`,
46
+ optional: isOptional(typeSchemas.request?.schema),
47
+ }
48
+ : undefined,
49
+ params: typeSchemas.queryParams?.name
50
+ ? {
51
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
52
+ optional: isOptional(typeSchemas.queryParams?.schema),
53
+ }
54
+ : undefined,
55
+ headers: typeSchemas.headerParams?.name
56
+ ? {
57
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
58
+ optional: isOptional(typeSchemas.headerParams?.schema),
59
+ }
60
+ : undefined,
61
+ },
62
+ },
63
+ config: {
64
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',
65
+ default: '{}',
66
+ },
67
+ })
68
+ }
69
+
26
70
  return FunctionParams.factory({
27
71
  pathParams: {
28
72
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
73
+ type: typeSchemas.pathParams?.name,
74
+ optional: isOptional(typeSchemas.pathParams?.schema),
29
75
  children: getPathParams(typeSchemas.pathParams, {
30
76
  typed: true,
31
77
  override(item) {
@@ -61,9 +107,10 @@ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
61
107
  })
62
108
  }
63
109
 
64
- export function QueryOptions({ name, clientName, typeSchemas, pathParamsType, queryKeyName }: Props): ReactNode {
65
- const params = getParams({ pathParamsType, typeSchemas })
110
+ export function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
111
+ const params = getParams({ paramsType, pathParamsType, typeSchemas })
66
112
  const clientParams = Client.getParams({
113
+ paramsType,
67
114
  typeSchemas,
68
115
  pathParamsType,
69
116
  })
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/client";
3
3
  import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
- import { useQuery, queryOptions } from "@tanstack/react-query";
5
+ import { queryOptions, useQuery } from "@tanstack/react-query";
6
6
  import { unref } from "vue";
7
7
 
8
8
  export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
@@ -2,7 +2,7 @@ import client from "axios";
2
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
- import { useQuery, queryOptions } from "@tanstack/react-query";
5
+ import { queryOptions, useQuery } from "@tanstack/react-query";
6
6
  import { unref } from "vue";
7
7
 
8
8
  export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
@@ -1,8 +1,8 @@
1
1
  import client from "axios";
2
- import type { MutationObserverOptions } from "@tanstack/react-query";
2
+ import type { MutationObserverOptions } from "@tanstack/vue-query";
3
3
  import type { RequestConfig } from "axios";
4
4
  import type { MaybeRef } from "vue";
5
- import { useMutation } from "@tanstack/react-query";
5
+ import { useMutation } from "@tanstack/vue-query";
6
6
 
7
7
  export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
8
8
 
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
3
  import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
- import { useQuery, queryOptions } from "@tanstack/react-query";
5
+ import { queryOptions, useQuery } from "@tanstack/react-query";
6
6
  import { unref } from "vue";
7
7
 
8
8
  export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
@@ -0,0 +1,62 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
4
+ import type { MaybeRef } from "vue";
5
+ import { queryOptions, useQuery } from "@tanstack/react-query";
6
+ import { unref } from "vue";
7
+
8
+ export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
9
+
10
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
11
+
12
+ /**
13
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
14
+ * @summary Finds Pets by tags
15
+ * @link /pet/findByTags
16
+ */
17
+ async function findPetsByTags({ headers, params }: {
18
+ headers: FindPetsByTagsHeaderParams;
19
+ params?: FindPetsByTagsQueryParams;
20
+ }, config: Partial<RequestConfig> = {}) {
21
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
22
+ return findPetsByTagsQueryResponse.parse(res.data);
23
+ }
24
+
25
+ export function findPetsByTagsQueryOptions({ headers, params }: {
26
+ headers: MaybeRef<FindPetsByTagsQueryParams>;
27
+ params?: MaybeRef<FindPetsByTagsQueryParams>;
28
+ }, config: Partial<RequestConfig> = {}) {
29
+ const queryKey = findPetsByTagsQueryKey(params);
30
+ return queryOptions({
31
+ queryKey,
32
+ queryFn: async ({ signal }) => {
33
+ config.signal = signal;
34
+ return findPetsByTags(unref({ headers: unref(headers), params: unref(params) }), unref(config));
35
+ },
36
+ });
37
+ }
38
+
39
+ /**
40
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
41
+ * @summary Finds Pets by tags
42
+ * @link /pet/findByTags
43
+ */
44
+ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>({ headers, params }: {
45
+ headers: MaybeRef<FindPetsByTagsHeaderParams>;
46
+ params?: MaybeRef<FindPetsByTagsQueryParams>;
47
+ }, options: {
48
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
49
+ client?: Partial<RequestConfig>;
50
+ } = {}) {
51
+ const { query: queryOptions, client: config = {} } = options ?? {};
52
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
53
+ const query = useQuery({
54
+ ...findPetsByTagsQueryOptions({ headers, params }, config) as unknown as QueryObserverOptions,
55
+ queryKey: queryKey as QueryKey,
56
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
57
+ }) as UseQueryReturnType<TData, FindPetsByTags400> & {
58
+ queryKey: TQueryKey;
59
+ };
60
+ query.queryKey = queryKey as TQueryKey;
61
+ return query;
62
+ }
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
3
  import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
- import { useQuery, queryOptions } from "@tanstack/react-query";
5
+ import { queryOptions, useQuery } from "@tanstack/react-query";
6
6
  import { unref } from "vue";
7
7
 
8
8
  export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
@@ -2,10 +2,10 @@ import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
3
  import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
- import { useQuery, queryOptions } from "@tanstack/react-query";
5
+ import { queryOptions, useQuery } from "@tanstack/react-query";
6
6
  import { unref } from "vue";
7
7
 
8
- export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [test, { url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
8
+ export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => ["test", { url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
9
9
 
10
10
  export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
11
11
 
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
3
  import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
- import { useQuery, queryOptions } from "@tanstack/react-query";
5
+ import { queryOptions, useQuery } from "@tanstack/react-query";
6
6
  import { unref } from "vue";
7
7
 
8
8
  export const findPetsByTagsQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
3
  import type { QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
- import { useInfiniteQuery, infiniteQueryOptions } from "@tanstack/react-query";
5
+ import { infiniteQueryOptions, useInfiniteQuery } from "@tanstack/react-query";
6
6
 
7
7
  export const findPetsByTagsInfiniteQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
8
8
 
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
3
  import type { QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from "@tanstack/react-query";
4
4
  import type { MaybeRef } from "vue";
5
- import { useInfiniteQuery, infiniteQueryOptions } from "@tanstack/react-query";
5
+ import { infiniteQueryOptions, useInfiniteQuery } from "@tanstack/react-query";
6
6
 
7
7
  export const findPetsByTagsInfiniteQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
8
8
 
@@ -2,7 +2,7 @@ import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
3
  import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "custom-query";
4
4
  import type { MaybeRef } from "vue";
5
- import { useQuery, queryOptions } from "custom-query";
5
+ import { queryOptions, useQuery } from "custom-query";
6
6
  import { unref } from "vue";
7
7
 
8
8
  export const updatePetWithFormQueryKey = (petId: MaybeRef<UpdatePetWithFormPathParams["petId"]>, data?: MaybeRef<UpdatePetWithFormMutationRequest>, params?: MaybeRef<UpdatePetWithFormQueryParams>) => [{ url: "/pet/:petId", params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const;
@@ -1,8 +1,8 @@
1
1
  import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { MutationObserverOptions } from "@tanstack/react-query";
3
+ import type { MutationObserverOptions } from "@tanstack/vue-query";
4
4
  import type { MaybeRef } from "vue";
5
- import { useMutation } from "@tanstack/react-query";
5
+ import { useMutation } from "@tanstack/vue-query";
6
6
 
7
7
  export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
8
8
 
@@ -1,8 +1,8 @@
1
1
  import client from "@kubb/plugin-client/client";
2
2
  import type { RequestConfig } from "@kubb/plugin-client/client";
3
- import type { MutationObserverOptions } from "@tanstack/react-query";
3
+ import type { MutationObserverOptions } from "@tanstack/vue-query";
4
4
  import type { MaybeRef } from "vue";
5
- import { useMutation } from "@tanstack/react-query";
5
+ import { useMutation } from "@tanstack/vue-query";
6
6
 
7
7
  export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
8
8
 
@@ -12,9 +12,7 @@ import { useMutation } from "@tanstack/react-query";
12
12
  * @summary Updates a pet in the store with form data
13
13
  * @link /pet/:petId
14
14
  */
15
- async function updatePetWithForm({ petId }: {
16
- petId: UpdatePetWithFormPathParams["petId"];
17
- }, data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
15
+ async function updatePetWithForm({ petId }: UpdatePetWithFormPathParams, data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
18
16
  const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
19
17
  return updatePetWithFormMutationResponse.parse(res.data);
20
18
  }
@@ -1,4 +1,3 @@
1
- import transformers from '@kubb/core/transformers'
2
1
  import { pluginClientName } from '@kubb/plugin-client'
3
2
  import { Client } from '@kubb/plugin-client/components'
4
3
  import { createReactGenerator } from '@kubb/plugin-oas'
@@ -20,6 +19,7 @@ export const infiniteQueryGenerator = createReactGenerator<PluginVueQuery>({
20
19
  const { getSchemas, getName, getFile } = useOperationManager()
21
20
  const isQuery = typeof options.query === 'boolean' ? options.query : !!options.query.methods?.some((method) => operation.method === method)
22
21
  const isInfinite = isQuery && !!options.infinite
22
+ const importPath = options.query ? options.query.importPath : '@tanstack/vue-query'
23
23
 
24
24
  const query = {
25
25
  name: getName(operation, { type: 'function', prefix: 'use', suffix: 'infinite' }),
@@ -51,19 +51,13 @@ export const infiniteQueryGenerator = createReactGenerator<PluginVueQuery>({
51
51
  schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),
52
52
  }
53
53
 
54
- if (!isQuery || !isInfinite || typeof options.query === 'boolean' || typeof options.infinite === 'boolean') {
54
+ if (!isQuery || !isInfinite) {
55
55
  return null
56
56
  }
57
57
 
58
58
  return (
59
59
  <File baseName={query.file.baseName} path={query.file.path} meta={query.file.meta} banner={output?.banner} footer={output?.footer}>
60
60
  {options.parser === 'zod' && <File.Import name={[zod.schemas.response.name]} root={query.file.path} path={zod.file.path} />}
61
- <File.Import name={['useInfiniteQuery', 'infiniteQueryOptions']} path={options.query.importPath} />
62
- <File.Import
63
- name={['QueryKey', 'WithRequired', 'InfiniteQueryObserverOptions', 'UseInfiniteQueryReturnType']}
64
- path={options.query.importPath}
65
- isTypeOnly
66
- />
67
61
  <File.Import name={['unref']} path="vue" />
68
62
  <File.Import name={['MaybeRef']} path="vue" isTypeOnly />
69
63
  <File.Import name={'client'} path={options.client.importPath} />
@@ -82,48 +76,61 @@ export const infiniteQueryGenerator = createReactGenerator<PluginVueQuery>({
82
76
  path={type.file.path}
83
77
  isTypeOnly
84
78
  />
85
-
86
79
  <QueryKey
87
80
  name={queryKey.name}
88
81
  typeName={queryKey.typeName}
89
82
  operation={operation}
90
83
  pathParamsType={options.pathParamsType}
91
84
  typeSchemas={type.schemas}
92
- keysFn={options.query.key}
85
+ transformer={options.queryKey}
93
86
  />
94
87
  <Client
95
88
  name={client.name}
96
89
  isExportable={false}
97
90
  isIndexable={false}
98
- baseURL={options.baseURL}
91
+ baseURL={options.client.baseURL}
99
92
  operation={operation}
100
93
  typeSchemas={type.schemas}
101
94
  zodSchemas={zod.schemas}
102
95
  dataReturnType={options.client.dataReturnType}
96
+ paramsType={options.paramsType}
103
97
  pathParamsType={options.pathParamsType}
104
98
  parser={options.parser}
105
99
  />
106
- <InfiniteQueryOptions
107
- name={queryOptions.name}
108
- clientName={client.name}
109
- queryKeyName={queryKey.name}
110
- typeSchemas={type.schemas}
111
- pathParamsType={options.pathParamsType}
112
- dataReturnType={options.client.dataReturnType}
113
- cursorParam={options.infinite.cursorParam}
114
- initialPageParam={options.infinite.initialPageParam}
115
- queryParam={options.infinite.queryParam}
116
- />
117
- <InfiniteQuery
118
- name={query.name}
119
- queryOptionsName={queryOptions.name}
120
- typeSchemas={type.schemas}
121
- pathParamsType={options.pathParamsType}
122
- operation={operation}
123
- dataReturnType={options.client.dataReturnType}
124
- queryKeyName={queryKey.name}
125
- queryKeyTypeName={queryKey.typeName}
126
- />
100
+ {options.infinite && (
101
+ <>
102
+ <File.Import name={['infiniteQueryOptions']} path={importPath} />
103
+ <InfiniteQueryOptions
104
+ name={queryOptions.name}
105
+ clientName={client.name}
106
+ queryKeyName={queryKey.name}
107
+ typeSchemas={type.schemas}
108
+ paramsType={options.paramsType}
109
+ pathParamsType={options.pathParamsType}
110
+ dataReturnType={options.client.dataReturnType}
111
+ cursorParam={options.infinite.cursorParam}
112
+ initialPageParam={options.infinite.initialPageParam}
113
+ queryParam={options.infinite.queryParam}
114
+ />
115
+ </>
116
+ )}
117
+ {options.infinite && (
118
+ <>
119
+ <File.Import name={['useInfiniteQuery']} path={importPath} />
120
+ <File.Import name={['QueryKey', 'InfiniteQueryObserverOptions', 'UseInfiniteQueryReturnType']} path={importPath} isTypeOnly />
121
+ <InfiniteQuery
122
+ name={query.name}
123
+ queryOptionsName={queryOptions.name}
124
+ typeSchemas={type.schemas}
125
+ paramsType={options.paramsType}
126
+ pathParamsType={options.pathParamsType}
127
+ operation={operation}
128
+ dataReturnType={options.client.dataReturnType}
129
+ queryKeyName={queryKey.name}
130
+ queryKeyTypeName={queryKey.typeName}
131
+ />
132
+ </>
133
+ )}
127
134
  </File>
128
135
  )
129
136
  },