@kubb/plugin-react-query 5.0.0-beta.79 → 5.0.0-beta.81
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 +193 -279
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +18 -170
- package/dist/index.js +193 -279
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,161 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
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 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 and query parameters 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
|
-
* The resolver shared by the client plugins. Functions and files use camelCase; URL helpers get
|
|
25
|
-
* a `get<Operation>Url` name.
|
|
26
|
-
*/
|
|
27
|
-
type ResolverClient = Resolver & {
|
|
28
|
-
/**
|
|
29
|
-
* Resolves the function name for a raw operation name.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* `resolver.resolveName('show pet by id') // -> 'showPetById'`
|
|
33
|
-
*/
|
|
34
|
-
resolveName(this: ResolverClient, name: string): string;
|
|
35
|
-
/**
|
|
36
|
-
* Resolves the output file name for a generated client module.
|
|
37
|
-
*/
|
|
38
|
-
resolvePathName(this: ResolverClient, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
|
|
39
|
-
/**
|
|
40
|
-
* Resolves the generated class name for class-based clients.
|
|
41
|
-
*/
|
|
42
|
-
resolveClassName(this: ResolverClient, name: string): string;
|
|
43
|
-
/**
|
|
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.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* `resolver.resolveGroupName('pet') // -> 'PetClient'`
|
|
50
|
-
*/
|
|
51
|
-
resolveGroupName(this: ResolverClient, name: string): string;
|
|
52
|
-
/**
|
|
53
|
-
* Resolves the property name a tag client is exposed under on the composed root SDK
|
|
54
|
-
* (`new PetStore(config).pet`).
|
|
55
|
-
*/
|
|
56
|
-
resolveClientPropertyName(this: ResolverClient, name: string): string;
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
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.
|
|
62
|
-
*/
|
|
63
|
-
type Options$1 = OutputOptions & {
|
|
64
|
-
/**
|
|
65
|
-
* Skip operations matching at least one entry in the list.
|
|
66
|
-
*/
|
|
67
|
-
exclude?: Array<Exclude>;
|
|
68
|
-
/**
|
|
69
|
-
* Restrict generation to operations matching at least one entry in the list.
|
|
70
|
-
*/
|
|
71
|
-
include?: Array<Include>;
|
|
72
|
-
/**
|
|
73
|
-
* Apply a different options object to operations matching a pattern.
|
|
74
|
-
*/
|
|
75
|
-
override?: Array<Override<ResolvedOptions$1>>;
|
|
76
|
-
/**
|
|
77
|
-
* Base URL prepended to every request. When omitted, falls back to the adapter's server URL.
|
|
78
|
-
*/
|
|
79
|
-
baseURL?: string;
|
|
80
|
-
/**
|
|
81
|
-
* Validate request and response bodies with schemas from `@kubb/plugin-zod`.
|
|
82
|
-
*
|
|
83
|
-
* @default false
|
|
84
|
-
*/
|
|
85
|
-
validator?: ValidatorOptions;
|
|
86
|
-
/**
|
|
87
|
-
* Generates a class-based SDK instead of the standalone functions. Each tag client is an instance
|
|
88
|
-
* class whose constructor takes a client config and builds its own client, so every environment is
|
|
89
|
-
* a separate instance. Leave `sdk` unset to keep the standalone per-operation functions (the
|
|
90
|
-
* default), which is also what query plugins consume.
|
|
91
|
-
*
|
|
92
|
-
* @example Instance class per tag
|
|
93
|
-
* ```ts
|
|
94
|
-
* pluginFetch({ sdk: {} })
|
|
95
|
-
* // const api = new PetClient({ baseURL: 'https://api.example.com' })
|
|
96
|
-
* // await api.getPetById({ path: { petId: 1 } })
|
|
97
|
-
* ```
|
|
98
|
-
* @example Composed root that instantiates every tag client from one config
|
|
99
|
-
* ```ts
|
|
100
|
-
* pluginFetch({ sdk: { name: 'petStore' } })
|
|
101
|
-
* // class PetStore {
|
|
102
|
-
* // readonly pet: PetClient
|
|
103
|
-
* // readonly store: StoreClient
|
|
104
|
-
* // constructor(config = {}) { ... }
|
|
105
|
-
* // }
|
|
106
|
-
* // const api = new PetStore({ baseURL })
|
|
107
|
-
* // await api.pet.getPetById({ path: { petId: 1 } })
|
|
108
|
-
* ```
|
|
109
|
-
* @example Flat class with every operation as a direct method
|
|
110
|
-
* ```ts
|
|
111
|
-
* pluginFetch({ sdk: { name: 'petStore', mode: 'flat' } })
|
|
112
|
-
* // const api = new PetStore({ baseURL })
|
|
113
|
-
* // await api.getPetById({ path: { petId: 1 } })
|
|
114
|
-
* ```
|
|
115
|
-
*/
|
|
116
|
-
sdk?: {
|
|
117
|
-
/**
|
|
118
|
-
* How the SDK groups operations.
|
|
119
|
-
* - `'tag'`: one class per tag. With `name`, a composed root instantiates every tag client.
|
|
120
|
-
* - `'flat'`: one class named by `name`, with every operation as a direct method.
|
|
121
|
-
*
|
|
122
|
-
* @default 'tag'
|
|
123
|
-
*/
|
|
124
|
-
mode?: Mode;
|
|
125
|
-
/**
|
|
126
|
-
* Name of the generated entry point, also the file name. With `mode: 'tag'` it emits a
|
|
127
|
-
* composed root class that instantiates every tag client from one shared config. With
|
|
128
|
-
* `mode: 'flat'` it names the single class.
|
|
129
|
-
*/
|
|
130
|
-
name?: string;
|
|
131
|
-
};
|
|
132
|
-
/**
|
|
133
|
-
* Override how names and file paths are built. Methods you omit fall back to the default resolver.
|
|
134
|
-
*/
|
|
135
|
-
resolver?: Partial<ResolverClient> & ThisType<ResolverClient>;
|
|
136
|
-
/**
|
|
137
|
-
* Macros applied to each operation node before code is printed.
|
|
138
|
-
*/
|
|
139
|
-
macros?: Array<ast.Macro>;
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* The resolved options after defaults are applied.
|
|
143
|
-
*/
|
|
144
|
-
type ResolvedOptions$1 = {
|
|
145
|
-
output: Output;
|
|
146
|
-
exclude: Array<Exclude>;
|
|
147
|
-
include: Array<Include> | undefined;
|
|
148
|
-
override: Array<Override<ResolvedOptions$1>>;
|
|
149
|
-
group: Group | null;
|
|
150
|
-
baseURL: Options$1['baseURL'];
|
|
151
|
-
validator: NonNullable<Options$1['validator']>;
|
|
152
|
-
sdk: {
|
|
153
|
-
mode: Mode;
|
|
154
|
-
name: string | undefined;
|
|
155
|
-
} | undefined;
|
|
156
|
-
resolver: ResolverClient;
|
|
157
|
-
};
|
|
158
|
-
//#endregion
|
|
159
3
|
//#region ../../internals/client/src/resolveClient.d.ts
|
|
160
4
|
/**
|
|
161
5
|
* Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
|
|
@@ -343,7 +187,7 @@ type Mutation = {
|
|
|
343
187
|
* HTTP methods treated as mutations. Operations using these methods produce
|
|
344
188
|
* `useMutation`-style hooks.
|
|
345
189
|
*
|
|
346
|
-
* @default ['post', 'put', 'delete']
|
|
190
|
+
* @default ['post', 'put', 'patch', 'delete']
|
|
347
191
|
*/
|
|
348
192
|
methods?: Array<string>;
|
|
349
193
|
/**
|
|
@@ -387,8 +231,8 @@ type Infinite = {
|
|
|
387
231
|
};
|
|
388
232
|
type CustomOptions = {
|
|
389
233
|
/**
|
|
390
|
-
* Module specifier of your custom-options hook. Imported as
|
|
391
|
-
* `import ${name} from '${importPath}'`.
|
|
234
|
+
* Module specifier of your custom-options hook. Imported as a named import,
|
|
235
|
+
* `import { ${name} } from '${importPath}'`.
|
|
392
236
|
*/
|
|
393
237
|
importPath: string;
|
|
394
238
|
/**
|
|
@@ -430,7 +274,7 @@ type Options = OutputOptions & {
|
|
|
430
274
|
override?: Array<Override<ResolvedOptions>>;
|
|
431
275
|
/**
|
|
432
276
|
* Enables `useInfiniteQuery` hooks for cursor- or page-based pagination.
|
|
433
|
-
* Pass an object to configure how the cursor is read
|
|
277
|
+
* Pass an object to configure how the cursor is read, or pass `false` to skip.
|
|
434
278
|
*
|
|
435
279
|
* @default false
|
|
436
280
|
*/
|
|
@@ -465,17 +309,21 @@ type Options = OutputOptions & {
|
|
|
465
309
|
* `HookOptions` type so the wrapper stays in sync with generated hooks.
|
|
466
310
|
*/
|
|
467
311
|
customOptions?: CustomOptions;
|
|
468
|
-
/**
|
|
469
|
-
* Validator applied to response bodies before they reach the caller.
|
|
470
|
-
* - `'client'` — no validation. Trusts the API.
|
|
471
|
-
* - `'zod'` — pipes responses through schemas from `@kubb/plugin-zod`.
|
|
472
|
-
*/
|
|
473
|
-
validator?: Options$1['validator'];
|
|
474
312
|
/**
|
|
475
313
|
* Override how hook names and file paths are built. Methods you omit fall
|
|
476
314
|
* back to the default `resolverReactQuery`.
|
|
477
315
|
*/
|
|
478
316
|
resolver?: Partial<ResolverReactQuery> & ThisType<ResolverReactQuery>;
|
|
317
|
+
/**
|
|
318
|
+
* Set to `false` to skip generating `use*` hook functions. `queryOptions`,
|
|
319
|
+
* `mutationOptions`, `queryKey`, and `mutationKey` helpers are still emitted.
|
|
320
|
+
* The resulting output uses only `@tanstack/react-query` factory imports
|
|
321
|
+
* (`queryOptions`, `infiniteQueryOptions`, `mutationOptions`) that are
|
|
322
|
+
* adapter-portable across React, Vue, Solid, and Svelte.
|
|
323
|
+
*
|
|
324
|
+
* @default false
|
|
325
|
+
*/
|
|
326
|
+
hooks?: boolean;
|
|
479
327
|
/**
|
|
480
328
|
* Macros applied to each operation node before printing.
|
|
481
329
|
*/
|
|
@@ -499,9 +347,8 @@ type ResolvedOptions = {
|
|
|
499
347
|
* The resolved contract client the generators import and call.
|
|
500
348
|
*/
|
|
501
349
|
client: ResolvedClient;
|
|
502
|
-
validator: NonNullable<Options['validator']>;
|
|
503
350
|
/**
|
|
504
|
-
*
|
|
351
|
+
* Resolved infinite query configuration, or `false` when infinite queries are disabled.
|
|
505
352
|
*/
|
|
506
353
|
infinite: NonNullable<Infinite> | false;
|
|
507
354
|
suspense: Suspense | false;
|
|
@@ -510,6 +357,7 @@ type ResolvedOptions = {
|
|
|
510
357
|
mutationKey: MutationKey | null;
|
|
511
358
|
mutation: NonNullable<Required<Mutation>> | false;
|
|
512
359
|
customOptions: NonNullable<Required<CustomOptions>> | null;
|
|
360
|
+
hooks: boolean;
|
|
513
361
|
resolver: ResolverReactQuery;
|
|
514
362
|
};
|
|
515
363
|
type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options, ResolvedOptions, ResolverReactQuery>;
|
|
@@ -529,8 +377,8 @@ declare global {
|
|
|
529
377
|
declare const pluginReactQueryName = "plugin-react-query";
|
|
530
378
|
/**
|
|
531
379
|
* Generates one TanStack Query hook per OpenAPI operation for React. Queries
|
|
532
|
-
* become `
|
|
533
|
-
* become `
|
|
380
|
+
* become `useFoo`, with `useFooSuspense` and `useFooInfinite` variants.
|
|
381
|
+
* Mutations become `useFoo`. Each hook is fully typed: query keys, input
|
|
534
382
|
* variables, response data, and error shape all come from the spec.
|
|
535
383
|
*
|
|
536
384
|
* @example
|