@kubb/plugin-react-query 3.0.0-alpha.3 → 3.0.0-alpha.30
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-2D27Y6L5.js +618 -0
- package/dist/chunk-2D27Y6L5.js.map +1 -0
- package/dist/chunk-C2H3KPHM.cjs +658 -0
- package/dist/chunk-C2H3KPHM.cjs.map +1 -0
- package/dist/chunk-JW3GZUSC.cjs +627 -0
- package/dist/chunk-JW3GZUSC.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 -154
- 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 +54 -140
- package/dist/index.js.map +1 -1
- package/dist/types-rJasmoxy.d.cts +187 -0
- package/dist/types-rJasmoxy.d.ts +187 -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 +51 -75
- package/src/types.ts +49 -88
- 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/types.ts
CHANGED
|
@@ -1,30 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type * as KubbFile from '@kubb/fs/types'
|
|
1
|
+
import type { 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,26 +65,10 @@ 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
|
*/
|
|
@@ -134,6 +101,16 @@ export type Options = {
|
|
|
134
101
|
* @default '@kubb/plugin-client/client'
|
|
135
102
|
*/
|
|
136
103
|
importPath?: string
|
|
104
|
+
/**
|
|
105
|
+
* ReturnType that needs to be used when calling client().
|
|
106
|
+
*
|
|
107
|
+
* `Data` will return ResponseConfig[data].
|
|
108
|
+
*
|
|
109
|
+
* `Full` will return ResponseConfig.
|
|
110
|
+
* @default `'data'`
|
|
111
|
+
* @private
|
|
112
|
+
*/
|
|
113
|
+
dataReturnType?: 'data' | 'full'
|
|
137
114
|
}
|
|
138
115
|
/**
|
|
139
116
|
* ReturnType that needs to be used when calling client().
|
|
@@ -144,31 +121,7 @@ export type Options = {
|
|
|
144
121
|
* @default `'data'`
|
|
145
122
|
* @private
|
|
146
123
|
*/
|
|
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'
|
|
124
|
+
|
|
172
125
|
/**
|
|
173
126
|
* Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
|
|
174
127
|
*/
|
|
@@ -181,6 +134,16 @@ export type Options = {
|
|
|
181
134
|
* Array containing override parameters to override `options` based on tags/operations/methods/paths.
|
|
182
135
|
*/
|
|
183
136
|
override?: Array<Override<ResolvedOptions>>
|
|
137
|
+
/**
|
|
138
|
+
* How to pass your pathParams.
|
|
139
|
+
*
|
|
140
|
+
* `object` will return the pathParams as an object.
|
|
141
|
+
*
|
|
142
|
+
* `inline` will return the pathParams as comma separated params.
|
|
143
|
+
* @default `'inline'`
|
|
144
|
+
* @private
|
|
145
|
+
*/
|
|
146
|
+
pathParamsType?: 'object' | 'inline'
|
|
184
147
|
/**
|
|
185
148
|
* When set, an infiniteQuery hooks will be added.
|
|
186
149
|
*/
|
|
@@ -193,11 +156,15 @@ export type Options = {
|
|
|
193
156
|
* Override some useQuery behaviours.
|
|
194
157
|
*/
|
|
195
158
|
query?: Partial<Query> | false
|
|
196
|
-
queryOptions?: Partial<QueryOptions> | false
|
|
197
159
|
/**
|
|
198
160
|
* Override some useMutation behaviours.
|
|
199
161
|
*/
|
|
200
|
-
|
|
162
|
+
mutation?: Mutation | false
|
|
163
|
+
/**
|
|
164
|
+
* Which parser can be used before returning the data to `@tanstack/query`.
|
|
165
|
+
* `'zod'` will use `@kubb/plugin-zod` to parse the data.
|
|
166
|
+
*/
|
|
167
|
+
parser?: 'client' | 'zod'
|
|
201
168
|
transformers?: {
|
|
202
169
|
/**
|
|
203
170
|
* Customize the names based on the type that is provided by the plugin.
|
|
@@ -205,30 +172,24 @@ export type Options = {
|
|
|
205
172
|
name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
|
|
206
173
|
}
|
|
207
174
|
/**
|
|
208
|
-
*
|
|
175
|
+
* Define some generators next to the react-query generators
|
|
209
176
|
*/
|
|
210
|
-
|
|
177
|
+
generators?: Array<Generator<PluginReactQuery>>
|
|
211
178
|
}
|
|
212
179
|
|
|
213
180
|
type ResolvedOptions = {
|
|
181
|
+
output: Output
|
|
182
|
+
baseURL: string | undefined
|
|
214
183
|
client: Required<NonNullable<PluginReactQuery['options']['client']>>
|
|
215
|
-
|
|
216
|
-
pathParamsType: NonNullable<
|
|
217
|
-
parser: PluginReactQuery['options']['parser']
|
|
184
|
+
parser: Required<NonNullable<Options['parser']>>
|
|
185
|
+
pathParamsType: NonNullable<Options['pathParamsType']>
|
|
218
186
|
/**
|
|
219
187
|
* Only used of infinite
|
|
220
188
|
*/
|
|
221
|
-
infinite: Infinite | false
|
|
189
|
+
infinite: NonNullable<Infinite> | false
|
|
222
190
|
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
|
|
191
|
+
query: NonNullable<Required<Query>> | false
|
|
192
|
+
mutation: NonNullable<Required<Mutation>> | false
|
|
232
193
|
}
|
|
233
194
|
|
|
234
195
|
export type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options, ResolvedOptions, never, ResolvePathOptions>
|