kubb 5.0.0-beta.1 → 5.0.0-beta.100

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 (63) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +104 -48
  3. package/bin/kubb.js +11 -3
  4. package/dist/astro.cjs +4 -0
  5. package/dist/astro.d.ts +2 -0
  6. package/dist/astro.js +2 -0
  7. package/dist/config.cjs +3 -0
  8. package/dist/config.d.ts +3 -0
  9. package/dist/config.js +2 -0
  10. package/dist/defineConfig-BCzzAVwJ.js +114 -0
  11. package/dist/defineConfig-BCzzAVwJ.js.map +1 -0
  12. package/dist/defineConfig-CzY_scM2.cjs +119 -0
  13. package/dist/defineConfig-CzY_scM2.cjs.map +1 -0
  14. package/dist/defineConfig-DwxZtGhf.d.ts +61 -0
  15. package/dist/esbuild.cjs +4 -0
  16. package/dist/esbuild.d.ts +2 -0
  17. package/dist/esbuild.js +2 -0
  18. package/dist/farm.cjs +4 -0
  19. package/dist/farm.d.ts +2 -0
  20. package/dist/farm.js +2 -0
  21. package/dist/index.cjs +9 -78
  22. package/dist/index.d.ts +4 -44
  23. package/dist/index.js +3 -78
  24. package/dist/jsx/jsx-dev-runtime.cjs +9 -0
  25. package/dist/jsx/jsx-dev-runtime.d.ts +1 -0
  26. package/dist/jsx/jsx-dev-runtime.js +2 -0
  27. package/dist/jsx/jsx-runtime.cjs +9 -0
  28. package/dist/jsx/jsx-runtime.d.ts +1 -0
  29. package/dist/jsx/jsx-runtime.js +2 -0
  30. package/dist/jsx.cjs +18 -0
  31. package/dist/jsx.d.ts +2 -0
  32. package/dist/jsx.js +3 -0
  33. package/dist/kit/testing.cjs +9 -0
  34. package/dist/kit/testing.d.ts +1 -0
  35. package/dist/kit/testing.js +2 -0
  36. package/dist/kit.cjs +9 -0
  37. package/dist/kit.d.ts +1 -0
  38. package/dist/kit.js +2 -0
  39. package/dist/nuxt.cjs +4 -0
  40. package/dist/nuxt.d.ts +2 -0
  41. package/dist/nuxt.js +2 -0
  42. package/dist/rolldown-runtime-Bx3C2hgW.cjs +38 -0
  43. package/dist/rolldown.cjs +4 -0
  44. package/dist/rolldown.d.ts +2 -0
  45. package/dist/rolldown.js +2 -0
  46. package/dist/rollup.cjs +4 -0
  47. package/dist/rollup.d.ts +2 -0
  48. package/dist/rollup.js +2 -0
  49. package/dist/rspack.cjs +4 -0
  50. package/dist/rspack.d.ts +2 -0
  51. package/dist/rspack.js +2 -0
  52. package/dist/vite.cjs +4 -0
  53. package/dist/vite.d.ts +2 -0
  54. package/dist/vite.js +2 -0
  55. package/dist/webpack.cjs +4 -0
  56. package/dist/webpack.d.ts +2 -0
  57. package/dist/webpack.js +2 -0
  58. package/package.json +83 -28
  59. package/dist/index.cjs.map +0 -1
  60. package/dist/index.js.map +0 -1
  61. package/src/defineConfig.ts +0 -91
  62. package/src/index.ts +0 -2
  63. /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/LICENSE CHANGED
@@ -1,14 +1,21 @@
1
- Copyright (c) 2026 Stijn Van Hulle
2
-
3
- This repository contains software under two licenses:
1
+ MIT License
4
2
 
5
- 1. Most of the code in this repository is licensed under the
6
- MIT License — see licenses/LICENSE-MIT for the full license text.
3
+ Copyright (c) 2026 Stijn Van Hulle
7
4
 
8
- 2. The following components are licensed under the
9
- GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later)
10
- see licenses/LICENSE-AGPL-3.0 for the full license text:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
11
 
12
- - packages/agent (published as @kubb/agent)
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
13
14
 
14
- Each package's own LICENSE file or package.json specifies its applicable license.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,18 +1,18 @@
1
1
  <div align="center">
2
2
  <a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
3
- <img width="180" src="https://raw.githubusercontent.com/kubb-labs/kubb/main/assets/logo.png" alt="Kubb logo">
3
+ <img src="https://kubb.dev/og.png" alt="Kubb banner">
4
4
  </a>
5
5
 
6
6
  [![npm version][npm-version-src]][npm-version-href]
7
7
  [![npm downloads][npm-downloads-src]][npm-downloads-href]
8
- [![Coverage][coverage-src]][coverage-href]
8
+ [![Stars][stars-src]][stars-href]
9
9
  [![License][license-src]][license-href]
10
- [![Sponsors][sponsors-src]][sponsors-href]
10
+ [![Coverage][coverage-src]][coverage-href]
11
+ [![Node][node-src]][node-href]
12
+ [![OC Backers][oc-backers-src]][oc-backers-href]
11
13
 
12
14
  <h4>
13
- <a href="https://codesandbox.io/s/github/kubb-labs/kubb/tree/main/examples/typescript" target="_blank">View Demo</a>
14
- <span> · </span>
15
- <a href="https://kubb.dev/" target="_blank">Documentation</a>
15
+ <a href="https://kubb.dev" target="_blank">Documentation</a>
16
16
  <span> · </span>
17
17
  <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
18
18
  <span> · </span>
@@ -22,28 +22,73 @@
22
22
 
23
23
  <br />
24
24
 
25
+ # Kubb
26
+
27
+ ### The meta framework for code generation
28
+
29
+ Point Kubb at a schema and it generates types, clients, hooks, validators, mocks, and more.
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ bun add kubb
35
+ # or
36
+ pnpm add kubb
37
+ # or
38
+ npm install kubb
39
+ ```
40
+
41
+ ## Quick start
42
+
43
+ Run the setup wizard to create a `kubb.config.ts`:
44
+
45
+ ```bash
46
+ npx kubb init
47
+ ```
48
+
49
+ The wizard creates a `package.json` if needed, guides you through plugin selection, installs packages, and writes `kubb.config.ts`. Then generate your code:
50
+
51
+ ```bash
52
+ npx kubb generate
53
+ ```
54
+
55
+ See the [documentation](https://kubb.dev) for detailed usage and advanced features.
56
+
25
57
  ## Features
26
58
 
27
- - Works with Node.js 22+ and TypeScript 6.
28
- - Convert Swagger 2.0, OpenAPI 3.0, and OpenAPI 3.1 to TypeScript types, API clients, and more via the [plugin ecosystem](https://github.com/kubb-labs/kubb-plugins).
29
- - Extensible plugin and middleware system for customizing and composing code generation.
30
- - CLI support with interactive setup, progress bar, and detailed logs.
31
- - Model Context Protocol (MCP) server for AI assistants like [Claude](https://claude.ai), [Cursor](https://cursor.sh), and other MCP-compatible tools.
32
- - JSX-based renderer (`@kubb/renderer-jsx`) for building custom plugin output.
33
- - Barrel file generation via the `@kubb/middleware-barrel` middleware.
59
+ - Generate TypeScript types, type-safe clients, [TanStack Query](https://github.com/TanStack/query) and [SWR](https://github.com/vercel/swr) hooks, [Zod](https://github.com/colinhacks/zod) validators, [Faker](https://github.com/faker-js/faker) mocks, and [MSW](https://github.com/mswjs/msw) handlers from one schema.
60
+ - Generate a typed [axios](https://axios-http.com/) or [Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) client with status-keyed results, auth, validation, file uploads, server-sent events, interceptors, and a swappable transport.
61
+ - Read OpenAPI 2.0, 3.0, and 3.1 through adapters like [`@kubb/adapter-oas`](https://npmx.dev/package/@kubb/adapter-oas), with output for Node.js and Bun.
62
+ - Enable only the [plugins](https://github.com/kubb-labs/plugins) you need: `plugin-ts`, `plugin-axios`, `plugin-fetch`, `plugin-react-query`, `plugin-vue-query`, `plugin-swr`, `plugin-zod`, `plugin-faker`, `plugin-msw`, `plugin-cypress`, `plugin-redoc`, `plugin-mcp`.
63
+ - Shape the output by grouping files by tag, including or excluding operations, and writing to disk, memory, or a custom storage backend.
64
+ - Build your own plugins, generators, adapters, and renderers with the [`kubb/kit`](https://kubb.dev/docs/5.x/reference/kit) authoring toolkit, plus a JSX renderer for component-based output.
65
+ - Run generation in your bundler with `unplugin-kubb` for [Vite](https://github.com/vitejs/vite), [Nuxt](https://github.com/nuxt/nuxt), [Astro](https://github.com/withastro/astro), [webpack](https://github.com/webpack/webpack), and more.
66
+ - Drive generation from AI tools over the built-in MCP server ([Claude](https://claude.ai), [Cursor](https://cursor.sh)) or inside [Claude Code](https://kubb.dev/docs/5.x/ai/claude).
34
67
 
35
68
  ## Supporting Kubb
36
69
 
37
- Kubb uses an MIT-licensed open source project with its ongoing development made possible entirely by the support of Sponsors. If you would like to become a sponsor, please consider:
70
+ Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
38
71
 
39
72
  - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
73
+ - [Back Kubb on Open Collective](https://opencollective.com/kubb)
74
+ - [See sponsorship tiers and our sponsors](https://kubb.dev/sponsors)
40
75
 
41
76
  <p align="center">
42
77
  <a href="https://github.com/sponsors/stijnvanhulle">
43
- <img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
78
+ <img src="https://shieldcn.dev/sponsors/stijnvanhulle.svg?titleAlign=center&mode=dark" alt="stijnvanhulle sponsors" width="100%" />
44
79
  </a>
45
80
  </p>
46
81
 
82
+ ## Contributing
83
+
84
+ We welcome contributions that help improve Kubb. A few ways to get involved:
85
+
86
+ - Found a bug? File it in the [issue tracker](https://github.com/kubb-labs/kubb/issues).
87
+ - Have an idea to improve Kubb? [Open an issue](https://github.com/kubb-labs/kubb/issues/new) to share it.
88
+ - Need help? Ask the community on [Discord](https://discord.gg/4dQjA6vrWX).
89
+
90
+ See [CONTRIBUTING.md](https://github.com/kubb-labs/kubb/blob/main/CONTRIBUTING.md) for the project structure, local setup, and commands.
91
+
47
92
  ## Contributors [![Contributors][contributors-src]][contributors-href]
48
93
 
49
94
  <!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
@@ -53,55 +98,73 @@ Kubb uses an MIT-licensed open source project with its ongoing development made
53
98
  <tbody>
54
99
  <tr>
55
100
  <td align="center" valign="top" width="14.28%"><a href="http://www.stijnvanhulle.be"><img src="https://avatars.githubusercontent.com/u/5904681?v=4?s=100" width="100px;" alt="Stijn Van Hulle"/><br /><sub><b>Stijn Van Hulle</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=stijnvanhulle" title="Code">💻</a></td>
56
- <td align="center" valign="top" width="14.28%"><a href="https://fosstodon.org/@xphentom"><img src="https://avatars.githubusercontent.com/u/5096867?v=4?s=100" width="100px;" alt="Wouter Roozeleer"/><br /><sub><b>Wouter Roozeleer</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=xPhentom" title="Code">💻</a></td>
57
101
  <td align="center" valign="top" width="14.28%"><a href="https://aluc.io/"><img src="https://avatars.githubusercontent.com/u/15520015?v=4?s=100" width="100px;" alt="Alfred"/><br /><sub><b>Alfred</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=b6pzeusbc54tvhw5jgpyw8pwz2x6gs" title="Code">💻</a></td>
58
102
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/raveclassic"><img src="https://avatars.githubusercontent.com/u/1743568?v=4?s=100" width="100px;" alt="Kirill Agalakov"/><br /><sub><b>Kirill Agalakov</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=raveclassic" title="Code">💻</a></td>
59
103
  <td align="center" valign="top" width="14.28%"><a href="http://wicky.nillia.ms"><img src="https://avatars.githubusercontent.com/u/1091390?v=4?s=100" width="100px;" alt="Nick Williams"/><br /><sub><b>Nick Williams</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=WickyNilliams" title="Documentation">📖</a></td>
60
104
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/helt"><img src="https://avatars.githubusercontent.com/u/1732112?v=4?s=100" width="100px;" alt="helt"/><br /><sub><b>helt</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=helt" title="Code">💻</a></td>
61
105
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/Ti-webdev"><img src="https://avatars.githubusercontent.com/u/478565?v=4?s=100" width="100px;" alt="Vasily Mikhaylovsky"/><br /><sub><b>Vasily Mikhaylovsky</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=Ti-webdev" title="Code">💻</a></td>
106
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/chiptus"><img src="https://avatars.githubusercontent.com/u/1381655?v=4?s=100" width="100px;" alt="Chaim Lev-Ari"/><br /><sub><b>Chaim Lev-Ari</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=chiptus" title="Code">💻</a></td>
62
107
  </tr>
63
108
  <tr>
64
- <td align="center" valign="top" width="14.28%"><a href="https://github.com/chiptus"><img src="https://avatars.githubusercontent.com/u/1381655?v=4?s=100" width="100px;" alt="Chaim Lev-Ari"/><br /><sub><b>Chaim Lev-Ari</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=chiptus" title="Code">💻</a></td>
65
109
  <td align="center" valign="top" width="14.28%"><a href="http://projects.pafnuty.name"><img src="https://avatars.githubusercontent.com/u/1635679?v=4?s=100" width="100px;" alt="Pavel Belousov"/><br /><sub><b>Pavel Belousov</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=pafnuty" title="Code">💻</a></td>
66
110
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/dmitry-blackwave"><img src="https://avatars.githubusercontent.com/u/5526543?v=4?s=100" width="100px;" alt="Dmitry Belov"/><br /><sub><b>Dmitry Belov</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=dmitry-blackwave" title="Code">💻</a></td>
67
111
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/aburgel"><img src="https://avatars.githubusercontent.com/u/341478?v=4?s=100" width="100px;" alt="Alex Burgel"/><br /><sub><b>Alex Burgel</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=aburgel" title="Code">💻</a></td>
68
112
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/dgarciamuria"><img src="https://avatars.githubusercontent.com/u/8144333?v=4?s=100" width="100px;" alt="Daniel Garcia"/><br /><sub><b>Daniel Garcia</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=dgarciamuria" title="Code">💻</a></td>
69
113
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/wuyuanyi135"><img src="https://avatars.githubusercontent.com/u/11760870?v=4?s=100" width="100px;" alt="wuyuanyi135"/><br /><sub><b>wuyuanyi135</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=wuyuanyi135" title="Code">💻</a></td>
70
114
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/cjthompson"><img src="https://avatars.githubusercontent.com/u/1958266?v=4?s=100" width="100px;" alt="Chris Thompson"/><br /><sub><b>Chris Thompson</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=cjthompson" title="Code">💻</a></td>
115
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/hkang1"><img src="https://avatars.githubusercontent.com/u/220971?v=4?s=100" width="100px;" alt="Caleb Hoyoul Kang"/><br /><sub><b>Caleb Hoyoul Kang</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=hkang1" title="Code">💻</a></td>
71
116
  </tr>
72
117
  <tr>
73
- <td align="center" valign="top" width="14.28%"><a href="https://github.com/hkang1"><img src="https://avatars.githubusercontent.com/u/220971?v=4?s=100" width="100px;" alt="Caleb Hoyoul Kang"/><br /><sub><b>Caleb Hoyoul Kang</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=hkang1" title="Code">💻</a></td>
74
118
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/grreeenn"><img src="https://avatars.githubusercontent.com/u/13204857?v=4?s=100" width="100px;" alt="Gregory Zhukovsky"/><br /><sub><b>Gregory Zhukovsky</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=grreeenn" title="Code">💻</a></td>
75
119
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/ChilloManiac"><img src="https://avatars.githubusercontent.com/u/3761964?v=4?s=100" width="100px;" alt="Christoffer Nørbjerg"/><br /><sub><b>Christoffer Nørbjerg</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=ChilloManiac" title="Code">💻</a></td>
76
120
  <td align="center" valign="top" width="14.28%"><a href="https://codefy.de/de/karriere"><img src="https://avatars.githubusercontent.com/u/122524301?v=4?s=100" width="100px;" alt="CHE1RON"/><br /><sub><b>CHE1RON</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=CHE1RON" title="Code">💻</a></td>
77
121
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/ekaradon"><img src="https://avatars.githubusercontent.com/u/9439390?v=4?s=100" width="100px;" alt="ekaradon"/><br /><sub><b>ekaradon</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=ekaradon" title="Code">💻</a></td>
78
122
  <td align="center" valign="top" width="14.28%"><a href="https://thijmen.dev"><img src="https://avatars.githubusercontent.com/u/383903?v=4?s=100" width="100px;" alt="Thijmen Stavenuiter"/><br /><sub><b>Thijmen Stavenuiter</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=Thijmen" title="Code">💻</a></td>
79
123
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/bohdanhusak"><img src="https://avatars.githubusercontent.com/u/13829370?v=4?s=100" width="100px;" alt="Bohdan Husak"/><br /><sub><b>Bohdan Husak</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=bohdanhusak" title="Documentation">📖</a></td>
124
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/Ericlm"><img src="https://avatars.githubusercontent.com/u/19361503?v=4?s=100" width="100px;" alt="Éric Le Maître"/><br /><sub><b>Éric Le Maître</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=Ericlm" title="Code">💻</a></td>
80
125
  </tr>
81
126
  <tr>
82
- <td align="center" valign="top" width="14.28%"><a href="https://github.com/Ericlm"><img src="https://avatars.githubusercontent.com/u/19361503?v=4?s=100" width="100px;" alt="Éric Le Maître"/><br /><sub><b>Éric Le Maître</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=Ericlm" title="Code">💻</a></td>
83
127
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/chambber"><img src="https://avatars.githubusercontent.com/u/11406841?v=4?s=100" width="100px;" alt="Rubens Pereira do Nascimento"/><br /><sub><b>Rubens Pereira do Nascimento</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=chambber" title="Code">💻</a></td>
84
128
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/msutkowski"><img src="https://avatars.githubusercontent.com/u/784953?v=4?s=100" width="100px;" alt="Matt Sutkowski"/><br /><sub><b>Matt Sutkowski</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=msutkowski" title="Code">💻</a></td>
85
129
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/vitorcamachoo"><img src="https://avatars.githubusercontent.com/u/20595956?v=4?s=100" width="100px;" alt="Vítor Camacho"/><br /><sub><b>Vítor Camacho</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=vitorcamachoo" title="Code">💻</a></td>
86
130
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/VasekProchazka"><img src="https://avatars.githubusercontent.com/u/13906845?v=4?s=100" width="100px;" alt="Václav Procházka"/><br /><sub><b>Václav Procházka</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=VasekProchazka" title="Code">💻</a></td>
87
131
  <td align="center" valign="top" width="14.28%"><a href="https://codx.dev"><img src="https://avatars.githubusercontent.com/u/59735735?v=4?s=100" width="100px;" alt="Luiz Bett"/><br /><sub><b>Luiz Bett</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=heyBett" title="Code">💻</a></td>
88
132
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/lambdank"><img src="https://avatars.githubusercontent.com/u/5475129?v=4?s=100" width="100px;" alt="Sebastian Andersen"/><br /><sub><b>Sebastian Andersen</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=lambdank" title="Code">💻</a></td>
133
+ <td align="center" valign="top" width="14.28%"><a href="https://akino.icu"><img src="https://avatars.githubusercontent.com/u/64176534?v=4?s=100" width="100px;" alt="Akino"/><br /><sub><b>Akino</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=akinoccc" title="Code">💻</a></td>
89
134
  </tr>
90
135
  <tr>
91
- <td align="center" valign="top" width="14.28%"><a href="https://akino.icu"><img src="https://avatars.githubusercontent.com/u/64176534?v=4?s=100" width="100px;" alt="Akino"/><br /><sub><b>Akino</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=akinoccc" title="Code">💻</a></td>
92
136
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/rmachado-studocu"><img src="https://avatars.githubusercontent.com/u/89906313?v=4?s=100" width="100px;" alt="Ricardo Machado"/><br /><sub><b>Ricardo Machado</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=rmachado-studocu" title="Code">💻</a></td>
93
137
  <td align="center" valign="top" width="14.28%"><a href="http://simonelnahas.com"><img src="https://avatars.githubusercontent.com/u/29279201?v=4?s=100" width="100px;" alt="Simon El Nahas"/><br /><sub><b>Simon El Nahas</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=simonelnahas" title="Documentation">📖</a></td>
94
138
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/maartenvansambeek"><img src="https://avatars.githubusercontent.com/u/91739524?v=4?s=100" width="100px;" alt="maartenvansambeek"/><br /><sub><b>maartenvansambeek</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=maartenvansambeek" title="Code">💻</a></td>
95
139
  <td align="center" valign="top" width="14.28%"><a href="https://sdufresne.info"><img src="https://avatars.githubusercontent.com/u/583851?v=4?s=100" width="100px;" alt="Stefan du Fresne"/><br /><sub><b>Stefan du Fresne</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=SCdF" title="Code">💻</a></td>
96
140
  <td align="center" valign="top" width="14.28%"><a href="https://hugofelippe.github.io/"><img src="https://avatars.githubusercontent.com/u/19368365?v=4?s=100" width="100px;" alt="Hugo Felippe de Souza Cruz"/><br /><sub><b>Hugo Felippe de Souza Cruz</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=hugoFelippe" title="Code">💻</a></td>
97
141
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/belgattitude"><img src="https://avatars.githubusercontent.com/u/259798?v=4?s=100" width="100px;" alt="Sébastien Vanvelthem"/><br /><sub><b>Sébastien Vanvelthem</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=belgattitude" title="Code">💻</a></td>
142
+ <td align="center" valign="top" width="14.28%"><a href="http://bento.me/vitalygashkov"><img src="https://avatars.githubusercontent.com/u/30000398?v=4?s=100" width="100px;" alt="Vitaly Gashkov"/><br /><sub><b>Vitaly Gashkov</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=vitalygashkov" title="Documentation">📖</a></td>
98
143
  </tr>
99
144
  <tr>
100
- <td align="center" valign="top" width="14.28%"><a href="http://bento.me/vitalygashkov"><img src="https://avatars.githubusercontent.com/u/30000398?v=4?s=100" width="100px;" alt="Vitaly Gashkov"/><br /><sub><b>Vitaly Gashkov</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=vitalygashkov" title="Documentation">📖</a></td>
101
145
  <td align="center" valign="top" width="14.28%"><a href="https://ducduc.nl"><img src="https://avatars.githubusercontent.com/u/9675738?v=4?s=100" width="100px;" alt="Duco Drupsteen"/><br /><sub><b>Duco Drupsteen</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=ducodrupsteen" title="Code">💻</a></td>
102
146
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/th3l0g4n"><img src="https://avatars.githubusercontent.com/u/326306?v=4?s=100" width="100px;" alt="th3l0g4n"/><br /><sub><b>th3l0g4n</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=th3l0g4n" title="Code">💻</a></td>
103
147
  <td align="center" valign="top" width="14.28%"><a href="https://rxliuli.com"><img src="https://avatars.githubusercontent.com/u/24560368?v=4?s=100" width="100px;" alt="rxliuli"/><br /><sub><b>rxliuli</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=rxliuli" title="Code">💻</a></td>
104
148
  <td align="center" valign="top" width="14.28%"><a href="https://github.com/humarkx"><img src="https://avatars.githubusercontent.com/u/13049940?v=4?s=100" width="100px;" alt="humarkx"/><br /><sub><b>humarkx</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=humarkx" title="Code">💻</a></td>
149
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/Jakub-Cerovsky"><img src="https://avatars.githubusercontent.com/u/141134227?v=4?s=100" width="100px;" alt="Jakub Cerovsky"/><br /><sub><b>Jakub Cerovsky</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=Jakub-Cerovsky" title="Code">💻</a></td>
150
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/yukikwi"><img src="https://avatars.githubusercontent.com/u/66879660?v=4?s=100" width="100px;" alt="Pachara Chantawong"/><br /><sub><b>Pachara Chantawong</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=yukikwi" title="Code">💻</a></td>
151
+ <td align="center" valign="top" width="14.28%"><a href="https://volodymyrkushnir.dev/"><img src="https://avatars.githubusercontent.com/u/10290626?v=4?s=100" width="100px;" alt="Volodymyr Kushnir"/><br /><sub><b>Volodymyr Kushnir</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=volodymyr-kushnir" title="Code">💻</a></td>
152
+ </tr>
153
+ <tr>
154
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/GKNewsrooms"><img src="https://avatars.githubusercontent.com/u/201248633?v=4?s=100" width="100px;" alt="GKNewsrooms"/><br /><sub><b>GKNewsrooms</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=GKNewsrooms" title="Code">💻</a></td>
155
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/stepek"><img src="https://avatars.githubusercontent.com/u/5058678?v=4?s=100" width="100px;" alt="Kamil Stepczuk"/><br /><sub><b>Kamil Stepczuk</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=stepek" title="Code">💻</a></td>
156
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/JoaoBrlt"><img src="https://avatars.githubusercontent.com/u/11065509?v=4?s=100" width="100px;" alt="João Brilhante"/><br /><sub><b>João Brilhante</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=JoaoBrlt" title="Code">💻</a></td>
157
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/kamilzki"><img src="https://avatars.githubusercontent.com/u/27976736?v=4?s=100" width="100px;" alt="Kamil Sieradzki"/><br /><sub><b>Kamil Sieradzki</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=kamilzki" title="Code">💻</a></td>
158
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/EricPierlotIdmog"><img src="https://avatars.githubusercontent.com/u/124898024?v=4?s=100" width="100px;" alt="Eric Pierlot"/><br /><sub><b>Eric Pierlot</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=EricPierlotIdmog" title="Code">💻</a></td>
159
+ <td align="center" valign="top" width="14.28%"><a href="http://atholin.se"><img src="https://avatars.githubusercontent.com/u/33940473?v=4?s=100" width="100px;" alt="Alexander Sjöcrona Tholin"/><br /><sub><b>Alexander Sjöcrona Tholin</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=ATholin" title="Code">💻</a></td>
160
+ <td align="center" valign="top" width="14.28%"><a href="http://hyoban.cc"><img src="https://avatars.githubusercontent.com/u/38493346?v=4?s=100" width="100px;" alt="Stephen Zhou"/><br /><sub><b>Stephen Zhou</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=hyoban" title="Code">💻</a></td>
161
+ </tr>
162
+ <tr>
163
+ <td align="center" valign="top" width="14.28%"><a href="https://choly.ca"><img src="https://avatars.githubusercontent.com/u/943597?v=4?s=100" width="100px;" alt="Ilia Choly"/><br /><sub><b>Ilia Choly</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=icholy" title="Code">💻</a></td>
164
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/skoropadas"><img src="https://avatars.githubusercontent.com/u/20700969?v=4?s=100" width="100px;" alt="Alex Skoropad"/><br /><sub><b>Alex Skoropad</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=skoropadas" title="Code">💻</a></td>
165
+ <td align="center" valign="top" width="14.28%"><a href="https://pateljay.io"><img src="https://avatars.githubusercontent.com/u/36803168?v=4?s=100" width="100px;" alt="Jay Patel"/><br /><sub><b>Jay Patel</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=jay-babu" title="Code">💻</a></td>
166
+ <td align="center" valign="top" width="14.28%"><a href="https://hamzamihaidaniel.com"><img src="https://avatars.githubusercontent.com/u/12731515?v=4?s=100" width="100px;" alt="Hamza Mihai Daniel"/><br /><sub><b>Hamza Mihai Daniel</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=hamzamihaidanielx" title="Code">💻</a></td>
167
+ <td align="center" valign="top" width="14.28%"><a href="https://github.com/DesselBane"><img src="https://avatars.githubusercontent.com/u/12199480?v=4?s=100" width="100px;" alt="DesselBane"/><br /><sub><b>DesselBane</b></sub></a><br /><a href="https://github.com/kubb-labs/kubb/commits?author=DesselBane" title="Code">💻</a></td>
105
168
  </tr>
106
169
  </tbody>
107
170
  </table>
@@ -110,39 +173,32 @@ Kubb uses an MIT-licensed open source project with its ongoing development made
110
173
  <!-- prettier-ignore-end -->
111
174
 
112
175
  <!-- ALL-CONTRIBUTORS-LIST:END -->
113
- <!-- prettier-ignore-start -->
114
- <!-- markdownlint-disable -->
115
176
 
116
- <!-- markdownlint-restore -->
117
- <!-- prettier-ignore-end -->
177
+ ## License
118
178
 
119
- <!-- ALL-CONTRIBUTORS-LIST:END -->
179
+ This repository is licensed under the [MIT License](./licenses/LICENSE-MIT), Copyright © 2025 [Stijn Van Hulle](https://stijnvanhulle.be).
180
+
181
+ See [LICENSE](./LICENSE) for details.
120
182
 
121
- ## Star History
183
+ ## Star history
122
184
 
123
- <a href="https://star-history.com/#kubb-labs/kubb&Date">
124
- <picture>
125
- <source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=kubb-labs/kubb&type=Date&theme=dark" />
126
- <source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=kubb-labs/kubb&type=Date" />
127
- <img alt="Star History Chart" src="https://api.star-history.com/svg?repos=kubb-labs/kubb&type=Date" />
128
- </picture>
129
- </a>
185
+ <img alt="Star history chart" src="https://shieldcn.dev/chart/github/stars/kubb-labs/kubb.svg?theme=orange" width="100%" />
130
186
 
131
187
  <!-- Badges -->
132
188
 
133
- [npm-version-src]: https://img.shields.io/npm/v/@kubb/core?flat&colorA=18181B&colorB=f58517
134
- [npm-version-href]: https://npmjs.com/package/@kubb/core
135
- [npm-downloads-src]: https://img.shields.io/npm/dm/@kubb/core?flat&colorA=18181B&colorB=f58517
136
- [npm-downloads-href]: https://npmjs.com/package/@kubb/core
137
- [license-src]: https://img.shields.io/github/license/kubb-labs/kubb.svg?flat&colorA=18181B&colorB=f58517
189
+ [npm-version-src]: https://shieldcn.dev/npm/v/@kubb/core.svg?variant=secondary&size=xs&theme=zinc&mode=dark
190
+ [npm-version-href]: https://npmx.dev/package/kubb
191
+ [npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/core.svg?variant=secondary&size=xs&theme=zinc&mode=dark
192
+ [npm-downloads-href]: https://npmx.dev/package/kubb
193
+ [stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
194
+ [stars-href]: https://github.com/kubb-labs/kubb
195
+ [license-src]: https://shieldcn.dev/npm/license/kubb.svg?variant=secondary&size=xs&theme=zinc
138
196
  [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
139
- [build-src]: https://img.shields.io/github/actions/workflow/status/kubb-labs/kubb/ci.yaml?style=flat&colorA=18181B&colorB=f58517
140
- [build-href]: https://www.npmjs.com/package/@kubb/core
141
- [minified-src]: https://img.shields.io/bundlephobia/min/@kubb/core?style=flat&colorA=18181B&colorB=f58517
142
- [minified-href]: https://www.npmjs.com/package/@kubb/core
143
- [coverage-src]: https://img.shields.io/codecov/c/github/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517
144
- [coverage-href]: https://www.npmjs.com/package/@kubb/core
145
- [contributors-src]: https://img.shields.io/github/contributors/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517&label=%20
197
+ [node-src]: https://shieldcn.dev/npm/node/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
198
+ [node-href]: https://npmx.dev/package/kubb
199
+ [contributors-src]: https://shieldcn.dev/github/contributors/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
146
200
  [contributors-href]: #contributors-
147
- [sponsors-src]: https://img.shields.io/github/sponsors/stijnvanhulle?style=flat&colorA=18181B&colorB=f58517
148
- [sponsors-href]: https://github.com/sponsors/stijnvanhulle/
201
+ [coverage-src]: https://shieldcn.dev/codecov/github/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
202
+ [coverage-href]: https://app.codecov.io/gh/kubb-labs/kubb
203
+ [oc-backers-src]: https://shieldcn.dev/opencollective/backers/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
204
+ [oc-backers-href]: https://opencollective.com/kubb
package/bin/kubb.js CHANGED
@@ -1,4 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import('@kubb/cli').then(({ run }) => {
3
- run(process.argv)
4
- })
2
+
3
+ process.setSourceMapsEnabled?.(true)
4
+ process.title = 'Kubb'
5
+
6
+ try {
7
+ const { run } = await import('@kubb/cli')
8
+ await run(process.argv)
9
+ } catch (err) {
10
+ console.error(err)
11
+ process.exit(1)
12
+ }
package/dist/astro.cjs ADDED
@@ -0,0 +1,4 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-Bx3C2hgW.cjs");
2
+ let unplugin_kubb_astro = require("unplugin-kubb/astro");
3
+ unplugin_kubb_astro = require_rolldown_runtime.__toESM(unplugin_kubb_astro, 1);
4
+ module.exports = unplugin_kubb_astro.default;
@@ -0,0 +1,2 @@
1
+ import astro_default from "unplugin-kubb/astro";
2
+ export { astro_default as default };
package/dist/astro.js ADDED
@@ -0,0 +1,2 @@
1
+ import astro_default from "unplugin-kubb/astro";
2
+ export { astro_default as default };
@@ -0,0 +1,3 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_defineConfig = require("./defineConfig-CzY_scM2.cjs");
3
+ exports.defineConfig = require_defineConfig.defineConfig;
@@ -0,0 +1,3 @@
1
+ import { t as defineConfig } from "./defineConfig-DwxZtGhf.js";
2
+ import { BarrelType } from "@kubb/plugin-barrel";
3
+ export { type BarrelType, defineConfig };
package/dist/config.js ADDED
@@ -0,0 +1,2 @@
1
+ import { t as defineConfig } from "./defineConfig-BCzzAVwJ.js";
2
+ export { defineConfig };
@@ -0,0 +1,114 @@
1
+ import "./rolldown-runtime-C0LytTxp.js";
2
+ import { applyConfigDefaults, cliReporter, fileReporter, jsonReporter } from "@kubb/core";
3
+ import { adapterOas } from "@kubb/adapter-oas";
4
+ import { pluginBarrel, pluginBarrelName } from "@kubb/plugin-barrel";
5
+ import { parserTs, parserTsx } from "@kubb/parser-ts";
6
+ import { parserMd } from "@kubb/parser-md";
7
+ //#region ../../internals/utils/src/promise.ts
8
+ /** Returns `true` when `result` is a thenable `Promise`.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * isPromise(Promise.resolve(1)) // true
13
+ * isPromise(42) // false
14
+ * ```
15
+ */
16
+ function isPromise(result) {
17
+ return result !== null && result !== void 0 && typeof result["then"] === "function";
18
+ }
19
+ //#endregion
20
+ //#region src/defineConfig.ts
21
+ /**
22
+ * Applies default `root`, adapter, parsers, plugins, `output.barrel`, `output.format`, and `output.lint` to a single user config when not set.
23
+ *
24
+ * - `root` defaults to `process.cwd()`
25
+ * - `adapter` defaults to `adapterOas()`
26
+ * - `parsers` defaults to `[parserTs(), parserTsx(), parserMd()]`
27
+ * - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter]`
28
+ * - `plugins` gets `pluginBarrel()` appended when none is already present
29
+ * - `output.barrel` defaults to `{ type: 'named' }` when not set (`pluginBarrel` is always present after the step above)
30
+ * - `output.format` defaults to `false`
31
+ * - `output.lint` defaults to `false`
32
+ */
33
+ function applyDefaults(config) {
34
+ const { adapter, output, plugins } = applyConfigDefaults(config, {
35
+ defaultAdapter: adapterOas(),
36
+ barrelPlugin: pluginBarrel(),
37
+ barrelPluginName: pluginBarrelName,
38
+ defaultOutput: {
39
+ barrel: { type: "named" },
40
+ format: false,
41
+ lint: false
42
+ }
43
+ });
44
+ return {
45
+ ...config,
46
+ root: config.root || process.cwd(),
47
+ adapter,
48
+ parsers: config.parsers?.length ? config.parsers : [
49
+ parserTs(),
50
+ parserTsx(),
51
+ parserMd()
52
+ ],
53
+ reporters: config.reporters?.length ? config.reporters : [
54
+ cliReporter,
55
+ jsonReporter,
56
+ fileReporter
57
+ ],
58
+ plugins,
59
+ output
60
+ };
61
+ }
62
+ function normalizeConfig(config) {
63
+ if (Array.isArray(config)) return config.map(applyDefaults);
64
+ return applyDefaults(config);
65
+ }
66
+ /**
67
+ * Defines a Kubb build configuration and fills in defaults for any omitted fields.
68
+ *
69
+ * Defaults applied when omitted:
70
+ * - `adapter` → `adapterOas()` (OpenAPI 2.0/3.0/3.1).
71
+ * - `parsers` → `[parserTs(), parserTsx(), parserMd()]`.
72
+ * - `reporters` → `[cliReporter, jsonReporter, fileReporter]`.
73
+ * - `plugins` → `pluginBarrel()` is appended when not already present.
74
+ * - `output.barrel` → `{ type: 'named' }` when not set.
75
+ * - `output.format` and `output.lint` → `false`.
76
+ *
77
+ * Accepts a config object, an array of configs, a Promise resolving to one,
78
+ * or a function that receives the parsed CLI options and returns any of the
79
+ * above. The return type is preserved so async/array variants stay typed.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * import { defineConfig } from 'kubb'
84
+ * import { pluginTs } from '@kubb/plugin-ts'
85
+ *
86
+ * export default defineConfig({
87
+ * input: './petStore.yaml',
88
+ * output: { path: './src/gen' },
89
+ * plugins: [pluginTs()],
90
+ * })
91
+ * ```
92
+ *
93
+ * @example Function form with CLI options
94
+ * ```ts
95
+ * import { defineConfig } from 'kubb'
96
+ *
97
+ * export default defineConfig(({ input }) => ({
98
+ * input: input ?? './petStore.yaml',
99
+ * output: { path: './src/gen' },
100
+ * plugins: [],
101
+ * }))
102
+ * ```
103
+ */
104
+ function defineConfig(config) {
105
+ if (typeof config === "function") return (async (cli) => {
106
+ return normalizeConfig(await config(cli));
107
+ });
108
+ if (isPromise(config)) return config.then((resolved) => normalizeConfig(resolved));
109
+ return normalizeConfig(config);
110
+ }
111
+ //#endregion
112
+ export { defineConfig as t };
113
+
114
+ //# sourceMappingURL=defineConfig-BCzzAVwJ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineConfig-BCzzAVwJ.js","names":[],"sources":["../../../internals/utils/src/promise.ts","../src/defineConfig.ts"],"sourcesContent":["import { toError } from './errors.ts'\n\n/** A value that may already be resolved or still pending.\n *\n * @example\n * ```ts\n * function load(id: string): PossiblePromise<string> {\n * return cache.get(id) ?? fetchRemote(id)\n * }\n * ```\n */\nexport type PossiblePromise<T> = Promise<T> | T\n\n/** Returns `true` when `result` is a thenable `Promise`.\n *\n * @example\n * ```ts\n * isPromise(Promise.resolve(1)) // true\n * isPromise(42) // false\n * ```\n */\nexport function isPromise<T>(result: PossiblePromise<T>): result is Promise<T> {\n return result !== null && result !== undefined && typeof (result as Record<string, unknown>)['then'] === 'function'\n}\n\ntype Store<TKey, TValue> = {\n has(key: TKey): boolean\n get(key: TKey): TValue | undefined\n set(key: TKey, value: TValue): unknown\n}\n\n/**\n * Wraps `factory` with a keyed cache backed by the provided store.\n *\n * Pass a `WeakMap` for object keys (results are GC-eligible when the key is\n * collected) or a `Map` for primitive keys. For multi-argument functions,\n * nest two `memoize` calls — the outer keyed by the first argument, the\n * inner (created once per outer miss) keyed by the second.\n *\n * Because the cache is owned by the caller, it can be shared, inspected, or\n * cleared independently of the memoized function.\n *\n * @example Single WeakMap key\n * ```ts\n * const cache = new WeakMap<SchemaNode, Set<string>>()\n * const getRefs = memoize(cache, (node) => collectRefs(node))\n * ```\n *\n * @example Single Map key (primitive)\n * ```ts\n * const cache = new Map<string, Resolver>()\n * const getResolver = memoize(cache, (name) => buildResolver(name))\n * ```\n *\n * @example Two-level (object + primitive)\n * ```ts\n * const outer = new WeakMap<Params[], Map<string, Params[]>>()\n * const fn = memoize(outer, (params) => memoize(new Map(), (key) => transform(params, key)))\n * fn(params)('camelcase')\n * ```\n */\nexport function memoize<TKey, TValue>(store: Store<TKey, TValue>, factory: (key: TKey) => TValue): (key: TKey) => TValue {\n return (key: TKey): TValue => {\n if (store.has(key)) return store.get(key)!\n const value = factory(key)\n store.set(key, value)\n return value\n }\n}\n\ntype SerialRunnerOptions = {\n /**\n * The async work to serialize.\n */\n run(): Promise<void>\n /**\n * Receives errors thrown by `run`, so a failure never rejects the returned trigger.\n */\n onError(error: Error): void\n}\n\n/**\n * Wraps `run` so invocations never overlap: a trigger that lands while a run is in flight\n * marks it dirty and runs once more after it finishes, no matter how many triggers arrived.\n * Useful for event-driven reruns (a file watcher, a queue drain) where bursts should\n * coalesce into a single trailing run.\n *\n * @example\n * ```ts\n * const rebuild = createSerialRunner({\n * run: () => build(),\n * onError: (error) => log.error(error.message),\n * })\n * watcher.on('change', () => void rebuild())\n * ```\n */\nexport function createSerialRunner({ run, onError }: SerialRunnerOptions): () => Promise<void> {\n let running = false\n let dirty = false\n\n return async (): Promise<void> => {\n if (running) {\n dirty = true\n return\n }\n running = true\n do {\n dirty = false\n try {\n await run()\n } catch (error) {\n onError(toError(error))\n }\n } while (dirty)\n running = false\n }\n}\n","import { isPromise, type PossiblePromise } from '@internals/utils'\nimport { adapterOas } from '@kubb/adapter-oas'\nimport { applyConfigDefaults, cliReporter, type CLIOptions, fileReporter, jsonReporter, type UserConfig } from '@kubb/core'\nimport { pluginBarrel, pluginBarrelName } from '@kubb/plugin-barrel'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\nimport { parserMd } from '@kubb/parser-md'\n\ntype AnyConfigResult = UserConfig<unknown> | Array<UserConfig<unknown>>\ntype ConfigInput = AnyConfigResult | Promise<AnyConfigResult> | ((cli: CLIOptions) => PossiblePromise<AnyConfigResult>)\ntype NormalizeConfig<TConfig> =\n TConfig extends Array<UserConfig<infer TInput>> ? Array<UserConfig<TInput>> : TConfig extends UserConfig<infer TInput> ? UserConfig<TInput> : never\ntype DefinedConfig<TConfig extends ConfigInput> = TConfig extends (cli: CLIOptions) => PossiblePromise<infer TResult>\n ? (cli: CLIOptions) => Promise<NormalizeConfig<TResult>>\n : TConfig extends Promise<infer TResult>\n ? Promise<NormalizeConfig<TResult>>\n : NormalizeConfig<TConfig>\n\n/**\n * Applies default `root`, adapter, parsers, plugins, `output.barrel`, `output.format`, and `output.lint` to a single user config when not set.\n *\n * - `root` defaults to `process.cwd()`\n * - `adapter` defaults to `adapterOas()`\n * - `parsers` defaults to `[parserTs(), parserTsx(), parserMd()]`\n * - `reporters` defaults to `[cliReporter, jsonReporter, fileReporter]`\n * - `plugins` gets `pluginBarrel()` appended when none is already present\n * - `output.barrel` defaults to `{ type: 'named' }` when not set (`pluginBarrel` is always present after the step above)\n * - `output.format` defaults to `false`\n * - `output.lint` defaults to `false`\n */\nfunction applyDefaults<TInput>(config: UserConfig<TInput>): UserConfig<TInput> {\n const { adapter, output, plugins } = applyConfigDefaults(config, {\n defaultAdapter: adapterOas(),\n barrelPlugin: pluginBarrel(),\n barrelPluginName: pluginBarrelName,\n defaultOutput: { barrel: { type: 'named' }, format: false, lint: false },\n })\n\n return {\n ...config,\n root: config.root || process.cwd(),\n adapter,\n parsers: config.parsers?.length ? config.parsers : [parserTs(), parserTsx(), parserMd()],\n reporters: config.reporters?.length ? config.reporters : [cliReporter, jsonReporter, fileReporter],\n plugins,\n output,\n }\n}\n\nfunction normalizeConfig<TInput>(config: UserConfig<TInput> | Array<UserConfig<TInput>>): UserConfig<TInput> | Array<UserConfig<TInput>> {\n if (Array.isArray(config)) {\n return config.map(applyDefaults)\n }\n\n return applyDefaults(config)\n}\n\n/**\n * Defines a Kubb build configuration and fills in defaults for any omitted fields.\n *\n * Defaults applied when omitted:\n * - `adapter` → `adapterOas()` (OpenAPI 2.0/3.0/3.1).\n * - `parsers` → `[parserTs(), parserTsx(), parserMd()]`.\n * - `reporters` → `[cliReporter, jsonReporter, fileReporter]`.\n * - `plugins` → `pluginBarrel()` is appended when not already present.\n * - `output.barrel` → `{ type: 'named' }` when not set.\n * - `output.format` and `output.lint` → `false`.\n *\n * Accepts a config object, an array of configs, a Promise resolving to one,\n * or a function that receives the parsed CLI options and returns any of the\n * above. The return type is preserved so async/array variants stay typed.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'kubb'\n * import { pluginTs } from '@kubb/plugin-ts'\n *\n * export default defineConfig({\n * input: './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [pluginTs()],\n * })\n * ```\n *\n * @example Function form with CLI options\n * ```ts\n * import { defineConfig } from 'kubb'\n *\n * export default defineConfig(({ input }) => ({\n * input: input ?? './petStore.yaml',\n * output: { path: './src/gen' },\n * plugins: [],\n * }))\n * ```\n */\nexport function defineConfig<TConfig extends ConfigInput>(config: TConfig): DefinedConfig<TConfig> {\n if (typeof config === 'function') {\n return (async (cli: CLIOptions) => {\n return normalizeConfig(await config(cli))\n }) as DefinedConfig<TConfig>\n }\n\n if (isPromise(config)) {\n return config.then((resolved) => normalizeConfig(resolved)) as DefinedConfig<TConfig>\n }\n\n return normalizeConfig(config) as DefinedConfig<TConfig>\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAgB,UAAa,QAAkD;CAC7E,OAAO,WAAW,QAAQ,WAAW,KAAA,KAAa,OAAQ,OAAmC,YAAY;AAC3G;;;;;;;;;;;;;;;ACMA,SAAS,cAAsB,QAAgD;CAC7E,MAAM,EAAE,SAAS,QAAQ,YAAY,oBAAoB,QAAQ;EAC/D,gBAAgB,WAAW;EAC3B,cAAc,aAAa;EAC3B,kBAAkB;EAClB,eAAe;GAAE,QAAQ,EAAE,MAAM,QAAQ;GAAG,QAAQ;GAAO,MAAM;EAAM;CACzE,CAAC;CAED,OAAO;EACL,GAAG;EACH,MAAM,OAAO,QAAQ,QAAQ,IAAI;EACjC;EACA,SAAS,OAAO,SAAS,SAAS,OAAO,UAAU;GAAC,SAAS;GAAG,UAAU;GAAG,SAAS;EAAC;EACvF,WAAW,OAAO,WAAW,SAAS,OAAO,YAAY;GAAC;GAAa;GAAc;EAAY;EACjG;EACA;CACF;AACF;AAEA,SAAS,gBAAwB,QAAwG;CACvI,IAAI,MAAM,QAAQ,MAAM,GACtB,OAAO,OAAO,IAAI,aAAa;CAGjC,OAAO,cAAc,MAAM;AAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,SAAgB,aAA0C,QAAyC;CACjG,IAAI,OAAO,WAAW,YACpB,QAAQ,OAAO,QAAoB;EACjC,OAAO,gBAAgB,MAAM,OAAO,GAAG,CAAC;CAC1C;CAGF,IAAI,UAAU,MAAM,GAClB,OAAO,OAAO,MAAM,aAAa,gBAAgB,QAAQ,CAAC;CAG5D,OAAO,gBAAgB,MAAM;AAC/B"}