@kubb/plugin-vue-query 3.0.0-beta.8 → 3.0.0

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 (56) hide show
  1. package/dist/{chunk-S7SEIU2L.cjs → chunk-A7SD37VK.cjs} +114 -97
  2. package/dist/chunk-A7SD37VK.cjs.map +1 -0
  3. package/dist/{chunk-V6YETPDM.js → chunk-DHJLKFYS.js} +240 -26
  4. package/dist/chunk-DHJLKFYS.js.map +1 -0
  5. package/dist/{chunk-FSQSBTBH.cjs → chunk-J4RZRRHQ.cjs} +240 -26
  6. package/dist/chunk-J4RZRRHQ.cjs.map +1 -0
  7. package/dist/{chunk-VAPLKIAH.js → chunk-O4EGNKUX.js} +106 -89
  8. package/dist/chunk-O4EGNKUX.js.map +1 -0
  9. package/dist/components.cjs +8 -8
  10. package/dist/components.d.cts +25 -14
  11. package/dist/components.d.ts +25 -14
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +5 -5
  14. package/dist/generators.d.cts +1 -1
  15. package/dist/generators.d.ts +1 -1
  16. package/dist/generators.js +2 -2
  17. package/dist/index.cjs +23 -24
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.js +22 -23
  22. package/dist/index.js.map +1 -1
  23. package/dist/types-C8LfCZUP.d.cts +389 -0
  24. package/dist/types-C8LfCZUP.d.ts +389 -0
  25. package/package.json +13 -13
  26. package/src/components/InfiniteQuery.tsx +54 -1
  27. package/src/components/InfiniteQueryOptions.tsx +49 -2
  28. package/src/components/Mutation.tsx +7 -3
  29. package/src/components/MutationKey.tsx +11 -5
  30. package/src/components/Query.tsx +65 -2
  31. package/src/components/QueryKey.tsx +17 -7
  32. package/src/components/QueryOptions.tsx +50 -3
  33. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +1 -1
  34. package/src/generators/__snapshots__/clientGetImportPath.ts +1 -1
  35. package/src/generators/__snapshots__/clientPostImportPath.ts +2 -2
  36. package/src/generators/__snapshots__/findByTags.ts +1 -1
  37. package/src/generators/__snapshots__/findByTagsObject.ts +62 -0
  38. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +1 -1
  39. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +2 -2
  40. package/src/generators/__snapshots__/findByTagsWithZod.ts +1 -1
  41. package/src/generators/__snapshots__/findInfiniteByTags.ts +1 -1
  42. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +1 -1
  43. package/src/generators/__snapshots__/postAsQuery.ts +1 -1
  44. package/src/generators/__snapshots__/updatePetById.ts +2 -2
  45. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +3 -5
  46. package/src/generators/infiniteQueryGenerator.tsx +39 -32
  47. package/src/generators/mutationGenerator.tsx +23 -16
  48. package/src/generators/queryGenerator.tsx +24 -18
  49. package/src/plugin.ts +21 -21
  50. package/src/types.ts +35 -14
  51. package/dist/chunk-FSQSBTBH.cjs.map +0 -1
  52. package/dist/chunk-S7SEIU2L.cjs.map +0 -1
  53. package/dist/chunk-V6YETPDM.js.map +0 -1
  54. package/dist/chunk-VAPLKIAH.js.map +0 -1
  55. package/dist/types-BGseXQR_.d.cts +0 -208
  56. package/dist/types-BGseXQR_.d.ts +0 -208
@@ -0,0 +1,389 @@
1
+ import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
2
+ import { HttpMethod, Operation } from '@kubb/oas';
3
+ import { ResolvePathOptions, Exclude, Include, Override, Generator, OperationSchemas } from '@kubb/plugin-oas';
4
+
5
+ type Options$2 = {
6
+ /**
7
+ * Specify the export location for the files and define the behavior of the output
8
+ * @default { path: 'clients', barrelType: 'named' }
9
+ */
10
+ output?: Output;
11
+ /**
12
+ * Group the clients based on the provided name.
13
+ */
14
+ group?: Group;
15
+ /**
16
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
17
+ */
18
+ exclude?: Array<Exclude>;
19
+ /**
20
+ * Array containing include parameters to include tags/operations/methods/paths.
21
+ */
22
+ include?: Array<Include>;
23
+ /**
24
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
25
+ */
26
+ override?: Array<Override<ResolvedOptions$2>>;
27
+ /**
28
+ * Create `operations.ts` file with all operations grouped by methods.
29
+ * @default false
30
+ */
31
+ operations?: boolean;
32
+ /**
33
+ * Path to the client import path that will be used to do the API calls.
34
+ * It will be used as `import client from '${client.importPath}'`.
35
+ * It allows both relative and absolute path but be aware that we will not change the path.
36
+ * @default '@kubb/plugin-client/client'
37
+ */
38
+ importPath?: string;
39
+ /**
40
+ * Allows you to set a custom base url for all generated calls.
41
+ */
42
+ baseURL?: string;
43
+ /**
44
+ * ReturnType that will be used when calling the client.
45
+ * - 'data' will return ResponseConfig[data].
46
+ * - 'full' will return ResponseConfig.
47
+ * @default 'data'
48
+ */
49
+ dataReturnType?: 'data' | 'full';
50
+ /**
51
+ * How to pass your params
52
+ * - 'object' will return the params and pathParams as an object.
53
+ * - 'inline' will return the params as comma separated params.
54
+ * @default 'inline'
55
+ */
56
+ paramsType?: 'object' | 'inline';
57
+ /**
58
+ * How to pass your pathParams.
59
+ * - 'object' will return the pathParams as an object.
60
+ * - 'inline' will return the pathParams as comma separated params.
61
+ * @default 'inline'
62
+ */
63
+ pathParamsType?: 'object' | 'inline';
64
+ /**
65
+ * Which parser can be used before returning the data
66
+ * - 'zod' will use `@kubb/plugin-zod` to parse the data.
67
+ * @default 'client'
68
+ */
69
+ parser?: 'client' | 'zod';
70
+ transformers?: {
71
+ /**
72
+ * Customize the names based on the type that is provided by the plugin.
73
+ */
74
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
75
+ };
76
+ /**
77
+ * Define some generators next to the client generators
78
+ */
79
+ generators?: Array<Generator<PluginClient>>;
80
+ };
81
+ type ResolvedOptions$2 = {
82
+ output: Output;
83
+ group?: Options$2['group'];
84
+ baseURL: string | undefined;
85
+ parser: NonNullable<Options$2['parser']>;
86
+ importPath: NonNullable<Options$2['importPath']>;
87
+ dataReturnType: NonNullable<Options$2['dataReturnType']>;
88
+ pathParamsType: NonNullable<Options$2['pathParamsType']>;
89
+ paramsType: NonNullable<Options$2['paramsType']>;
90
+ };
91
+ type PluginClient = PluginFactoryOptions<'plugin-client', Options$2, ResolvedOptions$2, never, ResolvePathOptions>;
92
+
93
+ type TransformerProps$1 = {
94
+ operation: Operation;
95
+ schemas: OperationSchemas;
96
+ };
97
+ type Transformer$1 = (props: TransformerProps$1) => unknown[];
98
+ type Suspense = object;
99
+ /**
100
+ * Customize the queryKey
101
+ */
102
+ type QueryKey$1 = Transformer$1;
103
+ /**
104
+ * Customize the mutationKey
105
+ */
106
+ type MutationKey$1 = Transformer$1;
107
+ type Query$1 = {
108
+ /**
109
+ * Define which HttpMethods can be used for queries
110
+ * @default ['get']
111
+ */
112
+ methods: Array<HttpMethod>;
113
+ /**
114
+ * Path to the useQuery that will be used to do the useQuery functionality.
115
+ * It will be used as `import { useQuery } from '${importPath}'`.
116
+ * It allows both relative and absolute path.
117
+ * the path will be applied as is, so relative path should be based on the file being generated.
118
+ * @default '@tanstack/react-query'
119
+ */
120
+ importPath?: string;
121
+ };
122
+ type Mutation$1 = {
123
+ /**
124
+ * Define which HttpMethods can be used for mutations
125
+ * @default ['post', 'put', 'delete']
126
+ */
127
+ methods: Array<HttpMethod>;
128
+ /**
129
+ * Path to the useQuery that will be used to do the useQuery functionality.
130
+ * It will be used as `import { useQuery } from '${importPath}'`.
131
+ * It allows both relative and absolute path.
132
+ * the path will be applied as is, so relative path should be based on the file being generated.
133
+ * @default '@tanstack/react-query'
134
+ */
135
+ importPath?: string;
136
+ };
137
+ type Infinite$1 = {
138
+ /**
139
+ * Specify the params key used for `pageParam`.
140
+ * @default 'id'
141
+ */
142
+ queryParam: string;
143
+ /**
144
+ * Which field of the data will be used, set it to undefined when no cursor is known.
145
+ */
146
+ cursorParam?: string | undefined;
147
+ /**
148
+ * The initial value, the value of the first page.
149
+ * @default 0
150
+ */
151
+ initialPageParam: unknown;
152
+ };
153
+ type Options$1 = {
154
+ /**
155
+ * Specify the export location for the files and define the behavior of the output
156
+ * @default { path: 'hooks', barrelType: 'named' }
157
+ */
158
+ output?: Output;
159
+ /**
160
+ * Group the @tanstack/query hooks based on the provided name.
161
+ */
162
+ group?: Group;
163
+ client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
164
+ /**
165
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
166
+ */
167
+ exclude?: Array<Exclude>;
168
+ /**
169
+ * Array containing include parameters to include tags/operations/methods/paths.
170
+ */
171
+ include?: Array<Include>;
172
+ /**
173
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
174
+ */
175
+ override?: Array<Override<ResolvedOptions$1>>;
176
+ /**
177
+ * How to pass your params
178
+ * - 'object' will return the params and pathParams as an object.
179
+ * - 'inline' will return the params as comma separated params.
180
+ * @default 'inline'
181
+ */
182
+ paramsType?: 'object' | 'inline';
183
+ /**
184
+ * How to pass your pathParams.
185
+ * - 'object' will return the pathParams as an object.
186
+ * - 'inline' will return the pathParams as comma separated params.
187
+ * @default 'inline'
188
+ */
189
+ pathParamsType?: PluginClient['options']['pathParamsType'];
190
+ /**
191
+ * When set, an infiniteQuery hooks will be added.
192
+ */
193
+ infinite?: Partial<Infinite$1> | false;
194
+ /**
195
+ * When set, a suspenseQuery hooks will be added.
196
+ */
197
+ suspense?: Partial<Suspense> | false;
198
+ queryKey?: QueryKey$1;
199
+ /**
200
+ * Override some useQuery behaviours.
201
+ */
202
+ query?: Partial<Query$1> | false;
203
+ mutationKey?: MutationKey$1;
204
+ /**
205
+ * Override some useMutation behaviours.
206
+ */
207
+ mutation?: Partial<Mutation$1> | false;
208
+ /**
209
+ * Which parser should be used before returning the data to `@tanstack/query`.
210
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
211
+ */
212
+ parser?: PluginClient['options']['parser'];
213
+ transformers?: {
214
+ /**
215
+ * Customize the names based on the type that is provided by the plugin.
216
+ */
217
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
218
+ };
219
+ /**
220
+ * Define some generators next to the react-query generators
221
+ */
222
+ generators?: Array<Generator<PluginReactQuery>>;
223
+ };
224
+ type ResolvedOptions$1 = {
225
+ output: Output;
226
+ client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
227
+ baseURL?: string;
228
+ };
229
+ parser: Required<NonNullable<Options$1['parser']>>;
230
+ pathParamsType: NonNullable<Options$1['pathParamsType']>;
231
+ paramsType: NonNullable<Options$1['paramsType']>;
232
+ /**
233
+ * Only used of infinite
234
+ */
235
+ infinite: NonNullable<Infinite$1> | false;
236
+ suspense: Suspense | false;
237
+ queryKey: QueryKey$1 | undefined;
238
+ query: NonNullable<Required<Query$1>> | false;
239
+ mutationKey: MutationKey$1 | undefined;
240
+ mutation: NonNullable<Required<Mutation$1>> | false;
241
+ };
242
+ type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
243
+
244
+ type TransformerProps = {
245
+ operation: Operation;
246
+ schemas: OperationSchemas;
247
+ };
248
+ type Transformer = (props: TransformerProps) => unknown[];
249
+ /**
250
+ * Customize the queryKey
251
+ */
252
+ type QueryKey = Transformer;
253
+ /**
254
+ * Customize the mutationKey
255
+ */
256
+ type MutationKey = Transformer;
257
+ type Query = {
258
+ /**
259
+ * Define which HttpMethods can be used for queries
260
+ * @default ['get']
261
+ */
262
+ methods: Array<HttpMethod>;
263
+ /**
264
+ * Path to the useQuery that will be used to do the useQuery functionality.
265
+ * It will be used as `import { useQuery } from '${importPath}'`.
266
+ * It allows both relative and absolute path.
267
+ * the path will be applied as is, so relative path should be based on the file being generated.
268
+ * @default '@tanstack/react-query'
269
+ */
270
+ importPath?: string;
271
+ };
272
+ type Mutation = {
273
+ /**
274
+ * Define which HttpMethods can be used for mutations
275
+ * @default ['post', 'put', 'delete']
276
+ */
277
+ methods: Array<HttpMethod>;
278
+ /**
279
+ * Path to the useQuery that will be used to do the useQuery functionality.
280
+ * It will be used as `import { useQuery } from '${importPath}'`.
281
+ * It allows both relative and absolute path.
282
+ * the path will be applied as is, so relative path should be based on the file being generated.
283
+ * @default '@tanstack/react-query'
284
+ */
285
+ importPath?: string;
286
+ };
287
+ type Infinite = {
288
+ /**
289
+ * Specify the params key used for `pageParam`.
290
+ * @default `'id'`
291
+ */
292
+ queryParam: string;
293
+ /**
294
+ * Which field of the data will be used, set it to undefined when no cursor is known.
295
+ */
296
+ cursorParam?: string | undefined;
297
+ /**
298
+ * The initial value, the value of the first page.
299
+ * @default `0`
300
+ */
301
+ initialPageParam: unknown;
302
+ };
303
+ type Options = {
304
+ /**
305
+ * Specify the export location for the files and define the behavior of the output
306
+ * @default { path: 'hooks', barrelType: 'named' }
307
+ */
308
+ output?: Output;
309
+ /**
310
+ * Group the @tanstack/query hooks based on the provided name.
311
+ */
312
+ group?: Group;
313
+ client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
314
+ /**
315
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
316
+ */
317
+ exclude?: Array<Exclude>;
318
+ /**
319
+ * Array containing include parameters to include tags/operations/methods/paths.
320
+ */
321
+ include?: Array<Include>;
322
+ /**
323
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
324
+ */
325
+ override?: Array<Override<ResolvedOptions>>;
326
+ /**
327
+ * How to pass your params
328
+ * - 'object' will return the params and pathParams as an object.
329
+ * - 'inline' will return the params as comma separated params.
330
+ * @default 'inline'
331
+ */
332
+ paramsType?: 'object' | 'inline';
333
+ /**
334
+ * How to pass your pathParams.
335
+ * - 'object' will return the pathParams as an object.
336
+ * - 'inline' will return the pathParams as comma separated params.
337
+ * @default 'inline'
338
+ */
339
+ pathParamsType?: PluginClient['options']['pathParamsType'];
340
+ /**
341
+ * When set, an infiniteQuery hooks will be added.
342
+ */
343
+ infinite?: Partial<Infinite> | false;
344
+ queryKey?: QueryKey;
345
+ /**
346
+ * Override some useQuery behaviours.
347
+ */
348
+ query?: Partial<Query> | false;
349
+ mutationKey?: MutationKey;
350
+ /**
351
+ * Override some useMutation behaviours.
352
+ */
353
+ mutation?: Mutation | false;
354
+ /**
355
+ * Which parser should be used before returning the data to `@tanstack/query`.
356
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
357
+ */
358
+ parser?: PluginClient['options']['parser'];
359
+ transformers?: {
360
+ /**
361
+ * Customize the names based on the type that is provided by the plugin.
362
+ */
363
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
364
+ };
365
+ /**
366
+ * Define some generators next to the vue-query generators
367
+ */
368
+ generators?: Array<Generator<PluginVueQuery>>;
369
+ };
370
+ type ResolvedOptions = {
371
+ output: Output;
372
+ client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
373
+ baseURL?: string;
374
+ };
375
+ parser: Required<NonNullable<Options['parser']>>;
376
+ paramsType: NonNullable<Options['paramsType']>;
377
+ pathParamsType: NonNullable<Options['pathParamsType']>;
378
+ /**
379
+ * Only used of infinite
380
+ */
381
+ infinite: NonNullable<Infinite> | false;
382
+ queryKey: QueryKey | undefined;
383
+ query: NonNullable<Required<Query>> | false;
384
+ mutationKey: MutationKey | undefined;
385
+ mutation: NonNullable<Required<Mutation>> | false;
386
+ };
387
+ type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, never, ResolvePathOptions>;
388
+
389
+ export type { Infinite as I, Options as O, PluginVueQuery as P, Transformer as T };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-vue-query",
3
- "version": "3.0.0-beta.8",
3
+ "version": "3.0.0",
4
4
  "description": "Generator vue-query hooks",
5
5
  "keywords": [
6
6
  "faker",
@@ -62,24 +62,24 @@
62
62
  "!/**/__tests__/**"
63
63
  ],
64
64
  "dependencies": {
65
- "@kubb/core": "3.0.0-beta.8",
66
- "@kubb/fs": "3.0.0-beta.8",
67
- "@kubb/oas": "3.0.0-beta.8",
68
- "@kubb/plugin-oas": "3.0.0-beta.8",
69
- "@kubb/plugin-ts": "3.0.0-beta.8",
70
- "@kubb/plugin-zod": "3.0.0-beta.8",
71
- "@kubb/react": "3.0.0-beta.8"
65
+ "@kubb/core": "3.0.0",
66
+ "@kubb/oas": "3.0.0",
67
+ "@kubb/fs": "3.0.0",
68
+ "@kubb/plugin-oas": "3.0.0",
69
+ "@kubb/plugin-ts": "3.0.0",
70
+ "@kubb/plugin-zod": "3.0.0",
71
+ "@kubb/react": "3.0.0"
72
72
  },
73
73
  "devDependencies": {
74
- "@types/react": "^18.3.11",
74
+ "@types/react": "^18.3.12",
75
75
  "react": "^18.3.1",
76
- "tsup": "^8.3.0",
76
+ "tsup": "^8.3.5",
77
77
  "typescript": "^5.6.3",
78
- "@kubb/config-ts": "3.0.0-beta.8",
79
- "@kubb/config-tsup": "3.0.0-beta.8"
78
+ "@kubb/config-ts": "3.0.0",
79
+ "@kubb/config-tsup": "3.0.0"
80
80
  },
81
81
  "peerDependencies": {
82
- "@kubb/react": "3.0.0-beta.8"
82
+ "@kubb/react": "3.0.0"
83
83
  },
84
84
  "engines": {
85
85
  "node": ">=20"
@@ -18,22 +18,72 @@ type Props = {
18
18
  queryKeyTypeName: string
19
19
  typeSchemas: OperationSchemas
20
20
  operation: Operation
21
+ paramsType: PluginVueQuery['resolvedOptions']['paramsType']
21
22
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
22
23
  dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
23
24
  }
24
25
 
25
26
  type GetParamsProps = {
27
+ paramsType: PluginVueQuery['resolvedOptions']['paramsType']
26
28
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
27
29
  dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
28
30
  typeSchemas: OperationSchemas
29
31
  }
30
32
 
31
- function getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
33
+ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
32
34
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
33
35
 
36
+ if (paramsType === 'object') {
37
+ return FunctionParams.factory({
38
+ data: {
39
+ mode: 'object',
40
+ children: {
41
+ ...getPathParams(typeSchemas.pathParams, {
42
+ typed: true,
43
+ override(item) {
44
+ return {
45
+ ...item,
46
+ type: `MaybeRef<${item.type}>`,
47
+ }
48
+ },
49
+ }),
50
+ data: typeSchemas.request?.name
51
+ ? {
52
+ type: `MaybeRef<${typeSchemas.request?.name}>`,
53
+ optional: isOptional(typeSchemas.request?.schema),
54
+ }
55
+ : undefined,
56
+ params: typeSchemas.queryParams?.name
57
+ ? {
58
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
59
+ optional: isOptional(typeSchemas.queryParams?.schema),
60
+ }
61
+ : undefined,
62
+ headers: typeSchemas.headerParams?.name
63
+ ? {
64
+ type: `MaybeRef<${typeSchemas.headerParams?.name}>`,
65
+ optional: isOptional(typeSchemas.headerParams?.schema),
66
+ }
67
+ : undefined,
68
+ },
69
+ },
70
+ options: {
71
+ type: `
72
+ {
73
+ query?: Partial<InfiniteQueryObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
74
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}
75
+ }
76
+ `,
77
+ default: '{}',
78
+ },
79
+ })
80
+ }
81
+
34
82
  return FunctionParams.factory({
35
83
  pathParams: {
36
84
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
85
+ type: typeSchemas.pathParams?.name,
86
+ optional: isOptional(typeSchemas.pathParams?.schema),
37
87
  children: getPathParams(typeSchemas.pathParams, {
38
88
  typed: true,
39
89
  override(item) {
@@ -79,6 +129,7 @@ export function InfiniteQuery({
79
129
  queryKeyTypeName,
80
130
  queryOptionsName,
81
131
  queryKeyName,
132
+ paramsType,
82
133
  pathParamsType,
83
134
  dataReturnType,
84
135
  typeSchemas,
@@ -93,10 +144,12 @@ export function InfiniteQuery({
93
144
  typeSchemas,
94
145
  })
95
146
  const queryOptionsParams = QueryOptions.getParams({
147
+ paramsType,
96
148
  pathParamsType,
97
149
  typeSchemas,
98
150
  })
99
151
  const params = getParams({
152
+ paramsType,
100
153
  pathParamsType,
101
154
  dataReturnType,
102
155
  typeSchemas,
@@ -14,6 +14,7 @@ type Props = {
14
14
  clientName: string
15
15
  queryKeyName: string
16
16
  typeSchemas: OperationSchemas
17
+ paramsType: PluginVueQuery['resolvedOptions']['paramsType']
17
18
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
18
19
  dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
19
20
  initialPageParam: Infinite['initialPageParam']
@@ -22,14 +23,58 @@ type Props = {
22
23
  }
23
24
 
24
25
  type GetParamsProps = {
26
+ paramsType: PluginVueQuery['resolvedOptions']['paramsType']
25
27
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
26
28
  typeSchemas: OperationSchemas
27
29
  }
28
30
 
29
- function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
31
+ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
32
+ if (paramsType === 'object') {
33
+ return FunctionParams.factory({
34
+ data: {
35
+ mode: 'object',
36
+ children: {
37
+ ...getPathParams(typeSchemas.pathParams, {
38
+ typed: true,
39
+ override(item) {
40
+ return {
41
+ ...item,
42
+ type: `MaybeRef<${item.type}>`,
43
+ }
44
+ },
45
+ }),
46
+ data: typeSchemas.request?.name
47
+ ? {
48
+ type: `MaybeRef<${typeSchemas.request?.name}>`,
49
+ optional: isOptional(typeSchemas.request?.schema),
50
+ }
51
+ : undefined,
52
+ params: typeSchemas.queryParams?.name
53
+ ? {
54
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
55
+ optional: isOptional(typeSchemas.queryParams?.schema),
56
+ }
57
+ : undefined,
58
+ headers: typeSchemas.headerParams?.name
59
+ ? {
60
+ type: `MaybeRef<${typeSchemas.queryParams?.name}>`,
61
+ optional: isOptional(typeSchemas.headerParams?.schema),
62
+ }
63
+ : undefined,
64
+ },
65
+ },
66
+ config: {
67
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',
68
+ default: '{}',
69
+ },
70
+ })
71
+ }
72
+
30
73
  return FunctionParams.factory({
31
74
  pathParams: {
32
75
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
76
+ type: typeSchemas.pathParams?.name,
77
+ optional: isOptional(typeSchemas.pathParams?.schema),
33
78
  children: getPathParams(typeSchemas.pathParams, {
34
79
  typed: true,
35
80
  override(item) {
@@ -71,13 +116,15 @@ export function InfiniteQueryOptions({
71
116
  initialPageParam,
72
117
  cursorParam,
73
118
  typeSchemas,
119
+ paramsType,
74
120
  dataReturnType,
75
121
  pathParamsType,
76
122
  queryParam,
77
123
  queryKeyName,
78
124
  }: Props): ReactNode {
79
- const params = getParams({ pathParamsType, typeSchemas })
125
+ const params = getParams({ paramsType, pathParamsType, typeSchemas })
80
126
  const clientParams = Client.getParams({
127
+ paramsType,
81
128
  typeSchemas,
82
129
  pathParamsType,
83
130
  })
@@ -19,6 +19,7 @@ type Props = {
19
19
  mutationKeyName: string
20
20
  typeSchemas: OperationSchemas
21
21
  operation: Operation
22
+ paramsType: PluginVueQuery['resolvedOptions']['paramsType']
22
23
  dataReturnType: PluginVueQuery['resolvedOptions']['client']['dataReturnType']
23
24
  pathParamsType: PluginVueQuery['resolvedOptions']['pathParamsType']
24
25
  }
@@ -66,7 +67,7 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
66
67
  options: {
67
68
  type: `
68
69
  {
69
- mutation?: MutationObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `{${TRequest}}`].join(', ')}>,
70
+ mutation?: MutationObserverOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', TRequest ? `{${TRequest}}` : undefined].filter(Boolean).join(', ')}>,
70
71
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},
71
72
  }
72
73
  `,
@@ -75,7 +76,7 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
75
76
  })
76
77
  }
77
78
 
78
- export function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props): ReactNode {
79
+ export function Mutation({ name, clientName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props): ReactNode {
79
80
  const mutationKeyParams = MutationKey.getParams({
80
81
  pathParamsType,
81
82
  typeSchemas,
@@ -88,6 +89,7 @@ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typ
88
89
  })
89
90
 
90
91
  const clientParams = Client.getParams({
92
+ paramsType,
91
93
  typeSchemas,
92
94
  pathParamsType,
93
95
  })
@@ -133,7 +135,9 @@ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typ
133
135
 
134
136
  const TRequest = mutationParams.toConstructor({ valueAsType: true })
135
137
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
136
- const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `{${TRequest}}`].join(', ')
138
+ const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', TRequest ? `{${TRequest}}` : undefined]
139
+ .filter(Boolean)
140
+ .join(', ')
137
141
 
138
142
  return (
139
143
  <File.Source name={name} isExportable isIndexable>