@kubb/plugin-solid-query 3.0.0-beta.1 → 3.0.0-beta.11

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 (37) hide show
  1. package/dist/{chunk-KFG7HL6L.js → chunk-2B3CNYIU.js} +121 -18
  2. package/dist/chunk-2B3CNYIU.js.map +1 -0
  3. package/dist/{chunk-PUTMS357.cjs → chunk-6Y63UXMY.cjs} +26 -19
  4. package/dist/chunk-6Y63UXMY.cjs.map +1 -0
  5. package/dist/{chunk-PZTHP4L4.cjs → chunk-SEUXRTS6.cjs} +121 -18
  6. package/dist/chunk-SEUXRTS6.cjs.map +1 -0
  7. package/dist/{chunk-5BGA4ELO.js → chunk-XQNPFOE7.js} +20 -13
  8. package/dist/chunk-XQNPFOE7.js.map +1 -0
  9. package/dist/components.cjs +4 -4
  10. package/dist/components.d.cts +9 -5
  11. package/dist/components.d.ts +9 -5
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +3 -3
  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 +19 -22
  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 +18 -21
  22. package/dist/index.js.map +1 -1
  23. package/dist/types-CTn1SVDk.d.cts +323 -0
  24. package/dist/types-CTn1SVDk.d.ts +323 -0
  25. package/package.json +14 -14
  26. package/src/components/Query.tsx +62 -6
  27. package/src/components/QueryOptions.tsx +47 -7
  28. package/src/generators/__snapshots__/findByTagsObject.ts +61 -0
  29. package/src/generators/queryGenerator.tsx +4 -2
  30. package/src/plugin.ts +17 -19
  31. package/src/types.ts +17 -22
  32. package/dist/chunk-5BGA4ELO.js.map +0 -1
  33. package/dist/chunk-KFG7HL6L.js.map +0 -1
  34. package/dist/chunk-PUTMS357.cjs.map +0 -1
  35. package/dist/chunk-PZTHP4L4.cjs.map +0 -1
  36. package/dist/types-B6vCm2AO.d.cts +0 -177
  37. package/dist/types-B6vCm2AO.d.ts +0 -177
@@ -0,0 +1,323 @@
1
+ import { PluginFactoryOptions, Output, Group, ResolveNameParams } from '@kubb/core';
2
+ import { HttpMethod } from '@kubb/oas';
3
+ import { ResolvePathOptions, Exclude, Include, Override, Generator } 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 Suspense = object;
94
+ type Query$1 = {
95
+ /**
96
+ * Customize the queryKey, here you can specify a suffix.
97
+ */
98
+ key: (key: unknown[]) => unknown[];
99
+ /**
100
+ * Define which HttpMethods can be used for queries
101
+ * @default ['get']
102
+ */
103
+ methods: Array<HttpMethod>;
104
+ /**
105
+ * Path to the useQuery that will be used to do the useQuery functionality.
106
+ * It will be used as `import { useQuery } from '${importPath}'`.
107
+ * It allows both relative and absolute path.
108
+ * the path will be applied as is, so relative path should be based on the file being generated.
109
+ * @default '@tanstack/react-query'
110
+ */
111
+ importPath?: string;
112
+ };
113
+ type Mutation = {
114
+ /**
115
+ * Customize the queryKey, here you can specify a suffix.
116
+ */
117
+ key: (key: unknown[]) => unknown[];
118
+ /**
119
+ * Define which HttpMethods can be used for mutations
120
+ * @default ['post', 'put', 'delete']
121
+ */
122
+ methods: Array<HttpMethod>;
123
+ /**
124
+ * Path to the useQuery that will be used to do the useQuery functionality.
125
+ * It will be used as `import { useQuery } from '${importPath}'`.
126
+ * It allows both relative and absolute path.
127
+ * the path will be applied as is, so relative path should be based on the file being generated.
128
+ * @default '@tanstack/react-query'
129
+ */
130
+ importPath?: string;
131
+ };
132
+ type Infinite = {
133
+ /**
134
+ * Specify the params key used for `pageParam`.
135
+ * @default 'id'
136
+ */
137
+ queryParam: string;
138
+ /**
139
+ * Which field of the data will be used, set it to undefined when no cursor is known.
140
+ */
141
+ cursorParam?: string | undefined;
142
+ /**
143
+ * The initial value, the value of the first page.
144
+ * @default 0
145
+ */
146
+ initialPageParam: unknown;
147
+ };
148
+ type Options$1 = {
149
+ /**
150
+ * Specify the export location for the files and define the behavior of the output
151
+ * @default { path: 'hooks', barrelType: 'named' }
152
+ */
153
+ output?: Output;
154
+ /**
155
+ * Group the @tanstack/query hooks based on the provided name.
156
+ */
157
+ group?: Group;
158
+ client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
159
+ /**
160
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
161
+ */
162
+ exclude?: Array<Exclude>;
163
+ /**
164
+ * Array containing include parameters to include tags/operations/methods/paths.
165
+ */
166
+ include?: Array<Include>;
167
+ /**
168
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
169
+ */
170
+ override?: Array<Override<ResolvedOptions$1>>;
171
+ /**
172
+ * How to pass your params
173
+ * - 'object' will return the params and pathParams as an object.
174
+ * - 'inline' will return the params as comma separated params.
175
+ * @default 'inline'
176
+ */
177
+ paramsType?: 'object' | 'inline';
178
+ /**
179
+ * How to pass your pathParams.
180
+ * - 'object' will return the pathParams as an object.
181
+ * - 'inline' will return the pathParams as comma separated params.
182
+ * @default 'inline'
183
+ */
184
+ pathParamsType?: PluginClient['options']['pathParamsType'];
185
+ /**
186
+ * When set, an infiniteQuery hooks will be added.
187
+ */
188
+ infinite?: Partial<Infinite> | false;
189
+ /**
190
+ * When set, a suspenseQuery hooks will be added.
191
+ */
192
+ suspense?: Partial<Suspense> | false;
193
+ /**
194
+ * Override some useQuery behaviours.
195
+ */
196
+ query?: Partial<Query$1> | false;
197
+ /**
198
+ * Override some useMutation behaviours.
199
+ */
200
+ mutation?: Partial<Mutation> | false;
201
+ /**
202
+ * Which parser should be used before returning the data to `@tanstack/query`.
203
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
204
+ */
205
+ parser?: PluginClient['options']['parser'];
206
+ transformers?: {
207
+ /**
208
+ * Customize the names based on the type that is provided by the plugin.
209
+ */
210
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
211
+ };
212
+ /**
213
+ * Define some generators next to the react-query generators
214
+ */
215
+ generators?: Array<Generator<PluginReactQuery>>;
216
+ };
217
+ type ResolvedOptions$1 = {
218
+ output: Output;
219
+ client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
220
+ baseURL?: string;
221
+ };
222
+ parser: Required<NonNullable<Options$1['parser']>>;
223
+ pathParamsType: NonNullable<Options$1['pathParamsType']>;
224
+ paramsType: NonNullable<Options$1['paramsType']>;
225
+ /**
226
+ * Only used of infinite
227
+ */
228
+ infinite: NonNullable<Infinite> | false;
229
+ suspense: Suspense | false;
230
+ query: NonNullable<Required<Query$1>> | false;
231
+ mutation: NonNullable<Required<Mutation>> | false;
232
+ };
233
+ type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
234
+
235
+ type Query = {
236
+ /**
237
+ * Customize the queryKey, here you can specify a suffix.
238
+ */
239
+ key: (key: unknown[]) => unknown[];
240
+ /**
241
+ * Define which HttpMethods can be used for queries
242
+ * @default ['get']
243
+ */
244
+ methods: Array<HttpMethod>;
245
+ /**
246
+ * Path to the useQuery that will be used to do the useQuery functionality.
247
+ * It will be used as `import { useQuery } from '${importPath}'`.
248
+ * It allows both relative and absolute path.
249
+ * the path will be applied as is, so relative path should be based on the file being generated.
250
+ * @default '@tanstack/svelte-query'
251
+ */
252
+ importPath?: string;
253
+ };
254
+ type Options = {
255
+ /**
256
+ * Specify the export location for the files and define the behavior of the output
257
+ * @default { path: 'hooks', barrelType: 'named' }
258
+ */
259
+ output?: Output;
260
+ /**
261
+ * Group the @tanstack/query hooks based on the provided name.
262
+ */
263
+ group?: Group;
264
+ client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath' | 'baseURL'>;
265
+ /**
266
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
267
+ */
268
+ exclude?: Array<Exclude>;
269
+ /**
270
+ * Array containing include parameters to include tags/operations/methods/paths.
271
+ */
272
+ include?: Array<Include>;
273
+ /**
274
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
275
+ */
276
+ override?: Array<Override<ResolvedOptions>>;
277
+ /**
278
+ * How to pass your params
279
+ * - 'object' will return the params and pathParams as an object.
280
+ * - 'inline' will return the params as comma separated params.
281
+ * @default 'inline'
282
+ */
283
+ paramsType?: 'object' | 'inline';
284
+ /**
285
+ * How to pass your pathParams.
286
+ * - 'object' will return the pathParams as an object.
287
+ * - 'inline' will return the pathParams as comma separated params.
288
+ * @default 'inline'
289
+ */
290
+ pathParamsType?: PluginClient['options']['pathParamsType'];
291
+ /**
292
+ * Override some useQuery behaviours.
293
+ */
294
+ query?: Partial<Query> | false;
295
+ /**
296
+ * Which parser should be used before returning the data to `@tanstack/query`.
297
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
298
+ */
299
+ parser?: PluginClient['options']['parser'];
300
+ transformers?: {
301
+ /**
302
+ * Customize the names based on the type that is provided by the plugin.
303
+ */
304
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
305
+ };
306
+ /**
307
+ * Define some generators next to the solid-query generators
308
+ */
309
+ generators?: Array<Generator<PluginSolidQuery>>;
310
+ };
311
+ type ResolvedOptions = {
312
+ output: Output;
313
+ client: Required<Omit<NonNullable<PluginReactQuery['options']['client']>, 'baseURL'>> & {
314
+ baseURL?: string;
315
+ };
316
+ parser: Required<NonNullable<Options['parser']>>;
317
+ paramsType: NonNullable<Options['paramsType']>;
318
+ pathParamsType: NonNullable<Options['pathParamsType']>;
319
+ query: NonNullable<Required<Query>> | false;
320
+ };
321
+ type PluginSolidQuery = PluginFactoryOptions<'plugin-solid-query', Options, ResolvedOptions, never, ResolvePathOptions>;
322
+
323
+ export type { Options as O, PluginSolidQuery as P };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-solid-query",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.11",
4
4
  "description": "Generator solid-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.1",
66
- "@kubb/fs": "3.0.0-beta.1",
67
- "@kubb/oas": "3.0.0-beta.1",
68
- "@kubb/plugin-oas": "3.0.0-beta.1",
69
- "@kubb/plugin-ts": "3.0.0-beta.1",
70
- "@kubb/plugin-zod": "3.0.0-beta.1",
71
- "@kubb/react": "3.0.0-beta.1"
65
+ "@kubb/core": "3.0.0-beta.11",
66
+ "@kubb/fs": "3.0.0-beta.11",
67
+ "@kubb/oas": "3.0.0-beta.11",
68
+ "@kubb/plugin-oas": "3.0.0-beta.11",
69
+ "@kubb/plugin-ts": "3.0.0-beta.11",
70
+ "@kubb/plugin-zod": "3.0.0-beta.11",
71
+ "@kubb/react": "3.0.0-beta.11"
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",
77
- "typescript": "^5.6.2",
78
- "@kubb/config-ts": "3.0.0-beta.1",
79
- "@kubb/config-tsup": "3.0.0-beta.1"
76
+ "tsup": "^8.3.5",
77
+ "typescript": "^5.6.3",
78
+ "@kubb/config-ts": "3.0.0-beta.11",
79
+ "@kubb/config-tsup": "3.0.0-beta.11"
80
80
  },
81
81
  "peerDependencies": {
82
- "@kubb/react": "3.0.0-beta.1"
82
+ "@kubb/react": "3.0.0-beta.11"
83
83
  },
84
84
  "engines": {
85
85
  "node": ">=20"
@@ -18,24 +18,68 @@ type Props = {
18
18
  queryKeyTypeName: string
19
19
  typeSchemas: OperationSchemas
20
20
  operation: Operation
21
+ paramsType: PluginSolidQuery['resolvedOptions']['paramsType']
21
22
  pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
22
23
  dataReturnType: PluginSolidQuery['resolvedOptions']['client']['dataReturnType']
23
24
  }
24
25
 
25
26
  type GetParamsProps = {
27
+ paramsType: PluginSolidQuery['resolvedOptions']['paramsType']
26
28
  pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
27
29
  dataReturnType: PluginSolidQuery['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, { typed: true }),
42
+ data: typeSchemas.request?.name
43
+ ? {
44
+ type: typeSchemas.request?.name,
45
+ optional: isOptional(typeSchemas.request?.schema),
46
+ }
47
+ : undefined,
48
+ params: typeSchemas.queryParams?.name
49
+ ? {
50
+ type: typeSchemas.queryParams?.name,
51
+ optional: isOptional(typeSchemas.queryParams?.schema),
52
+ }
53
+ : undefined,
54
+ headers: typeSchemas.headerParams?.name
55
+ ? {
56
+ type: typeSchemas.headerParams?.name,
57
+ optional: isOptional(typeSchemas.headerParams?.schema),
58
+ }
59
+ : undefined,
60
+ },
61
+ },
62
+ options: {
63
+ type: `
64
+ {
65
+ query?: Partial<CreateBaseQueryOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', 'TData', 'TQueryData', 'TQueryKey'].join(', ')}>>,
66
+ client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'}
67
+ }
68
+ `,
69
+ default: '{}',
70
+ },
71
+ })
72
+ }
73
+
34
74
  return FunctionParams.factory({
35
- pathParams: {
36
- mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
37
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
38
- },
75
+ pathParams: typeSchemas.pathParams?.name
76
+ ? {
77
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
78
+ children: getPathParams(typeSchemas.pathParams, { typed: true }),
79
+ type: typeSchemas.pathParams?.name,
80
+ optional: isOptional(typeSchemas.pathParams?.schema),
81
+ }
82
+ : undefined,
39
83
  data: typeSchemas.request?.name
40
84
  ? {
41
85
  type: typeSchemas.request?.name,
@@ -66,7 +110,17 @@ function getParams({ pathParamsType, dataReturnType, typeSchemas }: GetParamsPro
66
110
  })
67
111
  }
68
112
 
69
- export function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName, pathParamsType, dataReturnType, typeSchemas, operation }: Props): ReactNode {
113
+ export function Query({
114
+ name,
115
+ queryKeyTypeName,
116
+ queryOptionsName,
117
+ queryKeyName,
118
+ paramsType,
119
+ pathParamsType,
120
+ dataReturnType,
121
+ typeSchemas,
122
+ operation,
123
+ }: Props): ReactNode {
70
124
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
71
125
  const returnType = `CreateQueryResult<${['TData', typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'].join(', ')}> & { queryKey: TQueryKey }`
72
126
  const generics = [`TData = ${TData}`, `TQueryData = ${TData}`, `TQueryKey extends QueryKey = ${queryKeyTypeName}`]
@@ -76,10 +130,12 @@ export function Query({ name, queryKeyTypeName, queryOptionsName, queryKeyName,
76
130
  typeSchemas,
77
131
  })
78
132
  const queryOptionsParams = QueryOptions.getParams({
133
+ paramsType,
79
134
  pathParamsType,
80
135
  typeSchemas,
81
136
  })
82
137
  const params = getParams({
138
+ paramsType,
83
139
  pathParamsType,
84
140
  dataReturnType,
85
141
  typeSchemas,
@@ -14,20 +14,59 @@ type Props = {
14
14
  clientName: string
15
15
  queryKeyName: string
16
16
  typeSchemas: OperationSchemas
17
+ paramsType: PluginSolidQuery['resolvedOptions']['paramsType']
17
18
  pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
18
19
  }
19
20
 
20
21
  type GetParamsProps = {
22
+ paramsType: PluginSolidQuery['resolvedOptions']['paramsType']
21
23
  pathParamsType: PluginSolidQuery['resolvedOptions']['pathParamsType']
22
24
  typeSchemas: OperationSchemas
23
25
  }
24
26
 
25
- function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
27
+ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
28
+ if (paramsType === 'object') {
29
+ return FunctionParams.factory({
30
+ data: {
31
+ mode: 'object',
32
+ children: {
33
+ ...getPathParams(typeSchemas.pathParams, { typed: true }),
34
+ data: typeSchemas.request?.name
35
+ ? {
36
+ type: typeSchemas.request?.name,
37
+ optional: isOptional(typeSchemas.request?.schema),
38
+ }
39
+ : undefined,
40
+ params: typeSchemas.queryParams?.name
41
+ ? {
42
+ type: typeSchemas.queryParams?.name,
43
+ optional: isOptional(typeSchemas.queryParams?.schema),
44
+ }
45
+ : undefined,
46
+ headers: typeSchemas.headerParams?.name
47
+ ? {
48
+ type: typeSchemas.headerParams?.name,
49
+ optional: isOptional(typeSchemas.headerParams?.schema),
50
+ }
51
+ : undefined,
52
+ },
53
+ },
54
+ config: {
55
+ type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',
56
+ default: '{}',
57
+ },
58
+ })
59
+ }
60
+
26
61
  return FunctionParams.factory({
27
- pathParams: {
28
- mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
29
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
30
- },
62
+ pathParams: typeSchemas.pathParams?.name
63
+ ? {
64
+ mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
65
+ children: getPathParams(typeSchemas.pathParams, { typed: true }),
66
+ type: typeSchemas.pathParams?.name,
67
+ optional: isOptional(typeSchemas.pathParams?.schema),
68
+ }
69
+ : undefined,
31
70
  data: typeSchemas.request?.name
32
71
  ? {
33
72
  type: typeSchemas.request?.name,
@@ -53,10 +92,11 @@ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
53
92
  })
54
93
  }
55
94
 
56
- export function QueryOptions({ name, clientName, typeSchemas, pathParamsType, queryKeyName }: Props): ReactNode {
57
- const params = getParams({ pathParamsType, typeSchemas })
95
+ export function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
96
+ const params = getParams({ paramsType, pathParamsType, typeSchemas })
58
97
  const clientParams = Client.getParams({
59
98
  typeSchemas,
99
+ paramsType,
60
100
  pathParamsType,
61
101
  })
62
102
  const queryKeyParams = QueryKey.getParams({
@@ -0,0 +1,61 @@
1
+ import client from "@kubb/plugin-client/client";
2
+ import type { RequestConfig } from "@kubb/plugin-client/client";
3
+ import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
4
+ import { createQuery, queryOptions } from "@tanstack/svelte-query";
5
+
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
7
+
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
9
+
10
+ /**
11
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
+ * @summary Finds Pets by tags
13
+ * @link /pet/findByTags
14
+ */
15
+ async function findPetsByTags({ headers, params }: {
16
+ headers: FindPetsByTagsHeaderParams;
17
+ params?: FindPetsByTagsQueryParams;
18
+ }, config: Partial<RequestConfig> = {}) {
19
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
20
+ return findPetsByTagsQueryResponse.parse(res.data);
21
+ }
22
+
23
+ export function findPetsByTagsQueryOptions({ headers, params }: {
24
+ headers: FindPetsByTagsHeaderParams;
25
+ params?: FindPetsByTagsQueryParams;
26
+ }, config: Partial<RequestConfig> = {}) {
27
+ const queryKey = findPetsByTagsQueryKey(params);
28
+ return queryOptions({
29
+ queryKey,
30
+ queryFn: async ({ signal }) => {
31
+ config.signal = signal;
32
+ return findPetsByTags({ headers, params }, config);
33
+ },
34
+ });
35
+ }
36
+
37
+ /**
38
+ * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
39
+ * @summary Finds Pets by tags
40
+ * @link /pet/findByTags
41
+ */
42
+ export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>({ headers, params }: {
43
+ headers: FindPetsByTagsHeaderParams;
44
+ params?: FindPetsByTagsQueryParams;
45
+ }, options: {
46
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
47
+ client?: Partial<RequestConfig>;
48
+ } = {}) {
49
+ const { query: queryOptions, client: config = {} } = options ?? {};
50
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
51
+ const query = createQuery(() => ({
52
+ ...findPetsByTagsQueryOptions({ headers, params }, config) as unknown as CreateBaseQueryOptions,
53
+ queryKey,
54
+ initialData: null,
55
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
56
+ })) as CreateQueryResult<TData, FindPetsByTags400> & {
57
+ queryKey: TQueryKey;
58
+ };
59
+ query.queryKey = queryKey as TQueryKey;
60
+ return query;
61
+ }
@@ -1,4 +1,3 @@
1
- import transformers from '@kubb/core/transformers'
2
1
  import { pluginClientName } from '@kubb/plugin-client'
3
2
  import { Client } from '@kubb/plugin-client/components'
4
3
  import { createReactGenerator } from '@kubb/plugin-oas'
@@ -89,11 +88,12 @@ export const queryGenerator = createReactGenerator<PluginSolidQuery>({
89
88
  name={client.name}
90
89
  isExportable={false}
91
90
  isIndexable={false}
92
- baseURL={options.baseURL}
91
+ baseURL={options.client.baseURL}
93
92
  operation={operation}
94
93
  typeSchemas={type.schemas}
95
94
  zodSchemas={zod.schemas}
96
95
  dataReturnType={options.client.dataReturnType}
96
+ paramsType={options.paramsType}
97
97
  pathParamsType={options.pathParamsType}
98
98
  parser={options.parser}
99
99
  />
@@ -102,12 +102,14 @@ export const queryGenerator = createReactGenerator<PluginSolidQuery>({
102
102
  clientName={client.name}
103
103
  queryKeyName={queryKey.name}
104
104
  typeSchemas={type.schemas}
105
+ paramsType={options.paramsType}
105
106
  pathParamsType={options.pathParamsType}
106
107
  />
107
108
  <Query
108
109
  name={query.name}
109
110
  queryOptionsName={queryOptions.name}
110
111
  typeSchemas={type.schemas}
112
+ paramsType={options.paramsType}
111
113
  pathParamsType={options.pathParamsType}
112
114
  operation={operation}
113
115
  dataReturnType={options.client.dataReturnType}