@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-ZYTZV43V.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import transformers2 from '@kubb/core/transformers';
|
|
2
|
+
import { FunctionParams, URLPath } from '@kubb/core/utils';
|
|
3
|
+
import { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks';
|
|
4
|
+
import { getASTParams, getComments } from '@kubb/plugin-oas/utils';
|
|
5
|
+
import { useApp, File, Type, Function } from '@kubb/react';
|
|
6
|
+
import { pluginTsName } from '@kubb/plugin-ts';
|
|
7
|
+
import { jsx, Fragment, jsxs } from '@kubb/react/jsx-runtime';
|
|
8
|
+
import { isRequired } from '@kubb/oas';
|
|
9
|
+
import { PackageManager } from '@kubb/core';
|
|
10
|
+
import { pluginZodName } from '@kubb/plugin-zod';
|
|
8
11
|
|
|
9
|
-
// src/components/
|
|
10
|
-
import { useOperation, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
11
|
-
import { File, Type, useApp } from "@kubb/react";
|
|
12
|
-
import { pluginTsName } from "@kubb/plugin-ts";
|
|
13
|
-
import { Fragment, jsx, jsxs } from "@kubb/react/jsx-runtime";
|
|
12
|
+
// src/components/Mutation.tsx
|
|
14
13
|
function SchemaType() {
|
|
15
14
|
const {
|
|
16
15
|
plugin: {
|
|
@@ -51,10 +50,6 @@ function SchemaType() {
|
|
|
51
50
|
` }) })
|
|
52
51
|
] });
|
|
53
52
|
}
|
|
54
|
-
|
|
55
|
-
// src/components/Mutation.tsx
|
|
56
|
-
import { isRequired } from "@kubb/oas";
|
|
57
|
-
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "@kubb/react/jsx-runtime";
|
|
58
53
|
function Template({ name, params, mutateParams, JSDoc, client, hook, dataReturnType }) {
|
|
59
54
|
const isFormData = client.contentType === "multipart/form-data";
|
|
60
55
|
const headers = [
|
|
@@ -70,8 +65,8 @@ function Template({ name, params, mutateParams, JSDoc, client, hook, dataReturnT
|
|
|
70
65
|
headers.length ? `headers: { ${headers}, ...clientOptions.headers }` : void 0,
|
|
71
66
|
"...clientOptions"
|
|
72
67
|
].filter(Boolean);
|
|
73
|
-
const resolvedClientOptions = `${
|
|
74
|
-
${
|
|
68
|
+
const resolvedClientOptions = `${transformers2.createIndent(4)}${clientOptions.join(`,
|
|
69
|
+
${transformers2.createIndent(4)}`)}`;
|
|
75
70
|
const formData = isFormData ? `
|
|
76
71
|
const formData = new FormData()
|
|
77
72
|
if(data) {
|
|
@@ -83,7 +78,7 @@ ${transformers.createIndent(4)}`)}`;
|
|
|
83
78
|
})
|
|
84
79
|
}
|
|
85
80
|
` : void 0;
|
|
86
|
-
return /* @__PURE__ */
|
|
81
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { export: true, name, params, JSDoc, children: `
|
|
87
82
|
const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {}
|
|
88
83
|
|
|
89
84
|
return ${hook.name}({
|
|
@@ -107,17 +102,17 @@ function RootTemplate({ children }) {
|
|
|
107
102
|
mutate
|
|
108
103
|
}
|
|
109
104
|
}
|
|
110
|
-
} =
|
|
111
|
-
const { getSchemas, getFile } =
|
|
112
|
-
const operation =
|
|
113
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
105
|
+
} = useApp();
|
|
106
|
+
const { getSchemas, getFile } = useOperationManager();
|
|
107
|
+
const operation = useOperation();
|
|
108
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
114
109
|
const file = getFile(operation);
|
|
115
|
-
const fileType = getFile(operation, { pluginKey: [
|
|
116
|
-
return /* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */
|
|
119
|
-
/* @__PURE__ */
|
|
120
|
-
|
|
110
|
+
const fileType = getFile(operation, { pluginKey: [pluginTsName] });
|
|
111
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
112
|
+
/* @__PURE__ */ jsx(File.Import, { name: "client", path: importPath }),
|
|
113
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
|
|
114
|
+
/* @__PURE__ */ jsx(
|
|
115
|
+
File.Import,
|
|
121
116
|
{
|
|
122
117
|
name: [
|
|
123
118
|
schemas.request?.name,
|
|
@@ -132,15 +127,15 @@ function RootTemplate({ children }) {
|
|
|
132
127
|
isTypeOnly: true
|
|
133
128
|
}
|
|
134
129
|
),
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
|
|
130
|
+
/* @__PURE__ */ jsx(
|
|
131
|
+
File.Import,
|
|
137
132
|
{
|
|
138
133
|
name: ["UseMutationOptions", "UseMutationResult"],
|
|
139
134
|
path: typeof mutate !== "boolean" && mutate.importPath ? mutate.importPath : "@tanstack/react-query",
|
|
140
135
|
isTypeOnly: true
|
|
141
136
|
}
|
|
142
137
|
),
|
|
143
|
-
/* @__PURE__ */
|
|
138
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["useMutation"], path: typeof mutate !== "boolean" && mutate.importPath ? mutate.importPath : "@tanstack/react-query" }),
|
|
144
139
|
children
|
|
145
140
|
] });
|
|
146
141
|
}
|
|
@@ -150,11 +145,11 @@ function Mutation({ Template: Template6 = defaultTemplates.default }) {
|
|
|
150
145
|
plugin: {
|
|
151
146
|
options: { dataReturnType, mutate }
|
|
152
147
|
}
|
|
153
|
-
} =
|
|
154
|
-
const operation =
|
|
155
|
-
const { getSchemas, getName } =
|
|
148
|
+
} = useApp();
|
|
149
|
+
const operation = useOperation();
|
|
150
|
+
const { getSchemas, getName } = useOperationManager();
|
|
156
151
|
const name = getName(operation, { type: "function" });
|
|
157
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
152
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
158
153
|
const contentType = operation.getContentType();
|
|
159
154
|
const params = new FunctionParams();
|
|
160
155
|
const mutateParams = new FunctionParams();
|
|
@@ -265,7 +260,7 @@ function Mutation({ Template: Template6 = defaultTemplates.default }) {
|
|
|
265
260
|
if (!mutate) {
|
|
266
261
|
return null;
|
|
267
262
|
}
|
|
268
|
-
return /* @__PURE__ */
|
|
263
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
269
264
|
Template6,
|
|
270
265
|
{
|
|
271
266
|
name,
|
|
@@ -282,25 +277,12 @@ Mutation.File = function({ ...props }) {
|
|
|
282
277
|
const templates = { ...defaultTemplates, ...props.templates };
|
|
283
278
|
const Template6 = templates.default;
|
|
284
279
|
const RootTemplate2 = templates.root;
|
|
285
|
-
return /* @__PURE__ */
|
|
286
|
-
/* @__PURE__ */
|
|
287
|
-
/* @__PURE__ */
|
|
280
|
+
return /* @__PURE__ */ jsxs(RootTemplate2, { children: [
|
|
281
|
+
/* @__PURE__ */ jsx(SchemaType, {}),
|
|
282
|
+
/* @__PURE__ */ jsx(Mutation, { Template: Template6 })
|
|
288
283
|
] });
|
|
289
284
|
};
|
|
290
285
|
Mutation.templates = defaultTemplates;
|
|
291
|
-
|
|
292
|
-
// src/components/Query.tsx
|
|
293
|
-
import { PackageManager as PackageManager4 } from "@kubb/core";
|
|
294
|
-
import transformers3 from "@kubb/core/transformers";
|
|
295
|
-
import { FunctionParams as FunctionParams4, URLPath as URLPath4 } from "@kubb/core/utils";
|
|
296
|
-
import { File as File6, Function as Function4, useApp as useApp5 } from "@kubb/react";
|
|
297
|
-
import { pluginTsName as pluginTsName5 } from "@kubb/plugin-ts";
|
|
298
|
-
import { pluginZodName as pluginZodName2 } from "@kubb/plugin-zod";
|
|
299
|
-
import { useOperation as useOperation5, useOperationManager as useOperationManager5 } from "@kubb/plugin-oas/hooks";
|
|
300
|
-
import { getASTParams as getASTParams4, getComments as getComments2 } from "@kubb/plugin-oas/utils";
|
|
301
|
-
|
|
302
|
-
// src/utils.ts
|
|
303
|
-
import { PackageManager } from "@kubb/core";
|
|
304
286
|
var reactQueryDepRegex = /@tanstack\/(react|solid|vue|svelte)-query/;
|
|
305
287
|
function getImportNames() {
|
|
306
288
|
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
@@ -393,26 +375,21 @@ function getImportNames() {
|
|
|
393
375
|
}
|
|
394
376
|
};
|
|
395
377
|
}
|
|
396
|
-
|
|
397
|
-
// src/components/QueryImports.tsx
|
|
398
|
-
import { PackageManager as PackageManager2 } from "@kubb/core";
|
|
399
|
-
import { File as File3 } from "@kubb/react";
|
|
400
|
-
import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs3 } from "@kubb/react/jsx-runtime";
|
|
401
378
|
function Template2({ path, hookPath = path, isInfinite, hookName, queryOptions, optionsType, resultType }) {
|
|
402
|
-
return /* @__PURE__ */
|
|
403
|
-
/* @__PURE__ */
|
|
404
|
-
/* @__PURE__ */
|
|
405
|
-
queryOptions && /* @__PURE__ */
|
|
406
|
-
/* @__PURE__ */
|
|
379
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
380
|
+
/* @__PURE__ */ jsx(File.Import, { name: [optionsType, resultType], path, isTypeOnly: true }),
|
|
381
|
+
/* @__PURE__ */ jsx(File.Import, { name: [hookName], path: hookPath }),
|
|
382
|
+
queryOptions && /* @__PURE__ */ jsx(File.Import, { name: [queryOptions].filter(Boolean), path }),
|
|
383
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "WithRequired", isInfinite ? "InfiniteData" : void 0].filter(Boolean), path, isTypeOnly: true })
|
|
407
384
|
] });
|
|
408
385
|
}
|
|
409
386
|
var defaultTemplates2 = {
|
|
410
387
|
get react() {
|
|
411
388
|
return function({ context, hookPath, ...rest }) {
|
|
412
389
|
const importNames = getImportNames();
|
|
413
|
-
const isV5 = new
|
|
390
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
414
391
|
const { isInfinite, isSuspense } = context;
|
|
415
|
-
return /* @__PURE__ */
|
|
392
|
+
return /* @__PURE__ */ jsx(
|
|
416
393
|
Template2,
|
|
417
394
|
{
|
|
418
395
|
isInfinite,
|
|
@@ -427,9 +404,9 @@ var defaultTemplates2 = {
|
|
|
427
404
|
get solid() {
|
|
428
405
|
return function({ context, hookPath, ...rest }) {
|
|
429
406
|
const importNames = getImportNames();
|
|
430
|
-
const isV5 = new
|
|
407
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
431
408
|
const { isInfinite } = context;
|
|
432
|
-
return /* @__PURE__ */
|
|
409
|
+
return /* @__PURE__ */ jsx(
|
|
433
410
|
Template2,
|
|
434
411
|
{
|
|
435
412
|
isInfinite,
|
|
@@ -444,9 +421,9 @@ var defaultTemplates2 = {
|
|
|
444
421
|
get svelte() {
|
|
445
422
|
return function({ context, hookPath, ...rest }) {
|
|
446
423
|
const importNames = getImportNames();
|
|
447
|
-
const isV5 = new
|
|
424
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
448
425
|
const { isInfinite } = context;
|
|
449
|
-
return /* @__PURE__ */
|
|
426
|
+
return /* @__PURE__ */ jsx(
|
|
450
427
|
Template2,
|
|
451
428
|
{
|
|
452
429
|
isInfinite,
|
|
@@ -461,12 +438,12 @@ var defaultTemplates2 = {
|
|
|
461
438
|
get vue() {
|
|
462
439
|
return function({ context, hookPath, ...rest }) {
|
|
463
440
|
const importNames = getImportNames();
|
|
464
|
-
const isV5 = new
|
|
441
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
465
442
|
const { isInfinite } = context;
|
|
466
443
|
const path = "@tanstack/vue-query";
|
|
467
|
-
return /* @__PURE__ */
|
|
468
|
-
isV5 && /* @__PURE__ */
|
|
469
|
-
/* @__PURE__ */
|
|
444
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
445
|
+
isV5 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
446
|
+
/* @__PURE__ */ jsx(
|
|
470
447
|
Template2,
|
|
471
448
|
{
|
|
472
449
|
isInfinite,
|
|
@@ -476,27 +453,27 @@ var defaultTemplates2 = {
|
|
|
476
453
|
...rest
|
|
477
454
|
}
|
|
478
455
|
),
|
|
479
|
-
/* @__PURE__ */
|
|
456
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["QueryObserverOptions"], path, isTypeOnly: true })
|
|
480
457
|
] }),
|
|
481
|
-
!isV5 && isInfinite && /* @__PURE__ */
|
|
482
|
-
/* @__PURE__ */
|
|
483
|
-
/* @__PURE__ */
|
|
484
|
-
/* @__PURE__ */
|
|
458
|
+
!isV5 && isInfinite && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
459
|
+
/* @__PURE__ */ jsx(File.Import, { name: [importNames.queryInfinite.vue.resultType], path, isTypeOnly: true }),
|
|
460
|
+
/* @__PURE__ */ jsx(File.Import, { name: [importNames.queryInfinite.vue.optionsType], path: "@tanstack/vue-query/build/lib/types", isTypeOnly: true }),
|
|
461
|
+
/* @__PURE__ */ jsx(File.Import, { name: [importNames.queryInfinite.vue.hookName], path })
|
|
485
462
|
] }),
|
|
486
|
-
!isV5 && !isInfinite && /* @__PURE__ */
|
|
487
|
-
/* @__PURE__ */
|
|
488
|
-
/* @__PURE__ */
|
|
489
|
-
/* @__PURE__ */
|
|
463
|
+
!isV5 && !isInfinite && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
464
|
+
/* @__PURE__ */ jsx(File.Import, { name: [importNames.query.vue.resultType], path, isTypeOnly: true }),
|
|
465
|
+
/* @__PURE__ */ jsx(File.Import, { name: [importNames.query.vue.optionsType], path: "@tanstack/vue-query/build/lib/types", isTypeOnly: true }),
|
|
466
|
+
/* @__PURE__ */ jsx(File.Import, { name: [importNames.query.vue.hookName], path })
|
|
490
467
|
] }),
|
|
491
|
-
/* @__PURE__ */
|
|
492
|
-
/* @__PURE__ */
|
|
493
|
-
/* @__PURE__ */
|
|
468
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["unref"], path: "vue" }),
|
|
469
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["MaybeRef"], path: "vue", isTypeOnly: true }),
|
|
470
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["QueryKey", "WithRequired"], path, isTypeOnly: true })
|
|
494
471
|
] });
|
|
495
472
|
};
|
|
496
473
|
}
|
|
497
474
|
};
|
|
498
475
|
function QueryImports({ hookPath, isInfinite, isSuspense, Template: Template6 = defaultTemplates2.react }) {
|
|
499
|
-
return /* @__PURE__ */
|
|
476
|
+
return /* @__PURE__ */ jsx(
|
|
500
477
|
Template6,
|
|
501
478
|
{
|
|
502
479
|
hookPath,
|
|
@@ -508,35 +485,26 @@ function QueryImports({ hookPath, isInfinite, isSuspense, Template: Template6 =
|
|
|
508
485
|
);
|
|
509
486
|
}
|
|
510
487
|
QueryImports.templates = defaultTemplates2;
|
|
511
|
-
|
|
512
|
-
// src/components/QueryKey.tsx
|
|
513
|
-
import { FunctionParams as FunctionParams2, URLPath as URLPath2 } from "@kubb/core/utils";
|
|
514
|
-
import { useOperation as useOperation3, useOperationManager as useOperationManager3 } from "@kubb/plugin-oas/hooks";
|
|
515
|
-
import { getASTParams as getASTParams2 } from "@kubb/plugin-oas/utils";
|
|
516
|
-
import { File as File4, Function as Function2, Type as Type2, useApp as useApp3 } from "@kubb/react";
|
|
517
|
-
import { isRequired as isRequired2 } from "@kubb/oas";
|
|
518
|
-
import { pluginTsName as pluginTsName3 } from "@kubb/plugin-ts";
|
|
519
|
-
import { Fragment as Fragment4, jsx as jsx4, jsxs as jsxs4 } from "@kubb/react/jsx-runtime";
|
|
520
488
|
function Template3({ name, typeName, params, generics, returnType, JSDoc, keys }) {
|
|
521
|
-
return /* @__PURE__ */
|
|
522
|
-
/* @__PURE__ */
|
|
523
|
-
/* @__PURE__ */
|
|
489
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
490
|
+
/* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function.Arrow, { name, export: true, generics, params, returnType, singleLine: true, JSDoc, children: `[${keys}] as const` }) }),
|
|
491
|
+
/* @__PURE__ */ jsx(File.Source, { name: typeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` }) })
|
|
524
492
|
] });
|
|
525
493
|
}
|
|
526
494
|
var defaultTemplates3 = {
|
|
527
495
|
get react() {
|
|
528
496
|
return function(props) {
|
|
529
|
-
return /* @__PURE__ */
|
|
497
|
+
return /* @__PURE__ */ jsx(Template3, { ...props });
|
|
530
498
|
};
|
|
531
499
|
},
|
|
532
500
|
get solid() {
|
|
533
501
|
return function(props) {
|
|
534
|
-
return /* @__PURE__ */
|
|
502
|
+
return /* @__PURE__ */ jsx(Template3, { ...props });
|
|
535
503
|
};
|
|
536
504
|
},
|
|
537
505
|
get svelte() {
|
|
538
506
|
return function(props) {
|
|
539
|
-
return /* @__PURE__ */
|
|
507
|
+
return /* @__PURE__ */ jsx(Template3, { ...props });
|
|
540
508
|
};
|
|
541
509
|
},
|
|
542
510
|
get vue() {
|
|
@@ -546,24 +514,24 @@ var defaultTemplates3 = {
|
|
|
546
514
|
plugin: {
|
|
547
515
|
options: { pathParamsType, query }
|
|
548
516
|
}
|
|
549
|
-
} =
|
|
550
|
-
const { getSchemas } =
|
|
551
|
-
const operation =
|
|
552
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
553
|
-
const path = new
|
|
554
|
-
const params = new
|
|
517
|
+
} = useApp();
|
|
518
|
+
const { getSchemas } = useOperationManager();
|
|
519
|
+
const operation = useOperation();
|
|
520
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
521
|
+
const path = new URLPath(operation.path);
|
|
522
|
+
const params = new FunctionParams();
|
|
555
523
|
const withQueryParams = !!schemas.queryParams?.name;
|
|
556
524
|
const withRequest = !!schemas.request?.name;
|
|
557
525
|
params.add([
|
|
558
526
|
...pathParamsType === "object" ? [
|
|
559
|
-
|
|
527
|
+
getASTParams(schemas.pathParams, {
|
|
560
528
|
typed: true,
|
|
561
529
|
override: (item) => ({
|
|
562
530
|
...item,
|
|
563
531
|
type: `MaybeRef<${item.type}>`
|
|
564
532
|
})
|
|
565
533
|
})
|
|
566
|
-
] :
|
|
534
|
+
] : getASTParams(schemas.pathParams, {
|
|
567
535
|
typed: true,
|
|
568
536
|
override: (item) => ({
|
|
569
537
|
...item,
|
|
@@ -574,13 +542,13 @@ var defaultTemplates3 = {
|
|
|
574
542
|
name: "params",
|
|
575
543
|
type: `MaybeRef<${`${factory.name}["queryParams"]`}>`,
|
|
576
544
|
enabled: withQueryParams,
|
|
577
|
-
required:
|
|
545
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
578
546
|
},
|
|
579
547
|
{
|
|
580
548
|
name: "request",
|
|
581
549
|
type: `MaybeRef<${`${factory.name}["request"]`}>`,
|
|
582
550
|
enabled: withRequest,
|
|
583
|
-
required:
|
|
551
|
+
required: isRequired(schemas.request?.schema)
|
|
584
552
|
}
|
|
585
553
|
]);
|
|
586
554
|
const keys = [
|
|
@@ -592,7 +560,7 @@ var defaultTemplates3 = {
|
|
|
592
560
|
withQueryParams ? "...(params ? [params] : [])" : void 0,
|
|
593
561
|
withRequest ? "...(request ? [request] : [])" : void 0
|
|
594
562
|
].filter(Boolean);
|
|
595
|
-
return /* @__PURE__ */
|
|
563
|
+
return /* @__PURE__ */ jsx(Template3, { ...rest, params: params.toString(), keys: keys.join(", ") });
|
|
596
564
|
};
|
|
597
565
|
}
|
|
598
566
|
};
|
|
@@ -601,27 +569,27 @@ function QueryKey({ name, typeName, factory, keysFn, Template: Template6 = defau
|
|
|
601
569
|
plugin: {
|
|
602
570
|
options: { pathParamsType }
|
|
603
571
|
}
|
|
604
|
-
} =
|
|
605
|
-
const { getSchemas } =
|
|
606
|
-
const operation =
|
|
607
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
608
|
-
const path = new
|
|
609
|
-
const params = new
|
|
572
|
+
} = useApp();
|
|
573
|
+
const { getSchemas } = useOperationManager();
|
|
574
|
+
const operation = useOperation();
|
|
575
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
576
|
+
const path = new URLPath(operation.path);
|
|
577
|
+
const params = new FunctionParams();
|
|
610
578
|
const withQueryParams = !!schemas.queryParams?.name;
|
|
611
579
|
const withRequest = !!schemas.request?.name;
|
|
612
580
|
params.add([
|
|
613
|
-
...pathParamsType === "object" ? [
|
|
581
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams, { typed: true })] : getASTParams(schemas.pathParams, { typed: true }),
|
|
614
582
|
{
|
|
615
583
|
name: "params",
|
|
616
584
|
type: `${factory.name}["queryParams"]`,
|
|
617
585
|
enabled: withQueryParams,
|
|
618
|
-
required:
|
|
586
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
619
587
|
},
|
|
620
588
|
{
|
|
621
589
|
name: "data",
|
|
622
590
|
type: `${factory.name}["request"]`,
|
|
623
591
|
enabled: withRequest,
|
|
624
|
-
required:
|
|
592
|
+
required: isRequired(schemas.request?.schema)
|
|
625
593
|
}
|
|
626
594
|
]);
|
|
627
595
|
const keys = [
|
|
@@ -632,23 +600,11 @@ function QueryKey({ name, typeName, factory, keysFn, Template: Template6 = defau
|
|
|
632
600
|
withQueryParams ? "...(params ? [params] : [])" : void 0,
|
|
633
601
|
withRequest ? "...(data ? [data] : [])" : void 0
|
|
634
602
|
].filter(Boolean);
|
|
635
|
-
return /* @__PURE__ */
|
|
603
|
+
return /* @__PURE__ */ jsx(Template6, { typeName, name, params: params.toString(), keys: keysFn(keys).join(", "), context: { factory } });
|
|
636
604
|
}
|
|
637
605
|
QueryKey.templates = defaultTemplates3;
|
|
638
|
-
|
|
639
|
-
// src/components/QueryOptions.tsx
|
|
640
|
-
import { PackageManager as PackageManager3 } from "@kubb/core";
|
|
641
|
-
import transformers2 from "@kubb/core/transformers";
|
|
642
|
-
import { FunctionParams as FunctionParams3, URLPath as URLPath3 } from "@kubb/core/utils";
|
|
643
|
-
import { useOperation as useOperation4, useOperationManager as useOperationManager4 } from "@kubb/plugin-oas/hooks";
|
|
644
|
-
import { getASTParams as getASTParams3 } from "@kubb/plugin-oas/utils";
|
|
645
|
-
import { Function as Function3, useApp as useApp4, File as File5 } from "@kubb/react";
|
|
646
|
-
import { pluginZodName } from "@kubb/plugin-zod";
|
|
647
|
-
import { isRequired as isRequired3 } from "@kubb/oas";
|
|
648
|
-
import { pluginTsName as pluginTsName4 } from "@kubb/plugin-ts";
|
|
649
|
-
import { jsx as jsx5 } from "@kubb/react/jsx-runtime";
|
|
650
606
|
function Template4({ name, params, generics, returnType, JSDoc, hook, client, infinite, dataReturnType, parser }) {
|
|
651
|
-
const isV5 = new
|
|
607
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
652
608
|
const isFormData = client.contentType === "multipart/form-data";
|
|
653
609
|
const headers = [
|
|
654
610
|
client.contentType !== "application/json" ? `'Content-Type': '${client.contentType}'` : void 0,
|
|
@@ -697,7 +653,7 @@ ${transformers2.createIndent(4)}`)}`;
|
|
|
697
653
|
` : void 0;
|
|
698
654
|
if (infinite) {
|
|
699
655
|
if (isV5) {
|
|
700
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, params, JSDoc, children: `
|
|
701
657
|
const queryKey = ${hook.queryKey}
|
|
702
658
|
|
|
703
659
|
return infiniteQueryOptions({
|
|
@@ -716,7 +672,7 @@ ${transformers2.createIndent(4)}`)}`;
|
|
|
716
672
|
|
|
717
673
|
` }) });
|
|
718
674
|
}
|
|
719
|
-
return /* @__PURE__ */
|
|
675
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, generics, returnType, params, JSDoc, children: `
|
|
720
676
|
const queryKey = ${hook.queryKey}
|
|
721
677
|
|
|
722
678
|
return {
|
|
@@ -736,7 +692,7 @@ ${transformers2.createIndent(4)}`)}`;
|
|
|
736
692
|
` }) });
|
|
737
693
|
}
|
|
738
694
|
if (isV5) {
|
|
739
|
-
return /* @__PURE__ */
|
|
695
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, params, JSDoc, children: `
|
|
740
696
|
const queryKey = ${hook.queryKey}
|
|
741
697
|
|
|
742
698
|
return queryOptions({
|
|
@@ -755,7 +711,7 @@ ${transformers2.createIndent(4)}`)}`;
|
|
|
755
711
|
|
|
756
712
|
` }) });
|
|
757
713
|
}
|
|
758
|
-
return /* @__PURE__ */
|
|
714
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, generics, returnType, params, JSDoc, children: `
|
|
759
715
|
const queryKey = ${hook.queryKey}
|
|
760
716
|
|
|
761
717
|
return {
|
|
@@ -777,17 +733,17 @@ ${transformers2.createIndent(4)}`)}`;
|
|
|
777
733
|
var defaultTemplates4 = {
|
|
778
734
|
get react() {
|
|
779
735
|
return function(props) {
|
|
780
|
-
return /* @__PURE__ */
|
|
736
|
+
return /* @__PURE__ */ jsx(Template4, { ...props });
|
|
781
737
|
};
|
|
782
738
|
},
|
|
783
739
|
get solid() {
|
|
784
740
|
return function(props) {
|
|
785
|
-
return /* @__PURE__ */
|
|
741
|
+
return /* @__PURE__ */ jsx(Template4, { ...props });
|
|
786
742
|
};
|
|
787
743
|
},
|
|
788
744
|
get svelte() {
|
|
789
745
|
return function(props) {
|
|
790
|
-
return /* @__PURE__ */
|
|
746
|
+
return /* @__PURE__ */ jsx(Template4, { ...props });
|
|
791
747
|
};
|
|
792
748
|
},
|
|
793
749
|
get vue() {
|
|
@@ -797,15 +753,15 @@ var defaultTemplates4 = {
|
|
|
797
753
|
plugin: {
|
|
798
754
|
options: { pathParamsType }
|
|
799
755
|
}
|
|
800
|
-
} =
|
|
801
|
-
const { getSchemas } =
|
|
802
|
-
const operation =
|
|
803
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
804
|
-
const params = new
|
|
805
|
-
const queryKeyParams = new
|
|
756
|
+
} = useApp();
|
|
757
|
+
const { getSchemas } = useOperationManager();
|
|
758
|
+
const operation = useOperation();
|
|
759
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
760
|
+
const params = new FunctionParams();
|
|
761
|
+
const queryKeyParams = new FunctionParams();
|
|
806
762
|
params.add([
|
|
807
763
|
...pathParamsType === "object" ? [
|
|
808
|
-
|
|
764
|
+
getASTParams(schemas.pathParams, {
|
|
809
765
|
typed: true,
|
|
810
766
|
override: (item) => ({
|
|
811
767
|
...item,
|
|
@@ -813,7 +769,7 @@ var defaultTemplates4 = {
|
|
|
813
769
|
type: `MaybeRef<${item.type}>`
|
|
814
770
|
})
|
|
815
771
|
})
|
|
816
|
-
] :
|
|
772
|
+
] : getASTParams(schemas.pathParams, {
|
|
817
773
|
typed: true,
|
|
818
774
|
override: (item) => ({
|
|
819
775
|
...item,
|
|
@@ -825,19 +781,19 @@ var defaultTemplates4 = {
|
|
|
825
781
|
name: "refParams",
|
|
826
782
|
type: `MaybeRef<${schemas.queryParams?.name}>`,
|
|
827
783
|
enabled: client.withQueryParams,
|
|
828
|
-
required:
|
|
784
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
829
785
|
},
|
|
830
786
|
{
|
|
831
787
|
name: "refHeaders",
|
|
832
788
|
type: `MaybeRef<${schemas.headerParams?.name}>`,
|
|
833
789
|
enabled: client.withHeaders,
|
|
834
|
-
required:
|
|
790
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
835
791
|
},
|
|
836
792
|
{
|
|
837
793
|
name: "refData",
|
|
838
794
|
type: `MaybeRef<${schemas.request?.name}>`,
|
|
839
795
|
enabled: client.withData,
|
|
840
|
-
required:
|
|
796
|
+
required: isRequired(schemas.request?.schema)
|
|
841
797
|
},
|
|
842
798
|
{
|
|
843
799
|
name: "options",
|
|
@@ -847,13 +803,13 @@ var defaultTemplates4 = {
|
|
|
847
803
|
]);
|
|
848
804
|
queryKeyParams.add([
|
|
849
805
|
...pathParamsType === "object" ? [
|
|
850
|
-
|
|
806
|
+
getASTParams(schemas.pathParams, {
|
|
851
807
|
override: (item) => ({
|
|
852
808
|
...item,
|
|
853
809
|
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
854
810
|
})
|
|
855
811
|
})
|
|
856
|
-
] :
|
|
812
|
+
] : getASTParams(schemas.pathParams, {
|
|
857
813
|
override: (item) => ({
|
|
858
814
|
...item,
|
|
859
815
|
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
@@ -862,12 +818,12 @@ var defaultTemplates4 = {
|
|
|
862
818
|
{
|
|
863
819
|
name: "refParams",
|
|
864
820
|
enabled: client.withQueryParams,
|
|
865
|
-
required:
|
|
821
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
866
822
|
},
|
|
867
823
|
{
|
|
868
824
|
name: "refData",
|
|
869
825
|
enabled: client.withData,
|
|
870
|
-
required:
|
|
826
|
+
required: isRequired(schemas.request?.schema)
|
|
871
827
|
}
|
|
872
828
|
]);
|
|
873
829
|
const unrefs = params.items.filter((item) => item.enabled).map((item) => {
|
|
@@ -877,7 +833,7 @@ var defaultTemplates4 = {
|
|
|
877
833
|
queryKey: `${queryKey}(${queryKeyParams.toString()})`,
|
|
878
834
|
children: unrefs
|
|
879
835
|
};
|
|
880
|
-
return /* @__PURE__ */
|
|
836
|
+
return /* @__PURE__ */ jsx(Template4, { ...rest, params: params.toString(), hook, client });
|
|
881
837
|
};
|
|
882
838
|
}
|
|
883
839
|
};
|
|
@@ -888,11 +844,11 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
888
844
|
key: pluginKey,
|
|
889
845
|
options: { parser, pathParamsType, queryOptions }
|
|
890
846
|
}
|
|
891
|
-
} =
|
|
892
|
-
const { getSchemas } =
|
|
893
|
-
const operation =
|
|
847
|
+
} = useApp();
|
|
848
|
+
const { getSchemas } = useOperationManager();
|
|
849
|
+
const operation = useOperation();
|
|
894
850
|
const contentType = operation.getContentType();
|
|
895
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
851
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
896
852
|
const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: "function" });
|
|
897
853
|
const queryKey = pluginManager.resolveName({
|
|
898
854
|
name: [factory.name, infinite ? "Infinite" : void 0, suspense ? "Suspense" : void 0, "QueryKey"].filter(Boolean).join(""),
|
|
@@ -902,9 +858,9 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
902
858
|
name: [factory.name, infinite ? "Infinite" : void 0, suspense ? "Suspense" : void 0, "QueryOptions"].filter(Boolean).join(""),
|
|
903
859
|
pluginKey
|
|
904
860
|
});
|
|
905
|
-
const generics = new
|
|
906
|
-
const params = new
|
|
907
|
-
const queryKeyParams = new
|
|
861
|
+
const generics = new FunctionParams();
|
|
862
|
+
const params = new FunctionParams();
|
|
863
|
+
const queryKeyParams = new FunctionParams();
|
|
908
864
|
const clientGenerics = [`${factory.name}['data']`, `${factory.name}['error']`];
|
|
909
865
|
const resultGenerics = suspense ? [`${factory.name}['response']`, `${factory.name}["error"]`, "TData"] : [`${factory.name}['response']`, `${factory.name}["error"]`, "TData", "TQueryData"];
|
|
910
866
|
const client = {
|
|
@@ -913,7 +869,7 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
913
869
|
withPathParams: !!schemas.pathParams?.name,
|
|
914
870
|
withHeaders: !!schemas.headerParams?.name,
|
|
915
871
|
method: operation.method,
|
|
916
|
-
path: new
|
|
872
|
+
path: new URLPath(operation.path),
|
|
917
873
|
generics: clientGenerics.toString(),
|
|
918
874
|
contentType
|
|
919
875
|
};
|
|
@@ -922,24 +878,24 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
922
878
|
suspense ? void 0 : { type: "TQueryData", default: `${factory.name}["response"]` }
|
|
923
879
|
]);
|
|
924
880
|
params.add([
|
|
925
|
-
...pathParamsType === "object" ? [
|
|
881
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams, { typed: true })] : getASTParams(schemas.pathParams, { typed: true }),
|
|
926
882
|
{
|
|
927
883
|
name: "params",
|
|
928
884
|
type: `${factory.name}['queryParams']`,
|
|
929
885
|
enabled: client.withQueryParams,
|
|
930
|
-
required:
|
|
886
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
931
887
|
},
|
|
932
888
|
{
|
|
933
889
|
name: "headers",
|
|
934
890
|
type: `${factory.name}['headerParams']`,
|
|
935
891
|
enabled: client.withHeaders,
|
|
936
|
-
required:
|
|
892
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
937
893
|
},
|
|
938
894
|
{
|
|
939
895
|
name: "data",
|
|
940
896
|
type: `${factory.name}['request']`,
|
|
941
897
|
enabled: client.withData,
|
|
942
|
-
required:
|
|
898
|
+
required: isRequired(schemas.request?.schema)
|
|
943
899
|
},
|
|
944
900
|
{
|
|
945
901
|
name: "options",
|
|
@@ -948,16 +904,16 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
948
904
|
}
|
|
949
905
|
]);
|
|
950
906
|
queryKeyParams.add([
|
|
951
|
-
...pathParamsType === "object" ? [
|
|
907
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams)] : getASTParams(schemas.pathParams),
|
|
952
908
|
{
|
|
953
909
|
name: "params",
|
|
954
910
|
enabled: client.withQueryParams,
|
|
955
|
-
required:
|
|
911
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
956
912
|
},
|
|
957
913
|
{
|
|
958
914
|
name: "data",
|
|
959
915
|
enabled: client.withData,
|
|
960
|
-
required:
|
|
916
|
+
required: isRequired(schemas.request?.schema)
|
|
961
917
|
}
|
|
962
918
|
]);
|
|
963
919
|
const hook = {
|
|
@@ -966,7 +922,7 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
966
922
|
if (!queryOptions) {
|
|
967
923
|
return null;
|
|
968
924
|
}
|
|
969
|
-
return /* @__PURE__ */
|
|
925
|
+
return /* @__PURE__ */ jsx(
|
|
970
926
|
Template6,
|
|
971
927
|
{
|
|
972
928
|
name: queryOptionsName,
|
|
@@ -986,15 +942,11 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
986
942
|
);
|
|
987
943
|
}
|
|
988
944
|
QueryOptions.templates = defaultTemplates4;
|
|
989
|
-
|
|
990
|
-
// src/components/Query.tsx
|
|
991
|
-
import { isRequired as isRequired4 } from "@kubb/oas";
|
|
992
|
-
import { Fragment as Fragment5, jsx as jsx6, jsxs as jsxs5 } from "@kubb/react/jsx-runtime";
|
|
993
945
|
function Template5({ name, generics, returnType, params, JSDoc, hook, infinite }) {
|
|
994
|
-
const isV5 = new
|
|
946
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
995
947
|
const resolvedReturnType = `${returnType} & { queryKey: TQueryKey }`;
|
|
996
948
|
if (isV5) {
|
|
997
|
-
return /* @__PURE__ */
|
|
949
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, generics, returnType: resolvedReturnType, params, JSDoc, children: `
|
|
998
950
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
|
|
999
951
|
const queryKey = queryOptions?.queryKey ?? ${hook.queryKey}
|
|
1000
952
|
|
|
@@ -1010,7 +962,7 @@ function Template5({ name, generics, returnType, params, JSDoc, hook, infinite }
|
|
|
1010
962
|
|
|
1011
963
|
` }) });
|
|
1012
964
|
}
|
|
1013
|
-
return /* @__PURE__ */
|
|
965
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, generics, returnType: resolvedReturnType, params, JSDoc, children: `
|
|
1014
966
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
|
|
1015
967
|
const queryKey = queryOptions?.queryKey ?? ${hook.queryKey}
|
|
1016
968
|
|
|
@@ -1029,17 +981,17 @@ function Template5({ name, generics, returnType, params, JSDoc, hook, infinite }
|
|
|
1029
981
|
var defaultTemplates5 = {
|
|
1030
982
|
get react() {
|
|
1031
983
|
return function(props) {
|
|
1032
|
-
return /* @__PURE__ */
|
|
984
|
+
return /* @__PURE__ */ jsx(Template5, { ...props });
|
|
1033
985
|
};
|
|
1034
986
|
},
|
|
1035
987
|
get solid() {
|
|
1036
988
|
return function(props) {
|
|
1037
|
-
return /* @__PURE__ */
|
|
989
|
+
return /* @__PURE__ */ jsx(Template5, { ...props });
|
|
1038
990
|
};
|
|
1039
991
|
},
|
|
1040
992
|
get svelte() {
|
|
1041
993
|
return function(props) {
|
|
1042
|
-
return /* @__PURE__ */
|
|
994
|
+
return /* @__PURE__ */ jsx(Template5, { ...props });
|
|
1043
995
|
};
|
|
1044
996
|
},
|
|
1045
997
|
get vue() {
|
|
@@ -1051,9 +1003,9 @@ var defaultTemplates5 = {
|
|
|
1051
1003
|
key: pluginKey,
|
|
1052
1004
|
options: { pathParamsType }
|
|
1053
1005
|
}
|
|
1054
|
-
} =
|
|
1055
|
-
const operation =
|
|
1056
|
-
const { getSchemas } =
|
|
1006
|
+
} = useApp();
|
|
1007
|
+
const operation = useOperation();
|
|
1008
|
+
const { getSchemas } = useOperationManager();
|
|
1057
1009
|
const importNames = getImportNames();
|
|
1058
1010
|
const queryOptions = pluginManager.resolveName({
|
|
1059
1011
|
name: `${factory.name}QueryOptions`,
|
|
@@ -1062,11 +1014,11 @@ var defaultTemplates5 = {
|
|
|
1062
1014
|
const hookName = rest.infinite ? importNames.queryInfinite.vue.hookName : importNames.query.vue.hookName;
|
|
1063
1015
|
const resultType = rest.infinite ? importNames.queryInfinite.vue.resultType : importNames.query.vue.resultType;
|
|
1064
1016
|
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
|
|
1017
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
1018
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
1019
|
+
const params = new FunctionParams();
|
|
1020
|
+
const queryParams = new FunctionParams();
|
|
1021
|
+
const queryKeyParams = new FunctionParams();
|
|
1070
1022
|
const client = {
|
|
1071
1023
|
withQueryParams: !!schemas.queryParams?.name,
|
|
1072
1024
|
withData: !!schemas.request?.name,
|
|
@@ -1078,37 +1030,37 @@ var defaultTemplates5 = {
|
|
|
1078
1030
|
const queryOptionsGenerics = ["TData", "TQueryData"];
|
|
1079
1031
|
params.add([
|
|
1080
1032
|
...pathParamsType === "object" ? [
|
|
1081
|
-
|
|
1033
|
+
getASTParams(schemas.pathParams, {
|
|
1082
1034
|
typed: true,
|
|
1083
1035
|
override: (item) => ({
|
|
1084
1036
|
...item,
|
|
1085
|
-
name: item.name ? `ref${
|
|
1037
|
+
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
1086
1038
|
})
|
|
1087
1039
|
})
|
|
1088
|
-
] :
|
|
1040
|
+
] : getASTParams(schemas.pathParams, {
|
|
1089
1041
|
typed: true,
|
|
1090
1042
|
override: (item) => ({
|
|
1091
1043
|
...item,
|
|
1092
|
-
name: item.name ? `ref${
|
|
1044
|
+
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
1093
1045
|
})
|
|
1094
1046
|
}),
|
|
1095
1047
|
{
|
|
1096
1048
|
name: "refParams",
|
|
1097
1049
|
type: `MaybeRef<${schemas.queryParams?.name}>`,
|
|
1098
1050
|
enabled: client.withQueryParams,
|
|
1099
|
-
required:
|
|
1051
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1100
1052
|
},
|
|
1101
1053
|
{
|
|
1102
1054
|
name: "refHeaders",
|
|
1103
1055
|
type: `MaybeRef<${schemas.headerParams?.name}>`,
|
|
1104
1056
|
enabled: client.withHeaders,
|
|
1105
|
-
required:
|
|
1057
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
1106
1058
|
},
|
|
1107
1059
|
{
|
|
1108
1060
|
name: "refData",
|
|
1109
1061
|
type: `MaybeRef<${schemas.request?.name}>`,
|
|
1110
1062
|
enabled: client.withData,
|
|
1111
|
-
required:
|
|
1063
|
+
required: isRequired(schemas.request?.schema)
|
|
1112
1064
|
},
|
|
1113
1065
|
{
|
|
1114
1066
|
name: "options",
|
|
@@ -1120,22 +1072,22 @@ var defaultTemplates5 = {
|
|
|
1120
1072
|
}
|
|
1121
1073
|
]);
|
|
1122
1074
|
queryParams.add([
|
|
1123
|
-
...
|
|
1075
|
+
...getASTParams(schemas.pathParams, {
|
|
1124
1076
|
typed: false,
|
|
1125
1077
|
override: (item) => ({
|
|
1126
1078
|
...item,
|
|
1127
|
-
name: item.name ? `ref${
|
|
1079
|
+
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
1128
1080
|
})
|
|
1129
1081
|
}),
|
|
1130
1082
|
{
|
|
1131
1083
|
name: "refParams",
|
|
1132
1084
|
enabled: client.withQueryParams,
|
|
1133
|
-
required:
|
|
1085
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1134
1086
|
},
|
|
1135
1087
|
{
|
|
1136
1088
|
name: "refHeaders",
|
|
1137
1089
|
enabled: client.withHeaders,
|
|
1138
|
-
required:
|
|
1090
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
1139
1091
|
},
|
|
1140
1092
|
{
|
|
1141
1093
|
name: "clientOptions",
|
|
@@ -1144,30 +1096,30 @@ var defaultTemplates5 = {
|
|
|
1144
1096
|
]);
|
|
1145
1097
|
queryKeyParams.add([
|
|
1146
1098
|
...pathParamsType === "object" ? [
|
|
1147
|
-
|
|
1099
|
+
getASTParams(schemas.pathParams, {
|
|
1148
1100
|
override: (item) => ({
|
|
1149
1101
|
...item,
|
|
1150
|
-
name: item.name ? `ref${
|
|
1102
|
+
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
1151
1103
|
})
|
|
1152
1104
|
})
|
|
1153
|
-
] :
|
|
1105
|
+
] : getASTParams(schemas.pathParams, {
|
|
1154
1106
|
override: (item) => ({
|
|
1155
1107
|
...item,
|
|
1156
|
-
name: item.name ? `ref${
|
|
1108
|
+
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
1157
1109
|
})
|
|
1158
1110
|
}),
|
|
1159
1111
|
{
|
|
1160
1112
|
name: "refParams",
|
|
1161
1113
|
enabled: client.withQueryParams,
|
|
1162
|
-
required:
|
|
1114
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1163
1115
|
},
|
|
1164
1116
|
{
|
|
1165
1117
|
name: "refData",
|
|
1166
1118
|
enabled: client.withData,
|
|
1167
|
-
required:
|
|
1119
|
+
required: isRequired(schemas.request?.schema)
|
|
1168
1120
|
}
|
|
1169
1121
|
]);
|
|
1170
|
-
return /* @__PURE__ */
|
|
1122
|
+
return /* @__PURE__ */ jsx(
|
|
1171
1123
|
Template5,
|
|
1172
1124
|
{
|
|
1173
1125
|
...rest,
|
|
@@ -1200,12 +1152,12 @@ function Query({
|
|
|
1200
1152
|
key: pluginKey,
|
|
1201
1153
|
options: { dataReturnType, pathParamsType }
|
|
1202
1154
|
}
|
|
1203
|
-
} =
|
|
1204
|
-
const operation =
|
|
1205
|
-
const { getSchemas, getName } =
|
|
1206
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
1155
|
+
} = useApp();
|
|
1156
|
+
const operation = useOperation();
|
|
1157
|
+
const { getSchemas, getName } = useOperationManager();
|
|
1158
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
1207
1159
|
const name = getName(operation, { type: "function" });
|
|
1208
|
-
const isV5 = new
|
|
1160
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
1209
1161
|
const queryKey = pluginManager.resolveName({
|
|
1210
1162
|
name: [factory.name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0, "QueryKey"].filter(Boolean).join(""),
|
|
1211
1163
|
pluginKey
|
|
@@ -1219,13 +1171,13 @@ function Query({
|
|
|
1219
1171
|
name: [factory.name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0, "QueryOptions"].filter(Boolean).join(""),
|
|
1220
1172
|
pluginKey
|
|
1221
1173
|
});
|
|
1222
|
-
const generics = new
|
|
1223
|
-
const params = new
|
|
1224
|
-
const queryParams = new
|
|
1225
|
-
const queryKeyParams = new
|
|
1174
|
+
const generics = new FunctionParams();
|
|
1175
|
+
const params = new FunctionParams();
|
|
1176
|
+
const queryParams = new FunctionParams();
|
|
1177
|
+
const queryKeyParams = new FunctionParams();
|
|
1226
1178
|
const client = {
|
|
1227
1179
|
method: operation.method,
|
|
1228
|
-
path: new
|
|
1180
|
+
path: new URLPath(operation.path),
|
|
1229
1181
|
withQueryParams: !!schemas.queryParams?.name,
|
|
1230
1182
|
withData: !!schemas.request?.name,
|
|
1231
1183
|
withPathParams: !!schemas.pathParams?.name,
|
|
@@ -1243,24 +1195,24 @@ function Query({
|
|
|
1243
1195
|
const queryOptionsOverrideGenerics = props.suspense ? [`${factory.name}['response']`, `${factory.name}['error']`, "TData", "TQueryKey"] : [`${factory.name}['response']`, `${factory.name}['error']`, "TData", "TQueryData", "TQueryKey"];
|
|
1244
1196
|
const queryOptionsGenerics = props.suspense ? ["TData"] : ["TData", "TQueryData"];
|
|
1245
1197
|
params.add([
|
|
1246
|
-
...pathParamsType === "object" ? [
|
|
1198
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams, { typed: true })] : getASTParams(schemas.pathParams, { typed: true }),
|
|
1247
1199
|
{
|
|
1248
1200
|
name: "params",
|
|
1249
1201
|
type: `${factory.name}['queryParams']`,
|
|
1250
1202
|
enabled: client.withQueryParams,
|
|
1251
|
-
required:
|
|
1203
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1252
1204
|
},
|
|
1253
1205
|
{
|
|
1254
1206
|
name: "headers",
|
|
1255
1207
|
type: `${factory.name}['headerParams']`,
|
|
1256
1208
|
enabled: client.withHeaders,
|
|
1257
|
-
required:
|
|
1209
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
1258
1210
|
},
|
|
1259
1211
|
{
|
|
1260
1212
|
name: "data",
|
|
1261
1213
|
type: `${factory.name}['request']`,
|
|
1262
1214
|
enabled: client.withData,
|
|
1263
|
-
required:
|
|
1215
|
+
required: isRequired(schemas.request?.schema)
|
|
1264
1216
|
},
|
|
1265
1217
|
{
|
|
1266
1218
|
name: "options",
|
|
@@ -1272,21 +1224,21 @@ function Query({
|
|
|
1272
1224
|
}
|
|
1273
1225
|
]);
|
|
1274
1226
|
queryParams.add([
|
|
1275
|
-
...pathParamsType === "object" ? [
|
|
1227
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams)] : getASTParams(schemas.pathParams),
|
|
1276
1228
|
{
|
|
1277
1229
|
name: "params",
|
|
1278
1230
|
enabled: client.withQueryParams,
|
|
1279
|
-
required:
|
|
1231
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1280
1232
|
},
|
|
1281
1233
|
{
|
|
1282
1234
|
name: "headers",
|
|
1283
1235
|
enabled: client.withHeaders,
|
|
1284
|
-
required:
|
|
1236
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
1285
1237
|
},
|
|
1286
1238
|
{
|
|
1287
1239
|
name: "data",
|
|
1288
1240
|
enabled: client.withData,
|
|
1289
|
-
required:
|
|
1241
|
+
required: isRequired(schemas.request?.schema)
|
|
1290
1242
|
},
|
|
1291
1243
|
{
|
|
1292
1244
|
name: "clientOptions",
|
|
@@ -1294,16 +1246,16 @@ function Query({
|
|
|
1294
1246
|
}
|
|
1295
1247
|
]);
|
|
1296
1248
|
queryKeyParams.add([
|
|
1297
|
-
...pathParamsType === "object" ? [
|
|
1249
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams)] : getASTParams(schemas.pathParams),
|
|
1298
1250
|
{
|
|
1299
1251
|
name: "params",
|
|
1300
1252
|
enabled: client.withQueryParams,
|
|
1301
|
-
required:
|
|
1253
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1302
1254
|
},
|
|
1303
1255
|
{
|
|
1304
1256
|
name: "data",
|
|
1305
1257
|
enabled: client.withData,
|
|
1306
|
-
required:
|
|
1258
|
+
required: isRequired(schemas.request?.schema)
|
|
1307
1259
|
}
|
|
1308
1260
|
]);
|
|
1309
1261
|
const hook = {
|
|
@@ -1312,8 +1264,8 @@ function Query({
|
|
|
1312
1264
|
queryOptions: isV5 ? `${queryOptions}(${queryParams.toString()})` : `${queryOptions}<${queryOptionsGenerics.join(", ")}>(${queryParams.toString()})`,
|
|
1313
1265
|
queryKey: `${queryKey}(${queryKeyParams.toString()})`
|
|
1314
1266
|
};
|
|
1315
|
-
return /* @__PURE__ */
|
|
1316
|
-
/* @__PURE__ */
|
|
1267
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1268
|
+
/* @__PURE__ */ jsx(
|
|
1317
1269
|
QueryKey,
|
|
1318
1270
|
{
|
|
1319
1271
|
keysFn: props.query ? props.query.queryKey : (keys) => keys,
|
|
@@ -1323,7 +1275,7 @@ function Query({
|
|
|
1323
1275
|
typeName: queryKeyType
|
|
1324
1276
|
}
|
|
1325
1277
|
),
|
|
1326
|
-
props.queryOptions && /* @__PURE__ */
|
|
1278
|
+
props.queryOptions && /* @__PURE__ */ jsx(
|
|
1327
1279
|
QueryOptions,
|
|
1328
1280
|
{
|
|
1329
1281
|
Template: QueryOptionsTemplate,
|
|
@@ -1334,12 +1286,12 @@ function Query({
|
|
|
1334
1286
|
suspense: props.suspense
|
|
1335
1287
|
}
|
|
1336
1288
|
),
|
|
1337
|
-
props.query && /* @__PURE__ */
|
|
1289
|
+
props.query && /* @__PURE__ */ jsx(
|
|
1338
1290
|
Template6,
|
|
1339
1291
|
{
|
|
1340
1292
|
name: [name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0].filter(Boolean).join(""),
|
|
1341
1293
|
generics: generics.toString(),
|
|
1342
|
-
JSDoc: { comments:
|
|
1294
|
+
JSDoc: { comments: getComments(operation) },
|
|
1343
1295
|
params: params.toString(),
|
|
1344
1296
|
returnType: `${resultType}<${resultGenerics.join(", ")}>`,
|
|
1345
1297
|
hook,
|
|
@@ -1364,19 +1316,19 @@ Query.File = function({ templates }) {
|
|
|
1364
1316
|
parser
|
|
1365
1317
|
}
|
|
1366
1318
|
}
|
|
1367
|
-
} =
|
|
1368
|
-
const { getSchemas, getFile, getName } =
|
|
1369
|
-
const operation =
|
|
1370
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
1371
|
-
const zodSchemas = getSchemas(operation, { pluginKey: [
|
|
1319
|
+
} = useApp();
|
|
1320
|
+
const { getSchemas, getFile, getName } = useOperationManager();
|
|
1321
|
+
const operation = useOperation();
|
|
1322
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
1323
|
+
const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: "function" });
|
|
1372
1324
|
const file = getFile(operation);
|
|
1373
|
-
const fileType = getFile(operation, { pluginKey: [
|
|
1325
|
+
const fileType = getFile(operation, { pluginKey: [pluginTsName] });
|
|
1374
1326
|
const fileZodSchemas = getFile(operation, {
|
|
1375
|
-
pluginKey: [
|
|
1327
|
+
pluginKey: [pluginZodName]
|
|
1376
1328
|
});
|
|
1377
1329
|
const factoryName = getName(operation, { type: "type" });
|
|
1378
1330
|
const importNames = getImportNames();
|
|
1379
|
-
const isV5 = new
|
|
1331
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
1380
1332
|
const Template6 = templates?.query["react"] || defaultTemplates5["react"];
|
|
1381
1333
|
const QueryOptionsTemplate = templates?.queryOptions["react"] || QueryOptions.templates["react"];
|
|
1382
1334
|
const QueryKeyTemplate = templates?.queryKey["react"] || QueryKey.templates["react"];
|
|
@@ -1384,12 +1336,12 @@ Query.File = function({ templates }) {
|
|
|
1384
1336
|
const factory = {
|
|
1385
1337
|
name: factoryName
|
|
1386
1338
|
};
|
|
1387
|
-
return /* @__PURE__ */
|
|
1388
|
-
parser === "zod" && /* @__PURE__ */
|
|
1389
|
-
/* @__PURE__ */
|
|
1390
|
-
/* @__PURE__ */
|
|
1391
|
-
/* @__PURE__ */
|
|
1392
|
-
|
|
1339
|
+
return /* @__PURE__ */ jsxs(File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
1340
|
+
parser === "zod" && /* @__PURE__ */ jsx(File.Import, { name: [zodSchemas.response?.name], root: file.path, path: fileZodSchemas.path }),
|
|
1341
|
+
/* @__PURE__ */ jsx(File.Import, { name: "client", path: importPath }),
|
|
1342
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
|
|
1343
|
+
/* @__PURE__ */ jsx(
|
|
1344
|
+
File.Import,
|
|
1393
1345
|
{
|
|
1394
1346
|
name: [
|
|
1395
1347
|
schemas.request?.name,
|
|
@@ -1404,11 +1356,11 @@ Query.File = function({ templates }) {
|
|
|
1404
1356
|
isTypeOnly: true
|
|
1405
1357
|
}
|
|
1406
1358
|
),
|
|
1407
|
-
/* @__PURE__ */
|
|
1408
|
-
!!infinite && /* @__PURE__ */
|
|
1409
|
-
!!suspense && isV5 && /* @__PURE__ */
|
|
1410
|
-
/* @__PURE__ */
|
|
1411
|
-
/* @__PURE__ */
|
|
1359
|
+
/* @__PURE__ */ jsx(QueryImports, { hookPath: typeof query !== "boolean" ? query.importPath : void 0, Template: Import, isInfinite: false, isSuspense: false }),
|
|
1360
|
+
!!infinite && /* @__PURE__ */ jsx(QueryImports, { hookPath: typeof query !== "boolean" ? query.importPath : void 0, Template: Import, isInfinite: true, isSuspense: false }),
|
|
1361
|
+
!!suspense && isV5 && /* @__PURE__ */ jsx(QueryImports, { hookPath: typeof query !== "boolean" ? query.importPath : void 0, Template: Import, isInfinite: false, isSuspense: true }),
|
|
1362
|
+
/* @__PURE__ */ jsx(SchemaType, {}),
|
|
1363
|
+
/* @__PURE__ */ jsx(
|
|
1412
1364
|
Query,
|
|
1413
1365
|
{
|
|
1414
1366
|
factory,
|
|
@@ -1424,7 +1376,7 @@ Query.File = function({ templates }) {
|
|
|
1424
1376
|
optionsType: importNames.query["react"].optionsType
|
|
1425
1377
|
}
|
|
1426
1378
|
),
|
|
1427
|
-
!!infinite && /* @__PURE__ */
|
|
1379
|
+
!!infinite && /* @__PURE__ */ jsx(
|
|
1428
1380
|
Query,
|
|
1429
1381
|
{
|
|
1430
1382
|
factory,
|
|
@@ -1440,7 +1392,7 @@ Query.File = function({ templates }) {
|
|
|
1440
1392
|
optionsType: importNames.queryInfinite["react"].optionsType
|
|
1441
1393
|
}
|
|
1442
1394
|
),
|
|
1443
|
-
!!suspense && isV5 && /* @__PURE__ */
|
|
1395
|
+
!!suspense && isV5 && /* @__PURE__ */ jsx(
|
|
1444
1396
|
Query,
|
|
1445
1397
|
{
|
|
1446
1398
|
factory,
|
|
@@ -1460,11 +1412,6 @@ Query.File = function({ templates }) {
|
|
|
1460
1412
|
};
|
|
1461
1413
|
Query.templates = defaultTemplates5;
|
|
1462
1414
|
|
|
1463
|
-
export {
|
|
1464
|
-
|
|
1465
|
-
QueryImports,
|
|
1466
|
-
QueryKey,
|
|
1467
|
-
QueryOptions,
|
|
1468
|
-
Query
|
|
1469
|
-
};
|
|
1415
|
+
export { Mutation, Query, QueryImports, QueryKey, QueryOptions };
|
|
1416
|
+
//# sourceMappingURL=chunk-ZYTZV43V.js.map
|
|
1470
1417
|
//# sourceMappingURL=chunk-ZYTZV43V.js.map
|