kubb 5.0.0-alpha.74 → 5.0.0-beta.2
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/README.md +72 -18
- package/dist/index.cjs +6 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/defineConfig.ts +7 -5
package/README.md
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
[![License][license-src]][license-href]
|
|
10
10
|
[![Sponsors][sponsors-src]][sponsors-href]
|
|
11
11
|
|
|
12
|
+
### The meta framework for code generation
|
|
13
|
+
|
|
14
|
+
**Stop writing glue code. Define your API once and Kubb generates types, clients, hooks, validators, mocks and more.**
|
|
15
|
+
|
|
12
16
|
<h4>
|
|
13
|
-
<a href="https://
|
|
14
|
-
<span> · </span>
|
|
15
|
-
<a href="https://kubb.dev/" target="_blank">Documentation</a>
|
|
17
|
+
<a href="https://kubb.dev" target="_blank">Documentation</a>
|
|
16
18
|
<span> · </span>
|
|
17
19
|
<a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
|
|
18
20
|
<span> · </span>
|
|
@@ -22,6 +24,37 @@
|
|
|
22
24
|
|
|
23
25
|
<br />
|
|
24
26
|
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install kubb
|
|
31
|
+
# or
|
|
32
|
+
pnpm add kubb
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
Get started with Kubb in seconds:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx kubb init
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The interactive setup will:
|
|
44
|
+
|
|
45
|
+
- Create a `package.json` (if needed)
|
|
46
|
+
- Guide you through plugin selection
|
|
47
|
+
- Install packages automatically
|
|
48
|
+
- Generate `kubb.config.ts`
|
|
49
|
+
|
|
50
|
+
Then generate your code:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npx kubb generate
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
See the [documentation](https://kubb.dev) for detailed usage and advanced features.
|
|
57
|
+
|
|
25
58
|
## Features
|
|
26
59
|
|
|
27
60
|
- Works with Node.js 22+ and TypeScript 6.
|
|
@@ -34,7 +67,7 @@
|
|
|
34
67
|
|
|
35
68
|
## Supporting Kubb
|
|
36
69
|
|
|
37
|
-
Kubb
|
|
70
|
+
Kubb is an 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:
|
|
38
71
|
|
|
39
72
|
- [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
|
|
40
73
|
|
|
@@ -53,55 +86,73 @@ Kubb uses an MIT-licensed open source project with its ongoing development made
|
|
|
53
86
|
<tbody>
|
|
54
87
|
<tr>
|
|
55
88
|
<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
89
|
<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
90
|
<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
91
|
<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
92
|
<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
93
|
<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>
|
|
94
|
+
<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
95
|
</tr>
|
|
63
96
|
<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
97
|
<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
98
|
<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
99
|
<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
100
|
<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
101
|
<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
102
|
<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>
|
|
103
|
+
<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
104
|
</tr>
|
|
72
105
|
<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
106
|
<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
107
|
<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
108
|
<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
109
|
<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
110
|
<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
111
|
<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>
|
|
112
|
+
<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
113
|
</tr>
|
|
81
114
|
<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
115
|
<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
116
|
<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
117
|
<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
118
|
<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
119
|
<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
120
|
<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>
|
|
121
|
+
<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
122
|
</tr>
|
|
90
123
|
<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
124
|
<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
125
|
<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
126
|
<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
127
|
<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
128
|
<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
129
|
<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>
|
|
130
|
+
<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
131
|
</tr>
|
|
99
132
|
<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
133
|
<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
134
|
<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
135
|
<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
136
|
<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>
|
|
137
|
+
<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>
|
|
138
|
+
<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>
|
|
139
|
+
<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>
|
|
140
|
+
</tr>
|
|
141
|
+
<tr>
|
|
142
|
+
<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>
|
|
143
|
+
<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>
|
|
144
|
+
<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>
|
|
145
|
+
<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>
|
|
146
|
+
<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>
|
|
147
|
+
<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>
|
|
148
|
+
<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>
|
|
149
|
+
</tr>
|
|
150
|
+
<tr>
|
|
151
|
+
<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>
|
|
152
|
+
<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>
|
|
153
|
+
<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>
|
|
154
|
+
<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>
|
|
155
|
+
<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
156
|
</tr>
|
|
106
157
|
</tbody>
|
|
107
158
|
</table>
|
|
@@ -110,13 +161,16 @@ Kubb uses an MIT-licensed open source project with its ongoing development made
|
|
|
110
161
|
<!-- prettier-ignore-end -->
|
|
111
162
|
|
|
112
163
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
113
|
-
<!-- prettier-ignore-start -->
|
|
114
|
-
<!-- markdownlint-disable -->
|
|
115
164
|
|
|
116
|
-
|
|
117
|
-
<!-- prettier-ignore-end -->
|
|
165
|
+
## License
|
|
118
166
|
|
|
119
|
-
|
|
167
|
+
Most of this repository is licensed under the [MIT License](./licenses/LICENSE-MIT), Copyright © 2025 [Stijn Van Hulle](https://stijnvanhulle.be). Some components are licensed
|
|
168
|
+
under AGPL-3.0-or-later.
|
|
169
|
+
|
|
170
|
+
- **Most packages** — [MIT](./licenses/LICENSE-MIT)
|
|
171
|
+
- **`@kubb/agent`** — [AGPL-3.0-or-later](./licenses/LICENSE-AGPL-3.0)
|
|
172
|
+
|
|
173
|
+
See [LICENSE](./LICENSE) for details.
|
|
120
174
|
|
|
121
175
|
## Star History
|
|
122
176
|
|
|
@@ -131,11 +185,11 @@ Kubb uses an MIT-licensed open source project with its ongoing development made
|
|
|
131
185
|
<!-- Badges -->
|
|
132
186
|
|
|
133
187
|
[npm-version-src]: https://img.shields.io/npm/v/@kubb/core?flat&colorA=18181B&colorB=f58517
|
|
134
|
-
[npm-version-href]: https://
|
|
188
|
+
[npm-version-href]: https://npmx.dev/package/@kubb/core
|
|
135
189
|
[npm-downloads-src]: https://img.shields.io/npm/dm/@kubb/core?flat&colorA=18181B&colorB=f58517
|
|
136
190
|
[npm-downloads-href]: https://npmjs.com/package/@kubb/core
|
|
137
|
-
[license-src]: https://img.shields.io/
|
|
138
|
-
[license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
|
|
191
|
+
[license-src]: https://img.shields.io/npm/l/%40kubb%2Fcore?flat&colorA=18181B&colorB=f58517
|
|
192
|
+
[license-href]: https://github.com/kubb-labs/kubb/blob/main/licenses/LICENSE-MIT
|
|
139
193
|
[build-src]: https://img.shields.io/github/actions/workflow/status/kubb-labs/kubb/ci.yaml?style=flat&colorA=18181B&colorB=f58517
|
|
140
194
|
[build-href]: https://www.npmjs.com/package/@kubb/core
|
|
141
195
|
[minified-src]: https://img.shields.io/bundlephobia/min/@kubb/core?style=flat&colorA=18181B&colorB=f58517
|
package/dist/index.cjs
CHANGED
|
@@ -18,13 +18,13 @@ function isPromise(result) {
|
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/defineConfig.ts
|
|
20
20
|
/**
|
|
21
|
-
* Applies default adapter, parsers, middleware, `output.
|
|
21
|
+
* Applies default adapter, parsers, middleware, `output.barrel`, `output.format`, and `output.lint` to a single user config when not set.
|
|
22
22
|
*
|
|
23
23
|
* - `adapter` defaults to `adapterOas()`
|
|
24
24
|
* - `parsers` defaults to `[parserTs, parserTsx]`
|
|
25
25
|
* - `middleware` defaults to `[middlewareBarrel()]`
|
|
26
|
-
* - `output.
|
|
27
|
-
* When the user provides a custom middleware list without `middlewareBarrel`, `
|
|
26
|
+
* - `output.barrel` defaults to `{ type: 'named' }` **only when `middlewareBarrel` is part of `middleware`**.
|
|
27
|
+
* When the user provides a custom middleware list without `middlewareBarrel`, `barrel` is left untouched.
|
|
28
28
|
* - `output.format` defaults to `'auto'`
|
|
29
29
|
* - `output.lint` defaults to `'auto'`
|
|
30
30
|
*/
|
|
@@ -32,7 +32,7 @@ function applyDefaults(config) {
|
|
|
32
32
|
const middleware = config.middleware?.length ? config.middleware : [(0, _kubb_middleware_barrel.middlewareBarrel)()];
|
|
33
33
|
const hasBarrelMiddleware = middleware.some((m) => m.name === _kubb_middleware_barrel.middlewareBarrelName);
|
|
34
34
|
const output = { ...config.output };
|
|
35
|
-
if (hasBarrelMiddleware && output.
|
|
35
|
+
if (hasBarrelMiddleware && output.barrel === void 0) output.barrel = { type: "named" };
|
|
36
36
|
if (output.format === void 0) output.format = false;
|
|
37
37
|
if (output.lint === void 0) output.lint = false;
|
|
38
38
|
return {
|
|
@@ -59,10 +59,12 @@ function normalizeConfig(config) {
|
|
|
59
59
|
* receiving the CLI options as argument
|
|
60
60
|
*
|
|
61
61
|
* @example
|
|
62
|
+
* ```ts
|
|
62
63
|
* export default defineConfig(({ logLevel }) => ({
|
|
63
64
|
* root: 'src',
|
|
64
65
|
* plugins: [myPlugin()],
|
|
65
66
|
* }))
|
|
67
|
+
* ```
|
|
66
68
|
*/
|
|
67
69
|
function defineConfig(config) {
|
|
68
70
|
if (typeof config === "function") return (async (cli) => {
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["middlewareBarrelName","parserTs","parserTsx"],"sources":["../../../internals/utils/src/promise.ts","../src/defineConfig.ts"],"sourcesContent":["/** 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\n/** Returns `true` when `result` is a fulfilled `Promise.allSettled` result.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseFulfilledResult).map((r) => r.value)\n * ```\n */\nexport function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {\n return result.status === 'fulfilled'\n}\n\n/** Returns `true` when `result` is a rejected `Promise.allSettled` result with a typed `reason`.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseRejectedResult<Error>).map((r) => r.reason.message)\n * ```\n */\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n","import { isPromise, type PossiblePromise } from '@internals/utils'\nimport { adapterOas } from '@kubb/adapter-oas'\nimport type { CLIOptions, UserConfig } from '@kubb/core'\nimport { middlewareBarrel, middlewareBarrelName } from '@kubb/middleware-barrel'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\n\ntype AnyConfigResult = UserConfig<any> | Array<UserConfig<any>>\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 adapter, parsers, middleware, `output.
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["middlewareBarrelName","parserTs","parserTsx"],"sources":["../../../internals/utils/src/promise.ts","../src/defineConfig.ts"],"sourcesContent":["/** 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\n/** Returns `true` when `result` is a fulfilled `Promise.allSettled` result.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseFulfilledResult).map((r) => r.value)\n * ```\n */\nexport function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {\n return result.status === 'fulfilled'\n}\n\n/** Returns `true` when `result` is a rejected `Promise.allSettled` result with a typed `reason`.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseRejectedResult<Error>).map((r) => r.reason.message)\n * ```\n */\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n","import { isPromise, type PossiblePromise } from '@internals/utils'\nimport { adapterOas } from '@kubb/adapter-oas'\nimport type { CLIOptions, UserConfig } from '@kubb/core'\nimport { middlewareBarrel, middlewareBarrelName } from '@kubb/middleware-barrel'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\n\ntype AnyConfigResult = UserConfig<any> | Array<UserConfig<any>>\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 adapter, parsers, middleware, `output.barrel`, `output.format`, and `output.lint` to a single user config when not set.\n *\n * - `adapter` defaults to `adapterOas()`\n * - `parsers` defaults to `[parserTs, parserTsx]`\n * - `middleware` defaults to `[middlewareBarrel()]`\n * - `output.barrel` defaults to `{ type: 'named' }` **only when `middlewareBarrel` is part of `middleware`**.\n * When the user provides a custom middleware list without `middlewareBarrel`, `barrel` is left untouched.\n * - `output.format` defaults to `'auto'`\n * - `output.lint` defaults to `'auto'`\n */\nfunction applyDefaults<TInput>(config: UserConfig<TInput>): UserConfig<TInput> {\n const middleware = config.middleware?.length ? config.middleware : [middlewareBarrel()]\n const hasBarrelMiddleware = middleware.some((m) => m.name === middlewareBarrelName)\n\n const output = { ...config.output }\n if (hasBarrelMiddleware && output.barrel === undefined) {\n output.barrel = { type: 'named' }\n }\n if (output.format === undefined) {\n output.format = false\n }\n if (output.lint === undefined) {\n output.lint = false\n }\n\n return {\n ...config,\n adapter: config.adapter ?? adapterOas(),\n parsers: config.parsers?.length ? config.parsers : [parserTs, parserTsx],\n middleware,\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 * Helper for defining a Kubb configuration with built-in defaults.\n *\n * When no `adapter` is provided, `adapterOas()` is used automatically.\n * When no `parsers` are provided, `[parserTs, parserTsx]` is used automatically.\n *\n * Accepts either:\n * - A config object or array of configs\n * - A function returning the config(s), optionally async,\n * receiving the CLI options as argument\n *\n * @example\n * ```ts\n * export default defineConfig(({ logLevel }) => ({\n * root: 'src',\n * plugins: [myPlugin()],\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":";;;;;;;;;;;;;;AAmBA,SAAgB,UAAa,QAAkD;AAC7E,QAAO,WAAW,QAAQ,WAAW,KAAA,KAAa,OAAQ,OAAmC,YAAY;;;;;;;;;;;;;;;ACO3G,SAAS,cAAsB,QAAgD;CAC7E,MAAM,aAAa,OAAO,YAAY,SAAS,OAAO,aAAa,EAAA,GAAA,wBAAA,mBAAmB,CAAC;CACvF,MAAM,sBAAsB,WAAW,MAAM,MAAM,EAAE,SAASA,wBAAAA,qBAAqB;CAEnF,MAAM,SAAS,EAAE,GAAG,OAAO,QAAQ;AACnC,KAAI,uBAAuB,OAAO,WAAW,KAAA,EAC3C,QAAO,SAAS,EAAE,MAAM,SAAS;AAEnC,KAAI,OAAO,WAAW,KAAA,EACpB,QAAO,SAAS;AAElB,KAAI,OAAO,SAAS,KAAA,EAClB,QAAO,OAAO;AAGhB,QAAO;EACL,GAAG;EACH,SAAS,OAAO,YAAA,GAAA,kBAAA,aAAuB;EACvC,SAAS,OAAO,SAAS,SAAS,OAAO,UAAU,CAACC,gBAAAA,UAAUC,gBAAAA,UAAU;EACxE;EACA;EACD;;AAGH,SAAS,gBAAwB,QAAwG;AACvI,KAAI,MAAM,QAAQ,OAAO,CACvB,QAAO,OAAO,IAAI,cAAc;AAGlC,QAAO,cAAc,OAAO;;;;;;;;;;;;;;;;;;;;;AAsB9B,SAAgB,aAA0C,QAAyC;AACjG,KAAI,OAAO,WAAW,WACpB,SAAQ,OAAO,QAAoB;AACjC,SAAO,gBAAgB,MAAM,OAAO,IAAI,CAAC;;AAI7C,KAAI,UAAU,OAAO,CACnB,QAAO,OAAO,MAAM,aAAa,gBAAgB,SAAS,CAAC;AAG7D,QAAO,gBAAgB,OAAO"}
|
package/dist/index.d.ts
CHANGED
|
@@ -31,10 +31,12 @@ type DefinedConfig<TConfig extends ConfigInput> = TConfig extends ((cli: CLIOpti
|
|
|
31
31
|
* receiving the CLI options as argument
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
|
+
* ```ts
|
|
34
35
|
* export default defineConfig(({ logLevel }) => ({
|
|
35
36
|
* root: 'src',
|
|
36
37
|
* plugins: [myPlugin()],
|
|
37
38
|
* }))
|
|
39
|
+
* ```
|
|
38
40
|
*/
|
|
39
41
|
declare function defineConfig<TConfig extends ConfigInput>(config: TConfig): DefinedConfig<TConfig>;
|
|
40
42
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -17,13 +17,13 @@ function isPromise(result) {
|
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/defineConfig.ts
|
|
19
19
|
/**
|
|
20
|
-
* Applies default adapter, parsers, middleware, `output.
|
|
20
|
+
* Applies default adapter, parsers, middleware, `output.barrel`, `output.format`, and `output.lint` to a single user config when not set.
|
|
21
21
|
*
|
|
22
22
|
* - `adapter` defaults to `adapterOas()`
|
|
23
23
|
* - `parsers` defaults to `[parserTs, parserTsx]`
|
|
24
24
|
* - `middleware` defaults to `[middlewareBarrel()]`
|
|
25
|
-
* - `output.
|
|
26
|
-
* When the user provides a custom middleware list without `middlewareBarrel`, `
|
|
25
|
+
* - `output.barrel` defaults to `{ type: 'named' }` **only when `middlewareBarrel` is part of `middleware`**.
|
|
26
|
+
* When the user provides a custom middleware list without `middlewareBarrel`, `barrel` is left untouched.
|
|
27
27
|
* - `output.format` defaults to `'auto'`
|
|
28
28
|
* - `output.lint` defaults to `'auto'`
|
|
29
29
|
*/
|
|
@@ -31,7 +31,7 @@ function applyDefaults(config) {
|
|
|
31
31
|
const middleware = config.middleware?.length ? config.middleware : [middlewareBarrel()];
|
|
32
32
|
const hasBarrelMiddleware = middleware.some((m) => m.name === middlewareBarrelName);
|
|
33
33
|
const output = { ...config.output };
|
|
34
|
-
if (hasBarrelMiddleware && output.
|
|
34
|
+
if (hasBarrelMiddleware && output.barrel === void 0) output.barrel = { type: "named" };
|
|
35
35
|
if (output.format === void 0) output.format = false;
|
|
36
36
|
if (output.lint === void 0) output.lint = false;
|
|
37
37
|
return {
|
|
@@ -58,10 +58,12 @@ function normalizeConfig(config) {
|
|
|
58
58
|
* receiving the CLI options as argument
|
|
59
59
|
*
|
|
60
60
|
* @example
|
|
61
|
+
* ```ts
|
|
61
62
|
* export default defineConfig(({ logLevel }) => ({
|
|
62
63
|
* root: 'src',
|
|
63
64
|
* plugins: [myPlugin()],
|
|
64
65
|
* }))
|
|
66
|
+
* ```
|
|
65
67
|
*/
|
|
66
68
|
function defineConfig(config) {
|
|
67
69
|
if (typeof config === "function") return (async (cli) => {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../internals/utils/src/promise.ts","../src/defineConfig.ts"],"sourcesContent":["/** 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\n/** Returns `true` when `result` is a fulfilled `Promise.allSettled` result.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseFulfilledResult).map((r) => r.value)\n * ```\n */\nexport function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {\n return result.status === 'fulfilled'\n}\n\n/** Returns `true` when `result` is a rejected `Promise.allSettled` result with a typed `reason`.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseRejectedResult<Error>).map((r) => r.reason.message)\n * ```\n */\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n","import { isPromise, type PossiblePromise } from '@internals/utils'\nimport { adapterOas } from '@kubb/adapter-oas'\nimport type { CLIOptions, UserConfig } from '@kubb/core'\nimport { middlewareBarrel, middlewareBarrelName } from '@kubb/middleware-barrel'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\n\ntype AnyConfigResult = UserConfig<any> | Array<UserConfig<any>>\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 adapter, parsers, middleware, `output.
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../internals/utils/src/promise.ts","../src/defineConfig.ts"],"sourcesContent":["/** 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\n/** Returns `true` when `result` is a fulfilled `Promise.allSettled` result.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseFulfilledResult).map((r) => r.value)\n * ```\n */\nexport function isPromiseFulfilledResult<T = unknown>(result: PromiseSettledResult<unknown>): result is PromiseFulfilledResult<T> {\n return result.status === 'fulfilled'\n}\n\n/** Returns `true` when `result` is a rejected `Promise.allSettled` result with a typed `reason`.\n *\n * @example\n * ```ts\n * const results = await Promise.allSettled([p1, p2])\n * results.filter(isPromiseRejectedResult<Error>).map((r) => r.reason.message)\n * ```\n */\nexport function isPromiseRejectedResult<T>(result: PromiseSettledResult<unknown>): result is Omit<PromiseRejectedResult, 'reason'> & { reason: T } {\n return result.status === 'rejected'\n}\n","import { isPromise, type PossiblePromise } from '@internals/utils'\nimport { adapterOas } from '@kubb/adapter-oas'\nimport type { CLIOptions, UserConfig } from '@kubb/core'\nimport { middlewareBarrel, middlewareBarrelName } from '@kubb/middleware-barrel'\nimport { parserTs, parserTsx } from '@kubb/parser-ts'\n\ntype AnyConfigResult = UserConfig<any> | Array<UserConfig<any>>\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 adapter, parsers, middleware, `output.barrel`, `output.format`, and `output.lint` to a single user config when not set.\n *\n * - `adapter` defaults to `adapterOas()`\n * - `parsers` defaults to `[parserTs, parserTsx]`\n * - `middleware` defaults to `[middlewareBarrel()]`\n * - `output.barrel` defaults to `{ type: 'named' }` **only when `middlewareBarrel` is part of `middleware`**.\n * When the user provides a custom middleware list without `middlewareBarrel`, `barrel` is left untouched.\n * - `output.format` defaults to `'auto'`\n * - `output.lint` defaults to `'auto'`\n */\nfunction applyDefaults<TInput>(config: UserConfig<TInput>): UserConfig<TInput> {\n const middleware = config.middleware?.length ? config.middleware : [middlewareBarrel()]\n const hasBarrelMiddleware = middleware.some((m) => m.name === middlewareBarrelName)\n\n const output = { ...config.output }\n if (hasBarrelMiddleware && output.barrel === undefined) {\n output.barrel = { type: 'named' }\n }\n if (output.format === undefined) {\n output.format = false\n }\n if (output.lint === undefined) {\n output.lint = false\n }\n\n return {\n ...config,\n adapter: config.adapter ?? adapterOas(),\n parsers: config.parsers?.length ? config.parsers : [parserTs, parserTsx],\n middleware,\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 * Helper for defining a Kubb configuration with built-in defaults.\n *\n * When no `adapter` is provided, `adapterOas()` is used automatically.\n * When no `parsers` are provided, `[parserTs, parserTsx]` is used automatically.\n *\n * Accepts either:\n * - A config object or array of configs\n * - A function returning the config(s), optionally async,\n * receiving the CLI options as argument\n *\n * @example\n * ```ts\n * export default defineConfig(({ logLevel }) => ({\n * root: 'src',\n * plugins: [myPlugin()],\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":";;;;;;;;;;;;;AAmBA,SAAgB,UAAa,QAAkD;AAC7E,QAAO,WAAW,QAAQ,WAAW,KAAA,KAAa,OAAQ,OAAmC,YAAY;;;;;;;;;;;;;;;ACO3G,SAAS,cAAsB,QAAgD;CAC7E,MAAM,aAAa,OAAO,YAAY,SAAS,OAAO,aAAa,CAAC,kBAAkB,CAAC;CACvF,MAAM,sBAAsB,WAAW,MAAM,MAAM,EAAE,SAAS,qBAAqB;CAEnF,MAAM,SAAS,EAAE,GAAG,OAAO,QAAQ;AACnC,KAAI,uBAAuB,OAAO,WAAW,KAAA,EAC3C,QAAO,SAAS,EAAE,MAAM,SAAS;AAEnC,KAAI,OAAO,WAAW,KAAA,EACpB,QAAO,SAAS;AAElB,KAAI,OAAO,SAAS,KAAA,EAClB,QAAO,OAAO;AAGhB,QAAO;EACL,GAAG;EACH,SAAS,OAAO,WAAW,YAAY;EACvC,SAAS,OAAO,SAAS,SAAS,OAAO,UAAU,CAAC,UAAU,UAAU;EACxE;EACA;EACD;;AAGH,SAAS,gBAAwB,QAAwG;AACvI,KAAI,MAAM,QAAQ,OAAO,CACvB,QAAO,OAAO,IAAI,cAAc;AAGlC,QAAO,cAAc,OAAO;;;;;;;;;;;;;;;;;;;;;AAsB9B,SAAgB,aAA0C,QAAyC;AACjG,KAAI,OAAO,WAAW,WACpB,SAAQ,OAAO,QAAoB;AACjC,SAAO,gBAAgB,MAAM,OAAO,IAAI,CAAC;;AAI7C,KAAI,UAAU,OAAO,CACnB,QAAO,OAAO,MAAM,aAAa,gBAAgB,SAAS,CAAC;AAG7D,QAAO,gBAAgB,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kubb",
|
|
3
|
-
"version": "5.0.0-
|
|
3
|
+
"version": "5.0.0-beta.2",
|
|
4
4
|
"description": "Transform OpenAPI specifications into TypeScript, React-Query, Zod, Faker.js, MSW and more with a plugin-based code generation tool.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-client",
|
|
@@ -57,13 +57,13 @@
|
|
|
57
57
|
"registry": "https://registry.npmjs.org/"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@kubb/adapter-oas": "5.0.0-
|
|
61
|
-
"@kubb/agent": "5.0.0-
|
|
62
|
-
"@kubb/cli": "5.0.0-
|
|
63
|
-
"@kubb/core": "5.0.0-
|
|
64
|
-
"@kubb/mcp": "5.0.0-
|
|
65
|
-
"@kubb/middleware-barrel": "5.0.0-
|
|
66
|
-
"@kubb/parser-ts": "5.0.0-
|
|
60
|
+
"@kubb/adapter-oas": "5.0.0-beta.2",
|
|
61
|
+
"@kubb/agent": "5.0.0-beta.2",
|
|
62
|
+
"@kubb/cli": "5.0.0-beta.2",
|
|
63
|
+
"@kubb/core": "5.0.0-beta.2",
|
|
64
|
+
"@kubb/mcp": "5.0.0-beta.2",
|
|
65
|
+
"@kubb/middleware-barrel": "5.0.0-beta.2",
|
|
66
|
+
"@kubb/parser-ts": "5.0.0-beta.2"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"typescript": "^6.0.3",
|
package/src/defineConfig.ts
CHANGED
|
@@ -15,13 +15,13 @@ type DefinedConfig<TConfig extends ConfigInput> = TConfig extends (cli: CLIOptio
|
|
|
15
15
|
: NormalizeConfig<TConfig>
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* Applies default adapter, parsers, middleware, `output.
|
|
18
|
+
* Applies default adapter, parsers, middleware, `output.barrel`, `output.format`, and `output.lint` to a single user config when not set.
|
|
19
19
|
*
|
|
20
20
|
* - `adapter` defaults to `adapterOas()`
|
|
21
21
|
* - `parsers` defaults to `[parserTs, parserTsx]`
|
|
22
22
|
* - `middleware` defaults to `[middlewareBarrel()]`
|
|
23
|
-
* - `output.
|
|
24
|
-
* When the user provides a custom middleware list without `middlewareBarrel`, `
|
|
23
|
+
* - `output.barrel` defaults to `{ type: 'named' }` **only when `middlewareBarrel` is part of `middleware`**.
|
|
24
|
+
* When the user provides a custom middleware list without `middlewareBarrel`, `barrel` is left untouched.
|
|
25
25
|
* - `output.format` defaults to `'auto'`
|
|
26
26
|
* - `output.lint` defaults to `'auto'`
|
|
27
27
|
*/
|
|
@@ -30,8 +30,8 @@ function applyDefaults<TInput>(config: UserConfig<TInput>): UserConfig<TInput> {
|
|
|
30
30
|
const hasBarrelMiddleware = middleware.some((m) => m.name === middlewareBarrelName)
|
|
31
31
|
|
|
32
32
|
const output = { ...config.output }
|
|
33
|
-
if (hasBarrelMiddleware && output.
|
|
34
|
-
output.
|
|
33
|
+
if (hasBarrelMiddleware && output.barrel === undefined) {
|
|
34
|
+
output.barrel = { type: 'named' }
|
|
35
35
|
}
|
|
36
36
|
if (output.format === undefined) {
|
|
37
37
|
output.format = false
|
|
@@ -69,10 +69,12 @@ function normalizeConfig<TInput>(config: UserConfig<TInput> | Array<UserConfig<T
|
|
|
69
69
|
* receiving the CLI options as argument
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
|
+
* ```ts
|
|
72
73
|
* export default defineConfig(({ logLevel }) => ({
|
|
73
74
|
* root: 'src',
|
|
74
75
|
* plugins: [myPlugin()],
|
|
75
76
|
* }))
|
|
77
|
+
* ```
|
|
76
78
|
*/
|
|
77
79
|
export function defineConfig<TConfig extends ConfigInput>(config: TConfig): DefinedConfig<TConfig> {
|
|
78
80
|
if (typeof config === 'function') {
|