@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.
- package/dist/{chunk-TOBORUCM.js → chunk-BB5SCJJT.js} +10 -3
- package/dist/chunk-BB5SCJJT.js.map +1 -0
- package/dist/{chunk-F6TRULM6.cjs → chunk-DJNDGHXY.cjs} +17 -10
- package/dist/chunk-DJNDGHXY.cjs.map +1 -0
- package/dist/{chunk-SP3FM442.js → chunk-EZRBBWGF.js} +50 -30
- package/dist/chunk-EZRBBWGF.js.map +1 -0
- package/dist/{chunk-PHEQCKJY.cjs → chunk-YSVAGB5Y.cjs} +50 -30
- package/dist/chunk-YSVAGB5Y.cjs.map +1 -0
- package/dist/components.cjs +6 -6
- package/dist/components.d.cts +17 -9
- package/dist/components.d.ts +17 -9
- package/dist/components.js +1 -1
- package/dist/generators.cjs +4 -4
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +8 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/{types-BxGtUnah.d.ts → types-CdgT4Eeh.d.cts} +29 -2
- package/dist/{types-BxGtUnah.d.cts → types-CdgT4Eeh.d.ts} +29 -2
- package/package.json +11 -11
- package/src/components/Mutation.tsx +18 -4
- package/src/components/MutationKey.tsx +5 -4
- package/src/components/Query.tsx +9 -3
- package/src/components/QueryKey.tsx +9 -6
- package/src/components/QueryOptions.tsx +9 -5
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +49 -34
- package/src/generators/__snapshots__/clientGetImportPath.ts +49 -34
- package/src/generators/__snapshots__/clientPostImportPath.ts +46 -32
- package/src/generators/__snapshots__/findByTags.ts +49 -34
- package/src/generators/__snapshots__/findByTagsObject.ts +55 -44
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +49 -34
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +49 -34
- package/src/generators/__snapshots__/findByTagsWithZod.ts +49 -34
- package/src/generators/__snapshots__/postAsQuery.ts +66 -36
- package/src/generators/__snapshots__/updatePetById.ts +46 -32
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +46 -34
- package/src/generators/mutationGenerator.tsx +3 -0
- package/src/generators/queryGenerator.tsx +4 -0
- package/src/plugin.ts +3 -1
- package/src/types.ts +7 -0
- package/dist/chunk-F6TRULM6.cjs.map +0 -1
- package/dist/chunk-PHEQCKJY.cjs.map +0 -1
- package/dist/chunk-SP3FM442.js.map +0 -1
- 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({
|
|
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
|
<>
|
package/src/components/Query.tsx
CHANGED
|
@@ -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
|
|
2
|
-
import type { RequestConfig, ResponseConfig } from
|
|
3
|
-
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from
|
|
4
|
-
import { queryOptions, createQuery } from
|
|
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
|
-
|
|
6
|
+
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
7
7
|
|
|
8
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
2
|
-
import type { QueryKey, CreateBaseQueryOptions, CreateQueryResult } from
|
|
3
|
-
import type { RequestConfig } from
|
|
4
|
-
import { queryOptions, createQuery } from
|
|
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
|
-
|
|
6
|
+
export const findPetsByTagsQueryKey = (params?: FindPetsByTagsQueryParams) => [{ url: '/pet/findByTags' }, ...(params ? [params] : [])] as const
|
|
7
7
|
|
|
8
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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<
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
2
|
-
import type { CreateMutationOptions } from
|
|
3
|
-
import type { RequestConfig } from
|
|
4
|
-
import { createMutation } from
|
|
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
|
-
|
|
6
|
+
export const updatePetWithFormMutationKey = () => [{ url: '/pet/{petId}' }] as const
|
|
7
7
|
|
|
8
|
-
|
|
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(
|
|
15
|
-
|
|
16
|
-
|
|
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(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
}
|