@kubb/plugin-react-query 3.0.0-alpha.6 → 3.0.0-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-GTVJ55F2.cjs → chunk-7ZODZVKP.cjs} +10 -10
- package/dist/chunk-7ZODZVKP.cjs.map +1 -0
- package/dist/{chunk-IVMTW4XS.js → chunk-ZYTZV43V.js} +11 -11
- package/dist/chunk-ZYTZV43V.js.map +1 -0
- package/dist/components.cjs +2 -2
- package/dist/components.js +1 -1
- package/dist/index.cjs +23 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- package/src/__snapshots__/mutateAsQuery/updatePetWithForm.ts +7 -7
- package/src/__snapshots__/pathParamsTypeInline/getPetById.ts +7 -7
- package/src/__snapshots__/pathParamsTypeObject/getPetById.ts +7 -7
- package/src/__snapshots__/queryOptions/getPetById.ts +5 -5
- package/src/__snapshots__/queryWithoutQueryOptions/getPetById.ts +5 -5
- package/src/__snapshots__/variablesTypeMutate/deletePet.ts +3 -3
- package/src/components/Mutation.tsx +1 -1
- package/src/components/Query.tsx +2 -2
- package/src/components/QueryKey.tsx +5 -4
- package/src/components/QueryOptions.tsx +4 -4
- package/src/plugin.ts +10 -4
- package/dist/chunk-GTVJ55F2.cjs.map +0 -1
- package/dist/chunk-IVMTW4XS.js.map +0 -1
- package/src/__snapshots__/upload/UploadFile.ts +0 -72
- package/src/__snapshots__/uploadMutation/UploadFile.ts +0 -48
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
|
|
2
1
|
import client from "@kubb/plugin-client/client";
|
|
2
|
+
import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
|
4
4
|
|
|
5
5
|
type UpdatePetWithFormClient = typeof client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>;
|
|
@@ -18,16 +18,16 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const updatePetWithFormQueryKey = ({ petId }: {
|
|
22
22
|
petId: UpdatePetWithFormPathParams["petId"];
|
|
23
23
|
}, params?: UpdatePetWithForm["queryParams"], data?: UpdatePetWithForm["request"]) => [{ url: "/pet/:petId", params: { petId: petId } }, ...(params ? [params] : []), ...(data ? [data] : [])] as const;
|
|
24
24
|
|
|
25
|
-
export type UpdatePetWithFormQueryKey = ReturnType<typeof
|
|
25
|
+
export type UpdatePetWithFormQueryKey = ReturnType<typeof updatePetWithFormQueryKey>;
|
|
26
26
|
|
|
27
|
-
export function
|
|
27
|
+
export function updatePetWithFormQueryOptions<TData = UpdatePetWithForm["response"], TQueryData = UpdatePetWithForm["response"]>({ petId }: {
|
|
28
28
|
petId: UpdatePetWithFormPathParams["petId"];
|
|
29
29
|
}, params?: UpdatePetWithForm["queryParams"], data?: UpdatePetWithForm["request"], options: UpdatePetWithForm["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<UpdatePetWithForm["response"], UpdatePetWithForm["error"], TData, TQueryData>, "queryKey"> {
|
|
30
|
-
const queryKey =
|
|
30
|
+
const queryKey = updatePetWithFormQueryKey({ petId }, params, data);
|
|
31
31
|
return {
|
|
32
32
|
queryKey,
|
|
33
33
|
queryFn: async () => {
|
|
@@ -56,9 +56,9 @@ export function updatePetWithForm<TData = UpdatePetWithForm["response"], TQueryD
|
|
|
56
56
|
queryKey: TQueryKey;
|
|
57
57
|
} {
|
|
58
58
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {};
|
|
59
|
-
const queryKey = queryOptions?.queryKey ??
|
|
59
|
+
const queryKey = queryOptions?.queryKey ?? updatePetWithFormQueryKey({ petId }, params, data);
|
|
60
60
|
const query = useQuery<UpdatePetWithForm["data"], UpdatePetWithForm["error"], TData, any>({
|
|
61
|
-
...
|
|
61
|
+
...updatePetWithFormQueryOptions<TData, TQueryData>({ petId }, params, data, clientOptions),
|
|
62
62
|
queryKey,
|
|
63
63
|
...queryOptions
|
|
64
64
|
}) as UseQueryResult<TData, UpdatePetWithForm["error"]> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
|
|
2
1
|
import client from "@kubb/plugin-client/client";
|
|
2
|
+
import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
|
4
4
|
|
|
5
5
|
type GetPetByIdClient = typeof client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, never>;
|
|
@@ -18,12 +18,12 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const getPetByIdQueryKey = (petId: GetPetByIdPathParams["petId"]) => [{ url: "/pet/:petId", params: { petId: petId } }] as const;
|
|
22
22
|
|
|
23
|
-
export type GetPetByIdQueryKey = ReturnType<typeof
|
|
23
|
+
export type GetPetByIdQueryKey = ReturnType<typeof getPetByIdQueryKey>;
|
|
24
24
|
|
|
25
|
-
export function
|
|
26
|
-
const queryKey =
|
|
25
|
+
export function getPetByIdQueryOptions<TData = GetPetById["response"], TQueryData = GetPetById["response"]>(petId: GetPetByIdPathParams["petId"], options: GetPetById["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<GetPetById["response"], GetPetById["error"], TData, TQueryData>, "queryKey"> {
|
|
26
|
+
const queryKey = getPetByIdQueryKey(petId);
|
|
27
27
|
return {
|
|
28
28
|
queryKey,
|
|
29
29
|
queryFn: async () => {
|
|
@@ -49,9 +49,9 @@ export function getPetById<TData = GetPetById["response"], TQueryData = GetPetBy
|
|
|
49
49
|
queryKey: TQueryKey;
|
|
50
50
|
} {
|
|
51
51
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {};
|
|
52
|
-
const queryKey = queryOptions?.queryKey ??
|
|
52
|
+
const queryKey = queryOptions?.queryKey ?? getPetByIdQueryKey(petId);
|
|
53
53
|
const query = useQuery<GetPetById["data"], GetPetById["error"], TData, any>({
|
|
54
|
-
...
|
|
54
|
+
...getPetByIdQueryOptions<TData, TQueryData>(petId, clientOptions),
|
|
55
55
|
queryKey,
|
|
56
56
|
...queryOptions
|
|
57
57
|
}) as UseQueryResult<TData, GetPetById["error"]> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
|
|
2
1
|
import client from "@kubb/plugin-client/client";
|
|
2
|
+
import type { UseBaseQueryOptions, UseQueryResult, QueryKey, WithRequired } from "@tanstack/react-query";
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
|
4
4
|
|
|
5
5
|
type GetPetByIdClient = typeof client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, never>;
|
|
@@ -18,16 +18,16 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const getPetByIdQueryKey = ({ petId }: {
|
|
22
22
|
petId: GetPetByIdPathParams["petId"];
|
|
23
23
|
}) => [{ url: "/pet/:petId", params: { petId: petId } }] as const;
|
|
24
24
|
|
|
25
|
-
export type GetPetByIdQueryKey = ReturnType<typeof
|
|
25
|
+
export type GetPetByIdQueryKey = ReturnType<typeof getPetByIdQueryKey>;
|
|
26
26
|
|
|
27
|
-
export function
|
|
27
|
+
export function getPetByIdQueryOptions<TData = GetPetById["response"], TQueryData = GetPetById["response"]>({ petId }: {
|
|
28
28
|
petId: GetPetByIdPathParams["petId"];
|
|
29
29
|
}, options: GetPetById["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<GetPetById["response"], GetPetById["error"], TData, TQueryData>, "queryKey"> {
|
|
30
|
-
const queryKey =
|
|
30
|
+
const queryKey = getPetByIdQueryKey({ petId });
|
|
31
31
|
return {
|
|
32
32
|
queryKey,
|
|
33
33
|
queryFn: async () => {
|
|
@@ -55,9 +55,9 @@ export function getPetById<TData = GetPetById["response"], TQueryData = GetPetBy
|
|
|
55
55
|
queryKey: TQueryKey;
|
|
56
56
|
} {
|
|
57
57
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {};
|
|
58
|
-
const queryKey = queryOptions?.queryKey ??
|
|
58
|
+
const queryKey = queryOptions?.queryKey ?? getPetByIdQueryKey({ petId });
|
|
59
59
|
const query = useQuery<GetPetById["data"], GetPetById["error"], TData, any>({
|
|
60
|
-
...
|
|
60
|
+
...getPetByIdQueryOptions<TData, TQueryData>({ petId }, clientOptions),
|
|
61
61
|
queryKey,
|
|
62
62
|
...queryOptions
|
|
63
63
|
}) as UseQueryResult<TData, GetPetById["error"]> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UseBaseQueryOptions, QueryKey, WithRequired } from "@tanstack/react-query";
|
|
2
1
|
import client from "@kubb/plugin-client/client";
|
|
2
|
+
import type { UseBaseQueryOptions, QueryKey, WithRequired } from "@tanstack/react-query";
|
|
3
3
|
|
|
4
4
|
type GetPetByIdClient = typeof client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, never>;
|
|
5
5
|
|
|
@@ -17,16 +17,16 @@ import client from "@kubb/plugin-client/client";
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export const
|
|
20
|
+
export const getPetByIdQueryKey = ({ petId }: {
|
|
21
21
|
petId: GetPetByIdPathParams["petId"];
|
|
22
22
|
}) => [{ url: "/pet/:petId", params: { petId: petId } }] as const;
|
|
23
23
|
|
|
24
|
-
export type GetPetByIdQueryKey = ReturnType<typeof
|
|
24
|
+
export type GetPetByIdQueryKey = ReturnType<typeof getPetByIdQueryKey>;
|
|
25
25
|
|
|
26
|
-
export function
|
|
26
|
+
export function getPetByIdQueryOptions<TData = GetPetById["response"], TQueryData = GetPetById["response"]>({ petId }: {
|
|
27
27
|
petId: GetPetByIdPathParams["petId"];
|
|
28
28
|
}, options: GetPetById["client"]["parameters"] = {}): WithRequired<UseBaseQueryOptions<GetPetById["response"], GetPetById["error"], TData, TQueryData>, "queryKey"> {
|
|
29
|
-
const queryKey =
|
|
29
|
+
const queryKey = getPetByIdQueryKey({ petId });
|
|
30
30
|
return {
|
|
31
31
|
queryKey,
|
|
32
32
|
queryFn: async () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { UseBaseQueryOptions, UseQueryResult, QueryKey } from "@tanstack/react-query";
|
|
2
1
|
import client from "@kubb/plugin-client/client";
|
|
2
|
+
import type { UseBaseQueryOptions, UseQueryResult, QueryKey } from "@tanstack/react-query";
|
|
3
3
|
import { useQuery } from "@tanstack/react-query";
|
|
4
4
|
|
|
5
5
|
type GetPetByIdClient = typeof client<GetPetByIdQueryResponse, GetPetById400 | GetPetById404, never>;
|
|
@@ -18,11 +18,11 @@ import { useQuery } from "@tanstack/react-query";
|
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const getPetByIdQueryKey = ({ petId }: {
|
|
22
22
|
petId: GetPetByIdPathParams["petId"];
|
|
23
23
|
}) => [{ url: "/pet/:petId", params: { petId: petId } }] as const;
|
|
24
24
|
|
|
25
|
-
export type GetPetByIdQueryKey = ReturnType<typeof
|
|
25
|
+
export type GetPetByIdQueryKey = ReturnType<typeof getPetByIdQueryKey>;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* @description Returns a single pet
|
|
@@ -38,9 +38,9 @@ export function getPetById<TData = GetPetById["response"], TQueryData = GetPetBy
|
|
|
38
38
|
queryKey: TQueryKey;
|
|
39
39
|
} {
|
|
40
40
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {};
|
|
41
|
-
const queryKey = queryOptions?.queryKey ??
|
|
41
|
+
const queryKey = queryOptions?.queryKey ?? getPetByIdQueryKey({ petId });
|
|
42
42
|
const query = useQuery<GetPetById["data"], GetPetById["error"], TData, any>({
|
|
43
|
-
...
|
|
43
|
+
...getPetByIdQueryOptions<TData, TQueryData>({ petId }, clientOptions),
|
|
44
44
|
queryKey,
|
|
45
45
|
...queryOptions
|
|
46
46
|
}) as UseQueryResult<TData, GetPetById["error"]> & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { QueryKey } from "@tanstack/react-query";
|
|
2
1
|
import client from "@kubb/plugin-client/client";
|
|
2
|
+
import type { QueryKey } from "@tanstack/react-query";
|
|
3
3
|
|
|
4
4
|
type DeletePetClient = typeof client<DeletePetMutationResponse, DeletePet400, never>;
|
|
5
5
|
|
|
@@ -17,8 +17,8 @@ import client from "@kubb/plugin-client/client";
|
|
|
17
17
|
};
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
export const
|
|
20
|
+
export const deletePetQueryKey = ({ petId }: {
|
|
21
21
|
petId: DeletePetPathParams["petId"];
|
|
22
22
|
}) => [{ url: "/pet/:petId", params: { petId: petId } }] as const;
|
|
23
23
|
|
|
24
|
-
export type DeletePetQueryKey = ReturnType<typeof
|
|
24
|
+
export type DeletePetQueryKey = ReturnType<typeof deletePetQueryKey>;
|
|
@@ -82,7 +82,7 @@ function Template({ name, params, mutateParams, JSDoc, client, hook, dataReturnT
|
|
|
82
82
|
: undefined
|
|
83
83
|
|
|
84
84
|
return (
|
|
85
|
-
<File.Source name={name} isExportable>
|
|
85
|
+
<File.Source name={name} isExportable isIndexable>
|
|
86
86
|
<Function export name={name} params={params} JSDoc={JSDoc}>
|
|
87
87
|
{`
|
|
88
88
|
const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {}
|
package/src/components/Query.tsx
CHANGED
|
@@ -56,7 +56,7 @@ function Template({ name, generics, returnType, params, JSDoc, hook, infinite }:
|
|
|
56
56
|
|
|
57
57
|
if (isV5) {
|
|
58
58
|
return (
|
|
59
|
-
<File.Source name={name} isExportable>
|
|
59
|
+
<File.Source name={name} isExportable isIndexable>
|
|
60
60
|
<Function name={name} export generics={generics} returnType={resolvedReturnType} params={params} JSDoc={JSDoc}>
|
|
61
61
|
{`
|
|
62
62
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
|
|
@@ -79,7 +79,7 @@ function Template({ name, generics, returnType, params, JSDoc, hook, infinite }:
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
return (
|
|
82
|
-
<File.Source name={name} isExportable>
|
|
82
|
+
<File.Source name={name} isExportable isIndexable>
|
|
83
83
|
<Function name={name} export generics={generics} returnType={resolvedReturnType} params={params} JSDoc={JSDoc}>
|
|
84
84
|
{`
|
|
85
85
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { FunctionParams, URLPath } from '@kubb/core/utils'
|
|
2
|
-
import { Function, Type, File, useApp } from '@kubb/react'
|
|
3
2
|
import { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
4
3
|
import { getASTParams } from '@kubb/plugin-oas/utils'
|
|
4
|
+
import { File, Function, Type, useApp } from '@kubb/react'
|
|
5
5
|
|
|
6
6
|
import { isRequired } from '@kubb/oas'
|
|
7
|
+
import { pluginTsName } from '@kubb/plugin-ts'
|
|
7
8
|
import type { ReactNode } from 'react'
|
|
8
9
|
import type { PluginReactQuery } from '../types'
|
|
9
|
-
import { pluginTsName } from '@kubb/plugin-ts'
|
|
10
10
|
|
|
11
11
|
type TemplateProps = {
|
|
12
12
|
/**
|
|
@@ -41,12 +41,13 @@ type TemplateProps = {
|
|
|
41
41
|
function Template({ name, typeName, params, generics, returnType, JSDoc, keys }: TemplateProps): ReactNode {
|
|
42
42
|
return (
|
|
43
43
|
<>
|
|
44
|
-
<File.Source name={name} isExportable>
|
|
44
|
+
<File.Source name={name} isExportable isIndexable>
|
|
45
45
|
<Function.Arrow name={name} export generics={generics} params={params} returnType={returnType} singleLine JSDoc={JSDoc}>
|
|
46
46
|
{`[${keys}] as const`}
|
|
47
47
|
</Function.Arrow>
|
|
48
48
|
</File.Source>
|
|
49
|
-
|
|
49
|
+
|
|
50
|
+
<File.Source name={typeName} isExportable isIndexable isTypeOnly>
|
|
50
51
|
<Type name={typeName} export>
|
|
51
52
|
{`ReturnType<typeof ${name}>`}
|
|
52
53
|
</Type>
|
|
@@ -123,7 +123,7 @@ function Template({ name, params, generics, returnType, JSDoc, hook, client, inf
|
|
|
123
123
|
if (infinite) {
|
|
124
124
|
if (isV5) {
|
|
125
125
|
return (
|
|
126
|
-
<File.Source name={name} isExportable>
|
|
126
|
+
<File.Source name={name} isExportable isIndexable>
|
|
127
127
|
<Function name={name} export params={params} JSDoc={JSDoc}>
|
|
128
128
|
{`
|
|
129
129
|
const queryKey = ${hook.queryKey}
|
|
@@ -149,7 +149,7 @@ function Template({ name, params, generics, returnType, JSDoc, hook, client, inf
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
return (
|
|
152
|
-
<File.Source name={name} isExportable>
|
|
152
|
+
<File.Source name={name} isExportable isIndexable>
|
|
153
153
|
<Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>
|
|
154
154
|
{`
|
|
155
155
|
const queryKey = ${hook.queryKey}
|
|
@@ -176,7 +176,7 @@ function Template({ name, params, generics, returnType, JSDoc, hook, client, inf
|
|
|
176
176
|
|
|
177
177
|
if (isV5) {
|
|
178
178
|
return (
|
|
179
|
-
<File.Source name={name} isExportable>
|
|
179
|
+
<File.Source name={name} isExportable isIndexable>
|
|
180
180
|
<Function name={name} export params={params} JSDoc={JSDoc}>
|
|
181
181
|
{`
|
|
182
182
|
const queryKey = ${hook.queryKey}
|
|
@@ -202,7 +202,7 @@ function Template({ name, params, generics, returnType, JSDoc, hook, client, inf
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
return (
|
|
205
|
-
<File.Source name={name} isExportable>
|
|
205
|
+
<File.Source name={name} isExportable isIndexable>
|
|
206
206
|
<Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>
|
|
207
207
|
{`
|
|
208
208
|
const queryKey = ${hook.queryKey}
|
package/src/plugin.ts
CHANGED
|
@@ -40,6 +40,10 @@ export const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {
|
|
|
40
40
|
|
|
41
41
|
return {
|
|
42
42
|
name: pluginReactQueryName,
|
|
43
|
+
output: {
|
|
44
|
+
exportType: 'barrelNamed',
|
|
45
|
+
...output,
|
|
46
|
+
},
|
|
43
47
|
options: {
|
|
44
48
|
client: {
|
|
45
49
|
importPath: '@kubb/plugin-client/client',
|
|
@@ -143,16 +147,18 @@ export const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {
|
|
|
143
147
|
const files = await operationGenerator.build()
|
|
144
148
|
await this.addFile(...files)
|
|
145
149
|
|
|
146
|
-
if (this.config.output.
|
|
147
|
-
const
|
|
150
|
+
if (this.config.output.exportType) {
|
|
151
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
148
152
|
root,
|
|
149
153
|
output,
|
|
150
154
|
files: this.fileManager.files,
|
|
151
|
-
|
|
155
|
+
meta: {
|
|
156
|
+
pluginKey: this.plugin.key,
|
|
157
|
+
},
|
|
152
158
|
logger: this.logger,
|
|
153
159
|
})
|
|
154
160
|
|
|
155
|
-
await this.addFile(...
|
|
161
|
+
await this.addFile(...barrelFiles)
|
|
156
162
|
}
|
|
157
163
|
},
|
|
158
164
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-react-query/dist/chunk-GTVJ55F2.cjs","../src/components/Mutation.tsx","../src/components/SchemaType.tsx","../src/components/Query.tsx","../src/utils.ts","../src/components/QueryImports.tsx","../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx"],"names":["Fragment","useOperation","jsx","Template","RootT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;AACS,EAAA;AAEC,EAAA;AACR,IAAA;AACR,EAAA;AAGE,EAAA;AACc,IAAA;AACZX,oBAAAA;AACAA,oBAAAA;AACAA,oBAAAA;AAAM,MAAA;AAAL,MAAA;AACO,QAAA;AACI,0BAAA;AACA,UAAA;AACA,0BAAA;AACA,0BAAA;AACA,0BAAA;AACI,UAAA;AACL,QAAA;AACE,QAAA;AACL,QAAA;AACI,QAAA;AAAA,MAAA;AACZ,IAAA;AAEAA,oBAAAA;AAEE,IAAA;AAEa,IAAA;AAGfA,oBAAAA;AACAA,oBAAAA;AAAC,MAAA;AAAA,MAAA;AACC,QAAA;AACUC,QAAAA;AACV,QAAA;AACA,QAAA;AACU,QAAA;AACA,QAAA;AACV,QAAA;AACA,QAAA;AACU,QAAA;AACE,QAAA;AACC,QAAA;AAA2B,MAAA;AAC1C,IAAA;AAEE,IAAA;AAAC,MAAA;AAAA,MAAA;AACC,QAAA;AACUA,QAAAA;AACV,QAAA;AACA,QAAA;AACA,QAAA;AACU,QAAA;AACV,QAAA;AACA,QAAA;AACU,QAAA;AACE,QAAA;AACC,QAAA;AAAmC,MAAA;AAClD,IAAA;AAEa,IAAA;AACZ,MAAA;AAAA,MAAA;AACC,QAAA;AACUA,QAAAA;AACV,QAAA;AACA,QAAA;AACU,QAAA;AACV,QAAA;AACA,QAAA;AACA,QAAA;AACU,QAAA;AACE,QAAA;AACC,QAAA;AAAmC,MAAA;AAClD,IAAA;AAEJ,EAAA;AAEJ;AAEkBI;AHu0BI;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-react-query/dist/chunk-GTVJ55F2.cjs","sourcesContent":[null,"import transformers from '@kubb/core/transformers'\nimport { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams, getComments } from '@kubb/plugin-oas/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nimport { SchemaType } from './SchemaType.tsx'\n\nimport { isRequired } from '@kubb/oas'\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ComponentProps, ComponentType, ReactNode } from 'react'\nimport type { FileMeta, PluginReactQuery } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n mutateParams: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n hook: {\n name: string\n generics?: string\n children?: string\n }\n client: {\n generics: string\n method: HttpMethod\n path: URLPath\n withQueryParams: boolean\n withPathParams: boolean\n withData: boolean\n withHeaders: boolean\n contentType: string\n }\n dataReturnType: NonNullable<PluginReactQuery['options']['dataReturnType']>\n}\n\nfunction Template({ name, params, mutateParams, JSDoc, client, hook, dataReturnType }: TemplateProps): ReactNode {\n const isFormData = client.contentType === 'multipart/form-data'\n const headers = [\n client.contentType !== 'application/json' ? `'Content-Type': '${client.contentType}'` : undefined,\n client.withHeaders ? '...headers' : undefined,\n ]\n .filter(Boolean)\n .join(', ')\n\n const clientOptions = [\n `method: \"${client.method}\"`,\n `url: ${client.path.template}`,\n client.withQueryParams ? 'params' : undefined,\n client.withData && !isFormData ? 'data' : undefined,\n client.withData && isFormData ? 'data: formData' : undefined,\n headers.length ? `headers: { ${headers}, ...clientOptions.headers }` : undefined,\n '...clientOptions',\n ].filter(Boolean)\n\n const resolvedClientOptions = `${transformers.createIndent(4)}${clientOptions.join(`,\\n${transformers.createIndent(4)}`)}`\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : undefined\n\n return (\n <File.Source name={name} isExportable>\n <Function export name={name} params={params} JSDoc={JSDoc}>\n {`\n const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {}\n\n return ${hook.name}({\n mutationFn: async(${mutateParams}) => {\n ${hook.children || ''}\n ${formData || ''}\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n return ${dataReturnType === 'data' ? 'res.data' : 'res'}\n },\n ...mutationOptions\n })`}\n </Function>\n </File.Source>\n )\n}\n\ntype RootTemplateProps = {\n children?: React.ReactNode\n}\n\nfunction RootTemplate({ children }: RootTemplateProps) {\n const {\n plugin: {\n options: {\n client: { importPath },\n mutate,\n },\n },\n } = useApp<PluginReactQuery>()\n\n const { getSchemas, getFile } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n\n return (\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n name={[\n schemas.request?.name,\n schemas.response.name,\n schemas.pathParams?.name,\n schemas.queryParams?.name,\n schemas.headerParams?.name,\n ...(schemas.errors?.map((error) => error.name) || []),\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n <File.Import\n name={['UseMutationOptions', 'UseMutationResult']}\n path={typeof mutate !== 'boolean' && mutate.importPath ? mutate.importPath : '@tanstack/react-query'}\n isTypeOnly\n />\n <File.Import name={['useMutation']} path={typeof mutate !== 'boolean' && mutate.importPath ? mutate.importPath : '@tanstack/react-query'} />\n {children}\n </File>\n )\n}\n\nconst defaultTemplates = { default: Template, root: RootTemplate } as const\n\ntype Templates = Partial<typeof defaultTemplates>\n\ntype MutationProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: ComponentType<ComponentProps<typeof Template>>\n}\n\nexport function Mutation({ Template = defaultTemplates.default }: MutationProps): ReactNode {\n // TODO do checks on pathParamsType\n\n const {\n plugin: {\n options: { dataReturnType, mutate },\n },\n } = useApp<PluginReactQuery>()\n\n const operation = useOperation()\n const { getSchemas, getName } = useOperationManager()\n\n const name = getName(operation, { type: 'function' })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const contentType = operation.getContentType()\n\n const params = new FunctionParams()\n const mutateParams = new FunctionParams()\n const factoryName = getName(operation, { type: 'type' })\n\n const requestType =\n mutate && mutate.variablesType === 'mutate'\n ? FunctionParams.toObject([\n ...getASTParams(schemas.pathParams, { typed: true }),\n {\n name: 'params',\n type: `${factoryName}['queryParams']`,\n enabled: !!schemas.queryParams?.name,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'headers',\n type: `${factoryName}['headerParams']`,\n enabled: !!schemas.headerParams?.name,\n required: isRequired(schemas.headerParams?.schema),\n },\n {\n name: 'data',\n type: `${factoryName}['request']`,\n enabled: !!schemas.request?.name,\n required: isRequired(schemas.request?.schema),\n },\n ])?.type\n : schemas.request?.name\n ? `${factoryName}['request']`\n : 'never'\n\n const client = {\n method: operation.method,\n path: new URLPath(operation.path),\n generics: [`${factoryName}[\"data\"]`, `${factoryName}[\"error\"]`, requestType ? `${factoryName}[\"request\"]` : 'void'].join(', '),\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n contentType,\n }\n const hook = {\n name: 'useMutation',\n generics: [`${factoryName}['response']`, `${factoryName}[\"error\"]`, requestType ? `${requestType}` : 'void'].join(', '),\n }\n\n const resultGenerics = [\n `${factoryName}[\"response\"]`,\n `${factoryName}[\"error\"]`,\n mutate && mutate?.variablesType === 'mutate' ? requestType : `${factoryName}[\"request\"]`,\n ]\n\n if (mutate && mutate?.variablesType === 'mutate') {\n params.add([\n {\n name: 'options',\n type: `{\n mutation?: UseMutationOptions<${resultGenerics.join(', ')}>,\n client?: ${factoryName}['client']['parameters']\n }`,\n default: '{}',\n },\n ])\n\n mutateParams.add([\n [\n ...getASTParams(schemas.pathParams, { typed: false }),\n {\n name: 'params',\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'headers',\n enabled: client.withHeaders,\n required: isRequired(schemas.headerParams?.schema),\n },\n {\n name: 'data',\n enabled: !!schemas.request?.name,\n required: isRequired(schemas.request?.schema),\n },\n ],\n ])\n } else {\n params.add([\n ...getASTParams(schemas.pathParams, { typed: true }),\n {\n name: 'params',\n type: `${factoryName}['queryParams']`,\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'headers',\n type: `${factoryName}['headerParams']`,\n enabled: client.withHeaders,\n required: isRequired(schemas.headerParams?.schema),\n },\n {\n name: 'options',\n type: `{\n mutation?: UseMutationOptions<${resultGenerics.join(', ')}>,\n client?: ${factoryName}['client']['parameters']\n }`,\n default: '{}',\n },\n ])\n\n mutateParams.add([\n {\n name: 'data',\n enabled: !!schemas.request?.name,\n required: isRequired(schemas.request?.schema),\n },\n ])\n }\n\n if (!mutate) {\n return null\n }\n\n return (\n <>\n <Template\n name={name}\n JSDoc={{ comments: getComments(operation) }}\n client={client}\n hook={hook}\n params={params.toString()}\n mutateParams={mutateParams.toString()}\n dataReturnType={dataReturnType}\n />\n </>\n )\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: Templates\n}\n\nMutation.File = function ({ ...props }: FileProps): ReactNode {\n const templates = { ...defaultTemplates, ...props.templates }\n\n const Template = templates.default\n const RootTemplate = templates.root\n\n return (\n <RootTemplate>\n <SchemaType />\n <Mutation Template={Template} />\n </RootTemplate>\n )\n}\n\nMutation.templates = defaultTemplates\n","import { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { File, Type, useApp } from '@kubb/react'\n\nimport type { ReactNode } from 'react'\nimport type { PluginReactQuery } from '../types.ts'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\nexport function SchemaType(): ReactNode {\n const {\n plugin: {\n options: { dataReturnType },\n },\n } = useApp<PluginReactQuery>()\n const { getSchemas, getName } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n const [TData, TError, TRequest, TPathParams, TQueryParams, THeaderParams, TResponse] = [\n schemas.response.name,\n schemas.errors?.map((item) => item.name).join(' | ') || 'never',\n schemas.request?.name || 'never',\n schemas.pathParams?.name || 'never',\n schemas.queryParams?.name || 'never',\n schemas.headerParams?.name || 'never',\n schemas.response.name,\n ]\n const factoryName = getName(operation, { type: 'type' })\n\n const clientType = `${factoryName}Client`\n const isFormData = operation.getContentType() === 'multipart/form-data'\n\n return (\n <>\n <File.Source name={clientType} isTypeOnly>\n <Type name={clientType}>{`typeof client<${TResponse}, ${TError}, ${isFormData ? 'FormData' : TRequest}>`}</Type>\n </File.Source>\n <File.Source name={factoryName} isTypeOnly>\n <Type name={factoryName}>\n {`\n {\n data: ${TData}\n error: ${TError}\n request: ${isFormData ? 'FormData' : TRequest}\n pathParams: ${TPathParams}\n queryParams: ${TQueryParams}\n headerParams: ${THeaderParams}\n response: ${dataReturnType === 'data' ? TData : `Awaited<ReturnType<${clientType}>>`}\n client: {\n parameters: Partial<Parameters<${clientType}>[0]>\n return: Awaited<ReturnType<${clientType}>>\n }\n }\n `}\n </Type>\n </File.Source>\n </>\n )\n}\n","import { PackageManager } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { File, Function, useApp } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams, getComments } from '@kubb/plugin-oas/utils'\n\nimport { getImportNames, reactQueryDepRegex } from '../utils.ts'\nimport { QueryImports } from './QueryImports.tsx'\nimport { QueryKey } from './QueryKey.tsx'\nimport { QueryOptions } from './QueryOptions.tsx'\nimport { SchemaType } from './SchemaType.tsx'\n\nimport { isRequired } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { QueryOptions as QueryOptionsPluginOptions, Query as QueryPluginOptions } from '../types.ts'\nimport type { FileMeta, Infinite, PluginReactQuery, Suspense } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n hook: {\n name: string\n generics?: string\n queryKey: string\n queryOptions: string\n }\n infinite: Infinite | false\n}\n\nfunction Template({ name, generics, returnType, params, JSDoc, hook, infinite }: TemplateProps): ReactNode {\n const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, '>=5')\n const resolvedReturnType = `${returnType} & { queryKey: TQueryKey }`\n\n if (isV5) {\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export generics={generics} returnType={resolvedReturnType} params={params} JSDoc={JSDoc}>\n {`\n const { query: queryOptions, client: clientOptions = {} } = options ?? {}\n const queryKey = queryOptions?.queryKey ?? ${hook.queryKey}\n\n const query = ${hook.name}({\n ...${hook.queryOptions} as unknown as ${infinite ? 'InfiniteQueryObserverOptions' : 'QueryObserverOptions'},\n queryKey,\n ...queryOptions as unknown as ${infinite ? 'Omit<InfiniteQueryObserverOptions, \"queryKey\">' : 'Omit<QueryObserverOptions, \"queryKey\">'}\n }) as ${resolvedReturnType}\n\n query.queryKey = queryKey as TQueryKey\n\n return query\n\n `}\n </Function>\n </File.Source>\n )\n }\n\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export generics={generics} returnType={resolvedReturnType} params={params} JSDoc={JSDoc}>\n {`\n const { query: queryOptions, client: clientOptions = {} } = options ?? {}\n const queryKey = queryOptions?.queryKey ?? ${hook.queryKey}\n\n const query = ${hook.name}<${hook.generics}>({\n ...${hook.queryOptions},\n queryKey,\n ...queryOptions\n }) as ${resolvedReturnType}\n\n query.queryKey = queryKey as TQueryKey\n\n return query\n\n `}\n </Function>\n </File.Source>\n )\n}\n\ntype FrameworkProps = TemplateProps & {\n context: {\n factory: {\n name: string\n }\n queryKey: string\n }\n}\n\nconst defaultTemplates = {\n get react() {\n return function (props: FrameworkProps): ReactNode {\n return <Template {...props} />\n }\n },\n get solid() {\n return function (props: FrameworkProps): ReactNode {\n return <Template {...props} />\n }\n },\n get svelte() {\n return function (props: FrameworkProps): ReactNode {\n return <Template {...props} />\n }\n },\n get vue() {\n return function ({ context, hook, ...rest }: FrameworkProps): ReactNode {\n const { factory, queryKey } = context\n\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { pathParamsType },\n },\n } = useApp<PluginReactQuery>()\n const operation = useOperation()\n const { getSchemas } = useOperationManager()\n\n const importNames = getImportNames()\n\n const queryOptions = pluginManager.resolveName({\n name: `${factory.name}QueryOptions`,\n pluginKey,\n })\n\n const hookName = rest.infinite ? importNames.queryInfinite.vue.hookName : importNames.query.vue.hookName\n const resultType = rest.infinite ? importNames.queryInfinite.vue.resultType : importNames.query.vue.resultType\n const optionsType = rest.infinite ? importNames.queryInfinite.vue.optionsType : importNames.query.vue.optionsType\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, '>=5')\n const params = new FunctionParams()\n const queryParams = new FunctionParams()\n const queryKeyParams = new FunctionParams()\n const client = {\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n }\n\n const resultGenerics = ['TData', `${factory.name}['error']`]\n\n // only needed for the options to override the useQuery options/params\n const queryOptionsOverrideGenerics = [`${factory.name}['response']`, `${factory.name}['error']`, 'TData', 'TQueryKey']\n const queryOptionsGenerics = ['TData', 'TQueryData']\n\n params.add([\n ...(pathParamsType === 'object'\n ? [\n getASTParams(schemas.pathParams, {\n typed: true,\n override: (item) => ({\n ...item,\n name: item.name ? `ref${transformers.pascalCase(item.name)}` : undefined,\n }),\n }),\n ]\n : getASTParams(schemas.pathParams, {\n typed: true,\n override: (item) => ({\n ...item,\n name: item.name ? `ref${transformers.pascalCase(item.name)}` : undefined,\n }),\n })),\n {\n name: 'refParams',\n type: `MaybeRef<${schemas.queryParams?.name}>`,\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'refHeaders',\n type: `MaybeRef<${schemas.headerParams?.name}>`,\n enabled: client.withHeaders,\n required: isRequired(schemas.headerParams?.schema),\n },\n {\n name: 'refData',\n type: `MaybeRef<${schemas.request?.name}>`,\n enabled: client.withData,\n required: isRequired(schemas.request?.schema),\n },\n {\n name: 'options',\n type: `{\n query?: Partial<${optionsType}<${queryOptionsOverrideGenerics.join(', ')}>>,\n client?: ${factory.name}['client']['parameters']\n }`,\n default: '{}',\n },\n ])\n\n queryParams.add([\n ...getASTParams(schemas.pathParams, {\n typed: false,\n override: (item) => ({\n ...item,\n name: item.name ? `ref${transformers.pascalCase(item.name)}` : undefined,\n }),\n }),\n {\n name: 'refParams',\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'refHeaders',\n enabled: client.withHeaders,\n required: isRequired(schemas.headerParams?.schema),\n },\n {\n name: 'clientOptions',\n required: false,\n },\n ])\n\n queryKeyParams.add([\n ...(pathParamsType === 'object'\n ? [\n getASTParams(schemas.pathParams, {\n override: (item) => ({\n ...item,\n name: item.name ? `ref${transformers.pascalCase(item.name)}` : undefined,\n }),\n }),\n ]\n : getASTParams(schemas.pathParams, {\n override: (item) => ({\n ...item,\n name: item.name ? `ref${transformers.pascalCase(item.name)}` : undefined,\n }),\n })),\n {\n name: 'refParams',\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'refData',\n enabled: client.withData,\n required: isRequired(schemas.request?.schema),\n },\n ])\n\n return (\n <Template\n {...rest}\n params={params.toString()}\n returnType={`${resultType}<${resultGenerics.join(', ')}>`}\n hook={{\n ...hook,\n name: hookName,\n queryOptions: isV5\n ? `${queryOptions}(${queryParams.toString()})`\n : `${queryOptions}<${queryOptionsGenerics.join(', ')}>(${queryParams.toString()})`,\n queryKey: `${queryKey}(${queryKeyParams.toString()})`,\n }}\n />\n )\n }\n },\n} as const\n\ntype Props = {\n factory: {\n name: string\n }\n resultType: string\n hookName: string\n optionsType: string\n infinite: Infinite | false\n query: QueryPluginOptions | false\n queryOptions: QueryOptionsPluginOptions | false\n suspense: Suspense | false\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<FrameworkProps>\n /**\n * This will make it possible to override the default behaviour.\n */\n QueryKeyTemplate?: React.ComponentType<React.ComponentProps<typeof QueryKey.templates.react>>\n /**\n * This will make it possible to override the default behaviour.\n */\n QueryOptionsTemplate?: React.ComponentType<React.ComponentProps<typeof QueryOptions.templates.react>>\n}\n\nexport function Query({\n factory,\n optionsType,\n hookName,\n resultType,\n Template = defaultTemplates.react,\n QueryKeyTemplate = QueryKey.templates.react,\n QueryOptionsTemplate = QueryOptions.templates.react,\n ...props\n}: Props): ReactNode {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { dataReturnType, pathParamsType },\n },\n } = useApp<PluginReactQuery>()\n\n const operation = useOperation()\n const { getSchemas, getName } = useOperationManager()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const name = getName(operation, { type: 'function' })\n const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, '>=5')\n\n const queryKey = pluginManager.resolveName({\n name: [factory.name, props.infinite ? 'Infinite' : undefined, props.suspense ? 'Suspense' : undefined, 'QueryKey'].filter(Boolean).join(''),\n pluginKey,\n })\n const queryKeyType = pluginManager.resolveName({\n name: [factory.name, props.infinite ? 'Infinite' : undefined, props.suspense ? 'Suspense' : undefined, 'QueryKey'].filter(Boolean).join(''),\n type: 'type',\n pluginKey,\n })\n const queryOptions = pluginManager.resolveName({\n name: [factory.name, props.infinite ? 'Infinite' : undefined, props.suspense ? 'Suspense' : undefined, 'QueryOptions'].filter(Boolean).join(''),\n pluginKey,\n })\n\n const generics = new FunctionParams()\n const params = new FunctionParams()\n const queryParams = new FunctionParams()\n const queryKeyParams = new FunctionParams()\n //TODO operationManager.getCleitn\n const client = {\n method: operation.method,\n path: new URLPath(operation.path),\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n }\n\n generics.add([\n {\n type: 'TData',\n default: props.infinite ? `InfiniteData<${factory.name}[\"response\"]>` : `${factory.name}[\"response\"]`,\n },\n props.suspense ? undefined : { type: 'TQueryData', default: `${factory.name}[\"response\"]` },\n { type: 'TQueryKey extends QueryKey', default: queryKeyType },\n ])\n\n const resultGenerics = ['TData', `${factory.name}['error']`]\n // only needed for the options to override the useQuery options/params\n // suspense is having 4 generics instead of 5, TQueryData is not needed because data will always be defined\n const queryOptionsOverrideGenerics = props.suspense\n ? [`${factory.name}['response']`, `${factory.name}['error']`, 'TData', 'TQueryKey']\n : [`${factory.name}['response']`, `${factory.name}['error']`, 'TData', 'TQueryData', 'TQueryKey']\n\n const queryOptionsGenerics = props.suspense ? ['TData'] : ['TData', 'TQueryData']\n\n params.add([\n ...(pathParamsType === 'object' ? [getASTParams(schemas.pathParams, { typed: true })] : getASTParams(schemas.pathParams, { typed: true })),\n {\n name: 'params',\n type: `${factory.name}['queryParams']`,\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'headers',\n type: `${factory.name}['headerParams']`,\n enabled: client.withHeaders,\n required: isRequired(schemas.headerParams?.schema),\n },\n {\n name: 'data',\n type: `${factory.name}['request']`,\n enabled: client.withData,\n required: isRequired(schemas.request?.schema),\n },\n {\n name: 'options',\n type: `{\n query?: Partial<${optionsType}<${queryOptionsOverrideGenerics.join(', ')}>>,\n client?: ${factory.name}['client']['parameters']\n}`,\n default: '{}',\n },\n ])\n\n queryParams.add([\n ...(pathParamsType === 'object' ? [getASTParams(schemas.pathParams)] : getASTParams(schemas.pathParams)),\n {\n name: 'params',\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'headers',\n enabled: client.withHeaders,\n required: isRequired(schemas.headerParams?.schema),\n },\n {\n name: 'data',\n enabled: client.withData,\n required: isRequired(schemas.request?.schema),\n },\n {\n name: 'clientOptions',\n required: false,\n },\n ])\n\n queryKeyParams.add([\n ...(pathParamsType === 'object' ? [getASTParams(schemas.pathParams)] : getASTParams(schemas.pathParams)),\n {\n name: 'params',\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'data',\n enabled: client.withData,\n required: isRequired(schemas.request?.schema),\n },\n ])\n\n const hook = {\n name: hookName,\n generics: [isV5 ? 'any' : `${factory.name}['data']`, `${factory.name}['error']`, 'TData', 'any'].join(', '),\n queryOptions: isV5 ? `${queryOptions}(${queryParams.toString()})` : `${queryOptions}<${queryOptionsGenerics.join(', ')}>(${queryParams.toString()})`,\n queryKey: `${queryKey}(${queryKeyParams.toString()})`,\n }\n\n return (\n <>\n <QueryKey\n keysFn={props.query ? props.query.queryKey : (keys: unknown[]) => keys}\n Template={QueryKeyTemplate}\n factory={factory}\n name={queryKey}\n typeName={queryKeyType}\n />\n\n {props.queryOptions && (\n <QueryOptions\n Template={QueryOptionsTemplate}\n factory={factory}\n resultType={optionsType}\n dataReturnType={dataReturnType}\n infinite={props.infinite}\n suspense={props.suspense}\n />\n )}\n\n {props.query && (\n <Template\n name={[name, props.infinite ? 'Infinite' : undefined, props.suspense ? 'Suspense' : undefined].filter(Boolean).join('')}\n generics={generics.toString()}\n JSDoc={{ comments: getComments(operation) }}\n params={params.toString()}\n returnType={`${resultType}<${resultGenerics.join(', ')}>`}\n hook={hook}\n infinite={props.infinite}\n context={{\n factory,\n queryKey,\n }}\n />\n )}\n </>\n )\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: {\n query: typeof defaultTemplates\n queryKey: typeof QueryKey.templates\n queryOptions: typeof QueryOptions.templates\n queryImports: typeof QueryImports.templates\n }\n}\n\nQuery.File = function ({ templates }: FileProps): ReactNode {\n const {\n plugin: {\n options: {\n client: { importPath },\n infinite,\n suspense,\n query,\n queryOptions,\n parser,\n },\n },\n } = useApp<PluginReactQuery>()\n\n const { getSchemas, getFile, getName } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' })\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n const fileZodSchemas = getFile(operation, {\n pluginKey: [pluginZodName],\n })\n\n const factoryName = getName(operation, { type: 'type' })\n\n const importNames = getImportNames()\n const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, '>=5')\n const Template = templates?.query['react'] || defaultTemplates['react']\n const QueryOptionsTemplate = templates?.queryOptions['react'] || QueryOptions.templates['react']\n const QueryKeyTemplate = templates?.queryKey['react'] || QueryKey.templates['react']\n const Import = templates?.queryImports['react'] || QueryImports.templates['react']\n\n const factory = {\n name: factoryName,\n }\n\n return (\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n {parser === 'zod' && <File.Import name={[zodSchemas.response?.name]} root={file.path} path={fileZodSchemas.path} />}\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n name={[\n schemas.request?.name,\n schemas.response.name,\n schemas.pathParams?.name,\n schemas.queryParams?.name,\n schemas.headerParams?.name,\n ...(schemas.errors?.map((error) => error.name) || []),\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n\n <QueryImports hookPath={typeof query !== 'boolean' ? query.importPath : undefined} Template={Import} isInfinite={false} isSuspense={false} />\n {!!infinite && (\n <QueryImports hookPath={typeof query !== 'boolean' ? query.importPath : undefined} Template={Import} isInfinite={true} isSuspense={false} />\n )}\n {!!suspense && isV5 && (\n <QueryImports hookPath={typeof query !== 'boolean' ? query.importPath : undefined} Template={Import} isInfinite={false} isSuspense={true} />\n )}\n <SchemaType />\n <Query\n factory={factory}\n Template={Template}\n QueryKeyTemplate={QueryKeyTemplate}\n QueryOptionsTemplate={QueryOptionsTemplate}\n infinite={false}\n suspense={false}\n query={query}\n queryOptions={queryOptions}\n hookName={importNames.query['react'].hookName}\n resultType={importNames.query['react'].resultType}\n optionsType={importNames.query['react'].optionsType}\n />\n {!!infinite && (\n <Query\n factory={factory}\n Template={Template}\n QueryKeyTemplate={QueryKeyTemplate}\n QueryOptionsTemplate={QueryOptionsTemplate}\n infinite={infinite}\n suspense={false}\n query={query}\n queryOptions={queryOptions}\n hookName={importNames.queryInfinite['react'].hookName}\n resultType={importNames.queryInfinite['react'].resultType}\n optionsType={importNames.queryInfinite['react'].optionsType}\n />\n )}\n {!!suspense && isV5 && (\n <Query\n factory={factory}\n Template={Template}\n QueryKeyTemplate={QueryKeyTemplate}\n QueryOptionsTemplate={QueryOptionsTemplate}\n infinite={false}\n suspense={suspense}\n query={query}\n queryOptions={queryOptions}\n hookName={importNames.querySuspense['react'].hookName}\n resultType={importNames.querySuspense['react'].resultType}\n optionsType={importNames.querySuspense['react'].optionsType}\n />\n )}\n </File>\n )\n}\n\nQuery.templates = defaultTemplates\n","import { PackageManager } from '@kubb/core'\n\nexport const reactQueryDepRegex = /@tanstack\\/(react|solid|vue|svelte)-query/\n\nexport function getImportNames() {\n const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, '>=5')\n\n return {\n mutation: {\n react: {\n path: '@tanstack/react-query',\n hookName: 'useMutation',\n optionsType: 'UseMutationOptions',\n resultType: 'UseMutationResult',\n },\n solid: {\n path: '@tanstack/solid-query',\n hookName: 'createMutation',\n optionsType: 'CreateMutationOptions',\n resultType: 'CreateMutationResult',\n },\n svelte: {\n path: '@tanstack/svelte-query',\n hookName: 'createMutation',\n optionsType: 'CreateMutationOptions',\n resultType: 'CreateMutationResult',\n },\n vue: {\n path: '@tanstack/vue-query',\n hookName: 'useMutation',\n optionsType: isV5 ? 'UseMutationOptions' : 'VueMutationObserverOptions',\n resultType: 'UseMutationReturnType',\n },\n },\n query: {\n react: {\n path: '@tanstack/react-query',\n hookName: 'useQuery',\n optionsType: isV5 ? 'QueryObserverOptions' : 'UseBaseQueryOptions',\n resultType: 'UseQueryResult',\n },\n solid: {\n path: '@tanstack/solid-query',\n hookName: 'createQuery',\n optionsType: 'CreateBaseQueryOptions',\n resultType: 'CreateQueryResult',\n },\n svelte: {\n path: '@tanstack/svelte-query',\n hookName: 'createQuery',\n optionsType: 'CreateBaseQueryOptions',\n resultType: 'CreateQueryResult',\n },\n vue: {\n path: '@tanstack/vue-query',\n hookName: 'useQuery',\n optionsType: isV5 ? 'QueryObserverOptions' : 'VueQueryObserverOptions',\n resultType: isV5 ? 'UseQueryReturnType' : 'UseQueryReturnType',\n },\n },\n queryInfinite: {\n react: {\n path: '@tanstack/react-query',\n hookName: 'useInfiniteQuery',\n optionsType: isV5 ? 'InfiniteQueryObserverOptions' : 'UseInfiniteQueryOptions',\n resultType: 'UseInfiniteQueryResult',\n },\n solid: {\n path: '@tanstack/solid-query',\n hookName: 'createInfiniteQuery',\n optionsType: 'CreateInfiniteQueryOptions',\n resultType: 'CreateInfiniteQueryResult',\n },\n svelte: {\n path: '@tanstack/svelte-query',\n hookName: 'createInfiniteQuery',\n optionsType: 'CreateInfiniteQueryOptions',\n resultType: 'CreateInfiniteQueryResult',\n },\n vue: {\n path: '@tanstack/vue-query',\n hookName: 'useInfiniteQuery',\n optionsType: isV5 ? 'UseInfiniteQueryOptions' : 'VueInfiniteQueryObserverOptions',\n resultType: isV5 ? 'UseInfiniteQueryReturnType' : 'VueInfiniteQueryObserverOptions',\n },\n },\n querySuspense: {\n react: {\n path: '@tanstack/react-query',\n hookName: 'useSuspenseQuery',\n optionsType: 'UseSuspenseQueryOptions',\n resultType: 'UseSuspenseQueryResult',\n },\n },\n } as const\n}\n","import { PackageManager } from '@kubb/core'\nimport { File } from '@kubb/react'\n\nimport { getImportNames, reactQueryDepRegex } from '../utils.ts'\n\nimport type { ReactNode } from 'react'\n\ntype TemplateProps = {\n /**\n * Path to @tanstack-query\n */\n path: string\n /**\n * Override the path of 'useQuery'\n * @default 'path'\n */\n hookPath: string | undefined\n optionsType: string\n queryOptions: string | undefined\n resultType: string\n hookName: string\n isInfinite: boolean\n}\n\nfunction Template({ path, hookPath = path, isInfinite, hookName, queryOptions, optionsType, resultType }: TemplateProps): ReactNode {\n return (\n <>\n <File.Import name={[optionsType, resultType]} path={path} isTypeOnly />\n <File.Import name={[hookName]} path={hookPath} />\n\n {queryOptions && <File.Import name={[queryOptions].filter(Boolean)} path={path} />}\n <File.Import name={['QueryKey', 'WithRequired', isInfinite ? 'InfiniteData' : undefined].filter(Boolean)} path={path} isTypeOnly />\n </>\n )\n}\n\ntype FrameworkProps = Partial<TemplateProps> & {\n context: {\n isInfinite: boolean\n isSuspense: boolean\n }\n}\n\nconst defaultTemplates = {\n get react() {\n return function ({ context, hookPath, ...rest }: FrameworkProps): ReactNode {\n const importNames = getImportNames()\n const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, '>=5')\n const { isInfinite, isSuspense } = context\n\n return (\n <Template\n isInfinite={isInfinite}\n {...(isSuspense ? importNames.querySuspense.react : isInfinite ? importNames.queryInfinite.react : importNames.query.react)}\n queryOptions={isV5 ? (isInfinite ? 'infiniteQueryOptions' : 'queryOptions') : undefined}\n hookPath={hookPath}\n {...rest}\n />\n )\n }\n },\n get solid() {\n return function ({ context, hookPath, ...rest }: FrameworkProps): ReactNode {\n const importNames = getImportNames()\n const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, '>=5')\n const { isInfinite } = context\n\n return (\n <Template\n isInfinite={isInfinite}\n {...(isInfinite ? importNames.queryInfinite.solid : importNames.query.solid)}\n queryOptions={isV5 ? (isInfinite ? 'infiniteQueryOptions' : 'queryOptions') : undefined}\n hookPath={hookPath}\n {...rest}\n />\n )\n }\n },\n get svelte() {\n return function ({ context, hookPath, ...rest }: FrameworkProps): ReactNode {\n const importNames = getImportNames()\n const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, '>=5')\n const { isInfinite } = context\n\n return (\n <Template\n isInfinite={isInfinite}\n {...(isInfinite ? importNames.queryInfinite.svelte : importNames.query.svelte)}\n queryOptions={isV5 ? (isInfinite ? 'infiniteQueryOptions' : 'queryOptions') : undefined}\n hookPath={hookPath}\n {...rest}\n />\n )\n }\n },\n get vue() {\n return function ({ context, hookPath, ...rest }: FrameworkProps): ReactNode {\n const importNames = getImportNames()\n const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, '>=5')\n const { isInfinite } = context\n const path = '@tanstack/vue-query'\n\n return (\n <>\n {isV5 && (\n <>\n <Template\n isInfinite={isInfinite}\n {...(isInfinite ? importNames.queryInfinite.vue : importNames.query.vue)}\n queryOptions={isInfinite ? 'infiniteQueryOptions' : 'queryOptions'}\n hookPath={hookPath}\n {...rest}\n />\n <File.Import name={['QueryObserverOptions']} path={path} isTypeOnly />\n </>\n )}\n\n {!isV5 && isInfinite && (\n <>\n <File.Import name={[importNames.queryInfinite.vue.resultType]} path={path} isTypeOnly />\n <File.Import name={[importNames.queryInfinite.vue.optionsType]} path={'@tanstack/vue-query/build/lib/types'} isTypeOnly />\n <File.Import name={[importNames.queryInfinite.vue.hookName]} path={path} />\n </>\n )}\n\n {!isV5 && !isInfinite && (\n <>\n <File.Import name={[importNames.query.vue.resultType]} path={path} isTypeOnly />\n <File.Import name={[importNames.query.vue.optionsType]} path={'@tanstack/vue-query/build/lib/types'} isTypeOnly />\n <File.Import name={[importNames.query.vue.hookName]} path={path} />\n </>\n )}\n <File.Import name={['unref']} path={'vue'} />\n <File.Import name={['MaybeRef']} path={'vue'} isTypeOnly />\n <File.Import name={['QueryKey', 'WithRequired']} path={path} isTypeOnly />\n </>\n )\n }\n },\n} as const\n\ntype Props = {\n hookPath: string | undefined\n isInfinite: boolean\n /**\n * Only for React and v5\n */\n isSuspense: boolean\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<FrameworkProps>\n}\n\nexport function QueryImports({ hookPath, isInfinite, isSuspense, Template = defaultTemplates.react }: Props): ReactNode {\n return (\n <Template\n hookPath={hookPath}\n context={{\n isInfinite,\n isSuspense,\n }}\n />\n )\n}\n\nQueryImports.templates = defaultTemplates\n","import { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { Function, Type, File, useApp } from '@kubb/react'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams } from '@kubb/plugin-oas/utils'\n\nimport { isRequired } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { PluginReactQuery } from '../types'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * TypeName of the function in PascalCase\n */\n typeName: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n keys?: string\n}\n\nfunction Template({ name, typeName, params, generics, returnType, JSDoc, keys }: TemplateProps): ReactNode {\n return (\n <>\n <File.Source name={name} isExportable>\n <Function.Arrow name={name} export generics={generics} params={params} returnType={returnType} singleLine JSDoc={JSDoc}>\n {`[${keys}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={name} isExportable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\ntype FrameworkProps = TemplateProps & {\n context: {\n factory: {\n name: string\n }\n }\n}\n\nconst defaultTemplates = {\n get react() {\n return function (props: FrameworkProps): ReactNode {\n return <Template {...props} />\n }\n },\n get solid() {\n return function (props: FrameworkProps): ReactNode {\n return <Template {...props} />\n }\n },\n get svelte() {\n return function (props: FrameworkProps): ReactNode {\n return <Template {...props} />\n }\n },\n get vue() {\n return function ({ context, ...rest }: FrameworkProps): ReactNode {\n const { factory } = context\n\n const {\n plugin: {\n options: { pathParamsType, query },\n },\n } = useApp<PluginReactQuery>()\n const { getSchemas } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const path = new URLPath(operation.path)\n const params = new FunctionParams()\n const withQueryParams = !!schemas.queryParams?.name\n const withRequest = !!schemas.request?.name\n\n params.add([\n ...(pathParamsType === 'object'\n ? [\n getASTParams(schemas.pathParams, {\n typed: true,\n override: (item) => ({\n ...item,\n type: `MaybeRef<${item.type}>`,\n }),\n }),\n ]\n : getASTParams(schemas.pathParams, {\n typed: true,\n override: (item) => ({\n ...item,\n type: `MaybeRef<${item.type}>`,\n }),\n })),\n {\n name: 'params',\n type: `MaybeRef<${`${factory.name}[\"queryParams\"]`}>`,\n enabled: withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'request',\n type: `MaybeRef<${`${factory.name}[\"request\"]`}>`,\n enabled: withRequest,\n required: isRequired(schemas.request?.schema),\n },\n ])\n\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n replacer: (pathParam) => `unref(${pathParam})`,\n }),\n withQueryParams ? '...(params ? [params] : [])' : undefined,\n withRequest ? '...(request ? [request] : [])' : undefined,\n ].filter(Boolean)\n\n return <Template {...rest} params={params.toString()} keys={keys.join(', ')} />\n }\n },\n} as const\n\ntype Props = {\n name: string\n typeName: string\n keysFn: (keys: unknown[]) => unknown[]\n factory: {\n name: string\n }\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<FrameworkProps>\n}\n\nexport function QueryKey({ name, typeName, factory, keysFn, Template = defaultTemplates.react }: Props): ReactNode {\n const {\n plugin: {\n options: { pathParamsType },\n },\n } = useApp<PluginReactQuery>()\n const { getSchemas } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const path = new URLPath(operation.path)\n const params = new FunctionParams()\n const withQueryParams = !!schemas.queryParams?.name\n const withRequest = !!schemas.request?.name\n\n params.add([\n ...(pathParamsType === 'object' ? [getASTParams(schemas.pathParams, { typed: true })] : getASTParams(schemas.pathParams, { typed: true })),\n {\n name: 'params',\n type: `${factory.name}[\"queryParams\"]`,\n enabled: withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'data',\n type: `${factory.name}[\"request\"]`,\n enabled: withRequest,\n required: isRequired(schemas.request?.schema),\n },\n ])\n\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n withQueryParams ? '...(params ? [params] : [])' : undefined,\n withRequest ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return <Template typeName={typeName} name={name} params={params.toString()} keys={keysFn(keys).join(', ')} context={{ factory }} />\n}\n\nQueryKey.templates = defaultTemplates\n","import { PackageManager } from '@kubb/core'\nimport transformers from '@kubb/core/transformers'\nimport { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams } from '@kubb/plugin-oas/utils'\nimport { Function, useApp, File } from '@kubb/react'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { isRequired } from '@kubb/oas'\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { Infinite, PluginReactQuery, Suspense } from '../types.ts'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { reactQueryDepRegex } from '../utils.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n hook: {\n queryKey: string\n children?: string\n }\n client: {\n generics: string\n method: HttpMethod\n path: URLPath\n withQueryParams: boolean\n withPathParams: boolean\n withData: boolean\n withHeaders: boolean\n contentType: string\n }\n infinite: Infinite | false\n dataReturnType: NonNullable<PluginReactQuery['options']['dataReturnType']>\n parser: string | undefined\n}\n\nfunction Template({ name, params, generics, returnType, JSDoc, hook, client, infinite, dataReturnType, parser }: TemplateProps): ReactNode {\n const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, '>=5')\n const isFormData = client.contentType === 'multipart/form-data'\n const headers = [\n client.contentType !== 'application/json' ? `'Content-Type': '${client.contentType}'` : undefined,\n client.withHeaders ? '...headers' : undefined,\n ]\n .filter(Boolean)\n .join(', ')\n\n const clientOptions = [\n `method: \"${client.method}\"`,\n `url: ${client.path.template}`,\n client.withQueryParams && !infinite ? 'params' : undefined,\n client.withData && !isFormData ? 'data' : undefined,\n client.withData && isFormData ? 'data: formData' : undefined,\n headers.length ? `headers: { ${headers}, ...options.headers }` : undefined,\n '...options',\n client.withQueryParams && !!infinite\n ? `params: {\n ...params,\n ['${infinite.queryParam}']: pageParam,\n ...(options.params || {}),\n }`\n : undefined,\n ].filter(Boolean)\n\n const queryOptions = [\n isV5 && !!infinite ? `initialPageParam: ${infinite.initialPageParam}` : undefined,\n isV5 && !!infinite && !!infinite.cursorParam ? `getNextPageParam: (lastPage) => lastPage['${infinite.cursorParam}']` : undefined,\n isV5 && !!infinite && !!infinite.cursorParam ? `getPreviousPageParam: (firstPage) => firstPage['${infinite.cursorParam}']` : undefined,\n isV5 && !!infinite && !infinite.cursorParam && dataReturnType === 'full'\n ? 'getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1'\n : undefined,\n isV5 && !!infinite && !infinite.cursorParam && dataReturnType === 'data'\n ? 'getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1'\n : undefined,\n isV5 && !!infinite && !infinite.cursorParam\n ? 'getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1'\n : undefined,\n ].filter(Boolean)\n\n const resolvedClientOptions = `${transformers.createIndent(4)}${clientOptions.join(`,\\n${transformers.createIndent(4)}`)}`\n const resolvedQueryOptions = `${transformers.createIndent(4)}${queryOptions.join(`,\\n${transformers.createIndent(4)}`)}`\n\n let returnRes = parser ? `return ${parser}(res.data)` : 'return res.data'\n\n if (dataReturnType === 'full') {\n returnRes = parser ? `return {...res, data: ${parser}(res.data)}` : 'return res'\n }\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : undefined\n\n if (infinite) {\n if (isV5) {\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export params={params} JSDoc={JSDoc}>\n {`\n const queryKey = ${hook.queryKey}\n\n return infiniteQueryOptions({\n queryKey,\n queryFn: async ({ pageParam }) => {\n ${hook.children || ''}\n ${formData || ''}\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n ${returnRes}\n },\n ${resolvedQueryOptions}\n })\n\n `}\n </Function>\n </File.Source>\n )\n }\n\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const queryKey = ${hook.queryKey}\n\n return {\n queryKey,\n queryFn: async ({ pageParam }) => {\n ${hook.children || ''}\n ${formData || ''}\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n ${returnRes}\n },\n ${resolvedQueryOptions}\n }\n\n `}\n </Function>\n </File.Source>\n )\n }\n\n if (isV5) {\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export params={params} JSDoc={JSDoc}>\n {`\n const queryKey = ${hook.queryKey}\n\n return queryOptions({\n queryKey,\n queryFn: async () => {\n ${hook.children || ''}\n ${formData || ''}\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n ${returnRes}\n },\n ${resolvedQueryOptions}\n })\n\n `}\n </Function>\n </File.Source>\n )\n }\n\n return (\n <File.Source name={name} isExportable>\n <Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const queryKey = ${hook.queryKey}\n\n return {\n queryKey,\n queryFn: async () => {\n ${hook.children || ''}\n ${formData || ''}\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n ${returnRes}\n },\n ${resolvedQueryOptions}\n }\n\n `}\n </Function>\n </File.Source>\n )\n}\n\ntype FrameworkProps = TemplateProps & {\n context: {\n factory: {\n name: string\n }\n queryKey: string\n }\n}\n\nconst defaultTemplates = {\n get react() {\n return function (props: FrameworkProps): ReactNode {\n return <Template {...props} />\n }\n },\n get solid() {\n return function (props: FrameworkProps): ReactNode {\n return <Template {...props} />\n }\n },\n get svelte() {\n return function (props: FrameworkProps): ReactNode {\n return <Template {...props} />\n }\n },\n get vue() {\n return function ({ client, context, ...rest }: FrameworkProps): ReactNode {\n const { factory, queryKey } = context\n\n const {\n plugin: {\n options: { pathParamsType },\n },\n } = useApp<PluginReactQuery>()\n\n const { getSchemas } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const params = new FunctionParams()\n const queryKeyParams = new FunctionParams()\n\n params.add([\n ...(pathParamsType === 'object'\n ? [\n getASTParams(schemas.pathParams, {\n typed: true,\n override: (item) => ({\n ...item,\n name: item.name ? `ref${transformers.pascalCase(item.name)}` : undefined,\n type: `MaybeRef<${item.type}>`,\n }),\n }),\n ]\n : getASTParams(schemas.pathParams, {\n typed: true,\n override: (item) => ({\n ...item,\n name: item.name ? `ref${transformers.pascalCase(item.name)}` : undefined,\n type: `MaybeRef<${item.type}>`,\n }),\n })),\n {\n name: 'refParams',\n type: `MaybeRef<${schemas.queryParams?.name}>`,\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'refHeaders',\n type: `MaybeRef<${schemas.headerParams?.name}>`,\n enabled: client.withHeaders,\n required: isRequired(schemas.headerParams?.schema),\n },\n {\n name: 'refData',\n type: `MaybeRef<${schemas.request?.name}>`,\n enabled: client.withData,\n required: isRequired(schemas.request?.schema),\n },\n {\n name: 'options',\n type: `${factory.name}['client']['parameters']`,\n default: '{}',\n },\n ])\n\n queryKeyParams.add([\n ...(pathParamsType === 'object'\n ? [\n getASTParams(schemas.pathParams, {\n override: (item) => ({\n ...item,\n name: item.name ? `ref${transformers.pascalCase(item.name)}` : undefined,\n }),\n }),\n ]\n : getASTParams(schemas.pathParams, {\n override: (item) => ({\n ...item,\n name: item.name ? `ref${transformers.pascalCase(item.name)}` : undefined,\n }),\n })),\n {\n name: 'refParams',\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'refData',\n enabled: client.withData,\n required: isRequired(schemas.request?.schema),\n },\n ])\n\n const unrefs = params.items\n .filter((item) => item.enabled)\n .map((item) => {\n return item.name ? `const ${transformers.camelCase(item.name.replace('ref', ''))} = unref(${item.name})` : undefined\n })\n .join('\\n')\n\n const hook = {\n queryKey: `${queryKey}(${queryKeyParams.toString()})`,\n children: unrefs,\n }\n\n return <Template {...rest} params={params.toString()} hook={hook} client={client} />\n }\n },\n} as const\n\ntype Props = {\n infinite: Infinite | false\n suspense: Suspense | false\n factory: {\n name: string\n }\n resultType: string\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<FrameworkProps>\n dataReturnType: NonNullable<PluginReactQuery['options']['dataReturnType']>\n}\n\nexport function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType, Template = defaultTemplates.react }: Props): ReactNode {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { parser, pathParamsType, queryOptions },\n },\n } = useApp<PluginReactQuery>()\n\n const { getSchemas } = useOperationManager()\n const operation = useOperation()\n\n const contentType = operation.getContentType()\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' })\n\n const queryKey = pluginManager.resolveName({\n name: [factory.name, infinite ? 'Infinite' : undefined, suspense ? 'Suspense' : undefined, 'QueryKey'].filter(Boolean).join(''),\n pluginKey,\n })\n const queryOptionsName = pluginManager.resolveName({\n name: [factory.name, infinite ? 'Infinite' : undefined, suspense ? 'Suspense' : undefined, 'QueryOptions'].filter(Boolean).join(''),\n pluginKey,\n })\n\n const generics = new FunctionParams()\n const params = new FunctionParams()\n const queryKeyParams = new FunctionParams()\n\n const clientGenerics = [`${factory.name}['data']`, `${factory.name}['error']`]\n // suspense is having 4 generics instead of 5, TQueryData is not needed because data will always be defined\n const resultGenerics = suspense\n ? [`${factory.name}['response']`, `${factory.name}[\"error\"]`, 'TData']\n : [`${factory.name}['response']`, `${factory.name}[\"error\"]`, 'TData', 'TQueryData']\n\n const client = {\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n method: operation.method,\n path: new URLPath(operation.path),\n generics: clientGenerics.toString(),\n contentType,\n }\n\n generics.add([\n { type: 'TData', default: `${factory.name}[\"response\"]` },\n suspense ? undefined : { type: 'TQueryData', default: `${factory.name}[\"response\"]` },\n ])\n\n params.add([\n ...(pathParamsType === 'object' ? [getASTParams(schemas.pathParams, { typed: true })] : getASTParams(schemas.pathParams, { typed: true })),\n {\n name: 'params',\n type: `${factory.name}['queryParams']`,\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'headers',\n type: `${factory.name}['headerParams']`,\n enabled: client.withHeaders,\n required: isRequired(schemas.headerParams?.schema),\n },\n {\n name: 'data',\n type: `${factory.name}['request']`,\n enabled: client.withData,\n required: isRequired(schemas.request?.schema),\n },\n {\n name: 'options',\n type: `${factory.name}['client']['parameters']`,\n default: '{}',\n },\n ])\n\n queryKeyParams.add([\n ...(pathParamsType === 'object' ? [getASTParams(schemas.pathParams)] : getASTParams(schemas.pathParams)),\n {\n name: 'params',\n enabled: client.withQueryParams,\n required: isRequired(schemas.queryParams?.schema),\n },\n {\n name: 'data',\n enabled: client.withData,\n required: isRequired(schemas.request?.schema),\n },\n ])\n\n const hook = {\n queryKey: `${queryKey}(${queryKeyParams.toString()})`,\n }\n\n if (!queryOptions) {\n return null\n }\n\n return (\n <Template\n name={queryOptionsName}\n params={params.toString()}\n generics={generics.toString()}\n returnType={`WithRequired<${resultType}<${resultGenerics.join(', ')}>, 'queryKey'>`}\n client={client}\n hook={hook}\n infinite={infinite}\n dataReturnType={dataReturnType}\n parser={parser === 'zod' ? `${zodSchemas.response.name}.parse` : undefined}\n context={{\n factory,\n queryKey,\n }}\n />\n )\n}\n\nQueryOptions.templates = defaultTemplates\n"]}
|