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