@kubb/plugin-vue-query 5.0.0-beta.64 → 5.0.0-beta.73

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.d.ts CHANGED
@@ -1,6 +1,433 @@
1
- import { t as __name } from "./chunk-C0LytTxp.js";
2
- import { n as Options, r as PluginVueQuery } from "./types-C6a_58nb.js";
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 src/types.d.ts
180
+ type Transformer = (props: {
181
+ node: ast.OperationNode;
182
+ casing: 'camelcase' | undefined;
183
+ }) => Array<unknown>;
184
+ /**
185
+ * Resolver for Vue Query that provides naming methods for hook functions.
186
+ */
187
+ type ResolverVueQuery = Resolver & {
188
+ /**
189
+ * Resolves the base function name for an operation.
190
+ */
191
+ resolveName(this: ResolverVueQuery, name: string): string;
192
+ /**
193
+ * Resolves the output file name for a hook module.
194
+ */
195
+ resolvePathName(this: ResolverVueQuery, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
196
+ /**
197
+ * Resolves a query hook function name.
198
+ */
199
+ resolveQueryName(this: ResolverVueQuery, node: ast.OperationNode): string;
200
+ /**
201
+ * Resolves an infinite query hook function name.
202
+ */
203
+ resolveInfiniteQueryName(this: ResolverVueQuery, node: ast.OperationNode): string;
204
+ /**
205
+ * Resolves a mutation hook function name.
206
+ */
207
+ resolveMutationName(this: ResolverVueQuery, node: ast.OperationNode): string;
208
+ /**
209
+ * Resolves the query options helper name.
210
+ */
211
+ resolveQueryOptionsName(this: ResolverVueQuery, node: ast.OperationNode): string;
212
+ /**
213
+ * Resolves the infinite query options helper name.
214
+ */
215
+ resolveInfiniteQueryOptionsName(this: ResolverVueQuery, node: ast.OperationNode): string;
216
+ /**
217
+ * Resolves the query key helper name.
218
+ */
219
+ resolveQueryKeyName(this: ResolverVueQuery, node: ast.OperationNode): string;
220
+ /**
221
+ * Resolves the infinite query key helper name.
222
+ */
223
+ resolveInfiniteQueryKeyName(this: ResolverVueQuery, node: ast.OperationNode): string;
224
+ /**
225
+ * Resolves the mutation key helper name.
226
+ */
227
+ resolveMutationKeyName(this: ResolverVueQuery, node: ast.OperationNode): string;
228
+ /**
229
+ * Resolves the query key type name.
230
+ */
231
+ resolveQueryKeyTypeName(this: ResolverVueQuery, node: ast.OperationNode): string;
232
+ /**
233
+ * Resolves the infinite query key type name.
234
+ */
235
+ resolveInfiniteQueryKeyTypeName(this: ResolverVueQuery, node: ast.OperationNode): string;
236
+ /**
237
+ * Resolves the mutation type name.
238
+ */
239
+ resolveMutationTypeName(this: ResolverVueQuery, node: ast.OperationNode): string;
240
+ /**
241
+ * Resolves the client function name generated inline by query hooks.
242
+ */
243
+ resolveClientName(this: ResolverVueQuery, node: ast.OperationNode): string;
244
+ /**
245
+ * Resolves the client function name generated inline by infinite query hooks.
246
+ */
247
+ resolveInfiniteClientName(this: ResolverVueQuery, node: ast.OperationNode): string;
248
+ };
249
+ /**
250
+ * Builds the `queryKey` used by each generated query composable.
251
+ *
252
+ * @note String values are inlined verbatim into generated code. Wrap literal
253
+ * strings in `JSON.stringify(...)`.
254
+ */
255
+ type QueryKey = Transformer;
256
+ /**
257
+ * Builds the `mutationKey` used by each generated mutation composable.
258
+ *
259
+ * @note String values are inlined verbatim into generated code. Wrap literal
260
+ * strings in `JSON.stringify(...)`.
261
+ */
262
+ type MutationKey = Transformer;
263
+ type Query = {
264
+ /**
265
+ * HTTP methods treated as queries.
266
+ *
267
+ * @default ['get']
268
+ */
269
+ methods?: Array<string>;
270
+ /**
271
+ * Module specifier used in the `import { useQuery } from '...'` statement at
272
+ * the top of every generated composable file.
273
+ *
274
+ * @default '@tanstack/vue-query'
275
+ */
276
+ importPath?: string;
277
+ };
278
+ type Mutation = {
279
+ /**
280
+ * HTTP methods treated as mutations.
281
+ *
282
+ * @default ['post', 'put', 'delete']
283
+ */
284
+ methods?: Array<string>;
285
+ /**
286
+ * Module specifier used in the `import { useMutation } from '...'` statement
287
+ * at the top of every generated composable file.
288
+ *
289
+ * @default '@tanstack/vue-query'
290
+ */
291
+ importPath?: string;
292
+ };
293
+ type Infinite = {
294
+ /**
295
+ * Name of the query parameter that holds the page cursor.
296
+ *
297
+ * @default 'id'
298
+ */
299
+ queryParam?: string;
300
+ /**
301
+ * Path to the cursor field on the response. Leave undefined when the cursor
302
+ * is not known.
303
+ *
304
+ * @deprecated Use `nextParam` and `previousParam` for richer pagination control.
305
+ */
306
+ cursorParam?: string | null;
307
+ /**
308
+ * Path to the next-page cursor on the response. Supports dot notation
309
+ * (`'pagination.next.id'`) or array form.
310
+ */
311
+ nextParam?: string | Array<string> | null;
312
+ /**
313
+ * Path to the previous-page cursor on the response. Supports dot notation
314
+ * or array form.
315
+ */
316
+ previousParam?: string | Array<string> | null;
317
+ /**
318
+ * Initial value for `pageParam` on the first fetch.
319
+ *
320
+ * @default 0
321
+ */
322
+ initialPageParam?: unknown;
323
+ };
324
+ /**
325
+ * Where the generated composables are written and how they are exported, plus the optional
326
+ * `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
327
+ *
328
+ * @default { path: 'hooks', barrel: { type: 'named' } }
329
+ */
330
+ type Options = OutputOptions & {
331
+ /**
332
+ * Selects the HTTP client the generated composables call. Every client plugin speaks the `RequestResult`
333
+ * contract, so the composables call a contract `<op>` that takes one grouped `options` object.
334
+ *
335
+ * - `'fetch'` / `'axios'` calls the `@kubb/plugin-fetch` / `@kubb/plugin-axios` functions. When a
336
+ * single client plugin (plugin-fetch or plugin-axios) is registered it is
337
+ * auto-detected, so the string is only needed to disambiguate several client plugins.
338
+ *
339
+ * A client plugin must be registered. The composables always call its `<op>`.
340
+ */
341
+ client?: ClientSelector;
342
+ /**
343
+ * Skip operations matching at least one entry in the list.
344
+ */
345
+ exclude?: Array<Exclude>;
346
+ /**
347
+ * Restrict generation to operations matching at least one entry in the list.
348
+ */
349
+ include?: Array<Include>;
350
+ /**
351
+ * Apply a different options object to operations matching a pattern.
352
+ */
353
+ override?: Array<Override<ResolvedOptions>>;
354
+ /**
355
+ * Enables `useInfiniteQuery` composables for cursor- or page-based pagination.
356
+ * Pass an object to configure how the cursor is read; pass `false` to skip.
357
+ *
358
+ * @default false
359
+ */
360
+ infinite?: Partial<Infinite> | false;
361
+ /**
362
+ * Custom `queryKey` builder.
363
+ */
364
+ queryKey?: QueryKey;
365
+ /**
366
+ * Configures query composables. Set to `false` to skip composable generation
367
+ * and emit only `queryOptions(...)` helpers.
368
+ */
369
+ query?: Partial<Query> | false;
370
+ /**
371
+ * Custom `mutationKey` builder.
372
+ */
373
+ mutationKey?: MutationKey;
374
+ /**
375
+ * Configures mutation composables. Set to `false` to skip mutation generation.
376
+ */
377
+ mutation?: Partial<Mutation> | false;
378
+ /**
379
+ * Validator applied to response bodies before they reach the caller.
380
+ * - `'client'` — no validation.
381
+ * - `'zod'` — pipes responses through schemas from `@kubb/plugin-zod`.
382
+ */
383
+ parser?: Options$1['parser'];
384
+ /**
385
+ * Override how composable names and file paths are built.
386
+ */
387
+ resolver?: Partial<ResolverVueQuery> & ThisType<ResolverVueQuery>;
388
+ /**
389
+ * Macros applied to each operation node before printing.
390
+ */
391
+ macros?: Array<ast.Macro>;
392
+ };
393
+ /**
394
+ * The resolved client strategy for the generated composables, computed once during setup. The
395
+ * composables always import and call a registered contract client plugin's `<op>`.
396
+ */
397
+ type ResolvedClient = {
398
+ kind: 'contract';
399
+ pluginName: string;
400
+ };
401
+ type ResolvedOptions = {
402
+ output: Output;
403
+ group: Group | null;
404
+ exclude: NonNullable<Options['exclude']>;
405
+ include: Options['include'];
406
+ override: NonNullable<Options['override']>;
407
+ /**
408
+ * The resolved contract client the generators import and call.
409
+ */
410
+ client: ResolvedClient;
411
+ parser: NonNullable<Options['parser']>;
412
+ /**
413
+ * Only used for infinite
414
+ */
415
+ infinite: NonNullable<Infinite> | false;
416
+ queryKey: QueryKey | null;
417
+ query: NonNullable<Required<Query>> | false;
418
+ mutationKey: MutationKey | null;
419
+ mutation: NonNullable<Required<Mutation>> | false;
420
+ resolver: ResolverVueQuery;
421
+ };
422
+ type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, ResolverVueQuery>;
423
+ declare global {
424
+ namespace Kubb {
425
+ interface PluginRegistry {
426
+ 'plugin-vue-query': PluginVueQuery;
427
+ }
428
+ }
429
+ }
430
+ //#endregion
4
431
  //#region src/plugin.d.ts
5
432
  /**
6
433
  * Canonical plugin name for `@kubb/plugin-vue-query`. Used for driver lookups