@kubb/plugin-react-query 5.0.0-alpha.9 → 5.0.0-beta.10
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/LICENSE +17 -10
- package/README.md +34 -85
- package/dist/components-Dow6tde8.js +1459 -0
- package/dist/components-Dow6tde8.js.map +1 -0
- package/dist/components-HwdCDefj.cjs +1603 -0
- package/dist/components-HwdCDefj.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +49 -179
- package/dist/components.js +1 -1
- package/dist/generators-CcOmnTPa.cjs +1454 -0
- package/dist/generators-CcOmnTPa.cjs.map +1 -0
- package/dist/generators-yfZr_qfT.js +1412 -0
- package/dist/generators-yfZr_qfT.js.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +9 -505
- package/dist/generators.js +1 -1
- package/dist/index.cjs +197 -126
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +193 -126
- package/dist/index.js.map +1 -1
- package/dist/types-DG_OxOym.d.ts +363 -0
- package/extension.yaml +911 -0
- package/package.json +59 -64
- package/src/components/InfiniteQuery.tsx +79 -138
- package/src/components/InfiniteQueryOptions.tsx +55 -166
- package/src/components/Mutation.tsx +74 -111
- package/src/components/MutationOptions.tsx +61 -80
- package/src/components/Query.tsx +66 -142
- package/src/components/QueryOptions.tsx +56 -138
- package/src/components/SuspenseInfiniteQuery.tsx +79 -138
- package/src/components/SuspenseInfiniteQueryOptions.tsx +55 -166
- package/src/components/SuspenseQuery.tsx +66 -152
- package/src/generators/customHookOptionsFileGenerator.tsx +37 -51
- package/src/generators/hookOptionsGenerator.tsx +111 -174
- package/src/generators/infiniteQueryGenerator.tsx +158 -178
- package/src/generators/mutationGenerator.tsx +112 -139
- package/src/generators/queryGenerator.tsx +128 -142
- package/src/generators/suspenseInfiniteQueryGenerator.tsx +157 -156
- package/src/generators/suspenseQueryGenerator.tsx +126 -152
- package/src/index.ts +1 -1
- package/src/plugin.ts +134 -187
- package/src/resolvers/resolverReactQuery.ts +107 -0
- package/src/types.ts +172 -49
- package/src/utils.ts +10 -0
- package/dist/components-BHQT9ZLc.cjs +0 -1634
- package/dist/components-BHQT9ZLc.cjs.map +0 -1
- package/dist/components-CpyHYGOw.js +0 -1520
- package/dist/components-CpyHYGOw.js.map +0 -1
- package/dist/generators-DP07m3rH.cjs +0 -1469
- package/dist/generators-DP07m3rH.cjs.map +0 -1
- package/dist/generators-DkQwKTc2.js +0 -1427
- package/dist/generators-DkQwKTc2.js.map +0 -1
- package/dist/types-D5S7Ny9r.d.ts +0 -270
|
@@ -0,0 +1,363 @@
|
|
|
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 | 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 | 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
|
+
* Customize the queryKey.
|
|
173
|
+
*/
|
|
174
|
+
type QueryKey = Transformer;
|
|
175
|
+
/**
|
|
176
|
+
* Customize the mutationKey.
|
|
177
|
+
*/
|
|
178
|
+
type MutationKey = Transformer;
|
|
179
|
+
type Query = {
|
|
180
|
+
/**
|
|
181
|
+
* HTTP methods to use for queries.
|
|
182
|
+
*
|
|
183
|
+
* @default ['get']
|
|
184
|
+
*/
|
|
185
|
+
methods?: Array<string>;
|
|
186
|
+
/**
|
|
187
|
+
* Path to the useQuery hook for useQuery functionality.
|
|
188
|
+
* Used as `import { useQuery } from '${importPath}'`.
|
|
189
|
+
* Accepts relative and absolute paths.
|
|
190
|
+
* Path is used as-is; relative paths are based on the generated file location.
|
|
191
|
+
* @default '@tanstack/react-query'
|
|
192
|
+
*/
|
|
193
|
+
importPath?: string;
|
|
194
|
+
};
|
|
195
|
+
type Mutation = {
|
|
196
|
+
/**
|
|
197
|
+
* HTTP methods to use for mutations.
|
|
198
|
+
*
|
|
199
|
+
* @default ['post', 'put', 'delete']
|
|
200
|
+
*/
|
|
201
|
+
methods?: Array<string>;
|
|
202
|
+
/**
|
|
203
|
+
* Path to the useMutation hook for useMutation functionality.
|
|
204
|
+
* Used as `import { useMutation } from '${importPath}'`.
|
|
205
|
+
* Accepts relative and absolute paths.
|
|
206
|
+
* Path is used as-is; relative paths are based on the generated file location.
|
|
207
|
+
* @default '@tanstack/react-query'
|
|
208
|
+
*/
|
|
209
|
+
importPath?: string;
|
|
210
|
+
};
|
|
211
|
+
type Infinite = {
|
|
212
|
+
/**
|
|
213
|
+
* Specify the params key used for `pageParam`.
|
|
214
|
+
* @default 'id'
|
|
215
|
+
*/
|
|
216
|
+
queryParam: string;
|
|
217
|
+
/**
|
|
218
|
+
* Which field of the data is used, set it to undefined when no cursor is known.
|
|
219
|
+
* @deprecated Use `nextParam` and `previousParam` instead for more flexible pagination handling.
|
|
220
|
+
*/
|
|
221
|
+
cursorParam?: string | undefined;
|
|
222
|
+
/**
|
|
223
|
+
* Which field of the data is used to get the cursor for the next page.
|
|
224
|
+
* Supports dot notation (e.g. 'pagination.next.id') or array path (e.g. ['pagination', 'next', 'id']) to access nested fields.
|
|
225
|
+
*/
|
|
226
|
+
nextParam?: string | string[] | undefined;
|
|
227
|
+
/**
|
|
228
|
+
* Which field of the data is used to get the cursor for the previous page.
|
|
229
|
+
* Supports dot notation (e.g. 'pagination.prev.id') or array path (e.g. ['pagination', 'prev', 'id']) to access nested fields.
|
|
230
|
+
*/
|
|
231
|
+
previousParam?: string | string[] | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* The initial value, the value of the first page.
|
|
234
|
+
* @default 0
|
|
235
|
+
*/
|
|
236
|
+
initialPageParam: unknown;
|
|
237
|
+
};
|
|
238
|
+
type CustomOptions = {
|
|
239
|
+
/**
|
|
240
|
+
* Path to the hook that is used to customize the hook options.
|
|
241
|
+
* It used as `import ${customOptions.name} from '${customOptions.importPath}'`.
|
|
242
|
+
* It allows both relative and absolute paths but be aware that we will not change the path.
|
|
243
|
+
*/
|
|
244
|
+
importPath: string;
|
|
245
|
+
/**
|
|
246
|
+
* Name of the exported hook that is used to customize the hook options.
|
|
247
|
+
* It used as `import ${customOptions.name} from '${customOptions.importPath}'`.
|
|
248
|
+
* @default 'useCustomHookOptions'
|
|
249
|
+
*/
|
|
250
|
+
name?: string;
|
|
251
|
+
};
|
|
252
|
+
type Options = {
|
|
253
|
+
/**
|
|
254
|
+
* Specify the export location for the files and define the behavior of the output
|
|
255
|
+
* @default { path: 'hooks', barrelType: 'named' }
|
|
256
|
+
*/
|
|
257
|
+
output?: Output;
|
|
258
|
+
/**
|
|
259
|
+
* Group the @tanstack/query hooks based on the provided name.
|
|
260
|
+
*/
|
|
261
|
+
group?: Group;
|
|
262
|
+
client?: ClientImportPath & Pick<PluginClient['options'], 'clientType' | 'dataReturnType' | 'baseURL' | 'bundle' | 'paramsCasing'>;
|
|
263
|
+
/**
|
|
264
|
+
* Tags, operations, or paths to exclude from generation.
|
|
265
|
+
*/
|
|
266
|
+
exclude?: Array<Exclude>;
|
|
267
|
+
/**
|
|
268
|
+
* Tags, operations, or paths to include in generation.
|
|
269
|
+
*/
|
|
270
|
+
include?: Array<Include>;
|
|
271
|
+
/**
|
|
272
|
+
* Override options for specific tags, operations, or paths.
|
|
273
|
+
*/
|
|
274
|
+
override?: Array<Override<ResolvedOptions>>;
|
|
275
|
+
/**
|
|
276
|
+
* Apply casing to parameter names.
|
|
277
|
+
*/
|
|
278
|
+
paramsCasing?: 'camelcase';
|
|
279
|
+
/**
|
|
280
|
+
* How parameters are passed: grouped in an object or spread inline.
|
|
281
|
+
*
|
|
282
|
+
* @default 'inline'
|
|
283
|
+
*/
|
|
284
|
+
paramsType?: 'object' | 'inline';
|
|
285
|
+
/**
|
|
286
|
+
* How path parameters are passed: grouped in an object or spread inline.
|
|
287
|
+
*
|
|
288
|
+
* @default 'inline'
|
|
289
|
+
*/
|
|
290
|
+
pathParamsType?: PluginClient['options']['pathParamsType'];
|
|
291
|
+
/**
|
|
292
|
+
* Add infinite query hooks.
|
|
293
|
+
*/
|
|
294
|
+
infinite?: Partial<Infinite> | false;
|
|
295
|
+
/**
|
|
296
|
+
* Add suspense query hooks.
|
|
297
|
+
*/
|
|
298
|
+
suspense?: Partial<Suspense> | false;
|
|
299
|
+
queryKey?: QueryKey;
|
|
300
|
+
/**
|
|
301
|
+
* Configure useQuery behavior.
|
|
302
|
+
*/
|
|
303
|
+
query?: Partial<Query> | false;
|
|
304
|
+
mutationKey?: MutationKey;
|
|
305
|
+
/**
|
|
306
|
+
* Configure useMutation behavior.
|
|
307
|
+
*/
|
|
308
|
+
mutation?: Partial<Mutation> | false;
|
|
309
|
+
/**
|
|
310
|
+
* Use a custom hook to customize hook options and generate a HookOptions type.
|
|
311
|
+
*/
|
|
312
|
+
customOptions?: CustomOptions;
|
|
313
|
+
/**
|
|
314
|
+
* Parser to use for validating response data.
|
|
315
|
+
*/
|
|
316
|
+
parser?: PluginClient['options']['parser'];
|
|
317
|
+
/**
|
|
318
|
+
* Override naming conventions for function names and types.
|
|
319
|
+
*/
|
|
320
|
+
resolver?: Partial<ResolverReactQuery> & ThisType<ResolverReactQuery>;
|
|
321
|
+
/**
|
|
322
|
+
* AST visitor to transform generated nodes.
|
|
323
|
+
*/
|
|
324
|
+
transformer?: ast.Visitor;
|
|
325
|
+
/**
|
|
326
|
+
* Additional generators alongside the default generators.
|
|
327
|
+
*/
|
|
328
|
+
generators?: Array<Generator<PluginReactQuery>>;
|
|
329
|
+
};
|
|
330
|
+
type ResolvedOptions = {
|
|
331
|
+
output: Output;
|
|
332
|
+
group: Group | undefined;
|
|
333
|
+
exclude: NonNullable<Options['exclude']>;
|
|
334
|
+
include: Options['include'];
|
|
335
|
+
override: NonNullable<Options['override']>;
|
|
336
|
+
client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>;
|
|
337
|
+
parser: Required<NonNullable<Options['parser']>>;
|
|
338
|
+
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
339
|
+
paramsCasing: Options['paramsCasing'];
|
|
340
|
+
paramsType: NonNullable<Options['paramsType']>;
|
|
341
|
+
/**
|
|
342
|
+
* Only used for infinite
|
|
343
|
+
*/
|
|
344
|
+
infinite: NonNullable<Infinite> | false;
|
|
345
|
+
suspense: Suspense | false;
|
|
346
|
+
queryKey: QueryKey | undefined;
|
|
347
|
+
query: NonNullable<Required<Query>> | false;
|
|
348
|
+
mutationKey: MutationKey | undefined;
|
|
349
|
+
mutation: NonNullable<Required<Mutation>> | false;
|
|
350
|
+
customOptions: NonNullable<Required<CustomOptions>> | undefined;
|
|
351
|
+
resolver: ResolverReactQuery;
|
|
352
|
+
};
|
|
353
|
+
type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options, ResolvedOptions, ResolverReactQuery>;
|
|
354
|
+
declare global {
|
|
355
|
+
namespace Kubb {
|
|
356
|
+
interface PluginRegistry {
|
|
357
|
+
'plugin-react-query': PluginReactQuery;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
//#endregion
|
|
362
|
+
export { MutationKey$1 as a, QueryKey$1 as i, Options as n, PluginReactQuery as r, Infinite as t };
|
|
363
|
+
//# sourceMappingURL=types-DG_OxOym.d.ts.map
|