@kubb/plugin-svelte-query 3.1.0 → 3.3.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 (49) hide show
  1. package/dist/{chunk-TOBORUCM.js → chunk-BB5SCJJT.js} +10 -3
  2. package/dist/chunk-BB5SCJJT.js.map +1 -0
  3. package/dist/{chunk-F6TRULM6.cjs → chunk-DJNDGHXY.cjs} +17 -10
  4. package/dist/chunk-DJNDGHXY.cjs.map +1 -0
  5. package/dist/{chunk-SP3FM442.js → chunk-EZRBBWGF.js} +50 -30
  6. package/dist/chunk-EZRBBWGF.js.map +1 -0
  7. package/dist/{chunk-PHEQCKJY.cjs → chunk-YSVAGB5Y.cjs} +50 -30
  8. package/dist/chunk-YSVAGB5Y.cjs.map +1 -0
  9. package/dist/components.cjs +6 -6
  10. package/dist/components.d.cts +17 -9
  11. package/dist/components.d.ts +17 -9
  12. package/dist/components.js +1 -1
  13. package/dist/generators.cjs +4 -4
  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 +8 -6
  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 +5 -3
  22. package/dist/index.js.map +1 -1
  23. package/dist/{types-BxGtUnah.d.ts → types-CdgT4Eeh.d.cts} +29 -2
  24. package/dist/{types-BxGtUnah.d.cts → types-CdgT4Eeh.d.ts} +29 -2
  25. package/package.json +11 -11
  26. package/src/components/Mutation.tsx +18 -4
  27. package/src/components/MutationKey.tsx +5 -4
  28. package/src/components/Query.tsx +9 -3
  29. package/src/components/QueryKey.tsx +9 -6
  30. package/src/components/QueryOptions.tsx +9 -5
  31. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +49 -34
  32. package/src/generators/__snapshots__/clientGetImportPath.ts +49 -34
  33. package/src/generators/__snapshots__/clientPostImportPath.ts +46 -32
  34. package/src/generators/__snapshots__/findByTags.ts +49 -34
  35. package/src/generators/__snapshots__/findByTagsObject.ts +55 -44
  36. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +49 -34
  37. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +49 -34
  38. package/src/generators/__snapshots__/findByTagsWithZod.ts +49 -34
  39. package/src/generators/__snapshots__/postAsQuery.ts +66 -36
  40. package/src/generators/__snapshots__/updatePetById.ts +46 -32
  41. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +46 -34
  42. package/src/generators/mutationGenerator.tsx +3 -0
  43. package/src/generators/queryGenerator.tsx +4 -0
  44. package/src/plugin.ts +3 -1
  45. package/src/types.ts +7 -0
  46. package/dist/chunk-F6TRULM6.cjs.map +0 -1
  47. package/dist/chunk-PHEQCKJY.cjs.map +0 -1
  48. package/dist/chunk-SP3FM442.js.map +0 -1
  49. package/dist/chunk-TOBORUCM.js.map +0 -1
@@ -19,21 +19,23 @@ type Props = {
19
19
  mutationKeyName: string
20
20
  typeSchemas: OperationSchemas
21
21
  operation: Operation
22
+ paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']
22
23
  paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
23
24
  dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']
24
25
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
25
26
  }
26
27
 
27
28
  type GetParamsProps = {
29
+ paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']
28
30
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
29
31
  dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']
30
32
  typeSchemas: OperationSchemas
31
33
  }
32
34
 
33
- function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
35
+ function getParams({ paramsCasing, dataReturnType, typeSchemas }: GetParamsProps) {
34
36
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
35
37
  const mutationParams = FunctionParams.factory({
36
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
38
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
37
39
  data: typeSchemas.request?.name
38
40
  ? {
39
41
  type: typeSchemas.request?.name,
@@ -68,25 +70,37 @@ function getParams({ dataReturnType, typeSchemas }: GetParamsProps) {
68
70
  })
69
71
  }
70
72
 
71
- export function Mutation({ name, clientName, paramsType, pathParamsType, dataReturnType, typeSchemas, operation, mutationKeyName }: Props): ReactNode {
73
+ export function Mutation({
74
+ name,
75
+ clientName,
76
+ paramsCasing,
77
+ paramsType,
78
+ pathParamsType,
79
+ dataReturnType,
80
+ typeSchemas,
81
+ operation,
82
+ mutationKeyName,
83
+ }: Props): ReactNode {
72
84
  const mutationKeyParams = MutationKey.getParams({
73
85
  pathParamsType,
74
86
  typeSchemas,
75
87
  })
76
88
 
77
89
  const params = getParams({
90
+ paramsCasing,
78
91
  pathParamsType,
79
92
  dataReturnType,
80
93
  typeSchemas,
81
94
  })
82
95
 
83
96
  const clientParams = Client.getParams({
97
+ paramsCasing,
84
98
  paramsType,
85
99
  typeSchemas,
86
100
  pathParamsType,
87
101
  })
88
102
  const mutationParams = FunctionParams.factory({
89
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
103
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
90
104
  data: typeSchemas.request?.name
91
105
  ? {
92
106
  type: typeSchemas.request?.name,
@@ -11,6 +11,7 @@ type Props = {
11
11
  typeName: string
12
12
  typeSchemas: OperationSchemas
13
13
  operation: Operation
14
+ paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']
14
15
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
15
16
  transformer: Transformer | undefined
16
17
  }
@@ -24,15 +25,15 @@ function getParams({}: GetParamsProps) {
24
25
  return FunctionParams.factory({})
25
26
  }
26
27
 
27
- const getTransformer: Transformer = ({ operation }) => {
28
- const path = new URLPath(operation.path)
28
+ const getTransformer: Transformer = ({ operation, casing }) => {
29
+ const path = new URLPath(operation.path, { casing })
29
30
 
30
31
  return [JSON.stringify({ url: path.path })].filter(Boolean)
31
32
  }
32
33
 
33
- export function MutationKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
34
+ export function MutationKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
34
35
  const params = getParams({ pathParamsType, typeSchemas })
35
- const keys = transformer({ operation, schemas: typeSchemas })
36
+ const keys = transformer({ operation, schemas: typeSchemas, casing: paramsCasing })
36
37
 
37
38
  return (
38
39
  <>
@@ -18,19 +18,21 @@ type Props = {
18
18
  queryKeyTypeName: string
19
19
  typeSchemas: OperationSchemas
20
20
  operation: Operation
21
+ paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']
21
22
  paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
22
23
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
23
24
  dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']
24
25
  }
25
26
 
26
27
  type GetParamsProps = {
28
+ paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']
27
29
  paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
28
30
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
29
31
  dataReturnType: PluginSvelteQuery['resolvedOptions']['client']['dataReturnType']
30
32
  typeSchemas: OperationSchemas
31
33
  }
32
34
 
33
- function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
35
+ function getParams({ paramsType, paramsCasing, pathParamsType, dataReturnType, typeSchemas }: GetParamsProps) {
34
36
  const TData = dataReturnType === 'data' ? typeSchemas.response.name : `ResponseConfig<${typeSchemas.response.name}>`
35
37
 
36
38
  if (paramsType === 'object') {
@@ -38,7 +40,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
38
40
  data: {
39
41
  mode: 'object',
40
42
  children: {
41
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
43
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
42
44
  data: typeSchemas.request?.name
43
45
  ? {
44
46
  type: typeSchemas.request?.name,
@@ -75,7 +77,7 @@ function getParams({ paramsType, pathParamsType, dataReturnType, typeSchemas }:
75
77
  pathParams: typeSchemas.pathParams?.name
76
78
  ? {
77
79
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
78
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
80
+ children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
79
81
  optional: isOptional(typeSchemas.pathParams?.schema),
80
82
  }
81
83
  : undefined,
@@ -115,6 +117,7 @@ export function Query({
115
117
  queryOptionsName,
116
118
  queryKeyName,
117
119
  paramsType,
120
+ paramsCasing,
118
121
  pathParamsType,
119
122
  dataReturnType,
120
123
  typeSchemas,
@@ -126,15 +129,18 @@ export function Query({
126
129
 
127
130
  const queryKeyParams = QueryKey.getParams({
128
131
  pathParamsType,
132
+ paramsCasing,
129
133
  typeSchemas,
130
134
  })
131
135
  const queryOptionsParams = QueryOptions.getParams({
132
136
  paramsType,
137
+ paramsCasing,
133
138
  pathParamsType,
134
139
  typeSchemas,
135
140
  })
136
141
  const params = getParams({
137
142
  paramsType,
143
+ paramsCasing,
138
144
  pathParamsType,
139
145
  dataReturnType,
140
146
  typeSchemas,
@@ -12,20 +12,22 @@ type Props = {
12
12
  typeName: string
13
13
  typeSchemas: OperationSchemas
14
14
  operation: Operation
15
+ paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']
15
16
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
16
17
  transformer: Transformer | undefined
17
18
  }
18
19
 
19
20
  type GetParamsProps = {
21
+ paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']
20
22
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
21
23
  typeSchemas: OperationSchemas
22
24
  }
23
25
 
24
- function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
26
+ function getParams({ pathParamsType, paramsCasing, typeSchemas }: GetParamsProps) {
25
27
  return FunctionParams.factory({
26
28
  pathParams: {
27
29
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
28
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
30
+ children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
29
31
  },
30
32
  data: typeSchemas.request?.name
31
33
  ? {
@@ -42,8 +44,8 @@ function getParams({ pathParamsType, typeSchemas }: GetParamsProps) {
42
44
  })
43
45
  }
44
46
 
45
- const getTransformer: Transformer = ({ operation, schemas }) => {
46
- const path = new URLPath(operation.path)
47
+ const getTransformer: Transformer = ({ operation, schemas, casing }) => {
48
+ const path = new URLPath(operation.path, { casing })
47
49
  const keys = [
48
50
  path.toObject({
49
51
  type: 'path',
@@ -56,11 +58,12 @@ const getTransformer: Transformer = ({ operation, schemas }) => {
56
58
  return keys
57
59
  }
58
60
 
59
- export function QueryKey({ name, typeSchemas, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
60
- const params = getParams({ pathParamsType, typeSchemas })
61
+ export function QueryKey({ name, typeSchemas, paramsCasing, pathParamsType, operation, typeName, transformer = getTransformer }: Props): ReactNode {
62
+ const params = getParams({ pathParamsType, paramsCasing, typeSchemas })
61
63
  const keys = transformer({
62
64
  operation,
63
65
  schemas: typeSchemas,
66
+ casing: paramsCasing,
64
67
  })
65
68
 
66
69
  return (
@@ -14,23 +14,25 @@ type Props = {
14
14
  clientName: string
15
15
  queryKeyName: string
16
16
  typeSchemas: OperationSchemas
17
+ paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']
17
18
  paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
18
19
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
19
20
  }
20
21
 
21
22
  type GetParamsProps = {
23
+ paramsCasing: PluginSvelteQuery['resolvedOptions']['paramsCasing']
22
24
  paramsType: PluginSvelteQuery['resolvedOptions']['paramsType']
23
25
  pathParamsType: PluginSvelteQuery['resolvedOptions']['pathParamsType']
24
26
  typeSchemas: OperationSchemas
25
27
  }
26
28
 
27
- function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
29
+ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
28
30
  if (paramsType === 'object') {
29
31
  return FunctionParams.factory({
30
32
  data: {
31
33
  mode: 'object',
32
34
  children: {
33
- ...getPathParams(typeSchemas.pathParams, { typed: true }),
35
+ ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
34
36
  data: typeSchemas.request?.name
35
37
  ? {
36
38
  type: typeSchemas.request?.name,
@@ -62,7 +64,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
62
64
  pathParams: typeSchemas.pathParams?.name
63
65
  ? {
64
66
  mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
65
- children: getPathParams(typeSchemas.pathParams, { typed: true }),
67
+ children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
66
68
  optional: isOptional(typeSchemas.pathParams?.schema),
67
69
  }
68
70
  : undefined,
@@ -91,15 +93,17 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
91
93
  })
92
94
  }
93
95
 
94
- export function QueryOptions({ name, clientName, typeSchemas, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
95
- const params = getParams({ paramsType, pathParamsType, typeSchemas })
96
+ export function QueryOptions({ name, clientName, typeSchemas, paramsCasing, paramsType, pathParamsType, queryKeyName }: Props): ReactNode {
97
+ const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
96
98
  const clientParams = Client.getParams({
97
99
  paramsType,
100
+ paramsCasing,
98
101
  typeSchemas,
99
102
  pathParamsType,
100
103
  })
101
104
  const queryKeyParams = QueryKey.getParams({
102
105
  pathParamsType,
106
+ paramsCasing,
103
107
  typeSchemas,
104
108
  })
105
109
 
@@ -1,51 +1,66 @@
1
- import client from "@kubb/plugin-client/client";
2
- import type { RequestConfig, ResponseConfig } from "@kubb/plugin-client/client";
3
- import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
4
- import { queryOptions, createQuery } from "@tanstack/svelte-query";
1
+ import client from '@kubb/plugin-client/clients/axios'
2
+ import type { RequestConfig, ResponseConfig } from '@kubb/plugin-client/clients/axios'
3
+ import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from '@tanstack/svelte-query'
4
+ import { queryOptions, createQuery } from '@tanstack/svelte-query'
5
5
 
6
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
7
 
8
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
12
  * @summary Finds Pets by tags
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
- return { ...res, data: findPetsByTagsQueryResponse.parse(res.data) };
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
17
+ method: 'GET',
18
+ url: `/pet/findByTags`,
19
+ params,
20
+ headers: { ...headers, ...config.headers },
21
+ ...config,
22
+ })
23
+ return { ...res, data: findPetsByTagsQueryResponse.parse(res.data) }
18
24
  }
19
25
 
20
- export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
- const queryKey = findPetsByTagsQueryKey(params);
22
- return queryOptions({
23
- queryKey,
24
- queryFn: async ({ signal }) => {
25
- config.signal = signal;
26
- return findPetsByTags(headers, params, config);
27
- },
28
- });
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, 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
+ })
29
35
  }
30
36
 
31
- /**
37
+ /**
32
38
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
39
  * @summary Finds Pets by tags
34
40
  * {@link /pet/findByTags}
35
41
  */
36
- export function createFindPetsByTags<TData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryData = ResponseConfig<FindPetsByTagsQueryResponse>, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
- query?: Partial<CreateBaseQueryOptions<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
- client?: Partial<RequestConfig>;
39
- } = {}) {
40
- const { query: queryOptions, client: config = {} } = options ?? {};
41
- const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
- const query = createQuery({
43
- ...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
44
- queryKey,
45
- ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
46
- }) as CreateQueryResult<TData, FindPetsByTags400> & {
47
- queryKey: TQueryKey;
48
- };
49
- query.queryKey = queryKey as TQueryKey;
50
- return query;
42
+ export function createFindPetsByTags<
43
+ TData = ResponseConfig<FindPetsByTagsQueryResponse>,
44
+ TQueryData = ResponseConfig<FindPetsByTagsQueryResponse>,
45
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
46
+ >(
47
+ headers: FindPetsByTagsHeaderParams,
48
+ params?: FindPetsByTagsQueryParams,
49
+ options: {
50
+ query?: Partial<CreateBaseQueryOptions<ResponseConfig<FindPetsByTagsQueryResponse>, FindPetsByTags400, TData, TQueryData, TQueryKey>>
51
+ client?: Partial<RequestConfig>
52
+ } = {},
53
+ ) {
54
+ const { query: queryOptions, client: config = {} } = options ?? {}
55
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
56
+
57
+ const query = createQuery({
58
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions),
59
+ queryKey,
60
+ ...(queryOptions as unknown as Omit<CreateBaseQueryOptions, 'queryKey'>),
61
+ }) as CreateQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
62
+
63
+ query.queryKey = queryKey as TQueryKey
64
+
65
+ return query
51
66
  }
@@ -1,51 +1,66 @@
1
- import client from "axios";
2
- import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from "@tanstack/svelte-query";
3
- import type { RequestConfig } from "axios";
4
- import { queryOptions, createQuery } from "@tanstack/svelte-query";
1
+ import client from 'axios'
2
+ import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from '@tanstack/svelte-query'
3
+ import type { RequestConfig } from 'axios'
4
+ import { queryOptions, createQuery } from '@tanstack/svelte-query'
5
5
 
6
- export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: "/pet/findByTags" }, ...(params ? [params] : [])] as const;
6
+ export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
7
7
 
8
- export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>;
8
+ export type FindPetsByTagsQueryKey = ReturnType<typeof findPetsByTagsQueryKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
12
12
  * @summary Finds Pets by tags
13
13
  * {@link /pet/findByTags}
14
14
  */
15
15
  async function findPetsByTags(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
16
- const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, headers: { ...headers, ...config.headers }, ...config });
17
- return findPetsByTagsQueryResponse.parse(res.data);
16
+ const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({
17
+ method: 'GET',
18
+ url: `/pet/findByTags`,
19
+ params,
20
+ headers: { ...headers, ...config.headers },
21
+ ...config,
22
+ })
23
+ return findPetsByTagsQueryResponse.parse(res.data)
18
24
  }
19
25
 
20
- export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
21
- const queryKey = findPetsByTagsQueryKey(params);
22
- return queryOptions({
23
- queryKey,
24
- queryFn: async ({ signal }) => {
25
- config.signal = signal;
26
- return findPetsByTags(headers, params, config);
27
- },
28
- });
26
+ export function findPetsByTagsQueryOptions(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, 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
+ })
29
35
  }
30
36
 
31
- /**
37
+ /**
32
38
  * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
33
39
  * @summary Finds Pets by tags
34
40
  * {@link /pet/findByTags}
35
41
  */
36
- export function createFindPetsByTags<TData = FindPetsByTagsQueryResponse, TQueryData = FindPetsByTagsQueryResponse, TQueryKey extends QueryKey = FindPetsByTagsQueryKey>(headers: FindPetsByTagsHeaderParams, params?: FindPetsByTagsQueryParams, options: {
37
- query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>;
38
- client?: Partial<RequestConfig>;
39
- } = {}) {
40
- const { query: queryOptions, client: config = {} } = options ?? {};
41
- const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params);
42
- const query = createQuery({
43
- ...findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions,
44
- queryKey,
45
- ...queryOptions as unknown as Omit<CreateBaseQueryOptions, "queryKey">
46
- }) as CreateQueryResult<TData, FindPetsByTags400> & {
47
- queryKey: TQueryKey;
48
- };
49
- query.queryKey = queryKey as TQueryKey;
50
- return query;
42
+ export function createFindPetsByTags<
43
+ TData = FindPetsByTagsQueryResponse,
44
+ TQueryData = FindPetsByTagsQueryResponse,
45
+ TQueryKey extends QueryKey = FindPetsByTagsQueryKey,
46
+ >(
47
+ headers: FindPetsByTagsHeaderParams,
48
+ params?: FindPetsByTagsQueryParams,
49
+ options: {
50
+ query?: Partial<CreateBaseQueryOptions<FindPetsByTagsQueryResponse, FindPetsByTags400, TData, TQueryData, TQueryKey>>
51
+ client?: Partial<RequestConfig>
52
+ } = {},
53
+ ) {
54
+ const { query: queryOptions, client: config = {} } = options ?? {}
55
+ const queryKey = queryOptions?.queryKey ?? findPetsByTagsQueryKey(params)
56
+
57
+ const query = createQuery({
58
+ ...(findPetsByTagsQueryOptions(headers, params, config) as unknown as CreateBaseQueryOptions),
59
+ queryKey,
60
+ ...(queryOptions as unknown as Omit<CreateBaseQueryOptions, 'queryKey'>),
61
+ }) as CreateQueryResult<TData, FindPetsByTags400> & { queryKey: TQueryKey }
62
+
63
+ query.queryKey = queryKey as TQueryKey
64
+
65
+ return query
51
66
  }
@@ -1,44 +1,58 @@
1
- import client from "axios";
2
- import type { CreateMutationOptions } from "@tanstack/svelte-query";
3
- import type { RequestConfig } from "axios";
4
- import { createMutation } from "@tanstack/svelte-query";
1
+ import client from 'axios'
2
+ import type { CreateMutationOptions } from '@tanstack/svelte-query'
3
+ import type { RequestConfig } from 'axios'
4
+ import { createMutation } from '@tanstack/svelte-query'
5
5
 
6
- export const updatePetWithFormMutationKey = () => [{ "url": "/pet/{petId}" }] as const;
6
+ export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
7
7
 
8
- export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>;
8
+ export type UpdatePetWithFormMutationKey = ReturnType<typeof updatePetWithFormMutationKey>
9
9
 
10
- /**
10
+ /**
11
11
  * @summary Updates a pet in the store with form data
12
12
  * {@link /pet/:petId}
13
13
  */
14
- async function updatePetWithForm(petId: UpdatePetWithFormPathParams["petId"], data?: UpdatePetWithFormMutationRequest, params?: UpdatePetWithFormQueryParams, config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {}) {
15
- const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({ method: "POST", url: `/pet/${petId}`, params, data, ...config });
16
- return updatePetWithFormMutationResponse.parse(res.data);
14
+ async function updatePetWithForm(
15
+ petId: UpdatePetWithFormPathParams['petId'],
16
+ data?: UpdatePetWithFormMutationRequest,
17
+ params?: UpdatePetWithFormQueryParams,
18
+ config: Partial<RequestConfig<UpdatePetWithFormMutationRequest>> = {},
19
+ ) {
20
+ const res = await client<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, UpdatePetWithFormMutationRequest>({
21
+ method: 'POST',
22
+ url: `/pet/${petId}`,
23
+ params,
24
+ data,
25
+ ...config,
26
+ })
27
+ return updatePetWithFormMutationResponse.parse(res.data)
17
28
  }
18
29
 
19
- /**
30
+ /**
20
31
  * @summary Updates a pet in the store with form data
21
32
  * {@link /pet/:petId}
22
33
  */
23
- export function createUpdatePetWithForm(options: {
24
- mutation?: CreateMutationOptions<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
25
- petId: UpdatePetWithFormPathParams["petId"];
26
- data?: UpdatePetWithFormMutationRequest;
27
- params?: UpdatePetWithFormQueryParams;
28
- }>;
29
- client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>;
30
- } = {}) {
31
- const { mutation: mutationOptions, client: config = {} } = options ?? {};
32
- const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey();
33
- return createMutation<UpdatePetWithFormMutationResponse, UpdatePetWithForm405, {
34
- petId: UpdatePetWithFormPathParams["petId"];
35
- data?: UpdatePetWithFormMutationRequest;
36
- params?: UpdatePetWithFormQueryParams;
37
- }>({
38
- mutationFn: async ({ petId, data, params }) => {
39
- return updatePetWithForm(petId, data, params, config);
40
- },
41
- mutationKey,
42
- ...mutationOptions
43
- });
34
+ export function createUpdatePetWithForm(
35
+ options: {
36
+ mutation?: CreateMutationOptions<
37
+ UpdatePetWithFormMutationResponse,
38
+ UpdatePetWithForm405,
39
+ { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
40
+ >
41
+ client?: Partial<RequestConfig<UpdatePetWithFormMutationRequest>>
42
+ } = {},
43
+ ) {
44
+ const { mutation: mutationOptions, client: config = {} } = options ?? {}
45
+ const mutationKey = mutationOptions?.mutationKey ?? updatePetWithFormMutationKey()
46
+
47
+ return createMutation<
48
+ UpdatePetWithFormMutationResponse,
49
+ UpdatePetWithForm405,
50
+ { petId: UpdatePetWithFormPathParams['petId']; data?: UpdatePetWithFormMutationRequest; params?: UpdatePetWithFormQueryParams }
51
+ >({
52
+ mutationFn: async ({ petId, data, params }) => {
53
+ return updatePetWithForm(petId, data, params, config)
54
+ },
55
+ mutationKey,
56
+ ...mutationOptions,
57
+ })
44
58
  }