@kubb/plugin-client 5.5.12 → 5.5.14

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 CHANGED
@@ -439,11 +439,11 @@ function createGroupConfig(group) {
439
439
  //#region kubb-extension.json
440
440
  var compatibility = {
441
441
  "kubb": ">=5.8.3",
442
- "node": ">=22"
442
+ "node": ">=22.12"
443
443
  };
444
444
  //#endregion
445
445
  //#region package.json
446
- var version = "5.5.12";
446
+ var version = "5.5.14";
447
447
  //#endregion
448
448
  //#region ../../internals/client/src/builders/validatorOptions.ts
449
449
  /**
@@ -0,0 +1,251 @@
1
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
2
+ import "@kubb/plugin-zod";
3
+ //#region ../../internals/client/src/types.d.ts
4
+ /**
5
+ * Validator applied to request and response bodies using schemas from `@kubb/plugin-zod`.
6
+ * - `false`: no validation.
7
+ * - `'zod'`: validates the success (2xx) response body, and the error body when a non-2xx call does
8
+ * not throw (`throwOnError: false`).
9
+ * - `{ request?: 'zod'; response?: 'zod' }`: opt in per direction. `request` validates the request
10
+ * body before the call; `response` validates the success response body and,
11
+ * on the non-throw path, the error body.
12
+ */
13
+ type ValidatorOptions = false | 'zod' | {
14
+ request?: 'zod';
15
+ response?: 'zod';
16
+ };
17
+ /**
18
+ * How the class-based SDK groups operations.
19
+ * - `'tag'`: one class per tag, optionally composed into a root client.
20
+ * - `'flat'`: one class with every operation as a direct method.
21
+ */
22
+ type Mode = 'tag' | 'flat';
23
+ /**
24
+ * Shape of the value a generated operation function resolves to.
25
+ * - `'full'`: the complete `{ status, data, error, contentType, request, response }` result.
26
+ * - `'data'`: the bare success body when `throwOnError` is true, or the full result when it is false
27
+ * so callers can inspect `error`.
28
+ * - `'plain'`: the client's own promise typed as `RequestResult`, with no `withUnwrap` / `unwrapResult`
29
+ * helper. Backs `@kubb/plugin-client`.
30
+ */
31
+ type ReturnTypeOption = 'full' | 'data' | 'plain';
32
+ /**
33
+ * The resolver shared by the client plugins. Inherits the built-in camelCase `name` and `file`;
34
+ * classes and tag groups use PascalCase (with a `Client` suffix for groups).
35
+ */
36
+ type ResolverClient = Resolver & {
37
+ /**
38
+ * Resolves the generated class name for class-based clients.
39
+ */
40
+ className(this: ResolverClient, name: string): string;
41
+ /**
42
+ * Resolves the generated class name for a tag-based client group. The default appends a
43
+ * `Client` suffix (tag `pet` becomes `PetClient`) so the class never collides with the schema
44
+ * model of the same name in the barrel.
45
+ *
46
+ * @example
47
+ * `resolver.groupName('pet') // -> 'PetClient'`
48
+ */
49
+ groupName(this: ResolverClient, name: string): string;
50
+ /**
51
+ * Resolves the property name a tag client is exposed under on the composed root SDK
52
+ * (`new PetStore(config).pet`).
53
+ */
54
+ propertyName(this: ResolverClient, name: string): string;
55
+ };
56
+ /**
57
+ * The shared options surface for the client plugins. Deliberately small: there is one
58
+ * response contract and one grouped options object. Each plugin extends this with its own
59
+ * `transport` field.
60
+ */
61
+ type Options$1 = OutputOptions & {
62
+ /**
63
+ * Skip operations matching at least one entry in the list.
64
+ */
65
+ exclude?: Array<Exclude>;
66
+ /**
67
+ * Restrict generation to operations matching at least one entry in the list.
68
+ */
69
+ include?: Array<Include>;
70
+ /**
71
+ * Apply a different options object to operations matching a pattern.
72
+ */
73
+ override?: Array<Override<Omit<ResolvedOptions$1, 'throwOnErrorDefault'>>>;
74
+ /**
75
+ * Base URL prepended to every request. When omitted, the generated client sets no base URL, so
76
+ * set one at runtime with `client.setConfig({ baseURL })`. The adapter's server URL is not used.
77
+ * Values containing a `${...}` interpolation are emitted as template literals in the generated
78
+ * client config, which keeps runtime environment reads dynamic.
79
+ */
80
+ baseURL?: string;
81
+ /**
82
+ * Default error behavior for generated operations and their client. Per-call `throwOnError`
83
+ * takes precedence.
84
+ *
85
+ * @default true
86
+ */
87
+ throwOnErrorDefault?: boolean;
88
+ /**
89
+ * Validate request and response bodies with schemas from `@kubb/plugin-zod`.
90
+ *
91
+ * @default false
92
+ */
93
+ validator?: ValidatorOptions;
94
+ /**
95
+ * Shape of the value a generated operation function resolves to. Applies to the standalone
96
+ * functions and the class-based SDK; not to the query-hook plugins (`@kubb/plugin-react-query`,
97
+ * `@kubb/plugin-vue-query`, `@kubb/plugin-swr`), which keep calling the client directly and
98
+ * expect the full result.
99
+ *
100
+ * @default 'full'
101
+ * @example
102
+ * ```ts
103
+ * pluginAxios({ returnType: 'data' })
104
+ * // const pet = await getPetById({ path: { petId: 1 } }) // Pet, not { status, data, ... }
105
+ * ```
106
+ */
107
+ returnType?: ReturnTypeOption;
108
+ /**
109
+ * Generates a class-based SDK instead of the standalone functions. Each tag client is an instance
110
+ * class whose constructor takes a client config and builds its own client, so every environment is
111
+ * a separate instance. Leave `sdk` unset to keep the standalone per-operation functions (the
112
+ * default), which is also what query plugins consume.
113
+ *
114
+ * @example Instance class per tag
115
+ * ```ts
116
+ * pluginFetch({ sdk: {} })
117
+ * // const api = new PetClient({ baseURL: 'https://api.example.com' })
118
+ * // await api.getPetById({ path: { petId: 1 } })
119
+ * ```
120
+ * @example Composed root that instantiates every tag client from one config
121
+ * ```ts
122
+ * pluginFetch({ sdk: { name: 'petStore' } })
123
+ * // class PetStore {
124
+ * // readonly pet: PetClient
125
+ * // readonly store: StoreClient
126
+ * // constructor(config = {}) { ... }
127
+ * // }
128
+ * // const api = new PetStore({ baseURL })
129
+ * // await api.pet.getPetById({ path: { petId: 1 } })
130
+ * ```
131
+ * @example Flat class with every operation as a direct method
132
+ * ```ts
133
+ * pluginFetch({ sdk: { name: 'petStore', mode: 'flat' } })
134
+ * // const api = new PetStore({ baseURL })
135
+ * // await api.getPetById({ path: { petId: 1 } })
136
+ * ```
137
+ */
138
+ sdk?: {
139
+ /**
140
+ * How the SDK groups operations.
141
+ * - `'tag'`: one class per tag. With `name`, a composed root instantiates every tag client.
142
+ * - `'flat'`: one class named by `name`, with every operation as a direct method.
143
+ *
144
+ * @default 'tag'
145
+ */
146
+ mode?: Mode;
147
+ /**
148
+ * Name of the generated entry point, also the file name. With `mode: 'tag'` it emits a
149
+ * composed root class that instantiates every tag client from one shared config. With
150
+ * `mode: 'flat'` it names the single class.
151
+ */
152
+ name?: string;
153
+ };
154
+ /**
155
+ * Override how names and file paths are built. Methods you omit fall back to the default resolver.
156
+ */
157
+ resolver?: ResolverPatch<ResolverClient>;
158
+ /**
159
+ * Macros applied to each operation node before code is printed.
160
+ */
161
+ macros?: Array<ast.Macro>;
162
+ };
163
+ /**
164
+ * The resolved options after defaults are applied.
165
+ */
166
+ type ResolvedOptions$1 = {
167
+ output: Output;
168
+ exclude: Array<Exclude>;
169
+ include: Array<Include> | undefined;
170
+ override: Array<Override<Omit<ResolvedOptions$1, 'throwOnErrorDefault'>>>;
171
+ group: Group | null;
172
+ baseURL: Options$1['baseURL'];
173
+ throwOnErrorDefault: boolean;
174
+ validator: NonNullable<Options$1['validator']>;
175
+ returnType: ReturnTypeOption;
176
+ sdk: {
177
+ mode: Mode;
178
+ name: string | undefined;
179
+ } | undefined;
180
+ resolver: ResolverClient;
181
+ };
182
+ //#endregion
183
+ //#region src/types.d.ts
184
+ /**
185
+ * Omits keys from every member of a union, where the built-in `Omit` would collapse the union into one shape.
186
+ */
187
+ type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
188
+ /**
189
+ * Options for `pluginClient`. It takes the shared client options, without the ones this plugin does not use,
190
+ * plus the required `importPath`.
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * pluginClient({ importPath: '../../../client' })
195
+ * ```
196
+ */
197
+ type Options = DistributiveOmit<Options$1, 'sdk' | 'returnType' | 'baseURL' | 'override'> & {
198
+ /**
199
+ * Applies different options to operations that match a pattern.
200
+ * `sdk`, `returnType`, and `baseURL` are not available, because this plugin generates standalone operations and your client module owns the base URL.
201
+ */
202
+ override?: Array<Override<Omit<ResolvedOptions, 'throwOnErrorDefault' | 'sdk' | 'returnType' | 'baseURL'>>>;
203
+ /**
204
+ * Import specifier of your own client module, written into every generated import exactly as given.
205
+ * It must resolve from the generated file, so use a relative path, a package name, or an alias.
206
+ *
207
+ * @example
208
+ * ```ts
209
+ * pluginClient({ importPath: '../../../client' }) // relative to src/gen/clients/<tag>/
210
+ * pluginClient({ importPath: '@my-org/api-client' }) // a package
211
+ * ```
212
+ */
213
+ importPath: string;
214
+ };
215
+ /**
216
+ * Options after `pluginClient` applies its defaults.
217
+ */
218
+ type ResolvedOptions = ResolvedOptions$1 & {
219
+ importPath: string;
220
+ };
221
+ /**
222
+ * Plugin type of `@kubb/plugin-client`, registered in the Kubb plugin registry.
223
+ */
224
+ type PluginClient = PluginType<'plugin-client', Options, ResolvedOptions, ResolverClient>;
225
+ declare global {
226
+ namespace Kubb {
227
+ interface PluginRegistry {
228
+ 'plugin-client': PluginClient;
229
+ }
230
+ }
231
+ }
232
+ //#endregion
233
+ //#region src/plugin.d.ts
234
+ /**
235
+ * Canonical plugin name for `@kubb/plugin-client`.
236
+ */
237
+ export declare const pluginClientName = "plugin-client";
238
+ /**
239
+ * Generates typed operations that call a client module owned by your application.
240
+ * The module at `importPath` must export the runtime helpers and types used by generated operations.
241
+ * Kubb does not copy or inject a transport implementation.
242
+ *
243
+ * @example
244
+ * ```ts
245
+ * pluginClient({ importPath: '../api/client' })
246
+ * ```
247
+ */
248
+ export declare const pluginClient: import("kubb/kit").PluginFactory<PluginClient>;
249
+ //#endregion
250
+ export { type Options, type PluginClient, type ResolvedOptions, type ResolverClient, pluginClient as default };
251
+ //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
- import { Diagnostics, Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
1
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
3
2
  import "@kubb/plugin-zod";
4
3
  //#region ../../internals/client/src/types.d.ts
5
4
  /**
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Diagnostics, Resolver, Url, addGenerator, ast, createResolver, defineExtension, defineGenerator, macroSimplifyUnion, setMacros, setResolver } from "kubb/kit";
3
2
  import path from "node:path";
4
3
  import { createFunctionParameter, createFunctionParameters, functionPrinter, pluginTsName } from "@kubb/plugin-ts";
5
4
  import { pluginZodName } from "@kubb/plugin-zod";
6
5
  import { File, Function, jsxRenderer } from "kubb/jsx";
7
6
  import { jsx, jsxs } from "kubb/jsx/jsx-runtime";
7
+ //#endregion
8
8
  //#region ../../internals/shared/src/operation.ts
9
9
  /**
10
10
  * Builds the `ResolverFileParams` every operation generator passes to
@@ -413,11 +413,11 @@ function createGroupConfig(group) {
413
413
  //#region kubb-extension.json
414
414
  var compatibility = {
415
415
  "kubb": ">=5.8.3",
416
- "node": ">=22"
416
+ "node": ">=22.12"
417
417
  };
418
418
  //#endregion
419
419
  //#region package.json
420
- var version = "5.5.12";
420
+ var version = "5.5.14";
421
421
  //#endregion
422
422
  //#region ../../internals/client/src/builders/validatorOptions.ts
423
423
  /**
@@ -21,7 +21,7 @@
21
21
  "optionalDependencies": ["plugin-zod"],
22
22
  "compatibility": {
23
23
  "kubb": ">=5.8.3",
24
- "node": ">=22"
24
+ "node": ">=22.12"
25
25
  },
26
26
  "options": [
27
27
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-client",
3
- "version": "5.5.12",
3
+ "version": "5.5.14",
4
4
  "description": "Generate typed API operations against your own client module.",
5
5
  "keywords": [
6
6
  "api-client",
@@ -35,9 +35,14 @@
35
35
  "types": "./dist/index.d.ts",
36
36
  "exports": {
37
37
  ".": {
38
- "types": "./dist/index.d.ts",
39
- "import": "./dist/index.js",
40
- "require": "./dist/index.cjs"
38
+ "import": {
39
+ "types": "./dist/index.d.ts",
40
+ "default": "./dist/index.js"
41
+ },
42
+ "require": {
43
+ "types": "./dist/index.d.cts",
44
+ "default": "./dist/index.cjs"
45
+ }
41
46
  },
42
47
  "./package.json": "./package.json",
43
48
  "./kubb-extension.json": "./kubb-extension.json"
@@ -47,20 +52,20 @@
47
52
  "registry": "https://registry.npmjs.org/"
48
53
  },
49
54
  "dependencies": {
50
- "@kubb/plugin-ts": "^5.0.12",
51
- "@kubb/plugin-zod": "^5.4.10"
55
+ "@kubb/plugin-ts": "^5.0.14",
56
+ "@kubb/plugin-zod": "^5.4.12"
52
57
  },
53
58
  "devDependencies": {
54
59
  "@internals/client": "0.0.0",
55
60
  "@internals/shared": "0.0.0",
56
- "kubb": "^5.10.2",
61
+ "kubb": "^5.10.3",
57
62
  "typescript": "^6.0.3"
58
63
  },
59
64
  "peerDependencies": {
60
- "kubb": "^5.10.2"
65
+ "kubb": "^5.10.3"
61
66
  },
62
67
  "engines": {
63
- "node": ">=22"
68
+ "node": ">=22.12"
64
69
  },
65
70
  "scripts": {
66
71
  "build": "tsdown",
@@ -1,8 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __name = (target, value) => __defProp(target, "name", {
4
- value,
5
- configurable: true
6
- });
7
- //#endregion
8
- export { __name as t };