@kubb/agent 5.0.0-alpha.34 → 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.
Files changed (183) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/server/chunks/nitro/nitro.mjs +1790 -20812
  3. package/.output/server/chunks/nitro/nitro.mjs.map +1 -1
  4. package/.output/server/chunks/routes/api/health.get.mjs +16 -14
  5. package/.output/server/chunks/routes/api/health.get.mjs.map +1 -1
  6. package/.output/server/index.mjs +16 -14
  7. package/.output/server/index.mjs.map +1 -1
  8. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/constants.js +18 -0
  9. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/permessage-deflate.js +514 -0
  10. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/sender.js +602 -0
  11. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/stream.js +159 -0
  12. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket-server.js +540 -0
  13. package/.output/server/node_modules/.nitro/ws@8.18.0/lib/websocket.js +1388 -0
  14. package/.output/server/node_modules/.nitro/ws@8.18.0/package.json +69 -0
  15. package/.output/server/node_modules/.nitro/ws@8.18.0/wrapper.mjs +8 -0
  16. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/buffer-util.js +131 -0
  17. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/event-target.js +292 -0
  18. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/extension.js +203 -0
  19. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/limiter.js +55 -0
  20. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/receiver.js +706 -0
  21. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/subprotocol.js +62 -0
  22. package/.output/server/node_modules/.nitro/ws@8.20.0/lib/validation.js +152 -0
  23. package/.output/server/node_modules/@clack/core/dist/index.mjs +11 -0
  24. package/.output/server/node_modules/@clack/core/package.json +60 -0
  25. package/.output/server/node_modules/@clack/prompts/dist/index.mjs +137 -0
  26. package/.output/server/node_modules/@clack/prompts/package.json +65 -0
  27. package/.output/server/node_modules/@kubb/ast/dist/chunk--u3MIqq1.js +8 -0
  28. package/.output/server/node_modules/@kubb/ast/dist/index.js +423 -0
  29. package/.output/server/node_modules/@kubb/ast/package.json +70 -0
  30. package/.output/server/node_modules/@kubb/core/dist/chunk--u3MIqq1.js +8 -0
  31. package/.output/server/node_modules/@kubb/core/dist/hooks.js +23 -0
  32. package/.output/server/node_modules/@kubb/core/dist/index.js +2311 -0
  33. package/.output/server/node_modules/@kubb/core/package.json +109 -0
  34. package/.output/server/node_modules/@kubb/fabric-core/dist/chunk-O_arW02_.js +17 -0
  35. package/.output/server/node_modules/@kubb/fabric-core/dist/defaultParser-iCpMSYCp.js +15 -0
  36. package/.output/server/node_modules/@kubb/fabric-core/dist/getRelativePath-NAm_Y-vp.js +55 -0
  37. package/.output/server/node_modules/@kubb/fabric-core/dist/index.js +653 -0
  38. package/.output/server/node_modules/@kubb/fabric-core/dist/onProcessExit-Cput7j2c.js +742 -0
  39. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers/typescript.js +101 -0
  40. package/.output/server/node_modules/@kubb/fabric-core/dist/parsers.js +17 -0
  41. package/.output/server/node_modules/@kubb/fabric-core/dist/plugins.js +375 -0
  42. package/.output/server/node_modules/@kubb/fabric-core/package.json +111 -0
  43. package/.output/server/node_modules/@kubb/oas/dist/chunk--u3MIqq1.js +8 -0
  44. package/.output/server/node_modules/@kubb/oas/dist/index.js +918 -0
  45. package/.output/server/node_modules/@kubb/oas/package.json +94 -0
  46. package/.output/server/node_modules/@kubb/plugin-client/dist/StaticClassClient-bCe7RG_w.js +636 -0
  47. package/.output/server/node_modules/@kubb/plugin-client/dist/chunk--u3MIqq1.js +8 -0
  48. package/.output/server/node_modules/@kubb/plugin-client/dist/components.js +2 -0
  49. package/.output/server/node_modules/@kubb/plugin-client/dist/generators-BffddRNu.js +723 -0
  50. package/.output/server/node_modules/@kubb/plugin-client/dist/index.js +124 -0
  51. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/axios.source.js +6 -0
  52. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/clients/fetch.source.js +6 -0
  53. package/.output/server/node_modules/@kubb/plugin-client/dist/templates/config.source.js +6 -0
  54. package/.output/server/node_modules/@kubb/plugin-client/package.json +153 -0
  55. package/.output/server/node_modules/@kubb/plugin-cypress/dist/chunk--u3MIqq1.js +8 -0
  56. package/.output/server/node_modules/@kubb/plugin-cypress/dist/components-BK_6GU4v.js +257 -0
  57. package/.output/server/node_modules/@kubb/plugin-cypress/dist/generators-D5YFtyyC.js +71 -0
  58. package/.output/server/node_modules/@kubb/plugin-cypress/dist/index.js +79 -0
  59. package/.output/server/node_modules/@kubb/plugin-cypress/package.json +108 -0
  60. package/.output/server/node_modules/@kubb/plugin-faker/dist/chunk--u3MIqq1.js +8 -0
  61. package/.output/server/node_modules/@kubb/plugin-faker/dist/components-BkBIov4R.js +419 -0
  62. package/.output/server/node_modules/@kubb/plugin-faker/dist/fakerGenerator-BztogaeO.js +200 -0
  63. package/.output/server/node_modules/@kubb/plugin-faker/dist/index.js +141 -0
  64. package/.output/server/node_modules/@kubb/plugin-faker/package.json +103 -0
  65. package/.output/server/node_modules/@kubb/plugin-mcp/dist/Server-H3SwqhwF.js +178 -0
  66. package/.output/server/node_modules/@kubb/plugin-mcp/dist/chunk--u3MIqq1.js +8 -0
  67. package/.output/server/node_modules/@kubb/plugin-mcp/dist/generators-BqkMrcs9.js +274 -0
  68. package/.output/server/node_modules/@kubb/plugin-mcp/dist/index.js +122 -0
  69. package/.output/server/node_modules/@kubb/plugin-mcp/package.json +107 -0
  70. package/.output/server/node_modules/@kubb/plugin-msw/dist/chunk--u3MIqq1.js +8 -0
  71. package/.output/server/node_modules/@kubb/plugin-msw/dist/components-DgtTZkWX.js +277 -0
  72. package/.output/server/node_modules/@kubb/plugin-msw/dist/generators-C34kqa1L.js +161 -0
  73. package/.output/server/node_modules/@kubb/plugin-msw/dist/index.js +84 -0
  74. package/.output/server/node_modules/@kubb/plugin-msw/package.json +109 -0
  75. package/.output/server/node_modules/@kubb/plugin-oas/dist/SchemaMapper-CqMkO2T1.js +58 -0
  76. package/.output/server/node_modules/@kubb/plugin-oas/dist/chunk--u3MIqq1.js +8 -0
  77. package/.output/server/node_modules/@kubb/plugin-oas/dist/generators-D7C3CXsN.js +79 -0
  78. package/.output/server/node_modules/@kubb/plugin-oas/dist/generators.js +2 -0
  79. package/.output/server/node_modules/@kubb/plugin-oas/dist/getFooter-Pw3tLCiV.js +112 -0
  80. package/.output/server/node_modules/@kubb/plugin-oas/dist/hooks.js +200 -0
  81. package/.output/server/node_modules/@kubb/plugin-oas/dist/index.js +408 -0
  82. package/.output/server/node_modules/@kubb/plugin-oas/dist/requestBody-pRavthCw.js +1336 -0
  83. package/.output/server/node_modules/@kubb/plugin-oas/dist/utils.js +268 -0
  84. package/.output/server/node_modules/@kubb/plugin-oas/package.json +122 -0
  85. package/.output/server/node_modules/@kubb/plugin-react-query/dist/chunk--u3MIqq1.js +8 -0
  86. package/.output/server/node_modules/@kubb/plugin-react-query/dist/components-CpyHYGOw.js +1520 -0
  87. package/.output/server/node_modules/@kubb/plugin-react-query/dist/generators-CpiBv5eE.js +1427 -0
  88. package/.output/server/node_modules/@kubb/plugin-react-query/dist/index.js +166 -0
  89. package/.output/server/node_modules/@kubb/plugin-react-query/package.json +112 -0
  90. package/.output/server/node_modules/@kubb/plugin-redoc/dist/chunk--u3MIqq1.js +8 -0
  91. package/.output/server/node_modules/@kubb/plugin-redoc/dist/index.js +65 -0
  92. package/.output/server/node_modules/@kubb/plugin-redoc/package.json +85 -0
  93. package/.output/server/node_modules/@kubb/plugin-redoc/static/redoc.hbs +22 -0
  94. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/chunk--u3MIqq1.js +8 -0
  95. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/components-BhStIi1M.js +665 -0
  96. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/generators-CQClzsST.js +415 -0
  97. package/.output/server/node_modules/@kubb/plugin-solid-query/dist/index.js +145 -0
  98. package/.output/server/node_modules/@kubb/plugin-solid-query/package.json +113 -0
  99. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/chunk--u3MIqq1.js +8 -0
  100. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/components-DntKBsnB.js +666 -0
  101. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/generators-BtTsGGrM.js +414 -0
  102. package/.output/server/node_modules/@kubb/plugin-svelte-query/dist/index.js +145 -0
  103. package/.output/server/node_modules/@kubb/plugin-svelte-query/package.json +113 -0
  104. package/.output/server/node_modules/@kubb/plugin-swr/dist/chunk--u3MIqq1.js +8 -0
  105. package/.output/server/node_modules/@kubb/plugin-swr/dist/components-DRDGvgXG.js +702 -0
  106. package/.output/server/node_modules/@kubb/plugin-swr/dist/generators-ClWZJ-YG.js +399 -0
  107. package/.output/server/node_modules/@kubb/plugin-swr/dist/index.js +144 -0
  108. package/.output/server/node_modules/@kubb/plugin-swr/package.json +115 -0
  109. package/.output/server/node_modules/@kubb/plugin-ts/dist/chunk--u3MIqq1.js +8 -0
  110. package/.output/server/node_modules/@kubb/plugin-ts/dist/components-C7fu-sK1.js +723 -0
  111. package/.output/server/node_modules/@kubb/plugin-ts/dist/index.js +2 -0
  112. package/.output/server/node_modules/@kubb/plugin-ts/dist/plugin-CYC-FGXe.js +479 -0
  113. package/.output/server/node_modules/@kubb/plugin-ts/package.json +105 -0
  114. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/chunk--u3MIqq1.js +8 -0
  115. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/components-_AMBl0g-.js +1029 -0
  116. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/generators-Zb1s5Wmb.js +661 -0
  117. package/.output/server/node_modules/@kubb/plugin-vue-query/dist/index.js +157 -0
  118. package/.output/server/node_modules/@kubb/plugin-vue-query/package.json +114 -0
  119. package/.output/server/node_modules/@kubb/plugin-zod/dist/chunk--u3MIqq1.js +8 -0
  120. package/.output/server/node_modules/@kubb/plugin-zod/dist/components-eECfXVou.js +842 -0
  121. package/.output/server/node_modules/@kubb/plugin-zod/dist/generators-D1R6NNf2.js +290 -0
  122. package/.output/server/node_modules/@kubb/plugin-zod/dist/index.js +175 -0
  123. package/.output/server/node_modules/@kubb/plugin-zod/dist/templates/ToZod.source.js +6 -0
  124. package/.output/server/node_modules/@kubb/plugin-zod/package.json +112 -0
  125. package/.output/server/node_modules/@kubb/react-fabric/dist/chunk-BGCRLu6H.js +38 -0
  126. package/.output/server/node_modules/@kubb/react-fabric/dist/index.js +525 -0
  127. package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime-Bl0DfUmV.js +1448 -0
  128. package/.output/server/node_modules/@kubb/react-fabric/dist/jsx-runtime.js +12 -0
  129. package/.output/server/node_modules/@kubb/react-fabric/dist/parsers.js +2 -0
  130. package/.output/server/node_modules/@kubb/react-fabric/dist/plugins.js +4 -0
  131. package/.output/server/node_modules/@kubb/react-fabric/dist/reactPlugin-QQPrjNuQ.js +17813 -0
  132. package/.output/server/node_modules/@kubb/react-fabric/package.json +143 -0
  133. package/.output/server/node_modules/@redocly/config/lib/root-config-schema.js +11 -1
  134. package/.output/server/node_modules/@redocly/config/package.json +1 -1
  135. package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-document.js +25 -10
  136. package/.output/server/node_modules/@redocly/openapi-core/lib/bundle/bundle-visitor.js +32 -29
  137. package/.output/server/node_modules/@redocly/openapi-core/lib/config/config.js +5 -0
  138. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/index.js +1 -1
  139. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas2/remove-unused-components.js +47 -38
  140. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/index.js +1 -1
  141. package/.output/server/node_modules/@redocly/openapi-core/lib/decorators/oas3/remove-unused-components.js +45 -41
  142. package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-http-verbs-in-paths.js +3 -1
  143. package/.output/server/node_modules/@redocly/openapi-core/lib/rules/common/no-required-schema-properties-undefined.js +41 -55
  144. package/.output/server/node_modules/@redocly/openapi-core/lib/walk.js +28 -16
  145. package/.output/server/node_modules/@redocly/openapi-core/package.json +2 -2
  146. package/.output/server/node_modules/buffer-from/index.js +72 -0
  147. package/.output/server/node_modules/buffer-from/package.json +19 -0
  148. package/.output/server/node_modules/fast-string-truncated-width/dist/index.js +171 -0
  149. package/.output/server/node_modules/fast-string-truncated-width/dist/utils.js +15 -0
  150. package/.output/server/node_modules/fast-string-truncated-width/package.json +35 -0
  151. package/.output/server/node_modules/fast-string-width/dist/index.js +14 -0
  152. package/.output/server/node_modules/fast-string-width/package.json +34 -0
  153. package/.output/server/node_modules/fast-wrap-ansi/lib/main.js +216 -0
  154. package/.output/server/node_modules/fast-wrap-ansi/package.json +51 -0
  155. package/.output/server/node_modules/p-limit/index.js +127 -0
  156. package/.output/server/node_modules/p-limit/package.json +58 -0
  157. package/.output/server/node_modules/react-devtools-core/dist/backend.js +18302 -0
  158. package/.output/server/node_modules/react-devtools-core/package.json +38 -0
  159. package/.output/server/node_modules/sisteransi/package.json +34 -0
  160. package/.output/server/node_modules/sisteransi/src/index.js +58 -0
  161. package/.output/server/node_modules/source-map-support/package.json +31 -0
  162. package/.output/server/node_modules/source-map-support/source-map-support.js +625 -0
  163. package/.output/server/node_modules/typescript/lib/typescript.js +200276 -0
  164. package/.output/server/node_modules/typescript/package.json +120 -0
  165. package/.output/server/node_modules/yocto-queue/index.js +90 -0
  166. package/.output/server/node_modules/yocto-queue/package.json +48 -0
  167. package/.output/server/package.json +35 -4
  168. package/package.json +20 -20
  169. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/buffer-util.js +0 -0
  170. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/event-target.js +0 -0
  171. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/extension.js +0 -0
  172. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/limiter.js +0 -0
  173. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/receiver.js +0 -0
  174. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/subprotocol.js +0 -0
  175. /package/.output/server/node_modules/{ws → .nitro/ws@8.18.0}/lib/validation.js +0 -0
  176. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/constants.js +0 -0
  177. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/permessage-deflate.js +0 -0
  178. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/sender.js +0 -0
  179. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/stream.js +0 -0
  180. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket-server.js +0 -0
  181. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/lib/websocket.js +0 -0
  182. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/package.json +0 -0
  183. /package/.output/server/node_modules/{ws → .nitro/ws@8.20.0}/wrapper.mjs +0 -0
@@ -0,0 +1,290 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { n as Operations, t as Zod } from "./components-eECfXVou.js";
3
+ import path from "node:path";
4
+ import { SchemaGenerator, schemaKeywords } from "@kubb/plugin-oas";
5
+ import { pluginTsName } from "@kubb/plugin-ts";
6
+ import { useMode, usePluginManager } from "@kubb/core/hooks";
7
+ import { createReactGenerator } from "@kubb/plugin-oas/generators";
8
+ import { useOas, useOperationManager, useSchemaManager } from "@kubb/plugin-oas/hooks";
9
+ import { getBanner, getFooter, getImports } from "@kubb/plugin-oas/utils";
10
+ import { File } from "@kubb/react-fabric";
11
+ import { Fragment, jsx, jsxs } from "@kubb/react-fabric/jsx-runtime";
12
+ //#region src/generators/operationsGenerator.tsx
13
+ const operationsGenerator = createReactGenerator({
14
+ name: "operations",
15
+ Operations({ operations, generator, plugin }) {
16
+ const { key: pluginKey, options: { output, importPath } } = plugin;
17
+ const pluginManager = usePluginManager();
18
+ const oas = useOas();
19
+ const { getFile, groupSchemasByName } = useOperationManager(generator);
20
+ const name = "operations";
21
+ const file = pluginManager.getFile({
22
+ name,
23
+ extname: ".ts",
24
+ pluginKey
25
+ });
26
+ const transformedOperations = operations.map((operation) => ({
27
+ operation,
28
+ data: groupSchemasByName(operation, { type: "function" })
29
+ }));
30
+ const imports = Object.entries(transformedOperations).map(([key, { data, operation }]) => {
31
+ const names = [
32
+ data.request,
33
+ ...Object.values(data.responses),
34
+ ...Object.values(data.parameters)
35
+ ].filter(Boolean);
36
+ return /* @__PURE__ */ jsx(File.Import, {
37
+ name: names,
38
+ root: file.path,
39
+ path: getFile(operation).path
40
+ }, key);
41
+ }).filter(Boolean);
42
+ const isZodImport = importPath === "zod" || importPath === "zod/mini";
43
+ return /* @__PURE__ */ jsxs(File, {
44
+ baseName: file.baseName,
45
+ path: file.path,
46
+ meta: file.meta,
47
+ banner: getBanner({
48
+ oas,
49
+ output,
50
+ config: pluginManager.config
51
+ }),
52
+ footer: getFooter({
53
+ oas,
54
+ output
55
+ }),
56
+ children: [
57
+ /* @__PURE__ */ jsx(File.Import, {
58
+ isTypeOnly: true,
59
+ name: isZodImport ? "z" : ["z"],
60
+ path: importPath,
61
+ isNameSpace: isZodImport
62
+ }),
63
+ imports,
64
+ /* @__PURE__ */ jsx(Operations, {
65
+ name,
66
+ operations: transformedOperations
67
+ })
68
+ ]
69
+ });
70
+ }
71
+ });
72
+ //#endregion
73
+ //#region src/generators/zodGenerator.tsx
74
+ const zodGenerator = createReactGenerator({
75
+ name: "zod",
76
+ Operation({ config, operation, generator, plugin }) {
77
+ const { options, options: { coercion: globalCoercion, inferred, typed, mapper, wrapOutput, version, guidType, mini } } = plugin;
78
+ const mode = useMode();
79
+ const pluginManager = usePluginManager();
80
+ const oas = useOas();
81
+ const { getSchemas, getFile, getGroup } = useOperationManager(generator);
82
+ const schemaManager = useSchemaManager();
83
+ const file = getFile(operation);
84
+ const schemas = getSchemas(operation);
85
+ const schemaGenerator = new SchemaGenerator(options, {
86
+ fabric: generator.context.fabric,
87
+ oas,
88
+ plugin,
89
+ pluginManager,
90
+ events: generator.context.events,
91
+ mode,
92
+ override: options.override
93
+ });
94
+ const operationSchemas = [
95
+ schemas.pathParams,
96
+ schemas.queryParams,
97
+ schemas.headerParams,
98
+ schemas.statusCodes,
99
+ schemas.request,
100
+ schemas.response
101
+ ].flat().filter(Boolean);
102
+ const toZodPath = path.resolve(config.root, config.output.path, ".kubb/ToZod.ts");
103
+ const mapOperationSchema = ({ name, schema: schemaOriginal, description, keysToOmit: keysToOmitOriginal, ...options }) => {
104
+ let schemaObject = schemaOriginal;
105
+ let keysToOmit = keysToOmitOriginal;
106
+ if ((schemaOriginal.anyOf || schemaOriginal.oneOf) && keysToOmitOriginal && keysToOmitOriginal.length > 0) {
107
+ schemaObject = structuredClone(schemaOriginal);
108
+ delete schemaObject.$ref;
109
+ for (const key of keysToOmitOriginal) delete schemaObject.properties?.[key];
110
+ if (Array.isArray(schemaObject.required)) schemaObject.required = schemaObject.required.filter((key) => !keysToOmitOriginal.includes(key));
111
+ keysToOmit = void 0;
112
+ }
113
+ const hasProperties = Object.keys(schemaObject || {}).length > 0;
114
+ const hasDefaults = Object.values(schemaObject.properties || {}).some((prop) => prop && Object.hasOwn(prop, "default"));
115
+ const optional = !(Array.isArray(schemaObject?.required) ? schemaObject.required.length > 0 : !!schemaObject?.required) && !hasDefaults && hasProperties && name.includes("Params");
116
+ if (!optional && Array.isArray(schemaObject.required) && !schemaObject.required.length) schemaObject.required = Object.entries(schemaObject.properties || {}).filter(([_key, value]) => value && Object.hasOwn(value, "default")).map(([key]) => key);
117
+ const tree = [...schemaGenerator.parse({
118
+ schema: schemaObject,
119
+ name,
120
+ parentName: null
121
+ }), optional ? { keyword: schemaKeywords.optional } : void 0].filter(Boolean);
122
+ const imports = getImports(tree);
123
+ const group = options.operation ? getGroup(options.operation) : void 0;
124
+ const coercion = name.includes("Params") ? {
125
+ numbers: true,
126
+ strings: false,
127
+ dates: true
128
+ } : globalCoercion;
129
+ const zod = {
130
+ name: schemaManager.getName(name, { type: "function" }),
131
+ inferTypeName: schemaManager.getName(name, { type: "type" }),
132
+ file: schemaManager.getFile(name)
133
+ };
134
+ const type = {
135
+ name: schemaManager.getName(name, {
136
+ type: "type",
137
+ pluginKey: [pluginTsName]
138
+ }),
139
+ file: schemaManager.getFile(options.operationName || name, {
140
+ pluginKey: [pluginTsName],
141
+ group
142
+ })
143
+ };
144
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
145
+ typed && /* @__PURE__ */ jsx(File.Import, {
146
+ isTypeOnly: true,
147
+ root: file.path,
148
+ path: type.file.path,
149
+ name: [type.name]
150
+ }),
151
+ imports.map((imp) => /* @__PURE__ */ jsx(File.Import, {
152
+ root: file.path,
153
+ path: imp.path,
154
+ name: imp.name
155
+ }, [
156
+ imp.path,
157
+ imp.name,
158
+ imp.isTypeOnly
159
+ ].join("-"))),
160
+ /* @__PURE__ */ jsx(Zod, {
161
+ name: zod.name,
162
+ typeName: typed ? type.name : void 0,
163
+ inferTypeName: inferred ? zod.inferTypeName : void 0,
164
+ description,
165
+ tree,
166
+ schema: schemaObject,
167
+ mapper,
168
+ coercion,
169
+ keysToOmit,
170
+ wrapOutput,
171
+ version: plugin.options.version,
172
+ guidType,
173
+ emptySchemaType: plugin.options.emptySchemaType,
174
+ mini
175
+ })
176
+ ] });
177
+ };
178
+ const isZodImport = plugin.options.importPath === "zod" || plugin.options.importPath === "zod/mini";
179
+ return /* @__PURE__ */ jsxs(File, {
180
+ baseName: file.baseName,
181
+ path: file.path,
182
+ meta: file.meta,
183
+ banner: getBanner({
184
+ oas,
185
+ output: plugin.options.output,
186
+ config: pluginManager.config
187
+ }),
188
+ footer: getFooter({
189
+ oas,
190
+ output: plugin.options.output
191
+ }),
192
+ children: [
193
+ /* @__PURE__ */ jsx(File.Import, {
194
+ name: isZodImport ? "z" : ["z"],
195
+ path: plugin.options.importPath,
196
+ isNameSpace: isZodImport
197
+ }),
198
+ typed && version === "3" && /* @__PURE__ */ jsx(File.Import, {
199
+ name: ["ToZod"],
200
+ isTypeOnly: true,
201
+ root: file.path,
202
+ path: toZodPath
203
+ }),
204
+ operationSchemas.map(mapOperationSchema)
205
+ ]
206
+ });
207
+ },
208
+ Schema({ config, schema, plugin }) {
209
+ const { getName, getFile } = useSchemaManager();
210
+ const { options: { output, emptySchemaType, coercion, inferred, typed, mapper, importPath, wrapOutput, version, guidType, mini } } = plugin;
211
+ const pluginManager = usePluginManager();
212
+ const oas = useOas();
213
+ const imports = getImports(schema.tree);
214
+ const zod = {
215
+ name: getName(schema.name, { type: "function" }),
216
+ inferTypeName: getName(schema.name, { type: "type" }),
217
+ file: getFile(schema.name)
218
+ };
219
+ const type = {
220
+ name: getName(schema.name, {
221
+ type: "type",
222
+ pluginKey: [pluginTsName]
223
+ }),
224
+ file: getFile(schema.name, { pluginKey: [pluginTsName] })
225
+ };
226
+ const isZodImport = importPath === "zod" || importPath === "zod/mini";
227
+ const toZodPath = path.resolve(config.root, config.output.path, ".kubb/ToZod.ts");
228
+ return /* @__PURE__ */ jsxs(File, {
229
+ baseName: zod.file.baseName,
230
+ path: zod.file.path,
231
+ meta: zod.file.meta,
232
+ banner: getBanner({
233
+ oas,
234
+ output,
235
+ config: pluginManager.config
236
+ }),
237
+ footer: getFooter({
238
+ oas,
239
+ output
240
+ }),
241
+ children: [
242
+ /* @__PURE__ */ jsx(File.Import, {
243
+ name: isZodImport ? "z" : ["z"],
244
+ path: importPath,
245
+ isNameSpace: isZodImport
246
+ }),
247
+ typed && /* @__PURE__ */ jsx(File.Import, {
248
+ isTypeOnly: true,
249
+ root: zod.file.path,
250
+ path: type.file.path,
251
+ name: [type.name]
252
+ }),
253
+ typed && version === "3" && /* @__PURE__ */ jsx(File.Import, {
254
+ name: ["ToZod"],
255
+ isTypeOnly: true,
256
+ root: zod.file.path,
257
+ path: toZodPath
258
+ }),
259
+ imports.map((imp) => /* @__PURE__ */ jsx(File.Import, {
260
+ root: zod.file.path,
261
+ path: imp.path,
262
+ name: imp.name
263
+ }, [
264
+ imp.path,
265
+ imp.name,
266
+ imp.isTypeOnly
267
+ ].join("-"))),
268
+ /* @__PURE__ */ jsx(Zod, {
269
+ name: zod.name,
270
+ typeName: typed ? type.name : void 0,
271
+ inferTypeName: inferred ? zod.inferTypeName : void 0,
272
+ description: schema.value.description,
273
+ tree: schema.tree,
274
+ schema: schema.value,
275
+ mapper,
276
+ coercion,
277
+ wrapOutput,
278
+ version,
279
+ guidType,
280
+ emptySchemaType,
281
+ mini
282
+ })
283
+ ]
284
+ });
285
+ }
286
+ });
287
+ //#endregion
288
+ export { operationsGenerator as n, zodGenerator as t };
289
+
290
+ //# sourceMappingURL=generators-D1R6NNf2.js.map
@@ -0,0 +1,175 @@
1
+ import "./chunk--u3MIqq1.js";
2
+ import { n as operationsGenerator, t as zodGenerator } from "./generators-D1R6NNf2.js";
3
+ import { source } from "./templates/ToZod.source.js";
4
+ import path from "node:path";
5
+ import { PackageManager, definePlugin, getBarrelFiles, getMode } from "@kubb/core";
6
+ import { OperationGenerator, SchemaGenerator, pluginOasName } from "@kubb/plugin-oas";
7
+ import { pluginTsName } from "@kubb/plugin-ts";
8
+ //#region ../../internals/utils/src/casing.ts
9
+ /**
10
+ * Shared implementation for camelCase and PascalCase conversion.
11
+ * Splits on common word boundaries (spaces, hyphens, underscores, dots, slashes, colons)
12
+ * and capitalizes each word according to `pascal`.
13
+ *
14
+ * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
15
+ */
16
+ function toCamelOrPascal(text, pascal) {
17
+ 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) => {
18
+ if (word.length > 1 && word === word.toUpperCase()) return word;
19
+ if (i === 0 && !pascal) return word.charAt(0).toLowerCase() + word.slice(1);
20
+ return word.charAt(0).toUpperCase() + word.slice(1);
21
+ }).join("").replace(/[^a-zA-Z0-9]/g, "");
22
+ }
23
+ /**
24
+ * Splits `text` on `.` and applies `transformPart` to each segment.
25
+ * The last segment receives `isLast = true`, all earlier segments receive `false`.
26
+ * Segments are joined with `/` to form a file path.
27
+ */
28
+ function applyToFileParts(text, transformPart) {
29
+ const parts = text.split(".");
30
+ return parts.map((part, i) => transformPart(part, i === parts.length - 1)).join("/");
31
+ }
32
+ /**
33
+ * Converts `text` to camelCase.
34
+ * When `isFile` is `true`, dot-separated segments are each cased independently and joined with `/`.
35
+ *
36
+ * @example
37
+ * camelCase('hello-world') // 'helloWorld'
38
+ * camelCase('pet.petId', { isFile: true }) // 'pet/petId'
39
+ */
40
+ function camelCase(text, { isFile, prefix = "", suffix = "" } = {}) {
41
+ if (isFile) return applyToFileParts(text, (part, isLast) => camelCase(part, isLast ? {
42
+ prefix,
43
+ suffix
44
+ } : {}));
45
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, false);
46
+ }
47
+ /**
48
+ * Converts `text` to PascalCase.
49
+ * When `isFile` is `true`, the last dot-separated segment is PascalCased and earlier segments are camelCased.
50
+ *
51
+ * @example
52
+ * pascalCase('hello-world') // 'HelloWorld'
53
+ * pascalCase('pet.petId', { isFile: true }) // 'pet/PetId'
54
+ */
55
+ function pascalCase(text, { isFile, prefix = "", suffix = "" } = {}) {
56
+ if (isFile) return applyToFileParts(text, (part, isLast) => isLast ? pascalCase(part, {
57
+ prefix,
58
+ suffix
59
+ }) : camelCase(part));
60
+ return toCamelOrPascal(`${prefix} ${text} ${suffix}`, true);
61
+ }
62
+ //#endregion
63
+ //#region src/plugin.ts
64
+ const pluginZodName = "plugin-zod";
65
+ const pluginZod = definePlugin((options) => {
66
+ const { output = {
67
+ path: "zod",
68
+ barrelType: "named"
69
+ }, group, exclude = [], include, override = [], transformers = {}, dateType = "string", unknownType = "any", emptySchemaType = unknownType, integerType = "number", typed = false, mapper = {}, operations = false, mini = false, version = mini ? "4" : new PackageManager().isValidSync("zod", ">=4") ? "4" : "3", guidType = "uuid", importPath = mini ? "zod/mini" : version === "4" ? "zod/v4" : "zod", coercion = false, inferred = false, generators = [zodGenerator, operations ? operationsGenerator : void 0].filter(Boolean), wrapOutput = void 0, contentType } = options;
70
+ return {
71
+ name: pluginZodName,
72
+ options: {
73
+ output,
74
+ transformers,
75
+ include,
76
+ exclude,
77
+ override,
78
+ typed,
79
+ dateType,
80
+ unknownType,
81
+ emptySchemaType,
82
+ integerType,
83
+ mapper,
84
+ importPath,
85
+ coercion,
86
+ operations,
87
+ inferred,
88
+ group,
89
+ wrapOutput,
90
+ version,
91
+ guidType,
92
+ mini,
93
+ usedEnumNames: {}
94
+ },
95
+ pre: [pluginOasName, typed ? pluginTsName : void 0].filter(Boolean),
96
+ resolvePath(baseName, pathMode, options) {
97
+ const root = path.resolve(this.config.root, this.config.output.path);
98
+ if ((pathMode ?? getMode(path.resolve(root, output.path))) === "single")
99
+ /**
100
+ * when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
101
+ * Other plugins then need to call addOrAppend instead of just add from the fileManager class
102
+ */
103
+ return path.resolve(root, output.path);
104
+ if (group && (options?.group?.path || options?.group?.tag)) {
105
+ const groupName = group?.name ? group.name : (ctx) => {
106
+ if (group?.type === "path") return `${ctx.group.split("/")[1]}`;
107
+ return `${camelCase(ctx.group)}Controller`;
108
+ };
109
+ return path.resolve(root, output.path, groupName({ group: group.type === "path" ? options.group.path : options.group.tag }), baseName);
110
+ }
111
+ return path.resolve(root, output.path, baseName);
112
+ },
113
+ resolveName(name, type) {
114
+ let resolvedName = camelCase(name, {
115
+ suffix: type ? "schema" : void 0,
116
+ isFile: type === "file"
117
+ });
118
+ if (type === "type") resolvedName = pascalCase(resolvedName);
119
+ if (type) return transformers?.name?.(resolvedName, type) || resolvedName;
120
+ return resolvedName;
121
+ },
122
+ async install() {
123
+ const root = path.resolve(this.config.root, this.config.output.path);
124
+ const mode = getMode(path.resolve(root, output.path));
125
+ const oas = await this.getOas();
126
+ if (this.plugin.options.typed && this.plugin.options.version === "3") await this.addFile({
127
+ baseName: "ToZod.ts",
128
+ path: path.resolve(root, ".kubb/ToZod.ts"),
129
+ sources: [{
130
+ name: "ToZod",
131
+ value: source
132
+ }],
133
+ imports: [],
134
+ exports: []
135
+ });
136
+ const schemaFiles = await new SchemaGenerator(this.plugin.options, {
137
+ fabric: this.fabric,
138
+ oas,
139
+ pluginManager: this.pluginManager,
140
+ events: this.events,
141
+ plugin: this.plugin,
142
+ contentType,
143
+ include: void 0,
144
+ override,
145
+ mode,
146
+ output: output.path
147
+ }).build(...generators);
148
+ await this.upsertFile(...schemaFiles);
149
+ const operationFiles = await new OperationGenerator(this.plugin.options, {
150
+ fabric: this.fabric,
151
+ oas,
152
+ pluginManager: this.pluginManager,
153
+ events: this.events,
154
+ plugin: this.plugin,
155
+ contentType,
156
+ exclude,
157
+ include,
158
+ override,
159
+ mode
160
+ }).build(...generators);
161
+ await this.upsertFile(...operationFiles);
162
+ const barrelFiles = await getBarrelFiles(this.fabric.files, {
163
+ type: output.barrelType ?? "named",
164
+ root,
165
+ output,
166
+ meta: { pluginKey: this.plugin.key }
167
+ });
168
+ await this.upsertFile(...barrelFiles);
169
+ }
170
+ };
171
+ });
172
+ //#endregion
173
+ export { pluginZod, pluginZodName };
174
+
175
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,6 @@
1
+ //#region src/templates/ToZod.source.ts
2
+ const source = "/**\n * See https://github.com/colinhacks/tozod/blob/master/src/index.ts\n * Adapted based on https://github.com/colinhacks/zod/issues/372\n */\n\nimport type * as z from 'zod'\n\ntype IsAny<T> = [any extends T ? 'true' : 'false'] extends ['true'] ? true : false\ntype NonOptional<T> = T extends undefined ? never : T\ntype NonNullable<T> = T extends null ? never : T\ntype Equals<X, Y> = [X] extends [Y] ? ([Y] extends [X] ? true : false) : false\n\ntype ZodKey<T> =\n IsAny<T> extends true\n ? 'any'\n : Equals<T, boolean> extends true //[T] extends [booleanUtil.Type]\n ? 'boolean'\n : [undefined] extends [T]\n ? 'optional'\n : [null] extends [T]\n ? 'nullable'\n : T extends any[]\n ? 'array'\n : Equals<T, string> extends true\n ? 'string'\n : Equals<T, bigint> extends true //[T] extends [bigintUtil.Type]\n ? 'bigint'\n : Equals<T, number> extends true //[T] extends [numberUtil.Type]\n ? 'number'\n : Equals<T, Date> extends true //[T] extends [dateUtil.Type]\n ? 'date'\n : T extends { [k: string]: any } //[T] extends [structUtil.Type]\n ? 'object'\n : 'rest'\n\nexport type ToZod<T> = {\n any: z.ZodAny\n optional: z.ZodOptional<ToZod<NonOptional<T>>>\n nullable: z.ZodNullable<ToZod<NonNullable<T>>>\n array: T extends Array<infer U> ? z.ZodArray<ToZod<U>> : never\n string: z.ZodString\n bigint: z.ZodBigInt\n number: z.ZodNumber\n boolean: z.ZodBoolean\n date: z.ZodDate\n object: z.ZodObject<\n // @ts-expect-error cannot convert without Extract but Extract removes the type\n {\n [K in keyof T]: T[K]\n },\n 'passthrough',\n unknown,\n T\n >\n rest: z.ZodType<T>\n}[ZodKey<T>]\n\nexport type ZodShape<T> = {\n // Require all the keys from T\n [key in keyof T]-?: ToZod<T[key]>\n}\n";
3
+ //#endregion
4
+ export { source };
5
+
6
+ //# sourceMappingURL=ToZod.source.js.map
@@ -0,0 +1,112 @@
1
+ {
2
+ "name": "@kubb/plugin-zod",
3
+ "version": "4.37.2",
4
+ "description": "Zod schema generator plugin for Kubb, creating type-safe validation schemas from OpenAPI specifications for runtime data validation.",
5
+ "keywords": [
6
+ "zod",
7
+ "schema",
8
+ "schema-validation",
9
+ "validation",
10
+ "runtime-validation",
11
+ "type-safety",
12
+ "type-safe",
13
+ "typescript",
14
+ "openapi",
15
+ "swagger",
16
+ "oas",
17
+ "code-generator",
18
+ "codegen",
19
+ "plugins",
20
+ "kubb"
21
+ ],
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/kubb-labs/kubb.git",
25
+ "directory": "packages/plugin-zod"
26
+ },
27
+ "license": "MIT",
28
+ "author": "stijnvanhulle",
29
+ "sideEffects": false,
30
+ "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "import": "./dist/index.js",
34
+ "require": "./dist/index.cjs"
35
+ },
36
+ "./components": {
37
+ "import": "./dist/components.js",
38
+ "require": "./dist/components.cjs"
39
+ },
40
+ "./generators": {
41
+ "import": "./dist/generators.js",
42
+ "require": "./dist/generators.cjs"
43
+ },
44
+ "./templates/ToZod.source": {
45
+ "import": "./dist/templates/ToZod.source.js",
46
+ "require": "./dist/templates/ToZod.source.cjs"
47
+ },
48
+ "./package.json": "./package.json"
49
+ },
50
+ "types": "./dist/index.d.ts",
51
+ "typesVersions": {
52
+ "*": {
53
+ "components": [
54
+ "./dist/components.d.ts"
55
+ ],
56
+ "generators": [
57
+ "./dist/generators.d.ts"
58
+ ],
59
+ "templates/ToZod.source": [
60
+ "./dist/templates/ToZod.source.d.ts"
61
+ ]
62
+ }
63
+ },
64
+ "files": [
65
+ "src",
66
+ "templates",
67
+ "dist",
68
+ "!/**/**.test.**",
69
+ "!/**/__tests__/**",
70
+ "!/**/__snapshots__/**"
71
+ ],
72
+ "size-limit": [
73
+ {
74
+ "path": "./dist/*.js",
75
+ "limit": "510 KiB",
76
+ "gzip": true
77
+ }
78
+ ],
79
+ "dependencies": {
80
+ "@kubb/react-fabric": "0.14.0",
81
+ "remeda": "^2.33.6",
82
+ "@kubb/core": "4.37.2",
83
+ "@kubb/oas": "4.37.2",
84
+ "@kubb/plugin-ts": "4.37.2",
85
+ "@kubb/plugin-oas": "4.37.2"
86
+ },
87
+ "devDependencies": {
88
+ "@asteasolutions/zod-to-openapi": "^8.5.0",
89
+ "zod": "^3.25.76",
90
+ "@internals/utils": "0.0.0"
91
+ },
92
+ "engines": {
93
+ "node": ">=20"
94
+ },
95
+ "publishConfig": {
96
+ "access": "public",
97
+ "registry": "https://registry.npmjs.org/"
98
+ },
99
+ "main": "./dist/index.cjs",
100
+ "module": "./dist/index.js",
101
+ "scripts": {
102
+ "build": "tsdown && size-limit",
103
+ "clean": "npx rimraf ./dist",
104
+ "lint": "bun biome lint .",
105
+ "lint:fix": "bun biome lint --fix --unsafe .",
106
+ "release": "pnpm publish --no-git-check",
107
+ "release:canary": "bash ../../.github/canary.sh && node ../../scripts/build.js canary && pnpm publish --no-git-check",
108
+ "start": "tsdown --watch",
109
+ "test": "vitest --passWithNoTests",
110
+ "typecheck": "tsc -p ./tsconfig.json --noEmit --emitDeclarationOnly false"
111
+ }
112
+ }
@@ -0,0 +1,38 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", {
5
+ value,
6
+ configurable: true
7
+ });
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
13
+ var __exportAll = (all, no_symbols) => {
14
+ let target = {};
15
+ for (var name in all) __defProp(target, name, {
16
+ get: all[name],
17
+ enumerable: true
18
+ });
19
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
20
+ return target;
21
+ };
22
+ var __copyProps = (to, from, except, desc) => {
23
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
24
+ key = keys[i];
25
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
26
+ get: ((k) => from[k]).bind(null, key),
27
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
28
+ });
29
+ }
30
+ return to;
31
+ };
32
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
33
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
34
+ value: mod,
35
+ enumerable: true
36
+ }) : target, mod));
37
+ //#endregion
38
+ export { __toESM as a, __reExport as i, __exportAll as n, __name as r, __commonJSMin as t };