@kubb/plugin-svelte-query 3.16.2 → 3.16.3
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/components-B3IxfIQc.js +487 -0
- package/dist/components-B3IxfIQc.js.map +1 -0
- package/dist/components-Bl5LenX1.cjs +545 -0
- package/dist/components-Bl5LenX1.cjs.map +1 -0
- package/dist/components.cjs +6 -27
- package/dist/components.d.cts +191 -85
- package/dist/components.d.ts +191 -85
- package/dist/components.js +3 -3
- package/dist/generators-B0aaCM9R.cjs +355 -0
- package/dist/generators-B0aaCM9R.cjs.map +1 -0
- package/dist/generators-CNk_QjGS.js +344 -0
- package/dist/generators-CNk_QjGS.js.map +1 -0
- package/dist/generators.cjs +4 -16
- package/dist/generators.d.cts +8 -9
- package/dist/generators.d.ts +8 -9
- package/dist/generators.js +4 -4
- package/dist/index.cjs +108 -136
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.js +108 -130
- package/dist/index.js.map +1 -1
- package/dist/types-BmYdmD4y.d.ts +1361 -0
- package/dist/types-DGLdNNAs.d.cts +1361 -0
- package/package.json +23 -28
- package/dist/chunk-IRUWABQ4.js +0 -398
- package/dist/chunk-IRUWABQ4.js.map +0 -1
- package/dist/chunk-NPZ54AT7.cjs +0 -289
- package/dist/chunk-NPZ54AT7.cjs.map +0 -1
- package/dist/chunk-OJL7OC3Y.cjs +0 -404
- package/dist/chunk-OJL7OC3Y.cjs.map +0 -1
- package/dist/chunk-Y534JBKZ.js +0 -286
- package/dist/chunk-Y534JBKZ.js.map +0 -1
- package/dist/components.cjs.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/generators.cjs.map +0 -1
- package/dist/generators.js.map +0 -1
- package/dist/types-BIWbWacf.d.cts +0 -140
- package/dist/types-BIWbWacf.d.ts +0 -140
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
import { File, Function, FunctionParams, Type } from "@kubb/react";
|
|
2
|
+
import { isOptional } from "@kubb/oas";
|
|
3
|
+
import { Client } from "@kubb/plugin-client/components";
|
|
4
|
+
import { getComments, getPathParams } from "@kubb/plugin-oas/utils";
|
|
5
|
+
import { URLPath } from "@kubb/core/utils";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/components/MutationKey.tsx
|
|
9
|
+
function getParams$4({}) {
|
|
10
|
+
return FunctionParams.factory({});
|
|
11
|
+
}
|
|
12
|
+
const getTransformer$1 = ({ operation, casing }) => {
|
|
13
|
+
const path = new URLPath(operation.path, { casing });
|
|
14
|
+
return [JSON.stringify({ url: path.path })].filter(Boolean);
|
|
15
|
+
};
|
|
16
|
+
function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer$1 }) {
|
|
17
|
+
const params = getParams$4({
|
|
18
|
+
pathParamsType,
|
|
19
|
+
typeSchemas
|
|
20
|
+
});
|
|
21
|
+
const keys = transformer({
|
|
22
|
+
operation,
|
|
23
|
+
schemas: typeSchemas,
|
|
24
|
+
casing: paramsCasing
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
|
|
27
|
+
name,
|
|
28
|
+
isExportable: true,
|
|
29
|
+
isIndexable: true,
|
|
30
|
+
children: /* @__PURE__ */ jsx(Function.Arrow, {
|
|
31
|
+
name,
|
|
32
|
+
export: true,
|
|
33
|
+
params: params.toConstructor(),
|
|
34
|
+
singleLine: true,
|
|
35
|
+
children: `[${keys.join(", ")}] as const`
|
|
36
|
+
})
|
|
37
|
+
}), /* @__PURE__ */ jsx(File.Source, {
|
|
38
|
+
name: typeName,
|
|
39
|
+
isExportable: true,
|
|
40
|
+
isIndexable: true,
|
|
41
|
+
isTypeOnly: true,
|
|
42
|
+
children: /* @__PURE__ */ jsx(Type, {
|
|
43
|
+
name: typeName,
|
|
44
|
+
export: true,
|
|
45
|
+
children: `ReturnType<typeof ${name}>`
|
|
46
|
+
})
|
|
47
|
+
})] });
|
|
48
|
+
}
|
|
49
|
+
MutationKey.getParams = getParams$4;
|
|
50
|
+
MutationKey.getTransformer = getTransformer$1;
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/components/Mutation.tsx
|
|
54
|
+
function getParams$3({ paramsCasing, dataReturnType, typeSchemas }) {
|
|
55
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
56
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
57
|
+
const mutationParams = FunctionParams.factory({
|
|
58
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
59
|
+
typed: true,
|
|
60
|
+
casing: paramsCasing
|
|
61
|
+
}),
|
|
62
|
+
data: typeSchemas.request?.name ? {
|
|
63
|
+
type: typeSchemas.request?.name,
|
|
64
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
65
|
+
} : void 0,
|
|
66
|
+
params: typeSchemas.queryParams?.name ? {
|
|
67
|
+
type: typeSchemas.queryParams?.name,
|
|
68
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
69
|
+
} : void 0,
|
|
70
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
71
|
+
type: typeSchemas.headerParams?.name,
|
|
72
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
73
|
+
} : void 0
|
|
74
|
+
});
|
|
75
|
+
const TRequest = mutationParams.toConstructor();
|
|
76
|
+
return FunctionParams.factory({ options: {
|
|
77
|
+
type: `
|
|
78
|
+
{
|
|
79
|
+
mutation?: CreateMutationOptions<${[
|
|
80
|
+
TData,
|
|
81
|
+
TError,
|
|
82
|
+
TRequest ? `{${TRequest}}` : "void",
|
|
83
|
+
"TContext"
|
|
84
|
+
].join(", ")}> & { client?: QueryClient },
|
|
85
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"},
|
|
86
|
+
}
|
|
87
|
+
`,
|
|
88
|
+
default: "{}"
|
|
89
|
+
} });
|
|
90
|
+
}
|
|
91
|
+
function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
|
|
92
|
+
const mutationKeyParams = MutationKey.getParams({
|
|
93
|
+
pathParamsType,
|
|
94
|
+
typeSchemas
|
|
95
|
+
});
|
|
96
|
+
const params = getParams$3({
|
|
97
|
+
paramsCasing,
|
|
98
|
+
pathParamsType,
|
|
99
|
+
dataReturnType,
|
|
100
|
+
typeSchemas
|
|
101
|
+
});
|
|
102
|
+
const clientParams = Client.getParams({
|
|
103
|
+
paramsCasing,
|
|
104
|
+
paramsType,
|
|
105
|
+
typeSchemas,
|
|
106
|
+
pathParamsType,
|
|
107
|
+
isConfigurable: true
|
|
108
|
+
});
|
|
109
|
+
const mutationParams = FunctionParams.factory({
|
|
110
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
111
|
+
typed: true,
|
|
112
|
+
casing: paramsCasing
|
|
113
|
+
}),
|
|
114
|
+
data: typeSchemas.request?.name ? {
|
|
115
|
+
type: typeSchemas.request?.name,
|
|
116
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
117
|
+
} : void 0,
|
|
118
|
+
params: typeSchemas.queryParams?.name ? {
|
|
119
|
+
type: typeSchemas.queryParams?.name,
|
|
120
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
121
|
+
} : void 0,
|
|
122
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
123
|
+
type: typeSchemas.headerParams?.name,
|
|
124
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
125
|
+
} : void 0
|
|
126
|
+
});
|
|
127
|
+
const dataParams = FunctionParams.factory({ data: {
|
|
128
|
+
mode: "object",
|
|
129
|
+
children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
|
|
130
|
+
if (value) acc[key] = {
|
|
131
|
+
...value,
|
|
132
|
+
type: void 0
|
|
133
|
+
};
|
|
134
|
+
return acc;
|
|
135
|
+
}, {})
|
|
136
|
+
} });
|
|
137
|
+
const TRequest = mutationParams.toConstructor();
|
|
138
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
139
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
140
|
+
const generics = [
|
|
141
|
+
TData,
|
|
142
|
+
TError,
|
|
143
|
+
TRequest ? `{${TRequest}}` : "void",
|
|
144
|
+
"TContext"
|
|
145
|
+
].join(", ");
|
|
146
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
147
|
+
name,
|
|
148
|
+
isExportable: true,
|
|
149
|
+
isIndexable: true,
|
|
150
|
+
children: /* @__PURE__ */ jsx(Function, {
|
|
151
|
+
name,
|
|
152
|
+
export: true,
|
|
153
|
+
params: params.toConstructor(),
|
|
154
|
+
JSDoc: { comments: getComments(operation) },
|
|
155
|
+
generics: ["TContext"],
|
|
156
|
+
children: `
|
|
157
|
+
const { mutation = {}, client: config = {} } = options ?? {}
|
|
158
|
+
const { client: queryClient, ...mutationOptions } = mutation;
|
|
159
|
+
const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
160
|
+
|
|
161
|
+
return createMutation<${generics}>({
|
|
162
|
+
mutationFn: async(${dataParams.toConstructor()}) => {
|
|
163
|
+
return ${clientName}(${clientParams.toCall()})
|
|
164
|
+
},
|
|
165
|
+
mutationKey,
|
|
166
|
+
...mutationOptions
|
|
167
|
+
}, queryClient)
|
|
168
|
+
`
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/components/QueryKey.tsx
|
|
175
|
+
function getParams$2({ pathParamsType, paramsCasing, typeSchemas }) {
|
|
176
|
+
return FunctionParams.factory({
|
|
177
|
+
pathParams: {
|
|
178
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
179
|
+
children: getPathParams(typeSchemas.pathParams, {
|
|
180
|
+
typed: true,
|
|
181
|
+
casing: paramsCasing
|
|
182
|
+
})
|
|
183
|
+
},
|
|
184
|
+
data: typeSchemas.request?.name ? {
|
|
185
|
+
type: typeSchemas.request?.name,
|
|
186
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
187
|
+
} : void 0,
|
|
188
|
+
params: typeSchemas.queryParams?.name ? {
|
|
189
|
+
type: typeSchemas.queryParams?.name,
|
|
190
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
191
|
+
} : void 0
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
const getTransformer = ({ operation, schemas, casing }) => {
|
|
195
|
+
const path = new URLPath(operation.path, { casing });
|
|
196
|
+
const keys = [
|
|
197
|
+
path.toObject({
|
|
198
|
+
type: "path",
|
|
199
|
+
stringify: true
|
|
200
|
+
}),
|
|
201
|
+
schemas.queryParams?.name ? "...(params ? [params] : [])" : void 0,
|
|
202
|
+
schemas.request?.name ? "...(data ? [data] : [])" : void 0
|
|
203
|
+
].filter(Boolean);
|
|
204
|
+
return keys;
|
|
205
|
+
};
|
|
206
|
+
function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }) {
|
|
207
|
+
const params = getParams$2({
|
|
208
|
+
pathParamsType,
|
|
209
|
+
paramsCasing,
|
|
210
|
+
typeSchemas
|
|
211
|
+
});
|
|
212
|
+
const keys = transformer({
|
|
213
|
+
operation,
|
|
214
|
+
schemas: typeSchemas,
|
|
215
|
+
casing: paramsCasing
|
|
216
|
+
});
|
|
217
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
|
|
218
|
+
name,
|
|
219
|
+
isExportable: true,
|
|
220
|
+
isIndexable: true,
|
|
221
|
+
children: /* @__PURE__ */ jsx(Function.Arrow, {
|
|
222
|
+
name,
|
|
223
|
+
export: true,
|
|
224
|
+
params: params.toConstructor(),
|
|
225
|
+
singleLine: true,
|
|
226
|
+
children: `[${keys.join(", ")}] as const`
|
|
227
|
+
})
|
|
228
|
+
}), /* @__PURE__ */ jsx(File.Source, {
|
|
229
|
+
name: typeName,
|
|
230
|
+
isExportable: true,
|
|
231
|
+
isIndexable: true,
|
|
232
|
+
isTypeOnly: true,
|
|
233
|
+
children: /* @__PURE__ */ jsx(Type, {
|
|
234
|
+
name: typeName,
|
|
235
|
+
export: true,
|
|
236
|
+
children: `ReturnType<typeof ${name}>`
|
|
237
|
+
})
|
|
238
|
+
})] });
|
|
239
|
+
}
|
|
240
|
+
QueryKey.getParams = getParams$2;
|
|
241
|
+
QueryKey.getTransformer = getTransformer;
|
|
242
|
+
|
|
243
|
+
//#endregion
|
|
244
|
+
//#region src/components/QueryOptions.tsx
|
|
245
|
+
function getParams$1({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
246
|
+
if (paramsType === "object") return FunctionParams.factory({
|
|
247
|
+
data: {
|
|
248
|
+
mode: "object",
|
|
249
|
+
children: {
|
|
250
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
251
|
+
typed: true,
|
|
252
|
+
casing: paramsCasing
|
|
253
|
+
}),
|
|
254
|
+
data: typeSchemas.request?.name ? {
|
|
255
|
+
type: typeSchemas.request?.name,
|
|
256
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
257
|
+
} : void 0,
|
|
258
|
+
params: typeSchemas.queryParams?.name ? {
|
|
259
|
+
type: typeSchemas.queryParams?.name,
|
|
260
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
261
|
+
} : void 0,
|
|
262
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
263
|
+
type: typeSchemas.headerParams?.name,
|
|
264
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
265
|
+
} : void 0
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
config: {
|
|
269
|
+
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
|
|
270
|
+
default: "{}"
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
return FunctionParams.factory({
|
|
274
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
275
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
276
|
+
children: getPathParams(typeSchemas.pathParams, {
|
|
277
|
+
typed: true,
|
|
278
|
+
casing: paramsCasing
|
|
279
|
+
}),
|
|
280
|
+
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
281
|
+
} : void 0,
|
|
282
|
+
data: typeSchemas.request?.name ? {
|
|
283
|
+
type: typeSchemas.request?.name,
|
|
284
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
285
|
+
} : void 0,
|
|
286
|
+
params: typeSchemas.queryParams?.name ? {
|
|
287
|
+
type: typeSchemas.queryParams?.name,
|
|
288
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
289
|
+
} : void 0,
|
|
290
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
291
|
+
type: typeSchemas.headerParams?.name,
|
|
292
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
293
|
+
} : void 0,
|
|
294
|
+
config: {
|
|
295
|
+
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }",
|
|
296
|
+
default: "{}"
|
|
297
|
+
}
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryKeyName }) {
|
|
301
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
302
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
303
|
+
const params = getParams$1({
|
|
304
|
+
paramsType,
|
|
305
|
+
paramsCasing,
|
|
306
|
+
pathParamsType,
|
|
307
|
+
typeSchemas
|
|
308
|
+
});
|
|
309
|
+
const clientParams = Client.getParams({
|
|
310
|
+
paramsType,
|
|
311
|
+
paramsCasing,
|
|
312
|
+
typeSchemas,
|
|
313
|
+
pathParamsType,
|
|
314
|
+
isConfigurable: true
|
|
315
|
+
});
|
|
316
|
+
const queryKeyParams = QueryKey.getParams({
|
|
317
|
+
pathParamsType,
|
|
318
|
+
paramsCasing,
|
|
319
|
+
typeSchemas
|
|
320
|
+
});
|
|
321
|
+
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => item && !item.optional ? key : void 0).filter(Boolean).join("&& ");
|
|
322
|
+
const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
|
|
323
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
324
|
+
name,
|
|
325
|
+
isExportable: true,
|
|
326
|
+
isIndexable: true,
|
|
327
|
+
children: /* @__PURE__ */ jsx(Function, {
|
|
328
|
+
name,
|
|
329
|
+
export: true,
|
|
330
|
+
params: params.toConstructor(),
|
|
331
|
+
children: `
|
|
332
|
+
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
333
|
+
return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({
|
|
334
|
+
${enabledText}
|
|
335
|
+
queryKey,
|
|
336
|
+
queryFn: async ({ signal }) => {
|
|
337
|
+
config.signal = signal
|
|
338
|
+
return ${clientName}(${clientParams.toCall()})
|
|
339
|
+
},
|
|
340
|
+
})
|
|
341
|
+
`
|
|
342
|
+
})
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
QueryOptions.getParams = getParams$1;
|
|
346
|
+
|
|
347
|
+
//#endregion
|
|
348
|
+
//#region src/components/Query.tsx
|
|
349
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
|
|
350
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
351
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
352
|
+
if (paramsType === "object") return FunctionParams.factory({
|
|
353
|
+
data: {
|
|
354
|
+
mode: "object",
|
|
355
|
+
children: {
|
|
356
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
357
|
+
typed: true,
|
|
358
|
+
casing: paramsCasing
|
|
359
|
+
}),
|
|
360
|
+
data: typeSchemas.request?.name ? {
|
|
361
|
+
type: typeSchemas.request?.name,
|
|
362
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
363
|
+
} : void 0,
|
|
364
|
+
params: typeSchemas.queryParams?.name ? {
|
|
365
|
+
type: typeSchemas.queryParams?.name,
|
|
366
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
367
|
+
} : void 0,
|
|
368
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
369
|
+
type: typeSchemas.headerParams?.name,
|
|
370
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
371
|
+
} : void 0
|
|
372
|
+
}
|
|
373
|
+
},
|
|
374
|
+
options: {
|
|
375
|
+
type: `
|
|
376
|
+
{
|
|
377
|
+
query?: Partial<CreateBaseQueryOptions<${[
|
|
378
|
+
TData,
|
|
379
|
+
TError,
|
|
380
|
+
"TData",
|
|
381
|
+
"TQueryData",
|
|
382
|
+
"TQueryKey"
|
|
383
|
+
].join(", ")}>> & { client?: QueryClient },
|
|
384
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
|
|
385
|
+
}
|
|
386
|
+
`,
|
|
387
|
+
default: "{}"
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
return FunctionParams.factory({
|
|
391
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
392
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
393
|
+
children: getPathParams(typeSchemas.pathParams, {
|
|
394
|
+
typed: true,
|
|
395
|
+
casing: paramsCasing
|
|
396
|
+
}),
|
|
397
|
+
optional: isOptional(typeSchemas.pathParams?.schema)
|
|
398
|
+
} : void 0,
|
|
399
|
+
data: typeSchemas.request?.name ? {
|
|
400
|
+
type: typeSchemas.request?.name,
|
|
401
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
402
|
+
} : void 0,
|
|
403
|
+
params: typeSchemas.queryParams?.name ? {
|
|
404
|
+
type: typeSchemas.queryParams?.name,
|
|
405
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
406
|
+
} : void 0,
|
|
407
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
408
|
+
type: typeSchemas.headerParams?.name,
|
|
409
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
410
|
+
} : void 0,
|
|
411
|
+
options: {
|
|
412
|
+
type: `
|
|
413
|
+
{
|
|
414
|
+
query?: Partial<CreateBaseQueryOptions<${[
|
|
415
|
+
TData,
|
|
416
|
+
TError,
|
|
417
|
+
"TData",
|
|
418
|
+
"TQueryData",
|
|
419
|
+
"TQueryKey"
|
|
420
|
+
].join(", ")}>> & { client?: QueryClient },
|
|
421
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : "Partial<RequestConfig> & { client?: typeof fetch }"}
|
|
422
|
+
}
|
|
423
|
+
`,
|
|
424
|
+
default: "{}"
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation }) {
|
|
429
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
430
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
431
|
+
const returnType = `CreateQueryResult<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
|
|
432
|
+
const generics = [
|
|
433
|
+
`TData = ${TData}`,
|
|
434
|
+
`TQueryData = ${TData}`,
|
|
435
|
+
`TQueryKey extends QueryKey = ${queryKeyTypeName}`
|
|
436
|
+
];
|
|
437
|
+
const queryKeyParams = QueryKey.getParams({
|
|
438
|
+
pathParamsType,
|
|
439
|
+
paramsCasing,
|
|
440
|
+
typeSchemas
|
|
441
|
+
});
|
|
442
|
+
const queryOptionsParams = QueryOptions.getParams({
|
|
443
|
+
paramsType,
|
|
444
|
+
paramsCasing,
|
|
445
|
+
pathParamsType,
|
|
446
|
+
typeSchemas
|
|
447
|
+
});
|
|
448
|
+
const params = getParams({
|
|
449
|
+
paramsType,
|
|
450
|
+
paramsCasing,
|
|
451
|
+
pathParamsType,
|
|
452
|
+
dataReturnType,
|
|
453
|
+
typeSchemas
|
|
454
|
+
});
|
|
455
|
+
const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
|
|
456
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
457
|
+
name,
|
|
458
|
+
isExportable: true,
|
|
459
|
+
isIndexable: true,
|
|
460
|
+
children: /* @__PURE__ */ jsx(Function, {
|
|
461
|
+
name,
|
|
462
|
+
export: true,
|
|
463
|
+
generics: generics.join(", "),
|
|
464
|
+
params: params.toConstructor(),
|
|
465
|
+
JSDoc: { comments: getComments(operation) },
|
|
466
|
+
children: `
|
|
467
|
+
const { query: { client: queryClient, ...queryOptions } = {}, client: config = {} } = options ?? {}
|
|
468
|
+
const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
469
|
+
|
|
470
|
+
const query = createQuery({
|
|
471
|
+
...${queryOptions},
|
|
472
|
+
queryKey,
|
|
473
|
+
...queryOptions
|
|
474
|
+
} as unknown as CreateBaseQueryOptions, queryClient) as ${returnType}
|
|
475
|
+
|
|
476
|
+
query.queryKey = queryKey as TQueryKey
|
|
477
|
+
|
|
478
|
+
return query
|
|
479
|
+
`
|
|
480
|
+
})
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
Query.getParams = getParams;
|
|
484
|
+
|
|
485
|
+
//#endregion
|
|
486
|
+
export { Mutation, MutationKey, Query, QueryKey, QueryOptions };
|
|
487
|
+
//# sourceMappingURL=components-B3IxfIQc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-B3IxfIQc.js","names":["getParams","getTransformer: Transformer","getTransformer","getParams","getParams","getTransformer: Transformer","getParams"],"sources":["../src/components/MutationKey.tsx","../src/components/Mutation.tsx","../src/components/QueryKey.tsx","../src/components/QueryOptions.tsx","../src/components/Query.tsx"],"sourcesContent":["import { URLPath } from '@kubb/core/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\n\nimport type { Operation } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSvelteQuery, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({}: GetParamsProps) {\n return FunctionParams.factory({})\n}\n\nconst getTransformer: Transformer = ({ operation, casing }) => {\n const path = new URLPath(operation.path, { casing })\n\n return [JSON.stringify({ url: path.path })].filter(Boolean)\n}\n\nexport function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, typeSchemas })\n const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nMutationKey.getParams = getParams\nMutationKey.getTransformer = getTransformer\n","import { File, Function, FunctionParams } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport type { Params } from '@kubb/react/types'\nimport type { ReactNode } from 'react'\nimport type { PluginSvelteQuery } from '../types.ts'\nimport { MutationKey } from './MutationKey.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n typeName: string\n clientName: string\n mutationKeyName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']\n dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']\n pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsCasing, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const mutationParams = FunctionParams.factory({\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n })\n const TRequest = mutationParams.toConstructor()\n\n return FunctionParams.factory({\n options: {\n type: `\n{\n mutation?: CreateMutationOptions<${[TData, TError, TRequest ? `{${TRequest}}` : 'void', 'TContext'].join(', ')}> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'},\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Mutation({\n name,\n clientName,\n paramsCasing,\n paramsType,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n mutationKeyName,\n}: Props): ReactNode {\n const mutationKeyParams = MutationKey.getParams({\n pathParamsType,\n typeSchemas,\n })\n\n const params = getParams({\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const clientParams = Client.getParams({\n paramsCasing,\n paramsType,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n const mutationParams = FunctionParams.factory({\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n })\n const dataParams = FunctionParams.factory({\n data: {\n // No use of pathParams because useMutation can only take one argument in object form,\n // see https://tanstack.com/query/latest/docs/framework/react/reference/useMutation#usemutation\n mode: 'object',\n children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {\n if (value) {\n acc[key] = {\n ...value,\n type: undefined,\n }\n }\n\n return acc\n }, {} as Params),\n },\n })\n\n const TRequest = mutationParams.toConstructor()\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const generics = [TData, TError, TRequest ? `{${TRequest}}` : 'void', 'TContext'].join(', ')\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n generics={['TContext']}\n >\n {`\n const { mutation = {}, client: config = {} } = options ?? {}\n const { client: queryClient, ...mutationOptions } = mutation;\n const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})\n\n return createMutation<${generics}>({\n mutationFn: async(${dataParams.toConstructor()}) => {\n return ${clientName}(${clientParams.toCall()})\n },\n mutationKey,\n ...mutationOptions\n }, queryClient)\n `}\n </Function>\n </File.Source>\n )\n}\n","import { URLPath } from '@kubb/core/utils'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams, Type } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSvelteQuery, Transformer } from '../types'\n\ntype Props = {\n name: string\n typeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']\n transformer: Transformer | undefined\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']\n pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {\n return FunctionParams.factory({\n pathParams: {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n })\n}\n\nconst getTransformer: Transformer = ({ operation, schemas, casing }) => {\n const path = new URLPath(operation.path, { casing })\n const keys = [\n path.toObject({\n type: 'path',\n stringify: true,\n }),\n schemas.queryParams?.name ? '...(params ? [params] : [])' : undefined,\n schemas.request?.name ? '...(data ? [data] : [])' : undefined,\n ].filter(Boolean)\n\n return keys\n}\n\nexport function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {\n const params = getParams({ pathParamsType, paramsCasing, typeSchemas })\n const keys = transformer({\n operation,\n schemas: typeSchemas,\n casing: paramsCasing,\n })\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Function.Arrow name={name} export params={params.toConstructor()} singleLine>\n {`[${keys.join(', ')}] as const`}\n </Function.Arrow>\n </File.Source>\n <File.Source name={typeName} isExportable isIndexable isTypeOnly>\n <Type name={typeName} export>\n {`ReturnType<typeof ${name}>`}\n </Type>\n </File.Source>\n </>\n )\n}\n\nQueryKey.getParams = getParams\nQueryKey.getTransformer = getTransformer\n","import { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\n\nimport type { ReactNode } from 'react'\n\nimport { isOptional } from '@kubb/oas'\nimport { Client } from '@kubb/plugin-client/components'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport type { PluginSvelteQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\n\ntype Props = {\n name: string\n clientName: string\n queryKeyName: string\n typeSchemas: OperationSchemas\n paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name\n ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }`\n : 'Partial<RequestConfig> & { client?: typeof fetch }',\n default: '{}',\n },\n })\n}\n\nexport function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, dataReturnType, pathParamsType, queryKeyName }: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const clientParams = Client.getParams({\n paramsType,\n paramsCasing,\n typeSchemas,\n pathParamsType,\n isConfigurable: true,\n })\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n paramsCasing,\n typeSchemas,\n })\n\n const enabled = Object.entries(queryKeyParams.flatParams)\n .map(([key, item]) => (item && !item.optional ? key : undefined))\n .filter(Boolean)\n .join('&& ')\n\n const enabledText = enabled ? `enabled: !!(${enabled}),` : ''\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function name={name} export params={params.toConstructor()}>\n {`\n const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})\n return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({\n ${enabledText}\n queryKey,\n queryFn: async ({ signal }) => {\n config.signal = signal\n return ${clientName}(${clientParams.toCall()})\n },\n })\n`}\n </Function>\n </File.Source>\n )\n}\n\nQueryOptions.getParams = getParams\n","import { File, Function, FunctionParams } from '@kubb/react'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport type { ReactNode } from 'react'\nimport type { PluginSvelteQuery } from '../types.ts'\nimport { QueryKey } from './QueryKey.tsx'\nimport { QueryOptions } from './QueryOptions.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n queryOptionsName: string\n queryKeyName: string\n queryKeyTypeName: string\n typeSchemas: OperationSchemas\n operation: Operation\n paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']\n paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']\n pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']\n dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n options: {\n type: `\n{\n query?: Partial<CreateBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n options: {\n type: `\n{\n query?: Partial<CreateBaseQueryOptions<${[TData, TError, 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>> & { client?: QueryClient },\n client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof fetch }` : 'Partial<RequestConfig> & { client?: typeof fetch }'}\n}\n`,\n default: '{}',\n },\n })\n}\n\nexport function Query({\n name,\n queryKeyTypeName,\n queryOptionsName,\n queryKeyName,\n paramsType,\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n operation,\n}: Props): ReactNode {\n const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n const returnType = `CreateQueryResult<${['TData', TError].join(', ')}> & { queryKey: TQueryKey }`\n const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]\n\n const queryKeyParams = QueryKey.getParams({\n pathParamsType,\n paramsCasing,\n typeSchemas,\n })\n const queryOptionsParams = QueryOptions.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\n const params = getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n dataReturnType,\n typeSchemas,\n })\n\n const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n export\n generics={generics.join(', ')}\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {`\n const { query: { client: queryClient, ...queryOptions } = {}, client: config = {} } = options ?? {}\n const queryKey = queryOptions?.queryKey ?? ${queryKeyName}(${queryKeyParams.toCall()})\n\n const query = createQuery({\n ...${queryOptions},\n queryKey,\n ...queryOptions\n } as unknown as CreateBaseQueryOptions, queryClient) as ${returnType}\n\n query.queryKey = queryKey as TQueryKey\n\n return query\n `}\n </Function>\n </File.Source>\n )\n}\n\nQuery.getParams = getParams\n"],"mappings":";;;;;;;;AAuBA,SAASA,YAAU,EAAkB,EAAE;AACrC,QAAO,eAAe,QAAQ,CAAE,EAAC;AAClC;AAED,MAAMC,mBAA8B,CAAC,EAAE,WAAW,QAAQ,KAAK;CAC7D,MAAM,OAAO,IAAI,QAAQ,UAAU,MAAM,EAAE,OAAQ;AAEnD,QAAO,CAAC,KAAK,UAAU,EAAE,KAAK,KAAK,KAAM,EAAC,AAAC,EAAC,OAAO,QAAQ;AAC5D;AAED,SAAgB,YAAY,EAAE,MAAM,aAAa,cAAc,gBAAgB,WAAW,UAAU,cAAcC,kBAAuB,EAAa;CACpJ,MAAM,SAASF,YAAU;EAAE;EAAgB;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