@kubb/plugin-vue-query 5.0.0-alpha.9 → 5.0.0-beta.100

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.
Files changed (39) hide show
  1. package/LICENSE +17 -10
  2. package/README.md +38 -23
  3. package/dist/index.cjs +1651 -140
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.ts +358 -6
  6. package/dist/index.js +1618 -138
  7. package/dist/index.js.map +1 -1
  8. package/package.json +48 -76
  9. package/dist/components-Yjoe78Y7.cjs +0 -1119
  10. package/dist/components-Yjoe78Y7.cjs.map +0 -1
  11. package/dist/components-_AMBl0g-.js +0 -1029
  12. package/dist/components-_AMBl0g-.js.map +0 -1
  13. package/dist/components.cjs +0 -9
  14. package/dist/components.d.ts +0 -242
  15. package/dist/components.js +0 -2
  16. package/dist/generators-CR34GjVu.js +0 -661
  17. package/dist/generators-CR34GjVu.js.map +0 -1
  18. package/dist/generators-DH8VkK1q.cjs +0 -678
  19. package/dist/generators-DH8VkK1q.cjs.map +0 -1
  20. package/dist/generators.cjs +0 -5
  21. package/dist/generators.d.ts +0 -511
  22. package/dist/generators.js +0 -2
  23. package/dist/types-CgDFUvfZ.d.ts +0 -211
  24. package/src/components/InfiniteQuery.tsx +0 -208
  25. package/src/components/InfiniteQueryOptions.tsx +0 -249
  26. package/src/components/Mutation.tsx +0 -185
  27. package/src/components/MutationKey.tsx +0 -1
  28. package/src/components/Query.tsx +0 -208
  29. package/src/components/QueryKey.tsx +0 -94
  30. package/src/components/QueryOptions.tsx +0 -185
  31. package/src/components/index.ts +0 -7
  32. package/src/generators/index.ts +0 -3
  33. package/src/generators/infiniteQueryGenerator.tsx +0 -213
  34. package/src/generators/mutationGenerator.tsx +0 -176
  35. package/src/generators/queryGenerator.tsx +0 -191
  36. package/src/index.ts +0 -2
  37. package/src/plugin.ts +0 -218
  38. package/src/types.ts +0 -176
  39. /package/dist/{chunk--u3MIqq1.js → rolldown-runtime-C0LytTxp.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,10 +1,362 @@
1
- import { t as __name } from "./chunk--u3MIqq1.js";
2
- import { n as Options, r as PluginVueQuery } from "./types-CgDFUvfZ.js";
3
- import * as _kubb_core0 from "@kubb/core";
4
-
1
+ import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
2
+ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ResolverPatch, ast } from "kubb/kit";
3
+ import "@kubb/plugin-ts";
4
+ import "kubb/jsx";
5
+ import "@kubb/plugin-zod";
6
+ //#region ../../internals/client/src/resolveClient.d.ts
7
+ /**
8
+ * Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
9
+ * operation, shared so the selection rules and diagnostics stay in one place.
10
+ *
11
+ * Every client runtime lives in a dedicated client plugin, so a consumer always calls a registered
12
+ * contract client plugin (plugin-fetch or plugin-axios) and never emits its own inline client:
13
+ *
14
+ * - `contract` — a registered contract client plugin owns the `<op>` functions and the consumer
15
+ * imports and calls them.
16
+ * - `error` — no client plugin is registered, several are registered without a selector, or the
17
+ * requested one is missing.
18
+ *
19
+ * The `client` string selects explicitly (`'fetch'` / `'axios'`); when it is unset a lone registered
20
+ * contract client plugin is picked up automatically.
21
+ */
22
+ /**
23
+ * The client selector accepted by a consumer's `client` option. Both call a registered contract
24
+ * client plugin.
25
+ */
26
+ type ClientSelector = 'fetch' | 'axios';
27
+ /**
28
+ * The resolved client strategy stored in a consumer plugin's options: the generated code always
29
+ * imports and calls a registered contract client plugin's `<op>`. The client runtime lives in
30
+ * plugin-axios / plugin-fetch, so nothing is bundled by the consumer.
31
+ */
32
+ type ResolvedContractClient = {
33
+ kind: 'contract';
34
+ pluginName: string;
35
+ };
36
+ //#endregion
37
+ //#region ../../internals/tanstack-query/src/types.d.ts
38
+ type ParamsCasing = 'camelcase' | undefined;
39
+ type Transformer = (props: {
40
+ node: ast.OperationNode;
41
+ casing: ParamsCasing;
42
+ }) => Array<unknown>;
43
+ /**
44
+ * Configures the query side of a TanStack-family plugin: which HTTP methods produce query
45
+ * hooks and where the query runtime is imported from.
46
+ */
47
+ type Query = {
48
+ /**
49
+ * HTTP methods treated as queries. Operations using these methods produce
50
+ * `useQuery`-style hooks.
51
+ *
52
+ * @default ['GET']
53
+ */
54
+ methods?: Array<string>;
55
+ /**
56
+ * Module specifier used in the `import { useQuery } from '...'` statement at
57
+ * the top of every generated file. Each plugin defaults this to its own runtime
58
+ * package. Useful for routing through a wrapper that injects a default
59
+ * `queryClient`.
60
+ */
61
+ importPath?: string;
62
+ };
63
+ /**
64
+ * Configures the mutation side of a TanStack-family plugin: which HTTP methods produce
65
+ * mutation hooks and where the mutation runtime is imported from.
66
+ */
67
+ type Mutation = {
68
+ /**
69
+ * HTTP methods treated as mutations. Operations using these methods produce
70
+ * `useMutation`-style hooks.
71
+ *
72
+ * @default ['POST', 'PUT', 'PATCH', 'DELETE']
73
+ */
74
+ methods?: Array<string>;
75
+ /**
76
+ * Module specifier used in the `import { useMutation } from '...'` statement
77
+ * at the top of every generated file. Each plugin defaults this to its own
78
+ * runtime package.
79
+ */
80
+ importPath?: string;
81
+ };
82
+ type Infinite = {
83
+ /**
84
+ * Name of the query parameter that holds the page cursor.
85
+ *
86
+ * @default 'id'
87
+ */
88
+ queryParam?: string;
89
+ /**
90
+ * Path to the cursor field on the response. Leave undefined when the cursor
91
+ * is not known.
92
+ *
93
+ * @deprecated Use `nextParam` and `previousParam` for richer pagination control.
94
+ */
95
+ cursorParam?: string | null;
96
+ /**
97
+ * Path to the next-page cursor on the response. Supports dot notation
98
+ * (`'pagination.next.id'`) or array form (`['pagination', 'next', 'id']`).
99
+ */
100
+ nextParam?: string | Array<string> | null;
101
+ /**
102
+ * Path to the previous-page cursor on the response. Supports dot notation
103
+ * or array form.
104
+ */
105
+ previousParam?: string | Array<string> | null;
106
+ /**
107
+ * Initial value for `pageParam` on the first fetch.
108
+ *
109
+ * @default 0
110
+ */
111
+ initialPageParam?: unknown;
112
+ };
113
+ //#endregion
114
+ //#region src/types.d.ts
115
+ /**
116
+ * Resolver for Vue Query that provides naming methods for hook functions.
117
+ */
118
+ type ResolverVueQuery = Resolver & {
119
+ /**
120
+ * Names for a query operation: its `useQuery` composable, key helpers, options helper, and the
121
+ * inline client function it calls.
122
+ */
123
+ query: {
124
+ /**
125
+ * Resolves a query hook function name.
126
+ */
127
+ name(node: ast.OperationNode): string;
128
+ /**
129
+ * Resolves the query key helper name.
130
+ */
131
+ keyName(node: ast.OperationNode): string;
132
+ /**
133
+ * Resolves the query key type name.
134
+ */
135
+ keyTypeName(node: ast.OperationNode): string;
136
+ /**
137
+ * Resolves the query options helper name.
138
+ */
139
+ optionsName(node: ast.OperationNode): string;
140
+ /**
141
+ * Resolves the client function name generated inline by query hooks.
142
+ */
143
+ clientName(node: ast.OperationNode): string;
144
+ };
145
+ /**
146
+ * Names for an infinite query operation: its `useInfiniteQuery` composable, key helpers, options
147
+ * helper, and the inline client function it calls.
148
+ */
149
+ infiniteQuery: {
150
+ /**
151
+ * Resolves an infinite query hook function name.
152
+ */
153
+ name(node: ast.OperationNode): string;
154
+ /**
155
+ * Resolves the infinite query key helper name.
156
+ */
157
+ keyName(node: ast.OperationNode): string;
158
+ /**
159
+ * Resolves the infinite query key type name.
160
+ */
161
+ keyTypeName(node: ast.OperationNode): string;
162
+ /**
163
+ * Resolves the infinite query options helper name.
164
+ */
165
+ optionsName(node: ast.OperationNode): string;
166
+ /**
167
+ * Resolves the client function name generated inline by infinite query hooks.
168
+ */
169
+ clientName(node: ast.OperationNode): string;
170
+ };
171
+ /**
172
+ * Names for a mutation operation: its `useMutation` composable, key helper, and type name.
173
+ */
174
+ mutation: {
175
+ /**
176
+ * Resolves a mutation hook function name.
177
+ */
178
+ name(node: ast.OperationNode): string;
179
+ /**
180
+ * Resolves the mutation key helper name.
181
+ */
182
+ keyName(node: ast.OperationNode): string;
183
+ /**
184
+ * Resolves the mutation type name.
185
+ */
186
+ typeName(node: ast.OperationNode): string;
187
+ };
188
+ };
189
+ /**
190
+ * Builds the `queryKey` used by each generated query composable.
191
+ *
192
+ * @note String values are inlined verbatim into generated code. Wrap literal
193
+ * strings in `JSON.stringify(...)`.
194
+ */
195
+ type QueryKey = Transformer;
196
+ /**
197
+ * Builds the `mutationKey` used by each generated mutation composable.
198
+ *
199
+ * @note String values are inlined verbatim into generated code. Wrap literal
200
+ * strings in `JSON.stringify(...)`.
201
+ */
202
+ type MutationKey = Transformer;
203
+ /**
204
+ * Where the generated composables are written and how they are exported, plus the optional
205
+ * `group` strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
206
+ *
207
+ * @default { path: 'hooks', barrel: { type: 'named' } }
208
+ */
209
+ type Options = OutputOptions & {
210
+ /**
211
+ * Selects the HTTP client the generated composables call. Every client plugin speaks the `RequestResult`
212
+ * contract, so the composables call a contract `<op>` that takes one grouped `options` object.
213
+ *
214
+ * - `'fetch'` / `'axios'` calls the `@kubb/plugin-fetch` / `@kubb/plugin-axios` functions. When a
215
+ * single client plugin (plugin-fetch or plugin-axios) is registered it is
216
+ * auto-detected, so the string is only needed to disambiguate several client plugins.
217
+ *
218
+ * A client plugin must be registered. The composables always call its `<op>`.
219
+ */
220
+ client?: ClientSelector;
221
+ /**
222
+ * Skip operations matching at least one entry in the list.
223
+ */
224
+ exclude?: Array<Exclude>;
225
+ /**
226
+ * Restrict generation to operations matching at least one entry in the list.
227
+ */
228
+ include?: Array<Include>;
229
+ /**
230
+ * Apply a different options object to operations matching a pattern.
231
+ */
232
+ override?: Array<Override<ResolvedOptions>>;
233
+ /**
234
+ * Enables `useInfiniteQuery` composables for cursor- or page-based pagination.
235
+ * Pass an object to configure how the cursor is read, or pass `false` to skip.
236
+ *
237
+ * @default false
238
+ */
239
+ infinite?: Partial<Infinite> | false;
240
+ /**
241
+ * Custom `queryKey` builder.
242
+ */
243
+ queryKey?: QueryKey;
244
+ /**
245
+ * Configures query composables. Set to `false` to skip composable generation
246
+ * and emit only `queryOptions(...)` helpers.
247
+ */
248
+ query?: Partial<Query> | false;
249
+ /**
250
+ * Custom `mutationKey` builder.
251
+ */
252
+ mutationKey?: MutationKey;
253
+ /**
254
+ * Configures mutation composables. Set to `false` to skip mutation generation.
255
+ */
256
+ mutation?: Partial<Mutation> | false;
257
+ /**
258
+ * Override how composable names and file paths are built.
259
+ */
260
+ resolver?: ResolverPatch<ResolverVueQuery>;
261
+ /**
262
+ * Set to `false` to skip generating `use*` composable functions. `queryOptions`,
263
+ * `queryKey`, and `mutationKey` helpers are still emitted.
264
+ *
265
+ * @default false
266
+ */
267
+ hooks?: boolean;
268
+ /**
269
+ * Macros applied to each operation node before printing.
270
+ */
271
+ macros?: Array<ast.Macro>;
272
+ };
273
+ /**
274
+ * The resolved client strategy for the generated composables, computed once during setup. The
275
+ * composables always import and call a registered contract client plugin's `<op>`.
276
+ */
277
+ type ResolvedClient = ResolvedContractClient;
278
+ type ResolvedOptions = {
279
+ output: Output;
280
+ group: Group | null;
281
+ exclude: NonNullable<Options['exclude']>;
282
+ include: Options['include'];
283
+ override: NonNullable<Options['override']>;
284
+ /**
285
+ * The resolved contract client the generators import and call.
286
+ */
287
+ client: ResolvedClient;
288
+ /**
289
+ * Resolved infinite query configuration, or `false` when infinite queries are disabled.
290
+ */
291
+ infinite: NonNullable<Infinite> | false;
292
+ queryKey: QueryKey | null;
293
+ query: NonNullable<Required<Query>> | false;
294
+ mutationKey: MutationKey | null;
295
+ mutation: NonNullable<Required<Mutation>> | false;
296
+ hooks: boolean;
297
+ resolver: ResolverVueQuery;
298
+ };
299
+ type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, ResolverVueQuery>;
300
+ declare global {
301
+ namespace Kubb {
302
+ interface PluginRegistry {
303
+ 'plugin-vue-query': PluginVueQuery;
304
+ }
305
+ }
306
+ }
307
+ //#endregion
5
308
  //#region src/plugin.d.ts
309
+ /**
310
+ * Canonical plugin name for `@kubb/plugin-vue-query`. Used for driver lookups
311
+ * and cross-plugin dependency references.
312
+ */
6
313
  declare const pluginVueQueryName = "plugin-vue-query";
7
- declare const pluginVueQuery: (options?: Options | undefined) => _kubb_core0.UserPluginWithLifeCycle<PluginVueQuery>;
314
+ /**
315
+ * Generates one TanStack Query composable per OpenAPI operation for Vue's
316
+ * Composition API. Queries become `useFoo` (and optionally
317
+ * `useFooInfinite`). Mutations become `useFoo` as well. Each composable
318
+ * is fully typed end to end.
319
+ *
320
+ * @example
321
+ * ```ts
322
+ * import { defineConfig } from 'kubb/config'
323
+ * import { pluginTs } from '@kubb/plugin-ts'
324
+ * import { pluginVueQuery } from '@kubb/plugin-vue-query'
325
+ *
326
+ * export default defineConfig({
327
+ * input: './petStore.yaml',
328
+ * output: { path: './src/gen' },
329
+ * plugins: [
330
+ * pluginTs(),
331
+ * pluginVueQuery({
332
+ * output: { path: './hooks' },
333
+ * }),
334
+ * ],
335
+ * })
336
+ * ```
337
+ */
338
+ declare const pluginVueQuery: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginVueQuery>;
339
+ //#endregion
340
+ //#region src/resolvers/resolverVueQuery.d.ts
341
+ /**
342
+ * Default resolver used by `@kubb/plugin-vue-query`. Decides the names and
343
+ * file paths for every generated TanStack Query composable (`useFoo`,
344
+ * `useFooInfinite`) and its companion helpers.
345
+ *
346
+ * The `default` helpers are supplied by `createResolver`. Functions and files use camelCase;
347
+ * composables get the `use` prefix. Operation-specific naming is grouped under the `query`,
348
+ * `infiniteQuery`, and `mutation` namespaces.
349
+ *
350
+ * @example Resolve composable and helper names
351
+ * ```ts
352
+ * import { resolverVueQuery } from '@kubb/plugin-vue-query'
353
+ *
354
+ * resolverVueQuery.query.name(operationNode) // 'useGetPetById'
355
+ * resolverVueQuery.query.keyName(operationNode) // 'getPetByIdQueryKey'
356
+ * resolverVueQuery.query.optionsName(operationNode) // 'getPetByIdQueryOptions'
357
+ * ```
358
+ */
359
+ declare const resolverVueQuery: ResolverVueQuery;
8
360
  //#endregion
9
- export { type PluginVueQuery, pluginVueQuery, pluginVueQueryName };
361
+ export { type PluginVueQuery, type ResolverVueQuery, pluginVueQuery as default, pluginVueQuery, pluginVueQueryName, resolverVueQuery };
10
362
  //# sourceMappingURL=index.d.ts.map