@kubb/plugin-vue-query 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.
- package/dist/{components-SMmSlG37.cjs → components-CpE5cSDx.cjs} +97 -97
- package/dist/{components-SMmSlG37.cjs.map → components-CpE5cSDx.cjs.map} +1 -1
- package/dist/components.cjs +1 -1
- package/dist/{generators-M5BAqtv4.cjs → generators-BSkCG7hV.cjs} +119 -119
- package/dist/{generators-M5BAqtv4.cjs.map → generators-BSkCG7hV.cjs.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/index.cjs +24 -24
- package/dist/index.cjs.map +1 -1
- package/package.json +9 -9
|
@@ -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-
|
|
28
|
+
const require_components = require('./components-CpE5cSDx.cjs');
|
|
29
29
|
let node_path = require("node:path");
|
|
30
30
|
node_path = __toESM(node_path);
|
|
31
|
-
let
|
|
32
|
-
let
|
|
33
|
-
let
|
|
34
|
-
let
|
|
35
|
-
let
|
|
36
|
-
let
|
|
37
|
-
let
|
|
38
|
-
let
|
|
39
|
-
let
|
|
40
|
-
let
|
|
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_oas_utils = require("@kubb/plugin-oas/utils");
|
|
35
|
+
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
36
|
+
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
37
|
+
let _kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
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/infiniteQueryGenerator.tsx
|
|
44
|
-
const infiniteQueryGenerator = (0,
|
|
44
|
+
const infiniteQueryGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
45
45
|
name: "vue-infinite-query",
|
|
46
46
|
Operation({ config, operation, generator, plugin }) {
|
|
47
47
|
const { options, options: { output } } = plugin;
|
|
48
|
-
const pluginManager = (0,
|
|
49
|
-
const oas = (0,
|
|
50
|
-
const { getSchemas, getName, getFile } = (0,
|
|
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 = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
52
52
|
const isMutation = (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
53
53
|
const isInfinite = isQuery && !!options.infinite;
|
|
@@ -64,16 +64,16 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas_generators.createReactGener
|
|
|
64
64
|
suffix: "infinite"
|
|
65
65
|
})
|
|
66
66
|
};
|
|
67
|
-
const shouldUseClientPlugin = !!pluginManager.getPluginByKey([
|
|
67
|
+
const shouldUseClientPlugin = !!pluginManager.getPluginByKey([_kubb_plugin_client.pluginClientName]) && options.client.clientType !== "class";
|
|
68
68
|
const client = {
|
|
69
69
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
70
70
|
type: "function",
|
|
71
|
-
pluginKey: [
|
|
71
|
+
pluginKey: [_kubb_plugin_client.pluginClientName]
|
|
72
72
|
}) : getName(operation, {
|
|
73
73
|
type: "function",
|
|
74
74
|
suffix: "infinite"
|
|
75
75
|
}),
|
|
76
|
-
file: getFile(operation, { pluginKey: [
|
|
76
|
+
file: getFile(operation, { pluginKey: [_kubb_plugin_client.pluginClientName] })
|
|
77
77
|
};
|
|
78
78
|
const queryOptions = { name: getName(operation, {
|
|
79
79
|
type: "function",
|
|
@@ -90,93 +90,93 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas_generators.createReactGener
|
|
|
90
90
|
})
|
|
91
91
|
};
|
|
92
92
|
const type = {
|
|
93
|
-
file: getFile(operation, { pluginKey: [
|
|
93
|
+
file: getFile(operation, { pluginKey: [_kubb_plugin_ts.pluginTsName] }),
|
|
94
94
|
schemas: getSchemas(operation, {
|
|
95
|
-
pluginKey: [
|
|
95
|
+
pluginKey: [_kubb_plugin_ts.pluginTsName],
|
|
96
96
|
type: "type"
|
|
97
97
|
})
|
|
98
98
|
};
|
|
99
99
|
const zod = {
|
|
100
|
-
file: getFile(operation, { pluginKey: [
|
|
100
|
+
file: getFile(operation, { pluginKey: [_kubb_plugin_zod.pluginZodName] }),
|
|
101
101
|
schemas: getSchemas(operation, {
|
|
102
|
-
pluginKey: [
|
|
102
|
+
pluginKey: [_kubb_plugin_zod.pluginZodName],
|
|
103
103
|
type: "function"
|
|
104
104
|
})
|
|
105
105
|
};
|
|
106
106
|
if (!isQuery || isMutation || !isInfinite) return null;
|
|
107
|
-
return /* @__PURE__ */ (0,
|
|
107
|
+
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
|
|
108
108
|
baseName: query.file.baseName,
|
|
109
109
|
path: query.file.path,
|
|
110
110
|
meta: query.file.meta,
|
|
111
|
-
banner: (0,
|
|
111
|
+
banner: (0, _kubb_plugin_oas_utils.getBanner)({
|
|
112
112
|
oas,
|
|
113
113
|
output,
|
|
114
114
|
config: pluginManager.config
|
|
115
115
|
}),
|
|
116
|
-
footer: (0,
|
|
116
|
+
footer: (0, _kubb_plugin_oas_utils.getFooter)({
|
|
117
117
|
oas,
|
|
118
118
|
output
|
|
119
119
|
}),
|
|
120
120
|
children: [
|
|
121
|
-
options.parser === "zod" && /* @__PURE__ */ (0,
|
|
121
|
+
options.parser === "zod" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
122
122
|
name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
|
|
123
123
|
root: query.file.path,
|
|
124
124
|
path: zod.file.path
|
|
125
125
|
}),
|
|
126
|
-
options.client.importPath ? /* @__PURE__ */ (0,
|
|
127
|
-
/* @__PURE__ */ (0,
|
|
126
|
+
options.client.importPath ? /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
127
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
128
128
|
name: "fetch",
|
|
129
129
|
path: options.client.importPath
|
|
130
130
|
}),
|
|
131
|
-
/* @__PURE__ */ (0,
|
|
131
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
132
132
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
133
133
|
path: options.client.importPath,
|
|
134
134
|
isTypeOnly: true
|
|
135
135
|
}),
|
|
136
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ (0,
|
|
136
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
137
137
|
name: ["ResponseConfig"],
|
|
138
138
|
path: options.client.importPath,
|
|
139
139
|
isTypeOnly: true
|
|
140
140
|
})
|
|
141
|
-
] }) : /* @__PURE__ */ (0,
|
|
142
|
-
/* @__PURE__ */ (0,
|
|
141
|
+
] }) : /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
142
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
143
143
|
name: ["fetch"],
|
|
144
144
|
root: query.file.path,
|
|
145
145
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
146
146
|
}),
|
|
147
|
-
/* @__PURE__ */ (0,
|
|
147
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
148
148
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
149
149
|
root: query.file.path,
|
|
150
150
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
151
151
|
isTypeOnly: true
|
|
152
152
|
}),
|
|
153
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ (0,
|
|
153
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
154
154
|
name: ["ResponseConfig"],
|
|
155
155
|
root: query.file.path,
|
|
156
156
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
157
157
|
isTypeOnly: true
|
|
158
158
|
})
|
|
159
159
|
] }),
|
|
160
|
-
/* @__PURE__ */ (0,
|
|
160
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
161
161
|
name: ["toValue"],
|
|
162
162
|
path: "vue"
|
|
163
163
|
}),
|
|
164
|
-
/* @__PURE__ */ (0,
|
|
164
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
165
165
|
name: ["MaybeRefOrGetter"],
|
|
166
166
|
path: "vue",
|
|
167
167
|
isTypeOnly: true
|
|
168
168
|
}),
|
|
169
|
-
shouldUseClientPlugin && /* @__PURE__ */ (0,
|
|
169
|
+
shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
170
170
|
name: [client.name],
|
|
171
171
|
root: query.file.path,
|
|
172
172
|
path: client.file.path
|
|
173
173
|
}),
|
|
174
|
-
!shouldUseClientPlugin && /* @__PURE__ */ (0,
|
|
174
|
+
!shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
175
175
|
name: ["buildFormData"],
|
|
176
176
|
root: query.file.path,
|
|
177
177
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/config.ts")
|
|
178
178
|
}),
|
|
179
|
-
/* @__PURE__ */ (0,
|
|
179
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
180
180
|
name: [
|
|
181
181
|
type.schemas.request?.name,
|
|
182
182
|
type.schemas.response.name,
|
|
@@ -189,7 +189,7 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas_generators.createReactGener
|
|
|
189
189
|
path: type.file.path,
|
|
190
190
|
isTypeOnly: true
|
|
191
191
|
}),
|
|
192
|
-
/* @__PURE__ */ (0,
|
|
192
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryKey, {
|
|
193
193
|
name: queryKey.name,
|
|
194
194
|
typeName: queryKey.typeName,
|
|
195
195
|
operation,
|
|
@@ -198,7 +198,7 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas_generators.createReactGener
|
|
|
198
198
|
typeSchemas: type.schemas,
|
|
199
199
|
transformer: options.queryKey
|
|
200
200
|
}),
|
|
201
|
-
!shouldUseClientPlugin && /* @__PURE__ */ (0,
|
|
201
|
+
!shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_plugin_client_components.Client, {
|
|
202
202
|
name: client.name,
|
|
203
203
|
baseURL: options.client.baseURL,
|
|
204
204
|
operation,
|
|
@@ -210,17 +210,17 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas_generators.createReactGener
|
|
|
210
210
|
pathParamsType: options.pathParamsType,
|
|
211
211
|
parser: options.parser
|
|
212
212
|
}),
|
|
213
|
-
options.infinite && /* @__PURE__ */ (0,
|
|
214
|
-
/* @__PURE__ */ (0,
|
|
213
|
+
options.infinite && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
214
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
215
215
|
name: ["InfiniteData"],
|
|
216
216
|
isTypeOnly: true,
|
|
217
217
|
path: importPath
|
|
218
218
|
}),
|
|
219
|
-
/* @__PURE__ */ (0,
|
|
219
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
220
220
|
name: ["infiniteQueryOptions"],
|
|
221
221
|
path: importPath
|
|
222
222
|
}),
|
|
223
|
-
/* @__PURE__ */ (0,
|
|
223
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.InfiniteQueryOptions, {
|
|
224
224
|
name: queryOptions.name,
|
|
225
225
|
clientName: client.name,
|
|
226
226
|
queryKeyName: queryKey.name,
|
|
@@ -236,12 +236,12 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas_generators.createReactGener
|
|
|
236
236
|
queryParam: options.infinite.queryParam
|
|
237
237
|
})
|
|
238
238
|
] }),
|
|
239
|
-
options.infinite && /* @__PURE__ */ (0,
|
|
240
|
-
/* @__PURE__ */ (0,
|
|
239
|
+
options.infinite && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
240
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
241
241
|
name: ["useInfiniteQuery"],
|
|
242
242
|
path: importPath
|
|
243
243
|
}),
|
|
244
|
-
/* @__PURE__ */ (0,
|
|
244
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
245
245
|
name: [
|
|
246
246
|
"QueryKey",
|
|
247
247
|
"QueryClient",
|
|
@@ -251,7 +251,7 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas_generators.createReactGener
|
|
|
251
251
|
path: importPath,
|
|
252
252
|
isTypeOnly: true
|
|
253
253
|
}),
|
|
254
|
-
/* @__PURE__ */ (0,
|
|
254
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.InfiniteQuery, {
|
|
255
255
|
name: query.name,
|
|
256
256
|
queryOptionsName: queryOptions.name,
|
|
257
257
|
typeSchemas: type.schemas,
|
|
@@ -271,13 +271,13 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas_generators.createReactGener
|
|
|
271
271
|
|
|
272
272
|
//#endregion
|
|
273
273
|
//#region src/generators/mutationGenerator.tsx
|
|
274
|
-
const mutationGenerator = (0,
|
|
274
|
+
const mutationGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
275
275
|
name: "vue-query",
|
|
276
276
|
Operation({ config, operation, generator, plugin }) {
|
|
277
277
|
const { options, options: { output } } = plugin;
|
|
278
|
-
const pluginManager = (0,
|
|
279
|
-
const oas = (0,
|
|
280
|
-
const { getSchemas, getName, getFile } = (0,
|
|
278
|
+
const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
|
|
279
|
+
const oas = (0, _kubb_plugin_oas_hooks.useOas)();
|
|
280
|
+
const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
281
281
|
const isQuery = !!options.query && options.query?.methods.some((method) => operation.method === method);
|
|
282
282
|
const isMutation = options.mutation !== false && !isQuery && (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
283
283
|
const importPath = options.mutation ? options.mutation.importPath : "@tanstack/vue-query";
|
|
@@ -290,26 +290,26 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
|
|
|
290
290
|
file: getFile(operation, { prefix: "use" })
|
|
291
291
|
};
|
|
292
292
|
const type = {
|
|
293
|
-
file: getFile(operation, { pluginKey: [
|
|
293
|
+
file: getFile(operation, { pluginKey: [_kubb_plugin_ts.pluginTsName] }),
|
|
294
294
|
schemas: getSchemas(operation, {
|
|
295
|
-
pluginKey: [
|
|
295
|
+
pluginKey: [_kubb_plugin_ts.pluginTsName],
|
|
296
296
|
type: "type"
|
|
297
297
|
})
|
|
298
298
|
};
|
|
299
299
|
const zod = {
|
|
300
|
-
file: getFile(operation, { pluginKey: [
|
|
300
|
+
file: getFile(operation, { pluginKey: [_kubb_plugin_zod.pluginZodName] }),
|
|
301
301
|
schemas: getSchemas(operation, {
|
|
302
|
-
pluginKey: [
|
|
302
|
+
pluginKey: [_kubb_plugin_zod.pluginZodName],
|
|
303
303
|
type: "function"
|
|
304
304
|
})
|
|
305
305
|
};
|
|
306
|
-
const shouldUseClientPlugin = !!pluginManager.getPluginByKey([
|
|
306
|
+
const shouldUseClientPlugin = !!pluginManager.getPluginByKey([_kubb_plugin_client.pluginClientName]) && options.client.clientType !== "class";
|
|
307
307
|
const client = {
|
|
308
308
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
309
309
|
type: "function",
|
|
310
|
-
pluginKey: [
|
|
310
|
+
pluginKey: [_kubb_plugin_client.pluginClientName]
|
|
311
311
|
}) : getName(operation, { type: "function" }),
|
|
312
|
-
file: getFile(operation, { pluginKey: [
|
|
312
|
+
file: getFile(operation, { pluginKey: [_kubb_plugin_client.pluginClientName] })
|
|
313
313
|
};
|
|
314
314
|
const mutationKey = {
|
|
315
315
|
name: getName(operation, {
|
|
@@ -322,75 +322,75 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
|
|
|
322
322
|
})
|
|
323
323
|
};
|
|
324
324
|
if (!isMutation) return null;
|
|
325
|
-
return /* @__PURE__ */ (0,
|
|
325
|
+
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
|
|
326
326
|
baseName: mutation.file.baseName,
|
|
327
327
|
path: mutation.file.path,
|
|
328
328
|
meta: mutation.file.meta,
|
|
329
|
-
banner: (0,
|
|
329
|
+
banner: (0, _kubb_plugin_oas_utils.getBanner)({
|
|
330
330
|
oas,
|
|
331
331
|
output,
|
|
332
332
|
config: pluginManager.config
|
|
333
333
|
}),
|
|
334
|
-
footer: (0,
|
|
334
|
+
footer: (0, _kubb_plugin_oas_utils.getFooter)({
|
|
335
335
|
oas,
|
|
336
336
|
output
|
|
337
337
|
}),
|
|
338
338
|
children: [
|
|
339
|
-
options.parser === "zod" && /* @__PURE__ */ (0,
|
|
339
|
+
options.parser === "zod" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
340
340
|
name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
|
|
341
341
|
root: mutation.file.path,
|
|
342
342
|
path: zod.file.path
|
|
343
343
|
}),
|
|
344
|
-
options.client.importPath ? /* @__PURE__ */ (0,
|
|
345
|
-
/* @__PURE__ */ (0,
|
|
344
|
+
options.client.importPath ? /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
345
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
346
346
|
name: "fetch",
|
|
347
347
|
path: options.client.importPath
|
|
348
348
|
}),
|
|
349
|
-
/* @__PURE__ */ (0,
|
|
349
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
350
350
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
351
351
|
path: options.client.importPath,
|
|
352
352
|
isTypeOnly: true
|
|
353
353
|
}),
|
|
354
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ (0,
|
|
354
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
355
355
|
name: ["ResponseConfig"],
|
|
356
356
|
path: options.client.importPath,
|
|
357
357
|
isTypeOnly: true
|
|
358
358
|
})
|
|
359
|
-
] }) : /* @__PURE__ */ (0,
|
|
360
|
-
/* @__PURE__ */ (0,
|
|
359
|
+
] }) : /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
360
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
361
361
|
name: ["fetch"],
|
|
362
362
|
root: mutation.file.path,
|
|
363
363
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
364
364
|
}),
|
|
365
|
-
/* @__PURE__ */ (0,
|
|
365
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
366
366
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
367
367
|
root: mutation.file.path,
|
|
368
368
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
369
369
|
isTypeOnly: true
|
|
370
370
|
}),
|
|
371
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ (0,
|
|
371
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
372
372
|
name: ["ResponseConfig"],
|
|
373
373
|
root: mutation.file.path,
|
|
374
374
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
375
375
|
isTypeOnly: true
|
|
376
376
|
})
|
|
377
377
|
] }),
|
|
378
|
-
/* @__PURE__ */ (0,
|
|
378
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
379
379
|
name: ["MaybeRefOrGetter"],
|
|
380
380
|
path: "vue",
|
|
381
381
|
isTypeOnly: true
|
|
382
382
|
}),
|
|
383
|
-
shouldUseClientPlugin && /* @__PURE__ */ (0,
|
|
383
|
+
shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
384
384
|
name: [client.name],
|
|
385
385
|
root: mutation.file.path,
|
|
386
386
|
path: client.file.path
|
|
387
387
|
}),
|
|
388
|
-
!shouldUseClientPlugin && /* @__PURE__ */ (0,
|
|
388
|
+
!shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
389
389
|
name: ["buildFormData"],
|
|
390
390
|
root: mutation.file.path,
|
|
391
391
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/config.ts")
|
|
392
392
|
}),
|
|
393
|
-
/* @__PURE__ */ (0,
|
|
393
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
394
394
|
name: [
|
|
395
395
|
type.schemas.request?.name,
|
|
396
396
|
type.schemas.response.name,
|
|
@@ -403,7 +403,7 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
|
|
|
403
403
|
path: type.file.path,
|
|
404
404
|
isTypeOnly: true
|
|
405
405
|
}),
|
|
406
|
-
/* @__PURE__ */ (0,
|
|
406
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.MutationKey, {
|
|
407
407
|
name: mutationKey.name,
|
|
408
408
|
typeName: mutationKey.typeName,
|
|
409
409
|
operation,
|
|
@@ -412,7 +412,7 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
|
|
|
412
412
|
typeSchemas: type.schemas,
|
|
413
413
|
transformer: options.mutationKey
|
|
414
414
|
}),
|
|
415
|
-
!shouldUseClientPlugin && /* @__PURE__ */ (0,
|
|
415
|
+
!shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_plugin_client_components.Client, {
|
|
416
416
|
name: client.name,
|
|
417
417
|
baseURL: options.client.baseURL,
|
|
418
418
|
operation,
|
|
@@ -424,17 +424,17 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
|
|
|
424
424
|
pathParamsType: options.pathParamsType,
|
|
425
425
|
parser: options.parser
|
|
426
426
|
}),
|
|
427
|
-
options.mutation && /* @__PURE__ */ (0,
|
|
428
|
-
/* @__PURE__ */ (0,
|
|
427
|
+
options.mutation && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
428
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
429
429
|
name: ["useMutation"],
|
|
430
430
|
path: importPath
|
|
431
431
|
}),
|
|
432
|
-
/* @__PURE__ */ (0,
|
|
432
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
433
433
|
name: ["MutationObserverOptions", "QueryClient"],
|
|
434
434
|
path: importPath,
|
|
435
435
|
isTypeOnly: true
|
|
436
436
|
}),
|
|
437
|
-
/* @__PURE__ */ (0,
|
|
437
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Mutation, {
|
|
438
438
|
name: mutation.name,
|
|
439
439
|
clientName: client.name,
|
|
440
440
|
typeName: mutation.typeName,
|
|
@@ -454,13 +454,13 @@ const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)
|
|
|
454
454
|
|
|
455
455
|
//#endregion
|
|
456
456
|
//#region src/generators/queryGenerator.tsx
|
|
457
|
-
const queryGenerator = (0,
|
|
457
|
+
const queryGenerator = (0, _kubb_plugin_oas_generators.createReactGenerator)({
|
|
458
458
|
name: "vue-query",
|
|
459
459
|
Operation({ config, operation, generator, plugin }) {
|
|
460
460
|
const { options, options: { output } } = plugin;
|
|
461
|
-
const pluginManager = (0,
|
|
462
|
-
const oas = (0,
|
|
463
|
-
const { getSchemas, getName, getFile } = (0,
|
|
461
|
+
const pluginManager = (0, _kubb_core_hooks.usePluginManager)();
|
|
462
|
+
const oas = (0, _kubb_plugin_oas_hooks.useOas)();
|
|
463
|
+
const { getSchemas, getName, getFile } = (0, _kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
464
464
|
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
465
465
|
const isMutation = (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
466
466
|
const importPath = options.query ? options.query.importPath : "@tanstack/vue-query";
|
|
@@ -472,13 +472,13 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
472
472
|
typeName: getName(operation, { type: "type" }),
|
|
473
473
|
file: getFile(operation, { prefix: "use" })
|
|
474
474
|
};
|
|
475
|
-
const shouldUseClientPlugin = !!pluginManager.getPluginByKey([
|
|
475
|
+
const shouldUseClientPlugin = !!pluginManager.getPluginByKey([_kubb_plugin_client.pluginClientName]) && options.client.clientType !== "class";
|
|
476
476
|
const client = {
|
|
477
477
|
name: shouldUseClientPlugin ? getName(operation, {
|
|
478
478
|
type: "function",
|
|
479
|
-
pluginKey: [
|
|
479
|
+
pluginKey: [_kubb_plugin_client.pluginClientName]
|
|
480
480
|
}) : getName(operation, { type: "function" }),
|
|
481
|
-
file: getFile(operation, { pluginKey: [
|
|
481
|
+
file: getFile(operation, { pluginKey: [_kubb_plugin_client.pluginClientName] })
|
|
482
482
|
};
|
|
483
483
|
const queryOptions = { name: getName(operation, {
|
|
484
484
|
type: "function",
|
|
@@ -495,93 +495,93 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
495
495
|
})
|
|
496
496
|
};
|
|
497
497
|
const type = {
|
|
498
|
-
file: getFile(operation, { pluginKey: [
|
|
498
|
+
file: getFile(operation, { pluginKey: [_kubb_plugin_ts.pluginTsName] }),
|
|
499
499
|
schemas: getSchemas(operation, {
|
|
500
|
-
pluginKey: [
|
|
500
|
+
pluginKey: [_kubb_plugin_ts.pluginTsName],
|
|
501
501
|
type: "type"
|
|
502
502
|
})
|
|
503
503
|
};
|
|
504
504
|
const zod = {
|
|
505
|
-
file: getFile(operation, { pluginKey: [
|
|
505
|
+
file: getFile(operation, { pluginKey: [_kubb_plugin_zod.pluginZodName] }),
|
|
506
506
|
schemas: getSchemas(operation, {
|
|
507
|
-
pluginKey: [
|
|
507
|
+
pluginKey: [_kubb_plugin_zod.pluginZodName],
|
|
508
508
|
type: "function"
|
|
509
509
|
})
|
|
510
510
|
};
|
|
511
511
|
if (!isQuery || isMutation) return null;
|
|
512
|
-
return /* @__PURE__ */ (0,
|
|
512
|
+
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File, {
|
|
513
513
|
baseName: query.file.baseName,
|
|
514
514
|
path: query.file.path,
|
|
515
515
|
meta: query.file.meta,
|
|
516
|
-
banner: (0,
|
|
516
|
+
banner: (0, _kubb_plugin_oas_utils.getBanner)({
|
|
517
517
|
oas,
|
|
518
518
|
output,
|
|
519
519
|
config: pluginManager.config
|
|
520
520
|
}),
|
|
521
|
-
footer: (0,
|
|
521
|
+
footer: (0, _kubb_plugin_oas_utils.getFooter)({
|
|
522
522
|
oas,
|
|
523
523
|
output
|
|
524
524
|
}),
|
|
525
525
|
children: [
|
|
526
|
-
options.parser === "zod" && /* @__PURE__ */ (0,
|
|
526
|
+
options.parser === "zod" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
527
527
|
name: [zod.schemas.response.name, zod.schemas.request?.name].filter(Boolean),
|
|
528
528
|
root: query.file.path,
|
|
529
529
|
path: zod.file.path
|
|
530
530
|
}),
|
|
531
|
-
options.client.importPath ? /* @__PURE__ */ (0,
|
|
532
|
-
/* @__PURE__ */ (0,
|
|
531
|
+
options.client.importPath ? /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
532
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
533
533
|
name: "fetch",
|
|
534
534
|
path: options.client.importPath
|
|
535
535
|
}),
|
|
536
|
-
/* @__PURE__ */ (0,
|
|
536
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
537
537
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
538
538
|
path: options.client.importPath,
|
|
539
539
|
isTypeOnly: true
|
|
540
540
|
}),
|
|
541
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ (0,
|
|
541
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
542
542
|
name: ["ResponseConfig"],
|
|
543
543
|
path: options.client.importPath,
|
|
544
544
|
isTypeOnly: true
|
|
545
545
|
})
|
|
546
|
-
] }) : /* @__PURE__ */ (0,
|
|
547
|
-
/* @__PURE__ */ (0,
|
|
546
|
+
] }) : /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
547
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
548
548
|
name: ["fetch"],
|
|
549
549
|
root: query.file.path,
|
|
550
550
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts")
|
|
551
551
|
}),
|
|
552
|
-
/* @__PURE__ */ (0,
|
|
552
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
553
553
|
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
554
554
|
root: query.file.path,
|
|
555
555
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
556
556
|
isTypeOnly: true
|
|
557
557
|
}),
|
|
558
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ (0,
|
|
558
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
559
559
|
name: ["ResponseConfig"],
|
|
560
560
|
root: query.file.path,
|
|
561
561
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetch.ts"),
|
|
562
562
|
isTypeOnly: true
|
|
563
563
|
})
|
|
564
564
|
] }),
|
|
565
|
-
/* @__PURE__ */ (0,
|
|
565
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
566
566
|
name: ["toValue"],
|
|
567
567
|
path: "vue"
|
|
568
568
|
}),
|
|
569
|
-
/* @__PURE__ */ (0,
|
|
569
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
570
570
|
name: ["MaybeRefOrGetter"],
|
|
571
571
|
path: "vue",
|
|
572
572
|
isTypeOnly: true
|
|
573
573
|
}),
|
|
574
|
-
shouldUseClientPlugin && /* @__PURE__ */ (0,
|
|
574
|
+
shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
575
575
|
name: [client.name],
|
|
576
576
|
root: query.file.path,
|
|
577
577
|
path: client.file.path
|
|
578
578
|
}),
|
|
579
|
-
!shouldUseClientPlugin && /* @__PURE__ */ (0,
|
|
579
|
+
!shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
580
580
|
name: ["buildFormData"],
|
|
581
581
|
root: query.file.path,
|
|
582
582
|
path: node_path.default.resolve(config.root, config.output.path, ".kubb/config.ts")
|
|
583
583
|
}),
|
|
584
|
-
/* @__PURE__ */ (0,
|
|
584
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
585
585
|
name: [
|
|
586
586
|
type.schemas.request?.name,
|
|
587
587
|
type.schemas.response.name,
|
|
@@ -594,7 +594,7 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
594
594
|
path: type.file.path,
|
|
595
595
|
isTypeOnly: true
|
|
596
596
|
}),
|
|
597
|
-
/* @__PURE__ */ (0,
|
|
597
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryKey, {
|
|
598
598
|
name: queryKey.name,
|
|
599
599
|
typeName: queryKey.typeName,
|
|
600
600
|
operation,
|
|
@@ -603,7 +603,7 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
603
603
|
typeSchemas: type.schemas,
|
|
604
604
|
transformer: options.queryKey
|
|
605
605
|
}),
|
|
606
|
-
!shouldUseClientPlugin && /* @__PURE__ */ (0,
|
|
606
|
+
!shouldUseClientPlugin && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_plugin_client_components.Client, {
|
|
607
607
|
name: client.name,
|
|
608
608
|
baseURL: options.client.baseURL,
|
|
609
609
|
operation,
|
|
@@ -615,11 +615,11 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
615
615
|
pathParamsType: options.pathParamsType,
|
|
616
616
|
parser: options.parser
|
|
617
617
|
}),
|
|
618
|
-
/* @__PURE__ */ (0,
|
|
618
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
619
619
|
name: ["queryOptions"],
|
|
620
620
|
path: importPath
|
|
621
621
|
}),
|
|
622
|
-
/* @__PURE__ */ (0,
|
|
622
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryOptions, {
|
|
623
623
|
name: queryOptions.name,
|
|
624
624
|
clientName: client.name,
|
|
625
625
|
queryKeyName: queryKey.name,
|
|
@@ -629,12 +629,12 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
629
629
|
pathParamsType: options.pathParamsType,
|
|
630
630
|
dataReturnType: options.client.dataReturnType || "data"
|
|
631
631
|
}),
|
|
632
|
-
options.query && /* @__PURE__ */ (0,
|
|
633
|
-
/* @__PURE__ */ (0,
|
|
632
|
+
options.query && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
633
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
634
634
|
name: ["useQuery"],
|
|
635
635
|
path: importPath
|
|
636
636
|
}),
|
|
637
|
-
/* @__PURE__ */ (0,
|
|
637
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Import, {
|
|
638
638
|
name: [
|
|
639
639
|
"QueryKey",
|
|
640
640
|
"QueryClient",
|
|
@@ -644,7 +644,7 @@ const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
|
644
644
|
path: importPath,
|
|
645
645
|
isTypeOnly: true
|
|
646
646
|
}),
|
|
647
|
-
/* @__PURE__ */ (0,
|
|
647
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(require_components.Query, {
|
|
648
648
|
name: query.name,
|
|
649
649
|
queryOptionsName: queryOptions.name,
|
|
650
650
|
typeSchemas: type.schemas,
|
|
@@ -687,4 +687,4 @@ Object.defineProperty(exports, 'queryGenerator', {
|
|
|
687
687
|
return queryGenerator;
|
|
688
688
|
}
|
|
689
689
|
});
|
|
690
|
-
//# sourceMappingURL=generators-
|
|
690
|
+
//# sourceMappingURL=generators-BSkCG7hV.cjs.map
|