@kubb/plugin-react-query 5.0.0-beta.4 → 5.0.0-beta.56
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/README.md +38 -91
- package/dist/{components-DTGLu4UV.js → components-DL0Cai7l.js} +570 -514
- package/dist/components-DL0Cai7l.js.map +1 -0
- package/dist/{components-dAKJEn9b.cjs → components-yMQOuFmI.cjs} +600 -514
- package/dist/components-yMQOuFmI.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.d.ts +5 -77
- package/dist/components.js +1 -1
- package/dist/{generators-C_fbcjpG.js → generators-BG-Vcvfg.js} +444 -597
- package/dist/generators-BG-Vcvfg.js.map +1 -0
- package/dist/{generators-CWEQsdO9.cjs → generators-zGKP8yII.cjs} +442 -595
- package/dist/generators-zGKP8yII.cjs.map +1 -0
- package/dist/generators.cjs +1 -1
- package/dist/generators.d.ts +49 -10
- package/dist/generators.js +1 -1
- package/dist/index.cjs +201 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +32 -4
- package/dist/index.js +203 -30
- package/dist/index.js.map +1 -1
- package/dist/types-X7D0NSvJ.d.ts +396 -0
- package/package.json +18 -27
- package/src/components/InfiniteQuery.tsx +27 -17
- package/src/components/InfiniteQueryOptions.tsx +60 -81
- package/src/components/Mutation.tsx +39 -20
- package/src/components/MutationOptions.tsx +15 -14
- package/src/components/Query.tsx +18 -15
- package/src/components/QueryOptions.tsx +20 -56
- package/src/components/SuspenseInfiniteQuery.tsx +22 -17
- package/src/components/SuspenseInfiniteQueryOptions.tsx +51 -76
- package/src/components/SuspenseQuery.tsx +13 -15
- package/src/generators/customHookOptionsFileGenerator.tsx +16 -12
- package/src/generators/hookOptionsGenerator.tsx +42 -49
- package/src/generators/infiniteQueryGenerator.tsx +55 -80
- package/src/generators/mutationGenerator.tsx +54 -66
- package/src/generators/queryGenerator.tsx +52 -65
- package/src/generators/suspenseInfiniteQueryGenerator.tsx +50 -67
- package/src/generators/suspenseQueryGenerator.tsx +54 -78
- package/src/plugin.ts +47 -33
- package/src/resolvers/resolverReactQuery.ts +104 -8
- package/src/types.ts +202 -68
- package/src/utils.ts +11 -33
- package/dist/components-DTGLu4UV.js.map +0 -1
- package/dist/components-dAKJEn9b.cjs.map +0 -1
- package/dist/generators-CWEQsdO9.cjs.map +0 -1
- package/dist/generators-C_fbcjpG.js.map +0 -1
- package/dist/types-DfaFRSBf.d.ts +0 -284
- package/extension.yaml +0 -938
- /package/dist/{chunk--u3MIqq1.js → chunk-C0LytTxp.js} +0 -0
package/dist/types-DfaFRSBf.d.ts
DELETED
|
@@ -1,284 +0,0 @@
|
|
|
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
|
-
declare namespace MutationKey$1 {
|
|
29
|
-
var getParams: () => ast.FunctionParametersNode;
|
|
30
|
-
var getTransformer: Transformer;
|
|
31
|
-
}
|
|
32
|
-
//#endregion
|
|
33
|
-
//#region ../../internals/tanstack-query/src/components/QueryKey.d.ts
|
|
34
|
-
type Props = {
|
|
35
|
-
name: string;
|
|
36
|
-
typeName: string;
|
|
37
|
-
node: ast.OperationNode;
|
|
38
|
-
tsResolver: PluginTs['resolver'];
|
|
39
|
-
paramsCasing: 'camelcase' | undefined;
|
|
40
|
-
pathParamsType: 'object' | 'inline';
|
|
41
|
-
transformer: Transformer | undefined;
|
|
42
|
-
};
|
|
43
|
-
declare function QueryKey$1({
|
|
44
|
-
name,
|
|
45
|
-
node,
|
|
46
|
-
tsResolver,
|
|
47
|
-
paramsCasing,
|
|
48
|
-
pathParamsType,
|
|
49
|
-
typeName,
|
|
50
|
-
transformer
|
|
51
|
-
}: Props): KubbReactNode;
|
|
52
|
-
declare namespace QueryKey$1 {
|
|
53
|
-
var getParams: (node: ast.OperationNode, options: {
|
|
54
|
-
pathParamsType: "object" | "inline";
|
|
55
|
-
paramsCasing: "camelcase" | undefined;
|
|
56
|
-
resolver: PluginTs["resolver"];
|
|
57
|
-
}) => ast.FunctionParametersNode;
|
|
58
|
-
var getTransformer: Transformer;
|
|
59
|
-
var callPrinter: {
|
|
60
|
-
name: "functionParameters";
|
|
61
|
-
options: {
|
|
62
|
-
mode: "declaration" | "call" | "keys" | "values";
|
|
63
|
-
transformName?: (name: string) => string;
|
|
64
|
-
transformType?: (type: string) => string;
|
|
65
|
-
};
|
|
66
|
-
transform: (node: ast.FunctionParamNode) => string | null | undefined;
|
|
67
|
-
print: (node: ast.FunctionParamNode) => string | null | undefined;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
//#endregion
|
|
71
|
-
//#region src/types.d.ts
|
|
72
|
-
/**
|
|
73
|
-
* Resolver for React Query that provides naming methods for hook functions.
|
|
74
|
-
*/
|
|
75
|
-
type ResolverReactQuery = Resolver & {
|
|
76
|
-
/**
|
|
77
|
-
* Resolves the hook function name for an operation.
|
|
78
|
-
*
|
|
79
|
-
* @example Resolving hook names
|
|
80
|
-
* `resolver.resolveName('show pet by id') // -> 'showPetById'`
|
|
81
|
-
*/
|
|
82
|
-
resolveName(this: ResolverReactQuery, name: string): string;
|
|
83
|
-
};
|
|
84
|
-
type Suspense = object;
|
|
85
|
-
/**
|
|
86
|
-
* Customize the queryKey.
|
|
87
|
-
*/
|
|
88
|
-
type QueryKey = Transformer;
|
|
89
|
-
/**
|
|
90
|
-
* Customize the mutationKey.
|
|
91
|
-
*/
|
|
92
|
-
type MutationKey = Transformer;
|
|
93
|
-
type Query = {
|
|
94
|
-
/**
|
|
95
|
-
* HTTP methods to use for queries.
|
|
96
|
-
*
|
|
97
|
-
* @default ['get']
|
|
98
|
-
*/
|
|
99
|
-
methods?: Array<string>;
|
|
100
|
-
/**
|
|
101
|
-
* Path to the useQuery hook for useQuery functionality.
|
|
102
|
-
* Used as `import { useQuery } from '${importPath}'`.
|
|
103
|
-
* Accepts relative and absolute paths.
|
|
104
|
-
* Path is used as-is; relative paths are based on the generated file location.
|
|
105
|
-
* @default '@tanstack/react-query'
|
|
106
|
-
*/
|
|
107
|
-
importPath?: string;
|
|
108
|
-
};
|
|
109
|
-
type Mutation = {
|
|
110
|
-
/**
|
|
111
|
-
* HTTP methods to use for mutations.
|
|
112
|
-
*
|
|
113
|
-
* @default ['post', 'put', 'delete']
|
|
114
|
-
*/
|
|
115
|
-
methods?: Array<string>;
|
|
116
|
-
/**
|
|
117
|
-
* Path to the useMutation hook for useMutation functionality.
|
|
118
|
-
* Used as `import { useMutation } from '${importPath}'`.
|
|
119
|
-
* Accepts relative and absolute paths.
|
|
120
|
-
* Path is used as-is; relative paths are based on the generated file location.
|
|
121
|
-
* @default '@tanstack/react-query'
|
|
122
|
-
*/
|
|
123
|
-
importPath?: string;
|
|
124
|
-
};
|
|
125
|
-
type Infinite = {
|
|
126
|
-
/**
|
|
127
|
-
* Specify the params key used for `pageParam`.
|
|
128
|
-
* @default 'id'
|
|
129
|
-
*/
|
|
130
|
-
queryParam: string;
|
|
131
|
-
/**
|
|
132
|
-
* Which field of the data is used, set it to undefined when no cursor is known.
|
|
133
|
-
* @deprecated Use `nextParam` and `previousParam` instead for more flexible pagination handling.
|
|
134
|
-
*/
|
|
135
|
-
cursorParam?: string | undefined;
|
|
136
|
-
/**
|
|
137
|
-
* Which field of the data is used to get the cursor for the next page.
|
|
138
|
-
* Supports dot notation (e.g. 'pagination.next.id') or array path (e.g. ['pagination', 'next', 'id']) to access nested fields.
|
|
139
|
-
*/
|
|
140
|
-
nextParam?: string | string[] | undefined;
|
|
141
|
-
/**
|
|
142
|
-
* Which field of the data is used to get the cursor for the previous page.
|
|
143
|
-
* Supports dot notation (e.g. 'pagination.prev.id') or array path (e.g. ['pagination', 'prev', 'id']) to access nested fields.
|
|
144
|
-
*/
|
|
145
|
-
previousParam?: string | string[] | undefined;
|
|
146
|
-
/**
|
|
147
|
-
* The initial value, the value of the first page.
|
|
148
|
-
* @default 0
|
|
149
|
-
*/
|
|
150
|
-
initialPageParam: unknown;
|
|
151
|
-
};
|
|
152
|
-
type CustomOptions = {
|
|
153
|
-
/**
|
|
154
|
-
* Path to the hook that is used to customize the hook options.
|
|
155
|
-
* It used as `import ${customOptions.name} from '${customOptions.importPath}'`.
|
|
156
|
-
* It allows both relative and absolute paths but be aware that we will not change the path.
|
|
157
|
-
*/
|
|
158
|
-
importPath: string;
|
|
159
|
-
/**
|
|
160
|
-
* Name of the exported hook that is used to customize the hook options.
|
|
161
|
-
* It used as `import ${customOptions.name} from '${customOptions.importPath}'`.
|
|
162
|
-
* @default 'useCustomHookOptions'
|
|
163
|
-
*/
|
|
164
|
-
name?: string;
|
|
165
|
-
};
|
|
166
|
-
type Options = {
|
|
167
|
-
/**
|
|
168
|
-
* Specify the export location for the files and define the behavior of the output
|
|
169
|
-
* @default { path: 'hooks', barrelType: 'named' }
|
|
170
|
-
*/
|
|
171
|
-
output?: Output;
|
|
172
|
-
/**
|
|
173
|
-
* Group the @tanstack/query hooks based on the provided name.
|
|
174
|
-
*/
|
|
175
|
-
group?: Group;
|
|
176
|
-
client?: ClientImportPath & Pick<PluginClient['options'], 'clientType' | 'dataReturnType' | 'baseURL' | 'bundle' | 'paramsCasing'>;
|
|
177
|
-
/**
|
|
178
|
-
* Tags, operations, or paths to exclude from generation.
|
|
179
|
-
*/
|
|
180
|
-
exclude?: Array<Exclude>;
|
|
181
|
-
/**
|
|
182
|
-
* Tags, operations, or paths to include in generation.
|
|
183
|
-
*/
|
|
184
|
-
include?: Array<Include>;
|
|
185
|
-
/**
|
|
186
|
-
* Override options for specific tags, operations, or paths.
|
|
187
|
-
*/
|
|
188
|
-
override?: Array<Override<ResolvedOptions>>;
|
|
189
|
-
/**
|
|
190
|
-
* Apply casing to parameter names.
|
|
191
|
-
*/
|
|
192
|
-
paramsCasing?: 'camelcase';
|
|
193
|
-
/**
|
|
194
|
-
* How parameters are passed: grouped in an object or spread inline.
|
|
195
|
-
*
|
|
196
|
-
* @default 'inline'
|
|
197
|
-
*/
|
|
198
|
-
paramsType?: 'object' | 'inline';
|
|
199
|
-
/**
|
|
200
|
-
* How path parameters are passed: grouped in an object or spread inline.
|
|
201
|
-
*
|
|
202
|
-
* @default 'inline'
|
|
203
|
-
*/
|
|
204
|
-
pathParamsType?: PluginClient['options']['pathParamsType'];
|
|
205
|
-
/**
|
|
206
|
-
* Add infinite query hooks.
|
|
207
|
-
*/
|
|
208
|
-
infinite?: Partial<Infinite> | false;
|
|
209
|
-
/**
|
|
210
|
-
* Add suspense query hooks.
|
|
211
|
-
*/
|
|
212
|
-
suspense?: Partial<Suspense> | false;
|
|
213
|
-
queryKey?: QueryKey;
|
|
214
|
-
/**
|
|
215
|
-
* Configure useQuery behavior.
|
|
216
|
-
*/
|
|
217
|
-
query?: Partial<Query> | false;
|
|
218
|
-
mutationKey?: MutationKey;
|
|
219
|
-
/**
|
|
220
|
-
* Configure useMutation behavior.
|
|
221
|
-
*/
|
|
222
|
-
mutation?: Partial<Mutation> | false;
|
|
223
|
-
/**
|
|
224
|
-
* Use a custom hook to customize hook options and generate a HookOptions type.
|
|
225
|
-
*/
|
|
226
|
-
customOptions?: CustomOptions;
|
|
227
|
-
/**
|
|
228
|
-
* Parser to use for validating response data.
|
|
229
|
-
*/
|
|
230
|
-
parser?: PluginClient['options']['parser'];
|
|
231
|
-
transformers?: {
|
|
232
|
-
/**
|
|
233
|
-
* Override the default naming for hooks.
|
|
234
|
-
*/
|
|
235
|
-
name?: (name: string, type?: string) => string;
|
|
236
|
-
};
|
|
237
|
-
/**
|
|
238
|
-
* Override naming conventions for function names and types.
|
|
239
|
-
*/
|
|
240
|
-
resolver?: Partial<ResolverReactQuery> & ThisType<ResolverReactQuery>;
|
|
241
|
-
/**
|
|
242
|
-
* AST visitor to transform generated nodes.
|
|
243
|
-
*/
|
|
244
|
-
transformer?: ast.Visitor;
|
|
245
|
-
/**
|
|
246
|
-
* Additional generators alongside the default generators.
|
|
247
|
-
*/
|
|
248
|
-
generators?: Array<Generator<PluginReactQuery>>;
|
|
249
|
-
};
|
|
250
|
-
type ResolvedOptions = {
|
|
251
|
-
output: Output;
|
|
252
|
-
group: Group | undefined;
|
|
253
|
-
exclude: NonNullable<Options['exclude']>;
|
|
254
|
-
include: Options['include'];
|
|
255
|
-
override: NonNullable<Options['override']>;
|
|
256
|
-
client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>;
|
|
257
|
-
parser: Required<NonNullable<Options['parser']>>;
|
|
258
|
-
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
259
|
-
paramsCasing: Options['paramsCasing'];
|
|
260
|
-
paramsType: NonNullable<Options['paramsType']>;
|
|
261
|
-
/**
|
|
262
|
-
* Only used for infinite
|
|
263
|
-
*/
|
|
264
|
-
infinite: NonNullable<Infinite> | false;
|
|
265
|
-
suspense: Suspense | false;
|
|
266
|
-
queryKey: QueryKey | undefined;
|
|
267
|
-
query: NonNullable<Required<Query>> | false;
|
|
268
|
-
mutationKey: MutationKey | undefined;
|
|
269
|
-
mutation: NonNullable<Required<Mutation>> | false;
|
|
270
|
-
customOptions: NonNullable<Required<CustomOptions>> | undefined;
|
|
271
|
-
resolver: ResolverReactQuery;
|
|
272
|
-
transformers: NonNullable<Options['transformers']>;
|
|
273
|
-
};
|
|
274
|
-
type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options, ResolvedOptions, ResolverReactQuery>;
|
|
275
|
-
declare global {
|
|
276
|
-
namespace Kubb {
|
|
277
|
-
interface PluginRegistry {
|
|
278
|
-
'plugin-react-query': PluginReactQuery;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
//#endregion
|
|
283
|
-
export { MutationKey$1 as a, QueryKey$1 as i, Options as n, PluginReactQuery as r, Infinite as t };
|
|
284
|
-
//# sourceMappingURL=types-DfaFRSBf.d.ts.map
|