@kubb/plugin-react-query 5.0.0-beta.94 → 5.0.0-beta.98
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 +354 -529
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +106 -69
- package/dist/index.js +354 -530
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
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";
|
|
3
6
|
//#region ../../internals/client/src/resolveClient.d.ts
|
|
4
7
|
/**
|
|
5
8
|
* Resolves which client plugin a consumer (react-query, vue-query, swr, mcp) should call for an
|
|
@@ -21,6 +24,15 @@ import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactory
|
|
|
21
24
|
* client plugin.
|
|
22
25
|
*/
|
|
23
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
|
+
};
|
|
24
36
|
//#endregion
|
|
25
37
|
//#region ../../internals/tanstack-query/src/types.d.ts
|
|
26
38
|
type ParamsCasing = 'camelcase' | undefined;
|
|
@@ -28,6 +40,76 @@ type Transformer = (props: {
|
|
|
28
40
|
node: ast.OperationNode;
|
|
29
41
|
casing: ParamsCasing;
|
|
30
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
|
+
};
|
|
31
113
|
//#endregion
|
|
32
114
|
//#region src/types.d.ts
|
|
33
115
|
/**
|
|
@@ -218,70 +300,6 @@ type QueryKey = Transformer;
|
|
|
218
300
|
* strings in `JSON.stringify(...)`.
|
|
219
301
|
*/
|
|
220
302
|
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
303
|
type CustomOptions = {
|
|
286
304
|
/**
|
|
287
305
|
* Module specifier of your custom-options hook. Imported as a named import,
|
|
@@ -386,10 +404,7 @@ type Options = OutputOptions & {
|
|
|
386
404
|
* The resolved client strategy for the generated hooks, computed once during setup. The hooks always
|
|
387
405
|
* import and call a registered contract client plugin's `<op>`.
|
|
388
406
|
*/
|
|
389
|
-
type ResolvedClient =
|
|
390
|
-
kind: 'contract';
|
|
391
|
-
pluginName: string;
|
|
392
|
-
};
|
|
407
|
+
type ResolvedClient = ResolvedContractClient;
|
|
393
408
|
type ResolvedOptions = {
|
|
394
409
|
output: Output;
|
|
395
410
|
group: Group | null;
|
|
@@ -455,5 +470,27 @@ declare const pluginReactQueryName = "plugin-react-query";
|
|
|
455
470
|
*/
|
|
456
471
|
declare const pluginReactQuery: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginReactQuery>;
|
|
457
472
|
//#endregion
|
|
458
|
-
|
|
473
|
+
//#region src/resolvers/resolverReactQuery.d.ts
|
|
474
|
+
/**
|
|
475
|
+
* Default resolver used by `@kubb/plugin-react-query`. Decides the names and
|
|
476
|
+
* file paths for every generated TanStack Query hook (`useFoo`,
|
|
477
|
+
* `useFooSuspense`, `useFooInfinite`, ...) and its companion helpers
|
|
478
|
+
* (`fooQueryKey`, `fooQueryOptions`).
|
|
479
|
+
*
|
|
480
|
+
* Functions and files use the built-in camelCase casing; hooks get the `use`
|
|
481
|
+
* prefix; suspense and infinite variants are suffixed with `Suspense`/`Infinite`.
|
|
482
|
+
*
|
|
483
|
+
* @example Resolve hook and helper names
|
|
484
|
+
* ```ts
|
|
485
|
+
* import { resolverReactQuery } from '@kubb/plugin-react-query'
|
|
486
|
+
*
|
|
487
|
+
* resolverReactQuery.query.name(operationNode) // 'useGetPetById'
|
|
488
|
+
* resolverReactQuery.mutation.name(operationNode) // 'useUpdatePet'
|
|
489
|
+
* resolverReactQuery.query.keyName(operationNode) // 'getPetByIdQueryKey'
|
|
490
|
+
* resolverReactQuery.query.optionsName(operationNode) // 'getPetByIdQueryOptions'
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
declare const resolverReactQuery: ResolverReactQuery;
|
|
494
|
+
//#endregion
|
|
495
|
+
export { type PluginReactQuery, type ResolverReactQuery, pluginReactQuery as default, pluginReactQuery, pluginReactQueryName, resolverReactQuery };
|
|
459
496
|
//# sourceMappingURL=index.d.ts.map
|