@kubb/plugin-react-query 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (80) hide show
  1. package/README.md +13 -4
  2. package/dist/chunk-ESENIDWJ.js +608 -0
  3. package/dist/chunk-ESENIDWJ.js.map +1 -0
  4. package/dist/chunk-HAC4WPCC.js +608 -0
  5. package/dist/chunk-HAC4WPCC.js.map +1 -0
  6. package/dist/chunk-JQEH3UHY.cjs +618 -0
  7. package/dist/chunk-JQEH3UHY.cjs.map +1 -0
  8. package/dist/chunk-JYBGTT23.cjs +618 -0
  9. package/dist/chunk-JYBGTT23.cjs.map +1 -0
  10. package/dist/components.cjs +35 -14
  11. package/dist/components.cjs.map +1 -1
  12. package/dist/components.d.cts +143 -7
  13. package/dist/components.d.ts +143 -7
  14. package/dist/components.js +2 -14
  15. package/dist/components.js.map +1 -1
  16. package/dist/generators.cjs +25 -0
  17. package/dist/generators.cjs.map +1 -0
  18. package/dist/generators.d.cts +14 -0
  19. package/dist/generators.d.ts +14 -0
  20. package/dist/generators.js +4 -0
  21. package/dist/generators.js.map +1 -0
  22. package/dist/index.cjs +77 -154
  23. package/dist/index.cjs.map +1 -1
  24. package/dist/index.d.cts +1 -5
  25. package/dist/index.d.ts +1 -5
  26. package/dist/index.js +56 -140
  27. package/dist/index.js.map +1 -1
  28. package/dist/types-DFHc63S9.d.cts +179 -0
  29. package/dist/types-DFHc63S9.d.ts +179 -0
  30. package/package.json +22 -17
  31. package/src/components/InfiniteQuery.tsx +129 -0
  32. package/src/components/InfiniteQueryOptions.tsx +121 -0
  33. package/src/components/Mutation.tsx +113 -321
  34. package/src/components/Query.tsx +91 -598
  35. package/src/components/QueryKey.tsx +51 -178
  36. package/src/components/QueryOptions.tsx +65 -468
  37. package/src/components/SuspenseQuery.tsx +129 -0
  38. package/src/components/index.ts +3 -1
  39. package/src/generators/__snapshots__/clientDataReturnTypeFull.ts +50 -0
  40. package/src/generators/__snapshots__/clientGetImportPath.ts +50 -0
  41. package/src/generators/__snapshots__/clientPostImportPath.ts +38 -0
  42. package/src/generators/__snapshots__/findByTags.ts +50 -0
  43. package/src/generators/__snapshots__/findByTagsPathParamsObject.ts +50 -0
  44. package/src/generators/__snapshots__/findByTagsWithCustomQueryKey.ts +50 -0
  45. package/src/generators/__snapshots__/findByTagsWithZod.ts +50 -0
  46. package/src/generators/__snapshots__/findInfiniteByTags.ts +56 -0
  47. package/src/generators/__snapshots__/findInfiniteByTagsCursor.ts +56 -0
  48. package/src/generators/__snapshots__/getAsMutation.ts +31 -0
  49. package/src/generators/__snapshots__/postAsQuery.ts +48 -0
  50. package/src/generators/__snapshots__/updatePetById.ts +38 -0
  51. package/src/generators/__snapshots__/updatePetByIdPathParamsObject.ts +40 -0
  52. package/src/generators/index.ts +4 -0
  53. package/src/generators/infiniteQueryGenerator.tsx +125 -0
  54. package/src/generators/mutationGenerator.tsx +96 -0
  55. package/src/generators/queryGenerator.tsx +122 -0
  56. package/src/generators/suspenseQueryGenerator.tsx +121 -0
  57. package/src/plugin.ts +51 -73
  58. package/src/types.ts +43 -91
  59. package/dist/chunk-5IL6M74X.js +0 -1504
  60. package/dist/chunk-5IL6M74X.js.map +0 -1
  61. package/dist/chunk-JFX7DCS7.cjs +0 -1504
  62. package/dist/chunk-JFX7DCS7.cjs.map +0 -1
  63. package/dist/index-C9fwRDH7.d.cts +0 -579
  64. package/dist/index-C9fwRDH7.d.ts +0 -579
  65. package/src/OperationGenerator.tsx +0 -86
  66. package/src/__snapshots__/mutateAsQuery/updatePetWithForm.ts +0 -64
  67. package/src/__snapshots__/pathParamsTypeInline/getPetById.ts +0 -57
  68. package/src/__snapshots__/pathParamsTypeObject/getPetById.ts +0 -63
  69. package/src/__snapshots__/queryOptions/getPetById.ts +0 -37
  70. package/src/__snapshots__/queryWithoutQueryOptions/getPetById.ts +0 -47
  71. package/src/__snapshots__/upload/UploadFile.ts +0 -67
  72. package/src/__snapshots__/uploadMutation/UploadFile.ts +0 -44
  73. package/src/__snapshots__/variablesTypeMutate/deletePet.ts +0 -21
  74. package/src/components/Operations.tsx +0 -74
  75. package/src/components/QueryImports.tsx +0 -167
  76. package/src/components/SchemaType.tsx +0 -55
  77. package/src/components/__snapshots__/gen/showPetById.ts +0 -57
  78. package/src/components/__snapshots__/gen/useCreatePets.ts +0 -46
  79. package/src/components/__snapshots__/gen/useCreatePetsMutate.ts +0 -47
  80. package/src/utils.ts +0 -96
package/src/types.ts CHANGED
@@ -1,30 +1,15 @@
1
- import type { Plugin, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'
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
4
  import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'
6
- import type { Mutation } from './components/Mutation.tsx'
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'
12
5
 
13
- type Templates = {
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
6
+ type Suspense = object
22
7
 
23
- export type Query = {
8
+ type Query = {
24
9
  /**
25
10
  * Customize the queryKey, here you can specify a suffix.
26
11
  */
27
- queryKey: (key: unknown[]) => unknown[]
12
+ key: (key: unknown[]) => unknown[]
28
13
  /**
29
14
  * Define which HttpMethods can be used for queries
30
15
  * @default ['get']
@@ -40,14 +25,7 @@ export type Query = {
40
25
  importPath?: string
41
26
  }
42
27
 
43
- export type QueryOptions = object
44
-
45
- export type Mutate = {
46
- /**
47
- * Define the way of passing through the queryParams, headerParams and data.
48
- * @default `'hook'`
49
- */
50
- variablesType: 'mutate' | 'hook'
28
+ type Mutation = {
51
29
  /**
52
30
  * Define which HttpMethods can be used for mutations
53
31
  * @default ['post', 'put', 'delete']
@@ -82,26 +60,10 @@ export type Infinite = {
82
60
  }
83
61
 
84
62
  export type Options = {
85
- output?: {
86
- /**
87
- * Output to save the @tanstack/query hooks.
88
- * @default `"hooks"`
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
- }
63
+ /**
64
+ * @default 'hooks'
65
+ */
66
+ output?: Output
105
67
  /**
106
68
  * Group the @tanstack/query hooks based on the provided name.
107
69
  */
@@ -134,6 +96,16 @@ export type Options = {
134
96
  * @default '@kubb/plugin-client/client'
135
97
  */
136
98
  importPath?: string
99
+ /**
100
+ * ReturnType that needs to be used when calling client().
101
+ *
102
+ * `Data` will return ResponseConfig[data].
103
+ *
104
+ * `Full` will return ResponseConfig.
105
+ * @default `'data'`
106
+ * @private
107
+ */
108
+ dataReturnType?: 'data' | 'full'
137
109
  }
138
110
  /**
139
111
  * ReturnType that needs to be used when calling client().
@@ -144,31 +116,7 @@ export type Options = {
144
116
  * @default `'data'`
145
117
  * @private
146
118
  */
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'
119
+
172
120
  /**
173
121
  * Array containing exclude parameters to exclude/skip tags/operations/methods/paths.
174
122
  */
@@ -181,6 +129,16 @@ export type Options = {
181
129
  * Array containing override parameters to override `options` based on tags/operations/methods/paths.
182
130
  */
183
131
  override?: Array<Override<ResolvedOptions>>
132
+ /**
133
+ * How to pass your pathParams.
134
+ *
135
+ * `object` will return the pathParams as an object.
136
+ *
137
+ * `inline` will return the pathParams as comma separated params.
138
+ * @default `'inline'`
139
+ * @private
140
+ */
141
+ pathParamsType?: 'object' | 'inline'
184
142
  /**
185
143
  * When set, an infiniteQuery hooks will be added.
186
144
  */
@@ -193,42 +151,36 @@ export type Options = {
193
151
  * Override some useQuery behaviours.
194
152
  */
195
153
  query?: Partial<Query> | false
196
- queryOptions?: Partial<QueryOptions> | false
197
154
  /**
198
155
  * Override some useMutation behaviours.
199
156
  */
200
- mutate?: Mutate | false
157
+ mutation?: Mutation | false
158
+ /**
159
+ * Which parser can be used before returning the data to `@tanstack/query`.
160
+ * `'zod'` will use `@kubb/plugin-zod` to parse the data.
161
+ */
162
+ parser?: 'client' | 'zod'
201
163
  transformers?: {
202
164
  /**
203
165
  * Customize the names based on the type that is provided by the plugin.
204
166
  */
205
167
  name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string
206
168
  }
207
- /**
208
- * Make it possible to override one of the templates
209
- */
210
- templates?: Partial<Templates>
211
169
  }
212
170
 
213
171
  type ResolvedOptions = {
172
+ output: Output
173
+ baseURL: string | undefined
214
174
  client: Required<NonNullable<PluginReactQuery['options']['client']>>
215
- dataReturnType: NonNullable<PluginReactQuery['options']['dataReturnType']>
216
- pathParamsType: NonNullable<PluginReactQuery['options']['pathParamsType']>
217
- parser: PluginReactQuery['options']['parser']
175
+ parser: Required<NonNullable<Options['parser']>>
176
+ pathParamsType: NonNullable<Options['pathParamsType']>
218
177
  /**
219
178
  * Only used of infinite
220
179
  */
221
- infinite: Infinite | false
180
+ infinite: NonNullable<Infinite> | false
222
181
  suspense: Suspense | false
223
- query: Query | false
224
- queryOptions: QueryOptions | false
225
- mutate: Mutate | false
226
- templates: NonNullable<Templates>
227
- }
228
-
229
- export type FileMeta = {
230
- pluginKey?: Plugin['key']
231
- tag?: string
182
+ query: NonNullable<Required<Query>> | false
183
+ mutation: NonNullable<Required<Mutation>> | false
232
184
  }
233
185
 
234
186
  export type PluginReactQuery = PluginFactoryOptions<'plugin-react-query', Options, ResolvedOptions, never, ResolvePathOptions>