@kubb/agent 5.0.0-alpha.35 → 5.0.0-alpha.36
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/.output/nitro.json +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +1293 -20554
- package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
- package/.output/server/chunks/routes/api/health.get.mjs +16 -14
- package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
- package/.output/server/index.mjs +16 -14
- package/.output/server/index.mjs.map +1 -1
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/constants.js +18 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/permessage-deflate.js +514 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/sender.js +602 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/stream.js +159 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket-server.js +540 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket.js +1388 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/package.json +69 -0
- package/.output/server/node_modules/.nitro/ws@8.18.0/wrapper.mjs +8 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/buffer-util.js +131 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/event-target.js +292 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/extension.js +203 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/limiter.js +55 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/receiver.js +706 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/subprotocol.js +62 -0
- package/.output/server/node_modules/.nitro/ws@8.20.0/lib/validation.js +152 -0
- package/.output/server/node_modules/@clack/core/dist/index.mjs +11 -0
- package/.output/server/node_modules/@clack/core/package.json +60 -0
- package/.output/server/node_modules/@clack/prompts/dist/index.mjs +137 -0
- package/.output/server/node_modules/@clack/prompts/package.json +65 -0
- package/.output/server/node_modules/@kubb/ast/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/ast/dist/index.js +423 -0
- package/.output/server/node_modules/@kubb/ast/package.json +70 -0
- package/.output/server/node_modules/@kubb/core/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/core/dist/hooks.js +23 -0
- package/.output/server/node_modules/@kubb/core/dist/index.js +2311 -0
- package/.output/server/node_modules/@kubb/core/package.json +109 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-O_arW02_.js +17 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/defaultParser-iCpMSYCp.js +15 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/getRelativePath-NAm_Y-vp.js +55 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +653 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/onProcessExit-Cput7j2c.js +742 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +101 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +17 -0
- package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +375 -0
- package/.output/server/node_modules/@kubb/fabric-core/package.json +111 -0
- package/.output/server/node_modules/@kubb/oas/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/oas/dist/index.js +918 -0
- package/.output/server/node_modules/@kubb/oas/package.json +94 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/StaticClassClient-bCe7RG_w.js +636 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/components.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/generators-BffddRNu.js +723 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/index.js +124 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/axios.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/fetch.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/dist/templates/config.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-client/package.json +153 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/components-BK_6GU4v.js +257 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/generators-D5YFtyyC.js +71 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/dist/index.js +79 -0
- package/.output/server/node_modules/@kubb/plugin-cypress/package.json +108 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/components-BkBIov4R.js +419 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/fakerGenerator-BztogaeO.js +200 -0
- package/.output/server/node_modules/@kubb/plugin-faker/dist/index.js +141 -0
- package/.output/server/node_modules/@kubb/plugin-faker/package.json +103 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/Server-H3SwqhwF.js +178 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/generators-BqkMrcs9.js +274 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/dist/index.js +122 -0
- package/.output/server/node_modules/@kubb/plugin-mcp/package.json +107 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/components-DgtTZkWX.js +277 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/generators-C34kqa1L.js +161 -0
- package/.output/server/node_modules/@kubb/plugin-msw/dist/index.js +84 -0
- package/.output/server/node_modules/@kubb/plugin-msw/package.json +109 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/SchemaMapper-CqMkO2T1.js +58 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/generators-D7C3CXsN.js +79 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/generators.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/getFooter-Pw3tLCiV.js +112 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/hooks.js +200 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/index.js +408 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/requestBody-pRavthCw.js +1336 -0
- package/.output/server/node_modules/@kubb/plugin-oas/dist/utils.js +268 -0
- package/.output/server/node_modules/@kubb/plugin-oas/package.json +122 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/components-CpyHYGOw.js +1520 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/generators-CpiBv5eE.js +1427 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/dist/index.js +166 -0
- package/.output/server/node_modules/@kubb/plugin-react-query/package.json +112 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/dist/index.js +65 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/package.json +85 -0
- package/.output/server/node_modules/@kubb/plugin-redoc/static/redoc.hbs +22 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/components-BhStIi1M.js +665 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/generators-CQClzsST.js +415 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/dist/index.js +145 -0
- package/.output/server/node_modules/@kubb/plugin-solid-query/package.json +113 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/components-DntKBsnB.js +666 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/generators-BtTsGGrM.js +414 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/index.js +145 -0
- package/.output/server/node_modules/@kubb/plugin-svelte-query/package.json +113 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/components-DRDGvgXG.js +702 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/generators-ClWZJ-YG.js +399 -0
- package/.output/server/node_modules/@kubb/plugin-swr/dist/index.js +144 -0
- package/.output/server/node_modules/@kubb/plugin-swr/package.json +115 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/components-C7fu-sK1.js +723 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/index.js +2 -0
- package/.output/server/node_modules/@kubb/plugin-ts/dist/plugin-CYC-FGXe.js +479 -0
- package/.output/server/node_modules/@kubb/plugin-ts/package.json +105 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/components-_AMBl0g-.js +1029 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/generators-Zb1s5Wmb.js +661 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/dist/index.js +157 -0
- package/.output/server/node_modules/@kubb/plugin-vue-query/package.json +114 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/chunk--u3MIqq1.js +8 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/components-eECfXVou.js +842 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/generators-D1R6NNf2.js +290 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/index.js +175 -0
- package/.output/server/node_modules/@kubb/plugin-zod/dist/templates/ToZod.source.js +6 -0
- package/.output/server/node_modules/@kubb/plugin-zod/package.json +112 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/chunk-BGCRLu6H.js +38 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +525 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime-Bl0DfUmV.js +1448 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +12 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/parsers.js +2 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +4 -0
- package/.output/server/node_modules/@kubb/react-fabric/dist/reactPlugin-QQPrjNuQ.js +17813 -0
- package/.output/server/node_modules/@kubb/react-fabric/package.json +143 -0
- package/.output/server/node_modules/buffer-from/index.js +72 -0
- package/.output/server/node_modules/buffer-from/package.json +19 -0
- package/.output/server/node_modules/empathic/access.js +39 -0
- package/.output/server/node_modules/empathic/access.mjs +34 -0
- package/.output/server/node_modules/empathic/find.js +81 -0
- package/.output/server/node_modules/empathic/find.mjs +76 -0
- package/.output/server/node_modules/empathic/package.json +49 -0
- package/.output/server/node_modules/empathic/package.mjs +52 -0
- package/.output/server/node_modules/empathic/resolve.js +31 -0
- package/.output/server/node_modules/empathic/resolve.mjs +27 -0
- package/.output/server/node_modules/empathic/walk.js +22 -0
- package/.output/server/node_modules/empathic/walk.mjs +20 -0
- package/.output/server/node_modules/fast-string-truncated-width/dist/index.js +171 -0
- package/.output/server/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
- package/.output/server/node_modules/fast-string-truncated-width/package.json +35 -0
- package/.output/server/node_modules/fast-string-width/dist/index.js +14 -0
- package/.output/server/node_modules/fast-string-width/package.json +34 -0
- package/.output/server/node_modules/fast-wrap-ansi/lib/main.js +216 -0
- package/.output/server/node_modules/fast-wrap-ansi/package.json +51 -0
- package/.output/server/node_modules/p-limit/index.js +127 -0
- package/.output/server/node_modules/p-limit/package.json +58 -0
- package/.output/server/node_modules/react-devtools-core/dist/backend.js +18302 -0
- package/.output/server/node_modules/react-devtools-core/package.json +38 -0
- package/.output/server/node_modules/sisteransi/package.json +34 -0
- package/.output/server/node_modules/sisteransi/src/index.js +58 -0
- package/.output/server/node_modules/source-map-support/package.json +31 -0
- package/.output/server/node_modules/source-map-support/source-map-support.js +625 -0
- package/.output/server/node_modules/typescript/lib/typescript.js +200276 -0
- package/.output/server/node_modules/typescript/package.json +120 -0
- package/.output/server/node_modules/yocto-queue/index.js +90 -0
- package/.output/server/node_modules/yocto-queue/package.json +48 -0
- package/.output/server/package.json +34 -2
- package/package.json +20 -20
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/buffer-util.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/event-target.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/extension.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/limiter.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/receiver.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/subprotocol.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/validation.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/constants.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/permessage-deflate.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/sender.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/stream.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket-server.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket.js +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/package.json +0 -0
- /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/wrapper.mjs +0 -0
|
@@ -0,0 +1,1029 @@
|
|
|
1
|
+
import { t as __name } from "./chunk--u3MIqq1.js";
|
|
2
|
+
import { getDefaultValue, isOptional } from "@kubb/oas";
|
|
3
|
+
import { getComments, getPathParams } from "@kubb/plugin-oas/utils";
|
|
4
|
+
import { File, Function as Function$1, FunctionParams, Type } from "@kubb/react-fabric";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
6
|
+
import { Client } from "@kubb/plugin-client/components";
|
|
7
|
+
//#region ../../internals/utils/src/casing.ts
|
|
8
|
+
/**
|
|
9
|
+
* Shared implementation for camelCase and PascalCase conversion.
|
|
10
|
+
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
11
|
+
* and capitalizes each word according to `pascal`.
|
|
12
|
+
*
|
|
13
|
+
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
14
|
+
*/
|
|
15
|
+
function toCamelOrPascal(text, pascal) {
|
|
16
|
+
return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
|
|
17
|
+
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
18
|
+
if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
19
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
20
|
+
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
24
|
+
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
25
|
+
* Segments are joined with `/` to form a file path.
|
|
26
|
+
*/
|
|
27
|
+
function applyToFileParts(text, transformPart) {
|
|
28
|
+
const parts = text.split(".");
|
|
29
|
+
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Converts `text` to camelCase.
|
|
33
|
+
* When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* camelCase('hello-world') // 'helloWorld'
|
|
37
|
+
* camelCase('pet.petId', { isFile: true }) // 'pet/petId'
|
|
38
|
+
*/
|
|
39
|
+
function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
40
|
+
if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
|
|
41
|
+
prefix,
|
|
42
|
+
suffix
|
|
43
|
+
} : {}));
|
|
44
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Converts `text` to PascalCase.
|
|
48
|
+
* When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* pascalCase('hello-world') // 'HelloWorld'
|
|
52
|
+
* pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'
|
|
53
|
+
*/
|
|
54
|
+
function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
55
|
+
if (isFile) return applyToFileParts(text, (part, isLast) => isLast ? pascalCase(part, {
|
|
56
|
+
prefix,
|
|
57
|
+
suffix
|
|
58
|
+
}) : camelCase(part));
|
|
59
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region ../../internals/utils/src/object.ts
|
|
63
|
+
/**
|
|
64
|
+
* Converts a dot-notation path or string array into an optional-chaining accessor expression.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* getNestedAccessor('pagination.next.id', 'lastPage')
|
|
68
|
+
* // → "lastPage?.['pagination']?.['next']?.['id']"
|
|
69
|
+
*/
|
|
70
|
+
function getNestedAccessor(param, accessor) {
|
|
71
|
+
const parts = Array.isArray(param) ? param : param.split(".");
|
|
72
|
+
if (parts.length === 0 || parts.length === 1 && parts[0] === "") return void 0;
|
|
73
|
+
return `${accessor}?.['${`${parts.join("']?.['")}']`}`;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region ../../internals/utils/src/reserved.ts
|
|
77
|
+
/**
|
|
78
|
+
* Returns `true` when `name` is a syntactically valid JavaScript variable name.
|
|
79
|
+
*/
|
|
80
|
+
function isValidVarName(name) {
|
|
81
|
+
try {
|
|
82
|
+
new Function(`var ${name}`);
|
|
83
|
+
} catch {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region ../../internals/utils/src/urlPath.ts
|
|
90
|
+
/**
|
|
91
|
+
* Parses and transforms an OpenAPI/Swagger path string into various URL formats.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const p = new URLPath('/pet/{petId}')
|
|
95
|
+
* p.URL // '/pet/:petId'
|
|
96
|
+
* p.template // '`/pet/${petId}`'
|
|
97
|
+
*/
|
|
98
|
+
var URLPath = class {
|
|
99
|
+
/** The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`. */
|
|
100
|
+
path;
|
|
101
|
+
#options;
|
|
102
|
+
constructor(path, options = {}) {
|
|
103
|
+
this.path = path;
|
|
104
|
+
this.#options = options;
|
|
105
|
+
}
|
|
106
|
+
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */
|
|
107
|
+
get URL() {
|
|
108
|
+
return this.toURLPath();
|
|
109
|
+
}
|
|
110
|
+
/** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`). */
|
|
111
|
+
get isURL() {
|
|
112
|
+
try {
|
|
113
|
+
return !!new URL(this.path).href;
|
|
114
|
+
} catch {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
|
|
123
|
+
* new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
|
|
124
|
+
*/
|
|
125
|
+
get template() {
|
|
126
|
+
return this.toTemplateString();
|
|
127
|
+
}
|
|
128
|
+
/** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set. */
|
|
129
|
+
get object() {
|
|
130
|
+
return this.toObject();
|
|
131
|
+
}
|
|
132
|
+
/** Returns a map of path parameter names, or `undefined` when the path has no parameters. */
|
|
133
|
+
get params() {
|
|
134
|
+
return this.getParams();
|
|
135
|
+
}
|
|
136
|
+
#transformParam(raw) {
|
|
137
|
+
const param = isValidVarName(raw) ? raw : camelCase(raw);
|
|
138
|
+
return this.#options.casing === "camelcase" ? camelCase(param) : param;
|
|
139
|
+
}
|
|
140
|
+
/** Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name. */
|
|
141
|
+
#eachParam(fn) {
|
|
142
|
+
for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
|
|
143
|
+
const raw = match[1];
|
|
144
|
+
fn(raw, this.#transformParam(raw));
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
toObject({ type = "path", replacer, stringify } = {}) {
|
|
148
|
+
const object = {
|
|
149
|
+
url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
|
|
150
|
+
params: this.getParams()
|
|
151
|
+
};
|
|
152
|
+
if (stringify) {
|
|
153
|
+
if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
154
|
+
if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
|
|
155
|
+
return `{ url: '${object.url}' }`;
|
|
156
|
+
}
|
|
157
|
+
return object;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
161
|
+
* An optional `replacer` can transform each extracted parameter name before interpolation.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
|
|
165
|
+
*/
|
|
166
|
+
toTemplateString({ prefix = "", replacer } = {}) {
|
|
167
|
+
return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
|
|
168
|
+
if (i % 2 === 0) return part;
|
|
169
|
+
const param = this.#transformParam(part);
|
|
170
|
+
return `\${${replacer ? replacer(param) : param}}`;
|
|
171
|
+
}).join("")}\``;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Extracts all `{param}` segments from the path and returns them as a key-value map.
|
|
175
|
+
* An optional `replacer` transforms each parameter name in both key and value positions.
|
|
176
|
+
* Returns `undefined` when no path parameters are found.
|
|
177
|
+
*/
|
|
178
|
+
getParams(replacer) {
|
|
179
|
+
const params = {};
|
|
180
|
+
this.#eachParam((_raw, param) => {
|
|
181
|
+
const key = replacer ? replacer(param) : param;
|
|
182
|
+
params[key] = key;
|
|
183
|
+
});
|
|
184
|
+
return Object.keys(params).length > 0 ? params : void 0;
|
|
185
|
+
}
|
|
186
|
+
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */
|
|
187
|
+
toURLPath() {
|
|
188
|
+
return this.path.replace(/\{([^}]+)\}/g, ":$1");
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/components/QueryKey.tsx
|
|
193
|
+
function getParams$6({ pathParamsType, paramsCasing, typeSchemas }) {
|
|
194
|
+
return FunctionParams.factory({
|
|
195
|
+
pathParams: {
|
|
196
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
197
|
+
children: getPathParams(typeSchemas.pathParams, {
|
|
198
|
+
typed: true,
|
|
199
|
+
casing: paramsCasing,
|
|
200
|
+
override(item) {
|
|
201
|
+
return {
|
|
202
|
+
...item,
|
|
203
|
+
type: `MaybeRefOrGetter<${item.type}>`
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
},
|
|
208
|
+
data: typeSchemas.request?.name ? {
|
|
209
|
+
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
210
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
211
|
+
} : void 0,
|
|
212
|
+
params: typeSchemas.queryParams?.name ? {
|
|
213
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
214
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
215
|
+
} : void 0
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
__name(getParams$6, "getParams");
|
|
219
|
+
const getTransformer$1 = /* @__PURE__ */ __name(({ operation, schemas, casing }) => {
|
|
220
|
+
return [
|
|
221
|
+
new URLPath(operation.path, { casing }).toObject({
|
|
222
|
+
type: "path",
|
|
223
|
+
stringify: true
|
|
224
|
+
}),
|
|
225
|
+
schemas.queryParams?.name ? "...(params ? [params] : [])" : void 0,
|
|
226
|
+
schemas.request?.name ? "...(data ? [data] : [])" : void 0
|
|
227
|
+
].filter(Boolean);
|
|
228
|
+
}, "getTransformer");
|
|
229
|
+
function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer$1 }) {
|
|
230
|
+
const params = getParams$6({
|
|
231
|
+
pathParamsType,
|
|
232
|
+
typeSchemas,
|
|
233
|
+
paramsCasing
|
|
234
|
+
});
|
|
235
|
+
const keys = transformer({
|
|
236
|
+
operation,
|
|
237
|
+
schemas: typeSchemas,
|
|
238
|
+
casing: paramsCasing
|
|
239
|
+
});
|
|
240
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
|
|
241
|
+
name,
|
|
242
|
+
isExportable: true,
|
|
243
|
+
isIndexable: true,
|
|
244
|
+
children: /* @__PURE__ */ jsx(Function$1.Arrow, {
|
|
245
|
+
name,
|
|
246
|
+
export: true,
|
|
247
|
+
params: params.toConstructor(),
|
|
248
|
+
singleLine: true,
|
|
249
|
+
children: `[${keys.join(", ")}] as const`
|
|
250
|
+
})
|
|
251
|
+
}), /* @__PURE__ */ jsx(File.Source, {
|
|
252
|
+
name: typeName,
|
|
253
|
+
isExportable: true,
|
|
254
|
+
isIndexable: true,
|
|
255
|
+
isTypeOnly: true,
|
|
256
|
+
children: /* @__PURE__ */ jsx(Type, {
|
|
257
|
+
name: typeName,
|
|
258
|
+
export: true,
|
|
259
|
+
children: `ReturnType<typeof ${name}>`
|
|
260
|
+
})
|
|
261
|
+
})] });
|
|
262
|
+
}
|
|
263
|
+
QueryKey.getParams = getParams$6;
|
|
264
|
+
QueryKey.getTransformer = getTransformer$1;
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/components/QueryOptions.tsx
|
|
267
|
+
function getParams$5({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
268
|
+
if (paramsType === "object") {
|
|
269
|
+
const children = {
|
|
270
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
271
|
+
typed: true,
|
|
272
|
+
casing: paramsCasing,
|
|
273
|
+
override(item) {
|
|
274
|
+
return {
|
|
275
|
+
...item,
|
|
276
|
+
type: `MaybeRefOrGetter<${item.type}>`
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
}),
|
|
280
|
+
data: typeSchemas.request?.name ? {
|
|
281
|
+
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
282
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
283
|
+
} : void 0,
|
|
284
|
+
params: typeSchemas.queryParams?.name ? {
|
|
285
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
286
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
287
|
+
} : void 0,
|
|
288
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
289
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
290
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
291
|
+
} : void 0
|
|
292
|
+
};
|
|
293
|
+
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
294
|
+
return FunctionParams.factory({
|
|
295
|
+
data: {
|
|
296
|
+
mode: "object",
|
|
297
|
+
children,
|
|
298
|
+
default: allChildrenAreOptional ? "{}" : void 0
|
|
299
|
+
},
|
|
300
|
+
config: {
|
|
301
|
+
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
|
|
302
|
+
default: "{}"
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
return FunctionParams.factory({
|
|
307
|
+
pathParams: {
|
|
308
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
309
|
+
children: getPathParams(typeSchemas.pathParams, {
|
|
310
|
+
typed: true,
|
|
311
|
+
casing: paramsCasing,
|
|
312
|
+
override(item) {
|
|
313
|
+
return {
|
|
314
|
+
...item,
|
|
315
|
+
type: `MaybeRefOrGetter<${item.type}>`
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}),
|
|
319
|
+
default: getDefaultValue(typeSchemas.pathParams?.schema)
|
|
320
|
+
},
|
|
321
|
+
data: typeSchemas.request?.name ? {
|
|
322
|
+
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
323
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
324
|
+
} : void 0,
|
|
325
|
+
params: typeSchemas.queryParams?.name ? {
|
|
326
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
327
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
328
|
+
} : void 0,
|
|
329
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
330
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
331
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
332
|
+
} : void 0,
|
|
333
|
+
config: {
|
|
334
|
+
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
|
|
335
|
+
default: "{}"
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
__name(getParams$5, "getParams");
|
|
340
|
+
function QueryOptions({ name, clientName, dataReturnType, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }) {
|
|
341
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
342
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
343
|
+
const params = getParams$5({
|
|
344
|
+
paramsType,
|
|
345
|
+
paramsCasing,
|
|
346
|
+
pathParamsType,
|
|
347
|
+
typeSchemas
|
|
348
|
+
});
|
|
349
|
+
const clientParams = Client.getParams({
|
|
350
|
+
paramsType,
|
|
351
|
+
paramsCasing,
|
|
352
|
+
typeSchemas,
|
|
353
|
+
pathParamsType,
|
|
354
|
+
isConfigurable: true
|
|
355
|
+
});
|
|
356
|
+
const queryKeyParams = QueryKey.getParams({
|
|
357
|
+
pathParamsType,
|
|
358
|
+
typeSchemas,
|
|
359
|
+
paramsCasing
|
|
360
|
+
});
|
|
361
|
+
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => {
|
|
362
|
+
return item && !item.optional && !item.default ? key : void 0;
|
|
363
|
+
}).filter(Boolean).join("&& ");
|
|
364
|
+
const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
|
|
365
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
366
|
+
name,
|
|
367
|
+
isExportable: true,
|
|
368
|
+
isIndexable: true,
|
|
369
|
+
children: /* @__PURE__ */ jsx(Function$1, {
|
|
370
|
+
name,
|
|
371
|
+
export: true,
|
|
372
|
+
params: params.toConstructor(),
|
|
373
|
+
children: `
|
|
374
|
+
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
375
|
+
return queryOptions<${TData}, ${TError}, ${TData}, typeof queryKey>({
|
|
376
|
+
${enabledText}
|
|
377
|
+
queryKey,
|
|
378
|
+
queryFn: async ({ signal }) => {
|
|
379
|
+
return ${clientName}(${clientParams.toCall({ transformName(name) {
|
|
380
|
+
if (name === "config") return "{ ...config, signal: config.signal ?? signal }";
|
|
381
|
+
return `toValue(${name})`;
|
|
382
|
+
} })})
|
|
383
|
+
},
|
|
384
|
+
})
|
|
385
|
+
`
|
|
386
|
+
})
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
QueryOptions.getParams = getParams$5;
|
|
390
|
+
//#endregion
|
|
391
|
+
//#region src/components/InfiniteQuery.tsx
|
|
392
|
+
function getParams$4({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }) {
|
|
393
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
394
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
395
|
+
if (paramsType === "object") {
|
|
396
|
+
const children = {
|
|
397
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
398
|
+
typed: true,
|
|
399
|
+
casing: paramsCasing,
|
|
400
|
+
override(item) {
|
|
401
|
+
return {
|
|
402
|
+
...item,
|
|
403
|
+
type: `MaybeRefOrGetter<${item.type}>`
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
}),
|
|
407
|
+
data: typeSchemas.request?.name ? {
|
|
408
|
+
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
409
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
410
|
+
} : void 0,
|
|
411
|
+
params: typeSchemas.queryParams?.name ? {
|
|
412
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
413
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
414
|
+
} : void 0,
|
|
415
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
416
|
+
type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
|
|
417
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
418
|
+
} : void 0
|
|
419
|
+
};
|
|
420
|
+
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
421
|
+
return FunctionParams.factory({
|
|
422
|
+
data: {
|
|
423
|
+
mode: "object",
|
|
424
|
+
children,
|
|
425
|
+
default: allChildrenAreOptional ? "{}" : void 0
|
|
426
|
+
},
|
|
427
|
+
options: {
|
|
428
|
+
type: `
|
|
429
|
+
{
|
|
430
|
+
query?: Partial<UseInfiniteQueryOptions<${[
|
|
431
|
+
TData,
|
|
432
|
+
TError,
|
|
433
|
+
"TQueryData",
|
|
434
|
+
"TQueryKey",
|
|
435
|
+
"TQueryData"
|
|
436
|
+
].join(", ")}>> & { client?: QueryClient },
|
|
437
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
438
|
+
}
|
|
439
|
+
`,
|
|
440
|
+
default: "{}"
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
return FunctionParams.factory({
|
|
445
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
446
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
447
|
+
children: getPathParams(typeSchemas.pathParams, {
|
|
448
|
+
typed: true,
|
|
449
|
+
casing: paramsCasing,
|
|
450
|
+
override(item) {
|
|
451
|
+
return {
|
|
452
|
+
...item,
|
|
453
|
+
type: `MaybeRefOrGetter<${item.type}>`
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
}),
|
|
457
|
+
default: getDefaultValue(typeSchemas.pathParams?.schema)
|
|
458
|
+
} : void 0,
|
|
459
|
+
data: typeSchemas.request?.name ? {
|
|
460
|
+
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
461
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
462
|
+
} : void 0,
|
|
463
|
+
params: typeSchemas.queryParams?.name ? {
|
|
464
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
465
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
466
|
+
} : void 0,
|
|
467
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
468
|
+
type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
|
|
469
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
470
|
+
} : void 0,
|
|
471
|
+
options: {
|
|
472
|
+
type: `
|
|
473
|
+
{
|
|
474
|
+
query?: Partial<UseInfiniteQueryOptions<${[
|
|
475
|
+
TData,
|
|
476
|
+
TError,
|
|
477
|
+
"TQueryData",
|
|
478
|
+
"TQueryKey",
|
|
479
|
+
"TQueryData"
|
|
480
|
+
].join(", ")}>> & { client?: QueryClient },
|
|
481
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
482
|
+
}
|
|
483
|
+
`,
|
|
484
|
+
default: "{}"
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
__name(getParams$4, "getParams");
|
|
489
|
+
function InfiniteQuery({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, pathParamsType, paramsCasing, dataReturnType, typeSchemas, operation }) {
|
|
490
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
491
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
492
|
+
const returnType = `UseInfiniteQueryReturnType<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
|
|
493
|
+
const generics = [
|
|
494
|
+
`TData = InfiniteData<${TData}>`,
|
|
495
|
+
`TQueryData = ${TData}`,
|
|
496
|
+
`TQueryKey extends QueryKey = ${queryKeyTypeName}`
|
|
497
|
+
];
|
|
498
|
+
const queryKeyParams = QueryKey.getParams({
|
|
499
|
+
pathParamsType,
|
|
500
|
+
typeSchemas,
|
|
501
|
+
paramsCasing
|
|
502
|
+
});
|
|
503
|
+
const queryOptionsParams = QueryOptions.getParams({
|
|
504
|
+
paramsType,
|
|
505
|
+
pathParamsType,
|
|
506
|
+
typeSchemas,
|
|
507
|
+
paramsCasing
|
|
508
|
+
});
|
|
509
|
+
const params = getParams$4({
|
|
510
|
+
paramsCasing,
|
|
511
|
+
paramsType,
|
|
512
|
+
pathParamsType,
|
|
513
|
+
dataReturnType,
|
|
514
|
+
typeSchemas
|
|
515
|
+
});
|
|
516
|
+
const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
|
|
517
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
518
|
+
name,
|
|
519
|
+
isExportable: true,
|
|
520
|
+
isIndexable: true,
|
|
521
|
+
children: /* @__PURE__ */ jsx(Function$1, {
|
|
522
|
+
name,
|
|
523
|
+
export: true,
|
|
524
|
+
generics: generics.join(", "),
|
|
525
|
+
params: params.toConstructor(),
|
|
526
|
+
JSDoc: { comments: getComments(operation) },
|
|
527
|
+
children: `
|
|
528
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
529
|
+
const { client: queryClient, ...resolvedOptions } = queryConfig
|
|
530
|
+
const queryKey = (resolvedOptions && 'queryKey' in resolvedOptions ? toValue(resolvedOptions.queryKey) : undefined) ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
531
|
+
|
|
532
|
+
const query = useInfiniteQuery({
|
|
533
|
+
...${queryOptions},
|
|
534
|
+
...resolvedOptions,
|
|
535
|
+
queryKey
|
|
536
|
+
} as unknown as UseInfiniteQueryOptions<${TData}, ${TError}, ${TData}, TQueryKey, ${TData}>, toValue(queryClient)) as ${returnType}
|
|
537
|
+
|
|
538
|
+
query.queryKey = queryKey as TQueryKey
|
|
539
|
+
|
|
540
|
+
return query
|
|
541
|
+
`
|
|
542
|
+
})
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
InfiniteQuery.getParams = getParams$4;
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/components/InfiniteQueryOptions.tsx
|
|
548
|
+
function getParams$3({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
549
|
+
if (paramsType === "object") {
|
|
550
|
+
const children = {
|
|
551
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
552
|
+
typed: true,
|
|
553
|
+
casing: paramsCasing,
|
|
554
|
+
override(item) {
|
|
555
|
+
return {
|
|
556
|
+
...item,
|
|
557
|
+
type: `MaybeRefOrGetter<${item.type}>`
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
}),
|
|
561
|
+
data: typeSchemas.request?.name ? {
|
|
562
|
+
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
563
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
564
|
+
} : void 0,
|
|
565
|
+
params: typeSchemas.queryParams?.name ? {
|
|
566
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
567
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
568
|
+
} : void 0,
|
|
569
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
570
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
571
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
572
|
+
} : void 0
|
|
573
|
+
};
|
|
574
|
+
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
575
|
+
return FunctionParams.factory({
|
|
576
|
+
data: {
|
|
577
|
+
mode: "object",
|
|
578
|
+
children,
|
|
579
|
+
default: allChildrenAreOptional ? "{}" : void 0
|
|
580
|
+
},
|
|
581
|
+
config: {
|
|
582
|
+
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
|
|
583
|
+
default: "{}"
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
return FunctionParams.factory({
|
|
588
|
+
pathParams: {
|
|
589
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
590
|
+
children: getPathParams(typeSchemas.pathParams, {
|
|
591
|
+
typed: true,
|
|
592
|
+
casing: paramsCasing,
|
|
593
|
+
override(item) {
|
|
594
|
+
return {
|
|
595
|
+
...item,
|
|
596
|
+
type: `MaybeRefOrGetter<${item.type}>`
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
}),
|
|
600
|
+
default: getDefaultValue(typeSchemas.pathParams?.schema)
|
|
601
|
+
},
|
|
602
|
+
data: typeSchemas.request?.name ? {
|
|
603
|
+
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
604
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
605
|
+
} : void 0,
|
|
606
|
+
params: typeSchemas.queryParams?.name ? {
|
|
607
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
608
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
609
|
+
} : void 0,
|
|
610
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
611
|
+
type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
|
|
612
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
613
|
+
} : void 0,
|
|
614
|
+
config: {
|
|
615
|
+
type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }",
|
|
616
|
+
default: "{}"
|
|
617
|
+
}
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
__name(getParams$3, "getParams");
|
|
621
|
+
function InfiniteQueryOptions({ name, clientName, initialPageParam, cursorParam, nextParam, previousParam, typeSchemas, paramsType, paramsCasing, dataReturnType, pathParamsType, queryParam, queryKeyName }) {
|
|
622
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
623
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
624
|
+
const params = getParams$3({
|
|
625
|
+
paramsType,
|
|
626
|
+
paramsCasing,
|
|
627
|
+
pathParamsType,
|
|
628
|
+
typeSchemas
|
|
629
|
+
});
|
|
630
|
+
const clientParams = Client.getParams({
|
|
631
|
+
paramsType,
|
|
632
|
+
paramsCasing,
|
|
633
|
+
typeSchemas,
|
|
634
|
+
pathParamsType,
|
|
635
|
+
isConfigurable: true
|
|
636
|
+
});
|
|
637
|
+
const queryKeyParams = QueryKey.getParams({
|
|
638
|
+
paramsCasing,
|
|
639
|
+
pathParamsType,
|
|
640
|
+
typeSchemas
|
|
641
|
+
});
|
|
642
|
+
const hasNewParams = nextParam !== void 0 || previousParam !== void 0;
|
|
643
|
+
let getNextPageParamExpr;
|
|
644
|
+
let getPreviousPageParamExpr;
|
|
645
|
+
if (hasNewParams) {
|
|
646
|
+
if (nextParam) {
|
|
647
|
+
const accessor = getNestedAccessor(nextParam, "lastPage");
|
|
648
|
+
if (accessor) getNextPageParamExpr = `getNextPageParam: (lastPage) => ${accessor}`;
|
|
649
|
+
}
|
|
650
|
+
if (previousParam) {
|
|
651
|
+
const accessor = getNestedAccessor(previousParam, "firstPage");
|
|
652
|
+
if (accessor) getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => ${accessor}`;
|
|
653
|
+
}
|
|
654
|
+
} else if (cursorParam) {
|
|
655
|
+
getNextPageParamExpr = `getNextPageParam: (lastPage) => lastPage['${cursorParam}']`;
|
|
656
|
+
getPreviousPageParamExpr = `getPreviousPageParam: (firstPage) => firstPage['${cursorParam}']`;
|
|
657
|
+
} else {
|
|
658
|
+
if (dataReturnType === "full") getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage.data) && lastPage.data.length === 0 ? undefined : lastPageParam + 1";
|
|
659
|
+
else getNextPageParamExpr = "getNextPageParam: (lastPage, _allPages, lastPageParam) => Array.isArray(lastPage) && lastPage.length === 0 ? undefined : lastPageParam + 1";
|
|
660
|
+
getPreviousPageParamExpr = "getPreviousPageParam: (_firstPage, _allPages, firstPageParam) => firstPageParam <= 1 ? undefined : firstPageParam - 1";
|
|
661
|
+
}
|
|
662
|
+
const queryOptions = [
|
|
663
|
+
`initialPageParam: ${typeof initialPageParam === "string" ? JSON.stringify(initialPageParam) : initialPageParam}`,
|
|
664
|
+
getNextPageParamExpr,
|
|
665
|
+
getPreviousPageParamExpr
|
|
666
|
+
].filter(Boolean);
|
|
667
|
+
const infiniteOverrideParams = queryParam && typeSchemas.queryParams?.name ? `
|
|
668
|
+
if (!params) {
|
|
669
|
+
params = { }
|
|
670
|
+
}
|
|
671
|
+
params['${queryParam}'] = pageParam as unknown as ${typeSchemas.queryParams?.name}['${queryParam}']` : "";
|
|
672
|
+
const enabled = Object.entries(queryKeyParams.flatParams).map(([key, item]) => {
|
|
673
|
+
return item && !item.optional && !item.default ? key : void 0;
|
|
674
|
+
}).filter(Boolean).join("&& ");
|
|
675
|
+
const enabledText = enabled ? `enabled: !!(${enabled}),` : "";
|
|
676
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
677
|
+
name,
|
|
678
|
+
isExportable: true,
|
|
679
|
+
isIndexable: true,
|
|
680
|
+
children: /* @__PURE__ */ jsx(Function$1, {
|
|
681
|
+
name,
|
|
682
|
+
export: true,
|
|
683
|
+
params: params.toConstructor(),
|
|
684
|
+
children: `
|
|
685
|
+
const queryKey = ${queryKeyName}(${queryKeyParams.toCall()})
|
|
686
|
+
return infiniteQueryOptions<${TData}, ${TError}, ${TData}, typeof queryKey, number>({
|
|
687
|
+
${enabledText}
|
|
688
|
+
queryKey,
|
|
689
|
+
queryFn: async ({ signal, pageParam }) => {
|
|
690
|
+
${infiniteOverrideParams}
|
|
691
|
+
return ${clientName}(${clientParams.toCall({ transformName(name) {
|
|
692
|
+
if (name === "config") return "{ ...config, signal: config.signal ?? signal }";
|
|
693
|
+
return `toValue(${name})`;
|
|
694
|
+
} })})
|
|
695
|
+
},
|
|
696
|
+
${queryOptions.join(",\n")}
|
|
697
|
+
})
|
|
698
|
+
`
|
|
699
|
+
})
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
InfiniteQueryOptions.getParams = getParams$3;
|
|
703
|
+
//#endregion
|
|
704
|
+
//#region ../../internals/tanstack-query/src/components/MutationKey.tsx
|
|
705
|
+
function getParams$2({}) {
|
|
706
|
+
return FunctionParams.factory({});
|
|
707
|
+
}
|
|
708
|
+
__name(getParams$2, "getParams");
|
|
709
|
+
const getTransformer = ({ operation, casing }) => {
|
|
710
|
+
return [`{ url: '${new URLPath(operation.path, { casing }).toURLPath()}' }`];
|
|
711
|
+
};
|
|
712
|
+
function MutationKey({ name, typeSchemas, pathParamsType, paramsCasing, operation, typeName, transformer = getTransformer }) {
|
|
713
|
+
const params = getParams$2({
|
|
714
|
+
pathParamsType,
|
|
715
|
+
typeSchemas
|
|
716
|
+
});
|
|
717
|
+
const keys = transformer({
|
|
718
|
+
operation,
|
|
719
|
+
schemas: typeSchemas,
|
|
720
|
+
casing: paramsCasing
|
|
721
|
+
});
|
|
722
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
|
|
723
|
+
name,
|
|
724
|
+
isExportable: true,
|
|
725
|
+
isIndexable: true,
|
|
726
|
+
children: /* @__PURE__ */ jsx(Function$1.Arrow, {
|
|
727
|
+
name,
|
|
728
|
+
export: true,
|
|
729
|
+
params: params.toConstructor(),
|
|
730
|
+
singleLine: true,
|
|
731
|
+
children: `[${keys.join(", ")}] as const`
|
|
732
|
+
})
|
|
733
|
+
}), /* @__PURE__ */ jsx(File.Source, {
|
|
734
|
+
name: typeName,
|
|
735
|
+
isExportable: true,
|
|
736
|
+
isIndexable: true,
|
|
737
|
+
isTypeOnly: true,
|
|
738
|
+
children: /* @__PURE__ */ jsx(Type, {
|
|
739
|
+
name: typeName,
|
|
740
|
+
export: true,
|
|
741
|
+
children: `ReturnType<typeof ${name}>`
|
|
742
|
+
})
|
|
743
|
+
})] });
|
|
744
|
+
}
|
|
745
|
+
MutationKey.getParams = getParams$2;
|
|
746
|
+
MutationKey.getTransformer = getTransformer;
|
|
747
|
+
//#endregion
|
|
748
|
+
//#region src/components/Mutation.tsx
|
|
749
|
+
function getParams$1({ paramsCasing, dataReturnType, typeSchemas }) {
|
|
750
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
751
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
752
|
+
const TRequest = FunctionParams.factory({
|
|
753
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
754
|
+
typed: true,
|
|
755
|
+
casing: paramsCasing,
|
|
756
|
+
override(item) {
|
|
757
|
+
return {
|
|
758
|
+
...item,
|
|
759
|
+
type: `MaybeRefOrGetter<${item.type}>`
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
}),
|
|
763
|
+
data: typeSchemas.request?.name ? {
|
|
764
|
+
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
765
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
766
|
+
} : void 0,
|
|
767
|
+
params: typeSchemas.queryParams?.name ? {
|
|
768
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
769
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
770
|
+
} : void 0,
|
|
771
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
772
|
+
type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
|
|
773
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
774
|
+
} : void 0
|
|
775
|
+
}).toConstructor();
|
|
776
|
+
return FunctionParams.factory({ options: {
|
|
777
|
+
type: `
|
|
778
|
+
{
|
|
779
|
+
mutation?: MutationObserverOptions<${[
|
|
780
|
+
TData,
|
|
781
|
+
TError,
|
|
782
|
+
TRequest ? `{${TRequest}}` : "void",
|
|
783
|
+
"TContext"
|
|
784
|
+
].join(", ")}> & { client?: QueryClient },
|
|
785
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"},
|
|
786
|
+
}
|
|
787
|
+
`,
|
|
788
|
+
default: "{}"
|
|
789
|
+
} });
|
|
790
|
+
}
|
|
791
|
+
__name(getParams$1, "getParams");
|
|
792
|
+
function Mutation({ name, clientName, paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }) {
|
|
793
|
+
const mutationKeyParams = MutationKey.getParams({
|
|
794
|
+
pathParamsType,
|
|
795
|
+
typeSchemas
|
|
796
|
+
});
|
|
797
|
+
const params = getParams$1({
|
|
798
|
+
paramsCasing,
|
|
799
|
+
pathParamsType,
|
|
800
|
+
dataReturnType,
|
|
801
|
+
typeSchemas
|
|
802
|
+
});
|
|
803
|
+
const clientParams = Client.getParams({
|
|
804
|
+
paramsCasing,
|
|
805
|
+
paramsType,
|
|
806
|
+
typeSchemas,
|
|
807
|
+
pathParamsType,
|
|
808
|
+
isConfigurable: true
|
|
809
|
+
});
|
|
810
|
+
const mutationParams = FunctionParams.factory({
|
|
811
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
812
|
+
typed: true,
|
|
813
|
+
casing: paramsCasing
|
|
814
|
+
}),
|
|
815
|
+
data: typeSchemas.request?.name ? {
|
|
816
|
+
type: typeSchemas.request?.name,
|
|
817
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
818
|
+
} : void 0,
|
|
819
|
+
params: typeSchemas.queryParams?.name ? {
|
|
820
|
+
type: typeSchemas.queryParams?.name,
|
|
821
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
822
|
+
} : void 0,
|
|
823
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
824
|
+
type: typeSchemas.headerParams?.name,
|
|
825
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
826
|
+
} : void 0
|
|
827
|
+
});
|
|
828
|
+
const dataParams = FunctionParams.factory({ data: {
|
|
829
|
+
mode: "object",
|
|
830
|
+
children: Object.entries(mutationParams.params).reduce((acc, [key, value]) => {
|
|
831
|
+
if (value) acc[key] = {
|
|
832
|
+
...value,
|
|
833
|
+
type: void 0
|
|
834
|
+
};
|
|
835
|
+
return acc;
|
|
836
|
+
}, {})
|
|
837
|
+
} });
|
|
838
|
+
const TRequest = mutationParams.toConstructor();
|
|
839
|
+
const generics = [
|
|
840
|
+
dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`,
|
|
841
|
+
`ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`,
|
|
842
|
+
TRequest ? `{${TRequest}}` : "void",
|
|
843
|
+
"TContext"
|
|
844
|
+
].join(", ");
|
|
845
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
846
|
+
name,
|
|
847
|
+
isExportable: true,
|
|
848
|
+
isIndexable: true,
|
|
849
|
+
children: /* @__PURE__ */ jsx(Function$1, {
|
|
850
|
+
name,
|
|
851
|
+
export: true,
|
|
852
|
+
params: params.toConstructor(),
|
|
853
|
+
JSDoc: { comments: getComments(operation) },
|
|
854
|
+
generics: ["TContext"],
|
|
855
|
+
children: `
|
|
856
|
+
const { mutation = {}, client: config = {} } = options ?? {}
|
|
857
|
+
const { client: queryClient, ...mutationOptions } = mutation;
|
|
858
|
+
const mutationKey = mutationOptions?.mutationKey ?? ${mutationKeyName}(${mutationKeyParams.toCall()})
|
|
859
|
+
|
|
860
|
+
return useMutation<${generics}>({
|
|
861
|
+
mutationFn: async(${dataParams.toConstructor()}) => {
|
|
862
|
+
return ${clientName}(${clientParams.toCall()})
|
|
863
|
+
},
|
|
864
|
+
mutationKey,
|
|
865
|
+
...mutationOptions
|
|
866
|
+
}, queryClient)
|
|
867
|
+
`
|
|
868
|
+
})
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
//#endregion
|
|
872
|
+
//#region src/components/Query.tsx
|
|
873
|
+
function getParams({ paramsCasing, paramsType, pathParamsType, dataReturnType, typeSchemas }) {
|
|
874
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
875
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
876
|
+
if (paramsType === "object") {
|
|
877
|
+
const children = {
|
|
878
|
+
...getPathParams(typeSchemas.pathParams, {
|
|
879
|
+
typed: true,
|
|
880
|
+
casing: paramsCasing,
|
|
881
|
+
override(item) {
|
|
882
|
+
return {
|
|
883
|
+
...item,
|
|
884
|
+
type: `MaybeRefOrGetter<${item.type}>`
|
|
885
|
+
};
|
|
886
|
+
}
|
|
887
|
+
}),
|
|
888
|
+
data: typeSchemas.request?.name ? {
|
|
889
|
+
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
890
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
891
|
+
} : void 0,
|
|
892
|
+
params: typeSchemas.queryParams?.name ? {
|
|
893
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
894
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
895
|
+
} : void 0,
|
|
896
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
897
|
+
type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
|
|
898
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
899
|
+
} : void 0
|
|
900
|
+
};
|
|
901
|
+
const allChildrenAreOptional = Object.values(children).every((child) => !child || child.optional);
|
|
902
|
+
return FunctionParams.factory({
|
|
903
|
+
data: {
|
|
904
|
+
mode: "object",
|
|
905
|
+
children,
|
|
906
|
+
default: allChildrenAreOptional ? "{}" : void 0
|
|
907
|
+
},
|
|
908
|
+
options: {
|
|
909
|
+
type: `
|
|
910
|
+
{
|
|
911
|
+
query?: Partial<UseQueryOptions<${[
|
|
912
|
+
TData,
|
|
913
|
+
TError,
|
|
914
|
+
"TData",
|
|
915
|
+
"TQueryData",
|
|
916
|
+
"TQueryKey"
|
|
917
|
+
].join(", ")}>> & { client?: QueryClient },
|
|
918
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
919
|
+
}
|
|
920
|
+
`,
|
|
921
|
+
default: "{}"
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
return FunctionParams.factory({
|
|
926
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
927
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
928
|
+
children: getPathParams(typeSchemas.pathParams, {
|
|
929
|
+
typed: true,
|
|
930
|
+
casing: paramsCasing,
|
|
931
|
+
override(item) {
|
|
932
|
+
return {
|
|
933
|
+
...item,
|
|
934
|
+
type: `MaybeRefOrGetter<${item.type}>`
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
}),
|
|
938
|
+
default: getDefaultValue(typeSchemas.pathParams?.schema)
|
|
939
|
+
} : void 0,
|
|
940
|
+
data: typeSchemas.request?.name ? {
|
|
941
|
+
type: `MaybeRefOrGetter<${typeSchemas.request?.name}>`,
|
|
942
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
943
|
+
} : void 0,
|
|
944
|
+
params: typeSchemas.queryParams?.name ? {
|
|
945
|
+
type: `MaybeRefOrGetter<${typeSchemas.queryParams?.name}>`,
|
|
946
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
947
|
+
} : void 0,
|
|
948
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
949
|
+
type: `MaybeRefOrGetter<${typeSchemas.headerParams?.name}>`,
|
|
950
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
951
|
+
} : void 0,
|
|
952
|
+
options: {
|
|
953
|
+
type: `
|
|
954
|
+
{
|
|
955
|
+
query?: Partial<UseQueryOptions<${[
|
|
956
|
+
TData,
|
|
957
|
+
TError,
|
|
958
|
+
"TData",
|
|
959
|
+
"TQueryData",
|
|
960
|
+
"TQueryKey"
|
|
961
|
+
].join(", ")}>> & { client?: QueryClient },
|
|
962
|
+
client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: Client }` : "Partial<RequestConfig> & { client?: Client }"}
|
|
963
|
+
}
|
|
964
|
+
`,
|
|
965
|
+
default: "{}"
|
|
966
|
+
}
|
|
967
|
+
});
|
|
968
|
+
}
|
|
969
|
+
function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas, operation }) {
|
|
970
|
+
const TData = dataReturnType === "data" ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`;
|
|
971
|
+
const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(" | ") || "Error"}>`;
|
|
972
|
+
const returnType = `UseQueryReturnType<${["TData", TError].join(", ")}> & { queryKey: TQueryKey }`;
|
|
973
|
+
const generics = [
|
|
974
|
+
`TData = ${TData}`,
|
|
975
|
+
`TQueryData = ${TData}`,
|
|
976
|
+
`TQueryKey extends QueryKey = ${queryKeyTypeName}`
|
|
977
|
+
];
|
|
978
|
+
const queryKeyParams = QueryKey.getParams({
|
|
979
|
+
pathParamsType,
|
|
980
|
+
typeSchemas,
|
|
981
|
+
paramsCasing
|
|
982
|
+
});
|
|
983
|
+
const queryOptionsParams = QueryOptions.getParams({
|
|
984
|
+
paramsType,
|
|
985
|
+
pathParamsType,
|
|
986
|
+
typeSchemas,
|
|
987
|
+
paramsCasing
|
|
988
|
+
});
|
|
989
|
+
const params = getParams({
|
|
990
|
+
paramsCasing,
|
|
991
|
+
paramsType,
|
|
992
|
+
pathParamsType,
|
|
993
|
+
dataReturnType,
|
|
994
|
+
typeSchemas
|
|
995
|
+
});
|
|
996
|
+
const queryOptions = `${queryOptionsName}(${queryOptionsParams.toCall()})`;
|
|
997
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
998
|
+
name,
|
|
999
|
+
isExportable: true,
|
|
1000
|
+
isIndexable: true,
|
|
1001
|
+
children: /* @__PURE__ */ jsx(Function$1, {
|
|
1002
|
+
name,
|
|
1003
|
+
export: true,
|
|
1004
|
+
generics: generics.join(", "),
|
|
1005
|
+
params: params.toConstructor(),
|
|
1006
|
+
JSDoc: { comments: getComments(operation) },
|
|
1007
|
+
children: `
|
|
1008
|
+
const { query: queryConfig = {}, client: config = {} } = options ?? {}
|
|
1009
|
+
const { client: queryClient, ...resolvedOptions } = queryConfig
|
|
1010
|
+
const queryKey = (resolvedOptions && 'queryKey' in resolvedOptions ? toValue(resolvedOptions.queryKey) : undefined) ?? ${queryKeyName}(${queryKeyParams.toCall()})
|
|
1011
|
+
|
|
1012
|
+
const query = useQuery({
|
|
1013
|
+
...${queryOptions},
|
|
1014
|
+
...resolvedOptions,
|
|
1015
|
+
queryKey
|
|
1016
|
+
} as unknown as UseQueryOptions<${TData}, ${TError}, TData, ${TData}, TQueryKey>, toValue(queryClient)) as ${returnType}
|
|
1017
|
+
|
|
1018
|
+
query.queryKey = queryKey as TQueryKey
|
|
1019
|
+
|
|
1020
|
+
return query
|
|
1021
|
+
`
|
|
1022
|
+
})
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
Query.getParams = getParams;
|
|
1026
|
+
//#endregion
|
|
1027
|
+
export { InfiniteQuery as a, camelCase as c, InfiniteQueryOptions as i, pascalCase as l, Mutation as n, QueryOptions as o, MutationKey as r, QueryKey as s, Query as t };
|
|
1028
|
+
|
|
1029
|
+
//# sourceMappingURL=components-_AMBl0g-.js.map
|