@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,124 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { o as camelCase } from "./StaticClassClient-bCe7RG_w.js";
|
|
3
|
+
import { a as classClientGenerator, i as clientGenerator, n as operationsGenerator, r as groupedClientGenerator, t as staticClassClientGenerator } from "./generators-BffddRNu.js";
|
|
4
|
+
import { source } from "./templates/clients/axios.source.js";
|
|
5
|
+
import { source as source$1 } from "./templates/clients/fetch.source.js";
|
|
6
|
+
import { source as source$2 } from "./templates/config.source.js";
|
|
7
|
+
import path from "node:path";
|
|
8
|
+
import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
9
|
+
import { OperationGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
10
|
+
import { pluginZodName } from "@kubb/plugin-zod";
|
|
11
|
+
//#region src/plugin.ts
|
|
12
|
+
const pluginClientName = "plugin-client";
|
|
13
|
+
const pluginClient = definePlugin((options) => {
|
|
14
|
+
const { output = {
|
|
15
|
+
path: "clients",
|
|
16
|
+
barrelType: "named"
|
|
17
|
+
}, group, urlType = false, exclude = [], include, override = [], transformers = {}, dataReturnType = "data", paramsType = "inline", pathParamsType = paramsType === "object" ? "object" : options.pathParamsType || "inline", operations = false, baseURL, paramsCasing, clientType = "function", parser = "client", client = "axios", importPath, contentType, bundle = false, wrapper } = options;
|
|
18
|
+
const resolvedImportPath = importPath ?? (!bundle ? `@kubb/plugin-client/clients/${client}` : void 0);
|
|
19
|
+
const defaultGenerators = [
|
|
20
|
+
clientType === "staticClass" ? staticClassClientGenerator : clientType === "class" ? classClientGenerator : clientGenerator,
|
|
21
|
+
group && clientType === "function" ? groupedClientGenerator : void 0,
|
|
22
|
+
operations ? operationsGenerator : void 0
|
|
23
|
+
].filter((x) => Boolean(x));
|
|
24
|
+
const generators = options.generators ?? defaultGenerators;
|
|
25
|
+
return {
|
|
26
|
+
name: pluginClientName,
|
|
27
|
+
options: {
|
|
28
|
+
client,
|
|
29
|
+
clientType,
|
|
30
|
+
bundle,
|
|
31
|
+
output,
|
|
32
|
+
group,
|
|
33
|
+
parser,
|
|
34
|
+
dataReturnType,
|
|
35
|
+
importPath: resolvedImportPath,
|
|
36
|
+
paramsType,
|
|
37
|
+
paramsCasing,
|
|
38
|
+
pathParamsType,
|
|
39
|
+
baseURL,
|
|
40
|
+
urlType,
|
|
41
|
+
wrapper
|
|
42
|
+
},
|
|
43
|
+
pre: [pluginOasName, parser === "zod" ? pluginZodName : void 0].filter(Boolean),
|
|
44
|
+
resolvePath(baseName, pathMode, options) {
|
|
45
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
46
|
+
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
47
|
+
/**
|
|
48
|
+
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
49
|
+
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
50
|
+
*/
|
|
51
|
+
return path.resolve(root, output.path);
|
|
52
|
+
if (group && (options?.group?.path || options?.group?.tag)) {
|
|
53
|
+
const groupName = group?.name ? group.name : (ctx) => {
|
|
54
|
+
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
55
|
+
return `${camelCase(ctx.group)}Controller`;
|
|
56
|
+
};
|
|
57
|
+
return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
|
|
58
|
+
}
|
|
59
|
+
return path.resolve(root, output.path, baseName);
|
|
60
|
+
},
|
|
61
|
+
resolveName(name, type) {
|
|
62
|
+
const resolvedName = camelCase(name, { isFile: type === "file" });
|
|
63
|
+
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
64
|
+
return resolvedName;
|
|
65
|
+
},
|
|
66
|
+
async install() {
|
|
67
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
68
|
+
const mode = getMode(path.resolve(root, output.path));
|
|
69
|
+
const oas = await this.getOas();
|
|
70
|
+
const baseURL = await this.getBaseURL();
|
|
71
|
+
if (bundle && !this.plugin.options.importPath) await this.addFile({
|
|
72
|
+
baseName: "fetch.ts",
|
|
73
|
+
path: path.resolve(root, ".kubb/fetch.ts"),
|
|
74
|
+
sources: [{
|
|
75
|
+
name: "fetch",
|
|
76
|
+
value: this.plugin.options.client === "fetch" ? source$1 : source,
|
|
77
|
+
isExportable: true,
|
|
78
|
+
isIndexable: true
|
|
79
|
+
}],
|
|
80
|
+
imports: [],
|
|
81
|
+
exports: []
|
|
82
|
+
});
|
|
83
|
+
await this.addFile({
|
|
84
|
+
baseName: "config.ts",
|
|
85
|
+
path: path.resolve(root, ".kubb/config.ts"),
|
|
86
|
+
sources: [{
|
|
87
|
+
name: "config",
|
|
88
|
+
value: source$2,
|
|
89
|
+
isExportable: false,
|
|
90
|
+
isIndexable: false
|
|
91
|
+
}],
|
|
92
|
+
imports: [],
|
|
93
|
+
exports: []
|
|
94
|
+
});
|
|
95
|
+
const files = await new OperationGenerator(baseURL ? {
|
|
96
|
+
...this.plugin.options,
|
|
97
|
+
baseURL
|
|
98
|
+
} : this.plugin.options, {
|
|
99
|
+
fabric: this.fabric,
|
|
100
|
+
oas,
|
|
101
|
+
pluginManager: this.pluginManager,
|
|
102
|
+
events: this.events,
|
|
103
|
+
plugin: this.plugin,
|
|
104
|
+
contentType,
|
|
105
|
+
exclude,
|
|
106
|
+
include,
|
|
107
|
+
override,
|
|
108
|
+
mode
|
|
109
|
+
}).build(...generators);
|
|
110
|
+
await this.upsertFile(...files);
|
|
111
|
+
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
112
|
+
type: output.barrelType ?? "named",
|
|
113
|
+
root,
|
|
114
|
+
output,
|
|
115
|
+
meta: { pluginKey: this.plugin.key }
|
|
116
|
+
});
|
|
117
|
+
await this.upsertFile(...barrelFiles);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
//#endregion
|
|
122
|
+
export { pluginClient, pluginClientName };
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=index.js.map
|
package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/axios.source.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/templates/clients/axios.source.ts
|
|
2
|
+
const source = "import type { AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'\nimport axios from 'axios'\n\ndeclare const AXIOS_BASE: string\ndeclare const AXIOS_HEADERS: string\n\n/**\n * Subset of AxiosRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n validateStatus?: (status: number) => boolean\n headers?: AxiosRequestConfig['headers']\n}\n\n/**\n * Subset of AxiosResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers: AxiosResponse['headers']\n}\n\nexport type ResponseErrorConfig<TError = unknown> = AxiosError<TError>\n\nexport type Client = <TData, _TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>) => Promise<ResponseConfig<TData>>\n\nlet _config: Partial<RequestConfig> = {\n baseURL: typeof AXIOS_BASE !== 'undefined' ? AXIOS_BASE : undefined,\n headers: typeof AXIOS_HEADERS !== 'undefined' ? JSON.parse(AXIOS_HEADERS) : undefined,\n}\n\nexport const getConfig = () => _config\n\nexport const setConfig = (config: RequestConfig) => {\n _config = config\n return getConfig()\n}\n\nexport const mergeConfig = <T extends RequestConfig>(...configs: Array<Partial<T>>): Partial<T> => {\n return configs.reduce<Partial<T>>((merged, config) => {\n return {\n ...merged,\n ...config,\n headers: {\n ...merged.headers,\n ...config.headers,\n },\n }\n }, {})\n}\n\nexport const axiosInstance = axios.create(getConfig())\n\nexport const fetch = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n return axiosInstance.request<TData, ResponseConfig<TData>>(mergeConfig(getConfig(), config)).catch((e: AxiosError<TError>) => {\n throw e\n })\n}\n\nfetch.getConfig = getConfig\nfetch.setConfig = setConfig\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { source };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=axios.source.js.map
|
package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/fetch.source.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/templates/clients/fetch.source.ts
|
|
2
|
+
const source = "/**\n * RequestCredentials\n */\nexport type RequestCredentials = 'omit' | 'same-origin' | 'include'\n\n/**\n * Subset of FetchRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method?: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: [string, string][] | Record<string, string>\n credentials?: RequestCredentials\n}\n\n/**\n * Subset of FetchResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers: Headers\n}\n\nlet _config: Partial<RequestConfig> = {}\n\nexport const getConfig = () => _config\n\nexport const setConfig = (config: Partial<RequestConfig>) => {\n _config = config\n return getConfig()\n}\n\nexport const mergeConfig = <T extends RequestConfig>(...configs: Array<Partial<T>>): Partial<T> => {\n return configs.reduce<Partial<T>>((merged, config) => {\n return {\n ...merged,\n ...config,\n headers: {\n ...(Array.isArray(merged.headers) ? Object.fromEntries(merged.headers) : merged.headers),\n ...(Array.isArray(config.headers) ? Object.fromEntries(config.headers) : config.headers),\n },\n }\n }, {})\n}\n\nexport type ResponseErrorConfig<TError = unknown> = TError\n\nexport type Client = <TData, _TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>) => Promise<ResponseConfig<TData>>\n\nexport const fetch = async <TData, _TError = unknown, TVariables = unknown>(paramsConfig: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const normalizedParams = new URLSearchParams()\n\n const config = mergeConfig(getConfig(), paramsConfig)\n\n Object.entries(config.params || {}).forEach(([key, value]) => {\n if (value !== undefined) {\n normalizedParams.append(key, value === null ? 'null' : value.toString())\n }\n })\n\n let targetUrl = [config.baseURL, config.url].filter(Boolean).join('')\n\n if (config.params) {\n targetUrl += `?${normalizedParams}`\n }\n\n const response = await globalThis.fetch(targetUrl, {\n credentials: config.credentials || 'same-origin',\n method: config.method?.toUpperCase(),\n body: config.data instanceof FormData ? config.data : JSON.stringify(config.data),\n signal: config.signal,\n headers: config.headers,\n })\n\n const data = [204, 205, 304].includes(response.status) || !response.body ? {} : await response.json()\n\n return {\n data: data as TData,\n status: response.status,\n statusText: response.statusText,\n headers: response.headers as Headers,\n }\n}\n\nfetch.getConfig = getConfig\nfetch.setConfig = setConfig\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { source };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=fetch.source.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/templates/config.source.ts
|
|
2
|
+
const source = "export function buildFormData<T = unknown>(data: T): FormData {\n const formData = new FormData()\n\n function appendData(key: string, value: any) {\n if (value instanceof Blob) {\n formData.append(key, value)\n return\n }\n if (value instanceof Date) {\n formData.append(key, value.toISOString())\n return\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n formData.append(key, String(value))\n return\n }\n if (typeof value === 'string') {\n formData.append(key, value)\n return\n }\n if (typeof value === 'object') {\n formData.append(key, new Blob([JSON.stringify(value)], { type: 'application/json' }))\n return\n }\n }\n\n if (data) {\n Object.entries(data).forEach(([key, value]) => {\n if (value === undefined || value === null) return\n\n if (Array.isArray(value)) {\n for (const valueItem of value) {\n if (valueItem === undefined || valueItem === null) continue\n appendData(key, valueItem)\n }\n } else {\n appendData(key, value)\n }\n })\n }\n\n return formData\n}\n";
|
|
3
|
+
//#endregion
|
|
4
|
+
export { source };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=config.source.js.map
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kubb/plugin-client",
|
|
3
|
+
"version": "4.37.2",
|
|
4
|
+
"description": "API client generator plugin for Kubb, creating type-safe HTTP clients (Axios, Fetch) from OpenAPI specifications for making API requests.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"api-client",
|
|
7
|
+
"http-client",
|
|
8
|
+
"sdk-generator",
|
|
9
|
+
"axios",
|
|
10
|
+
"fetch",
|
|
11
|
+
"rest-api",
|
|
12
|
+
"typescript",
|
|
13
|
+
"type-safety",
|
|
14
|
+
"type-safe",
|
|
15
|
+
"openapi",
|
|
16
|
+
"swagger",
|
|
17
|
+
"oas",
|
|
18
|
+
"code-generator",
|
|
19
|
+
"codegen",
|
|
20
|
+
"plugins",
|
|
21
|
+
"kubb"
|
|
22
|
+
],
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/kubb-labs/kubb.git",
|
|
26
|
+
"directory": "packages/plugin-client"
|
|
27
|
+
},
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"author": "stijnvanhulle",
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"type": "module",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"require": "./dist/index.cjs"
|
|
36
|
+
},
|
|
37
|
+
"./clients/axios": {
|
|
38
|
+
"import": "./dist/clients/axios.js",
|
|
39
|
+
"require": "./dist/clients/axios.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./clients/fetch": {
|
|
42
|
+
"import": "./dist/clients/fetch.js",
|
|
43
|
+
"require": "./dist/clients/fetch.cjs"
|
|
44
|
+
},
|
|
45
|
+
"./components": {
|
|
46
|
+
"import": "./dist/components.js",
|
|
47
|
+
"require": "./dist/components.cjs"
|
|
48
|
+
},
|
|
49
|
+
"./generators": {
|
|
50
|
+
"import": "./dist/generators.js",
|
|
51
|
+
"require": "./dist/generators.cjs"
|
|
52
|
+
},
|
|
53
|
+
"./templates/clients/axios.source": {
|
|
54
|
+
"import": "./dist/templates/clients/axios.source.js",
|
|
55
|
+
"require": "./dist/templates/clients/axios.source.cjs"
|
|
56
|
+
},
|
|
57
|
+
"./templates/clients/fetch.source": {
|
|
58
|
+
"import": "./dist/templates/clients/fetch.source.js",
|
|
59
|
+
"require": "./dist/templates/clients/fetch.source.cjs"
|
|
60
|
+
},
|
|
61
|
+
"./templates/config.source": {
|
|
62
|
+
"import": "./dist/templates/config.source.js",
|
|
63
|
+
"require": "./dist/templates/config.source.cjs"
|
|
64
|
+
},
|
|
65
|
+
"./package.json": "./package.json"
|
|
66
|
+
},
|
|
67
|
+
"types": "./dist/index.d.ts",
|
|
68
|
+
"typesVersions": {
|
|
69
|
+
"*": {
|
|
70
|
+
"components": [
|
|
71
|
+
"./dist/components.d.ts"
|
|
72
|
+
],
|
|
73
|
+
"generators": [
|
|
74
|
+
"./dist/generators.d.ts"
|
|
75
|
+
],
|
|
76
|
+
"clients/axios": [
|
|
77
|
+
"./dist/clients/axios.d.ts"
|
|
78
|
+
],
|
|
79
|
+
"clients/fetch": [
|
|
80
|
+
"./dist/clients/fetch.d.ts"
|
|
81
|
+
],
|
|
82
|
+
"templates/config.source": [
|
|
83
|
+
"./dist/templates/config.source.d.ts"
|
|
84
|
+
],
|
|
85
|
+
"templates/clients/axios.source": [
|
|
86
|
+
"./dist/templates/clients/axios.source.d.ts"
|
|
87
|
+
],
|
|
88
|
+
"templates/clients/fetch.source": [
|
|
89
|
+
"./dist/templates/clients/fetch.source.d.ts"
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
"files": [
|
|
94
|
+
"src",
|
|
95
|
+
"dist",
|
|
96
|
+
"templates",
|
|
97
|
+
"*.d.ts",
|
|
98
|
+
"*.d.cts",
|
|
99
|
+
"!/**/**.test.**",
|
|
100
|
+
"!/**/__tests__/**",
|
|
101
|
+
"!/**/__snapshots__/**"
|
|
102
|
+
],
|
|
103
|
+
"size-limit": [
|
|
104
|
+
{
|
|
105
|
+
"path": "./dist/*.js",
|
|
106
|
+
"limit": "510 KiB",
|
|
107
|
+
"gzip": true
|
|
108
|
+
}
|
|
109
|
+
],
|
|
110
|
+
"dependencies": {
|
|
111
|
+
"@kubb/fabric-core": "0.14.0",
|
|
112
|
+
"@kubb/react-fabric": "0.14.0",
|
|
113
|
+
"@kubb/core": "4.37.2",
|
|
114
|
+
"@kubb/oas": "4.37.2",
|
|
115
|
+
"@kubb/plugin-oas": "4.37.2",
|
|
116
|
+
"@kubb/plugin-ts": "4.37.2",
|
|
117
|
+
"@kubb/plugin-zod": "4.37.2"
|
|
118
|
+
},
|
|
119
|
+
"devDependencies": {
|
|
120
|
+
"axios": "^1.13.6",
|
|
121
|
+
"@internals/utils": "0.0.0"
|
|
122
|
+
},
|
|
123
|
+
"peerDependencies": {
|
|
124
|
+
"@kubb/fabric-core": "0.14.0",
|
|
125
|
+
"@kubb/react-fabric": "0.14.0",
|
|
126
|
+
"axios": "^1.7.2"
|
|
127
|
+
},
|
|
128
|
+
"peerDependenciesMeta": {
|
|
129
|
+
"axios": {
|
|
130
|
+
"optional": true
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"engines": {
|
|
134
|
+
"node": ">=20"
|
|
135
|
+
},
|
|
136
|
+
"publishConfig": {
|
|
137
|
+
"access": "public",
|
|
138
|
+
"registry": "https://registry.npmjs.org/"
|
|
139
|
+
},
|
|
140
|
+
"main": "./dist/index.cjs",
|
|
141
|
+
"module": "./dist/index.js",
|
|
142
|
+
"scripts": {
|
|
143
|
+
"build": "tsdown && size-limit",
|
|
144
|
+
"clean": "npx rimraf ./dist",
|
|
145
|
+
"lint": "bun biome lint .",
|
|
146
|
+
"lint:fix": "bun biome lint --fix --unsafe .",
|
|
147
|
+
"release": "pnpm publish --no-git-check",
|
|
148
|
+
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
149
|
+
"start": "tsdown --watch",
|
|
150
|
+
"test": "vitest --passWithNoTests",
|
|
151
|
+
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { getPathParams } from "@kubb/plugin-oas/utils";
|
|
3
|
+
import { File, Function as Function$1, FunctionParams } from "@kubb/react-fabric";
|
|
4
|
+
import { isAllOptional, isOptional } from "@kubb/oas";
|
|
5
|
+
import { jsx } from "@kubb/react-fabric/jsx-runtime";
|
|
6
|
+
//#region ../../internals/utils/src/casing.ts
|
|
7
|
+
/**
|
|
8
|
+
* Shared implementation for camelCase and PascalCase conversion.
|
|
9
|
+
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
10
|
+
* and capitalizes each word according to `pascal`.
|
|
11
|
+
*
|
|
12
|
+
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
13
|
+
*/
|
|
14
|
+
function toCamelOrPascal(text, pascal) {
|
|
15
|
+
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) => {
|
|
16
|
+
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
17
|
+
if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
18
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
19
|
+
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
23
|
+
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
24
|
+
* Segments are joined with `/` to form a file path.
|
|
25
|
+
*/
|
|
26
|
+
function applyToFileParts(text, transformPart) {
|
|
27
|
+
const parts = text.split(".");
|
|
28
|
+
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Converts `text` to camelCase.
|
|
32
|
+
* When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* camelCase('hello-world') // 'helloWorld'
|
|
36
|
+
* camelCase('pet.petId', { isFile: true }) // 'pet/petId'
|
|
37
|
+
*/
|
|
38
|
+
function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
39
|
+
if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
|
|
40
|
+
prefix,
|
|
41
|
+
suffix
|
|
42
|
+
} : {}));
|
|
43
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region ../../internals/utils/src/reserved.ts
|
|
47
|
+
/**
|
|
48
|
+
* Returns `true` when `name` is a syntactically valid JavaScript variable name.
|
|
49
|
+
*/
|
|
50
|
+
function isValidVarName(name) {
|
|
51
|
+
try {
|
|
52
|
+
new Function(`var ${name}`);
|
|
53
|
+
} catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region ../../internals/utils/src/urlPath.ts
|
|
60
|
+
/**
|
|
61
|
+
* Parses and transforms an OpenAPI/Swagger path string into various URL formats.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* const p = new URLPath('/pet/{petId}')
|
|
65
|
+
* p.URL // '/pet/:petId'
|
|
66
|
+
* p.template // '`/pet/${petId}`'
|
|
67
|
+
*/
|
|
68
|
+
var URLPath = class {
|
|
69
|
+
/** The raw OpenAPI/Swagger path string, e.g. `/pet/{petId}`. */
|
|
70
|
+
path;
|
|
71
|
+
#options;
|
|
72
|
+
constructor(path, options = {}) {
|
|
73
|
+
this.path = path;
|
|
74
|
+
this.#options = options;
|
|
75
|
+
}
|
|
76
|
+
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */
|
|
77
|
+
get URL() {
|
|
78
|
+
return this.toURLPath();
|
|
79
|
+
}
|
|
80
|
+
/** Returns `true` when `path` is a fully-qualified URL (e.g. starts with `https://`). */
|
|
81
|
+
get isURL() {
|
|
82
|
+
try {
|
|
83
|
+
return !!new URL(this.path).href;
|
|
84
|
+
} catch {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* new URLPath('/pet/{petId}').template // '`/pet/${petId}`'
|
|
93
|
+
* new URLPath('/account/monetary-accountID').template // '`/account/${monetaryAccountId}`'
|
|
94
|
+
*/
|
|
95
|
+
get template() {
|
|
96
|
+
return this.toTemplateString();
|
|
97
|
+
}
|
|
98
|
+
/** Returns the path and its extracted params as a structured `URLObject`, or as a stringified expression when `stringify` is set. */
|
|
99
|
+
get object() {
|
|
100
|
+
return this.toObject();
|
|
101
|
+
}
|
|
102
|
+
/** Returns a map of path parameter names, or `undefined` when the path has no parameters. */
|
|
103
|
+
get params() {
|
|
104
|
+
return this.getParams();
|
|
105
|
+
}
|
|
106
|
+
#transformParam(raw) {
|
|
107
|
+
const param = isValidVarName(raw) ? raw : camelCase(raw);
|
|
108
|
+
return this.#options.casing === "camelcase" ? camelCase(param) : param;
|
|
109
|
+
}
|
|
110
|
+
/** Iterates over every `{param}` token in `path`, calling `fn` with the raw token and transformed name. */
|
|
111
|
+
#eachParam(fn) {
|
|
112
|
+
for (const match of this.path.matchAll(/\{([^}]+)\}/g)) {
|
|
113
|
+
const raw = match[1];
|
|
114
|
+
fn(raw, this.#transformParam(raw));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
toObject({ type = "path", replacer, stringify } = {}) {
|
|
118
|
+
const object = {
|
|
119
|
+
url: type === "path" ? this.toURLPath() : this.toTemplateString({ replacer }),
|
|
120
|
+
params: this.getParams()
|
|
121
|
+
};
|
|
122
|
+
if (stringify) {
|
|
123
|
+
if (type === "template") return JSON.stringify(object).replaceAll("'", "").replaceAll(`"`, "");
|
|
124
|
+
if (object.params) return `{ url: '${object.url}', params: ${JSON.stringify(object.params).replaceAll("'", "").replaceAll(`"`, "")} }`;
|
|
125
|
+
return `{ url: '${object.url}' }`;
|
|
126
|
+
}
|
|
127
|
+
return object;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Converts the OpenAPI path to a TypeScript template literal string.
|
|
131
|
+
* An optional `replacer` can transform each extracted parameter name before interpolation.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* new URLPath('/pet/{petId}').toTemplateString() // '`/pet/${petId}`'
|
|
135
|
+
*/
|
|
136
|
+
toTemplateString({ prefix = "", replacer } = {}) {
|
|
137
|
+
return `\`${prefix}${this.path.split(/\{([^}]+)\}/).map((part, i) => {
|
|
138
|
+
if (i % 2 === 0) return part;
|
|
139
|
+
const param = this.#transformParam(part);
|
|
140
|
+
return `\${${replacer ? replacer(param) : param}}`;
|
|
141
|
+
}).join("")}\``;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Extracts all `{param}` segments from the path and returns them as a key-value map.
|
|
145
|
+
* An optional `replacer` transforms each parameter name in both key and value positions.
|
|
146
|
+
* Returns `undefined` when no path parameters are found.
|
|
147
|
+
*/
|
|
148
|
+
getParams(replacer) {
|
|
149
|
+
const params = {};
|
|
150
|
+
this.#eachParam((_raw, param) => {
|
|
151
|
+
const key = replacer ? replacer(param) : param;
|
|
152
|
+
params[key] = key;
|
|
153
|
+
});
|
|
154
|
+
return Object.keys(params).length > 0 ? params : void 0;
|
|
155
|
+
}
|
|
156
|
+
/** Converts the OpenAPI path to Express-style colon syntax, e.g. `/pet/{petId}` → `/pet/:petId`. */
|
|
157
|
+
toURLPath() {
|
|
158
|
+
return this.path.replace(/\{([^}]+)\}/g, ":$1");
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/components/Request.tsx
|
|
163
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }) {
|
|
164
|
+
if (paramsType === "object") {
|
|
165
|
+
const pathParams = getPathParams(typeSchemas.pathParams, {
|
|
166
|
+
typed: true,
|
|
167
|
+
casing: paramsCasing
|
|
168
|
+
});
|
|
169
|
+
return FunctionParams.factory({
|
|
170
|
+
data: {
|
|
171
|
+
mode: "object",
|
|
172
|
+
children: {
|
|
173
|
+
...pathParams,
|
|
174
|
+
data: typeSchemas.request?.name ? {
|
|
175
|
+
type: typeSchemas.request?.name,
|
|
176
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
177
|
+
} : void 0,
|
|
178
|
+
params: typeSchemas.queryParams?.name ? {
|
|
179
|
+
type: typeSchemas.queryParams?.name,
|
|
180
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
181
|
+
} : void 0,
|
|
182
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
183
|
+
type: typeSchemas.headerParams?.name,
|
|
184
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
185
|
+
} : void 0
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
options: {
|
|
189
|
+
type: "Partial<Cypress.RequestOptions>",
|
|
190
|
+
default: "{}"
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
return FunctionParams.factory({
|
|
195
|
+
pathParams: typeSchemas.pathParams?.name ? {
|
|
196
|
+
mode: pathParamsType === "object" ? "object" : "inlineSpread",
|
|
197
|
+
children: getPathParams(typeSchemas.pathParams, {
|
|
198
|
+
typed: true,
|
|
199
|
+
casing: paramsCasing
|
|
200
|
+
}),
|
|
201
|
+
default: isAllOptional(typeSchemas.pathParams?.schema) ? "{}" : void 0
|
|
202
|
+
} : void 0,
|
|
203
|
+
data: typeSchemas.request?.name ? {
|
|
204
|
+
type: typeSchemas.request?.name,
|
|
205
|
+
optional: isOptional(typeSchemas.request?.schema)
|
|
206
|
+
} : void 0,
|
|
207
|
+
params: typeSchemas.queryParams?.name ? {
|
|
208
|
+
type: typeSchemas.queryParams?.name,
|
|
209
|
+
optional: isOptional(typeSchemas.queryParams?.schema)
|
|
210
|
+
} : void 0,
|
|
211
|
+
headers: typeSchemas.headerParams?.name ? {
|
|
212
|
+
type: typeSchemas.headerParams?.name,
|
|
213
|
+
optional: isOptional(typeSchemas.headerParams?.schema)
|
|
214
|
+
} : void 0,
|
|
215
|
+
options: {
|
|
216
|
+
type: "Partial<Cypress.RequestOptions>",
|
|
217
|
+
default: "{}"
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function Request({ baseURL = "", name, dataReturnType, typeSchemas, url, method, paramsType, paramsCasing, pathParamsType }) {
|
|
222
|
+
const path = new URLPath(url, { casing: paramsCasing });
|
|
223
|
+
const params = getParams({
|
|
224
|
+
paramsType,
|
|
225
|
+
paramsCasing,
|
|
226
|
+
pathParamsType,
|
|
227
|
+
typeSchemas
|
|
228
|
+
});
|
|
229
|
+
const returnType = dataReturnType === "data" ? `Cypress.Chainable<${typeSchemas.response.name}>` : `Cypress.Chainable<Cypress.Response<${typeSchemas.response.name}>>`;
|
|
230
|
+
const urlTemplate = path.toTemplateString({ prefix: baseURL });
|
|
231
|
+
const requestOptions = [`method: '${method}'`, `url: ${urlTemplate}`];
|
|
232
|
+
if (typeSchemas.queryParams?.name) requestOptions.push("qs: params");
|
|
233
|
+
if (typeSchemas.headerParams?.name) requestOptions.push("headers");
|
|
234
|
+
if (typeSchemas.request?.name) requestOptions.push("body: data");
|
|
235
|
+
requestOptions.push("...options");
|
|
236
|
+
return /* @__PURE__ */ jsx(File.Source, {
|
|
237
|
+
name,
|
|
238
|
+
isIndexable: true,
|
|
239
|
+
isExportable: true,
|
|
240
|
+
children: /* @__PURE__ */ jsx(Function$1, {
|
|
241
|
+
name,
|
|
242
|
+
export: true,
|
|
243
|
+
params: params.toConstructor(),
|
|
244
|
+
returnType,
|
|
245
|
+
children: dataReturnType === "data" ? `return cy.request<${typeSchemas.response.name}>({
|
|
246
|
+
${requestOptions.join(",\n ")}
|
|
247
|
+
}).then((res) => res.body)` : `return cy.request<${typeSchemas.response.name}>({
|
|
248
|
+
${requestOptions.join(",\n ")}
|
|
249
|
+
})`
|
|
250
|
+
})
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
Request.getParams = getParams;
|
|
254
|
+
//#endregion
|
|
255
|
+
export { camelCase as n, Request as t };
|
|
256
|
+
|
|
257
|
+
//# sourceMappingURL=components-BK_6GU4v.js.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { t as Request } from "./components-BK_6GU4v.js";
|
|
3
|
+
import { pluginTsName } from "@kubb/plugin-ts";
|
|
4
|
+
import { usePluginManager } from "@kubb/core/hooks";
|
|
5
|
+
import { createReactGenerator } from "@kubb/plugin-oas/generators";
|
|
6
|
+
import { useOas, useOperationManager } from "@kubb/plugin-oas/hooks";
|
|
7
|
+
import { getBanner, getFooter } from "@kubb/plugin-oas/utils";
|
|
8
|
+
import { File } from "@kubb/react-fabric";
|
|
9
|
+
import { jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
10
|
+
//#region src/generators/cypressGenerator.tsx
|
|
11
|
+
const cypressGenerator = createReactGenerator({
|
|
12
|
+
name: "cypress",
|
|
13
|
+
Operation({ operation, generator, plugin }) {
|
|
14
|
+
const { options: { output, baseURL, dataReturnType, paramsCasing, paramsType, pathParamsType } } = plugin;
|
|
15
|
+
const pluginManager = usePluginManager();
|
|
16
|
+
const oas = useOas();
|
|
17
|
+
const { getSchemas, getName, getFile } = useOperationManager(generator);
|
|
18
|
+
const request = {
|
|
19
|
+
name: getName(operation, { type: "function" }),
|
|
20
|
+
file: getFile(operation)
|
|
21
|
+
};
|
|
22
|
+
const type = {
|
|
23
|
+
file: getFile(operation, { pluginKey: [pluginTsName] }),
|
|
24
|
+
schemas: getSchemas(operation, {
|
|
25
|
+
pluginKey: [pluginTsName],
|
|
26
|
+
type: "type"
|
|
27
|
+
})
|
|
28
|
+
};
|
|
29
|
+
return /* @__PURE__ */ jsxs(File, {
|
|
30
|
+
baseName: request.file.baseName,
|
|
31
|
+
path: request.file.path,
|
|
32
|
+
meta: request.file.meta,
|
|
33
|
+
banner: getBanner({
|
|
34
|
+
oas,
|
|
35
|
+
output,
|
|
36
|
+
config: pluginManager.config
|
|
37
|
+
}),
|
|
38
|
+
footer: getFooter({
|
|
39
|
+
oas,
|
|
40
|
+
output
|
|
41
|
+
}),
|
|
42
|
+
children: [/* @__PURE__ */ jsx(File.Import, {
|
|
43
|
+
name: [
|
|
44
|
+
type.schemas.request?.name,
|
|
45
|
+
type.schemas.response.name,
|
|
46
|
+
type.schemas.pathParams?.name,
|
|
47
|
+
type.schemas.queryParams?.name,
|
|
48
|
+
type.schemas.headerParams?.name,
|
|
49
|
+
...type.schemas.statusCodes?.map((item) => item.name) || []
|
|
50
|
+
].filter(Boolean),
|
|
51
|
+
root: request.file.path,
|
|
52
|
+
path: type.file.path,
|
|
53
|
+
isTypeOnly: true
|
|
54
|
+
}), /* @__PURE__ */ jsx(Request, {
|
|
55
|
+
name: request.name,
|
|
56
|
+
dataReturnType,
|
|
57
|
+
paramsCasing,
|
|
58
|
+
paramsType,
|
|
59
|
+
pathParamsType,
|
|
60
|
+
typeSchemas: type.schemas,
|
|
61
|
+
method: operation.method,
|
|
62
|
+
baseURL,
|
|
63
|
+
url: operation.path
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
//#endregion
|
|
69
|
+
export { cypressGenerator as t };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=generators-D5YFtyyC.js.map
|