@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/dist/index.d.ts CHANGED
@@ -1,127 +1,66 @@
1
- import { t as __name } from "./chunk-C0LytTxp.js";
2
- import { Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
3
- import { ResolverTs } from "@kubb/plugin-ts";
4
- import { ResolverZod } from "@kubb/plugin-zod";
5
- import { KubbReactNode } from "@kubb/renderer-jsx/types";
6
-
7
- //#region src/types.d.ts
1
+ import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ResolverPatch, ast } from "kubb/kit";
3
+ import "@kubb/plugin-zod";
4
+ import "kubb/jsx";
5
+ //#region ../../internals/client/src/types.d.ts
6
+ /**
7
+ * Validator applied to request and response bodies using schemas from `@kubb/plugin-zod`.
8
+ * - `false`: no validation.
9
+ * - `'zod'`: validates the success (2xx) response body, and the error body when a non-2xx call does
10
+ * not throw (`throwOnError: false`).
11
+ * - `{ request?: 'zod'; response?: 'zod' }`: opt in per direction. `request` validates the request
12
+ * body before the call; `response` validates the success response body and,
13
+ * on the non-throw path, the error body.
14
+ */
15
+ type ValidatorOptions = false | 'zod' | {
16
+ request?: 'zod';
17
+ response?: 'zod';
18
+ };
8
19
  /**
9
- * The concrete resolver type for `@kubb/plugin-client`.
10
- * Extends the base `Resolver` with a `resolveName` helper for client function names.
20
+ * How the class-based SDK groups operations.
21
+ * - `'tag'`: one class per tag, optionally composed into a root client.
22
+ * - `'flat'`: one class with every operation as a direct method.
11
23
  */
12
- type ResolverClient = Resolver & {
13
- /**
14
- * Resolves the function name for a given raw operation name.
15
- *
16
- * @example Resolving operation names
17
- * `resolver.resolveName('show pet by id') // -> 'showPetById'`
18
- */
19
- resolveName(this: ResolverClient, name: string): string;
20
- /**
21
- * Resolves the output file name for a client module.
22
- */
23
- resolvePathName(this: ResolverClient, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
24
- /**
25
- * Resolves the generated class name for class-based clients.
26
- */
27
- resolveClassName(this: ResolverClient, name: string): string;
28
- /**
29
- * Resolves the generated class name for tag-based client groups. The default
30
- * appends a `Client` suffix (tag `pet` becomes `PetClient`) so the class never
31
- * collides with the schema model of the same name in the barrel.
32
- *
33
- * @example Resolving tag-group class names
34
- * `resolver.resolveGroupName('pet') // -> 'PetClient'`
35
- */
36
- resolveGroupName(this: ResolverClient, name: string): string;
37
- /**
38
- * Resolves the generated SDK facade property name for a client class.
39
- */
40
- resolveClientPropertyName(this: ResolverClient, name: string): string;
41
- /**
42
- * Resolves the URL helper function name for an operation.
43
- *
44
- * @example Resolving URL helper names
45
- * `resolver.resolveUrlName(node) // -> 'getShowPetByIdUrl'`
46
- */
47
- resolveUrlName(this: ResolverClient, node: ast.OperationNode): string;
48
- };
24
+ type Mode = 'tag' | 'flat';
49
25
  /**
50
- * Use either a preset `client` type OR a custom `importPath`, not both.
51
- * `importPath` will override the default `client` preset when both are provided.
52
- * These options are mutually exclusive. `bundle` and `importPath` are also
53
- * mutually exclusive since `bundle` only has effect when `importPath` is not set.
26
+ * Shape of the value a generated operation function resolves to.
27
+ * - `'full'`: the complete `{ status, data, error, contentType, request, response }` result.
28
+ * - `'data'`: the bare success body when `throwOnError` is true, or the full result when it is false
29
+ * so callers can inspect `error`.
30
+ * - `'plain'`: the client's own promise typed as `RequestResult`, with no `withUnwrap` / `unwrapResult`
31
+ * helper. Backs `@kubb/plugin-client`.
54
32
  */
55
- type ClientImportPath = {
56
- /**
57
- * HTTP client used by the generated code.
58
- * - `'axios'` — imports from `@kubb/plugin-client/clients/axios`. Requires `axios` at runtime.
59
- * - `'fetch'` — imports from `@kubb/plugin-client/clients/fetch`. Uses the global `fetch`.
60
- *
61
- * @default 'axios'
62
- */
63
- client?: 'axios' | 'fetch';
64
- importPath?: never;
65
- } | {
66
- client?: never;
67
- /**
68
- * Path to a custom client module. Generated files import their HTTP runtime from here
69
- * instead of `@kubb/plugin-client/clients/{client}`. Accepts both relative paths and
70
- * bare module specifiers; the value is used as-is.
71
- *
72
- * @note When combined with a query plugin, the module must export `Client`,
73
- * `RequestConfig`, and `ResponseErrorConfig` types.
74
- */
75
- importPath: string;
76
- /**
77
- * `bundle` has no effect when `importPath` is set.
78
- * Use either `bundle` (with `client`) or `importPath`, not both.
79
- */
80
- bundle?: never;
81
- };
33
+ type ReturnTypeOption = 'full' | 'data' | 'plain';
82
34
  /**
83
- * Discriminated union that ties `pathParamsType` to the `paramsType` values where it is meaningful.
84
- *
85
- * - `paramsType: 'object'` — all parameters (including path params) are merged into a single
86
- * destructured object. `pathParamsType` is never reached in this code path and has no effect.
87
- * - `paramsType?: 'inline'` (or omitted) — each parameter group is a separate function argument.
88
- * `pathParamsType` controls whether the path-param group itself is destructured (`'object'`)
89
- * or spread as individual arguments (`'inline'`).
35
+ * The resolver shared by the client plugins. Inherits the built-in camelCase `name` and `file`;
36
+ * classes and tag groups use PascalCase (with a `Client` suffix for groups).
90
37
  */
91
- type ParamsTypeOptions = {
92
- /**
93
- * Every operation parameter (path, query, headers, body) is wrapped in a single
94
- * destructured object argument.
95
- */
96
- paramsType: 'object';
38
+ type ResolverClient = Resolver & {
97
39
  /**
98
- * `pathParamsType` has no effect when `paramsType` is `'object'`.
99
- * Path params already live inside the single destructured object.
40
+ * Resolves the generated class name for class-based clients.
100
41
  */
101
- pathParamsType?: never;
102
- } | {
42
+ className(this: ResolverClient, name: string): string;
103
43
  /**
104
- * Each parameter group is emitted as a separate positional function argument.
44
+ * Resolves the generated class name for a tag-based client group. The default appends a
45
+ * `Client` suffix (tag `pet` becomes `PetClient`) so the class never collides with the schema
46
+ * model of the same name in the barrel.
105
47
  *
106
- * @default 'inline'
48
+ * @example
49
+ * `resolver.groupName('pet') // -> 'PetClient'`
107
50
  */
108
- paramsType?: 'inline';
51
+ groupName(this: ResolverClient, name: string): string;
109
52
  /**
110
- * How URL path parameters are arranged inside the inline argument list.
111
- * - `'object'` groups them into one destructured object: `{ petId }: PathParams`.
112
- * - `'inline'` emits each path param as its own argument: `petId: string`.
113
- *
114
- * @default 'inline'
53
+ * Resolves the property name a tag client is exposed under on the composed root SDK
54
+ * (`new PetStore(config).pet`).
115
55
  */
116
- pathParamsType?: 'object' | 'inline';
56
+ propertyName(this: ResolverClient, name: string): string;
117
57
  };
118
58
  /**
119
- * Where the generated client files are written and how they are exported, plus the optional
120
- * `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
121
- *
122
- * @default { path: 'clients', barrel: { type: 'named' } }
59
+ * The shared options surface for the client plugins. Deliberately small: there is one
60
+ * response contract and one grouped options object. Each plugin extends this with its own
61
+ * `transport` field.
123
62
  */
124
- type Options = OutputOptions & {
63
+ type Options$1 = OutputOptions & {
125
64
  /**
126
65
  * Skip operations matching at least one entry in the list.
127
66
  */
@@ -133,299 +72,181 @@ type Options = OutputOptions & {
133
72
  /**
134
73
  * Apply a different options object to operations matching a pattern.
135
74
  */
136
- override?: Array<Override<ResolvedOptions>>;
137
- /**
138
- * Emit an `operations.ts` file that re-exports every generated function grouped by HTTP method.
139
- *
140
- * @default false
141
- */
142
- operations?: boolean;
143
- /**
144
- * Whether to also export the URL builder helpers (`get<Operation>Url`).
145
- * - `'export'` exposes them via the barrel.
146
- * - `false` keeps them private.
147
- *
148
- * @default false
149
- */
150
- urlType?: 'export' | false;
75
+ override?: Array<Override<Omit<ResolvedOptions$1, 'throwOnErrorDefault'>>>;
151
76
  /**
152
- * Base URL prepended to every request. When omitted, falls back to the adapter's
153
- * server URL (typically `servers[0].url`).
77
+ * Base URL prepended to every request. When omitted, falls back to the adapter's server URL.
78
+ * Values containing a `${...}` interpolation are emitted as template literals in the generated
79
+ * client config, which keeps runtime environment reads dynamic.
154
80
  */
155
81
  baseURL?: string;
156
82
  /**
157
- * Shape of the value returned by each generated client function.
158
- * - `'data'` — only the response body.
159
- * - `'full'` — the full response as a discriminated union keyed by HTTP status code.
160
- * Each member is `{ status: N; data: StatusNType; statusText: string }`,
161
- * so narrowing on `res.status` also narrows `res.data` to the matching response type.
162
- *
163
- * @default 'data'
164
- */
165
- dataReturnType?: 'data' | 'full';
166
- /**
167
- * Rename parameter properties in the generated client (path, query, headers).
168
- * The HTTP request still uses the original spec names; Kubb writes the mapping for you.
83
+ * Default error behavior for generated operations and their client. Per-call `throwOnError`
84
+ * takes precedence.
169
85
  *
170
- * @note Use the same value on `@kubb/plugin-ts` so types stay compatible.
86
+ * @default true
171
87
  */
172
- paramsCasing?: 'camelcase';
88
+ throwOnErrorDefault?: boolean;
173
89
  /**
174
- * Validator applied to request and response bodies using schemas from `@kubb/plugin-zod`.
175
- * - `false` (default): no validation. The response is returned as-is.
176
- * - `'zod'`: validates response bodies only (backward-compatible shorthand).
177
- * - `{ request?: 'zod'; response?: 'zod' }`: opt in per direction. `request` validates the
178
- * request body and query parameters before the call. `response` validates the response body.
90
+ * Validate request and response bodies with schemas from `@kubb/plugin-zod`.
179
91
  *
180
92
  * @default false
181
- * @example Response only (shorthand)
182
- * `parser: 'zod'`
183
- * @example Both directions
184
- * `parser: { request: 'zod', response: 'zod' }`
185
- */
186
- parser?: false | 'zod' | {
187
- request?: 'zod';
188
- response?: 'zod';
189
- };
190
- /**
191
- * Shape of the generated client.
192
- * - `'function'` — one standalone async function per operation.
193
- * - `'class'` — one class per tag with instance methods.
194
- * - `'staticClass'` — one class per tag with static methods.
195
- *
196
- * @default 'function'
197
- * @note Only `'function'` is compatible with query plugins.
198
93
  */
199
- clientType?: 'function' | 'class' | 'staticClass';
94
+ validator?: ValidatorOptions;
200
95
  /**
201
- * Copy the HTTP client runtime into the generated output so consumers do not need
202
- * `@kubb/plugin-client` at runtime. When `false`, generated files import from
203
- * `@kubb/plugin-client/clients/{client}`.
96
+ * Shape of the value a generated operation function resolves to. Applies to the standalone
97
+ * functions and the class-based SDK; not to the query-hook plugins (`@kubb/plugin-react-query`,
98
+ * `@kubb/plugin-vue-query`, `@kubb/plugin-swr`), which keep calling the client directly and
99
+ * expect the full result.
204
100
  *
205
- * @default false
101
+ * @default 'full'
102
+ * @example
103
+ * ```ts
104
+ * pluginAxios({ returnType: 'data' })
105
+ * // const pet = await getPetById({ path: { petId: 1 } }) // Pet, not { status, data, ... }
106
+ * ```
206
107
  */
207
- bundle?: boolean;
108
+ returnType?: ReturnTypeOption;
208
109
  /**
209
- * Generate a single SDK class composing every tag-based client into one entry point.
210
- * Automatically enables `clientType: 'class'`.
110
+ * Generates a class-based SDK instead of the standalone functions. Each tag client is an instance
111
+ * class whose constructor takes a client config and builds its own client, so every environment is
112
+ * a separate instance. Leave `sdk` unset to keep the standalone per-operation functions (the
113
+ * default), which is also what query plugins consume.
211
114
  *
212
- * @example
115
+ * @example Instance class per tag
116
+ * ```ts
117
+ * pluginFetch({ sdk: {} })
118
+ * // const api = new PetClient({ baseURL: 'https://api.example.com' })
119
+ * // await api.getPetById({ path: { petId: 1 } })
120
+ * ```
121
+ * @example Composed root that instantiates every tag client from one config
213
122
  * ```ts
214
- * pluginClient({
215
- * sdk: { className: 'PetStoreSDK' },
216
- * })
217
- * // class PetStoreSDK {
218
- * // readonly petClient: PetClient
219
- * // readonly storeClient: StoreClient
123
+ * pluginFetch({ sdk: { name: 'petStore' } })
124
+ * // class PetStore {
125
+ * // readonly pet: PetClient
126
+ * // readonly store: StoreClient
220
127
  * // constructor(config = {}) { ... }
221
128
  * // }
129
+ * // const api = new PetStore({ baseURL })
130
+ * // await api.pet.getPetById({ path: { petId: 1 } })
131
+ * ```
132
+ * @example Flat class with every operation as a direct method
133
+ * ```ts
134
+ * pluginFetch({ sdk: { name: 'petStore', mode: 'flat' } })
135
+ * // const api = new PetStore({ baseURL })
136
+ * // await api.getPetById({ path: { petId: 1 } })
222
137
  * ```
223
138
  */
224
139
  sdk?: {
225
140
  /**
226
- * Name of the generated SDK facade class. Also the file name.
141
+ * How the SDK groups operations.
142
+ * - `'tag'`: one class per tag. With `name`, a composed root instantiates every tag client.
143
+ * - `'flat'`: one class named by `name`, with every operation as a direct method.
144
+ *
145
+ * @default 'tag'
146
+ */
147
+ mode?: Mode;
148
+ /**
149
+ * Name of the generated entry point, also the file name. With `mode: 'tag'` it emits a
150
+ * composed root class that instantiates every tag client from one shared config. With
151
+ * `mode: 'flat'` it names the single class.
227
152
  */
228
- className: string;
153
+ name?: string;
229
154
  };
230
155
  /**
231
- * Override how names and file paths are built for the generated client.
232
- * Methods you omit fall back to the default resolver. `this` is bound to the
233
- * full resolver, so `this.default(name)` delegates to the built-in implementation.
156
+ * Override how names and file paths are built. Methods you omit fall back to the default resolver.
234
157
  */
235
- resolver?: Partial<ResolverClient> & ThisType<ResolverClient>;
158
+ resolver?: ResolverPatch<ResolverClient>;
236
159
  /**
237
160
  * Macros applied to each operation node before code is printed.
238
- * Return `null` or `undefined` from a callback to leave the node unchanged.
239
161
  */
240
162
  macros?: Array<ast.Macro>;
241
- /**
242
- * Custom generators that run alongside the built-in client generators.
243
- */
244
- generators?: Array<Generator<PluginClient>>;
245
- } & ClientImportPath & ParamsTypeOptions;
246
- type ResolvedOptions = {
163
+ };
164
+ /**
165
+ * The resolved options after defaults are applied.
166
+ */
167
+ type ResolvedOptions$1 = {
247
168
  output: Output;
248
169
  exclude: Array<Exclude>;
249
170
  include: Array<Include> | undefined;
250
- override: Array<Override<ResolvedOptions>>;
171
+ override: Array<Override<Omit<ResolvedOptions$1, 'throwOnErrorDefault'>>>;
251
172
  group: Group | null;
252
- client: Options['client'];
253
- clientType: NonNullable<Options['clientType']>;
254
- bundle: NonNullable<Options['bundle']>;
255
- parser: NonNullable<Options['parser']>;
256
- urlType: NonNullable<Options['urlType']>;
257
- importPath: Options['importPath'];
258
- baseURL: Options['baseURL'];
259
- dataReturnType: NonNullable<Options['dataReturnType']>;
260
- pathParamsType: NonNullable<NonNullable<Options['pathParamsType']>>;
261
- paramsType: NonNullable<Options['paramsType']>;
262
- paramsCasing: Options['paramsCasing'];
263
- sdk: Options['sdk'];
173
+ baseURL: Options$1['baseURL'];
174
+ throwOnErrorDefault: boolean;
175
+ validator: NonNullable<Options$1['validator']>;
176
+ returnType: ReturnTypeOption;
177
+ sdk: {
178
+ mode: Mode;
179
+ name: string | undefined;
180
+ } | undefined;
264
181
  resolver: ResolverClient;
265
182
  };
266
- type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, ResolverClient>;
267
- declare global {
268
- namespace Kubb {
269
- interface PluginRegistry {
270
- 'plugin-client': PluginClient;
271
- }
272
- }
273
- }
274
- //#endregion
275
- //#region src/components/Client.d.ts
276
- type Props = {
277
- name: string;
278
- urlName?: string;
279
- isExportable?: boolean;
280
- isIndexable?: boolean;
281
- isConfigurable?: boolean;
282
- returnType?: string;
283
- baseURL: string | null | undefined;
284
- dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
285
- paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
286
- paramsType: PluginClient['resolvedOptions']['pathParamsType'];
287
- pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
288
- parser: PluginClient['resolvedOptions']['parser'] | undefined;
289
- node: ast.OperationNode;
290
- tsResolver: ResolverTs;
291
- zodResolver?: ResolverZod | null;
292
- children?: KubbReactNode;
293
- };
294
- declare function Client({
295
- name,
296
- isExportable,
297
- isIndexable,
298
- returnType,
299
- baseURL,
300
- dataReturnType,
301
- parser,
302
- paramsType,
303
- paramsCasing,
304
- pathParamsType,
305
- node,
306
- tsResolver,
307
- zodResolver,
308
- urlName,
309
- children,
310
- isConfigurable
311
- }: Props): KubbReactNode;
312
- //#endregion
313
- //#region src/generators/classClientGenerator.d.ts
314
- /**
315
- * Built-in `operations` generator for `@kubb/plugin-client` when
316
- * `clientType: 'class'`. Emits one class per tag, with one instance method
317
- * per operation and a shared constructor for request configuration.
318
- */
319
- declare const classClientGenerator: import("@kubb/core").Generator<PluginClient, unknown>;
320
183
  //#endregion
321
- //#region src/generators/clientGenerator.d.ts
184
+ //#region src/types.d.ts
322
185
  /**
323
- * Built-in operation generator for `@kubb/plugin-client`. Emits one async
324
- * function per OpenAPI operation, plus the matching URL helper. Used when
325
- * `clientType: 'function'` (the default).
186
+ * Omits keys from every member of a union, where the built-in `Omit` would collapse the union into one shape.
326
187
  */
327
- declare const clientGenerator: import("@kubb/core").Generator<PluginClient, unknown>;
328
- //#endregion
329
- //#region src/generators/groupedClientGenerator.d.ts
188
+ type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
330
189
  /**
331
- * Emits one aggregate file per tag/group when `group` is configured. Each
332
- * file re-exports every client function for that group, so callers can
333
- * `import { petController } from './gen/clients'` instead of importing
334
- * each operation individually.
190
+ * Options for `pluginClient`. It takes the shared client options, without the ones this plugin does not use,
191
+ * plus the required `importPath`.
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * pluginClient({ importPath: '../../../client' })
196
+ * ```
335
197
  */
336
- declare const groupedClientGenerator: import("@kubb/core").Generator<PluginClient, unknown>;
337
- //#endregion
338
- //#region src/generators/operationsGenerator.d.ts
198
+ type Options = DistributiveOmit<Options$1, 'sdk' | 'returnType' | 'baseURL' | 'override'> & {
199
+ /**
200
+ * Applies different options to operations that match a pattern.
201
+ * `sdk`, `returnType`, and `baseURL` are not available, because this plugin generates standalone operations and your client module owns the base URL.
202
+ */
203
+ override?: Array<Override<Omit<ResolvedOptions, 'throwOnErrorDefault' | 'sdk' | 'returnType' | 'baseURL'>>>;
204
+ /**
205
+ * Import specifier of your own client module, written into every generated import exactly as given.
206
+ * It must resolve from the generated file, so use a relative path, a package name, or an alias.
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * pluginClient({ importPath: '../../../client' }) // relative to src/gen/clients/<tag>/
211
+ * pluginClient({ importPath: '@my-org/api-client' }) // a package
212
+ * ```
213
+ */
214
+ importPath: string;
215
+ };
339
216
  /**
340
- * Generates an `operations.ts` file that re-exports every operation grouped
341
- * by HTTP method. Enabled when `pluginClient({ operations: true })`. Useful
342
- * for building meta-tooling on top of the generated client (route
343
- * registries, API explorers).
217
+ * Options after `pluginClient` applies its defaults.
344
218
  */
345
- declare const operationsGenerator: import("@kubb/core").Generator<PluginClient, unknown>;
346
- //#endregion
347
- //#region src/generators/staticClassClientGenerator.d.ts
219
+ type ResolvedOptions = ResolvedOptions$1 & {
220
+ importPath: string;
221
+ };
348
222
  /**
349
- * Built-in `operations` generator for `@kubb/plugin-client` when
350
- * `clientType: 'staticClass'`. Emits one class per tag, with a static method
351
- * per operation so callers can use `Pet.getPetById(...)` without
352
- * instantiating the class.
223
+ * Plugin type of `@kubb/plugin-client`, registered in the Kubb plugin registry.
353
224
  */
354
- declare const staticClassClientGenerator: import("@kubb/core").Generator<PluginClient, unknown>;
225
+ type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, ResolverClient>;
226
+ declare global {
227
+ namespace Kubb {
228
+ interface PluginRegistry {
229
+ 'plugin-client': PluginClient;
230
+ }
231
+ }
232
+ }
355
233
  //#endregion
356
234
  //#region src/plugin.d.ts
357
235
  /**
358
- * Canonical plugin name for `@kubb/plugin-client`. Used for driver lookups and
359
- * cross-plugin dependency references.
236
+ * Canonical plugin name for `@kubb/plugin-client`.
360
237
  */
361
- declare const pluginClientName = "plugin-client";
238
+ export declare const pluginClientName = "plugin-client";
362
239
  /**
363
- * Generates one HTTP client function per OpenAPI operation. Each function has
364
- * typed path params, query params, body, and response, so callers use the API
365
- * like any other typed function. Ships with `axios` and `fetch` runtimes; bring
366
- * your own by setting `importPath`.
240
+ * Generates typed operations that call a client module owned by your application.
241
+ * The module at `importPath` must export the runtime helpers and types used by generated operations.
242
+ * Kubb does not copy or inject a transport implementation.
367
243
  *
368
244
  * @example
369
245
  * ```ts
370
- * import { defineConfig } from 'kubb'
371
- * import { pluginTs } from '@kubb/plugin-ts'
372
- * import { pluginClient } from '@kubb/plugin-client'
373
- *
374
- * export default defineConfig({
375
- * input: { path: './petStore.yaml' },
376
- * output: { path: './src/gen' },
377
- * plugins: [
378
- * pluginTs(),
379
- * pluginClient({
380
- * output: { path: './clients' },
381
- * client: 'fetch',
382
- * }),
383
- * ],
384
- * })
246
+ * pluginClient({ importPath: '../api/client' })
385
247
  * ```
386
248
  */
387
- declare const pluginClient: (options?: Options | undefined) => import("@kubb/core").Plugin<PluginClient>;
388
- //#endregion
389
- //#region src/resolvers/resolverClient.d.ts
390
- /**
391
- * Default resolver used by `@kubb/plugin-client`. Decides the names and file
392
- * paths for every generated client function or class. Functions and files use
393
- * camelCase; classes and tag groups use PascalCase.
394
- *
395
- * @example Resolve client function and class names
396
- * ```ts
397
- * import { resolverClient } from '@kubb/plugin-client'
398
- *
399
- * resolverClient.default('list pets', 'function') // 'listPets'
400
- * resolverClient.resolveClassName('pet') // 'Pet'
401
- * resolverClient.resolveGroupName('pet') // 'PetClient'
402
- * resolverClient.resolveUrlName(operationNode) // 'getShowPetByIdUrl'
403
- * ```
404
- */
405
- declare const resolverClient: ResolverClient;
406
- //#endregion
407
- //#region src/utils.d.ts
408
- type ParserOption = PluginClient['resolvedOptions']['parser'];
409
- /**
410
- * Returns `true` when any direction of the parser uses Zod (used for dependency checks).
411
- */
412
- declare function isParserEnabled(parser: ParserOption | undefined | false): boolean;
413
- /**
414
- * Returns `'zod'` when request body parsing is enabled, `null` otherwise.
415
- * The string shorthand `'zod'` also enables request body parsing (existing behavior).
416
- */
417
- declare function resolveRequestParser(parser: ParserOption | undefined | false): 'zod' | null;
418
- /**
419
- * Returns `'zod'` when query-parameters parsing is enabled, `null` otherwise.
420
- * Only the object form `{ request: 'zod' }` enables query-params parsing.
421
- * The string shorthand `'zod'` does not, preserving its existing behavior.
422
- */
423
- declare function resolveQueryParamsParser(parser: ParserOption | undefined | false): 'zod' | null;
424
- /**
425
- * Returns `'zod'` when response-direction parsing is enabled, `null` otherwise.
426
- * `parser: 'zod'` (string shorthand) maps to response parsing and returns `'zod'`.
427
- */
428
- declare function resolveResponseParser(parser: ParserOption | undefined | false): 'zod' | null;
249
+ export declare const pluginClient: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginClient>;
429
250
  //#endregion
430
- export { Client, type ClientImportPath, type PluginClient, type ResolverClient, classClientGenerator, clientGenerator, pluginClient as default, pluginClient, groupedClientGenerator, isParserEnabled, operationsGenerator, pluginClientName, resolveQueryParamsParser, resolveRequestParser, resolveResponseParser, resolverClient, staticClassClientGenerator };
251
+ export { type Options, type PluginClient, type ResolvedOptions, type ResolverClient, pluginClient as default };
431
252
  //# sourceMappingURL=index.d.ts.map