@kubb/plugin-vue-query 5.0.0-beta.80 → 5.0.0-beta.84
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 +180 -277
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +14 -173
- package/dist/index.js +113 -210
- package/dist/index.js.map +1 -1
- package/package.json +4 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,161 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "
|
|
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
|
|
2
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "kubb/kit";
|
|
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;
|
|
@@ -266,7 +114,7 @@ type Query = {
|
|
|
266
114
|
/**
|
|
267
115
|
* HTTP methods treated as queries.
|
|
268
116
|
*
|
|
269
|
-
* @default ['
|
|
117
|
+
* @default ['GET']
|
|
270
118
|
*/
|
|
271
119
|
methods?: Array<string>;
|
|
272
120
|
/**
|
|
@@ -281,7 +129,7 @@ type Mutation = {
|
|
|
281
129
|
/**
|
|
282
130
|
* HTTP methods treated as mutations.
|
|
283
131
|
*
|
|
284
|
-
* @default ['
|
|
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,19 +225,13 @@ 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>;
|
|
390
232
|
/**
|
|
391
233
|
* Set to `false` to skip generating `use*` composable functions. `queryOptions`,
|
|
392
|
-
* `
|
|
234
|
+
* `queryKey`, and `mutationKey` helpers are still emitted.
|
|
393
235
|
*
|
|
394
236
|
* @default false
|
|
395
237
|
*/
|
|
@@ -417,9 +259,8 @@ type ResolvedOptions = {
|
|
|
417
259
|
* The resolved contract client the generators import and call.
|
|
418
260
|
*/
|
|
419
261
|
client: ResolvedClient;
|
|
420
|
-
validator: NonNullable<Options['validator']>;
|
|
421
262
|
/**
|
|
422
|
-
*
|
|
263
|
+
* Resolved infinite query configuration, or `false` when infinite queries are disabled.
|
|
423
264
|
*/
|
|
424
265
|
infinite: NonNullable<Infinite> | false;
|
|
425
266
|
queryKey: QueryKey | null;
|
|
@@ -446,13 +287,13 @@ declare global {
|
|
|
446
287
|
declare const pluginVueQueryName = "plugin-vue-query";
|
|
447
288
|
/**
|
|
448
289
|
* Generates one TanStack Query composable per OpenAPI operation for Vue's
|
|
449
|
-
* Composition API. Queries become `
|
|
450
|
-
* `
|
|
290
|
+
* Composition API. Queries become `useFoo` (and optionally
|
|
291
|
+
* `useFooInfinite`). Mutations become `useFoo` as well. Each composable
|
|
451
292
|
* is fully typed end to end.
|
|
452
293
|
*
|
|
453
294
|
* @example
|
|
454
295
|
* ```ts
|
|
455
|
-
* import { defineConfig } from 'kubb'
|
|
296
|
+
* import { defineConfig } from 'kubb/config'
|
|
456
297
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
457
298
|
* import { pluginVueQuery } from '@kubb/plugin-vue-query'
|
|
458
299
|
*
|
|
@@ -468,7 +309,7 @@ declare const pluginVueQueryName = "plugin-vue-query";
|
|
|
468
309
|
* })
|
|
469
310
|
* ```
|
|
470
311
|
*/
|
|
471
|
-
declare const pluginVueQuery: (options?: Options | undefined) => import("
|
|
312
|
+
declare const pluginVueQuery: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginVueQuery>;
|
|
472
313
|
//#endregion
|
|
473
314
|
export { type PluginVueQuery, pluginVueQuery as default, pluginVueQuery, pluginVueQueryName };
|
|
474
315
|
//# sourceMappingURL=index.d.ts.map
|