@kubb/plugin-vue-query 4.4.1 → 4.5.1
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-DoPUxAFs.cjs → components-CvorLYVT.cjs} +214 -214
- package/dist/components-CvorLYVT.cjs.map +1 -0
- package/dist/{components-B8p5782n.js → components-kADKAHgd.js} +213 -213
- package/dist/components-kADKAHgd.js.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.cts +114 -114
- package/dist/components.d.ts +114 -114
- package/dist/components.js +1 -1
- package/dist/{generators-a7s1tUe0.cjs → generators-B7BEw8ZB.cjs} +206 -143
- package/dist/generators-B7BEw8ZB.cjs.map +1 -0
- package/dist/{generators-CxbnV3X_.js → generators-DHkXUh19.js} +203 -141
- package/dist/generators-DHkXUh19.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.d.cts +5 -5
- package/dist/generators.d.ts +5 -5
- package/dist/generators.js +2 -2
- package/dist/index.cjs +18 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/dist/{types-CGRXTDFW.d.ts → types-BfKwA3Gv.d.cts} +175 -183
- package/dist/{types-PVIn4n6Z.d.cts → types-I09wleY8.d.ts} +175 -183
- package/package.json +9 -9
- package/src/components/QueryOptions.tsx +1 -1
- package/src/components/index.ts +3 -3
- package/src/generators/index.ts +2 -2
- package/src/generators/infiniteQueryGenerator.tsx +35 -11
- package/src/generators/mutationGenerator.tsx +34 -9
- package/src/generators/queryGenerator.tsx +35 -11
- package/src/plugin.ts +24 -1
- package/src/types.ts +4 -3
- package/dist/components-B8p5782n.js.map +0 -1
- package/dist/components-DoPUxAFs.cjs.map +0 -1
- package/dist/generators-CxbnV3X_.js.map +0 -1
- package/dist/generators-a7s1tUe0.cjs.map +0 -1
|
@@ -1,66 +1,76 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
2
|
-
let
|
|
3
|
-
|
|
1
|
+
const require_components = require('./components-CvorLYVT.cjs');
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
node_path = require_components.__toESM(node_path);
|
|
4
|
+
let __kubb_plugin_client = require("@kubb/plugin-client");
|
|
5
|
+
__kubb_plugin_client = require_components.__toESM(__kubb_plugin_client);
|
|
4
6
|
let __kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
5
7
|
__kubb_plugin_ts = require_components.__toESM(__kubb_plugin_ts);
|
|
6
8
|
let __kubb_plugin_zod = require("@kubb/plugin-zod");
|
|
7
9
|
__kubb_plugin_zod = require_components.__toESM(__kubb_plugin_zod);
|
|
8
|
-
let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
9
|
-
__kubb_plugin_client_components = require_components.__toESM(__kubb_plugin_client_components);
|
|
10
10
|
let __kubb_plugin_oas_utils = require("@kubb/plugin-oas/utils");
|
|
11
11
|
__kubb_plugin_oas_utils = require_components.__toESM(__kubb_plugin_oas_utils);
|
|
12
12
|
let __kubb_react_fabric = require("@kubb/react-fabric");
|
|
13
13
|
__kubb_react_fabric = require_components.__toESM(__kubb_react_fabric);
|
|
14
14
|
let __kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
15
15
|
__kubb_react_fabric_jsx_runtime = require_components.__toESM(__kubb_react_fabric_jsx_runtime);
|
|
16
|
+
let __kubb_plugin_client_components = require("@kubb/plugin-client/components");
|
|
17
|
+
__kubb_plugin_client_components = require_components.__toESM(__kubb_plugin_client_components);
|
|
16
18
|
let __kubb_core_hooks = require("@kubb/core/hooks");
|
|
17
19
|
__kubb_core_hooks = require_components.__toESM(__kubb_core_hooks);
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
+
let __kubb_plugin_oas_generators = require("@kubb/plugin-oas/generators");
|
|
21
|
+
__kubb_plugin_oas_generators = require_components.__toESM(__kubb_plugin_oas_generators);
|
|
20
22
|
let __kubb_plugin_oas_hooks = require("@kubb/plugin-oas/hooks");
|
|
21
23
|
__kubb_plugin_oas_hooks = require_components.__toESM(__kubb_plugin_oas_hooks);
|
|
22
24
|
let remeda = require("remeda");
|
|
23
25
|
remeda = require_components.__toESM(remeda);
|
|
24
26
|
|
|
25
|
-
//#region src/generators/
|
|
26
|
-
const
|
|
27
|
-
name: "vue-query",
|
|
28
|
-
Operation({
|
|
29
|
-
const { options: { output } } =
|
|
27
|
+
//#region src/generators/infiniteQueryGenerator.tsx
|
|
28
|
+
const infiniteQueryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
29
|
+
name: "vue-infinite-query",
|
|
30
|
+
Operation({ config, operation, generator, plugin }) {
|
|
31
|
+
const { options, options: { output } } = plugin;
|
|
30
32
|
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
31
33
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
32
|
-
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
34
|
+
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
33
35
|
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
34
36
|
const isMutation = (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
37
|
+
const isInfinite = isQuery && !!options.infinite;
|
|
35
38
|
const importPath = options.query ? options.query.importPath : "@tanstack/vue-query";
|
|
36
39
|
const query = {
|
|
37
40
|
name: getName(operation, {
|
|
38
41
|
type: "function",
|
|
39
|
-
prefix: "use"
|
|
42
|
+
prefix: "use",
|
|
43
|
+
suffix: "infinite"
|
|
40
44
|
}),
|
|
41
45
|
typeName: getName(operation, { type: "type" }),
|
|
42
|
-
file: getFile(operation, {
|
|
46
|
+
file: getFile(operation, {
|
|
47
|
+
prefix: "use",
|
|
48
|
+
suffix: "infinite"
|
|
49
|
+
})
|
|
43
50
|
};
|
|
44
51
|
const hasClientPlugin = !!pluginManager.getPluginByKey([__kubb_plugin_client.pluginClientName]);
|
|
45
52
|
const client = {
|
|
46
53
|
name: hasClientPlugin ? getName(operation, {
|
|
47
54
|
type: "function",
|
|
48
55
|
pluginKey: [__kubb_plugin_client.pluginClientName]
|
|
49
|
-
}) : getName(operation, {
|
|
56
|
+
}) : getName(operation, {
|
|
57
|
+
type: "function",
|
|
58
|
+
suffix: "infinite"
|
|
59
|
+
}),
|
|
50
60
|
file: getFile(operation, { pluginKey: [__kubb_plugin_client.pluginClientName] })
|
|
51
61
|
};
|
|
52
62
|
const queryOptions = { name: getName(operation, {
|
|
53
63
|
type: "function",
|
|
54
|
-
suffix: "
|
|
64
|
+
suffix: "InfiniteQueryOptions"
|
|
55
65
|
}) };
|
|
56
66
|
const queryKey = {
|
|
57
67
|
name: getName(operation, {
|
|
58
68
|
type: "const",
|
|
59
|
-
suffix: "
|
|
69
|
+
suffix: "InfiniteQueryKey"
|
|
60
70
|
}),
|
|
61
71
|
typeName: getName(operation, {
|
|
62
72
|
type: "type",
|
|
63
|
-
suffix: "
|
|
73
|
+
suffix: "InfiniteQueryKey"
|
|
64
74
|
})
|
|
65
75
|
};
|
|
66
76
|
const type = {
|
|
@@ -77,7 +87,7 @@ const queryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
77
87
|
type: "function"
|
|
78
88
|
})
|
|
79
89
|
};
|
|
80
|
-
if (!isQuery || isMutation) return null;
|
|
90
|
+
if (!isQuery || isMutation || !isInfinite) return null;
|
|
81
91
|
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric.File, {
|
|
82
92
|
baseName: query.file.baseName,
|
|
83
93
|
path: query.file.path,
|
|
@@ -97,6 +107,40 @@ const queryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
97
107
|
root: query.file.path,
|
|
98
108
|
path: zod.file.path
|
|
99
109
|
}),
|
|
110
|
+
options.client.importPath ? /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
111
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
112
|
+
name: "fetch",
|
|
113
|
+
path: options.client.importPath
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
116
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
117
|
+
path: options.client.importPath,
|
|
118
|
+
isTypeOnly: true
|
|
119
|
+
}),
|
|
120
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
121
|
+
name: ["ResponseConfig"],
|
|
122
|
+
path: options.client.importPath,
|
|
123
|
+
isTypeOnly: true
|
|
124
|
+
})
|
|
125
|
+
] }) : /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
126
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
127
|
+
name: "fetch",
|
|
128
|
+
root: query.file.path,
|
|
129
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts")
|
|
130
|
+
}),
|
|
131
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
132
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
133
|
+
root: query.file.path,
|
|
134
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
|
|
135
|
+
isTypeOnly: true
|
|
136
|
+
}),
|
|
137
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
138
|
+
name: ["ResponseConfig"],
|
|
139
|
+
root: query.file.path,
|
|
140
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
|
|
141
|
+
isTypeOnly: true
|
|
142
|
+
})
|
|
143
|
+
] }),
|
|
100
144
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
101
145
|
name: ["toValue"],
|
|
102
146
|
path: "vue"
|
|
@@ -106,25 +150,11 @@ const queryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
106
150
|
path: "vue",
|
|
107
151
|
isTypeOnly: true
|
|
108
152
|
}),
|
|
109
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
110
|
-
name: "fetch",
|
|
111
|
-
path: options.client.importPath
|
|
112
|
-
}),
|
|
113
|
-
!!hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
153
|
+
hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
114
154
|
name: [client.name],
|
|
115
155
|
root: query.file.path,
|
|
116
156
|
path: client.file.path
|
|
117
157
|
}),
|
|
118
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
119
|
-
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
120
|
-
path: options.client.importPath,
|
|
121
|
-
isTypeOnly: true
|
|
122
|
-
}),
|
|
123
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
124
|
-
name: ["ResponseConfig"],
|
|
125
|
-
path: options.client.importPath,
|
|
126
|
-
isTypeOnly: true
|
|
127
|
-
}),
|
|
128
158
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
129
159
|
name: [
|
|
130
160
|
type.schemas.request?.name,
|
|
@@ -153,42 +183,52 @@ const queryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
153
183
|
operation,
|
|
154
184
|
typeSchemas: type.schemas,
|
|
155
185
|
zodSchemas: zod.schemas,
|
|
156
|
-
dataReturnType: options.client.dataReturnType,
|
|
186
|
+
dataReturnType: options.client.dataReturnType || "data",
|
|
157
187
|
paramsCasing: options.paramsCasing,
|
|
158
188
|
paramsType: options.paramsType,
|
|
159
189
|
pathParamsType: options.pathParamsType,
|
|
160
190
|
parser: options.parser
|
|
161
191
|
}),
|
|
162
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.
|
|
163
|
-
name: ["queryOptions"],
|
|
164
|
-
path: importPath
|
|
165
|
-
}),
|
|
166
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryOptions, {
|
|
167
|
-
name: queryOptions.name,
|
|
168
|
-
clientName: client.name,
|
|
169
|
-
queryKeyName: queryKey.name,
|
|
170
|
-
paramsCasing: options.paramsCasing,
|
|
171
|
-
typeSchemas: type.schemas,
|
|
172
|
-
paramsType: options.paramsType,
|
|
173
|
-
pathParamsType: options.pathParamsType,
|
|
174
|
-
dataReturnType: options.client.dataReturnType
|
|
175
|
-
}),
|
|
176
|
-
options.query && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
192
|
+
options.infinite && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
177
193
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
178
|
-
name: ["
|
|
194
|
+
name: ["InfiniteData"],
|
|
195
|
+
isTypeOnly: true,
|
|
196
|
+
path: importPath
|
|
197
|
+
}),
|
|
198
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
199
|
+
name: ["infiniteQueryOptions"],
|
|
200
|
+
path: importPath
|
|
201
|
+
}),
|
|
202
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.InfiniteQueryOptions, {
|
|
203
|
+
name: queryOptions.name,
|
|
204
|
+
clientName: client.name,
|
|
205
|
+
queryKeyName: queryKey.name,
|
|
206
|
+
typeSchemas: type.schemas,
|
|
207
|
+
paramsType: options.paramsType,
|
|
208
|
+
paramsCasing: options.paramsCasing,
|
|
209
|
+
pathParamsType: options.pathParamsType,
|
|
210
|
+
dataReturnType: options.client.dataReturnType || "data",
|
|
211
|
+
cursorParam: options.infinite.cursorParam,
|
|
212
|
+
initialPageParam: options.infinite.initialPageParam,
|
|
213
|
+
queryParam: options.infinite.queryParam
|
|
214
|
+
})
|
|
215
|
+
] }),
|
|
216
|
+
options.infinite && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
217
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
218
|
+
name: ["useInfiniteQuery"],
|
|
179
219
|
path: importPath
|
|
180
220
|
}),
|
|
181
221
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
182
222
|
name: [
|
|
183
223
|
"QueryKey",
|
|
184
224
|
"QueryClient",
|
|
185
|
-
"
|
|
186
|
-
"
|
|
225
|
+
"InfiniteQueryObserverOptions",
|
|
226
|
+
"UseInfiniteQueryReturnType"
|
|
187
227
|
],
|
|
188
228
|
path: importPath,
|
|
189
229
|
isTypeOnly: true
|
|
190
230
|
}),
|
|
191
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.
|
|
231
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.InfiniteQuery, {
|
|
192
232
|
name: query.name,
|
|
193
233
|
queryOptionsName: queryOptions.name,
|
|
194
234
|
typeSchemas: type.schemas,
|
|
@@ -196,7 +236,7 @@ const queryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
196
236
|
paramsType: options.paramsType,
|
|
197
237
|
pathParamsType: options.pathParamsType,
|
|
198
238
|
operation,
|
|
199
|
-
dataReturnType: options.client.dataReturnType,
|
|
239
|
+
dataReturnType: options.client.dataReturnType || "data",
|
|
200
240
|
queryKeyName: queryKey.name,
|
|
201
241
|
queryKeyTypeName: queryKey.typeName
|
|
202
242
|
})
|
|
@@ -208,13 +248,13 @@ const queryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
208
248
|
|
|
209
249
|
//#endregion
|
|
210
250
|
//#region src/generators/mutationGenerator.tsx
|
|
211
|
-
const mutationGenerator = (0,
|
|
251
|
+
const mutationGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
212
252
|
name: "vue-query",
|
|
213
|
-
Operation({
|
|
214
|
-
const { options: { output } } =
|
|
253
|
+
Operation({ config, operation, generator, plugin }) {
|
|
254
|
+
const { options, options: { output } } = plugin;
|
|
215
255
|
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
216
256
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
217
|
-
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
257
|
+
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
218
258
|
const isMutation = !(!!options.query && options.query?.methods.some((method) => operation.method === method)) && (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
219
259
|
const importPath = options.mutation ? options.mutation.importPath : "@tanstack/vue-query";
|
|
220
260
|
const mutation = {
|
|
@@ -277,29 +317,50 @@ const mutationGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
277
317
|
root: mutation.file.path,
|
|
278
318
|
path: zod.file.path
|
|
279
319
|
}),
|
|
320
|
+
options.client.importPath ? /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
321
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
322
|
+
name: "fetch",
|
|
323
|
+
path: options.client.importPath
|
|
324
|
+
}),
|
|
325
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
326
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
327
|
+
path: options.client.importPath,
|
|
328
|
+
isTypeOnly: true
|
|
329
|
+
}),
|
|
330
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
331
|
+
name: ["ResponseConfig"],
|
|
332
|
+
path: options.client.importPath,
|
|
333
|
+
isTypeOnly: true
|
|
334
|
+
})
|
|
335
|
+
] }) : /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
336
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
337
|
+
name: "fetch",
|
|
338
|
+
root: mutation.file.path,
|
|
339
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts")
|
|
340
|
+
}),
|
|
341
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
342
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
343
|
+
root: mutation.file.path,
|
|
344
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
|
|
345
|
+
isTypeOnly: true
|
|
346
|
+
}),
|
|
347
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
348
|
+
name: ["ResponseConfig"],
|
|
349
|
+
root: mutation.file.path,
|
|
350
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
|
|
351
|
+
isTypeOnly: true
|
|
352
|
+
})
|
|
353
|
+
] }),
|
|
280
354
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
281
355
|
name: ["MaybeRefOrGetter"],
|
|
282
356
|
path: "vue",
|
|
283
357
|
isTypeOnly: true
|
|
284
358
|
}),
|
|
285
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
286
|
-
name: "fetch",
|
|
287
|
-
path: options.client.importPath
|
|
288
|
-
}),
|
|
289
359
|
!!hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
290
360
|
name: [client.name],
|
|
291
361
|
root: mutation.file.path,
|
|
292
362
|
path: client.file.path
|
|
293
363
|
}),
|
|
294
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
295
|
-
name: [
|
|
296
|
-
"RequestConfig",
|
|
297
|
-
"ResponseConfig",
|
|
298
|
-
"ResponseErrorConfig"
|
|
299
|
-
],
|
|
300
|
-
path: options.client.importPath,
|
|
301
|
-
isTypeOnly: true
|
|
302
|
-
}),
|
|
303
364
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
304
365
|
name: [
|
|
305
366
|
type.schemas.request?.name,
|
|
@@ -328,7 +389,7 @@ const mutationGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
328
389
|
operation,
|
|
329
390
|
typeSchemas: type.schemas,
|
|
330
391
|
zodSchemas: zod.schemas,
|
|
331
|
-
dataReturnType: options.client.dataReturnType,
|
|
392
|
+
dataReturnType: options.client.dataReturnType || "data",
|
|
332
393
|
paramsCasing: options.paramsCasing,
|
|
333
394
|
paramsType: options.paramsType,
|
|
334
395
|
pathParamsType: options.pathParamsType,
|
|
@@ -351,7 +412,7 @@ const mutationGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
351
412
|
typeSchemas: type.schemas,
|
|
352
413
|
operation,
|
|
353
414
|
paramsCasing: options.paramsCasing,
|
|
354
|
-
dataReturnType: options.client.dataReturnType,
|
|
415
|
+
dataReturnType: options.client.dataReturnType || "data",
|
|
355
416
|
paramsType: options.paramsType,
|
|
356
417
|
pathParamsType: options.pathParamsType,
|
|
357
418
|
mutationKeyName: mutationKey.name
|
|
@@ -363,53 +424,45 @@ const mutationGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
363
424
|
});
|
|
364
425
|
|
|
365
426
|
//#endregion
|
|
366
|
-
//#region src/generators/
|
|
367
|
-
const
|
|
368
|
-
name: "vue-
|
|
369
|
-
Operation({
|
|
370
|
-
const { options: { output } } =
|
|
427
|
+
//#region src/generators/queryGenerator.tsx
|
|
428
|
+
const queryGenerator = (0, __kubb_plugin_oas_generators.createReactGenerator)({
|
|
429
|
+
name: "vue-query",
|
|
430
|
+
Operation({ config, operation, generator, plugin }) {
|
|
431
|
+
const { options, options: { output } } = plugin;
|
|
371
432
|
const pluginManager = (0, __kubb_core_hooks.usePluginManager)();
|
|
372
433
|
const oas = (0, __kubb_plugin_oas_hooks.useOas)();
|
|
373
|
-
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)();
|
|
434
|
+
const { getSchemas, getName, getFile } = (0, __kubb_plugin_oas_hooks.useOperationManager)(generator);
|
|
374
435
|
const isQuery = typeof options.query === "boolean" ? true : options.query?.methods.some((method) => operation.method === method);
|
|
375
436
|
const isMutation = (0, remeda.difference)(options.mutation ? options.mutation.methods : [], options.query ? options.query.methods : []).some((method) => operation.method === method);
|
|
376
|
-
const isInfinite = isQuery && !!options.infinite;
|
|
377
437
|
const importPath = options.query ? options.query.importPath : "@tanstack/vue-query";
|
|
378
438
|
const query = {
|
|
379
439
|
name: getName(operation, {
|
|
380
440
|
type: "function",
|
|
381
|
-
prefix: "use"
|
|
382
|
-
suffix: "infinite"
|
|
441
|
+
prefix: "use"
|
|
383
442
|
}),
|
|
384
443
|
typeName: getName(operation, { type: "type" }),
|
|
385
|
-
file: getFile(operation, {
|
|
386
|
-
prefix: "use",
|
|
387
|
-
suffix: "infinite"
|
|
388
|
-
})
|
|
444
|
+
file: getFile(operation, { prefix: "use" })
|
|
389
445
|
};
|
|
390
446
|
const hasClientPlugin = !!pluginManager.getPluginByKey([__kubb_plugin_client.pluginClientName]);
|
|
391
447
|
const client = {
|
|
392
448
|
name: hasClientPlugin ? getName(operation, {
|
|
393
449
|
type: "function",
|
|
394
450
|
pluginKey: [__kubb_plugin_client.pluginClientName]
|
|
395
|
-
}) : getName(operation, {
|
|
396
|
-
type: "function",
|
|
397
|
-
suffix: "infinite"
|
|
398
|
-
}),
|
|
451
|
+
}) : getName(operation, { type: "function" }),
|
|
399
452
|
file: getFile(operation, { pluginKey: [__kubb_plugin_client.pluginClientName] })
|
|
400
453
|
};
|
|
401
454
|
const queryOptions = { name: getName(operation, {
|
|
402
455
|
type: "function",
|
|
403
|
-
suffix: "
|
|
456
|
+
suffix: "QueryOptions"
|
|
404
457
|
}) };
|
|
405
458
|
const queryKey = {
|
|
406
459
|
name: getName(operation, {
|
|
407
460
|
type: "const",
|
|
408
|
-
suffix: "
|
|
461
|
+
suffix: "QueryKey"
|
|
409
462
|
}),
|
|
410
463
|
typeName: getName(operation, {
|
|
411
464
|
type: "type",
|
|
412
|
-
suffix: "
|
|
465
|
+
suffix: "QueryKey"
|
|
413
466
|
})
|
|
414
467
|
};
|
|
415
468
|
const type = {
|
|
@@ -426,7 +479,7 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
426
479
|
type: "function"
|
|
427
480
|
})
|
|
428
481
|
};
|
|
429
|
-
if (!isQuery || isMutation
|
|
482
|
+
if (!isQuery || isMutation) return null;
|
|
430
483
|
return /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric.File, {
|
|
431
484
|
baseName: query.file.baseName,
|
|
432
485
|
path: query.file.path,
|
|
@@ -446,6 +499,40 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
446
499
|
root: query.file.path,
|
|
447
500
|
path: zod.file.path
|
|
448
501
|
}),
|
|
502
|
+
options.client.importPath ? /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
503
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
504
|
+
name: "fetch",
|
|
505
|
+
path: options.client.importPath
|
|
506
|
+
}),
|
|
507
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
508
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
509
|
+
path: options.client.importPath,
|
|
510
|
+
isTypeOnly: true
|
|
511
|
+
}),
|
|
512
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
513
|
+
name: ["ResponseConfig"],
|
|
514
|
+
path: options.client.importPath,
|
|
515
|
+
isTypeOnly: true
|
|
516
|
+
})
|
|
517
|
+
] }) : /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
518
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
519
|
+
name: "fetch",
|
|
520
|
+
root: query.file.path,
|
|
521
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts")
|
|
522
|
+
}),
|
|
523
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
524
|
+
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
525
|
+
root: query.file.path,
|
|
526
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
|
|
527
|
+
isTypeOnly: true
|
|
528
|
+
}),
|
|
529
|
+
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
530
|
+
name: ["ResponseConfig"],
|
|
531
|
+
root: query.file.path,
|
|
532
|
+
path: node_path.default.resolve(config.root, config.output.path, ".kubb/fetcher.ts"),
|
|
533
|
+
isTypeOnly: true
|
|
534
|
+
})
|
|
535
|
+
] }),
|
|
449
536
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
450
537
|
name: ["toValue"],
|
|
451
538
|
path: "vue"
|
|
@@ -455,25 +542,11 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
455
542
|
path: "vue",
|
|
456
543
|
isTypeOnly: true
|
|
457
544
|
}),
|
|
458
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
459
|
-
name: "fetch",
|
|
460
|
-
path: options.client.importPath
|
|
461
|
-
}),
|
|
462
|
-
hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
545
|
+
!!hasClientPlugin && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
463
546
|
name: [client.name],
|
|
464
547
|
root: query.file.path,
|
|
465
548
|
path: client.file.path
|
|
466
549
|
}),
|
|
467
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
468
|
-
name: ["RequestConfig", "ResponseErrorConfig"],
|
|
469
|
-
path: options.client.importPath,
|
|
470
|
-
isTypeOnly: true
|
|
471
|
-
}),
|
|
472
|
-
options.client.dataReturnType === "full" && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
473
|
-
name: ["ResponseConfig"],
|
|
474
|
-
path: options.client.importPath,
|
|
475
|
-
isTypeOnly: true
|
|
476
|
-
}),
|
|
477
550
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
478
551
|
name: [
|
|
479
552
|
type.schemas.request?.name,
|
|
@@ -502,52 +575,42 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
502
575
|
operation,
|
|
503
576
|
typeSchemas: type.schemas,
|
|
504
577
|
zodSchemas: zod.schemas,
|
|
505
|
-
dataReturnType: options.client.dataReturnType,
|
|
578
|
+
dataReturnType: options.client.dataReturnType || "data",
|
|
506
579
|
paramsCasing: options.paramsCasing,
|
|
507
580
|
paramsType: options.paramsType,
|
|
508
581
|
pathParamsType: options.pathParamsType,
|
|
509
582
|
parser: options.parser
|
|
510
583
|
}),
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
paramsType: options.paramsType,
|
|
527
|
-
paramsCasing: options.paramsCasing,
|
|
528
|
-
pathParamsType: options.pathParamsType,
|
|
529
|
-
dataReturnType: options.client.dataReturnType,
|
|
530
|
-
cursorParam: options.infinite.cursorParam,
|
|
531
|
-
initialPageParam: options.infinite.initialPageParam,
|
|
532
|
-
queryParam: options.infinite.queryParam
|
|
533
|
-
})
|
|
534
|
-
] }),
|
|
535
|
-
options.infinite && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
584
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
585
|
+
name: ["queryOptions"],
|
|
586
|
+
path: importPath
|
|
587
|
+
}),
|
|
588
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.QueryOptions, {
|
|
589
|
+
name: queryOptions.name,
|
|
590
|
+
clientName: client.name,
|
|
591
|
+
queryKeyName: queryKey.name,
|
|
592
|
+
paramsCasing: options.paramsCasing,
|
|
593
|
+
typeSchemas: type.schemas,
|
|
594
|
+
paramsType: options.paramsType,
|
|
595
|
+
pathParamsType: options.pathParamsType,
|
|
596
|
+
dataReturnType: options.client.dataReturnType || "data"
|
|
597
|
+
}),
|
|
598
|
+
options.query && /* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsxs)(__kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
536
599
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
537
|
-
name: ["
|
|
600
|
+
name: ["useQuery"],
|
|
538
601
|
path: importPath
|
|
539
602
|
}),
|
|
540
603
|
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(__kubb_react_fabric.File.Import, {
|
|
541
604
|
name: [
|
|
542
605
|
"QueryKey",
|
|
543
606
|
"QueryClient",
|
|
544
|
-
"
|
|
545
|
-
"
|
|
607
|
+
"QueryObserverOptions",
|
|
608
|
+
"UseQueryReturnType"
|
|
546
609
|
],
|
|
547
610
|
path: importPath,
|
|
548
611
|
isTypeOnly: true
|
|
549
612
|
}),
|
|
550
|
-
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.
|
|
613
|
+
/* @__PURE__ */ (0, __kubb_react_fabric_jsx_runtime.jsx)(require_components.Query, {
|
|
551
614
|
name: query.name,
|
|
552
615
|
queryOptionsName: queryOptions.name,
|
|
553
616
|
typeSchemas: type.schemas,
|
|
@@ -555,7 +618,7 @@ const infiniteQueryGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
555
618
|
paramsType: options.paramsType,
|
|
556
619
|
pathParamsType: options.pathParamsType,
|
|
557
620
|
operation,
|
|
558
|
-
dataReturnType: options.client.dataReturnType,
|
|
621
|
+
dataReturnType: options.client.dataReturnType || "data",
|
|
559
622
|
queryKeyName: queryKey.name,
|
|
560
623
|
queryKeyTypeName: queryKey.typeName
|
|
561
624
|
})
|
|
@@ -584,4 +647,4 @@ Object.defineProperty(exports, 'queryGenerator', {
|
|
|
584
647
|
return queryGenerator;
|
|
585
648
|
}
|
|
586
649
|
});
|
|
587
|
-
//# sourceMappingURL=generators-
|
|
650
|
+
//# sourceMappingURL=generators-B7BEw8ZB.cjs.map
|