@kubb/plugin-vue-query 5.5.1 → 5.5.3

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 CHANGED
@@ -341,11 +341,11 @@ function createGroupConfig(group) {
341
341
  //#region kubb-extension.json
342
342
  var compatibility = {
343
343
  "kubb": ">=5.8.3",
344
- "node": ">=22"
344
+ "node": ">=22.12"
345
345
  };
346
346
  //#endregion
347
347
  //#region package.json
348
- var version = "5.5.1";
348
+ var version = "5.5.3";
349
349
  //#endregion
350
350
  //#region ../../internals/tanstack-query/src/components/HookFile.tsx
351
351
  /**
@@ -0,0 +1,401 @@
1
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
2
+ import "@kubb/plugin-zod";
3
+ import "@kubb/plugin-ts";
4
+ import "kubb/jsx";
5
+ //#region ../../internals/client/src/resolveClient.d.ts
6
+ /**
7
+ * The client selector accepted by a consumer's `client` option. Each calls a registered contract
8
+ * client plugin.
9
+ */
10
+ type ClientSelector = 'fetch' | 'axios' | 'client';
11
+ /**
12
+ * The resolved client strategy stored in a consumer plugin's options: the generated code always
13
+ * imports and calls a registered contract client plugin's `<op>`. The client runtime lives in
14
+ * plugin-axios / plugin-fetch, so nothing is bundled by the consumer.
15
+ */
16
+ type ResolvedContractClient = {
17
+ kind: 'contract';
18
+ pluginName: string;
19
+ };
20
+ //#endregion
21
+ //#region ../../internals/tanstack-query/src/types.d.ts
22
+ type ParamsCasing = 'camelcase' | undefined;
23
+ /**
24
+ * The hook a key is built for. Plain and suspense queries can share a key, but an infinite query
25
+ * caches `InfiniteData` and must never share one with a plain query.
26
+ */
27
+ type KeyVariant = 'query' | 'suspenseQuery' | 'infiniteQuery' | 'suspenseInfiniteQuery' | 'mutation';
28
+ /**
29
+ * Builds query or mutation key segments for an operation node.
30
+ * Receives `variant` indicating which hook or composable the key is built for.
31
+ */
32
+ type Transformer = (props: {
33
+ node: ast.OperationNode;
34
+ casing: ParamsCasing;
35
+ variant: KeyVariant;
36
+ }) => Array<unknown>;
37
+ /**
38
+ * Configures the query side of a TanStack-family plugin: which HTTP methods produce query
39
+ * hooks and where the query runtime is imported from.
40
+ */
41
+ type Query = {
42
+ /**
43
+ * HTTP methods treated as queries. Operations using these methods produce
44
+ * `useQuery`-style hooks.
45
+ *
46
+ * @default ['GET', 'QUERY']
47
+ */
48
+ methods?: Array<string>;
49
+ /**
50
+ * Module specifier used in the `import { useQuery } from '...'` statement at
51
+ * the top of every generated file. Each plugin defaults this to its own runtime
52
+ * package. Useful for routing through a wrapper that injects a default
53
+ * `queryClient`.
54
+ */
55
+ importPath?: string;
56
+ };
57
+ /**
58
+ * Configures the mutation side of a TanStack-family plugin: which HTTP methods produce
59
+ * mutation hooks and where the mutation runtime is imported from.
60
+ */
61
+ type Mutation = {
62
+ /**
63
+ * HTTP methods treated as mutations. Operations using these methods produce
64
+ * `useMutation`-style hooks.
65
+ *
66
+ * @default ['POST', 'PUT', 'PATCH', 'DELETE']
67
+ */
68
+ methods?: Array<string>;
69
+ /**
70
+ * Module specifier used in the `import { useMutation } from '...'` statement
71
+ * at the top of every generated file. Each plugin defaults this to its own
72
+ * runtime package.
73
+ */
74
+ importPath?: string;
75
+ };
76
+ type Infinite = {
77
+ /**
78
+ * Name of the query parameter that holds the page cursor.
79
+ *
80
+ * @default 'id'
81
+ */
82
+ queryParam?: string;
83
+ /**
84
+ * Path to the cursor field on the response. Leave undefined when the cursor
85
+ * is not known.
86
+ *
87
+ * @deprecated Use `nextParam` and `previousParam` for richer pagination control.
88
+ */
89
+ cursorParam?: string | null;
90
+ /**
91
+ * Path to the next-page cursor on the response. Supports dot notation
92
+ * (`'pagination.next.id'`) or array form (`['pagination', 'next', 'id']`).
93
+ */
94
+ nextParam?: string | Array<string> | null;
95
+ /**
96
+ * Path to the previous-page cursor on the response. Supports dot notation
97
+ * or array form.
98
+ */
99
+ previousParam?: string | Array<string> | null;
100
+ /**
101
+ * Initial value for `pageParam` on the first fetch.
102
+ *
103
+ * @default 0
104
+ */
105
+ initialPageParam?: unknown;
106
+ /**
107
+ * Whether `initialPageParam` was explicitly configured rather than defaulted.
108
+ * When omitted or false, the default previous page threshold remains 1 (legacy 1-based default).
109
+ */
110
+ hasExplicitInitialPageParam?: boolean;
111
+ /**
112
+ * Source of TanStack Query's `getNextPageParam`, inlined verbatim as a function expression. Use it
113
+ * when the next page has to be computed rather than read from a field. Takes precedence over
114
+ * `nextParam` and `cursorParam`.
115
+ *
116
+ * Note: Because functions are inlined verbatim into generated code via `.toString()`, they cannot
117
+ * reference local closures or external variables from the config file.
118
+ *
119
+ * @example
120
+ * `'(lastPage) => (lastPage.hasNext ? lastPage.number + 1 : undefined)'`
121
+ * // or with definePageParam:
122
+ * `definePageParam<MyResponse, number>((lastPage) => (lastPage.hasNext ? lastPage.number + 1 : undefined))`
123
+ */
124
+ getNextPageParam?: string | PageParamFn | null;
125
+ /**
126
+ * Source of TanStack Query's `getPreviousPageParam`, inlined verbatim as a function expression.
127
+ * Takes precedence over `previousParam` and `cursorParam`.
128
+ *
129
+ * Note: Because functions are inlined verbatim into generated code via `.toString()`, they cannot
130
+ * reference local closures or external variables from the config file.
131
+ *
132
+ * @example
133
+ * `'(firstPage) => (firstPage.number > 0 ? firstPage.number - 1 : undefined)'`
134
+ * // or with definePageParam:
135
+ * `definePageParam<MyResponse, number>((firstPage) => (firstPage.number > 0 ? firstPage.number - 1 : undefined))`
136
+ */
137
+ getPreviousPageParam?: string | PageParamFn | null;
138
+ };
139
+ type PageParamFn<TPage = any, TParam = any> = (page: TPage, allPages: Array<TPage>, pageParam: TParam, allPageParams: Array<TParam>) => TParam | undefined | null;
140
+ //#endregion
141
+ //#region ../../internals/tanstack-query/src/utils.d.ts
142
+ /**
143
+ * Helper to define a typed page param function for `infinite.getNextPageParam` or
144
+ * `infinite.getPreviousPageParam`. Serializes the function to a string for inlining in generated code.
145
+ *
146
+ * Note: Because the function is inlined verbatim into the generated file via `.toString()`,
147
+ * it must be self-contained and cannot reference local closures or external variables from
148
+ * the config file.
149
+ */
150
+ export declare function definePageParam<TPage = any, TParam = any>(fn: PageParamFn<TPage, TParam>): string;
151
+ //#endregion
152
+ //#region src/types.d.ts
153
+ /**
154
+ * Resolver for Vue Query that provides naming methods for hook functions.
155
+ */
156
+ type ResolverVueQuery = Resolver & {
157
+ /**
158
+ * Names for a query operation: its `useQuery` composable, key helpers, options helper, and the
159
+ * inline client function it calls.
160
+ */
161
+ query: {
162
+ /**
163
+ * Resolves a query hook function name.
164
+ */
165
+ name(node: ast.OperationNode): string;
166
+ /**
167
+ * Resolves the query key helper name.
168
+ */
169
+ keyName(node: ast.OperationNode): string;
170
+ /**
171
+ * Resolves the query key type name.
172
+ */
173
+ keyTypeName(node: ast.OperationNode): string;
174
+ /**
175
+ * Resolves the query options helper name.
176
+ */
177
+ optionsName(node: ast.OperationNode): string;
178
+ /**
179
+ * Resolves the client function name generated inline by query hooks.
180
+ */
181
+ clientName(node: ast.OperationNode): string;
182
+ };
183
+ /**
184
+ * Names for an infinite query operation: its `useInfiniteQuery` composable, key helpers, options
185
+ * helper, and the inline client function it calls.
186
+ */
187
+ infiniteQuery: {
188
+ /**
189
+ * Resolves an infinite query hook function name.
190
+ */
191
+ name(node: ast.OperationNode): string;
192
+ /**
193
+ * Resolves the infinite query key helper name.
194
+ */
195
+ keyName(node: ast.OperationNode): string;
196
+ /**
197
+ * Resolves the infinite query key type name.
198
+ */
199
+ keyTypeName(node: ast.OperationNode): string;
200
+ /**
201
+ * Resolves the infinite query options helper name.
202
+ */
203
+ optionsName(node: ast.OperationNode): string;
204
+ /**
205
+ * Resolves the client function name generated inline by infinite query hooks.
206
+ */
207
+ clientName(node: ast.OperationNode): string;
208
+ };
209
+ /**
210
+ * Names for a mutation operation: its `useMutation` composable, key helper, and type name.
211
+ */
212
+ mutation: {
213
+ /**
214
+ * Resolves a mutation hook function name.
215
+ */
216
+ name(node: ast.OperationNode): string;
217
+ /**
218
+ * Resolves the mutation key helper name.
219
+ */
220
+ keyName(node: ast.OperationNode): string;
221
+ /**
222
+ * Resolves the mutation type name.
223
+ */
224
+ typeName(node: ast.OperationNode): string;
225
+ };
226
+ };
227
+ /**
228
+ * Builds the `queryKey` used by each generated query composable. `variant` tells which composable
229
+ * the key is for, so infinite keys can stay apart from plain ones.
230
+ *
231
+ * @note String values are inlined verbatim into generated code. Wrap literal
232
+ * strings in `JSON.stringify(...)`.
233
+ */
234
+ type QueryKey = Transformer;
235
+ /**
236
+ * Builds the `mutationKey` used by each generated mutation composable.
237
+ *
238
+ * @note String values are inlined verbatim into generated code. Wrap literal
239
+ * strings in `JSON.stringify(...)`.
240
+ */
241
+ type MutationKey = Transformer;
242
+ /**
243
+ * Where the generated composables are written and how they are exported, plus the optional
244
+ * `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
245
+ *
246
+ * @default { path: 'hooks', barrel: { type: 'named' } }
247
+ */
248
+ type Options = OutputOptions & {
249
+ /**
250
+ * Selects the HTTP client the generated composables call. Every client plugin speaks the `RequestResult`
251
+ * contract, so the composables call a contract `<op>` that takes one grouped `options` object.
252
+ *
253
+ * - `'fetch'` / `'axios'` / `'client'` calls the `@kubb/plugin-fetch` / `@kubb/plugin-axios` /
254
+ * `@kubb/plugin-client` functions. When a single client plugin is registered it is
255
+ * auto-detected, so the string is only needed to disambiguate several client plugins.
256
+ *
257
+ * A client plugin must be registered. The composables always call its `<op>`.
258
+ */
259
+ client?: ClientSelector;
260
+ /**
261
+ * Skip operations matching at least one entry in the list.
262
+ */
263
+ exclude?: Array<Exclude>;
264
+ /**
265
+ * Restrict generation to operations matching at least one entry in the list.
266
+ */
267
+ include?: Array<Include>;
268
+ /**
269
+ * Apply a different options object to operations matching a pattern.
270
+ */
271
+ override?: Array<Override<ResolvedOptions>>;
272
+ /**
273
+ * Enables `useInfiniteQuery` composables for cursor- or page-based pagination.
274
+ * Pass an object to configure how the cursor is read, or pass `false` to skip.
275
+ *
276
+ * @default false
277
+ */
278
+ infinite?: Partial<Infinite> | false;
279
+ /**
280
+ * Custom `queryKey` builder.
281
+ */
282
+ queryKey?: QueryKey;
283
+ /**
284
+ * Configures query composables. Set to `false` to skip composable generation
285
+ * and emit only `queryOptions(...)` helpers.
286
+ */
287
+ query?: Partial<Query> | false;
288
+ /**
289
+ * Custom `mutationKey` builder.
290
+ */
291
+ mutationKey?: MutationKey;
292
+ /**
293
+ * Configures mutation composables. Set to `false` to skip mutation generation.
294
+ */
295
+ mutation?: Partial<Mutation> | false;
296
+ /**
297
+ * Override how composable names and file paths are built.
298
+ */
299
+ resolver?: ResolverPatch<ResolverVueQuery>;
300
+ /**
301
+ * Set to `true` to also generate `use*` composable functions. By default only the
302
+ * `queryOptions`, `queryKey`, and `mutationKey` helpers are emitted.
303
+ *
304
+ * @default false
305
+ */
306
+ hooks?: boolean;
307
+ /**
308
+ * Macros applied to each operation node before printing.
309
+ */
310
+ macros?: Array<ast.Macro>;
311
+ };
312
+ /**
313
+ * The resolved client strategy for the generated composables, computed once during setup. The
314
+ * composables always import and call a registered contract client plugin's `<op>`.
315
+ */
316
+ type ResolvedClient = ResolvedContractClient;
317
+ type ResolvedOptions = {
318
+ output: Output;
319
+ group: Group | null;
320
+ exclude: NonNullable<Options['exclude']>;
321
+ include: Options['include'];
322
+ override: NonNullable<Options['override']>;
323
+ /**
324
+ * The resolved contract client the generators import and call.
325
+ */
326
+ client: ResolvedClient;
327
+ /**
328
+ * Resolved infinite query configuration, or `false` when infinite queries are disabled.
329
+ */
330
+ infinite: NonNullable<Infinite> | false;
331
+ queryKey: QueryKey | null;
332
+ query: NonNullable<Required<Query>> | false;
333
+ mutationKey: MutationKey | null;
334
+ mutation: NonNullable<Required<Mutation>> | false;
335
+ hooks: boolean;
336
+ resolver: ResolverVueQuery;
337
+ };
338
+ type PluginVueQuery = PluginType<'plugin-vue-query', Options, ResolvedOptions, ResolverVueQuery>;
339
+ declare global {
340
+ namespace Kubb {
341
+ interface PluginRegistry {
342
+ 'plugin-vue-query': PluginVueQuery;
343
+ }
344
+ }
345
+ }
346
+ //#endregion
347
+ //#region src/plugin.d.ts
348
+ /**
349
+ * Canonical plugin name for `@kubb/plugin-vue-query`. Used for driver lookups
350
+ * and cross-plugin dependency references.
351
+ */
352
+ export declare const pluginVueQueryName = "plugin-vue-query";
353
+ /**
354
+ * Generates one TanStack Query composable per OpenAPI operation for Vue's
355
+ * Composition API. Queries become `useFoo` (and optionally
356
+ * `useFooInfinite`). Mutations become `useFoo` as well. Each composable
357
+ * is fully typed end to end.
358
+ *
359
+ * @example
360
+ * ```ts
361
+ * import { defineConfig } from 'kubb/config'
362
+ * import { pluginTs } from '@kubb/plugin-ts'
363
+ * import { pluginVueQuery } from '@kubb/plugin-vue-query'
364
+ *
365
+ * export default defineConfig({
366
+ * input: './petStore.yaml',
367
+ * output: { path: './src/gen' },
368
+ * plugins: [
369
+ * pluginTs(),
370
+ * pluginVueQuery({
371
+ * output: { path: './hooks' },
372
+ * }),
373
+ * ],
374
+ * })
375
+ * ```
376
+ */
377
+ export declare const pluginVueQuery: import("kubb/kit").PluginFactory<PluginVueQuery>;
378
+ //#endregion
379
+ //#region src/resolvers/resolverVueQuery.d.ts
380
+ /**
381
+ * Default resolver used by `@kubb/plugin-vue-query`. Decides the names and
382
+ * file paths for every generated TanStack Query composable (`useFoo`,
383
+ * `useFooInfinite`) and its companion helpers.
384
+ *
385
+ * The `default` helpers are supplied by `createResolver`. Functions and files use camelCase;
386
+ * composables get the `use` prefix. Operation-specific naming is grouped under the `query`,
387
+ * `infiniteQuery`, and `mutation` namespaces.
388
+ *
389
+ * @example Resolve composable and helper names
390
+ * ```ts
391
+ * import { resolverVueQuery } from '@kubb/plugin-vue-query'
392
+ *
393
+ * resolverVueQuery.query.name(operationNode) // 'useGetPetById'
394
+ * resolverVueQuery.query.keyName(operationNode) // 'getPetByIdQueryKey'
395
+ * resolverVueQuery.query.optionsName(operationNode) // 'getPetByIdQueryOptions'
396
+ * ```
397
+ */
398
+ export declare const resolverVueQuery: ResolverVueQuery;
399
+ //#endregion
400
+ export { type PageParamFn, type PluginVueQuery, type ResolverVueQuery, pluginVueQuery as default };
401
+ //# sourceMappingURL=index.d.cts.map
package/dist/index.d.ts CHANGED
@@ -1,8 +1,7 @@
1
- import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
- import { Diagnostics, Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
1
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginType, Resolver, ResolverPatch, ast } from "kubb/kit";
2
+ import "@kubb/plugin-zod";
3
3
  import "@kubb/plugin-ts";
4
4
  import "kubb/jsx";
5
- import "@kubb/plugin-zod";
6
5
  //#region ../../internals/client/src/resolveClient.d.ts
7
6
  /**
8
7
  * The client selector accepted by a consumer's `client` option. Each calls a registered contract
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import "./rolldown-runtime-C0LytTxp.js";
2
1
  import { Diagnostics, Resolver, Url, addGenerator, ast, createResolver, defineExtension, defineGenerator, setMacros, setResolver, useConfig } from "kubb/kit";
3
2
  import path from "node:path";
4
3
  import { createFunctionParameter, createFunctionParameters, createObjectBindingPattern, createTypeLiteral, functionPrinter, pluginTsName } from "@kubb/plugin-ts";
5
4
  import { File, Function, Type, jsxRenderer } from "kubb/jsx";
6
5
  import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
6
+ //#endregion
7
7
  //#region ../../internals/shared/src/operation.ts
8
8
  /**
9
9
  * Builds the `ResolverFileParams` every operation generator passes to
@@ -315,11 +315,11 @@ function createGroupConfig(group) {
315
315
  //#region kubb-extension.json
316
316
  var compatibility = {
317
317
  "kubb": ">=5.8.3",
318
- "node": ">=22"
318
+ "node": ">=22.12"
319
319
  };
320
320
  //#endregion
321
321
  //#region package.json
322
- var version = "5.5.1";
322
+ var version = "5.5.3";
323
323
  //#endregion
324
324
  //#region ../../internals/tanstack-query/src/components/HookFile.tsx
325
325
  /**
@@ -20,7 +20,7 @@
20
20
  "dependencies": ["plugin-ts"],
21
21
  "compatibility": {
22
22
  "kubb": ">=5.8.3",
23
- "node": ">=22"
23
+ "node": ">=22.12"
24
24
  },
25
25
  "role": "consumer",
26
26
  "options": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-vue-query",
3
- "version": "5.5.1",
3
+ "version": "5.5.3",
4
4
  "description": "Generate type-safe TanStack Query (Vue Query) composables with Kubb. Covers useQuery, useMutation, useInfiniteQuery, and queryOptions with Vue 3 Composition API support.",
5
5
  "keywords": [
6
6
  "code-generation",
@@ -66,9 +66,14 @@
66
66
  },
67
67
  "exports": {
68
68
  ".": {
69
- "types": "./dist/index.d.ts",
70
- "import": "./dist/index.js",
71
- "require": "./dist/index.cjs"
69
+ "import": {
70
+ "types": "./dist/index.d.ts",
71
+ "default": "./dist/index.js"
72
+ },
73
+ "require": {
74
+ "types": "./dist/index.d.cts",
75
+ "default": "./dist/index.cjs"
76
+ }
72
77
  },
73
78
  "./package.json": "./package.json",
74
79
  "./kubb-extension.json": "./kubb-extension.json"
@@ -78,7 +83,7 @@
78
83
  "registry": "https://registry.npmjs.org/"
79
84
  },
80
85
  "dependencies": {
81
- "@kubb/plugin-ts": "^5.0.12"
86
+ "@kubb/plugin-ts": "^5.0.14"
82
87
  },
83
88
  "devDependencies": {
84
89
  "@internals/client": "0.0.0",
@@ -86,12 +91,12 @@
86
91
  "@internals/tanstack-query": "0.0.0",
87
92
  "@internals/utils": "0.0.0",
88
93
  "@tanstack/vue-query": "^5.104.2",
89
- "kubb": "^5.10.2",
94
+ "kubb": "^5.10.3",
90
95
  "vue": "^3.5.43"
91
96
  },
92
97
  "peerDependencies": {
93
98
  "@tanstack/vue-query": "^5.41.0",
94
- "kubb": "^5.10.2",
99
+ "kubb": "^5.10.3",
95
100
  "vue": ">=3.3.0"
96
101
  },
97
102
  "peerDependenciesMeta": {
@@ -103,7 +108,7 @@
103
108
  }
104
109
  },
105
110
  "engines": {
106
- "node": ">=22"
111
+ "node": ">=22.12"
107
112
  },
108
113
  "scripts": {
109
114
  "build": "tsdown",
@@ -1,8 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __defProp = Object.defineProperty;
3
- var __name = (target, value) => __defProp(target, "name", {
4
- value,
5
- configurable: true
6
- });
7
- //#endregion
8
- export { __name as t };