@kubb/plugin-react-query 5.0.0-beta.87 → 5.0.0-beta.95

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
@@ -21,6 +21,15 @@ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactory
21
21
  * client plugin.
22
22
  */
23
23
  type ClientSelector = 'fetch' | 'axios';
24
+ /**
25
+ * The resolved client strategy stored in a consumer plugin's options: the generated code always
26
+ * imports and calls a registered contract client plugin's `<op>`. The client runtime lives in
27
+ * plugin-axios / plugin-fetch, so nothing is bundled by the consumer.
28
+ */
29
+ type ResolvedContractClient = {
30
+ kind: 'contract';
31
+ pluginName: string;
32
+ };
24
33
  //#endregion
25
34
  //#region ../../internals/tanstack-query/src/types.d.ts
26
35
  type ParamsCasing = 'camelcase' | undefined;
@@ -28,6 +37,76 @@ type Transformer = (props: {
28
37
  node: ast.OperationNode;
29
38
  casing: ParamsCasing;
30
39
  }) => Array<unknown>;
40
+ /**
41
+ * Configures the query side of a TanStack-family plugin: which HTTP methods produce query
42
+ * hooks and where the query runtime is imported from.
43
+ */
44
+ type Query = {
45
+ /**
46
+ * HTTP methods treated as queries. Operations using these methods produce
47
+ * `useQuery`-style hooks.
48
+ *
49
+ * @default ['GET']
50
+ */
51
+ methods?: Array<string>;
52
+ /**
53
+ * Module specifier used in the `import { useQuery } from '...'` statement at
54
+ * the top of every generated file. Each plugin defaults this to its own runtime
55
+ * package. Useful for routing through a wrapper that injects a default
56
+ * `queryClient`.
57
+ */
58
+ importPath?: string;
59
+ };
60
+ /**
61
+ * Configures the mutation side of a TanStack-family plugin: which HTTP methods produce
62
+ * mutation hooks and where the mutation runtime is imported from.
63
+ */
64
+ type Mutation = {
65
+ /**
66
+ * HTTP methods treated as mutations. Operations using these methods produce
67
+ * `useMutation`-style hooks.
68
+ *
69
+ * @default ['POST', 'PUT', 'PATCH', 'DELETE']
70
+ */
71
+ methods?: Array<string>;
72
+ /**
73
+ * Module specifier used in the `import { useMutation } from '...'` statement
74
+ * at the top of every generated file. Each plugin defaults this to its own
75
+ * runtime package.
76
+ */
77
+ importPath?: string;
78
+ };
79
+ type Infinite = {
80
+ /**
81
+ * Name of the query parameter that holds the page cursor.
82
+ *
83
+ * @default 'id'
84
+ */
85
+ queryParam?: string;
86
+ /**
87
+ * Path to the cursor field on the response. Leave undefined when the cursor
88
+ * is not known.
89
+ *
90
+ * @deprecated Use `nextParam` and `previousParam` for richer pagination control.
91
+ */
92
+ cursorParam?: string | null;
93
+ /**
94
+ * Path to the next-page cursor on the response. Supports dot notation
95
+ * (`'pagination.next.id'`) or array form (`['pagination', 'next', 'id']`).
96
+ */
97
+ nextParam?: string | Array<string> | null;
98
+ /**
99
+ * Path to the previous-page cursor on the response. Supports dot notation
100
+ * or array form.
101
+ */
102
+ previousParam?: string | Array<string> | null;
103
+ /**
104
+ * Initial value for `pageParam` on the first fetch.
105
+ *
106
+ * @default 0
107
+ */
108
+ initialPageParam?: unknown;
109
+ };
31
110
  //#endregion
32
111
  //#region src/types.d.ts
33
112
  /**
@@ -218,70 +297,6 @@ type QueryKey = Transformer;
218
297
  * strings in `JSON.stringify(...)`.
219
298
  */
220
299
  type MutationKey = Transformer;
221
- type Query = {
222
- /**
223
- * HTTP methods treated as queries. Operations using these methods produce
224
- * `useQuery`-style hooks.
225
- *
226
- * @default ['GET']
227
- */
228
- methods?: Array<string>;
229
- /**
230
- * Module specifier used in the `import { useQuery } from '...'` statement at
231
- * the top of every generated hook file. Useful for routing through a wrapper
232
- * that injects a default `queryClient`.
233
- *
234
- * @default '@tanstack/react-query'
235
- */
236
- importPath?: string;
237
- };
238
- type Mutation = {
239
- /**
240
- * HTTP methods treated as mutations. Operations using these methods produce
241
- * `useMutation`-style hooks.
242
- *
243
- * @default ['POST', 'PUT', 'PATCH', 'DELETE']
244
- */
245
- methods?: Array<string>;
246
- /**
247
- * Module specifier used in the `import { useMutation } from '...'` statement
248
- * at the top of every generated hook file.
249
- *
250
- * @default '@tanstack/react-query'
251
- */
252
- importPath?: string;
253
- };
254
- type Infinite = {
255
- /**
256
- * Name of the query parameter that holds the page cursor.
257
- *
258
- * @default 'id'
259
- */
260
- queryParam?: string;
261
- /**
262
- * Path to the cursor field on the response. Leave undefined when the cursor
263
- * is not known.
264
- *
265
- * @deprecated Use `nextParam` and `previousParam` for richer pagination control.
266
- */
267
- cursorParam?: string | null;
268
- /**
269
- * Path to the next-page cursor on the response. Supports dot notation
270
- * (`'pagination.next.id'`) or array form (`['pagination', 'next', 'id']`).
271
- */
272
- nextParam?: string | Array<string> | null;
273
- /**
274
- * Path to the previous-page cursor on the response. Supports dot notation
275
- * or array form.
276
- */
277
- previousParam?: string | Array<string> | null;
278
- /**
279
- * Initial value for `pageParam` on the first fetch.
280
- *
281
- * @default 0
282
- */
283
- initialPageParam?: unknown;
284
- };
285
300
  type CustomOptions = {
286
301
  /**
287
302
  * Module specifier of your custom-options hook. Imported as a named import,
@@ -386,10 +401,7 @@ type Options = OutputOptions & {
386
401
  * The resolved client strategy for the generated hooks, computed once during setup. The hooks always
387
402
  * import and call a registered contract client plugin's `<op>`.
388
403
  */
389
- type ResolvedClient = {
390
- kind: 'contract';
391
- pluginName: string;
392
- };
404
+ type ResolvedClient = ResolvedContractClient;
393
405
  type ResolvedOptions = {
394
406
  output: Output;
395
407
  group: Group | null;
@@ -441,7 +453,7 @@ declare const pluginReactQueryName = "plugin-react-query";
441
453
  * import { pluginReactQuery } from '@kubb/plugin-react-query'
442
454
  *
443
455
  * export default defineConfig({
444
- * input: { path: './petStore.yaml' },
456
+ * input: './petStore.yaml',
445
457
  * output: { path: './src/gen' },
446
458
  * plugins: [
447
459
  * pluginTs(),
@@ -455,5 +467,27 @@ declare const pluginReactQueryName = "plugin-react-query";
455
467
  */
456
468
  declare const pluginReactQuery: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginReactQuery>;
457
469
  //#endregion
458
- export { type PluginReactQuery, pluginReactQuery as default, pluginReactQuery, pluginReactQueryName };
470
+ //#region src/resolvers/resolverReactQuery.d.ts
471
+ /**
472
+ * Default resolver used by `@kubb/plugin-react-query`. Decides the names and
473
+ * file paths for every generated TanStack Query hook (`useFoo`,
474
+ * `useFooSuspense`, `useFooInfinite`, ...) and its companion helpers
475
+ * (`fooQueryKey`, `fooQueryOptions`).
476
+ *
477
+ * Functions and files use the built-in camelCase casing; hooks get the `use`
478
+ * prefix; suspense and infinite variants are suffixed with `Suspense`/`Infinite`.
479
+ *
480
+ * @example Resolve hook and helper names
481
+ * ```ts
482
+ * import { resolverReactQuery } from '@kubb/plugin-react-query'
483
+ *
484
+ * resolverReactQuery.query.name(operationNode) // 'useGetPetById'
485
+ * resolverReactQuery.mutation.name(operationNode) // 'useUpdatePet'
486
+ * resolverReactQuery.query.keyName(operationNode) // 'getPetByIdQueryKey'
487
+ * resolverReactQuery.query.optionsName(operationNode) // 'getPetByIdQueryOptions'
488
+ * ```
489
+ */
490
+ declare const resolverReactQuery: ResolverReactQuery;
491
+ //#endregion
492
+ export { type PluginReactQuery, type ResolverReactQuery, pluginReactQuery as default, pluginReactQuery, pluginReactQueryName, resolverReactQuery };
459
493
  //# sourceMappingURL=index.d.ts.map