@kubb/plugin-client 5.0.0-beta.64 → 5.7.0-canary.20260930T095256

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +8 -61
  2. package/dist/index.cjs +753 -1749
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.ts +168 -347
  5. package/dist/index.js +729 -1734
  6. package/dist/index.js.map +1 -1
  7. package/package.json +12 -64
  8. package/src/generators/clientGenerator.tsx +9 -0
  9. package/src/index.ts +2 -0
  10. package/src/plugin.ts +71 -0
  11. package/src/types.ts +54 -0
  12. package/dist/chunk-Bx3C2hgW.cjs +0 -38
  13. package/dist/clients/axios.cjs +0 -68
  14. package/dist/clients/axios.cjs.map +0 -1
  15. package/dist/clients/axios.d.ts +0 -49
  16. package/dist/clients/axios.js +0 -58
  17. package/dist/clients/axios.js.map +0 -1
  18. package/dist/clients/fetch.cjs +0 -128
  19. package/dist/clients/fetch.cjs.map +0 -1
  20. package/dist/clients/fetch.d.ts +0 -50
  21. package/dist/clients/fetch.js +0 -120
  22. package/dist/clients/fetch.js.map +0 -1
  23. package/dist/templates/clients/axios.source.cjs +0 -7
  24. package/dist/templates/clients/axios.source.cjs.map +0 -1
  25. package/dist/templates/clients/axios.source.d.ts +0 -7
  26. package/dist/templates/clients/axios.source.js +0 -6
  27. package/dist/templates/clients/axios.source.js.map +0 -1
  28. package/dist/templates/clients/fetch.source.cjs +0 -7
  29. package/dist/templates/clients/fetch.source.cjs.map +0 -1
  30. package/dist/templates/clients/fetch.source.d.ts +0 -7
  31. package/dist/templates/clients/fetch.source.js +0 -6
  32. package/dist/templates/clients/fetch.source.js.map +0 -1
  33. package/dist/templates/config.source.cjs +0 -7
  34. package/dist/templates/config.source.cjs.map +0 -1
  35. package/dist/templates/config.source.d.ts +0 -7
  36. package/dist/templates/config.source.js +0 -6
  37. package/dist/templates/config.source.js.map +0 -1
  38. /package/dist/{chunk-C0LytTxp.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/README.md CHANGED
@@ -1,70 +1,17 @@
1
- <div align="center">
2
- <a href="https://kubb.dev" target="_blank" rel="noopener noreferrer">
3
- <img src="https://kubb.dev/og.png" alt="Kubb banner">
4
- </a>
5
-
6
- [![npm version][npm-version-src]][npm-version-href]
7
- [![npm downloads][npm-downloads-src]][npm-downloads-href]
8
- [![Stars][stars-src]][stars-href]
9
- [![License][license-src]][license-href]
10
- [![Node][node-src]][node-href]
11
-
12
- <h4>
13
- <a href="https://kubb.dev/plugins/client" target="_blank">Documentation</a>
14
- <span> · </span>
15
- <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Report Bug</a>
16
- <span> · </span>
17
- <a href="https://github.com/kubb-labs/kubb/issues/" target="_blank">Request Feature</a>
18
- </h4>
19
- </div>
20
-
21
- <br />
22
-
23
1
  # @kubb/plugin-client
24
2
 
25
- ### Generate type-safe HTTP clients from OpenAPI
26
-
27
- `@kubb/plugin-client` generates HTTP clients from your OpenAPI specification. It supports Axios, Fetch, and custom adapters, with request and response types inferred directly from the spec.
3
+ Generate typed operations from an OpenAPI document and connect them to a client module that you own. The plugin generates operation functions and types; it does not choose a transport or copy runtime helpers.
28
4
 
29
- ## Installation
5
+ ```ts
6
+ import { pluginClient } from '@kubb/plugin-client'
30
7
 
31
- ```bash
32
- bun add @kubb/plugin-client
33
- # or
34
- pnpm add @kubb/plugin-client
35
- # or
36
- npm install @kubb/plugin-client
8
+ pluginClient({ importPath: '../api/client' })
37
9
  ```
38
10
 
39
- ## Documentation
40
-
41
- See the [full documentation](https://kubb.dev/plugins/client) for configuration options and examples.
42
-
43
- ## Supporting Kubb
44
-
45
- Kubb is an open source project, and its development is funded entirely by sponsors. If you would like to become a sponsor, please consider:
46
-
47
- - [Become a Sponsor on GitHub](https://github.com/sponsors/stijnvanhulle)
48
-
49
- <p align="center">
50
- <a href="https://github.com/sponsors/stijnvanhulle">
51
- <img src="https://raw.githubusercontent.com/stijnvanhulle/sponsors/main/sponsors.svg" alt="My sponsors" />
52
- </a>
53
- </p>
54
-
55
- ## License
11
+ `importPath` is written into each generated import as-is, so it must resolve from the generated operation file (for example `../../../client`, or a package or alias specifier). The module must export `client`, plus the `Options` and `RequestResult` types. Generated operations call `client` with a config containing `method`, `url`, and the operation options, and return its promise typed as `RequestResult`. There are no `withUnwrap` or `unwrapResult` helpers to write, and `returnType` is not an option.
56
12
 
57
- [MIT](https://github.com/kubb-labs/plugins/blob/main/LICENSE)
13
+ If your spec has server-sent event operations, also export `toEventStream` and the `EventStreamResult` and `SuccessOf` types. Implement the behavior your application needs in that module.
58
14
 
59
- <!-- Badges -->
15
+ Set the base URL, auth, retries, and any other behavior inside your `client`. `sdk`, `returnType`, and `baseURL` are not options of this plugin. `validator: 'zod'` needs `pluginZod()` in the plugins, and generation stops with an error if it is missing. Your `client` receives the schemas on `config.validator` (`{ request?, response?, error? }`), so add that field to your `RequestConfig` and run them yourself.
60
16
 
61
- [npm-version-src]: https://shieldcn.dev/npm/v/@kubb/plugin-client.svg?variant=secondary&size=xs&theme=zinc&mode=dark
62
- [npm-version-href]: https://npmx.dev/package/@kubb/plugin-client
63
- [npm-downloads-src]: https://shieldcn.dev/npm/dm/@kubb/plugin-client.svg?variant=secondary&size=xs&theme=zinc&mode=dark
64
- [npm-downloads-href]: https://npmx.dev/package/@kubb/plugin-client
65
- [stars-src]: https://shieldcn.dev/github/stars/kubb-labs/kubb.svg?variant=secondary&size=xs&theme=zinc&mode=dark
66
- [stars-href]: https://github.com/kubb-labs/kubb
67
- [license-src]: https://shieldcn.dev/npm/license/@kubb/plugin-client.svg?variant=secondary&size=xs&theme=zinc
68
- [license-href]: https://github.com/kubb-labs/kubb/blob/main/LICENSE
69
- [node-src]: https://shieldcn.dev/npm/node/@kubb/plugin-client.svg?variant=secondary&size=xs&theme=zinc&mode=dark
70
- [node-href]: https://npmx.dev/package/@kubb/plugin-client
17
+ See [`examples/client`](../../examples/client) for a minimal `client.ts` built on `fetch`.