@kubb/plugin-client 5.0.0-beta.42 → 5.0.0-beta.56

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __name } from "./chunk-C0LytTxp.js";
2
- import { Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
2
+ import { Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
3
3
  import { ResolverTs } from "@kubb/plugin-ts";
4
4
  import { ResolverZod } from "@kubb/plugin-zod";
5
5
  import { KubbReactNode } from "@kubb/renderer-jsx/types";
@@ -26,7 +26,12 @@ type ResolverClient = Resolver & {
26
26
  */
27
27
  resolveClassName(this: ResolverClient, name: string): string;
28
28
  /**
29
- * Resolves the generated class name for tag-based client groups.
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'`
30
35
  */
31
36
  resolveGroupName(this: ResolverClient, name: string): string;
32
37
  /**
@@ -110,17 +115,13 @@ type ParamsTypeOptions = {
110
115
  */
111
116
  pathParamsType?: 'object' | 'inline';
112
117
  };
113
- type Options = {
114
- /**
115
- * Where the generated client files are written and how they are exported.
116
- *
117
- * @default { path: 'clients', barrel: { type: 'named' } }
118
- */
119
- output?: Output;
120
- /**
121
- * Split generated files into subfolders based on the operation's tag.
122
- */
123
- group?: Group;
118
+ /**
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' } }
123
+ */
124
+ type Options = OutputOptions & {
124
125
  /**
125
126
  * Skip operations matching at least one entry in the list.
126
127
  */
@@ -155,7 +156,9 @@ type Options = {
155
156
  /**
156
157
  * Shape of the value returned by each generated client function.
157
158
  * - `'data'` — only the response body.
158
- * - `'full'` — the full response config (body, status, headers, request).
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.
159
162
  *
160
163
  * @default 'data'
161
164
  */
@@ -168,14 +171,22 @@ type Options = {
168
171
  */
169
172
  paramsCasing?: 'camelcase';
170
173
  /**
171
- * Validator applied to response bodies before they are returned to the caller.
172
- * - `false` (default) no validation. The client has no runtime parser; the response is
173
- * returned as-is, cast to the generated TypeScript type.
174
- * - `'zod'` pipes responses through schemas from `@kubb/plugin-zod`.
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.
175
179
  *
176
180
  * @default false
181
+ * @example Response only (shorthand)
182
+ * `parser: 'zod'`
183
+ * @example Both directions
184
+ * `parser: { request: 'zod', response: 'zod' }`
177
185
  */
178
- parser?: false | 'zod';
186
+ parser?: false | 'zod' | {
187
+ request?: 'zod';
188
+ response?: 'zod';
189
+ };
179
190
  /**
180
191
  * Shape of the generated client.
181
192
  * - `'function'` — one standalone async function per operation.
@@ -204,8 +215,8 @@ type Options = {
204
215
  * sdk: { className: 'PetStoreSDK' },
205
216
  * })
206
217
  * // class PetStoreSDK {
207
- * // readonly petController: petController
208
- * // readonly storeController: storeController
218
+ * // readonly petClient: PetClient
219
+ * // readonly storeClient: StoreClient
209
220
  * // constructor(config = {}) { ... }
210
221
  * // }
211
222
  * ```
@@ -387,10 +398,34 @@ declare const pluginClient: (options?: Options | undefined) => import("@kubb/cor
387
398
  *
388
399
  * resolverClient.default('list pets', 'function') // 'listPets'
389
400
  * resolverClient.resolveClassName('pet') // 'Pet'
401
+ * resolverClient.resolveGroupName('pet') // 'PetClient'
390
402
  * resolverClient.resolveUrlName(operationNode) // 'getShowPetByIdUrl'
391
403
  * ```
392
404
  */
393
405
  declare const resolverClient: ResolverClient;
394
406
  //#endregion
395
- export { Client, type ClientImportPath, type PluginClient, type ResolverClient, classClientGenerator, clientGenerator, pluginClient as default, pluginClient, groupedClientGenerator, operationsGenerator, pluginClientName, resolverClient, staticClassClientGenerator };
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;
429
+ //#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 };
396
431
  //# sourceMappingURL=index.d.ts.map