@kubb/plugin-swr 4.12.3 → 4.12.5

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.
@@ -25,29 +25,29 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
25
25
  }) : target, mod));
26
26
 
27
27
  //#endregion
28
- const require_components = require('./components-Djw0ll1l.cjs');
28
+ const require_components = require('./components-DD7X6DkL.cjs');
29
29
  let node_path = require("node:path");
30
30
  node_path = __toESM(node_path);
31
- let __kubb_plugin_client = require("@kubb/plugin-client");
32
- let __kubb_plugin_ts = require("@kubb/plugin-ts");
33
- let __kubb_plugin_zod = require("@kubb/plugin-zod");
34
- let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
35
- let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
36
- let __kubb_react_fabric = require("@kubb/react-fabric");
37
- let __kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
38
- let __kubb_core_hooks = require("@kubb/core/hooks");
39
- let __kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
40
- let __kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
31
+ let _kubb_plugin_client = require("@kubb/plugin-client");
32
+ let _kubb_plugin_ts = require("@kubb/plugin-ts");
33
+ let _kubb_plugin_zod = require("@kubb/plugin-zod");
34
+ let _kubb_plugin_client_components = require("@kubb/plugin-client/components");
35
+ let _kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
36
+ let _kubb_react_fabric = require("@kubb/react-fabric");
37
+ let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
38
+ let _kubb_core_hooks = require("@kubb/core/hooks");
39
+ let _kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
40
+ let _kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
41
41
  let remeda = require("remeda");
42
42
 
43
43
  //#region src/generators/mutationGenerator.tsx
44
- const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
44
+ const mutationGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
45
45
  name: "swr-mutation",
46
46
  Operation({ config, operation, generator, plugin }) {
47
47
  const { options, options: { output } } = plugin;
48
- const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
49
- const oas = (0, __kubb_plugin_oas_hooks.useOas)();
50
- const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)(generator);
48
+ const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
49
+ const oas = (0, _kubb_plugin_oas_hooks.useOas)();
50
+ const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
51
51
  const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
52
52
  const isMutation = options.mutation !== false && !isQuery && (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
53
53
  const importPath = options.mutation ? options.mutation.importPath : "swr";
@@ -60,26 +60,26 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
60
60
  file: getFile(operation, { prefix: "use" })
61
61
  };
62
62
  const type = {
63
- file: getFile(operation, { pluginKey: [__kubb_plugin_ts.pluginTsName] }),
63
+ file: getFile(operation, { pluginKey: [_kubb_plugin_ts.pluginTsName] }),
64
64
  schemas: getSchemas(operation, {
65
- pluginKey: [__kubb_plugin_ts.pluginTsName],
65
+ pluginKey: [_kubb_plugin_ts.pluginTsName],
66
66
  type: "type"
67
67
  })
68
68
  };
69
69
  const zod = {
70
- file: getFile(operation, { pluginKey: [__kubb_plugin_zod.pluginZodName] }),
70
+ file: getFile(operation, { pluginKey: [_kubb_plugin_zod.pluginZodName] }),
71
71
  schemas: getSchemas(operation, {
72
- pluginKey: [__kubb_plugin_zod.pluginZodName],
72
+ pluginKey: [_kubb_plugin_zod.pluginZodName],
73
73
  type: "function"
74
74
  })
75
75
  };
76
- const shouldUseClientPlugin = !!pluginManager.getPluginByKey([__kubb_plugin_client.pluginClientName]) && options.client.clientType !== "class";
76
+ const shouldUseClientPlugin = !!pluginManager.getPluginByKey([_kubb_plugin_client.pluginClientName]) && options.client.clientType !== "class";
77
77
  const client = {
78
78
  name: shouldUseClientPlugin ? getName(operation, {
79
79
  type: "function",
80
- pluginKey: [__kubb_plugin_client.pluginClientName]
80
+ pluginKey: [_kubb_plugin_client.pluginClientName]
81
81
  }) : getName(operation, { type: "function" }),
82
- file: getFile(operation, { pluginKey: [__kubb_plugin_client.pluginClientName] })
82
+ file: getFile(operation, { pluginKey: [_kubb_plugin_client.pluginClientName] })
83
83
  };
84
84
  const mutationKey = {
85
85
  name: getName(operation, {
@@ -92,79 +92,79 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
92
92
  })
93
93
  };
94
94
  if (!isMutation) return null;
95
- return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric.File, {
95
+ return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
96
96
  baseName: mutation.file.baseName,
97
97
  path: mutation.file.path,
98
98
  meta: mutation.file.meta,
99
- banner: (0, __kubb_plugin_oas_utils.getBanner)({
99
+ banner: (0, _kubb_plugin_oas_utils.getBanner)({
100
100
  oas,
101
101
  output,
102
102
  config: pluginManager.config
103
103
  }),
104
- footer: (0, __kubb_plugin_oas_utils.getFooter)({
104
+ footer: (0, _kubb_plugin_oas_utils.getFooter)({
105
105
  oas,
106
106
  output
107
107
  }),
108
108
  children: [
109
- options.parser === "zod" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
109
+ options.parser === "zod" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
110
110
  name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
111
111
  root: mutation.file.path,
112
112
  path: zod.file.path
113
113
  }),
114
- options.client.importPath ? /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
115
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
114
+ options.client.importPath ? /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
115
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
116
116
  name: "fetch",
117
117
  path: options.client.importPath
118
118
  }),
119
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
119
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
120
120
  name: ["RequestConfig", "ResponseErrorConfig"],
121
121
  path: options.client.importPath,
122
122
  isTypeOnly: true
123
123
  }),
124
- options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
124
+ options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
125
125
  name: ["ResponseConfig"],
126
126
  path: options.client.importPath,
127
127
  isTypeOnly: true
128
128
  })
129
- ] }) : /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
130
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
129
+ ] }) : /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
130
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
131
131
  name: ["fetch"],
132
132
  root: mutation.file.path,
133
133
  path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts")
134
134
  }),
135
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
135
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
136
136
  name: ["RequestConfig", "ResponseErrorConfig"],
137
137
  root: mutation.file.path,
138
138
  path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
139
139
  isTypeOnly: true
140
140
  }),
141
- options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
141
+ options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
142
142
  name: ["ResponseConfig"],
143
143
  root: mutation.file.path,
144
144
  path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
145
145
  isTypeOnly: true
146
146
  })
147
147
  ] }),
148
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
148
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
149
149
  name: "useSWRMutation",
150
150
  path: importPath
151
151
  }),
152
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
152
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
153
153
  name: ["SWRMutationConfiguration", "SWRMutationResponse"],
154
154
  path: importPath,
155
155
  isTypeOnly: true
156
156
  }),
157
- shouldUseClientPlugin && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
157
+ shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
158
158
  name: [client.name],
159
159
  root: mutation.file.path,
160
160
  path: client.file.path
161
161
  }),
162
- !shouldUseClientPlugin && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
162
+ !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
163
163
  name: ["buildFormData"],
164
164
  root: mutation.file.path,
165
165
  path: node_path.default.resolve(config.root, config.output.path, ".kubb/config.ts")
166
166
  }),
167
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
167
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
168
168
  name: [
169
169
  type.schemas.request?.name,
170
170
  type.schemas.response.name,
@@ -177,7 +177,7 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
177
177
  path: type.file.path,
178
178
  isTypeOnly: true
179
179
  }),
180
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.MutationKey, {
180
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.MutationKey, {
181
181
  name: mutationKey.name,
182
182
  typeName: mutationKey.typeName,
183
183
  operation,
@@ -186,7 +186,7 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
186
186
  paramsCasing: options.paramsCasing,
187
187
  transformer: options.mutationKey
188
188
  }),
189
- !shouldUseClientPlugin && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_plugin_client_components.Client, {
189
+ !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_plugin_client_components.Client, {
190
190
  name: client.name,
191
191
  baseURL: options.client.baseURL,
192
192
  operation,
@@ -198,7 +198,7 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
198
198
  pathParamsType: options.pathParamsType,
199
199
  parser: options.parser
200
200
  }),
201
- options.mutation && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.Mutation, {
201
+ options.mutation && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Mutation, {
202
202
  name: mutation.name,
203
203
  clientName: client.name,
204
204
  typeName: mutation.typeName,
@@ -219,13 +219,13 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
219
219
 
220
220
  //#endregion
221
221
  //#region src/generators/queryGenerator.tsx
222
- const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
222
+ const queryGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
223
223
  name: "swr-query",
224
224
  Operation({ config, operation, generator, plugin }) {
225
225
  const { options, options: { output } } = plugin;
226
- const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
227
- const oas = (0, __kubb_plugin_oas_hooks.useOas)();
228
- const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)(generator);
226
+ const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
227
+ const oas = (0, _kubb_plugin_oas_hooks.useOas)();
228
+ const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
229
229
  const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
230
230
  const isMutation = (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
231
231
  const importPath = options.query ? options.query.importPath : "swr/mutation";
@@ -237,13 +237,13 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
237
237
  typeName: getName(operation, { type: "type" }),
238
238
  file: getFile(operation, { prefix: "use" })
239
239
  };
240
- const shouldUseClientPlugin = !!pluginManager.getPluginByKey([__kubb_plugin_client.pluginClientName]) && options.client.clientType !== "class";
240
+ const shouldUseClientPlugin = !!pluginManager.getPluginByKey([_kubb_plugin_client.pluginClientName]) && options.client.clientType !== "class";
241
241
  const client = {
242
242
  name: shouldUseClientPlugin ? getName(operation, {
243
243
  type: "function",
244
- pluginKey: [__kubb_plugin_client.pluginClientName]
244
+ pluginKey: [_kubb_plugin_client.pluginClientName]
245
245
  }) : getName(operation, { type: "function" }),
246
- file: getFile(operation, { pluginKey: [__kubb_plugin_client.pluginClientName] })
246
+ file: getFile(operation, { pluginKey: [_kubb_plugin_client.pluginClientName] })
247
247
  };
248
248
  const queryOptions = { name: getName(operation, {
249
249
  type: "function",
@@ -260,84 +260,84 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
260
260
  })
261
261
  };
262
262
  const type = {
263
- file: getFile(operation, { pluginKey: [__kubb_plugin_ts.pluginTsName] }),
263
+ file: getFile(operation, { pluginKey: [_kubb_plugin_ts.pluginTsName] }),
264
264
  schemas: getSchemas(operation, {
265
- pluginKey: [__kubb_plugin_ts.pluginTsName],
265
+ pluginKey: [_kubb_plugin_ts.pluginTsName],
266
266
  type: "type"
267
267
  })
268
268
  };
269
269
  const zod = {
270
- file: getFile(operation, { pluginKey: [__kubb_plugin_zod.pluginZodName] }),
270
+ file: getFile(operation, { pluginKey: [_kubb_plugin_zod.pluginZodName] }),
271
271
  schemas: getSchemas(operation, {
272
- pluginKey: [__kubb_plugin_zod.pluginZodName],
272
+ pluginKey: [_kubb_plugin_zod.pluginZodName],
273
273
  type: "function"
274
274
  })
275
275
  };
276
276
  if (!isQuery || isMutation) return null;
277
- return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric.File, {
277
+ return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
278
278
  baseName: query.file.baseName,
279
279
  path: query.file.path,
280
280
  meta: query.file.meta,
281
- banner: (0, __kubb_plugin_oas_utils.getBanner)({
281
+ banner: (0, _kubb_plugin_oas_utils.getBanner)({
282
282
  oas,
283
283
  output,
284
284
  config: pluginManager.config
285
285
  }),
286
- footer: (0, __kubb_plugin_oas_utils.getFooter)({
286
+ footer: (0, _kubb_plugin_oas_utils.getFooter)({
287
287
  oas,
288
288
  output
289
289
  }),
290
290
  children: [
291
- options.parser === "zod" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
291
+ options.parser === "zod" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
292
292
  name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
293
293
  root: query.file.path,
294
294
  path: zod.file.path
295
295
  }),
296
- options.client.importPath ? /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
297
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
296
+ options.client.importPath ? /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
297
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
298
298
  name: "fetch",
299
299
  path: options.client.importPath
300
300
  }),
301
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
301
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
302
302
  name: ["RequestConfig", "ResponseErrorConfig"],
303
303
  path: options.client.importPath,
304
304
  isTypeOnly: true
305
305
  }),
306
- options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
306
+ options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
307
307
  name: ["ResponseConfig"],
308
308
  path: options.client.importPath,
309
309
  isTypeOnly: true
310
310
  })
311
- ] }) : /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
312
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
311
+ ] }) : /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
312
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
313
313
  name: ["fetch"],
314
314
  root: query.file.path,
315
315
  path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts")
316
316
  }),
317
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
317
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
318
318
  name: ["RequestConfig", "ResponseErrorConfig"],
319
319
  root: query.file.path,
320
320
  path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
321
321
  isTypeOnly: true
322
322
  }),
323
- options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
323
+ options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
324
324
  name: ["ResponseConfig"],
325
325
  root: query.file.path,
326
326
  path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
327
327
  isTypeOnly: true
328
328
  })
329
329
  ] }),
330
- shouldUseClientPlugin && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
330
+ shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
331
331
  name: [client.name],
332
332
  root: query.file.path,
333
333
  path: client.file.path
334
334
  }),
335
- !shouldUseClientPlugin && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
335
+ !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
336
336
  name: ["buildFormData"],
337
337
  root: query.file.path,
338
338
  path: node_path.default.resolve(config.root, config.output.path, ".kubb/config.ts")
339
339
  }),
340
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
340
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
341
341
  name: [
342
342
  type.schemas.request?.name,
343
343
  type.schemas.response.name,
@@ -350,7 +350,7 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
350
350
  path: type.file.path,
351
351
  isTypeOnly: true
352
352
  }),
353
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryKey, {
353
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryKey, {
354
354
  name: queryKey.name,
355
355
  typeName: queryKey.typeName,
356
356
  operation,
@@ -359,7 +359,7 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
359
359
  paramsCasing: options.paramsCasing,
360
360
  transformer: options.queryKey
361
361
  }),
362
- !shouldUseClientPlugin && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_plugin_client_components.Client, {
362
+ !shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_plugin_client_components.Client, {
363
363
  name: client.name,
364
364
  baseURL: options.client.baseURL,
365
365
  operation,
@@ -371,7 +371,7 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
371
371
  pathParamsType: options.pathParamsType,
372
372
  parser: options.parser
373
373
  }),
374
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryOptions, {
374
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryOptions, {
375
375
  name: queryOptions.name,
376
376
  clientName: client.name,
377
377
  typeSchemas: type.schemas,
@@ -379,17 +379,17 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
379
379
  paramsCasing: options.paramsCasing,
380
380
  pathParamsType: options.pathParamsType
381
381
  }),
382
- options.query && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
383
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
382
+ options.query && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
383
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
384
384
  name: "useSWR",
385
385
  path: importPath
386
386
  }),
387
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
387
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
388
388
  name: ["SWRResponse"],
389
389
  path: importPath,
390
390
  isTypeOnly: true
391
391
  }),
392
- /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.Query, {
392
+ /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Query, {
393
393
  name: query.name,
394
394
  queryOptionsName: queryOptions.name,
395
395
  typeSchemas: type.schemas,
@@ -426,4 +426,4 @@ Object.defineProperty(exports, 'queryGenerator', {
426
426
  return queryGenerator;
427
427
  }
428
428
  });
429
- //# sourceMappingURL=generators-DM1zpqft.cjs.map
429
+ //# sourceMappingURL=generators-CexgebyO.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generators-DM1zpqft.cjs","names":["pluginTsName","pluginZodName","pluginClientName","File","path","MutationKey","Client","Mutation","pluginClientName","pluginTsName","pluginZodName","File","path","QueryKey","Client","QueryOptions","Query"],"sources":["../src/generators/mutationGenerator.tsx","../src/generators/queryGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { usePluginManager } from '@kubb/core/hooks'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\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 } from '@kubb/react-fabric'\nimport { difference } from 'remeda'\nimport { Mutation, MutationKey } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-mutation',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { output },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)\n const isMutation =\n options.mutation !== false &&\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 : 'swr'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\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 // Class-based clients are not compatible with query hooks, so we generate inline clients\n const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'\n const client = {\n name: shouldUseClientPlugin\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 {options.client.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.client.importPath} />\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 </>\n ) : (\n <>\n <File.Import name={['fetch']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['RequestConfig', 'ResponseErrorConfig']}\n root={mutation.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import\n name={['ResponseConfig']}\n root={mutation.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n )}\n </>\n )}\n <File.Import name=\"useSWRMutation\" path={importPath} />\n <File.Import name={['SWRMutationConfiguration', 'SWRMutationResponse']} path={importPath} isTypeOnly />\n {shouldUseClientPlugin && <File.Import name={[client.name]} root={mutation.file.path} path={client.file.path} />}\n {!shouldUseClientPlugin && (\n <File.Import name={['buildFormData']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n )}\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 pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.mutationKey}\n />\n\n {!shouldUseClientPlugin && (\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 || 'data'}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n {options.mutation && (\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n mutationKeyTypeName={mutationKey.typeName}\n paramsToTrigger={options.mutation.paramsToTrigger}\n />\n )}\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { usePluginManager } from '@kubb/core/hooks'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\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 } from '@kubb/react-fabric'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-query',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { output },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\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 : 'swr/mutation'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n // Class-based clients are not compatible with query hooks, so we generate inline clients\n const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'\n const client = {\n name: shouldUseClientPlugin\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 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, {\n pluginKey: [pluginTsName],\n type: 'type',\n }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, {\n pluginKey: [pluginZodName],\n type: 'function',\n }),\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 {options.client.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.client.importPath} />\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 </>\n ) : (\n <>\n <File.Import name={['fetch']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['RequestConfig', 'ResponseErrorConfig']}\n root={query.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />\n )}\n </>\n )}\n {shouldUseClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n {!shouldUseClientPlugin && (\n <File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n )}\n\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 <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 {!shouldUseClientPlugin && (\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 || 'data'}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n />\n {options.query && (\n <>\n <File.Import name=\"useSWR\" path={importPath} />\n <File.Import name={['SWRResponse']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n dataReturnType={options.client.dataReturnType || 'data'}\n queryKeyName={queryKey.name}\n paramsCasing={options.paramsCasing}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAa,2EAAoD;CAC/D,MAAM;CACN,UAAU,EAAE,QAAQ,WAAW,WAAW,UAAU;EAClD,MAAM,EACJ,SACA,SAAS,EAAE,aACT;EACJ,MAAM,yDAAkC;EAExC,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,6DAAgC,UAAU;EAEvE,MAAM,UAAU,CAAC,CAAC,QAAQ,SAAS,QAAQ,OAAO,QAAQ,MAAM,WAAW,UAAU,WAAW,OAAO;EACvG,MAAM,aACJ,QAAQ,aAAa,SACrB,CAAC,kCACU,QAAQ,WAAW,QAAQ,SAAS,UAAU,EAAE,EAAE,QAAQ,QAAQ,QAAQ,MAAM,UAAU,EAAE,CAAC,CAAC,MAAM,WAAW,UAAU,WAAW,OAAO;EAExJ,MAAM,aAAa,QAAQ,WAAW,QAAQ,SAAS,aAAa;EAEpE,MAAM,WAAW;GACf,MAAM,QAAQ,WAAW;IAAE,MAAM;IAAY,QAAQ;IAAO,CAAC;GAC7D,UAAU,QAAQ,WAAW,EAAE,MAAM,QAAQ,CAAC;GAC9C,MAAM,QAAQ,WAAW,EAAE,QAAQ,OAAO,CAAC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ACpB,gBAAgB,QAAQ;MACb;MACX,gBAAgB,QAAQ,OAAO,kBAAkB;MACjD,cAAc,SAAS;MACvB,cAAc,QAAQ;MACtB,kBAAkB,SAAS;OAC3B;QACD;;IAEA;;CAGZ,CAAC"}
1
+ {"version":3,"file":"generators-CexgebyO.cjs","names":["pluginTsName","pluginZodName","pluginClientName","File","path","MutationKey","Client","Mutation","pluginClientName","pluginTsName","pluginZodName","File","path","QueryKey","Client","QueryOptions","Query"],"sources":["../src/generators/mutationGenerator.tsx","../src/generators/queryGenerator.tsx"],"sourcesContent":["import path from 'node:path'\nimport { usePluginManager } from '@kubb/core/hooks'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\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 } from '@kubb/react-fabric'\nimport { difference } from 'remeda'\nimport { Mutation, MutationKey } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const mutationGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-mutation',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { output },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\n\n const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method)\n const isMutation =\n options.mutation !== false &&\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 : 'swr'\n\n const mutation = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\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 // Class-based clients are not compatible with query hooks, so we generate inline clients\n const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'\n const client = {\n name: shouldUseClientPlugin\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 {options.client.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.client.importPath} />\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 </>\n ) : (\n <>\n <File.Import name={['fetch']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['RequestConfig', 'ResponseErrorConfig']}\n root={mutation.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import\n name={['ResponseConfig']}\n root={mutation.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n )}\n </>\n )}\n <File.Import name=\"useSWRMutation\" path={importPath} />\n <File.Import name={['SWRMutationConfiguration', 'SWRMutationResponse']} path={importPath} isTypeOnly />\n {shouldUseClientPlugin && <File.Import name={[client.name]} root={mutation.file.path} path={client.file.path} />}\n {!shouldUseClientPlugin && (\n <File.Import name={['buildFormData']} root={mutation.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n )}\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 pathParamsType={options.pathParamsType}\n typeSchemas={type.schemas}\n paramsCasing={options.paramsCasing}\n transformer={options.mutationKey}\n />\n\n {!shouldUseClientPlugin && (\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 || 'data'}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n {options.mutation && (\n <Mutation\n name={mutation.name}\n clientName={client.name}\n typeName={mutation.typeName}\n typeSchemas={type.schemas}\n operation={operation}\n dataReturnType={options.client.dataReturnType || 'data'}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n mutationKeyName={mutationKey.name}\n mutationKeyTypeName={mutationKey.typeName}\n paramsToTrigger={options.mutation.paramsToTrigger}\n />\n )}\n </File>\n )\n },\n})\n","import path from 'node:path'\nimport { usePluginManager } from '@kubb/core/hooks'\nimport { pluginClientName } from '@kubb/plugin-client'\nimport { Client } from '@kubb/plugin-client/components'\nimport { createReactGenerator } from '@kubb/plugin-oas/generators'\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 } from '@kubb/react-fabric'\nimport { difference } from 'remeda'\nimport { Query, QueryKey, QueryOptions } from '../components'\nimport type { PluginSwr } from '../types'\n\nexport const queryGenerator = createReactGenerator<PluginSwr>({\n name: 'swr-query',\n Operation({ config, operation, generator, plugin }) {\n const {\n options,\n options: { output },\n } = plugin\n const pluginManager = usePluginManager()\n\n const oas = useOas()\n const { getSchemas, getName, getFile } = useOperationManager(generator)\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 : 'swr/mutation'\n\n const query = {\n name: getName(operation, { type: 'function', prefix: 'use' }),\n typeName: getName(operation, { type: 'type' }),\n file: getFile(operation, { prefix: 'use' }),\n }\n\n const hasClientPlugin = !!pluginManager.getPluginByKey([pluginClientName])\n // Class-based clients are not compatible with query hooks, so we generate inline clients\n const shouldUseClientPlugin = hasClientPlugin && options.client.clientType !== 'class'\n const client = {\n name: shouldUseClientPlugin\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 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, {\n pluginKey: [pluginTsName],\n type: 'type',\n }),\n }\n\n const zod = {\n file: getFile(operation, { pluginKey: [pluginZodName] }),\n schemas: getSchemas(operation, {\n pluginKey: [pluginZodName],\n type: 'function',\n }),\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 {options.client.importPath ? (\n <>\n <File.Import name={'fetch'} path={options.client.importPath} />\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 </>\n ) : (\n <>\n <File.Import name={['fetch']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} />\n <File.Import\n name={['RequestConfig', 'ResponseErrorConfig']}\n root={query.file.path}\n path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')}\n isTypeOnly\n />\n {options.client.dataReturnType === 'full' && (\n <File.Import name={['ResponseConfig']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/fetch.ts')} isTypeOnly />\n )}\n </>\n )}\n {shouldUseClientPlugin && <File.Import name={[client.name]} root={query.file.path} path={client.file.path} />}\n {!shouldUseClientPlugin && (\n <File.Import name={['buildFormData']} root={query.file.path} path={path.resolve(config.root, config.output.path, '.kubb/config.ts')} />\n )}\n\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 <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 {!shouldUseClientPlugin && (\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 || 'data'}\n paramsCasing={options.paramsCasing}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n parser={options.parser}\n />\n )}\n <QueryOptions\n name={queryOptions.name}\n clientName={client.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n paramsCasing={options.paramsCasing}\n pathParamsType={options.pathParamsType}\n />\n {options.query && (\n <>\n <File.Import name=\"useSWR\" path={importPath} />\n <File.Import name={['SWRResponse']} path={importPath} isTypeOnly />\n <Query\n name={query.name}\n queryOptionsName={queryOptions.name}\n typeSchemas={type.schemas}\n paramsType={options.paramsType}\n pathParamsType={options.pathParamsType}\n operation={operation}\n dataReturnType={options.client.dataReturnType || 'data'}\n queryKeyName={queryKey.name}\n paramsCasing={options.paramsCasing}\n queryKeyTypeName={queryKey.typeName}\n />\n </>\n )}\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAa,0EAAoD;CAC/D,MAAM;CACN,UAAU,EAAE,QAAQ,WAAW,WAAW,UAAU;EAClD,MAAM,EACJ,SACA,SAAS,EAAE,aACT;EACJ,MAAM,wDAAkC;EAExC,MAAM,0CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,4DAAgC,UAAU;EAEvE,MAAM,UAAU,CAAC,CAAC,QAAQ,SAAS,QAAQ,OAAO,QAAQ,MAAM,WAAW,UAAU,WAAW,OAAO;EACvG,MAAM,aACJ,QAAQ,aAAa,SACrB,CAAC,kCACU,QAAQ,WAAW,QAAQ,SAAS,UAAU,EAAE,EAAE,QAAQ,QAAQ,QAAQ,MAAM,UAAU,EAAE,CAAC,CAAC,MAAM,WAAW,UAAU,WAAW,OAAO;EAExJ,MAAM,aAAa,QAAQ,WAAW,QAAQ,SAAS,aAAa;EAE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;MAAS,MAAM;OAAc;KAC/C,wDAACA,wBAAK;MAAO,MAAM,CAAC,cAAc;MAAE,MAAM;MAAY;OAAa;KACnE,wDAACK;MACC,MAAM,MAAM;MACZ,kBAAkB,aAAa;MAC/B,aAAa,KAAK;MAClB,YAAY,QAAQ;MACpB,gBAAgB,QAAQ;MACb;MACX,gBAAgB,QAAQ,OAAO,kBAAkB;MACjD,cAAc,SAAS;MACvB,cAAc,QAAQ;MACtB,kBAAkB,SAAS;OAC3B;QACD;;IAEA;;CAGZ,CAAC"}
@@ -1,4 +1,4 @@
1
- const require_generators = require('./generators-DM1zpqft.cjs');
1
+ const require_generators = require('./generators-CexgebyO.cjs');
2
2
 
3
3
  exports.mutationGenerator = require_generators.mutationGenerator;
4
4
  exports.queryGenerator = require_generators.queryGenerator;
package/dist/index.cjs CHANGED
@@ -1,18 +1,18 @@
1
- const require_generators = require('./generators-DM1zpqft.cjs');
2
- const require_components = require('./components-Djw0ll1l.cjs');
1
+ const require_generators = require('./generators-CexgebyO.cjs');
2
+ const require_components = require('./components-DD7X6DkL.cjs');
3
3
  let node_path = require("node:path");
4
4
  node_path = require_generators.__toESM(node_path);
5
- let __kubb_core = require("@kubb/core");
6
- let __kubb_core_transformers = require("@kubb/core/transformers");
7
- let __kubb_core_utils = require("@kubb/core/utils");
8
- let __kubb_plugin_client = require("@kubb/plugin-client");
9
- let __kubb_plugin_oas = require("@kubb/plugin-oas");
10
- let __kubb_plugin_ts = require("@kubb/plugin-ts");
11
- let __kubb_plugin_zod = require("@kubb/plugin-zod");
5
+ let _kubb_core = require("@kubb/core");
6
+ let _kubb_core_transformers = require("@kubb/core/transformers");
7
+ let _kubb_core_utils = require("@kubb/core/utils");
8
+ let _kubb_plugin_client = require("@kubb/plugin-client");
9
+ let _kubb_plugin_oas = require("@kubb/plugin-oas");
10
+ let _kubb_plugin_ts = require("@kubb/plugin-ts");
11
+ let _kubb_plugin_zod = require("@kubb/plugin-zod");
12
12
 
13
13
  //#region src/plugin.ts
14
14
  const pluginSwrName = "plugin-swr";
15
- const pluginSwr = (0, __kubb_core.definePlugin)((options) => {
15
+ const pluginSwr = (0, _kubb_core.definePlugin)((options) => {
16
16
  const { output = {
17
17
  path: "hooks",
18
18
  barrelType: "named"
@@ -54,13 +54,13 @@ const pluginSwr = (0, __kubb_core.definePlugin)((options) => {
54
54
  group
55
55
  },
56
56
  pre: [
57
- __kubb_plugin_oas.pluginOasName,
58
- __kubb_plugin_ts.pluginTsName,
59
- parser === "zod" ? __kubb_plugin_zod.pluginZodName : void 0
57
+ _kubb_plugin_oas.pluginOasName,
58
+ _kubb_plugin_ts.pluginTsName,
59
+ parser === "zod" ? _kubb_plugin_zod.pluginZodName : void 0
60
60
  ].filter(Boolean),
61
61
  resolvePath(baseName, pathMode, options$1) {
62
62
  const root = node_path.default.resolve(this.config.root, this.config.output.path);
63
- if ((pathMode ?? (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
63
+ if ((pathMode ?? (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path))) === "single")
64
64
  /**
65
65
  * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
66
66
  * Other plugins then need to call addOrAppend instead of just add from the fileManager class
@@ -69,32 +69,32 @@ const pluginSwr = (0, __kubb_core.definePlugin)((options) => {
69
69
  if (group && (options$1?.group?.path || options$1?.group?.tag)) {
70
70
  const groupName = group?.name ? group.name : (ctx) => {
71
71
  if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
72
- return `${(0, __kubb_core_transformers.camelCase)(ctx.group)}Controller`;
72
+ return `${(0, _kubb_core_transformers.camelCase)(ctx.group)}Controller`;
73
73
  };
74
74
  return node_path.default.resolve(root, output.path, groupName({ group: group.type === "path" ? options$1.group.path : options$1.group.tag }), baseName);
75
75
  }
76
76
  return node_path.default.resolve(root, output.path, baseName);
77
77
  },
78
78
  resolveName(name, type) {
79
- let resolvedName = (0, __kubb_core_transformers.camelCase)(name);
80
- if (type === "file" || type === "function") resolvedName = (0, __kubb_core_transformers.camelCase)(name, { isFile: type === "file" });
81
- if (type === "type") resolvedName = (0, __kubb_core_transformers.pascalCase)(name);
79
+ let resolvedName = (0, _kubb_core_transformers.camelCase)(name);
80
+ if (type === "file" || type === "function") resolvedName = (0, _kubb_core_transformers.camelCase)(name, { isFile: type === "file" });
81
+ if (type === "type") resolvedName = (0, _kubb_core_transformers.pascalCase)(name);
82
82
  if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
83
83
  return resolvedName;
84
84
  },
85
85
  async install() {
86
86
  const root = node_path.default.resolve(this.config.root, this.config.output.path);
87
- const mode = (0, __kubb_core.getMode)(node_path.default.resolve(root, output.path));
87
+ const mode = (0, _kubb_core.getMode)(node_path.default.resolve(root, output.path));
88
88
  const oas = await this.getOas();
89
89
  const baseURL = await this.getBaseURL();
90
90
  if (baseURL) this.plugin.options.client.baseURL = baseURL;
91
- const hasClientPlugin = !!this.pluginManager.getPluginByKey([__kubb_plugin_client.pluginClientName]);
91
+ const hasClientPlugin = !!this.pluginManager.getPluginByKey([_kubb_plugin_client.pluginClientName]);
92
92
  if (this.plugin.options.client.bundle && !hasClientPlugin && !this.plugin.options.client.importPath) await this.upsertFile({
93
93
  baseName: "fetch.ts",
94
94
  path: node_path.default.resolve(root, ".kubb/fetch.ts"),
95
95
  sources: [{
96
96
  name: "fetch",
97
- value: (0, __kubb_core_utils.resolveModuleSource)(this.plugin.options.client.client === "fetch" ? "@kubb/plugin-client/templates/clients/fetch" : "@kubb/plugin-client/templates/clients/axios").source,
97
+ value: (0, _kubb_core_utils.resolveModuleSource)(this.plugin.options.client.client === "fetch" ? "@kubb/plugin-client/templates/clients/fetch" : "@kubb/plugin-client/templates/clients/axios").source,
98
98
  isExportable: true,
99
99
  isIndexable: true
100
100
  }]
@@ -104,12 +104,12 @@ const pluginSwr = (0, __kubb_core.definePlugin)((options) => {
104
104
  path: node_path.default.resolve(root, ".kubb/config.ts"),
105
105
  sources: [{
106
106
  name: "config",
107
- value: (0, __kubb_core_utils.resolveModuleSource)("@kubb/plugin-client/templates/config").source,
107
+ value: (0, _kubb_core_utils.resolveModuleSource)("@kubb/plugin-client/templates/config").source,
108
108
  isExportable: false,
109
109
  isIndexable: false
110
110
  }]
111
111
  });
112
- const files = await new __kubb_plugin_oas.OperationGenerator(this.plugin.options, {
112
+ const files = await new _kubb_plugin_oas.OperationGenerator(this.plugin.options, {
113
113
  fabric: this.fabric,
114
114
  oas,
115
115
  pluginManager: this.pluginManager,
@@ -122,7 +122,7 @@ const pluginSwr = (0, __kubb_core.definePlugin)((options) => {
122
122
  mode
123
123
  }).build(...generators);
124
124
  await this.upsertFile(...files);
125
- const barrelFiles = await (0, __kubb_core.getBarrelFiles)(this.fabric.files, {
125
+ const barrelFiles = await (0, _kubb_core.getBarrelFiles)(this.fabric.files, {
126
126
  type: output.barrelType ?? "named",
127
127
  root,
128
128
  output,