@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,200 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { t as Faker } from "./components-BkBIov4R.js";
|
|
3
|
+
import { SchemaGenerator, schemaKeywords } from "@kubb/plugin-oas";
|
|
4
|
+
import { pluginTsName } from "@kubb/plugin-ts";
|
|
5
|
+
import { useMode, usePluginManager } from "@kubb/core/hooks";
|
|
6
|
+
import { createReactGenerator } from "@kubb/plugin-oas/generators";
|
|
7
|
+
import { useOas, useOperationManager, useSchemaManager } from "@kubb/plugin-oas/hooks";
|
|
8
|
+
import { applyParamsCasing, getBanner, getFooter, getImports, isParameterSchema } from "@kubb/plugin-oas/utils";
|
|
9
|
+
import { File } from "@kubb/react-fabric";
|
|
10
|
+
import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
11
|
+
//#region src/generators/fakerGenerator.tsx
|
|
12
|
+
const fakerGenerator = createReactGenerator({
|
|
13
|
+
name: "faker",
|
|
14
|
+
Operation({ operation, generator, plugin }) {
|
|
15
|
+
const { options, options: { dateParser, regexGenerator, seed, mapper } } = plugin;
|
|
16
|
+
const mode = useMode();
|
|
17
|
+
const pluginManager = usePluginManager();
|
|
18
|
+
const oas = useOas();
|
|
19
|
+
const { getSchemas, getFile, getGroup } = useOperationManager(generator);
|
|
20
|
+
const schemaManager = useSchemaManager();
|
|
21
|
+
const file = getFile(operation);
|
|
22
|
+
const schemas = getSchemas(operation);
|
|
23
|
+
const schemaGenerator = new SchemaGenerator(options, {
|
|
24
|
+
fabric: generator.context.fabric,
|
|
25
|
+
oas,
|
|
26
|
+
plugin,
|
|
27
|
+
events: generator.context.events,
|
|
28
|
+
pluginManager,
|
|
29
|
+
mode,
|
|
30
|
+
override: options.override
|
|
31
|
+
});
|
|
32
|
+
const operationSchemas = [
|
|
33
|
+
schemas.pathParams,
|
|
34
|
+
schemas.queryParams,
|
|
35
|
+
schemas.headerParams,
|
|
36
|
+
schemas.statusCodes,
|
|
37
|
+
schemas.request,
|
|
38
|
+
schemas.response
|
|
39
|
+
].flat().filter((x) => Boolean(x));
|
|
40
|
+
const mapOperationSchema = ({ name, schema, description, ...options }) => {
|
|
41
|
+
const transformedSchema = isParameterSchema(name) && plugin.options.paramsCasing ? applyParamsCasing(schema, plugin.options.paramsCasing) : schema;
|
|
42
|
+
const tree = schemaGenerator.parse({
|
|
43
|
+
schema: transformedSchema,
|
|
44
|
+
name,
|
|
45
|
+
parentName: null
|
|
46
|
+
});
|
|
47
|
+
const imports = getImports(tree);
|
|
48
|
+
const group = options.operation ? getGroup(options.operation) : void 0;
|
|
49
|
+
const faker = {
|
|
50
|
+
name: schemaManager.getName(name, { type: "function" }),
|
|
51
|
+
file: schemaManager.getFile(name)
|
|
52
|
+
};
|
|
53
|
+
const type = {
|
|
54
|
+
name: schemaManager.getName(name, {
|
|
55
|
+
type: "type",
|
|
56
|
+
pluginKey: [pluginTsName]
|
|
57
|
+
}),
|
|
58
|
+
file: schemaManager.getFile(options.operationName || name, {
|
|
59
|
+
pluginKey: [pluginTsName],
|
|
60
|
+
group
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
const canOverride = tree.some(({ keyword }) => keyword === schemaKeywords.array || keyword === schemaKeywords.and || keyword === schemaKeywords.object || keyword === schemaKeywords.union || keyword === schemaKeywords.tuple || keyword === schemaKeywords.enum || keyword === schemaKeywords.ref);
|
|
64
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
65
|
+
canOverride && /* @__PURE__ */ jsx(File.Import, {
|
|
66
|
+
isTypeOnly: true,
|
|
67
|
+
root: file.path,
|
|
68
|
+
path: type.file.path,
|
|
69
|
+
name: [type.name]
|
|
70
|
+
}),
|
|
71
|
+
imports.map((imp) => /* @__PURE__ */ jsx(File.Import, {
|
|
72
|
+
root: file.path,
|
|
73
|
+
path: imp.path,
|
|
74
|
+
name: imp.name
|
|
75
|
+
}, [
|
|
76
|
+
imp.path,
|
|
77
|
+
imp.name,
|
|
78
|
+
imp.isTypeOnly
|
|
79
|
+
].join("-"))),
|
|
80
|
+
/* @__PURE__ */ jsx(Faker, {
|
|
81
|
+
name: faker.name,
|
|
82
|
+
typeName: type.name,
|
|
83
|
+
description,
|
|
84
|
+
tree,
|
|
85
|
+
regexGenerator,
|
|
86
|
+
dateParser,
|
|
87
|
+
mapper,
|
|
88
|
+
seed,
|
|
89
|
+
canOverride
|
|
90
|
+
})
|
|
91
|
+
] });
|
|
92
|
+
};
|
|
93
|
+
return /* @__PURE__ */ jsxs(File, {
|
|
94
|
+
baseName: file.baseName,
|
|
95
|
+
path: file.path,
|
|
96
|
+
meta: file.meta,
|
|
97
|
+
banner: getBanner({
|
|
98
|
+
oas,
|
|
99
|
+
output: plugin.options.output,
|
|
100
|
+
config: pluginManager.config
|
|
101
|
+
}),
|
|
102
|
+
footer: getFooter({
|
|
103
|
+
oas,
|
|
104
|
+
output: plugin.options.output
|
|
105
|
+
}),
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
108
|
+
name: ["faker"],
|
|
109
|
+
path: "@faker-js/faker"
|
|
110
|
+
}),
|
|
111
|
+
regexGenerator === "randexp" && /* @__PURE__ */ jsx(File.Import, {
|
|
112
|
+
name: "RandExp",
|
|
113
|
+
path: "randexp"
|
|
114
|
+
}),
|
|
115
|
+
dateParser !== "faker" && /* @__PURE__ */ jsx(File.Import, {
|
|
116
|
+
path: dateParser,
|
|
117
|
+
name: dateParser
|
|
118
|
+
}),
|
|
119
|
+
operationSchemas.map(mapOperationSchema)
|
|
120
|
+
]
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
Schema({ schema, plugin }) {
|
|
124
|
+
const { getName, getFile } = useSchemaManager();
|
|
125
|
+
const { options: { output, dateParser, regexGenerator, seed, mapper } } = plugin;
|
|
126
|
+
const pluginManager = usePluginManager();
|
|
127
|
+
const oas = useOas();
|
|
128
|
+
const imports = getImports(schema.tree);
|
|
129
|
+
const faker = {
|
|
130
|
+
name: getName(schema.name, { type: "function" }),
|
|
131
|
+
file: getFile(schema.name)
|
|
132
|
+
};
|
|
133
|
+
const type = {
|
|
134
|
+
name: getName(schema.name, {
|
|
135
|
+
type: "type",
|
|
136
|
+
pluginKey: [pluginTsName]
|
|
137
|
+
}),
|
|
138
|
+
file: getFile(schema.name, { pluginKey: [pluginTsName] })
|
|
139
|
+
};
|
|
140
|
+
const canOverride = schema.tree.some(({ keyword }) => keyword === schemaKeywords.array || keyword === schemaKeywords.and || keyword === schemaKeywords.object || keyword === schemaKeywords.union || keyword === schemaKeywords.tuple || keyword === schemaKeywords.ref || keyword === schemaKeywords.enum || keyword === schemaKeywords.string || keyword === schemaKeywords.integer || keyword === schemaKeywords.number);
|
|
141
|
+
return /* @__PURE__ */ jsxs(File, {
|
|
142
|
+
baseName: faker.file.baseName,
|
|
143
|
+
path: faker.file.path,
|
|
144
|
+
meta: faker.file.meta,
|
|
145
|
+
banner: getBanner({
|
|
146
|
+
oas,
|
|
147
|
+
output,
|
|
148
|
+
config: pluginManager.config
|
|
149
|
+
}),
|
|
150
|
+
footer: getFooter({
|
|
151
|
+
oas,
|
|
152
|
+
output
|
|
153
|
+
}),
|
|
154
|
+
children: [
|
|
155
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
156
|
+
name: ["faker"],
|
|
157
|
+
path: "@faker-js/faker"
|
|
158
|
+
}),
|
|
159
|
+
regexGenerator === "randexp" && /* @__PURE__ */ jsx(File.Import, {
|
|
160
|
+
name: "RandExp",
|
|
161
|
+
path: "randexp"
|
|
162
|
+
}),
|
|
163
|
+
dateParser !== "faker" && /* @__PURE__ */ jsx(File.Import, {
|
|
164
|
+
path: dateParser,
|
|
165
|
+
name: dateParser
|
|
166
|
+
}),
|
|
167
|
+
/* @__PURE__ */ jsx(File.Import, {
|
|
168
|
+
isTypeOnly: true,
|
|
169
|
+
root: faker.file.path,
|
|
170
|
+
path: type.file.path,
|
|
171
|
+
name: [type.name]
|
|
172
|
+
}),
|
|
173
|
+
imports.map((imp) => /* @__PURE__ */ jsx(File.Import, {
|
|
174
|
+
root: faker.file.path,
|
|
175
|
+
path: imp.path,
|
|
176
|
+
name: imp.name
|
|
177
|
+
}, [
|
|
178
|
+
imp.path,
|
|
179
|
+
imp.name,
|
|
180
|
+
imp.isTypeOnly
|
|
181
|
+
].join("-"))),
|
|
182
|
+
/* @__PURE__ */ jsx(Faker, {
|
|
183
|
+
name: faker.name,
|
|
184
|
+
typeName: type.name,
|
|
185
|
+
description: schema.value.description,
|
|
186
|
+
tree: schema.tree,
|
|
187
|
+
regexGenerator,
|
|
188
|
+
dateParser,
|
|
189
|
+
mapper,
|
|
190
|
+
seed,
|
|
191
|
+
canOverride
|
|
192
|
+
})
|
|
193
|
+
]
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
//#endregion
|
|
198
|
+
export { fakerGenerator as t };
|
|
199
|
+
|
|
200
|
+
//# sourceMappingURL=fakerGenerator-BztogaeO.js.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { t as fakerGenerator } from "./fakerGenerator-BztogaeO.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { definePlugin, getBarrelFiles, getMode } from "@kubb/core";
|
|
5
|
+
import { OperationGenerator, SchemaGenerator, pluginOasName } from "@kubb/plugin-oas";
|
|
6
|
+
import { pluginTsName } from "@kubb/plugin-ts";
|
|
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
|
+
//#endregion
|
|
47
|
+
//#region src/plugin.ts
|
|
48
|
+
const pluginFakerName = "plugin-faker";
|
|
49
|
+
const pluginFaker = definePlugin((options) => {
|
|
50
|
+
const { output = {
|
|
51
|
+
path: "mocks",
|
|
52
|
+
barrelType: "named"
|
|
53
|
+
}, seed, group, exclude = [], include, override = [], transformers = {}, mapper = {}, unknownType = "any", emptySchemaType = unknownType, dateType = "string", integerType = "number", dateParser = "faker", generators = [fakerGenerator].filter(Boolean), regexGenerator = "faker", paramsCasing, contentType } = options;
|
|
54
|
+
return {
|
|
55
|
+
name: pluginFakerName,
|
|
56
|
+
options: {
|
|
57
|
+
output,
|
|
58
|
+
transformers,
|
|
59
|
+
seed,
|
|
60
|
+
dateType,
|
|
61
|
+
integerType,
|
|
62
|
+
unknownType,
|
|
63
|
+
emptySchemaType,
|
|
64
|
+
dateParser,
|
|
65
|
+
mapper,
|
|
66
|
+
override,
|
|
67
|
+
regexGenerator,
|
|
68
|
+
paramsCasing,
|
|
69
|
+
group,
|
|
70
|
+
usedEnumNames: {}
|
|
71
|
+
},
|
|
72
|
+
pre: [pluginOasName, pluginTsName],
|
|
73
|
+
resolvePath(baseName, pathMode, options) {
|
|
74
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
75
|
+
if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
|
|
76
|
+
/**
|
|
77
|
+
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
78
|
+
* Other plugins then need to call addOrAppend instead of just add from the fileManager class
|
|
79
|
+
*/
|
|
80
|
+
return path.resolve(root, output.path);
|
|
81
|
+
if (group && (options?.group?.path || options?.group?.tag)) {
|
|
82
|
+
const groupName = group?.name ? group.name : (ctx) => {
|
|
83
|
+
if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
|
|
84
|
+
return `${camelCase(ctx.group)}Controller`;
|
|
85
|
+
};
|
|
86
|
+
return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
|
|
87
|
+
}
|
|
88
|
+
return path.resolve(root, output.path, baseName);
|
|
89
|
+
},
|
|
90
|
+
resolveName(name, type) {
|
|
91
|
+
const resolvedName = camelCase(name, {
|
|
92
|
+
prefix: type ? "create" : void 0,
|
|
93
|
+
isFile: type === "file"
|
|
94
|
+
});
|
|
95
|
+
if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
|
|
96
|
+
return resolvedName;
|
|
97
|
+
},
|
|
98
|
+
async install() {
|
|
99
|
+
const root = path.resolve(this.config.root, this.config.output.path);
|
|
100
|
+
const mode = getMode(path.resolve(root, output.path));
|
|
101
|
+
const oas = await this.getOas();
|
|
102
|
+
const schemaFiles = await new SchemaGenerator(this.plugin.options, {
|
|
103
|
+
fabric: this.fabric,
|
|
104
|
+
oas,
|
|
105
|
+
pluginManager: this.pluginManager,
|
|
106
|
+
events: this.events,
|
|
107
|
+
plugin: this.plugin,
|
|
108
|
+
contentType,
|
|
109
|
+
include: void 0,
|
|
110
|
+
override,
|
|
111
|
+
mode,
|
|
112
|
+
output: output.path
|
|
113
|
+
}).build(...generators);
|
|
114
|
+
await this.upsertFile(...schemaFiles);
|
|
115
|
+
const operationFiles = await new OperationGenerator(this.plugin.options, {
|
|
116
|
+
fabric: this.fabric,
|
|
117
|
+
oas,
|
|
118
|
+
pluginManager: this.pluginManager,
|
|
119
|
+
events: this.events,
|
|
120
|
+
plugin: this.plugin,
|
|
121
|
+
contentType,
|
|
122
|
+
exclude,
|
|
123
|
+
include,
|
|
124
|
+
override,
|
|
125
|
+
mode
|
|
126
|
+
}).build(...generators);
|
|
127
|
+
await this.upsertFile(...operationFiles);
|
|
128
|
+
const barrelFiles = await getBarrelFiles(this.fabric.files, {
|
|
129
|
+
type: output.barrelType ?? "named",
|
|
130
|
+
root,
|
|
131
|
+
output,
|
|
132
|
+
meta: { pluginKey: this.plugin.key }
|
|
133
|
+
});
|
|
134
|
+
await this.upsertFile(...barrelFiles);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
//#endregion
|
|
139
|
+
export { pluginFaker, pluginFakerName };
|
|
140
|
+
|
|
141
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kubb/plugin-faker",
|
|
3
|
+
"version": "4.37.2",
|
|
4
|
+
"description": "Faker.js data generator plugin for Kubb, creating realistic mock data from OpenAPI specifications for development and testing.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"faker",
|
|
7
|
+
"faker.js",
|
|
8
|
+
"fakerjs",
|
|
9
|
+
"mock-data",
|
|
10
|
+
"mocks",
|
|
11
|
+
"data-generation",
|
|
12
|
+
"fixtures",
|
|
13
|
+
"testing",
|
|
14
|
+
"development",
|
|
15
|
+
"typescript",
|
|
16
|
+
"openapi",
|
|
17
|
+
"swagger",
|
|
18
|
+
"oas",
|
|
19
|
+
"code-generator",
|
|
20
|
+
"codegen",
|
|
21
|
+
"plugins",
|
|
22
|
+
"kubb"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/kubb-labs/kubb.git",
|
|
27
|
+
"directory": "packages/plugin-faker"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"author": "stijnvanhulle",
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"type": "module",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"import": "./dist/index.js",
|
|
36
|
+
"require": "./dist/index.cjs"
|
|
37
|
+
},
|
|
38
|
+
"./components": {
|
|
39
|
+
"import": "./dist/components.js",
|
|
40
|
+
"require": "./dist/components.cjs"
|
|
41
|
+
},
|
|
42
|
+
"./generators": {
|
|
43
|
+
"import": "./dist/generators.js",
|
|
44
|
+
"require": "./dist/generators.cjs"
|
|
45
|
+
},
|
|
46
|
+
"./package.json": "./package.json"
|
|
47
|
+
},
|
|
48
|
+
"types": "./dist/index.d.ts",
|
|
49
|
+
"typesVersions": {
|
|
50
|
+
"*": {
|
|
51
|
+
"components": [
|
|
52
|
+
"./dist/components.d.ts"
|
|
53
|
+
],
|
|
54
|
+
"generators": [
|
|
55
|
+
"./dist/generators.d.ts"
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"files": [
|
|
60
|
+
"src",
|
|
61
|
+
"dist",
|
|
62
|
+
"!/**/**.test.**",
|
|
63
|
+
"!/**/__tests__/**",
|
|
64
|
+
"!/**/__snapshots__/**"
|
|
65
|
+
],
|
|
66
|
+
"size-limit": [
|
|
67
|
+
{
|
|
68
|
+
"path": "./dist/*.js",
|
|
69
|
+
"limit": "510 KiB",
|
|
70
|
+
"gzip": true
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"dependencies": {
|
|
74
|
+
"@kubb/react-fabric": "0.14.0",
|
|
75
|
+
"@kubb/core": "4.37.2",
|
|
76
|
+
"@kubb/oas": "4.37.2",
|
|
77
|
+
"@kubb/plugin-oas": "4.37.2",
|
|
78
|
+
"@kubb/plugin-ts": "4.37.2"
|
|
79
|
+
},
|
|
80
|
+
"engines": {
|
|
81
|
+
"node": ">=20"
|
|
82
|
+
},
|
|
83
|
+
"publishConfig": {
|
|
84
|
+
"access": "public",
|
|
85
|
+
"registry": "https://registry.npmjs.org/"
|
|
86
|
+
},
|
|
87
|
+
"main": "./dist/index.cjs",
|
|
88
|
+
"module": "./dist/index.js",
|
|
89
|
+
"devDependencies": {
|
|
90
|
+
"@internals/utils": "0.0.0"
|
|
91
|
+
},
|
|
92
|
+
"scripts": {
|
|
93
|
+
"build": "tsdown && size-limit",
|
|
94
|
+
"clean": "npx rimraf ./dist",
|
|
95
|
+
"lint": "bun biome lint .",
|
|
96
|
+
"lint:fix": "bun biome lint --fix --unsafe .",
|
|
97
|
+
"release": "pnpm publish --no-git-check",
|
|
98
|
+
"release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
|
|
99
|
+
"start": "tsdown --watch",
|
|
100
|
+
"test": "vitest --passWithNoTests",
|
|
101
|
+
"typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import "./chunk--u3MIqq1.js";
|
|
2
|
+
import { isOptional } from "@kubb/plugin-oas/utils";
|
|
3
|
+
import { Const, File, FunctionParams } from "@kubb/react-fabric";
|
|
4
|
+
import { jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
|
|
5
|
+
//#region ../../internals/utils/src/casing.ts
|
|
6
|
+
/**
|
|
7
|
+
* Shared implementation for camelCase and PascalCase conversion.
|
|
8
|
+
* Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
|
|
9
|
+
* and capitalizes each word according to `pascal`.
|
|
10
|
+
*
|
|
11
|
+
* When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
|
|
12
|
+
*/
|
|
13
|
+
function toCamelOrPascal(text, pascal) {
|
|
14
|
+
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) => {
|
|
15
|
+
if (word.length > 1 && word === word.toUpperCase()) return word;
|
|
16
|
+
if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
|
|
17
|
+
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
18
|
+
}).join("").replace(/[^a-zA-Z0-9]/g, "");
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Splits `text` on `.` and applies `transformPart` to each segment.
|
|
22
|
+
* The last segment receives `isLast = true`, all earlier segments receive `false`.
|
|
23
|
+
* Segments are joined with `/` to form a file path.
|
|
24
|
+
*/
|
|
25
|
+
function applyToFileParts(text, transformPart) {
|
|
26
|
+
const parts = text.split(".");
|
|
27
|
+
return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Converts `text` to camelCase.
|
|
31
|
+
* When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* camelCase('hello-world') // 'helloWorld'
|
|
35
|
+
* camelCase('pet.petId', { isFile: true }) // 'pet/petId'
|
|
36
|
+
*/
|
|
37
|
+
function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
|
|
38
|
+
if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
|
|
39
|
+
prefix,
|
|
40
|
+
suffix
|
|
41
|
+
} : {}));
|
|
42
|
+
return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
//#region ../../internals/utils/src/reserved.ts
|
|
46
|
+
/**
|
|
47
|
+
* Returns `true` when `name` is a syntactically valid JavaScript variable name.
|
|
48
|
+
*/
|
|
49
|
+
function isValidVarName(name) {
|
|
50
|
+
try {
|
|
51
|
+
new Function(`var ${name}`);
|
|
52
|
+
} catch {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/components/Server.tsx
|
|
59
|
+
function zodExprFromOasSchema(schema) {
|
|
60
|
+
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
61
|
+
const baseType = types.find((t) => t && t !== "null");
|
|
62
|
+
const isNullableType = types.includes("null");
|
|
63
|
+
let expr;
|
|
64
|
+
if (Array.isArray(schema.enum) && schema.enum.length > 0) {
|
|
65
|
+
expr = `z.enum([${schema.enum.map((v) => JSON.stringify(v)).join(", ")}])`;
|
|
66
|
+
if (isNullableType) expr = `${expr}.nullable()`;
|
|
67
|
+
return expr;
|
|
68
|
+
}
|
|
69
|
+
switch (baseType) {
|
|
70
|
+
case "integer":
|
|
71
|
+
expr = "z.coerce.number()";
|
|
72
|
+
break;
|
|
73
|
+
case "number":
|
|
74
|
+
expr = "z.number()";
|
|
75
|
+
break;
|
|
76
|
+
case "boolean":
|
|
77
|
+
expr = "z.boolean()";
|
|
78
|
+
break;
|
|
79
|
+
case "array":
|
|
80
|
+
expr = "z.array(z.unknown())";
|
|
81
|
+
break;
|
|
82
|
+
default: expr = "z.string()";
|
|
83
|
+
}
|
|
84
|
+
if (isNullableType) expr = `${expr}.nullable()`;
|
|
85
|
+
return expr;
|
|
86
|
+
}
|
|
87
|
+
function getParams({ schemas, paramsCasing }) {
|
|
88
|
+
const pathParamProperties = schemas.pathParams?.schema?.properties ?? {};
|
|
89
|
+
const requiredFields = Array.isArray(schemas.pathParams?.schema?.required) ? schemas.pathParams.schema.required : [];
|
|
90
|
+
const pathParamEntries = Object.entries(pathParamProperties).reduce((acc, [originalKey, propSchema]) => {
|
|
91
|
+
const key = paramsCasing === "camelcase" || !isValidVarName(originalKey) ? camelCase(originalKey) : originalKey;
|
|
92
|
+
acc[key] = {
|
|
93
|
+
value: zodExprFromOasSchema(propSchema),
|
|
94
|
+
optional: !requiredFields.includes(originalKey)
|
|
95
|
+
};
|
|
96
|
+
return acc;
|
|
97
|
+
}, {});
|
|
98
|
+
return FunctionParams.factory({ data: {
|
|
99
|
+
mode: "object",
|
|
100
|
+
children: {
|
|
101
|
+
...pathParamEntries,
|
|
102
|
+
data: schemas.request?.name ? {
|
|
103
|
+
value: schemas.request?.name,
|
|
104
|
+
optional: isOptional(schemas.request?.schema)
|
|
105
|
+
} : void 0,
|
|
106
|
+
params: schemas.queryParams?.name ? {
|
|
107
|
+
value: schemas.queryParams?.name,
|
|
108
|
+
optional: isOptional(schemas.queryParams?.schema)
|
|
109
|
+
} : void 0,
|
|
110
|
+
headers: schemas.headerParams?.name ? {
|
|
111
|
+
value: schemas.headerParams?.name,
|
|
112
|
+
optional: isOptional(schemas.headerParams?.schema)
|
|
113
|
+
} : void 0
|
|
114
|
+
}
|
|
115
|
+
} });
|
|
116
|
+
}
|
|
117
|
+
function Server({ name, serverName, serverVersion, paramsCasing, operations }) {
|
|
118
|
+
return /* @__PURE__ */ jsxs(File.Source, {
|
|
119
|
+
name,
|
|
120
|
+
isExportable: true,
|
|
121
|
+
isIndexable: true,
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ jsx(Const, {
|
|
124
|
+
name: "server",
|
|
125
|
+
export: true,
|
|
126
|
+
children: `
|
|
127
|
+
new McpServer({
|
|
128
|
+
name: '${serverName}',
|
|
129
|
+
version: '${serverVersion}',
|
|
130
|
+
})
|
|
131
|
+
`
|
|
132
|
+
}),
|
|
133
|
+
operations.map(({ tool, mcp, zod }) => {
|
|
134
|
+
const paramsClient = getParams({
|
|
135
|
+
schemas: zod.schemas,
|
|
136
|
+
paramsCasing
|
|
137
|
+
});
|
|
138
|
+
const outputSchema = zod.schemas.response?.name;
|
|
139
|
+
const config = [
|
|
140
|
+
tool.title ? `title: ${JSON.stringify(tool.title)}` : null,
|
|
141
|
+
`description: ${JSON.stringify(tool.description)}`,
|
|
142
|
+
outputSchema ? `outputSchema: { data: ${outputSchema} }` : null
|
|
143
|
+
].filter(Boolean).join(",\n ");
|
|
144
|
+
if (zod.schemas.request?.name || zod.schemas.headerParams?.name || zod.schemas.queryParams?.name || zod.schemas.pathParams?.name) return `
|
|
145
|
+
server.registerTool(${JSON.stringify(tool.name)}, {
|
|
146
|
+
${config},
|
|
147
|
+
inputSchema: ${paramsClient.toObjectValue()},
|
|
148
|
+
}, async (${paramsClient.toObject()}) => {
|
|
149
|
+
return ${mcp.name}(${paramsClient.toObject()})
|
|
150
|
+
})
|
|
151
|
+
`;
|
|
152
|
+
return `
|
|
153
|
+
server.registerTool(${JSON.stringify(tool.name)}, {
|
|
154
|
+
${config},
|
|
155
|
+
}, async () => {
|
|
156
|
+
return ${mcp.name}(${paramsClient.toObject()})
|
|
157
|
+
})
|
|
158
|
+
`;
|
|
159
|
+
}).filter(Boolean),
|
|
160
|
+
`
|
|
161
|
+
export async function startServer() {
|
|
162
|
+
try {
|
|
163
|
+
const transport = new StdioServerTransport()
|
|
164
|
+
await server.connect(transport)
|
|
165
|
+
|
|
166
|
+
} catch (error) {
|
|
167
|
+
console.error('Failed to start server:', error)
|
|
168
|
+
process.exit(1)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
`
|
|
172
|
+
]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
export { camelCase as n, Server as t };
|
|
177
|
+
|
|
178
|
+
//# sourceMappingURL=Server-H3SwqhwF.js.map
|