@kubb/plugin-react-query 3.0.0-alpha.10 → 3.0.0-alpha.11
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/chunk-7ZODZVKP.cjs +306 -349
- package/dist/chunk-7ZODZVKP.cjs.map +1 -1
- package/dist/chunk-ZYTZV43V.js +211 -264
- package/dist/chunk-ZYTZV43V.js.map +1 -1
- package/dist/components.cjs +23 -12
- package/dist/components.cjs.map +1 -1
- package/dist/components.js +2 -12
- package/dist/components.js.map +1 -1
- package/dist/index.cjs +52 -56
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -26
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
package/dist/chunk-7ZODZVKP.cjs
CHANGED
|
@@ -1,40 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
3
|
-
var _utils = require('@kubb/core/utils');
|
|
4
|
-
var _hooks = require('@kubb/plugin-oas/hooks');
|
|
5
|
-
var _utils3 = require('@kubb/plugin-oas/utils');
|
|
6
|
-
var _react = require('@kubb/react');
|
|
7
|
-
var _plugints = require('@kubb/plugin-ts');
|
|
1
|
+
'use strict';
|
|
8
2
|
|
|
9
|
-
|
|
3
|
+
var transformers2 = require('@kubb/core/transformers');
|
|
4
|
+
var utils = require('@kubb/core/utils');
|
|
5
|
+
var hooks = require('@kubb/plugin-oas/hooks');
|
|
6
|
+
var utils$1 = require('@kubb/plugin-oas/utils');
|
|
7
|
+
var react = require('@kubb/react');
|
|
8
|
+
var pluginTs = require('@kubb/plugin-ts');
|
|
9
|
+
var jsxRuntime = require('@kubb/react/jsx-runtime');
|
|
10
|
+
var oas = require('@kubb/oas');
|
|
11
|
+
var core = require('@kubb/core');
|
|
12
|
+
var pluginZod = require('@kubb/plugin-zod');
|
|
10
13
|
|
|
14
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
15
|
|
|
16
|
+
var transformers2__default = /*#__PURE__*/_interopDefault(transformers2);
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
// src/components/Mutation.tsx
|
|
14
19
|
function SchemaType() {
|
|
15
20
|
const {
|
|
16
21
|
plugin: {
|
|
17
22
|
options: { dataReturnType }
|
|
18
23
|
}
|
|
19
|
-
} =
|
|
20
|
-
const { getSchemas, getName } =
|
|
21
|
-
const operation =
|
|
22
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
24
|
+
} = react.useApp();
|
|
25
|
+
const { getSchemas, getName } = hooks.useOperationManager();
|
|
26
|
+
const operation = hooks.useOperation();
|
|
27
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
|
|
23
28
|
const [TData, TError, TRequest, TPathParams, TQueryParams, THeaderParams, TResponse] = [
|
|
24
29
|
schemas.response.name,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
schemas.errors?.map((item) => item.name).join(" | ") || "never",
|
|
31
|
+
schemas.request?.name || "never",
|
|
32
|
+
schemas.pathParams?.name || "never",
|
|
33
|
+
schemas.queryParams?.name || "never",
|
|
34
|
+
schemas.headerParams?.name || "never",
|
|
30
35
|
schemas.response.name
|
|
31
36
|
];
|
|
32
37
|
const factoryName = getName(operation, { type: "type" });
|
|
33
38
|
const clientType = `${factoryName}Client`;
|
|
34
39
|
const isFormData = operation.getContentType() === "multipart/form-data";
|
|
35
|
-
return /* @__PURE__ */
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
-
/* @__PURE__ */
|
|
40
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
41
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name: clientType, isTypeOnly: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Type, { name: clientType, children: `typeof client<${TResponse}, ${TError}, ${isFormData ? "FormData" : TRequest}>` }) }),
|
|
42
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name: factoryName, isTypeOnly: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Type, { name: factoryName, children: `
|
|
38
43
|
{
|
|
39
44
|
data: ${TData}
|
|
40
45
|
error: ${TError}
|
|
@@ -51,10 +56,6 @@ function SchemaType() {
|
|
|
51
56
|
` }) })
|
|
52
57
|
] });
|
|
53
58
|
}
|
|
54
|
-
|
|
55
|
-
// src/components/Mutation.tsx
|
|
56
|
-
var _oas = require('@kubb/oas');
|
|
57
|
-
|
|
58
59
|
function Template({ name, params, mutateParams, JSDoc, client, hook, dataReturnType }) {
|
|
59
60
|
const isFormData = client.contentType === "multipart/form-data";
|
|
60
61
|
const headers = [
|
|
@@ -70,8 +71,8 @@ function Template({ name, params, mutateParams, JSDoc, client, hook, dataReturnT
|
|
|
70
71
|
headers.length ? `headers: { ${headers}, ...clientOptions.headers }` : void 0,
|
|
71
72
|
"...clientOptions"
|
|
72
73
|
].filter(Boolean);
|
|
73
|
-
const resolvedClientOptions = `${
|
|
74
|
-
${
|
|
74
|
+
const resolvedClientOptions = `${transformers2__default.default.createIndent(4)}${clientOptions.join(`,
|
|
75
|
+
${transformers2__default.default.createIndent(4)}`)}`;
|
|
75
76
|
const formData = isFormData ? `
|
|
76
77
|
const formData = new FormData()
|
|
77
78
|
if(data) {
|
|
@@ -83,7 +84,7 @@ ${_transformers2.default.createIndent(4)}`)}`;
|
|
|
83
84
|
})
|
|
84
85
|
}
|
|
85
86
|
` : void 0;
|
|
86
|
-
return /* @__PURE__ */
|
|
87
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { export: true, name, params, JSDoc, children: `
|
|
87
88
|
const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {}
|
|
88
89
|
|
|
89
90
|
return ${hook.name}({
|
|
@@ -107,40 +108,40 @@ function RootTemplate({ children }) {
|
|
|
107
108
|
mutate
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
|
-
} =
|
|
111
|
-
const { getSchemas, getFile } =
|
|
112
|
-
const operation =
|
|
113
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
111
|
+
} = react.useApp();
|
|
112
|
+
const { getSchemas, getFile } = hooks.useOperationManager();
|
|
113
|
+
const operation = hooks.useOperation();
|
|
114
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
|
|
114
115
|
const file = getFile(operation);
|
|
115
|
-
const fileType = getFile(operation, { pluginKey: [
|
|
116
|
-
return /* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
|
|
116
|
+
const fileType = getFile(operation, { pluginKey: [pluginTs.pluginTsName] });
|
|
117
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
118
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: importPath }),
|
|
119
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
|
|
120
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
121
|
+
react.File.Import,
|
|
121
122
|
{
|
|
122
123
|
name: [
|
|
123
|
-
|
|
124
|
+
schemas.request?.name,
|
|
124
125
|
schemas.response.name,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
...
|
|
126
|
+
schemas.pathParams?.name,
|
|
127
|
+
schemas.queryParams?.name,
|
|
128
|
+
schemas.headerParams?.name,
|
|
129
|
+
...schemas.errors?.map((error) => error.name) || []
|
|
129
130
|
].filter(Boolean),
|
|
130
131
|
root: file.path,
|
|
131
132
|
path: fileType.path,
|
|
132
133
|
isTypeOnly: true
|
|
133
134
|
}
|
|
134
135
|
),
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
137
|
+
react.File.Import,
|
|
137
138
|
{
|
|
138
139
|
name: ["UseMutationOptions", "UseMutationResult"],
|
|
139
140
|
path: typeof mutate !== "boolean" && mutate.importPath ? mutate.importPath : "@tanstack/react-query",
|
|
140
141
|
isTypeOnly: true
|
|
141
142
|
}
|
|
142
143
|
),
|
|
143
|
-
/* @__PURE__ */
|
|
144
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["useMutation"], path: typeof mutate !== "boolean" && mutate.importPath ? mutate.importPath : "@tanstack/react-query" }),
|
|
144
145
|
children
|
|
145
146
|
] });
|
|
146
147
|
}
|
|
@@ -150,44 +151,44 @@ function Mutation({ Template: Template6 = defaultTemplates.default }) {
|
|
|
150
151
|
plugin: {
|
|
151
152
|
options: { dataReturnType, mutate }
|
|
152
153
|
}
|
|
153
|
-
} =
|
|
154
|
-
const operation =
|
|
155
|
-
const { getSchemas, getName } =
|
|
154
|
+
} = react.useApp();
|
|
155
|
+
const operation = hooks.useOperation();
|
|
156
|
+
const { getSchemas, getName } = hooks.useOperationManager();
|
|
156
157
|
const name = getName(operation, { type: "function" });
|
|
157
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
158
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
|
|
158
159
|
const contentType = operation.getContentType();
|
|
159
|
-
const params = new
|
|
160
|
-
const mutateParams = new
|
|
160
|
+
const params = new utils.FunctionParams();
|
|
161
|
+
const mutateParams = new utils.FunctionParams();
|
|
161
162
|
const factoryName = getName(operation, { type: "type" });
|
|
162
|
-
const requestType = mutate && mutate.variablesType === "mutate" ?
|
|
163
|
-
...
|
|
163
|
+
const requestType = mutate && mutate.variablesType === "mutate" ? utils.FunctionParams.toObject([
|
|
164
|
+
...utils$1.getASTParams(schemas.pathParams, { typed: true }),
|
|
164
165
|
{
|
|
165
166
|
name: "params",
|
|
166
167
|
type: `${factoryName}['queryParams']`,
|
|
167
|
-
enabled: !!
|
|
168
|
-
required:
|
|
168
|
+
enabled: !!schemas.queryParams?.name,
|
|
169
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
169
170
|
},
|
|
170
171
|
{
|
|
171
172
|
name: "headers",
|
|
172
173
|
type: `${factoryName}['headerParams']`,
|
|
173
|
-
enabled: !!
|
|
174
|
-
required:
|
|
174
|
+
enabled: !!schemas.headerParams?.name,
|
|
175
|
+
required: oas.isRequired(schemas.headerParams?.schema)
|
|
175
176
|
},
|
|
176
177
|
{
|
|
177
178
|
name: "data",
|
|
178
179
|
type: `${factoryName}['request']`,
|
|
179
|
-
enabled: !!
|
|
180
|
-
required:
|
|
180
|
+
enabled: !!schemas.request?.name,
|
|
181
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
181
182
|
}
|
|
182
|
-
])
|
|
183
|
+
])?.type : schemas.request?.name ? `${factoryName}['request']` : "never";
|
|
183
184
|
const client = {
|
|
184
185
|
method: operation.method,
|
|
185
|
-
path: new
|
|
186
|
+
path: new utils.URLPath(operation.path),
|
|
186
187
|
generics: [`${factoryName}["data"]`, `${factoryName}["error"]`, requestType ? `${factoryName}["request"]` : "void"].join(", "),
|
|
187
|
-
withQueryParams: !!
|
|
188
|
-
withData: !!
|
|
189
|
-
withPathParams: !!
|
|
190
|
-
withHeaders: !!
|
|
188
|
+
withQueryParams: !!schemas.queryParams?.name,
|
|
189
|
+
withData: !!schemas.request?.name,
|
|
190
|
+
withPathParams: !!schemas.pathParams?.name,
|
|
191
|
+
withHeaders: !!schemas.headerParams?.name,
|
|
191
192
|
contentType
|
|
192
193
|
};
|
|
193
194
|
const hook = {
|
|
@@ -197,9 +198,9 @@ function Mutation({ Template: Template6 = defaultTemplates.default }) {
|
|
|
197
198
|
const resultGenerics = [
|
|
198
199
|
`${factoryName}["response"]`,
|
|
199
200
|
`${factoryName}["error"]`,
|
|
200
|
-
mutate &&
|
|
201
|
+
mutate && mutate?.variablesType === "mutate" ? requestType : `${factoryName}["request"]`
|
|
201
202
|
];
|
|
202
|
-
if (mutate &&
|
|
203
|
+
if (mutate && mutate?.variablesType === "mutate") {
|
|
203
204
|
params.add([
|
|
204
205
|
{
|
|
205
206
|
name: "options",
|
|
@@ -212,38 +213,38 @@ function Mutation({ Template: Template6 = defaultTemplates.default }) {
|
|
|
212
213
|
]);
|
|
213
214
|
mutateParams.add([
|
|
214
215
|
[
|
|
215
|
-
...
|
|
216
|
+
...utils$1.getASTParams(schemas.pathParams, { typed: false }),
|
|
216
217
|
{
|
|
217
218
|
name: "params",
|
|
218
219
|
enabled: client.withQueryParams,
|
|
219
|
-
required:
|
|
220
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
220
221
|
},
|
|
221
222
|
{
|
|
222
223
|
name: "headers",
|
|
223
224
|
enabled: client.withHeaders,
|
|
224
|
-
required:
|
|
225
|
+
required: oas.isRequired(schemas.headerParams?.schema)
|
|
225
226
|
},
|
|
226
227
|
{
|
|
227
228
|
name: "data",
|
|
228
|
-
enabled: !!
|
|
229
|
-
required:
|
|
229
|
+
enabled: !!schemas.request?.name,
|
|
230
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
230
231
|
}
|
|
231
232
|
]
|
|
232
233
|
]);
|
|
233
234
|
} else {
|
|
234
235
|
params.add([
|
|
235
|
-
...
|
|
236
|
+
...utils$1.getASTParams(schemas.pathParams, { typed: true }),
|
|
236
237
|
{
|
|
237
238
|
name: "params",
|
|
238
239
|
type: `${factoryName}['queryParams']`,
|
|
239
240
|
enabled: client.withQueryParams,
|
|
240
|
-
required:
|
|
241
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
241
242
|
},
|
|
242
243
|
{
|
|
243
244
|
name: "headers",
|
|
244
245
|
type: `${factoryName}['headerParams']`,
|
|
245
246
|
enabled: client.withHeaders,
|
|
246
|
-
required:
|
|
247
|
+
required: oas.isRequired(schemas.headerParams?.schema)
|
|
247
248
|
},
|
|
248
249
|
{
|
|
249
250
|
name: "options",
|
|
@@ -257,19 +258,19 @@ function Mutation({ Template: Template6 = defaultTemplates.default }) {
|
|
|
257
258
|
mutateParams.add([
|
|
258
259
|
{
|
|
259
260
|
name: "data",
|
|
260
|
-
enabled: !!
|
|
261
|
-
required:
|
|
261
|
+
enabled: !!schemas.request?.name,
|
|
262
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
262
263
|
}
|
|
263
264
|
]);
|
|
264
265
|
}
|
|
265
266
|
if (!mutate) {
|
|
266
267
|
return null;
|
|
267
268
|
}
|
|
268
|
-
return /* @__PURE__ */
|
|
269
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
269
270
|
Template6,
|
|
270
271
|
{
|
|
271
272
|
name,
|
|
272
|
-
JSDoc: { comments:
|
|
273
|
+
JSDoc: { comments: utils$1.getComments(operation) },
|
|
273
274
|
client,
|
|
274
275
|
hook,
|
|
275
276
|
params: params.toString(),
|
|
@@ -282,28 +283,15 @@ Mutation.File = function({ ...props }) {
|
|
|
282
283
|
const templates = { ...defaultTemplates, ...props.templates };
|
|
283
284
|
const Template6 = templates.default;
|
|
284
285
|
const RootTemplate2 = templates.root;
|
|
285
|
-
return /* @__PURE__ */
|
|
286
|
-
/* @__PURE__ */
|
|
287
|
-
/* @__PURE__ */
|
|
286
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(RootTemplate2, { children: [
|
|
287
|
+
/* @__PURE__ */ jsxRuntime.jsx(SchemaType, {}),
|
|
288
|
+
/* @__PURE__ */ jsxRuntime.jsx(Mutation, { Template: Template6 })
|
|
288
289
|
] });
|
|
289
290
|
};
|
|
290
291
|
Mutation.templates = defaultTemplates;
|
|
291
|
-
|
|
292
|
-
// src/components/Query.tsx
|
|
293
|
-
var _core = require('@kubb/core');
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
var _pluginzod = require('@kubb/plugin-zod');
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
// src/utils.ts
|
|
303
|
-
|
|
304
292
|
var reactQueryDepRegex = /@tanstack\/(react|solid|vue|svelte)-query/;
|
|
305
293
|
function getImportNames() {
|
|
306
|
-
const isV5 = new
|
|
294
|
+
const isV5 = new core.PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
307
295
|
return {
|
|
308
296
|
mutation: {
|
|
309
297
|
react: {
|
|
@@ -393,26 +381,21 @@ function getImportNames() {
|
|
|
393
381
|
}
|
|
394
382
|
};
|
|
395
383
|
}
|
|
396
|
-
|
|
397
|
-
// src/components/QueryImports.tsx
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
384
|
function Template2({ path, hookPath = path, isInfinite, hookName, queryOptions, optionsType, resultType }) {
|
|
402
|
-
return /* @__PURE__ */
|
|
403
|
-
/* @__PURE__ */
|
|
404
|
-
/* @__PURE__ */
|
|
405
|
-
queryOptions && /* @__PURE__ */
|
|
406
|
-
/* @__PURE__ */
|
|
385
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
386
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [optionsType, resultType], path, isTypeOnly: true }),
|
|
387
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [hookName], path: hookPath }),
|
|
388
|
+
queryOptions && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [queryOptions].filter(Boolean), path }),
|
|
389
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "WithRequired", isInfinite ? "InfiniteData" : void 0].filter(Boolean), path, isTypeOnly: true })
|
|
407
390
|
] });
|
|
408
391
|
}
|
|
409
392
|
var defaultTemplates2 = {
|
|
410
393
|
get react() {
|
|
411
394
|
return function({ context, hookPath, ...rest }) {
|
|
412
395
|
const importNames = getImportNames();
|
|
413
|
-
const isV5 = new
|
|
396
|
+
const isV5 = new core.PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
414
397
|
const { isInfinite, isSuspense } = context;
|
|
415
|
-
return /* @__PURE__ */
|
|
398
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
416
399
|
Template2,
|
|
417
400
|
{
|
|
418
401
|
isInfinite,
|
|
@@ -427,9 +410,9 @@ var defaultTemplates2 = {
|
|
|
427
410
|
get solid() {
|
|
428
411
|
return function({ context, hookPath, ...rest }) {
|
|
429
412
|
const importNames = getImportNames();
|
|
430
|
-
const isV5 = new
|
|
413
|
+
const isV5 = new core.PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
431
414
|
const { isInfinite } = context;
|
|
432
|
-
return /* @__PURE__ */
|
|
415
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
433
416
|
Template2,
|
|
434
417
|
{
|
|
435
418
|
isInfinite,
|
|
@@ -444,9 +427,9 @@ var defaultTemplates2 = {
|
|
|
444
427
|
get svelte() {
|
|
445
428
|
return function({ context, hookPath, ...rest }) {
|
|
446
429
|
const importNames = getImportNames();
|
|
447
|
-
const isV5 = new
|
|
430
|
+
const isV5 = new core.PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
448
431
|
const { isInfinite } = context;
|
|
449
|
-
return /* @__PURE__ */
|
|
432
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
450
433
|
Template2,
|
|
451
434
|
{
|
|
452
435
|
isInfinite,
|
|
@@ -461,12 +444,12 @@ var defaultTemplates2 = {
|
|
|
461
444
|
get vue() {
|
|
462
445
|
return function({ context, hookPath, ...rest }) {
|
|
463
446
|
const importNames = getImportNames();
|
|
464
|
-
const isV5 = new
|
|
447
|
+
const isV5 = new core.PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
465
448
|
const { isInfinite } = context;
|
|
466
449
|
const path = "@tanstack/vue-query";
|
|
467
|
-
return /* @__PURE__ */
|
|
468
|
-
isV5 && /* @__PURE__ */
|
|
469
|
-
/* @__PURE__ */
|
|
450
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
451
|
+
isV5 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
452
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
470
453
|
Template2,
|
|
471
454
|
{
|
|
472
455
|
isInfinite,
|
|
@@ -476,27 +459,27 @@ var defaultTemplates2 = {
|
|
|
476
459
|
...rest
|
|
477
460
|
}
|
|
478
461
|
),
|
|
479
|
-
/* @__PURE__ */
|
|
462
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryObserverOptions"], path, isTypeOnly: true })
|
|
480
463
|
] }),
|
|
481
|
-
!isV5 && isInfinite && /* @__PURE__ */
|
|
482
|
-
/* @__PURE__ */
|
|
483
|
-
/* @__PURE__ */
|
|
484
|
-
/* @__PURE__ */
|
|
464
|
+
!isV5 && isInfinite && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
465
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [importNames.queryInfinite.vue.resultType], path, isTypeOnly: true }),
|
|
466
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [importNames.queryInfinite.vue.optionsType], path: "@tanstack/vue-query/build/lib/types", isTypeOnly: true }),
|
|
467
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [importNames.queryInfinite.vue.hookName], path })
|
|
485
468
|
] }),
|
|
486
|
-
!isV5 && !isInfinite && /* @__PURE__ */
|
|
487
|
-
/* @__PURE__ */
|
|
488
|
-
/* @__PURE__ */
|
|
489
|
-
/* @__PURE__ */
|
|
469
|
+
!isV5 && !isInfinite && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
470
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [importNames.query.vue.resultType], path, isTypeOnly: true }),
|
|
471
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [importNames.query.vue.optionsType], path: "@tanstack/vue-query/build/lib/types", isTypeOnly: true }),
|
|
472
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [importNames.query.vue.hookName], path })
|
|
490
473
|
] }),
|
|
491
|
-
/* @__PURE__ */
|
|
492
|
-
/* @__PURE__ */
|
|
493
|
-
/* @__PURE__ */
|
|
474
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["unref"], path: "vue" }),
|
|
475
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["MaybeRef"], path: "vue", isTypeOnly: true }),
|
|
476
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["QueryKey", "WithRequired"], path, isTypeOnly: true })
|
|
494
477
|
] });
|
|
495
478
|
};
|
|
496
479
|
}
|
|
497
480
|
};
|
|
498
481
|
function QueryImports({ hookPath, isInfinite, isSuspense, Template: Template6 = defaultTemplates2.react }) {
|
|
499
|
-
return /* @__PURE__ */
|
|
482
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
500
483
|
Template6,
|
|
501
484
|
{
|
|
502
485
|
hookPath,
|
|
@@ -508,35 +491,26 @@ function QueryImports({ hookPath, isInfinite, isSuspense, Template: Template6 =
|
|
|
508
491
|
);
|
|
509
492
|
}
|
|
510
493
|
QueryImports.templates = defaultTemplates2;
|
|
511
|
-
|
|
512
|
-
// src/components/QueryKey.tsx
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
494
|
function Template3({ name, typeName, params, generics, returnType, JSDoc, keys }) {
|
|
521
|
-
return /* @__PURE__ */
|
|
522
|
-
/* @__PURE__ */
|
|
523
|
-
/* @__PURE__ */
|
|
495
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
496
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function.Arrow, { name, export: true, generics, params, returnType, singleLine: true, JSDoc, children: `[${keys}] as const` }) }),
|
|
497
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Type, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` }) })
|
|
524
498
|
] });
|
|
525
499
|
}
|
|
526
500
|
var defaultTemplates3 = {
|
|
527
501
|
get react() {
|
|
528
502
|
return function(props) {
|
|
529
|
-
return /* @__PURE__ */
|
|
503
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template3, { ...props });
|
|
530
504
|
};
|
|
531
505
|
},
|
|
532
506
|
get solid() {
|
|
533
507
|
return function(props) {
|
|
534
|
-
return /* @__PURE__ */
|
|
508
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template3, { ...props });
|
|
535
509
|
};
|
|
536
510
|
},
|
|
537
511
|
get svelte() {
|
|
538
512
|
return function(props) {
|
|
539
|
-
return /* @__PURE__ */
|
|
513
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template3, { ...props });
|
|
540
514
|
};
|
|
541
515
|
},
|
|
542
516
|
get vue() {
|
|
@@ -546,24 +520,24 @@ var defaultTemplates3 = {
|
|
|
546
520
|
plugin: {
|
|
547
521
|
options: { pathParamsType, query }
|
|
548
522
|
}
|
|
549
|
-
} =
|
|
550
|
-
const { getSchemas } =
|
|
551
|
-
const operation =
|
|
552
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
553
|
-
const path = new
|
|
554
|
-
const params = new
|
|
555
|
-
const withQueryParams = !!
|
|
556
|
-
const withRequest = !!
|
|
523
|
+
} = react.useApp();
|
|
524
|
+
const { getSchemas } = hooks.useOperationManager();
|
|
525
|
+
const operation = hooks.useOperation();
|
|
526
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
|
|
527
|
+
const path = new utils.URLPath(operation.path);
|
|
528
|
+
const params = new utils.FunctionParams();
|
|
529
|
+
const withQueryParams = !!schemas.queryParams?.name;
|
|
530
|
+
const withRequest = !!schemas.request?.name;
|
|
557
531
|
params.add([
|
|
558
532
|
...pathParamsType === "object" ? [
|
|
559
|
-
|
|
533
|
+
utils$1.getASTParams(schemas.pathParams, {
|
|
560
534
|
typed: true,
|
|
561
535
|
override: (item) => ({
|
|
562
536
|
...item,
|
|
563
537
|
type: `MaybeRef<${item.type}>`
|
|
564
538
|
})
|
|
565
539
|
})
|
|
566
|
-
] :
|
|
540
|
+
] : utils$1.getASTParams(schemas.pathParams, {
|
|
567
541
|
typed: true,
|
|
568
542
|
override: (item) => ({
|
|
569
543
|
...item,
|
|
@@ -574,13 +548,13 @@ var defaultTemplates3 = {
|
|
|
574
548
|
name: "params",
|
|
575
549
|
type: `MaybeRef<${`${factory.name}["queryParams"]`}>`,
|
|
576
550
|
enabled: withQueryParams,
|
|
577
|
-
required:
|
|
551
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
578
552
|
},
|
|
579
553
|
{
|
|
580
554
|
name: "request",
|
|
581
555
|
type: `MaybeRef<${`${factory.name}["request"]`}>`,
|
|
582
556
|
enabled: withRequest,
|
|
583
|
-
required:
|
|
557
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
584
558
|
}
|
|
585
559
|
]);
|
|
586
560
|
const keys = [
|
|
@@ -592,7 +566,7 @@ var defaultTemplates3 = {
|
|
|
592
566
|
withQueryParams ? "...(params ? [params] : [])" : void 0,
|
|
593
567
|
withRequest ? "...(request ? [request] : [])" : void 0
|
|
594
568
|
].filter(Boolean);
|
|
595
|
-
return /* @__PURE__ */
|
|
569
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template3, { ...rest, params: params.toString(), keys: keys.join(", ") });
|
|
596
570
|
};
|
|
597
571
|
}
|
|
598
572
|
};
|
|
@@ -601,27 +575,27 @@ function QueryKey({ name, typeName, factory, keysFn, Template: Template6 = defau
|
|
|
601
575
|
plugin: {
|
|
602
576
|
options: { pathParamsType }
|
|
603
577
|
}
|
|
604
|
-
} =
|
|
605
|
-
const { getSchemas } =
|
|
606
|
-
const operation =
|
|
607
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
608
|
-
const path = new
|
|
609
|
-
const params = new
|
|
610
|
-
const withQueryParams = !!
|
|
611
|
-
const withRequest = !!
|
|
578
|
+
} = react.useApp();
|
|
579
|
+
const { getSchemas } = hooks.useOperationManager();
|
|
580
|
+
const operation = hooks.useOperation();
|
|
581
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
|
|
582
|
+
const path = new utils.URLPath(operation.path);
|
|
583
|
+
const params = new utils.FunctionParams();
|
|
584
|
+
const withQueryParams = !!schemas.queryParams?.name;
|
|
585
|
+
const withRequest = !!schemas.request?.name;
|
|
612
586
|
params.add([
|
|
613
|
-
...pathParamsType === "object" ? [
|
|
587
|
+
...pathParamsType === "object" ? [utils$1.getASTParams(schemas.pathParams, { typed: true })] : utils$1.getASTParams(schemas.pathParams, { typed: true }),
|
|
614
588
|
{
|
|
615
589
|
name: "params",
|
|
616
590
|
type: `${factory.name}["queryParams"]`,
|
|
617
591
|
enabled: withQueryParams,
|
|
618
|
-
required:
|
|
592
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
619
593
|
},
|
|
620
594
|
{
|
|
621
595
|
name: "data",
|
|
622
596
|
type: `${factory.name}["request"]`,
|
|
623
597
|
enabled: withRequest,
|
|
624
|
-
required:
|
|
598
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
625
599
|
}
|
|
626
600
|
]);
|
|
627
601
|
const keys = [
|
|
@@ -632,23 +606,11 @@ function QueryKey({ name, typeName, factory, keysFn, Template: Template6 = defau
|
|
|
632
606
|
withQueryParams ? "...(params ? [params] : [])" : void 0,
|
|
633
607
|
withRequest ? "...(data ? [data] : [])" : void 0
|
|
634
608
|
].filter(Boolean);
|
|
635
|
-
return /* @__PURE__ */
|
|
609
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template6, { typeName, name, params: params.toString(), keys: keysFn(keys).join(", "), context: { factory } });
|
|
636
610
|
}
|
|
637
611
|
QueryKey.templates = defaultTemplates3;
|
|
638
|
-
|
|
639
|
-
// src/components/QueryOptions.tsx
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
612
|
function Template4({ name, params, generics, returnType, JSDoc, hook, client, infinite, dataReturnType, parser }) {
|
|
651
|
-
const isV5 = new
|
|
613
|
+
const isV5 = new core.PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
652
614
|
const isFormData = client.contentType === "multipart/form-data";
|
|
653
615
|
const headers = [
|
|
654
616
|
client.contentType !== "application/json" ? `'Content-Type': '${client.contentType}'` : void 0,
|
|
@@ -676,10 +638,10 @@ function Template4({ name, params, generics, returnType, JSDoc, hook, client, in
|
|
|
676
638
|
isV5 && !!infinite && !infinite.cursorParam && dataReturnType === "data" ? "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1" : void 0,
|
|
677
639
|
isV5 && !!infinite && !infinite.cursorParam ? "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1" : void 0
|
|
678
640
|
].filter(Boolean);
|
|
679
|
-
const resolvedClientOptions = `${
|
|
680
|
-
${
|
|
681
|
-
const resolvedQueryOptions = `${
|
|
682
|
-
${
|
|
641
|
+
const resolvedClientOptions = `${transformers2__default.default.createIndent(4)}${clientOptions.join(`,
|
|
642
|
+
${transformers2__default.default.createIndent(4)}`)}`;
|
|
643
|
+
const resolvedQueryOptions = `${transformers2__default.default.createIndent(4)}${queryOptions.join(`,
|
|
644
|
+
${transformers2__default.default.createIndent(4)}`)}`;
|
|
683
645
|
let returnRes = parser ? `return ${parser}(res.data)` : "return res.data";
|
|
684
646
|
if (dataReturnType === "full") {
|
|
685
647
|
returnRes = parser ? `return {...res, data: ${parser}(res.data)}` : "return res";
|
|
@@ -697,7 +659,7 @@ ${_transformers2.default.createIndent(4)}`)}`;
|
|
|
697
659
|
` : void 0;
|
|
698
660
|
if (infinite) {
|
|
699
661
|
if (isV5) {
|
|
700
|
-
return /* @__PURE__ */
|
|
662
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { name, export: true, params, JSDoc, children: `
|
|
701
663
|
const queryKey = ${hook.queryKey}
|
|
702
664
|
|
|
703
665
|
return infiniteQueryOptions({
|
|
@@ -716,7 +678,7 @@ ${_transformers2.default.createIndent(4)}`)}`;
|
|
|
716
678
|
|
|
717
679
|
` }) });
|
|
718
680
|
}
|
|
719
|
-
return /* @__PURE__ */
|
|
681
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
|
|
720
682
|
const queryKey = ${hook.queryKey}
|
|
721
683
|
|
|
722
684
|
return {
|
|
@@ -736,7 +698,7 @@ ${_transformers2.default.createIndent(4)}`)}`;
|
|
|
736
698
|
` }) });
|
|
737
699
|
}
|
|
738
700
|
if (isV5) {
|
|
739
|
-
return /* @__PURE__ */
|
|
701
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { name, export: true, params, JSDoc, children: `
|
|
740
702
|
const queryKey = ${hook.queryKey}
|
|
741
703
|
|
|
742
704
|
return queryOptions({
|
|
@@ -755,7 +717,7 @@ ${_transformers2.default.createIndent(4)}`)}`;
|
|
|
755
717
|
|
|
756
718
|
` }) });
|
|
757
719
|
}
|
|
758
|
-
return /* @__PURE__ */
|
|
720
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
|
|
759
721
|
const queryKey = ${hook.queryKey}
|
|
760
722
|
|
|
761
723
|
return {
|
|
@@ -777,17 +739,17 @@ ${_transformers2.default.createIndent(4)}`)}`;
|
|
|
777
739
|
var defaultTemplates4 = {
|
|
778
740
|
get react() {
|
|
779
741
|
return function(props) {
|
|
780
|
-
return /* @__PURE__ */
|
|
742
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template4, { ...props });
|
|
781
743
|
};
|
|
782
744
|
},
|
|
783
745
|
get solid() {
|
|
784
746
|
return function(props) {
|
|
785
|
-
return /* @__PURE__ */
|
|
747
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template4, { ...props });
|
|
786
748
|
};
|
|
787
749
|
},
|
|
788
750
|
get svelte() {
|
|
789
751
|
return function(props) {
|
|
790
|
-
return /* @__PURE__ */
|
|
752
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template4, { ...props });
|
|
791
753
|
};
|
|
792
754
|
},
|
|
793
755
|
get vue() {
|
|
@@ -797,47 +759,47 @@ var defaultTemplates4 = {
|
|
|
797
759
|
plugin: {
|
|
798
760
|
options: { pathParamsType }
|
|
799
761
|
}
|
|
800
|
-
} =
|
|
801
|
-
const { getSchemas } =
|
|
802
|
-
const operation =
|
|
803
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
804
|
-
const params = new
|
|
805
|
-
const queryKeyParams = new
|
|
762
|
+
} = react.useApp();
|
|
763
|
+
const { getSchemas } = hooks.useOperationManager();
|
|
764
|
+
const operation = hooks.useOperation();
|
|
765
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
|
|
766
|
+
const params = new utils.FunctionParams();
|
|
767
|
+
const queryKeyParams = new utils.FunctionParams();
|
|
806
768
|
params.add([
|
|
807
769
|
...pathParamsType === "object" ? [
|
|
808
|
-
|
|
770
|
+
utils$1.getASTParams(schemas.pathParams, {
|
|
809
771
|
typed: true,
|
|
810
772
|
override: (item) => ({
|
|
811
773
|
...item,
|
|
812
|
-
name: item.name ? `ref${
|
|
774
|
+
name: item.name ? `ref${transformers2__default.default.pascalCase(item.name)}` : void 0,
|
|
813
775
|
type: `MaybeRef<${item.type}>`
|
|
814
776
|
})
|
|
815
777
|
})
|
|
816
|
-
] :
|
|
778
|
+
] : utils$1.getASTParams(schemas.pathParams, {
|
|
817
779
|
typed: true,
|
|
818
780
|
override: (item) => ({
|
|
819
781
|
...item,
|
|
820
|
-
name: item.name ? `ref${
|
|
782
|
+
name: item.name ? `ref${transformers2__default.default.pascalCase(item.name)}` : void 0,
|
|
821
783
|
type: `MaybeRef<${item.type}>`
|
|
822
784
|
})
|
|
823
785
|
}),
|
|
824
786
|
{
|
|
825
787
|
name: "refParams",
|
|
826
|
-
type: `MaybeRef<${
|
|
788
|
+
type: `MaybeRef<${schemas.queryParams?.name}>`,
|
|
827
789
|
enabled: client.withQueryParams,
|
|
828
|
-
required:
|
|
790
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
829
791
|
},
|
|
830
792
|
{
|
|
831
793
|
name: "refHeaders",
|
|
832
|
-
type: `MaybeRef<${
|
|
794
|
+
type: `MaybeRef<${schemas.headerParams?.name}>`,
|
|
833
795
|
enabled: client.withHeaders,
|
|
834
|
-
required:
|
|
796
|
+
required: oas.isRequired(schemas.headerParams?.schema)
|
|
835
797
|
},
|
|
836
798
|
{
|
|
837
799
|
name: "refData",
|
|
838
|
-
type: `MaybeRef<${
|
|
800
|
+
type: `MaybeRef<${schemas.request?.name}>`,
|
|
839
801
|
enabled: client.withData,
|
|
840
|
-
required:
|
|
802
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
841
803
|
},
|
|
842
804
|
{
|
|
843
805
|
name: "options",
|
|
@@ -847,37 +809,37 @@ var defaultTemplates4 = {
|
|
|
847
809
|
]);
|
|
848
810
|
queryKeyParams.add([
|
|
849
811
|
...pathParamsType === "object" ? [
|
|
850
|
-
|
|
812
|
+
utils$1.getASTParams(schemas.pathParams, {
|
|
851
813
|
override: (item) => ({
|
|
852
814
|
...item,
|
|
853
|
-
name: item.name ? `ref${
|
|
815
|
+
name: item.name ? `ref${transformers2__default.default.pascalCase(item.name)}` : void 0
|
|
854
816
|
})
|
|
855
817
|
})
|
|
856
|
-
] :
|
|
818
|
+
] : utils$1.getASTParams(schemas.pathParams, {
|
|
857
819
|
override: (item) => ({
|
|
858
820
|
...item,
|
|
859
|
-
name: item.name ? `ref${
|
|
821
|
+
name: item.name ? `ref${transformers2__default.default.pascalCase(item.name)}` : void 0
|
|
860
822
|
})
|
|
861
823
|
}),
|
|
862
824
|
{
|
|
863
825
|
name: "refParams",
|
|
864
826
|
enabled: client.withQueryParams,
|
|
865
|
-
required:
|
|
827
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
866
828
|
},
|
|
867
829
|
{
|
|
868
830
|
name: "refData",
|
|
869
831
|
enabled: client.withData,
|
|
870
|
-
required:
|
|
832
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
871
833
|
}
|
|
872
834
|
]);
|
|
873
835
|
const unrefs = params.items.filter((item) => item.enabled).map((item) => {
|
|
874
|
-
return item.name ? `const ${
|
|
836
|
+
return item.name ? `const ${transformers2__default.default.camelCase(item.name.replace("ref", ""))} = unref(${item.name})` : void 0;
|
|
875
837
|
}).join("\n");
|
|
876
838
|
const hook = {
|
|
877
839
|
queryKey: `${queryKey}(${queryKeyParams.toString()})`,
|
|
878
840
|
children: unrefs
|
|
879
841
|
};
|
|
880
|
-
return /* @__PURE__ */
|
|
842
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template4, { ...rest, params: params.toString(), hook, client });
|
|
881
843
|
};
|
|
882
844
|
}
|
|
883
845
|
};
|
|
@@ -888,12 +850,12 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
888
850
|
key: pluginKey,
|
|
889
851
|
options: { parser, pathParamsType, queryOptions }
|
|
890
852
|
}
|
|
891
|
-
} =
|
|
892
|
-
const { getSchemas } =
|
|
893
|
-
const operation =
|
|
853
|
+
} = react.useApp();
|
|
854
|
+
const { getSchemas } = hooks.useOperationManager();
|
|
855
|
+
const operation = hooks.useOperation();
|
|
894
856
|
const contentType = operation.getContentType();
|
|
895
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
896
|
-
const zodSchemas = getSchemas(operation, { pluginKey: [
|
|
857
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
|
|
858
|
+
const zodSchemas = getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" });
|
|
897
859
|
const queryKey = pluginManager.resolveName({
|
|
898
860
|
name: [factory.name, infinite ? "Infinite" : void 0, suspense ? "Suspense" : void 0, "QueryKey"].filter(Boolean).join(""),
|
|
899
861
|
pluginKey
|
|
@@ -902,18 +864,18 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
902
864
|
name: [factory.name, infinite ? "Infinite" : void 0, suspense ? "Suspense" : void 0, "QueryOptions"].filter(Boolean).join(""),
|
|
903
865
|
pluginKey
|
|
904
866
|
});
|
|
905
|
-
const generics = new
|
|
906
|
-
const params = new
|
|
907
|
-
const queryKeyParams = new
|
|
867
|
+
const generics = new utils.FunctionParams();
|
|
868
|
+
const params = new utils.FunctionParams();
|
|
869
|
+
const queryKeyParams = new utils.FunctionParams();
|
|
908
870
|
const clientGenerics = [`${factory.name}['data']`, `${factory.name}['error']`];
|
|
909
871
|
const resultGenerics = suspense ? [`${factory.name}['response']`, `${factory.name}["error"]`, "TData"] : [`${factory.name}['response']`, `${factory.name}["error"]`, "TData", "TQueryData"];
|
|
910
872
|
const client = {
|
|
911
|
-
withQueryParams: !!
|
|
912
|
-
withData: !!
|
|
913
|
-
withPathParams: !!
|
|
914
|
-
withHeaders: !!
|
|
873
|
+
withQueryParams: !!schemas.queryParams?.name,
|
|
874
|
+
withData: !!schemas.request?.name,
|
|
875
|
+
withPathParams: !!schemas.pathParams?.name,
|
|
876
|
+
withHeaders: !!schemas.headerParams?.name,
|
|
915
877
|
method: operation.method,
|
|
916
|
-
path: new
|
|
878
|
+
path: new utils.URLPath(operation.path),
|
|
917
879
|
generics: clientGenerics.toString(),
|
|
918
880
|
contentType
|
|
919
881
|
};
|
|
@@ -922,24 +884,24 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
922
884
|
suspense ? void 0 : { type: "TQueryData", default: `${factory.name}["response"]` }
|
|
923
885
|
]);
|
|
924
886
|
params.add([
|
|
925
|
-
...pathParamsType === "object" ? [
|
|
887
|
+
...pathParamsType === "object" ? [utils$1.getASTParams(schemas.pathParams, { typed: true })] : utils$1.getASTParams(schemas.pathParams, { typed: true }),
|
|
926
888
|
{
|
|
927
889
|
name: "params",
|
|
928
890
|
type: `${factory.name}['queryParams']`,
|
|
929
891
|
enabled: client.withQueryParams,
|
|
930
|
-
required:
|
|
892
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
931
893
|
},
|
|
932
894
|
{
|
|
933
895
|
name: "headers",
|
|
934
896
|
type: `${factory.name}['headerParams']`,
|
|
935
897
|
enabled: client.withHeaders,
|
|
936
|
-
required:
|
|
898
|
+
required: oas.isRequired(schemas.headerParams?.schema)
|
|
937
899
|
},
|
|
938
900
|
{
|
|
939
901
|
name: "data",
|
|
940
902
|
type: `${factory.name}['request']`,
|
|
941
903
|
enabled: client.withData,
|
|
942
|
-
required:
|
|
904
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
943
905
|
},
|
|
944
906
|
{
|
|
945
907
|
name: "options",
|
|
@@ -948,16 +910,16 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
948
910
|
}
|
|
949
911
|
]);
|
|
950
912
|
queryKeyParams.add([
|
|
951
|
-
...pathParamsType === "object" ? [
|
|
913
|
+
...pathParamsType === "object" ? [utils$1.getASTParams(schemas.pathParams)] : utils$1.getASTParams(schemas.pathParams),
|
|
952
914
|
{
|
|
953
915
|
name: "params",
|
|
954
916
|
enabled: client.withQueryParams,
|
|
955
|
-
required:
|
|
917
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
956
918
|
},
|
|
957
919
|
{
|
|
958
920
|
name: "data",
|
|
959
921
|
enabled: client.withData,
|
|
960
|
-
required:
|
|
922
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
961
923
|
}
|
|
962
924
|
]);
|
|
963
925
|
const hook = {
|
|
@@ -966,7 +928,7 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
966
928
|
if (!queryOptions) {
|
|
967
929
|
return null;
|
|
968
930
|
}
|
|
969
|
-
return /* @__PURE__ */
|
|
931
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
970
932
|
Template6,
|
|
971
933
|
{
|
|
972
934
|
name: queryOptionsName,
|
|
@@ -986,15 +948,11 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
986
948
|
);
|
|
987
949
|
}
|
|
988
950
|
QueryOptions.templates = defaultTemplates4;
|
|
989
|
-
|
|
990
|
-
// src/components/Query.tsx
|
|
991
|
-
|
|
992
|
-
|
|
993
951
|
function Template5({ name, generics, returnType, params, JSDoc, hook, infinite }) {
|
|
994
|
-
const isV5 = new
|
|
952
|
+
const isV5 = new core.PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
995
953
|
const resolvedReturnType = `${returnType} & { queryKey: TQueryKey }`;
|
|
996
954
|
if (isV5) {
|
|
997
|
-
return /* @__PURE__ */
|
|
955
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { name, export: true, generics, returnType: resolvedReturnType, params, JSDoc, children: `
|
|
998
956
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
|
|
999
957
|
const queryKey = queryOptions?.queryKey ?? ${hook.queryKey}
|
|
1000
958
|
|
|
@@ -1010,7 +968,7 @@ function Template5({ name, generics, returnType, params, JSDoc, hook, infinite }
|
|
|
1010
968
|
|
|
1011
969
|
` }) });
|
|
1012
970
|
}
|
|
1013
|
-
return /* @__PURE__ */
|
|
971
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Function, { name, export: true, generics, returnType: resolvedReturnType, params, JSDoc, children: `
|
|
1014
972
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
|
|
1015
973
|
const queryKey = queryOptions?.queryKey ?? ${hook.queryKey}
|
|
1016
974
|
|
|
@@ -1029,17 +987,17 @@ function Template5({ name, generics, returnType, params, JSDoc, hook, infinite }
|
|
|
1029
987
|
var defaultTemplates5 = {
|
|
1030
988
|
get react() {
|
|
1031
989
|
return function(props) {
|
|
1032
|
-
return /* @__PURE__ */
|
|
990
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template5, { ...props });
|
|
1033
991
|
};
|
|
1034
992
|
},
|
|
1035
993
|
get solid() {
|
|
1036
994
|
return function(props) {
|
|
1037
|
-
return /* @__PURE__ */
|
|
995
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template5, { ...props });
|
|
1038
996
|
};
|
|
1039
997
|
},
|
|
1040
998
|
get svelte() {
|
|
1041
999
|
return function(props) {
|
|
1042
|
-
return /* @__PURE__ */
|
|
1000
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Template5, { ...props });
|
|
1043
1001
|
};
|
|
1044
1002
|
},
|
|
1045
1003
|
get vue() {
|
|
@@ -1051,9 +1009,9 @@ var defaultTemplates5 = {
|
|
|
1051
1009
|
key: pluginKey,
|
|
1052
1010
|
options: { pathParamsType }
|
|
1053
1011
|
}
|
|
1054
|
-
} =
|
|
1055
|
-
const operation =
|
|
1056
|
-
const { getSchemas } =
|
|
1012
|
+
} = react.useApp();
|
|
1013
|
+
const operation = hooks.useOperation();
|
|
1014
|
+
const { getSchemas } = hooks.useOperationManager();
|
|
1057
1015
|
const importNames = getImportNames();
|
|
1058
1016
|
const queryOptions = pluginManager.resolveName({
|
|
1059
1017
|
name: `${factory.name}QueryOptions`,
|
|
@@ -1062,53 +1020,53 @@ var defaultTemplates5 = {
|
|
|
1062
1020
|
const hookName = rest.infinite ? importNames.queryInfinite.vue.hookName : importNames.query.vue.hookName;
|
|
1063
1021
|
const resultType = rest.infinite ? importNames.queryInfinite.vue.resultType : importNames.query.vue.resultType;
|
|
1064
1022
|
const optionsType = rest.infinite ? importNames.queryInfinite.vue.optionsType : importNames.query.vue.optionsType;
|
|
1065
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
1066
|
-
const isV5 = new
|
|
1067
|
-
const params = new
|
|
1068
|
-
const queryParams = new
|
|
1069
|
-
const queryKeyParams = new
|
|
1023
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
|
|
1024
|
+
const isV5 = new core.PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
1025
|
+
const params = new utils.FunctionParams();
|
|
1026
|
+
const queryParams = new utils.FunctionParams();
|
|
1027
|
+
const queryKeyParams = new utils.FunctionParams();
|
|
1070
1028
|
const client = {
|
|
1071
|
-
withQueryParams: !!
|
|
1072
|
-
withData: !!
|
|
1073
|
-
withPathParams: !!
|
|
1074
|
-
withHeaders: !!
|
|
1029
|
+
withQueryParams: !!schemas.queryParams?.name,
|
|
1030
|
+
withData: !!schemas.request?.name,
|
|
1031
|
+
withPathParams: !!schemas.pathParams?.name,
|
|
1032
|
+
withHeaders: !!schemas.headerParams?.name
|
|
1075
1033
|
};
|
|
1076
1034
|
const resultGenerics = ["TData", `${factory.name}['error']`];
|
|
1077
1035
|
const queryOptionsOverrideGenerics = [`${factory.name}['response']`, `${factory.name}['error']`, "TData", "TQueryKey"];
|
|
1078
1036
|
const queryOptionsGenerics = ["TData", "TQueryData"];
|
|
1079
1037
|
params.add([
|
|
1080
1038
|
...pathParamsType === "object" ? [
|
|
1081
|
-
|
|
1039
|
+
utils$1.getASTParams(schemas.pathParams, {
|
|
1082
1040
|
typed: true,
|
|
1083
1041
|
override: (item) => ({
|
|
1084
1042
|
...item,
|
|
1085
|
-
name: item.name ? `ref${
|
|
1043
|
+
name: item.name ? `ref${transformers2__default.default.pascalCase(item.name)}` : void 0
|
|
1086
1044
|
})
|
|
1087
1045
|
})
|
|
1088
|
-
] :
|
|
1046
|
+
] : utils$1.getASTParams(schemas.pathParams, {
|
|
1089
1047
|
typed: true,
|
|
1090
1048
|
override: (item) => ({
|
|
1091
1049
|
...item,
|
|
1092
|
-
name: item.name ? `ref${
|
|
1050
|
+
name: item.name ? `ref${transformers2__default.default.pascalCase(item.name)}` : void 0
|
|
1093
1051
|
})
|
|
1094
1052
|
}),
|
|
1095
1053
|
{
|
|
1096
1054
|
name: "refParams",
|
|
1097
|
-
type: `MaybeRef<${
|
|
1055
|
+
type: `MaybeRef<${schemas.queryParams?.name}>`,
|
|
1098
1056
|
enabled: client.withQueryParams,
|
|
1099
|
-
required:
|
|
1057
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
1100
1058
|
},
|
|
1101
1059
|
{
|
|
1102
1060
|
name: "refHeaders",
|
|
1103
|
-
type: `MaybeRef<${
|
|
1061
|
+
type: `MaybeRef<${schemas.headerParams?.name}>`,
|
|
1104
1062
|
enabled: client.withHeaders,
|
|
1105
|
-
required:
|
|
1063
|
+
required: oas.isRequired(schemas.headerParams?.schema)
|
|
1106
1064
|
},
|
|
1107
1065
|
{
|
|
1108
1066
|
name: "refData",
|
|
1109
|
-
type: `MaybeRef<${
|
|
1067
|
+
type: `MaybeRef<${schemas.request?.name}>`,
|
|
1110
1068
|
enabled: client.withData,
|
|
1111
|
-
required:
|
|
1069
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
1112
1070
|
},
|
|
1113
1071
|
{
|
|
1114
1072
|
name: "options",
|
|
@@ -1120,22 +1078,22 @@ var defaultTemplates5 = {
|
|
|
1120
1078
|
}
|
|
1121
1079
|
]);
|
|
1122
1080
|
queryParams.add([
|
|
1123
|
-
...
|
|
1081
|
+
...utils$1.getASTParams(schemas.pathParams, {
|
|
1124
1082
|
typed: false,
|
|
1125
1083
|
override: (item) => ({
|
|
1126
1084
|
...item,
|
|
1127
|
-
name: item.name ? `ref${
|
|
1085
|
+
name: item.name ? `ref${transformers2__default.default.pascalCase(item.name)}` : void 0
|
|
1128
1086
|
})
|
|
1129
1087
|
}),
|
|
1130
1088
|
{
|
|
1131
1089
|
name: "refParams",
|
|
1132
1090
|
enabled: client.withQueryParams,
|
|
1133
|
-
required:
|
|
1091
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
1134
1092
|
},
|
|
1135
1093
|
{
|
|
1136
1094
|
name: "refHeaders",
|
|
1137
1095
|
enabled: client.withHeaders,
|
|
1138
|
-
required:
|
|
1096
|
+
required: oas.isRequired(schemas.headerParams?.schema)
|
|
1139
1097
|
},
|
|
1140
1098
|
{
|
|
1141
1099
|
name: "clientOptions",
|
|
@@ -1144,30 +1102,30 @@ var defaultTemplates5 = {
|
|
|
1144
1102
|
]);
|
|
1145
1103
|
queryKeyParams.add([
|
|
1146
1104
|
...pathParamsType === "object" ? [
|
|
1147
|
-
|
|
1105
|
+
utils$1.getASTParams(schemas.pathParams, {
|
|
1148
1106
|
override: (item) => ({
|
|
1149
1107
|
...item,
|
|
1150
|
-
name: item.name ? `ref${
|
|
1108
|
+
name: item.name ? `ref${transformers2__default.default.pascalCase(item.name)}` : void 0
|
|
1151
1109
|
})
|
|
1152
1110
|
})
|
|
1153
|
-
] :
|
|
1111
|
+
] : utils$1.getASTParams(schemas.pathParams, {
|
|
1154
1112
|
override: (item) => ({
|
|
1155
1113
|
...item,
|
|
1156
|
-
name: item.name ? `ref${
|
|
1114
|
+
name: item.name ? `ref${transformers2__default.default.pascalCase(item.name)}` : void 0
|
|
1157
1115
|
})
|
|
1158
1116
|
}),
|
|
1159
1117
|
{
|
|
1160
1118
|
name: "refParams",
|
|
1161
1119
|
enabled: client.withQueryParams,
|
|
1162
|
-
required:
|
|
1120
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
1163
1121
|
},
|
|
1164
1122
|
{
|
|
1165
1123
|
name: "refData",
|
|
1166
1124
|
enabled: client.withData,
|
|
1167
|
-
required:
|
|
1125
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
1168
1126
|
}
|
|
1169
1127
|
]);
|
|
1170
|
-
return /* @__PURE__ */
|
|
1128
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1171
1129
|
Template5,
|
|
1172
1130
|
{
|
|
1173
1131
|
...rest,
|
|
@@ -1200,12 +1158,12 @@ function Query({
|
|
|
1200
1158
|
key: pluginKey,
|
|
1201
1159
|
options: { dataReturnType, pathParamsType }
|
|
1202
1160
|
}
|
|
1203
|
-
} =
|
|
1204
|
-
const operation =
|
|
1205
|
-
const { getSchemas, getName } =
|
|
1206
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
1161
|
+
} = react.useApp();
|
|
1162
|
+
const operation = hooks.useOperation();
|
|
1163
|
+
const { getSchemas, getName } = hooks.useOperationManager();
|
|
1164
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
|
|
1207
1165
|
const name = getName(operation, { type: "function" });
|
|
1208
|
-
const isV5 = new
|
|
1166
|
+
const isV5 = new core.PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
1209
1167
|
const queryKey = pluginManager.resolveName({
|
|
1210
1168
|
name: [factory.name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0, "QueryKey"].filter(Boolean).join(""),
|
|
1211
1169
|
pluginKey
|
|
@@ -1219,17 +1177,17 @@ function Query({
|
|
|
1219
1177
|
name: [factory.name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0, "QueryOptions"].filter(Boolean).join(""),
|
|
1220
1178
|
pluginKey
|
|
1221
1179
|
});
|
|
1222
|
-
const generics = new
|
|
1223
|
-
const params = new
|
|
1224
|
-
const queryParams = new
|
|
1225
|
-
const queryKeyParams = new
|
|
1180
|
+
const generics = new utils.FunctionParams();
|
|
1181
|
+
const params = new utils.FunctionParams();
|
|
1182
|
+
const queryParams = new utils.FunctionParams();
|
|
1183
|
+
const queryKeyParams = new utils.FunctionParams();
|
|
1226
1184
|
const client = {
|
|
1227
1185
|
method: operation.method,
|
|
1228
|
-
path: new
|
|
1229
|
-
withQueryParams: !!
|
|
1230
|
-
withData: !!
|
|
1231
|
-
withPathParams: !!
|
|
1232
|
-
withHeaders: !!
|
|
1186
|
+
path: new utils.URLPath(operation.path),
|
|
1187
|
+
withQueryParams: !!schemas.queryParams?.name,
|
|
1188
|
+
withData: !!schemas.request?.name,
|
|
1189
|
+
withPathParams: !!schemas.pathParams?.name,
|
|
1190
|
+
withHeaders: !!schemas.headerParams?.name
|
|
1233
1191
|
};
|
|
1234
1192
|
generics.add([
|
|
1235
1193
|
{
|
|
@@ -1243,24 +1201,24 @@ function Query({
|
|
|
1243
1201
|
const queryOptionsOverrideGenerics = props.suspense ? [`${factory.name}['response']`, `${factory.name}['error']`, "TData", "TQueryKey"] : [`${factory.name}['response']`, `${factory.name}['error']`, "TData", "TQueryData", "TQueryKey"];
|
|
1244
1202
|
const queryOptionsGenerics = props.suspense ? ["TData"] : ["TData", "TQueryData"];
|
|
1245
1203
|
params.add([
|
|
1246
|
-
...pathParamsType === "object" ? [
|
|
1204
|
+
...pathParamsType === "object" ? [utils$1.getASTParams(schemas.pathParams, { typed: true })] : utils$1.getASTParams(schemas.pathParams, { typed: true }),
|
|
1247
1205
|
{
|
|
1248
1206
|
name: "params",
|
|
1249
1207
|
type: `${factory.name}['queryParams']`,
|
|
1250
1208
|
enabled: client.withQueryParams,
|
|
1251
|
-
required:
|
|
1209
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
1252
1210
|
},
|
|
1253
1211
|
{
|
|
1254
1212
|
name: "headers",
|
|
1255
1213
|
type: `${factory.name}['headerParams']`,
|
|
1256
1214
|
enabled: client.withHeaders,
|
|
1257
|
-
required:
|
|
1215
|
+
required: oas.isRequired(schemas.headerParams?.schema)
|
|
1258
1216
|
},
|
|
1259
1217
|
{
|
|
1260
1218
|
name: "data",
|
|
1261
1219
|
type: `${factory.name}['request']`,
|
|
1262
1220
|
enabled: client.withData,
|
|
1263
|
-
required:
|
|
1221
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
1264
1222
|
},
|
|
1265
1223
|
{
|
|
1266
1224
|
name: "options",
|
|
@@ -1272,21 +1230,21 @@ function Query({
|
|
|
1272
1230
|
}
|
|
1273
1231
|
]);
|
|
1274
1232
|
queryParams.add([
|
|
1275
|
-
...pathParamsType === "object" ? [
|
|
1233
|
+
...pathParamsType === "object" ? [utils$1.getASTParams(schemas.pathParams)] : utils$1.getASTParams(schemas.pathParams),
|
|
1276
1234
|
{
|
|
1277
1235
|
name: "params",
|
|
1278
1236
|
enabled: client.withQueryParams,
|
|
1279
|
-
required:
|
|
1237
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
1280
1238
|
},
|
|
1281
1239
|
{
|
|
1282
1240
|
name: "headers",
|
|
1283
1241
|
enabled: client.withHeaders,
|
|
1284
|
-
required:
|
|
1242
|
+
required: oas.isRequired(schemas.headerParams?.schema)
|
|
1285
1243
|
},
|
|
1286
1244
|
{
|
|
1287
1245
|
name: "data",
|
|
1288
1246
|
enabled: client.withData,
|
|
1289
|
-
required:
|
|
1247
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
1290
1248
|
},
|
|
1291
1249
|
{
|
|
1292
1250
|
name: "clientOptions",
|
|
@@ -1294,16 +1252,16 @@ function Query({
|
|
|
1294
1252
|
}
|
|
1295
1253
|
]);
|
|
1296
1254
|
queryKeyParams.add([
|
|
1297
|
-
...pathParamsType === "object" ? [
|
|
1255
|
+
...pathParamsType === "object" ? [utils$1.getASTParams(schemas.pathParams)] : utils$1.getASTParams(schemas.pathParams),
|
|
1298
1256
|
{
|
|
1299
1257
|
name: "params",
|
|
1300
1258
|
enabled: client.withQueryParams,
|
|
1301
|
-
required:
|
|
1259
|
+
required: oas.isRequired(schemas.queryParams?.schema)
|
|
1302
1260
|
},
|
|
1303
1261
|
{
|
|
1304
1262
|
name: "data",
|
|
1305
1263
|
enabled: client.withData,
|
|
1306
|
-
required:
|
|
1264
|
+
required: oas.isRequired(schemas.request?.schema)
|
|
1307
1265
|
}
|
|
1308
1266
|
]);
|
|
1309
1267
|
const hook = {
|
|
@@ -1312,8 +1270,8 @@ function Query({
|
|
|
1312
1270
|
queryOptions: isV5 ? `${queryOptions}(${queryParams.toString()})` : `${queryOptions}<${queryOptionsGenerics.join(", ")}>(${queryParams.toString()})`,
|
|
1313
1271
|
queryKey: `${queryKey}(${queryKeyParams.toString()})`
|
|
1314
1272
|
};
|
|
1315
|
-
return /* @__PURE__ */
|
|
1316
|
-
/* @__PURE__ */
|
|
1273
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1274
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1317
1275
|
QueryKey,
|
|
1318
1276
|
{
|
|
1319
1277
|
keysFn: props.query ? props.query.queryKey : (keys) => keys,
|
|
@@ -1323,7 +1281,7 @@ function Query({
|
|
|
1323
1281
|
typeName: queryKeyType
|
|
1324
1282
|
}
|
|
1325
1283
|
),
|
|
1326
|
-
props.queryOptions && /* @__PURE__ */
|
|
1284
|
+
props.queryOptions && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1327
1285
|
QueryOptions,
|
|
1328
1286
|
{
|
|
1329
1287
|
Template: QueryOptionsTemplate,
|
|
@@ -1334,12 +1292,12 @@ function Query({
|
|
|
1334
1292
|
suspense: props.suspense
|
|
1335
1293
|
}
|
|
1336
1294
|
),
|
|
1337
|
-
props.query && /* @__PURE__ */
|
|
1295
|
+
props.query && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1338
1296
|
Template6,
|
|
1339
1297
|
{
|
|
1340
1298
|
name: [name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0].filter(Boolean).join(""),
|
|
1341
1299
|
generics: generics.toString(),
|
|
1342
|
-
JSDoc: { comments:
|
|
1300
|
+
JSDoc: { comments: utils$1.getComments(operation) },
|
|
1343
1301
|
params: params.toString(),
|
|
1344
1302
|
returnType: `${resultType}<${resultGenerics.join(", ")}>`,
|
|
1345
1303
|
hook,
|
|
@@ -1364,51 +1322,51 @@ Query.File = function({ templates }) {
|
|
|
1364
1322
|
parser
|
|
1365
1323
|
}
|
|
1366
1324
|
}
|
|
1367
|
-
} =
|
|
1368
|
-
const { getSchemas, getFile, getName } =
|
|
1369
|
-
const operation =
|
|
1370
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
1371
|
-
const zodSchemas = getSchemas(operation, { pluginKey: [
|
|
1325
|
+
} = react.useApp();
|
|
1326
|
+
const { getSchemas, getFile, getName } = hooks.useOperationManager();
|
|
1327
|
+
const operation = hooks.useOperation();
|
|
1328
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTs.pluginTsName], type: "type" });
|
|
1329
|
+
const zodSchemas = getSchemas(operation, { pluginKey: [pluginZod.pluginZodName], type: "function" });
|
|
1372
1330
|
const file = getFile(operation);
|
|
1373
|
-
const fileType = getFile(operation, { pluginKey: [
|
|
1331
|
+
const fileType = getFile(operation, { pluginKey: [pluginTs.pluginTsName] });
|
|
1374
1332
|
const fileZodSchemas = getFile(operation, {
|
|
1375
|
-
pluginKey: [
|
|
1333
|
+
pluginKey: [pluginZod.pluginZodName]
|
|
1376
1334
|
});
|
|
1377
1335
|
const factoryName = getName(operation, { type: "type" });
|
|
1378
1336
|
const importNames = getImportNames();
|
|
1379
|
-
const isV5 = new
|
|
1380
|
-
const Template6 =
|
|
1381
|
-
const QueryOptionsTemplate =
|
|
1382
|
-
const QueryKeyTemplate =
|
|
1383
|
-
const Import =
|
|
1337
|
+
const isV5 = new core.PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
1338
|
+
const Template6 = templates?.query["react"] || defaultTemplates5["react"];
|
|
1339
|
+
const QueryOptionsTemplate = templates?.queryOptions["react"] || QueryOptions.templates["react"];
|
|
1340
|
+
const QueryKeyTemplate = templates?.queryKey["react"] || QueryKey.templates["react"];
|
|
1341
|
+
const Import = templates?.queryImports["react"] || QueryImports.templates["react"];
|
|
1384
1342
|
const factory = {
|
|
1385
1343
|
name: factoryName
|
|
1386
1344
|
};
|
|
1387
|
-
return /* @__PURE__ */
|
|
1388
|
-
parser === "zod" && /* @__PURE__ */
|
|
1389
|
-
/* @__PURE__ */
|
|
1390
|
-
/* @__PURE__ */
|
|
1391
|
-
/* @__PURE__ */
|
|
1392
|
-
|
|
1345
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
1346
|
+
parser === "zod" && /* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: [zodSchemas.response?.name], root: file.path, path: fileZodSchemas.path }),
|
|
1347
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: "client", path: importPath }),
|
|
1348
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.File.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
|
|
1349
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1350
|
+
react.File.Import,
|
|
1393
1351
|
{
|
|
1394
1352
|
name: [
|
|
1395
|
-
|
|
1353
|
+
schemas.request?.name,
|
|
1396
1354
|
schemas.response.name,
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
...
|
|
1355
|
+
schemas.pathParams?.name,
|
|
1356
|
+
schemas.queryParams?.name,
|
|
1357
|
+
schemas.headerParams?.name,
|
|
1358
|
+
...schemas.errors?.map((error) => error.name) || []
|
|
1401
1359
|
].filter(Boolean),
|
|
1402
1360
|
root: file.path,
|
|
1403
1361
|
path: fileType.path,
|
|
1404
1362
|
isTypeOnly: true
|
|
1405
1363
|
}
|
|
1406
1364
|
),
|
|
1407
|
-
/* @__PURE__ */
|
|
1408
|
-
!!infinite && /* @__PURE__ */
|
|
1409
|
-
!!suspense && isV5 && /* @__PURE__ */
|
|
1410
|
-
/* @__PURE__ */
|
|
1411
|
-
/* @__PURE__ */
|
|
1365
|
+
/* @__PURE__ */ jsxRuntime.jsx(QueryImports, { hookPath: typeof query !== "boolean" ? query.importPath : void 0, Template: Import, isInfinite: false, isSuspense: false }),
|
|
1366
|
+
!!infinite && /* @__PURE__ */ jsxRuntime.jsx(QueryImports, { hookPath: typeof query !== "boolean" ? query.importPath : void 0, Template: Import, isInfinite: true, isSuspense: false }),
|
|
1367
|
+
!!suspense && isV5 && /* @__PURE__ */ jsxRuntime.jsx(QueryImports, { hookPath: typeof query !== "boolean" ? query.importPath : void 0, Template: Import, isInfinite: false, isSuspense: true }),
|
|
1368
|
+
/* @__PURE__ */ jsxRuntime.jsx(SchemaType, {}),
|
|
1369
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1412
1370
|
Query,
|
|
1413
1371
|
{
|
|
1414
1372
|
factory,
|
|
@@ -1424,7 +1382,7 @@ Query.File = function({ templates }) {
|
|
|
1424
1382
|
optionsType: importNames.query["react"].optionsType
|
|
1425
1383
|
}
|
|
1426
1384
|
),
|
|
1427
|
-
!!infinite && /* @__PURE__ */
|
|
1385
|
+
!!infinite && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1428
1386
|
Query,
|
|
1429
1387
|
{
|
|
1430
1388
|
factory,
|
|
@@ -1440,7 +1398,7 @@ Query.File = function({ templates }) {
|
|
|
1440
1398
|
optionsType: importNames.queryInfinite["react"].optionsType
|
|
1441
1399
|
}
|
|
1442
1400
|
),
|
|
1443
|
-
!!suspense && isV5 && /* @__PURE__ */
|
|
1401
|
+
!!suspense && isV5 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1444
1402
|
Query,
|
|
1445
1403
|
{
|
|
1446
1404
|
factory,
|
|
@@ -1460,11 +1418,10 @@ Query.File = function({ templates }) {
|
|
|
1460
1418
|
};
|
|
1461
1419
|
Query.templates = defaultTemplates5;
|
|
1462
1420
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
exports.Mutation = Mutation; exports.QueryImports = QueryImports; exports.QueryKey = QueryKey; exports.QueryOptions = QueryOptions; exports.Query = Query;
|
|
1421
|
+
exports.Mutation = Mutation;
|
|
1422
|
+
exports.Query = Query;
|
|
1423
|
+
exports.QueryImports = QueryImports;
|
|
1424
|
+
exports.QueryKey = QueryKey;
|
|
1425
|
+
exports.QueryOptions = QueryOptions;
|
|
1426
|
+
//# sourceMappingURL=chunk-7ZODZVKP.cjs.map
|
|
1470
1427
|
//# sourceMappingURL=chunk-7ZODZVKP.cjs.map
|