@kubb/plugin-react-query 5.0.0-beta.64 → 5.0.0-beta.74
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 +2 -2
- package/dist/index.cjs +2521 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +521 -3
- package/dist/index.js +2488 -49
- package/dist/index.js.map +1 -1
- package/package.json +10 -19
- package/dist/components-B0j2b6y8.cjs +0 -1583
- package/dist/components-B0j2b6y8.cjs.map +0 -1
- package/dist/components-Ds-e_nnK.js +0 -1433
- package/dist/components-Ds-e_nnK.js.map +0 -1
- package/dist/components.cjs +0 -13
- package/dist/components.d.ts +0 -270
- package/dist/components.js +0 -2
- package/dist/generators-CU6zfet7.cjs +0 -1349
- package/dist/generators-CU6zfet7.cjs.map +0 -1
- package/dist/generators-nnZhtlrk.js +0 -1307
- package/dist/generators-nnZhtlrk.js.map +0 -1
- package/dist/generators.cjs +0 -9
- package/dist/generators.d.ts +0 -66
- package/dist/generators.js +0 -2
- package/dist/types-ANQXv7Gr.d.ts +0 -396
- /package/dist/{chunk-C0LytTxp.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,524 @@
|
|
|
1
|
-
import { t as __name } from "./
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
|
|
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 success (2xx) response bodies only.
|
|
8
|
+
* - `{ request?: 'zod'; response?: 'zod' }`: opt in per direction. `request` validates the request
|
|
9
|
+
* body and query parameters before the call; `response` validates the success response body.
|
|
10
|
+
*/
|
|
11
|
+
type ParserOptions = false | 'zod' | {
|
|
12
|
+
request?: 'zod';
|
|
13
|
+
response?: 'zod';
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* How the class-based SDK groups operations.
|
|
17
|
+
* - `'tag'`: one class per tag, optionally composed into a root client.
|
|
18
|
+
* - `'flat'`: one class with every operation as a direct method.
|
|
19
|
+
*/
|
|
20
|
+
type Mode = 'tag' | 'flat';
|
|
21
|
+
/**
|
|
22
|
+
* The resolver shared by the client plugins. Functions and files use camelCase; URL helpers get
|
|
23
|
+
* a `get<Operation>Url` name.
|
|
24
|
+
*/
|
|
25
|
+
type ResolverClient = Resolver & {
|
|
26
|
+
/**
|
|
27
|
+
* Resolves the function name for a raw operation name.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* `resolver.resolveName('show pet by id') // -> 'showPetById'`
|
|
31
|
+
*/
|
|
32
|
+
resolveName(this: ResolverClient, name: string): string;
|
|
33
|
+
/**
|
|
34
|
+
* Resolves the output file name for a generated client module.
|
|
35
|
+
*/
|
|
36
|
+
resolvePathName(this: ResolverClient, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
|
|
37
|
+
/**
|
|
38
|
+
* Resolves the generated class name for class-based clients.
|
|
39
|
+
*/
|
|
40
|
+
resolveClassName(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.resolveGroupName('pet') // -> 'PetClient'`
|
|
48
|
+
*/
|
|
49
|
+
resolveGroupName(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
|
+
resolveClientPropertyName(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<ResolvedOptions$1>>;
|
|
74
|
+
/**
|
|
75
|
+
* Base URL prepended to every request. When omitted, falls back to the adapter's server URL.
|
|
76
|
+
*/
|
|
77
|
+
baseURL?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Validate request and response bodies with schemas from `@kubb/plugin-zod`.
|
|
80
|
+
*
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
parser?: ParserOptions;
|
|
84
|
+
/**
|
|
85
|
+
* Generates a class-based SDK instead of the standalone functions. Each tag client is an instance
|
|
86
|
+
* class whose constructor takes a client config and builds its own client, so every environment is
|
|
87
|
+
* a separate instance. Leave `sdk` unset to keep the standalone per-operation functions (the
|
|
88
|
+
* default), which is also what query plugins consume.
|
|
89
|
+
*
|
|
90
|
+
* @example Instance class per tag
|
|
91
|
+
* ```ts
|
|
92
|
+
* pluginFetch({ sdk: {} })
|
|
93
|
+
* // const api = new PetClient({ baseURL: 'https://api.example.com' })
|
|
94
|
+
* // await api.getPetById({ path: { petId: 1 } })
|
|
95
|
+
* ```
|
|
96
|
+
* @example Composed root that instantiates every tag client from one config
|
|
97
|
+
* ```ts
|
|
98
|
+
* pluginFetch({ sdk: { name: 'petStore' } })
|
|
99
|
+
* // class PetStore {
|
|
100
|
+
* // readonly pet: PetClient
|
|
101
|
+
* // readonly store: StoreClient
|
|
102
|
+
* // constructor(config = {}) { ... }
|
|
103
|
+
* // }
|
|
104
|
+
* // const api = new PetStore({ baseURL })
|
|
105
|
+
* // await api.pet.getPetById({ path: { petId: 1 } })
|
|
106
|
+
* ```
|
|
107
|
+
* @example Flat class with every operation as a direct method
|
|
108
|
+
* ```ts
|
|
109
|
+
* pluginFetch({ sdk: { name: 'petStore', mode: 'flat' } })
|
|
110
|
+
* // const api = new PetStore({ baseURL })
|
|
111
|
+
* // await api.getPetById({ path: { petId: 1 } })
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
sdk?: {
|
|
115
|
+
/**
|
|
116
|
+
* How the SDK groups operations.
|
|
117
|
+
* - `'tag'`: one class per tag. With `name`, a composed root instantiates every tag client.
|
|
118
|
+
* - `'flat'`: one class named by `name`, with every operation as a direct method.
|
|
119
|
+
*
|
|
120
|
+
* @default 'tag'
|
|
121
|
+
*/
|
|
122
|
+
mode?: Mode;
|
|
123
|
+
/**
|
|
124
|
+
* Name of the generated entry point, also the file name. With `mode: 'tag'` it emits a
|
|
125
|
+
* composed root class that instantiates every tag client from one shared config. With
|
|
126
|
+
* `mode: 'flat'` it names the single class.
|
|
127
|
+
*/
|
|
128
|
+
name?: string;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Override how names and file paths are built. Methods you omit fall back to the default resolver.
|
|
132
|
+
*/
|
|
133
|
+
resolver?: Partial<ResolverClient> & ThisType<ResolverClient>;
|
|
134
|
+
/**
|
|
135
|
+
* Macros applied to each operation node before code is printed.
|
|
136
|
+
*/
|
|
137
|
+
macros?: Array<ast.Macro>;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* The resolved options after defaults are applied.
|
|
141
|
+
*/
|
|
142
|
+
type ResolvedOptions$1 = {
|
|
143
|
+
output: Output;
|
|
144
|
+
exclude: Array<Exclude>;
|
|
145
|
+
include: Array<Include> | undefined;
|
|
146
|
+
override: Array<Override<ResolvedOptions$1>>;
|
|
147
|
+
group: Group | null;
|
|
148
|
+
baseURL: Options$1['baseURL'];
|
|
149
|
+
parser: NonNullable<Options$1['parser']>;
|
|
150
|
+
sdk: {
|
|
151
|
+
mode: Mode;
|
|
152
|
+
name: string | undefined;
|
|
153
|
+
} | undefined;
|
|
154
|
+
resolver: ResolverClient;
|
|
155
|
+
};
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region ../../internals/client/src/resolveClient.d.ts
|
|
158
|
+
/**
|
|
159
|
+
* Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
|
|
160
|
+
* operation, shared so the selection rules and diagnostics stay in one place.
|
|
161
|
+
*
|
|
162
|
+
* Every client runtime lives in a dedicated client plugin, so a consumer always calls a registered
|
|
163
|
+
* contract client plugin (plugin-fetch or plugin-axios) and never emits its own inline client:
|
|
164
|
+
*
|
|
165
|
+
* - `contract` — a registered contract client plugin owns the `<op>` functions and the consumer
|
|
166
|
+
* imports and calls them.
|
|
167
|
+
* - `error` — no client plugin is registered, several are registered without a selector, or the
|
|
168
|
+
* requested one is missing.
|
|
169
|
+
*
|
|
170
|
+
* The `client` string selects explicitly (`'fetch'` / `'axios'`); when it is unset a lone registered
|
|
171
|
+
* contract client plugin is picked up automatically.
|
|
172
|
+
*/
|
|
173
|
+
/**
|
|
174
|
+
* The client selector accepted by a consumer's `client` option. Both call a registered contract
|
|
175
|
+
* client plugin.
|
|
176
|
+
*/
|
|
177
|
+
type ClientSelector = 'fetch' | 'axios';
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region ../../internals/tanstack-query/src/types.d.ts
|
|
180
|
+
type ParamsCasing = 'camelcase' | undefined;
|
|
181
|
+
type Transformer = (props: {
|
|
182
|
+
node: ast.OperationNode;
|
|
183
|
+
casing: ParamsCasing;
|
|
184
|
+
}) => Array<unknown>;
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/types.d.ts
|
|
187
|
+
/**
|
|
188
|
+
* Resolver for React Query that provides naming methods for hook functions.
|
|
189
|
+
*/
|
|
190
|
+
type ResolverReactQuery = Resolver & {
|
|
191
|
+
/**
|
|
192
|
+
* Resolves the base function name for an operation.
|
|
193
|
+
*
|
|
194
|
+
* @example Resolving base operation names
|
|
195
|
+
* `resolver.resolveName('show pet by id') // -> 'showPetById'`
|
|
196
|
+
*/
|
|
197
|
+
resolveName(this: ResolverReactQuery, name: string): string;
|
|
198
|
+
/**
|
|
199
|
+
* Resolves the output file name for a hook module.
|
|
200
|
+
*/
|
|
201
|
+
resolvePathName(this: ResolverReactQuery, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
|
|
202
|
+
/**
|
|
203
|
+
* Resolves a query hook function name.
|
|
204
|
+
*/
|
|
205
|
+
resolveQueryName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
206
|
+
/**
|
|
207
|
+
* Resolves a suspense query hook function name.
|
|
208
|
+
*/
|
|
209
|
+
resolveSuspenseQueryName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
210
|
+
/**
|
|
211
|
+
* Resolves an infinite query hook function name.
|
|
212
|
+
*/
|
|
213
|
+
resolveInfiniteQueryName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
214
|
+
/**
|
|
215
|
+
* Resolves a suspense infinite query hook function name.
|
|
216
|
+
*/
|
|
217
|
+
resolveSuspenseInfiniteQueryName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
218
|
+
/**
|
|
219
|
+
* Resolves a mutation hook function name.
|
|
220
|
+
*/
|
|
221
|
+
resolveMutationName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
222
|
+
/**
|
|
223
|
+
* Resolves the query options helper name.
|
|
224
|
+
*/
|
|
225
|
+
resolveQueryOptionsName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
226
|
+
/**
|
|
227
|
+
* Resolves the suspense query options helper name.
|
|
228
|
+
*/
|
|
229
|
+
resolveSuspenseQueryOptionsName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
230
|
+
/**
|
|
231
|
+
* Resolves the infinite query options helper name.
|
|
232
|
+
*/
|
|
233
|
+
resolveInfiniteQueryOptionsName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
234
|
+
/**
|
|
235
|
+
* Resolves the suspense infinite query options helper name.
|
|
236
|
+
*/
|
|
237
|
+
resolveSuspenseInfiniteQueryOptionsName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
238
|
+
/**
|
|
239
|
+
* Resolves the mutation options helper name.
|
|
240
|
+
*/
|
|
241
|
+
resolveMutationOptionsName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
242
|
+
/**
|
|
243
|
+
* Resolves the query key helper name.
|
|
244
|
+
*/
|
|
245
|
+
resolveQueryKeyName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
246
|
+
/**
|
|
247
|
+
* Resolves the suspense query key helper name.
|
|
248
|
+
*/
|
|
249
|
+
resolveSuspenseQueryKeyName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
250
|
+
/**
|
|
251
|
+
* Resolves the infinite query key helper name.
|
|
252
|
+
*/
|
|
253
|
+
resolveInfiniteQueryKeyName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
254
|
+
/**
|
|
255
|
+
* Resolves the suspense infinite query key helper name.
|
|
256
|
+
*/
|
|
257
|
+
resolveSuspenseInfiniteQueryKeyName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
258
|
+
/**
|
|
259
|
+
* Resolves the mutation key helper name.
|
|
260
|
+
*/
|
|
261
|
+
resolveMutationKeyName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
262
|
+
/**
|
|
263
|
+
* Resolves the query key type name.
|
|
264
|
+
*/
|
|
265
|
+
resolveQueryKeyTypeName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
266
|
+
/**
|
|
267
|
+
* Resolves the suspense query key type name.
|
|
268
|
+
*/
|
|
269
|
+
resolveSuspenseQueryKeyTypeName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
270
|
+
/**
|
|
271
|
+
* Resolves the infinite query key type name.
|
|
272
|
+
*/
|
|
273
|
+
resolveInfiniteQueryKeyTypeName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
274
|
+
/**
|
|
275
|
+
* Resolves the suspense infinite query key type name.
|
|
276
|
+
*/
|
|
277
|
+
resolveSuspenseInfiniteQueryKeyTypeName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
278
|
+
/**
|
|
279
|
+
* Resolves the mutation type name.
|
|
280
|
+
*/
|
|
281
|
+
resolveMutationTypeName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
282
|
+
/**
|
|
283
|
+
* Resolves the client function name generated inline by query hooks.
|
|
284
|
+
*/
|
|
285
|
+
resolveClientName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
286
|
+
/**
|
|
287
|
+
* Resolves the client function name generated inline by suspense query hooks.
|
|
288
|
+
*/
|
|
289
|
+
resolveSuspenseClientName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
290
|
+
/**
|
|
291
|
+
* Resolves the client function name generated inline by infinite query hooks.
|
|
292
|
+
*/
|
|
293
|
+
resolveInfiniteClientName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
294
|
+
/**
|
|
295
|
+
* Resolves the client function name generated inline by suspense infinite query hooks.
|
|
296
|
+
*/
|
|
297
|
+
resolveSuspenseInfiniteClientName(this: ResolverReactQuery, node: ast.OperationNode): string;
|
|
298
|
+
/**
|
|
299
|
+
* Resolves the generated custom hook options map type name.
|
|
300
|
+
*/
|
|
301
|
+
resolveHookOptionsName(this: ResolverReactQuery): string;
|
|
302
|
+
/**
|
|
303
|
+
* Resolves the helper function name used inside the custom hook options file.
|
|
304
|
+
*/
|
|
305
|
+
resolveCustomHookOptionsName(this: ResolverReactQuery): string;
|
|
306
|
+
};
|
|
307
|
+
type Suspense = object;
|
|
308
|
+
/**
|
|
309
|
+
* Builds the `queryKey` used by each generated query hook.
|
|
310
|
+
*
|
|
311
|
+
* @note String values are inlined verbatim into generated code. Wrap literal
|
|
312
|
+
* strings in `JSON.stringify(...)`.
|
|
313
|
+
*/
|
|
314
|
+
type QueryKey = Transformer;
|
|
315
|
+
/**
|
|
316
|
+
* Builds the `mutationKey` used by each generated mutation hook.
|
|
317
|
+
*
|
|
318
|
+
* @note String values are inlined verbatim into generated code. Wrap literal
|
|
319
|
+
* strings in `JSON.stringify(...)`.
|
|
320
|
+
*/
|
|
321
|
+
type MutationKey = Transformer;
|
|
322
|
+
type Query = {
|
|
323
|
+
/**
|
|
324
|
+
* HTTP methods treated as queries. Operations using these methods produce
|
|
325
|
+
* `useQuery`-style hooks.
|
|
326
|
+
*
|
|
327
|
+
* @default ['get']
|
|
328
|
+
*/
|
|
329
|
+
methods?: Array<string>;
|
|
330
|
+
/**
|
|
331
|
+
* Module specifier used in the `import { useQuery } from '...'` statement at
|
|
332
|
+
* the top of every generated hook file. Useful for routing through a wrapper
|
|
333
|
+
* that injects a default `queryClient`.
|
|
334
|
+
*
|
|
335
|
+
* @default '@tanstack/react-query'
|
|
336
|
+
*/
|
|
337
|
+
importPath?: string;
|
|
338
|
+
};
|
|
339
|
+
type Mutation = {
|
|
340
|
+
/**
|
|
341
|
+
* HTTP methods treated as mutations. Operations using these methods produce
|
|
342
|
+
* `useMutation`-style hooks.
|
|
343
|
+
*
|
|
344
|
+
* @default ['post', 'put', 'delete']
|
|
345
|
+
*/
|
|
346
|
+
methods?: Array<string>;
|
|
347
|
+
/**
|
|
348
|
+
* Module specifier used in the `import { useMutation } from '...'` statement
|
|
349
|
+
* at the top of every generated hook file.
|
|
350
|
+
*
|
|
351
|
+
* @default '@tanstack/react-query'
|
|
352
|
+
*/
|
|
353
|
+
importPath?: string;
|
|
354
|
+
};
|
|
355
|
+
type Infinite = {
|
|
356
|
+
/**
|
|
357
|
+
* Name of the query parameter that holds the page cursor.
|
|
358
|
+
*
|
|
359
|
+
* @default 'id'
|
|
360
|
+
*/
|
|
361
|
+
queryParam?: string;
|
|
362
|
+
/**
|
|
363
|
+
* Path to the cursor field on the response. Leave undefined when the cursor
|
|
364
|
+
* is not known.
|
|
365
|
+
*
|
|
366
|
+
* @deprecated Use `nextParam` and `previousParam` for richer pagination control.
|
|
367
|
+
*/
|
|
368
|
+
cursorParam?: string | null;
|
|
369
|
+
/**
|
|
370
|
+
* Path to the next-page cursor on the response. Supports dot notation
|
|
371
|
+
* (`'pagination.next.id'`) or array form (`['pagination', 'next', 'id']`).
|
|
372
|
+
*/
|
|
373
|
+
nextParam?: string | Array<string> | null;
|
|
374
|
+
/**
|
|
375
|
+
* Path to the previous-page cursor on the response. Supports dot notation
|
|
376
|
+
* or array form.
|
|
377
|
+
*/
|
|
378
|
+
previousParam?: string | Array<string> | null;
|
|
379
|
+
/**
|
|
380
|
+
* Initial value for `pageParam` on the first fetch.
|
|
381
|
+
*
|
|
382
|
+
* @default 0
|
|
383
|
+
*/
|
|
384
|
+
initialPageParam?: unknown;
|
|
385
|
+
};
|
|
386
|
+
type CustomOptions = {
|
|
387
|
+
/**
|
|
388
|
+
* Module specifier of your custom-options hook. Imported as
|
|
389
|
+
* `import ${name} from '${importPath}'`.
|
|
390
|
+
*/
|
|
391
|
+
importPath: string;
|
|
392
|
+
/**
|
|
393
|
+
* Exported function name of your custom-options hook.
|
|
394
|
+
*
|
|
395
|
+
* @default 'useCustomHookOptions'
|
|
396
|
+
*/
|
|
397
|
+
name?: string;
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* Where the generated hooks are written and how they are exported, plus the optional `group`
|
|
401
|
+
* strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
|
|
402
|
+
*
|
|
403
|
+
* @default { path: 'hooks', barrel: { type: 'named' } }
|
|
404
|
+
*/
|
|
405
|
+
type Options = OutputOptions & {
|
|
406
|
+
/**
|
|
407
|
+
* Selects the HTTP client the generated hooks call. Every client plugin speaks the `RequestResult`
|
|
408
|
+
* contract, so the hooks call a contract `<op>` that takes one grouped `options` object.
|
|
409
|
+
*
|
|
410
|
+
* `'fetch'` / `'axios'` calls the `@kubb/plugin-fetch` / `@kubb/plugin-axios` functions. When a
|
|
411
|
+
* single client plugin (plugin-fetch or plugin-axios) is registered it is
|
|
412
|
+
* auto-detected, so the string is only needed to disambiguate several client plugins.
|
|
413
|
+
*
|
|
414
|
+
* A client plugin must be registered. The hooks always call its `<op>`.
|
|
415
|
+
*/
|
|
416
|
+
client?: ClientSelector;
|
|
417
|
+
/**
|
|
418
|
+
* Skip operations matching at least one entry in the list.
|
|
419
|
+
*/
|
|
420
|
+
exclude?: Array<Exclude>;
|
|
421
|
+
/**
|
|
422
|
+
* Restrict generation to operations matching at least one entry in the list.
|
|
423
|
+
*/
|
|
424
|
+
include?: Array<Include>;
|
|
425
|
+
/**
|
|
426
|
+
* Apply a different options object to operations matching a pattern.
|
|
427
|
+
*/
|
|
428
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
429
|
+
/**
|
|
430
|
+
* Enables `useInfiniteQuery` hooks for cursor- or page-based pagination.
|
|
431
|
+
* Pass an object to configure how the cursor is read; pass `false` to skip.
|
|
432
|
+
*
|
|
433
|
+
* @default false
|
|
434
|
+
*/
|
|
435
|
+
infinite?: Partial<Infinite> | false;
|
|
436
|
+
/**
|
|
437
|
+
* Adds `useSuspenseQuery` hooks alongside the regular `useQuery` ones.
|
|
438
|
+
* Pass an empty object (`{}`) to enable. TanStack Query v5+ only.
|
|
439
|
+
*/
|
|
440
|
+
suspense?: Partial<Suspense> | false;
|
|
441
|
+
/**
|
|
442
|
+
* Custom `queryKey` builder. Use to add a version namespace, swap to
|
|
443
|
+
* operation IDs, or shape keys to match an existing invalidation strategy.
|
|
444
|
+
*/
|
|
445
|
+
queryKey?: QueryKey;
|
|
446
|
+
/**
|
|
447
|
+
* Configures query hooks. Set to `false` to skip generating hooks entirely
|
|
448
|
+
* and emit only `queryOptions(...)` helpers.
|
|
449
|
+
*/
|
|
450
|
+
query?: Partial<Query> | false;
|
|
451
|
+
/**
|
|
452
|
+
* Custom `mutationKey` builder. Useful when you batch invalidations or read
|
|
453
|
+
* mutation state via `useMutationState`.
|
|
454
|
+
*/
|
|
455
|
+
mutationKey?: MutationKey;
|
|
456
|
+
/**
|
|
457
|
+
* Configures mutation hooks. Set to `false` to skip mutation generation.
|
|
458
|
+
*/
|
|
459
|
+
mutation?: Partial<Mutation> | false;
|
|
460
|
+
/**
|
|
461
|
+
* Wires every generated hook through a user-supplied function that returns
|
|
462
|
+
* extra options (`onSuccess`, `onError`, `select`, ...). Also emits a
|
|
463
|
+
* `HookOptions` type so the wrapper stays in sync with generated hooks.
|
|
464
|
+
*/
|
|
465
|
+
customOptions?: CustomOptions;
|
|
466
|
+
/**
|
|
467
|
+
* Validator applied to response bodies before they reach the caller.
|
|
468
|
+
* - `'client'` — no validation. Trusts the API.
|
|
469
|
+
* - `'zod'` — pipes responses through schemas from `@kubb/plugin-zod`.
|
|
470
|
+
*/
|
|
471
|
+
parser?: Options$1['parser'];
|
|
472
|
+
/**
|
|
473
|
+
* Override how hook names and file paths are built. Methods you omit fall
|
|
474
|
+
* back to the default `resolverReactQuery`.
|
|
475
|
+
*/
|
|
476
|
+
resolver?: Partial<ResolverReactQuery> & ThisType<ResolverReactQuery>;
|
|
477
|
+
/**
|
|
478
|
+
* Macros applied to each operation node before printing.
|
|
479
|
+
*/
|
|
480
|
+
macros?: Array<ast.Macro>;
|
|
481
|
+
};
|
|
482
|
+
/**
|
|
483
|
+
* The resolved client strategy for the generated hooks, computed once during setup. The hooks always
|
|
484
|
+
* import and call a registered contract client plugin's `<op>`.
|
|
485
|
+
*/
|
|
486
|
+
type ResolvedClient = {
|
|
487
|
+
kind: 'contract';
|
|
488
|
+
pluginName: string;
|
|
489
|
+
};
|
|
490
|
+
type ResolvedOptions = {
|
|
491
|
+
output: Output;
|
|
492
|
+
group: Group | null;
|
|
493
|
+
exclude: NonNullable<Options['exclude']>;
|
|
494
|
+
include: Options['include'];
|
|
495
|
+
override: NonNullable<Options['override']>;
|
|
496
|
+
/**
|
|
497
|
+
* The resolved contract client the generators import and call.
|
|
498
|
+
*/
|
|
499
|
+
client: ResolvedClient;
|
|
500
|
+
parser: NonNullable<Options['parser']>;
|
|
501
|
+
/**
|
|
502
|
+
* Only used for infinite
|
|
503
|
+
*/
|
|
504
|
+
infinite: NonNullable<Infinite> | false;
|
|
505
|
+
suspense: Suspense | false;
|
|
506
|
+
queryKey: QueryKey | null;
|
|
507
|
+
query: NonNullable<Required<Query>> | false;
|
|
508
|
+
mutationKey: MutationKey | null;
|
|
509
|
+
mutation: NonNullable<Required<Mutation>> | false;
|
|
510
|
+
customOptions: NonNullable<Required<CustomOptions>> | null;
|
|
511
|
+
resolver: ResolverReactQuery;
|
|
512
|
+
};
|
|
513
|
+
type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options, ResolvedOptions, ResolverReactQuery>;
|
|
514
|
+
declare global {
|
|
515
|
+
namespace Kubb {
|
|
516
|
+
interface PluginRegistry {
|
|
517
|
+
'plugin-react-query': PluginReactQuery;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
//#endregion
|
|
4
522
|
//#region src/plugin.d.ts
|
|
5
523
|
/**
|
|
6
524
|
* Canonical plugin name for `@kubb/plugin-react-query`. Used for driver lookups
|