@kubb/plugin-svelte-query 3.16.2 → 3.16.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/components-B3IxfIQc.js +487 -0
  2. package/dist/components-B3IxfIQc.js.map +1 -0
  3. package/dist/components-Bl5LenX1.cjs +545 -0
  4. package/dist/components-Bl5LenX1.cjs.map +1 -0
  5. package/dist/components.cjs +6 -27
  6. package/dist/components.d.cts +191 -85
  7. package/dist/components.d.ts +191 -85
  8. package/dist/components.js +3 -3
  9. package/dist/generators-B0aaCM9R.cjs +355 -0
  10. package/dist/generators-B0aaCM9R.cjs.map +1 -0
  11. package/dist/generators-CNk_QjGS.js +344 -0
  12. package/dist/generators-CNk_QjGS.js.map +1 -0
  13. package/dist/generators.cjs +4 -16
  14. package/dist/generators.d.cts +8 -9
  15. package/dist/generators.d.ts +8 -9
  16. package/dist/generators.js +4 -4
  17. package/dist/index.cjs +108 -136
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +6 -8
  20. package/dist/index.d.ts +6 -8
  21. package/dist/index.js +108 -130
  22. package/dist/index.js.map +1 -1
  23. package/dist/types-BmYdmD4y.d.ts +1361 -0
  24. package/dist/types-DGLdNNAs.d.cts +1361 -0
  25. package/package.json +23 -28
  26. package/dist/chunk-IRUWABQ4.js +0 -398
  27. package/dist/chunk-IRUWABQ4.js.map +0 -1
  28. package/dist/chunk-NPZ54AT7.cjs +0 -289
  29. package/dist/chunk-NPZ54AT7.cjs.map +0 -1
  30. package/dist/chunk-OJL7OC3Y.cjs +0 -404
  31. package/dist/chunk-OJL7OC3Y.cjs.map +0 -1
  32. package/dist/chunk-Y534JBKZ.js +0 -286
  33. package/dist/chunk-Y534JBKZ.js.map +0 -1
  34. package/dist/components.cjs.map +0 -1
  35. package/dist/components.js.map +0 -1
  36. package/dist/generators.cjs.map +0 -1
  37. package/dist/generators.js.map +0 -1
  38. package/dist/types-BIWbWacf.d.cts +0 -140
  39. package/dist/types-BIWbWacf.d.ts +0 -140
@@ -0,0 +1,355 @@
1
+ const require_components = require('./components-Bl5LenX1.cjs');
2
+ const __kubb_plugin_oas = require_components.__toESM(require("@kubb/plugin-oas"));
3
+ const __kubb_plugin_ts = require_components.__toESM(require("@kubb/plugin-ts"));
4
+ const __kubb_plugin_zod = require_components.__toESM(require("@kubb/plugin-zod"));
5
+ const __kubb_react = require_components.__toESM(require("@kubb/react"));
6
+ const __kubb_plugin_client_components = require_components.__toESM(require("@kubb/plugin-client/components"));
7
+ const __kubb_plugin_oas_utils = require_components.__toESM(require("@kubb/plugin-oas/utils"));
8
+ const __kubb_react_jsx_runtime = require_components.__toESM(require("@kubb/react/jsx-runtime"));
9
+ const __kubb_plugin_client = require_components.__toESM(require("@kubb/plugin-client"));
10
+ const __kubb_plugin_oas_hooks = require_components.__toESM(require("@kubb/plugin-oas/hooks"));
11
+ const remeda = require_components.__toESM(require("remeda"));
12
+
13
+ //#region src/generators/queryGenerator.tsx
14
+ const queryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
15
+ name: "svelte-query",
16
+ Operation({ options, operation }) {
17
+ const { plugin: { options: { output } }, pluginManager } = (0, __kubb_react.useApp)();
18
+ const oas = (0, __kubb_plugin_oas_hooks.useOas)();
19
+ const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
20
+ const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
21
+ const isMutation = (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
22
+ const importPath = options.query ? options.query.importPath : "@tanstack/svelte-query";
23
+ const query = {
24
+ name: getName(operation, {
25
+ type: "function",
26
+ prefix: "create"
27
+ }),
28
+ typeName: getName(operation, { type: "type" }),
29
+ file: getFile(operation, { prefix: "create" })
30
+ };
31
+ const hasClientPlugin = !!pluginManager.getPluginByKey([__kubb_plugin_client.pluginClientName]);
32
+ const client = {
33
+ name: hasClientPlugin ? getName(operation, {
34
+ type: "function",
35
+ pluginKey: [__kubb_plugin_client.pluginClientName]
36
+ }) : getName(operation, { type: "function" }),
37
+ file: getFile(operation, { pluginKey: [__kubb_plugin_client.pluginClientName] })
38
+ };
39
+ const queryOptions = { name: getName(operation, {
40
+ type: "function",
41
+ suffix: "QueryOptions"
42
+ }) };
43
+ const queryKey = {
44
+ name: getName(operation, {
45
+ type: "const",
46
+ suffix: "QueryKey"
47
+ }),
48
+ typeName: getName(operation, {
49
+ type: "type",
50
+ suffix: "QueryKey"
51
+ })
52
+ };
53
+ const type = {
54
+ file: getFile(operation, { pluginKey: [__kubb_plugin_ts.pluginTsName] }),
55
+ schemas: getSchemas(operation, {
56
+ pluginKey: [__kubb_plugin_ts.pluginTsName],
57
+ type: "type"
58
+ })
59
+ };
60
+ const zod = {
61
+ file: getFile(operation, { pluginKey: [__kubb_plugin_zod.pluginZodName] }),
62
+ schemas: getSchemas(operation, {
63
+ pluginKey: [__kubb_plugin_zod.pluginZodName],
64
+ type: "function"
65
+ })
66
+ };
67
+ if (!isQuery || isMutation) return null;
68
+ return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.File, {
69
+ baseName: query.file.baseName,
70
+ path: query.file.path,
71
+ meta: query.file.meta,
72
+ banner: (0, __kubb_plugin_oas_utils.getBanner)({
73
+ oas,
74
+ output,
75
+ config: pluginManager.config
76
+ }),
77
+ footer: (0, __kubb_plugin_oas_utils.getFooter)({
78
+ oas,
79
+ output
80
+ }),
81
+ children: [
82
+ options.parser === "zod" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
83
+ name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
84
+ root: query.file.path,
85
+ path: zod.file.path
86
+ }),
87
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
88
+ name: "fetch",
89
+ path: options.client.importPath
90
+ }),
91
+ !!hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
92
+ name: [client.name],
93
+ root: query.file.path,
94
+ path: client.file.path
95
+ }),
96
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
97
+ name: ["RequestConfig", "ResponseErrorConfig"],
98
+ path: options.client.importPath,
99
+ isTypeOnly: true
100
+ }),
101
+ options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
102
+ name: ["ResponseConfig"],
103
+ path: options.client.importPath,
104
+ isTypeOnly: true
105
+ }),
106
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
107
+ name: [
108
+ type.schemas.request?.name,
109
+ type.schemas.response.name,
110
+ type.schemas.pathParams?.name,
111
+ type.schemas.queryParams?.name,
112
+ type.schemas.headerParams?.name,
113
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
114
+ ].filter(Boolean),
115
+ root: query.file.path,
116
+ path: type.file.path,
117
+ isTypeOnly: true
118
+ }),
119
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.QueryKey, {
120
+ name: queryKey.name,
121
+ typeName: queryKey.typeName,
122
+ operation,
123
+ pathParamsType: options.pathParamsType,
124
+ typeSchemas: type.schemas,
125
+ paramsCasing: options.paramsCasing,
126
+ transformer: options.queryKey
127
+ }),
128
+ !hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_plugin_client_components.Client, {
129
+ name: client.name,
130
+ baseURL: options.client.baseURL,
131
+ operation,
132
+ typeSchemas: type.schemas,
133
+ zodSchemas: zod.schemas,
134
+ dataReturnType: options.client.dataReturnType,
135
+ paramsCasing: options.paramsCasing,
136
+ paramsType: options.paramsType,
137
+ pathParamsType: options.pathParamsType,
138
+ parser: options.parser
139
+ }),
140
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
141
+ name: ["queryOptions"],
142
+ path: importPath
143
+ }),
144
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.QueryOptions, {
145
+ name: queryOptions.name,
146
+ clientName: client.name,
147
+ queryKeyName: queryKey.name,
148
+ typeSchemas: type.schemas,
149
+ paramsCasing: options.paramsCasing,
150
+ paramsType: options.paramsType,
151
+ pathParamsType: options.pathParamsType,
152
+ dataReturnType: options.client.dataReturnType
153
+ }),
154
+ options.query && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [
155
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
156
+ name: ["createQuery"],
157
+ path: importPath
158
+ }),
159
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
160
+ name: [
161
+ "QueryKey",
162
+ "QueryClient",
163
+ "CreateBaseQueryOptions",
164
+ "CreateQueryResult"
165
+ ],
166
+ path: importPath,
167
+ isTypeOnly: true
168
+ }),
169
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.Query, {
170
+ name: query.name,
171
+ queryOptionsName: queryOptions.name,
172
+ typeSchemas: type.schemas,
173
+ pathParamsType: options.pathParamsType,
174
+ operation,
175
+ paramsCasing: options.paramsCasing,
176
+ paramsType: options.paramsType,
177
+ dataReturnType: options.client.dataReturnType,
178
+ queryKeyName: queryKey.name,
179
+ queryKeyTypeName: queryKey.typeName
180
+ })
181
+ ] })
182
+ ]
183
+ });
184
+ }
185
+ });
186
+
187
+ //#endregion
188
+ //#region src/generators/mutationGenerator.tsx
189
+ const mutationGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
190
+ name: "svelte-query",
191
+ Operation({ options, operation }) {
192
+ const { plugin: { options: { output } }, pluginManager } = (0, __kubb_react.useApp)();
193
+ const oas = (0, __kubb_plugin_oas_hooks.useOas)();
194
+ const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
195
+ const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
196
+ const isMutation = !isQuery && (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
197
+ const importPath = options.mutation ? options.mutation.importPath : "@tanstack/svelte-query";
198
+ const mutation = {
199
+ name: getName(operation, {
200
+ type: "function",
201
+ prefix: "create"
202
+ }),
203
+ typeName: getName(operation, { type: "type" }),
204
+ file: getFile(operation, { prefix: "create" })
205
+ };
206
+ const type = {
207
+ file: getFile(operation, { pluginKey: [__kubb_plugin_ts.pluginTsName] }),
208
+ schemas: getSchemas(operation, {
209
+ pluginKey: [__kubb_plugin_ts.pluginTsName],
210
+ type: "type"
211
+ })
212
+ };
213
+ const zod = {
214
+ file: getFile(operation, { pluginKey: [__kubb_plugin_zod.pluginZodName] }),
215
+ schemas: getSchemas(operation, {
216
+ pluginKey: [__kubb_plugin_zod.pluginZodName],
217
+ type: "function"
218
+ })
219
+ };
220
+ const hasClientPlugin = !!pluginManager.getPluginByKey([__kubb_plugin_client.pluginClientName]);
221
+ const client = {
222
+ name: hasClientPlugin ? getName(operation, {
223
+ type: "function",
224
+ pluginKey: [__kubb_plugin_client.pluginClientName]
225
+ }) : getName(operation, { type: "function" }),
226
+ file: getFile(operation, { pluginKey: [__kubb_plugin_client.pluginClientName] })
227
+ };
228
+ const mutationKey = {
229
+ name: getName(operation, {
230
+ type: "const",
231
+ suffix: "MutationKey"
232
+ }),
233
+ typeName: getName(operation, {
234
+ type: "type",
235
+ suffix: "MutationKey"
236
+ })
237
+ };
238
+ if (!isMutation) return null;
239
+ return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.File, {
240
+ baseName: mutation.file.baseName,
241
+ path: mutation.file.path,
242
+ meta: mutation.file.meta,
243
+ banner: (0, __kubb_plugin_oas_utils.getBanner)({
244
+ oas,
245
+ output,
246
+ config: pluginManager.config
247
+ }),
248
+ footer: (0, __kubb_plugin_oas_utils.getFooter)({
249
+ oas,
250
+ output
251
+ }),
252
+ children: [
253
+ options.parser === "zod" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
254
+ name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
255
+ root: mutation.file.path,
256
+ path: zod.file.path
257
+ }),
258
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
259
+ name: "fetch",
260
+ path: options.client.importPath
261
+ }),
262
+ !!hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
263
+ name: [client.name],
264
+ root: mutation.file.path,
265
+ path: client.file.path
266
+ }),
267
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
268
+ name: [
269
+ "RequestConfig",
270
+ "ResponseConfig",
271
+ "ResponseErrorConfig"
272
+ ],
273
+ path: options.client.importPath,
274
+ isTypeOnly: true
275
+ }),
276
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
277
+ name: [
278
+ type.schemas.request?.name,
279
+ type.schemas.response.name,
280
+ type.schemas.pathParams?.name,
281
+ type.schemas.queryParams?.name,
282
+ type.schemas.headerParams?.name,
283
+ ...type.schemas.statusCodes?.map((item) => item.name) || []
284
+ ].filter(Boolean),
285
+ root: mutation.file.path,
286
+ path: type.file.path,
287
+ isTypeOnly: true
288
+ }),
289
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.MutationKey, {
290
+ name: mutationKey.name,
291
+ typeName: mutationKey.typeName,
292
+ operation,
293
+ paramsCasing: options.paramsCasing,
294
+ pathParamsType: options.pathParamsType,
295
+ typeSchemas: type.schemas,
296
+ transformer: options.mutationKey
297
+ }),
298
+ !hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_plugin_client_components.Client, {
299
+ name: client.name,
300
+ baseURL: options.client.baseURL,
301
+ operation,
302
+ typeSchemas: type.schemas,
303
+ zodSchemas: zod.schemas,
304
+ dataReturnType: options.client.dataReturnType,
305
+ paramsCasing: options.paramsCasing,
306
+ paramsType: options.paramsType,
307
+ pathParamsType: options.pathParamsType,
308
+ parser: options.parser
309
+ }),
310
+ options.mutation && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [
311
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
312
+ name: ["createMutation"],
313
+ path: importPath
314
+ }),
315
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
316
+ name: [
317
+ "CreateMutationOptions",
318
+ "CreateMutationResult",
319
+ "QueryClient"
320
+ ],
321
+ path: importPath,
322
+ isTypeOnly: true
323
+ }),
324
+ /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(require_components.Mutation, {
325
+ name: mutation.name,
326
+ clientName: client.name,
327
+ typeName: mutation.typeName,
328
+ typeSchemas: type.schemas,
329
+ operation,
330
+ paramsCasing: options.paramsCasing,
331
+ dataReturnType: options.client.dataReturnType,
332
+ paramsType: options.paramsType,
333
+ pathParamsType: options.pathParamsType,
334
+ mutationKeyName: mutationKey.name
335
+ })
336
+ ] })
337
+ ]
338
+ });
339
+ }
340
+ });
341
+
342
+ //#endregion
343
+ Object.defineProperty(exports, 'mutationGenerator', {
344
+ enumerable: true,
345
+ get: function () {
346
+ return mutationGenerator;
347
+ }
348
+ });
349
+ Object.defineProperty(exports, 'queryGenerator', {
350
+ enumerable: true,
351
+ get: function () {
352
+ return queryGenerator;
353
+ }
354
+ });
355
+ //# sourceMappingURL=generators-B0aaCM9R.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generators-B0aaCM9R.cjs","names":["pluginClientName","pluginTsName","pluginZodName","File","QueryKey","Client","QueryOptions","Query","pluginTsName","pluginZodName","pluginClientName","File","MutationKey","Client","Mutation"],"sources":["../src/generators/queryGenerator.tsx","../src/generators/mutationGenerator.tsx"],"sourcesContent":["import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSvelteQuery } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSvelteQuery>({\n name: 'svelte-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginSvelteQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = typeof options.query === 'boolean' ? true : options.query?.methods.some((method) => operation.method === method)\n const isMutation = difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some(\n (method) => operation.method === method,\n )\n const importPath = options.query ? options.query.importPath : '@tanstack/svelte-query'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const queryOptions = {\n name: getName(operation, { type: 'function', suffix: 'QueryOptions' }),\n }\n\n const queryKey = {\n name: getName(operation, { type: 'const', suffix: 'QueryKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'QueryKey' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n if (!isQuery || isMutation) {\n return null\n }\n\n return (\n <File\n baseName={query.file.baseName}\n path={query.file.path}\n meta={query.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={query.file.path} path={zod.file.path} />\n )}\n <File.Import name={'fetch'} path={options.client.importPath} />\n {!!hasClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n {options.client.dataReturnType === 'full' && <File.Import name={['ResponseConfig']} path={options.client.importPath} isTypeOnly />}\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={query.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <QueryKey\n name={queryKey.name}\n typeName={queryKey.typeName}\n operation={operation}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.queryKey}\n />\n\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <File.Import name={['queryOptions']} path={importPath} />\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n queryKeyName={queryKey.name}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n dataReturnType={options.client.dataReturnType}\n />\n {options.query && (\n <>\n <File.Import name={['createQuery']} path={importPath} />\n <File.Import name={['QueryKey', 'QueryClient', 'CreateBaseQueryOptions', 'CreateQueryResult']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n pathParamsType={options.pathParamsType}\n operation={operation}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n dataReturnType={options.client.dataReturnType}\n queryKeyName={queryKey.name}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n","import { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { pluginZodName } from '@kubb/plugin-zod'\nimport { File, useApp } from '@kubb/react'\nimport { difference } from 'remeda'\nimport { Mutation, MutationKey } from '../components'\nimport type { PluginSvelteQuery } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSvelteQuery>({\n name: 'svelte-query',\n Operation({ options, operation }) {\n const {\n plugin: {\n options: { output },\n },\n pluginManager,\n } = useApp<PluginSvelteQuery>()\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager()\n\n const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)\n const isMutation =\n !isQuery &&\n difference(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method)\n\n const importPath = options.mutation ? options.mutation.importPath : '@tanstack/svelte-query'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'create' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'create' }),\n }\n\n const type = {\n file: getFile(operation, { pluginKey: [pluginTsName] }),\n //todo remove type?\n schemas: getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n const client = {\n name: hasClientPlugin\n ? getName(operation, {\n type: 'function',\n pluginKey: [pluginClientName],\n })\n : getName(operation, {\n type: 'function',\n }),\n file: getFile(operation, { pluginKey: [pluginClientName] }),\n }\n\n const mutationKey = {\n name: getName(operation, { type: 'const', suffix: 'MutationKey' }),\n typeName: getName(operation, { type: 'type', suffix: 'MutationKey' }),\n }\n\n if (!isMutation) {\n return null\n }\n\n return (\n <File\n baseName={mutation.file.baseName}\n path={mutation.file.path}\n meta={mutation.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {options.parser === 'zod' && (\n <File.Import name={[zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean)} root={mutation.file.path} path={zod.file.path} />\n )}\n <File.Import name={'fetch'} path={options.client.importPath} />\n {!!hasClientPlugin && <File.Import name={[client.name]} root={mutation.file.path} path={client.file.path} />}\n <File.Import name={['RequestConfig', 'ResponseConfig', 'ResponseErrorConfig']} path={options.client.importPath} isTypeOnly />\n <File.Import\n name={[\n type.schemas.request?.name,\n type.schemas.response.name,\n type.schemas.pathParams?.name,\n type.schemas.queryParams?.name,\n type.schemas.headerParams?.name,\n ...(type.schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={mutation.file.path}\n path={type.file.path}\n isTypeOnly\n />\n\n <MutationKey\n name={mutationKey.name}\n typeName={mutationKey.typeName}\n operation={operation}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n transformer={options.mutationKey}\n />\n {!hasClientPlugin && (\n <Client\n name={client.name}\n baseURL={options.client.baseURL}\n operation={operation}\n typeSchemas={type.schemas}\n zodSchemas={zod.schemas}\n dataReturnType={options.client.dataReturnType}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n {options.mutation && (\n <>\n <File.Import name={['createMutation']} path={importPath} />\n <File.Import name={['CreateMutationOptions', 'CreateMutationResult', 'QueryClient']} path={importPath} isTypeOnly />\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n paramsCasing={options.paramsCasing}\n dataReturnType={options.client.dataReturnType}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n />\n </>\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;AAYA,MAAa,6DAAyD;CACpE,MAAM;CACN,UAAU,EAAE,SAAS,WAAW,EAAE;EAChC,MAAM,EACJ,QAAQ,EACN,SAAS,EAAE,QAAQ,EACpB,EACD,eACD,6BAA8B;EAC/B,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,SAAS,qDAAwB;EAE9D,MAAM,UAAU,OAAO,QAAQ,UAAU,YAAY,OAAO,QAAQ,OAAO,QAAQ,KAAK,CAAC,WAAW,UAAU,WAAW,OAAO;EAChI,MAAM,oCAAwB,QAAQ,WAAW,QAAQ,SAAS,UAAU,CAAE,GAAE,QAAQ,QAAQ,QAAQ,MAAM,UAAU,CAAE,EAAC,CAAC,KAC1H,CAAC,WAAW,UAAU,WAAW,OAClC;EACD,MAAM,aAAa,QAAQ,QAAQ,QAAQ,MAAM,aAAa;EAE9D,MAAM,QAAQ;GACZ,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;GAAU,EAAC;GAChE,UAAU,QAAQ,WAAW,EAAE,MAAM,OAAQ,EAAC;GAC9C,MAAM,QAAQ,WAAW,EAAE,QAAQ,SAAU,EAAC;EAC/C;EAED,MAAM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