@kubb/plugin-react-query 3.0.0-alpha.9 → 3.0.0-beta.2

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 (78) hide show
  1. package/README.md +14 -5
  2. package/dist/chunk-37VO6QXJ.cjs +669 -0
  3. package/dist/chunk-37VO6QXJ.cjs.map +1 -0
  4. package/dist/chunk-C2H3KPHM.cjs +658 -0
  5. package/dist/chunk-C2H3KPHM.cjs.map +1 -0
  6. package/dist/chunk-IRW2Y3EC.js +660 -0
  7. package/dist/chunk-IRW2Y3EC.js.map +1 -0
  8. package/dist/chunk-Y3DM2P6L.js +647 -0
  9. package/dist/chunk-Y3DM2P6L.js.map +1 -0
  10. package/dist/components.cjs +39 -12
  11. package/dist/components.cjs.map +1 -1
  12. package/dist/components.d.cts +161 -6
  13. package/dist/components.d.ts +161 -6
  14. package/dist/components.js +2 -12
  15. package/dist/components.js.map +1 -1
  16. package/dist/generators.cjs +25 -0
  17. package/dist/generators.cjs.map +1 -0
  18. package/dist/generators.d.cts +14 -0
  19. package/dist/generators.d.ts +14 -0
  20. package/dist/generators.js +4 -0
  21. package/dist/generators.js.map +1 -0
  22. package/dist/index.cjs +78 -130
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +1 -4
  25. package/dist/index.d.ts +1 -4
  26. package/dist/index.js +61 -120
  27. package/dist/index.js.map +1 -1
  28. package/dist/types-5pnOmDmM.d.cts +231 -0
  29. package/dist/types-5pnOmDmM.d.ts +231 -0
  30. package/package.json +22 -17
  31. package/src/components/InfiniteQuery.tsx +129 -0
  32. package/src/components/InfiniteQueryOptions.tsx +130 -0
  33. package/src/components/Mutation.tsx +137 -321
  34. package/src/components/MutationKey.tsx +48 -0
  35. package/src/components/Query.tsx +91 -594
  36. package/src/components/QueryKey.tsx +51 -182
  37. package/src/components/QueryOptions.tsx +71 -473
  38. package/src/components/SuspenseQuery.tsx +129 -0
  39. package/src/components/index.ts +4 -0
  40. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +51 -0
  41. package/src/generators/__snapshots__/clientGetImportPath.ts +51 -0
  42. package/src/generators/__snapshots__/clientPostImportPath.ts +44 -0
  43. package/src/generators/__snapshots__/findByTags.ts +51 -0
  44. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +51 -0
  45. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +51 -0
  46. package/src/generators/__snapshots__/findByTagsWithZod.ts +51 -0
  47. package/src/generators/__snapshots__/findInfiniteByTags.ts +57 -0
  48. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +57 -0
  49. package/src/generators/__snapshots__/getAsMutation.ts +31 -0
  50. package/src/generators/__snapshots__/postAsQuery.ts +50 -0
  51. package/src/generators/__snapshots__/updatePetById.ts +44 -0
  52. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +46 -0
  53. package/src/generators/index.ts +4 -0
  54. package/src/generators/infiniteQueryGenerator.tsx +124 -0
  55. package/src/generators/mutationGenerator.tsx +108 -0
  56. package/src/generators/queryGenerator.tsx +121 -0
  57. package/src/generators/suspenseQueryGenerator.tsx +120 -0
  58. package/src/plugin.ts +60 -76
  59. package/src/types.ts +42 -115
  60. package/dist/chunk-7ZODZVKP.cjs +0 -1470
  61. package/dist/chunk-7ZODZVKP.cjs.map +0 -1
  62. package/dist/chunk-ZYTZV43V.js +0 -1470
  63. package/dist/chunk-ZYTZV43V.js.map +0 -1
  64. package/dist/index-5kpkk-7M.d.cts +0 -545
  65. package/dist/index-5kpkk-7M.d.ts +0 -545
  66. package/src/OperationGenerator.tsx +0 -57
  67. package/src/__snapshots__/mutateAsQuery/updatePetWithForm.ts +0 -69
  68. package/src/__snapshots__/pathParamsTypeInline/getPetById.ts +0 -62
  69. package/src/__snapshots__/pathParamsTypeObject/getPetById.ts +0 -68
  70. package/src/__snapshots__/queryOptions/getPetById.ts +0 -41
  71. package/src/__snapshots__/queryWithoutQueryOptions/getPetById.ts +0 -51
  72. package/src/__snapshots__/variablesTypeMutate/deletePet.ts +0 -24
  73. package/src/components/QueryImports.tsx +0 -167
  74. package/src/components/SchemaType.tsx +0 -59
  75. package/src/components/__snapshots__/gen/showPetById.ts +0 -67
  76. package/src/components/__snapshots__/gen/useCreatePets.ts +0 -46
  77. package/src/components/__snapshots__/gen/useCreatePetsMutate.ts +0 -46
  78. package/src/utils.ts +0 -96
@@ -1,4 +1,8 @@
1
1
  export { Mutation } from './Mutation.tsx'
2
2
  export { Query } from './Query.tsx'
3
3
  export { QueryKey } from './QueryKey.tsx'
4
+ export { MutationKey } from './MutationKey.tsx'
4
5
  export { QueryOptions } from './QueryOptions.tsx'
6
+ export { InfiniteQueryOptions } from './InfiniteQueryOptions.tsx'
7
+ export { InfiniteQuery } from './InfiniteQuery.tsx'
8
+ export { SuspenseQuery } from './SuspenseQuery.tsx'
@@ -0,0 +1,51 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
4
+ import { useQuery, queryOptions } from "@tanstack/react-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
+ return { ...res, data: findPetsByTagsQueryResponse.parse(res.data) };
18
+ }
19
+
20
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
+ const queryKey = findPetsByTagsQueryKey(params);
22
+ return queryOptions({
23
+ queryKey,
24
+ queryFn: async ({ signal }) => {
25
+ config.signal = signal;
26
+ return findPetsByTags(headers, params, config);
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function useFindPetsByTags<TData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
+ query?: Partial<QueryObserverOptions<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
+ client?: Partial<RequestConfig>;
39
+ } = {}) {
40
+ const { query: queryOptions, client: config = {} } = options ?? {};
41
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
+ const query = useQuery({
43
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
+ queryKey,
45
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
47
+ queryKey: TQueryKey;
48
+ };
49
+ query.queryKey = queryKey as TQueryKey;
50
+ return query;
51
+ }
@@ -0,0 +1,51 @@
1
+ import client from "axios";
2
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
3
+ import type { RequestConfig } from "axios";
4
+ import { useQuery, queryOptions } from "@tanstack/react-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
+ return findPetsByTagsQueryResponse.parse(res.data);
18
+ }
19
+
20
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
+ const queryKey = findPetsByTagsQueryKey(params);
22
+ return queryOptions({
23
+ queryKey,
24
+ queryFn: async ({ signal }) => {
25
+ config.signal = signal;
26
+ return findPetsByTags(headers, params, config);
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
+ client?: Partial<RequestConfig>;
39
+ } = {}) {
40
+ const { query: queryOptions, client: config = {} } = options ?? {};
41
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
+ const query = useQuery({
43
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
+ queryKey,
45
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
47
+ queryKey: TQueryKey;
48
+ };
49
+ query.queryKey = queryKey as TQueryKey;
50
+ return query;
51
+ }
@@ -0,0 +1,44 @@
1
+ import client from "axios";
2
+ import type { UseMutationOptions } from "@tanstack/react-query";
3
+ import type { RequestConfig } from "axios";
4
+ import { useMutation } from "@tanstack/react-query";
5
+
6
+ export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
7
+
8
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
9
+
10
+ /**
11
+ * @summary Updates a pet in the store with form data
12
+ * @link /pet/:petId
13
+ */
14
+ async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
15
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
16
+ return updatePetWithFormMutationResponse.parse(res.data);
17
+ }
18
+
19
+ /**
20
+ * @summary Updates a pet in the store with form data
21
+ * @link /pet/:petId
22
+ */
23
+ export function useUpdatePetWithForm(options: {
24
+ mutation?: UseMutationOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
25
+ petId: UpdatePetWithFormPathParams["petId"];
26
+ data?: UpdatePetWithFormMutationRequest;
27
+ params?: UpdatePetWithFormQueryParams;
28
+ }>;
29
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
30
+ } = {}) {
31
+ const { mutation: mutationOptions, client: config = {} } = options ?? {};
32
+ const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
33
+ return useMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
34
+ petId: UpdatePetWithFormPathParams["petId"];
35
+ data?: UpdatePetWithFormMutationRequest;
36
+ params?: UpdatePetWithFormQueryParams;
37
+ }>({
38
+ mutationFn: async ({ petId, data, params }) => {
39
+ return updatePetWithForm(petId, data, params, config);
40
+ },
41
+ mutationKey,
42
+ ...mutationOptions
43
+ });
44
+ }
@@ -0,0 +1,51 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
4
+ import { useQuery, queryOptions } from "@tanstack/react-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
+ return findPetsByTagsQueryResponse.parse(res.data);
18
+ }
19
+
20
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
+ const queryKey = findPetsByTagsQueryKey(params);
22
+ return queryOptions({
23
+ queryKey,
24
+ queryFn: async ({ signal }) => {
25
+ config.signal = signal;
26
+ return findPetsByTags(headers, params, config);
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
+ client?: Partial<RequestConfig>;
39
+ } = {}) {
40
+ const { query: queryOptions, client: config = {} } = options ?? {};
41
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
+ const query = useQuery({
43
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
+ queryKey,
45
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
47
+ queryKey: TQueryKey;
48
+ };
49
+ query.queryKey = queryKey as TQueryKey;
50
+ return query;
51
+ }
@@ -0,0 +1,51 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
4
+ import { useQuery, queryOptions } from "@tanstack/react-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
+ return findPetsByTagsQueryResponse.parse(res.data);
18
+ }
19
+
20
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
+ const queryKey = findPetsByTagsQueryKey(params);
22
+ return queryOptions({
23
+ queryKey,
24
+ queryFn: async ({ signal }) => {
25
+ config.signal = signal;
26
+ return findPetsByTags(headers, params, config);
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
+ client?: Partial<RequestConfig>;
39
+ } = {}) {
40
+ const { query: queryOptions, client: config = {} } = options ?? {};
41
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
+ const query = useQuery({
43
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
+ queryKey,
45
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
47
+ queryKey: TQueryKey;
48
+ };
49
+ query.queryKey = queryKey as TQueryKey;
50
+ return query;
51
+ }
@@ -0,0 +1,51 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
4
+ import { useQuery, queryOptions } from "@tanstack/react-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [test, { url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
+ return findPetsByTagsQueryResponse.parse(res.data);
18
+ }
19
+
20
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
+ const queryKey = findPetsByTagsQueryKey(params);
22
+ return queryOptions({
23
+ queryKey,
24
+ queryFn: async ({ signal }) => {
25
+ config.signal = signal;
26
+ return findPetsByTags(headers, params, config);
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
+ client?: Partial<RequestConfig>;
39
+ } = {}) {
40
+ const { query: queryOptions, client: config = {} } = options ?? {};
41
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
+ const query = useQuery({
43
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
+ queryKey,
45
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
47
+ queryKey: TQueryKey;
48
+ };
49
+ query.queryKey = queryKey as TQueryKey;
50
+ return query;
51
+ }
@@ -0,0 +1,51 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from "@tanstack/react-query";
4
+ import { useQuery, queryOptions } from "@tanstack/react-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
+ return findPetsByTagsQueryResponse.parse(res.data);
18
+ }
19
+
20
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
+ const queryKey = findPetsByTagsQueryKey(params);
22
+ return queryOptions({
23
+ queryKey,
24
+ queryFn: async ({ signal }) => {
25
+ config.signal = signal;
26
+ return findPetsByTags(headers, params, config);
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
+ * @summary Finds Pets by tags
34
+ * @link /pet/findByTags
35
+ */
36
+ export function useFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
+ query?: Partial<QueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
+ client?: Partial<RequestConfig>;
39
+ } = {}) {
40
+ const { query: queryOptions, client: config = {} } = options ?? {};
41
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
+ const query = useQuery({
43
+ ...findPetsByTagsQueryOptions(headers, params, config) as unknown as QueryObserverOptions,
44
+ queryKey,
45
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
46
+ }) as UseQueryResult<TData, FindPetsByTags400> & {
47
+ queryKey: TQueryKey;
48
+ };
49
+ query.queryKey = queryKey as TQueryKey;
50
+ return query;
51
+ }
@@ -0,0 +1,57 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from "@tanstack/react-query";
4
+ import { useInfiniteQuery, infiniteQueryOptions } from "@tanstack/react-query";
5
+
6
+ export const findPetsByTagsInfiniteQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
+ return findPetsByTagsQueryResponse.parse(res.data);
18
+ }
19
+
20
+ export function findPetsByTagsInfiniteQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
+ const queryKey = findPetsByTagsInfiniteQueryKey(params);
22
+ return infiniteQueryOptions({
23
+ queryKey,
24
+ queryFn: async ({ signal, pageParam }) => {
25
+ config.signal = signal;
26
+ if (params) {
27
+ params["pageSize"] = pageParam as unknown as FindPetsByTagsQueryParams["pageSize"];
28
+ }
29
+ return findPetsByTags(headers, params, config);
30
+ },
31
+ initialPageParam: 0,
32
+ getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1,
33
+ getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1
34
+ });
35
+ }
36
+
37
+ /**
38
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
39
+ * @summary Finds Pets by tags
40
+ * @link /pet/findByTags
41
+ */
42
+ export function useFindPetsByTagsInfinite<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
43
+ query?: Partial<InfiniteQueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
44
+ client?: Partial<RequestConfig>;
45
+ } = {}) {
46
+ const { query: queryOptions, client: config = {} } = options ?? {};
47
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params);
48
+ const query = useInfiniteQuery({
49
+ ...findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions,
50
+ queryKey,
51
+ ...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
52
+ }) as UseInfiniteQueryResult<TData, FindPetsByTags400> & {
53
+ queryKey: TQueryKey;
54
+ };
55
+ query.queryKey = queryKey as TQueryKey;
56
+ return query;
57
+ }
@@ -0,0 +1,57 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, InfiniteQueryObserverOptions, UseInfiniteQueryResult } from "@tanstack/react-query";
4
+ import { useInfiniteQuery, infiniteQueryOptions } from "@tanstack/react-query";
5
+
6
+ export const findPetsByTagsInfiniteQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsInfiniteQueryKey = ReturnType<typeof findPetsByTagsInfiniteQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
+ return findPetsByTagsQueryResponse.parse(res.data);
18
+ }
19
+
20
+ export function findPetsByTagsInfiniteQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
+ const queryKey = findPetsByTagsInfiniteQueryKey(params);
22
+ return infiniteQueryOptions({
23
+ queryKey,
24
+ queryFn: async ({ signal, pageParam }) => {
25
+ config.signal = signal;
26
+ if (params) {
27
+ params["pageSize"] = pageParam as unknown as FindPetsByTagsQueryParams["pageSize"];
28
+ }
29
+ return findPetsByTags(headers, params, config);
30
+ },
31
+ initialPageParam: 0,
32
+ getNextPageParam: (lastPage) => lastPage["cursor"],
33
+ getPreviousPageParam: (firstPage) => firstPage["cursor"]
34
+ });
35
+ }
36
+
37
+ /**
38
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
39
+ * @summary Finds Pets by tags
40
+ * @link /pet/findByTags
41
+ */
42
+ export function useFindPetsByTagsInfinite<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsInfiniteQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
43
+ query?: Partial<InfiniteQueryObserverOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
44
+ client?: Partial<RequestConfig>;
45
+ } = {}) {
46
+ const { query: queryOptions, client: config = {} } = options ?? {};
47
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsInfiniteQueryKey(params);
48
+ const query = useInfiniteQuery({
49
+ ...findPetsByTagsInfiniteQueryOptions(headers, params, config) as unknown as InfiniteQueryObserverOptions,
50
+ queryKey,
51
+ ...queryOptions as unknown as Omit<InfiniteQueryObserverOptions, "queryKey">
52
+ }) as UseInfiniteQueryResult<TData, FindPetsByTags400> & {
53
+ queryKey: TQueryKey;
54
+ };
55
+ query.queryKey = queryKey as TQueryKey;
56
+ return query;
57
+ }
@@ -0,0 +1,31 @@
1
+ import client from '@kubb/plugin-client/client'
2
+ import type { RequestConfig } from '@kubb/plugin-client/client'
3
+ import type { UseMutationOptions } from 'custom-swr/mutation'
4
+ import { useMutation } from 'custom-swr/mutation'
5
+
6
+ /**
7
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
8
+ * @summary Finds Pets by tags
9
+ * @link /pet/findByTags
10
+ */
11
+ export function findPetsByTags(
12
+ options: {
13
+ mutation?: UseMutationOptions<
14
+ FindPetsByTagsQueryResponse,
15
+ FindPetsByTags400,
16
+ {
17
+ headers: FindPetsByTagsHeaderParams
18
+ params?: FindPetsByTagsQueryParams
19
+ }
20
+ >
21
+ client?: Partial<RequestConfig>
22
+ } = {},
23
+ ) {
24
+ const { mutation: mutationOptions, client: config = {} } = options ?? {}
25
+ return useMutation({
26
+ mutationFn: async ({ headers, params }: { headers: FindPetsByTagsHeaderParams; params?: FindPetsByTagsQueryParams }) => {
27
+ return findPetsByTags(headers, params, config)
28
+ },
29
+ ...mutationOptions,
30
+ })
31
+ }
@@ -0,0 +1,50 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, QueryObserverOptions, UseQueryResult } from "custom-query";
4
+ import { useQuery, queryOptions } from "custom-query";
5
+
6
+ export const updatePetWithFormQueryKey = (petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams) => [{ url: "/pet/:petId", params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const;
7
+
8
+ export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>;
9
+
10
+ /**
11
+ * @summary Updates a pet in the store with form data
12
+ * @link /pet/:petId
13
+ */
14
+ async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
15
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
16
+ return updatePetWithFormMutationResponse.parse(res.data);
17
+ }
18
+
19
+ export function updatePetWithFormQueryOptions(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
20
+ const queryKey = updatePetWithFormQueryKey(petId, data, params);
21
+ return queryOptions({
22
+ enabled: !!(petId),
23
+ queryKey,
24
+ queryFn: async ({ signal }) => {
25
+ config.signal = signal;
26
+ return updatePetWithForm(petId, data, params, config);
27
+ },
28
+ });
29
+ }
30
+
31
+ /**
32
+ * @summary Updates a pet in the store with form data
33
+ * @link /pet/:petId
34
+ */
35
+ export function useUpdatePetWithForm<TData = UpdatePetWithFormMutationResponse, TQueryData = UpdatePetWithFormMutationResponse, TQueryKey extends QueryKey = UpdatePetWithFormQueryKey>(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, options: {
36
+ query?: Partial<QueryObserverOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, TData, TQueryData, TQueryKey>>;
37
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
38
+ } = {}) {
39
+ const { query: queryOptions, client: config = {} } = options ?? {};
40
+ const queryKey = queryOptions?.queryKey ?? updatePetWithFormQueryKey(petId, data, params);
41
+ const query = useQuery({
42
+ ...updatePetWithFormQueryOptions(petId, data, params, config) as unknown as QueryObserverOptions,
43
+ queryKey,
44
+ ...queryOptions as unknown as Omit<QueryObserverOptions, "queryKey">
45
+ }) as UseQueryResult<TData, UpdatePetWithForm405> & {
46
+ queryKey: TQueryKey;
47
+ };
48
+ query.queryKey = queryKey as TQueryKey;
49
+ return query;
50
+ }
@@ -0,0 +1,44 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { UseMutationOptions } from "@tanstack/react-query";
4
+ import { useMutation } from "@tanstack/react-query";
5
+
6
+ export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
7
+
8
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
9
+
10
+ /**
11
+ * @summary Updates a pet in the store with form data
12
+ * @link /pet/:petId
13
+ */
14
+ async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
15
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
16
+ return updatePetWithFormMutationResponse.parse(res.data);
17
+ }
18
+
19
+ /**
20
+ * @summary Updates a pet in the store with form data
21
+ * @link /pet/:petId
22
+ */
23
+ export function useUpdatePetWithForm(options: {
24
+ mutation?: UseMutationOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
25
+ petId: UpdatePetWithFormPathParams["petId"];
26
+ data?: UpdatePetWithFormMutationRequest;
27
+ params?: UpdatePetWithFormQueryParams;
28
+ }>;
29
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
30
+ } = {}) {
31
+ const { mutation: mutationOptions, client: config = {} } = options ?? {};
32
+ const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
33
+ return useMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
34
+ petId: UpdatePetWithFormPathParams["petId"];
35
+ data?: UpdatePetWithFormMutationRequest;
36
+ params?: UpdatePetWithFormQueryParams;
37
+ }>({
38
+ mutationFn: async ({ petId, data, params }) => {
39
+ return updatePetWithForm(petId, data, params, config);
40
+ },
41
+ mutationKey,
42
+ ...mutationOptions
43
+ });
44
+ }
@@ -0,0 +1,46 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { UseMutationOptions } from "@tanstack/react-query";
4
+ import { useMutation } from "@tanstack/react-query";
5
+
6
+ export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
7
+
8
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
9
+
10
+ /**
11
+ * @summary Updates a pet in the store with form data
12
+ * @link /pet/:petId
13
+ */
14
+ async function updatePetWithForm({ petId }: {
15
+ petId: UpdatePetWithFormPathParams["petId"];
16
+ }, data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
17
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
18
+ return updatePetWithFormMutationResponse.parse(res.data);
19
+ }
20
+
21
+ /**
22
+ * @summary Updates a pet in the store with form data
23
+ * @link /pet/:petId
24
+ */
25
+ export function useUpdatePetWithForm(options: {
26
+ mutation?: UseMutationOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
27
+ petId: UpdatePetWithFormPathParams["petId"];
28
+ data?: UpdatePetWithFormMutationRequest;
29
+ params?: UpdatePetWithFormQueryParams;
30
+ }>;
31
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
32
+ } = {}) {
33
+ const { mutation: mutationOptions, client: config = {} } = options ?? {};
34
+ const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
35
+ return useMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
36
+ petId: UpdatePetWithFormPathParams["petId"];
37
+ data?: UpdatePetWithFormMutationRequest;
38
+ params?: UpdatePetWithFormQueryParams;
39
+ }>({
40
+ mutationFn: async ({ petId, data, params }) => {
41
+ return updatePetWithForm({ petId }, data, params, config);
42
+ },
43
+ mutationKey,
44
+ ...mutationOptions
45
+ });
46
+ }