@kubb/plugin-client 5.0.0-beta.4 → 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/README.md +39 -24
- package/dist/clients/axios.cjs +26 -4
- package/dist/clients/axios.cjs.map +1 -1
- package/dist/clients/axios.d.ts +11 -5
- package/dist/clients/axios.js +26 -4
- package/dist/clients/axios.js.map +1 -1
- package/dist/clients/fetch.cjs +77 -9
- package/dist/clients/fetch.cjs.map +1 -1
- package/dist/clients/fetch.d.ts +10 -3
- package/dist/clients/fetch.js +77 -9
- package/dist/clients/fetch.js.map +1 -1
- package/dist/index.cjs +836 -514
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +206 -105
- package/dist/index.js +833 -515
- package/dist/index.js.map +1 -1
- package/dist/templates/clients/axios.source.cjs +1 -1
- package/dist/templates/clients/axios.source.cjs.map +1 -1
- package/dist/templates/clients/axios.source.d.ts +1 -1
- package/dist/templates/clients/axios.source.js +1 -1
- package/dist/templates/clients/axios.source.js.map +1 -1
- package/dist/templates/clients/fetch.source.cjs +1 -1
- package/dist/templates/clients/fetch.source.cjs.map +1 -1
- package/dist/templates/clients/fetch.source.d.ts +1 -1
- package/dist/templates/clients/fetch.source.js +1 -1
- package/dist/templates/clients/fetch.source.js.map +1 -1
- package/dist/templates/config.source.cjs.map +1 -1
- package/dist/templates/config.source.d.ts +1 -1
- package/dist/templates/config.source.js.map +1 -1
- package/package.json +14 -26
- package/src/clients/axios.ts +41 -7
- package/src/clients/fetch.ts +106 -6
- package/src/components/ClassClient.tsx +47 -24
- package/src/components/Client.tsx +100 -71
- package/src/components/StaticClassClient.tsx +47 -24
- package/src/components/Url.tsx +10 -12
- package/src/components/WrapperClient.tsx +9 -5
- package/src/functionParams.ts +8 -8
- package/src/generators/classClientGenerator.tsx +63 -51
- package/src/generators/clientGenerator.tsx +45 -48
- package/src/generators/groupedClientGenerator.tsx +12 -6
- package/src/generators/operationsGenerator.ts +47 -0
- package/src/generators/staticClassClientGenerator.tsx +57 -45
- package/src/index.ts +2 -1
- package/src/plugin.ts +30 -28
- package/src/resolvers/resolverClient.ts +32 -8
- package/src/types.ts +111 -65
- package/src/utils.ts +142 -63
- package/extension.yaml +0 -776
- package/src/components/Operations.tsx +0 -28
- package/src/generators/operationsGenerator.tsx +0 -28
- package/templates/clients/axios.ts +0 -73
- package/templates/clients/fetch.ts +0 -96
- package/templates/config.ts +0 -43
- /package/dist/{chunk-ByKO4r7w.cjs → chunk-Bx3C2hgW.cjs} +0 -0
- /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { t as __name } from "./chunk
|
|
2
|
-
import
|
|
3
|
-
import { Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
|
|
1
|
+
import { t as __name } from "./chunk-C0LytTxp.js";
|
|
2
|
+
import { Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
|
|
4
3
|
import { ResolverTs } from "@kubb/plugin-ts";
|
|
5
4
|
import { ResolverZod } from "@kubb/plugin-zod";
|
|
6
5
|
import { KubbReactNode } from "@kubb/renderer-jsx/types";
|
|
@@ -13,10 +12,39 @@ import { KubbReactNode } from "@kubb/renderer-jsx/types";
|
|
|
13
12
|
type ResolverClient = Resolver & {
|
|
14
13
|
/**
|
|
15
14
|
* Resolves the function name for a given raw operation name.
|
|
15
|
+
*
|
|
16
16
|
* @example Resolving operation names
|
|
17
17
|
* `resolver.resolveName('show pet by id') // -> 'showPetById'`
|
|
18
18
|
*/
|
|
19
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;
|
|
20
48
|
};
|
|
21
49
|
/**
|
|
22
50
|
* Use either a preset `client` type OR a custom `importPath`, not both.
|
|
@@ -26,9 +54,10 @@ type ResolverClient = Resolver & {
|
|
|
26
54
|
*/
|
|
27
55
|
type ClientImportPath = {
|
|
28
56
|
/**
|
|
29
|
-
*
|
|
30
|
-
* - 'axios'
|
|
31
|
-
* - 'fetch'
|
|
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
|
+
*
|
|
32
61
|
* @default 'axios'
|
|
33
62
|
*/
|
|
34
63
|
client?: 'axios' | 'fetch';
|
|
@@ -36,9 +65,12 @@ type ClientImportPath = {
|
|
|
36
65
|
} | {
|
|
37
66
|
client?: never;
|
|
38
67
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
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.
|
|
42
74
|
*/
|
|
43
75
|
importPath: string;
|
|
44
76
|
/**
|
|
@@ -58,140 +90,156 @@ type ClientImportPath = {
|
|
|
58
90
|
*/
|
|
59
91
|
type ParamsTypeOptions = {
|
|
60
92
|
/**
|
|
61
|
-
*
|
|
93
|
+
* Every operation parameter (path, query, headers, body) is wrapped in a single
|
|
62
94
|
* destructured object argument.
|
|
63
|
-
* - 'object' returns the params and pathParams as an object.
|
|
64
|
-
* @default 'inline'
|
|
65
95
|
*/
|
|
66
96
|
paramsType: 'object';
|
|
67
97
|
/**
|
|
68
98
|
* `pathParamsType` has no effect when `paramsType` is `'object'`.
|
|
69
|
-
* Path params
|
|
99
|
+
* Path params already live inside the single destructured object.
|
|
70
100
|
*/
|
|
71
101
|
pathParamsType?: never;
|
|
72
102
|
} | {
|
|
73
103
|
/**
|
|
74
|
-
* Each parameter group is emitted as a separate function argument.
|
|
75
|
-
*
|
|
104
|
+
* Each parameter group is emitted as a separate positional function argument.
|
|
105
|
+
*
|
|
76
106
|
* @default 'inline'
|
|
77
107
|
*/
|
|
78
108
|
paramsType?: 'inline';
|
|
79
109
|
/**
|
|
80
|
-
*
|
|
81
|
-
* - 'object' groups
|
|
82
|
-
* - 'inline' emits each path param as its own argument: `petId: string`.
|
|
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
|
+
*
|
|
83
114
|
* @default 'inline'
|
|
84
115
|
*/
|
|
85
116
|
pathParamsType?: 'object' | 'inline';
|
|
86
117
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
* Group the clients based on the provided name.
|
|
95
|
-
*/
|
|
96
|
-
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 & {
|
|
97
125
|
/**
|
|
98
|
-
*
|
|
126
|
+
* Skip operations matching at least one entry in the list.
|
|
99
127
|
*/
|
|
100
128
|
exclude?: Array<Exclude>;
|
|
101
129
|
/**
|
|
102
|
-
*
|
|
130
|
+
* Restrict generation to operations matching at least one entry in the list.
|
|
103
131
|
*/
|
|
104
132
|
include?: Array<Include>;
|
|
105
133
|
/**
|
|
106
|
-
*
|
|
134
|
+
* Apply a different options object to operations matching a pattern.
|
|
107
135
|
*/
|
|
108
136
|
override?: Array<Override<ResolvedOptions>>;
|
|
109
137
|
/**
|
|
110
|
-
*
|
|
138
|
+
* Emit an `operations.ts` file that re-exports every generated function grouped by HTTP method.
|
|
139
|
+
*
|
|
111
140
|
* @default false
|
|
112
141
|
*/
|
|
113
142
|
operations?: boolean;
|
|
114
143
|
/**
|
|
115
|
-
*
|
|
116
|
-
* - 'export'
|
|
117
|
-
* - false
|
|
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
|
+
*
|
|
118
148
|
* @default false
|
|
119
|
-
* @example getGetPetByIdUrl
|
|
120
149
|
*/
|
|
121
150
|
urlType?: 'export' | false;
|
|
122
151
|
/**
|
|
123
|
-
*
|
|
152
|
+
* Base URL prepended to every request. When omitted, falls back to the adapter's
|
|
153
|
+
* server URL (typically `servers[0].url`).
|
|
124
154
|
*/
|
|
125
155
|
baseURL?: string;
|
|
126
156
|
/**
|
|
127
|
-
*
|
|
128
|
-
* - 'data'
|
|
129
|
-
* - 'full'
|
|
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
|
+
*
|
|
130
163
|
* @default 'data'
|
|
131
164
|
*/
|
|
132
165
|
dataReturnType?: 'data' | 'full';
|
|
133
166
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
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.
|
|
169
|
+
*
|
|
170
|
+
* @note Use the same value on `@kubb/plugin-ts` so types stay compatible.
|
|
137
171
|
*/
|
|
138
172
|
paramsCasing?: 'camelcase';
|
|
139
173
|
/**
|
|
140
|
-
*
|
|
141
|
-
* -
|
|
142
|
-
* - 'zod'
|
|
143
|
-
*
|
|
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.
|
|
179
|
+
*
|
|
180
|
+
* @default false
|
|
181
|
+
* @example Response only (shorthand)
|
|
182
|
+
* `parser: 'zod'`
|
|
183
|
+
* @example Both directions
|
|
184
|
+
* `parser: { request: 'zod', response: 'zod' }`
|
|
144
185
|
*/
|
|
145
|
-
parser?:
|
|
186
|
+
parser?: false | 'zod' | {
|
|
187
|
+
request?: 'zod';
|
|
188
|
+
response?: 'zod';
|
|
189
|
+
};
|
|
146
190
|
/**
|
|
147
|
-
*
|
|
148
|
-
* - 'function'
|
|
149
|
-
* - 'class'
|
|
150
|
-
* - 'staticClass'
|
|
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
|
+
*
|
|
151
196
|
* @default 'function'
|
|
197
|
+
* @note Only `'function'` is compatible with query plugins.
|
|
152
198
|
*/
|
|
153
199
|
clientType?: 'function' | 'class' | 'staticClass';
|
|
154
200
|
/**
|
|
155
|
-
*
|
|
156
|
-
* When
|
|
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}`.
|
|
204
|
+
*
|
|
157
205
|
* @default false
|
|
158
|
-
* In version 5 of Kubb this is by default true
|
|
159
206
|
*/
|
|
160
207
|
bundle?: boolean;
|
|
161
208
|
/**
|
|
162
|
-
* Generate
|
|
163
|
-
*
|
|
209
|
+
* Generate a single SDK class composing every tag-based client into one entry point.
|
|
210
|
+
* Automatically enables `clientType: 'class'`.
|
|
211
|
+
*
|
|
164
212
|
* @example
|
|
165
213
|
* ```ts
|
|
166
214
|
* pluginClient({
|
|
167
215
|
* sdk: { className: 'PetStoreSDK' },
|
|
168
216
|
* })
|
|
169
|
-
* // Generates a class with a shared constructor config and one property per tag:
|
|
170
217
|
* // class PetStoreSDK {
|
|
171
|
-
* // readonly
|
|
172
|
-
* // readonly
|
|
218
|
+
* // readonly petClient: PetClient
|
|
219
|
+
* // readonly storeClient: StoreClient
|
|
173
220
|
* // constructor(config = {}) { ... }
|
|
174
221
|
* // }
|
|
175
222
|
* ```
|
|
176
223
|
*/
|
|
177
224
|
sdk?: {
|
|
178
225
|
/**
|
|
179
|
-
* Name of the generated SDK facade class.
|
|
226
|
+
* Name of the generated SDK facade class. Also the file name.
|
|
180
227
|
*/
|
|
181
228
|
className: string;
|
|
182
229
|
};
|
|
183
230
|
/**
|
|
184
|
-
* Override
|
|
185
|
-
*
|
|
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.
|
|
186
234
|
*/
|
|
187
235
|
resolver?: Partial<ResolverClient> & ThisType<ResolverClient>;
|
|
188
236
|
/**
|
|
189
|
-
*
|
|
190
|
-
* Return `null` or `undefined`
|
|
237
|
+
* AST visitor applied to each operation node before code is printed.
|
|
238
|
+
* Return `null` or `undefined` to leave the node unchanged.
|
|
191
239
|
*/
|
|
192
240
|
transformer?: ast.Visitor;
|
|
193
241
|
/**
|
|
194
|
-
*
|
|
242
|
+
* Custom generators that run alongside the built-in client generators.
|
|
195
243
|
*/
|
|
196
244
|
generators?: Array<Generator<PluginClient>>;
|
|
197
245
|
} & ClientImportPath & ParamsTypeOptions;
|
|
@@ -200,7 +248,7 @@ type ResolvedOptions = {
|
|
|
200
248
|
exclude: Array<Exclude>;
|
|
201
249
|
include: Array<Include> | undefined;
|
|
202
250
|
override: Array<Override<ResolvedOptions>>;
|
|
203
|
-
group: Group |
|
|
251
|
+
group: Group | null;
|
|
204
252
|
client: Options['client'];
|
|
205
253
|
clientType: NonNullable<Options['clientType']>;
|
|
206
254
|
bundle: NonNullable<Options['bundle']>;
|
|
@@ -232,7 +280,7 @@ type Props = {
|
|
|
232
280
|
isIndexable?: boolean;
|
|
233
281
|
isConfigurable?: boolean;
|
|
234
282
|
returnType?: string;
|
|
235
|
-
baseURL: string | undefined;
|
|
283
|
+
baseURL: string | null | undefined;
|
|
236
284
|
dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
|
|
237
285
|
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
238
286
|
paramsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
@@ -240,17 +288,9 @@ type Props = {
|
|
|
240
288
|
parser: PluginClient['resolvedOptions']['parser'] | undefined;
|
|
241
289
|
node: ast.OperationNode;
|
|
242
290
|
tsResolver: ResolverTs;
|
|
243
|
-
zodResolver?: ResolverZod;
|
|
291
|
+
zodResolver?: ResolverZod | null;
|
|
244
292
|
children?: KubbReactNode;
|
|
245
293
|
};
|
|
246
|
-
type GetParamsProps = {
|
|
247
|
-
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
248
|
-
paramsType: PluginClient['resolvedOptions']['paramsType'];
|
|
249
|
-
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
250
|
-
node: ast.OperationNode;
|
|
251
|
-
tsResolver: ResolverTs;
|
|
252
|
-
isConfigurable: boolean;
|
|
253
|
-
};
|
|
254
294
|
declare function Client({
|
|
255
295
|
name,
|
|
256
296
|
isExportable,
|
|
@@ -269,62 +309,123 @@ declare function Client({
|
|
|
269
309
|
children,
|
|
270
310
|
isConfigurable
|
|
271
311
|
}: Props): KubbReactNode;
|
|
272
|
-
declare namespace Client {
|
|
273
|
-
var getParams: ({
|
|
274
|
-
paramsType,
|
|
275
|
-
paramsCasing,
|
|
276
|
-
pathParamsType,
|
|
277
|
-
node,
|
|
278
|
-
tsResolver,
|
|
279
|
-
isConfigurable
|
|
280
|
-
}: GetParamsProps) => ast.FunctionParametersNode;
|
|
281
|
-
}
|
|
282
312
|
//#endregion
|
|
283
313
|
//#region src/generators/classClientGenerator.d.ts
|
|
284
|
-
|
|
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>;
|
|
285
320
|
//#endregion
|
|
286
321
|
//#region src/generators/clientGenerator.d.ts
|
|
287
|
-
|
|
322
|
+
/**
|
|
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).
|
|
326
|
+
*/
|
|
327
|
+
declare const clientGenerator: import("@kubb/core").Generator<PluginClient, unknown>;
|
|
288
328
|
//#endregion
|
|
289
329
|
//#region src/generators/groupedClientGenerator.d.ts
|
|
290
|
-
|
|
330
|
+
/**
|
|
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.
|
|
335
|
+
*/
|
|
336
|
+
declare const groupedClientGenerator: import("@kubb/core").Generator<PluginClient, unknown>;
|
|
291
337
|
//#endregion
|
|
292
338
|
//#region src/generators/operationsGenerator.d.ts
|
|
293
|
-
|
|
339
|
+
/**
|
|
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).
|
|
344
|
+
*/
|
|
345
|
+
declare const operationsGenerator: import("@kubb/core").Generator<PluginClient, unknown>;
|
|
294
346
|
//#endregion
|
|
295
347
|
//#region src/generators/staticClassClientGenerator.d.ts
|
|
296
|
-
|
|
348
|
+
/**
|
|
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.
|
|
353
|
+
*/
|
|
354
|
+
declare const staticClassClientGenerator: import("@kubb/core").Generator<PluginClient, unknown>;
|
|
297
355
|
//#endregion
|
|
298
356
|
//#region src/plugin.d.ts
|
|
299
357
|
/**
|
|
300
|
-
* Canonical plugin name for `@kubb/plugin-client
|
|
358
|
+
* Canonical plugin name for `@kubb/plugin-client`. Used for driver lookups and
|
|
359
|
+
* cross-plugin dependency references.
|
|
301
360
|
*/
|
|
302
361
|
declare const pluginClientName = "plugin-client";
|
|
303
362
|
/**
|
|
304
|
-
* Generates
|
|
305
|
-
*
|
|
306
|
-
*
|
|
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`.
|
|
307
367
|
*
|
|
308
|
-
* @example
|
|
368
|
+
* @example
|
|
309
369
|
* ```ts
|
|
310
|
-
* import
|
|
370
|
+
* import { defineConfig } from 'kubb'
|
|
371
|
+
* import { pluginTs } from '@kubb/plugin-ts'
|
|
372
|
+
* import { pluginClient } from '@kubb/plugin-client'
|
|
373
|
+
*
|
|
311
374
|
* export default defineConfig({
|
|
312
|
-
*
|
|
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
|
+
* ],
|
|
313
384
|
* })
|
|
314
385
|
* ```
|
|
315
386
|
*/
|
|
316
|
-
declare const pluginClient: (options?: Options | undefined) =>
|
|
387
|
+
declare const pluginClient: (options?: Options | undefined) => import("@kubb/core").Plugin<PluginClient>;
|
|
317
388
|
//#endregion
|
|
318
389
|
//#region src/resolvers/resolverClient.d.ts
|
|
319
390
|
/**
|
|
320
|
-
*
|
|
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.
|
|
321
394
|
*
|
|
322
|
-
*
|
|
395
|
+
* @example Resolve client function and class names
|
|
396
|
+
* ```ts
|
|
397
|
+
* import { resolverClient } from '@kubb/plugin-client'
|
|
323
398
|
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
399
|
+
* resolverClient.default('list pets', 'function') // 'listPets'
|
|
400
|
+
* resolverClient.resolveClassName('pet') // 'Pet'
|
|
401
|
+
* resolverClient.resolveGroupName('pet') // 'PetClient'
|
|
402
|
+
* resolverClient.resolveUrlName(operationNode) // 'getShowPetByIdUrl'
|
|
403
|
+
* ```
|
|
326
404
|
*/
|
|
327
405
|
declare const resolverClient: ResolverClient;
|
|
328
406
|
//#endregion
|
|
329
|
-
|
|
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 };
|
|
330
431
|
//# sourceMappingURL=index.d.ts.map
|