@kubb/plugin-svelte-query 3.0.0-alpha.31 → 3.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.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/dist/{chunk-WAAKXO6O.cjs → chunk-HUR476BL.cjs} +125 -21
  3. package/dist/chunk-HUR476BL.cjs.map +1 -0
  4. package/dist/{chunk-B7GVNGYU.js → chunk-LSV2AJSI.js} +125 -21
  5. package/dist/chunk-LSV2AJSI.js.map +1 -0
  6. package/dist/{chunk-TZ5HDOZR.js → chunk-NH7LXCFD.js} +15 -8
  7. package/dist/chunk-NH7LXCFD.js.map +1 -0
  8. package/dist/{chunk-DUG3WM5P.cjs → chunk-VO3QBBZG.cjs} +24 -17
  9. package/dist/chunk-VO3QBBZG.cjs.map +1 -0
  10. package/dist/components.cjs +6 -6
  11. package/dist/components.d.cts +11 -6
  12. package/dist/components.d.ts +11 -6
  13. package/dist/components.js +1 -1
  14. package/dist/generators.cjs +4 -4
  15. package/dist/generators.d.cts +1 -1
  16. package/dist/generators.d.ts +1 -1
  17. package/dist/generators.js +2 -2
  18. package/dist/index.cjs +6 -5
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +5 -4
  23. package/dist/index.js.map +1 -1
  24. package/dist/types-Cg7Z4H-7.d.cts +200 -0
  25. package/dist/types-Cg7Z4H-7.d.ts +200 -0
  26. package/package.json +14 -14
  27. package/src/components/Mutation.tsx +7 -3
  28. package/src/components/Query.tsx +62 -6
  29. package/src/components/QueryOptions.tsx +47 -7
  30. package/src/generators/__snapshots__/findByTagsObject.ts +60 -0
  31. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +1 -3
  32. package/src/generators/mutationGenerator.tsx +2 -1
  33. package/src/generators/queryGenerator.tsx +3 -1
  34. package/src/plugin.ts +3 -2
  35. package/src/types.ts +18 -39
  36. package/dist/chunk-B7GVNGYU.js.map +0 -1
  37. package/dist/chunk-DUG3WM5P.cjs.map +0 -1
  38. package/dist/chunk-TZ5HDOZR.js.map +0 -1
  39. package/dist/chunk-WAAKXO6O.cjs.map +0 -1
  40. package/dist/types-s0tn0Q8J.d.cts +0 -138
  41. package/dist/types-s0tn0Q8J.d.ts +0 -138
@@ -0,0 +1,200 @@
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$1 = {
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$1>>;
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
+ * ReturnType that will be used when calling the client.
41
+ * - 'data' will return ResponseConfig[data].
42
+ * - 'full' will return ResponseConfig.
43
+ * @default 'data'
44
+ */
45
+ dataReturnType?: 'data' | 'full';
46
+ /**
47
+ * How to pass your params
48
+ * - 'object' will return the params and pathParams as an object.
49
+ * - 'inline' will return the params as comma separated params.
50
+ * @default 'inline'
51
+ */
52
+ paramsType?: 'object' | 'inline';
53
+ /**
54
+ * How to pass your pathParams.
55
+ * - 'object' will return the pathParams as an object.
56
+ * - 'inline' will return the pathParams as comma separated params.
57
+ * @default 'inline'
58
+ */
59
+ pathParamsType?: 'object' | 'inline';
60
+ /**
61
+ * Which parser can be used before returning the data
62
+ * - 'zod' will use `@kubb/plugin-zod` to parse the data.
63
+ * @default 'client'
64
+ */
65
+ parser?: 'client' | 'zod';
66
+ transformers?: {
67
+ /**
68
+ * Customize the names based on the type that is provided by the plugin.
69
+ */
70
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
71
+ };
72
+ /**
73
+ * Define some generators next to the client generators
74
+ */
75
+ generators?: Array<Generator<PluginClient>>;
76
+ };
77
+ type ResolvedOptions$1 = {
78
+ output: Output;
79
+ group?: Options$1['group'];
80
+ baseURL: string | undefined;
81
+ parser: NonNullable<Options$1['parser']>;
82
+ importPath: NonNullable<Options$1['importPath']>;
83
+ dataReturnType: NonNullable<Options$1['dataReturnType']>;
84
+ pathParamsType: NonNullable<Options$1['pathParamsType']>;
85
+ paramsType: NonNullable<Options$1['paramsType']>;
86
+ };
87
+ type PluginClient = PluginFactoryOptions<'plugin-client', Options$1, ResolvedOptions$1, never, ResolvePathOptions>;
88
+
89
+ type Query = {
90
+ /**
91
+ * Customize the queryKey, here you can specify a suffix.
92
+ */
93
+ key: (key: unknown[]) => unknown[];
94
+ /**
95
+ * Define which HttpMethods can be used for queries
96
+ * @default ['get']
97
+ */
98
+ methods: Array<HttpMethod>;
99
+ /**
100
+ * Path to the useQuery that will be used to do the useQuery functionality.
101
+ * It will be used as `import { useQuery } from '${importPath}'`.
102
+ * It allows both relative and absolute path.
103
+ * the path will be applied as is, so relative path should be based on the file being generated.
104
+ * @default '@tanstack/svelte-query'
105
+ */
106
+ importPath?: string;
107
+ };
108
+ type Mutation = {
109
+ /**
110
+ * Customize the queryKey, here you can specify a suffix.
111
+ */
112
+ key: (key: unknown[]) => unknown[];
113
+ /**
114
+ * Define which HttpMethods can be used for mutations
115
+ * @default ['post', 'put', 'delete']
116
+ */
117
+ methods: Array<HttpMethod>;
118
+ /**
119
+ * Path to the useQuery that will be used to do the useQuery functionality.
120
+ * It will be used as `import { useQuery } from '${importPath}'`.
121
+ * It allows both relative and absolute path.
122
+ * the path will be applied as is, so relative path should be based on the file being generated.
123
+ * @default '@tanstack/svelte-query'
124
+ */
125
+ importPath?: string;
126
+ };
127
+ type Options = {
128
+ /**
129
+ * Specify the export location for the files and define the behavior of the output
130
+ * @default { path: 'hooks', barrelType: 'named' }
131
+ */
132
+ output?: Output;
133
+ /**
134
+ * Group the @tanstack/query hooks based on the provided name.
135
+ */
136
+ group?: Group;
137
+ client?: Pick<PluginClient['options'], 'dataReturnType' | 'importPath'>;
138
+ /**
139
+ * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
140
+ */
141
+ exclude?: Array<Exclude>;
142
+ /**
143
+ * Array containing include parameters to include tags/operations/methods/paths.
144
+ */
145
+ include?: Array<Include>;
146
+ /**
147
+ * Array containing override parameters to override `options` based on tags/operations/methods/paths.
148
+ */
149
+ override?: Array<Override<ResolvedOptions>>;
150
+ /**
151
+ * How to pass your params
152
+ * - 'object' will return the params and pathParams as an object.
153
+ * - 'inline' will return the params as comma separated params.
154
+ * @default 'inline'
155
+ */
156
+ paramsType?: 'object' | 'inline';
157
+ /**
158
+ * How to pass your pathParams.
159
+ * - 'object' will return the pathParams as an object.
160
+ * - 'inline' will return the pathParams as comma separated params.
161
+ * @default 'inline'
162
+ */
163
+ pathParamsType?: PluginClient['options']['pathParamsType'];
164
+ /**
165
+ * Override some useQuery behaviours.
166
+ */
167
+ query?: Partial<Query> | false;
168
+ /**
169
+ * Override some useMutation behaviours.
170
+ */
171
+ mutation?: Mutation | false;
172
+ /**
173
+ * Which parser should be used before returning the data to `@tanstack/query`.
174
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
175
+ */
176
+ parser?: PluginClient['options']['parser'];
177
+ transformers?: {
178
+ /**
179
+ * Customize the names based on the type that is provided by the plugin.
180
+ */
181
+ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string;
182
+ };
183
+ /**
184
+ * Define some generators next to the svelte-query generators
185
+ */
186
+ generators?: Array<Generator<PluginSvelteQuery>>;
187
+ };
188
+ type ResolvedOptions = {
189
+ output: Output;
190
+ baseURL: string | undefined;
191
+ client: Required<NonNullable<PluginSvelteQuery['options']['client']>>;
192
+ parser: Required<NonNullable<Options['parser']>>;
193
+ paramsType: NonNullable<Options['paramsType']>;
194
+ pathParamsType: NonNullable<Options['pathParamsType']>;
195
+ query: NonNullable<Required<Query>> | false;
196
+ mutation: NonNullable<Required<Mutation>> | false;
197
+ };
198
+ type PluginSvelteQuery = PluginFactoryOptions<'plugin-svelte-query', Options, ResolvedOptions, never, ResolvePathOptions>;
199
+
200
+ export type { Options as O, PluginSvelteQuery as P };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-svelte-query",
3
- "version": "3.0.0-alpha.31",
3
+ "version": "3.0.0-beta.10",
4
4
  "description": "Generator svelte-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-alpha.31",
66
- "@kubb/fs": "3.0.0-alpha.31",
67
- "@kubb/oas": "3.0.0-alpha.31",
68
- "@kubb/plugin-oas": "3.0.0-alpha.31",
69
- "@kubb/plugin-ts": "3.0.0-alpha.31",
70
- "@kubb/plugin-zod": "3.0.0-alpha.31",
71
- "@kubb/react": "3.0.0-alpha.31"
65
+ "@kubb/core": "3.0.0-beta.10",
66
+ "@kubb/fs": "3.0.0-beta.10",
67
+ "@kubb/oas": "3.0.0-beta.10",
68
+ "@kubb/plugin-oas": "3.0.0-beta.10",
69
+ "@kubb/plugin-ts": "3.0.0-beta.10",
70
+ "@kubb/plugin-zod": "3.0.0-beta.10",
71
+ "@kubb/react": "3.0.0-beta.10"
72
72
  },
73
73
  "devDependencies": {
74
- "@types/react": "^18.3.10",
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-alpha.31",
79
- "@kubb/config-tsup": "3.0.0-alpha.31"
76
+ "tsup": "^8.3.5",
77
+ "typescript": "^5.6.3",
78
+ "@kubb/config-ts": "3.0.0-beta.10",
79
+ "@kubb/config-tsup": "3.0.0-beta.10"
80
80
  },
81
81
  "peerDependencies": {
82
- "@kubb/react": "3.0.0-alpha.31"
82
+ "@kubb/react": "3.0.0-beta.10"
83
83
  },
84
84
  "engines": {
85
85
  "node": ">=20"
@@ -19,6 +19,7 @@ type Props = {
19
19
  mutationKeyName: string
20
20
  typeSchemas: OperationSchemas
21
21
  operation: Operation
22
+ paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
22
23
  dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']
23
24
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
24
25
  }
@@ -58,7 +59,7 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
58
59
  options: {
59
60
  type: `
60
61
  {
61
- mutation?: CreateMutationOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `{${TRequest}}`].join(', ')}>,
62
+ mutation?: CreateMutationOptions<${[TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', TRequest ? `{${TRequest}}` : undefined].filter(Boolean).join(', ')}>,
62
63
  client?: ${typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>'},
63
64
  }
64
65
  `,
@@ -67,7 +68,7 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
67
68
  })
68
69
  }
69
70
 
70
- export function Mutation({ name, clientName, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props): ReactNode {
71
+ export function Mutation({ name, clientName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props): ReactNode {
71
72
  const mutationKeyParams = MutationKey.getParams({
72
73
  pathParamsType,
73
74
  typeSchemas,
@@ -80,6 +81,7 @@ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typ
80
81
  })
81
82
 
82
83
  const clientParams = Client.getParams({
84
+ paramsType,
83
85
  typeSchemas,
84
86
  pathParamsType,
85
87
  })
@@ -124,7 +126,9 @@ export function Mutation({ name, clientName, pathParamsType, dataReturnType, typ
124
126
 
125
127
  const TRequest = mutationParams.toConstructor({ valueAsType: true })
126
128
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
127
- const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', `{${TRequest}}`].join(', ')
129
+ const generics = [TData, typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error', TRequest ? `{${TRequest}}` : undefined]
130
+ .filter(Boolean)
131
+ .join(', ')
128
132
 
129
133
  return (
130
134
  <File.Source name={name} isExportable isIndexable>
@@ -18,24 +18,68 @@ type Props = {
18
18
  queryKeyTypeName: string
19
19
  typeSchemas: OperationSchemas
20
20
  operation: Operation
21
+ paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
21
22
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
22
23
  dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']
23
24
  }
24
25
 
25
26
  type GetParamsProps = {
27
+ paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
26
28
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
27
29
  dataReturnType: PluginSvelteQuery['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: PluginSvelteQuery['resolvedOptions']['paramsType']
17
18
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
18
19
  }
19
20
 
20
21
  type GetParamsProps = {
22
+ paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
21
23
  pathParamsType: PluginSvelteQuery['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,9 +92,10 @@ 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({
98
+ paramsType,
59
99
  typeSchemas,
60
100
  pathParamsType,
61
101
  })
@@ -0,0 +1,60 @@
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
+ ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
55
+ }) as CreateQueryResult<TData, FindPetsByTags400> & {
56
+ queryKey: TQueryKey;
57
+ };
58
+ query.queryKey = queryKey as TQueryKey;
59
+ return query;
60
+ }
@@ -11,9 +11,7 @@ import { createMutation } from "@tanstack/svelte-query";
11
11
  * @summary Updates a pet in the store with form data
12
12
  * @link /pet/:petId
13
13
  */
14
- async function updatePetWithForm({ petId }: {
15
- petId: UpdatePetWithFormPathParams["petId"];
16
- }, data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
14
+ async function updatePetWithForm({ petId }: UpdatePetWithFormPathParams, data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
17
15
  const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
18
16
  return updatePetWithFormMutationResponse.parse(res.data);
19
17
  }
@@ -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,6 +88,7 @@ export const mutationGenerator = createReactGenerator<PluginSvelteQuery>({
89
88
  typeSchemas={type.schemas}
90
89
  zodSchemas={zod.schemas}
91
90
  dataReturnType={options.client.dataReturnType}
91
+ paramsType={options.paramsType}
92
92
  pathParamsType={options.pathParamsType}
93
93
  parser={options.parser}
94
94
  />
@@ -99,6 +99,7 @@ export const mutationGenerator = createReactGenerator<PluginSvelteQuery>({
99
99
  typeSchemas={type.schemas}
100
100
  operation={operation}
101
101
  dataReturnType={options.client.dataReturnType}
102
+ paramsType={options.paramsType}
102
103
  pathParamsType={options.pathParamsType}
103
104
  mutationKeyName={mutationKey.name}
104
105
  />
@@ -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'
@@ -95,6 +94,7 @@ export const queryGenerator = createReactGenerator<PluginSvelteQuery>({
95
94
  typeSchemas={type.schemas}
96
95
  zodSchemas={zod.schemas}
97
96
  dataReturnType={options.client.dataReturnType}
97
+ paramsType={options.paramsType}
98
98
  pathParamsType={options.pathParamsType}
99
99
  parser={options.parser}
100
100
  />
@@ -103,6 +103,7 @@ export const queryGenerator = createReactGenerator<PluginSvelteQuery>({
103
103
  clientName={client.name}
104
104
  queryKeyName={queryKey.name}
105
105
  typeSchemas={type.schemas}
106
+ paramsType={options.paramsType}
106
107
  pathParamsType={options.pathParamsType}
107
108
  />
108
109
  <Query
@@ -111,6 +112,7 @@ export const queryGenerator = createReactGenerator<PluginSvelteQuery>({
111
112
  typeSchemas={type.schemas}
112
113
  pathParamsType={options.pathParamsType}
113
114
  operation={operation}
115
+ paramsType={options.paramsType}
114
116
  dataReturnType={options.client.dataReturnType}
115
117
  queryKeyName={queryKey.name}
116
118
  queryKeyTypeName={queryKey.typeName}
package/src/plugin.ts CHANGED
@@ -2,7 +2,6 @@ import path from 'node:path'
2
2
 
3
3
  import { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'
4
4
  import { camelCase, pascalCase } from '@kubb/core/transformers'
5
- import { renderTemplate } from '@kubb/core/utils'
6
5
  import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
7
6
 
8
7
  import { pluginTsName } from '@kubb/plugin-ts'
@@ -24,6 +23,7 @@ export const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((options) => {
24
23
  override = [],
25
24
  parser = 'client',
26
25
  transformers = {},
26
+ paramsType = 'inline',
27
27
  pathParamsType = 'inline',
28
28
  mutation = {},
29
29
  query = {},
@@ -53,7 +53,8 @@ export const pluginSvelteQuery = createPlugin<PluginSvelteQuery>((options) => {
53
53
  importPath: '@tanstack/svelte-query',
54
54
  ...mutation,
55
55
  },
56
- pathParamsType,
56
+ paramsType,
57
+ pathParamsType: paramsType === 'object' ? 'object' : pathParamsType,
57
58
  parser,
58
59
  },
59
60
  pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),