@kubb/plugin-react-query 5.0.0-beta.3 → 5.0.0-beta.30

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 (48) hide show
  1. package/README.md +34 -83
  2. package/dist/{components-DTGLu4UV.js → components-CDmg-RPi.js} +275 -255
  3. package/dist/components-CDmg-RPi.js.map +1 -0
  4. package/dist/{components-dAKJEn9b.cjs → components-MPBTffPl.cjs} +299 -255
  5. package/dist/components-MPBTffPl.cjs.map +1 -0
  6. package/dist/components.cjs +1 -1
  7. package/dist/components.d.ts +1 -75
  8. package/dist/components.js +1 -1
  9. package/dist/{generators-C_fbcjpG.js → generators-Bma51Uar.js} +301 -261
  10. package/dist/generators-Bma51Uar.js.map +1 -0
  11. package/dist/{generators-CWEQsdO9.cjs → generators-BtsWNz-6.cjs} +299 -259
  12. package/dist/generators-BtsWNz-6.cjs.map +1 -0
  13. package/dist/generators.cjs +1 -1
  14. package/dist/generators.d.ts +41 -1
  15. package/dist/generators.js +1 -1
  16. package/dist/index.cjs +143 -20
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.ts +30 -1
  19. package/dist/index.js +143 -20
  20. package/dist/index.js.map +1 -1
  21. package/dist/types-DiZPLTXl.d.ts +400 -0
  22. package/extension.yaml +1507 -0
  23. package/package.json +16 -18
  24. package/src/components/InfiniteQuery.tsx +19 -13
  25. package/src/components/InfiniteQueryOptions.tsx +29 -47
  26. package/src/components/Mutation.tsx +35 -15
  27. package/src/components/MutationOptions.tsx +14 -13
  28. package/src/components/Query.tsx +9 -10
  29. package/src/components/QueryOptions.tsx +6 -27
  30. package/src/components/SuspenseInfiniteQuery.tsx +19 -13
  31. package/src/components/SuspenseInfiniteQueryOptions.tsx +29 -47
  32. package/src/components/SuspenseQuery.tsx +9 -10
  33. package/src/generators/customHookOptionsFileGenerator.tsx +18 -14
  34. package/src/generators/hookOptionsGenerator.tsx +36 -33
  35. package/src/generators/infiniteQueryGenerator.tsx +46 -64
  36. package/src/generators/mutationGenerator.tsx +42 -50
  37. package/src/generators/queryGenerator.tsx +43 -49
  38. package/src/generators/suspenseInfiniteQueryGenerator.tsx +41 -51
  39. package/src/generators/suspenseQueryGenerator.tsx +44 -62
  40. package/src/plugin.ts +42 -16
  41. package/src/resolvers/resolverReactQuery.ts +102 -6
  42. package/src/types.ts +199 -61
  43. package/src/utils.ts +10 -33
  44. package/dist/components-DTGLu4UV.js.map +0 -1
  45. package/dist/components-dAKJEn9b.cjs.map +0 -1
  46. package/dist/generators-CWEQsdO9.cjs.map +0 -1
  47. package/dist/generators-C_fbcjpG.js.map +0 -1
  48. package/dist/types-DfaFRSBf.d.ts +0 -284
@@ -0,0 +1,400 @@
1
+ import { t as __name } from "./chunk--u3MIqq1.js";
2
+ import { Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, Resolver, ast } from "@kubb/core";
3
+ import { ClientImportPath, PluginClient } from "@kubb/plugin-client";
4
+ import { PluginTs } from "@kubb/plugin-ts";
5
+ import { KubbReactNode } from "@kubb/renderer-jsx/types";
6
+
7
+ //#region ../../internals/tanstack-query/src/types.d.ts
8
+ type ParamsCasing = 'camelcase' | undefined;
9
+ type Transformer = (props: {
10
+ node: ast.OperationNode;
11
+ casing: ParamsCasing;
12
+ }) => unknown[];
13
+ //#endregion
14
+ //#region ../../internals/tanstack-query/src/components/MutationKey.d.ts
15
+ type Props$1 = {
16
+ name: string;
17
+ node: ast.OperationNode;
18
+ paramsCasing: 'camelcase' | undefined;
19
+ pathParamsType: 'object' | 'inline';
20
+ transformer: Transformer | null | undefined;
21
+ };
22
+ declare function MutationKey$1({
23
+ name,
24
+ paramsCasing,
25
+ node,
26
+ transformer
27
+ }: Props$1): KubbReactNode;
28
+ //#endregion
29
+ //#region ../../internals/tanstack-query/src/components/QueryKey.d.ts
30
+ type Props = {
31
+ name: string;
32
+ typeName: string;
33
+ node: ast.OperationNode;
34
+ tsResolver: PluginTs['resolver'];
35
+ paramsCasing: 'camelcase' | undefined;
36
+ pathParamsType: 'object' | 'inline';
37
+ transformer: Transformer | null | undefined;
38
+ };
39
+ declare function QueryKey$1({
40
+ name,
41
+ node,
42
+ tsResolver,
43
+ paramsCasing,
44
+ pathParamsType,
45
+ typeName,
46
+ transformer
47
+ }: Props): KubbReactNode;
48
+ //#endregion
49
+ //#region src/types.d.ts
50
+ /**
51
+ * Resolver for React Query that provides naming methods for hook functions.
52
+ */
53
+ type ResolverReactQuery = Resolver & {
54
+ /**
55
+ * Resolves the base function name for an operation.
56
+ *
57
+ * @example Resolving base operation names
58
+ * `resolver.resolveName('show pet by id') // -> 'showPetById'`
59
+ */
60
+ resolveName(this: ResolverReactQuery, name: string): string;
61
+ /**
62
+ * Resolves the output file name for a hook module.
63
+ */
64
+ resolvePathName(this: ResolverReactQuery, name: string, type?: 'file' | 'function' | 'type' | 'const'): string;
65
+ /**
66
+ * Resolves a query hook function name.
67
+ */
68
+ resolveQueryName(this: ResolverReactQuery, node: ast.OperationNode): string;
69
+ /**
70
+ * Resolves a suspense query hook function name.
71
+ */
72
+ resolveSuspenseQueryName(this: ResolverReactQuery, node: ast.OperationNode): string;
73
+ /**
74
+ * Resolves an infinite query hook function name.
75
+ */
76
+ resolveInfiniteQueryName(this: ResolverReactQuery, node: ast.OperationNode): string;
77
+ /**
78
+ * Resolves a suspense infinite query hook function name.
79
+ */
80
+ resolveSuspenseInfiniteQueryName(this: ResolverReactQuery, node: ast.OperationNode): string;
81
+ /**
82
+ * Resolves a mutation hook function name.
83
+ */
84
+ resolveMutationName(this: ResolverReactQuery, node: ast.OperationNode): string;
85
+ /**
86
+ * Resolves the query options helper name.
87
+ */
88
+ resolveQueryOptionsName(this: ResolverReactQuery, node: ast.OperationNode): string;
89
+ /**
90
+ * Resolves the suspense query options helper name.
91
+ */
92
+ resolveSuspenseQueryOptionsName(this: ResolverReactQuery, node: ast.OperationNode): string;
93
+ /**
94
+ * Resolves the infinite query options helper name.
95
+ */
96
+ resolveInfiniteQueryOptionsName(this: ResolverReactQuery, node: ast.OperationNode): string;
97
+ /**
98
+ * Resolves the suspense infinite query options helper name.
99
+ */
100
+ resolveSuspenseInfiniteQueryOptionsName(this: ResolverReactQuery, node: ast.OperationNode): string;
101
+ /**
102
+ * Resolves the mutation options helper name.
103
+ */
104
+ resolveMutationOptionsName(this: ResolverReactQuery, node: ast.OperationNode): string;
105
+ /**
106
+ * Resolves the query key helper name.
107
+ */
108
+ resolveQueryKeyName(this: ResolverReactQuery, node: ast.OperationNode): string;
109
+ /**
110
+ * Resolves the suspense query key helper name.
111
+ */
112
+ resolveSuspenseQueryKeyName(this: ResolverReactQuery, node: ast.OperationNode): string;
113
+ /**
114
+ * Resolves the infinite query key helper name.
115
+ */
116
+ resolveInfiniteQueryKeyName(this: ResolverReactQuery, node: ast.OperationNode): string;
117
+ /**
118
+ * Resolves the suspense infinite query key helper name.
119
+ */
120
+ resolveSuspenseInfiniteQueryKeyName(this: ResolverReactQuery, node: ast.OperationNode): string;
121
+ /**
122
+ * Resolves the mutation key helper name.
123
+ */
124
+ resolveMutationKeyName(this: ResolverReactQuery, node: ast.OperationNode): string;
125
+ /**
126
+ * Resolves the query key type name.
127
+ */
128
+ resolveQueryKeyTypeName(this: ResolverReactQuery, node: ast.OperationNode): string;
129
+ /**
130
+ * Resolves the suspense query key type name.
131
+ */
132
+ resolveSuspenseQueryKeyTypeName(this: ResolverReactQuery, node: ast.OperationNode): string;
133
+ /**
134
+ * Resolves the infinite query key type name.
135
+ */
136
+ resolveInfiniteQueryKeyTypeName(this: ResolverReactQuery, node: ast.OperationNode): string;
137
+ /**
138
+ * Resolves the suspense infinite query key type name.
139
+ */
140
+ resolveSuspenseInfiniteQueryKeyTypeName(this: ResolverReactQuery, node: ast.OperationNode): string;
141
+ /**
142
+ * Resolves the mutation type name.
143
+ */
144
+ resolveMutationTypeName(this: ResolverReactQuery, node: ast.OperationNode): string;
145
+ /**
146
+ * Resolves the client function name generated inline by query hooks.
147
+ */
148
+ resolveClientName(this: ResolverReactQuery, node: ast.OperationNode): string;
149
+ /**
150
+ * Resolves the client function name generated inline by suspense query hooks.
151
+ */
152
+ resolveSuspenseClientName(this: ResolverReactQuery, node: ast.OperationNode): string;
153
+ /**
154
+ * Resolves the client function name generated inline by infinite query hooks.
155
+ */
156
+ resolveInfiniteClientName(this: ResolverReactQuery, node: ast.OperationNode): string;
157
+ /**
158
+ * Resolves the client function name generated inline by suspense infinite query hooks.
159
+ */
160
+ resolveSuspenseInfiniteClientName(this: ResolverReactQuery, node: ast.OperationNode): string;
161
+ /**
162
+ * Resolves the generated custom hook options map type name.
163
+ */
164
+ resolveHookOptionsName(this: ResolverReactQuery): string;
165
+ /**
166
+ * Resolves the helper function name used inside the custom hook options file.
167
+ */
168
+ resolveCustomHookOptionsName(this: ResolverReactQuery): string;
169
+ };
170
+ type Suspense = object;
171
+ /**
172
+ * Builds the `queryKey` used by each generated query hook.
173
+ *
174
+ * @note String values are inlined verbatim into generated code. Wrap literal
175
+ * strings in `JSON.stringify(...)`.
176
+ */
177
+ type QueryKey = Transformer;
178
+ /**
179
+ * Builds the `mutationKey` used by each generated mutation hook.
180
+ *
181
+ * @note String values are inlined verbatim into generated code. Wrap literal
182
+ * strings in `JSON.stringify(...)`.
183
+ */
184
+ type MutationKey = Transformer;
185
+ type Query = {
186
+ /**
187
+ * HTTP methods treated as queries. Operations using these methods produce
188
+ * `useQuery`-style hooks.
189
+ *
190
+ * @default ['get']
191
+ */
192
+ methods?: Array<string>;
193
+ /**
194
+ * Module specifier used in the `import { useQuery } from '...'` statement at
195
+ * the top of every generated hook file. Useful for routing through a wrapper
196
+ * that injects a default `queryClient`.
197
+ *
198
+ * @default '@tanstack/react-query'
199
+ */
200
+ importPath?: string;
201
+ };
202
+ type Mutation = {
203
+ /**
204
+ * HTTP methods treated as mutations. Operations using these methods produce
205
+ * `useMutation`-style hooks.
206
+ *
207
+ * @default ['post', 'put', 'delete']
208
+ */
209
+ methods?: Array<string>;
210
+ /**
211
+ * Module specifier used in the `import { useMutation } from '...'` statement
212
+ * at the top of every generated hook file.
213
+ *
214
+ * @default '@tanstack/react-query'
215
+ */
216
+ importPath?: string;
217
+ };
218
+ type Infinite = {
219
+ /**
220
+ * Name of the query parameter that holds the page cursor.
221
+ *
222
+ * @default 'id'
223
+ */
224
+ queryParam?: string;
225
+ /**
226
+ * Path to the cursor field on the response. Leave undefined when the cursor
227
+ * is not known.
228
+ *
229
+ * @deprecated Use `nextParam` and `previousParam` for richer pagination control.
230
+ */
231
+ cursorParam?: string | null;
232
+ /**
233
+ * Path to the next-page cursor on the response. Supports dot notation
234
+ * (`'pagination.next.id'`) or array form (`['pagination', 'next', 'id']`).
235
+ */
236
+ nextParam?: string | Array<string> | null;
237
+ /**
238
+ * Path to the previous-page cursor on the response. Supports dot notation
239
+ * or array form.
240
+ */
241
+ previousParam?: string | Array<string> | null;
242
+ /**
243
+ * Initial value for `pageParam` on the first fetch.
244
+ *
245
+ * @default 0
246
+ */
247
+ initialPageParam?: unknown;
248
+ };
249
+ type CustomOptions = {
250
+ /**
251
+ * Module specifier of your custom-options hook. Imported as
252
+ * `import ${name} from '${importPath}'`.
253
+ */
254
+ importPath: string;
255
+ /**
256
+ * Exported function name of your custom-options hook.
257
+ *
258
+ * @default 'useCustomHookOptions'
259
+ */
260
+ name?: string;
261
+ };
262
+ type Options = {
263
+ /**
264
+ * Where the generated hooks are written and how they are exported.
265
+ *
266
+ * @default { path: 'hooks', barrel: { type: 'named' } }
267
+ */
268
+ output?: Output;
269
+ /**
270
+ * Split generated files into subfolders based on the operation's tag.
271
+ */
272
+ group?: Group;
273
+ /**
274
+ * HTTP client used inside every generated hook. Mirrors a subset of
275
+ * `pluginClient` options.
276
+ */
277
+ client?: ClientImportPath & Pick<PluginClient['options'], 'clientType' | 'dataReturnType' | 'baseURL' | 'bundle' | 'paramsCasing'>;
278
+ /**
279
+ * Skip operations matching at least one entry in the list.
280
+ */
281
+ exclude?: Array<Exclude>;
282
+ /**
283
+ * Restrict generation to operations matching at least one entry in the list.
284
+ */
285
+ include?: Array<Include>;
286
+ /**
287
+ * Apply a different options object to operations matching a pattern.
288
+ */
289
+ override?: Array<Override<ResolvedOptions>>;
290
+ /**
291
+ * Rename parameter properties in the generated hooks.
292
+ *
293
+ * @note Must match the value of `paramsCasing` on `@kubb/plugin-ts`.
294
+ */
295
+ paramsCasing?: 'camelcase';
296
+ /**
297
+ * How operation parameters appear in the generated hook signature.
298
+ * - `'inline'` — positional arguments.
299
+ * - `'object'` — single destructured object argument.
300
+ *
301
+ * @default 'inline'
302
+ */
303
+ paramsType?: 'object' | 'inline';
304
+ /**
305
+ * How URL path parameters are arranged inside the inline argument list.
306
+ *
307
+ * @default 'inline'
308
+ */
309
+ pathParamsType?: PluginClient['options']['pathParamsType'];
310
+ /**
311
+ * Enables `useInfiniteQuery` hooks for cursor- or page-based pagination.
312
+ * Pass an object to configure how the cursor is read; pass `false` to skip.
313
+ *
314
+ * @default false
315
+ */
316
+ infinite?: Partial<Infinite> | false;
317
+ /**
318
+ * Adds `useSuspenseQuery` hooks alongside the regular `useQuery` ones.
319
+ * Pass an empty object (`{}`) to enable. TanStack Query v5+ only.
320
+ */
321
+ suspense?: Partial<Suspense> | false;
322
+ /**
323
+ * Custom `queryKey` builder. Use to add a version namespace, swap to
324
+ * operation IDs, or shape keys to match an existing invalidation strategy.
325
+ */
326
+ queryKey?: QueryKey;
327
+ /**
328
+ * Configures query hooks. Set to `false` to skip generating hooks entirely
329
+ * and emit only `queryOptions(...)` helpers.
330
+ */
331
+ query?: Partial<Query> | false;
332
+ /**
333
+ * Custom `mutationKey` builder. Useful when you batch invalidations or read
334
+ * mutation state via `useMutationState`.
335
+ */
336
+ mutationKey?: MutationKey;
337
+ /**
338
+ * Configures mutation hooks. Set to `false` to skip mutation generation.
339
+ */
340
+ mutation?: Partial<Mutation> | false;
341
+ /**
342
+ * Wires every generated hook through a user-supplied function that returns
343
+ * extra options (`onSuccess`, `onError`, `select`, ...). Also emits a
344
+ * `HookOptions` type so the wrapper stays in sync with generated hooks.
345
+ */
346
+ customOptions?: CustomOptions;
347
+ /**
348
+ * Validator applied to response bodies before they reach the caller.
349
+ * - `'client'` — no validation. Trusts the API.
350
+ * - `'zod'` — pipes responses through schemas from `@kubb/plugin-zod`.
351
+ */
352
+ parser?: PluginClient['options']['parser'];
353
+ /**
354
+ * Override how hook names and file paths are built. Methods you omit fall
355
+ * back to the default `resolverReactQuery`.
356
+ */
357
+ resolver?: Partial<ResolverReactQuery> & ThisType<ResolverReactQuery>;
358
+ /**
359
+ * AST visitor applied to each operation node before printing.
360
+ */
361
+ transformer?: ast.Visitor;
362
+ /**
363
+ * Custom generators that run alongside the built-in React Query generators.
364
+ */
365
+ generators?: Array<Generator<PluginReactQuery>>;
366
+ };
367
+ type ResolvedOptions = {
368
+ output: Output;
369
+ group: Group | null;
370
+ exclude: NonNullable<Options['exclude']>;
371
+ include: Options['include'];
372
+ override: NonNullable<Options['override']>;
373
+ client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>;
374
+ parser: Required<NonNullable<Options['parser']>>;
375
+ pathParamsType: NonNullable<Options['pathParamsType']>;
376
+ paramsCasing: Options['paramsCasing'];
377
+ paramsType: NonNullable<Options['paramsType']>;
378
+ /**
379
+ * Only used for infinite
380
+ */
381
+ infinite: NonNullable<Infinite> | false;
382
+ suspense: Suspense | false;
383
+ queryKey: QueryKey | null;
384
+ query: NonNullable<Required<Query>> | false;
385
+ mutationKey: MutationKey | null;
386
+ mutation: NonNullable<Required<Mutation>> | false;
387
+ customOptions: NonNullable<Required<CustomOptions>> | null;
388
+ resolver: ResolverReactQuery;
389
+ };
390
+ type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options, ResolvedOptions, ResolverReactQuery>;
391
+ declare global {
392
+ namespace Kubb {
393
+ interface PluginRegistry {
394
+ 'plugin-react-query': PluginReactQuery;
395
+ }
396
+ }
397
+ }
398
+ //#endregion
399
+ export { MutationKey$1 as a, QueryKey$1 as i, Options as n, PluginReactQuery as r, Infinite as t };
400
+ //# sourceMappingURL=types-DiZPLTXl.d.ts.map