@kubb/plugin-react-query 3.0.0-alpha.1 → 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 +1427 -0
- package/dist/chunk-7ZODZVKP.cjs.map +1 -0
- package/dist/{chunk-5IL6M74X.js → chunk-ZYTZV43V.js} +295 -382
- package/dist/chunk-ZYTZV43V.js.map +1 -0
- package/dist/components.cjs +23 -14
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +1 -2
- package/dist/components.d.ts +1 -2
- package/dist/components.js +2 -14
- package/dist/components.js.map +1 -1
- package/dist/{index-C9fwRDH7.d.cts → index-5kpkk-7M.d.cts} +7 -41
- package/dist/{index-C9fwRDH7.d.ts → index-5kpkk-7M.d.ts} +7 -41
- package/dist/index.cjs +67 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +30 -77
- package/dist/index.js.map +1 -1
- package/package.json +15 -15
- package/src/OperationGenerator.tsx +0 -29
- package/src/__snapshots__/mutateAsQuery/updatePetWithForm.ts +14 -9
- package/src/__snapshots__/pathParamsTypeInline/getPetById.ts +14 -9
- package/src/__snapshots__/pathParamsTypeObject/getPetById.ts +14 -9
- package/src/__snapshots__/queryOptions/getPetById.ts +9 -5
- package/src/__snapshots__/queryWithoutQueryOptions/getPetById.ts +11 -7
- package/src/__snapshots__/variablesTypeMutate/deletePet.ts +6 -3
- package/src/components/Mutation.tsx +30 -30
- package/src/components/Query.tsx +74 -78
- package/src/components/QueryKey.tsx +13 -9
- package/src/components/QueryOptions.tsx +21 -13
- package/src/components/SchemaType.tsx +9 -5
- package/src/components/__snapshots__/gen/showPetById.ts +58 -48
- package/src/components/__snapshots__/gen/useCreatePets.ts +36 -36
- package/src/components/__snapshots__/gen/useCreatePetsMutate.ts +36 -37
- package/src/components/index.ts +0 -1
- package/src/plugin.ts +16 -34
- package/src/types.ts +0 -3
- package/dist/chunk-5IL6M74X.js.map +0 -1
- package/dist/chunk-JFX7DCS7.cjs +0 -1504
- package/dist/chunk-JFX7DCS7.cjs.map +0 -1
- package/src/__snapshots__/upload/UploadFile.ts +0 -67
- package/src/__snapshots__/uploadMutation/UploadFile.ts +0 -44
- package/src/components/Operations.tsx +0 -74
|
@@ -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 { 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: {
|
|
@@ -33,8 +32,8 @@ function SchemaType() {
|
|
|
33
32
|
const clientType = `${factoryName}Client`;
|
|
34
33
|
const isFormData = operation.getContentType() === "multipart/form-data";
|
|
35
34
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
36
|
-
/* @__PURE__ */ jsx(Type, { name: clientType, children: `typeof client<${TResponse}, ${TError}, ${isFormData ? "FormData" : TRequest}>` }),
|
|
37
|
-
/* @__PURE__ */ jsx(Type, { name: factoryName, children: `
|
|
35
|
+
/* @__PURE__ */ jsx(File.Source, { name: clientType, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: clientType, children: `typeof client<${TResponse}, ${TError}, ${isFormData ? "FormData" : TRequest}>` }) }),
|
|
36
|
+
/* @__PURE__ */ jsx(File.Source, { name: factoryName, isTypeOnly: true, children: /* @__PURE__ */ jsx(Type, { name: factoryName, children: `
|
|
38
37
|
{
|
|
39
38
|
data: ${TData}
|
|
40
39
|
error: ${TError}
|
|
@@ -48,13 +47,9 @@ function SchemaType() {
|
|
|
48
47
|
return: Awaited<ReturnType<${clientType}>>
|
|
49
48
|
}
|
|
50
49
|
}
|
|
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}({
|
|
@@ -97,7 +92,7 @@ ${transformers.createIndent(4)}`)}`;
|
|
|
97
92
|
return ${dataReturnType === "data" ? "res.data" : "res"}
|
|
98
93
|
},
|
|
99
94
|
...mutationOptions
|
|
100
|
-
})` });
|
|
95
|
+
})` }) });
|
|
101
96
|
}
|
|
102
97
|
function RootTemplate({ children }) {
|
|
103
98
|
const {
|
|
@@ -107,16 +102,16 @@ 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__ */
|
|
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(
|
|
120
115
|
File.Import,
|
|
121
116
|
{
|
|
122
117
|
name: [
|
|
@@ -132,7 +127,7 @@ function RootTemplate({ children }) {
|
|
|
132
127
|
isTypeOnly: true
|
|
133
128
|
}
|
|
134
129
|
),
|
|
135
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ jsx(
|
|
136
131
|
File.Import,
|
|
137
132
|
{
|
|
138
133
|
name: ["UseMutationOptions", "UseMutationResult"],
|
|
@@ -140,21 +135,21 @@ function RootTemplate({ children }) {
|
|
|
140
135
|
isTypeOnly: true
|
|
141
136
|
}
|
|
142
137
|
),
|
|
143
|
-
/* @__PURE__ */
|
|
144
|
-
|
|
145
|
-
] })
|
|
138
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["useMutation"], path: typeof mutate !== "boolean" && mutate.importPath ? mutate.importPath : "@tanstack/react-query" }),
|
|
139
|
+
children
|
|
140
|
+
] });
|
|
146
141
|
}
|
|
147
142
|
var defaultTemplates = { default: Template, root: RootTemplate };
|
|
148
|
-
function Mutation({ Template:
|
|
143
|
+
function Mutation({ Template: Template6 = defaultTemplates.default }) {
|
|
149
144
|
const {
|
|
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,8 +260,8 @@ function Mutation({ Template: Template7 = defaultTemplates.default }) {
|
|
|
265
260
|
if (!mutate) {
|
|
266
261
|
return null;
|
|
267
262
|
}
|
|
268
|
-
return /* @__PURE__ */
|
|
269
|
-
|
|
263
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
264
|
+
Template6,
|
|
270
265
|
{
|
|
271
266
|
name,
|
|
272
267
|
JSDoc: { comments: getComments(operation) },
|
|
@@ -280,58 +275,14 @@ function Mutation({ Template: Template7 = defaultTemplates.default }) {
|
|
|
280
275
|
}
|
|
281
276
|
Mutation.File = function({ ...props }) {
|
|
282
277
|
const templates = { ...defaultTemplates, ...props.templates };
|
|
283
|
-
const
|
|
284
|
-
const
|
|
285
|
-
return /* @__PURE__ */
|
|
286
|
-
/* @__PURE__ */
|
|
287
|
-
/* @__PURE__ */
|
|
278
|
+
const Template6 = templates.default;
|
|
279
|
+
const RootTemplate2 = templates.root;
|
|
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/Operations.tsx
|
|
293
|
-
import { Parser as Parser2, File as File2, useApp as useApp3 } from "@kubb/react";
|
|
294
|
-
import { jsx as jsx3 } from "@kubb/react/jsx-runtime";
|
|
295
|
-
function Template2({}) {
|
|
296
|
-
return null;
|
|
297
|
-
}
|
|
298
|
-
function RootTemplate2({ children }) {
|
|
299
|
-
const {
|
|
300
|
-
pluginManager,
|
|
301
|
-
plugin: { key: pluginKey }
|
|
302
|
-
} = useApp3();
|
|
303
|
-
const file = pluginManager.getFile({
|
|
304
|
-
name: "operations",
|
|
305
|
-
mode: "split",
|
|
306
|
-
extName: ".ts",
|
|
307
|
-
pluginKey
|
|
308
|
-
});
|
|
309
|
-
return /* @__PURE__ */ jsx3(Parser2, { language: "typescript", children: /* @__PURE__ */ jsx3(File2, { baseName: file.baseName, path: file.path, meta: file.meta, children: /* @__PURE__ */ jsx3(File2.Source, { children }) }) });
|
|
310
|
-
}
|
|
311
|
-
var defaultTemplates2 = { default: Template2, root: RootTemplate2 };
|
|
312
|
-
function Operations({ Template: Template7 = defaultTemplates2.default }) {
|
|
313
|
-
return /* @__PURE__ */ jsx3(Template7, {});
|
|
314
|
-
}
|
|
315
|
-
Operations.File = function(props) {
|
|
316
|
-
const templates = { ...defaultTemplates2, ...props.templates };
|
|
317
|
-
const Template7 = templates.default;
|
|
318
|
-
const RootTemplate3 = templates.root;
|
|
319
|
-
return /* @__PURE__ */ jsx3(RootTemplate3, { children: /* @__PURE__ */ jsx3(Operations, { Template: Template7 }) });
|
|
320
|
-
};
|
|
321
|
-
Operations.templates = defaultTemplates2;
|
|
322
|
-
|
|
323
|
-
// src/components/Query.tsx
|
|
324
|
-
import { PackageManager as PackageManager4 } from "@kubb/core";
|
|
325
|
-
import transformers3 from "@kubb/core/transformers";
|
|
326
|
-
import { FunctionParams as FunctionParams4, URLPath as URLPath4 } from "@kubb/core/utils";
|
|
327
|
-
import { Parser as Parser3, File as File4, Function as Function4, useApp as useApp6 } from "@kubb/react";
|
|
328
|
-
import { pluginTsName as pluginTsName5 } from "@kubb/plugin-ts";
|
|
329
|
-
import { pluginZodName as pluginZodName2 } from "@kubb/plugin-zod";
|
|
330
|
-
import { useOperation as useOperation5, useOperationManager as useOperationManager5 } from "@kubb/plugin-oas/hooks";
|
|
331
|
-
import { getASTParams as getASTParams4, getComments as getComments2 } from "@kubb/plugin-oas/utils";
|
|
332
|
-
|
|
333
|
-
// src/utils.ts
|
|
334
|
-
import { PackageManager } from "@kubb/core";
|
|
335
286
|
var reactQueryDepRegex = /@tanstack\/(react|solid|vue|svelte)-query/;
|
|
336
287
|
function getImportNames() {
|
|
337
288
|
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
@@ -424,27 +375,22 @@ function getImportNames() {
|
|
|
424
375
|
}
|
|
425
376
|
};
|
|
426
377
|
}
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
return /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
434
|
-
/* @__PURE__ */ jsx4(File3.Import, { name: [optionsType, resultType], path, isTypeOnly: true }),
|
|
435
|
-
/* @__PURE__ */ jsx4(File3.Import, { name: [hookName], path: hookPath }),
|
|
436
|
-
queryOptions && /* @__PURE__ */ jsx4(File3.Import, { name: [queryOptions].filter(Boolean), path }),
|
|
437
|
-
/* @__PURE__ */ jsx4(File3.Import, { name: ["QueryKey", "WithRequired", isInfinite ? "InfiniteData" : void 0].filter(Boolean), path, isTypeOnly: true })
|
|
378
|
+
function Template2({ path, hookPath = path, isInfinite, hookName, queryOptions, optionsType, resultType }) {
|
|
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 })
|
|
438
384
|
] });
|
|
439
385
|
}
|
|
440
|
-
var
|
|
386
|
+
var defaultTemplates2 = {
|
|
441
387
|
get react() {
|
|
442
388
|
return function({ context, hookPath, ...rest }) {
|
|
443
389
|
const importNames = getImportNames();
|
|
444
|
-
const isV5 = new
|
|
390
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
445
391
|
const { isInfinite, isSuspense } = context;
|
|
446
|
-
return /* @__PURE__ */
|
|
447
|
-
|
|
392
|
+
return /* @__PURE__ */ jsx(
|
|
393
|
+
Template2,
|
|
448
394
|
{
|
|
449
395
|
isInfinite,
|
|
450
396
|
...isSuspense ? importNames.querySuspense.react : isInfinite ? importNames.queryInfinite.react : importNames.query.react,
|
|
@@ -458,10 +404,10 @@ var defaultTemplates3 = {
|
|
|
458
404
|
get solid() {
|
|
459
405
|
return function({ context, hookPath, ...rest }) {
|
|
460
406
|
const importNames = getImportNames();
|
|
461
|
-
const isV5 = new
|
|
407
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
462
408
|
const { isInfinite } = context;
|
|
463
|
-
return /* @__PURE__ */
|
|
464
|
-
|
|
409
|
+
return /* @__PURE__ */ jsx(
|
|
410
|
+
Template2,
|
|
465
411
|
{
|
|
466
412
|
isInfinite,
|
|
467
413
|
...isInfinite ? importNames.queryInfinite.solid : importNames.query.solid,
|
|
@@ -475,10 +421,10 @@ var defaultTemplates3 = {
|
|
|
475
421
|
get svelte() {
|
|
476
422
|
return function({ context, hookPath, ...rest }) {
|
|
477
423
|
const importNames = getImportNames();
|
|
478
|
-
const isV5 = new
|
|
424
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
479
425
|
const { isInfinite } = context;
|
|
480
|
-
return /* @__PURE__ */
|
|
481
|
-
|
|
426
|
+
return /* @__PURE__ */ jsx(
|
|
427
|
+
Template2,
|
|
482
428
|
{
|
|
483
429
|
isInfinite,
|
|
484
430
|
...isInfinite ? importNames.queryInfinite.svelte : importNames.query.svelte,
|
|
@@ -492,13 +438,13 @@ var defaultTemplates3 = {
|
|
|
492
438
|
get vue() {
|
|
493
439
|
return function({ context, hookPath, ...rest }) {
|
|
494
440
|
const importNames = getImportNames();
|
|
495
|
-
const isV5 = new
|
|
441
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
496
442
|
const { isInfinite } = context;
|
|
497
443
|
const path = "@tanstack/vue-query";
|
|
498
|
-
return /* @__PURE__ */
|
|
499
|
-
isV5 && /* @__PURE__ */
|
|
500
|
-
/* @__PURE__ */
|
|
501
|
-
|
|
444
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
445
|
+
isV5 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
446
|
+
/* @__PURE__ */ jsx(
|
|
447
|
+
Template2,
|
|
502
448
|
{
|
|
503
449
|
isInfinite,
|
|
504
450
|
...isInfinite ? importNames.queryInfinite.vue : importNames.query.vue,
|
|
@@ -507,28 +453,28 @@ var defaultTemplates3 = {
|
|
|
507
453
|
...rest
|
|
508
454
|
}
|
|
509
455
|
),
|
|
510
|
-
/* @__PURE__ */
|
|
456
|
+
/* @__PURE__ */ jsx(File.Import, { name: ["QueryObserverOptions"], path, isTypeOnly: true })
|
|
511
457
|
] }),
|
|
512
|
-
!isV5 && isInfinite && /* @__PURE__ */
|
|
513
|
-
/* @__PURE__ */
|
|
514
|
-
/* @__PURE__ */
|
|
515
|
-
/* @__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 })
|
|
516
462
|
] }),
|
|
517
|
-
!isV5 && !isInfinite && /* @__PURE__ */
|
|
518
|
-
/* @__PURE__ */
|
|
519
|
-
/* @__PURE__ */
|
|
520
|
-
/* @__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 })
|
|
521
467
|
] }),
|
|
522
|
-
/* @__PURE__ */
|
|
523
|
-
/* @__PURE__ */
|
|
524
|
-
/* @__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 })
|
|
525
471
|
] });
|
|
526
472
|
};
|
|
527
473
|
}
|
|
528
474
|
};
|
|
529
|
-
function QueryImports({ hookPath, isInfinite, isSuspense, Template:
|
|
530
|
-
return /* @__PURE__ */
|
|
531
|
-
|
|
475
|
+
function QueryImports({ hookPath, isInfinite, isSuspense, Template: Template6 = defaultTemplates2.react }) {
|
|
476
|
+
return /* @__PURE__ */ jsx(
|
|
477
|
+
Template6,
|
|
532
478
|
{
|
|
533
479
|
hookPath,
|
|
534
480
|
context: {
|
|
@@ -538,36 +484,27 @@ function QueryImports({ hookPath, isInfinite, isSuspense, Template: Template7 =
|
|
|
538
484
|
}
|
|
539
485
|
);
|
|
540
486
|
}
|
|
541
|
-
QueryImports.templates =
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
import { useOperation as useOperation3, useOperationManager as useOperationManager3 } from "@kubb/plugin-oas/hooks";
|
|
547
|
-
import { getASTParams as getASTParams2 } from "@kubb/plugin-oas/utils";
|
|
548
|
-
import { isRequired as isRequired2 } from "@kubb/oas";
|
|
549
|
-
import { pluginTsName as pluginTsName3 } from "@kubb/plugin-ts";
|
|
550
|
-
import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs4 } from "@kubb/react/jsx-runtime";
|
|
551
|
-
function Template4({ name, typeName, params, generics, returnType, JSDoc, keys }) {
|
|
552
|
-
return /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
553
|
-
/* @__PURE__ */ jsx5(Function2.Arrow, { name, export: true, generics, params, returnType, singleLine: true, JSDoc, children: `[${keys}] as const` }),
|
|
554
|
-
/* @__PURE__ */ jsx5(Type2, { name: typeName, export: true, children: `ReturnType<typeof ${name}>` })
|
|
487
|
+
QueryImports.templates = defaultTemplates2;
|
|
488
|
+
function Template3({ name, typeName, params, generics, returnType, JSDoc, keys }) {
|
|
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}>` }) })
|
|
555
492
|
] });
|
|
556
493
|
}
|
|
557
|
-
var
|
|
494
|
+
var defaultTemplates3 = {
|
|
558
495
|
get react() {
|
|
559
496
|
return function(props) {
|
|
560
|
-
return /* @__PURE__ */
|
|
497
|
+
return /* @__PURE__ */ jsx(Template3, { ...props });
|
|
561
498
|
};
|
|
562
499
|
},
|
|
563
500
|
get solid() {
|
|
564
501
|
return function(props) {
|
|
565
|
-
return /* @__PURE__ */
|
|
502
|
+
return /* @__PURE__ */ jsx(Template3, { ...props });
|
|
566
503
|
};
|
|
567
504
|
},
|
|
568
505
|
get svelte() {
|
|
569
506
|
return function(props) {
|
|
570
|
-
return /* @__PURE__ */
|
|
507
|
+
return /* @__PURE__ */ jsx(Template3, { ...props });
|
|
571
508
|
};
|
|
572
509
|
},
|
|
573
510
|
get vue() {
|
|
@@ -577,24 +514,24 @@ var defaultTemplates4 = {
|
|
|
577
514
|
plugin: {
|
|
578
515
|
options: { pathParamsType, query }
|
|
579
516
|
}
|
|
580
|
-
} =
|
|
581
|
-
const { getSchemas } =
|
|
582
|
-
const operation =
|
|
583
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
584
|
-
const path = new
|
|
585
|
-
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();
|
|
586
523
|
const withQueryParams = !!schemas.queryParams?.name;
|
|
587
524
|
const withRequest = !!schemas.request?.name;
|
|
588
525
|
params.add([
|
|
589
526
|
...pathParamsType === "object" ? [
|
|
590
|
-
|
|
527
|
+
getASTParams(schemas.pathParams, {
|
|
591
528
|
typed: true,
|
|
592
529
|
override: (item) => ({
|
|
593
530
|
...item,
|
|
594
531
|
type: `MaybeRef<${item.type}>`
|
|
595
532
|
})
|
|
596
533
|
})
|
|
597
|
-
] :
|
|
534
|
+
] : getASTParams(schemas.pathParams, {
|
|
598
535
|
typed: true,
|
|
599
536
|
override: (item) => ({
|
|
600
537
|
...item,
|
|
@@ -605,13 +542,13 @@ var defaultTemplates4 = {
|
|
|
605
542
|
name: "params",
|
|
606
543
|
type: `MaybeRef<${`${factory.name}["queryParams"]`}>`,
|
|
607
544
|
enabled: withQueryParams,
|
|
608
|
-
required:
|
|
545
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
609
546
|
},
|
|
610
547
|
{
|
|
611
548
|
name: "request",
|
|
612
549
|
type: `MaybeRef<${`${factory.name}["request"]`}>`,
|
|
613
550
|
enabled: withRequest,
|
|
614
|
-
required:
|
|
551
|
+
required: isRequired(schemas.request?.schema)
|
|
615
552
|
}
|
|
616
553
|
]);
|
|
617
554
|
const keys = [
|
|
@@ -623,36 +560,36 @@ var defaultTemplates4 = {
|
|
|
623
560
|
withQueryParams ? "...(params ? [params] : [])" : void 0,
|
|
624
561
|
withRequest ? "...(request ? [request] : [])" : void 0
|
|
625
562
|
].filter(Boolean);
|
|
626
|
-
return /* @__PURE__ */
|
|
563
|
+
return /* @__PURE__ */ jsx(Template3, { ...rest, params: params.toString(), keys: keys.join(", ") });
|
|
627
564
|
};
|
|
628
565
|
}
|
|
629
566
|
};
|
|
630
|
-
function QueryKey({ name, typeName, factory, keysFn, Template:
|
|
567
|
+
function QueryKey({ name, typeName, factory, keysFn, Template: Template6 = defaultTemplates3.react }) {
|
|
631
568
|
const {
|
|
632
569
|
plugin: {
|
|
633
570
|
options: { pathParamsType }
|
|
634
571
|
}
|
|
635
|
-
} =
|
|
636
|
-
const { getSchemas } =
|
|
637
|
-
const operation =
|
|
638
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
639
|
-
const path = new
|
|
640
|
-
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();
|
|
641
578
|
const withQueryParams = !!schemas.queryParams?.name;
|
|
642
579
|
const withRequest = !!schemas.request?.name;
|
|
643
580
|
params.add([
|
|
644
|
-
...pathParamsType === "object" ? [
|
|
581
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams, { typed: true })] : getASTParams(schemas.pathParams, { typed: true }),
|
|
645
582
|
{
|
|
646
583
|
name: "params",
|
|
647
584
|
type: `${factory.name}["queryParams"]`,
|
|
648
585
|
enabled: withQueryParams,
|
|
649
|
-
required:
|
|
586
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
650
587
|
},
|
|
651
588
|
{
|
|
652
589
|
name: "data",
|
|
653
590
|
type: `${factory.name}["request"]`,
|
|
654
591
|
enabled: withRequest,
|
|
655
|
-
required:
|
|
592
|
+
required: isRequired(schemas.request?.schema)
|
|
656
593
|
}
|
|
657
594
|
]);
|
|
658
595
|
const keys = [
|
|
@@ -663,23 +600,11 @@ function QueryKey({ name, typeName, factory, keysFn, Template: Template7 = defau
|
|
|
663
600
|
withQueryParams ? "...(params ? [params] : [])" : void 0,
|
|
664
601
|
withRequest ? "...(data ? [data] : [])" : void 0
|
|
665
602
|
].filter(Boolean);
|
|
666
|
-
return /* @__PURE__ */
|
|
603
|
+
return /* @__PURE__ */ jsx(Template6, { typeName, name, params: params.toString(), keys: keysFn(keys).join(", "), context: { factory } });
|
|
667
604
|
}
|
|
668
|
-
QueryKey.templates =
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
import { PackageManager as PackageManager3 } from "@kubb/core";
|
|
672
|
-
import transformers2 from "@kubb/core/transformers";
|
|
673
|
-
import { FunctionParams as FunctionParams3, URLPath as URLPath3 } from "@kubb/core/utils";
|
|
674
|
-
import { useOperation as useOperation4, useOperationManager as useOperationManager4 } from "@kubb/plugin-oas/hooks";
|
|
675
|
-
import { getASTParams as getASTParams3 } from "@kubb/plugin-oas/utils";
|
|
676
|
-
import { Function as Function3, useApp as useApp5 } from "@kubb/react";
|
|
677
|
-
import { pluginZodName } from "@kubb/plugin-zod";
|
|
678
|
-
import { isRequired as isRequired3 } from "@kubb/oas";
|
|
679
|
-
import { pluginTsName as pluginTsName4 } from "@kubb/plugin-ts";
|
|
680
|
-
import { jsx as jsx6 } from "@kubb/react/jsx-runtime";
|
|
681
|
-
function Template5({ name, params, generics, returnType, JSDoc, hook, client, infinite, dataReturnType, parser }) {
|
|
682
|
-
const isV5 = new PackageManager3().isValidSync(reactQueryDepRegex, ">=5");
|
|
605
|
+
QueryKey.templates = defaultTemplates3;
|
|
606
|
+
function Template4({ name, params, generics, returnType, JSDoc, hook, client, infinite, dataReturnType, parser }) {
|
|
607
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
683
608
|
const isFormData = client.contentType === "multipart/form-data";
|
|
684
609
|
const headers = [
|
|
685
610
|
client.contentType !== "application/json" ? `'Content-Type': '${client.contentType}'` : void 0,
|
|
@@ -728,7 +653,7 @@ ${transformers2.createIndent(4)}`)}`;
|
|
|
728
653
|
` : void 0;
|
|
729
654
|
if (infinite) {
|
|
730
655
|
if (isV5) {
|
|
731
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, params, JSDoc, children: `
|
|
732
657
|
const queryKey = ${hook.queryKey}
|
|
733
658
|
|
|
734
659
|
return infiniteQueryOptions({
|
|
@@ -745,9 +670,9 @@ ${transformers2.createIndent(4)}`)}`;
|
|
|
745
670
|
${resolvedQueryOptions}
|
|
746
671
|
})
|
|
747
672
|
|
|
748
|
-
` });
|
|
673
|
+
` }) });
|
|
749
674
|
}
|
|
750
|
-
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: `
|
|
751
676
|
const queryKey = ${hook.queryKey}
|
|
752
677
|
|
|
753
678
|
return {
|
|
@@ -764,10 +689,10 @@ ${transformers2.createIndent(4)}`)}`;
|
|
|
764
689
|
${resolvedQueryOptions}
|
|
765
690
|
}
|
|
766
691
|
|
|
767
|
-
` });
|
|
692
|
+
` }) });
|
|
768
693
|
}
|
|
769
694
|
if (isV5) {
|
|
770
|
-
return /* @__PURE__ */
|
|
695
|
+
return /* @__PURE__ */ jsx(File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsx(Function, { name, export: true, params, JSDoc, children: `
|
|
771
696
|
const queryKey = ${hook.queryKey}
|
|
772
697
|
|
|
773
698
|
return queryOptions({
|
|
@@ -784,9 +709,9 @@ ${transformers2.createIndent(4)}`)}`;
|
|
|
784
709
|
${resolvedQueryOptions}
|
|
785
710
|
})
|
|
786
711
|
|
|
787
|
-
` });
|
|
712
|
+
` }) });
|
|
788
713
|
}
|
|
789
|
-
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: `
|
|
790
715
|
const queryKey = ${hook.queryKey}
|
|
791
716
|
|
|
792
717
|
return {
|
|
@@ -803,22 +728,22 @@ ${transformers2.createIndent(4)}`)}`;
|
|
|
803
728
|
${resolvedQueryOptions}
|
|
804
729
|
}
|
|
805
730
|
|
|
806
|
-
` });
|
|
731
|
+
` }) });
|
|
807
732
|
}
|
|
808
|
-
var
|
|
733
|
+
var defaultTemplates4 = {
|
|
809
734
|
get react() {
|
|
810
735
|
return function(props) {
|
|
811
|
-
return /* @__PURE__ */
|
|
736
|
+
return /* @__PURE__ */ jsx(Template4, { ...props });
|
|
812
737
|
};
|
|
813
738
|
},
|
|
814
739
|
get solid() {
|
|
815
740
|
return function(props) {
|
|
816
|
-
return /* @__PURE__ */
|
|
741
|
+
return /* @__PURE__ */ jsx(Template4, { ...props });
|
|
817
742
|
};
|
|
818
743
|
},
|
|
819
744
|
get svelte() {
|
|
820
745
|
return function(props) {
|
|
821
|
-
return /* @__PURE__ */
|
|
746
|
+
return /* @__PURE__ */ jsx(Template4, { ...props });
|
|
822
747
|
};
|
|
823
748
|
},
|
|
824
749
|
get vue() {
|
|
@@ -828,15 +753,15 @@ var defaultTemplates5 = {
|
|
|
828
753
|
plugin: {
|
|
829
754
|
options: { pathParamsType }
|
|
830
755
|
}
|
|
831
|
-
} =
|
|
832
|
-
const { getSchemas } =
|
|
833
|
-
const operation =
|
|
834
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
835
|
-
const params = new
|
|
836
|
-
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();
|
|
837
762
|
params.add([
|
|
838
763
|
...pathParamsType === "object" ? [
|
|
839
|
-
|
|
764
|
+
getASTParams(schemas.pathParams, {
|
|
840
765
|
typed: true,
|
|
841
766
|
override: (item) => ({
|
|
842
767
|
...item,
|
|
@@ -844,7 +769,7 @@ var defaultTemplates5 = {
|
|
|
844
769
|
type: `MaybeRef<${item.type}>`
|
|
845
770
|
})
|
|
846
771
|
})
|
|
847
|
-
] :
|
|
772
|
+
] : getASTParams(schemas.pathParams, {
|
|
848
773
|
typed: true,
|
|
849
774
|
override: (item) => ({
|
|
850
775
|
...item,
|
|
@@ -856,19 +781,19 @@ var defaultTemplates5 = {
|
|
|
856
781
|
name: "refParams",
|
|
857
782
|
type: `MaybeRef<${schemas.queryParams?.name}>`,
|
|
858
783
|
enabled: client.withQueryParams,
|
|
859
|
-
required:
|
|
784
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
860
785
|
},
|
|
861
786
|
{
|
|
862
787
|
name: "refHeaders",
|
|
863
788
|
type: `MaybeRef<${schemas.headerParams?.name}>`,
|
|
864
789
|
enabled: client.withHeaders,
|
|
865
|
-
required:
|
|
790
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
866
791
|
},
|
|
867
792
|
{
|
|
868
793
|
name: "refData",
|
|
869
794
|
type: `MaybeRef<${schemas.request?.name}>`,
|
|
870
795
|
enabled: client.withData,
|
|
871
|
-
required:
|
|
796
|
+
required: isRequired(schemas.request?.schema)
|
|
872
797
|
},
|
|
873
798
|
{
|
|
874
799
|
name: "options",
|
|
@@ -878,13 +803,13 @@ var defaultTemplates5 = {
|
|
|
878
803
|
]);
|
|
879
804
|
queryKeyParams.add([
|
|
880
805
|
...pathParamsType === "object" ? [
|
|
881
|
-
|
|
806
|
+
getASTParams(schemas.pathParams, {
|
|
882
807
|
override: (item) => ({
|
|
883
808
|
...item,
|
|
884
809
|
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
885
810
|
})
|
|
886
811
|
})
|
|
887
|
-
] :
|
|
812
|
+
] : getASTParams(schemas.pathParams, {
|
|
888
813
|
override: (item) => ({
|
|
889
814
|
...item,
|
|
890
815
|
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
@@ -893,12 +818,12 @@ var defaultTemplates5 = {
|
|
|
893
818
|
{
|
|
894
819
|
name: "refParams",
|
|
895
820
|
enabled: client.withQueryParams,
|
|
896
|
-
required:
|
|
821
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
897
822
|
},
|
|
898
823
|
{
|
|
899
824
|
name: "refData",
|
|
900
825
|
enabled: client.withData,
|
|
901
|
-
required:
|
|
826
|
+
required: isRequired(schemas.request?.schema)
|
|
902
827
|
}
|
|
903
828
|
]);
|
|
904
829
|
const unrefs = params.items.filter((item) => item.enabled).map((item) => {
|
|
@@ -908,22 +833,22 @@ var defaultTemplates5 = {
|
|
|
908
833
|
queryKey: `${queryKey}(${queryKeyParams.toString()})`,
|
|
909
834
|
children: unrefs
|
|
910
835
|
};
|
|
911
|
-
return /* @__PURE__ */
|
|
836
|
+
return /* @__PURE__ */ jsx(Template4, { ...rest, params: params.toString(), hook, client });
|
|
912
837
|
};
|
|
913
838
|
}
|
|
914
839
|
};
|
|
915
|
-
function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType, Template:
|
|
840
|
+
function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType, Template: Template6 = defaultTemplates4.react }) {
|
|
916
841
|
const {
|
|
917
842
|
pluginManager,
|
|
918
843
|
plugin: {
|
|
919
844
|
key: pluginKey,
|
|
920
845
|
options: { parser, pathParamsType, queryOptions }
|
|
921
846
|
}
|
|
922
|
-
} =
|
|
923
|
-
const { getSchemas } =
|
|
924
|
-
const operation =
|
|
847
|
+
} = useApp();
|
|
848
|
+
const { getSchemas } = useOperationManager();
|
|
849
|
+
const operation = useOperation();
|
|
925
850
|
const contentType = operation.getContentType();
|
|
926
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
851
|
+
const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: "type" });
|
|
927
852
|
const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: "function" });
|
|
928
853
|
const queryKey = pluginManager.resolveName({
|
|
929
854
|
name: [factory.name, infinite ? "Infinite" : void 0, suspense ? "Suspense" : void 0, "QueryKey"].filter(Boolean).join(""),
|
|
@@ -933,9 +858,9 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
933
858
|
name: [factory.name, infinite ? "Infinite" : void 0, suspense ? "Suspense" : void 0, "QueryOptions"].filter(Boolean).join(""),
|
|
934
859
|
pluginKey
|
|
935
860
|
});
|
|
936
|
-
const generics = new
|
|
937
|
-
const params = new
|
|
938
|
-
const queryKeyParams = new
|
|
861
|
+
const generics = new FunctionParams();
|
|
862
|
+
const params = new FunctionParams();
|
|
863
|
+
const queryKeyParams = new FunctionParams();
|
|
939
864
|
const clientGenerics = [`${factory.name}['data']`, `${factory.name}['error']`];
|
|
940
865
|
const resultGenerics = suspense ? [`${factory.name}['response']`, `${factory.name}["error"]`, "TData"] : [`${factory.name}['response']`, `${factory.name}["error"]`, "TData", "TQueryData"];
|
|
941
866
|
const client = {
|
|
@@ -944,7 +869,7 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
944
869
|
withPathParams: !!schemas.pathParams?.name,
|
|
945
870
|
withHeaders: !!schemas.headerParams?.name,
|
|
946
871
|
method: operation.method,
|
|
947
|
-
path: new
|
|
872
|
+
path: new URLPath(operation.path),
|
|
948
873
|
generics: clientGenerics.toString(),
|
|
949
874
|
contentType
|
|
950
875
|
};
|
|
@@ -953,24 +878,24 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
953
878
|
suspense ? void 0 : { type: "TQueryData", default: `${factory.name}["response"]` }
|
|
954
879
|
]);
|
|
955
880
|
params.add([
|
|
956
|
-
...pathParamsType === "object" ? [
|
|
881
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams, { typed: true })] : getASTParams(schemas.pathParams, { typed: true }),
|
|
957
882
|
{
|
|
958
883
|
name: "params",
|
|
959
884
|
type: `${factory.name}['queryParams']`,
|
|
960
885
|
enabled: client.withQueryParams,
|
|
961
|
-
required:
|
|
886
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
962
887
|
},
|
|
963
888
|
{
|
|
964
889
|
name: "headers",
|
|
965
890
|
type: `${factory.name}['headerParams']`,
|
|
966
891
|
enabled: client.withHeaders,
|
|
967
|
-
required:
|
|
892
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
968
893
|
},
|
|
969
894
|
{
|
|
970
895
|
name: "data",
|
|
971
896
|
type: `${factory.name}['request']`,
|
|
972
897
|
enabled: client.withData,
|
|
973
|
-
required:
|
|
898
|
+
required: isRequired(schemas.request?.schema)
|
|
974
899
|
},
|
|
975
900
|
{
|
|
976
901
|
name: "options",
|
|
@@ -979,16 +904,16 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
979
904
|
}
|
|
980
905
|
]);
|
|
981
906
|
queryKeyParams.add([
|
|
982
|
-
...pathParamsType === "object" ? [
|
|
907
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams)] : getASTParams(schemas.pathParams),
|
|
983
908
|
{
|
|
984
909
|
name: "params",
|
|
985
910
|
enabled: client.withQueryParams,
|
|
986
|
-
required:
|
|
911
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
987
912
|
},
|
|
988
913
|
{
|
|
989
914
|
name: "data",
|
|
990
915
|
enabled: client.withData,
|
|
991
|
-
required:
|
|
916
|
+
required: isRequired(schemas.request?.schema)
|
|
992
917
|
}
|
|
993
918
|
]);
|
|
994
919
|
const hook = {
|
|
@@ -997,8 +922,8 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
997
922
|
if (!queryOptions) {
|
|
998
923
|
return null;
|
|
999
924
|
}
|
|
1000
|
-
return /* @__PURE__ */
|
|
1001
|
-
|
|
925
|
+
return /* @__PURE__ */ jsx(
|
|
926
|
+
Template6,
|
|
1002
927
|
{
|
|
1003
928
|
name: queryOptionsName,
|
|
1004
929
|
params: params.toString(),
|
|
@@ -1016,16 +941,12 @@ function QueryOptions({ factory, infinite, suspense, resultType, dataReturnType,
|
|
|
1016
941
|
}
|
|
1017
942
|
);
|
|
1018
943
|
}
|
|
1019
|
-
QueryOptions.templates =
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
import { isRequired as isRequired4 } from "@kubb/oas";
|
|
1023
|
-
import { Fragment as Fragment5, jsx as jsx7, jsxs as jsxs5 } from "@kubb/react/jsx-runtime";
|
|
1024
|
-
function Template6({ name, generics, returnType, params, JSDoc, hook, infinite }) {
|
|
1025
|
-
const isV5 = new PackageManager4().isValidSync(reactQueryDepRegex, ">=5");
|
|
944
|
+
QueryOptions.templates = defaultTemplates4;
|
|
945
|
+
function Template5({ name, generics, returnType, params, JSDoc, hook, infinite }) {
|
|
946
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
1026
947
|
const resolvedReturnType = `${returnType} & { queryKey: TQueryKey }`;
|
|
1027
948
|
if (isV5) {
|
|
1028
|
-
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: `
|
|
1029
950
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
|
|
1030
951
|
const queryKey = queryOptions?.queryKey ?? ${hook.queryKey}
|
|
1031
952
|
|
|
@@ -1041,7 +962,7 @@ function Template6({ name, generics, returnType, params, JSDoc, hook, infinite }
|
|
|
1041
962
|
|
|
1042
963
|
` }) });
|
|
1043
964
|
}
|
|
1044
|
-
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: `
|
|
1045
966
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
|
|
1046
967
|
const queryKey = queryOptions?.queryKey ?? ${hook.queryKey}
|
|
1047
968
|
|
|
@@ -1057,20 +978,20 @@ function Template6({ name, generics, returnType, params, JSDoc, hook, infinite }
|
|
|
1057
978
|
|
|
1058
979
|
` }) });
|
|
1059
980
|
}
|
|
1060
|
-
var
|
|
981
|
+
var defaultTemplates5 = {
|
|
1061
982
|
get react() {
|
|
1062
983
|
return function(props) {
|
|
1063
|
-
return /* @__PURE__ */
|
|
984
|
+
return /* @__PURE__ */ jsx(Template5, { ...props });
|
|
1064
985
|
};
|
|
1065
986
|
},
|
|
1066
987
|
get solid() {
|
|
1067
988
|
return function(props) {
|
|
1068
|
-
return /* @__PURE__ */
|
|
989
|
+
return /* @__PURE__ */ jsx(Template5, { ...props });
|
|
1069
990
|
};
|
|
1070
991
|
},
|
|
1071
992
|
get svelte() {
|
|
1072
993
|
return function(props) {
|
|
1073
|
-
return /* @__PURE__ */
|
|
994
|
+
return /* @__PURE__ */ jsx(Template5, { ...props });
|
|
1074
995
|
};
|
|
1075
996
|
},
|
|
1076
997
|
get vue() {
|
|
@@ -1082,9 +1003,9 @@ var defaultTemplates6 = {
|
|
|
1082
1003
|
key: pluginKey,
|
|
1083
1004
|
options: { pathParamsType }
|
|
1084
1005
|
}
|
|
1085
|
-
} =
|
|
1086
|
-
const operation =
|
|
1087
|
-
const { getSchemas } =
|
|
1006
|
+
} = useApp();
|
|
1007
|
+
const operation = useOperation();
|
|
1008
|
+
const { getSchemas } = useOperationManager();
|
|
1088
1009
|
const importNames = getImportNames();
|
|
1089
1010
|
const queryOptions = pluginManager.resolveName({
|
|
1090
1011
|
name: `${factory.name}QueryOptions`,
|
|
@@ -1093,11 +1014,11 @@ var defaultTemplates6 = {
|
|
|
1093
1014
|
const hookName = rest.infinite ? importNames.queryInfinite.vue.hookName : importNames.query.vue.hookName;
|
|
1094
1015
|
const resultType = rest.infinite ? importNames.queryInfinite.vue.resultType : importNames.query.vue.resultType;
|
|
1095
1016
|
const optionsType = rest.infinite ? importNames.queryInfinite.vue.optionsType : importNames.query.vue.optionsType;
|
|
1096
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
1097
|
-
const isV5 = new
|
|
1098
|
-
const params = new
|
|
1099
|
-
const queryParams = new
|
|
1100
|
-
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();
|
|
1101
1022
|
const client = {
|
|
1102
1023
|
withQueryParams: !!schemas.queryParams?.name,
|
|
1103
1024
|
withData: !!schemas.request?.name,
|
|
@@ -1109,37 +1030,37 @@ var defaultTemplates6 = {
|
|
|
1109
1030
|
const queryOptionsGenerics = ["TData", "TQueryData"];
|
|
1110
1031
|
params.add([
|
|
1111
1032
|
...pathParamsType === "object" ? [
|
|
1112
|
-
|
|
1033
|
+
getASTParams(schemas.pathParams, {
|
|
1113
1034
|
typed: true,
|
|
1114
1035
|
override: (item) => ({
|
|
1115
1036
|
...item,
|
|
1116
|
-
name: item.name ? `ref${
|
|
1037
|
+
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
1117
1038
|
})
|
|
1118
1039
|
})
|
|
1119
|
-
] :
|
|
1040
|
+
] : getASTParams(schemas.pathParams, {
|
|
1120
1041
|
typed: true,
|
|
1121
1042
|
override: (item) => ({
|
|
1122
1043
|
...item,
|
|
1123
|
-
name: item.name ? `ref${
|
|
1044
|
+
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
1124
1045
|
})
|
|
1125
1046
|
}),
|
|
1126
1047
|
{
|
|
1127
1048
|
name: "refParams",
|
|
1128
1049
|
type: `MaybeRef<${schemas.queryParams?.name}>`,
|
|
1129
1050
|
enabled: client.withQueryParams,
|
|
1130
|
-
required:
|
|
1051
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1131
1052
|
},
|
|
1132
1053
|
{
|
|
1133
1054
|
name: "refHeaders",
|
|
1134
1055
|
type: `MaybeRef<${schemas.headerParams?.name}>`,
|
|
1135
1056
|
enabled: client.withHeaders,
|
|
1136
|
-
required:
|
|
1057
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
1137
1058
|
},
|
|
1138
1059
|
{
|
|
1139
1060
|
name: "refData",
|
|
1140
1061
|
type: `MaybeRef<${schemas.request?.name}>`,
|
|
1141
1062
|
enabled: client.withData,
|
|
1142
|
-
required:
|
|
1063
|
+
required: isRequired(schemas.request?.schema)
|
|
1143
1064
|
},
|
|
1144
1065
|
{
|
|
1145
1066
|
name: "options",
|
|
@@ -1151,22 +1072,22 @@ var defaultTemplates6 = {
|
|
|
1151
1072
|
}
|
|
1152
1073
|
]);
|
|
1153
1074
|
queryParams.add([
|
|
1154
|
-
...
|
|
1075
|
+
...getASTParams(schemas.pathParams, {
|
|
1155
1076
|
typed: false,
|
|
1156
1077
|
override: (item) => ({
|
|
1157
1078
|
...item,
|
|
1158
|
-
name: item.name ? `ref${
|
|
1079
|
+
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
1159
1080
|
})
|
|
1160
1081
|
}),
|
|
1161
1082
|
{
|
|
1162
1083
|
name: "refParams",
|
|
1163
1084
|
enabled: client.withQueryParams,
|
|
1164
|
-
required:
|
|
1085
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1165
1086
|
},
|
|
1166
1087
|
{
|
|
1167
1088
|
name: "refHeaders",
|
|
1168
1089
|
enabled: client.withHeaders,
|
|
1169
|
-
required:
|
|
1090
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
1170
1091
|
},
|
|
1171
1092
|
{
|
|
1172
1093
|
name: "clientOptions",
|
|
@@ -1175,31 +1096,31 @@ var defaultTemplates6 = {
|
|
|
1175
1096
|
]);
|
|
1176
1097
|
queryKeyParams.add([
|
|
1177
1098
|
...pathParamsType === "object" ? [
|
|
1178
|
-
|
|
1099
|
+
getASTParams(schemas.pathParams, {
|
|
1179
1100
|
override: (item) => ({
|
|
1180
1101
|
...item,
|
|
1181
|
-
name: item.name ? `ref${
|
|
1102
|
+
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
1182
1103
|
})
|
|
1183
1104
|
})
|
|
1184
|
-
] :
|
|
1105
|
+
] : getASTParams(schemas.pathParams, {
|
|
1185
1106
|
override: (item) => ({
|
|
1186
1107
|
...item,
|
|
1187
|
-
name: item.name ? `ref${
|
|
1108
|
+
name: item.name ? `ref${transformers2.pascalCase(item.name)}` : void 0
|
|
1188
1109
|
})
|
|
1189
1110
|
}),
|
|
1190
1111
|
{
|
|
1191
1112
|
name: "refParams",
|
|
1192
1113
|
enabled: client.withQueryParams,
|
|
1193
|
-
required:
|
|
1114
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1194
1115
|
},
|
|
1195
1116
|
{
|
|
1196
1117
|
name: "refData",
|
|
1197
1118
|
enabled: client.withData,
|
|
1198
|
-
required:
|
|
1119
|
+
required: isRequired(schemas.request?.schema)
|
|
1199
1120
|
}
|
|
1200
1121
|
]);
|
|
1201
|
-
return /* @__PURE__ */
|
|
1202
|
-
|
|
1122
|
+
return /* @__PURE__ */ jsx(
|
|
1123
|
+
Template5,
|
|
1203
1124
|
{
|
|
1204
1125
|
...rest,
|
|
1205
1126
|
params: params.toString(),
|
|
@@ -1220,7 +1141,7 @@ function Query({
|
|
|
1220
1141
|
optionsType,
|
|
1221
1142
|
hookName,
|
|
1222
1143
|
resultType,
|
|
1223
|
-
Template:
|
|
1144
|
+
Template: Template6 = defaultTemplates5.react,
|
|
1224
1145
|
QueryKeyTemplate = QueryKey.templates.react,
|
|
1225
1146
|
QueryOptionsTemplate = QueryOptions.templates.react,
|
|
1226
1147
|
...props
|
|
@@ -1231,12 +1152,12 @@ function Query({
|
|
|
1231
1152
|
key: pluginKey,
|
|
1232
1153
|
options: { dataReturnType, pathParamsType }
|
|
1233
1154
|
}
|
|
1234
|
-
} =
|
|
1235
|
-
const operation =
|
|
1236
|
-
const { getSchemas, getName } =
|
|
1237
|
-
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" });
|
|
1238
1159
|
const name = getName(operation, { type: "function" });
|
|
1239
|
-
const isV5 = new
|
|
1160
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
1240
1161
|
const queryKey = pluginManager.resolveName({
|
|
1241
1162
|
name: [factory.name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0, "QueryKey"].filter(Boolean).join(""),
|
|
1242
1163
|
pluginKey
|
|
@@ -1250,13 +1171,13 @@ function Query({
|
|
|
1250
1171
|
name: [factory.name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0, "QueryOptions"].filter(Boolean).join(""),
|
|
1251
1172
|
pluginKey
|
|
1252
1173
|
});
|
|
1253
|
-
const generics = new
|
|
1254
|
-
const params = new
|
|
1255
|
-
const queryParams = new
|
|
1256
|
-
const queryKeyParams = new
|
|
1174
|
+
const generics = new FunctionParams();
|
|
1175
|
+
const params = new FunctionParams();
|
|
1176
|
+
const queryParams = new FunctionParams();
|
|
1177
|
+
const queryKeyParams = new FunctionParams();
|
|
1257
1178
|
const client = {
|
|
1258
1179
|
method: operation.method,
|
|
1259
|
-
path: new
|
|
1180
|
+
path: new URLPath(operation.path),
|
|
1260
1181
|
withQueryParams: !!schemas.queryParams?.name,
|
|
1261
1182
|
withData: !!schemas.request?.name,
|
|
1262
1183
|
withPathParams: !!schemas.pathParams?.name,
|
|
@@ -1274,24 +1195,24 @@ function Query({
|
|
|
1274
1195
|
const queryOptionsOverrideGenerics = props.suspense ? [`${factory.name}['response']`, `${factory.name}['error']`, "TData", "TQueryKey"] : [`${factory.name}['response']`, `${factory.name}['error']`, "TData", "TQueryData", "TQueryKey"];
|
|
1275
1196
|
const queryOptionsGenerics = props.suspense ? ["TData"] : ["TData", "TQueryData"];
|
|
1276
1197
|
params.add([
|
|
1277
|
-
...pathParamsType === "object" ? [
|
|
1198
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams, { typed: true })] : getASTParams(schemas.pathParams, { typed: true }),
|
|
1278
1199
|
{
|
|
1279
1200
|
name: "params",
|
|
1280
1201
|
type: `${factory.name}['queryParams']`,
|
|
1281
1202
|
enabled: client.withQueryParams,
|
|
1282
|
-
required:
|
|
1203
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1283
1204
|
},
|
|
1284
1205
|
{
|
|
1285
1206
|
name: "headers",
|
|
1286
1207
|
type: `${factory.name}['headerParams']`,
|
|
1287
1208
|
enabled: client.withHeaders,
|
|
1288
|
-
required:
|
|
1209
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
1289
1210
|
},
|
|
1290
1211
|
{
|
|
1291
1212
|
name: "data",
|
|
1292
1213
|
type: `${factory.name}['request']`,
|
|
1293
1214
|
enabled: client.withData,
|
|
1294
|
-
required:
|
|
1215
|
+
required: isRequired(schemas.request?.schema)
|
|
1295
1216
|
},
|
|
1296
1217
|
{
|
|
1297
1218
|
name: "options",
|
|
@@ -1303,21 +1224,21 @@ function Query({
|
|
|
1303
1224
|
}
|
|
1304
1225
|
]);
|
|
1305
1226
|
queryParams.add([
|
|
1306
|
-
...pathParamsType === "object" ? [
|
|
1227
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams)] : getASTParams(schemas.pathParams),
|
|
1307
1228
|
{
|
|
1308
1229
|
name: "params",
|
|
1309
1230
|
enabled: client.withQueryParams,
|
|
1310
|
-
required:
|
|
1231
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1311
1232
|
},
|
|
1312
1233
|
{
|
|
1313
1234
|
name: "headers",
|
|
1314
1235
|
enabled: client.withHeaders,
|
|
1315
|
-
required:
|
|
1236
|
+
required: isRequired(schemas.headerParams?.schema)
|
|
1316
1237
|
},
|
|
1317
1238
|
{
|
|
1318
1239
|
name: "data",
|
|
1319
1240
|
enabled: client.withData,
|
|
1320
|
-
required:
|
|
1241
|
+
required: isRequired(schemas.request?.schema)
|
|
1321
1242
|
},
|
|
1322
1243
|
{
|
|
1323
1244
|
name: "clientOptions",
|
|
@@ -1325,16 +1246,16 @@ function Query({
|
|
|
1325
1246
|
}
|
|
1326
1247
|
]);
|
|
1327
1248
|
queryKeyParams.add([
|
|
1328
|
-
...pathParamsType === "object" ? [
|
|
1249
|
+
...pathParamsType === "object" ? [getASTParams(schemas.pathParams)] : getASTParams(schemas.pathParams),
|
|
1329
1250
|
{
|
|
1330
1251
|
name: "params",
|
|
1331
1252
|
enabled: client.withQueryParams,
|
|
1332
|
-
required:
|
|
1253
|
+
required: isRequired(schemas.queryParams?.schema)
|
|
1333
1254
|
},
|
|
1334
1255
|
{
|
|
1335
1256
|
name: "data",
|
|
1336
1257
|
enabled: client.withData,
|
|
1337
|
-
required:
|
|
1258
|
+
required: isRequired(schemas.request?.schema)
|
|
1338
1259
|
}
|
|
1339
1260
|
]);
|
|
1340
1261
|
const hook = {
|
|
@@ -1343,8 +1264,8 @@ function Query({
|
|
|
1343
1264
|
queryOptions: isV5 ? `${queryOptions}(${queryParams.toString()})` : `${queryOptions}<${queryOptionsGenerics.join(", ")}>(${queryParams.toString()})`,
|
|
1344
1265
|
queryKey: `${queryKey}(${queryKeyParams.toString()})`
|
|
1345
1266
|
};
|
|
1346
|
-
return /* @__PURE__ */
|
|
1347
|
-
/* @__PURE__ */
|
|
1267
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1268
|
+
/* @__PURE__ */ jsx(
|
|
1348
1269
|
QueryKey,
|
|
1349
1270
|
{
|
|
1350
1271
|
keysFn: props.query ? props.query.queryKey : (keys) => keys,
|
|
@@ -1354,7 +1275,7 @@ function Query({
|
|
|
1354
1275
|
typeName: queryKeyType
|
|
1355
1276
|
}
|
|
1356
1277
|
),
|
|
1357
|
-
props.queryOptions && /* @__PURE__ */
|
|
1278
|
+
props.queryOptions && /* @__PURE__ */ jsx(
|
|
1358
1279
|
QueryOptions,
|
|
1359
1280
|
{
|
|
1360
1281
|
Template: QueryOptionsTemplate,
|
|
@@ -1365,12 +1286,12 @@ function Query({
|
|
|
1365
1286
|
suspense: props.suspense
|
|
1366
1287
|
}
|
|
1367
1288
|
),
|
|
1368
|
-
props.query && /* @__PURE__ */
|
|
1369
|
-
|
|
1289
|
+
props.query && /* @__PURE__ */ jsx(
|
|
1290
|
+
Template6,
|
|
1370
1291
|
{
|
|
1371
1292
|
name: [name, props.infinite ? "Infinite" : void 0, props.suspense ? "Suspense" : void 0].filter(Boolean).join(""),
|
|
1372
1293
|
generics: generics.toString(),
|
|
1373
|
-
JSDoc: { comments:
|
|
1294
|
+
JSDoc: { comments: getComments(operation) },
|
|
1374
1295
|
params: params.toString(),
|
|
1375
1296
|
returnType: `${resultType}<${resultGenerics.join(", ")}>`,
|
|
1376
1297
|
hook,
|
|
@@ -1395,32 +1316,32 @@ Query.File = function({ templates }) {
|
|
|
1395
1316
|
parser
|
|
1396
1317
|
}
|
|
1397
1318
|
}
|
|
1398
|
-
} =
|
|
1399
|
-
const { getSchemas, getFile, getName } =
|
|
1400
|
-
const operation =
|
|
1401
|
-
const schemas = getSchemas(operation, { pluginKey: [
|
|
1402
|
-
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" });
|
|
1403
1324
|
const file = getFile(operation);
|
|
1404
|
-
const fileType = getFile(operation, { pluginKey: [
|
|
1325
|
+
const fileType = getFile(operation, { pluginKey: [pluginTsName] });
|
|
1405
1326
|
const fileZodSchemas = getFile(operation, {
|
|
1406
|
-
pluginKey: [
|
|
1327
|
+
pluginKey: [pluginZodName]
|
|
1407
1328
|
});
|
|
1408
1329
|
const factoryName = getName(operation, { type: "type" });
|
|
1409
1330
|
const importNames = getImportNames();
|
|
1410
|
-
const isV5 = new
|
|
1411
|
-
const
|
|
1331
|
+
const isV5 = new PackageManager().isValidSync(reactQueryDepRegex, ">=5");
|
|
1332
|
+
const Template6 = templates?.query["react"] || defaultTemplates5["react"];
|
|
1412
1333
|
const QueryOptionsTemplate = templates?.queryOptions["react"] || QueryOptions.templates["react"];
|
|
1413
1334
|
const QueryKeyTemplate = templates?.queryKey["react"] || QueryKey.templates["react"];
|
|
1414
1335
|
const Import = templates?.queryImports["react"] || QueryImports.templates["react"];
|
|
1415
1336
|
const factory = {
|
|
1416
1337
|
name: factoryName
|
|
1417
1338
|
};
|
|
1418
|
-
return /* @__PURE__ */
|
|
1419
|
-
parser === "zod" && /* @__PURE__ */
|
|
1420
|
-
/* @__PURE__ */
|
|
1421
|
-
/* @__PURE__ */
|
|
1422
|
-
/* @__PURE__ */
|
|
1423
|
-
|
|
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,
|
|
1424
1345
|
{
|
|
1425
1346
|
name: [
|
|
1426
1347
|
schemas.request?.name,
|
|
@@ -1435,70 +1356,62 @@ Query.File = function({ templates }) {
|
|
|
1435
1356
|
isTypeOnly: true
|
|
1436
1357
|
}
|
|
1437
1358
|
),
|
|
1438
|
-
/* @__PURE__ */
|
|
1439
|
-
!!infinite && /* @__PURE__ */
|
|
1440
|
-
!!suspense && isV5 && /* @__PURE__ */
|
|
1441
|
-
/* @__PURE__ */
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
] })
|
|
1492
|
-
] }) });
|
|
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(
|
|
1364
|
+
Query,
|
|
1365
|
+
{
|
|
1366
|
+
factory,
|
|
1367
|
+
Template: Template6,
|
|
1368
|
+
QueryKeyTemplate,
|
|
1369
|
+
QueryOptionsTemplate,
|
|
1370
|
+
infinite: false,
|
|
1371
|
+
suspense: false,
|
|
1372
|
+
query,
|
|
1373
|
+
queryOptions,
|
|
1374
|
+
hookName: importNames.query["react"].hookName,
|
|
1375
|
+
resultType: importNames.query["react"].resultType,
|
|
1376
|
+
optionsType: importNames.query["react"].optionsType
|
|
1377
|
+
}
|
|
1378
|
+
),
|
|
1379
|
+
!!infinite && /* @__PURE__ */ jsx(
|
|
1380
|
+
Query,
|
|
1381
|
+
{
|
|
1382
|
+
factory,
|
|
1383
|
+
Template: Template6,
|
|
1384
|
+
QueryKeyTemplate,
|
|
1385
|
+
QueryOptionsTemplate,
|
|
1386
|
+
infinite,
|
|
1387
|
+
suspense: false,
|
|
1388
|
+
query,
|
|
1389
|
+
queryOptions,
|
|
1390
|
+
hookName: importNames.queryInfinite["react"].hookName,
|
|
1391
|
+
resultType: importNames.queryInfinite["react"].resultType,
|
|
1392
|
+
optionsType: importNames.queryInfinite["react"].optionsType
|
|
1393
|
+
}
|
|
1394
|
+
),
|
|
1395
|
+
!!suspense && isV5 && /* @__PURE__ */ jsx(
|
|
1396
|
+
Query,
|
|
1397
|
+
{
|
|
1398
|
+
factory,
|
|
1399
|
+
Template: Template6,
|
|
1400
|
+
QueryKeyTemplate,
|
|
1401
|
+
QueryOptionsTemplate,
|
|
1402
|
+
infinite: false,
|
|
1403
|
+
suspense,
|
|
1404
|
+
query,
|
|
1405
|
+
queryOptions,
|
|
1406
|
+
hookName: importNames.querySuspense["react"].hookName,
|
|
1407
|
+
resultType: importNames.querySuspense["react"].resultType,
|
|
1408
|
+
optionsType: importNames.querySuspense["react"].optionsType
|
|
1409
|
+
}
|
|
1410
|
+
)
|
|
1411
|
+
] });
|
|
1493
1412
|
};
|
|
1494
|
-
Query.templates =
|
|
1413
|
+
Query.templates = defaultTemplates5;
|
|
1495
1414
|
|
|
1496
|
-
export {
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
QueryImports,
|
|
1500
|
-
QueryKey,
|
|
1501
|
-
QueryOptions,
|
|
1502
|
-
Query
|
|
1503
|
-
};
|
|
1504
|
-
//# sourceMappingURL=chunk-5IL6M74X.js.map
|
|
1415
|
+
export { Mutation, Query, QueryImports, QueryKey, QueryOptions };
|
|
1416
|
+
//# sourceMappingURL=chunk-ZYTZV43V.js.map
|
|
1417
|
+
//# sourceMappingURL=chunk-ZYTZV43V.js.map
|