@kubb/plugin-react-query 3.0.0-alpha.5 → 3.0.0-alpha.6
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-JFX7DCS7.cjs → chunk-GTVJ55F2.cjs} +116 -150
- package/dist/chunk-GTVJ55F2.cjs.map +1 -0
- package/dist/{chunk-5IL6M74X.js → chunk-IVMTW4XS.js} +168 -202
- package/dist/chunk-IVMTW4XS.js.map +1 -0
- package/dist/components.cjs +2 -4
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +1 -2
- package/dist/components.d.ts +1 -2
- package/dist/components.js +1 -3
- package/dist/{index-C9fwRDH7.d.cts → index-5kpkk-7M.d.cts} +7 -41
- package/dist/{index-C9fwRDH7.d.ts → index-5kpkk-7M.d.ts} +7 -41
- package/dist/index.cjs +19 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +7 -47
- package/dist/index.js.map +1 -1
- package/package.json +14 -14
- package/src/OperationGenerator.tsx +0 -29
- package/src/__snapshots__/mutateAsQuery/updatePetWithForm.ts +11 -6
- package/src/__snapshots__/pathParamsTypeInline/getPetById.ts +11 -6
- package/src/__snapshots__/pathParamsTypeObject/getPetById.ts +11 -6
- package/src/__snapshots__/queryOptions/getPetById.ts +9 -5
- package/src/__snapshots__/queryWithoutQueryOptions/getPetById.ts +9 -5
- package/src/__snapshots__/upload/UploadFile.ts +11 -6
- package/src/__snapshots__/uploadMutation/UploadFile.ts +9 -5
- package/src/__snapshots__/variablesTypeMutate/deletePet.ts +7 -4
- package/src/components/Mutation.tsx +30 -30
- package/src/components/Query.tsx +74 -78
- package/src/components/QueryKey.tsx +11 -8
- package/src/components/QueryOptions.tsx +21 -13
- package/src/components/SchemaType.tsx +9 -5
- package/src/components/__snapshots__/gen/showPetById.ts +58 -48
- package/src/components/__snapshots__/gen/useCreatePets.ts +36 -36
- package/src/components/__snapshots__/gen/useCreatePetsMutate.ts +36 -37
- package/src/components/index.ts +0 -1
- package/src/plugin.ts +8 -29
- package/src/types.ts +0 -3
- package/dist/chunk-5IL6M74X.js.map +0 -1
- package/dist/chunk-JFX7DCS7.cjs.map +0 -1
- package/src/components/Operations.tsx +0 -74
|
@@ -2,7 +2,7 @@ import transformers from '@kubb/core/transformers'
|
|
|
2
2
|
import { FunctionParams, URLPath } from '@kubb/core/utils'
|
|
3
3
|
import { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
4
4
|
import { getASTParams, getComments } from '@kubb/plugin-oas/utils'
|
|
5
|
-
import { File, Function,
|
|
5
|
+
import { File, Function, useApp } from '@kubb/react'
|
|
6
6
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
7
7
|
|
|
8
8
|
import { SchemaType } from './SchemaType.tsx'
|
|
@@ -82,8 +82,9 @@ function Template({ name, params, mutateParams, JSDoc, client, hook, dataReturnT
|
|
|
82
82
|
: undefined
|
|
83
83
|
|
|
84
84
|
return (
|
|
85
|
-
<
|
|
86
|
-
{
|
|
85
|
+
<File.Source name={name} isExportable>
|
|
86
|
+
<Function export name={name} params={params} JSDoc={JSDoc}>
|
|
87
|
+
{`
|
|
87
88
|
const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {}
|
|
88
89
|
|
|
89
90
|
return ${hook.name}({
|
|
@@ -98,7 +99,8 @@ function Template({ name, params, mutateParams, JSDoc, client, hook, dataReturnT
|
|
|
98
99
|
},
|
|
99
100
|
...mutationOptions
|
|
100
101
|
})`}
|
|
101
|
-
|
|
102
|
+
</Function>
|
|
103
|
+
</File.Source>
|
|
102
104
|
)
|
|
103
105
|
}
|
|
104
106
|
|
|
@@ -124,32 +126,30 @@ function RootTemplate({ children }: RootTemplateProps) {
|
|
|
124
126
|
const fileType = getFile(operation, { pluginKey: [pluginTsName] })
|
|
125
127
|
|
|
126
128
|
return (
|
|
127
|
-
<
|
|
128
|
-
<File
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
name
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
</File>
|
|
152
|
-
</Parser>
|
|
129
|
+
<File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
|
|
130
|
+
<File.Import name={'client'} path={importPath} />
|
|
131
|
+
<File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />
|
|
132
|
+
<File.Import
|
|
133
|
+
name={[
|
|
134
|
+
schemas.request?.name,
|
|
135
|
+
schemas.response.name,
|
|
136
|
+
schemas.pathParams?.name,
|
|
137
|
+
schemas.queryParams?.name,
|
|
138
|
+
schemas.headerParams?.name,
|
|
139
|
+
...(schemas.errors?.map((error) => error.name) || []),
|
|
140
|
+
].filter(Boolean)}
|
|
141
|
+
root={file.path}
|
|
142
|
+
path={fileType.path}
|
|
143
|
+
isTypeOnly
|
|
144
|
+
/>
|
|
145
|
+
<File.Import
|
|
146
|
+
name={['UseMutationOptions', 'UseMutationResult']}
|
|
147
|
+
path={typeof mutate !== 'boolean' && mutate.importPath ? mutate.importPath : '@tanstack/react-query'}
|
|
148
|
+
isTypeOnly
|
|
149
|
+
/>
|
|
150
|
+
<File.Import name={['useMutation']} path={typeof mutate !== 'boolean' && mutate.importPath ? mutate.importPath : '@tanstack/react-query'} />
|
|
151
|
+
{children}
|
|
152
|
+
</File>
|
|
153
153
|
)
|
|
154
154
|
}
|
|
155
155
|
|
package/src/components/Query.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PackageManager } from '@kubb/core'
|
|
2
2
|
import transformers from '@kubb/core/transformers'
|
|
3
3
|
import { FunctionParams, URLPath } from '@kubb/core/utils'
|
|
4
|
-
import {
|
|
4
|
+
import { File, Function, useApp } from '@kubb/react'
|
|
5
5
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
6
6
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
7
7
|
import { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
@@ -56,7 +56,7 @@ function Template({ name, generics, returnType, params, JSDoc, hook, infinite }:
|
|
|
56
56
|
|
|
57
57
|
if (isV5) {
|
|
58
58
|
return (
|
|
59
|
-
|
|
59
|
+
<File.Source name={name} isExportable>
|
|
60
60
|
<Function name={name} export generics={generics} returnType={resolvedReturnType} params={params} JSDoc={JSDoc}>
|
|
61
61
|
{`
|
|
62
62
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
|
|
@@ -74,12 +74,12 @@ function Template({ name, generics, returnType, params, JSDoc, hook, infinite }:
|
|
|
74
74
|
|
|
75
75
|
`}
|
|
76
76
|
</Function>
|
|
77
|
-
|
|
77
|
+
</File.Source>
|
|
78
78
|
)
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
return (
|
|
82
|
-
|
|
82
|
+
<File.Source name={name} isExportable>
|
|
83
83
|
<Function name={name} export generics={generics} returnType={resolvedReturnType} params={params} JSDoc={JSDoc}>
|
|
84
84
|
{`
|
|
85
85
|
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
|
|
@@ -97,7 +97,7 @@ function Template({ name, generics, returnType, params, JSDoc, hook, infinite }:
|
|
|
97
97
|
|
|
98
98
|
`}
|
|
99
99
|
</Function>
|
|
100
|
-
|
|
100
|
+
</File.Source>
|
|
101
101
|
)
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -547,80 +547,76 @@ Query.File = function ({ templates }: FileProps): ReactNode {
|
|
|
547
547
|
}
|
|
548
548
|
|
|
549
549
|
return (
|
|
550
|
-
<
|
|
551
|
-
<File
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
name
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
/>
|
|
550
|
+
<File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>
|
|
551
|
+
{parser === 'zod' && <File.Import name={[zodSchemas.response?.name]} root={file.path} path={fileZodSchemas.path} />}
|
|
552
|
+
<File.Import name={'client'} path={importPath} />
|
|
553
|
+
<File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />
|
|
554
|
+
<File.Import
|
|
555
|
+
name={[
|
|
556
|
+
schemas.request?.name,
|
|
557
|
+
schemas.response.name,
|
|
558
|
+
schemas.pathParams?.name,
|
|
559
|
+
schemas.queryParams?.name,
|
|
560
|
+
schemas.headerParams?.name,
|
|
561
|
+
...(schemas.errors?.map((error) => error.name) || []),
|
|
562
|
+
].filter(Boolean)}
|
|
563
|
+
root={file.path}
|
|
564
|
+
path={fileType.path}
|
|
565
|
+
isTypeOnly
|
|
566
|
+
/>
|
|
568
567
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
</File.Source>
|
|
622
|
-
</File>
|
|
623
|
-
</Parser>
|
|
568
|
+
<QueryImports hookPath={typeof query !== 'boolean' ? query.importPath : undefined} Template={Import} isInfinite={false} isSuspense={false} />
|
|
569
|
+
{!!infinite && (
|
|
570
|
+
<QueryImports hookPath={typeof query !== 'boolean' ? query.importPath : undefined} Template={Import} isInfinite={true} isSuspense={false} />
|
|
571
|
+
)}
|
|
572
|
+
{!!suspense && isV5 && (
|
|
573
|
+
<QueryImports hookPath={typeof query !== 'boolean' ? query.importPath : undefined} Template={Import} isInfinite={false} isSuspense={true} />
|
|
574
|
+
)}
|
|
575
|
+
<SchemaType />
|
|
576
|
+
<Query
|
|
577
|
+
factory={factory}
|
|
578
|
+
Template={Template}
|
|
579
|
+
QueryKeyTemplate={QueryKeyTemplate}
|
|
580
|
+
QueryOptionsTemplate={QueryOptionsTemplate}
|
|
581
|
+
infinite={false}
|
|
582
|
+
suspense={false}
|
|
583
|
+
query={query}
|
|
584
|
+
queryOptions={queryOptions}
|
|
585
|
+
hookName={importNames.query['react'].hookName}
|
|
586
|
+
resultType={importNames.query['react'].resultType}
|
|
587
|
+
optionsType={importNames.query['react'].optionsType}
|
|
588
|
+
/>
|
|
589
|
+
{!!infinite && (
|
|
590
|
+
<Query
|
|
591
|
+
factory={factory}
|
|
592
|
+
Template={Template}
|
|
593
|
+
QueryKeyTemplate={QueryKeyTemplate}
|
|
594
|
+
QueryOptionsTemplate={QueryOptionsTemplate}
|
|
595
|
+
infinite={infinite}
|
|
596
|
+
suspense={false}
|
|
597
|
+
query={query}
|
|
598
|
+
queryOptions={queryOptions}
|
|
599
|
+
hookName={importNames.queryInfinite['react'].hookName}
|
|
600
|
+
resultType={importNames.queryInfinite['react'].resultType}
|
|
601
|
+
optionsType={importNames.queryInfinite['react'].optionsType}
|
|
602
|
+
/>
|
|
603
|
+
)}
|
|
604
|
+
{!!suspense && isV5 && (
|
|
605
|
+
<Query
|
|
606
|
+
factory={factory}
|
|
607
|
+
Template={Template}
|
|
608
|
+
QueryKeyTemplate={QueryKeyTemplate}
|
|
609
|
+
QueryOptionsTemplate={QueryOptionsTemplate}
|
|
610
|
+
infinite={false}
|
|
611
|
+
suspense={suspense}
|
|
612
|
+
query={query}
|
|
613
|
+
queryOptions={queryOptions}
|
|
614
|
+
hookName={importNames.querySuspense['react'].hookName}
|
|
615
|
+
resultType={importNames.querySuspense['react'].resultType}
|
|
616
|
+
optionsType={importNames.querySuspense['react'].optionsType}
|
|
617
|
+
/>
|
|
618
|
+
)}
|
|
619
|
+
</File>
|
|
624
620
|
)
|
|
625
621
|
}
|
|
626
622
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FunctionParams, URLPath } from '@kubb/core/utils'
|
|
2
|
-
import { Function, Type, useApp } from '@kubb/react'
|
|
2
|
+
import { Function, Type, File, useApp } from '@kubb/react'
|
|
3
3
|
import { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
4
4
|
import { getASTParams } from '@kubb/plugin-oas/utils'
|
|
5
5
|
|
|
@@ -41,13 +41,16 @@ type TemplateProps = {
|
|
|
41
41
|
function Template({ name, typeName, params, generics, returnType, JSDoc, keys }: TemplateProps): ReactNode {
|
|
42
42
|
return (
|
|
43
43
|
<>
|
|
44
|
-
<
|
|
45
|
-
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
<File.Source name={name} isExportable>
|
|
45
|
+
<Function.Arrow name={name} export generics={generics} params={params} returnType={returnType} singleLine JSDoc={JSDoc}>
|
|
46
|
+
{`[${keys}] as const`}
|
|
47
|
+
</Function.Arrow>
|
|
48
|
+
</File.Source>
|
|
49
|
+
<File.Source name={name} isExportable isTypeOnly>
|
|
50
|
+
<Type name={typeName} export>
|
|
51
|
+
{`ReturnType<typeof ${name}>`}
|
|
52
|
+
</Type>
|
|
53
|
+
</File.Source>
|
|
51
54
|
</>
|
|
52
55
|
)
|
|
53
56
|
}
|
|
@@ -3,7 +3,7 @@ import transformers from '@kubb/core/transformers'
|
|
|
3
3
|
import { FunctionParams, URLPath } from '@kubb/core/utils'
|
|
4
4
|
import { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
5
5
|
import { getASTParams } from '@kubb/plugin-oas/utils'
|
|
6
|
-
import { Function, useApp } from '@kubb/react'
|
|
6
|
+
import { Function, useApp, File } from '@kubb/react'
|
|
7
7
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
8
8
|
|
|
9
9
|
import { isRequired } from '@kubb/oas'
|
|
@@ -123,8 +123,9 @@ function Template({ name, params, generics, returnType, JSDoc, hook, client, inf
|
|
|
123
123
|
if (infinite) {
|
|
124
124
|
if (isV5) {
|
|
125
125
|
return (
|
|
126
|
-
<
|
|
127
|
-
{
|
|
126
|
+
<File.Source name={name} isExportable>
|
|
127
|
+
<Function name={name} export params={params} JSDoc={JSDoc}>
|
|
128
|
+
{`
|
|
128
129
|
const queryKey = ${hook.queryKey}
|
|
129
130
|
|
|
130
131
|
return infiniteQueryOptions({
|
|
@@ -142,13 +143,15 @@ function Template({ name, params, generics, returnType, JSDoc, hook, client, inf
|
|
|
142
143
|
})
|
|
143
144
|
|
|
144
145
|
`}
|
|
145
|
-
|
|
146
|
+
</Function>
|
|
147
|
+
</File.Source>
|
|
146
148
|
)
|
|
147
149
|
}
|
|
148
150
|
|
|
149
151
|
return (
|
|
150
|
-
<
|
|
151
|
-
{
|
|
152
|
+
<File.Source name={name} isExportable>
|
|
153
|
+
<Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>
|
|
154
|
+
{`
|
|
152
155
|
const queryKey = ${hook.queryKey}
|
|
153
156
|
|
|
154
157
|
return {
|
|
@@ -166,14 +169,16 @@ function Template({ name, params, generics, returnType, JSDoc, hook, client, inf
|
|
|
166
169
|
}
|
|
167
170
|
|
|
168
171
|
`}
|
|
169
|
-
|
|
172
|
+
</Function>
|
|
173
|
+
</File.Source>
|
|
170
174
|
)
|
|
171
175
|
}
|
|
172
176
|
|
|
173
177
|
if (isV5) {
|
|
174
178
|
return (
|
|
175
|
-
<
|
|
176
|
-
{
|
|
179
|
+
<File.Source name={name} isExportable>
|
|
180
|
+
<Function name={name} export params={params} JSDoc={JSDoc}>
|
|
181
|
+
{`
|
|
177
182
|
const queryKey = ${hook.queryKey}
|
|
178
183
|
|
|
179
184
|
return queryOptions({
|
|
@@ -191,13 +196,15 @@ function Template({ name, params, generics, returnType, JSDoc, hook, client, inf
|
|
|
191
196
|
})
|
|
192
197
|
|
|
193
198
|
`}
|
|
194
|
-
|
|
199
|
+
</Function>
|
|
200
|
+
</File.Source>
|
|
195
201
|
)
|
|
196
202
|
}
|
|
197
203
|
|
|
198
204
|
return (
|
|
199
|
-
<
|
|
200
|
-
{
|
|
205
|
+
<File.Source name={name} isExportable>
|
|
206
|
+
<Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>
|
|
207
|
+
{`
|
|
201
208
|
const queryKey = ${hook.queryKey}
|
|
202
209
|
|
|
203
210
|
return {
|
|
@@ -215,7 +222,8 @@ function Template({ name, params, generics, returnType, JSDoc, hook, client, inf
|
|
|
215
222
|
}
|
|
216
223
|
|
|
217
224
|
`}
|
|
218
|
-
|
|
225
|
+
</Function>
|
|
226
|
+
</File.Source>
|
|
219
227
|
)
|
|
220
228
|
}
|
|
221
229
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'
|
|
2
|
-
import { Type, useApp } from '@kubb/react'
|
|
2
|
+
import { File, Type, useApp } from '@kubb/react'
|
|
3
3
|
|
|
4
4
|
import type { ReactNode } from 'react'
|
|
5
5
|
import type { PluginReactQuery } from '../types.ts'
|
|
@@ -32,9 +32,12 @@ export function SchemaType(): ReactNode {
|
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<>
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
<File.Source name={clientType} isTypeOnly>
|
|
36
|
+
<Type name={clientType}>{`typeof client<${TResponse}, ${TError}, ${isFormData ? 'FormData' : TRequest}>`}</Type>
|
|
37
|
+
</File.Source>
|
|
38
|
+
<File.Source name={factoryName} isTypeOnly>
|
|
39
|
+
<Type name={factoryName}>
|
|
40
|
+
{`
|
|
38
41
|
{
|
|
39
42
|
data: ${TData}
|
|
40
43
|
error: ${TError}
|
|
@@ -49,7 +52,8 @@ export function SchemaType(): ReactNode {
|
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
`}
|
|
52
|
-
|
|
55
|
+
</Type>
|
|
56
|
+
</File.Source>
|
|
53
57
|
</>
|
|
54
58
|
)
|
|
55
59
|
}
|
|
@@ -1,57 +1,67 @@
|
|
|
1
1
|
type GetPetsUuidClient = typeof client<GetPetsUuidQueryResponse, never, never>
|
|
2
|
-
type GetPetsUuid = {
|
|
3
|
-
data: GetPetsUuidQueryResponse
|
|
4
|
-
error: never
|
|
5
|
-
request: never
|
|
6
|
-
pathParams: never
|
|
7
|
-
queryParams: never
|
|
8
|
-
headerParams: never
|
|
9
|
-
response: GetPetsUuidQueryResponse
|
|
10
|
-
client: {
|
|
11
|
-
parameters: Partial<Parameters<GetPetsUuidClient>[0]>
|
|
12
|
-
return: Awaited<ReturnType<GetPetsUuidClient>>
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
2
|
|
|
16
|
-
|
|
3
|
+
type GetPetsUuid =
|
|
4
|
+
{
|
|
5
|
+
data: GetPetsUuidQueryResponse
|
|
6
|
+
error: never
|
|
7
|
+
request: never
|
|
8
|
+
pathParams: never
|
|
9
|
+
queryParams: never
|
|
10
|
+
headerParams: never
|
|
11
|
+
response: GetPetsUuidQueryResponse
|
|
12
|
+
client: {
|
|
13
|
+
parameters: Partial<Parameters<GetPetsUuidClient>[0]>
|
|
14
|
+
return: Awaited<ReturnType<GetPetsUuidClient>>
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const GetPetsUuidQueryKey = () => [{ url: '/pets/:uuid', params: {uuid:uuid} }] as const
|
|
19
|
+
|
|
17
20
|
export type GetPetsUuidQueryKey = ReturnType<typeof GetPetsUuidQueryKey>
|
|
18
|
-
export function GetPetsUuidQueryOptions<TData = GetPetsUuid['response'], TQueryData = GetPetsUuid['response']>(
|
|
19
|
-
options: GetPetsUuid['client']['parameters'] = {},
|
|
20
|
-
): WithRequired<UseBaseQueryOptions<GetPetsUuid['response'], GetPetsUuid['error'], TData, TQueryData>, 'queryKey'> {
|
|
21
|
-
const queryKey = GetPetsUuidQueryKey()
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
export function GetPetsUuidQueryOptions<TData = GetPetsUuid["response"], TQueryData = GetPetsUuid["response"]>(options: GetPetsUuid['client']['parameters'] = {}): WithRequired<UseBaseQueryOptions<GetPetsUuid['response'], GetPetsUuid["error"], TData, TQueryData>, 'queryKey'> {
|
|
23
|
+
|
|
24
|
+
const queryKey = GetPetsUuidQueryKey()
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
queryKey,
|
|
28
|
+
queryFn: async () => {
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
const res = await client<GetPetsUuid['data'],GetPetsUuid['error']>({
|
|
32
|
+
method: "get",
|
|
28
33
|
url: `/pets/${uuid}`,
|
|
29
|
-
...options
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
...options
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
return res.data
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
35
43
|
}
|
|
44
|
+
|
|
36
45
|
/**
|
|
37
46
|
* @link /pets/:uuid
|
|
38
47
|
*/
|
|
39
|
-
export function useGetPetsUuid<TData = GetPetsUuid[
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
export function useGetPetsUuid<TData = GetPetsUuid["response"], TQueryData = GetPetsUuid["response"], TQueryKey extends QueryKey = GetPetsUuidQueryKey>(options: {
|
|
49
|
+
query?: Partial<UseBaseQueryOptions<GetPetsUuid['response'], GetPetsUuid['error'], TData, TQueryData, TQueryKey>>,
|
|
50
|
+
client?: GetPetsUuid['client']['parameters']
|
|
51
|
+
} = {}): UseQueryResult<TData, GetPetsUuid['error']> & { queryKey: TQueryKey } {
|
|
52
|
+
|
|
53
|
+
const { query: queryOptions, client: clientOptions = {} } = options ?? {}
|
|
54
|
+
const queryKey = queryOptions?.queryKey ?? GetPetsUuidQueryKey()
|
|
55
|
+
|
|
56
|
+
const query = useQuery<GetPetsUuid['data'], GetPetsUuid['error'], TData, any>({
|
|
57
|
+
...GetPetsUuidQueryOptions<TData, TQueryData>(clientOptions),
|
|
58
|
+
queryKey,
|
|
59
|
+
...queryOptions
|
|
60
|
+
}) as UseQueryResult<TData, GetPetsUuid['error']> & { queryKey: TQueryKey }
|
|
61
|
+
|
|
62
|
+
query.queryKey = queryKey as TQueryKey
|
|
63
|
+
|
|
64
|
+
return query
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
}
|
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
type CreatePetsClient = typeof client<CreatePetsMutationResponse, never, CreatePetsMutationRequest>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
|
|
3
|
+
type CreatePets =
|
|
4
|
+
{
|
|
5
|
+
data: CreatePetsMutationResponse
|
|
6
|
+
error: never
|
|
7
|
+
request: CreatePetsMutationRequest
|
|
8
|
+
pathParams: CreatePetsPathParams
|
|
9
|
+
queryParams: CreatePetsQueryParams
|
|
10
|
+
headerParams: CreatePetsHeaderParams
|
|
11
|
+
response: CreatePetsMutationResponse
|
|
12
|
+
client: {
|
|
13
|
+
parameters: Partial<Parameters<CreatePetsClient>[0]>
|
|
14
|
+
return: Awaited<ReturnType<CreatePetsClient>>
|
|
15
|
+
}
|
|
16
|
+
}
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* @summary Create a pet
|
|
18
20
|
* @link /pets/:uuid
|
|
19
21
|
*/
|
|
20
|
-
export function useCreatePets(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const res = await client<CreatePets['data'], CreatePets['error'], CreatePets['request']>({
|
|
34
|
-
method: 'post',
|
|
22
|
+
export function useCreatePets(uuid: CreatePetsPathParams["uuid"], headers: CreatePets['headerParams'], params?: CreatePets['queryParams'], options: {
|
|
23
|
+
mutation?: UseMutationOptions<CreatePets["response"], CreatePets["error"], CreatePets["request"]>,
|
|
24
|
+
client?: CreatePets['client']['parameters']
|
|
25
|
+
} = {}) {
|
|
26
|
+
|
|
27
|
+
const { mutation: mutationOptions, client: clientOptions = {} } = options ?? {}
|
|
28
|
+
|
|
29
|
+
return useMutation({
|
|
30
|
+
mutationFn: async(data) => {
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
const res = await client<CreatePets["data"], CreatePets["error"], CreatePets["request"]>({
|
|
34
|
+
method: "post",
|
|
35
35
|
url: `/pets/${uuid}`,
|
|
36
36
|
params,
|
|
37
37
|
data,
|
|
38
38
|
headers: { ...headers, ...clientOptions.headers },
|
|
39
|
-
...clientOptions
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
39
|
+
...clientOptions
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
return res.data
|
|
43
|
+
},
|
|
44
|
+
...mutationOptions
|
|
45
|
+
})
|
|
46
|
+
}
|