@kubb/plugin-react-query 3.0.0-alpha.3 → 3.0.0-alpha.31
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/README.md +13 -4
- package/dist/chunk-C2H3KPHM.cjs +658 -0
- package/dist/chunk-C2H3KPHM.cjs.map +1 -0
- package/dist/chunk-J7NSRJSY.js +661 -0
- package/dist/chunk-J7NSRJSY.js.map +1 -0
- package/dist/chunk-M5RJDPKE.cjs +670 -0
- package/dist/chunk-M5RJDPKE.cjs.map +1 -0
- package/dist/chunk-Y3DM2P6L.js +647 -0
- package/dist/chunk-Y3DM2P6L.js.map +1 -0
- package/dist/components.cjs +39 -14
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +161 -7
- package/dist/components.d.ts +161 -7
- package/dist/components.js +2 -14
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +25 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +14 -0
- package/dist/generators.d.ts +14 -0
- package/dist/generators.js +4 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.cjs +75 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -5
- package/dist/index.d.ts +1 -5
- package/dist/index.js +58 -145
- package/dist/index.js.map +1 -1
- package/dist/types-oaGq_oPb.d.cts +169 -0
- package/dist/types-oaGq_oPb.d.ts +169 -0
- package/package.json +22 -17
- package/src/components/InfiniteQuery.tsx +129 -0
- package/src/components/InfiniteQueryOptions.tsx +130 -0
- package/src/components/Mutation.tsx +138 -322
- package/src/components/MutationKey.tsx +48 -0
- package/src/components/Query.tsx +91 -598
- package/src/components/QueryKey.tsx +51 -178
- package/src/components/QueryOptions.tsx +72 -466
- package/src/components/SuspenseQuery.tsx +129 -0
- package/src/components/index.ts +4 -1
- package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +51 -0
- package/src/generators/__snapshots__/clientGetImportPath.ts +51 -0
- package/src/generators/__snapshots__/clientPostImportPath.ts +44 -0
- package/src/generators/__snapshots__/findByTags.ts +51 -0
- package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +51 -0
- package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +51 -0
- package/src/generators/__snapshots__/findByTagsWithZod.ts +51 -0
- package/src/generators/__snapshots__/findInfiniteByTags.ts +57 -0
- package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +57 -0
- package/src/generators/__snapshots__/getAsMutation.ts +31 -0
- package/src/generators/__snapshots__/postAsQuery.ts +50 -0
- package/src/generators/__snapshots__/updatePetById.ts +44 -0
- package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +46 -0
- package/src/generators/index.ts +4 -0
- package/src/generators/infiniteQueryGenerator.tsx +124 -0
- package/src/generators/mutationGenerator.tsx +108 -0
- package/src/generators/queryGenerator.tsx +121 -0
- package/src/generators/suspenseQueryGenerator.tsx +120 -0
- package/src/plugin.ts +58 -83
- package/src/types.ts +50 -107
- package/dist/chunk-5IL6M74X.js +0 -1504
- package/dist/chunk-5IL6M74X.js.map +0 -1
- package/dist/chunk-JFX7DCS7.cjs +0 -1504
- package/dist/chunk-JFX7DCS7.cjs.map +0 -1
- package/dist/index-C9fwRDH7.d.cts +0 -579
- package/dist/index-C9fwRDH7.d.ts +0 -579
- package/src/OperationGenerator.tsx +0 -86
- package/src/__snapshots__/mutateAsQuery/updatePetWithForm.ts +0 -64
- package/src/__snapshots__/pathParamsTypeInline/getPetById.ts +0 -57
- package/src/__snapshots__/pathParamsTypeObject/getPetById.ts +0 -63
- package/src/__snapshots__/queryOptions/getPetById.ts +0 -37
- package/src/__snapshots__/queryWithoutQueryOptions/getPetById.ts +0 -47
- package/src/__snapshots__/upload/UploadFile.ts +0 -67
- package/src/__snapshots__/uploadMutation/UploadFile.ts +0 -44
- package/src/__snapshots__/variablesTypeMutate/deletePet.ts +0 -21
- package/src/components/Operations.tsx +0 -74
- package/src/components/QueryImports.tsx +0 -167
- package/src/components/SchemaType.tsx +0 -55
- package/src/components/__snapshots__/gen/showPetById.ts +0 -57
- package/src/components/__snapshots__/gen/useCreatePets.ts +0 -46
- package/src/components/__snapshots__/gen/useCreatePetsMutate.ts +0 -47
- package/src/utils.ts +0 -96
package/src/plugin.ts
CHANGED
|
@@ -1,52 +1,48 @@
|
|
|
1
1
|
import path from 'node:path'
|
|
2
2
|
|
|
3
|
-
import { FileManager, PluginManager, createPlugin } from '@kubb/core'
|
|
3
|
+
import { FileManager, type Group, PluginManager, createPlugin } from '@kubb/core'
|
|
4
4
|
import { camelCase, pascalCase } from '@kubb/core/transformers'
|
|
5
5
|
import { renderTemplate } from '@kubb/core/utils'
|
|
6
|
-
import { pluginOasName } from '@kubb/plugin-oas'
|
|
7
|
-
|
|
6
|
+
import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'
|
|
7
|
+
|
|
8
8
|
import { pluginTsName } from '@kubb/plugin-ts'
|
|
9
9
|
import { pluginZodName } from '@kubb/plugin-zod'
|
|
10
10
|
|
|
11
|
-
import { OperationGenerator } from './OperationGenerator.tsx'
|
|
12
|
-
import { Mutation, Operations, Query, QueryKey, QueryOptions } from './components/index.ts'
|
|
13
|
-
|
|
14
11
|
import type { Plugin } from '@kubb/core'
|
|
15
12
|
import type { PluginOas } from '@kubb/plugin-oas'
|
|
16
|
-
import {
|
|
13
|
+
import { infiniteQueryGenerator, mutationGenerator, queryGenerator, suspenseQueryGenerator } from './generators'
|
|
17
14
|
import type { PluginReactQuery } from './types.ts'
|
|
18
15
|
|
|
19
16
|
export const pluginReactQueryName = 'plugin-react-query' satisfies PluginReactQuery['name']
|
|
20
17
|
|
|
21
18
|
export const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {
|
|
22
19
|
const {
|
|
23
|
-
output = { path: 'hooks' },
|
|
20
|
+
output = { path: 'hooks', barrelType: 'named' },
|
|
24
21
|
group,
|
|
25
22
|
exclude = [],
|
|
26
23
|
include,
|
|
27
24
|
override = [],
|
|
28
|
-
parser,
|
|
25
|
+
parser = 'client',
|
|
29
26
|
suspense = {},
|
|
30
27
|
infinite,
|
|
31
28
|
transformers = {},
|
|
32
|
-
dataReturnType = 'data',
|
|
33
29
|
pathParamsType = 'inline',
|
|
34
|
-
|
|
30
|
+
generators = [queryGenerator, suspenseQueryGenerator, infiniteQueryGenerator, mutationGenerator].filter(Boolean),
|
|
31
|
+
mutation = {},
|
|
35
32
|
query = {},
|
|
36
|
-
queryOptions = {},
|
|
37
|
-
templates,
|
|
38
33
|
} = options
|
|
39
|
-
const template = group?.output ? group.output : `${output.path}/{{tag}}Controller`
|
|
40
34
|
|
|
41
35
|
return {
|
|
42
36
|
name: pluginReactQueryName,
|
|
43
37
|
options: {
|
|
38
|
+
output,
|
|
39
|
+
baseURL: undefined,
|
|
44
40
|
client: {
|
|
45
41
|
importPath: '@kubb/plugin-client/client',
|
|
42
|
+
dataReturnType: 'data',
|
|
43
|
+
pathParamsType: 'inline',
|
|
46
44
|
...options.client,
|
|
47
45
|
},
|
|
48
|
-
dataReturnType,
|
|
49
|
-
pathParamsType,
|
|
50
46
|
infinite: infinite
|
|
51
47
|
? {
|
|
52
48
|
queryParam: 'id',
|
|
@@ -56,31 +52,19 @@ export const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {
|
|
|
56
52
|
}
|
|
57
53
|
: false,
|
|
58
54
|
suspense,
|
|
59
|
-
query:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
...query,
|
|
65
|
-
}
|
|
66
|
-
: false,
|
|
67
|
-
queryOptions,
|
|
68
|
-
mutate: mutate
|
|
69
|
-
? {
|
|
70
|
-
variablesType: 'hook',
|
|
71
|
-
methods: ['post', 'put', 'patch', 'delete'],
|
|
72
|
-
...mutate,
|
|
73
|
-
}
|
|
74
|
-
: false,
|
|
75
|
-
templates: {
|
|
76
|
-
mutation: Mutation.templates,
|
|
77
|
-
query: Query.templates,
|
|
78
|
-
queryOptions: QueryOptions.templates,
|
|
79
|
-
queryKey: QueryKey.templates,
|
|
80
|
-
queryImports: QueryImports.templates,
|
|
81
|
-
operations: Operations.templates,
|
|
82
|
-
...templates,
|
|
55
|
+
query: {
|
|
56
|
+
key: (key: unknown[]) => key,
|
|
57
|
+
methods: ['get'],
|
|
58
|
+
importPath: '@tanstack/react-query',
|
|
59
|
+
...query,
|
|
83
60
|
},
|
|
61
|
+
mutation: {
|
|
62
|
+
key: (key: unknown[]) => key,
|
|
63
|
+
methods: ['post', 'put', 'patch', 'delete'],
|
|
64
|
+
importPath: '@tanstack/react-query',
|
|
65
|
+
...mutation,
|
|
66
|
+
},
|
|
67
|
+
pathParamsType,
|
|
84
68
|
parser,
|
|
85
69
|
},
|
|
86
70
|
pre: [pluginOasName, pluginTsName, parser === 'zod' ? pluginZodName : undefined].filter(Boolean),
|
|
@@ -88,6 +72,12 @@ export const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {
|
|
|
88
72
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
89
73
|
const mode = pathMode ?? FileManager.getMode(path.resolve(root, output.path))
|
|
90
74
|
|
|
75
|
+
if (options?.tag && group?.type === 'tag') {
|
|
76
|
+
const groupName: Group['name'] = group?.name ? group.name : (ctx) => `${ctx.group}Controller`
|
|
77
|
+
|
|
78
|
+
return path.resolve(root, output.path, groupName({ group: camelCase(options.tag) }), baseName)
|
|
79
|
+
}
|
|
80
|
+
|
|
91
81
|
if (mode === 'single') {
|
|
92
82
|
/**
|
|
93
83
|
* when output is a file then we will always append to the same file(output file), see fileManager.addOrAppend
|
|
@@ -96,12 +86,6 @@ export const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {
|
|
|
96
86
|
return path.resolve(root, output.path)
|
|
97
87
|
}
|
|
98
88
|
|
|
99
|
-
if (options?.tag && group?.type === 'tag') {
|
|
100
|
-
const tag = camelCase(options.tag)
|
|
101
|
-
|
|
102
|
-
return path.resolve(root, renderTemplate(template, { tag }), baseName)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
89
|
return path.resolve(root, output.path, baseName)
|
|
106
90
|
},
|
|
107
91
|
resolveName(name, type) {
|
|
@@ -109,7 +93,6 @@ export const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {
|
|
|
109
93
|
|
|
110
94
|
if (type === 'file' || type === 'function') {
|
|
111
95
|
resolvedName = camelCase(name, {
|
|
112
|
-
prefix: 'use',
|
|
113
96
|
isFile: type === 'file',
|
|
114
97
|
})
|
|
115
98
|
}
|
|
@@ -129,48 +112,40 @@ export const pluginReactQuery = createPlugin<PluginReactQuery>((options) => {
|
|
|
129
112
|
const oas = await swaggerPlugin.context.getOas()
|
|
130
113
|
const root = path.resolve(this.config.root, this.config.output.path)
|
|
131
114
|
const mode = FileManager.getMode(path.resolve(root, output.path))
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
const files = await operationGenerator.build()
|
|
145
|
-
await this.addFile(...files)
|
|
146
|
-
},
|
|
147
|
-
async buildEnd() {
|
|
148
|
-
if (this.config.output.write === false) {
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
const root = path.resolve(this.config.root, this.config.output.path)
|
|
153
|
-
|
|
154
|
-
if (group?.type === 'tag') {
|
|
155
|
-
const rootFiles = await getGroupedByTagFiles({
|
|
156
|
-
logger: this.logger,
|
|
157
|
-
files: this.fileManager.files,
|
|
115
|
+
const baseURL = await swaggerPlugin.context.getBaseURL()
|
|
116
|
+
|
|
117
|
+
const operationGenerator = new OperationGenerator(
|
|
118
|
+
{
|
|
119
|
+
...this.plugin.options,
|
|
120
|
+
baseURL,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
oas,
|
|
124
|
+
pluginManager: this.pluginManager,
|
|
158
125
|
plugin: this.plugin,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
126
|
+
contentType: swaggerPlugin.context.contentType,
|
|
127
|
+
exclude,
|
|
128
|
+
include,
|
|
129
|
+
override,
|
|
130
|
+
mode,
|
|
131
|
+
},
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
const files = await operationGenerator.build(...generators)
|
|
135
|
+
await this.addFile(...files)
|
|
167
136
|
|
|
168
|
-
await this.fileManager.
|
|
137
|
+
const barrelFiles = await this.fileManager.getBarrelFiles({
|
|
138
|
+
type: output.barrelType ?? 'named',
|
|
169
139
|
root,
|
|
170
140
|
output,
|
|
171
|
-
|
|
141
|
+
files: this.fileManager.files,
|
|
142
|
+
meta: {
|
|
143
|
+
pluginKey: this.plugin.key,
|
|
144
|
+
},
|
|
172
145
|
logger: this.logger,
|
|
173
146
|
})
|
|
147
|
+
|
|
148
|
+
await this.addFile(...barrelFiles)
|
|
174
149
|
},
|
|
175
150
|
}
|
|
176
151
|
})
|
package/src/types.ts
CHANGED
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type * as KubbFile from '@kubb/fs/types'
|
|
1
|
+
import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
|
|
3
2
|
|
|
4
3
|
import type { HttpMethod } from '@kubb/oas'
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type { Operations } from './components/Operations.tsx'
|
|
8
|
-
import type { Query as QueryTemplate } from './components/Query.tsx'
|
|
9
|
-
import type { QueryImports } from './components/QueryImports.tsx'
|
|
10
|
-
import type { QueryKey } from './components/QueryKey.tsx'
|
|
11
|
-
import type { QueryOptions as QueryOptionsTemplate } from './components/QueryOptions.tsx'
|
|
4
|
+
import type { PluginClient } from '@kubb/plugin-client'
|
|
5
|
+
import type { Exclude, Generator, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'
|
|
12
6
|
|
|
13
|
-
type
|
|
14
|
-
operations?: typeof Operations.templates | false
|
|
15
|
-
mutation?: typeof Mutation.templates | false
|
|
16
|
-
query?: typeof QueryTemplate.templates | false
|
|
17
|
-
queryOptions?: typeof QueryOptionsTemplate.templates | false
|
|
18
|
-
queryKey?: typeof QueryKey.templates | false
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type Suspense = object
|
|
7
|
+
type Suspense = object
|
|
22
8
|
|
|
23
|
-
|
|
9
|
+
type Query = {
|
|
24
10
|
/**
|
|
25
11
|
* Customize the queryKey, here you can specify a suffix.
|
|
26
12
|
*/
|
|
27
|
-
|
|
13
|
+
key: (key: unknown[]) => unknown[]
|
|
28
14
|
/**
|
|
29
15
|
* Define which HttpMethods can be used for queries
|
|
30
16
|
* @default ['get']
|
|
@@ -40,14 +26,11 @@ export type Query = {
|
|
|
40
26
|
importPath?: string
|
|
41
27
|
}
|
|
42
28
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
export type Mutate = {
|
|
29
|
+
type Mutation = {
|
|
46
30
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @default `'hook'`
|
|
31
|
+
* Customize the queryKey, here you can specify a suffix.
|
|
49
32
|
*/
|
|
50
|
-
|
|
33
|
+
key: (key: unknown[]) => unknown[]
|
|
51
34
|
/**
|
|
52
35
|
* Define which HttpMethods can be used for mutations
|
|
53
36
|
* @default ['post', 'put', 'delete']
|
|
@@ -82,48 +65,14 @@ export type Infinite = {
|
|
|
82
65
|
}
|
|
83
66
|
|
|
84
67
|
export type Options = {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
*/
|
|
90
|
-
path: string
|
|
91
|
-
/**
|
|
92
|
-
* Name to be used for the `export * as {{exportAs}} from './'`
|
|
93
|
-
*/
|
|
94
|
-
exportAs?: string
|
|
95
|
-
/**
|
|
96
|
-
* Add an extension to the generated imports and exports, default it will not use an extension
|
|
97
|
-
*/
|
|
98
|
-
extName?: KubbFile.Extname
|
|
99
|
-
/**
|
|
100
|
-
* Define what needs to exported, here you can also disable the export of barrel files
|
|
101
|
-
* @default `'barrel'`
|
|
102
|
-
*/
|
|
103
|
-
exportType?: 'barrel' | 'barrelNamed' | false
|
|
104
|
-
}
|
|
68
|
+
/**
|
|
69
|
+
* @default 'hooks'
|
|
70
|
+
*/
|
|
71
|
+
output?: Output
|
|
105
72
|
/**
|
|
106
73
|
* Group the @tanstack/query hooks based on the provided name.
|
|
107
74
|
*/
|
|
108
|
-
group?:
|
|
109
|
-
/**
|
|
110
|
-
* Tag will group based on the operation tag inside the Swagger file
|
|
111
|
-
*/
|
|
112
|
-
type: 'tag'
|
|
113
|
-
/**
|
|
114
|
-
* Relative path to save the grouped @tanstack/query hooks.
|
|
115
|
-
*
|
|
116
|
-
* `{{tag}}` will be replaced by the current tagName.
|
|
117
|
-
* @example `${output}/{{tag}}Controller` => `hooks/PetController`
|
|
118
|
-
* @default `${output}/{{tag}}Controller`
|
|
119
|
-
*/
|
|
120
|
-
output?: string
|
|
121
|
-
/**
|
|
122
|
-
* Name to be used for the `export * as {{exportAs}} from './`
|
|
123
|
-
* @default `"{{tag}}Hooks"`
|
|
124
|
-
*/
|
|
125
|
-
exportAs?: string
|
|
126
|
-
}
|
|
75
|
+
group?: Group
|
|
127
76
|
|
|
128
77
|
client?: {
|
|
129
78
|
/**
|
|
@@ -134,6 +83,16 @@ export type Options = {
|
|
|
134
83
|
* @default '@kubb/plugin-client/client'
|
|
135
84
|
*/
|
|
136
85
|
importPath?: string
|
|
86
|
+
/**
|
|
87
|
+
* ReturnType that needs to be used when calling client().
|
|
88
|
+
*
|
|
89
|
+
* `Data` will return ResponseConfig[data].
|
|
90
|
+
*
|
|
91
|
+
* `Full` will return ResponseConfig.
|
|
92
|
+
* @default `'data'`
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
dataReturnType?: 'data' | 'full'
|
|
137
96
|
}
|
|
138
97
|
/**
|
|
139
98
|
* ReturnType that needs to be used when calling client().
|
|
@@ -144,31 +103,7 @@ export type Options = {
|
|
|
144
103
|
* @default `'data'`
|
|
145
104
|
* @private
|
|
146
105
|
*/
|
|
147
|
-
|
|
148
|
-
* ReturnType that needs to be used when calling client().
|
|
149
|
-
*
|
|
150
|
-
* `Data` will return ResponseConfig[data].
|
|
151
|
-
*
|
|
152
|
-
* `Full` will return ResponseConfig.
|
|
153
|
-
* @default `'data'`
|
|
154
|
-
* @private
|
|
155
|
-
*/
|
|
156
|
-
dataReturnType?: 'data' | 'full'
|
|
157
|
-
/**
|
|
158
|
-
* How to pass your pathParams.
|
|
159
|
-
*
|
|
160
|
-
* `object` will return the pathParams as an object.
|
|
161
|
-
*
|
|
162
|
-
* `inline` will return the pathParams as comma separated params.
|
|
163
|
-
* @default `'inline'`
|
|
164
|
-
* @private
|
|
165
|
-
*/
|
|
166
|
-
pathParamsType?: 'object' | 'inline'
|
|
167
|
-
/**
|
|
168
|
-
* Which parser can be used before returning the data to `@tanstack/query`.
|
|
169
|
-
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
170
|
-
*/
|
|
171
|
-
parser?: 'zod'
|
|
106
|
+
|
|
172
107
|
/**
|
|
173
108
|
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
174
109
|
*/
|
|
@@ -181,6 +116,16 @@ export type Options = {
|
|
|
181
116
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
182
117
|
*/
|
|
183
118
|
override?: Array<Override<ResolvedOptions>>
|
|
119
|
+
/**
|
|
120
|
+
* How to pass your pathParams.
|
|
121
|
+
*
|
|
122
|
+
* `object` will return the pathParams as an object.
|
|
123
|
+
*
|
|
124
|
+
* `inline` will return the pathParams as comma separated params.
|
|
125
|
+
* @default `'inline'`
|
|
126
|
+
* @private
|
|
127
|
+
*/
|
|
128
|
+
pathParamsType?: 'object' | 'inline'
|
|
184
129
|
/**
|
|
185
130
|
* When set, an infiniteQuery hooks will be added.
|
|
186
131
|
*/
|
|
@@ -193,11 +138,15 @@ export type Options = {
|
|
|
193
138
|
* Override some useQuery behaviours.
|
|
194
139
|
*/
|
|
195
140
|
query?: Partial<Query> | false
|
|
196
|
-
queryOptions?: Partial<QueryOptions> | false
|
|
197
141
|
/**
|
|
198
142
|
* Override some useMutation behaviours.
|
|
199
143
|
*/
|
|
200
|
-
|
|
144
|
+
mutation?: Mutation | false
|
|
145
|
+
/**
|
|
146
|
+
* Which parser can be used before returning the data to `@tanstack/query`.
|
|
147
|
+
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
148
|
+
*/
|
|
149
|
+
parser?: 'client' | 'zod'
|
|
201
150
|
transformers?: {
|
|
202
151
|
/**
|
|
203
152
|
* Customize the names based on the type that is provided by the plugin.
|
|
@@ -205,30 +154,24 @@ export type Options = {
|
|
|
205
154
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
|
|
206
155
|
}
|
|
207
156
|
/**
|
|
208
|
-
*
|
|
157
|
+
* Define some generators next to the react-query generators
|
|
209
158
|
*/
|
|
210
|
-
|
|
159
|
+
generators?: Array<Generator<PluginReactQuery>>
|
|
211
160
|
}
|
|
212
161
|
|
|
213
162
|
type ResolvedOptions = {
|
|
163
|
+
output: Output
|
|
164
|
+
baseURL: string | undefined
|
|
214
165
|
client: Required<NonNullable<PluginReactQuery['options']['client']>>
|
|
215
|
-
|
|
216
|
-
pathParamsType: NonNullable<
|
|
217
|
-
parser: PluginReactQuery['options']['parser']
|
|
166
|
+
parser: Required<NonNullable<Options['parser']>>
|
|
167
|
+
pathParamsType: NonNullable<Options['pathParamsType']>
|
|
218
168
|
/**
|
|
219
169
|
* Only used of infinite
|
|
220
170
|
*/
|
|
221
|
-
infinite: Infinite | false
|
|
171
|
+
infinite: NonNullable<Infinite> | false
|
|
222
172
|
suspense: Suspense | false
|
|
223
|
-
query: Query | false
|
|
224
|
-
|
|
225
|
-
mutate: Mutate | false
|
|
226
|
-
templates: NonNullable<Templates>
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export type FileMeta = {
|
|
230
|
-
pluginKey?: Plugin['key']
|
|
231
|
-
tag?: string
|
|
173
|
+
query: NonNullable<Required<Query>> | false
|
|
174
|
+
mutation: NonNullable<Required<Mutation>> | false
|
|
232
175
|
}
|
|
233
176
|
|
|
234
177
|
export type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options, ResolvedOptions, never, ResolvePathOptions>
|