@kubb/plugin-client 5.5.8 → 5.5.10
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/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/docs/overview.md +10 -14
- package/kubb-extension.json +1 -0
- package/package.json +5 -5
- package/src/types.ts +2 -2
package/dist/index.cjs
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Exclude, Group, Include, Output, OutputOptions, Override,
|
|
2
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
|
|
3
3
|
import "@kubb/plugin-zod";
|
|
4
4
|
import "kubb/jsx";
|
|
5
5
|
//#region ../../internals/client/src/types.d.ts
|
|
@@ -223,7 +223,7 @@ type ResolvedOptions = ResolvedOptions$1 & {
|
|
|
223
223
|
/**
|
|
224
224
|
* Plugin type of `@kubb/plugin-client`, registered in the Kubb plugin registry.
|
|
225
225
|
*/
|
|
226
|
-
type PluginClient =
|
|
226
|
+
type PluginClient = PluginType<'plugin-client', Options, ResolvedOptions, ResolverClient>;
|
|
227
227
|
declare global {
|
|
228
228
|
namespace Kubb {
|
|
229
229
|
interface PluginRegistry {
|
package/dist/index.js
CHANGED
package/docs/overview.md
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
# Client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Client plugin turns each operation in your OpenAPI spec into a typed function that calls a client module you write. The generated code has no Fetch, axios, or Kubb runtime dependency.
|
|
4
4
|
|
|
5
|
-
Each function takes grouped `path`, `query`, `headers`, and `body` parameters and passes the operation's auth requirements to your client in a `security` list. A single call can pass its own `client` to replace the default.
|
|
6
|
-
|
|
7
|
-
Use it to connect the generated functions to an HTTP layer you already have, or to sign requests. For a ready-made client, use `@kubb/plugin-fetch` or `@kubb/plugin-axios` instead.
|
|
5
|
+
Each function takes grouped `path`, `query`, `headers`, and `body` parameters and passes the operation's auth requirements to your client in a `security` list. A single call can pass its own `client` to replace the default. For a ready-made client, or to use the query plugins or `@kubb/plugin-mcp`, use `@kubb/plugin-fetch` or `@kubb/plugin-axios` instead.
|
|
8
6
|
|
|
9
7
|
## Setup
|
|
10
8
|
|
|
11
|
-
- Set `importPath` to your client module.
|
|
12
|
-
- Add `@kubb/plugin-ts` for the operation types
|
|
13
|
-
- Add `@kubb/plugin-zod` when you set `validator
|
|
9
|
+
- Set the required `importPath` option to your client module. The module must export `client` and the `Options` and `RequestResult` types. When the spec has server-sent event operations, it must also export `toEventStream` and the `EventStreamResult` and `SuccessOf` types.
|
|
10
|
+
- Add `@kubb/plugin-ts` for the operation types, or `@kubb/plugin-zod` with `inferred: true`.
|
|
11
|
+
- Add `@kubb/plugin-zod` when you set `validator`, and install `zod` v4. Generation fails without the plugin.
|
|
14
12
|
|
|
15
13
|
## Options worth knowing
|
|
16
14
|
|
|
17
15
|
- `importPath` is written into every generated import as given, so it must resolve from the generated file. A relative path, a package name, or an alias works.
|
|
18
|
-
- `validator: 'zod'` passes
|
|
16
|
+
- `validator: 'zod'` passes response schemas from `@kubb/plugin-zod` to your client. Use `{ request: 'zod', response: 'zod' }` to also pass request body schemas.
|
|
19
17
|
- `throwOnErrorDefault` is the `throwOnError` value each call passes to your client. The default is `true`.
|
|
20
18
|
|
|
19
|
+
See [Options](https://kubb.dev/extensions/kubb-labs/plugin-client/options) for every option and its default.
|
|
20
|
+
|
|
21
21
|
## Example
|
|
22
22
|
|
|
23
|
+
The config below groups the generated functions by tag and points them at the client module in `src/client.ts`.
|
|
24
|
+
|
|
23
25
|
```typescript [kubb.config.ts]
|
|
24
26
|
import { defineConfig } from 'kubb/config'
|
|
25
27
|
import { pluginTs } from '@kubb/plugin-ts'
|
|
@@ -39,9 +41,3 @@ export default defineConfig({
|
|
|
39
41
|
],
|
|
40
42
|
})
|
|
41
43
|
```
|
|
42
|
-
|
|
43
|
-
## See also
|
|
44
|
-
|
|
45
|
-
- [`@kubb/plugin-fetch`](https://kubb.dev/extensions/kubb-labs/plugin-fetch)
|
|
46
|
-
- [`@kubb/plugin-axios`](https://kubb.dev/extensions/kubb-labs/plugin-axios)
|
|
47
|
-
- [Example project](https://github.com/kubb-labs/plugins/tree/main/examples/client)
|
package/kubb-extension.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.10",
|
|
4
4
|
"description": "Generate typed API operations against your own client module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-client",
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
"registry": "https://registry.npmjs.org/"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@kubb/plugin-ts": "^5.0.
|
|
51
|
-
"@kubb/plugin-zod": "^5.4.
|
|
50
|
+
"@kubb/plugin-ts": "^5.0.11",
|
|
51
|
+
"@kubb/plugin-zod": "^5.4.9"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@internals/client": "0.0.0",
|
|
55
55
|
"@internals/shared": "0.0.0",
|
|
56
|
-
"kubb": "^5.
|
|
56
|
+
"kubb": "^5.9.2",
|
|
57
57
|
"typescript": "^6.0.3"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"kubb": "^5.
|
|
60
|
+
"kubb": "^5.9.2"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
63
|
"node": ">=22"
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Override,
|
|
1
|
+
import type { Override, PluginType } from 'kubb/kit'
|
|
2
2
|
import type { Options as ClientOptions, ResolvedOptions as ClientResolvedOptions, ResolverClient } from '@internals/client'
|
|
3
3
|
|
|
4
4
|
export type { ResolverClient } from '@internals/client'
|
|
@@ -43,7 +43,7 @@ export type ResolvedOptions = ClientResolvedOptions & { importPath: string }
|
|
|
43
43
|
/**
|
|
44
44
|
* Plugin type of `@kubb/plugin-client`, registered in the Kubb plugin registry.
|
|
45
45
|
*/
|
|
46
|
-
export type PluginClient =
|
|
46
|
+
export type PluginClient = PluginType<'plugin-client', Options, ResolvedOptions, ResolverClient>
|
|
47
47
|
|
|
48
48
|
declare global {
|
|
49
49
|
namespace Kubb {
|