kubb 5.0.0-beta.9 → 5.0.0-beta.91
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/LICENSE +17 -10
- package/README.md +51 -45
- package/bin/kubb.js +11 -3
- package/dist/astro.cjs +4 -0
- package/dist/astro.d.ts +2 -0
- package/dist/astro.js +2 -0
- package/dist/config.cjs +3 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +2 -0
- package/dist/defineConfig-BCzzAVwJ.js +114 -0
- package/dist/defineConfig-BCzzAVwJ.js.map +1 -0
- package/dist/defineConfig-CG4ndZ9i.d.ts +62 -0
- package/dist/defineConfig-CzY_scM2.cjs +119 -0
- package/dist/defineConfig-CzY_scM2.cjs.map +1 -0
- package/dist/esbuild.cjs +4 -0
- package/dist/esbuild.d.ts +2 -0
- package/dist/esbuild.js +2 -0
- package/dist/farm.cjs +4 -0
- package/dist/farm.d.ts +2 -0
- package/dist/farm.js +2 -0
- package/dist/index.cjs +9 -78
- package/dist/index.d.ts +4 -44
- package/dist/index.js +3 -78
- package/dist/jsx/jsx-dev-runtime.cjs +9 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +1 -0
- package/dist/jsx/jsx-dev-runtime.js +2 -0
- package/dist/jsx/jsx-runtime.cjs +9 -0
- package/dist/jsx/jsx-runtime.d.ts +1 -0
- package/dist/jsx/jsx-runtime.js +2 -0
- package/dist/jsx.cjs +18 -0
- package/dist/jsx.d.ts +2 -0
- package/dist/jsx.js +3 -0
- package/dist/kit/testing.cjs +9 -0
- package/dist/kit/testing.d.ts +1 -0
- package/dist/kit/testing.js +2 -0
- package/dist/kit.cjs +9 -0
- package/dist/kit.d.ts +1 -0
- package/dist/kit.js +2 -0
- package/dist/nuxt.cjs +4 -0
- package/dist/nuxt.d.ts +2 -0
- package/dist/nuxt.js +2 -0
- package/dist/rolldown-runtime-Bx3C2hgW.cjs +38 -0
- package/dist/rolldown.cjs +4 -0
- package/dist/rolldown.d.ts +2 -0
- package/dist/rolldown.js +2 -0
- package/dist/rollup.cjs +4 -0
- package/dist/rollup.d.ts +2 -0
- package/dist/rollup.js +2 -0
- package/dist/rspack.cjs +4 -0
- package/dist/rspack.d.ts +2 -0
- package/dist/rspack.js +2 -0
- package/dist/vite.cjs +4 -0
- package/dist/vite.d.ts +2 -0
- package/dist/vite.js +2 -0
- package/dist/webpack.cjs +4 -0
- package/dist/webpack.d.ts +2 -0
- package/dist/webpack.js +2 -0
- package/package.json +82 -35
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/src/defineConfig.ts +0 -91
- package/src/index.ts +0 -2
- /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/LICENSE
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
This repository contains software under two licenses:
|
|
1
|
+
MIT License
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
MIT License — see licenses/LICENSE-MIT for the full license text.
|
|
3
|
+
Copyright (c) 2026 Stijn Van Hulle
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,15 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<h1>kubb</h1>
|
|
3
2
|
<a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
|
|
4
|
-
<img
|
|
3
|
+
<img src="https://kubb.dev/og.png" alt="Kubb banner">
|
|
5
4
|
</a>
|
|
6
5
|
|
|
7
6
|
[![npm version][npm-version-src]][npm-version-href]
|
|
8
7
|
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
|
9
|
-
[![
|
|
8
|
+
[![Stars][stars-src]][stars-href]
|
|
10
9
|
[![License][license-src]][license-href]
|
|
11
|
-
[![
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Point Kubb at an OpenAPI spec and it generates types, clients, hooks, validators, mocks, and more.
|
|
10
|
+
[![Coverage][coverage-src]][coverage-href]
|
|
11
|
+
[![Node][node-src]][node-href]
|
|
12
|
+
[![OC Backers][oc-backers-src]][oc-backers-href]
|
|
16
13
|
|
|
17
14
|
<h4>
|
|
18
15
|
<a href="https://kubb.dev" target="_blank">Documentation</a>
|
|
@@ -25,6 +22,12 @@ Point Kubb at an OpenAPI spec and it generates types, clients, hooks, validators
|
|
|
25
22
|
|
|
26
23
|
<br />
|
|
27
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
|
+
|
|
28
31
|
## Installation
|
|
29
32
|
|
|
30
33
|
```bash
|
|
@@ -53,26 +56,39 @@ See the [documentation](https://kubb.dev) for detailed usage and advanced featur
|
|
|
53
56
|
|
|
54
57
|
## Features
|
|
55
58
|
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
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).
|
|
63
67
|
|
|
64
68
|
## Supporting Kubb
|
|
65
69
|
|
|
66
|
-
Kubb is an open source project
|
|
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:
|
|
67
71
|
|
|
68
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)
|
|
69
75
|
|
|
70
76
|
<p align="center">
|
|
71
77
|
<a href="https://github.com/sponsors/stijnvanhulle">
|
|
72
|
-
<img src="https://
|
|
78
|
+
<img src="https://shieldcn.dev/sponsors/stijnvanhulle.svg?titleAlign=center&mode=dark" alt="stijnvanhulle sponsors" width="100%" />
|
|
73
79
|
</a>
|
|
74
80
|
</p>
|
|
75
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
|
+
|
|
76
92
|
## Contributors [![Contributors][contributors-src]][contributors-href]
|
|
77
93
|
|
|
78
94
|
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
|
|
@@ -160,39 +176,29 @@ Kubb is an open source project with its ongoing development made possible entire
|
|
|
160
176
|
|
|
161
177
|
## License
|
|
162
178
|
|
|
163
|
-
|
|
164
|
-
under AGPL-3.0-or-later.
|
|
165
|
-
|
|
166
|
-
- **Most packages** — [MIT](./licenses/LICENSE-MIT)
|
|
167
|
-
- **`@kubb/agent`** — [AGPL-3.0-or-later](./licenses/LICENSE-AGPL-3.0)
|
|
179
|
+
This repository is licensed under the [MIT License](./licenses/LICENSE-MIT), Copyright © 2025 [Stijn Van Hulle](https://stijnvanhulle.be).
|
|
168
180
|
|
|
169
181
|
See [LICENSE](./LICENSE) for details.
|
|
170
182
|
|
|
171
|
-
## Star
|
|
183
|
+
## Star history
|
|
172
184
|
|
|
173
|
-
<
|
|
174
|
-
<picture>
|
|
175
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=kubb-labs/kubb&type=Date&theme=dark" />
|
|
176
|
-
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=kubb-labs/kubb&type=Date" />
|
|
177
|
-
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=kubb-labs/kubb&type=Date" />
|
|
178
|
-
</picture>
|
|
179
|
-
</a>
|
|
185
|
+
<img alt="Star history chart" src="https://shieldcn.dev/chart/github/stars/kubb-labs/kubb.svg?theme=orange" width="100%" />
|
|
180
186
|
|
|
181
187
|
<!-- Badges -->
|
|
182
188
|
|
|
183
|
-
[npm-version-src]: https://
|
|
184
|
-
[npm-version-href]: https://npmx.dev/package
|
|
185
|
-
[npm-downloads-src]: https://
|
|
186
|
-
[npm-downloads-href]: https://
|
|
187
|
-
[
|
|
188
|
-
[
|
|
189
|
-
[
|
|
190
|
-
[
|
|
191
|
-
[
|
|
192
|
-
[
|
|
193
|
-
[
|
|
194
|
-
[coverage-href]: https://www.npmjs.com/package/@kubb/core
|
|
195
|
-
[contributors-src]: https://img.shields.io/github/contributors/kubb-labs/kubb?style=flat&colorA=18181B&colorB=f58517&label=%20
|
|
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
|
|
196
|
+
[license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
|
|
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
|
|
196
200
|
[contributors-href]: #contributors-
|
|
197
|
-
[
|
|
198
|
-
[
|
|
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
|
-
|
|
3
|
-
|
|
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
package/dist/astro.d.ts
ADDED
package/dist/astro.js
ADDED
package/dist/config.cjs
ADDED
package/dist/config.d.ts
ADDED
package/dist/config.js
ADDED
|
@@ -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<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 `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"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { CLIOptions, UserConfig } from "@kubb/core";
|
|
3
|
+
|
|
4
|
+
//#region ../../internals/utils/src/promise.d.ts
|
|
5
|
+
/** A value that may already be resolved or still pending.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* function load(id: string): PossiblePromise<string> {
|
|
10
|
+
* return cache.get(id) ?? fetchRemote(id)
|
|
11
|
+
* }
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
type PossiblePromise<T> = Promise<T> | T;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/defineConfig.d.ts
|
|
17
|
+
type AnyConfigResult = UserConfig<any> | Array<UserConfig<any>>;
|
|
18
|
+
type ConfigInput = AnyConfigResult | Promise<AnyConfigResult> | ((cli: CLIOptions) => PossiblePromise<AnyConfigResult>);
|
|
19
|
+
type NormalizeConfig<TConfig> = TConfig extends Array<UserConfig<infer TInput>> ? Array<UserConfig<TInput>> : TConfig extends UserConfig<infer TInput> ? UserConfig<TInput> : never;
|
|
20
|
+
type DefinedConfig<TConfig extends ConfigInput> = TConfig extends ((cli: CLIOptions) => PossiblePromise<infer TResult>) ? (cli: CLIOptions) => Promise<NormalizeConfig<TResult>> : TConfig extends Promise<infer TResult> ? Promise<NormalizeConfig<TResult>> : NormalizeConfig<TConfig>;
|
|
21
|
+
/**
|
|
22
|
+
* Defines a Kubb build configuration and fills in defaults for any omitted fields.
|
|
23
|
+
*
|
|
24
|
+
* Defaults applied when omitted:
|
|
25
|
+
* - `adapter` → `adapterOas()` (OpenAPI 2.0/3.0/3.1).
|
|
26
|
+
* - `parsers` → `[parserTs(), parserTsx(), parserMd()]`.
|
|
27
|
+
* - `reporters` → `[cliReporter, jsonReporter, fileReporter]`.
|
|
28
|
+
* - `plugins` → `pluginBarrel()` is appended when not already present.
|
|
29
|
+
* - `output.barrel` → `{ type: 'named' }` when not set.
|
|
30
|
+
* - `output.format` and `output.lint` → `false`.
|
|
31
|
+
*
|
|
32
|
+
* Accepts a config object, an array of configs, a Promise resolving to one,
|
|
33
|
+
* or a function that receives the parsed CLI options and returns any of the
|
|
34
|
+
* above. The return type is preserved so async/array variants stay typed.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { defineConfig } from 'kubb'
|
|
39
|
+
* import { pluginTs } from '@kubb/plugin-ts'
|
|
40
|
+
*
|
|
41
|
+
* export default defineConfig({
|
|
42
|
+
* input: './petStore.yaml',
|
|
43
|
+
* output: { path: './src/gen' },
|
|
44
|
+
* plugins: [pluginTs()],
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example Function form with CLI options
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { defineConfig } from 'kubb'
|
|
51
|
+
*
|
|
52
|
+
* export default defineConfig(({ input }) => ({
|
|
53
|
+
* input: input ?? './petStore.yaml',
|
|
54
|
+
* output: { path: './src/gen' },
|
|
55
|
+
* plugins: [],
|
|
56
|
+
* }))
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare function defineConfig<TConfig extends ConfigInput>(config: TConfig): DefinedConfig<TConfig>;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { defineConfig as t };
|
|
62
|
+
//# sourceMappingURL=defineConfig-CG4ndZ9i.d.ts.map
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
+
let _kubb_core = require("@kubb/core");
|
|
3
|
+
let _kubb_adapter_oas = require("@kubb/adapter-oas");
|
|
4
|
+
let _kubb_plugin_barrel = require("@kubb/plugin-barrel");
|
|
5
|
+
let _kubb_parser_ts = require("@kubb/parser-ts");
|
|
6
|
+
let _kubb_parser_md = require("@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 } = (0, _kubb_core.applyConfigDefaults)(config, {
|
|
35
|
+
defaultAdapter: (0, _kubb_adapter_oas.adapterOas)(),
|
|
36
|
+
barrelPlugin: (0, _kubb_plugin_barrel.pluginBarrel)(),
|
|
37
|
+
barrelPluginName: _kubb_plugin_barrel.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
|
+
(0, _kubb_parser_ts.parserTs)(),
|
|
50
|
+
(0, _kubb_parser_ts.parserTsx)(),
|
|
51
|
+
(0, _kubb_parser_md.parserMd)()
|
|
52
|
+
],
|
|
53
|
+
reporters: config.reporters?.length ? config.reporters : [
|
|
54
|
+
_kubb_core.cliReporter,
|
|
55
|
+
_kubb_core.jsonReporter,
|
|
56
|
+
_kubb_core.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
|
+
Object.defineProperty(exports, "defineConfig", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function() {
|
|
115
|
+
return defineConfig;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
//# sourceMappingURL=defineConfig-CzY_scM2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defineConfig-CzY_scM2.cjs","names":["pluginBarrelName","cliReporter","jsonReporter","fileReporter"],"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<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 `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,aAAA,GAAA,WAAA,oBAAA,CAAgC,QAAQ;EAC/D,iBAAA,GAAA,kBAAA,WAAA,CAA2B;EAC3B,eAAA,GAAA,oBAAA,aAAA,CAA2B;EAC3B,kBAAkBA,oBAAAA;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;iCAAU;kCAAa;iCAAY;EAAC;EACvF,WAAW,OAAO,WAAW,SAAS,OAAO,YAAY;GAACC,WAAAA;GAAaC,WAAAA;GAAcC,WAAAA;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"}
|
package/dist/esbuild.cjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const require_rolldown_runtime = require("./rolldown-runtime-Bx3C2hgW.cjs");
|
|
2
|
+
let unplugin_kubb_esbuild = require("unplugin-kubb/esbuild");
|
|
3
|
+
unplugin_kubb_esbuild = require_rolldown_runtime.__toESM(unplugin_kubb_esbuild, 1);
|
|
4
|
+
module.exports = unplugin_kubb_esbuild.default;
|
package/dist/esbuild.js
ADDED
package/dist/farm.cjs
ADDED
package/dist/farm.d.ts
ADDED
package/dist/farm.js
ADDED