@kubb/plugin-vue-query 0.0.0-canary-20241104172400

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 (59) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +123 -0
  3. package/dist/chunk-A7SD37VK.cjs +584 -0
  4. package/dist/chunk-A7SD37VK.cjs.map +1 -0
  5. package/dist/chunk-DHJLKFYS.js +827 -0
  6. package/dist/chunk-DHJLKFYS.js.map +1 -0
  7. package/dist/chunk-J4RZRRHQ.cjs +837 -0
  8. package/dist/chunk-J4RZRRHQ.cjs.map +1 -0
  9. package/dist/chunk-O4EGNKUX.js +576 -0
  10. package/dist/chunk-O4EGNKUX.js.map +1 -0
  11. package/dist/components.cjs +36 -0
  12. package/dist/components.cjs.map +1 -0
  13. package/dist/components.d.cts +150 -0
  14. package/dist/components.d.ts +150 -0
  15. package/dist/components.js +3 -0
  16. package/dist/components.js.map +1 -0
  17. package/dist/generators.cjs +21 -0
  18. package/dist/generators.cjs.map +1 -0
  19. package/dist/generators.d.cts +12 -0
  20. package/dist/generators.d.ts +12 -0
  21. package/dist/generators.js +4 -0
  22. package/dist/generators.js.map +1 -0
  23. package/dist/index.cjs +134 -0
  24. package/dist/index.cjs.map +1 -0
  25. package/dist/index.d.cts +9 -0
  26. package/dist/index.d.ts +9 -0
  27. package/dist/index.js +127 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/types-C8LfCZUP.d.cts +389 -0
  30. package/dist/types-C8LfCZUP.d.ts +389 -0
  31. package/package.json +102 -0
  32. package/src/components/InfiniteQuery.tsx +190 -0
  33. package/src/components/InfiniteQueryOptions.tsx +185 -0
  34. package/src/components/Mutation.tsx +167 -0
  35. package/src/components/MutationKey.tsx +54 -0
  36. package/src/components/Query.tsx +191 -0
  37. package/src/components/QueryKey.tsx +91 -0
  38. package/src/components/QueryOptions.tsx +152 -0
  39. package/src/components/index.ts +7 -0
  40. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +53 -0
  41. package/src/generators/__snapshots__/clientGetImportPath.ts +53 -0
  42. package/src/generators/__snapshots__/clientPostImportPath.ts +45 -0
  43. package/src/generators/__snapshots__/findByTags.ts +53 -0
  44. package/src/generators/__snapshots__/findByTagsObject.ts +62 -0
  45. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +53 -0
  46. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +53 -0
  47. package/src/generators/__snapshots__/findByTagsWithZod.ts +53 -0
  48. package/src/generators/__snapshots__/findInfiniteByTags.ts +58 -0
  49. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +58 -0
  50. package/src/generators/__snapshots__/postAsQuery.ts +52 -0
  51. package/src/generators/__snapshots__/updatePetById.ts +45 -0
  52. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +45 -0
  53. package/src/generators/index.ts +3 -0
  54. package/src/generators/infiniteQueryGenerator.tsx +137 -0
  55. package/src/generators/mutationGenerator.tsx +116 -0
  56. package/src/generators/queryGenerator.tsx +129 -0
  57. package/src/index.ts +2 -0
  58. package/src/plugin.ts +149 -0
  59. package/src/types.ts +159 -0
@@ -0,0 +1,152 @@
1
+ import { getPathParams } from '@kubb/plugin-oas/utils'
2
+ import { File, Function, FunctionParams } from '@kubb/react'
3
+
4
+ import type { ReactNode } from 'react'
5
+
6
+ import { isOptional } from '@kubb/oas'
7
+ import { Client } from '@kubb/plugin-client/components'
8
+ import type { OperationSchemas } from '@kubb/plugin-oas'
9
+ import type { PluginReactQuery } from '@kubb/plugin-react-query'
10
+ import type { PluginVueQuery } from '../types.ts'
11
+ import { QueryKey } from './QueryKey.tsx'
12
+
13
+ type Props = {
14
+ name: string
15
+ clientName: string
16
+ queryKeyName: string
17
+ typeSchemas: OperationSchemas
18
+ paramsType: PluginVueQuery['resolvedOptions']['paramsType']
19
+ pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
20
+ }
21
+
22
+ type GetParamsProps = {
23
+ paramsType: PluginVueQuery['resolvedOptions']['paramsType']
24
+ pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
25
+ typeSchemas: OperationSchemas
26
+ }
27
+
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
+
70
+ return FunctionParams.factory({
71
+ pathParams: {
72
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
73
+ type: typeSchemas.pathParams?.name,
74
+ optional: isOptional(typeSchemas.pathParams?.schema),
75
+ children: getPathParams(typeSchemas.pathParams, {
76
+ typed: true,
77
+ override(item) {
78
+ return {
79
+ ...item,
80
+ type: `MaybeRef<${item.type}>`,
81
+ }
82
+ },
83
+ }),
84
+ },
85
+ data: typeSchemas.request?.name
86
+ ? {
87
+ type: `MaybeRef<${typeSchemas.request?.name}>`,
88
+ optional: isOptional(typeSchemas.request?.schema),
89
+ }
90
+ : undefined,
91
+ params: typeSchemas.queryParams?.name
92
+ ? {
93
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
94
+ optional: isOptional(typeSchemas.queryParams?.schema),
95
+ }
96
+ : undefined,
97
+ headers: typeSchemas.headerParams?.name
98
+ ? {
99
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
100
+ optional: isOptional(typeSchemas.headerParams?.schema),
101
+ }
102
+ : undefined,
103
+ config: {
104
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',
105
+ default: '{}',
106
+ },
107
+ })
108
+ }
109
+
110
+ export function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
111
+ const params = getParams({ paramsType, pathParamsType, typeSchemas })
112
+ const clientParams = Client.getParams({
113
+ paramsType,
114
+ typeSchemas,
115
+ pathParamsType,
116
+ })
117
+ const queryKeyParams = QueryKey.getParams({
118
+ pathParamsType,
119
+ typeSchemas,
120
+ })
121
+
122
+ const enabled = Object.entries(queryKeyParams.flatParams)
123
+ .map(([key, item]) => (item && !item.optional ? key : undefined))
124
+ .filter(Boolean)
125
+ .join('&& ')
126
+
127
+ const enabledText = enabled ? `enabled: !!(${enabled})` : ''
128
+
129
+ return (
130
+ <File.Source name={name} isExportable isIndexable>
131
+ <Function name={name} export params={params.toConstructor()}>
132
+ {`
133
+ const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
134
+ return queryOptions({
135
+ ${enabledText}
136
+ queryKey,
137
+ queryFn: async ({ signal }) => {
138
+ config.signal = signal
139
+ return ${clientName}(${clientParams.toCall({
140
+ transformName(name) {
141
+ return `unref(${name})`
142
+ },
143
+ })})
144
+ },
145
+ })
146
+ `}
147
+ </Function>
148
+ </File.Source>
149
+ )
150
+ }
151
+
152
+ QueryOptions.getParams = getParams
@@ -0,0 +1,7 @@
1
+ export { Mutation } from './Mutation.tsx'
2
+ export { Query } from './Query.tsx'
3
+ export { QueryKey } from './QueryKey.tsx'
4
+ export { QueryOptions } from './QueryOptions.tsx'
5
+ export { InfiniteQueryOptions } from './InfiniteQueryOptions.tsx'
6
+ export { InfiniteQuery } from './InfiniteQuery.tsx'
7
+ export { MutationKey } from './MutationKey.tsx'
@@ -0,0 +1,53 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig, ResponseConfig } 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: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
18
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
19
+ return { ...res, data: findPetsByTagsQueryResponse.parse(res.data) };
20
+ }
21
+
22
+ export function findPetsByTagsQueryOptions(headers: MaybeRef<FindPetsByTagsQueryParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, config: Partial<RequestConfig> = {}) {
23
+ const queryKey = findPetsByTagsQueryKey(params);
24
+ return queryOptions({
25
+ queryKey,
26
+ queryFn: async ({ signal }) => {
27
+ config.signal = signal;
28
+ return findPetsByTags(unref(headers), unref(params), unref(config));
29
+ },
30
+ });
31
+ }
32
+
33
+ /**
34
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
35
+ * @summary Finds Pets by tags
36
+ * @link /pet/findByTags
37
+ */
38
+ export function useFindPetsByTags<TData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: MaybeRef<FindPetsByTagsHeaderParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, options: {
39
+ query?: Partial<QueryObserverOptions<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
40
+ client?: Partial<RequestConfig>;
41
+ } = {}) {
42
+ const { query: queryOptions, client: config = {} } = options ?? {};
43
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
44
+ const query = useQuery({
45
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
46
+ queryKey: queryKey as QueryKey,
47
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
48
+ }) as UseQueryReturnType<TData, FindPetsByTags400> & {
49
+ queryKey: TQueryKey;
50
+ };
51
+ query.queryKey = queryKey as TQueryKey;
52
+ return query;
53
+ }
@@ -0,0 +1,53 @@
1
+ import client from "axios";
2
+ import type { QueryKey, QueryObserverOptions, UseQueryReturnType } from "@tanstack/react-query";
3
+ import type { RequestConfig } from "axios";
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: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
18
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
19
+ return findPetsByTagsQueryResponse.parse(res.data);
20
+ }
21
+
22
+ export function findPetsByTagsQueryOptions(headers: MaybeRef<FindPetsByTagsQueryParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, config: Partial<RequestConfig> = {}) {
23
+ const queryKey = findPetsByTagsQueryKey(params);
24
+ return queryOptions({
25
+ queryKey,
26
+ queryFn: async ({ signal }) => {
27
+ config.signal = signal;
28
+ return findPetsByTags(unref(headers), unref(params), unref(config));
29
+ },
30
+ });
31
+ }
32
+
33
+ /**
34
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
35
+ * @summary Finds Pets by tags
36
+ * @link /pet/findByTags
37
+ */
38
+ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: MaybeRef<FindPetsByTagsHeaderParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, options: {
39
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
40
+ client?: Partial<RequestConfig>;
41
+ } = {}) {
42
+ const { query: queryOptions, client: config = {} } = options ?? {};
43
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
44
+ const query = useQuery({
45
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
46
+ queryKey: queryKey as QueryKey,
47
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
48
+ }) as UseQueryReturnType<TData, FindPetsByTags400> & {
49
+ queryKey: TQueryKey;
50
+ };
51
+ query.queryKey = queryKey as TQueryKey;
52
+ return query;
53
+ }
@@ -0,0 +1,45 @@
1
+ import client from "axios";
2
+ import type { MutationObserverOptions } from "@tanstack/vue-query";
3
+ import type { RequestConfig } from "axios";
4
+ import type { MaybeRef } from "vue";
5
+ import { useMutation } from "@tanstack/vue-query";
6
+
7
+ export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
8
+
9
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
10
+
11
+ /**
12
+ * @summary Updates a pet in the store with form data
13
+ * @link /pet/:petId
14
+ */
15
+ async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
16
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
17
+ return updatePetWithFormMutationResponse.parse(res.data);
18
+ }
19
+
20
+ /**
21
+ * @summary Updates a pet in the store with form data
22
+ * @link /pet/:petId
23
+ */
24
+ export function useUpdatePetWithForm(options: {
25
+ mutation?: MutationObserverOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
26
+ petId: MaybeRef<UpdatePetWithFormPathParams["petId"]>;
27
+ data?: MaybeRef<UpdatePetWithFormMutationRequest>;
28
+ params?: MaybeRef<UpdatePetWithFormQueryParams>;
29
+ }>;
30
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
31
+ } = {}) {
32
+ const { mutation: mutationOptions, client: config = {} } = options ?? {};
33
+ const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
34
+ return useMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
35
+ petId: UpdatePetWithFormPathParams["petId"];
36
+ data?: UpdatePetWithFormMutationRequest;
37
+ params?: UpdatePetWithFormQueryParams;
38
+ }>({
39
+ mutationFn: async ({ petId, data, params }) => {
40
+ return updatePetWithForm(petId, data, params, config);
41
+ },
42
+ mutationKey,
43
+ ...mutationOptions
44
+ });
45
+ }
@@ -0,0 +1,53 @@
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: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
18
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
19
+ return findPetsByTagsQueryResponse.parse(res.data);
20
+ }
21
+
22
+ export function findPetsByTagsQueryOptions(headers: MaybeRef<FindPetsByTagsQueryParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, config: Partial<RequestConfig> = {}) {
23
+ const queryKey = findPetsByTagsQueryKey(params);
24
+ return queryOptions({
25
+ queryKey,
26
+ queryFn: async ({ signal }) => {
27
+ config.signal = signal;
28
+ return findPetsByTags(unref(headers), unref(params), unref(config));
29
+ },
30
+ });
31
+ }
32
+
33
+ /**
34
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
35
+ * @summary Finds Pets by tags
36
+ * @link /pet/findByTags
37
+ */
38
+ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: MaybeRef<FindPetsByTagsHeaderParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, options: {
39
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
40
+ client?: Partial<RequestConfig>;
41
+ } = {}) {
42
+ const { query: queryOptions, client: config = {} } = options ?? {};
43
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
44
+ const query = useQuery({
45
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
46
+ queryKey: queryKey as QueryKey,
47
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
48
+ }) as UseQueryReturnType<TData, FindPetsByTags400> & {
49
+ queryKey: TQueryKey;
50
+ };
51
+ query.queryKey = queryKey as TQueryKey;
52
+ return query;
53
+ }
@@ -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
+ }
@@ -0,0 +1,53 @@
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: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
18
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
19
+ return findPetsByTagsQueryResponse.parse(res.data);
20
+ }
21
+
22
+ export function findPetsByTagsQueryOptions(headers: MaybeRef<FindPetsByTagsQueryParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, config: Partial<RequestConfig> = {}) {
23
+ const queryKey = findPetsByTagsQueryKey(params);
24
+ return queryOptions({
25
+ queryKey,
26
+ queryFn: async ({ signal }) => {
27
+ config.signal = signal;
28
+ return findPetsByTags(unref(headers), unref(params), unref(config));
29
+ },
30
+ });
31
+ }
32
+
33
+ /**
34
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
35
+ * @summary Finds Pets by tags
36
+ * @link /pet/findByTags
37
+ */
38
+ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: MaybeRef<FindPetsByTagsHeaderParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, options: {
39
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
40
+ client?: Partial<RequestConfig>;
41
+ } = {}) {
42
+ const { query: queryOptions, client: config = {} } = options ?? {};
43
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
44
+ const query = useQuery({
45
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
46
+ queryKey: queryKey as QueryKey,
47
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
48
+ }) as UseQueryReturnType<TData, FindPetsByTags400> & {
49
+ queryKey: TQueryKey;
50
+ };
51
+ query.queryKey = queryKey as TQueryKey;
52
+ return query;
53
+ }
@@ -0,0 +1,53 @@
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>) => ["test", { 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: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
18
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
19
+ return findPetsByTagsQueryResponse.parse(res.data);
20
+ }
21
+
22
+ export function findPetsByTagsQueryOptions(headers: MaybeRef<FindPetsByTagsQueryParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, config: Partial<RequestConfig> = {}) {
23
+ const queryKey = findPetsByTagsQueryKey(params);
24
+ return queryOptions({
25
+ queryKey,
26
+ queryFn: async ({ signal }) => {
27
+ config.signal = signal;
28
+ return findPetsByTags(unref(headers), unref(params), unref(config));
29
+ },
30
+ });
31
+ }
32
+
33
+ /**
34
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
35
+ * @summary Finds Pets by tags
36
+ * @link /pet/findByTags
37
+ */
38
+ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: MaybeRef<FindPetsByTagsHeaderParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, options: {
39
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
40
+ client?: Partial<RequestConfig>;
41
+ } = {}) {
42
+ const { query: queryOptions, client: config = {} } = options ?? {};
43
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
44
+ const query = useQuery({
45
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
46
+ queryKey: queryKey as QueryKey,
47
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
48
+ }) as UseQueryReturnType<TData, FindPetsByTags400> & {
49
+ queryKey: TQueryKey;
50
+ };
51
+ query.queryKey = queryKey as TQueryKey;
52
+ return query;
53
+ }
@@ -0,0 +1,53 @@
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: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
18
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
19
+ return findPetsByTagsQueryResponse.parse(res.data);
20
+ }
21
+
22
+ export function findPetsByTagsQueryOptions(headers: MaybeRef<FindPetsByTagsQueryParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, config: Partial<RequestConfig> = {}) {
23
+ const queryKey = findPetsByTagsQueryKey(params);
24
+ return queryOptions({
25
+ queryKey,
26
+ queryFn: async ({ signal }) => {
27
+ config.signal = signal;
28
+ return findPetsByTags(unref(headers), unref(params), unref(config));
29
+ },
30
+ });
31
+ }
32
+
33
+ /**
34
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
35
+ * @summary Finds Pets by tags
36
+ * @link /pet/findByTags
37
+ */
38
+ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: MaybeRef<FindPetsByTagsHeaderParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, options: {
39
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
40
+ client?: Partial<RequestConfig>;
41
+ } = {}) {
42
+ const { query: queryOptions, client: config = {} } = options ?? {};
43
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
44
+ const query = useQuery({
45
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
46
+ queryKey: queryKey as QueryKey,
47
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
48
+ }) as UseQueryReturnType<TData, FindPetsByTags400> & {
49
+ queryKey: TQueryKey;
50
+ };
51
+ query.queryKey = queryKey as TQueryKey;
52
+ return query;
53
+ }
@@ -0,0 +1,58 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryReturnType } from "@tanstack/react-query";
4
+ import type { MaybeRef } from "vue";
5
+ import { infiniteQueryOptions, useInfiniteQuery } from "@tanstack/react-query";
6
+
7
+ export const findPetsByTagsInfiniteQueryKey = (params?: MaybeRef<FindPetsByTagsQueryParams>) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
8
+
9
+ export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>;
10
+
11
+ /**
12
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
13
+ * @summary Finds Pets by tags
14
+ * @link /pet/findByTags
15
+ */
16
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
17
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
18
+ return findPetsByTagsQueryResponse.parse(res.data);
19
+ }
20
+
21
+ export function findPetsByTagsInfiniteQueryOptions(headers: MaybeRef<FindPetsByTagsHeaderParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, config: Partial<RequestConfig> = {}) {
22
+ const queryKey = findPetsByTagsInfiniteQueryKey(params);
23
+ return infiniteQueryOptions({
24
+ queryKey,
25
+ queryFn: async ({ signal, pageParam }) => {
26
+ config.signal = signal;
27
+ if (params) {
28
+ params["pageSize"] = pageParam as unknown as FindPetsByTagsQueryParams["pageSize"];
29
+ }
30
+ return findPetsByTags(headers, params, config);
31
+ },
32
+ initialPageParam: 0,
33
+ getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1,
34
+ getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1
35
+ });
36
+ }
37
+
38
+ /**
39
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
40
+ * @summary Finds Pets by tags
41
+ * @link /pet/findByTags
42
+ */
43
+ export function useFindPetsByTagsInfinite<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey>(headers: MaybeRef<FindPetsByTagsHeaderParams>, params?: MaybeRef<FindPetsByTagsQueryParams>, options: {
44
+ query?: Partial<InfiniteQueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
45
+ client?: Partial<RequestConfig>;
46
+ } = {}) {
47
+ const { query: queryOptions, client: config = {} } = options ?? {};
48
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params);
49
+ const query = useInfiniteQuery({
50
+ ...findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions,
51
+ queryKey: queryKey as QueryKey,
52
+ ...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
53
+ }) as UseInfiniteQueryReturnType<TData, FindPetsByTags400> & {
54
+ queryKey: TQueryKey;
55
+ };
56
+ query.queryKey = queryKey as TQueryKey;
57
+ return query;
58
+ }