@kubb/plugin-vue-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 +139 -225
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +16 -167
- package/dist/index.js +139 -225
- package/dist/index.js.map +1 -1
- package/package.json +8 -9
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
|
|
@@ -179,6 +23,10 @@ type ResolvedOptions$1 = {
|
|
|
179
23
|
type ClientSelector = 'fetch' | 'axios';
|
|
180
24
|
//#endregion
|
|
181
25
|
//#region src/types.d.ts
|
|
26
|
+
/**
|
|
27
|
+
* Builds the parts of a query or mutation key for one operation. Receives the operation node and
|
|
28
|
+
* the resolved `paramsCasing` setting and returns the key elements in order.
|
|
29
|
+
*/
|
|
182
30
|
type Transformer = (props: {
|
|
183
31
|
node: ast.OperationNode;
|
|
184
32
|
casing: 'camelcase' | undefined;
|
|
@@ -281,7 +129,7 @@ type Mutation = {
|
|
|
281
129
|
/**
|
|
282
130
|
* HTTP methods treated as mutations.
|
|
283
131
|
*
|
|
284
|
-
* @default ['post', 'put', 'delete']
|
|
132
|
+
* @default ['post', 'put', 'patch', 'delete']
|
|
285
133
|
*/
|
|
286
134
|
methods?: Array<string>;
|
|
287
135
|
/**
|
|
@@ -355,7 +203,7 @@ type Options = OutputOptions & {
|
|
|
355
203
|
override?: Array<Override<ResolvedOptions>>;
|
|
356
204
|
/**
|
|
357
205
|
* Enables `useInfiniteQuery` composables for cursor- or page-based pagination.
|
|
358
|
-
* Pass an object to configure how the cursor is read
|
|
206
|
+
* Pass an object to configure how the cursor is read, or pass `false` to skip.
|
|
359
207
|
*
|
|
360
208
|
* @default false
|
|
361
209
|
*/
|
|
@@ -377,16 +225,17 @@ type Options = OutputOptions & {
|
|
|
377
225
|
* Configures mutation composables. Set to `false` to skip mutation generation.
|
|
378
226
|
*/
|
|
379
227
|
mutation?: Partial<Mutation> | false;
|
|
380
|
-
/**
|
|
381
|
-
* Validator applied to response bodies before they reach the caller.
|
|
382
|
-
* - `'client'` — no validation.
|
|
383
|
-
* - `'zod'` — pipes responses through schemas from `@kubb/plugin-zod`.
|
|
384
|
-
*/
|
|
385
|
-
validator?: Options$1['validator'];
|
|
386
228
|
/**
|
|
387
229
|
* Override how composable names and file paths are built.
|
|
388
230
|
*/
|
|
389
231
|
resolver?: Partial<ResolverVueQuery> & ThisType<ResolverVueQuery>;
|
|
232
|
+
/**
|
|
233
|
+
* Set to `false` to skip generating `use*` composable functions. `queryOptions`,
|
|
234
|
+
* `queryKey`, and `mutationKey` helpers are still emitted.
|
|
235
|
+
*
|
|
236
|
+
* @default false
|
|
237
|
+
*/
|
|
238
|
+
hooks?: boolean;
|
|
390
239
|
/**
|
|
391
240
|
* Macros applied to each operation node before printing.
|
|
392
241
|
*/
|
|
@@ -410,15 +259,15 @@ type ResolvedOptions = {
|
|
|
410
259
|
* The resolved contract client the generators import and call.
|
|
411
260
|
*/
|
|
412
261
|
client: ResolvedClient;
|
|
413
|
-
validator: NonNullable<Options['validator']>;
|
|
414
262
|
/**
|
|
415
|
-
*
|
|
263
|
+
* Resolved infinite query configuration, or `false` when infinite queries are disabled.
|
|
416
264
|
*/
|
|
417
265
|
infinite: NonNullable<Infinite> | false;
|
|
418
266
|
queryKey: QueryKey | null;
|
|
419
267
|
query: NonNullable<Required<Query>> | false;
|
|
420
268
|
mutationKey: MutationKey | null;
|
|
421
269
|
mutation: NonNullable<Required<Mutation>> | false;
|
|
270
|
+
hooks: boolean;
|
|
422
271
|
resolver: ResolverVueQuery;
|
|
423
272
|
};
|
|
424
273
|
type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, ResolverVueQuery>;
|
|
@@ -439,7 +288,7 @@ declare const pluginVueQueryName = "plugin-vue-query";
|
|
|
439
288
|
/**
|
|
440
289
|
* Generates one TanStack Query composable per OpenAPI operation for Vue's
|
|
441
290
|
* Composition API. Queries become `useFooQuery` (and optionally
|
|
442
|
-
* `useFooInfiniteQuery`)
|
|
291
|
+
* `useFooInfiniteQuery`). Mutations become `useFooMutation`. Each composable
|
|
443
292
|
* is fully typed end to end.
|
|
444
293
|
*
|
|
445
294
|
* @example
|